Пример #1
0
void Plot::populate()
{
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setMinorPen( Qt::black, 0, Qt::DashLine );
    grid->enableXMin( true );
    grid->attach( this );

    QwtPlotCurve *curve = new QwtPlotCurve();
    curve->setTitle("Some Points");
    curve->setPen( Qt::blue, 4 ),
          curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );

    QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                       QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ) );
    curve->setSymbol( symbol );

    QPolygonF points;
    points << QPointF( 10.0, 4.4 )
           << QPointF( 100.0, 3.0 ) << QPointF( 200.0, 4.5 )
           << QPointF( 300.0, 6.8 ) << QPointF( 400.0, 7.9 )
           << QPointF( 500.0, 7.1 ) << QPointF( 600.0, 7.9 )
           << QPointF( 700.0, 7.1 ) << QPointF( 800.0, 5.4 )
           << QPointF( 900.0, 2.8 ) << QPointF( 1000.0, 3.6 );
    curve->setSamples( points );
    curve->attach( this );
}
Пример #2
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent )
{
    setAutoFillBackground( true );
    setPalette( Qt::darkGray );
    setCanvasBackground( Qt::white );

    plotLayout()->setAlignCanvasToScales( true );

    initAxis( QwtAxis::yLeft, "Local Time", Qt::LocalTime );
    initAxis( QwtAxis::yRight, 
        "Coordinated Universal Time ( UTC )", Qt::UTC );

    QwtPlotPanner *panner = new QwtPlotPanner( canvas() );
    QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() );

    for ( int axis = 0; axis < QwtAxis::PosCount; axis++ )
    {
        const bool on = QwtAxis::isYAxis( axis );

        setAxisVisible( axis, on );
        panner->setAxisEnabled( axis, on );
        magnifier->setAxisEnabled( axis, on );
    }

    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setMajorPen( Qt::black, 0, Qt::SolidLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::SolidLine );
    grid->enableX( false );
    grid->enableXMin( false );
    grid->enableY( true );
    grid->enableYMin( true );

    grid->attach( this );
}
Пример #3
0
// MyPlot2D::MyPlot2D(QWidget *parent, const char *name)
MyPlot2D::MyPlot2D( QWidget *parent ):
        QwtPlot(parent) {
    setAutoReplot( false );

    setTitle( "Comparison of WATER FIT against Measurements" );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setBorderRadius( 10 );

    setCanvas( canvas );
    setCanvasBackground( QColor( "LightGray" ) );

    // legend
    // QwtLegend *legend = new QwtLegend;
    // insertLegend( legend, QwtPlot::BottomLegend );

    // grid
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin( true );
    grid->setMajorPen( Qt::white, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
    grid->attach( this );

    // axes
    enableAxis( QwtPlot::yRight );
    setAxisTitle( QwtPlot::xBottom, "Distance from CAX (cm)" );
    setAxisTitle( QwtPlot::yLeft, "Relative Output Factor" );
    // setAxisTitle( QwtPlot::yRight, "Phase [deg]" );

    // setAxisMaxMajor( QwtPlot::xBottom, 6 );
    // setAxisMaxMinor( QwtPlot::xBottom, 9 );
    // setAxisScaleEngine( QwtPlot::xBottom, new QwtLogScaleEngine );

    setAutoReplot( true );
}
Пример #4
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);
    }
Пример #5
0
MavPlot::MavPlot(QWidget *parent) : QwtPlot(parent), _havePrintColors(false) {
    setAutoReplot(false);
    setTitle("MAV System Data Plot");
    setCanvasBackground(QColor(Qt::darkGray));

    // legend
    QwtLegend *legend = new QwtLegend;
    insertLegend(legend, QwtPlot::BottomLegend);
    #if (QWT_VERSION < QWT_VERSION_CHECK(6,1,0))
        legend->setItemMode(QwtLegend::ClickableItem);
        connect(this, SIGNAL(legendClicked(QwtPlotItem*)), SLOT(legendClicked(QwtPlotItem*)));
    #else
        legend->setDefaultItemMode(QwtLegendData::Clickable);        
        connect(legend, SIGNAL(clicked(const QVariant&, int)), SLOT(legendClickedNew(const QVariant&, int)));
    #endif    

    // grid
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin(true);
    #if (QWT_VERSION < QWT_VERSION_CHECK(6,1,0))
        grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
        grid->setMinPen(QPen(QColor(0x8, 0x8, 0x8), 0 , Qt::DotLine));
    #else
        grid->setMajorPen(QPen(Qt::gray, 0, Qt::DotLine));
        grid->setMinorPen(QPen(QColor(0x8, 0x8, 0x8), 0 , Qt::DotLine));
    #endif
    grid->attach(this);

    // axes
    //enableAxis(QwtPlot::yRight);
    setAxisTitle(QwtPlot::xBottom, "time");
    setAxisScaleDraw(QwtPlot::xBottom, new HumanReadableTime()); // no need to de-alloc or store, plot does it

    // A-B markers
    for (int i=0; i<2; i++) {
        _user_markers[i].setLineStyle(QwtPlotMarker::VLine);
        _user_markers[i].setLabelAlignment(Qt::AlignRight | Qt::AlignBottom);
        _user_markers[i].setLinePen(QPen(QColor(255, 140, 0), 0, Qt::SolidLine));
        _user_markers_visible[i] = false;
    }
    _user_markers[0].setLabel(QwtText("A"));
    _user_markers[1].setLabel(QwtText("B"));

    // data marker
    _data_marker.setLineStyle(QwtPlotMarker::VLine);
    _data_marker.setLinePen(QPen(QColor(255, 160, 47), 2, Qt::SolidLine));
    _data_marker.setLabel(QwtText("data"));
    _data_marker.setLabelAlignment(Qt::AlignTop | Qt::AlignRight);
    _data_marker_visible = false;
    _data_marker.setZ(9999); // higher value -> paint on top of everything else

    setAutoReplot(true);
}
Пример #6
0
void MQwt::plot()
{
    mPlot = new QwtPlot(&mMain);
    mPlot->setCanvasBackground(QColor("White"));
    mPlot->setAutoReplot(true);

    // Grid; optional but I like them
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->attach(mPlot);
    grid->setMajorPen(Qt::black, 0, Qt::DotLine);
    grid->setMinorPen(Qt::gray, 0, Qt::DotLine);

    mMain.setCentralWidget(mPlot);
    mMain.show();
}
Пример #7
0
void SpectrumWindow::createSpectrumPlot()
{
    m_pSpectrumPlot = new QwtPlot();
    m_pSpectrumPlot->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    m_pSpectrumPlot->setMinimumSize(0, 0);
    m_pSpectrumPlot->setBaseSize(0, 0);
    m_pSpectrumPlot->enableAxis(QwtPlot::xBottom, true);
    m_pSpectrumPlot->enableAxis(QwtPlot::yLeft, true);
    QwtLogScaleEngine *pLogScale = new QwtLogScaleEngine();
    m_pSpectrumPlot->setAxisScaleEngine(QwtPlot::xBottom, pLogScale);
    m_pSpectrumPlot->setAxisAutoScale(QwtPlot::xBottom, false);
    m_pSpectrumPlot->setAxisScale(QwtPlot::xBottom, cMinFrequency, cMaxFrequency);
    m_pSpectrumPlot->setAxisFont(QwtPlot::xBottom, cAxisFont);
    m_pSpectrumPlot->setAxisFont(QwtPlot::yLeft, cAxisFont);
    m_pSpectrumPlot->setCanvasBackground(QColor(19, 19, 22));
    dynamic_cast<QwtPlotCanvas*>(m_pSpectrumPlot->canvas())->setFrameShadow(QFrame::Plain);

    m_pSpectrumPicker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
                                          QwtPicker::CrossRubberBand,
                                          QwtPicker::AlwaysOn,
                                          m_pSpectrumPlot->canvas());
    m_pSpectrumPicker->setTrackerPen(QColor(128, 255, 255));

    QwtText title(tr("Frequency, Hz"));
    title.setFont(cAxisTitleFont);
    title.setColor(cAxisTitleColor);
    m_pSpectrumPlot->setAxisTitle(QwtPlot::xBottom, title);
    m_pSpectrumPlot->setAxisAutoScale(QwtPlot::yLeft, false);
    //m_pSpectrumPlot->setAxisScale(QwtPlot::yLeft, 0.0, 1.0);
    m_pSpectrumPlot->setAxisScale(QwtPlot::yLeft, cDbScale, 0.0);
    m_yAxisScale = 1.0;

    QwtPlotGrid *pGrid = new QwtPlotGrid();
    pGrid->enableXMin(true);
    pGrid->setMajorPen(Qt::darkGray, 0, Qt::DotLine);
    pGrid->setMinorPen(Qt::gray, 0, Qt::DotLine);
    pGrid->attach(m_pSpectrumPlot);

    QPen pen;
    pen.setColor(cSpectrumColor);
    pen.setWidthF(1.0f);
    m_pSpectrumCurve = new QwtPlotCurve();
    m_pSpectrumCurve->setPen(pen);
    m_pSpectrumCurve->setBrush(cSpectrumFillColor);
    m_pSpectrumCurve->setBaseline(cDbScale - 50);   // Add offset to compensate plot margins
    m_pSpectrumCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    m_pSpectrumCurve->attach(m_pSpectrumPlot);
}
Пример #8
0
int main( int argc, char **argv )
{
  //using HistogramItem = QwtPlotItem;
  using HistogramItem = QwtPlotHistogram;
  //using QwtIntervalData = QwtSeriesData<QwtIntervalSample>;

  QApplication a(argc, argv);
  QwtPlot plot;
  plot.setCanvasBackground(QColor(Qt::white));
  plot.setTitle("Histogram");
  QwtPlotGrid *grid = new QwtPlotGrid;
  grid->enableXMin(true);
  grid->enableYMin(true);

  grid->setMajorPen(QPen(Qt::black, 0, Qt::DotLine));
  grid->setMinorPen(QPen(Qt::gray, 0 , Qt::DotLine));
  grid->attach(&plot);
  HistogramItem *histogram = new HistogramItem;
  //histogram->setColor(Qt::darkCyan);
  const int numValues = 20;
  //QwtArray<QwtDoubleInterval> intervals(numValues);
  QwtArray<QwtIntervalSample> intervals(numValues);
  QwtArray<double> values(numValues);
  double pos = 0.0;
  for ( int i = 0; i < (int)intervals.size(); i++ )
  {
    //const int width = 5 + rand() % 15;
    const int value = rand() % 100;
    //intervals[i] = QwtDoubleInterval(pos, pos + double(width));
    intervals[i] = QwtIntervalSample(value, pos, pos + double(width));
    //values[i] = value;
    pos += width;
  }

  //histogram->setData(QwtIntervalData(intervals, values));
  histogram->setSamples(intervals);
  //histogram->setSamples(QwtIntervalData(intervals, values));
  //QwtIntervalData d;
  //histogram->setData(d);
  histogram->attach(&plot);
  plot.setAxisScale(QwtPlot::yLeft, 0.0, 100.0);
  plot.setAxisScale(QwtPlot::xBottom, 0.0, pos);
  plot.replot();
  plot.resize(600,400);
  plot.show();
  return a.exec();
}
Пример #9
0
Plot::Plot( QWidget *parent, const QwtInterval &interval ):
    QwtPlot( parent )
{
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis ++ )
        setAxisScale( axis, interval.minValue(), interval.maxValue() );

    setCanvasBackground( QColor( Qt::darkBlue ) );
    plotLayout()->setAlignCanvasToScales( true );

    // grid
    QwtPlotGrid *grid = new QwtPlotGrid;
    //grid->enableXMin(true);
    grid->setMajorPen( Qt::white, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
    grid->attach( this );

    const int numEllipses = 10;

    for ( int i = 0; i < numEllipses; i++ )
    {
        const double x = interval.minValue() +
            qrand() % qRound( interval.width() );
        const double y = interval.minValue() +
            qrand() % qRound( interval.width() );
        const double r = interval.minValue() +
            qrand() % qRound( interval.width() / 6 );

        const QRectF area( x - r, y - r , 2 * r, 2 * r );

        RectItem *item = new RectItem( RectItem::Ellipse );
        item->setRenderHint( QwtPlotItem::RenderAntialiased, true );
        item->setRect( area );
        item->setPen( QPen( Qt::yellow ) );
        item->attach( this );
    }

    TextItem *textItem = new TextItem();
    textItem->setText( "Navigation Example" );
    textItem->attach( this );

    d_rectOfInterest = new RectItem( RectItem::Rect );
    d_rectOfInterest->setPen( Qt::NoPen );
    QColor c = Qt::gray;
    c.setAlpha( 100 );
    d_rectOfInterest->setBrush( QBrush( c ) );
    d_rectOfInterest->attach( this );
}
Пример #10
0
void panelControlMotor::chartSetting()
{
    QwtPlotGrid *grid = new QwtPlotGrid();
    ui->chartTemp->setAutoReplot(true);

    grid->setMinorPen(QPen(Qt::gray, 0, Qt::DotLine));
    grid->setMajorPen(QPen(Qt::gray, 0, Qt::DotLine));
    grid->enableX(true);
    grid->enableY(true);
    grid->attach(ui->chartTemp);

    temperature = new QwtPlotCurve();
    temperature->setTitle("temperature");
    temperature->setPen(Qt::black, 2, Qt::SolidLine);
    temperature->setRenderHint(QwtPlotItem::RenderAntialiased, true);
    temperature->attach(ui->chartTemp);
}
Пример #11
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);

}
Пример #12
0
void SpectrumWindow::createWaveformPlot()
{
    m_pWaveformPlot = new QwtPlot();
    m_pWaveformPlot->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    m_pWaveformPlot->setMinimumSize(0, 0);
    m_pWaveformPlot->setBaseSize(0, 0);
    m_pWaveformPlot->enableAxis(QwtPlot::xBottom, true);
    m_pWaveformPlot->enableAxis(QwtPlot::yLeft, true);
    m_pWaveformPlot->setAxisFont(QwtPlot::xBottom, cAxisFont);
    QwtText title(tr("Time, ms"));
    title.setFont(cAxisTitleFont);
    title.setColor(cAxisTitleColor);
    m_pWaveformPlot->setAxisTitle(QwtPlot::xBottom, title);
    m_pWaveformPlot->setAxisFont(QwtPlot::yLeft, cAxisFont);
    m_pWaveformPlot->setAxisAutoScale(QwtPlot::yLeft, false);
    m_pWaveformPlot->setAxisScale(QwtPlot::yLeft, -1.0, 1.0);
    m_pWaveformPlot->setCanvasBackground(QColor(32, 24, 16));
    dynamic_cast<QwtPlotCanvas*>(m_pWaveformPlot->canvas())->setFrameShadow(QFrame::Plain);

    m_pWaveformPicker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
                                          QwtPicker::CrossRubberBand,
                                          QwtPicker::AlwaysOn,
                                          m_pWaveformPlot->canvas());
    m_pWaveformPicker->setTrackerPen(QColor(255, 255, 128));

    QwtPlotGrid *pGrid = new QwtPlotGrid();
    pGrid->enableXMin(true);
    pGrid->setMajorPen(Qt::darkGray, 0, Qt::DotLine);
    pGrid->setMinorPen(Qt::gray, 0, Qt::DotLine);
    pGrid->attach(m_pWaveformPlot);

    QPen pen;
    pen.setColor(cWaveformColor);
    pen.setWidthF(1.5f);

    m_pWaveformCurve = new QwtPlotCurve();
    m_pWaveformCurve->setPen(pen);
    m_pWaveformCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    m_pWaveformCurve->attach(m_pWaveformPlot);
}
Пример #13
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);
}
Пример #14
0
void Histograma::populate(QImage *img)
{
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableX(false);
    grid->enableY(true);
    grid->enableXMin(true);
    grid->enableYMin(true);
    grid->setMajorPen(QPen(Qt::black, 0, Qt::DotLine));
    grid->setMinorPen(QPen(Qt::gray, 0, Qt::DotLine));
    grid->attach(this);

    int cinza, mQtd = 0;
    int x, y;
    // Quantidade de pontos de 0 a 255
    const int pts = 256;

    QVector<float> valores(pts);

    // inicializa os valores com 0
    for (int i = 0; i < pts; i++)
            valores[i] = 0.0;

    for (x = 0; x < img->width(); x++) {
        for (y = 0; y < img->height(); y++) {
            cinza = qGray(img->pixel(QPoint(x,y)));
            valores[cinza]++;

            if (valores[cinza] > mQtd)
                mQtd = valores[cinza];
        }
    }

    Histogram *hist = new Histogram("", Qt::black);
    hist->setValues(pts, &valores);

    hist->attach(this);
    this->replot();
}
Пример #15
0
//---------------------------------------------------------------------------
void Plots::Plots_Create(PlotType Type)
{
    // Paddings
    if (paddings[Type]==NULL)
    {
        paddings[Type]=new QWidget(this);
        paddings[Type]->setVisible(false);
    }

    // General design of plot
    QwtPlot* plot = new QwtPlot(this);
    plot->setVisible(false);
    plot->setMinimumHeight(1);
    plot->enableAxis(QwtPlot::xBottom, Type==PlotType_Axis);
    plot->setAxisMaxMajor(QwtPlot::yLeft, 0);
    plot->setAxisMaxMinor(QwtPlot::yLeft, 0);
    plot->setAxisScale(QwtPlot::xBottom, 0, FileInfoData->Videos[0]->x_Max[XAxis_Kind_index]);
    if (PerPlotGroup[Type].Count>3)
        plot->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    // Plot grid
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->enableXMin(true);
    grid->enableYMin(true);
    grid->setMajorPen(Qt::darkGray, 0, Qt::DotLine );
    grid->setMinorPen(Qt::gray, 0 , Qt::DotLine );
    grid->attach(plot);

    // Plot curves
    for(unsigned j=0; j<PerPlotGroup[Type].Count; ++j)
    {
        plotsCurves[Type][j] = new QwtPlotCurve(PerPlotName[PerPlotGroup[Type].Start+j].Name);
        QColor c;

        switch (PerPlotGroup[Type].Count)
        {
             case 1 :
                        switch (Type)
                        {
                            case PlotType_YDiff: c=Qt::darkGreen; break;
                            case PlotType_UDiff: c=Qt::darkBlue; break;
                            case PlotType_VDiff: c=Qt::darkRed; break;
                            default: c=Qt::black;
                        }
                        break;
             case 2 :
                        switch (j)
                        {
                            case 0: c=Qt::darkGreen; break;
                            case 1: c=Qt::darkRed; break;
                            default: c=Qt::black;
                        }
                        break;
             case 3 :
                        switch (j)
                        {
                            case 0: c=Qt::darkRed; break;
                            case 1: c=Qt::darkBlue; break;
                            case 2: c=Qt::darkGreen; break;
                            default: c=Qt::black;
                        }
                        break;
             case 5 :
                        switch (j)
                        {
                            case 0: c=Qt::red; break;
                            case 1: c=QColor::fromRgb(0x00, 0x66, 0x00); break; //Qt::green
                            case 2: c=Qt::black; break;
                            case 3: c=Qt::green; break;
                            case 4: c=Qt::red; break;
                            default: c=Qt::black;
                        }
                        break;
            default:    c=Qt::black;
        }

        plotsCurves[Type][j]->setPen(c);
        plotsCurves[Type][j]->setRenderHint(QwtPlotItem::RenderAntialiased);
        plotsCurves[Type][j]->setZ(plotsCurves[Type][j]->z()-j); //Invert data order (e.g. MAX before MIN)
        plotsCurves[Type][j]->attach(plot);
     }

    // Legends
    QwtLegend *legend = new QwtLegend(this);
    legend->setVisible(false);
    legend->setMinimumHeight(1);
    legend->setMaxColumns(1);
    QFont Font=legend->font();
    #ifdef _WIN32
        Font.setPointSize(6);
    #else // _WIN32
        Font.setPointSize(8);
    #endif //_WIN32
    legend->setFont(Font);
    connect(plot, SIGNAL(legendDataChanged(const QVariant &, const QList<QwtLegendData> &)), legend, SLOT(updateLegend(const QVariant &, const QList<QwtLegendData> &)));
    plot->updateLegend();

    // Assignment
    plots[Type]=plot;
    legends[Type]=legend;

    // Pickers
    plotsPickers[Type] = new QwtPlotPicker( QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, plots[Type]->canvas() );
    plotsPickers[Type]->setStateMachine( new QwtPickerDragPointMachine () );
    plotsPickers[Type]->setRubberBandPen( QColor( Qt::green ) );
    plotsPickers[Type]->setTrackerPen( QColor( Qt::white ) );
    connect(plotsPickers[Type], SIGNAL(moved(const QPointF&)), SLOT(plot_moved(const QPointF&)));
    connect(plotsPickers[Type], SIGNAL(selected(const QPointF&)), SLOT(plot_moved(const QPointF&)));

    // Marker
    QwtPlotMarker* plotMarker=new QwtPlotMarker;
    plotMarker->setLineStyle(QwtPlotMarker::VLine);
    plotMarker->setLinePen(QPen(Qt::magenta, 1));
    plotMarker->setXValue(0);
    plotMarker->attach(plot);
    plotsMarkers[Type]=plotMarker;
}
Пример #16
0
BrainPlot::BrainPlot(QWidget *parent, int nChannels, int Length, int Amplitude):
    QwtPlot( parent ),
    d_curves( nChannels ),
    d_zeros( nChannels )
{
    /*Set some attributes*/
    minusExpectedAmplitude = -Amplitude;
    plotLength = Length;
    this->nChannels = nChannels;

    /*Start sample counter*/
    sample = 0;

    /*Painter*/
    d_directPainter = new QwtPlotDirectPainter( this );
    if ( QwtPainter::isX11GraphicsSystem() )
    {
#if QT_VERSION < 0x050000
        canvas()->setAttribute( Qt::WA_PaintOutsidePaintEvent, true );
#endif
        canvas()->setAttribute( Qt::WA_PaintOnScreen, true );
    }

    /*Activates the legend for channel tracking*/
    QwtLegend *legend = new QwtLegend;
    legend->setDefaultItemMode( QwtLegendData::ReadOnly);
    insertLegend( legend, QwtPlot::LeftLegend );

    /*Instantiate the reference lines and the data curves for each channel*/
    int Hfactor = 360/(nChannels+1);//different colors for each curve
    char name[15];

    for(int c = 0; c < nChannels; c++) {
        /*Curve*/
        sprintf(name, "Channel %d", c+1);
        d_curves[c] = new QwtPlotCurve( name);
        d_curves[c]->setData( new CurveData(plotLength,
                                            minusExpectedAmplitude*(2*c+1)) );
        d_curves[c]->setPen( QColor::fromHsv ( Hfactor*c, 255, 255));
        d_curves[c]->setStyle( QwtPlotCurve::Lines );
        d_curves[c]->setSymbol( new QwtSymbol( QwtSymbol::NoSymbol));
        d_curves[c]->attach( this );

        /*Reference line*/
        d_zeros[c] = new QwtPlotCurve;
        d_zeros[c]->setData( new CurveData() );
        d_zeros[c]->setPen( QColor::fromHsv ( Hfactor*c, 255, 140));
        d_zeros[c]->setStyle( QwtPlotCurve::Lines );
        d_zeros[c]->setSymbol( new QwtSymbol( QwtSymbol::NoSymbol));
        d_zeros[c]->setItemAttribute(QwtPlotItem::Legend, false);
        d_zeros[c]->attach( this );

        /*Draw reference lines*/
        CurveData *data = static_cast<CurveData *>( d_zeros[c]->data() );
        data->append(QPointF(0, minusExpectedAmplitude*(2*c+1)));
        data->append(QPointF(plotLength, minusExpectedAmplitude*(2*c+1)));
        d_directPainter->drawSeries( d_zeros[c], 0, 1);
    }

    /*Sweeping line*/
    d_sweep = new QwtPlotCurve;
    d_sweep->setData( new CurveData() );
    d_sweep->setPen( Qt::black, plotLength/100, Qt::SolidLine);
    d_sweep->setStyle( QwtPlotCurve::Lines );
    d_sweep->setSymbol( new QwtSymbol( QwtSymbol::NoSymbol));
    d_sweep->setItemAttribute(QwtPlotItem::Legend, false);
    d_sweep->attach( this );

    CurveData *data = static_cast<CurveData *>( d_sweep->data() );
    data->append(QPointF(0, plotLength));
    data->append(QPointF(0, 2*nChannels*minusExpectedAmplitude));

    /*Axis*/
    setAxisScale( xBottom, 0, plotLength );
    setAxisScale( yLeft, 2*nChannels*minusExpectedAmplitude, 0 );

    enableAxis(xBottom, false);
    enableAxis(yLeft, false);

    /*Frame*/
    setFrameStyle( QFrame::NoFrame );
    setLineWidth( 0 );

    /*Canvas*/
    plotLayout()->setAlignCanvasToScales( true );
    plotLayout()->setCanvasMargin(100, QwtPlot::xBottom);
    plotLayout()->setCanvasMargin(100, QwtPlot::xTop);
    setCanvasBackground( Qt::black );

    /*Grid*/
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->setMajorPen( Qt::gray, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0, Qt::DotLine );
    grid->enableYMin(true);
    grid->attach( this );

    /*Optimizaion for real-time data collecting*/
    setAutoReplot( false );

    /*Show*/
    replot();
}
Пример #17
0
//---------------------------------------------------------------------------
Plot::Plot( size_t streamPos, size_t Type, size_t Group, QWidget *parent ) :
    QwtPlot( parent ),
    m_streamPos( streamPos ),
    m_type( Type ),
    m_group( Group )
{
    setAutoReplot( false );

    QwtPlotCanvas* canvas = dynamic_cast<QwtPlotCanvas*>( this->canvas() );
    if ( canvas )
    {
        canvas->setFrameStyle( QFrame::Plain | QFrame::Panel );
        canvas->setLineWidth( 1 );
#if 1
        canvas->setPalette( QColor("Cornsilk") );
#endif
    }

    setAxisMaxMajor( QwtPlot::yLeft, 0 );
    setAxisMaxMinor( QwtPlot::yLeft, 0 );
    setAxisScaleDraw( QwtPlot::yLeft, new PlotScaleDrawY() );

    enableAxis( QwtPlot::xBottom, false );

    // something invalid
    setAxisScale( QwtPlot::xBottom, -1, 0 );
    setAxisScale( QwtPlot::yLeft, -1, 0 );

    // Plot grid
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->enableXMin( true );
    grid->enableYMin( true );
    grid->setMajorPen( Qt::darkGray, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
    grid->attach( this );

    m_cursor = new PlotCursor( canvas );
    m_cursor->setPosition( 0 );

    // curves

    for( unsigned j = 0; j < PerStreamType[m_type].PerGroup[m_group].Count; ++j )
    {
        QwtPlotCurve* curve = new QwtPlotCurve( PerStreamType[m_type].PerItem[PerStreamType[m_type].PerGroup[m_group].Start + j].Name );

        curve->setPen( curveColor( j ) );
        curve->setRenderHint( QwtPlotItem::RenderAntialiased );
        curve->setZ( curve->z() - j ); //Invert data order (e.g. MAX before MIN)
        curve->attach( this );

        m_curves += curve;
    }

    // visual helpers
    if ( m_type == Type_Video )
    switch (m_group)
    {
        case Group_Y :
                        Plot_AddHLine( this,  16,  61,  89, 171);
                        Plot_AddHLine( this, 235, 220,  20,  60);
                        break;
        case Group_U :
        case Group_V :
                        Plot_AddHLine( this,  16,  61,  89, 171);
                        Plot_AddHLine( this, 240, 220,  20,  60);
                        break;
        case Group_Sat :
                        Plot_AddHLine( this,  88, 255,   0, 255);
                        Plot_AddHLine( this, 118, 220,  20,  60);
                        break;
        default      :  ;  
    }

    PlotPicker* picker = new PlotPicker( canvas, &PerStreamType[m_type], m_group, &m_curves );
    connect( picker, SIGNAL( moved( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );
    connect( picker, SIGNAL( selected( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );

    connect( axisWidget( QwtPlot::xBottom ), SIGNAL( scaleDivChanged() ), SLOT( onXScaleChanged() ) );

    // legend
    m_legend = new PlotLegend();
    
    connect( this, SIGNAL( legendDataChanged( const QVariant &, const QList<QwtLegendData> & ) ),
         m_legend, SLOT( updateLegend( const QVariant &, const QList<QwtLegendData> & ) ) );

    updateLegend();
}
Пример #18
0
QmitkHistogramWidget::QmitkHistogramWidget(QWidget * parent, bool showreport)
  : QDialog(parent)
  , m_Plot(NULL)
  , m_Textedit(NULL)
  , m_Marker(NULL)
  , m_Picker(NULL)
  , m_Zoomer(NULL)
  , m_Histogram(NULL)
{
  QBoxLayout *layout = new QVBoxLayout(this);

  //***histogram***

  QGroupBox *hgroupbox = new QGroupBox("", this);

  hgroupbox->setMinimumSize(900, 400);

  m_Plot = new QwtPlot(hgroupbox);
  m_Plot->setCanvasBackground(QColor(Qt::white));
  m_Plot->setTitle("Histogram");
  QwtText text = m_Plot->titleLabel()->text();
  text.setFont(QFont("Helvetica", 12, QFont::Normal));

  QwtPlotGrid *grid = new QwtPlotGrid;
  grid->enableXMin(true);
  grid->enableYMin(true);
  grid->setMajorPen(QPen(Qt::black, 0, Qt::DotLine));
  grid->setMinorPen(QPen(Qt::gray, 0 , Qt::DotLine));
  grid->attach(m_Plot);

  layout->addWidget(hgroupbox);

  layout->setSpacing(20);

  if (showreport == true)
  {
    //***report***
    QGroupBox *rgroupbox = new QGroupBox("", this);

    rgroupbox->setMinimumSize(900, 400);

    QLabel *label = new QLabel("Gray  Value  Analysis", rgroupbox);
    label->setAlignment(Qt::AlignHCenter);
    label->setFont(QFont("Helvetica", 14, QFont::Bold));

    m_Textedit = new QTextEdit(rgroupbox);
    m_Textedit->setFont(QFont("Helvetica", 12, QFont::Normal));
    m_Textedit->setReadOnly(true);

    layout->addWidget(rgroupbox);
  }

  m_Picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
                               QwtPlotPicker::NoRubberBand, QwtPicker::AlwaysOn,
                               m_Plot->canvas());
  // the m_PickerMachine pointer is managed by the m_Picker instance
  m_Picker->setStateMachine(new QwtPickerClickPointMachine());

  connect(m_Picker, SIGNAL(selected(const QwtDoublePoint &)),
    SLOT(OnSelect(const QwtDoublePoint &)));
}
Пример #19
0
Plot::Plot(QWidget *parent):QwtPlot( parent )
{    setAutoReplot( false );

     setTitle( "FFT" );

     QwtPlotCanvas *canvas = new QwtPlotCanvas();
     canvas->setBorderRadius( 10 );

     setCanvas( canvas );
     setCanvasBackground( QColor( "MidnightBlue" ) );

     // legend
     QwtLegend *legend = new QwtLegend;
     insertLegend( legend, QwtPlot::BottomLegend );

     // grid
     QwtPlotGrid *grid = new QwtPlotGrid;
     grid->enableXMin( true );
     grid->setMajorPen( Qt::white, 0, Qt::DotLine );
     grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
     grid->attach( this );

     // axes
     //enableAxis( QwtPlot::yRight );
     setAxisTitle( QwtPlot::xBottom, "Frequency [kHz]" );
     setAxisTitle( QwtPlot::yLeft, "Amplitude " );
     //setAxisTitle( QwtPlot::yRight, "Phase [deg]" );




     setAxisMaxMajor( QwtPlot::xBottom, 6 );
     setAxisMaxMinor( QwtPlot::xBottom, 9 );


      //setAxisScale(QwtPlot::xBottom,0.01,100);

     //setAxisScaleEngine( QwtPlot::xBottom, ScaleEngine_Lin_X );


     // setAxisScaleEngine(QwtPlot::xBottom, new QwtLogScaleEngine );

     // curves


     d_curve1 = new QwtPlotCurve( "Amplitude Ch1" );
     d_curve1->setRenderHint( QwtPlotItem::RenderAntialiased );
     d_curve1->setPen( Qt::red );
     d_curve1->setLegendAttribute( QwtPlotCurve::LegendShowLine );
     d_curve1->setYAxis( QwtPlot::yLeft );
     d_curve1->attach( this );




     m_Channel2=true;

      if(m_Channel2){
         d_curve2 = new QwtPlotCurve( "Amplitude Ch2 " );
         d_curve2->setRenderHint( QwtPlotItem::RenderAntialiased );
         d_curve2->setPen( Qt::magenta );
         d_curve2->setLegendAttribute( QwtPlotCurve::LegendShowLine );
         d_curve2->setYAxis( QwtPlot::yLeft );
         d_curve2->attach( this );
      }

      d_average = new QwtPlotCurve( "Average Ch1" );
      d_average->setRenderHint( QwtPlotItem::RenderAntialiased );
      d_average->setPen( Qt::white );
      d_average->setLegendAttribute( QwtPlotCurve::LegendShowLine );
      d_average->setYAxis( QwtPlot::yLeft );
      d_average->attach( this );


     // marker
     d_marker1 = new QwtPlotMarker();
     d_marker1->setValue( 0.0, 0.0 );
     d_marker1->setLineStyle( QwtPlotMarker::VLine );
     d_marker1->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
     d_marker1->setLinePen(  Qt::green, 0, Qt::DashDotLine );
     d_marker1->attach( this );

      if(m_Channel2){
        /*  d_marker2 = new QwtPlotMarker();
          d_marker2->setValue( 0.0, 0.0 );
          d_marker2->setLineStyle( QwtPlotMarker::VLine );
          d_marker2->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
          d_marker2->setLinePen(  Qt::gray, 0, Qt::DashDotLine );
          d_marker2->attach( this );*/

          /*
         d_marker2 = new QwtPlotMarker();
         d_marker2->setLineStyle( QwtPlotMarker::HLine );
         d_marker2->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
         d_marker2->setLinePen( QColor( 200, 150, 0 ), 0, Qt::DashDotLine );
         d_marker2->setSymbol( new QwtSymbol( QwtSymbol::Diamond,
            QColor( Qt::yellow ), QColor( Qt::green ), QSize( 8, 8 ) ) );
         d_marker2->attach( this );*/
      }

    //setDamp( 0.0 );

     setAutoReplot( true );


}
Пример #20
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)));
}
Пример #21
0
void scopePlot::init(QString title)
{
  
  setup=true;
  setCentralWidget(wd);
  connect(ui.offsetWheel, SIGNAL(valueChanged(double)),SLOT(slotOffsetChanged(double )));
  connect(ui.rangeWheel, SIGNAL(valueChanged(double)), SLOT(slotRangeChanged(double )));
  connect(ui.samplesPushButton, SIGNAL(clicked()), this, SLOT(slotSamplesButtton()));
  plW=ui.plotWindow;
  plW->setTitle(title);
  plW->setCanvasBackground(Qt::darkBlue);
  curve1->attach(plW);
  curve2->attach(plW);
  curve3->attach(plW);
  curve4->attach(plW);
  plW->setAxisTitle(QwtPlot::xBottom,xAxisTitle);
  plW->setAxisScale(QwtPlot::xBottom, 0, 100);
  plW->setAxisTitle(QwtPlot::yLeft, "Values");
  plW->setAxisScale(QwtPlot::yLeft, -1.5, 1.5);

  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(plW);
  QwtText m1("M1");
  m1.setColor(QColor(Qt::white));
  marker1=new QwtPlotMarker();
  marker1->setValue(0.0, 0.0);
  marker1->setLabel(m1);
  marker1->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom);
  marker1->setLinePen(QPen(QColor(200,150,0), 0, Qt::DashDotLine));
  marker1->setSymbol( new QwtSymbol(QwtSymbol::Diamond,QColor(Qt::green), QColor(Qt::green), QSize(7,7)));
  //	marker1->hide();
  marker1->attach(plW);



  QwtText m2("M2");
  m2.setColor(QColor(Qt::white));
  marker2=new QwtPlotMarker();
  marker2->setValue(0.0, 0.0);
  marker2->setLabel(m2);
  marker2->setLabelAlignment(Qt::AlignLeft | Qt::AlignTop);
  marker2->setLinePen(QPen(QColor(200,150,0), 0, Qt::DashDotLine));
  marker2->setSymbol( new QwtSymbol(QwtSymbol::Diamond,QColor(Qt::yellow), QColor(Qt::yellow), QSize(7,7)));
  //	marker2->hide();
  marker2->attach(plW);



  legend = new QwtLegend;
  legend->setFrameStyle(QFrame::Box|QFrame::Sunken);
  legend->setDefaultItemMode(QwtLegendData::Checkable);
  QPalette pal(legend->palette());
  pal.setColor(QPalette::Window,Qt::darkBlue);
  pal.setColor(QPalette::WindowText,Qt::white);
  pal.setColor(QPalette::Text,Qt::black);
  legend->setPalette(pal);
  plW->insertLegend(legend, QwtPlot::BottomLegend);

  picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, plW->canvas());
  picker->setStateMachine(new QwtPickerDragPointMachine());
  picker->setRubberBandPen(QColor(Qt::green));
  picker->setRubberBand(QwtPicker::CrossRubberBand);
  picker->setTrackerPen(QColor(Qt::white));
  picker->setEnabled(true);
  plW->replot();

  QwtPlotItemList items = plW->itemList( QwtPlotItem::Rtti_PlotCurve);
  for ( int i = 0; i < items.size(); i++ )
    {
      const QVariant itemInfo = plW->itemToInfo( items[i] );

      QwtLegendLabel *legendLabel =qobject_cast<QwtLegendLabel *>( legend->legendWidget( itemInfo ) );
      if (legendLabel )
        {
          legendLabel->setChecked( true );
        }

      items[i]->setVisible( true );
    }
  connect(picker, SIGNAL(moved(const QPointF  &)),SLOT(pickerMoved(const QPointF &)));
  connect(picker, SIGNAL(selected(const QPointF  &)), SLOT(pickerSelected(const QPointF  &)));
  connect(legend, SIGNAL(checked(const QVariant &, bool ,int)),SLOT(legendClicked(const QVariant &,bool)));
  connect(ui.nextButton, SIGNAL(clicked()),SLOT(slotNext()));
  connect(ui.previousButton, SIGNAL(clicked()),SLOT(slotPrevious()));
  plW->setAxisTitle(QwtPlot::xBottom,xAxisTitle);
  xOffset=0;
}
Пример #22
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent)
{
    setPalette( Qt::black );

    // we want to have the axis scales like a frame around the
    // canvas
    plotLayout()->setAlignCanvasToScales( true );
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
        axisWidget( axis )->setMargin( 0 );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setAutoFillBackground( false );
    canvas->setFrameStyle( QFrame::NoFrame );
    setCanvas( canvas );

    setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );

    // a title
    QwtText title( "Picker Demo" );
    title.setColor( Qt::white );
    title.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop );

    QFont font;
    font.setBold( true );
    title.setFont( font );

    QwtPlotTextLabel *titleItem = new QwtPlotTextLabel();
    titleItem->setText( title );
    titleItem->attach( this );

#if 1
    // section

    //QColor c( "PaleVioletRed" );

    QwtPlotZoneItem* zone = new QwtPlotZoneItem();
    zone->setPen( Qt::darkGray );
    zone->setBrush( QColor( "#834358" ) );
    zone->setOrientation( Qt::Horizontal );
    zone->setInterval( 3.8, 5.7 );
    zone->attach( this );

#else
    // grid

    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setMajorPen( Qt::white, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
    grid->attach( this );
#endif

    // curves

    QPolygonF points1;
    points1 << QPointF( 0.2, 4.4 ) << QPointF( 1.2, 3.0 )
            << QPointF( 2.7, 4.5 ) << QPointF( 3.5, 6.8 )
            << QPointF( 4.7, 7.9 ) << QPointF( 5.8, 7.1 );

    insertCurve( "Curve 1", "DarkOrange", points1 );

    QPolygonF points2;
    points2 << QPointF( 0.4, 8.7 ) << QPointF( 1.4, 7.8 )
            << QPointF( 2.3, 5.5 ) << QPointF( 3.3, 4.1 )
            << QPointF( 4.4, 5.2 ) << QPointF( 5.6, 5.7 );

    insertCurve( "Curve 2", "DodgerBlue", points2 );

    CurveTracker* tracker = new CurveTracker( this->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" ) );
}
Пример #23
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent )
{
    setAutoReplot( false );

    setTitle( "Frequency Response of a Second-Order System" );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setBorderRadius( 10 );

    setCanvas( canvas );
    setCanvasBackground( QColor( "MidnightBlue" ) );

    // legend
    QwtLegend *legend = new QwtLegend;
    insertLegend( legend, QwtPlot::BottomLegend );

    // grid
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin( true );
    grid->setMajorPen( Qt::white, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
    grid->attach( this );

    // axes
    enableAxis( QwtPlot::yRight );
    setAxisTitle( QwtPlot::xBottom, "Normalized Frequency" );
    setAxisTitle( QwtPlot::yLeft, "Amplitude [dB]" );
    setAxisTitle( QwtPlot::yRight, "Phase [deg]" );

    setAxisMaxMajor( QwtPlot::xBottom, 6 );
    setAxisMaxMinor( QwtPlot::xBottom, 9 );
    setAxisScaleEngine( QwtPlot::xBottom, new QwtLogScaleEngine );

    // curves
    d_curve1 = new QwtPlotCurve( "Amplitude" );
    d_curve1->setRenderHint( QwtPlotItem::RenderAntialiased );
    d_curve1->setPen( Qt::yellow );
    d_curve1->setLegendAttribute( QwtPlotCurve::LegendShowLine );
    d_curve1->setYAxis( QwtPlot::yLeft );
    d_curve1->attach( this );

    d_curve2 = new QwtPlotCurve( "Phase" );
    d_curve2->setRenderHint( QwtPlotItem::RenderAntialiased );
    d_curve2->setPen( Qt::cyan );
    d_curve2->setLegendAttribute( QwtPlotCurve::LegendShowLine );
    d_curve2->setYAxis( QwtPlot::yRight );
    d_curve2->attach( this );

    // marker
    d_marker1 = new QwtPlotMarker();
    d_marker1->setValue( 0.0, 0.0 );
    d_marker1->setLineStyle( QwtPlotMarker::VLine );
    d_marker1->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
    d_marker1->setLinePen( Qt::green, 0, Qt::DashDotLine );
    d_marker1->attach( this );

    d_marker2 = new QwtPlotMarker();
    d_marker2->setLineStyle( QwtPlotMarker::HLine );
    d_marker2->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
    d_marker2->setLinePen( QColor( 200, 150, 0 ), 0, Qt::DashDotLine );
    d_marker2->setSymbol( new QwtSymbol( QwtSymbol::Diamond,
        QColor( Qt::yellow ), QColor( Qt::green ), QSize( 8, 8 ) ) );
    d_marker2->attach( this );

    setDamp( 0.0 );

    setAutoReplot( true );
}