From 25fd6e0324dc8296b66a3c9b8e628d6738f15fe7 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 15 Oct 2011 18:23:04 -0400 Subject: qtgui: wip: updating qtgui to work with QWT 6 (and trying to maintain backwards compatability to 5.2). This wip works for just the fft plots. --- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'gr-qtgui/lib/TimeDomainDisplayPlot.cc') diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index f635a2b0c..b3c0a035a 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -103,14 +103,23 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) memset(_xAxisPoints, 0x0, _numPoints*sizeof(double)); _zoomer = new TimeDomainDisplayZoomer(canvas(), 0); + +#if QWT_VERSION < 0x060000 _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection); +#endif // Disable polygon clipping +#if QWT_VERSION < 0x060000 QwtPainter::setDeviceClipping(false); +#else + QwtPainter::setPolylineSplitting(false); +#endif +#if QWT_VERSION < 0x060000 // We don't need the cache here canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); +#endif QPalette palette; palette.setColor(canvas()->backgroundRole(), QColor("white")); @@ -130,8 +139,6 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) << QColor(Qt::yellow) << QColor(Qt::gray) << QColor(Qt::darkRed) << QColor(Qt::darkGreen) << QColor(Qt::darkBlue) << QColor(Qt::darkGray); - int ncolors = colors.size(); - // Setup dataPoints and plot vectors // Automatically deleted when parent is deleted for(int i = 0; i < _nplots; i++) { @@ -141,8 +148,13 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) _plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i))); _plot_curve[i]->attach(this); _plot_curve[i]->setPen(QPen(colors[i])); + +#if QWT_VERSION < 0x060000 _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _numPoints); - } +#else + _plot_curve[i]->setRawSamples(_xAxisPoints, _dataPoints[i], _numPoints); +#endif +} _sampleRate = 1; _resetXAxisPoints(); @@ -158,8 +170,8 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) // emit the position of clicks on widget _picker = new QwtDblClickPlotPicker(canvas()); - connect(_picker, SIGNAL(selected(const QwtDoublePoint &)), - this, SLOT(OnPickerPointSelected(const QwtDoublePoint &))); + connect(_picker, SIGNAL(selected(const QPointF &)), + this, SLOT(OnPickerPointSelected(const QPointF &))); // Configure magnify on mouse wheel _magnifier = new QwtPlotMagnifier(canvas()); @@ -245,7 +257,12 @@ void TimeDomainDisplayPlot::PlotNewData(const std::vector dataPoints, for(int i = 0; i < _nplots; i++) { delete[] _dataPoints[i]; _dataPoints[i] = new double[_numPoints]; + +#if QWT_VERSION < 0x060000 _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _numPoints); +#else + _plot_curve[i]->setRawSamples(_xAxisPoints, _dataPoints[i], _numPoints); +#endif } setXaxis(0, numDataPoints); @@ -300,8 +317,9 @@ TimeDomainDisplayPlot::SetSampleRate(double sr, double units, } } + void -TimeDomainDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) +TimeDomainDisplayPlot::OnPickerPointSelected(const QPointF & p) { QPointF point = p; //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); -- cgit From 33158da478cb0db5739663556e8dbeccbf08d7c9 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 00:19:10 -0400 Subject: qtgui: Time domain plot working againt under qwt6. --- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gr-qtgui/lib/TimeDomainDisplayPlot.cc') diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index b3c0a035a..8bc40b998 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -272,6 +272,8 @@ void TimeDomainDisplayPlot::PlotNewData(const std::vector dataPoints, for(int i = 0; i < _nplots; i++) { memcpy(_dataPoints[i], dataPoints[i], numDataPoints*sizeof(double)); } + + replot(); } } -- cgit From 45c2212608ca66b5fadbc860771e042198e1ebcd Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 19:45:29 -0400 Subject: qtgui: more compatability issues. --- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gr-qtgui/lib/TimeDomainDisplayPlot.cc') diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index 8bc40b998..eca6076b6 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -170,8 +170,14 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) // emit the position of clicks on widget _picker = new QwtDblClickPlotPicker(canvas()); + +#if QWT_VERSION < 0x060000 + connect(_picker, SIGNAL(selected(const QwtDoublePoint &)), + this, SLOT(OnPickerPointSelected(const QwtDoublePoint &))); +#else connect(_picker, SIGNAL(selected(const QPointF &)), this, SLOT(OnPickerPointSelected(const QPointF &))); +#endif // Configure magnify on mouse wheel _magnifier = new QwtPlotMagnifier(canvas()); @@ -320,6 +326,15 @@ TimeDomainDisplayPlot::SetSampleRate(double sr, double units, } +#if QWT_VERSION < 0x060000 +void +TimeDomainDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) +{ + QPointF point = p; + //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); + emit plotPointSelected(point); +} +#else void TimeDomainDisplayPlot::OnPickerPointSelected(const QPointF & p) { @@ -327,5 +342,6 @@ TimeDomainDisplayPlot::OnPickerPointSelected(const QPointF & p) //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); emit plotPointSelected(point); } +#endif #endif /* TIME_DOMAIN_DISPLAY_PLOT_C */ -- cgit