Esempio n. 1
0
void Plot::clear()
{
    this->detachItems();
    pointsArr.clear();

    //  ...a horizontal line at y = 1...
    QwtPlotMarker *mY1 = new QwtPlotMarker();
    mY1->setLabel( QString::fromLatin1( "y = 1" ) );
    mY1->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
    mY1->setLineStyle( QwtPlotMarker::HLine );
    mY1->setYValue( 1.0 );
    mY1->setLinePen(Qt::black, 1, Qt::DashLine);
    mY1->attach( this );

    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 = 0
    QwtPlotMarker *mX = new QwtPlotMarker();
    mX->setLabel( QString::fromLatin1( "x = 0" ) );
    mX->setLabelAlignment( Qt::AlignLeft | Qt::AlignBottom );
    mX->setLabelOrientation( Qt::Vertical );
    mX->setLineStyle( QwtPlotMarker::VLine );
    mX->setLinePen( Qt::black, 0, Qt::DashDotLine );
    mX->setXValue( 0 );
    mX->attach( this );
}
Esempio n. 2
0
SimDialog::SimDialog( QWidget * parent, Qt::WFlags f) 
	: QDialog(parent, f)
{
  setupUi(this);

  // setup the plot ...
  m_plot->setTitle("Comparing Similarity Measures");
  m_plot->insertLegend(new QwtLegend(), QwtPlot::BottomLegend);

  // set up the axes ...
  m_plot->setAxisTitle(QwtPlot::xBottom, "Variations");
  m_plot->setAxisScale(QwtPlot::xBottom, -10, 10);

  m_plot->setAxisTitle(QwtPlot::yLeft, "Similarity");
  m_plot->setAxisScale(QwtPlot::yLeft, -1.5, 1.5);

  // enable grid ...
  QwtPlotGrid *grid = new QwtPlotGrid;
  grid->enableXMin(true);
  grid->enableYMin(true);
  grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
  grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
  grid->attach(m_plot);

  //  Insert zero line at y = 0
  QwtPlotMarker *mY = new QwtPlotMarker();
  mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
  mY->setLineStyle(QwtPlotMarker::HLine);
  mY->setYValue(0.0);
  mY->attach(m_plot);

  //  Insert zero line at x = 0
  QwtPlotMarker *mX = new QwtPlotMarker();
  mX->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
  mX->setLineStyle(QwtPlotMarker::VLine);
  mX->setXValue(0.0);
  mX->attach(m_plot);

  // Insert new curves
  cReg = new QwtPlotCurve("Regular Similarity Measure");
  cReg->attach(m_plot);

  cOct = new QwtPlotCurve("Octree based Similarity Measure");
  cOct->attach(m_plot);

  // Set curve styles
  cReg->setPen(QPen(Qt::red, 2));
  cOct->setPen(QPen(Qt::blue, 2));

  // Populate the volume combos ...
  MainWindow* _win  = (MainWindow *)this->parent();
  viewer3d *  _view = (viewer3d *) _win->getViewer();
  QList<Volume*> _vols = _view->getVolumes();

  // append Volume names to combo boxes ...
  // Need to modify Volume class so that it stored patient name ...
  // More importantly modify PatientBrowser so that the data can be directly
  // loaded.
}
Esempio n. 3
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);
}
void Variog_plot::mouseReleaseEvent(QMouseEvent * event)
{
  std::cerr << "show_pairs_count() called " << std::endl;
  if( event->button() != Qt::RightButton ) return;

  const float offset=1.02;
  QFont font;
  font.setPointSize( 7 );

  if( !pairs_shown_ ) {
    for( unsigned int i=0; i < pairs_.size(); i++ ) {
      QString label;
      label.setNum( pairs_[i] );
      QwtText T(label);
      
      QwtPlotMarker * marker = new QwtPlotMarker();
      marker->attach(this);

      T.setFont(font);
      marker->setValue(pairs_coord_x_[i], pairs_coord_y_[i]*offset);
      marker->setLabel(T);
    }
    pairs_shown_ = true;
  }
  else {
    detachItems(QwtPlotItem::Rtti_PlotMarker);
    pairs_shown_ = false;
  }
  replot();
}
Esempio n. 5
0
void PlotWindow::drawLapMarkers()
{
	if (_data_log->numLaps() > 1)
	{
		for (int i=0; i < _data_log->numLaps(); ++i)
		{
			QwtPlotMarker* marker = new QwtPlotMarker;
			marker->setLineStyle(QwtPlotMarker::VLine);
			marker->setLinePen(QPen(Qt::DotLine));
			if (_x_axis_measurement->currentIndex() == 0) // time
			{
				const double time = _data_log->time(_data_log->lap(i).second);
				marker->setXValue(time);
			}
			else // distance
			{
				const double dist = _data_log->dist(_data_log->lap(i).second);
				marker->setXValue(dist);
			}
			marker->attach(_plot);
			marker->show();
			_lap_markers.push_back(marker);
		}
	}
}
DataPlot::DataPlot(QWidget *parent, TelemetryStateReceiver* collector, OdometryStateReceiver* odometryReceiver,QMap<QString, QStringList> *list) :
    QwtPlot(parent),
    d_interval(0),
    d_timerId(-1)
{
    node=collector;
    odom_receiver=odometryReceiver;
    connect_status=false;
    QObject::connect( node, SIGNAL( parameterReceived( )), this, SLOT( onParameterReceived( )));

    data_count=0;
    posicionBuffer=PLOT_SIZE;
    colors_list <<"red"<<"blue"<<"green"<<"black"<<"yellow"<<"magenta"<<"cyan"<<"gray"<<"darkCyan"<<"darkMagenta"<<"darkYellow"<<"darkGray"<<"darkRed"<<"darkBlue"<<"darkGreen"<<"lightGray" <<"red"<<"blue"<<"green"<<"black"<<"yellow"<<"magenta"<<"cyan"<<"gray"<<"darkCyan"<<"darkMagenta"<<"darkYellow"<<"darkGray"<<"darkRed"<<"darkBlue"<<"darkGreen"<<"lightGray" <<"red"<<"blue"<<"green"<<"black"<<"yellow"<<"magenta"<<"cyan"<<"gray"<<"darkCyan"<<"darkMagenta"<<"darkYellow"<<"darkGray"<<"darkRed"<<"darkBlue"<<"darkGreen"<<"lightGray" <<"red"<<"blue"<<"green"<<"black"<<"yellow"<<"magenta"<<"cyan"<<"gray"<<"darkCyan"<<"darkMagenta"<<"darkYellow"<<"darkGray"<<"darkRed"<<"darkBlue"<<"darkGreen"<<"lightGray";

    iterator_colors=0;
    is_stop_pressed=false;
    alignScales();
    setAutoReplot(false);

    parameters_list = setCurveLabels(*list);
    current_min_limit=0;
    current_max_limit=0;


    QwtPlotZoomer* zoomer = new MyZoomer(canvas());


    QwtPlotPanner *panner = new QwtPlotPanner(canvas());
    panner->setAxisEnabled(QwtPlot::yRight, true);
    panner->setMouseButton(Qt::MidButton);

    // Avoid jumping when labels with more/less digits
    // appear/disappear when scrolling vertically
    const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
    QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
    sd->setMinimumExtent( fm.width("100.00") );

    const QColor c(Qt::darkBlue);
    zoomer->setRubberBandPen(c);
    zoomer->setTrackerPen(c);

    setGridPlot();
    initTimeData();

#if 0
    //  Insert zero line at y = 0
    QwtPlotMarker *mY = new QwtPlotMarker();
    mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
    mY->setLineStyle(QwtPlotMarker::HLine);
    mY->setYValue(0.0);
    mY->attach(this);
#endif

    initAxisX();
    initAxisY();
    initCurves();

    setTimerInterval(1000);// 1 second = 1000
}
void SweepInspector::loadSweep(int index) {
  //load in new sweep values from data
  if (data == NULL) return;
  if ( (index < 0)  || (index >= data->getNumSweeps())) return;

  //remove old data and get new
  if (d_curve) d_curve->attach(NULL);
  detachItems();
  fsweep sweep = data->getSweep(index);

  d_curve = new QwtPlotCurve( data->timestampFromIndex(index) ); //Qwt will delete() this when its done with it
  d_curve->setRenderHint( QwtPlotItem::RenderAntialiased );
  d_curve->setStyle( QwtPlotCurve::Lines );
  d_curve->setPen( QColor( Qt::yellow ), 2, Qt::SolidLine );
  d_curve->setSamples( sweep );
  d_curve->attach(this);

  QwtInterval frange = data->limits(FREQ);
  //setAxisScale(QwtPlot::xBottom, frange.minValue(), frange.maxValue(), (frange.maxValue() - frange.minValue())/ 5.0);
  //setAxisScale(QwtPlot::yLeft, -135, 20, 10.0);
  setTitle( QString("RF Sweep @ %1").arg(data->timestampFromIndex(index)) );
  //set maximum zoom out
  zoomer->setZoomBase(QRectF(QPointF(frange.minValue(), 40), QPointF(frange.maxValue(), -135)));
  zoomer->zoomBase();

  //find max, min, and average values and drop it on plot as well
  double max = sweep.first().y(), min = sweep.first().y(), avg=0;
  for(int i=0; i < sweep.size(); i++) {
    max = std::max(max, sweep.at(i).y());
    min = std::min(min, sweep.at(i).y());
    avg += sweep.at(i).y();
  } avg /= sweep.size();

  //add markers onto the plot
  QwtPlotMarker *one = new QwtPlotMarker(), *two = new QwtPlotMarker();
  one->attach(this); one->setAxes(QwtPlot::xTop, QwtPlot::yRight);
  two->attach(this); two->setAxes(QwtPlot::xTop, QwtPlot::yRight);

  QwtText tone = QwtText(QString("Max: %1 dBm\nMin: %2 dBm\nAvg: %3 dBm").arg(max).arg(min).arg(avg));
  tone.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
  tone.setColor( Qt::green );
  tone.setRenderFlags(Qt::AlignTop | Qt::AlignLeft);

  one->setLabel(tone);
  one->setValue(0, 10);
  one->setLabelAlignment(Qt::AlignBottom | Qt::AlignRight);

  QwtText ttwo(data->plotText());
  ttwo.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
  ttwo.setColor( Qt::white );
  ttwo.setRenderFlags(Qt::AlignBottom | Qt::AlignRight);

  two->setLabel(ttwo);
  two->setValue(10, 10);
  two->setLabelAlignment(Qt::AlignBottom | Qt::AlignLeft);

  replot();
  repaint();
}
Esempio n. 8
0
File: wykres.cpp Progetto: maxbog/f1
void wykres::dodaj_naj(double d) {
    QwtPlotMarker *mY = new QwtPlotMarker();
    mY->setLabel(QString::fromLatin1("Osobnik najlepszy = ")+QString::number(-d));
    mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
    mY->setLineStyle(QwtPlotMarker::HLine);
    mY->setYValue(-d);
    mY->attach(this);
}
Esempio n. 9
0
void Plot_AddHLine(QwtPlot* plot, double value , double r , double g, double b)
{
    QwtPlotMarker *marker = new QwtPlotMarker();
    marker->setLineStyle ( QwtPlotMarker::HLine );
    marker->setLinePen(QPen(QColor(r, g, b, 128), 1, Qt::DashDotLine));
    marker->attach( plot );
    marker->setYValue( value );
}
Esempio n. 10
0
  /**
   * This is a helper method to create new band markers with the same line
   *   style and a custom color.
   *
   * @param color The color of the band marker
   * @return The requested plot marker; ownership is passed to the caller
   */
  QwtPlotMarker *SpectralPlotWindow::createMarker(QColor color) {
    QPen markerPen(color);
    markerPen.setWidth(1);

    QwtPlotMarker *newMarker = new QwtPlotMarker;
    newMarker->setLineStyle(QwtPlotMarker::LineStyle(2));
    newMarker->setLinePen(markerPen);
    newMarker->attach(plot());
    newMarker->setVisible(false);

    return newMarker;
  }
Esempio n. 11
0
/**
 * Dodaje dodatkowy opis wykresu.
 *
 * @param caption opis wykresu
 * @param x pozycja na wykresie w skali czasu
 * @param y pozycja na wykresie w skali pionowej (np. częstotliwości)
 */
void SpectrogramPlot::setExtraCaption(QString caption, double x, double y)
{
    QwtPlotMarker* marker = new QwtPlotMarker();
    QwtText label(caption);
    label.setColor(QColor::fromRgba(0x88FFFFFF));
    label.setFont(QFont("Arial", 10, QFont::Bold));
    marker->setLabel(label);
    marker->setLineStyle(QwtPlotMarker::NoLine);
    marker->setValue(x, y);
    marker->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom);
    marker->attach(this);
}
Esempio n. 12
0
void QgsCurveEditorWidget::addPlotMarker( double x, double y, bool isSelected )
{
  QColor borderColor( 0, 0, 0 );

  QColor brushColor = isSelected ? borderColor : QColor( 255, 255, 255, 0 );

  QwtPlotMarker *marker = new QwtPlotMarker();
  marker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,  QBrush( brushColor ), QPen( borderColor, isSelected ? 2 : 1 ), QSize( 8, 8 ) ) );
  marker->setValue( x, y );
  marker->attach( mPlot );
  marker->setRenderHint( QwtPlotItem::RenderAntialiased, true );
  mMarkers << marker;
}
Esempio n. 13
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. 14
0
void caStripPlot::addText(double x, double y, char* text, QColor c, int fontsize)
{
    QwtPlotMarker *mY = new QwtPlotMarker();
    QwtText txt;
    txt.setText(text);
    txt.setFont(QFont("Helvetica",fontsize, QFont::Bold));
    txt.setColor(c);
    mY->setLabel(txt);
    mY->setLabelAlignment(Qt::AlignRight | Qt::AlignTop);
    mY->setXValue(x);
    mY->setYValue(y);
    mY->attach(this);
    replot();
}
Esempio n. 15
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicGridStatisticsDialog::setMarkers(const Rim3dOverlayInfoConfig::HistogramData& histData, QwtPlot* plot)
{
    auto scale = plot->axisScaleDiv(QwtPlot::yLeft);

    QwtPlotMarker* marker;

    if (histData.p10 != HUGE_VAL)
    {
        marker = createVerticalPlotMarker(Qt::red, histData.p10);
        marker->attach(plot);
    }

    if (histData.p90 != HUGE_VAL)
    {
        marker = createVerticalPlotMarker(Qt::red, histData.p90);
        marker->attach(plot);
    }

    if (histData.mean != HUGE_VAL)
    {
        marker = createVerticalPlotMarker(Qt::blue, histData.mean);
        marker->attach(plot);
    }
}
Esempio n. 16
0
void QgsGradientColorRampDialog::addPlotMarker( double x, double y, const QColor &color, bool isSelected )
{
  QColor borderColor = color.darker( 200 );
  borderColor.setAlpha( 255 );

  QColor brushColor = color;
  brushColor.setAlpha( 255 );

  QwtPlotMarker *marker = new QwtPlotMarker();
  marker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,  QBrush( brushColor ), QPen( borderColor, isSelected ? 2 : 1 ), QSize( 8, 8 ) ) );
  marker->setValue( x, y );
  marker->attach( mPlot );
  marker->setRenderHint( QwtPlotItem::RenderAntialiased, true );
  mMarkers << marker;
}
Esempio n. 17
0
void MainWindow::setInitialTimeDisplay(int start)
{
    std::size_t ncols = _vm["file.ncols"].as<int>();
    std::size_t nrows = _vm["file.nrows"].as<int>();
    //TODO: move plotting to appropiate method
    std::size_t numofplottedsamples = _vm["plot.num.samples"].as<int>();
    _gridPlot->p->detachItems();
    _gridPlot->setoffset(start);

    double interrowoffset = _vm["inter.row.offset"].as<double>();

    for (std::size_t row=0; row<nrows; ++row){
//    for (std::size_t row=0; row<1; ++row){
        std::vector<double> xs(numofplottedsamples);
        std::vector<double> ys(numofplottedsamples);

        std::stringstream strst;
        std::string strTitle = "Row";
        strst << strTitle << "-" << row;
        strTitle = strst.str();
        QwtPlotCurve *tscurve = new QwtPlotCurve((char *)strTitle.c_str());

        for (std::size_t x = 0; x < numofplottedsamples; ++x)
        {
            if (x+start<ncols){
		    xs[x] = (x+start)/_gridPlot->gridXpixelsperunit; //position in seconds
		    if (_bf!=NULL) {
			    ys[x] = row*interrowoffset + (*_bf)(row,x+start)/_gridPlot->gridYpixelsperunit; //y value of that sample
		    } else if (_bfsi!=NULL) {
			    ys[x] = row*interrowoffset + (*_bfsi)(row,x+start)/_gridPlot->gridYpixelsperunit; //y value of that sample
		    }
            }
        }

        tscurve->setSamples(&xs[0],&ys[0],xs.size());
        tscurve->setPen(QPen(Qt::black));

        QwtPlotMarker *rowNameText = new QwtPlotMarker();
        rowNameText->setLabel(QString(strTitle.c_str()));
        rowNameText->setXValue(xs[0]+0.25);
        rowNameText->setYValue(row*interrowoffset-0.5);
        rowNameText->attach(_gridPlot->p);

        tscurve->attach(_gridPlot->p);
    }
    _gridPlot->resetzoom();
}
Esempio n. 18
0
void Graph::addMarker(double val, const QColor &color, int axis)
{
    QwtPlotMarker *m = new QwtPlotMarker();
    m->setLineStyle(axis == QwtPlot::xBottom ? QwtPlotMarker::VLine : QwtPlotMarker::HLine);
    m->setLinePen(QPen(color));
    m->setYAxis(axis);
    m->setValue(val, val);
    m->attach(this);
    m->setLabel(QString::number(val));

    if(axis == QwtPlot::xBottom)
        m->setLabelAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    else
        m->setLabelAlignment(Qt::AlignTop | Qt::AlignHCenter);

    getMarkers(axis).push_back(m);
}
Esempio n. 19
0
void QmitkTbssRoiAnalysisWidget::drawBar(int x)
{

  m_Plot->detachItems(QwtPlotItem::Rtti_PlotMarker, true);


  QwtPlotMarker *mX = new QwtPlotMarker();
  //mX->setLabel(QString::fromLatin1("selected point"));
  mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
  mX->setLabelOrientation(Qt::Vertical);
  mX->setLineStyle(QwtPlotMarker::VLine);
  mX->setLinePen(QPen(Qt::black, 0, Qt::SolidLine));
  mX->setXValue(x);
  mX->attach(m_Plot);


  this->Replot();

}
void QgsVectorGradientColorRampV2Dialog::addPlotMarker( double x, double y, const QColor& color, bool isSelected )
{
  QColor borderColor = color.darker( 200 );
  borderColor.setAlpha( 255 );

  QColor brushColor = color;
  brushColor.setAlpha( 255 );

  QwtPlotMarker *marker = new QwtPlotMarker();
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
  marker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,  QBrush( brushColor ), QPen( borderColor, isSelected ? 2 : 1 ), QSize( 10, 10 ) ) );
#else
  marker->setSymbol( QwtSymbol( QwtSymbol::Ellipse,  QBrush( brushColor ), QPen( borderColor, isSelected ? 2 : 1 ), QSize( 10, 10 ) ) );
#endif
  marker->setValue( x, y );
  marker->attach( mPlot );
  marker->setRenderHint( QwtPlotItem::RenderAntialiased, true );
  mMarkers << marker;
}
Esempio n. 21
0
void VectorPlot::addMarking(const std::vector<int> &marking)
{
	QwtDoubleRect boundingRect(0, 1, marking.size() - 1, 2);

	setupPlot(boundingRect);

	// this is gonna be slow...
	for(unsigned i = 0; i < marking.size(); ++i) {
		QwtPlotMarker* marker = new QwtPlotMarker();
		QwtText text;
		text.setText(QString::number(marking[i]));

		marker->setLabel(text);

		marker->setXValue((double)i);
		marker->setYValue(0.0);

		marker->attach(plot);
	}
}
Esempio n. 22
0
void VectorPlot::addHorizontalLine(double value, QString labelText)
{
	QPen pen(QColor(0, 0, 255));

	QwtPlotMarker* horizontalLineMarker = new QwtPlotMarker();
	horizontalLineMarker->setLineStyle(QwtPlotMarker::HLine);
	horizontalLineMarker->setLinePen(pen);
	horizontalLineMarker->setYValue(value);

	QwtText label;
	label.setText(labelText);
	QFont font = label.font();
	font.setPointSize(9);
	label.setFont(font);

	horizontalLineMarker->setLabel(label);
	horizontalLineMarker->setLabelAlignment(Qt::AlignTop | Qt::AlignLeft);

	horizontalLineMarker->attach(plot);
}
Esempio n. 23
0
File: psd.cpp Progetto: timqi/psd
Psd::Psd(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Psd)
{
    ui->setupUi(this);

    ui->plot->setTitle("原信号:cos(2*PI*40*i)+3*cos(2*PI*100*i)+w(n)");
    ui->plot->setAutoFillBackground( true );
    ui->plot->insertLegend( new QwtLegend(), QwtPlot::RightLegend );
    ui->plot->setAutoReplot( false );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setLineWidth( 1 );
    canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    canvas->setBorderRadius( 15 );

    QPalette canvasPalette( Qt::white );
    canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
    canvas->setPalette( canvasPalette );
    ui->plot->setCanvas( canvas );

    ( void ) new QwtPlotPanner( canvas );
    ( void ) new QwtPlotMagnifier( canvas );

    cSin->setRenderHint( QwtPlotItem::RenderAntialiased );
    cSin->setLegendAttribute( QwtPlotCurve::LegendShowLine, false );
    cSin->setPen( Qt::red );
    cSin->attach( ui->plot );

    QwtPlotMarker *mY = new QwtPlotMarker();
    mY->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
    mY->setLineStyle( QwtPlotMarker::HLine );
    mY->setYValue( 0.0 );
    mY->attach( ui->plot );

    init();
    pf();
    populate();
}
Esempio n. 24
0
void QgsHistogramWidget::drawHistogram()
{
  if ( !mVectorLayer || mSourceFieldExp.isEmpty() )
    return;

  QApplication::setOverrideCursor( Qt::WaitCursor );

  if ( mValues.empty() )
  {
    bool ok;
    mValues = mVectorLayer->getDoubleValues( mSourceFieldExp, ok );

    if ( ! ok )
    {
      QApplication::restoreOverrideCursor();
      return;
    }
    qSort( mValues.begin(), mValues.end() );
    mHistogram.setValues( mValues );
    mBinsSpinBox->blockSignals( true );
    mBinsSpinBox->setValue( qMax( mHistogram.optimalNumberBins(), 30 ) );
    mBinsSpinBox->blockSignals( false );

    mStats.setStatistics( QgsStatisticalSummary::StDev );
    mStats.calculate( mValues );
  }

  // clear plot
  mpPlot->detachItems();

  //ensure all children get removed
  mpPlot->setAutoDelete( true );
  // Set axis titles
  mpPlot->setAxisTitle( QwtPlot::xBottom, QObject::tr( "Value" ) );
  mpPlot->setAxisTitle( QwtPlot::yLeft, QObject::tr( "Count" ) );
  mpPlot->setAxisAutoScale( QwtPlot::yLeft );
  mpPlot->setAxisAutoScale( QwtPlot::xBottom );

  // add a grid
  QwtPlotGrid * grid = new QwtPlotGrid();
  grid->enableX( false );
  grid->setPen( mGridPen );
  grid->attach( mpPlot );

  // make colors list
  mHistoColors.clear();
  foreach ( QgsRendererRangeV2 range, mRanges )
  {
    mHistoColors << ( range.symbol() ? range.symbol()->color() : Qt::black );
  }

  //draw histogram
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
  QwtPlotHistogram * plotHistogram = 0;
  plotHistogram = createPlotHistogram( mRanges.count() > 0 ? mRanges.at( 0 ).label() : QString(),
                                       mRanges.count() > 0 ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
                                       mRanges.count() > 0 ? Qt::NoPen : mPen );
#else
  HistogramItem *plotHistogramItem = 0;
  plotHistogramItem = createHistoItem( mRanges.count() > 0 ? mRanges.at( 0 ).label() : QString(),
                                       mRanges.count() > 0 ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
                                       mRanges.count() > 0 ? Qt::NoPen : mPen );
#endif

#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
  QVector<QwtIntervalSample> dataHisto;
#else

  // we safely assume that QT>=4.0 (min version is 4.7), therefore QwtArray is a QVector, so don't set size here
  QwtArray<QwtDoubleInterval> intervalsHisto;
  QwtArray<double> valuesHisto;

#endif

  int bins = mBinsSpinBox->value();
  QList<double> edges = mHistogram.binEdges( bins );
  QList<int> counts = mHistogram.counts( bins );

  int rangeIndex = 0;
  int lastValue = 0;

  for ( int bin = 0; bin < bins; ++bin )
  {
    int binValue = counts.at( bin );

    //current bin crosses two graduated ranges, so we split between
    //two histogram items
    if ( rangeIndex < mRanges.count() - 1 && edges.at( bin ) > mRanges.at( rangeIndex ).upperValue() )
    {
      rangeIndex++;
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
      plotHistogram->setSamples( dataHisto );
      plotHistogram->attach( mpPlot );
      plotHistogram = createPlotHistogram( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
      dataHisto.clear();
      dataHisto << QwtIntervalSample( lastValue, mRanges.at( rangeIndex - 1 ).upperValue(), edges.at( bin ) );
#else
      plotHistogramItem->setData( QwtIntervalData( intervalsHisto, valuesHisto ) );
      plotHistogramItem->attach( mpPlot );
      plotHistogramItem = createHistoItem( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
      intervalsHisto.clear();
      valuesHisto.clear();
      intervalsHisto.append( QwtDoubleInterval( mRanges.at( rangeIndex - 1 ).upperValue(), edges.at( bin ) ) );
      valuesHisto.append( lastValue );
#endif
    }

    double upperEdge = mRanges.count() > 0 ? qMin( edges.at( bin + 1 ), mRanges.at( rangeIndex ).upperValue() )
                       : edges.at( bin + 1 );

#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
    dataHisto << QwtIntervalSample( binValue, edges.at( bin ), upperEdge );
#else
    intervalsHisto.append( QwtDoubleInterval( edges.at( bin ), upperEdge ) );
    valuesHisto.append( double( binValue ) );
#endif

    lastValue = binValue;
  }

#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
  plotHistogram->setSamples( dataHisto );
  plotHistogram->attach( mpPlot );
#else
  plotHistogramItem->setData( QwtIntervalData( intervalsHisto, valuesHisto ) );
  plotHistogramItem->attach( mpPlot );
#endif

  mRangeMarkers.clear();
  foreach ( QgsRendererRangeV2 range, mRanges )
  {
    QwtPlotMarker* rangeMarker = new QwtPlotMarker();
    rangeMarker->attach( mpPlot );
    rangeMarker->setLineStyle( QwtPlotMarker::VLine );
    rangeMarker->setXValue( range.upperValue() );
    rangeMarker->setLabel( QString::number( range.upperValue() ) );
    rangeMarker->setLabelOrientation( Qt::Vertical );
    rangeMarker->setLabelAlignment( Qt::AlignLeft | Qt::AlignTop );
    rangeMarker->show();
    mRangeMarkers << rangeMarker;
  }
Esempio n. 25
0
//
//  Initialize main window
//
DataPlot::DataPlot(QWidget *parent):
    QwtPlot(parent),
    d_interval(0),
    d_timerId(-1)
{
    // Disable polygon clipping
    QwtPainter::setDeviceClipping(false);

    // We don't need the cache here
    canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
    canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);

#if QT_VERSION >= 0x040000
#ifdef Q_WS_X11
    /*
       Qt::WA_PaintOnScreen is only supported for X11, but leads
       to substantial bugs with Qt 4.2.x/Windows
     */
    canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif
#endif

    alignScales();
    
    //  Initialize data
    for (int i = 0; i< PLOT_SIZE; i++)
    {
        d_x[i] = 0.5 * i;     // time axis
        d_y[i] = 0;
        d_z[i] = 0;
    }

    // Assign a title
    setTitle("A Test for High Refresh Rates");
    insertLegend(new QwtLegend(), QwtPlot::BottomLegend);

    // Insert new curves
    QwtPlotCurve *cRight = new QwtPlotCurve("Data Moving Right");
    cRight->attach(this);

    QwtPlotCurve *cLeft = new QwtPlotCurve("Data Moving Left");
    cLeft->attach(this);

    // Set curve styles
    cRight->setPen(QPen(Qt::red));
    cLeft->setPen(QPen(Qt::blue));

    // Attach (don't copy) data. Both curves use the same x array.
    cRight->setRawData(d_x, d_y, PLOT_SIZE);
    cLeft->setRawData(d_x, d_z, PLOT_SIZE);

#if 0
    //  Insert zero line at y = 0
    QwtPlotMarker *mY = new QwtPlotMarker();
    mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
    mY->setLineStyle(QwtPlotMarker::HLine);
    mY->setYValue(0.0);
    mY->attach(this);
#endif

    // Axis 
    setAxisTitle(QwtPlot::xBottom, "Time/seconds");
    setAxisScale(QwtPlot::xBottom, 0, 100);

    setAxisTitle(QwtPlot::yLeft, "Values");
    setAxisScale(QwtPlot::yLeft, -1.5, 1.5);
    
    setTimerInterval(0.0); 
}
Esempio n. 26
0
MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow),
  m_accelXPoints(100, QPointF(0, 0)), m_accelYPoints(100, QPointF(0, 0)),
  m_gyroXPoints(100, QPointF(0, 0)), m_gyroYPoints(100, QPointF(0, 0)),
  m_counter(0), m_power(0)
{
	ui->setupUi(this);

	// init scenes
	xScene = new QGraphicsScene();
	yScene = new QGraphicsScene();
	xScene->setBackgroundBrush(Qt::white);
	yScene->setBackgroundBrush(Qt::white);
	ui->xGraphicsView->setScene(xScene);
	ui->yGraphicsView->setScene(yScene);

	m_tcpSocket = new QTcpSocket(this);
	connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(onTcpRead()));

	m_controlSocket = new QTcpSocket(this);
	connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(onControlRead()));

	// connecting
	connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(connectToServer()));
	connect(ui->disconnectButton, SIGNAL(clicked()), this, SLOT(disconnectFromServer()));

	// control buttons
	connect(ui->up2Button, SIGNAL(clicked()), this, SLOT(handleControlButton()));
	connect(ui->up1Button, SIGNAL(clicked()), this, SLOT(handleControlButton()));
	connect(ui->zeroButton, SIGNAL(clicked()), this, SLOT(handleControlButton()));
	connect(ui->down1Button, SIGNAL(clicked()), this, SLOT(handleControlButton()));
	connect(ui->down2Button, SIGNAL(clicked()), this, SLOT(handleControlButton()));

	// plotting setup
	m_accelXData = new QwtPointSeriesData();
	m_accelYData = new QwtPointSeriesData();
	m_accelXCurve = new QwtPlotCurve("Accel X");
	m_accelYCurve = new QwtPlotCurve("Accel Y");
	m_accelXCurve->setPen( QPen( Qt::black ) );
	m_accelYCurve->setPen( QPen( Qt::red));
	m_accelXCurve->attach( ui->plot );
	m_accelYCurve->attach(ui->plot);

	m_gyroXData = new QwtPointSeriesData();
	m_gyroYData = new QwtPointSeriesData();
	m_gyroXCurve = new QwtPlotCurve("Gyro X");
	m_gyroYCurve = new QwtPlotCurve("Gyro Y");
	m_gyroXCurve->setPen( QPen( Qt::green ) );
	m_gyroYCurve->setPen( QPen( Qt::blue));
	m_gyroXCurve->attach( ui->plot );
	m_gyroYCurve->attach(ui->plot);

	ui->plot->setCanvasBackground(Qt::white);
	// Axes
	ui->plot->setAxisTitle( QwtPlot::xBottom, "Seconds" );
	ui->plot->setAxisTitle( QwtPlot::yLeft, "Degrees" );
	ui->plot->setAxisScale( QwtPlot::yLeft, -90, 90 );

	// zero line
	QwtPlotMarker* zeroMarker = new QwtPlotMarker();
	zeroMarker->setLineStyle(QwtPlotMarker::HLine);
	zeroMarker->setLinePen(QPen(Qt::DotLine));
	zeroMarker->setSymbol(new QwtSymbol(QwtSymbol::HLine));
	zeroMarker->setYValue(0);
	zeroMarker->attach(ui->plot);

	updatePlot(0, 0, 0, 0);
}
Esempio n. 27
0
/*!
  * Initializes the Main Window
  */
DataPlot::DataPlot(QWidget *parent):
    QwtPlot(parent),
    d_interval(0),
    d_timerId(-1),
    min(0),
    max(10)



{

    id = 0;
    plotAccx = plotAccy = plotMgx = plotMgy = plotTemp = plotMic = plotVl = plotIr = true;
    auto_scale = false;
    filter = new dataFilter();

    for(int i = 0; i < 8; i++)
        attached[i] = true;
    // Disable polygon clipping
    QwtPainter::setDeviceClipping(false);
    running = false;
    // We don't need the cache here
    canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
    canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);

#if QT_VERSION >= 0x040000
#ifdef Q_WS_X11
    /*
       Qt::WA_PaintOnScreen is only supported for X11, but leads
       to substantial bugs with Qt 4.2.x/Windows
     */
    canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif
#endif

    alignScales();
    
    //  Initialize data
    for (int i = 0; i< PLOT_SIZE; i++)
    {
        d_x[i] = 0.5 * i;     // time axis
        d_mgx[i] = 0;
        d_mgy[i] = 0;
        d_accx[i] = 0;
        d_accy[i] = 0;
        d_mic[i] = 0;
        d_ir[i] = 0;
        d_temp[i] = 0;
    }


    // Assign a title
    setTitle(QString("Sensors for Node %1").arg(id));
    insertLegend(new QwtLegend(), QwtPlot::BottomLegend);

    // Insert new curves
    mgxPlot = new QwtPlotCurve("MGx");
    //mgxFilteredPlot = new QwtPlotCurve("Filtered MGx");

    mgyPlot = new QwtPlotCurve("MGy");
    //mgyPlot = new QwtPlotCurve("Moving Average");

    AccyPlot = new QwtPlotCurve("ACCy");
    //AccyPlot = new QwtPlotCurve("e");

    AccxPlot = new QwtPlotCurve("ACCx");
    tempPlot = new QwtPlotCurve("Temp");
    irPlot = new QwtPlotCurve("IR");
    micPlot = new QwtPlotCurve("MIC");
    vlPlot = new QwtPlotCurve("VL");

    AccyPlot->attach(this);
    AccxPlot->attach(this);
    mgxPlot->attach(this);
    //mgxFilteredPlot->attach(this);
    mgyPlot->attach(this);
    tempPlot->attach(this);
    irPlot->attach(this);
    micPlot->attach(this);
    vlPlot->attach(this);

    const QColor bgColor(255,255,255);
#if QT_VERSION < 0x040000
    setPaletteBackgroundColor(bgColor);
#else
    QPalette p = palette();
    p.setColor(backgroundRole(), bgColor);
    setPalette(p);
#endif

    //! \todo Change line thickness
    // Set curve styles

    QPen *pen = new QPen(Qt::darkBlue);
    pen->setWidth(2);
    mgxPlot->setPen(*pen);

    QwtSplineCurveFitter *f = new QwtSplineCurveFitter();
    f->setFitMode(QwtSplineCurveFitter::Spline);
    mgxPlot->setCurveFitter(f);

    pen->setColor(Qt::darkMagenta);
    //mgxFilteredPlot->setPen(*pen);

    pen->setColor(Qt::red);
    mgyPlot->setPen(*pen);
    mgyPlot->setCurveFitter(f);

    pen->setColor(Qt::green);
    AccyPlot->setPen(*pen);
    AccyPlot->setCurveFitter(f);

    pen->setColor(Qt::darkGray);
    AccxPlot->setPen(*pen);
    AccxPlot->setCurveFitter(f);

    pen->setColor(Qt::yellow);
    tempPlot->setPen(*pen);
    tempPlot->setCurveFitter(f);

    pen->setColor(Qt::darkGreen);
    irPlot->setPen(*pen);
    irPlot->setCurveFitter(f);

    pen->setColor(Qt::magenta);
    micPlot->setPen(*pen);
    micPlot->setCurveFitter(f);

    pen->setColor(Qt::darkRed);
    vlPlot->setPen(*pen);
    vlPlot->setCurveFitter(f);

    // Attach (don't copy) data. Both curves use the same x array.
    mgxPlot->setRawData(d_x, d_mgx, PLOT_SIZE);
//    mgxFilteredPlot->setRawData(d_x, d_fmgx, PLOT_SIZE);
    mgyPlot->setRawData(d_x, d_mgy, PLOT_SIZE);
    AccyPlot->setRawData(d_x, d_accy, PLOT_SIZE);
    AccxPlot->setRawData(d_x, d_accx, PLOT_SIZE);
    tempPlot->setRawData(d_x, d_temp, PLOT_SIZE);
    irPlot->setRawData(d_x, d_ir, PLOT_SIZE);
    micPlot->setRawData(d_x, d_mic, PLOT_SIZE);
    vlPlot->setRawData(d_x, d_vl, PLOT_SIZE);

#if 0
    //  Insert zero line at y = 0
    QwtPlotMarker *mY = new QwtPlotMarker();
    mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
    mY->setLineStyle(QwtPlotMarker::HLine);
    mY->setYValue(0.0);
    mY->attach(this);
#endif

    // Axis 
    setAxisTitle(QwtPlot::xBottom, "Time/seconds");
    setAxisScale(QwtPlot::xBottom, 0, 100);

    setAxisTitle(QwtPlot::yLeft, "Values");
    setAxisScale(QwtPlot::yLeft, 0, 10);
    
    setTimerInterval(0.0); 
}
Esempio n. 28
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. 29
0
Plot::Plot(QWidget *parent):
    QwtPlot( parent )
{
    setAutoFillBackground( true );
    setPalette( QPalette( QColor( 165, 193, 228 ) ) );
    updateGradient();

    setTitle( "График аппроксимации" );
    insertLegend( new QwtLegend(), QwtPlot::RightLegend );

    // axes
    setAxisTitle( xBottom, "" );
    setAxisScale( xBottom, 0.0, 10.0 );

    setAxisTitle( yLeft, "Функция принадлежности -->" );
    setAxisScale( yLeft, 0, 2 );

    // canvas
    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setLineWidth( 1 );
    canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    canvas->setBorderRadius( 15 );

    QPalette canvasPalette( Qt::white );
    canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
    canvas->setPalette( canvasPalette );

    setCanvas( canvas );

    // panning with the left mouse button
    ( void ) new QwtPlotPanner( canvas );

    // zoom in/out with the wheel
    ( void ) new QwtPlotMagnifier( canvas );

    //  ...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 horizontal line at y = 1...
    QwtPlotMarker *mY1 = new QwtPlotMarker();
    mY1->setLabel( QString::fromLatin1( "y = 1" ) );
    mY1->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
    mY1->setLineStyle( QwtPlotMarker::HLine );
    mY1->setYValue( 1.0 );
    mY1->setLinePen(Qt::black, 1, Qt::DashLine);
    mY1->attach( this );

    //  ...a vertical line at x = 0
    QwtPlotMarker *mX = new QwtPlotMarker();
    mX->setLabel( QString::fromLatin1( "x = 0" ) );
    mX->setLabelAlignment( Qt::AlignLeft | Qt::AlignBottom );
    mX->setLabelOrientation( Qt::Vertical );
    mX->setLineStyle( QwtPlotMarker::VLine );
    mX->setLinePen( Qt::black, 0, Qt::DashDotLine );
    mX->setXValue( 0 );
    mX->attach( this );

//    curvePoints = new QwtPlotCurve();
//    curvePoints->setStyle( QwtPlotCurve::Dots );
//    curvePoints->attach( this );
}
Esempio n. 30
0
void Plot::populate()
{
    GridItem *gridItem = new GridItem();
#if 0
    gridItem->setOrientations( Qt::Horizontal );
#endif
    gridItem->attach( this );

    const Qt::GlobalColor colors[] =
    {
        Qt::red,
        Qt::blue,
        Qt::darkCyan,
        Qt::darkMagenta,
        Qt::darkYellow
    };

    const int numColors = sizeof( colors ) / sizeof( colors[0] );

    for ( int i = 0; i < QuoteFactory::NumStocks; i++ )
    {
        QuoteFactory::Stock stock = static_cast<QuoteFactory::Stock>( i );

        QwtPlotTradingCurve *curve = new QwtPlotTradingCurve();
        curve->setTitle( QuoteFactory::title( stock ) );
        curve->setOrientation( Qt::Vertical );
        curve->setSamples( QuoteFactory::samples2010( stock ) );

        // as we have one sample per day a symbol width of
        // 12h avoids overlapping symbols. We also bound
        // the width, so that is is not scaled below 3 and
        // above 15 pixels.

        curve->setSymbolExtent( 12 * 3600 * 1000.0 );
        curve->setMinSymbolWidth( 3 );
        curve->setMaxSymbolWidth( 15 );

        const Qt::GlobalColor color = colors[ i % numColors ];

        curve->setSymbolPen( color );
        curve->setSymbolBrush( QwtPlotTradingCurve::Decreasing, color );
        curve->setSymbolBrush( QwtPlotTradingCurve::Increasing, Qt::white );
        curve->attach( this );

        showItem( curve, true );
    }

    for ( int i = 0; i < 2; i++ )
    {
        QwtPlotMarker *marker = new QwtPlotMarker();

        marker->setTitle( QString( "Event %1" ).arg( i + 1 ) );
        marker->setLineStyle( QwtPlotMarker::VLine );
        marker->setLinePen( colors[ i % numColors ], 0, Qt::DashLine );
        marker->setVisible( false );

        QDateTime dt( QDate( 2010, 1, 1 ) );
        dt = dt.addDays( 77 * ( i + 1 ) );
        
        marker->setValue( QwtDate::toDouble( dt ), 0.0 );

        marker->setItemAttribute( QwtPlotItem::Legend, true );

        marker->attach( this );
    }

    // to show how QwtPlotZoneItem works

    ZoneItem *zone1 = new ZoneItem( "Zone 1");
    zone1->setColor( Qt::darkBlue );
    zone1->setInterval( QDate( 2010, 3, 10 ), QDate( 2010, 3, 27 ) );
    zone1->setVisible( false );
    zone1->attach( this );

    ZoneItem *zone2 = new ZoneItem( "Zone 2");
    zone2->setColor( Qt::darkMagenta );
    zone2->setInterval( QDate( 2010, 8, 1 ), QDate( 2010, 8, 24 ) );
    zone2->setVisible( false );
    zone2->attach( this );

}