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 ); }
Plot::Plot( QWidget *parent ): QwtPlot( parent ), d_curve( NULL ) { /*canvas()->setStyleSheet( "border: 2px solid Black;" "border-radius: 15px;" "background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1," "stop: 0 LemonChiffon, stop: 1 PaleGoldenrod );" );*/ //QwtPlotCanvas *newcanvas=new QwtPlotCanvas(); //newcanvas->setPalette(Qt::white); //newcanvas->setBorderRadius(10); //setCanvas( newcanvas ); //plotLayout()->setAlignCanvasToScales( true ); setAxisTitle( QwtPlot::yLeft, "ylabel" ); setAxisTitle( QwtPlot::xBottom, "xlabel" ); //setAxisScale(QwtPlot::yLeft,0.0,25.0); //setAxisScale(QwtPlot::xBottom,0.0,25.0); //canvas()->resize(800, 600); //plotLayout(AlignScales); // attach curve d_curve = new QwtPlotCurve( "Scattered Points" ); d_curve->setPen( QColor( "Black" ) ); // d_curve->setCurveAttribute(fitten); // when using QwtPlotCurve::ImageBuffer simple dots can be // rendered in parallel on multicore systems. d_curve->setRenderThreadCount( 0 ); // 0: use QThread::idealThreadCount() //d_curve->setCurveAttribute(QwtPlotCurve::Fitted, true); d_curve->attach( this ); QwtSymbol * symbol2 = new QwtSymbol( QwtSymbol::XCross, QBrush(Qt::white), QPen(Qt::red, 1), QSize(6,6)); //QwtSymbol::Style style = Cross; setSymbol( symbol2 ); //setSymbol(NULL); // panning with the left mouse button (void )new QwtPlotPanner( canvas() ); // zoom in/out with the wheel QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() ); magnifier->setMouseButton( Qt::NoButton ); // distanve measurement with the right mouse button DistancePicker *picker = new DistancePicker( canvas() ); picker->setMousePattern( QwtPlotPicker::MouseSelect1, Qt::RightButton ); picker->setRubberBandPen( QPen( Qt::blue ) ); QwtPlotGrid *grid = new QwtPlotGrid; grid->enableX( true );//设置网格线 grid->enableY( true ); grid->setMajorPen( Qt::black, 0, Qt::DotLine ); grid->attach( this ); //QSize sizeH = sizeHint(); }
void MainWindow::enableMagnifier() //приближение-удаление { // #include <qwt_plot_magnifier.h> QwtPlotMagnifier *magnifier = new QwtPlotMagnifier(ui->Qwt_Widget->canvas()); // клавиша, активирующая приближение/удаление magnifier->setMouseButton(Qt::MidButton); }
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 ); }
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 *) )); }
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(); }