Esempio n. 1
1
QTabWidget* ResultsPage::createDataTabWidget()
{
    QTabWidget *tabWidget = new QTabWidget;

    // Plot
    m_plot = new QwtPlot(tabWidget);
    m_plot->setCanvasBackground(Qt::white);
    m_plot->setContextMenuPolicy(Qt::CustomContextMenu);
    m_plot->setAutoReplot(false);

    connect(m_plot, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(showPlotContextMenu(QPoint)));
    
    // Picker to allow for selection of the closest curve and displays curve
    // coordinates with a cross rubber band.
    QwtPlotPicker *picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
                                              QwtPicker::CrossRubberBand, QwtPicker::ActiveOnly,
                                              m_plot->canvas());
    picker->setStateMachine(new QwtPickerDragPointMachine());

    connect(picker, SIGNAL(appended(QPoint)), this, SLOT(pointSelected(QPoint)));

    // Legend
    QwtLegend* legend = new QwtLegend;
    legend->setFrameStyle(QFrame::Box | QFrame::Sunken);
    m_plot->insertLegend(legend, QwtPlot::BottomLegend);
#if QWT_VERSION >= 0x060100
    connect(m_plot,
            SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)),
            legend,
            SLOT(updateLegend(QVariant,QList<QwtLegendData>)));
#endif

    // Add the generic curves to the legend
    QList<QPair<QString, Qt::GlobalColor> > pairs;
    pairs << qMakePair(tr("Unselected Realization"), Qt::darkGray)
          << qMakePair(tr("Selected and Enabled Realization"), Qt::darkGreen)
          << qMakePair(tr("Selected and Disabled Realization"), Qt::darkRed);

    QPair<QString, Qt::GlobalColor> pair;
    foreach (pair, pairs) {
        QwtPlotCurve *curve = new QwtPlotCurve(pair.first);

        curve->setLegendIconSize(QSize(32, 8));
        curve->setPen(QPen(QBrush(pair.second), 2));
        curve->setLegendAttribute(QwtPlotCurve::LegendShowLine);
#if QWT_VERSION < 0x060100
        curve->updateLegend(legend);
#else
        m_plot->updateLegend(curve);
#endif
    }
Esempio n. 2
0
void Plot::initCurves()
{
    QwtPointSeriesData* data = new QwtPointSeriesData();
    
    m_manager.GetPointSeriesData(data, ResourceManager::MF_0);
    
    QwtPlotCurve* curve = new QwtPlotCurve(tr("measured data"));
    curve->setRenderHint(QwtPlotItem::RenderAntialiased);
    curve->setLegendAttribute(QwtPlotCurve::LegendNoAttribute);
    curve->setPen(QPen(Qt::red));
    curve->attach(this);
    curve->setData(data);
}
Esempio n. 3
0
void Plot::populate()
{
    // Insert new curves
    QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
    cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
    cSin->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
    cSin->setPen(QPen(Qt::red));
    cSin->attach(this);

    QwtPlotCurve *cCos = new QwtPlotCurve("y = cos(x)");
    cCos->setRenderHint(QwtPlotItem::RenderAntialiased);
    cCos->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
    cCos->setPen(QPen(Qt::blue));
    cCos->attach(this);

    // Create sin and cos data
    cSin->setData(new FunctionData(::sin));
    cCos->setData(new FunctionData(::cos));

    // Insert markers
    
    //  ...a horizontal line at y = 0...
    QwtPlotMarker *mY = new QwtPlotMarker();
    mY->setLabel(QString::fromLatin1("y = 0"));
    mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
    mY->setLineStyle(QwtPlotMarker::HLine);
    mY->setYValue(0.0);
    mY->attach(this);

    //  ...a vertical line at x = 2 * pi
    QwtPlotMarker *mX = new QwtPlotMarker();
    mX->setLabel(QString::fromLatin1("x = 2 pi"));
    mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
    mX->setLabelOrientation(Qt::Vertical);
    mX->setLineStyle(QwtPlotMarker::VLine);
    mX->setLinePen(QPen(Qt::black, 0, Qt::DashDotLine));
    mX->setXValue(2.0 * M_PI);
    mX->attach(this);
}
Esempio n. 4
0
void GraphWidget::addNewPlot(chaos::common::utility::PointerBuffer *pointerBuffer, std::string& plotName , chaos::DataType::DataType dataType){
    boost::mutex::scoped_lock  lock(manageMutex);
    if(plotMap.count(plotName)>0) return;
    boost::shared_ptr<PlotPtrBufferAndCurve> newPlotInfo(new PlotPtrBufferAndCurve());
    boost::mt19937 rng((const uint_fast32_t) std::time(0) );
    boost::uniform_int<> one_to_six( 0, 255 );
    boost::variate_generator< boost::mt19937, boost::uniform_int<> > randInt(rng, one_to_six);

    QwtPlotCurve *c = new QwtPlotCurve(plotName.c_str());
    c->setPen(QPen(QColor(randInt(), randInt(), randInt())));
    c->setRenderHint(QwtPlotItem::RenderAntialiased);
    c->setStyle(QwtPlotCurve::Lines);
    c->attach(plot);
    c->setLegendAttribute(QwtPlotCurve::LegendShowLine);
    c->setRenderHint(QwtPlotItem::RenderAntialiased, true);
    newPlotInfo->curve = c;
    newPlotInfo->curvePointer = pointerBuffer;
    newPlotInfo->dataType = dataType;
    pointerPlotMap.insert(std::make_pair(plotName, newPlotInfo));
}
Esempio n. 5
0
void Plot::populate()
{
    // Insert new curves
    QwtPlotCurve *cSin = new QwtPlotCurve( "y = sin(x)" );
    cSin->setRenderHint( QwtPlotItem::RenderAntialiased );
    cSin->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
    cSin->setPen( Qt::red );
    cSin->attach( this );

    cSin->setData( new Data() );



    CurveTracker* tracker = new CurveTracker( canvas() );

    // for the demo we want the tracker to be active without
    // having to click on the canvas
    tracker->setStateMachine( new QwtPickerTrackerMachine() );
    tracker->setRubberBandPen( QPen( "MediumOrchid" ) );

}
Esempio n. 6
0
QWT_ABSTRACT_SERIESITEM * MavPlot::_add_data_timeseries(const DataTimeseries<ST> * data, unsigned int plotnumber /* used for colors etc */) {

    /*
     * so we have a timeseries of type ST. We need to "translate" it for the plot, and then add it.
     * One problem is, that Qwt cannot plot double against float...so we need to "convert" every-
     * thing to double here.
     */
    QVector<double> xdata, ydata;
    if (!data2xyvect(data, xdata, ydata)) {
        return NULL;
    }

    QwtPlotCurve *curve = new QwtPlotCurve(QString().fromStdString(data->get_name()));
    curve->setRenderHint(QwtPlotItem::RenderAntialiased);
    curve->setPen(QPen(_suggestColor(plotnumber))); // FIXME: offer choices

    curve->setLegendAttribute(QwtPlotCurve::LegendShowLine);    
    curve->setSamples(xdata, ydata); // makes a deep copy
    curve->attach(this);

    return dynamic_cast<QWT_ABSTRACT_SERIESITEM *>(curve);
}
Esempio n. 7
0
int main( int argc, char **argv )
{
    QApplication a( argc, argv );

    QwtPlot plot;
    plot.setTitle( "Plot Demo" );
    plot.setCanvasBackground( Qt::white );

    plot.setAxisScale( QwtPlot::xBottom, -1.0, 6.0 );

    QwtLegend *legend = new QwtLegend();
    legend->setDefaultItemMode( QwtLegendData::Checkable );
    plot.insertLegend( legend );

    for ( int i = 0; i < 4; i++ )
    {
        QwtPlotCurve *curve = new QwtPlotCurve();
        curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
        curve->setPen( Qt::blue );

        QBrush brush;
        QwtSymbol::Style style = QwtSymbol::NoSymbol;
        QString title;
        if ( i == 0 )
        {
            brush = Qt::magenta;
            style = QwtSymbol::Path;
            title = "Path";
        }
        else if ( i == 2 )
        {
            brush = Qt::red;
            style = QwtSymbol::Graphic;
            title = "Graphic";
        }
        else if ( i == 1 )
        {
            brush = Qt::yellow;
            style = QwtSymbol::SvgDocument;
            title = "Svg";
        }
        else if ( i == 3 )
        {
            brush = Qt::cyan;
            style = QwtSymbol::Pixmap;
            title = "Pixmap";
        }

        MySymbol *symbol = new MySymbol( style, brush );

        curve->setSymbol( symbol );
        curve->setTitle( title );
        curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true );
        curve->setLegendIconSize( QSize( 15, 18 ) );

        QPolygonF points;
        points << QPointF( 0.0, 4.4 ) << QPointF( 1.0, 3.0 )
            << QPointF( 2.0, 4.5 ) << QPointF( 3.0, 6.8 )
            << QPointF( 4.0, 7.9 ) << QPointF( 5.0, 7.1 );

        points.translate( 0.0, i * 2.0 );

        curve->setSamples( points );
        curve->attach( &plot );
    }

    plot.resize( 600, 400 );
    plot.show();

    return a.exec();
}