예제 #1
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 );
}
예제 #2
0
파일: plot.cpp 프로젝트: 0vermind/NeoLoader
Plot::Plot( QWidget *parent ):
    QwtPlot( parent )
{
    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setBorderRadius( 10 );
    setCanvas( canvas );

#if 0
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setPen( Qt::DotLine );
    grid->attach( this );
#endif

    d_spectrogram = new QwtPlotSpectrogram();
    d_spectrogram->setRenderThreadCount( 0 ); // use system specific thread count

    d_spectrogram->setColorMap( new ColorMap() );

    d_spectrogram->setData( new RasterData() );
    d_spectrogram->attach( this );

    const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis );
    // A color bar on the right axis
    QwtScaleWidget *rightAxis = axisWidget( QwtPlot::yRight );
    rightAxis->setColorBarEnabled( true );
    rightAxis->setColorBarWidth( 40 );
    rightAxis->setColorMap( zInterval, new ColorMap() );

    setAxisScale( QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() );
    enableAxis( QwtPlot::yRight );

    plotLayout()->setAlignCanvasToScales( true );

    setAxisScale( QwtPlot::xBottom, 0.0, 3.0 );
    setAxisMaxMinor( QwtPlot::xBottom, 0 );
    setAxisScale( QwtPlot::yLeft, 0.0, 3.0 );
    setAxisMaxMinor( QwtPlot::yLeft, 0 );

    QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas );
    magnifier->setAxisEnabled( QwtPlot::yRight, false );

    QwtPlotPanner *panner = new QwtPlotPanner( canvas );
    panner->setAxisEnabled( QwtPlot::yRight, false );
}
예제 #3
0
FrameView::FrameView (Connection * conn, FrameViewConfig const & cfg, QString const & fname, QStringList const & path)
	: DockedWidgetBase(conn->getMainWindow(), path)
	, m_bars(0)
	, m_config(cfg)
	, m_config_ui(m_config, this)
{
	setContextMenuPolicy(Qt::CustomContextMenu);
	connect(this, SIGNAL(customContextMenuRequested(QPoint const &)), this, SLOT(onShowContextMenu(QPoint const &)));

	m_plot = new QwtPlot();
	m_bars = new BarPlot();
	m_bars->attach(m_plot);

	m_plot->plotLayout()->setAlignCanvasToScales(true);
	m_plot->plotLayout()->setCanvasMargin(0);
	m_plot->setContentsMargins(QMargins(0, 0, 0, 0));
	m_plot->setMinimumSize(64,64);

	m_plot->setAutoReplot(true);
	//qDebug("%s this=0x%08x", __FUNCTION__, this);

	QwtPlotMagnifier * lookglass = new QwtPlotMagnifier(m_plot->canvas());
	m_plot->canvas()->setFocusPolicy(Qt::WheelFocus);
	lookglass->setAxisEnabled(QwtPlot::yLeft, false);

	XZoomer * zoomer = new XZoomer(m_plot->canvas());
	zoomer->setRubberBandPen( QColor( Qt::black ) );
	zoomer->setTrackerPen( QColor( Qt::black ) );
	zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier );
	zoomer->setMousePattern( QwtEventPattern::MouseSelect3, Qt::RightButton, Qt::ShiftModifier);

	QwtPlotPicker * picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
										QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,
										m_plot->canvas());
	//picker->setStateMachine(new QwtPickerDragPointMachine());
	picker->setStateMachine(new QwtPickerClickPointMachine());
	picker->setRubberBandPen(QColor(Qt::green));
	picker->setRubberBand(QwtPicker::CrossRubberBand);
	picker->setTrackerPen(QColor(Qt::white));

	QwtPlotPanner * panner = new QwtPlotPanner(m_plot->canvas());
	panner->setAxisEnabled(QwtPlot::yLeft, false);
	panner->setMouseButton(Qt::MidButton);

    m_plot->setAxisMaxMinor(QwtPlot::xBottom, 3);
    m_plot->setAxisScaleDraw(QwtPlot::xBottom, new FrameScaleDraw(Qt::Horizontal, m_bars->m_strvalues));

	m_plot->setAxisAutoScale(QwtPlot::yLeft, true);
	m_bars->setLayoutPolicy(QwtPlotAbstractBarChart::FixedSampleSize);
	m_bars->setLayoutHint(5);
	m_bars->setSpacing(1);

	QwtSlider * slider = createSlider(1);
    connect(slider, SIGNAL(valueChanged(double)), SLOT(setNum(double)));
    QVBoxLayout * layout = new QVBoxLayout( this );
    layout->addWidget(m_plot);
    //layout->addWidget(slider);
	m_bars->setLegendMode(QwtPlotBarChart::LegendBarTitles);

    connect(picker, SIGNAL(selected(QRectF const &) ), this, SLOT(selected(QRectF const &)));
    connect(picker, SIGNAL(selected(QPointF const &) ), this, SLOT(selected(QPointF const &)));
    connect(picker, SIGNAL(appended(QPointF const &) ), this, SLOT(appended(QPointF const &)));
    connect(picker, SIGNAL(selected(QVector<QPointF> const &) ), this, SLOT(selected(QVector<QPointF> const &)));

    connect(&getSyncWidgets(), SIGNAL( requestSynchronization(E_SyncMode mode, int, unsigned long long, void *) ),
						 this, SLOT( performSynchronization(E_SyncMode mode, int, unsigned long long, void *) ));
    connect(this, SIGNAL( requestSynchronization(E_SyncMode mode, int, unsigned long long, void *) ),
						 &getSyncWidgets(), SLOT( performSynchronization(E_SyncMode mode, int, unsigned long long, void *) ));
}
예제 #4
0
파일: plot.cpp 프로젝트: volthouse/desktop
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();    
}