Example #1
1
void Plot::initTools()
{
    QwtPlotZoomer* zoomer = new QwtPlotZoomer(QwtPlot::xBottom,QwtPlot::yLeft,this->canvas());
    // QwtPlotPicker* picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
    //     QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,this->canvas());
    zoomer->setTrackerMode(QwtPicker::AlwaysOn);
}
Example #2
1
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
}
Example #4
0
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 );
}
Example #5
0
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 );
}
Example #6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
//-----------------------------------------------------
    vBox = new QWidget;
    vBox->setWindowTitle( "Графік температури" );
    TempPlot *plot = new TempPlot;
    plot->setParent(this);
    plot->setTitle( "Графік температури" );
    QwtPlotGrid *grid;
    grid = new QwtPlotGrid;
    grid->enableXMin(true);
    grid->setMajorPen(QPen(Qt::gray,0,Qt::DashLine));
    grid->setMinorPen((QPen(Qt::gray,0,Qt::DotLine)));
    grid->attach(plot);
    QwtPlotZoomer *zoom;
    zoom = new QwtPlotZoomer(plot->canvas());
    zoom->setRubberBandPen(QPen(Qt::white));
    const int margin = 1;
    plot->setContentsMargins( margin, margin, margin, margin );
    QVBoxLayout *layout = new QVBoxLayout( vBox );
    layout->addWidget( plot );
    vBox->resize( 650, 330);
//-----------------------------------------------------
    vBox2 = new QWidget;
    vBox2->setWindowTitle( "Графік рівня радіосигналу");
    RssiPlot *plot2 = new RssiPlot;
    plot2->setParent(this);
    plot2->setTitle( "Графік рівня радіосигналу" );
    QwtPlotGrid *grid2;
    grid2 = new QwtPlotGrid;
    grid2->enableXMin(true);
    grid2->setMajorPen(QPen(Qt::gray,0,Qt::DashLine));
    grid2->setMinorPen((QPen(Qt::gray,0,Qt::DotLine)));
    grid2->attach(plot2);
    QwtPlotZoomer *zoom2;
    zoom2 = new QwtPlotZoomer(plot2->canvas());
    zoom2->setRubberBandPen(QPen(Qt::white));
    const int margin2 = 1;
    plot2->setContentsMargins( margin2, margin2, margin2, margin2 );
    QVBoxLayout *layout2 = new QVBoxLayout( vBox2 );
    layout2->addWidget( plot2 );
    vBox2->resize( 650, 330 );
//-----------------------------------------------------
    timer = new QTimer(this);
    serial = new QSerialPort(this);
    QString str;
    foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts()) {
        str=serialPortInfo.portName();
        ui->comboBox_2->addItem(str);
    }
Example #7
0
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);
}
Example #8
0
//---------------------------------------------------------------------------
void Plots::Zoom_Move(size_t Begin)
{
    size_t Increment=Data_FramePos_Max/ZoomScale;
    if (Begin+Increment>Data_FramePos_Max)
        Begin=Data_FramePos_Max-Increment;

    Zoom_Left=FileInfoData->Videos[0]->x[XAxis_Kind_index][Begin];
    Zoom_Width=FileInfoData->Videos[0]->x_Max[XAxis_Kind_index]/ZoomScale;

    for (size_t Type=0; Type<PlotType_Max; Type++)
        if (plots[Type])
        {
            QwtPlotZoomer* zoomer = new QwtPlotZoomer(plots[Type]->canvas());
            QRectF Rect=zoomer->zoomBase();
            Rect.setLeft(Zoom_Left);
            Rect.setWidth(Zoom_Width);
            zoomer->zoom(Rect);
            delete zoomer;
        }
}
Example #9
0
Graph::Graph(QWidget *parent) : QwtPlot(parent)
{
    // zoom in/out with the wheel
    Magnifier *magnifier = new Magnifier( canvas() );
    magnifier->setMouseButton(Qt::NoButton);

    // panning with the left mouse button
    Panner *panner =  new Panner( canvas() );
    panner->setMouseButton(Qt::LeftButton);

    // zooming with middle button
    QwtPlotZoomer *zoomer = new QwtPlotZoomer(canvas());
    {
        QVector<QwtEventPattern::MousePattern> pattern(6);
        pattern[0].button = Qt::MiddleButton;
        zoomer->setMousePattern(pattern);
    }

    m_grid = new QwtPlotGrid();
    m_grid->setMinorPen(QPen(Qt::gray, 0.0, Qt::DotLine));
    m_grid->setMajorPen(QPen(Qt::black, 0.0, Qt::DotLine));
    m_grid->enableX(true);
    m_grid->enableXMin(true);
    m_grid->enableY(true);
    m_grid->enableYMin(true);
    m_grid->attach(this);

    initLegend();

    connect(axisWidget(QwtPlot::xBottom), SIGNAL(scaleDivChanged()), SIGNAL(updateSampleSize()));

    setAxisScale(QwtPlot::xBottom, -20, 20);
    setAxisScale(QwtPlot::yRight, -20, 20);
    setAxisScale(QwtPlot::yLeft, -20, 20);
    axisWidget(QwtPlot::xBottom)->setToolTip(tr("Double-click to add marker"));
    axisWidget(QwtPlot::yLeft)->setToolTip(tr("Double-click to add marker"));
    axisWidget(QwtPlot::yRight)->setToolTip(tr("Double-click to add marker"));

    // to show graph appearance while dragging from add button to widget area
    replot();
}
Example #10
0
Graph::Graph(QWidget* parent):
        QMainWindow(parent)
{

    layout = new QHBoxLayout(this);
    title = "Graphic";
    plot = new QwtPlot(this);
    curve = new QwtPlotCurve(title);
    curve->attach(plot);
    curve->setVisible(true);
    ;
    this->setCentralWidget(plot);

    //layout->addWidget(plot);
    //this->setLayout(layout);
    this->setGeometry(10,10,300,300);
    QwtPlotZoomer* zoomer = new MyZoomer(plot->canvas());
    zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
        Qt::RightButton, Qt::ControlModifier);
    zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
        Qt::RightButton);

}
Example #11
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);    
}
Example #12
0
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);
}
Example #13
0
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)));
}
Example #14
0
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);
}
Example #15
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent )
{
    //setAutoFillBackground( true );
    //setPalette( QPalette( QColor( 165, 193, 228 ) ) );
    //updateGradient();

    //setTitle( "A Simple QwtPlot Demonstration" );
    //insertLegend( new QwtLegend(), QwtPlot::BottomLegend );

    // axes
    setAxisTitle( xBottom, "x -->" );
    setAxisScale( xBottom, 0.0, 360.0 );

    setAxisTitle( yLeft, "y -->" );
    setAxisScale( yLeft, -10.0, 10.0 );


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

    QwtPlotGrid* grid = new QwtPlotGrid();
    grid->setPen(Qt::black, 0.1, Qt::DashLine);
    grid->attach(this);

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

    setCanvas( canvas );

    // panning with the left mouse button
    QwtPlotPanner* panner = new QwtPlotPanner( canvas );
    panner->setMouseButton(Qt::LeftButton, Qt::ControlModifier);

    // zoom in/out with the wheel
    QwtPlotMagnifier* magnifier = new QwtPlotMagnifier( canvas );
    magnifier->setAxisEnabled(xBottom, false);


    QwtPlotZoomer* zoomer = new QwtPlotZoomer(canvas);
    zoomer->setKeyPattern( QwtEventPattern::KeyRedo, Qt::Key_I, Qt::ShiftModifier );
    zoomer->setKeyPattern( QwtEventPattern::KeyUndo, Qt::Key_O, Qt::ShiftModifier );
    zoomer->setKeyPattern( QwtEventPattern::KeyHome, Qt::Key_Home );

    zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier);
    zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ShiftModifier);




    canvas->setFocusPolicy(Qt::StrongFocus);
    canvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
    canvas->setFocus();
    //canvas->setFrameShadow(QwtPlot::Plain);
    //canvas->setCursor(Qt::arrowCursor);
    canvas->setLineWidth(0);
    //canvas->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
    //canvas->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);

    //populate();    
}