当前位置: 首页>>代码示例>>C++>>正文


C++ QwtPlot类代码示例

本文整理汇总了C++中QwtPlot的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlot类的具体用法?C++ QwtPlot怎么用?C++ QwtPlot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QwtPlot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parent

bool Editor::eventFilter( QObject* object, QEvent* event )
{
    QwtPlot *plot = qobject_cast<QwtPlot *>( parent() );
    if ( plot && object == plot->canvas() )
    {
        switch( event->type() )
        {
            case QEvent::MouseButtonPress:
            {
                const QMouseEvent* mouseEvent =
                    dynamic_cast<QMouseEvent* >( event );

                if ( d_overlay == NULL && 
                    mouseEvent->button() == Qt::LeftButton  )
                {
                    const bool accepted = pressed( mouseEvent->pos() );
                    if ( accepted )
                    {
                        d_overlay = new Overlay( plot->canvas(), this );

                        d_overlay->updateOverlay();
                        d_overlay->show();
                    }
                }

                break;
            }
            case QEvent::MouseMove:
            {
                if ( d_overlay )
                {
                    const QMouseEvent* mouseEvent =
                        dynamic_cast< QMouseEvent* >( event );

                    const bool accepted = moved( mouseEvent->pos() );
                    if ( accepted )
                        d_overlay->updateOverlay();
                }

                break;
            }
            case QEvent::MouseButtonRelease:
            {
                const QMouseEvent* mouseEvent =
                    static_cast<QMouseEvent* >( event );

                if ( d_overlay && mouseEvent->button() == Qt::LeftButton )
                {
                    released( mouseEvent->pos() );

                    delete d_overlay;
                    d_overlay = NULL;
                }

                break;
            }
            default:
                break;
        }

        return false;
    }

    return QObject::eventFilter( object, event );
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:65,代码来源:editor.cpp

示例2: contentsBoundingRect

	void PlotItem::paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget*)
	{
		const auto& rect = option->rect;
#else
	void PlotItem::paint (QPainter *painter)
	{
		const auto& rect = contentsBoundingRect ().toRect ();
#endif

		QwtPlot plot;
		plot.setFrameShape (QFrame::NoFrame);
		plot.enableAxis (QwtPlot::yLeft, LeftAxisEnabled_);
		plot.enableAxis (QwtPlot::xBottom, BottomAxisEnabled_);
		plot.setAxisTitle (QwtPlot::yLeft, LeftAxisTitle_);
		plot.setAxisTitle (QwtPlot::xBottom, BottomAxisTitle_);
		plot.resize (rect.size ());

		auto setPaletteColor = [&plot] (const QColor& color, QPalette::ColorRole role) -> void
		{
			if (!color.isValid ())
				return;

			auto pal = plot.palette ();
			pal.setColor (role, { color });
			plot.setPalette (pal);
		};

		setPaletteColor (BackgroundColor_, QPalette::Window);
		setPaletteColor (TextColor_, QPalette::WindowText);
		setPaletteColor (TextColor_, QPalette::Text);

		if (!PlotTitle_.isEmpty ())
			plot.setTitle (QwtText { PlotTitle_ });

		if (MinYValue_ < MaxYValue_)
		{
			plot.setAxisAutoScale (QwtPlot::yLeft, false);
			plot.setAxisScale (QwtPlot::yLeft, MinYValue_, MaxYValue_);
		}
		plot.setAutoFillBackground (false);
		plot.setCanvasBackground (Qt::transparent);

		if (YGridEnabled_)
		{
			auto grid = new QwtPlotGrid;
			grid->enableYMin (YMinorGridEnabled_);
			grid->enableX (false);
#if QWT_VERSION >= 0x060100
			grid->setMajorPen (QPen (GridLinesColor_, 1, Qt::SolidLine));
			grid->setMinorPen (QPen (GridLinesColor_, 1, Qt::DashLine));
#else
			grid->setMajPen (QPen (GridLinesColor_, 1, Qt::SolidLine));
			grid->setMinPen (QPen (GridLinesColor_, 1, Qt::DashLine));
#endif
			grid->attach (&plot);
		}

		auto items = Multipoints_;
		if (items.isEmpty ())
			items.push_back ({ Color_, Points_ });

		if (MinXValue_ < MaxXValue_)
			plot.setAxisScale (QwtPlot::xBottom, MinXValue_, MaxXValue_);
		else if (const auto ptsCount = items.first ().Points_.size ())
			plot.setAxisScale (QwtPlot::xBottom, 0, ptsCount - 1);

		std::vector<std::unique_ptr<QwtPlotCurve>> curves;
		for (const auto& item : items)
		{
			curves.emplace_back (new QwtPlotCurve);
			const auto curve = curves.back ().get ();

			curve->setPen (QPen (item.Color_));
			auto transpColor = item.Color_;
			transpColor.setAlphaF (Alpha_);
			curve->setBrush (transpColor);

			curve->setRenderHint (QwtPlotItem::RenderAntialiased);
			curve->attach (&plot);

			curve->setSamples (item.Points_.toVector ());
		}

		plot.replot ();

		QwtPlotRenderer {}.render (&plot, painter, rect);

		const auto xExtent = CalcXExtent (plot);
		const auto yExtent = CalcYExtent (plot);
		if (xExtent != XExtent_ || yExtent != YExtent_)
		{
			XExtent_ = xExtent;
			YExtent_ = yExtent;
			emit extentsChanged ();
		}
	}
开发者ID:tehnick,项目名称:leechcraft,代码行数:96,代码来源:plotitem.cpp

示例3: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    string videoName = "static";
//
//*** Pixel variation error

//  original video pixel variation (RMSE) reading
    tic();
    vector<double> RMSEO,framesO;
    double avrRMSEO;
    if(readPixelRMSE("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+".avi",RMSEO,framesO,avrRMSEO)>0) return -1;
    toc();

//  fusion stabilized video pixel variation (RMSE) reading
    tic();
    vector<double> RMSEF,framesF;
    double avrRMSEF;
    if(readPixelRMSE("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable_F.avi",RMSEF,framesF,avrRMSEF)>0) return -1;
    toc();

//  video processing stabilized video pixel variation (RMSE) reading
    tic();
    vector<double> RMSEV,framesV;
    double avrRMSEV;
    if(readPixelRMSE("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable_VP.avi",RMSEV,framesV,avrRMSEV)>0) return -1;
    toc();
//  second round fusion stabilized video pixel variation (RMSE) reading
    tic();
    vector<double> RMSEF2,framesF2;
    double avrRMSEF2;
    if(readPixelRMSE("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable2_F.avi",RMSEF2,framesF2,avrRMSEF2)>0) return -1;
    toc();

//  second round video processing stabilized video pixel variation (RMSE) reading
    tic();
    vector<double> RMSEV2,framesV2;
    double avrRMSEV2;
    if(readPixelRMSE("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable2_VP.avi",RMSEV2,framesV2,avrRMSEV2)>0) return -1;
    toc();

//  plot first round
    QwtPlot plotRMSE;
    plotRMSE.setTitle("Root Mean Squared pixel variation per frame");
    plotRMSE.setCanvasBackground(Qt::white);
    plotRMSE.insertLegend(new QwtLegend());
    plotRMSE.setAxisTitle(QwtPlot::yLeft,"RMSE (px)");
    plotRMSE.setAxisTitle(QwtPlot::xBottom,"Frame");
    QwtPlotMarker *mAO=new QwtPlotMarker();
    mAO->setLinePen(QPen(Qt::darkBlue));
    mAO->setLineStyle(QwtPlotMarker::HLine);
    mAO->setValue(0,avrRMSEO);
    mAO->attach(&plotRMSE);
    QwtPlotMarker *mAF=new QwtPlotMarker();
    mAF->setLinePen(QPen(Qt::darkRed));
    mAF->setLineStyle(QwtPlotMarker::HLine);
    mAF->setValue(0,avrRMSEF);
    mAF->attach(&plotRMSE);
    QwtPlotMarker *mAV=new QwtPlotMarker();
    mAV->setLinePen(QPen(Qt::darkGreen));
    mAV->setLineStyle(QwtPlotMarker::HLine);
    mAV->setValue(0,avrRMSEV);
    mAV->attach(&plotRMSE);
    QwtPlotCurve *curveRMSEO = new QwtPlotCurve();
    curveRMSEO->setTitle("Original");
    curveRMSEO->setPen(Qt::blue,2);
    curveRMSEO->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveRMSEO->setRawSamples(framesO.data(),RMSEO.data(),framesO.size());
    curveRMSEO->attach(&plotRMSE);
    QwtPlotCurve *curveRMSEF = new QwtPlotCurve();
    curveRMSEF->setTitle("Fusion stabilized");
    curveRMSEF->setPen(Qt::red,2);
    curveRMSEF->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveRMSEF->setRawSamples(framesF.data(),RMSEF.data(),framesF.size());
    curveRMSEF->attach(&plotRMSE);
    QwtPlotCurve *curveRMSEV = new QwtPlotCurve();
    curveRMSEV->setTitle("Video Processing stabilized");
    curveRMSEV->setPen(Qt::green,2);
    curveRMSEV->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveRMSEV->setRawSamples(framesV.data(),RMSEV.data(),framesV.size());
    curveRMSEV->attach(&plotRMSE);
    plotRMSE.resize(600,400);
    plotRMSE.show();

//  plot second round
    QwtPlot plotRMSE2;
    plotRMSE2.setTitle("Root Mean Squared pixel variation per frame (second round)");
    plotRMSE2.setCanvasBackground(Qt::white);
    plotRMSE2.insertLegend(new QwtLegend());
    plotRMSE2.setAxisTitle(QwtPlot::yLeft,"RMSE (px)");
    plotRMSE2.setAxisTitle(QwtPlot::xBottom,"Frame");
    QwtPlotMarker *mAO2=new QwtPlotMarker();
    mAO2->setLinePen(QPen(Qt::darkBlue));
    mAO2->setLineStyle(QwtPlotMarker::HLine);
    mAO2->setValue(0,avrRMSEO);
    mAO2->attach(&plotRMSE2);
    QwtPlotMarker *mAOF=new QwtPlotMarker();
    mAOF->setLinePen(QPen(Qt::darkCyan));
    mAOF->setLineStyle(QwtPlotMarker::HLine);
//.........这里部分代码省略.........
开发者ID:superchao1982,项目名称:MasterProject,代码行数:101,代码来源:main.cpp

示例4: main

int main( int argc, char **argv )
{
    QApplication a( argc, argv );

    QwtPlot plot;
    plot.setTitle( "Plot Demo" );
    plot.setCanvasBackground( Qt::white );

    plot.setAxisScale( QwtPlot::xBottom, -1.0, 6.0 );

    QwtLegend *legend = new QwtLegend();
    legend->setDefaultItemMode( QwtLegendData::Checkable );
    plot.insertLegend( legend );

    for ( int i = 0; i < 4; i++ )
    {
        QwtPlotCurve *curve = new QwtPlotCurve();
        curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
        curve->setPen( Qt::blue );

        QBrush brush;
        QwtSymbol::Style style = QwtSymbol::NoSymbol;
        QString title;
        if ( i == 0 )
        {
            brush = Qt::magenta;
            style = QwtSymbol::Path;
            title = "Path";
        }
        else if ( i == 2 )
        {
            brush = Qt::red;
            style = QwtSymbol::Graphic;
            title = "Graphic";
        }
        else if ( i == 1 )
        {
            brush = Qt::yellow;
            style = QwtSymbol::SvgDocument;
            title = "Svg";
        }
        else if ( i == 3 )
        {
            brush = Qt::cyan;
            style = QwtSymbol::Pixmap;
            title = "Pixmap";
        }

        MySymbol *symbol = new MySymbol( style, brush );

        curve->setSymbol( symbol );
        curve->setTitle( title );
        curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true );
        curve->setLegendIconSize( QSize( 15, 18 ) );

        QPolygonF points;
        points << QPointF( 0.0, 4.4 ) << QPointF( 1.0, 3.0 )
            << QPointF( 2.0, 4.5 ) << QPointF( 3.0, 6.8 )
            << QPointF( 4.0, 7.9 ) << QPointF( 5.0, 7.1 );

        points.translate( 0.0, i * 2.0 );

        curve->setSamples( points );
        curve->attach( &plot );
    }

    plot.resize( 600, 400 );
    plot.show();

    return a.exec();
}
开发者ID:iclosure,项目名称:jdataanalyse,代码行数:71,代码来源:symbols.cpp

示例5: doubleClicked

bool TitlePicker::eventFilter(QObject *object, QEvent *e)
{
	if (object != (QObject *)title)
		return FALSE;
	
    if ( object->inherits("QLabel") && e->type() == QEvent::MouseButtonDblClick)
		{
		emit doubleClicked();
        return TRUE;
		}

	if ( object->inherits("QLabel") &&  e->type() == QEvent::MouseButtonPress )
		{
		emit clicked();

		const QMouseEvent *me = (const QMouseEvent *)e;	
		if (me->button()==QEvent::RightButton)
			emit showTitleMenu();

		QwtPlot *plot = (QwtPlot *)title->parent();
		if (plot->margin() < 2 && plot->lineWidth() < 2)
			{
			QRect r = title->rect();
			r.addCoords(2, 2, -2, -2);
			if (!r.contains(me->pos()))
				emit highlightGraph();
			}

		return TRUE;
		}

	if ( object->inherits("QLabel") &&  e->type() == QEvent::MouseMove)
		{	
		const QMouseEvent *me = (const QMouseEvent *)e;			
		movedGraph=TRUE;
		emit moveGraph(me->pos());

        return TRUE;
		}
	
	if ( object->inherits("QLabel") && e->type() == QEvent::MouseButtonRelease)
		{
		const QMouseEvent *me = (const QMouseEvent *)e;
		if (me->button()== QEvent::LeftButton)
			{
			emit clicked();
			if (movedGraph)
				{
				emit releasedGraph();
				movedGraph=FALSE;
				}
        	return TRUE;
			}
		}

	if ( object->inherits("QLabel") && 
        e->type() == QEvent::KeyPress)
		{
		switch (((const QKeyEvent *)e)->key()) 
			{
			case Qt::Key_Delete: 
			emit removeTitle();	
            return TRUE;
			}
		}

    return QObject::eventFilter(object, e);
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:68,代码来源:scalePicker.cpp

示例6: QObject

dtkPlotViewZoomer::dtkPlotViewZoomer(dtkPlotView *parent) : QObject(parent)
{
    QwtPlot *plot = reinterpret_cast<QwtPlot *>(parent->plotWidget());
    d = new dtkPlotViewZoomerPrivate(reinterpret_cast<QwtPlotCanvas *>(plot->canvas()));
}
开发者ID:papadop,项目名称:dtk,代码行数:5,代码来源:dtkPlotViewZoomer.cpp

示例7: refresh

/**
 * Odświeża bieżący wykres.
 */
void ChartsWidget::refresh()
{
    QwtPlot* plot = static_cast<QwtPlot*>(ui->tabCharts->currentWidget());
    plot->replot();
    emit sendMessage(tr("Chart refreshed"));
}
开发者ID:akhmadzaki,项目名称:SimpleBird,代码行数:9,代码来源:ChartsWidget.cpp

示例8: gsl_vector_calloc

QSize MultiLayer::arrangeLayers(bool userSize) {
  const QRect rect = canvas->geometry();

  gsl_vector *xTopR = gsl_vector_calloc(
      graphs);  // ratio between top axis + title and canvas height
  gsl_vector *xBottomR =
      gsl_vector_calloc(graphs);  // ratio between bottom axis and canvas height
  gsl_vector *yLeftR = gsl_vector_calloc(graphs);
  gsl_vector *yRightR = gsl_vector_calloc(graphs);
  gsl_vector *maxXTopHeight =
      gsl_vector_calloc(rows);  // maximum top axis + title height in a row
  gsl_vector *maxXBottomHeight =
      gsl_vector_calloc(rows);  // maximum bottom axis height in a row
  gsl_vector *maxYLeftWidth =
      gsl_vector_calloc(cols);  // maximum left axis width in a column
  gsl_vector *maxYRightWidth =
      gsl_vector_calloc(cols);  // maximum right axis width in a column
  gsl_vector *Y = gsl_vector_calloc(rows);
  gsl_vector *X = gsl_vector_calloc(cols);

  int i;
  for (i = 0; i < graphs;
       i++) {  // calculate scales/canvas dimensions reports for each layer and
               // stores them in the above vectors
    Graph *gr = (Graph *)graphsList.at(i);
    QwtPlot *plot = gr->plotWidget();
    QwtPlotLayout *plotLayout = plot->plotLayout();
    QRect cRect = plotLayout->canvasRect();
    double ch = (double)cRect.height();
    double cw = (double)cRect.width();

    QRect tRect = plotLayout->titleRect();
    QwtScaleWidget *scale = (QwtScaleWidget *)plot->axisWidget(QwtPlot::xTop);

    int topHeight = 0;
    if (!tRect.isNull()) topHeight += tRect.height() + plotLayout->spacing();
    if (scale) {
      QRect sRect = plotLayout->scaleRect(QwtPlot::xTop);
      topHeight += sRect.height();
    }
    gsl_vector_set(xTopR, i, double(topHeight) / ch);

    scale = (QwtScaleWidget *)plot->axisWidget(QwtPlot::xBottom);
    if (scale) {
      QRect sRect = plotLayout->scaleRect(QwtPlot::xBottom);
      gsl_vector_set(xBottomR, i, double(sRect.height()) / ch);
    }

    scale = (QwtScaleWidget *)plot->axisWidget(QwtPlot::yLeft);
    if (scale) {
      QRect sRect = plotLayout->scaleRect(QwtPlot::yLeft);
      gsl_vector_set(yLeftR, i, double(sRect.width()) / cw);
    }

    scale = (QwtScaleWidget *)plot->axisWidget(QwtPlot::yRight);
    if (scale) {
      QRect sRect = plotLayout->scaleRect(QwtPlot::yRight);
      gsl_vector_set(yRightR, i, double(sRect.width()) / cw);
    }

    // calculate max scales/canvas dimensions ratio for each line and column and
    // stores them to vectors
    int row = i / cols;
    if (row >= rows) row = rows - 1;

    int col = i % cols;

    double aux = gsl_vector_get(xTopR, i);
    double old_max = gsl_vector_get(maxXTopHeight, row);
    if (aux >= old_max) gsl_vector_set(maxXTopHeight, row, aux);

    aux = gsl_vector_get(xBottomR, i);
    if (aux >= gsl_vector_get(maxXBottomHeight, row))
      gsl_vector_set(maxXBottomHeight, row, aux);

    aux = gsl_vector_get(yLeftR, i);
    if (aux >= gsl_vector_get(maxYLeftWidth, col))
      gsl_vector_set(maxYLeftWidth, col, aux);

    aux = gsl_vector_get(yRightR, i);
    if (aux >= gsl_vector_get(maxYRightWidth, col))
      gsl_vector_set(maxYRightWidth, col, aux);
  }

  double c_heights = 0.0;
  for (i = 0; i < rows; i++) {
    gsl_vector_set(Y, i, c_heights);
    c_heights += 1 + gsl_vector_get(maxXTopHeight, i) +
                 gsl_vector_get(maxXBottomHeight, i);
  }

  double c_widths = 0.0;
  for (i = 0; i < cols; i++) {
    gsl_vector_set(X, i, c_widths);
    c_widths += 1 + gsl_vector_get(maxYLeftWidth, i) +
                gsl_vector_get(maxYRightWidth, i);
  }

  if (!userSize) {
    l_canvas_width = int(
//.........这里部分代码省略.........
开发者ID:narunlifescience,项目名称:AlphaPlot,代码行数:101,代码来源:MultiLayer.cpp

示例9: while

void PlotExporter::exportPlot(QwtPlot *plot, const QRectF &zoom)
{
  QSizeF guessedDimensions;
  ExportPlotToImageDialog::Parameters p = m_exportDlg->parameters();

  m_exportDlg->setAspectRatio(plot->size().width() / plot->size().height());

  while (m_exportDlg->exec() == QDialog::Accepted) {
    p = m_exportDlg->parameters();

    QString path;

    if (p.path.length() < 0) {
      QMessageBox::warning(nullptr, QObject::tr("Invalid input"), QObject::tr("Invalid path"));
      continue;
    }
    if (!m_supportedFormats.contains(p.format)) {
      QMessageBox::warning(nullptr, QObject::tr("Invalid input"), QObject::tr("Invalid output format"));
      continue;
    }

    if (p.path.endsWith("." + p.format))
      path = p.path;
    else
      path = p.path + "." + p.format;

    /* Create a temporary QwtPlot to use to write the chart to file */
    QwtPlot exPlot;
    QwtPlotZoomer exPlorZoomer(exPlot.canvas());
    exPlorZoomer.zoom(zoom);

    exPlot.setCanvasBackground(QBrush(Qt::white));
    exPlot.setTitle(p.title);
    exPlot.setAxisTitle(QwtPlot::xBottom, plot->axisTitle(QwtPlot::xBottom));
    exPlot.setAxisTitle(QwtPlot::xTop, plot->axisTitle(QwtPlot::xTop));
    exPlot.setAxisTitle(QwtPlot::yLeft, plot->axisTitle(QwtPlot::yLeft));
    exPlot.setAxisTitle(QwtPlot::yRight, plot->axisTitle(QwtPlot::yRight));
    QwtPlotItemList curves = plot->itemList();

    /* Attach all plots from the GUI plot to the temporary plot
     * Note that this will detach the plots from the GUI plot! */
    QList<qreal> curvePenWidths;
    for (QwtPlotItem *i : curves) {
      QwtPlotCurve *c = dynamic_cast<QwtPlotCurve *>(i);

      if (c != nullptr) {
        QPen p = c->pen();
        qreal w = p.widthF();
        qreal nw;

        curvePenWidths.push_back(w);

        nw = w - 1.0;
        if (nw < 0.0)
          nw = 0.0;

        p.setWidthF(nw);
        c->setPen(p);
      }

      i->attach(&exPlot);
    }

    /* Scale up from millimeters to centimeters*/
    QSizeF dimensionsMM(p.dimensions.width() * 10.0, p.dimensions.height() * 10.0);

    /* Store current properties of the plot as we need to change them for rendering */
    QFont xBottomFont = plot->axisWidget(QwtPlot::xBottom)->font();
    QFont xTopFont = plot->axisWidget(QwtPlot::xTop)->font();
    QFont yLeftFont = plot->axisWidget(QwtPlot::yLeft)->font();
    QFont yRightFont = plot->axisWidget(QwtPlot::yRight)->font();
    QFont xBottomTitleFont = plot->axisTitle(QwtPlot::xBottom).font();
    QFont xTopTitleFont = plot->axisTitle(QwtPlot::xTop).font();
    QFont yLeftTitleFont = plot->axisTitle(QwtPlot::yLeft).font();
    QFont yRightTitleFont = plot->axisTitle(QwtPlot::yRight).font();
    QFont titleFont = plot->title().font();
    const qreal xBottomPenWidth = plot->axisWidget(QwtPlot::xBottom)->scaleDraw()->penWidth() > 0 ? plot->axisWidget(QwtPlot::xBottom)->scaleDraw()->penWidth() : 1.0;
    const qreal xTopPenWidth = plot->axisWidget(QwtPlot::xTop)->scaleDraw()->penWidth() > 0 ? plot->axisWidget(QwtPlot::xTop)->scaleDraw()->penWidth() : 1.0;
    const qreal yLeftPenWidth = plot->axisWidget(QwtPlot::yLeft)->scaleDraw()->penWidth() > 0 ? plot->axisWidget(QwtPlot::yLeft)->scaleDraw()->penWidth() : 1.0;
    const qreal yRightPenWidth = plot->axisWidget(QwtPlot::yRight)->scaleDraw()->penWidth() > 0 ? plot->axisWidget(QwtPlot::yRight)->scaleDraw()->penWidth() : 1.0;

    /* Recalculate sizes by the DPI for every element that needs it */
    const qreal outputInPixels = (static_cast<qreal>(p.dimensions.width()) / 2.54) * p.dpi;
    const qreal scalingRatio = (static_cast<qreal>(qApp->desktop()->logicalDpiX()) / p.dpi) * (outputInPixels / plot->geometry().width());

    const qreal _xBottomPenWidth = floor((xBottomPenWidth * scalingRatio) + 0.45);
    const qreal _xTopPenWidth = floor((xTopPenWidth * scalingRatio) + 0.45);
    const qreal _yLeftPenWidth = floor((yLeftPenWidth * scalingRatio) + 0.45);
    const qreal _yRightPenWidth = floor((yRightPenWidth * scalingRatio) + 0.45);
    xBottomFont.setPointSizeF(p.axisNumbersFontSize * scalingRatio);
    xTopFont.setPointSizeF(p.axisNumbersFontSize * scalingRatio);
    yLeftFont.setPointSizeF(p.axisNumbersFontSize * scalingRatio);
    yRightFont.setPointSizeF(p.axisNumbersFontSize * scalingRatio);
    xBottomTitleFont.setPointSizeF(p.axisTitlesFontSize * scalingRatio);
    xTopTitleFont.setPointSizeF(p.axisTitlesFontSize * scalingRatio);
    yLeftTitleFont.setPointSizeF(p.axisTitlesFontSize * scalingRatio);
    yRightTitleFont.setPointSizeF(p.axisTitlesFontSize * scalingRatio);
    titleFont.setPointSizeF(p.chartTitleFontSize * scalingRatio);
    exPlot.axisWidget(QwtPlot::xBottom)->scaleDraw()->setPenWidth(_xBottomPenWidth);
    exPlot.axisWidget(QwtPlot::xTop)->scaleDraw()->setPenWidth(_xTopPenWidth);
//.........这里部分代码省略.........
开发者ID:echmet,项目名称:CEval,代码行数:101,代码来源:plotexporter.cpp

示例10: drawDistPlots

//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
void MainWindow:: drawDistPlots(bool dummy)
{
    double *x, *prob;
    x = new double[nDistPts];
    prob = new double[nDistPts];
    QString median_qstr, shape_qstr;
    double median, shape;
    double expMean[3];
    double expTbase;
    bool use_lognormal = cbox_USE_LOGNORMAL_DIST->isChecked();

    groupBox_divisiondistributions->setEnabled(use_lognormal);
    for (int j=0; j<ndistplots; j++) {
        QwtPlot *qp = distplot_list[j];
        if (j == 0) {
            qp->setTitle("Type 1 division time (hrs)");
            if (use_lognormal) {
                median_qstr = line_DIVIDE_TIME_1_MEDIAN->text();
                shape_qstr = line_DIVIDE_TIME_1_SHAPE->text();
            } else {
                expTbase = line_T_G1_1->text().toDouble() + line_T_S_1->text().toDouble() + line_T_G2_1->text().toDouble();
                expMean[0] = line_G1_MEAN_DELAY_1->text().toDouble();
                expMean[1] = line_S_MEAN_DELAY_1->text().toDouble();
                expMean[2] = line_G2_MEAN_DELAY_1->text().toDouble();
            }
        } else if (j == 1) {
            qp->setTitle("Type 2 division time (hrs)");
            if (use_lognormal) {
                median_qstr = line_DIVIDE_TIME_2_MEDIAN->text();
                shape_qstr = line_DIVIDE_TIME_2_SHAPE->text();
            } else {
                expTbase = line_T_G1_2->text().toDouble() + line_T_S_2->text().toDouble() + line_T_G2_2->text().toDouble();
                expMean[0] = line_G1_MEAN_DELAY_2->text().toDouble();
                expMean[1] = line_S_MEAN_DELAY_2->text().toDouble();
                expMean[2] = line_G2_MEAN_DELAY_2->text().toDouble();
            }
        }
        if (use_lognormal) {
            median = median_qstr.toDouble();
            shape = shape_qstr.toDouble();
            create_lognorm_dist(median, shape, nDistPts, x, prob);
        } else {
            create_expon_dist(expTbase, expMean, nDistPts, x, prob);
        }

        int n = dist_limit(prob,nDistPts);
        double xmax = x[n];
        qp->setAxisScale(QwtPlot::xBottom, 0.0, xmax, 0.0);

        if (first_plot) {
            curve_list[j] = new QwtPlotCurve("title");
            curve_list[j]->setSamples(x, prob, n);
            curve_list[j]->attach(qp);
        } else {
            curve_list[j]->setSamples(x, prob, n);
        }
        qp->replot();
    }
    delete [] x;
    x = NULL;
    delete [] prob;
    prob = NULL;
    first_plot = false;
}
开发者ID:gibbogle,项目名称:vspheroid-abm,代码行数:66,代码来源:lognormal.cpp

示例11: qAbs

void PlotMagnifier::rescale( double factor, AxisMode axis )
{
    factor = qAbs( 1.0/factor );

    QwtPlot* plt = plot();
    if ( plt == nullptr || factor == 1.0 ){
        return;
    }

    bool doReplot = false;

    const bool autoReplot = plt->autoReplot();
    plt->setAutoReplot( false );

    const int axis_list[2] = {QwtPlot::xBottom, QwtPlot::yLeft};
    QRectF new_rect;

    for ( int i = 0; i <2; i++ )
    {
        double temp_factor = factor;
        if( i==1 && axis == X_AXIS)
        {
            temp_factor = 1.0;
        }
        if( i==0 && axis == Y_AXIS)
        {
            temp_factor = 1.0;
        }

        int axisId = axis_list[i];

        if ( isAxisEnabled( axisId ) )
        {
            const QwtScaleMap scaleMap = plt->canvasMap( axisId );

            double v1 = scaleMap.s1();
            double v2 = scaleMap.s2();
            double center = _mouse_position.x();

            if( axisId == QwtPlot::yLeft){
                center = _mouse_position.y();
            }

            if ( scaleMap.transformation() )
            {
                // the coordinate system of the paint device is always linear
                v1 = scaleMap.transform( v1 ); // scaleMap.p1()
                v2 = scaleMap.transform( v2 ); // scaleMap.p2()
            }

            const double width = ( v2 - v1 );
            const double ratio = (v2-center)/ (width);

            v1 = center - width*temp_factor*(1-ratio);
            v2 = center + width*temp_factor*(ratio);

            if( v1 > v2 ) std::swap( v1, v2 );

            if ( scaleMap.transformation() )
            {
                v1 = scaleMap.invTransform( v1 );
                v2 = scaleMap.invTransform( v2 );
            }

            if( v1 < _lower_bounds[axisId]) v1 = _lower_bounds[axisId];
            if( v2 > _upper_bounds[axisId]) v2 = _upper_bounds[axisId];

            plt->setAxisScale( axisId, v1, v2 );

            if( axisId == QwtPlot::xBottom)
            {
                new_rect.setLeft(  v1 );
                new_rect.setRight( v2 );
            }
            else{
                new_rect.setBottom( v1 );
                new_rect.setTop( v2 );
            }

            doReplot = true;
        }
    }

    plt->setAutoReplot( autoReplot );

    if ( doReplot ){
        emit rescaled( new_rect );
    }
}
开发者ID:facontidavide,项目名称:PlotJuggler,代码行数:89,代码来源:plotmagnifier.cpp

示例12: plotAt

void PlotMatrix::alignScaleBorder( int rowOrColumn, int axis )
{
    int startDist = 0;
    int endDist = 0;

    if ( axis == QwtPlot::yLeft )
    {
        QwtPlot *p = plotAt( rowOrColumn, 0 );
        if ( p )
            p->axisWidget( axis )->getBorderDistHint( startDist, endDist );

        for ( int col = 1; col < numColumns(); col++ )
        {
            QwtPlot *p = plotAt( rowOrColumn, col );
            if ( p )
                p->axisWidget( axis )->setMinBorderDist( startDist, endDist );
        }
    }
    else if ( axis == QwtPlot::yRight )
    {
        QwtPlot *p = plotAt( rowOrColumn, numColumns() - 1 );
        if ( p )
            p->axisWidget( axis )->getBorderDistHint( startDist, endDist );

        for ( int col = 0; col < numColumns() - 1; col++ )
        {
            QwtPlot *p = plotAt( rowOrColumn, col );
            if ( p )
                p->axisWidget( axis )->setMinBorderDist( startDist, endDist );
        }       
    }
    if ( axis == QwtPlot::xTop )
    {
        QwtPlot *p = plotAt( rowOrColumn, 0 );
        if ( p )
            p->axisWidget( axis )->getBorderDistHint( startDist, endDist );
    
        for ( int row = 1; row < numRows(); row++ )
        {
            QwtPlot *p = plotAt( row, rowOrColumn );
            if ( p )
                p->axisWidget( axis )->setMinBorderDist( startDist, endDist );
        }   
    }   
    else if ( axis == QwtPlot::xBottom )
    {       
        QwtPlot *p = plotAt( numRows() - 1, rowOrColumn );
        if ( p )
            p->axisWidget( axis )->getBorderDistHint( startDist, endDist );
    
        for ( int row = 0; row < numRows() - 1; row++ )
        {
            QwtPlot *p = plotAt( row, rowOrColumn );
            if ( p )
                p->axisWidget( axis )->setMinBorderDist( startDist, endDist );
        }
    }
}
开发者ID:Au-Zone,项目名称:qwt,代码行数:58,代码来源:plotmatrix.cpp

示例13: main

int main(int argc, char *argv[])
{

    //  QGuiApplication a(argc, argv);
    QApplication a(argc, argv);
    QwtPlot *plot = new QwtPlot();
    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setBorderRadius(10);

    plot->setCanvas(canvas);
    plot->setCanvasBackground(QColor("LIGHTGRAY"));

    plot->enableAxis(QwtPlot::yRight);
    plot->enableAxis(QwtPlot::xTop);
    plot->setAxisTitle(QwtPlot::xBottom, "Xline");
    plot->setAxisTitle(QwtPlot::xTop, "Xline");
    plot->setAxisTitle(QwtPlot::yLeft, "Inline");
    plot->setAxisTitle(QwtPlot::yRight, "Inline");
    //    float minx = srv->getStations().first().x();
    //    float maxx = srv->getStations().last().x();
        plot->setAxisScale( QwtPlot::xBottom,3500,300);
    //    plot->setAxisScale( QwtPlot::xTop,minx,maxx );
    //    QwtScaleDraw *sd = axisScaleDraw( QwtPlot::yLeft );
    //    sd->setMinimumExtent( sd->extent( axisWidget( QwtPlot::yLeft )->font() ) );
    plot->plotLayout()->setAlignCanvasToScales( true );
    QFileDialog custDialog;
    QStringList names = custDialog.getOpenFileNames(NULL, ("Open Files..."),QString(), ("UKOOA Files (*.p190 *.p90);;All Files (*)"));

    // handle if the dialog was "Cancelled"
    if(names.isEmpty())
    {
        return 0;
    }
    qSort(names.begin(), names.end());
    QVector <QwtPlotCurve *> curves;
    foreach (QString name, names)
    {


        QwtPlotCurve *vCurve = new QwtPlotCurve;
       if(name.contains(QString( "NS1763")) || name.contains(QString("NS2029")))
        {
           QColor c = Qt::red;
            vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::red,c , QSize( 2, 2 ) ) );
        }
        else
        {
           QColor c = Qt::green;
            vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::green,c , QSize( 2, 2 ) ) );
        }
        vCurve->setStyle( QwtPlotCurve::NoCurve );
        vCurve->setPen( Qt::gray );

        cout << name.toStdString() << endl;
        QVector<QPointF> curveData;

        //  m_nameLineLable->setText(m_names.at(0));
        QFile *ukFile = new QFile(QString(name));

        bool rt = ukFile->open(QIODevice::ReadOnly);

        cout << "return " << rt << endl;

        qint64 icount = 0;

        qint64 fileSize = ukFile->size();
        char *data = new char[fileSize];
        ukFile->read(data,fileSize);
        QString sData = data;
        QString shot = "SNS";
        while (true)
        {
            ukFile->seek(icount);
            ukFile->read(data,fileSize);
            sData = data;;
            if(icount>=fileSize)
            {
                break;
            }
            auto sPos = sData.indexOf(shot,0,Qt::CaseInsensitive);
            QString cr = sData.mid(sPos,19);
            if(cr.contains("\n"))
            {
                sPos +=2;
            }
            // auto shotNo  = sData.mid(sPos+20,sPos+5);
            QString shotNo = sData.mid(sPos+19,6);
            int shotNos;

            if(shotNo.contains("\n") || shotNo.contains("\r"))
            {
                shotNo = sData.mid(sPos+19,8);
                int shift1 = shotNo.indexOf("\r");
                int shift = shotNo.indexOf("\n");
                //    cout << shift1 << " " << shift << endl;
                QString tmp = shotNo.mid(0,shift1);
                tmp.append(shotNo.mid(shift+1,3));
                shotNos = tmp.toInt();
            }
            else
//.........这里部分代码省略.........
开发者ID:osamanagib,项目名称:UkooaFix,代码行数:101,代码来源:main.cpp

示例14: plot

/*!
   Update the axes scales

   \param intervals Scale intervals
*/
void QwtPlotRescaler::updateScales(
    QwtInterval intervals[QwtPlot::axisCnt] ) const
{
    if ( d_data->inReplot >= 5 )
    {
        return;
    }

    QwtPlot *plt = const_cast<QwtPlot *>( plot() );

    const bool doReplot = plt->autoReplot();
    plt->setAutoReplot( false );

    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
    {
        if ( axis == referenceAxis() || aspectRatio( axis ) > 0.0 )
        {
            double v1 = intervals[axis].minValue();
            double v2 = intervals[axis].maxValue();

            if ( plt->axisScaleDiv( axis )->lowerBound() >
                plt->axisScaleDiv( axis )->upperBound() )
            {
                qSwap( v1, v2 );
            }

            if ( d_data->inReplot >= 1 )
            {
                d_data->axisData[axis].scaleDiv = *plt->axisScaleDiv( axis );
            }

            if ( d_data->inReplot >= 2 )
            {
                QList<double> ticks[QwtScaleDiv::NTickTypes];
                for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
                    ticks[i] = d_data->axisData[axis].scaleDiv.ticks( i );

                plt->setAxisScaleDiv( axis, QwtScaleDiv( v1, v2, ticks ) );
            }
            else
            {
                plt->setAxisScale( axis, v1, v2 );
            }
        }
    }

    const bool immediatePaint = 
        plt->canvas()->testPaintAttribute( QwtPlotCanvas::ImmediatePaint );
    plt->canvas()->setPaintAttribute( QwtPlotCanvas::ImmediatePaint, false );

    plt->setAutoReplot( doReplot );

    d_data->inReplot++;
    plt->replot();
    d_data->inReplot--;

    plt->canvas()->setPaintAttribute( 
        QwtPlotCanvas::ImmediatePaint, immediatePaint );
}
开发者ID:Alex-Rongzhen-Huang,项目名称:OpenPilot,代码行数:64,代码来源:qwt_plot_rescaler.cpp

示例15: plot

void QwtPlotZoomer::rescale()
{
    QwtPlot *plt = plot();
    if ( !plt )
        return;

    const QwtDoubleRect &rect = d_data->zoomStack[d_data->zoomRectIndex];
    if ( rect != scaleRect() )
    {
        const bool doReplot = plt->autoReplot();
        plt->setAutoReplot(false);

        double x1 = rect.left();
        double x2 = rect.right();
        if ( plt->axisScaleDiv(xAxis())->lowerBound() > 
            plt->axisScaleDiv(xAxis())->upperBound() )
        {
            qSwap(x1, x2);
        }

        plt->setAxisScale(xAxis(), x1, x2);

        double y1 = rect.top();
        double y2 = rect.bottom();
        if ( plt->axisScaleDiv(yAxis())->lowerBound() > 
            plt->axisScaleDiv(yAxis())->upperBound() )
        {
            qSwap(y1, y2);
        }
        plt->setAxisScale(yAxis(), y1, y2);

        plt->setAutoReplot(doReplot);

        plt->replot();
    }
}
开发者ID:AlexKraemer,项目名称:RFID_ME_HW_GUI,代码行数:36,代码来源:qwt_plot_zoomer.cpp


注:本文中的QwtPlot类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。