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/WaterfallDisplayPlot.cc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 1476be2bd..8d0622c94 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -274,7 +274,9 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) // Ctrl+RighButton: zoom out to full size _zoomer = new WaterfallZoomer(canvas(), 0); +#if QWT_VERSION < 0x060000 _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection); +#endif _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, @@ -286,9 +288,9 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(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 &))); + // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically @@ -433,7 +435,11 @@ void WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, const double maxIntensity) { +#if QWT_VERSION < 0x060000 _waterfallData->setRange(QwtDoubleInterval(minIntensity, maxIntensity)); +#else + _waterfallData->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity)); +#endif emit UpdatedLowerIntensityLevel(minIntensity); emit UpdatedUpperIntensityLevel(maxIntensity); @@ -549,12 +555,20 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight); rightAxis->setTitle("Intensity (dB)"); rightAxis->setColorBarEnabled(true); + +#if QWT_VERSION < 0x060000 rightAxis->setColorMap(d_spectrogram->data()->range(), d_spectrogram->colorMap()); - setAxisScale(QwtPlot::yRight, d_spectrogram->data()->range().minValue(), d_spectrogram->data()->range().maxValue() ); +#else + QwtInterval intv = d_spectrogram->data()->interval(); + QwtColorMap *map = (QwtColorMap*)(&d_spectrogram->colorMap()); + rightAxis->setColorMap(intv, map); + setAxisScale(QwtPlot::yRight, intv.minValue(), intv.maxValue()); +#endif + enableAxis(QwtPlot::yRight); plotLayout()->setAlignCanvasToScales(true); @@ -571,10 +585,10 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() } void -WaterfallDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) +WaterfallDisplayPlot::OnPickerPointSelected(const QPointF & p) { QPointF point = p; - //fprintf(stderr,"OnPickerPointSelected %f %f %d\n", point.x(), point.y(), _xAxisMultiplier); + //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } -- cgit From 4496fae2deea200755225c007a26f4c7be0470e9 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 16:32:41 -0400 Subject: qtgui: waterfall plot mostly working under qwt6 (plots, but updates to scale and color not working yet). --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 78 +++++++++++++++++------------------- 1 file changed, 36 insertions(+), 42 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 8d0622c94..b7e511b5b 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -241,8 +241,6 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) resize(parent->width(), parent->height()); _numPoints = 1024; - _waterfallData = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); - QPalette palette; palette.setColor(canvas()->backgroundRole(), QColor("white")); canvas()->setPalette(palette); @@ -255,24 +253,26 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) _lastReplot = 0; - d_spectrogram = new PlotWaterfall(_waterfallData, "Waterfall Display"); - _intensityColorMapType = INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR; - QwtLinearColorMap colorMap(Qt::darkCyan, Qt::white); - colorMap.addColorStop(0.25, Qt::cyan); - colorMap.addColorStop(0.5, Qt::yellow); - colorMap.addColorStop(0.75, Qt::red); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::darkCyan, Qt::white); + colorMap->addColorStop(0.25, Qt::cyan); + colorMap->addColorStop(0.5, Qt::yellow); + colorMap->addColorStop(0.75, Qt::red); - d_spectrogram->setColorMap(colorMap); + d_data = new WaterfallData(_startFrequency, _stopFrequency, + _numPoints, 200); + d_spectrogram = new QwtPlotSpectrogram("Spectrogram"); + d_spectrogram->setColorMap(colorMap); + d_spectrogram->setData(d_data); d_spectrogram->attach(this); + d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size - _zoomer = new WaterfallZoomer(canvas(), 0); #if QWT_VERSION < 0x060000 _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection); @@ -298,7 +298,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); sd->setMinimumExtent( fm.width("100.00") ); - const QColor c(Qt::white); + const QColor c(Qt::black); _zoomer->setRubberBandPen(c); _zoomer->setTrackerPen(c); @@ -309,15 +309,14 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) WaterfallDisplayPlot::~WaterfallDisplayPlot() { - delete _waterfallData; delete d_spectrogram; } void WaterfallDisplayPlot::Reset() { - _waterfallData->ResizeData(_startFrequency, _stopFrequency, _numPoints); - _waterfallData->Reset(); + d_data->ResizeData(_startFrequency, _stopFrequency, _numPoints); + d_data->Reset(); setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); @@ -410,9 +409,8 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, } if(gruel::high_res_timer_now() - _lastReplot > timePerFFT*gruel::high_res_timer_tps()) { - //FIXME: We may want to average the data between these updates to smooth display - _waterfallData->addFFTData(dataPoints, numDataPoints, droppedFrames); - _waterfallData->IncrementNumLinesToUpdate(); + d_data->addFFTData(dataPoints, numDataPoints, droppedFrames); + d_data->IncrementNumLinesToUpdate(); QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); timeScale->SetSecondsPerLine(timePerFFT); @@ -423,7 +421,7 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, d_spectrogram->invalidateCache(); d_spectrogram->itemChanged(); - + replot(); _lastReplot = gruel::high_res_timer_now(); @@ -433,14 +431,8 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, void WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, - const double maxIntensity) + const double maxIntensity) { -#if QWT_VERSION < 0x060000 - _waterfallData->setRange(QwtDoubleInterval(minIntensity, maxIntensity)); -#else - _waterfallData->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity)); -#endif - emit UpdatedLowerIntensityLevel(minIntensity); emit UpdatedUpperIntensityLevel(maxIntensity); @@ -453,7 +445,8 @@ WaterfallDisplayPlot::replot() QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); timeScale->initiateUpdate(); - WaterfallFreqDisplayScaleDraw* freqScale = (WaterfallFreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom); + WaterfallFreqDisplayScaleDraw* freqScale = \ + (WaterfallFreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom); freqScale->initiateUpdate(); // Update the time axis display @@ -496,29 +489,29 @@ WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, switch(newType){ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:{ _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::darkCyan, Qt::white); - colorMap.addColorStop(0.25, Qt::cyan); - colorMap.addColorStop(0.5, Qt::yellow); - colorMap.addColorStop(0.75, Qt::red); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::darkCyan, Qt::white); + colorMap->addColorStop(0.25, Qt::cyan); + colorMap->addColorStop(0.5, Qt::yellow); + colorMap->addColorStop(0.75, Qt::red); d_spectrogram->setColorMap(colorMap); break; } case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{ _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::black, Qt::white); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::black, Qt::white); d_spectrogram->setColorMap(colorMap); break; } case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{ _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::white, Qt::black); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::white, Qt::black); d_spectrogram->setColorMap(colorMap); break; } case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:{ _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::black, Qt::white); - colorMap.addColorStop(0.5, Qt::darkRed); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::black, Qt::white); + colorMap->addColorStop(0.5, Qt::darkRed); d_spectrogram->setColorMap(colorMap); break; } @@ -526,7 +519,8 @@ WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, _userDefinedLowIntensityColor = lowColor; _userDefinedHighIntensityColor = highColor; _intensityColorMapType = newType; - QwtLinearColorMap colorMap(_userDefinedLowIntensityColor, _userDefinedHighIntensityColor); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(_userDefinedLowIntensityColor, + _userDefinedHighIntensityColor); d_spectrogram->setColorMap(colorMap); break; } @@ -561,11 +555,11 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() d_spectrogram->colorMap()); setAxisScale(QwtPlot::yRight, d_spectrogram->data()->range().minValue(), - d_spectrogram->data()->range().maxValue() ); + d_spectrogram->data()->range().maxValue()); #else - QwtInterval intv = d_spectrogram->data()->interval(); - QwtColorMap *map = (QwtColorMap*)(&d_spectrogram->colorMap()); - rightAxis->setColorMap(intv, map); + QwtInterval intv = d_spectrogram->interval(Qt::ZAxis); + const QwtColorMap *map = d_spectrogram->colorMap(); + rightAxis->setColorMap(intv, (QwtColorMap*)map); setAxisScale(QwtPlot::yRight, intv.minValue(), intv.maxValue()); #endif @@ -574,8 +568,8 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() plotLayout()->setAlignCanvasToScales(true); // Tell the display to redraw everything - d_spectrogram->invalidateCache(); - d_spectrogram->itemChanged(); + ////d_spectrogram->invalidateCache(); + ////d_spectrogram->itemChanged(); // Draw again replot(); @@ -588,7 +582,7 @@ void WaterfallDisplayPlot::OnPickerPointSelected(const QPointF & p) { QPointF point = p; - //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); + fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } -- cgit From bade47de8c8e9fe92ae7a777260e900d6c708f09 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 17:35:24 -0400 Subject: qtgui: fixed waterfall color map issue under qwt6. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 93 ++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 19 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index b7e511b5b..ba15608e9 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -230,6 +230,58 @@ private: std::string _unitType; }; +class ColorMap_MultiColor: public QwtLinearColorMap +{ +public: + ColorMap_MultiColor(): + QwtLinearColorMap(Qt::darkCyan, Qt::white) + { + addColorStop(0.25, Qt::cyan); + addColorStop(0.5, Qt::yellow); + addColorStop(0.75, Qt::red); + } +}; + +class ColorMap_WhiteHot: public QwtLinearColorMap +{ +public: + ColorMap_WhiteHot(): + QwtLinearColorMap(Qt::black, Qt::white) + { + } +}; + +class ColorMap_BlackHot: public QwtLinearColorMap +{ +public: + ColorMap_BlackHot(): + QwtLinearColorMap(Qt::white, Qt::black) + { + } +}; + +class ColorMap_Incandescent: public QwtLinearColorMap +{ +public: + ColorMap_Incandescent(): + QwtLinearColorMap(Qt::black, Qt::white) + { + addColorStop(0.5, Qt::darkRed); + } +}; + +class ColorMap_UserDefined: public QwtLinearColorMap +{ +public: + ColorMap_UserDefined(QColor low, QColor high): + QwtLinearColorMap(low, high) + { + } +}; + +/********************************************************************* +MAIN WATERFALL PLOT WIDGET +*********************************************************************/ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) : QwtPlot(parent) @@ -489,39 +541,29 @@ WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, switch(newType){ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:{ _intensityColorMapType = newType; - QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::darkCyan, Qt::white); - colorMap->addColorStop(0.25, Qt::cyan); - colorMap->addColorStop(0.5, Qt::yellow); - colorMap->addColorStop(0.75, Qt::red); - d_spectrogram->setColorMap(colorMap); + d_spectrogram->setColorMap(new ColorMap_MultiColor()); break; } case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{ _intensityColorMapType = newType; - QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::black, Qt::white); - d_spectrogram->setColorMap(colorMap); + d_spectrogram->setColorMap(new ColorMap_WhiteHot()); break; } case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{ _intensityColorMapType = newType; - QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::white, Qt::black); - d_spectrogram->setColorMap(colorMap); + d_spectrogram->setColorMap(new ColorMap_BlackHot()); break; } case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:{ _intensityColorMapType = newType; - QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::black, Qt::white); - colorMap->addColorStop(0.5, Qt::darkRed); - d_spectrogram->setColorMap(colorMap); + d_spectrogram->setColorMap(new ColorMap_Incandescent()); break; } case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:{ _userDefinedLowIntensityColor = lowColor; _userDefinedHighIntensityColor = highColor; _intensityColorMapType = newType; - QwtLinearColorMap *colorMap = new QwtLinearColorMap(_userDefinedLowIntensityColor, - _userDefinedHighIntensityColor); - d_spectrogram->setColorMap(colorMap); + d_spectrogram->setColorMap(new ColorMap_UserDefined(lowColor, highColor)); break; } default: break; @@ -558,8 +600,21 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() d_spectrogram->data()->range().maxValue()); #else QwtInterval intv = d_spectrogram->interval(Qt::ZAxis); - const QwtColorMap *map = d_spectrogram->colorMap(); - rightAxis->setColorMap(intv, (QwtColorMap*)map); + switch(_intensityColorMapType) { + case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR: + rightAxis->setColorMap(intv, new ColorMap_MultiColor()); break; + case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT: + rightAxis->setColorMap(intv, new ColorMap_WhiteHot()); break; + case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT: + rightAxis->setColorMap(intv, new ColorMap_BlackHot()); break; + case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT: + rightAxis->setColorMap(intv, new ColorMap_Incandescent()); break; + case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED: + rightAxis->setColorMap(intv, new ColorMap_UserDefined(_userDefinedLowIntensityColor, + _userDefinedHighIntensityColor)); break; + default: + rightAxis->setColorMap(intv, new ColorMap_MultiColor()); break; + } setAxisScale(QwtPlot::yRight, intv.minValue(), intv.maxValue()); #endif @@ -568,8 +623,8 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() plotLayout()->setAlignCanvasToScales(true); // Tell the display to redraw everything - ////d_spectrogram->invalidateCache(); - ////d_spectrogram->itemChanged(); + d_spectrogram->invalidateCache(); + d_spectrogram->itemChanged(); // Draw again replot(); -- cgit From df09ce46e6783352e09981f61f1f25f1db1ab68c Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 17:56:51 -0400 Subject: qtgui: adjusting intensity knobs and auto scale in waterfall works in qwt6. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index ba15608e9..643370b96 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -306,11 +306,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) _lastReplot = 0; _intensityColorMapType = INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR; - - QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::darkCyan, Qt::white); - colorMap->addColorStop(0.25, Qt::cyan); - colorMap->addColorStop(0.5, Qt::yellow); - colorMap->addColorStop(0.75, Qt::red); + QwtLinearColorMap *colorMap = new ColorMap_MultiColor(); d_data = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); @@ -488,6 +484,8 @@ WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, emit UpdatedLowerIntensityLevel(minIntensity); emit UpdatedUpperIntensityLevel(maxIntensity); + d_data->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity)); + _UpdateIntensityRangeDisplay(); } -- cgit From 0319e05a4bb9a41082d00e334ac1647314dfaacd Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 18:39:45 -0400 Subject: qtgui: wip: working to make plots backwards compatible with qwt 5.2. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 62 ++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 6 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 643370b96..84d71d76d 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -306,16 +306,21 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) _lastReplot = 0; _intensityColorMapType = INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR; - QwtLinearColorMap *colorMap = new ColorMap_MultiColor(); d_data = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); d_spectrogram = new QwtPlotSpectrogram("Spectrogram"); - d_spectrogram->setColorMap(colorMap); - d_spectrogram->setData(d_data); + d_spectrogram->setData(*d_data); d_spectrogram->attach(this); d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); + +#if QWT_VERSION < 0x060000 + ColorMap_MultiColor colorMap; + d_spectrogram->setColorMap(colorMap); +#else + d_spectrogram->setColorMap(new ColorMap_MultiColor()); +#endif // LeftButton for the zooming // MidButton for the panning @@ -336,8 +341,13 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(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 // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically @@ -357,6 +367,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) WaterfallDisplayPlot::~WaterfallDisplayPlot() { + delete d_data; delete d_spectrogram; } @@ -484,7 +495,10 @@ WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, emit UpdatedLowerIntensityLevel(minIntensity); emit UpdatedUpperIntensityLevel(maxIntensity); +#if QWT_VERSION < 0x060000 +#else d_data->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity)); +#endif _UpdateIntensityRangeDisplay(); } @@ -539,29 +553,54 @@ WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, switch(newType){ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:{ _intensityColorMapType = newType; +#if QWT_VERSION < 0x060000 + ColorMap_MultiColor colorMap; + d_spectrogram->setColorMap(colorMap); +#else d_spectrogram->setColorMap(new ColorMap_MultiColor()); +#endif break; } case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{ _intensityColorMapType = newType; +#if QWT_VERSION < 0x060000 + ColorMap_WhiteHot colorMap; + d_spectrogram->setColorMap(colorMap); +#else d_spectrogram->setColorMap(new ColorMap_WhiteHot()); +#endif break; } case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{ _intensityColorMapType = newType; +#if QWT_VERSION < 0x060000 + ColorMap_BlackHot colorMap; + d_spectrogram->setColorMap(colorMap); +#else d_spectrogram->setColorMap(new ColorMap_BlackHot()); +#endif break; } case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:{ _intensityColorMapType = newType; +#if QWT_VERSION < 0x060000 + ColorMap_Incandescent colorMap; + d_spectrogram->setColorMap(colorMap); +#else d_spectrogram->setColorMap(new ColorMap_Incandescent()); +#endif break; } case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:{ _userDefinedLowIntensityColor = lowColor; _userDefinedHighIntensityColor = highColor; _intensityColorMapType = newType; +#if QWT_VERSION < 0x060000 + ColorMap_UserDefined colorMap(lowColor, highColor); + d_spectrogram->setColorMap(colorMap); +#else d_spectrogram->setColorMap(new ColorMap_UserDefined(lowColor, highColor)); +#endif break; } default: break; @@ -591,11 +630,11 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() rightAxis->setColorBarEnabled(true); #if QWT_VERSION < 0x060000 - rightAxis->setColorMap(d_spectrogram->data()->range(), + rightAxis->setColorMap(d_data->range(), d_spectrogram->colorMap()); setAxisScale(QwtPlot::yRight, - d_spectrogram->data()->range().minValue(), - d_spectrogram->data()->range().maxValue()); + d_data->range().minValue(), + d_data->range().maxValue()); #else QwtInterval intv = d_spectrogram->interval(Qt::ZAxis); switch(_intensityColorMapType) { @@ -631,6 +670,16 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() _lastReplot = gruel::high_res_timer_now(); } +#if QWT_VERSION < 0x060000 +void +WaterfallDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) +{ + QPointF point = p; + fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); + point.setX(point.x() * _xAxisMultiplier); + emit plotPointSelected(point); +} +#else void WaterfallDisplayPlot::OnPickerPointSelected(const QPointF & p) { @@ -639,5 +688,6 @@ WaterfallDisplayPlot::OnPickerPointSelected(const QPointF & p) point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } +#endif #endif /* WATERFALL_DISPLAY_PLOT_C */ -- 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/WaterfallDisplayPlot.cc | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 84d71d76d..7abd9aeef 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -310,17 +310,20 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) d_data = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); - d_spectrogram = new QwtPlotSpectrogram("Spectrogram"); - d_spectrogram->setData(*d_data); - d_spectrogram->attach(this); - d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); - #if QWT_VERSION < 0x060000 + d_spectrogram = new PlotWaterfall(d_data, "Waterfall Display"); + ColorMap_MultiColor colorMap; d_spectrogram->setColorMap(colorMap); + #else + d_spectrogram = new QwtPlotSpectrogram("Spectrogram"); + d_spectrogram->setData(*d_data); + d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); d_spectrogram->setColorMap(new ColorMap_MultiColor()); #endif + + d_spectrogram->attach(this); // LeftButton for the zooming // MidButton for the panning @@ -492,14 +495,15 @@ void WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, const double maxIntensity) { - emit UpdatedLowerIntensityLevel(minIntensity); - emit UpdatedUpperIntensityLevel(maxIntensity); - #if QWT_VERSION < 0x060000 + d_data->setRange(QwtDoubleInterval(minIntensity, maxIntensity)); #else d_data->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity)); #endif + emit UpdatedLowerIntensityLevel(minIntensity); + emit UpdatedUpperIntensityLevel(maxIntensity); + _UpdateIntensityRangeDisplay(); } @@ -630,11 +634,11 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() rightAxis->setColorBarEnabled(true); #if QWT_VERSION < 0x060000 - rightAxis->setColorMap(d_data->range(), + rightAxis->setColorMap(d_spectrogram->data()->range(), d_spectrogram->colorMap()); setAxisScale(QwtPlot::yRight, - d_data->range().minValue(), - d_data->range().maxValue()); + d_spectrogram->data()->range().minValue(), + d_spectrogram->data()->range().maxValue()); #else QwtInterval intv = d_spectrogram->interval(Qt::ZAxis); switch(_intensityColorMapType) { @@ -675,7 +679,7 @@ void WaterfallDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) { QPointF point = p; - fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); + //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } @@ -684,7 +688,7 @@ void WaterfallDisplayPlot::OnPickerPointSelected(const QPointF & p) { QPointF point = p; - fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); + //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } -- cgit