Exemple #1
0
void PlotMatrix::alignVAxes( int col, int axis )
{
    if ( axis != QwtPlot::yLeft && axis != QwtPlot::yRight )
        return;

    double maxExtent = 0;
    for ( int row = 0; row < numRows(); row++ )
    {
        QwtPlot *p = plot( row, col );
        if ( p )
        {
            QwtScaleWidget *scaleWidget = p->axisWidget( axis );

            QwtScaleDraw *sd = scaleWidget->scaleDraw();
            sd->setMinimumExtent( 0.0 );

            const double extent = sd->extent( scaleWidget->font() );
            if ( extent > maxExtent )
                maxExtent = extent;
        }
    }
    for ( int row = 0; row < numRows(); row++ )
    {
        QwtPlot *p = plot( row, col );
        if ( p )
        {
            QwtScaleWidget *scaleWidget = p->axisWidget( axis );
            scaleWidget->scaleDraw()->setMinimumExtent( maxExtent );
        }
    }
}
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 );
}
Spectrogramplot::Spectrogramplot(int numDataPoints, int numRows, QWidget *parent)
  :QwtPlot(parent)
  ,nData_(numDataPoints)
  ,nRows_(numRows)
{
  spectrogram_ = new QwtPlotSpectrogram();
  spectrogram_->setRenderThreadCount(0); // set system specific thread count
  data_ = new WaterfallData(nData_, nRows_);
  spectrogram_->attach(this);

  setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
  setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);

  axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating,true);
  axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating,true);

  spectrogram_->setColorMap(new ColorMap());
  spectrogram_->setData(data_);

  setXAxisRange(0, nData_);
  setYAxisRange(0, nRows_);
  setZAxisScale(-1,1);

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

  zoomer_ = new MyZoomer(qobject_cast<QwtPlotCanvas*>(canvas()));
  zoomer_->setMousePattern(QwtEventPattern::MouseSelect1,
      Qt::LeftButton);
  zoomer_->setMousePattern(QwtEventPattern::MouseSelect2,
      Qt::LeftButton, Qt::ControlModifier);

  panner_ = new QwtPlotPanner(canvas());
  panner_->setAxisEnabled(QwtPlot::yRight, false);
  panner_->setMouseButton(Qt::RightButton);

  magnifier_ = new QwtPlotMagnifier(canvas());
  magnifier_->setMouseButton(Qt::NoButton);

  // 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);
}
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);
}
Exemple #6
0
    virtual void rescale()
    {
        QwtScaleWidget *scaleWidget = plot()->axisWidget(yAxis());
        QwtScaleDraw *sd = scaleWidget->scaleDraw();

        int minExtent = 0;
        if ( zoomRectIndex() > 0 )
        {
            // When scrolling in vertical direction
            // the plot is jumping in horizontal direction
            // because of the different widths of the labels
            // So we better use a fixed extent.

            minExtent = sd->spacing() + sd->maxTickLength() + 1;
            minExtent += sd->labelSize(
                scaleWidget->font(), c_rangeMax).width();
        }

        sd->setMinimumExtent(minExtent);

        ScrollZoomer::rescale();
    }
Exemple #7
0
//---------------------------------------------------------------------------
void Plots::alignYAxes()
{
    double maxExtent = 0;

    for ( size_t streamPos = 0; streamPos < m_fileInfoData->Stats.size(); streamPos++ )
        if ( m_fileInfoData->Stats[streamPos] && m_plots[streamPos] )
        {
            size_t type = m_fileInfoData->Stats[streamPos]->Type_Get();
        
            for ( int group = 0; group < PerStreamType[type].CountOfGroups; group++ )
                if (m_plots[streamPos][group] && m_plots[streamPos] )
            {
                QwtScaleWidget *scaleWidget = m_plots[streamPos][group]->axisWidget( QwtPlot::yLeft );

                QwtScaleDraw* scaleDraw = scaleWidget->scaleDraw();
                scaleDraw->setMinimumExtent( 0.0 );

                if ( m_plots[streamPos][group] && m_plots[streamPos][group]->isVisibleTo( this ) )
                {
                    const double extent = scaleDraw->extent( scaleWidget->font() );
                    maxExtent = qMax( extent, maxExtent );
                }
            }
            maxExtent += 3; // margin
        }

    for ( size_t streamPos = 0; streamPos < m_fileInfoData->Stats.size(); streamPos++ )
        if ( m_fileInfoData->Stats[streamPos] && m_plots[streamPos] )
        {
            size_t type = m_fileInfoData->Stats[streamPos]->Type_Get();
        
            for ( int group = 0; group < PerStreamType[type].CountOfGroups; group++ )
                if (m_plots[streamPos][group])
            {
                QwtScaleWidget *scaleWidget = m_plots[streamPos][group]->axisWidget( QwtPlot::yLeft );
                scaleWidget->scaleDraw()->setMinimumExtent( maxExtent );
            }
        }
}
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 #9
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 #10
0
Plot::Plot(QWidget *parent):
    QwtPlot(parent)
{
    setTitle("Interactive Plot");

    setCanvasColor(Qt::darkCyan);

    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
    grid->attach(this);

    // axes

    setAxisScale(QwtPlot::xBottom, 0.0, 100.0);
    setAxisScale(QwtPlot::yLeft, 0.0, 100.0);

    // Avoid jumping when label with 3 digits
    // appear/disappear when scrolling vertically

    QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
    sd->setMinimumExtent( sd->extent(axisWidget(QwtPlot::yLeft)->font()));

    plotLayout()->setAlignCanvasToScales(true);

    insertCurve(Qt::Vertical, Qt::blue, 30.0);
    insertCurve(Qt::Vertical, Qt::magenta, 70.0);
    insertCurve(Qt::Horizontal, Qt::yellow, 30.0);
    insertCurve(Qt::Horizontal, Qt::white, 70.0);

    replot();

    // ------------------------------------
    // We add a color bar to the left axis
    // ------------------------------------

    QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(yLeft);
    scaleWidget->setMargin(10); // area for the color bar
    d_colorBar = new ColorBar(Qt::Vertical, scaleWidget);
    d_colorBar->setRange(Qt::red, Qt::darkBlue);
    d_colorBar->setFocusPolicy(Qt::TabFocus);

    connect(d_colorBar, SIGNAL(selected(const QColor &)),
        SLOT(setCanvasColor(const QColor &)));

    // we need the resize events, to lay out the color bar
    scaleWidget->installEventFilter(this); 

    // ------------------------------------
    // We add a wheel to the canvas
    // ------------------------------------

    d_wheel = new QwtWheel(canvas());
    d_wheel->setOrientation(Qt::Vertical);
    d_wheel->setRange(-100, 100);
    d_wheel->setValue(0.0);
    d_wheel->setMass(0.2);
    d_wheel->setTotalAngle(4 * 360.0);

    connect(d_wheel, SIGNAL(valueChanged(double)),
        SLOT(scrollLeftAxis(double)));

    // we need the resize events, to lay out the wheel
    canvas()->installEventFilter(this);

    d_colorBar->setWhatsThis(
        "Selecting a color will change the background of the plot.");
    scaleWidget->setWhatsThis(
        "Selecting a value at the scale will insert a new curve.");
    d_wheel->setWhatsThis(
        "With the wheel you can move the visible area.");
    axisWidget(xBottom)->setWhatsThis(
        "Selecting a value at the scale will insert a new curve.");
}
Exemple #11
0
void PlotMatrix::alignAxes( int rowOrColumn, int axis )
{
    if ( axis == QwtPlot::yLeft || axis == QwtPlot::yRight )
    {
        double maxExtent = 0;

        for ( int row = 0; row < numRows(); row++ )
        {
            QwtPlot *p = plotAt( row, rowOrColumn );
            if ( p )
            {
                QwtScaleWidget *scaleWidget = p->axisWidget( axis );

                QwtScaleDraw *sd = scaleWidget->scaleDraw();
                sd->setMinimumExtent( 0.0 );

                const double extent = sd->extent( scaleWidget->font() );
                if ( extent > maxExtent )
                    maxExtent = extent;
            }
        }

        for ( int row = 0; row < numRows(); row++ )
        {
            QwtPlot *p = plotAt( row, rowOrColumn );
            if ( p )
            {
                QwtScaleWidget *scaleWidget = p->axisWidget( axis );
                scaleWidget->scaleDraw()->setMinimumExtent( maxExtent );
            }
        }
    }
    else
    {
        double maxExtent = 0;

        for ( int col = 0; col < numColumns(); col++ )
        {
            QwtPlot *p = plotAt( rowOrColumn, col );
            if ( p )
            {
                QwtScaleWidget *scaleWidget = p->axisWidget( axis );

                QwtScaleDraw *sd = scaleWidget->scaleDraw();
                sd->setMinimumExtent( 0.0 );

                const double extent = sd->extent( scaleWidget->font() );
                if ( extent > maxExtent )
                    maxExtent = extent;
            }
        }

        for ( int col = 0; col < numColumns(); col++ )
        {
            QwtPlot *p = plotAt( rowOrColumn, col );
            if ( p )
            {
                QwtScaleWidget *scaleWidget = p->axisWidget( axis );
                scaleWidget->scaleDraw()->setMinimumExtent( maxExtent );
            }
        }
    }
}