Esempio n. 1
0
Plot::Plot(QWidget *parent):
    QwtPlot( parent )
{
    // panning with the left mouse button
    (void) new QwtPlotPanner( canvas() );

    // zoom in/out with the wheel
    (void) new QwtPlotMagnifier( canvas() );

    setAutoFillBackground( true );
    setPalette( QPalette( QColor( 165, 193, 228 ) ) );
    updateGradient();

    setTitle("A Simple QwtPlot Demonstration");
    insertLegend(new QwtLegend(), QwtPlot::RightLegend);

    // axes 
    setAxisTitle(xBottom, "x -->" );
    setAxisScale(xBottom, 0.0, 10.0);

    setAxisTitle(yLeft, "y -->");
    setAxisScale(yLeft, -1.0, 1.0);

    // canvas
    canvas()->setLineWidth( 1 );
    canvas()->setFrameStyle( QFrame::Box | QFrame::Plain );
    canvas()->setBorderRadius( 15 );

    QPalette canvasPalette( Qt::white );
    canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
    canvas()->setPalette( canvasPalette );

    populate();
}
Esempio n. 2
0
BarChart::BarChart( QWidget *parent ):
    QwtPlot( parent )
{
    const struct 
    {
        const char *distro;
        const int hits;
        QColor color;

    } pageHits[] =
    {
        { "Arch", 1114, QColor( "DodgerBlue" ) },
        { "Debian", 1373, QColor( "#d70751" ) },
        { "Fedora", 1638, QColor( "SteelBlue" ) },
        { "Mageia", 1395, QColor( "Indigo" ) },
        { "Mint", 3874, QColor( 183, 255, 183 ) },
        { "openSuSE", 1532, QColor( 115, 186, 37 ) },
        { "Puppy", 1059, QColor( "LightSkyBlue" ) },
        { "Ubuntu", 2391, QColor( "FireBrick" ) }
    };

    setAutoFillBackground( true );
    setPalette( QColor( "Linen" ) );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setLineWidth( 2 );
    canvas->setFrameStyle( QFrame::Box | QFrame::Sunken );
    canvas->setBorderRadius( 10 );

    QPalette canvasPalette( QColor( "Plum" ) );
    canvasPalette.setColor( QPalette::Foreground, QColor( "Indigo" ) );
    canvas->setPalette( canvasPalette );

    setCanvas( canvas );

    setTitle( "DistroWatch Page Hit Ranking, April 2012" );

    d_barChartItem = new DistroChartItem();

    QVector< double > samples;

    for ( uint i = 0; i < sizeof( pageHits ) / sizeof( pageHits[ 0 ] ); i++ )
    {
        d_distros += pageHits[ i ].distro;
        samples += pageHits[ i ].hits;

        d_barChartItem->addDistro( 
            pageHits[ i ].distro, pageHits[ i ].color );
    }

    d_barChartItem->setSamples( samples );

    d_barChartItem->attach( this );

    insertLegend( new QwtLegend() );

    setOrientation( 0 );
    setAutoReplot( false );
}
Esempio n. 3
0
void caStripPlot::setBackground(QColor c)
{
    thisBackColor = c;
    QPalette canvasPalette(c);
    canvasPalette.setColor(QPalette::Foreground, QColor(133, 190, 232));
    canvas()->setPalette(canvasPalette);
    replot();
}
FrameNumberVisualizator::FrameNumberVisualizator(int duree,int dataFreq,int min, int max, QWidget *parent):
   QWidget(parent),
   duree_de_visualisation(duree),
   frequency(dataFreq)
{

   QHBoxLayout * mainLayout = new QHBoxLayout;
   this->setLayout(mainLayout);

   plot = new QwtPlot();
   mainLayout->addWidget(plot,5);

   //Axis
   plot->enableAxis(QwtPlot::xBottom,false);
   plot->setAxisScale( QwtPlot::xBottom, 0.0, duree_de_visualisation );
   plot->setAxisScale( QwtPlot::yLeft, 0, 1000 );

   // canvas
   QwtPlotCanvas *canvas = new QwtPlotCanvas();
   canvas->setLineWidth( 1 );
   canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
   canvas->setBorderRadius( 15 );

   QPalette canvasPalette( Qt::white );
   canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
   canvas->setPalette( canvasPalette );

   plot->setCanvas( canvas );

   curve = new QwtPlotCurve("frame");
   curve->setRenderHint( QwtPlotItem::RenderAntialiased );
   curve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
   curve->setPen( Qt::red );
   curve->attach( plot );

   timerReplot = new QTimer;
   timerReplot->setInterval(50);
   connect(timerReplot,SIGNAL(timeout()),plot,SLOT(replot()));

   timerRescale = new QTimer;
   timerRescale->setInterval(1000);
   connect(timerRescale,SIGNAL(timeout()),SLOT(rescale()));

}
Esempio n. 5
0
Plot::Plot(QWidget *parent):
    QwtPlot( parent )
{
    setAutoFillBackground( true );
    setPalette( QPalette( QColor( 165, 193, 228 ) ) );
    updateGradient();

    setTitle( "График аппроксимации" );
    insertLegend( new QwtLegend(), QwtPlot::RightLegend );

    // axes
    setAxisTitle( xBottom, "" );
    setAxisScale( xBottom, 0.0, 60.0 );

    setAxisTitle( yLeft, "Функция принадлежности -->" );
    setAxisScale( yLeft, -0.1, 1.1 );

    // canvas
    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setLineWidth( 1 );
    canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    canvas->setBorderRadius( 15 );

    QPalette canvasPalette( Qt::white );
    canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
    canvas->setPalette( canvasPalette );

    setCanvas( canvas );

    // panning with the left mouse button
    //( void ) new QwtPlotPanner( canvas );

    // zoom in/out with the wheel
    ( void ) new QwtPlotMagnifier( canvas );

    zoom = new QwtPlotZoomer(canvas);
    zoom->setRubberBandPen(QPen(Qt::red));

    clear();

    //  ...a horizontal line at y = 0...

<<<<<<< HEAD
CallLogPlot::CallLogPlot(QwtPlot* plot, QObject* parent)
    :QObject(parent)
    , m_plot(plot)
    , m_barScaleDrawX(NULL)
    , m_barCount(0)
{
    Q_ASSERT(m_plot);
    m_plot->setAutoReplot(false);

    // 设置图表颜色
    m_plot->setAutoFillBackground(true);
    m_plot->setPalette(QColor("Linen"));

    // 设置图表画布
    QwtPlotCanvas* canvas = new QwtPlotCanvas();
    canvas->setLineWidth(2);
    canvas->setFrameStyle(QFrame::Box | QFrame::Sunken);
    QPalette canvasPalette(QColor("Plum"));
    canvasPalette.setColor(QPalette::Foreground, QColor("Indigo"));
    canvas->setPalette(canvasPalette);
    m_plot->setCanvas(canvas);

    // 创建柱状图表
    m_barChart = new BarChart();
    m_barChart->attach(m_plot);
    m_barChart->setOrientation(Qt::Vertical);

    // 设置X坐标轴
    m_barScaleDrawX = new BarScaleDrawX();
    m_plot->setAxisMaxMajor(QwtPlot::xBottom, 0);
    m_plot->setAxisScaleDraw(QwtPlot::xBottom, m_barScaleDrawX);

    // 设置Y坐标轴
    m_barScaleDrawY = new BarScaleDrawY();
    m_plot->setAxisMaxMinor(QwtPlot::yLeft, 3);
    m_plot->setAxisScaleDraw(QwtPlot::yLeft, m_barScaleDrawY);

    // 设置布局
    m_plot->plotLayout()->setCanvasMargin(0);
    m_plot->replot();
}
Esempio n. 7
0
File: psd.cpp Progetto: timqi/psd
Psd::Psd(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Psd)
{
    ui->setupUi(this);

    ui->plot->setTitle("原信号:cos(2*PI*40*i)+3*cos(2*PI*100*i)+w(n)");
    ui->plot->setAutoFillBackground( true );
    ui->plot->insertLegend( new QwtLegend(), QwtPlot::RightLegend );
    ui->plot->setAutoReplot( false );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setLineWidth( 1 );
    canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    canvas->setBorderRadius( 15 );

    QPalette canvasPalette( Qt::white );
    canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
    canvas->setPalette( canvasPalette );
    ui->plot->setCanvas( canvas );

    ( void ) new QwtPlotPanner( canvas );
    ( void ) new QwtPlotMagnifier( canvas );

    cSin->setRenderHint( QwtPlotItem::RenderAntialiased );
    cSin->setLegendAttribute( QwtPlotCurve::LegendShowLine, false );
    cSin->setPen( Qt::red );
    cSin->attach( ui->plot );

    QwtPlotMarker *mY = new QwtPlotMarker();
    mY->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
    mY->setLineStyle( QwtPlotMarker::HLine );
    mY->setYValue( 0.0 );
    mY->attach( ui->plot );

    init();
    pf();
    populate();
}
Esempio n. 8
0
Plot::Plot(QWidget *parent):
    QwtPlot( parent )
{
    setAutoFillBackground( true );
    setPalette( QPalette( QColor( 165, 193, 228 ) ) );
    updateGradient();

    setTitle( "График аппроксимации" );
    insertLegend( new QwtLegend(), QwtPlot::RightLegend );

    // axes
    setAxisTitle( xBottom, "" );
    setAxisScale( xBottom, 0.0, 10.0 );

    setAxisTitle( yLeft, "Функция принадлежности -->" );
    setAxisScale( yLeft, 0, 2 );

    // canvas
    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setLineWidth( 1 );
    canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    canvas->setBorderRadius( 15 );

    QPalette canvasPalette( Qt::white );
    canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
    canvas->setPalette( canvasPalette );

    setCanvas( canvas );

    // panning with the left mouse button
    ( void ) new QwtPlotPanner( canvas );

    // zoom in/out with the wheel
    ( void ) new QwtPlotMagnifier( canvas );

    //  ...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 horizontal line at y = 1...
    QwtPlotMarker *mY1 = new QwtPlotMarker();
    mY1->setLabel( QString::fromLatin1( "y = 1" ) );
    mY1->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
    mY1->setLineStyle( QwtPlotMarker::HLine );
    mY1->setYValue( 1.0 );
    mY1->setLinePen(Qt::black, 1, Qt::DashLine);
    mY1->attach( this );

    //  ...a vertical line at x = 0
    QwtPlotMarker *mX = new QwtPlotMarker();
    mX->setLabel( QString::fromLatin1( "x = 0" ) );
    mX->setLabelAlignment( Qt::AlignLeft | Qt::AlignBottom );
    mX->setLabelOrientation( Qt::Vertical );
    mX->setLineStyle( QwtPlotMarker::VLine );
    mX->setLinePen( Qt::black, 0, Qt::DashDotLine );
    mX->setXValue( 0 );
    mX->attach( this );

//    curvePoints = new QwtPlotCurve();
//    curvePoints->setStyle( QwtPlotCurve::Dots );
//    curvePoints->attach( this );
}
ThreeAxisDataVisualizator::ThreeAxisDataVisualizator(int duree,int dataFreq,int min, int max, int _type, QWidget *parent):
    QWidget(parent),
    duree_de_visualisation(duree),
    frequency(dataFreq),
    type(_type),
    min(0),
    max(0)
{
    curves = QList<QString>();
    QString typeStr;
    if(type==DataType::acc){
        typeStr = "accelerometre";
    }else  if(type==DataType::gyro){
        typeStr = "gyroscope";
    }else  if(type==DataType::euler){
        typeStr = "euler";
    }else  if(type==DataType::qua){
        typeStr = "quaternion";
    }

    curves.append(typeStr+" x");
    curves.append(typeStr+" y");
    curves.append(typeStr+" z");

    QHBoxLayout * mainLayout = new QHBoxLayout;
    this->setLayout(mainLayout);

    plot = new QwtPlot();
    mainLayout->addWidget(plot,5);

    QWidget * checkBoxGroup = new QWidget(this);
    mainLayout->addWidget(checkBoxGroup,1);

    QVBoxLayout * checkBoxGroupLayout = new QVBoxLayout;
    checkBoxGroup->setLayout(checkBoxGroupLayout);

    QPushButton * resetScaleButton = new QPushButton;
    resetScaleButton->setText("reset y scale");
    setStyleSheet("QPushButton{"
                  "font-family: Futura;"
                  "color:#4C6BCF;"
                  "font-size: 14px;"
                  "border:2px solid ;"
                  "border-color: #4C6BCF;"
                  "border-radius:5px;"
                  "min-height:60;}");

    checkBoxGroupLayout->addWidget(resetScaleButton);

    checkBoxX = new QCheckBox(curves.at(0),checkBoxGroup);
    checkBoxGroupLayout->addWidget(checkBoxX);

    checkBoxY = new QCheckBox(curves.at(1),checkBoxGroup);
    checkBoxGroupLayout->addWidget(checkBoxY);

    checkBoxZ = new QCheckBox(curves.at(2),checkBoxGroup);
    checkBoxGroupLayout->addWidget(checkBoxZ);

    timeSlider = new QSlider(Qt::Horizontal,checkBoxGroup);
    checkBoxGroupLayout->addWidget(timeSlider);

    checkBoxX->setChecked(true);
    checkBoxY->setChecked(true);
    checkBoxZ->setChecked(true);

    QSignalMapper * mapper = new QSignalMapper;
    mapper->setMapping(checkBoxX,0);
    mapper->setMapping(checkBoxY,1);
    mapper->setMapping(checkBoxZ,2);

    connect(checkBoxX,SIGNAL(stateChanged(int)),mapper,SLOT(map()));
    connect(checkBoxY,SIGNAL(stateChanged(int)),mapper,SLOT(map()));
    connect(checkBoxZ,SIGNAL(stateChanged(int)),mapper,SLOT(map()));

    connect(mapper,SIGNAL(mapped(int)),SLOT(handleCheckBox(int)));

    // canvas
    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setLineWidth( 1 );
    canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    canvas->setBorderRadius( 15 );

    QPalette canvasPalette( Qt::white );
    canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
    canvas->setPalette( canvasPalette );

    plot->setCanvas( canvas );

    QwtPlotScaleItem *it1 = new QwtPlotScaleItem(QwtScaleDraw::BottomScale ,0.0);
    it1->attach(plot);
    plot->enableAxis(QwtPlot::xBottom,false);
    plot->setAxisScale( QwtPlot::xBottom, 0.0, duree_de_visualisation );
    plot->setAxisScale( QwtPlot::yLeft, min, max );

    xCurve = new QwtPlotCurve( curves.at(0));
    xCurve->setRenderHint( QwtPlotItem::RenderAntialiased );
    xCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
    xCurve->setPen( Qt::red );
    xCurve->attach( plot );

    yCurve = new QwtPlotCurve(curves.at(1));
    yCurve->setRenderHint( QwtPlotItem::RenderAntialiased );
    yCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
    yCurve->setPen( Qt::blue );
    yCurve->attach( plot );

    zCurve = new QwtPlotCurve( curves.at(2));
    zCurve->setRenderHint( QwtPlotItem::RenderAntialiased );
    zCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
    zCurve->setPen( Qt::green );
    zCurve->attach( plot );


   timerReplot = new QTimer;
   timerReplot->setInterval(50);
   connect(timerReplot,SIGNAL(timeout()),plot,SLOT(replot()));
   connect(timeSlider,SIGNAL(sliderMoved(int)),SLOT(updateVizualizatorTimeWindow(int)));

   timerRescale = new QTimer;
   timerRescale->setInterval(1000);
   connect(timerRescale,SIGNAL(timeout()),SLOT(rescale()));

   connect(resetScaleButton,SIGNAL(clicked(bool)),SLOT(resetScale()));

    setEnabled(false);
}
Esempio n. 10
0
LevelOneMuChart::LevelOneMuChart(QWidget *parent)
    : QwtPlot(parent)
{
    setAutoReplot(false);

    /* Panning with the left mouse button */
    (void)new QwtPlotPanner(canvas());

    /* Zoom in/out with the wheel */
    (void)new QwtPlotMagnifier(canvas());

    /* Picker  */
    plotPicker = new QwtPlotPicker(QwtPlot::xBottom,
                                   QwtPlot::yLeft,
                                   QwtPlotPicker::CrossRubberBand,
                                   QwtPicker::AlwaysOn,
                                   canvas());
    plotPicker->setStateMachine(new QwtPickerDragPointMachine());
    plotPicker->setRubberBandPen(QColor(Qt::blue));
    plotPicker->setRubberBand(QwtPicker::CrossRubberBand);
    plotPicker->setTrackerPen(QColor(Qt::black));

    setAutoFillBackground(true);
    setPalette(QPalette(QColor(199, 237, 255))); // Light Blue

    updateWidgetGradient();

    setTitle(tr("Chart of available deviations"));

    /* Legend */
    legend = new QwtLegend();
    legend->setItemMode(QwtLegend::CheckableItem);
    insertLegend(legend, QwtPlot::RightLegend);

    /* Canvas Settings */
    canvas()->setLineWidth(1);
    canvas()->setFrameStyle(QFrame::Box | QFrame::Plain);

    QPalette canvasPalette(Qt::white);
    canvasPalette.setColor(QPalette::Foreground, QColor(133, 190, 232));
    canvas()->setPalette(canvasPalette);

    plotAssay();

    /* Legend */
    connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)),
            SLOT(showItem(QwtPlotItem *, bool)));

    QwtPlotItemList items = itemList(QwtPlotItem::Rtti_PlotCurve);
    for (int i = 0; i < items.size(); i++)
    {
        if (i < 3)
        {
            QwtLegendItem *legendItem =
                    qobject_cast<QwtLegendItem *>(legend->find(items[i]));
            if (legendItem)
            {
                legendItem->setChecked(true);
            }
            items[i]->setVisible(true);
        }
        else
        {
            items[i]->setVisible(false);
        }
    }
    setAutoReplot(true);
}
Esempio n. 11
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();    
}