Ejemplo n.º 1
0
/*!
  \brief Redraw the plot

  If the autoReplot option is not set (which is the default)
  or if any curves are attached to raw data, the plot has to
  be refreshed explicitly in order to make changes visible.

  \sa updateAxes(), setAutoReplot()
*/
void QwtPlot::replot()
{
    bool doAutoReplot = autoReplot();
    setAutoReplot( false );

    updateAxes();

    /*
      Maybe the layout needs to be updated, because of changed
      axes labels. We need to process them here before painting
      to avoid that scales and canvas get out of sync.
     */
    QApplication::sendPostedEvents( this, QEvent::LayoutRequest );

    if ( d_data->canvas )
    {
        const bool ok = QMetaObject::invokeMethod( 
            d_data->canvas, "replot", Qt::DirectConnection );
        if ( !ok )
        {
            // fallback, when canvas has no a replot method
            d_data->canvas->update( d_data->canvas->contentsRect() );
        }
    }

    setAutoReplot( doAutoReplot );
}
Ejemplo n.º 2
0
void Plot::setDamp( double damping )
{
    const bool doReplot = autoReplot();
    setAutoReplot( false );

    const int ArraySize = 1024;

    double frequency[ArraySize];
    double amplitude[ArraySize];


    for(int i=0;i<ArraySize;i++){
        frequency[i]=i;
        amplitude[i]=100*std::sin(2*M_PI*i/1024);
    }


    //double phase[ArraySize];

    // build frequency vector with logarithmic division
 /*   logSpace( frequency, ArraySize, 0.01, 100 );

    int i3 = 1;
    double fmax = 1;
    double amax = -1000.0;

    for ( int i = 0; i < ArraySize; i++ )
    {
        double f = frequency[i];
       //const ComplexNumber g =
       //     ComplexNumber( 1.0 ) / ComplexNumber( 1.0 - f * f, 2.0 * damping * f );

        amplitude[i] = 20.0 * log10( qSqrt( g.real() * g.real() + g.imag() * g.imag() ) );
        //phase[i] = qAtan2( g.imag(), g.real() ) * ( 180.0 / M_PI );

        if ( ( i3 <= 1 ) && ( amplitude[i] < -3.0 ) )
            i3 = i;
        if ( amplitude[i] > amax )
        {
            amax = amplitude[i];
            fmax = frequency[i];
        }

    }

    double f3 = frequency[i3] - ( frequency[i3] - frequency[i3 - 1] )
        / ( amplitude[i3] - amplitude[i3 -1] ) * ( amplitude[i3] + 3 );
*/
    //showPeak( fmax, amax );
    //show3dB( f3 );
 //   showData( frequency, amplitude, ArraySize );

    setAutoReplot( doReplot );

    replot();
}
Ejemplo n.º 3
0
/*!
  \brief Redraw the plot
  If the autoReplot option is not set (which is the default)
  or if any curves are attached to raw data, the plot has to
  be refreshed explicitly in order to make changes visible.
  \sa setAutoReplot()
*/
void QwtPlot::replot()
{
    bool doAutoReplot = autoReplot();
    setAutoReplot(FALSE);

    updateAxes();
    drawCanvas(d_canvas->contentsRect());

    setAutoReplot(doAutoReplot);
}
Ejemplo n.º 4
0
/*!
  \brief Redraw the plot

  If the autoReplot option is not set (which is the default)
  or if any curves are attached to raw data, the plot has to
  be refreshed explicitly in order to make changes visible.

  \sa setAutoReplot()
  \warning Calls canvas()->repaint, take care of infinite recursions
*/
void QwtPlot::replot()
{
    bool doAutoReplot = autoReplot();
    setAutoReplot(FALSE);

    updateAxes();

    d_canvas->invalidateCache();
    d_canvas->repaint(d_canvas->contentsRect(), FALSE);

    setAutoReplot(doAutoReplot);
}
Ejemplo n.º 5
0
/*!
  \brief Redraw the plot

  If the autoReplot option is not set (which is the default)
  or if any curves are attached to raw data, the plot has to
  be refreshed explicitly in order to make changes visible.

  \sa setAutoReplot()
  \warning Calls canvas()->repaint, take care of infinite recursions
*/
void QwtPolarPlot::replot()
{
  bool doAutoReplot = autoReplot();
  setAutoReplot( false );

  for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
    updateScale( scaleId );

  d_data->canvas->invalidatePaintCache();
  d_data->canvas->repaint();

  setAutoReplot( doAutoReplot );
}
Ejemplo n.º 6
0
void Plot::showData( const double *frequency, const double *amplitude, int count, int Channel )
{

    const bool doReplot = autoReplot();
    setAutoReplot( false );
    if(Channel==0)d_average->setSamples( frequency, amplitude, count );
    if(Channel==1)d_curve1->setSamples( frequency, amplitude, count );
    if(Channel==2)d_curve2->setSamples( frequency, amplitude, count );
    setAutoReplot( doReplot );


    //setAxisScale(QwtPlot::yLeft,d_average->minYValue(),d_average->maxYValue()*2);
    //d_curve2->setSamples( frequency, phase, count );

}
Ejemplo n.º 7
0
IncrementalPlot::IncrementalPlot( QWidget *parent ):
    QwtPlot( parent ),
    d_curve( NULL )
{
    d_directPainter = new QwtPlotDirectPainter( this );

    setCanvasBackground(QColor(Qt::black));
    setAxisScale(QwtPlot::yLeft, 0, 1024);
    setAxisScale(QwtPlot::xBottom, 0, 5000);

    if ( QwtPainter::isX11GraphicsSystem() )
    {
#if QT_VERSION < 0x050000
        canvas()->setAttribute( Qt::WA_PaintOutsidePaintEvent, true );
#endif
        canvas()->setAttribute( Qt::WA_PaintOnScreen, true );
    }

    d_curve = new QwtPlotCurve( "Test Curve" );
    d_curve->setData( new CurveData() );
    showSymbols( true );

    d_curve->attach( this );

    setAutoReplot( false );
}
Ejemplo n.º 8
0
IncrementalPlot::IncrementalPlot(QWidget *parent): 
    QwtPlot(parent),
    d_data(NULL),
    d_curve(NULL)
{
    setAutoReplot(false);
}
Ejemplo n.º 9
0
DataPlotFFT::DataPlotFFT(QWidget *parent):
    QwtPlot(parent),
    d_data(NULL),
    d_curve(NULL)
{
    setAutoReplot(false);

    setFrameStyle(QFrame::NoFrame);
    setLineWidth(0);
    setCanvasLineWidth(2);

    //plotLayout()->setAlignCanvasToScales(true);

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

    setCanvasBackground(Qt::white);
    //setCanvasBackground(QColor(29, 100, 141)); // nice blue

    //setAxisAutoScale(xBottom);
    //s/etAxisAutoScale(yLeft);

    setAxisScale(xBottom, 0.5, -0.5);
    setAxisScale(yLeft, -10.00, 10.00);
    setAxisAutoScale(yLeft);
    //setAxisAutoScale(xBottom);

    replot();
}
Ejemplo n.º 10
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent)
{
    setAutoReplot( false );

    setTitle( "Animated Curves" );

    // hide all axes
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
        enableAxis( axis, false );

    plotLayout()->setCanvasMargin( 10 );

    d_curves[0] = new Curve1();
    d_curves[1] = new Curve2();
    d_curves[2] = new Curve3();
    d_curves[3] = new Curve4();

    updateCurves();

    for ( int i = 0; i < CurveCount; i++ )
        d_curves[i]->attach( this );

    d_time.start();
    ( void )startTimer( 40 );
}
Ejemplo n.º 11
0
HistPlot::HistPlot(QWidget *parent):
QwtPlot(parent)
{
	setCanvasBackground(QColor(Qt::black));
	plotLayout()->setAlignCanvasToScales(true);

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

	//populate();

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

	//replot(); // creating the legend items

	QwtPlotItemList items = itemList(QwtPlotItem::Rtti_PlotHistogram);
	for ( int i = 0; i < items.size(); i++ )
	{
		if ( i == 0 )
		{
			//QwtLegendItem *legendItem = (QwtLegendItem *)legend->find(items[i]);
			//if ( legendItem )
			//	legendItem->setChecked(true);
			items[i]->setVisible(true);
		}
		else
			items[i]->setVisible(false);
	}

	setAutoReplot(true);
}
Ejemplo n.º 12
0
BarChart::BarChart( QWidget *parent ):
    QwtPlot( parent )
{
    setAutoFillBackground( true );

    setPalette( Qt::white );
    canvas()->setPalette( QColor( "LemonChiffon" ) );

    setTitle( "Bar Chart" );

    setAxisTitle( QwtPlot::yLeft, "Whatever" );
    setAxisTitle( QwtPlot::xBottom, "Whatever" );

    d_barChartItem = new QwtPlotMultiBarChart( "Bar Chart " );
    d_barChartItem->setLayoutPolicy( QwtPlotMultiBarChart::AutoAdjustSamples );
    d_barChartItem->setSpacing( 20 );
    d_barChartItem->setMargin( 3 );

    d_barChartItem->attach( this );

    insertLegend( new QwtLegend() );

    populate();
    setOrientation( 0 );

    setAutoReplot( true );
}
Ejemplo n.º 13
0
HistoricPlot::HistoricPlot(QWidget *parent)
:QwtPlot(parent)
{
    //Fondo del canvas negro
    canvas()->setPalette(Qt::black);

    //Auto repintar las curvas
    setAutoReplot(true);

    setTitle("Historian Variable Plot");

    // Grid
    m_grid = new QwtPlotGrid;
    m_grid->enableXMin( true );
    m_grid->setMajorPen( Qt::gray, 0, Qt::DotLine );
    m_grid->setMinorPen( Qt::darkGray, 0, Qt::DotLine );
    m_grid->attach( this );

    //Scale
    m_scaleDraw = new QwtDateScaleDraw( Qt::UTC );

    m_scaleDraw->setDateFormat( QwtDate::Millisecond, "hh:mm:ss:zzz\nddd dd MMM yyyy" );
    m_scaleDraw->setDateFormat( QwtDate::Second, "hh:mm:ss\nddd dd MMM yyyy" );
    m_scaleDraw->setDateFormat( QwtDate::Minute, "hh:mm\nddd dd MMM yyyy" );
    m_scaleDraw->setDateFormat( QwtDate::Hour, "hh:mm\nddd dd MMM yyyy" );
    m_scaleDraw->setDateFormat( QwtDate::Day, "ddd dd MMM yyyy" );
    m_scaleDraw->setDateFormat( QwtDate::Week, "Www yyyy" );
    m_scaleDraw->setDateFormat( QwtDate::Month, "MMM yyyy" );
    m_scaleDraw->setDateFormat( QwtDate::Year, "yyyy");


    m_scaleEngine = new QwtDateScaleEngine( Qt::UTC );

    //Axis
    setAxisTitle( QwtPlot::xBottom, QString( "Time" ) );
    setAxisScaleDraw( QwtPlot::xBottom, m_scaleDraw );
    setAxisScaleEngine( QwtPlot::xBottom, m_scaleEngine );
    setAxisLabelRotation( QwtPlot::xBottom, -50.0 );
    setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom );

    setAxisTitle( QwtPlot::yLeft, QString( "Value" ) );

    //Legend
    m_legend = new QwtLegend;
    insertLegend(m_legend);

    //Zoomer
    m_zoomer = new Zoomer( canvas() );
    m_zoomer->setMousePattern( QwtEventPattern::MouseSelect2,
        Qt::RightButton, Qt::ControlModifier );
    m_zoomer->setMousePattern( QwtEventPattern::MouseSelect3,
        Qt::RightButton );

    //Panner
    m_panner = new QwtPlotPanner( canvas() );
    m_panner->setMouseButton( Qt::MidButton );

    resize(800,600);
}
Ejemplo n.º 14
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 );
}
Ejemplo n.º 15
0
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
}
Ejemplo n.º 16
0
//! Destructor
QwtPlot::~QwtPlot()
{
    setAutoReplot( false );
    detachItems( QwtPlotItem::Rtti_PlotItem, autoDelete() );

    delete d_data->layout;
    deleteAxesData();
    delete d_data;
}
Ejemplo n.º 17
0
/*!
  \brief Redraw the plot

  If the autoReplot option is not set (which is the default)
  or if any curves are attached to raw data, the plot has to
  be refreshed explicitly in order to make changes visible.

  \sa setAutoReplot()
  \warning Calls canvas()->repaint, take care of infinite recursions
*/
void QwtPlot::replot()
{
    bool doAutoReplot = autoReplot();
    setAutoReplot( false );

    updateAxes();

    /*
      Maybe the layout needs to be updated, because of changed
      axes labels. We need to process them here before painting
      to avoid that scales and canvas get out of sync.
     */
    QApplication::sendPostedEvents( this, QEvent::LayoutRequest );

    d_data->canvas->replot();

    setAutoReplot( doAutoReplot );
}
Ejemplo n.º 18
0
Plot::Plot(QWidget *parent):
    QwtPlot(parent),
    d_paintedPoints(0),
    d_interval(0.0, 10.0),
    d_timerId(-1)
{
    d_directPainter = new QwtPlotDirectPainter();

    setAutoReplot(false);

    // We don't need the cache here
    canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
    //canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);


#if defined(Q_WS_X11)
    // Even if not recommended by TrollTech, Qt::WA_PaintOutsidePaintEvent
    // works on X11. This has a nice effect on the performance.
    
    canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
    canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif

    plotLayout()->setAlignCanvasToScales(true);

    setAxisTitle(QwtPlot::xBottom, "Time [s]");
    setAxisScale(QwtPlot::xBottom, d_interval.minValue(), d_interval.maxValue()); 
    setAxisScale(QwtPlot::yLeft, -200.0, 200.0);

    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setPen(QPen(Qt::gray, 0.0, Qt::DotLine));
    grid->enableX(true);
    grid->enableXMin(true);
    grid->enableY(true);
    grid->enableYMin(false);
    grid->attach(this);

    d_origin = new QwtPlotMarker();
    d_origin->setLineStyle(QwtPlotMarker::Cross);
    d_origin->setValue(d_interval.minValue() + d_interval.width() / 2.0, 0.0);
    d_origin->setLinePen(QPen(Qt::gray, 0.0, Qt::DashLine));
    d_origin->attach(this);

    d_curve = new QwtPlotCurve();
    d_curve->setStyle(QwtPlotCurve::Lines);
    d_curve->setPen(QPen(Qt::green));
#if 1
    d_curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
#endif
#if 1
    d_curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, false);
#endif
    d_curve->setData(new CurveData());
    d_curve->attach(this);
}
SweepInspector::SweepInspector(QWidget *parent) : QwtPlot(parent), data(NULL), d_curve(NULL), picker(NULL) {
  setObjectName( "SweepData" );
  setTitle( "RF Sweep" );
  setAxisTitle( QwtPlot::xBottom, "Frequency");
  setAxisTitle( QwtPlot::yLeft, QString( "Power Level (dBm)"));
  setAutoReplot(true);

  enableAxis(QwtPlot::xBottom, true);
  enableAxis(QwtPlot::yLeft, true);
  enableAxis(QwtPlot::xTop, false);
  enableAxis(QwtPlot::yRight, false);

  canvas = new QwtPlotCanvas();
  canvas->setPalette( Qt::black );
  canvas->setBorderRadius(0);
  setCanvas(canvas);

  //Allow zooming / panning
  zoomer = new QwtPlotZoomer( canvas );
  zoomer->setRubberBandPen( QColor( Qt::white ) );
  zoomer->setTrackerPen( QColor( Qt::white ) );
  connect(zoomer, SIGNAL(zoomed(const QRectF &)), this, SLOT(zoomed(const QRectF &)));

  panner = new QwtPlotPanner( canvas );
  panner->setMouseButton( Qt::MidButton );

  //Show the X/Y markers that follow the mouse
  picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, canvas);
  picker->setStateMachine( new QwtPickerTrackerMachine() );
  picker->setRubberBandPen( QColor( Qt::cyan ) );
  picker->setTrackerPen( QColor( Qt::cyan ) );

  //FreqdBmPicker *er = new FreqdBmPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, canvas);

  //Setup grid
  grid = new QwtPlotGrid();
  grid->enableXMin( true );
  grid->enableYMin( true );
  QColor color(Qt::gray); color.setAlpha(128);
  grid->setMajorPen( color, 1, Qt::DotLine );
  grid->setMinorPen( color, 1, Qt::DotLine );
  grid->attach( this );

  //format in kHz, MHz, GHz, not raw values
  setAxisScaleDraw(QwtPlot::xBottom, new FreqScaleDraw);
  setAxisAutoScale(QwtPlot::xBottom, true);
  //setAxisScale(QwtPlot::xBottom, 1, 4.4e9, 4.4e9 / 5.0);
  //setAxisScale(QwtPlot::yLeft, -135, 20, 20.0);

  setAxisScale(QwtPlot::yRight, 0, 10, 1);
  setAxisScale(QwtPlot::xTop, 0, 10, 1);
  
  repaint();
  replot();
}
Ejemplo n.º 20
0
BarChart::BarChart( QWidget *parent ):
    QwtPlot( parent )
{
    setAutoFillBackground( true );
	canvas()->setPalette(QColor(165, 193, 228) /*QColor( "LemonChiffon" )*/);
	d_barChartItem = new DistroChartItem("Bar Chart ");
    //d_barChartItem->setLayoutPolicy( QwtPlotBarChart::AutoAdjustSamples );
    //d_barChartItem->setSpacing( 40 );
    //d_barChartItem->setMargin( 0 );
    setAutoReplot( true );
}
Ejemplo n.º 21
0
IncrementalPlot::IncrementalPlot(QWidget *parent): 
    QwtPlot(parent),
    d_data(NULL),
    d_curve(NULL)
{
    d_directPainter = new QwtPlotDirectPainter(this);

#if defined(Q_WS_X11)
    canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
    canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif

    setAutoReplot(false);
}
Ejemplo n.º 22
0
TVPlot::TVPlot( QWidget *parent ):
    QwtPlot( parent )
{
    setTitle( "Watching TV during a weekend" );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setPalette( Qt::gray );
    canvas->setBorderRadius( 10 );
    setCanvas( canvas );

    plotLayout()->setAlignCanvasToScales( true );

    setAxisTitle( QwtPlot::yLeft, "Number of People" );
    setAxisTitle( QwtPlot::xBottom, "Number of Hours" );

    QwtLegend *legend = new QwtLegend;
    legend->setDefaultItemMode( QwtLegendData::Checkable );
    insertLegend( legend, QwtPlot::RightLegend );

    populate();

    connect( legend, SIGNAL( checked( const QVariant &, bool, int ) ),
        SLOT( showItem( const QVariant &, bool ) ) );

    replot(); // creating the legend items

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

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

            items[i]->setVisible( true );
        }
        else
        {
            items[i]->setVisible( false );
        }
    }

    setAutoReplot( true );
}
Ejemplo n.º 23
0
Histograma::Histograma(QWidget *parent):
    QwtPlot(parent)
{
    // titulo do widget de histograma
    setTitle("");

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

    setAxisTitle(QwtPlot::yLeft, "");
    setAxisTitle(QwtPlot::xBottom, "Tons de Cinza");

    // Define os valores Max e Min para o eixo X
    setAxisScale(QwtPlot::xBottom, 0, 255);

    setAutoReplot(true);
}
Ejemplo n.º 24
0
ICResultChart::ICResultChart(QWidget *parent) :
    QwtPlot(parent)
{

    setAutoFillBackground(true);

    setPalette(Qt::white);
    canvas()->setPalette(Qt::gray);

    d_barChartItem = new QwtPlotBarChart("Quantity");
    //d_barChartItem->setLayoutPolicy(QwtPlotBarChart::AutoAdjustSamples);
    //d_barChartItem->setSpacing(MIN_SPACING);
    //d_barChartItem->setMargin(MIN_MARGIN);

    d_barChartItem->attach(this);

    setAutoReplot(true);
}
Ejemplo n.º 25
0
PlotWidget::PlotWidget(QWidget *parent) :
    QwtPlot(parent),
    ui(new Ui::PlotWidget)
{
    ui->setupUi(this);

    // Setup plot stuff
    setAutoReplot(false);
    canvas()->setBorderRadius( 10 );

    plotLayout()->setAlignCanvasToScales(true);

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

    setAxisTitle(QwtPlot::xBottom, " Time [s]");
    setAxisScaleDraw(QwtPlot::xBottom,
                     new QwtScaleDraw());
    setAxisAutoScale(QwtPlot::xBottom, false);
    setAxisScale(QwtPlot::xBottom, 0, Market::EXPERIMENT_RUNNING_TIME);
    setAxisLabelRotation(QwtPlot::xBottom, -50.0);
    setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);

    setAxisTitle(QwtPlot::yLeft, " Price [$]");
    setAxisScaleDraw(QwtPlot::yLeft,
                     new QwtScaleDraw());
    setAxisScale(QwtPlot::yLeft, 0, MAX_PRICE_PLOT);
    setAxisLabelRotation(QwtPlot::yLeft, -50.0);
    setAxisLabelAlignment(QwtPlot::yLeft, Qt::AlignLeft | Qt::AlignBottom);

    // Setup the data
    asset1Data = new CircularBuffer((Market::EXPERIMENT_RUNNING_TIME)/2 + 4); // Running time, /2 for data every 2 seconds, + a safety buffer
    asset2Data = new CircularBuffer((Market::EXPERIMENT_RUNNING_TIME)/2 + 4);
    timeData = new CircularBuffer((Market::EXPERIMENT_RUNNING_TIME)/2 + 4);

    asset1Curve = new QwtPlotCurve("Asset 1");
    asset1Curve->setPen(QPen(Qt::red));
    asset1Curve->attach(this);

    asset2Curve = new QwtPlotCurve("Asset 2");
    asset2Curve->setPen(QPen(Qt::blue));
    asset2Curve->attach(this);
}
Ejemplo n.º 26
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent )
{
    setAutoReplot( false );

    setTitle( "Movable Items" );

    const int margin = 5;
    setContentsMargins( margin, margin, margin, margin );

    setAutoFillBackground( true );
    setPalette( QColor( "DimGray" ).lighter( 110 ) );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
#if 0
    // a gradient making a replot slow on X11
    canvas->setStyleSheet(
        "border: 2px solid Black;"
        "border-radius: 15px;"
        "background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1,"
            "stop: 0 LemonChiffon, stop: 0.5 PaleGoldenrod, stop: 1 LemonChiffon );"
    );
#else
    canvas->setStyleSheet(
        "border: 2px inset DimGray;"
        "border-radius: 15px;"
        "background: LemonChiffon;"
    );
#endif

    setCanvas( canvas );
    insertLegend( new Legend(), QwtPlot::RightLegend );

    populate();

    updateAxes();
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
        setAxisAutoScale( axis, false );

    d_editor = new Editor( this );
    ( void ) new QwtPlotMagnifier( canvas );
}
Ejemplo n.º 27
0
Spectrograph::Spectrograph(QWidget *parent):
    QwtPlot(parent)
{
    //real-time plotting
    d_directPainter = new QwtPlotDirectPainter();

    setAutoReplot( false );
    //all plot widgets will be displayed on the canvas
    setCanvas( new QwtPlotCanvas() );

    plotLayout()->setAlignCanvasToScales( true );
    //set plot title and range
    setAxisTitle( QwtPlot::xBottom, "Frequency (MHz)" );
    setAxisTitle( QwtPlot::yLeft, "Amplitude (dB)" );
    setAxisScale( QwtPlot::xBottom, 0, RESULT_LENGTH );
    setAxisScale( QwtPlot::yLeft, -90, -10);

    //black background
    setCanvasBackground(QColor(0,0,0));

    //add grid
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setPen( Qt::white, 0.0, Qt::DotLine );
    grid->enableX( true );
    grid->enableXMin( true );
    grid->enableY( true );
    grid->enableYMin( false );
    grid->attach( this );//attach grid to plot

    //add curve
    d_curve = new QwtPlotCurve();
    d_curve->setStyle( QwtPlotCurve::Lines );
    d_curve->setPen(Qt::yellow);
    d_curve->setPaintAttribute( QwtPlotCurve::ClipPolygons, false );
    d_curve->attach( this );//attach curve to plot

    for(int i=0; i<RESULT_LENGTH; ++i) {
        d_x[i] = i;
    }

}
Ejemplo n.º 28
0
EEGPlot::EEGPlot(int channelId, QWidget *parent, const QObject* sender,
				 const char* dataSignal, unsigned int numChannels)
	: QwtPlot(parent)
	, m_channelId(channelId)
	, m_firstPacket(true)
	, m_numChannels(numChannels)
{
	setAutoReplot(false);

	setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	CENT::connect(sender, dataSignal, this, SLOT(dataReceived(CentData::AnalogData)));

	m_curve = new QwtPlotCurve("signal channel");
	m_curve->setStyle(QwtPlotCurve::Lines);
	m_curve->setPen(QPen(Qt::darkBlue));

	m_curve->setRenderHint(QwtPlotItem::RenderAntialiased, false);
	m_curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, true);
	
	m_arraySeriesData = new ArraySeriesData();
	m_curve->setData(m_arraySeriesData);
	m_curve->attach(this);

	// Canvas
	setCanvasBackground(QBrush(Qt::white));

	// Axes
	enableAxis(QwtPlot::yLeft, true);
	setAxisTitle(QwtPlot::yLeft, Y_AXIS_TEXT);
	setAxisAutoScale(QwtPlot::yLeft, true);
	setAxisScaleDraw(QwtPlot::yLeft, new IntegerScaleDraw);


	setAxisAutoScale(QwtPlot::xBottom, false);
	QwtText xText(tr(X_AXIS_TEXT_LOC));
	setAxisTitle(QwtPlot::xBottom, xText);

	CENT::connect(&m_redrawTimer, SIGNAL(timeout()), this, SLOT(replotManual()));
	m_redrawTimer.setInterval(200);
	m_redrawTimer.start();
}
Ejemplo n.º 29
0
int QwtPlot::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QFrame::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 5)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 5;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QBrush*>(_v) = canvasBackground(); break;
        case 1: *reinterpret_cast< bool*>(_v) = autoReplot(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setCanvasBackground(*reinterpret_cast< QBrush*>(_v)); break;
        case 1: setAutoReplot(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
OscilloscopePlot::OscilloscopePlot( QWidget *parent ):
    QwtPlot( parent ),
    d_paintedPoints( 0 ),
    d_interval( 0.0, 10.0 ),
    d_timerId( -1 )
{
    d_directPainter = new QwtPlotDirectPainter();

    setAutoReplot( false );
    setCanvas( new Canvas() );

    plotLayout()->setAlignCanvasToScales( true );

    setAxisTitle( QwtPlot::xBottom, "Time [s]" );
    setAxisScale( QwtPlot::xBottom, d_interval.minValue(), d_interval.maxValue() );
    setAxisScale( QwtPlot::yLeft, -200.0, 200.0 );

    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setPen( Qt::gray, 0.0, Qt::DotLine );
    grid->enableX( true );
    grid->enableXMin( true );
    grid->enableY( true );
    grid->enableYMin( false );
    grid->attach( this );

    d_origin = new QwtPlotMarker();
    d_origin->setLineStyle( QwtPlotMarker::Cross );
    d_origin->setValue( d_interval.minValue() + d_interval.width() / 2.0, 0.0 );
    d_origin->setLinePen( Qt::gray, 0.0, Qt::DashLine );
    d_origin->attach( this );

    d_curve = new QwtPlotCurve();
    d_curve->setStyle( QwtPlotCurve::Lines );
    d_curve->setPen( canvas()->palette().color( QPalette::WindowText ) );
    d_curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
    d_curve->setPaintAttribute( QwtPlotCurve::ClipPolygons, false );
    d_curve->setData( new CurveData() );
    d_curve->attach( this );
}