//---------------------------------------------------------------------------
void JrkPlotDialog::createCurve(QString title, QColor cl, bool on, double scale)
{
    QwtPlotCurve *curve;    
    QPen pen;

    curve = new QwtPlotCurve(title);

    pen.setColor(cl);
    pen.setWidth(2);

    curve->setPen(pen);

    curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, true);
    curve->setRenderHint( QwtPlotCurve::RenderAntialiased, true);

#if 0
    QwtSplineCurveFitter* curveFitter = new QwtSplineCurveFitter();
    curveFitter->setSplineSize(500);
    curve->setCurveFitter(curveFitter);
#endif

    curve->attach(ui->jrkPlot);
    showCurve(curve, on);

    jrkdata.push_back(new JrkPlotData(curve, scale, samples()));
    // qDebug("Scale: %f", scale);
}
示例#2
0
    Curve3()
    {
        setStyle( QwtPlotCurve::Lines );
        setPen( QColor( 100, 200, 150 ), 2 );

        QwtSplineCurveFitter* curveFitter = new QwtSplineCurveFitter();
        curveFitter->setFitMode( QwtSplineCurveFitter::ParametricSpline );
        curveFitter->setSplineSize( 200 );
        setCurveFitter( curveFitter );

        setCurveAttribute( QwtPlotCurve::Fitted, true );

        // somewhere in the top right corner
        QTransform transform;
        transform.translate( 7.0, 7.5 );
        transform.scale( 2.0, 2.0 );

        setTransformation( transform );
    }   
示例#3
0
    Curve1()
    {
        setPen( QColor( 150, 150, 200 ), 2 );
        setStyle( QwtPlotCurve::Lines );

        QwtSplineCurveFitter *curveFitter = new QwtSplineCurveFitter();
        curveFitter->setSplineSize( 150 );
        setCurveFitter( curveFitter );

        setCurveAttribute( QwtPlotCurve::Fitted, true );

        QwtSymbol *symbol = new QwtSymbol( QwtSymbol::XCross );
        symbol->setPen( Qt::yellow );
        symbol->setSize( 7 );

        setSymbol( symbol );

        // somewhere to the left
        QTransform transform;
        transform.scale( 1.5, 1.0 );
        transform.translate( 1.5, 3.0 );

        setTransformation( transform );
    }
示例#4
0
/*!
  * Initializes the Main Window
  */
DataPlot::DataPlot(QWidget *parent):
    QwtPlot(parent),
    d_interval(0),
    d_timerId(-1),
    min(0),
    max(10)



{

    id = 0;
    plotAccx = plotAccy = plotMgx = plotMgy = plotTemp = plotMic = plotVl = plotIr = true;
    auto_scale = false;
    filter = new dataFilter();

    for(int i = 0; i < 8; i++)
        attached[i] = true;
    // Disable polygon clipping
    QwtPainter::setDeviceClipping(false);
    running = false;
    // We don't need the cache here
    canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
    canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);

#if QT_VERSION >= 0x040000
#ifdef Q_WS_X11
    /*
       Qt::WA_PaintOnScreen is only supported for X11, but leads
       to substantial bugs with Qt 4.2.x/Windows
     */
    canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif
#endif

    alignScales();
    
    //  Initialize data
    for (int i = 0; i< PLOT_SIZE; i++)
    {
        d_x[i] = 0.5 * i;     // time axis
        d_mgx[i] = 0;
        d_mgy[i] = 0;
        d_accx[i] = 0;
        d_accy[i] = 0;
        d_mic[i] = 0;
        d_ir[i] = 0;
        d_temp[i] = 0;
    }


    // Assign a title
    setTitle(QString("Sensors for Node %1").arg(id));
    insertLegend(new QwtLegend(), QwtPlot::BottomLegend);

    // Insert new curves
    mgxPlot = new QwtPlotCurve("MGx");
    //mgxFilteredPlot = new QwtPlotCurve("Filtered MGx");

    mgyPlot = new QwtPlotCurve("MGy");
    //mgyPlot = new QwtPlotCurve("Moving Average");

    AccyPlot = new QwtPlotCurve("ACCy");
    //AccyPlot = new QwtPlotCurve("e");

    AccxPlot = new QwtPlotCurve("ACCx");
    tempPlot = new QwtPlotCurve("Temp");
    irPlot = new QwtPlotCurve("IR");
    micPlot = new QwtPlotCurve("MIC");
    vlPlot = new QwtPlotCurve("VL");

    AccyPlot->attach(this);
    AccxPlot->attach(this);
    mgxPlot->attach(this);
    //mgxFilteredPlot->attach(this);
    mgyPlot->attach(this);
    tempPlot->attach(this);
    irPlot->attach(this);
    micPlot->attach(this);
    vlPlot->attach(this);

    const QColor bgColor(255,255,255);
#if QT_VERSION < 0x040000
    setPaletteBackgroundColor(bgColor);
#else
    QPalette p = palette();
    p.setColor(backgroundRole(), bgColor);
    setPalette(p);
#endif

    //! \todo Change line thickness
    // Set curve styles

    QPen *pen = new QPen(Qt::darkBlue);
    pen->setWidth(2);
    mgxPlot->setPen(*pen);

    QwtSplineCurveFitter *f = new QwtSplineCurveFitter();
    f->setFitMode(QwtSplineCurveFitter::Spline);
    mgxPlot->setCurveFitter(f);

    pen->setColor(Qt::darkMagenta);
    //mgxFilteredPlot->setPen(*pen);

    pen->setColor(Qt::red);
    mgyPlot->setPen(*pen);
    mgyPlot->setCurveFitter(f);

    pen->setColor(Qt::green);
    AccyPlot->setPen(*pen);
    AccyPlot->setCurveFitter(f);

    pen->setColor(Qt::darkGray);
    AccxPlot->setPen(*pen);
    AccxPlot->setCurveFitter(f);

    pen->setColor(Qt::yellow);
    tempPlot->setPen(*pen);
    tempPlot->setCurveFitter(f);

    pen->setColor(Qt::darkGreen);
    irPlot->setPen(*pen);
    irPlot->setCurveFitter(f);

    pen->setColor(Qt::magenta);
    micPlot->setPen(*pen);
    micPlot->setCurveFitter(f);

    pen->setColor(Qt::darkRed);
    vlPlot->setPen(*pen);
    vlPlot->setCurveFitter(f);

    // Attach (don't copy) data. Both curves use the same x array.
    mgxPlot->setRawData(d_x, d_mgx, PLOT_SIZE);
//    mgxFilteredPlot->setRawData(d_x, d_fmgx, PLOT_SIZE);
    mgyPlot->setRawData(d_x, d_mgy, PLOT_SIZE);
    AccyPlot->setRawData(d_x, d_accy, PLOT_SIZE);
    AccxPlot->setRawData(d_x, d_accx, PLOT_SIZE);
    tempPlot->setRawData(d_x, d_temp, PLOT_SIZE);
    irPlot->setRawData(d_x, d_ir, PLOT_SIZE);
    micPlot->setRawData(d_x, d_mic, PLOT_SIZE);
    vlPlot->setRawData(d_x, d_vl, PLOT_SIZE);

#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

    // Axis 
    setAxisTitle(QwtPlot::xBottom, "Time/seconds");
    setAxisScale(QwtPlot::xBottom, 0, 100);

    setAxisTitle(QwtPlot::yLeft, "Values");
    setAxisScale(QwtPlot::yLeft, 0, 10);
    
    setTimerInterval(0.0); 
}