plotter::plotter(QWidget *parent) : QWidget(parent) { curve.setSymbol(new QwtSymbol(QwtSymbol::Ellipse, Qt::yellow, QPen(Qt::blue), QSize(2, 2) ) ); curve.setPen(QColor(Qt::red)); curve.setStyle(QwtPlotCurve::Sticks); plot.setFixedHeight(200); // plot.setTitle("Distribution of recognized sequences"); curve.setRenderHint(QwtPlotItem::RenderAntialiased); curve.attach(&plot); QwtPlotZoomer* zoomer = new QwtPlotZoomer(plot.canvas()); zoomer->setRubberBandPen( QColor(Qt::black)); zoomer->setTrackerPen( QColor( Qt::black ) ); zoomer->setTrackerMode(QwtPlotZoomer::AlwaysOn); zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier ); zoomer->setMousePattern( QwtEventPattern::MouseSelect3, Qt::RightButton ); layout = new QVBoxLayout; layout->addWidget(&plot); this->setLayout(layout); }
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 }
Plot::Plot( QWidget *parent ): QwtPlot( parent ), d_formatType( 0 ), d_alpha(255) { d_spectrogram = new QwtPlotSpectrogram(); d_spectrogram->setRenderThreadCount( 0 ); // use system specific thread count d_spectrogram->setCachePolicy( QwtPlotRasterItem::PaintCache ); QList<double> contourLevels; for ( double level = 0.5; level < 10.0; level += 1.0 ) contourLevels += level; d_spectrogram->setContourLevels( contourLevels ); d_spectrogram->setData( new SpectrogramData() ); d_spectrogram->attach( this ); const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis ); // A color bar on the right axis QwtScaleWidget *rightAxis = axisWidget( QwtPlot::yRight ); rightAxis->setTitle( "Intensity" ); rightAxis->setColorBarEnabled( true ); setAxisScale( QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() ); enableAxis( QwtPlot::yRight ); plotLayout()->setAlignCanvasToScales( true ); setColorMap( Plot::RGBMap ); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size QwtPlotZoomer* zoomer = new MyZoomer( canvas() ); zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier ); zoomer->setMousePattern( QwtEventPattern::MouseSelect3, Qt::RightButton ); QwtPlotPanner *panner = new QwtPlotPanner( canvas() ); panner->setAxisEnabled( QwtPlot::yRight, false ); 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 ); }
Plot::Plot( QWidget *parent ): QwtPlot( parent ) { setObjectName( "FriedbergPlot" ); setTitle( "Temperature of Friedberg/Germany" ); setAxisTitle( QwtPlot::xBottom, "2007" ); setAxisScaleDiv( QwtPlot::xBottom, yearScaleDiv() ); setAxisScaleDraw( QwtPlot::xBottom, new YearScaleDraw() ); setAxisTitle( QwtPlot::yLeft, QString( "Temperature [%1C]" ).arg( QChar( 0x00B0 ) ) ); // grid QwtPlotGrid *grid = new Grid; grid->attach( this ); insertLegend( new QwtLegend(), QwtPlot::RightLegend ); const int numDays = 365; QVector<QPointF> averageData( numDays ); QVector<QwtIntervalSample> rangeData( numDays ); for ( int i = 0; i < numDays; i++ ) { const Temperature &t = friedberg2007[i]; averageData[i] = QPointF( double( i ), t.averageValue ); rangeData[i] = QwtIntervalSample( double( i ), QwtInterval( t.minValue, t.maxValue ) ); } insertCurve( "Average", averageData, Qt::black ); insertErrorBars( "Range", rangeData, Qt::blue ); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size QwtPlotZoomer* zoomer = new QwtPlotZoomer( canvas() ); zoomer->setRubberBandPen( QColor( Qt::black ) ); zoomer->setTrackerPen( QColor( Qt::black ) ); zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier ); zoomer->setMousePattern( QwtEventPattern::MouseSelect3, Qt::RightButton ); QwtPlotPanner *panner = new QwtPlotPanner( canvas() ); panner->setMouseButton( Qt::MidButton ); canvas()->setPalette( Qt::darkGray ); canvas()->setBorderRadius( 10 ); }
int qfit::setupGui() { // if(QApplication::arguments().size() > 1) // filePath->setText(QApplication::arguments().at(1)); if(QApplication::argc() == 2) { filePath->setText(QApplication::argv()[1]); } selectFit->addItem(tr("Fit Linear"));/*TODO add once are available in FitTools selectFit->addItem(tr("Fit Slope")); selectFit->addItem(tr("Fit Horizontal")); selectFit->addItem(tr("Fit Exponential")); selectFit->addItem(tr("Fit Logarithmic"));*/ #ifdef Qwt6_FOUND // plot stuff // panning with the middle mouse button QwtPlotPanner *panner = new QwtPlotPanner(qwtPlot->canvas()); panner->setMouseButton(Qt::MidButton); // zoom in/out with the wheel (void) new QwtPlotMagnifier(qwtPlot->canvas()); // zoom an area with left button QwtPlotZoomer *zoomer = new QwtPlotZoomer(qwtPlot->canvas()); zoomer->setRubberBandPen(QColor(Qt::black)); zoomer->setTrackerPen(QColor(Qt::black)); zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); // canvas qwtPlot->canvas()->setLineWidth(1); qwtPlot->canvas()->setFrameStyle(QFrame::Box | QFrame::Plain); qwtPlot->canvas()->setBorderRadius(10); qwtPlot->canvas()->setPalette(Qt::darkGray); //grid QwtPlotGrid *grid = new QwtPlotGrid(); grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine)); // grid->setMinPen(QPen(Qt::gray, 0, Qt::DotLine)); grid->attach(qwtPlot); #endif // tooltips infoButton->setToolTip(trUtf8("About")); openFileButton->setToolTip(trUtf8("Open file")); selectFit->setToolTip(trUtf8("Fit typology")); startFit->setToolTip(trUtf8("GO!")); cleanLogButton->setToolTip(trUtf8("Clear log")); #ifdef Qwt6_FOUND savePlotButton->setToolTip(trUtf8("Save plot")); #endif return(0); }
Curve::Curve(int device_port, int ele_max,QColor color, QWidget *parent) : QwtPlot(parent),device_port(device_port),color(color),ele_max(ele_max) { reset(); setObjectName(tr("%1-%2 Real-Eletric").arg(device_port)); setTitle(tr("实时电流")); setAxisTitle(QwtPlot::xBottom,"时间(s)"); setAxisTitle(QwtPlot::yLeft,tr("电流(A)")); setAxisScale(QwtPlot::xBottom,x_min,x_max); setAxisScale(QwtPlot::yLeft,0.0,50.0); QwtPlotCanvas *canvas = new QwtPlotCanvas; canvas->setPalette(QColor("#404040")); canvas->setBorderRadius(10); canvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator); setCanvas(canvas); insertLegend(new QwtLegend(),QwtPlot::RightLegend); QwtPlotZoomer *zoomer = new QwtPlotZoomer(canvas); zoomer->setRubberBandPen(QPen(QColor(Qt::red),1)); zoomer->setTrackerPen(QColor(Qt::red)); zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,Qt::ControlModifier); zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); QwtPlotPanner *panner = new QwtPlotPanner(canvas); panner->setMouseButton(Qt::MidButton); panner->setCursor(Qt::OpenHandCursor); panner->setEnabled(true); panner->setAxisEnabled(QwtPlot::yLeft,false); connect(panner,SIGNAL(panned(int,int)),this,SLOT(get_coord(int,int))); new QwtPlotMagnifier(this->canvas()); QwtPlotPicker *m_picker = new QwtPlotPicker( QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::HLineRubberBand , QwtPicker::AlwaysOn, this->canvas() ); m_picker->setTrackerPen(QPen(Qt::red,1)); QFont font; font.setPixelSize(15); m_picker->setTrackerFont(font); d_curve = new QwtPlotCurve(tr("支路%1").arg(device_port)); d_curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,Qt::blue,QPen(Qt::blue),QSize(5,5))); d_curve->setStyle(QwtPlotCurve::Lines); d_curve->setCurveAttribute( QwtPlotCurve::Fitted ); d_curve->setPen(QPen(Qt::magenta)); d_curve->setRenderHint(QwtPlotItem::RenderAntialiased,true); d_curve->attach(this); d_curve_Max = new QwtPlotCurve(tr("最大值")); d_curve_Max->setStyle(QwtPlotCurve::Lines); d_curve_Max->setCurveAttribute(QwtPlotCurve::Fitted); d_curve_Max->setPen(QPen(Qt::red)); d_curve_Max->setRenderHint(QwtPlotItem::RenderAntialiased,true); d_curve_Max->attach(this); }
Plot::Plot(QWidget *parent): QwtPlot(parent) { d_spectrogram = new QwtPlotSpectrogram(); QwtLinearColorMap colorMap(Qt::darkCyan, Qt::red); colorMap.addColorStop(0.1, Qt::cyan); colorMap.addColorStop(0.6, Qt::green); colorMap.addColorStop(0.95, Qt::yellow); d_spectrogram->setColorMap(colorMap); d_spectrogram->setData(SpectrogramData()); d_spectrogram->attach(this); QwtValueList contourLevels; for ( double level = 0.5; level < 10.0; level += 1.0 ) contourLevels += level; d_spectrogram->setContourLevels(contourLevels); QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight); rightAxis->setTitle("Intensity"); rightAxis->setColorBarEnabled(true); rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap()); setAxisScale(QwtPlot::yRight, d_spectrogram->data().range().minValue(), d_spectrogram->data().range().maxValue() ); enableAxis(QwtPlot::yRight); plotLayout()->setAlignCanvasToScales(true); replot(); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size QwtPlotZoomer* zoomer = new QwtPlotZoomer(canvas()); #if QT_VERSION < 0x040000 zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton); #else zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); #endif zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); QwtPlotPanner *panner = new QwtPlotPanner(canvas()); panner->setAxisEnabled(QwtPlot::yRight, false); 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); }
PlotForm::PlotForm() { m_data[0] = 0; m_data[1] = 0; m_data[2] = 0; m_data_len = 0; x_axis_type = 0; widget.setupUi(this); curve[0].setColor(Qt::yellow); curve[0].attach(widget.qwtPlot); curve[0].setVisible(true); curve[1].setColor(Qt::green); curve[1].attach(widget.qwtPlot); curve[1].setVisible(true); setDataLen(512); noise(); // grid QwtPlotGrid *grid = new QwtPlotGrid(); grid->enableXMin(true); grid->setMajorPen(QPen(Qt::white, 0, Qt::DotLine)); grid->setMinorPen(QPen(Qt::gray, 0 , Qt::DotLine)); grid->attach(widget.qwtPlot); //scale widget.qwtPlot->setCanvasBackground(QColor(Qt::black)); QwtPlotPicker *d_picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, widget.qwtPlot->canvas()); d_picker->setStateMachine(new QwtPickerDragPointMachine()); d_picker->setRubberBandPen(QColor(Qt::green)); d_picker->setRubberBand(QwtPicker::CrossRubberBand); d_picker->setTrackerPen(QColor(Qt::green)); QwtPlotZoomer* zoomer = new QwtPlotZoomer( widget.qwtPlot->canvas() ); zoomer->setRubberBandPen( QColor( Qt::white ) ); zoomer->setTrackerPen( QColor( Qt::white ) ); zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier ); zoomer->setMousePattern( QwtEventPattern::MouseSelect3, Qt::RightButton ); mr_center.setLineStyle(QwtPlotMarker::VLine); mr_center.setLinePen(QPen(Qt::darkRed, 0, Qt::SolidLine)); mr_center.setXValue(840.0); mr_center.attach(widget.qwtPlot); mr_center.setVisible(false); mr_left.setLineStyle(QwtPlotMarker::VLine); mr_left.setLinePen(QPen(Qt::darkRed, 0, Qt::DotLine)); mr_left.setXValue(830.0); mr_left.attach(widget.qwtPlot); mr_left.setVisible(false); mr_right.setLineStyle(QwtPlotMarker::VLine); mr_right.setLinePen(QPen(Qt::darkRed, 0, Qt::DotLine)); mr_right.setXValue(850.0); mr_right.attach(widget.qwtPlot); mr_right.setVisible(false); QwtPlotPanner *panner = new QwtPlotPanner( widget.qwtPlot->canvas() ); panner->setMouseButton( Qt::MidButton ); widget.qwtPlot->plotLayout()->setAlignCanvasToScales(true); dvalidator = new QDoubleValidator(); widget.leMin->setValidator(dvalidator); widget.leMax->setValidator(dvalidator); connect(widget.btnYAxisLog, SIGNAL(clicked(bool)), this, SLOT(setScaleEngineY(bool))); connect(widget.btnAutoScale, SIGNAL(clicked(bool)), this, SLOT(setAutoScale(bool))); connect(widget.btnSave, SIGNAL(clicked()), this, SLOT(save())); connect(widget.btnZoomIn , SIGNAL(clicked()), this, SLOT(zoomIn ())); connect(widget.btnZoomOut, SIGNAL(clicked()), this, SLOT(zoomOut())); // connect(widget.leMin, SIGNAL(valueChanged(double)), this, SLOT(rescale(double))); // connect(widget.leMax, SIGNAL(valueChanged(double)), this, SLOT(rescale(double))); }
Plot::Plot(QWidget *parent): QwtPlot(parent), d_origin(0), d_grid(0), d_marker(0), mStopped(true), mAxisSyncRequired(false), mColorMode(0), mTimeWindow(10.0), mAlignMode(RIGHT) { setAutoReplot(false); // The backing store is important, when working with widget // overlays ( f.e rubberbands for zooming ). // Here we don't have them and the internal // backing store of QWidget is good enough. QwtPlotCanvas* plotCanvas = qobject_cast<QwtPlotCanvas*>(canvas()); plotCanvas->setPaintAttribute(QwtPlotCanvas::BackingStore, false); #if defined(Q_WS_X11) // Even if not recommended by TrollTech, Qt::WA_PaintOutsidePaintEvent // works on X11. This has a nice effect on the performance. plotCanvas->setAttribute(Qt::WA_PaintOutsidePaintEvent, true); // Disabling the backing store of Qt improves the performance // for the direct painter even more, but the canvas becomes // a native window of the window system, receiving paint events // for resize and expose operations. Those might be expensive // when there are many points and the backing store of // the canvas is disabled. So in this application // we better don't both backing stores. if ( plotCanvas->testPaintAttribute( QwtPlotCanvas::BackingStore ) ) { plotCanvas->setAttribute(Qt::WA_PaintOnScreen, true); plotCanvas->setAttribute(Qt::WA_NoSystemBackground, true); } #endif plotLayout()->setAlignCanvasToScales(true); setAxisAutoScale(QwtPlot::xBottom, false); setAxisAutoScale(QwtPlot::yLeft, false); setAxisTitle(QwtPlot::xBottom, "Time [s]"); setAxisScale(QwtPlot::xBottom, 0, 10); setAxisScale(QwtPlot::yLeft, -4.0, 4.0); setAxisScaleDraw(QwtPlot::xBottom, new MyScaleDraw); initBackground(); QwtPlotZoomer* zoomer = new MyZoomer(this); zoomer->setMousePattern(QwtEventPattern::QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier); // disable MouseSelect3 action of the zoomer zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton); MyPanner *panner = new MyPanner(this); // zoom in/out with the wheel mMagnifier = new MyMagnifier(this); mMagnifier->setMouseButton(Qt::MiddleButton); const QColor c(Qt::darkBlue); zoomer->setRubberBandPen(c); zoomer->setTrackerPen(c); this->setMinimumHeight(200); }