From 32ef4974395913878f252434c21a63a259bb9b97 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 15 Oct 2011 16:32:35 -0400 Subject: qtgui: avoids a simple warning. --- gr-qtgui/lib/spectrumdisplayform.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gr-qtgui') diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index 0e8594029..d3ca01483 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -466,7 +466,8 @@ SpectrumDisplayForm::_AverageHistory(const double* newBuffer) if(_historyEntryCount > static_cast(_historyVector->size())){ _historyEntryCount = _historyVector->size(); } - _historyEntry = (++_historyEntry)%_historyVector->size(); + _historyEntry += 1; + _historyEntry = _historyEntry % _historyVector->size(); // Total up and then average the values double sum; -- cgit 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/ConstellationDisplayPlot.cc | 26 ++++++-- gr-qtgui/lib/ConstellationDisplayPlot.h | 8 ++- gr-qtgui/lib/FrequencyDisplayPlot.cc | 58 ++++++++++++++--- gr-qtgui/lib/FrequencyDisplayPlot.h | 8 ++- gr-qtgui/lib/SpectrumGUIClass.cc | 6 +- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 30 +++++++-- gr-qtgui/lib/TimeDomainDisplayPlot.h | 6 +- gr-qtgui/lib/WaterfallDisplayPlot.cc | 26 ++++++-- gr-qtgui/lib/WaterfallDisplayPlot.h | 6 +- gr-qtgui/lib/plot_waterfall.cc | 108 ++++++++++++------------------- gr-qtgui/lib/plot_waterfall.h | 26 +++++--- gr-qtgui/lib/qtgui_sink_f.h | 1 - gr-qtgui/lib/qtgui_util.cc | 34 +++++++++- gr-qtgui/lib/qtgui_util.h | 9 ++- gr-qtgui/lib/spectrumdisplayform.cc | 87 +++++++++++++++---------- gr-qtgui/lib/spectrumdisplayform.h | 18 +++--- gr-qtgui/lib/waterfallGlobalData.cc | 76 ++++++++++++++++++++-- gr-qtgui/lib/waterfallGlobalData.h | 17 +++++ 18 files changed, 390 insertions(+), 160 deletions(-) (limited to 'gr-qtgui') diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.cc b/gr-qtgui/lib/ConstellationDisplayPlot.cc index dda7cfea2..a9c64d274 100644 --- a/gr-qtgui/lib/ConstellationDisplayPlot.cc +++ b/gr-qtgui/lib/ConstellationDisplayPlot.cc @@ -68,11 +68,17 @@ ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent) _imagDataPoints = new double[_numPoints]; // 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")); @@ -91,13 +97,22 @@ ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent) _plot_curve->attach(this); _plot_curve->setPen(QPen(Qt::blue, _penSize, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); _plot_curve->setStyle(QwtPlotCurve::Dots); + +#if QWT_VERSION < 0x060000 _plot_curve->setRawData(_realDataPoints, _imagDataPoints, _numPoints); +#else + _plot_curve->setRawSamples(_realDataPoints, _imagDataPoints, _numPoints); +#endif memset(_realDataPoints, 0x0, _numPoints*sizeof(double)); memset(_imagDataPoints, 0x0, _numPoints*sizeof(double)); _zoomer = new ConstellationDisplayZoomer(canvas()); + +#if QWT_VERSION < 0x060000 _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection); +#endif + _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, @@ -120,9 +135,8 @@ ConstellationDisplayPlot::ConstellationDisplayPlot(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 &))); connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool ) ), this, SLOT(LegendEntryChecked(QwtPlotItem *, bool ) )); } @@ -193,7 +207,11 @@ void ConstellationDisplayPlot::PlotNewData(const double* realDataPoints, _realDataPoints = new double[_numPoints]; _imagDataPoints = new double[_numPoints]; +#if QWT_VERSION < 0x060000 _plot_curve->setRawData(_realDataPoints, _imagDataPoints, _numPoints); +#else + _plot_curve->setRawSamples(_realDataPoints, _imagDataPoints, _numPoints); +#endif } memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double)); @@ -210,7 +228,7 @@ ConstellationDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on) } void -ConstellationDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) +ConstellationDisplayPlot::OnPickerPointSelected(const QPointF & p) { QPointF point = p; //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.h b/gr-qtgui/lib/ConstellationDisplayPlot.h index 23004f86c..cab11c704 100644 --- a/gr-qtgui/lib/ConstellationDisplayPlot.h +++ b/gr-qtgui/lib/ConstellationDisplayPlot.h @@ -38,6 +38,11 @@ #include #include +#if QWT_VERSION >= 0x060000 +#include // doesn't seem necessary, but is... +#include +#endif + class ConstellationDisplayPlot : public QwtPlot { Q_OBJECT @@ -61,8 +66,7 @@ public: public slots: void resizeSlot( QSize *s ); - - void OnPickerPointSelected(const QwtDoublePoint & p); + void OnPickerPointSelected(const QPointF & p); signals: void plotPointSelected(const QPointF p); diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc b/gr-qtgui/lib/FrequencyDisplayPlot.cc index f57edd8f6..4e71dcad4 100644 --- a/gr-qtgui/lib/FrequencyDisplayPlot.cc +++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc @@ -133,11 +133,17 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) _xAxisPoints = new double[_numPoints]; // 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")); @@ -156,18 +162,35 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) _fft_plot_curve = new QwtPlotCurve("Power Spectrum"); _fft_plot_curve->attach(this); _fft_plot_curve->setPen(QPen(Qt::blue)); + +#if QWT_VERSION < 0x060000 _fft_plot_curve->setRawData(_xAxisPoints, _dataPoints, _numPoints); +#else + _fft_plot_curve->setRawSamples(_xAxisPoints, _dataPoints, _numPoints); +#endif _min_fft_plot_curve = new QwtPlotCurve("Minimum Power"); _min_fft_plot_curve->attach(this); _min_fft_plot_curve->setPen(QPen(Qt::magenta)); + +#if QWT_VERSION < 0x060000 _min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints); +#else + _min_fft_plot_curve->setRawSamples(_xAxisPoints, _minFFTPoints, _numPoints); +#endif + _min_fft_plot_curve->setVisible(false); _max_fft_plot_curve = new QwtPlotCurve("Maximum Power"); _max_fft_plot_curve->attach(this); _max_fft_plot_curve->setPen(QPen(Qt::darkYellow)); + +#if QWT_VERSION < 0x060000 _max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints); +#else + _max_fft_plot_curve->setRawSamples(_xAxisPoints, _maxFFTPoints, _numPoints); +#endif + _max_fft_plot_curve->setVisible(false); _lower_intensity_marker= new QwtPlotMarker(); @@ -197,9 +220,16 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) symbol.setSize(8); symbol.setPen(QPen(Qt::yellow)); symbol.setBrush(QBrush(Qt::yellow)); + +#if QWT_VERSION < 0x060000 _markerPeakAmplitude->setSymbol(symbol); - _markerPeakAmplitude->attach(this); +#else + _markerPeakAmplitude->setSymbol(&symbol); +#endif + /// THIS CAUSES A PROBLEM! + //_markerPeakAmplitude->attach(this); + _markerNoiseFloorAmplitude = new QwtPlotMarker(); _markerNoiseFloorAmplitude->setLineStyle(QwtPlotMarker::HLine); _markerNoiseFloorAmplitude->setLinePen(QPen(Qt::darkRed, 0, Qt::DotLine)); @@ -220,15 +250,19 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(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()); _magnifier->setAxisEnabled(QwtPlot::xBottom, false); _zoomer = new FreqDisplayZoomer(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, @@ -362,7 +396,7 @@ FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDat { // Only update plot if there is data and if the time interval has elapsed if((numDataPoints > 0) && - (gruel::high_res_timer_now() - _lastReplot > timeInterval*gruel::high_res_timer_tps())) { + (gruel::high_res_timer_now() - _lastReplot > timeInterval*gruel::high_res_timer_tps())) { if(numDataPoints != _numPoints) { _numPoints = numDataPoints; @@ -375,16 +409,22 @@ FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDat _xAxisPoints = new double[_numPoints]; _minFFTPoints = new double[_numPoints]; _maxFFTPoints = new double[_numPoints]; - + +#if QWT_VERSION < 0x060000 _fft_plot_curve->setRawData(_xAxisPoints, _dataPoints, _numPoints); _min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints); _max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints); +#else + _fft_plot_curve->setRawSamples(_xAxisPoints, _dataPoints, _numPoints); + _min_fft_plot_curve->setRawSamples(_xAxisPoints, _minFFTPoints, _numPoints); + _max_fft_plot_curve->setRawSamples(_xAxisPoints, _maxFFTPoints, _numPoints); +#endif _resetXAxisPoints(); ClearMaxData(); ClearMinData(); } - + memcpy(_dataPoints, dataPoints, numDataPoints*sizeof(double)); for(int64_t point = 0; point < numDataPoints; point++){ if(dataPoints[point] < _minFFTPoints[point]){ @@ -401,6 +441,8 @@ FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDat SetUpperIntensityLevel(_peakAmplitude); + replot(); + _lastReplot = gruel::high_res_timer_now(); } } @@ -478,7 +520,7 @@ FrequencyDisplayPlot::SetBGColour (QColor c) { QPalette palette; palette.setColor(canvas()->backgroundRole(), c); - canvas()->setPalette(palette); + canvas()->setPalette(palette); } void @@ -491,7 +533,7 @@ FrequencyDisplayPlot::ShowCFMarker (const bool show) } void -FrequencyDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) +FrequencyDisplayPlot::OnPickerPointSelected(const QPointF & p) { QPointF point = p; //fprintf(stderr,"OnPickerPointSelected %f %f %d\n", point.x(), point.y(), _xAxisMultiplier); diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.h b/gr-qtgui/lib/FrequencyDisplayPlot.h index a263fec2f..cd9393de8 100644 --- a/gr-qtgui/lib/FrequencyDisplayPlot.h +++ b/gr-qtgui/lib/FrequencyDisplayPlot.h @@ -39,6 +39,10 @@ #include #include +#if QWT_VERSION >= 0x060000 +#include +#endif + class FrequencyDisplayPlot:public QwtPlot{ Q_OBJECT @@ -75,8 +79,7 @@ public slots: void resizeSlot( QSize *e ); void SetLowerIntensityLevel(const double); void SetUpperIntensityLevel(const double); - - void OnPickerPointSelected(const QwtDoublePoint & p); + void OnPickerPointSelected(const QPointF & p); signals: void plotPointSelected(const QPointF p); @@ -107,6 +110,7 @@ private: QwtPlotMarker *_markerCF; QwtDblClickPlotPicker *_picker; + QwtPlotMagnifier *_magnifier; double* _dataPoints; diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc index af95e2bb2..e7ab84667 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/lib/SpectrumGUIClass.cc @@ -104,9 +104,9 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, // Toggle Windows on/off _spectrumDisplayForm->ToggleTabFrequency(frequency); - _spectrumDisplayForm->ToggleTabWaterfall(waterfall); - _spectrumDisplayForm->ToggleTabTime(time); - _spectrumDisplayForm->ToggleTabConstellation(constellation); + //_spectrumDisplayForm->ToggleTabWaterfall(waterfall); + //_spectrumDisplayForm->ToggleTabTime(time); + //_spectrumDisplayForm->ToggleTabConstellation(constellation); _windowOpennedFlag = true; 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()); diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/lib/TimeDomainDisplayPlot.h index af87e1b14..8e277bc81 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.h +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.h @@ -39,6 +39,10 @@ #include #include +#if QWT_VERSION >= 0x060000 +#include +#endif + class TimeDomainDisplayPlot:public QwtPlot{ Q_OBJECT @@ -61,7 +65,7 @@ public slots: void SetSampleRate(double sr, double units, const std::string &strunits); - void OnPickerPointSelected(const QwtDoublePoint & p); + void OnPickerPointSelected(const QPointF & p); signals: void plotPointSelected(const QPointF p); 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); } diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.h b/gr-qtgui/lib/WaterfallDisplayPlot.h index 0c6a521b1..17eba13b2 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.h +++ b/gr-qtgui/lib/WaterfallDisplayPlot.h @@ -34,6 +34,10 @@ #include +#if QWT_VERSION >= 0x060000 +#include +#endif + class WaterfallDisplayPlot:public QwtPlot{ Q_OBJECT @@ -73,7 +77,7 @@ public: public slots: void resizeSlot( QSize *s ); - void OnPickerPointSelected(const QwtDoublePoint & p); + void OnPickerPointSelected(const QPointF & p); signals: void UpdatedLowerIntensityLevel(const double); diff --git a/gr-qtgui/lib/plot_waterfall.cc b/gr-qtgui/lib/plot_waterfall.cc index 2b1447e03..e8e9c0e49 100644 --- a/gr-qtgui/lib/plot_waterfall.cc +++ b/gr-qtgui/lib/plot_waterfall.cc @@ -2,68 +2,35 @@ #include #include #include "qwt_painter.h" -#include "qwt_double_interval.h" #include "qwt_scale_map.h" #include "qwt_color_map.h" #include "plot_waterfall.h" -#if QT_VERSION < 0x040000 -typedef Q3ValueVector QwtColorTable; -#else -typedef QVector QwtColorTable; +#if QWT_VERSION < 0x060000 +#include "qwt_double_interval.h" #endif +typedef QVector QwtColorTable; class PlotWaterfallImage: public QImage { // This class hides some Qt3/Qt4 API differences public: PlotWaterfallImage(const QSize &size, QwtColorMap::Format format): -#if QT_VERSION < 0x040000 - QImage(size, format == QwtColorMap::RGB ? 32 : 8) -#else - QImage(size, format == QwtColorMap::RGB - ? QImage::Format_ARGB32 : QImage::Format_Indexed8 ) -#endif - { - } - - PlotWaterfallImage(const QImage &other): - QImage(other) - { - } - - void initColorTable(const QImage& other) - { -#if QT_VERSION < 0x040000 - const unsigned int numColors = other.numColors(); - - setNumColors(numColors); - for ( unsigned int i = 0; i < numColors; i++ ) - setColor(i, other.color(i)); -#else - setColorTable(other.colorTable()); -#endif - } - -#if QT_VERSION < 0x040000 - - void setColorTable(const QwtColorTable &colorTable) - { - setNumColors(colorTable.size()); - for ( unsigned int i = 0; i < colorTable.size(); i++ ) - setColor(i, colorTable[i]); - } - - QwtColorTable colorTable() const - { - QwtColorTable table(numColors()); - for ( int i = 0; i < numColors(); i++ ) - table[i] = color(i); - - return table; - } -#endif + QImage(size, format == QwtColorMap::RGB + ? QImage::Format_ARGB32 : QImage::Format_Indexed8 ) + { + } + + PlotWaterfallImage(const QImage &other): + QImage(other) + { + } + + void initColorTable(const QImage& other) + { + setColorTable(other.colorTable()); + } }; class PlotWaterfall::PrivateData @@ -138,7 +105,11 @@ int PlotWaterfall::rtti() const void PlotWaterfall::setColorMap(const QwtColorMap &colorMap) { delete d_data->colorMap; +#if QWT_VERSION < 0x060000 d_data->colorMap = colorMap.copy(); +#else + memcpy(&d_data->colorMap, &colorMap, sizeof(colorMap)); +#endif invalidateCache(); itemChanged(); @@ -156,10 +127,12 @@ const QwtColorMap &PlotWaterfall::colorMap() const \return Bounding rect of the data \sa QwtRasterData::boundingRect */ +#if QWT_VERSION < 0x060000 QwtDoubleRect PlotWaterfall::boundingRect() const { - return d_data->data->boundingRect(); + return d_data->data->boundingRect(); } +#endif /*! \brief Returns the recommended raster for a given rect. @@ -170,10 +143,12 @@ QwtDoubleRect PlotWaterfall::boundingRect() const \param rect Rect for the raster hint \return data().rasterHint(rect) */ +#if 0 QSize PlotWaterfall::rasterHint(const QwtDoubleRect &rect) const { - return d_data->data->rasterHint(rect); + return d_data->data->rasterHint(rect); } +#endif /*! \brief Render an image from the data and color map. @@ -192,19 +167,21 @@ QSize PlotWaterfall::rasterHint(const QwtDoubleRect &rect) const \sa QwtRasterData::intensity(), QwtColorMap::rgb(), QwtColorMap::colorIndex() */ -QImage PlotWaterfall::renderImage( - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QwtDoubleRect &area) const +QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &area, + const QSize &size) const { if ( area.isEmpty() ) return QImage(); - QRect rect = transform(xMap, yMap, area); + //QRect rect = transform(xMap, yMap, area); + QRect rect = QRect(0,0,0,0); QwtScaleMap xxMap = xMap; QwtScaleMap yyMap = yMap; - const QSize res = d_data->data->rasterHint(area); + const QSize res(0,0); // = d_data->data->rasterHint(area); if ( res.isValid() ) { /* @@ -243,7 +220,11 @@ QImage PlotWaterfall::renderImage( PlotWaterfallImage image(rect.size(), d_data->colorMap->format()); +#if QWT_VERSION < 0x060000 const QwtDoubleInterval intensityRange = d_data->data->range(); +#else + const QwtInterval intensityRange = d_data->data->interval(); +#endif if ( !intensityRange.isValid() ) return image; @@ -292,13 +273,7 @@ QImage PlotWaterfall::renderImage( const bool vInvert = yyMap.p1() < yyMap.p2(); if ( hInvert || vInvert ) { -#ifdef __GNUC__ -#endif -#if QT_VERSION < 0x040000 - image = image.mirror(hInvert, vInvert); -#else - image = image.mirrored(hInvert, vInvert); -#endif + image = image.mirrored(hInvert, vInvert); } return image; @@ -317,8 +292,9 @@ QImage PlotWaterfall::renderImage( */ void PlotWaterfall::draw(QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRect &canvasRect) const + const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { QwtPlotRasterItem::draw(painter, xMap, yMap, canvasRect); } diff --git a/gr-qtgui/lib/plot_waterfall.h b/gr-qtgui/lib/plot_waterfall.h index a11461611..ce24d88d8 100644 --- a/gr-qtgui/lib/plot_waterfall.h +++ b/gr-qtgui/lib/plot_waterfall.h @@ -3,9 +3,12 @@ #include #include +#include -#include "qwt_valuelist.h" -#include "qwt_plot_rasteritem.h" +#if QWT_VERSION >= 0x060000 +#include // doesn't seem necessary, but is... +#include +#endif class QwtColorMap; @@ -22,7 +25,8 @@ class QwtColorMap; class PlotWaterfall: public QwtPlotRasterItem { public: - explicit PlotWaterfall(WaterfallData* data, const QString &title = QString::null); + explicit PlotWaterfall(WaterfallData* data, + const QString &title = QString::null); virtual ~PlotWaterfall(); const WaterfallData* data()const; @@ -30,19 +34,23 @@ public: void setColorMap(const QwtColorMap &); const QwtColorMap &colorMap() const; +#if QWT_VERSION < 0x060000 virtual QwtDoubleRect boundingRect() const; - virtual QSize rasterHint(const QwtDoubleRect &) const; +#endif + //virtual QSize rasterHint(const QwtDoubleRect &) const; virtual int rtti() const; virtual void draw(QPainter *p, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRect &rect) const; + const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &rect) const; protected: - virtual QImage renderImage( - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QwtDoubleRect &rect) const; + QImage renderImage(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &rect, + const QSize &size=QSize(0,0)) const; private: class PrivateData; diff --git a/gr-qtgui/lib/qtgui_sink_f.h b/gr-qtgui/lib/qtgui_sink_f.h index 30db05eea..6d43f18dd 100644 --- a/gr-qtgui/lib/qtgui_sink_f.h +++ b/gr-qtgui/lib/qtgui_sink_f.h @@ -29,7 +29,6 @@ #include #include #include -//#include #include "SpectrumGUIClass.h" class qtgui_sink_f; diff --git a/gr-qtgui/lib/qtgui_util.cc b/gr-qtgui/lib/qtgui_util.cc index 87b90997a..543ce1b1c 100644 --- a/gr-qtgui/lib/qtgui_util.cc +++ b/gr-qtgui/lib/qtgui_util.cc @@ -22,17 +22,24 @@ #include +#if QWT_VERSION < 0x060000 QwtPickerDblClickPointMachine::QwtPickerDblClickPointMachine() : QwtPickerMachine () { - } +#else +QwtPickerDblClickPointMachine::QwtPickerDblClickPointMachine() + : QwtPickerMachine (PointSelection) +{ +} +#endif QwtPickerDblClickPointMachine::~QwtPickerDblClickPointMachine() { } +#if QWT_VERSION < 0x060000 QwtPickerMachine::CommandList QwtPickerDblClickPointMachine::transition(const QwtEventPattern &eventPattern, const QEvent *e) @@ -53,10 +60,35 @@ QwtPickerDblClickPointMachine::transition(const QwtEventPattern &eventPattern, return cmdList; } +#else + +QList +QwtPickerDblClickPointMachine::transition(const QwtEventPattern &eventPattern, + const QEvent *e) +{ + QList cmdList; + switch(e->type()) { + case QEvent::MouseButtonDblClick: + if ( eventPattern.mouseMatch(QwtEventPattern::MouseSelect1, + (const QMouseEvent *)e) ) { + cmdList += QwtPickerMachine::Begin; + cmdList += QwtPickerMachine::Append; + cmdList += QwtPickerMachine::End; + } + break; + default: + break; + } + return cmdList; +} +#endif + QwtDblClickPlotPicker::QwtDblClickPlotPicker(QwtPlotCanvas* canvas) : QwtPlotPicker(canvas) { +#if QWT_VERSION < 0x060000 setSelectionFlags(QwtPicker::PointSelection); +#endif } QwtDblClickPlotPicker::~QwtDblClickPlotPicker() diff --git a/gr-qtgui/lib/qtgui_util.h b/gr-qtgui/lib/qtgui_util.h index 5b129c7b5..7b3692e75 100644 --- a/gr-qtgui/lib/qtgui_util.h +++ b/gr-qtgui/lib/qtgui_util.h @@ -44,7 +44,14 @@ public: QwtPickerDblClickPointMachine(); ~QwtPickerDblClickPointMachine(); - virtual CommandList transition( const QwtEventPattern &eventPattern, const QEvent *e); +#if QWT_VERSION < 0x060000 + virtual CommandList transition( const QwtEventPattern &eventPattern, + const QEvent *e); +#else + virtual QList + transition( const QwtEventPattern &eventPattern, + const QEvent *e); +#endif }; #endif /* INCLUDED_QTGUI_UTIL_H */ diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index d3ca01483..f52f96241 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -34,37 +34,37 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) _intValidator = new QIntValidator(this); _intValidator->setBottom(0); _frequencyDisplayPlot = new FrequencyDisplayPlot(FrequencyPlotDisplayFrame); - _waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame); + //_waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame); - _timeDomainDisplayPlot = new TimeDomainDisplayPlot(2, TimeDomainDisplayFrame); - _constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame); + //_timeDomainDisplayPlot = new TimeDomainDisplayPlot(2, TimeDomainDisplayFrame); + //_constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame); _numRealDataPoints = 1024; _realFFTDataPoints = new double[_numRealDataPoints]; _averagedValues = new double[_numRealDataPoints]; _historyVector = new std::vector; - _timeDomainDisplayPlot->setTitle(0, "real"); - _timeDomainDisplayPlot->setTitle(1, "imag"); + //_timeDomainDisplayPlot->setTitle(0, "real"); + //_timeDomainDisplayPlot->setTitle(1, "imag"); AvgLineEdit->setRange(0, 500); // Set range of Average box value from 0 to 500 MinHoldCheckBox_toggled( false ); MaxHoldCheckBox_toggled( false ); - WaterfallMaximumIntensityWheel->setRange(-200, 0); - WaterfallMaximumIntensityWheel->setTickCnt(50); - WaterfallMinimumIntensityWheel->setRange(-200, 0); - WaterfallMinimumIntensityWheel->setTickCnt(50); - WaterfallMinimumIntensityWheel->setValue(-200); + //WaterfallMaximumIntensityWheel->setRange(-200, 0); + //WaterfallMaximumIntensityWheel->setTickCnt(50); + //WaterfallMinimumIntensityWheel->setRange(-200, 0); + //WaterfallMinimumIntensityWheel->setTickCnt(50); + //WaterfallMinimumIntensityWheel->setValue(-200); _peakFrequency = 0; _peakAmplitude = -HUGE_VAL; _noiseFloorAmplitude = -HUGE_VAL; - connect(_waterfallDisplayPlot, SIGNAL(UpdatedLowerIntensityLevel(const double)), - _frequencyDisplayPlot, SLOT(SetLowerIntensityLevel(const double))); - connect(_waterfallDisplayPlot, SIGNAL(UpdatedUpperIntensityLevel(const double)), - _frequencyDisplayPlot, SLOT(SetUpperIntensityLevel(const double))); + //connect(_waterfallDisplayPlot, SIGNAL(UpdatedLowerIntensityLevel(const double)), + // _frequencyDisplayPlot, SLOT(SetLowerIntensityLevel(const double))); + //connect(_waterfallDisplayPlot, SIGNAL(UpdatedUpperIntensityLevel(const double)), + // _frequencyDisplayPlot, SLOT(SetUpperIntensityLevel(const double))); _frequencyDisplayPlot->SetLowerIntensityLevel(-200); _frequencyDisplayPlot->SetUpperIntensityLevel(-200); @@ -77,9 +77,9 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) Reset(); ToggleTabFrequency(false); - ToggleTabWaterfall(false); - ToggleTabTime(false); - ToggleTabConstellation(false); + //ToggleTabWaterfall(false); + //ToggleTabTime(false); + //ToggleTabConstellation(false); _historyEntry = 0; _historyEntryCount = 0; @@ -90,16 +90,16 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) // Connect double click signals up connect(_frequencyDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), - this, SLOT(onFFTPlotPointSelected(const QPointF))); + this, SLOT(onFFTPlotPointSelected(const QPointF))); - connect(_waterfallDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), - this, SLOT(onWFallPlotPointSelected(const QPointF))); + //connect(_waterfallDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), + // this, SLOT(onWFallPlotPointSelected(const QPointF))); - connect(_timeDomainDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), - this, SLOT(onTimePlotPointSelected(const QPointF))); + //connect(_timeDomainDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), + // this, SLOT(onTimePlotPointSelected(const QPointF))); - connect(_constellationDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), - this, SLOT(onConstPlotPointSelected(const QPointF))); + //connect(_constellationDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), + // this, SLOT(onConstPlotPointSelected(const QPointF))); } SpectrumDisplayForm::~SpectrumDisplayForm() @@ -238,6 +238,7 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate _noiseFloorAmplitude, _peakFrequency, _peakAmplitude, d_update_time); } + /* if(tabindex == d_plot_time) { _timeDomainDisplayPlot->PlotNewData(timeDomainDataPoints, numTimeDomainDataPoints, @@ -258,7 +259,7 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate spectrumUpdateEvent->getDroppedFFTFrames()); } } - + */ // Tell the system the GUI has been updated if(_systemSpecifiedFlag){ @@ -276,6 +277,7 @@ SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) s.setHeight(FrequencyPlotDisplayFrame->height()); emit _frequencyDisplayPlot->resizeSlot(&s); + /* s.setWidth(TimeDomainDisplayFrame->width()); s.setHeight(TimeDomainDisplayFrame->height()); emit _timeDomainDisplayPlot->resizeSlot(&s); @@ -287,6 +289,7 @@ SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) s.setWidth(ConstellationDisplayFrame->width()); s.setHeight(ConstellationDisplayFrame->height()); emit _constellationDisplayPlot->resizeSlot(&s); + */ } void @@ -299,8 +302,8 @@ SpectrumDisplayForm::customEvent( QEvent * e) //FFTSizeComboBox->setCurrentIndex(1); } - waterfallMinimumIntensityChangedCB(WaterfallMinimumIntensityWheel->value()); - waterfallMaximumIntensityChangedCB(WaterfallMaximumIntensityWheel->value()); + //waterfallMinimumIntensityChangedCB(WaterfallMinimumIntensityWheel->value()); + //waterfallMaximumIntensityChangedCB(WaterfallMaximumIntensityWheel->value()); // Clear any previous display Reset(); @@ -333,9 +336,9 @@ SpectrumDisplayForm::UpdateGuiTimer() // This is called by the displayTimer and redraws the canvases of // all of the plots. _frequencyDisplayPlot->canvas()->update(); - _waterfallDisplayPlot->canvas()->update(); - _timeDomainDisplayPlot->canvas()->update(); - _constellationDisplayPlot->canvas()->update(); + //_waterfallDisplayPlot->canvas()->update(); + //_timeDomainDisplayPlot->canvas()->update(); + //_constellationDisplayPlot->canvas()->update(); } @@ -417,6 +420,7 @@ SpectrumDisplayForm::SetFrequencyRange(const double newCenterFrequency, _centerFrequency, UseRFFrequenciesCheckBox->isChecked(), units, strunits[iunit]); + /* _waterfallDisplayPlot->SetFrequencyRange(_startFrequency, _stopFrequency, _centerFrequency, @@ -424,6 +428,7 @@ SpectrumDisplayForm::SetFrequencyRange(const double newCenterFrequency, units, strunits[iunit]); _timeDomainDisplayPlot->SetSampleRate(_stopFrequency - _startFrequency, units, strtime[iunit]); + */ } } @@ -512,7 +517,7 @@ SpectrumDisplayForm::Reset() { AverageDataReset(); - _waterfallDisplayPlot->Reset(); + //_waterfallDisplayPlot->Reset(); } @@ -561,6 +566,7 @@ SpectrumDisplayForm::UseRFFrequenciesCB( bool useRFFlag ) void SpectrumDisplayForm::waterfallMaximumIntensityChangedCB( double newValue ) { + /* if(newValue > WaterfallMinimumIntensityWheel->value()){ WaterfallMaximumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); } @@ -570,12 +576,14 @@ SpectrumDisplayForm::waterfallMaximumIntensityChangedCB( double newValue ) _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), WaterfallMaximumIntensityWheel->value()); + */ } void SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue ) { + /* if(newValue < WaterfallMaximumIntensityWheel->value()){ WaterfallMinimumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); } @@ -585,6 +593,7 @@ SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue ) _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), WaterfallMaximumIntensityWheel->value()); + */ } void @@ -599,6 +608,7 @@ SpectrumDisplayForm::FFTComboBoxSelectedCB( const QString &fftSizeString ) void SpectrumDisplayForm::WaterfallAutoScaleBtnCB() { + /* double minimumIntensity = _noiseFloorAmplitude - 5; if(minimumIntensity < WaterfallMinimumIntensityWheel->minValue()){ minimumIntensity = WaterfallMinimumIntensityWheel->minValue(); @@ -610,11 +620,13 @@ SpectrumDisplayForm::WaterfallAutoScaleBtnCB() } WaterfallMaximumIntensityWheel->setValue(maximumIntensity); waterfallMaximumIntensityChangedCB(maximumIntensity); + */ } void SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) { + /* QColor lowIntensityColor; QColor highIntensityColor; if(newType == WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED){ @@ -636,6 +648,7 @@ SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) } _waterfallDisplayPlot->SetIntensityColorMapType(newType, lowIntensityColor, highIntensityColor); + */ } void @@ -656,6 +669,7 @@ SpectrumDisplayForm::ToggleTabFrequency(const bool state) void SpectrumDisplayForm::ToggleTabWaterfall(const bool state) { + /* if(state == true) { if(d_plot_waterfall == -1) { SpectrumTypeTab->addTab(WaterfallPage, "Waterfall Display"); @@ -666,11 +680,13 @@ SpectrumDisplayForm::ToggleTabWaterfall(const bool state) SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(WaterfallPage)); d_plot_waterfall = -1; } + */ } void SpectrumDisplayForm::ToggleTabTime(const bool state) { + /* if(state == true) { if(d_plot_time == -1) { SpectrumTypeTab->addTab(TimeDomainPage, "Time Domain Display"); @@ -681,11 +697,13 @@ SpectrumDisplayForm::ToggleTabTime(const bool state) SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(TimeDomainPage)); d_plot_time = -1; } + */ } void SpectrumDisplayForm::ToggleTabConstellation(const bool state) { + /* if(state == true) { if(d_plot_constellation == -1) { SpectrumTypeTab->addTab(ConstellationPage, "Constellation Display"); @@ -696,26 +714,27 @@ SpectrumDisplayForm::ToggleTabConstellation(const bool state) SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(ConstellationPage)); d_plot_constellation = -1; } + */ } void SpectrumDisplayForm::SetTimeDomainAxis(double min, double max) { - _timeDomainDisplayPlot->setYaxis(min, max); + //_timeDomainDisplayPlot->setYaxis(min, max); } void SpectrumDisplayForm::SetConstellationAxis(double xmin, double xmax, double ymin, double ymax) { - _constellationDisplayPlot->set_axis(xmin, xmax, ymin, ymax); + //_constellationDisplayPlot->set_axis(xmin, xmax, ymin, ymax); } void SpectrumDisplayForm::SetConstellationPenSize(int size) { - _constellationDisplayPlot->set_pen_size( size ); + //_constellationDisplayPlot->set_pen_size( size ); } void diff --git a/gr-qtgui/lib/spectrumdisplayform.h b/gr-qtgui/lib/spectrumdisplayform.h index 30303a36f..77b796ae1 100644 --- a/gr-qtgui/lib/spectrumdisplayform.h +++ b/gr-qtgui/lib/spectrumdisplayform.h @@ -30,9 +30,9 @@ class SpectrumGUIClass; #include #include -#include -#include -#include +//#include +//#include +//#include #include #include #include @@ -112,9 +112,9 @@ private: double* _realFFTDataPoints; QIntValidator* _intValidator; FrequencyDisplayPlot* _frequencyDisplayPlot; - WaterfallDisplayPlot* _waterfallDisplayPlot; - TimeDomainDisplayPlot* _timeDomainDisplayPlot; - ConstellationDisplayPlot* _constellationDisplayPlot; + //WaterfallDisplayPlot* _waterfallDisplayPlot; + //TimeDomainDisplayPlot* _timeDomainDisplayPlot; + //ConstellationDisplayPlot* _constellationDisplayPlot; SpectrumGUIClass* _system; bool _systemSpecifiedFlag; double _centerFrequency; @@ -128,9 +128,9 @@ private: // whether or not to use a particular display int d_plot_fft; - int d_plot_waterfall; - int d_plot_time; - int d_plot_constellation; + //int d_plot_waterfall; + //int d_plot_time; + //int d_plot_constellation; QTimer *displayTimer; double d_update_time; diff --git a/gr-qtgui/lib/waterfallGlobalData.cc b/gr-qtgui/lib/waterfallGlobalData.cc index 1ba153f0d..66bea855a 100644 --- a/gr-qtgui/lib/waterfallGlobalData.cc +++ b/gr-qtgui/lib/waterfallGlobalData.cc @@ -7,10 +7,23 @@ WaterfallData::WaterfallData(const double minimumFrequency, const double maximumFrequency, const uint64_t fftPoints, const unsigned int historyExtent) +#if QWT_VERSION < 0x060000 : QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */, 0 /* Y START */, maximumFrequency - minimumFrequency /* WIDTH */, static_cast(historyExtent)/* HEIGHT */)) +#else + : QwtRasterData() +#endif { + _bounding_rect = QRectF(minimumFrequency, + 0, + maximumFrequency - minimumFrequency, + static_cast(historyExtent)); + +#if QWT_VERSION >= 0x060000 + pixelHint(_bounding_rect); +#endif + _intensityRange = QwtDoubleInterval(-200.0, 0.0); _fftPoints = fftPoints; @@ -35,6 +48,7 @@ void WaterfallData::Reset() void WaterfallData::Copy(const WaterfallData* rhs) { +#if QWT_VERSION < 0x060000 if((_fftPoints != rhs->GetNumFFTPoints()) || (boundingRect() != rhs->boundingRect()) ){ _fftPoints = rhs->GetNumFFTPoints(); @@ -42,38 +56,74 @@ void WaterfallData::Copy(const WaterfallData* rhs) delete[] _spectrumData; _spectrumData = new double[_fftPoints * _historyLength]; } +#else + if(_fftPoints != rhs->GetNumFFTPoints()) { + _fftPoints = rhs->GetNumFFTPoints(); + delete[] _spectrumData; + _spectrumData = new double[_fftPoints * _historyLength]; + } +#endif + Reset(); SetSpectrumDataBuffer(rhs->GetSpectrumDataBuffer()); SetNumLinesToUpdate(rhs->GetNumLinesToUpdate()); + +#if QWT_VERSION < 0x060000 setRange(rhs->range()); +#else + setInterval(Qt::ZAxis, rhs->interval()); +#endif } void WaterfallData::ResizeData(const double startFreq, const double stopFreq, const uint64_t fftPoints) { +#if QWT_VERSION < 0x060000 if((fftPoints != GetNumFFTPoints()) || (boundingRect().width() != (stopFreq - startFreq)) || (boundingRect().left() != startFreq)){ + + setBoundingRect(QwtDoubleRect(startFreq, 0, + stopFreq-startFreq, + boundingRect().height())); + _fftPoints = fftPoints; + delete[] _spectrumData; + _spectrumData = new double[_fftPoints * _historyLength]; + } + +#else + + if((fftPoints != GetNumFFTPoints()) || + (_bounding_rect.width() != (stopFreq - startFreq)) || + (_bounding_rect.left() != startFreq)){ + + _bounding_rect = QRectF(startFreq, 0, + stopFreq-startFreq, + _bounding_rect.height()); + pixelHint(_bounding_rect); - setBoundingRect(QwtDoubleRect(startFreq, 0, stopFreq-startFreq, boundingRect().height())); _fftPoints = fftPoints; delete[] _spectrumData; _spectrumData = new double[_fftPoints * _historyLength]; } +#endif + Reset(); } QwtRasterData *WaterfallData::copy() const { - WaterfallData* returnData = new WaterfallData(boundingRect().left(), - boundingRect().right(), + WaterfallData* returnData = new WaterfallData(_bounding_rect.left(), + _bounding_rect.right(), _fftPoints, _historyLength); returnData->Copy(this); return returnData; } + +#if QWT_VERSION < 0x060000 QwtDoubleInterval WaterfallData::range() const { return _intensityRange; @@ -84,13 +134,27 @@ void WaterfallData::setRange(const QwtDoubleInterval& newRange) _intensityRange = newRange; } +#else + +QwtInterval WaterfallData::interval() const +{ + return _intensityRange; +} + +void WaterfallData::setInterval(Qt::Axis axis, const QwtInterval& newRange) +{ + _intensityRange = newRange; +} +#endif + + double WaterfallData::value(double x, double y) const { double returnValue = 0.0; - const unsigned int intY = static_cast((1.0 - (y/boundingRect().height())) * - static_cast(_historyLength - 1)); - const unsigned int intX = static_cast((((x - boundingRect().left()) / boundingRect().width()) * + const unsigned int intY = static_cast((1.0 - (y/_bounding_rect.height())) * + static_cast(_historyLength-1)); + const unsigned int intX = static_cast((((x - _bounding_rect.left()) / _bounding_rect.width()) * static_cast(_fftPoints-1)) + 0.5); const int location = (intY * _fftPoints) + intX; diff --git a/gr-qtgui/lib/waterfallGlobalData.h b/gr-qtgui/lib/waterfallGlobalData.h index 51f65064c..f274daa2d 100644 --- a/gr-qtgui/lib/waterfallGlobalData.h +++ b/gr-qtgui/lib/waterfallGlobalData.h @@ -4,6 +4,10 @@ #include #include +#if QWT_VERSION >= 0x060000 +#include // doesn't seem necessary, but is... +#include +#endif class WaterfallData: public QwtRasterData { @@ -17,8 +21,14 @@ public: virtual void ResizeData(const double, const double, const uint64_t); virtual QwtRasterData *copy() const; + +#if QWT_VERSION < 0x060000 virtual QwtDoubleInterval range() const; virtual void setRange(const QwtDoubleInterval&); +#else + virtual QwtInterval interval() const; + virtual void setInterval(Qt::Axis axis, const QwtInterval&); +#endif virtual double value(double x, double y) const; @@ -38,7 +48,14 @@ protected: uint64_t _fftPoints; uint64_t _historyLength; int _numLinesToUpdate; + + QRectF _bounding_rect; + +#if QWT_VERSION < 0x060000 QwtDoubleInterval _intensityRange; +#else + QwtInterval _intensityRange; +#endif private: -- 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/SpectrumGUIClass.cc | 2 +- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 2 ++ gr-qtgui/lib/spectrumdisplayform.cc | 29 +++++++++++++---------------- gr-qtgui/lib/spectrumdisplayform.h | 6 +++--- 4 files changed, 19 insertions(+), 20 deletions(-) (limited to 'gr-qtgui') diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc index e7ab84667..026c1986c 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/lib/SpectrumGUIClass.cc @@ -105,7 +105,7 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, // Toggle Windows on/off _spectrumDisplayForm->ToggleTabFrequency(frequency); //_spectrumDisplayForm->ToggleTabWaterfall(waterfall); - //_spectrumDisplayForm->ToggleTabTime(time); + _spectrumDisplayForm->ToggleTabTime(time); //_spectrumDisplayForm->ToggleTabConstellation(constellation); _windowOpennedFlag = true; 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(); } } diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index f52f96241..8c9cc085f 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008,2009,2010,2011 Free Software Foundation, Inc. + * Copyright 2008-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -35,16 +35,15 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) _intValidator->setBottom(0); _frequencyDisplayPlot = new FrequencyDisplayPlot(FrequencyPlotDisplayFrame); //_waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame); - - //_timeDomainDisplayPlot = new TimeDomainDisplayPlot(2, TimeDomainDisplayFrame); + _timeDomainDisplayPlot = new TimeDomainDisplayPlot(2, TimeDomainDisplayFrame); //_constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame); _numRealDataPoints = 1024; _realFFTDataPoints = new double[_numRealDataPoints]; _averagedValues = new double[_numRealDataPoints]; _historyVector = new std::vector; - //_timeDomainDisplayPlot->setTitle(0, "real"); - //_timeDomainDisplayPlot->setTitle(1, "imag"); + _timeDomainDisplayPlot->setTitle(0, "real"); + _timeDomainDisplayPlot->setTitle(1, "imag"); AvgLineEdit->setRange(0, 500); // Set range of Average box value from 0 to 500 MinHoldCheckBox_toggled( false ); @@ -78,7 +77,7 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) ToggleTabFrequency(false); //ToggleTabWaterfall(false); - //ToggleTabTime(false); + ToggleTabTime(false); //ToggleTabConstellation(false); _historyEntry = 0; @@ -95,8 +94,8 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) //connect(_waterfallDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), // this, SLOT(onWFallPlotPointSelected(const QPointF))); - //connect(_timeDomainDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), - // this, SLOT(onTimePlotPointSelected(const QPointF))); + connect(_timeDomainDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), + this, SLOT(onTimePlotPointSelected(const QPointF))); //connect(_constellationDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), // this, SLOT(onConstPlotPointSelected(const QPointF))); @@ -238,12 +237,12 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate _noiseFloorAmplitude, _peakFrequency, _peakAmplitude, d_update_time); } - /* if(tabindex == d_plot_time) { _timeDomainDisplayPlot->PlotNewData(timeDomainDataPoints, numTimeDomainDataPoints, d_update_time); - } + } + /* if(tabindex == d_plot_constellation) { _constellationDisplayPlot->PlotNewData(realTimeDomainDataPoints, imagTimeDomainDataPoints, @@ -277,11 +276,11 @@ SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) s.setHeight(FrequencyPlotDisplayFrame->height()); emit _frequencyDisplayPlot->resizeSlot(&s); - /* s.setWidth(TimeDomainDisplayFrame->width()); s.setHeight(TimeDomainDisplayFrame->height()); emit _timeDomainDisplayPlot->resizeSlot(&s); + /* s.setWidth(WaterfallPlotDisplayFrame->width()); s.setHeight(WaterfallPlotDisplayFrame->height()); emit _waterfallDisplayPlot->resizeSlot(&s); @@ -337,7 +336,7 @@ SpectrumDisplayForm::UpdateGuiTimer() // all of the plots. _frequencyDisplayPlot->canvas()->update(); //_waterfallDisplayPlot->canvas()->update(); - //_timeDomainDisplayPlot->canvas()->update(); + _timeDomainDisplayPlot->canvas()->update(); //_constellationDisplayPlot->canvas()->update(); } @@ -426,9 +425,9 @@ SpectrumDisplayForm::SetFrequencyRange(const double newCenterFrequency, _centerFrequency, UseRFFrequenciesCheckBox->isChecked(), units, strunits[iunit]); + */ _timeDomainDisplayPlot->SetSampleRate(_stopFrequency - _startFrequency, units, strtime[iunit]); - */ } } @@ -686,7 +685,6 @@ SpectrumDisplayForm::ToggleTabWaterfall(const bool state) void SpectrumDisplayForm::ToggleTabTime(const bool state) { - /* if(state == true) { if(d_plot_time == -1) { SpectrumTypeTab->addTab(TimeDomainPage, "Time Domain Display"); @@ -697,7 +695,6 @@ SpectrumDisplayForm::ToggleTabTime(const bool state) SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(TimeDomainPage)); d_plot_time = -1; } - */ } void @@ -721,7 +718,7 @@ SpectrumDisplayForm::ToggleTabConstellation(const bool state) void SpectrumDisplayForm::SetTimeDomainAxis(double min, double max) { - //_timeDomainDisplayPlot->setYaxis(min, max); + _timeDomainDisplayPlot->setYaxis(min, max); } void diff --git a/gr-qtgui/lib/spectrumdisplayform.h b/gr-qtgui/lib/spectrumdisplayform.h index 77b796ae1..061ce63a1 100644 --- a/gr-qtgui/lib/spectrumdisplayform.h +++ b/gr-qtgui/lib/spectrumdisplayform.h @@ -31,7 +31,7 @@ class SpectrumGUIClass; #include #include //#include -//#include +#include //#include #include #include @@ -113,7 +113,7 @@ private: QIntValidator* _intValidator; FrequencyDisplayPlot* _frequencyDisplayPlot; //WaterfallDisplayPlot* _waterfallDisplayPlot; - //TimeDomainDisplayPlot* _timeDomainDisplayPlot; + TimeDomainDisplayPlot* _timeDomainDisplayPlot; //ConstellationDisplayPlot* _constellationDisplayPlot; SpectrumGUIClass* _system; bool _systemSpecifiedFlag; @@ -129,7 +129,7 @@ private: // whether or not to use a particular display int d_plot_fft; //int d_plot_waterfall; - //int d_plot_time; + int d_plot_time; //int d_plot_constellation; QTimer *displayTimer; -- cgit From 4ba2c75f9109b750f8c04b60a04f2100e33e9416 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 00:23:32 -0400 Subject: qtgui: constellation plot working again under qwt6. --- gr-qtgui/lib/ConstellationDisplayPlot.cc | 2 ++ gr-qtgui/lib/SpectrumGUIClass.cc | 2 +- gr-qtgui/lib/spectrumdisplayform.cc | 20 +++++++++----------- gr-qtgui/lib/spectrumdisplayform.h | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'gr-qtgui') diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.cc b/gr-qtgui/lib/ConstellationDisplayPlot.cc index a9c64d274..e01c99b74 100644 --- a/gr-qtgui/lib/ConstellationDisplayPlot.cc +++ b/gr-qtgui/lib/ConstellationDisplayPlot.cc @@ -217,6 +217,8 @@ void ConstellationDisplayPlot::PlotNewData(const double* realDataPoints, memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double)); memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double)); + replot(); + _lastReplot = gruel::high_res_timer_now(); } } diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc index 026c1986c..f71f457d9 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/lib/SpectrumGUIClass.cc @@ -106,7 +106,7 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, _spectrumDisplayForm->ToggleTabFrequency(frequency); //_spectrumDisplayForm->ToggleTabWaterfall(waterfall); _spectrumDisplayForm->ToggleTabTime(time); - //_spectrumDisplayForm->ToggleTabConstellation(constellation); + _spectrumDisplayForm->ToggleTabConstellation(constellation); _windowOpennedFlag = true; diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index 8c9cc085f..6f82c03ff 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -36,7 +36,7 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) _frequencyDisplayPlot = new FrequencyDisplayPlot(FrequencyPlotDisplayFrame); //_waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame); _timeDomainDisplayPlot = new TimeDomainDisplayPlot(2, TimeDomainDisplayFrame); - //_constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame); + _constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame); _numRealDataPoints = 1024; _realFFTDataPoints = new double[_numRealDataPoints]; _averagedValues = new double[_numRealDataPoints]; @@ -78,7 +78,7 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) ToggleTabFrequency(false); //ToggleTabWaterfall(false); ToggleTabTime(false); - //ToggleTabConstellation(false); + ToggleTabConstellation(false); _historyEntry = 0; _historyEntryCount = 0; @@ -97,8 +97,8 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) connect(_timeDomainDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), this, SLOT(onTimePlotPointSelected(const QPointF))); - //connect(_constellationDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), - // this, SLOT(onConstPlotPointSelected(const QPointF))); + connect(_constellationDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), + this, SLOT(onConstPlotPointSelected(const QPointF))); } SpectrumDisplayForm::~SpectrumDisplayForm() @@ -242,7 +242,6 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate numTimeDomainDataPoints, d_update_time); } - /* if(tabindex == d_plot_constellation) { _constellationDisplayPlot->PlotNewData(realTimeDomainDataPoints, imagTimeDomainDataPoints, @@ -250,6 +249,7 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate d_update_time); } + /* // Don't update the repeated data for the waterfall if(!repeatDataFlag){ if(tabindex == d_plot_waterfall) { @@ -284,11 +284,11 @@ SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) s.setWidth(WaterfallPlotDisplayFrame->width()); s.setHeight(WaterfallPlotDisplayFrame->height()); emit _waterfallDisplayPlot->resizeSlot(&s); + */ s.setWidth(ConstellationDisplayFrame->width()); s.setHeight(ConstellationDisplayFrame->height()); emit _constellationDisplayPlot->resizeSlot(&s); - */ } void @@ -337,7 +337,7 @@ SpectrumDisplayForm::UpdateGuiTimer() _frequencyDisplayPlot->canvas()->update(); //_waterfallDisplayPlot->canvas()->update(); _timeDomainDisplayPlot->canvas()->update(); - //_constellationDisplayPlot->canvas()->update(); + _constellationDisplayPlot->canvas()->update(); } @@ -700,7 +700,6 @@ SpectrumDisplayForm::ToggleTabTime(const bool state) void SpectrumDisplayForm::ToggleTabConstellation(const bool state) { - /* if(state == true) { if(d_plot_constellation == -1) { SpectrumTypeTab->addTab(ConstellationPage, "Constellation Display"); @@ -711,7 +710,6 @@ SpectrumDisplayForm::ToggleTabConstellation(const bool state) SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(ConstellationPage)); d_plot_constellation = -1; } - */ } @@ -725,13 +723,13 @@ void SpectrumDisplayForm::SetConstellationAxis(double xmin, double xmax, double ymin, double ymax) { - //_constellationDisplayPlot->set_axis(xmin, xmax, ymin, ymax); + _constellationDisplayPlot->set_axis(xmin, xmax, ymin, ymax); } void SpectrumDisplayForm::SetConstellationPenSize(int size) { - //_constellationDisplayPlot->set_pen_size( size ); + _constellationDisplayPlot->set_pen_size( size ); } void diff --git a/gr-qtgui/lib/spectrumdisplayform.h b/gr-qtgui/lib/spectrumdisplayform.h index 061ce63a1..8ee450daf 100644 --- a/gr-qtgui/lib/spectrumdisplayform.h +++ b/gr-qtgui/lib/spectrumdisplayform.h @@ -32,7 +32,7 @@ class SpectrumGUIClass; #include //#include #include -//#include +#include #include #include #include @@ -114,7 +114,7 @@ private: FrequencyDisplayPlot* _frequencyDisplayPlot; //WaterfallDisplayPlot* _waterfallDisplayPlot; TimeDomainDisplayPlot* _timeDomainDisplayPlot; - //ConstellationDisplayPlot* _constellationDisplayPlot; + ConstellationDisplayPlot* _constellationDisplayPlot; SpectrumGUIClass* _system; bool _systemSpecifiedFlag; double _centerFrequency; @@ -130,7 +130,7 @@ private: int d_plot_fft; //int d_plot_waterfall; int d_plot_time; - //int d_plot_constellation; + int d_plot_constellation; QTimer *displayTimer; double d_update_time; -- 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/Makefile.am | 2 - gr-qtgui/lib/SpectrumGUIClass.cc | 2 +- gr-qtgui/lib/WaterfallDisplayPlot.cc | 78 +++++++++++++++++------------------- gr-qtgui/lib/WaterfallDisplayPlot.h | 9 +++-- gr-qtgui/lib/plot_waterfall.cc | 29 +++++++------- gr-qtgui/lib/plot_waterfall.h | 1 + gr-qtgui/lib/spectrumdisplayform.cc | 51 ++++++++--------------- gr-qtgui/lib/spectrumdisplayform.h | 6 +-- gr-qtgui/lib/waterfallGlobalData.cc | 75 +++++++++++++++++----------------- gr-qtgui/lib/waterfallGlobalData.h | 5 --- 10 files changed, 116 insertions(+), 142 deletions(-) (limited to 'gr-qtgui') diff --git a/gr-qtgui/lib/Makefile.am b/gr-qtgui/lib/Makefile.am index 849ee8360..99c42a9f7 100644 --- a/gr-qtgui/lib/Makefile.am +++ b/gr-qtgui/lib/Makefile.am @@ -54,7 +54,6 @@ libgnuradio_qtgui_la_SOURCES = \ timedisplayform.cc \ SpectrumGUIClass.cc \ spectrumUpdateEvents.cc \ - plot_waterfall.cc \ qtgui_sink_c.cc \ qtgui_sink_f.cc \ qtgui_time_sink_c.cc \ @@ -70,7 +69,6 @@ grinclude_HEADERS = \ WaterfallDisplayPlot.h \ waterfallGlobalData.h \ ConstellationDisplayPlot.h \ - plot_waterfall.h \ spectrumdisplayform.h \ timedisplayform.h \ SpectrumGUIClass.h \ diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc index f71f457d9..af95e2bb2 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/lib/SpectrumGUIClass.cc @@ -104,7 +104,7 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, // Toggle Windows on/off _spectrumDisplayForm->ToggleTabFrequency(frequency); - //_spectrumDisplayForm->ToggleTabWaterfall(waterfall); + _spectrumDisplayForm->ToggleTabWaterfall(waterfall); _spectrumDisplayForm->ToggleTabTime(time); _spectrumDisplayForm->ToggleTabConstellation(constellation); 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); } diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.h b/gr-qtgui/lib/WaterfallDisplayPlot.h index 17eba13b2..90a72ff2e 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.h +++ b/gr-qtgui/lib/WaterfallDisplayPlot.h @@ -26,11 +26,13 @@ #include #include #include +#include #include #include #include -#include +//#include +#include #include @@ -93,14 +95,13 @@ private: double _stopFrequency; int _xAxisMultiplier; - PlotWaterfall *d_spectrogram; - QwtPlotPanner* _panner; QwtPlotZoomer* _zoomer; QwtDblClickPlotPicker *_picker; - WaterfallData* _waterfallData; + WaterfallData *d_data; + QwtPlotSpectrogram *d_spectrogram; gruel::high_res_timer_type _lastReplot; diff --git a/gr-qtgui/lib/plot_waterfall.cc b/gr-qtgui/lib/plot_waterfall.cc index e8e9c0e49..26f41e722 100644 --- a/gr-qtgui/lib/plot_waterfall.cc +++ b/gr-qtgui/lib/plot_waterfall.cc @@ -36,18 +36,18 @@ public: class PlotWaterfall::PrivateData { public: - PrivateData() - { - data = NULL; - colorMap = new QwtLinearColorMap(); - } - ~PrivateData() - { - delete colorMap; - } - - WaterfallData *data; - QwtColorMap *colorMap; + PrivateData() + { + data = NULL; + colorMap = new QwtLinearColorMap(); + } + ~PrivateData() + { + delete colorMap; + } + + WaterfallData *data; + QwtColorMap *colorMap; }; /*! @@ -121,8 +121,9 @@ void PlotWaterfall::setColorMap(const QwtColorMap &colorMap) */ const QwtColorMap &PlotWaterfall::colorMap() const { - return *d_data->colorMap; + return *d_data->colorMap; } + /*! \return Bounding rect of the data \sa QwtRasterData::boundingRect @@ -223,7 +224,7 @@ QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap, #if QWT_VERSION < 0x060000 const QwtDoubleInterval intensityRange = d_data->data->range(); #else - const QwtInterval intensityRange = d_data->data->interval(); + const QwtInterval intensityRange = d_data->data->interval(Qt::ZAxis); #endif if ( !intensityRange.isValid() ) return image; diff --git a/gr-qtgui/lib/plot_waterfall.h b/gr-qtgui/lib/plot_waterfall.h index ce24d88d8..120b5b4cf 100644 --- a/gr-qtgui/lib/plot_waterfall.h +++ b/gr-qtgui/lib/plot_waterfall.h @@ -32,6 +32,7 @@ public: const WaterfallData* data()const; void setColorMap(const QwtColorMap &); + const QwtColorMap &colorMap() const; #if QWT_VERSION < 0x060000 diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index 6f82c03ff..9fe553557 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -34,7 +34,7 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) _intValidator = new QIntValidator(this); _intValidator->setBottom(0); _frequencyDisplayPlot = new FrequencyDisplayPlot(FrequencyPlotDisplayFrame); - //_waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame); + _waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame); _timeDomainDisplayPlot = new TimeDomainDisplayPlot(2, TimeDomainDisplayFrame); _constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame); _numRealDataPoints = 1024; @@ -49,21 +49,21 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) MinHoldCheckBox_toggled( false ); MaxHoldCheckBox_toggled( false ); - //WaterfallMaximumIntensityWheel->setRange(-200, 0); - //WaterfallMaximumIntensityWheel->setTickCnt(50); - //WaterfallMinimumIntensityWheel->setRange(-200, 0); - //WaterfallMinimumIntensityWheel->setTickCnt(50); - //WaterfallMinimumIntensityWheel->setValue(-200); + WaterfallMaximumIntensityWheel->setRange(-200, 0); + WaterfallMaximumIntensityWheel->setTickCnt(50); + WaterfallMinimumIntensityWheel->setRange(-200, 0); + WaterfallMinimumIntensityWheel->setTickCnt(50); + WaterfallMinimumIntensityWheel->setValue(-200); _peakFrequency = 0; _peakAmplitude = -HUGE_VAL; _noiseFloorAmplitude = -HUGE_VAL; - //connect(_waterfallDisplayPlot, SIGNAL(UpdatedLowerIntensityLevel(const double)), - // _frequencyDisplayPlot, SLOT(SetLowerIntensityLevel(const double))); - //connect(_waterfallDisplayPlot, SIGNAL(UpdatedUpperIntensityLevel(const double)), - // _frequencyDisplayPlot, SLOT(SetUpperIntensityLevel(const double))); + connect(_waterfallDisplayPlot, SIGNAL(UpdatedLowerIntensityLevel(const double)), + _frequencyDisplayPlot, SLOT(SetLowerIntensityLevel(const double))); + connect(_waterfallDisplayPlot, SIGNAL(UpdatedUpperIntensityLevel(const double)), + _frequencyDisplayPlot, SLOT(SetUpperIntensityLevel(const double))); _frequencyDisplayPlot->SetLowerIntensityLevel(-200); _frequencyDisplayPlot->SetUpperIntensityLevel(-200); @@ -76,7 +76,7 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) Reset(); ToggleTabFrequency(false); - //ToggleTabWaterfall(false); + ToggleTabWaterfall(false); ToggleTabTime(false); ToggleTabConstellation(false); @@ -91,8 +91,8 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) connect(_frequencyDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), this, SLOT(onFFTPlotPointSelected(const QPointF))); - //connect(_waterfallDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), - // this, SLOT(onWFallPlotPointSelected(const QPointF))); + connect(_waterfallDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), + this, SLOT(onWFallPlotPointSelected(const QPointF))); connect(_timeDomainDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), this, SLOT(onTimePlotPointSelected(const QPointF))); @@ -249,7 +249,6 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate d_update_time); } - /* // Don't update the repeated data for the waterfall if(!repeatDataFlag){ if(tabindex == d_plot_waterfall) { @@ -258,7 +257,6 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate spectrumUpdateEvent->getDroppedFFTFrames()); } } - */ // Tell the system the GUI has been updated if(_systemSpecifiedFlag){ @@ -280,11 +278,9 @@ SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) s.setHeight(TimeDomainDisplayFrame->height()); emit _timeDomainDisplayPlot->resizeSlot(&s); - /* s.setWidth(WaterfallPlotDisplayFrame->width()); s.setHeight(WaterfallPlotDisplayFrame->height()); emit _waterfallDisplayPlot->resizeSlot(&s); - */ s.setWidth(ConstellationDisplayFrame->width()); s.setHeight(ConstellationDisplayFrame->height()); @@ -298,11 +294,10 @@ SpectrumDisplayForm::customEvent( QEvent * e) if(_systemSpecifiedFlag){ WindowComboBox->setCurrentIndex(_system->GetWindowType()); FFTSizeComboBox->setCurrentIndex(_system->GetFFTSizeIndex()); - //FFTSizeComboBox->setCurrentIndex(1); } - //waterfallMinimumIntensityChangedCB(WaterfallMinimumIntensityWheel->value()); - //waterfallMaximumIntensityChangedCB(WaterfallMaximumIntensityWheel->value()); + waterfallMinimumIntensityChangedCB(WaterfallMinimumIntensityWheel->value()); + waterfallMaximumIntensityChangedCB(WaterfallMaximumIntensityWheel->value()); // Clear any previous display Reset(); @@ -335,7 +330,7 @@ SpectrumDisplayForm::UpdateGuiTimer() // This is called by the displayTimer and redraws the canvases of // all of the plots. _frequencyDisplayPlot->canvas()->update(); - //_waterfallDisplayPlot->canvas()->update(); + _waterfallDisplayPlot->canvas()->update(); _timeDomainDisplayPlot->canvas()->update(); _constellationDisplayPlot->canvas()->update(); } @@ -419,13 +414,11 @@ SpectrumDisplayForm::SetFrequencyRange(const double newCenterFrequency, _centerFrequency, UseRFFrequenciesCheckBox->isChecked(), units, strunits[iunit]); - /* _waterfallDisplayPlot->SetFrequencyRange(_startFrequency, _stopFrequency, _centerFrequency, UseRFFrequenciesCheckBox->isChecked(), units, strunits[iunit]); - */ _timeDomainDisplayPlot->SetSampleRate(_stopFrequency - _startFrequency, units, strtime[iunit]); } @@ -516,7 +509,7 @@ SpectrumDisplayForm::Reset() { AverageDataReset(); - //_waterfallDisplayPlot->Reset(); + _waterfallDisplayPlot->Reset(); } @@ -565,7 +558,6 @@ SpectrumDisplayForm::UseRFFrequenciesCB( bool useRFFlag ) void SpectrumDisplayForm::waterfallMaximumIntensityChangedCB( double newValue ) { - /* if(newValue > WaterfallMinimumIntensityWheel->value()){ WaterfallMaximumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); } @@ -575,14 +567,12 @@ SpectrumDisplayForm::waterfallMaximumIntensityChangedCB( double newValue ) _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), WaterfallMaximumIntensityWheel->value()); - */ } void SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue ) { - /* if(newValue < WaterfallMaximumIntensityWheel->value()){ WaterfallMinimumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); } @@ -592,7 +582,6 @@ SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue ) _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), WaterfallMaximumIntensityWheel->value()); - */ } void @@ -607,7 +596,6 @@ SpectrumDisplayForm::FFTComboBoxSelectedCB( const QString &fftSizeString ) void SpectrumDisplayForm::WaterfallAutoScaleBtnCB() { - /* double minimumIntensity = _noiseFloorAmplitude - 5; if(minimumIntensity < WaterfallMinimumIntensityWheel->minValue()){ minimumIntensity = WaterfallMinimumIntensityWheel->minValue(); @@ -619,13 +607,11 @@ SpectrumDisplayForm::WaterfallAutoScaleBtnCB() } WaterfallMaximumIntensityWheel->setValue(maximumIntensity); waterfallMaximumIntensityChangedCB(maximumIntensity); - */ } void SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) { - /* QColor lowIntensityColor; QColor highIntensityColor; if(newType == WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED){ @@ -647,7 +633,6 @@ SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) } _waterfallDisplayPlot->SetIntensityColorMapType(newType, lowIntensityColor, highIntensityColor); - */ } void @@ -668,7 +653,6 @@ SpectrumDisplayForm::ToggleTabFrequency(const bool state) void SpectrumDisplayForm::ToggleTabWaterfall(const bool state) { - /* if(state == true) { if(d_plot_waterfall == -1) { SpectrumTypeTab->addTab(WaterfallPage, "Waterfall Display"); @@ -679,7 +663,6 @@ SpectrumDisplayForm::ToggleTabWaterfall(const bool state) SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(WaterfallPage)); d_plot_waterfall = -1; } - */ } void diff --git a/gr-qtgui/lib/spectrumdisplayform.h b/gr-qtgui/lib/spectrumdisplayform.h index 8ee450daf..30303a36f 100644 --- a/gr-qtgui/lib/spectrumdisplayform.h +++ b/gr-qtgui/lib/spectrumdisplayform.h @@ -30,7 +30,7 @@ class SpectrumGUIClass; #include #include -//#include +#include #include #include #include @@ -112,7 +112,7 @@ private: double* _realFFTDataPoints; QIntValidator* _intValidator; FrequencyDisplayPlot* _frequencyDisplayPlot; - //WaterfallDisplayPlot* _waterfallDisplayPlot; + WaterfallDisplayPlot* _waterfallDisplayPlot; TimeDomainDisplayPlot* _timeDomainDisplayPlot; ConstellationDisplayPlot* _constellationDisplayPlot; SpectrumGUIClass* _system; @@ -128,7 +128,7 @@ private: // whether or not to use a particular display int d_plot_fft; - //int d_plot_waterfall; + int d_plot_waterfall; int d_plot_time; int d_plot_constellation; diff --git a/gr-qtgui/lib/waterfallGlobalData.cc b/gr-qtgui/lib/waterfallGlobalData.cc index 66bea855a..c57a3b5c1 100644 --- a/gr-qtgui/lib/waterfallGlobalData.cc +++ b/gr-qtgui/lib/waterfallGlobalData.cc @@ -12,18 +12,9 @@ WaterfallData::WaterfallData(const double minimumFrequency, maximumFrequency - minimumFrequency /* WIDTH */, static_cast(historyExtent)/* HEIGHT */)) #else - : QwtRasterData() + : QwtRasterData() #endif { - _bounding_rect = QRectF(minimumFrequency, - 0, - maximumFrequency - minimumFrequency, - static_cast(historyExtent)); - -#if QWT_VERSION >= 0x060000 - pixelHint(_bounding_rect); -#endif - _intensityRange = QwtDoubleInterval(-200.0, 0.0); _fftPoints = fftPoints; @@ -31,6 +22,12 @@ WaterfallData::WaterfallData(const double minimumFrequency, _spectrumData = new double[_fftPoints * _historyLength]; +#if QWT_VERSION >= 0x060000 + setInterval(Qt::XAxis, QwtInterval(minimumFrequency, maximumFrequency)); + setInterval(Qt::YAxis, QwtInterval(0, historyExtent)); + setInterval(Qt::ZAxis, QwtInterval(-200, 0.0)); +#endif + Reset(); } @@ -71,7 +68,9 @@ void WaterfallData::Copy(const WaterfallData* rhs) #if QWT_VERSION < 0x060000 setRange(rhs->range()); #else - setInterval(Qt::ZAxis, rhs->interval()); + setInterval(Qt::XAxis, rhs->interval(Qt::XAxis)); + setInterval(Qt::YAxis, rhs->interval(Qt::YAxis)); + setInterval(Qt::ZAxis, rhs->interval(Qt::ZAxis)); #endif } @@ -93,31 +92,33 @@ void WaterfallData::ResizeData(const double startFreq, } #else - if((fftPoints != GetNumFFTPoints()) || - (_bounding_rect.width() != (stopFreq - startFreq)) || - (_bounding_rect.left() != startFreq)){ + (interval(Qt::XAxis).width() != (stopFreq - startFreq)) || + (interval(Qt::XAxis).minValue() != startFreq)){ - _bounding_rect = QRectF(startFreq, 0, - stopFreq-startFreq, - _bounding_rect.height()); - pixelHint(_bounding_rect); + setInterval(Qt::XAxis, QwtInterval(startFreq, stopFreq)); _fftPoints = fftPoints; delete[] _spectrumData; _spectrumData = new double[_fftPoints * _historyLength]; } #endif - - + Reset(); } QwtRasterData *WaterfallData::copy() const { - WaterfallData* returnData = new WaterfallData(_bounding_rect.left(), - _bounding_rect.right(), +#if QWT_VERSION < 0x060000 + WaterfallData* returnData = new WaterfallData(boundingRect().left(), + boundingRect().right(), _fftPoints, _historyLength); +#else + WaterfallData* returnData = new WaterfallData(interval(Qt::XAxis).minValue(), + interval(Qt::XAxis).maxValue(), + _fftPoints, _historyLength); +#endif + returnData->Copy(this); return returnData; } @@ -134,28 +135,27 @@ void WaterfallData::setRange(const QwtDoubleInterval& newRange) _intensityRange = newRange; } -#else - -QwtInterval WaterfallData::interval() const -{ - return _intensityRange; -} - -void WaterfallData::setInterval(Qt::Axis axis, const QwtInterval& newRange) -{ - _intensityRange = newRange; -} #endif double WaterfallData::value(double x, double y) const { double returnValue = 0.0; - - const unsigned int intY = static_cast((1.0 - (y/_bounding_rect.height())) * + +#if QWT_VERSION < 0x060000 + const unsigned int intY = static_cast((1.0 - (y/boundingRect().height())) * static_cast(_historyLength-1)); - const unsigned int intX = static_cast((((x - _bounding_rect.left()) / _bounding_rect.width()) * + const unsigned int intX = static_cast((((x - boundingRect().left()) / boundingRect().width()) * static_cast(_fftPoints-1)) + 0.5); +#else + double height = interval(Qt::YAxis).maxValue(); + double left = interval(Qt::XAxis).minValue(); + double right = interval(Qt::XAxis).maxValue(); + double ylen = static_cast(_historyLength-1); + double xlen = static_cast(_fftPoints-1); + const unsigned int intY = static_cast((1.0 - y/height) * ylen); + const unsigned int intX = static_cast((((x - left) / (right-left)) * xlen) + 0.5); +#endif const int location = (intY * _fftPoints) + intX; if((location > -1) && (location < static_cast(_fftPoints * _historyLength))){ @@ -196,7 +196,8 @@ void WaterfallData::addFFTData(const double* fftData, } // add the new buffer - memcpy(&_spectrumData[(_historyLength - 1) * _fftPoints], fftData, _fftPoints*sizeof(double)); + memcpy(&_spectrumData[(_historyLength - 1) * _fftPoints], fftData, + _fftPoints*sizeof(double)); } } diff --git a/gr-qtgui/lib/waterfallGlobalData.h b/gr-qtgui/lib/waterfallGlobalData.h index f274daa2d..89e48da5f 100644 --- a/gr-qtgui/lib/waterfallGlobalData.h +++ b/gr-qtgui/lib/waterfallGlobalData.h @@ -25,9 +25,6 @@ public: #if QWT_VERSION < 0x060000 virtual QwtDoubleInterval range() const; virtual void setRange(const QwtDoubleInterval&); -#else - virtual QwtInterval interval() const; - virtual void setInterval(Qt::Axis axis, const QwtInterval&); #endif virtual double value(double x, double y) const; @@ -49,8 +46,6 @@ protected: uint64_t _historyLength; int _numLinesToUpdate; - QRectF _bounding_rect; - #if QWT_VERSION < 0x060000 QwtDoubleInterval _intensityRange; #else -- 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') 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') 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 ++++++++++++++++++++++++++++++++---- gr-qtgui/lib/WaterfallDisplayPlot.h | 4 +++ 2 files changed, 60 insertions(+), 6 deletions(-) (limited to 'gr-qtgui') 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 */ diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.h b/gr-qtgui/lib/WaterfallDisplayPlot.h index 90a72ff2e..611566995 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.h +++ b/gr-qtgui/lib/WaterfallDisplayPlot.h @@ -79,7 +79,11 @@ public: public slots: void resizeSlot( QSize *s ); +#if QWT_VERSION < 0x060000 + void OnPickerPointSelected(const QwtDoublePoint & p); +#else void OnPickerPointSelected(const QPointF & p); +#endif signals: void UpdatedLowerIntensityLevel(const double); -- 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/ConstellationDisplayPlot.cc | 17 +++++++++++++++++ gr-qtgui/lib/ConstellationDisplayPlot.h | 5 +++++ gr-qtgui/lib/FrequencyDisplayPlot.cc | 17 +++++++++++++++++ gr-qtgui/lib/FrequencyDisplayPlot.h | 5 +++++ gr-qtgui/lib/Makefile.am | 2 ++ gr-qtgui/lib/TimeDomainDisplayPlot.cc | 16 ++++++++++++++++ gr-qtgui/lib/TimeDomainDisplayPlot.h | 4 ++++ gr-qtgui/lib/WaterfallDisplayPlot.cc | 30 +++++++++++++++++------------- gr-qtgui/lib/WaterfallDisplayPlot.h | 12 +++++++++--- gr-qtgui/lib/plot_waterfall.cc | 17 ++++++++++------- gr-qtgui/lib/plot_waterfall.h | 11 +++++++++-- gr-qtgui/lib/waterfallGlobalData.cc | 1 + 12 files changed, 112 insertions(+), 25 deletions(-) (limited to 'gr-qtgui') diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.cc b/gr-qtgui/lib/ConstellationDisplayPlot.cc index e01c99b74..ca7eede36 100644 --- a/gr-qtgui/lib/ConstellationDisplayPlot.cc +++ b/gr-qtgui/lib/ConstellationDisplayPlot.cc @@ -135,8 +135,15 @@ ConstellationDisplayPlot::ConstellationDisplayPlot(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 + connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool ) ), this, SLOT(LegendEntryChecked(QwtPlotItem *, bool ) )); } @@ -229,6 +236,15 @@ ConstellationDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on) plotItem->setVisible(!on); } +#if QWT_VERSION < 0x060000 +void +ConstellationDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) +{ + QPointF point = p; + //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); + emit plotPointSelected(point); +} +#else void ConstellationDisplayPlot::OnPickerPointSelected(const QPointF & p) { @@ -236,5 +252,6 @@ ConstellationDisplayPlot::OnPickerPointSelected(const QPointF & p) //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); emit plotPointSelected(point); } +#endif #endif /* CONSTELLATION_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.h b/gr-qtgui/lib/ConstellationDisplayPlot.h index cab11c704..d252a8c87 100644 --- a/gr-qtgui/lib/ConstellationDisplayPlot.h +++ b/gr-qtgui/lib/ConstellationDisplayPlot.h @@ -66,7 +66,12 @@ public: public slots: void resizeSlot( QSize *s ); + +#if QWT_VERSION < 0x060000 + void OnPickerPointSelected(const QwtDoublePoint & p); +#else void OnPickerPointSelected(const QPointF & p); +#endif signals: void plotPointSelected(const QPointF p); diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc b/gr-qtgui/lib/FrequencyDisplayPlot.cc index 4e71dcad4..2e62f2b96 100644 --- a/gr-qtgui/lib/FrequencyDisplayPlot.cc +++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc @@ -250,8 +250,14 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(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()); @@ -532,6 +538,16 @@ FrequencyDisplayPlot::ShowCFMarker (const bool show) _markerCF->hide(); } +#if QWT_VERSION < 0x060000 +void +FrequencyDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) +{ + QPointF point = p; + //fprintf(stderr,"OnPickerPointSelected %f %f %d\n", point.x(), point.y(), _xAxisMultiplier); + point.setX(point.x() * _xAxisMultiplier); + emit plotPointSelected(point); +} +#else void FrequencyDisplayPlot::OnPickerPointSelected(const QPointF & p) { @@ -540,5 +556,6 @@ FrequencyDisplayPlot::OnPickerPointSelected(const QPointF & p) point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } +#endif #endif /* FREQUENCY_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.h b/gr-qtgui/lib/FrequencyDisplayPlot.h index cd9393de8..961f30168 100644 --- a/gr-qtgui/lib/FrequencyDisplayPlot.h +++ b/gr-qtgui/lib/FrequencyDisplayPlot.h @@ -79,7 +79,12 @@ public slots: void resizeSlot( QSize *e ); void SetLowerIntensityLevel(const double); void SetUpperIntensityLevel(const double); + +#if QWT_VERSION < 0x060000 + void OnPickerPointSelected(const QwtDoublePoint & p); +#else void OnPickerPointSelected(const QPointF & p); +#endif signals: void plotPointSelected(const QPointF p); diff --git a/gr-qtgui/lib/Makefile.am b/gr-qtgui/lib/Makefile.am index 99c42a9f7..3257c3aae 100644 --- a/gr-qtgui/lib/Makefile.am +++ b/gr-qtgui/lib/Makefile.am @@ -54,6 +54,7 @@ libgnuradio_qtgui_la_SOURCES = \ timedisplayform.cc \ SpectrumGUIClass.cc \ spectrumUpdateEvents.cc \ + plot_waterfall.cc \ qtgui_sink_c.cc \ qtgui_sink_f.cc \ qtgui_time_sink_c.cc \ @@ -73,6 +74,7 @@ grinclude_HEADERS = \ timedisplayform.h \ SpectrumGUIClass.h \ spectrumUpdateEvents.h \ + plot_waterfall.h \ gr_qtgui_api.h \ qtgui_sink_c.h \ qtgui_sink_f.h \ 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 */ diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/lib/TimeDomainDisplayPlot.h index 8e277bc81..6c7fc4330 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.h +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.h @@ -65,7 +65,11 @@ public slots: void SetSampleRate(double sr, double units, const std::string &strunits); +#if QWT_VERSION < 0x060000 + void OnPickerPointSelected(const QwtDoublePoint & p); +#else void OnPickerPointSelected(const QPointF & p); +#endif signals: void plotPointSelected(const QPointF p); 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); } diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.h b/gr-qtgui/lib/WaterfallDisplayPlot.h index 611566995..0458597b0 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.h +++ b/gr-qtgui/lib/WaterfallDisplayPlot.h @@ -29,14 +29,14 @@ #include #include #include - #include -//#include #include #include -#if QWT_VERSION >= 0x060000 +#if QWT_VERSION < 0x060000 +#include +#else #include #endif @@ -79,6 +79,7 @@ public: public slots: void resizeSlot( QSize *s ); + #if QWT_VERSION < 0x060000 void OnPickerPointSelected(const QwtDoublePoint & p); #else @@ -105,7 +106,12 @@ private: QwtDblClickPlotPicker *_picker; WaterfallData *d_data; + +#if QWT_VERSION < 0x060000 + PlotWaterfall *d_spectrogram; +#else QwtPlotSpectrogram *d_spectrogram; +#endif gruel::high_res_timer_type _lastReplot; diff --git a/gr-qtgui/lib/plot_waterfall.cc b/gr-qtgui/lib/plot_waterfall.cc index 26f41e722..527eea22e 100644 --- a/gr-qtgui/lib/plot_waterfall.cc +++ b/gr-qtgui/lib/plot_waterfall.cc @@ -107,8 +107,6 @@ void PlotWaterfall::setColorMap(const QwtColorMap &colorMap) delete d_data->colorMap; #if QWT_VERSION < 0x060000 d_data->colorMap = colorMap.copy(); -#else - memcpy(&d_data->colorMap, &colorMap, sizeof(colorMap)); #endif invalidateCache(); @@ -144,7 +142,7 @@ QwtDoubleRect PlotWaterfall::boundingRect() const \param rect Rect for the raster hint \return data().rasterHint(rect) */ -#if 0 +#if QWT_VERSION < 0x060000 QSize PlotWaterfall::rasterHint(const QwtDoubleRect &rect) const { return d_data->data->rasterHint(rect); @@ -168,21 +166,26 @@ QSize PlotWaterfall::rasterHint(const QwtDoubleRect &rect) const \sa QwtRasterData::intensity(), QwtColorMap::rgb(), QwtColorMap::colorIndex() */ +#if QWT_VERSION < 0x060000 +QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtDoubleRect &area) const +#else QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &area, const QSize &size) const +#endif { if ( area.isEmpty() ) return QImage(); - //QRect rect = transform(xMap, yMap, area); - QRect rect = QRect(0,0,0,0); + QRect rect = transform(xMap, yMap, area); QwtScaleMap xxMap = xMap; QwtScaleMap yyMap = yMap; - const QSize res(0,0); // = d_data->data->rasterHint(area); + const QSize res = d_data->data->rasterHint(area); if ( res.isValid() ) { /* @@ -295,7 +298,7 @@ QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap, void PlotWaterfall::draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect) const + const QRect &canvasRect) const { QwtPlotRasterItem::draw(painter, xMap, yMap, canvasRect); } diff --git a/gr-qtgui/lib/plot_waterfall.h b/gr-qtgui/lib/plot_waterfall.h index 120b5b4cf..d4cb8d6da 100644 --- a/gr-qtgui/lib/plot_waterfall.h +++ b/gr-qtgui/lib/plot_waterfall.h @@ -38,20 +38,27 @@ public: #if QWT_VERSION < 0x060000 virtual QwtDoubleRect boundingRect() const; #endif - //virtual QSize rasterHint(const QwtDoubleRect &) const; + + virtual QSize rasterHint(const QwtDoubleRect &) const; virtual int rtti() const; virtual void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &rect) const; + const QRect &rect) const; protected: +#if QWT_VERSION < 0x060000 + QImage renderImage(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtDoubleRect &rect) const; +#else QImage renderImage(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &rect, const QSize &size=QSize(0,0)) const; +#endif private: class PrivateData; diff --git a/gr-qtgui/lib/waterfallGlobalData.cc b/gr-qtgui/lib/waterfallGlobalData.cc index c57a3b5c1..04366a297 100644 --- a/gr-qtgui/lib/waterfallGlobalData.cc +++ b/gr-qtgui/lib/waterfallGlobalData.cc @@ -2,6 +2,7 @@ #define WATERFALL_GLOBAL_DATA_CPP #include +#include WaterfallData::WaterfallData(const double minimumFrequency, const double maximumFrequency, -- cgit