Esempio n. 1
0
Plot::Plot()
{
    setTitle("A Simple QwtPlot Demonstration");
    insertLegend(new QwtLegend(), QwtPlot::RightLegend);

    // Set axis titles
    setAxisTitle(xBottom, "x -->");
    setAxisTitle(yLeft, "y -->");
    
    // Insert new curves
    QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
#if QT_VERSION >= 0x040000
    cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
    cSin->setPen(QPen(Qt::red));
    cSin->attach(this);

    QwtPlotCurve *cCos = new QwtPlotCurve("y = cos(x)");
#if QT_VERSION >= 0x040000
    cCos->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
    cCos->setPen(QPen(Qt::blue));
    cCos->attach(this);

    // Create sin and cos data
    const int nPoints = 100;
    cSin->setData(SimpleData(::sin, nPoints));
    cCos->setData(SimpleData(::cos, nPoints));

    // Insert markers
    
    //  ...a horizontal line at y = 0...
    QwtPlotMarker *mY = new QwtPlotMarker();
    mY->setLabel(QString::fromLatin1("y = 0"));
    mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
    mY->setLineStyle(QwtPlotMarker::HLine);
    mY->setYValue(0.0);
    mY->attach(this);

    //  ...a vertical line at x = 2 * pi
    QwtPlotMarker *mX = new QwtPlotMarker();
    mX->setLabel(QString::fromLatin1("x = 2 pi"));
    mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
    mX->setLabelOrientation(Qt::Vertical);
    mX->setLineStyle(QwtPlotMarker::VLine);
    mX->setLinePen(QPen(Qt::black, 0, Qt::DashDotLine));
    mX->setXValue(2.0 * M_PI);
    mX->attach(this);
}
Esempio n. 2
0
void HistoricPlot::addCurve(quint32 idVariable, std::vector<VariablePoint> data)
{
    m_zoomer->setZoomBase(true);

    QwtPlotCurve *c = new QwtPlotCurve(QString("id : %1").arg(idVariable));
    c->setPen( QColor(qrand() % 255,qrand() % 255,qrand() % 255), 2 ),
    c->setRenderHint( QwtPlotItem::RenderAntialiased, true );

    QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 5, 5 ) );
    c->setSymbol( symbol );

    QVector<VariablePoint> d2 = QVector<VariablePoint>::fromStdVector(data);
    QVector<QPointF> cleanData;

    for (int i = 0; i < data.size(); ++i) {
        VariablePoint vp = d2.at(i);
        qDebug() << QString("ID: %1, VALUE: %2").arg(vp.idVariable()).arg(vp.value().toDouble());

        if (vp.value().type() == QVariant::Double)
            cleanData.append(QPointF(QwtDate::toDouble(QDateTime::fromMSecsSinceEpoch(vp.timeStamp())),
                                 vp.value().toDouble()));
        else
            cleanData.append(QPointF(QwtDate::toDouble(QDateTime::fromMSecsSinceEpoch(vp.timeStamp())),
                                 (double)vp.value().toLongLong()));
    }

    c->setSamples(cleanData);
    c->attach(this);
}
Esempio n. 3
0
void CDataPlot::rebuild(void)
{
	for(int ci = 0; ci < m_portalCurveMap.count(); ++ci)
	{
		if(m_portalCurveMap.values().at(ci))
		{
			m_portalCurveMap.values().at(ci)->detach();
			delete m_portalCurveMap.values().at(ci);
		}
	}
	m_portalCurveMap.clear();

	if(m_algTreeModel)
	{
		QList<CPortal*> portals = m_algTreeModel->checkedPortalList();
		foreach(CPortal *portal, portals)
		{
			if(!portal) continue;
			QwtPlotCurve *curve = new QwtPlotCurve(portal->caption());
			curve->setData(new CCurveData(portal));
			curve->setPen(portal->dataColor(), 3);
			curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
			curve->attach(this);
			m_portalCurveMap[portal] = curve;
		}
	}

	refresh();
}
Esempio n. 4
0
void Plot::populate()
{
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setMinorPen( Qt::black, 0, Qt::DashLine );
    grid->enableXMin( true );
    grid->attach( this );

    QwtPlotCurve *curve = new QwtPlotCurve();
    curve->setTitle("Some Points");
    curve->setPen( Qt::blue, 4 ),
          curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );

    QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                       QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ) );
    curve->setSymbol( symbol );

    QPolygonF points;
    points << QPointF( 10.0, 4.4 )
           << QPointF( 100.0, 3.0 ) << QPointF( 200.0, 4.5 )
           << QPointF( 300.0, 6.8 ) << QPointF( 400.0, 7.9 )
           << QPointF( 500.0, 7.1 ) << QPointF( 600.0, 7.9 )
           << QPointF( 700.0, 7.1 ) << QPointF( 800.0, 5.4 )
           << QPointF( 900.0, 2.8 ) << QPointF( 1000.0, 3.6 );
    curve->setSamples( points );
    curve->attach( this );
}
Esempio n. 5
0
void PlotWidget::AddPlotData(QString title, float* plotData, int size, bool showMarkers)
{	
	if(_curves.contains(title))
		return;
	QwtPointSeriesData *points = CreatePointSeriesFromArray(plotData, size);
	QwtPlotCurve *curve = new QwtPlotCurve(title);	
	curve->setData(points);
	//Устанавливается цвет
	curve->setPen(QColor(255,0,0), 2.0);
	if(size < 1000)
		curve->setRenderHint(QwtPlotItem::RenderAntialiased);
	//Marker
	if(_showMarkers || showMarkers)
	{
		/*QwtSymbol *symbol1 = new QwtSymbol();
		symbol1->setStyle(QwtSymbol::Ellipse);
		symbol1->setPen(QColor(Qt::black));	
		symbol1->setSize(4);*/
		curve->setSymbol(GetDefaultMarker());
	}
	//Кривая добавляется на график
	curve->attach(_plot);
	//Добавляется в список кривых
	_curves.insert(title, curve);
	//Область рисования перерисовывается, если включен автоматический режим
	CheckNReplot();
}
QwtPlotCurve * PlotViewWidget::addCurveData(WaveformData *curveData, bool secondary, QColor col)
{
    maWaveformData << curveData;

    QwtPlotCurve *waveCurve = new QwtPlotCurve("dummy");
    waveCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    waveCurve->setPen(QPen(col));
    waveCurve->setSamples( curveData );
    maCurves << waveCurve;
    waveCurve->attach(this);

    if( !mSecondaryAxis || maCurves.length() == 0 ) // no secondary axis or just one plot
    {
        replot();
        setAxisScaleDiv(QwtPlot::yRight, axisScaleDiv(QwtPlot::yLeft));
        replot();
    }
    else
    {
        if(secondary)
        {
            setAxisAutoScale(QwtPlot::yRight);
            waveCurve->setYAxis(QwtPlot::yRight);
        }
        else
        {
            waveCurve->setYAxis(QwtPlot::yLeft);
        }
    }

    repaint();
    return waveCurve;
}
//---------------------------------------------------------------------------
void JrkPlotDialog::createCurve(QString title, QColor cl, bool on, double scale)
{
    QwtPlotCurve *curve;    
    QPen pen;

    curve = new QwtPlotCurve(title);

    pen.setColor(cl);
    pen.setWidth(2);

    curve->setPen(pen);

    curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, true);
    curve->setRenderHint( QwtPlotCurve::RenderAntialiased, true);

#if 0
    QwtSplineCurveFitter* curveFitter = new QwtSplineCurveFitter();
    curveFitter->setSplineSize(500);
    curve->setCurveFitter(curveFitter);
#endif

    curve->attach(ui->jrkPlot);
    showCurve(curve, on);

    jrkdata.push_back(new JrkPlotData(curve, scale, samples()));
    // qDebug("Scale: %f", scale);
}
Esempio n. 8
0
void CentralWidget::initTmpPlotAndGL()
{
    QwtPlot *plot = new QwtPlot(this);
    plot->setTitle( "Plot Demo" );
    plot->setCanvasBackground( Qt::white );
    plot->setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );

    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->attach( plot );

    QwtPlotCurve *curve = new QwtPlotCurve();
    curve->setTitle( "Some Points" );
    curve->setPen( Qt::blue, 4 ),
    curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );

    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 );
    curve->setSamples( points );
    curve->attach( plot );
    this->addTab(plot, tr("Tmp Plot"));

    MyGLWidget *widget = new MyGLWidget(this);
    this->addTab(widget, tr("Tmp OpenGL"));
}
Esempio n. 9
0
QwtPlotCurve* Curves::createCurve(int i) const
{
    QwtPlotCurve* curve = new QwtPlotCurve(file->header(i));
    curve->setRenderHint(QwtPlotCurve::RenderAntialiased);
    curve->setPen(QPen(QColor(rand() % 255, rand() % 255, rand() % 255), 2));
    curve->setPaintAttribute(QwtPlotCurve::ClipPolygons);
    return curve;
}
Esempio n. 10
0
int main(int argc, char *argv[])
{
	/*const int L = 10; 
	fftw_complex *in; 
	fftw_complex *out;
	gsl_sf_bessel_k0_scaled(0.684684);
	fftw_plan p;

	in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*L);
	out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*L);
	p = fftw_plan_dft_1d(L, in, out,FFTW_FORWARD,FFTW_MEASURE); 

	fftw_execute(p);
	fftw_destroy_plan(p);
	fftw_free(in);
	fftw_free(out);
	 
	QApplication a(argc, argv);
	Ekg w;
	w.show();
	qDebug() << "sdfsdfsd";
	std::cout << "ALKO PROJEKT CPP CHLOSTA!";			
	
	return a.exec();*/

	    QApplication a( argc, argv );
 
    QwtPlot plot;
    plot.setTitle( "Plot Demo" );
    plot.setCanvasBackground( Qt::white );
    plot.setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );
    plot.insertLegend( new QwtLegend() );
 
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->attach( &plot );
 
    QwtPlotCurve *curve = new QwtPlotCurve();
    curve->setTitle( "Some Points" );
    curve->setPen( Qt::blue, 4 ),
    curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
 
    QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
        QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ) );
    curve->setSymbol( symbol );
 
    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 );
    curve->setSamples( points );
 
    curve->attach( &plot );
  
    plot.resize( 600, 400 );
    plot.show(); 
  
    return a.exec();
}
Esempio n. 11
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatsGenPlotWidget::updatePlotCurves()
{
// qDebug() << "StatsGenPlotWidget::updatePlotCurves" << "\n";
  //Loop over each entry in the table
  QwtPlotCurve* curve = NULL;

  // Delete all the plots
  qint32 nRows = m_PlotCurves.count();
  for (qint32 r = nRows - 1; r >= 0; --r)
  {
    curve = m_PlotCurves[r];
    curve->detach();
    m_PlotCurves.remove(r);
    delete curve;
  }

  nRows = m_TableModel->rowCount();
  float xMax = 0.0;
  float yMax = 0.0;

  for (qint32 r = 0; r < nRows; ++r)
  {
    if (r == m_PlotCurves.size())
    {
      curve = new QwtPlotCurve("");
      curve->setRenderHint(QwtPlotItem::RenderAntialiased);
      QColor c = QColor(m_TableModel->getColor(r));
      c.setAlpha(UIA::Alpha);
      curve->setPen(QPen(c));
      curve->attach(m_PlotView);
      m_PlotCurves.append(curve);
    }
    else
    {
      curve = m_PlotCurves[r];
      QColor c = QColor(m_TableModel->getColor(r));
      c.setAlpha(UIA::Alpha);
      curve->setPen(QPen(c));
    }

    switch(m_DistributionType)
    {
      case DREAM3D::DistributionType::Beta:
        createBetaCurve(r, xMax, yMax);
        break;
      case DREAM3D::DistributionType::LogNormal:
        createLogNormalCurve(r, xMax, yMax);
        break;
      case DREAM3D::DistributionType::Power:
        createPowerCurve(r, xMax, yMax);
        break;
      default:
        break;
    }
  }
  m_PlotView->replot();

}
Esempio n. 12
0
void MQwt::curve(var iX, var iY, var iTitle)
{
    QwtPlotCurve* curve = new QwtPlotCurve(iTitle.str());
    curve->attach(mPlot);
    curve->setRenderHint(QwtPlotItem::RenderAntialiased);
    curve->setSamples(
        iX.ptr<double>(), iY.ptr<double>(), std::min(iX.size(), iY.size())
    );
}
Esempio n. 13
0
void MainWindow::sampleFormatChanged()
{
    for (int i = 0; i < curves.size(); i++) {
        curves[i].curve->detach();
        delete curves[i].curve;
        curves[i].data->clear();
        delete curves[i].data;
    }
    curves.clear();
    timeAxis.clear();

    QList<sampleValue> sampleList = kwp.getSample();
    int numSamples = settingsDialog->rate * settingsDialog->historySecs + 1;

    timeAxis.clear();
    for (int i = 0; i < numSamples; i++) {
        timeAxis.prepend(-i / static_cast<double>(settingsDialog->rate));
    }

    int numColors = sizeof(colorList) / sizeof(QString);

    for (int i = 0; i < sampleList.length(); i++) {
        QwtPlotCurve* curve = new QwtPlotCurve;
        QVector<double>* data = new QVector<double>();
        data->reserve(numSamples+1);
        data->fill(0, numSamples);

        QColor curveColor;
        curveColor.setNamedColor(colorList[i % numColors]);

        int blockNum = sampleList.at(i).refs.at(0).blockNum;
        int pos = sampleList.at(i).refs.at(0).pos;
        blockLabels_t label = kwp.getBlockLabel(blockNum);
        QString desc = label.desc[pos] + " " + label.subDesc[pos];

        curve->setRenderHint(QwtPlotItem::RenderAntialiased);
        curve->setPen(curveColor);
        curve->setTitle(desc);

        curve->setRawSamples(timeAxis.constData(), data->constData(), numSamples);
        curve->attach(ui->plot);

        // set legend checked
        QwtLegendItem *legendItem = qobject_cast<QwtLegendItem*>(ui->plot->legend()->find(curve));
        if (legendItem) {
            legendItem->setChecked(true);
        }

        curveAndData tmp;
        tmp.curve = curve;
        tmp.data = data;
        curves.append(tmp);
    }
}
Esempio n. 14
0
void GraphWidget::addNewPlot(chaos::common::utility::PointerBuffer *pointerBuffer, std::string& plotName , chaos::DataType::DataType dataType){
    boost::mutex::scoped_lock  lock(manageMutex);
    if(plotMap.count(plotName)>0) return;
    boost::shared_ptr<PlotPtrBufferAndCurve> newPlotInfo(new PlotPtrBufferAndCurve());
    boost::mt19937 rng((const uint_fast32_t) std::time(0) );
    boost::uniform_int<> one_to_six( 0, 255 );
    boost::variate_generator< boost::mt19937, boost::uniform_int<> > randInt(rng, one_to_six);

    QwtPlotCurve *c = new QwtPlotCurve(plotName.c_str());
    c->setPen(QPen(QColor(randInt(), randInt(), randInt())));
    c->setRenderHint(QwtPlotItem::RenderAntialiased);
    c->setStyle(QwtPlotCurve::Lines);
    c->attach(plot);
    c->setLegendAttribute(QwtPlotCurve::LegendShowLine);
    c->setRenderHint(QwtPlotItem::RenderAntialiased, true);
    newPlotInfo->curve = c;
    newPlotInfo->curvePointer = pointerBuffer;
    newPlotInfo->dataType = dataType;
    pointerPlotMap.insert(std::make_pair(plotName, newPlotInfo));
}
Esempio n. 15
0
void Plot::populate()
{
    // Insert new curves
    QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
    cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
    cSin->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
    cSin->setPen(QPen(Qt::red));
    cSin->attach(this);

    QwtPlotCurve *cCos = new QwtPlotCurve("y = cos(x)");
    cCos->setRenderHint(QwtPlotItem::RenderAntialiased);
    cCos->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
    cCos->setPen(QPen(Qt::blue));
    cCos->attach(this);

    // Create sin and cos data
    cSin->setData(new FunctionData(::sin));
    cCos->setData(new FunctionData(::cos));

    // Insert markers
    
    //  ...a horizontal line at y = 0...
    QwtPlotMarker *mY = new QwtPlotMarker();
    mY->setLabel(QString::fromLatin1("y = 0"));
    mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
    mY->setLineStyle(QwtPlotMarker::HLine);
    mY->setYValue(0.0);
    mY->attach(this);

    //  ...a vertical line at x = 2 * pi
    QwtPlotMarker *mX = new QwtPlotMarker();
    mX->setLabel(QString::fromLatin1("x = 2 pi"));
    mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
    mX->setLabelOrientation(Qt::Vertical);
    mX->setLineStyle(QwtPlotMarker::VLine);
    mX->setLinePen(QPen(Qt::black, 0, Qt::DashDotLine));
    mX->setXValue(2.0 * M_PI);
    mX->attach(this);
}
Esempio n. 16
0
void Plot::initCurves()
{
    QwtPointSeriesData* data = new QwtPointSeriesData();
    
    m_manager.GetPointSeriesData(data, ResourceManager::MF_0);
    
    QwtPlotCurve* curve = new QwtPlotCurve(tr("measured data"));
    curve->setRenderHint(QwtPlotItem::RenderAntialiased);
    curve->setLegendAttribute(QwtPlotCurve::LegendNoAttribute);
    curve->setPen(QPen(Qt::red));
    curve->attach(this);
    curve->setData(data);
}
QwtPlotCurve* PowerBarHistoryPlot::createCurve(const QwtText& title, const QPen& pen, ArraySeriesData* data)
{
	QwtPlotCurve* curve = new QwtPlotCurve(title);
	curve->setStyle(QwtPlotCurve::Lines);
	curve->setPen(pen);

	curve->setRenderHint(QwtPlotItem::RenderAntialiased, false);
	curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, true);

	curve->setData(data);
	curve->attach(m_plot);

	return curve;
}
Esempio n. 18
0
void Plot::insertCurve( const QString &title,
                        const QColor &color, const QPolygonF &points )
{
    QwtPlotCurve *curve = new QwtPlotCurve();
    curve->setTitle( title );
    curve->setPen( color, 2 ),
          curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );

    QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                       QBrush( Qt::white ), QPen( color, 2 ), QSize( 8, 8 ) );
    curve->setSymbol( symbol );

    curve->setSamples( points );

    curve->attach( this );
}
Esempio n. 19
0
            void AmplitudePlot::addSampleSource(PointSampler* src) {
                
                // Insert new curves
                QwtPlotCurve* curve = new QwtPlotCurve(src->objectName());
                _sources.insert(src, curve);
                curve->setPen(QPen(src->getColor()));
                curve->setRenderHint(QwtPlotItem::RenderAntialiased);
                
                SampleHistoryPlotDataAdapter adapter(src);
                curve->setData(adapter);
                
                curve->attach(_ui->plot);
                
                _ui->plot->setAxisScale(QwtPlot::xBottom, 0, src->getHistory().size());

                connect(src, SIGNAL(sampleHistoryChanged(const PointSampler*)), SLOT(updatePlot()));
                connect(src, SIGNAL(enabledChanged(bool)), SLOT(updateSeriesVisibility(bool)));
            }
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatsGenRDFWidget::updateRDFPlot(QVector<float>& freqs)
{
  // These are the output vectors
  QwtArray<double> xD(static_cast<int>(freqs.size()));
  QwtArray<double> yD(static_cast<int>(freqs.size()));

  QLocale loc = QLocale::system();

  bool ok = false;
  float minDist = loc.toFloat(minDistLE->text(), &ok);
  float maxDist = loc.toFloat(maxDistLE->text(), &ok);

  const int numValues = freqs.size();
  float increment = (maxDist - minDist) / numValues;

  double pos = minDist;

  for (qint32 i = 0; i < numValues; ++i)
  {
    xD[i] = pos;
    yD[i] = static_cast<double>(freqs.at(i));
    pos = pos + increment;
  }

  // This will actually plot the XY data in the Qwt plot widget
  QwtPlotCurve* curve = m_PlotCurve;
#if QWT_VERSION >= 0x060000
  curve->setSamples(xD, yD);
#else
  curve->setData(xD, yD);
#endif
  curve->setStyle(QwtPlotCurve::Lines);
  //Use Antialiasing to improve plot render quality
  curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
  QPen pen;
  pen.setColor(Qt::white);
  pen.setWidth(2);
  curve->setPen(pen);//Set colour and thickness for drawing the curve
  curve->attach(m_RDFPlot);
  m_RDFPlot->replot();
}
Esempio n. 21
0
void Plot::populate()
{
    // Insert new curves
    QwtPlotCurve *cSin = new QwtPlotCurve( "y = sin(x)" );
    cSin->setRenderHint( QwtPlotItem::RenderAntialiased );
    cSin->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
    cSin->setPen( Qt::red );
    cSin->attach( this );

    cSin->setData( new Data() );



    CurveTracker* tracker = new CurveTracker( canvas() );

    // for the demo we want the tracker to be active without
    // having to click on the canvas
    tracker->setStateMachine( new QwtPickerTrackerMachine() );
    tracker->setRubberBandPen( QPen( "MediumOrchid" ) );

}
Esempio n. 22
0
void SetWPDlg::on_pb_test2_clicked() {

	QwtDial *p = ui->dial;
	p->setValue(10.0);
	QwtKnob *k = ui->knob;
	k->setValue(10.0);

	QwtPlot *pp = ui->qwtPlot;
    pp->setAxisScale(QwtPlot::xBottom, 0.0, 10.0);
    pp->setAxisScale(QwtPlot::yLeft, -1.0, 1.0);

    pp->setTitle("fsdafdafdafdaadsf");

	QwtPlotCurve *c = new QwtPlotCurve("curve1");
    c->setRenderHint(QwtPlotItem::RenderAntialiased);
    c->setPen(QPen(Qt::red));
    c->setData(new SinusDataT());
    c->attach(pp);
    pp->show();

}
Esempio n. 23
0
QWT_ABSTRACT_SERIESITEM * MavPlot::_add_data_timeseries(const DataTimeseries<ST> * data, unsigned int plotnumber /* used for colors etc */) {

    /*
     * so we have a timeseries of type ST. We need to "translate" it for the plot, and then add it.
     * One problem is, that Qwt cannot plot double against float...so we need to "convert" every-
     * thing to double here.
     */
    QVector<double> xdata, ydata;
    if (!data2xyvect(data, xdata, ydata)) {
        return NULL;
    }

    QwtPlotCurve *curve = new QwtPlotCurve(QString().fromStdString(data->get_name()));
    curve->setRenderHint(QwtPlotItem::RenderAntialiased);
    curve->setPen(QPen(_suggestColor(plotnumber))); // FIXME: offer choices

    curve->setLegendAttribute(QwtPlotCurve::LegendShowLine);    
    curve->setSamples(xdata, ydata); // makes a deep copy
    curve->attach(this);

    return dynamic_cast<QWT_ABSTRACT_SERIESITEM *>(curve);
}
Esempio n. 24
0
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);
    mAOF->setValue(0,avrRMSEF);
    mAOF->attach(&plotRMSE2);
    QwtPlotMarker *mAF2=new QwtPlotMarker();
    mAF2->setLinePen(QPen(Qt::darkRed));
    mAF2->setLineStyle(QwtPlotMarker::HLine);
    mAF2->setValue(0,avrRMSEF2);
    mAF2->attach(&plotRMSE2);
    QwtPlotMarker *mAV2=new QwtPlotMarker();
    mAV2->setLinePen(QPen(Qt::darkGreen));
    mAV2->setLineStyle(QwtPlotMarker::HLine);
    mAV2->setValue(0,avrRMSEV2);
    mAV2->attach(&plotRMSE2);
    QwtPlotCurve *curveRMSEO2 = new QwtPlotCurve();
    curveRMSEO2->setTitle("Original");
    curveRMSEO2->setPen(Qt::blue,2);
    curveRMSEO2->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveRMSEO2->setRawSamples(framesO.data(),RMSEO.data(),framesO.size());
    curveRMSEO2->attach(&plotRMSE2);
    QwtPlotCurve *curveRMSEOF = new QwtPlotCurve();
    curveRMSEOF->setTitle("First round fusion stabilized");
    curveRMSEOF->setPen(Qt::cyan,2);
    curveRMSEOF->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveRMSEOF->setRawSamples(framesF.data(),RMSEF.data(),framesF.size());
    curveRMSEOF->attach(&plotRMSE2);
    QwtPlotCurve *curveRMSEF2 = new QwtPlotCurve();
    curveRMSEF2->setTitle("Fusion stabilized");
    curveRMSEF2->setPen(Qt::red,2);
    curveRMSEF2->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveRMSEF2->setRawSamples(framesF2.data(),RMSEF2.data(),framesF2.size());
    curveRMSEF2->attach(&plotRMSE2);
    QwtPlotCurve *curveRMSEV2 = new QwtPlotCurve();
    curveRMSEV2->setTitle("Video Processing stabilized");
    curveRMSEV2->setPen(Qt::green,2);
    curveRMSEV2->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveRMSEV2->setRawSamples(framesV2.data(),RMSEV2.data(),framesV2.size());
    curveRMSEV2->attach(&plotRMSE2);
    plotRMSE2.resize(600,400);
    plotRMSE2.show();

//
//*** Flow

//  original video motion flows reading
    tic();
    vector<double> xflowsO,yflowsO,framesFlowO;
    double avrxO=0,avryO=0;
    if(readFlows("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+".avi",xflowsO,yflowsO,framesFlowO,avrxO,avryO,true)>0) return -1;
    toc();

//  fusion stabilized video motion flows reading
    tic();
    vector<double> xflowsF,yflowsF,framesFlowF;
    double avrxF=0,avryF=0;
    if(readFlows("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable_F.avi",xflowsF,yflowsF,framesFlowF,avrxF,avryF,true)>0) return -1;
    toc();

//  video processing stabilized video motion flows reading
    tic();
    vector<double> xflowsV,yflowsV,framesFlowV;
    double avrxV=0,avryV=0;
    if(readFlows("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable_VP.avi",xflowsV,yflowsV,framesFlowV,avrxV,avryV,true)>0) return -1;
    toc();

//  second round fusion stabilized video motion flows reading
    tic();
    vector<double> xflowsF2,yflowsF2,framesFlowF2;
    double avrxF2=0,avryF2=0;
    if(readFlows("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable2_F.avi",xflowsF2,yflowsF2,framesFlowF2,avrxF2,avryF2,true)>0) return -1;
    toc();

//  second round video processing stabilized video motion flows reading
    tic();
    vector<double> xflowsV2,yflowsV2,framesFlowV2;
    double avrxV2=0,avryV2=0;
    if(readFlows("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable2_VP.avi",xflowsV2,yflowsV2,framesFlowV2,avrxV2,avryV2,true)>0) return -1;
    toc();

//  plots
    QwtPlot plotxFlow;
    plotxFlow.setTitle("Average horizontal flow per frame");
    plotxFlow.setCanvasBackground(Qt::white);
    plotxFlow.insertLegend(new QwtLegend());
    plotxFlow.setAxisTitle(QwtPlot::yLeft,"Flow (px)");
    plotxFlow.setAxisTitle(QwtPlot::xBottom,"Frame");
    QwtPlotMarker *mxAO=new QwtPlotMarker();
    mxAO->setLinePen(QPen(Qt::darkBlue));
    mxAO->setLineStyle(QwtPlotMarker::HLine);
    mxAO->setValue(0,avrxO);
    mxAO->attach(&plotxFlow);
    QwtPlotMarker *mxAF=new QwtPlotMarker();
    mxAF->setLinePen(QPen(Qt::darkRed));
    mxAF->setLineStyle(QwtPlotMarker::HLine);
    mxAF->setValue(0,avrxF);
    mxAF->attach(&plotxFlow);
    QwtPlotMarker *mxAV=new QwtPlotMarker();
    mxAV->setLinePen(QPen(Qt::darkGreen));
    mxAV->setLineStyle(QwtPlotMarker::HLine);
    mxAV->setValue(0,avrxV);
    mxAV->attach(&plotxFlow);
    QwtPlotCurve *curvexFlowO = new QwtPlotCurve();
    curvexFlowO->setTitle("Original");
    curvexFlowO->setPen(Qt::blue,2);
    curvexFlowO->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curvexFlowO->setRawSamples(framesFlowO.data(),xflowsO.data(),framesFlowO.size());
    curvexFlowO->attach(&plotxFlow);
    QwtPlotCurve *curvexFlowF = new QwtPlotCurve();
    curvexFlowF->setTitle("Fusion stabilized");
    curvexFlowF->setPen(Qt::red,2);
    curvexFlowF->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curvexFlowF->setRawSamples(framesFlowF.data(),xflowsF.data(),framesFlowF.size());
    curvexFlowF->attach(&plotxFlow);
    QwtPlotCurve *curvexFlowV = new QwtPlotCurve();
    curvexFlowV->setTitle("Video Processing stabilized");
    curvexFlowV->setPen(Qt::green,2);
    curvexFlowV->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curvexFlowV->setRawSamples(framesFlowV.data(),xflowsV.data(),framesFlowV.size());
    curvexFlowV->attach(&plotxFlow);
    plotxFlow.resize(600,400);
    plotxFlow.show();

    QwtPlot plotxFlow2;
    plotxFlow2.setTitle("Average horizontal flow per frame (second round)");
    plotxFlow2.setCanvasBackground(Qt::white);
    plotxFlow2.insertLegend(new QwtLegend());
    plotxFlow2.setAxisTitle(QwtPlot::yLeft,"Flow (px)");
    plotxFlow2.setAxisTitle(QwtPlot::xBottom,"Frame");
    QwtPlotMarker *mxAO2=new QwtPlotMarker();
    mxAO2->setLinePen(QPen(Qt::darkBlue));
    mxAO2->setLineStyle(QwtPlotMarker::HLine);
    mxAO2->setValue(0,avrxO);
    mxAO2->attach(&plotxFlow2);
    QwtPlotMarker *mxAF0=new QwtPlotMarker();
    mxAF0->setLinePen(QPen(Qt::darkCyan));
    mxAF0->setLineStyle(QwtPlotMarker::HLine);
    mxAF0->setValue(0,avrxF);
    mxAF0->attach(&plotxFlow2);
    QwtPlotMarker *mxAF2=new QwtPlotMarker();
    mxAF2->setLinePen(QPen(Qt::darkRed));
    mxAF2->setLineStyle(QwtPlotMarker::HLine);
    mxAF2->setValue(0,avrxF2);
    mxAF2->attach(&plotxFlow2);
    QwtPlotMarker *mxAV2=new QwtPlotMarker();
    mxAV2->setLinePen(QPen(Qt::darkGreen));
    mxAV2->setLineStyle(QwtPlotMarker::HLine);
    mxAV2->setValue(0,avrxV2);
    mxAV2->attach(&plotxFlow2);
    QwtPlotCurve *curvexFlowO2 = new QwtPlotCurve();
    curvexFlowO2->setTitle("Original");
    curvexFlowO2->setPen(Qt::blue,2);
    curvexFlowO2->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curvexFlowO2->setRawSamples(framesFlowO.data(),xflowsO.data(),framesFlowO.size());
    curvexFlowO2->attach(&plotxFlow2);
    QwtPlotCurve *curvexFlowFO = new QwtPlotCurve();
    curvexFlowFO->setTitle("First round fusion stabilized");
    curvexFlowFO->setPen(Qt::cyan,2);
    curvexFlowFO->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curvexFlowFO->setRawSamples(framesFlowF.data(),xflowsF.data(),framesFlowF.size());
    curvexFlowFO->attach(&plotxFlow2);
    QwtPlotCurve *curvexFlowF2 = new QwtPlotCurve();
    curvexFlowF2->setTitle("Fusion stabilized");
    curvexFlowF2->setPen(Qt::red,2);
    curvexFlowF2->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curvexFlowF2->setRawSamples(framesFlowF2.data(),xflowsF2.data(),framesFlowF2.size());
    curvexFlowF2->attach(&plotxFlow2);
    QwtPlotCurve *curvexFlowV2 = new QwtPlotCurve();
    curvexFlowV2->setTitle("Video Processing stabilized");
    curvexFlowV2->setPen(Qt::green,2);
    curvexFlowV2->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curvexFlowV2->setRawSamples(framesFlowV2.data(),xflowsV2.data(),framesFlowV2.size());
    curvexFlowV2->attach(&plotxFlow2);
    plotxFlow2.resize(600,400);
    plotxFlow2.show();

    QwtPlot plotyFlow;
    plotyFlow.setTitle("Average vertical flow per frame");
    plotyFlow.setCanvasBackground(Qt::white);
    plotyFlow.insertLegend(new QwtLegend());
    plotyFlow.setAxisTitle(QwtPlot::yLeft,"Flow (px)");
    plotyFlow.setAxisTitle(QwtPlot::xBottom,"Frame");
    QwtPlotMarker *myAO=new QwtPlotMarker();
    myAO->setLinePen(QPen(Qt::darkBlue));
    myAO->setLineStyle(QwtPlotMarker::HLine);
    myAO->setValue(0,avryO);
    myAO->attach(&plotyFlow);
    QwtPlotMarker *myAF=new QwtPlotMarker();
    myAF->setLinePen(QPen(Qt::darkRed));
    myAF->setLineStyle(QwtPlotMarker::HLine);
    myAF->setValue(0,avryF);
    myAF->attach(&plotyFlow);
    QwtPlotMarker *myAV=new QwtPlotMarker();
    myAV->setLinePen(QPen(Qt::darkGreen));
    myAV->setLineStyle(QwtPlotMarker::HLine);
    myAV->setValue(0,avryV);
    myAV->attach(&plotyFlow);
    QwtPlotCurve *curveyFlowO = new QwtPlotCurve();
    curveyFlowO->setTitle("Original");
    curveyFlowO->setPen(Qt::blue,2);
    curveyFlowO->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveyFlowO->setRawSamples(framesFlowO.data(),yflowsO.data(),framesFlowO.size());
    curveyFlowO->attach(&plotyFlow);
    QwtPlotCurve *curveyFlowF = new QwtPlotCurve();
    curveyFlowF->setTitle("Fusion stabilized");
    curveyFlowF->setPen(Qt::red,2);
    curveyFlowF->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveyFlowF->setRawSamples(framesFlowF.data(),yflowsF.data(),framesFlowF.size());
    curveyFlowF->attach(&plotyFlow);
    QwtPlotCurve *curveyFlowV = new QwtPlotCurve();
    curveyFlowV->setTitle("Video Processing stabilized");
    curveyFlowV->setPen(Qt::green,2);
    curveyFlowV->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveyFlowV->setRawSamples(framesFlowV.data(),yflowsV.data(),framesFlowV.size());
    curveyFlowV->attach(&plotyFlow);
    plotyFlow.resize(600,400);
    plotyFlow.show();

    QwtPlot plotyFlow2;
    plotyFlow2.setTitle("Average vertical flow per frame (second round)");
    plotyFlow2.setCanvasBackground(Qt::white);
    plotyFlow2.insertLegend(new QwtLegend());
    plotyFlow2.setAxisTitle(QwtPlot::yLeft,"Flow (px)");
    plotyFlow2.setAxisTitle(QwtPlot::xBottom,"Frame");
    QwtPlotMarker *myAO2=new QwtPlotMarker();
    myAO2->setLinePen(QPen(Qt::darkBlue));
    myAO2->setLineStyle(QwtPlotMarker::HLine);
    myAO2->setValue(0,avryO);
    myAO2->attach(&plotyFlow2);
    QwtPlotMarker *myAF0=new QwtPlotMarker();
    myAF0->setLinePen(QPen(Qt::darkCyan));
    myAF0->setLineStyle(QwtPlotMarker::HLine);
    myAF0->setValue(0,avryF);
    myAF0->attach(&plotyFlow2);
    QwtPlotMarker *myAF2=new QwtPlotMarker();
    myAF2->setLinePen(QPen(Qt::darkRed));
    myAF2->setLineStyle(QwtPlotMarker::HLine);
    myAF2->setValue(0,avryF2);
    myAF2->attach(&plotyFlow2);
    QwtPlotMarker *myAV2=new QwtPlotMarker();
    myAV2->setLinePen(QPen(Qt::darkGreen));
    myAV2->setLineStyle(QwtPlotMarker::HLine);
    myAV2->setValue(0,avryV2);
    myAV2->attach(&plotyFlow2);
    QwtPlotCurve *curveyFlowO2 = new QwtPlotCurve();
    curveyFlowO2->setTitle("Original");
    curveyFlowO2->setPen(Qt::blue,2);
    curveyFlowO2->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveyFlowO2->setRawSamples(framesFlowO.data(),yflowsO.data(),framesFlowO.size());
    curveyFlowO2->attach(&plotyFlow2);
    QwtPlotCurve *curveyFlowFO = new QwtPlotCurve();
    curveyFlowFO->setTitle("First round fusion stabilized");
    curveyFlowFO->setPen(Qt::cyan,2);
    curveyFlowFO->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveyFlowFO->setRawSamples(framesFlowF.data(),yflowsF.data(),framesFlowF.size());
    curveyFlowFO->attach(&plotyFlow2);
    QwtPlotCurve *curveyFlowF2 = new QwtPlotCurve();
    curveyFlowF2->setTitle("Fusion stabilized");
    curveyFlowF2->setPen(Qt::red,2);
    curveyFlowF2->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveyFlowF2->setRawSamples(framesFlowF2.data(),yflowsF2.data(),framesFlowF2.size());
    curveyFlowF2->attach(&plotyFlow2);
    QwtPlotCurve *curveyFlowV2 = new QwtPlotCurve();
    curveyFlowV2->setTitle("Video Processing stabilized");
    curveyFlowV2->setPen(Qt::green,2);
    curveyFlowV2->setRenderHint(QwtPlotItem::RenderAntialiased,true);
    curveyFlowV2->setRawSamples(framesFlowV2.data(),yflowsV2.data(),framesFlowV2.size());
    curveyFlowV2->attach(&plotyFlow2);
    plotyFlow2.resize(600,400);
    plotyFlow2.show();
//
    return a.exec();
}
Esempio n. 25
0
void
CpintPlot::plot_allCurve(CpintPlot *thisPlot,
                         int n_values,
                         const double *power_values)
{
    clear_CP_Curves();

    QVector<double> energyBests(n_values);
    QVector<double> time_values(n_values);
    // generate an array of time values
    for (int t = 0; t < n_values; t++) {
        time_values[t] = (t + 1) / 60.0;
        energyBests[t] = power_values[t] * time_values[t] * 60.0 / 1000.0;
    }

    // generate zones from derived CP value
    if (cp > 0) {
        QList <int> power_zone;
        int n_zones = zones->lowsFromCP(&power_zone, (int) int(cp));
        int high = n_values - 1;
        int zone = 0;
        while (zone < n_zones && high > 0) {
            int low = high - 1;
            int nextZone = zone + 1;
            if (nextZone >= power_zone.size())
                low = 0;
            else {
                while ((low > 0) && (power_values[low] < power_zone[nextZone]))
                    --low;
            }

            QColor color = zoneColor(zone, n_zones);
            QString name = zones->getDefaultZoneName(zone);
            QwtPlotCurve *curve = new QwtPlotCurve(name);
            if (appsettings->value(this, GC_ANTIALIAS, false).toBool() == true)
                curve->setRenderHint(QwtPlotItem::RenderAntialiased);
            QPen pen(color.darker(200));
            pen.setWidth(appsettings->value(this, GC_LINEWIDTH, 2.0).toDouble());
            curve->setPen(pen);
            curve->attach(thisPlot);

            // use a linear gradient
            color.setAlpha(180);
            QColor color1 = color;
            color1.setAlpha(64);
            QLinearGradient linearGradient(0, 0, 0, height());
            linearGradient.setColorAt(0.0, color);
            linearGradient.setColorAt(1.0, color1);
            linearGradient.setSpread(QGradient::PadSpread);
            curve->setBrush(linearGradient);   // fill below the line

            if (series == RideFile::none) { // this is Energy mode 
                curve->setData(time_values.data() + low,
                               energyBests.data() + low, high - low + 1);
            } else {
                curve->setData(time_values.data() + low,
                               power_values + low, high - low + 1);
            }
            allCurves.append(curve);

            if (series != RideFile::none || energyBests[high] > 100.0) {
                QwtText text(name);
                text.setFont(QFont("Helvetica", 20, QFont::Bold));
                color.setAlpha(255);
                text.setColor(color);
                QwtPlotMarker *label_mark = new QwtPlotMarker();
                // place the text in the geometric mean in time, at a decent power
                double x, y;
                if (series == RideFile::none) {
                    x = (time_values[low] + time_values[high]) / 2;
                    y = (energyBests[low] + energyBests[high]) / 5;
                }
                else {
                    x = sqrt(time_values[low] * time_values[high]);
                    y = (power_values[low] + power_values[high]) / 5;
                }
                label_mark->setValue(x, y);
                label_mark->setLabel(text);
                label_mark->attach(thisPlot);
                allZoneLabels.append(label_mark);
            }

            high = low;
            ++zone;
        }
    }
    // no zones available: just plot the curve without zones
    else {
        QwtPlotCurve *curve = new QwtPlotCurve(tr("maximal power"));
        if (appsettings->value(this, GC_ANTIALIAS, false).toBool() == true)
            curve->setRenderHint(QwtPlotItem::RenderAntialiased);
        QPen pen(GColor(CCP));
        pen.setWidth(appsettings->value(this, GC_LINEWIDTH, 2.0).toDouble());
        curve->setPen(pen);
        QColor brush_color = GColor(CCP);
        brush_color.setAlpha(200);
        curve->setBrush(brush_color);   // brush fills below the line
        if (series == RideFile::none)
            curve->setData(time_values.data(), energyBests.data(), n_values);
        else
            curve->setData(time_values.data(), power_values, n_values);
        curve->attach(thisPlot);
        allCurves.append(curve);
    }

    // Energy mode is really only interesting in the range where energy is
    // linear in interval duration--up to about 1 hour.
    double xmax = (series == RideFile::none)  ? 60.0 : time_values[n_values - 1];

    if (series == RideFile::vam)
        thisPlot->setAxisScale(thisPlot->xBottom, (double) 4.993, (double)xmax);
    else
        thisPlot->setAxisScale(thisPlot->xBottom, (double) 0.017, (double)xmax);

    double ymax;
    if (series == RideFile::none) {
        int i = std::lower_bound(time_values.begin(), time_values.end(), 60.0) - time_values.begin();
        ymax = 10 * ceil(energyBests[i] / 10);
    }
    else {
        ymax = 100 * ceil(power_values[0] / 100);
        if (ymax == 100)
            ymax = 5 * ceil(power_values[0] / 5);
    }
    thisPlot->setAxisScale(thisPlot->yLeft, 0, ymax);
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatsGenMDFWidget::updateMDFPlot(QVector<float>& odf)
{
  int err = 0;
  int size = 100000;

  // These are the input vectors
  QVector<float> angles;
  QVector<float> axes;
  QVector<float> weights;

  angles = m_MDFTableModel->getData(SGMDFTableModel::Angle);
  weights = m_MDFTableModel->getData(SGMDFTableModel::Weight);
  axes = m_MDFTableModel->getData(SGMDFTableModel::Axis);

  // These are the output vectors
  QVector<float> x;
  QVector<float> y;
  if ( Ebsd::CrystalStructure::Cubic_High == m_CrystalStructure )
  {
    // Allocate a new vector to hold the mdf data
    QVector<float> mdf(CubicOps::k_MdfSize);
    // Calculate the MDF Data using the ODF data and the rows from the MDF Table model
    Texture::CalculateMDFData<float, CubicOps>(angles.data(), axes.data(), weights.data(), odf.data(), mdf.data(), static_cast<size_t>(angles.size()));
    // Now generate the actual XY point data that gets plotted.
    int npoints = 13;
    x.resize(npoints);
    y.resize(npoints);
    err = StatsGen::GenCubicMDFPlotData(mdf.data(), x.data(), y.data(), npoints, size);
    if (err < 0)
    {
      return;
    }
  }
  else if ( Ebsd::CrystalStructure::Hexagonal_High == m_CrystalStructure )
  {
    // Allocate a new vector to hold the mdf data
    QVector<float> mdf(HexagonalOps::k_MdfSize);
    // Calculate the MDF Data using the ODF data and the rows from the MDF Table model
    Texture::CalculateMDFData<float, HexagonalOps>(angles.data(), axes.data(), weights.data(), odf.data(), mdf.data(), static_cast<size_t>(angles.size()));
    // Now generate the actual XY point data that gets plotted.
    int npoints = 20;
    x.resize(npoints);
    y.resize(npoints);
    err = StatsGen::GenHexMDFPlotData(mdf.data(), x.data(), y.data(), npoints, size);
    if (err < 0) { return; }
  }

  QwtArray<double> xD(static_cast<int>(x.size()));
  QwtArray<double> yD(static_cast<int>(x.size()));
  for (qint32 i = 0; i < x.size(); ++i)
  {
    xD[i] = static_cast<double>(x.at(i));
    yD[i] = static_cast<double>(y.at(i));
  }


  // This will actually plot the XY data in the Qwt plot widget
  QwtPlotCurve* curve = m_PlotCurve;
#if QWT_VERSION >= 0x060000
  curve->setSamples(xD, yD);
#else
  curve->setData(xD, yD);
#endif
  QColor color = QColor("DodgerBlue");
  curve->setPen(color, 2);
  curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
  curve->setStyle(QwtPlotCurve::Lines);
  QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
      QBrush( Qt::white ), QPen( color, 2 ), QSize( 8, 8 ) );
  curve->setSymbol( symbol );
  curve->attach(m_MDFPlot);
  m_MDFPlot->replot();
}
Esempio n. 27
0
//---------------------------------------------------------------------------
Plot::Plot( size_t streamPos, size_t Type, size_t Group, QWidget *parent ) :
    QwtPlot( parent ),
    m_streamPos( streamPos ),
    m_type( Type ),
    m_group( Group )
{
    setAutoReplot( false );

    QwtPlotCanvas* canvas = dynamic_cast<QwtPlotCanvas*>( this->canvas() );
    if ( canvas )
    {
        canvas->setFrameStyle( QFrame::Plain | QFrame::Panel );
        canvas->setLineWidth( 1 );
#if 1
        canvas->setPalette( QColor("Cornsilk") );
#endif
    }

    setAxisMaxMajor( QwtPlot::yLeft, 0 );
    setAxisMaxMinor( QwtPlot::yLeft, 0 );
    setAxisScaleDraw( QwtPlot::yLeft, new PlotScaleDrawY() );

    enableAxis( QwtPlot::xBottom, false );

    // something invalid
    setAxisScale( QwtPlot::xBottom, -1, 0 );
    setAxisScale( QwtPlot::yLeft, -1, 0 );

    // Plot grid
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->enableXMin( true );
    grid->enableYMin( true );
    grid->setMajorPen( Qt::darkGray, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
    grid->attach( this );

    m_cursor = new PlotCursor( canvas );
    m_cursor->setPosition( 0 );

    // curves

    for( unsigned j = 0; j < PerStreamType[m_type].PerGroup[m_group].Count; ++j )
    {
        QwtPlotCurve* curve = new QwtPlotCurve( PerStreamType[m_type].PerItem[PerStreamType[m_type].PerGroup[m_group].Start + j].Name );

        curve->setPen( curveColor( j ) );
        curve->setRenderHint( QwtPlotItem::RenderAntialiased );
        curve->setZ( curve->z() - j ); //Invert data order (e.g. MAX before MIN)
        curve->attach( this );

        m_curves += curve;
    }

    // visual helpers
    if ( m_type == Type_Video )
    switch (m_group)
    {
        case Group_Y :
                        Plot_AddHLine( this,  16,  61,  89, 171);
                        Plot_AddHLine( this, 235, 220,  20,  60);
                        break;
        case Group_U :
        case Group_V :
                        Plot_AddHLine( this,  16,  61,  89, 171);
                        Plot_AddHLine( this, 240, 220,  20,  60);
                        break;
        case Group_Sat :
                        Plot_AddHLine( this,  88, 255,   0, 255);
                        Plot_AddHLine( this, 118, 220,  20,  60);
                        break;
        default      :  ;  
    }

    PlotPicker* picker = new PlotPicker( canvas, &PerStreamType[m_type], m_group, &m_curves );
    connect( picker, SIGNAL( moved( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );
    connect( picker, SIGNAL( selected( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );

    connect( axisWidget( QwtPlot::xBottom ), SIGNAL( scaleDivChanged() ), SLOT( onXScaleChanged() ) );

    // legend
    m_legend = new PlotLegend();
    
    connect( this, SIGNAL( legendDataChanged( const QVariant &, const QList<QwtLegendData> & ) ),
         m_legend, SLOT( updateLegend( const QVariant &, const QList<QwtLegendData> & ) ) );

    updateLegend();
}
Esempio n. 28
0
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();
}
Esempio n. 29
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotWidget::plotCurves(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, double pressure, double pointMarkerYValue, QString pointMarkerLabel, QString plotTitle, QString yAxisTitle)
{
    m_qwtPlot->detachItems(QwtPlotItem::Rtti_PlotCurve);
    m_qwtPlot->detachItems(QwtPlotItem::Rtti_PlotMarker);
    m_qwtCurveArr.clear();
    m_pvtCurveArr.clear();
    m_trackerPlotMarker = nullptr;


    // Construct an auxiliary curve that connects the first point in all the input curves as a visual aid
    // This should only be shown when the phase being plotted is oil
    // Will not be added to our array of qwt curves since we do not expect the user to interact with it
    {
        std::vector<double> xVals;
        std::vector<double> yVals;
        for (size_t i = 0; i < curveArr.size(); i++)
        {
            const RigFlowDiagSolverInterface::PvtCurve& curve = curveArr[i];
            if (curve.phase == RigFlowDiagSolverInterface::PvtCurve::OIL && curve.pressureVals.size() > 0 && curve.yVals.size() > 0)
            {
                xVals.push_back(curve.pressureVals[0]);
                yVals.push_back(curve.yVals[0]);
            }
        }

        if (xVals.size() > 1)
        {
            QwtPlotCurve* qwtCurve = new QwtPlotCurve();
            qwtCurve->setSamples(xVals.data(), yVals.data(), static_cast<int>(xVals.size()));

            qwtCurve->setStyle(QwtPlotCurve::Lines);
            qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);

            QColor curveClr = Qt::darkGreen;
            const QPen curvePen(curveClr);
            qwtCurve->setPen(curvePen);

            qwtCurve->attach(m_qwtPlot);
        }
    }


    // Add the primary curves
    for (size_t i = 0; i < curveArr.size(); i++)
    {
        const RigFlowDiagSolverInterface::PvtCurve& curve = curveArr[i];
        QwtPlotCurve* qwtCurve = new QwtPlotCurve();

        CVF_ASSERT(curve.pressureVals.size() == curve.yVals.size());
        qwtCurve->setSamples(curve.pressureVals.data(), curve.yVals.data(), static_cast<int>(curve.pressureVals.size()));

        qwtCurve->setStyle(QwtPlotCurve::Lines);

        QColor curveClr = Qt::magenta;
        if      (curve.phase == RigFlowDiagSolverInterface::PvtCurve::GAS)   curveClr = QColor(Qt::red);
        else if (curve.phase == RigFlowDiagSolverInterface::PvtCurve::OIL)   curveClr = QColor(Qt::green);
        const QPen curvePen(curveClr);
        qwtCurve->setPen(curvePen);

        qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);

        QwtSymbol* curveSymbol = new QwtSymbol(QwtSymbol::Ellipse);
        curveSymbol->setSize(6, 6);
        curveSymbol->setPen(curvePen);
        curveSymbol->setBrush(Qt::NoBrush);
        qwtCurve->setSymbol(curveSymbol);

        qwtCurve->attach(m_qwtPlot);

        m_qwtCurveArr.push_back(qwtCurve);
    }

    m_pvtCurveArr = curveArr;
    CVF_ASSERT(m_pvtCurveArr.size() == m_qwtCurveArr.size());


    // Add vertical marker line to indicate cell pressure
    if (pressure != HUGE_VAL)
    {
        QwtPlotMarker* lineMarker = new QwtPlotMarker;
        lineMarker->setXValue(pressure);
        lineMarker->setLineStyle(QwtPlotMarker::VLine);
        lineMarker->setLinePen(QPen(QColor(128, 128, 255), 1, Qt::DashLine));
        lineMarker->setLabel(QString("PRESSURE"));
        lineMarker->setLabelAlignment(Qt::AlignTop | Qt::AlignRight);
        lineMarker->setLabelOrientation(Qt::Vertical);
        lineMarker->attach(m_qwtPlot);
    }

    // Then point marker
    if (pressure != HUGE_VAL && pointMarkerYValue != HUGE_VAL)
    {
        QwtPlotMarker* pointMarker = new QwtPlotMarker;
        pointMarker->setValue(pressure, pointMarkerYValue);

        QColor markerClr(128, 0, 255);
        QwtSymbol* symbol = new QwtSymbol(QwtSymbol::Ellipse);
        symbol->setSize(13, 13);
        symbol->setPen(QPen(markerClr, 2));
        symbol->setBrush(Qt::NoBrush);
        pointMarker->setSymbol(symbol);

        if (!pointMarkerLabel.isEmpty())
        {
            QwtText text(pointMarkerLabel);
            text.setRenderFlags(Qt::AlignLeft);
            text.setColor(markerClr);
            pointMarker->setLabel(text);
            pointMarker->setLabelAlignment(Qt::AlignTop | Qt::AlignRight);
        }

        pointMarker->attach(m_qwtPlot);
    }

    m_qwtPlot->setTitle(plotTitle);

    m_qwtPlot->setAxisTitle(QwtPlot::xBottom, QString("Pressure [%1]").arg(RiaEclipseUnitTools::unitStringPressure(unitSystem)));
    m_qwtPlot->setAxisTitle(QwtPlot::yLeft, yAxisTitle);

    updateTrackerPlotMarkerAndLabelFromPicker();

    m_qwtPlot->replot();
}
Esempio n. 30
0
void ScatterPlot::setData (ScatterSettings *settings)
{
    // get application settings
    cranklength = appsettings->value(this, GC_CRANKLENGTH, 0.0).toDouble() / 1000.0;

    // if there are no settings or incomplete settings
    // create a null data plot
    if (settings == NULL || settings->ride == NULL || settings->ride->ride() == NULL ||
        settings->x == 0 || settings->y == 0 ) {
        return;
    }


    // if its not setup or no settings exist default to 175mm cranks
    if (cranklength == 0.0) cranklength = 0.175;

    //
    // Create Main Plot dataset - used to frame intervals
    //
    int points=0;

    x.clear();
    y.clear();
    x.resize(settings->ride->ride()->dataPoints().count());
    y.resize(settings->ride->ride()->dataPoints().count());

    double maxY = maxX = -65535;
    double minY = minX = 65535;

    foreach(const RideFilePoint *point, settings->ride->ride()->dataPoints()) {

        double xv = x[points] = pointType(point, settings->x, context->athlete->useMetricUnits, cranklength);
        double yv = y[points] = pointType(point, settings->y, context->athlete->useMetricUnits, cranklength);

        // skip zeroes?
        if (!(settings->ignore && (x[points] == 0 || y[points] == 0))) {
            points++;
            if (yv > maxY) maxY = yv;
            if (yv < minY) minY = yv;
            if (xv > maxX) maxX = xv;
            if (xv < minX) minX = xv;
        }
    }

    QwtSymbol sym;
    sym.setStyle(QwtSymbol::Ellipse);
    sym.setSize(6);
    sym.setPen(GCColor::invert(GColor(CPLOTBACKGROUND)));
    sym.setBrush(QBrush(Qt::NoBrush));
    QPen p;
    p.setColor(GColor(CPLOTSYMBOL));
    sym.setPen(p);

    // wipe away existing
	if (all) {
        all->detach();
	    delete all;
    }

    // setup the framing curve
    if (settings->frame) {
        all = new QwtPlotCurve();
        all->setSymbol(new QwtSymbol(sym));
        all->setStyle(QwtPlotCurve::Dots);
        all->setRenderHint(QwtPlotItem::RenderAntialiased);
	    all->setData(x.constData(), y.constData(), points);
        all->attach(this);
    } else {
        all = NULL;
    }

    QPen gridPen(GColor(CPLOTGRID));
    gridPen.setStyle(Qt::DotLine);

    if (grid) {
        grid->detach();
        delete grid;
    }

    if (settings->gridlines) {
        grid = new QwtPlotGrid();
        grid->setPen(gridPen);
        grid->enableX(true);
        grid->enableY(true);
        grid->attach(this);
    } else {
        grid = NULL;
    }

    setAxisTitle(yLeft, describeType(settings->y, true, useMetricUnits));
    setAxisTitle(xBottom, describeType(settings->x, true, useMetricUnits));

    // truncate PfPv values to make easier to read
    if (settings->y == MODEL_AEPF) setAxisScale(yLeft, 0, 600);
    else setAxisScale(yLeft, minY, maxY);
    if (settings->x == MODEL_CPV) setAxisScale(xBottom, 0, 3);
    else setAxisScale(xBottom, minX, maxX);

    //
    // Create Interval Plot dataset - used to frame intervals
    //

    // clear out any interval curves which are presently defined
    if (intervalCurves.size()) {
       QListIterator<QwtPlotCurve *> i(intervalCurves);
       while (i.hasNext()) {
           QwtPlotCurve *curve = i.next();
           curve->detach();
           delete curve;
       }
    }
    intervalCurves.clear();

    // which ones are highlighted then?
    QVector<int> intervals;
    QMap<int,int> displaySequence;

    for (int child=0; child<context->athlete->allIntervalItems()->childCount(); child++) {
        IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(child));
        if ((current != NULL) && current->isSelected()) {
            intervals.append(child);
            displaySequence.insert(current->displaySequence, intervals.count()-1);
        }
    }

    if (intervals.count() > 0) {

        // interval data in here
        QVector<QVector<double> > xvals(intervals.count()); // array of curve x arrays
        QVector<QVector<double> > yvals(intervals.count()); // array of curve x arrays
        QVector<int> points(intervals.count());             // points in eac curve

        // extract interval data
        foreach(const RideFilePoint *point, settings->ride->ride()->dataPoints()) {

            double x = pointType(point, settings->x, useMetricUnits, cranklength);
            double y = pointType(point, settings->y, useMetricUnits, cranklength);

            if (!(settings->ignore && (x == 0 && y ==0))) {

                // which interval is it in?
                for (int idx=0; idx<intervals.count(); idx++) {

                    IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(intervals[idx]));

                    if (point->secs+settings->ride->ride()->recIntSecs() > current->start && point->secs< current->stop) {
                        xvals[idx].append(x);
                        yvals[idx].append(y);
                        points[idx]++;
                    }
                }
            }
        }

        // now we have the interval data lets create the curves
        QMapIterator<int, int> order(displaySequence);
        while (order.hasNext()) {
            order.next();
            int idx = order.value();

            QPen pen;
            QColor intervalColor;
            intervalColor.setHsv((255/context->athlete->allIntervalItems()->childCount()) * (intervals[idx]), 255,255);
            pen.setColor(intervalColor);
            sym.setPen(pen);

            QwtPlotCurve *curve = new QwtPlotCurve();

            curve->setSymbol(new QwtSymbol(sym));
            curve->setStyle(QwtPlotCurve::Dots);
            curve->setRenderHint(QwtPlotItem::RenderAntialiased);
            curve->setData(xvals[idx].constData(), yvals[idx].constData(), points[idx]);
            curve->attach(this);

            intervalCurves.append(curve);
        }
    }