/**
 * Tworzy wykres spektrogramu.
 *
 * Przygotowuje mapowanie kolorów, skale osi we właściwych jednostkach itp.
 *
 * @param parent obiekt rodzica
 */
SpectrogramPlot::SpectrogramPlot(QWidget* parent):
    QwtPlot(tr("Wave file not loaded"), parent)
{
    spectrogram = new QwtPlotSpectrogram();
    QwtLinearColorMap colorMap(Qt::black, Qt::red);
    colorMap.addColorStop(0.3, Qt::darkBlue);
    colorMap.addColorStop(0.4, Qt::blue);
    colorMap.addColorStop(0.65, Qt::green);
    colorMap.addColorStop(0.85, Qt::yellow);
    spectrogram->setColorMap(colorMap);

    // kolorowa prawa oœś
    QwtScaleWidget *rightAxis = axisWidget(yRight);
    rightAxis->setTitle(tr("Intensity [dB]"));
    rightAxis->setColorBarEnabled(true);
    enableAxis(yRight);
    spectrogram->attach(this);
    const QFontMetrics fmRight(rightAxis->font());
    int intensityWidth = rightAxis->colorBarWidth() + fmRight.width("888 888");
    axisScaleDraw(yRight)->setMinimumExtent(intensityWidth);

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

    // dolna oś
    setAxisScaleDraw(xBottom, new DurationScaleDraw());
}
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
}
Exemple #3
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 );
}
Exemple #4
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 );
}
Exemple #5
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);
}
SectionWindow::SectionWindow(QWidget *parent):
    QMainWindow(parent)
{
    m_data = new RasterData();
    m_plot = new QwtPlot(parent);
    m_spect = new QwtPlotSpectrogram();

    m_spect->setColorMap(QwtLinearColorMap(Qt::darkCyan, Qt::red));
    m_spect->setData(*m_data);
    m_spect->attach(m_plot);

    m_plot->axisWidget(QwtPlot::xBottom)->setTitle("Band (index)");
    m_plot->axisWidget(QwtPlot::yLeft)->setTitle("Arclength (pixel)");
    m_plot->setMargin(5);

    // A color bar on the right axis
    QwtScaleWidget *rightAxis = m_plot->axisWidget(QwtPlot::yRight);
    rightAxis->setTitle("Intensity");
    rightAxis->setColorBarEnabled(true);

    m_plot->enableAxis(QwtPlot::yRight);

    m_plot->plotLayout()->setAlignCanvasToScales(true);
    m_plot->replot();

    // LeftButton for the zooming
    // MidButton for the panning
    // RightButton: zoom out by 1
    // Ctrl+RighButton: zoom out to full size

    m_zoomer = new MyZoomer(this, m_plot->canvas());
    m_zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
        Qt::RightButton, Qt::ControlModifier);
    m_zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
        Qt::RightButton);
    const QColor c(Qt::darkBlue);
    m_zoomer->setRubberBandPen(c);
    m_zoomer->setTrackerPen(c);

    QwtPlotPanner *panner = new QwtPlotPanner(m_plot->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(m_plot->axisWidget(QwtPlot::yLeft)->font());
    QwtScaleDraw *sd = m_plot->axisScaleDraw(QwtPlot::yLeft);
    sd->setMinimumExtent( fm.width("100.00") );

    setCentralWidget(m_plot);
}
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    m_timer = new QTimer(this);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(updateQuery()));
    m_timer->start(1000);
    m_plot = new Plot(this);
    m_vect = new QListView(this);
    ListModel=new QStandardItemModel();
    this->setMinimumSize(700, 500);
    m_vect->setMinimumWidth(150);
    m_vect->setMaximumWidth(250);
    m_command=new QLineEdit(this);
    m_sendCommand = new QPushButton(this);
    connect(m_sendCommand, SIGNAL(clicked()), this, SLOT(onSendCommandPressed()));
    m_sendCommand->setText("Envoyer commande");
    /*
     *Pour que le bouton ajuste sa taille lorsque l'on agrandit la fenetre
     *m_sendCommand->????();
     */
    m_sendCommand->setMinimumWidth(150);
    m_sendCommand->setMaximumWidth(250);

    QwtPlotMagnifier* magnifier = new QwtPlotMagnifier(m_plot->canvas());
    QwtPlotPanner* panner = new QwtPlotPanner(m_plot->canvas());
    panner->setMouseButton(Qt::LeftButton);

    QWidget * centralArea = new QWidget;
    QHBoxLayout *plotAndVect = new QHBoxLayout;
    QHBoxLayout *cmdLineAndButton = new QHBoxLayout;
    QVBoxLayout *central = new QVBoxLayout;

    plotAndVect->addWidget(m_plot);
    plotAndVect->addWidget(m_vect);
    cmdLineAndButton->addWidget(m_command);
    cmdLineAndButton->addWidget(m_sendCommand);

    central->addLayout(plotAndVect);
    central->addLayout(cmdLineAndButton);
    centralArea->setLayout(central);

    this->setCentralWidget(centralArea);


    this->createActions();
    this->createMenus();
    this->createStatusBar();


}
CIncrementalPlot::CIncrementalPlot(const QColor& Back, const QColor& Front, const QColor& Grid, const QString& yAxis, EUnits eUnits, QWidget *parent)
:QWidget(parent)
{
	m_bReplotPending = false;
	m_iLimit = HR2S(1);

	m_pMainLayout = new QVBoxLayout();
	m_pMainLayout->setMargin(0);

	m_pChart = new QwtPlot();

	m_pMainLayout->addWidget(m_pChart);

	setLayout(m_pMainLayout);

	m_pChart->setStyleSheet(QString("color: rgb(%1, %2, %3); background-color: rgb(%4, %5, %6);")
		.arg(Front.red()).arg(Front.green()).arg(Front.blue())
		.arg(Back.red()).arg(Back.green()).arg(Back.blue()));

	QFont smallerFont(QApplication::font());
	m_pChart->setAxisScaleDraw(QwtPlot::xBottom, new CDateScale);
	switch(eUnits)
	{
	case eBytes: m_pChart->setAxisScaleDraw(QwtPlot::yLeft, new CRateScale);
	}
	m_pChart->setAxisFont(QwtPlot::yLeft,smallerFont);
	m_pChart->setAxisFont(QwtPlot::xBottom,smallerFont);

	m_pChart->plotLayout()->setAlignCanvasToScales(true);

	QwtLegendEx* pLegend = new QwtLegendEx;
	pLegend->setStyleSheet(QString("color: rgb(%1, %2, %3);")
		.arg(Front.red()).arg(Front.green()).arg(Front.blue()));
	m_pChart->insertLegend(pLegend, QwtPlot::BottomLegend);

	QwtPlotGrid *pGrid = new QwtPlotGrid;
	pGrid->setMajorPen(QPen(Grid,0,Qt::DotLine));
	pGrid->attach(m_pChart);

	QwtPlotPanner *pPanner = new QwtPlotPanner(m_pChart->canvas());
	pPanner->setAxisEnabled(QwtPlot::yRight,false);
	pPanner->setAxisEnabled(QwtPlot::xTop,false);
	pPanner->setMouseButton(Qt::MidButton);
	
	m_pChart->setAxisAutoScale(QwtPlot::yLeft);
	m_pChart->setAxisAutoScale(QwtPlot::xBottom);
	m_pChart->setAxisTitle(QwtPlot::yLeft,yAxis);
	//m_pChart->setAxisTitle(QwtPlot::xBottom,tr("Time"));
}
Exemple #9
0
HarmPlot::HarmPlot(const QString& aDir, IRInfo anIi, QWidget *parent) throw (QLE) : QwtPlot(parent)
{
    this->setAttribute(Qt::WA_DeleteOnClose);

    this->dir = aDir;
    this->ii = anIi;

    this->data = (HarmData**) new char[sizeof(HarmData*) * (MAX_HARM - 1)];

    this->setAutoReplot(false);
    this->setCanvasBackground(BG_COLOR);

    this->setAxisScale(QwtPlot::yLeft, -120.0, 20.0);
    this->setAxisMaxMajor(QwtPlot::yLeft, 7);
    this->setAxisMaxMinor(QwtPlot::yLeft, 10);

    this->setAxisMaxMajor(QwtPlot::xBottom, 6);
    this->setAxisMaxMinor(QwtPlot::xBottom, 10);
#if QWT_VERSION > 0x060000
    QwtLogScaleEngine* logEngine = new QwtLogScaleEngine(10.0);
#else
    QwtLog10ScaleEngine* logEngine = new QwtLog10ScaleEngine();
#endif
    this->setAxisScaleEngine(QwtPlot::xBottom, logEngine);

    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin(true);
#if QWT_VERSION > 0x060000
    grid->setMajorPen(QPen(MAJ_PEN_COLOR, 0, Qt::DotLine));
    grid->setMinorPen(QPen(MIN_PEN_COLOR, 0 , Qt::DotLine));
#else
    grid->setMajPen(QPen(MAJ_PEN_COLOR, 0, Qt::DotLine));
    grid->setMinPen(QPen(MIN_PEN_COLOR, 0 , Qt::DotLine));
#endif
    grid->attach(this);

    this->addCurves();

    QwtPlotPanner* panner = new QwtPlotPanner(this->canvas());
    panner->setMouseButton(Qt::MidButton);
    panner->setEnabled(true);

    this->setAutoReplot(true);

}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
RiuSummaryQwtPlot::RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* parent) : QwtPlot(parent)
{
    Q_ASSERT(plotDefinition);
    m_plotDefinition = plotDefinition;

    m_grid = new QwtPlotGrid;
    m_grid->attach(this);

    setDefaults();

    // LeftButton for the zooming
    m_zoomerLeft = new QwtPlotZoomer(canvas());
    m_zoomerLeft->setRubberBandPen(QColor(Qt::black));
    m_zoomerLeft->setTrackerMode(QwtPicker::AlwaysOff);
    m_zoomerLeft->setTrackerPen(QColor(Qt::black));
    m_zoomerLeft->initMousePattern(1);

    // MidButton for the panning
    QwtPlotPanner* panner = new QwtPlotPanner(canvas());
    panner->setMouseButton(Qt::MidButton);

    connect(m_zoomerLeft, SIGNAL(zoomed( const QRectF & )), SLOT(onZoomedSlot()));
    connect(panner, SIGNAL(panned( int , int  )), SLOT(onZoomedSlot()));

    // Attach a zoomer for the right axis
    m_zoomerRight = new QwtPlotZoomer(canvas());
    m_zoomerRight->setAxis(xTop, yRight);
    m_zoomerRight->setTrackerMode(QwtPicker::AlwaysOff);
    m_zoomerRight->initMousePattern(1);


    RiuQwtScalePicker* scalePicker = new RiuQwtScalePicker(this);
    connect(scalePicker, SIGNAL(clicked(int, double)), this, SLOT(onAxisClicked(int, double)));

    // Create a plot picker to display values next to mouse cursor
    m_plotPicker = new RiuQwtPlotPicker(this->canvas());
    m_plotPicker->setTrackerMode(QwtPicker::AlwaysOn);

    m_plotMarker = new QwtPlotMarker;

    // QwtPlotMarker takes ownership of the symbol, it is deleted in destructor of QwtPlotMarker
    QwtSymbol* mySymbol = new QwtSymbol(QwtSymbol::Ellipse, Qt::NoBrush, QPen(Qt::black, 2.0), QSize(12, 12));
    m_plotMarker->setSymbol(mySymbol);
}
Exemple #11
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent )
{
    setTitle( "Trading Chart" );

    QwtDateScaleDraw *scaleDraw = new DateScaleDraw( Qt::UTC );
    QwtDateScaleEngine *scaleEngine = new QwtDateScaleEngine( Qt::UTC );

    setAxisTitle( QwtPlot::xBottom, QString( "2010" ) );
    setAxisScaleDraw( QwtPlot::xBottom, scaleDraw );
    setAxisScaleEngine( QwtPlot::xBottom, scaleEngine );
    setAxisLabelRotation( QwtPlot::xBottom, -50.0 );
    setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom );

    setAxisTitle( QwtPlot::yLeft, QString( "Price [EUR]" ) );

#if 0
    QwtLegend *legend = new QwtLegend;
    legend->setDefaultItemMode( QwtLegendData::Checkable );
    insertLegend( legend, QwtPlot::RightLegend );
#else
    Legend *legend = new Legend;
    insertLegend( legend, QwtPlot::RightLegend );
#endif

    populate();

    // LeftButton for the zooming
    // MidButton for the panning
    // RightButton: zoom out by 1
    // Ctrl+RighButton: zoom out to full size

    Zoomer* zoomer = new Zoomer( canvas() );
    zoomer->setMousePattern( QwtEventPattern::MouseSelect2,
        Qt::RightButton, Qt::ControlModifier );
    zoomer->setMousePattern( QwtEventPattern::MouseSelect3,
        Qt::RightButton );

    QwtPlotPanner *panner = new QwtPlotPanner( canvas() );
    panner->setMouseButton( Qt::MidButton );

    connect( legend, SIGNAL( checked( QwtPlotItem *, bool, int ) ),
        SLOT( showItem( QwtPlotItem *, bool ) ) );
}
Exemple #12
0
IRPlot::IRPlot(const QString& aDir, IRInfo anIi, QWidget *parent) throw (QLE) : QwtPlot(parent)
{
    this->dir = aDir;
    this->ii = anIi;

    this->time = 0;
    this->amps = 0;

    this->setAutoReplot(false);
    this->setCanvasBackground(BG_COLOR);

    unsigned curveLength = this->calculate();

    this->setAxisScale( xBottom, this->time[0], this->time[curveLength-1]);
    this->setAxisAutoScale( xBottom);
    this->setAxisScale( yLeft, -1.5, 1.5);

    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin(true);
#if QWT_VERSION > 0x060000
    grid->setMajorPen(QPen(MAJ_PEN_COLOR, 0, Qt::DotLine));
    grid->setMinorPen(QPen(MIN_PEN_COLOR, 0 , Qt::DotLine));
#else
    grid->setMajPen(QPen(MAJ_PEN_COLOR, 0, Qt::DotLine));
    grid->setMinPen(QPen(MIN_PEN_COLOR, 0 , Qt::DotLine));
#endif
    grid->attach(this);

    QwtPlotCurve* ampCurve = new QwtPlotCurve("IR_Plot");
    ampCurve->setPen(QPen(AMP_CURVE_COLOR));
    ampCurve->setYAxis(QwtPlot::yLeft);
    ampCurve->attach(this);
    ampCurve->setSamples(this->time, this->amps, curveLength);

    QwtPlotPanner* panner = new QwtPlotPanner(this->canvas());
    panner->setMouseButton(Qt::MidButton);
    panner->setEnabled(true);

    this->setAutoReplot(true);
}
Exemple #13
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();    
}
Exemple #14
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);
}
Exemple #16
0
SpectrogramPlot::SpectrogramPlot( QWidget *parent ) : QwtPlot(parent)
                                                    , impl_( new impl( this ) )
{
    impl_->spectrogram_->setRenderThreadCount( 0 ); // use system specific thread count
    
    impl_->spectrogram_->setColorMap( new ColorMap() );
    impl_->spectrogram_->setCachePolicy( QwtPlotRasterItem::PaintCache );

    impl_->spectrogram_->setData( impl_->drawable_ );
    impl_->spectrogram_->attach( this );

    impl_->marker_->attach( this );

    // QList<double> contourLevels;
    // for ( double level = 0.5; level < 10.0; level += 1.0 )
    //     contourLevels += level;
    // impl_->spectrogram_->setContourLevels( contourLevels );

    const QwtInterval zInterval = impl_->spectrogram_->data()->interval( Qt::ZAxis );
    // A color bar on the right axis
    QwtScaleWidget *rightAxis = axisWidget( QwtPlot::yRight );
    rightAxis->setTitle( "Intensity" );
    rightAxis->setColorBarEnabled( true );

    // rightAxis->setColorMap( zInterval, new ColorMap() );
    setAxisZMax( 10.0 );

    //setAxisScale( QwtPlot::xBottom, 0, 64 );
    //setAxisScale( QwtPlot::yLeft,  64, 0 );
    axisScaleEngine( QwtPlot::xBottom )->setAttribute( QwtScaleEngine::Floating, true );
    axisScaleEngine( QwtPlot::yLeft )->setAttribute( QwtScaleEngine::Floating, true );
    axisScaleEngine( QwtPlot::yLeft )->setAttribute( QwtScaleEngine::Inverted, true );
    
	setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue());
    enableAxis( QwtPlot::yRight );

    plotLayout()->setAlignCanvasToScales( true );
    replot();

    if ( auto zoomer = new adplot::Zoomer( QwtPlot::xBottom, QwtPlot::yLeft, canvas() ) ) {
        const QColor c( 0xe0, 0xff, 0xff, 0x40 ); // lightcyan
        zoomer->setRubberBandPen( c );
        zoomer->setTrackerPen( c );
        zoomer->setTrackerMode( QwtPlotPicker::ActiveOnly );
    }

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

    if ( auto picker = new adplot::Picker( canvas() ) ) {

        //picker->setStateMachine( new QwtPickerClickPointMachine() );
        picker->setStateMachine( new QwtPickerDragRectMachine() );
        picker->setRubberBand( QwtPicker::RectRubberBand );
        picker->setRubberBandPen( QColor( Qt::red ) );
        picker->setTrackerPen( QColor( Qt::white ) );
        
        picker->setMousePattern( QwtEventPattern::MouseSelect1, Qt::RightButton );
        picker->setTrackerMode( QwtPicker::AlwaysOff );
        picker->setEnabled( true );
        
        connect( picker, static_cast<void( QwtPlotPicker::* )( const QPointF& )>( &QwtPlotPicker::selected ), 
                 this, [this] ( const QPointF& p ) {
                     impl_->marker_->setRect( p ); replot();
                     emit cellSelected( impl_->marker_->rect() );
                 } );

        connect( picker, static_cast<void( QwtPlotPicker::* )( const QRectF& )>( &QwtPlotPicker::selected ), 
                 this, [this] ( const QRectF& rc ) {
                     impl_->marker_->setRect( rc ); replot();
                     emit cellSelected( impl_->marker_->rect() );                     
                 } );        
    }

    QFont font;
    qtwrapper::font::setFont( font, qtwrapper::fontSizeSmall, qtwrapper::fontAxisLabel );
    setAxisFont( QwtPlot::xBottom, font );
    setAxisFont( QwtPlot::yLeft, font );

    // Set fixed 'extent' for axis in order to 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( "888.0" ) );

    setContextMenuPolicy( Qt::CustomContextMenu );

}
Exemple #17
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)));
}
Exemple #18
0
FrameView::FrameView (Connection * conn, FrameViewConfig const & cfg, QString const & fname, QStringList const & path)
	: DockedWidgetBase(conn->getMainWindow(), path)
	, m_bars(0)
	, m_config(cfg)
	, m_config_ui(m_config, this)
{
	setContextMenuPolicy(Qt::CustomContextMenu);
	connect(this, SIGNAL(customContextMenuRequested(QPoint const &)), this, SLOT(onShowContextMenu(QPoint const &)));

	m_plot = new QwtPlot();
	m_bars = new BarPlot();
	m_bars->attach(m_plot);

	m_plot->plotLayout()->setAlignCanvasToScales(true);
	m_plot->plotLayout()->setCanvasMargin(0);
	m_plot->setContentsMargins(QMargins(0, 0, 0, 0));
	m_plot->setMinimumSize(64,64);

	m_plot->setAutoReplot(true);
	//qDebug("%s this=0x%08x", __FUNCTION__, this);

	QwtPlotMagnifier * lookglass = new QwtPlotMagnifier(m_plot->canvas());
	m_plot->canvas()->setFocusPolicy(Qt::WheelFocus);
	lookglass->setAxisEnabled(QwtPlot::yLeft, false);

	XZoomer * zoomer = new XZoomer(m_plot->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, Qt::ShiftModifier);

	QwtPlotPicker * picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
										QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,
										m_plot->canvas());
	//picker->setStateMachine(new QwtPickerDragPointMachine());
	picker->setStateMachine(new QwtPickerClickPointMachine());
	picker->setRubberBandPen(QColor(Qt::green));
	picker->setRubberBand(QwtPicker::CrossRubberBand);
	picker->setTrackerPen(QColor(Qt::white));

	QwtPlotPanner * panner = new QwtPlotPanner(m_plot->canvas());
	panner->setAxisEnabled(QwtPlot::yLeft, false);
	panner->setMouseButton(Qt::MidButton);

    m_plot->setAxisMaxMinor(QwtPlot::xBottom, 3);
    m_plot->setAxisScaleDraw(QwtPlot::xBottom, new FrameScaleDraw(Qt::Horizontal, m_bars->m_strvalues));

	m_plot->setAxisAutoScale(QwtPlot::yLeft, true);
	m_bars->setLayoutPolicy(QwtPlotAbstractBarChart::FixedSampleSize);
	m_bars->setLayoutHint(5);
	m_bars->setSpacing(1);

	QwtSlider * slider = createSlider(1);
    connect(slider, SIGNAL(valueChanged(double)), SLOT(setNum(double)));
    QVBoxLayout * layout = new QVBoxLayout( this );
    layout->addWidget(m_plot);
    //layout->addWidget(slider);
	m_bars->setLegendMode(QwtPlotBarChart::LegendBarTitles);

    connect(picker, SIGNAL(selected(QRectF const &) ), this, SLOT(selected(QRectF const &)));
    connect(picker, SIGNAL(selected(QPointF const &) ), this, SLOT(selected(QPointF const &)));
    connect(picker, SIGNAL(appended(QPointF const &) ), this, SLOT(appended(QPointF const &)));
    connect(picker, SIGNAL(selected(QVector<QPointF> const &) ), this, SLOT(selected(QVector<QPointF> const &)));

    connect(&getSyncWidgets(), SIGNAL( requestSynchronization(E_SyncMode mode, int, unsigned long long, void *) ),
						 this, SLOT( performSynchronization(E_SyncMode mode, int, unsigned long long, void *) ));
    connect(this, SIGNAL( requestSynchronization(E_SyncMode mode, int, unsigned long long, void *) ),
						 &getSyncWidgets(), SLOT( performSynchronization(E_SyncMode mode, int, unsigned long long, void *) ));
}