QTabWidget* ResultsPage::createDataTabWidget() { QTabWidget *tabWidget = new QTabWidget; // Plot m_plot = new QwtPlot(tabWidget); m_plot->setCanvasBackground(Qt::white); m_plot->setContextMenuPolicy(Qt::CustomContextMenu); m_plot->setAutoReplot(false); connect(m_plot, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showPlotContextMenu(QPoint))); // Picker to allow for selection of the closest curve and displays curve // coordinates with a cross rubber band. QwtPlotPicker *picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPicker::CrossRubberBand, QwtPicker::ActiveOnly, m_plot->canvas()); picker->setStateMachine(new QwtPickerDragPointMachine()); connect(picker, SIGNAL(appended(QPoint)), this, SLOT(pointSelected(QPoint))); // Legend QwtLegend* legend = new QwtLegend; legend->setFrameStyle(QFrame::Box | QFrame::Sunken); m_plot->insertLegend(legend, QwtPlot::BottomLegend); #if QWT_VERSION >= 0x060100 connect(m_plot, SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)), legend, SLOT(updateLegend(QVariant,QList<QwtLegendData>))); #endif // Add the generic curves to the legend QList<QPair<QString, Qt::GlobalColor> > pairs; pairs << qMakePair(tr("Unselected Realization"), Qt::darkGray) << qMakePair(tr("Selected and Enabled Realization"), Qt::darkGreen) << qMakePair(tr("Selected and Disabled Realization"), Qt::darkRed); QPair<QString, Qt::GlobalColor> pair; foreach (pair, pairs) { QwtPlotCurve *curve = new QwtPlotCurve(pair.first); curve->setLegendIconSize(QSize(32, 8)); curve->setPen(QPen(QBrush(pair.second), 2)); curve->setLegendAttribute(QwtPlotCurve::LegendShowLine); #if QWT_VERSION < 0x060100 curve->updateLegend(legend); #else m_plot->updateLegend(curve); #endif }
// // The (chart-level) implementation of tracing charts // TracingEngine::TracingEngine(Chart *chart) { QwtPlotPicker *picker = chart->my.picker; my.chart = chart; my.chart->my.style = Chart::EventStyle; my.scaleDraw = new TracingScaleDraw(this); chart->setAxisScaleDraw(QwtPlot::yLeft, my.scaleDraw); my.scaleEngine = new TracingScaleEngine(this); chart->setAxisScaleEngine(QwtPlot::yLeft, my.scaleEngine); // use a rectangular point picker for event tracing picker->setStateMachine(new QwtPickerDragRectMachine()); picker->setRubberBand(QwtPicker::RectRubberBand); picker->setRubberBandPen(QColor(Qt::green)); }
// // The SamplingEngine implements all sampling-specific Chart behaviour // SamplingEngine::SamplingEngine(Chart *chart, pmDesc &desc) { QwtPlotPicker *picker = chart->my.picker; ChartEngine *engine = chart->my.engine; my.chart = chart; my.rateConvert = engine->rateConvert(); my.antiAliasing = engine->antiAliasing(); normaliseUnits(desc); my.units = desc.units; my.scaleEngine = new SamplingScaleEngine(); chart->setAxisScaleEngine(QwtPlot::yLeft, my.scaleEngine); chart->setAxisScaleDraw(QwtPlot::yLeft, new QwtScaleDraw()); // use an individual point picker for sampled data picker->setStateMachine(new QwtPickerDragPointMachine()); picker->setRubberBand(QwtPicker::CrossRubberBand); picker->setRubberBandPen(QColor(Qt::green)); }
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 *) )); }