From befadabc2f18b483c71250adfd7dbf42f66b16f0 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 12:55:16 -0400 Subject: gr-qtgui: restructuring qtgui directory to new layout. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 547 +++++++++++++++++++++++++++++++++++ 1 file changed, 547 insertions(+) create mode 100644 gr-qtgui/lib/WaterfallDisplayPlot.cc (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc new file mode 100644 index 000000000..a8e5361e7 --- /dev/null +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -0,0 +1,547 @@ +#ifndef WATERFALL_DISPLAY_PLOT_C +#define WATERFALL_DISPLAY_PLOT_C + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +namespace pt = boost::posix_time; + +class FreqOffsetAndPrecisionClass +{ +public: + FreqOffsetAndPrecisionClass(const int freqPrecision) + { + _frequencyPrecision = freqPrecision; + _centerFrequency = 0; + } + + virtual ~FreqOffsetAndPrecisionClass() + { + } + + virtual unsigned int GetFrequencyPrecision() const + { + return _frequencyPrecision; + } + + virtual void SetFrequencyPrecision(const unsigned int newPrecision) + { + _frequencyPrecision = newPrecision; + } + + virtual double GetCenterFrequency() const + { + return _centerFrequency; + } + + virtual void SetCenterFrequency(const double newFreq) + { + _centerFrequency = newFreq; + } + +protected: + unsigned int _frequencyPrecision; + double _centerFrequency; + +private: + +}; + +class WaterfallFreqDisplayScaleDraw: public QwtScaleDraw, public FreqOffsetAndPrecisionClass{ +public: + WaterfallFreqDisplayScaleDraw(const unsigned int precision) + : QwtScaleDraw(), FreqOffsetAndPrecisionClass(precision) + { + } + + virtual ~WaterfallFreqDisplayScaleDraw() + { + } + + QwtText label(double value) const + { + return QString("%1").arg(value, 0, 'f', GetFrequencyPrecision()); + } + + virtual void initiateUpdate() + { + invalidateCache(); + } + +protected: + +private: + +}; + +class TimeScaleData +{ +public: + TimeScaleData() + { + timespec_reset(&_zeroTime); + _secondsPerLine = 1.0; + } + + virtual ~TimeScaleData() + { + } + + virtual timespec GetZeroTime() const + { + return _zeroTime; + } + + virtual void SetZeroTime(const timespec newTime) + { + _zeroTime = newTime; + } + + virtual void SetSecondsPerLine(const double newTime) + { + _secondsPerLine = newTime; + } + + virtual double GetSecondsPerLine() const + { + return _secondsPerLine; + } + + +protected: + timespec _zeroTime; + double _secondsPerLine; + +private: + +}; + +class QwtTimeScaleDraw: public QwtScaleDraw, public TimeScaleData +{ +public: + QwtTimeScaleDraw():QwtScaleDraw(),TimeScaleData() + { + } + + virtual ~QwtTimeScaleDraw() + { + } + + virtual QwtText label(double value) const + { + timespec lineTime = timespec_add(GetZeroTime(), (-value) * GetSecondsPerLine()); + std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); + + // lops off the YYYY-mmm-DD part of the string + int ind = time_str.find(" "); + if(ind != std::string::npos) + time_str = time_str.substr(ind); + return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); + } + + virtual void initiateUpdate() + { + // Do this in one call rather than when zeroTime and secondsPerLine + // updates is to prevent the display from being updated too often... + invalidateCache(); + } + +protected: + +private: + +}; + +class WaterfallZoomer: public QwtPlotZoomer, public TimeScaleData, + public FreqOffsetAndPrecisionClass +{ +public: + WaterfallZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision) + : QwtPlotZoomer(canvas), TimeScaleData(), + FreqOffsetAndPrecisionClass(freqPrecision) + { + setTrackerMode(QwtPicker::AlwaysOn); + } + + virtual ~WaterfallZoomer() + { + } + + virtual void updateTrackerText() + { + updateDisplay(); + } + + void SetUnitType(const std::string &type) + { + _unitType = type; + } + +protected: + using QwtPlotZoomer::trackerText; + virtual QwtText trackerText( const QwtDoublePoint& p ) const + { + timespec lineTime = timespec_add(GetZeroTime(), (-p.y()) * GetSecondsPerLine()); + std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); + + // lops off the YYYY-mmm-DD part of the string + int ind = time_str.find(" "); + if(ind != std::string::npos) + time_str = time_str.substr(ind); + QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); + + QwtText t(QString("%1 %2, %3"). + arg(p.x(), 0, 'f', GetFrequencyPrecision()). + arg(_unitType.c_str()).arg(yLabel)); + return t; + } + +private: + std::string _unitType; +}; + + +WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) + : QwtPlot(parent) +{ + _zoomer = NULL; + _startFrequency = 0; + _stopFrequency = 4000; + + 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); + + setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)"); + setAxisScaleDraw(QwtPlot::xBottom, new WaterfallFreqDisplayScaleDraw(0)); + + setAxisTitle(QwtPlot::yLeft, "Time"); + setAxisScaleDraw(QwtPlot::yLeft, new QwtTimeScaleDraw()); + + timespec_reset(&_lastReplot); + + 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); + + d_spectrogram->setColorMap(colorMap); + + d_spectrogram->attach(this); + + // 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 QT_VERSION < 0x040000 + _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, + Qt::RightButton, Qt::ControlModifier); +#else + _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, + Qt::RightButton, Qt::ControlModifier); +#endif + _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, + Qt::RightButton); + + _panner = new QwtPlotPanner(canvas()); + _panner->setAxisEnabled(QwtPlot::yRight, false); + _panner->setMouseButton(Qt::MidButton); + + // Avoid jumping when labels with more/less digits + // appear/disappear when scrolling vertically + + const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); + QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); + sd->setMinimumExtent( fm.width("100.00") ); + + const QColor c(Qt::white); + _zoomer->setRubberBandPen(c); + _zoomer->setTrackerPen(c); + + _UpdateIntensityRangeDisplay(); +} + +WaterfallDisplayPlot::~WaterfallDisplayPlot() +{ + delete _waterfallData; + delete d_spectrogram; +} + +void +WaterfallDisplayPlot::Reset() +{ + _waterfallData->ResizeData(_startFrequency, _stopFrequency, _numPoints); + _waterfallData->Reset(); + + setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); + + // Load up the new base zoom settings + QwtDoubleRect newSize = _zoomer->zoomBase(); + newSize.setLeft(_startFrequency); + newSize.setWidth(_stopFrequency-_startFrequency); + _zoomer->zoom(newSize); + _zoomer->setZoomBase(newSize); + _zoomer->zoom(0); +} + +void +WaterfallDisplayPlot::SetFrequencyRange(const double constStartFreq, + const double constStopFreq, + const double constCenterFreq, + const bool useCenterFrequencyFlag, + const double units, const std::string &strunits) +{ + double startFreq = constStartFreq / units; + double stopFreq = constStopFreq / units; + double centerFreq = constCenterFreq / units; + + _useCenterFrequencyFlag = useCenterFrequencyFlag; + + if(_useCenterFrequencyFlag){ + startFreq = (startFreq + centerFreq); + stopFreq = (stopFreq + centerFreq); + } + + bool reset = false; + if((startFreq != _startFrequency) || (stopFreq != _stopFrequency)) + reset = true; + + if(stopFreq > startFreq) { + _startFrequency = startFreq; + _stopFrequency = stopFreq; + + if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){ + double display_units = ceil(log10(units)/2.0); + setAxisScaleDraw(QwtPlot::xBottom, new WaterfallFreqDisplayScaleDraw(display_units)); + setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str())); + + if(reset) { + Reset(); + } + + ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision(display_units); + ((WaterfallZoomer*)_zoomer)->SetUnitType(strunits); + } + } +} + + +double +WaterfallDisplayPlot::GetStartFrequency() const +{ + return _startFrequency; +} + +double +WaterfallDisplayPlot::GetStopFrequency() const +{ + return _stopFrequency; +} + +void +WaterfallDisplayPlot::PlotNewData(const double* dataPoints, + const int64_t numDataPoints, + const double timePerFFT, + const timespec timestamp, + const int droppedFrames) +{ + if(numDataPoints > 0){ + if(numDataPoints != _numPoints){ + _numPoints = numDataPoints; + + Reset(); + + d_spectrogram->invalidateCache(); + d_spectrogram->itemChanged(); + + if(isVisible()){ + replot(); + } + + _lastReplot = get_highres_clock(); + } + + if(diff_timespec(get_highres_clock(), _lastReplot) > timePerFFT) { + //FIXME: We may want to average the data between these updates to smooth display + _waterfallData->addFFTData(dataPoints, numDataPoints, droppedFrames); + _waterfallData->IncrementNumLinesToUpdate(); + + QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); + timeScale->SetSecondsPerLine(timePerFFT); + timeScale->SetZeroTime(timestamp); + + ((WaterfallZoomer*)_zoomer)->SetSecondsPerLine(timePerFFT); + ((WaterfallZoomer*)_zoomer)->SetZeroTime(timestamp); + + d_spectrogram->invalidateCache(); + d_spectrogram->itemChanged(); + + replot(); + + _lastReplot = get_highres_clock(); + } + } +} + +void +WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, + const double maxIntensity) +{ + _waterfallData->setRange(QwtDoubleInterval(minIntensity, maxIntensity)); + + emit UpdatedLowerIntensityLevel(minIntensity); + emit UpdatedUpperIntensityLevel(maxIntensity); + + _UpdateIntensityRangeDisplay(); +} + +void +WaterfallDisplayPlot::replot() +{ + QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); + timeScale->initiateUpdate(); + + WaterfallFreqDisplayScaleDraw* freqScale = (WaterfallFreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom); + freqScale->initiateUpdate(); + + // Update the time axis display + if(axisWidget(QwtPlot::yLeft) != NULL){ + axisWidget(QwtPlot::yLeft)->update(); + } + + // Update the Frequency Offset Display + if(axisWidget(QwtPlot::xBottom) != NULL){ + axisWidget(QwtPlot::xBottom)->update(); + } + + if(_zoomer != NULL){ + ((WaterfallZoomer*)_zoomer)->updateTrackerText(); + } + + QwtPlot::replot(); +} + +void +WaterfallDisplayPlot::resizeSlot( QSize *s ) +{ + resize(s->width(), s->height()); +} + +int +WaterfallDisplayPlot::GetIntensityColorMapType() const +{ + return _intensityColorMapType; +} + +void +WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, + const QColor lowColor, + const QColor highColor) +{ + if((_intensityColorMapType != newType) || + ((newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED) && + (lowColor.isValid() && highColor.isValid()))){ + 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); + d_spectrogram->setColorMap(colorMap); + break; + } + case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{ + _intensityColorMapType = newType; + QwtLinearColorMap colorMap(Qt::black, Qt::white); + d_spectrogram->setColorMap(colorMap); + break; + } + case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{ + _intensityColorMapType = newType; + QwtLinearColorMap colorMap(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); + d_spectrogram->setColorMap(colorMap); + break; + } + case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:{ + _userDefinedLowIntensityColor = lowColor; + _userDefinedHighIntensityColor = highColor; + _intensityColorMapType = newType; + QwtLinearColorMap colorMap(_userDefinedLowIntensityColor, _userDefinedHighIntensityColor); + d_spectrogram->setColorMap(colorMap); + break; + } + default: break; + } + + _UpdateIntensityRangeDisplay(); + } +} + +const QColor +WaterfallDisplayPlot::GetUserDefinedLowIntensityColor() const +{ + return _userDefinedLowIntensityColor; +} + +const QColor +WaterfallDisplayPlot::GetUserDefinedHighIntensityColor() const +{ + return _userDefinedHighIntensityColor; +} + +void +WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() +{ + QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight); + rightAxis->setTitle("Intensity (dB)"); + rightAxis->setColorBarEnabled(true); + rightAxis->setColorMap(d_spectrogram->data()->range(), + d_spectrogram->colorMap()); + + setAxisScale(QwtPlot::yRight, + d_spectrogram->data()->range().minValue(), + d_spectrogram->data()->range().maxValue() ); + enableAxis(QwtPlot::yRight); + + plotLayout()->setAlignCanvasToScales(true); + + // Tell the display to redraw everything + d_spectrogram->invalidateCache(); + d_spectrogram->itemChanged(); + + // Draw again + replot(); + + // Update the last replot timer + _lastReplot = get_highres_clock(); +} + +#endif /* WATERFALL_DISPLAY_PLOT_C */ -- cgit From b7f96d543b35b8d5a401ced3afbc0aff2d7043db Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 13:41:32 -0400 Subject: gr-qtgui: fixed some signed/unsigned comparison warnings. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index a8e5361e7..08a71c023 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -142,7 +142,7 @@ public: std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); // lops off the YYYY-mmm-DD part of the string - int ind = time_str.find(" "); + size_t ind = time_str.find(" "); if(ind != std::string::npos) time_str = time_str.substr(ind); return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); @@ -194,7 +194,7 @@ protected: std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); // lops off the YYYY-mmm-DD part of the string - int ind = time_str.find(" "); + size_t ind = time_str.find(" "); if(ind != std::string::npos) time_str = time_str.substr(ind); QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); -- cgit From 41ad09b4f22228dd555ea73f2078cb9ff056b979 Mon Sep 17 00:00:00 2001 From: Mike Cornelius Date: Mon, 11 Apr 2011 00:48:29 -0400 Subject: gr-qtgui: adding double-click point selector to main gui widgets. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 08a71c023..2234f4238 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -253,13 +253,9 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) // Ctrl+RighButton: zoom out to full size _zoomer = new WaterfallZoomer(canvas(), 0); -#if QT_VERSION < 0x040000 + _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection); _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); -#else - _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); -#endif _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); @@ -267,6 +263,11 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) _panner->setAxisEnabled(QwtPlot::yRight, false); _panner->setMouseButton(Qt::MidButton); + // emit the position of clicks on widget + _picker = new QwtDblClickPlotPicker(canvas()); + connect(_picker, SIGNAL(selected(const QwtDoublePoint &)), + this, SLOT(OnPickerPointSelected(const QwtDoublePoint &))); + // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically @@ -279,6 +280,8 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) _zoomer->setTrackerPen(c); _UpdateIntensityRangeDisplay(); + + _xAxisMultiplier = 1; } WaterfallDisplayPlot::~WaterfallDisplayPlot() @@ -315,6 +318,8 @@ WaterfallDisplayPlot::SetFrequencyRange(const double constStartFreq, double stopFreq = constStopFreq / units; double centerFreq = constCenterFreq / units; + _xAxisMultiplier = units; + _useCenterFrequencyFlag = useCenterFrequencyFlag; if(_useCenterFrequencyFlag){ @@ -544,4 +549,13 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() _lastReplot = get_highres_clock(); } +void +WaterfallDisplayPlot::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); +} + #endif /* WATERFALL_DISPLAY_PLOT_C */ -- cgit From 7ba2647977f9b302969208fa8548d1ca8dcddd4b Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 18 Apr 2011 23:07:31 -0400 Subject: gr-qtgui: adding copyright dates to qtgui files. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 2234f4238..52381a9f6 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -1,3 +1,25 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009,2010,2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + #ifndef WATERFALL_DISPLAY_PLOT_C #define WATERFALL_DISPLAY_PLOT_C -- cgit From 697562c3d4319ab6f13e4c2910a853409731595d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 7 Jun 2011 21:48:02 -0400 Subject: qtgui: replace timespec with typedef so its easier to replace --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 52381a9f6..9bcbc46d0 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -110,7 +110,7 @@ class TimeScaleData public: TimeScaleData() { - timespec_reset(&_zeroTime); + highres_timespec_reset(&_zeroTime); _secondsPerLine = 1.0; } @@ -118,12 +118,12 @@ public: { } - virtual timespec GetZeroTime() const + virtual highres_timespec GetZeroTime() const { return _zeroTime; } - virtual void SetZeroTime(const timespec newTime) + virtual void SetZeroTime(const highres_timespec newTime) { _zeroTime = newTime; } @@ -140,7 +140,7 @@ public: protected: - timespec _zeroTime; + highres_timespec _zeroTime; double _secondsPerLine; private: @@ -160,7 +160,7 @@ public: virtual QwtText label(double value) const { - timespec lineTime = timespec_add(GetZeroTime(), (-value) * GetSecondsPerLine()); + highres_timespec lineTime = highres_timespec_add(GetZeroTime(), -value*GetSecondsPerLine()); std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); // lops off the YYYY-mmm-DD part of the string @@ -212,7 +212,7 @@ protected: using QwtPlotZoomer::trackerText; virtual QwtText trackerText( const QwtDoublePoint& p ) const { - timespec lineTime = timespec_add(GetZeroTime(), (-p.y()) * GetSecondsPerLine()); + highres_timespec lineTime = highres_timespec_add(GetZeroTime(), -p.y()*GetSecondsPerLine()); std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); // lops off the YYYY-mmm-DD part of the string @@ -254,7 +254,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) setAxisTitle(QwtPlot::yLeft, "Time"); setAxisScaleDraw(QwtPlot::yLeft, new QwtTimeScaleDraw()); - timespec_reset(&_lastReplot); + highres_timespec_reset(&_lastReplot); d_spectrogram = new PlotWaterfall(_waterfallData, "Waterfall Display"); @@ -389,7 +389,7 @@ void WaterfallDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDataPoints, const double timePerFFT, - const timespec timestamp, + const highres_timespec timestamp, const int droppedFrames) { if(numDataPoints > 0){ @@ -408,7 +408,7 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, _lastReplot = get_highres_clock(); } - if(diff_timespec(get_highres_clock(), _lastReplot) > timePerFFT) { + if(diff_highres_timespec(get_highres_clock(), _lastReplot) > timePerFFT) { //FIXME: We may want to average the data between these updates to smooth display _waterfallData->addFFTData(dataPoints, numDataPoints, droppedFrames); _waterfallData->IncrementNumLinesToUpdate(); -- cgit From 1418dccc89f554202e33d4d743c910407e8710a6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 7 Jun 2011 22:27:35 -0400 Subject: qtgui: partially switch to gruel high res timer --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 9bcbc46d0..cc7ab14a3 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -110,7 +110,7 @@ class TimeScaleData public: TimeScaleData() { - highres_timespec_reset(&_zeroTime); + highres_timespec_reset(_zeroTime); _secondsPerLine = 1.0; } @@ -161,13 +161,14 @@ public: virtual QwtText label(double value) const { highres_timespec lineTime = highres_timespec_add(GetZeroTime(), -value*GetSecondsPerLine()); - std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); + unsigned long milliseconds = lineTime*1000/gruel::high_res_timer_tps(); + std::string time_str = pt::to_simple_string(pt::from_time_t(milliseconds/1000)); // lops off the YYYY-mmm-DD part of the string size_t ind = time_str.find(" "); if(ind != std::string::npos) time_str = time_str.substr(ind); - return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); + return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), milliseconds%1000)); } virtual void initiateUpdate() @@ -213,13 +214,14 @@ protected: virtual QwtText trackerText( const QwtDoublePoint& p ) const { highres_timespec lineTime = highres_timespec_add(GetZeroTime(), -p.y()*GetSecondsPerLine()); - std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); + unsigned long milliseconds = lineTime*1000/gruel::high_res_timer_tps(); + std::string time_str = pt::to_simple_string(pt::from_time_t(milliseconds/1000)); // lops off the YYYY-mmm-DD part of the string size_t ind = time_str.find(" "); if(ind != std::string::npos) time_str = time_str.substr(ind); - QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); + QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), milliseconds%1000)); QwtText t(QString("%1 %2, %3"). arg(p.x(), 0, 'f', GetFrequencyPrecision()). @@ -254,7 +256,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) setAxisTitle(QwtPlot::yLeft, "Time"); setAxisScaleDraw(QwtPlot::yLeft, new QwtTimeScaleDraw()); - highres_timespec_reset(&_lastReplot); + highres_timespec_reset(_lastReplot); d_spectrogram = new PlotWaterfall(_waterfallData, "Waterfall Display"); -- cgit From eae515a2356a140e4407945eed21e56b90bb98d9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 7 Jun 2011 22:39:07 -0400 Subject: qtgui: removed most of the functions in highResTimeFunctions.h --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index cc7ab14a3..90386281a 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -110,7 +110,7 @@ class TimeScaleData public: TimeScaleData() { - highres_timespec_reset(_zeroTime); + _zeroTime = 0; _secondsPerLine = 1.0; } @@ -160,15 +160,15 @@ public: virtual QwtText label(double value) const { - highres_timespec lineTime = highres_timespec_add(GetZeroTime(), -value*GetSecondsPerLine()); - unsigned long milliseconds = lineTime*1000/gruel::high_res_timer_tps(); - std::string time_str = pt::to_simple_string(pt::from_time_t(milliseconds/1000)); + double secs = GetZeroTime()/double(gruel::high_res_timer_tps()) - (value * GetSecondsPerLine()); + std::string time_str = pt::to_simple_string(pt::from_time_t(time_t(secs))); // lops off the YYYY-mmm-DD part of the string size_t ind = time_str.find(" "); if(ind != std::string::npos) time_str = time_str.substr(ind); - return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), milliseconds%1000)); + return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), + long(std::fmod(secs*1000, 1000)))); } virtual void initiateUpdate() @@ -213,15 +213,15 @@ protected: using QwtPlotZoomer::trackerText; virtual QwtText trackerText( const QwtDoublePoint& p ) const { - highres_timespec lineTime = highres_timespec_add(GetZeroTime(), -p.y()*GetSecondsPerLine()); - unsigned long milliseconds = lineTime*1000/gruel::high_res_timer_tps(); - std::string time_str = pt::to_simple_string(pt::from_time_t(milliseconds/1000)); + double secs = GetZeroTime()/double(gruel::high_res_timer_tps()) - (p.y() * GetSecondsPerLine()); + std::string time_str = pt::to_simple_string(pt::from_time_t(time_t(secs))); // lops off the YYYY-mmm-DD part of the string size_t ind = time_str.find(" "); if(ind != std::string::npos) time_str = time_str.substr(ind); - QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), milliseconds%1000)); + QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), + long(std::fmod(secs*1000, 1000)))); QwtText t(QString("%1 %2, %3"). arg(p.x(), 0, 'f', GetFrequencyPrecision()). @@ -256,7 +256,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) setAxisTitle(QwtPlot::yLeft, "Time"); setAxisScaleDraw(QwtPlot::yLeft, new QwtTimeScaleDraw()); - highres_timespec_reset(_lastReplot); + _lastReplot = 0; d_spectrogram = new PlotWaterfall(_waterfallData, "Waterfall Display"); @@ -410,7 +410,7 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, _lastReplot = get_highres_clock(); } - if(diff_highres_timespec(get_highres_clock(), _lastReplot) > timePerFFT) { + if(get_highres_clock() - _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(); -- cgit From bbf11bb338a4a88a1f270f77649212fea0b0cab0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 7 Jun 2011 22:55:41 -0400 Subject: qtgui: removed all traces of highResTimeFunctions.h --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 90386281a..20e1fa4ec 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -118,12 +118,12 @@ public: { } - virtual highres_timespec GetZeroTime() const + virtual gruel::high_res_timer_type GetZeroTime() const { return _zeroTime; } - virtual void SetZeroTime(const highres_timespec newTime) + virtual void SetZeroTime(const gruel::high_res_timer_type newTime) { _zeroTime = newTime; } @@ -140,7 +140,7 @@ public: protected: - highres_timespec _zeroTime; + gruel::high_res_timer_type _zeroTime; double _secondsPerLine; private: @@ -391,7 +391,7 @@ void WaterfallDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDataPoints, const double timePerFFT, - const highres_timespec timestamp, + const gruel::high_res_timer_type timestamp, const int droppedFrames) { if(numDataPoints > 0){ @@ -407,10 +407,10 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, replot(); } - _lastReplot = get_highres_clock(); + _lastReplot = gruel::high_res_timer_now(); } - if(get_highres_clock() - _lastReplot > timePerFFT*gruel::high_res_timer_tps()) { + 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(); @@ -427,7 +427,7 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, replot(); - _lastReplot = get_highres_clock(); + _lastReplot = gruel::high_res_timer_now(); } } } @@ -570,7 +570,7 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() replot(); // Update the last replot timer - _lastReplot = get_highres_clock(); + _lastReplot = gruel::high_res_timer_now(); } void -- cgit From fd509d44bfa14375dce396e712869be257903fc7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 7 Jun 2011 23:04:42 -0400 Subject: qtgui: make a common function for the time label creation in waterfall --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 20e1fa4ec..3dc182bca 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -147,6 +147,19 @@ private: }; +static QString +make_time_label(double secs) +{ + std::string time_str = pt::to_simple_string(pt::from_time_t(time_t(secs))); + + // lops off the YYYY-mmm-DD part of the string + size_t ind = time_str.find(" "); + if(ind != std::string::npos) + time_str = time_str.substr(ind); + + return QString("").sprintf("%s.%03ld", time_str.c_str(), long(std::fmod(secs*1000, 1000))); +} + class QwtTimeScaleDraw: public QwtScaleDraw, public TimeScaleData { public: @@ -161,14 +174,7 @@ public: virtual QwtText label(double value) const { double secs = GetZeroTime()/double(gruel::high_res_timer_tps()) - (value * GetSecondsPerLine()); - std::string time_str = pt::to_simple_string(pt::from_time_t(time_t(secs))); - - // lops off the YYYY-mmm-DD part of the string - size_t ind = time_str.find(" "); - if(ind != std::string::npos) - time_str = time_str.substr(ind); - return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), - long(std::fmod(secs*1000, 1000)))); + return QwtText(make_time_label(secs)); } virtual void initiateUpdate() @@ -214,18 +220,9 @@ protected: virtual QwtText trackerText( const QwtDoublePoint& p ) const { double secs = GetZeroTime()/double(gruel::high_res_timer_tps()) - (p.y() * GetSecondsPerLine()); - std::string time_str = pt::to_simple_string(pt::from_time_t(time_t(secs))); - - // lops off the YYYY-mmm-DD part of the string - size_t ind = time_str.find(" "); - if(ind != std::string::npos) - time_str = time_str.substr(ind); - QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), - long(std::fmod(secs*1000, 1000)))); - QwtText t(QString("%1 %2, %3"). - arg(p.x(), 0, 'f', GetFrequencyPrecision()). - arg(_unitType.c_str()).arg(yLabel)); + arg(p.x(), 0, 'f', GetFrequencyPrecision()). + arg(_unitType.c_str()).arg(make_time_label(secs))); return t; } -- cgit From bba53da8418681d03ffd504042900bdd316f8e58 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 7 Jun 2011 23:05:49 -0400 Subject: added high_res_timer_epoch to give ticks at the epoch --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 3dc182bca..1476be2bd 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -125,7 +125,7 @@ public: virtual void SetZeroTime(const gruel::high_res_timer_type newTime) { - _zeroTime = newTime; + _zeroTime = newTime - gruel::high_res_timer_epoch(); } virtual void SetSecondsPerLine(const double newTime) -- 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/WaterfallDisplayPlot.cc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 1476be2bd..8d0622c94 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -274,7 +274,9 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) // Ctrl+RighButton: zoom out to full size _zoomer = new WaterfallZoomer(canvas(), 0); +#if QWT_VERSION < 0x060000 _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection); +#endif _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, @@ -286,9 +288,9 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) // emit the position of clicks on widget _picker = new QwtDblClickPlotPicker(canvas()); - connect(_picker, SIGNAL(selected(const QwtDoublePoint &)), - this, SLOT(OnPickerPointSelected(const QwtDoublePoint &))); - + connect(_picker, SIGNAL(selected(const QPointF &)), + this, SLOT(OnPickerPointSelected(const QPointF &))); + // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically @@ -433,7 +435,11 @@ void WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, const double maxIntensity) { +#if QWT_VERSION < 0x060000 _waterfallData->setRange(QwtDoubleInterval(minIntensity, maxIntensity)); +#else + _waterfallData->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity)); +#endif emit UpdatedLowerIntensityLevel(minIntensity); emit UpdatedUpperIntensityLevel(maxIntensity); @@ -549,12 +555,20 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight); rightAxis->setTitle("Intensity (dB)"); rightAxis->setColorBarEnabled(true); + +#if QWT_VERSION < 0x060000 rightAxis->setColorMap(d_spectrogram->data()->range(), d_spectrogram->colorMap()); - setAxisScale(QwtPlot::yRight, d_spectrogram->data()->range().minValue(), d_spectrogram->data()->range().maxValue() ); +#else + QwtInterval intv = d_spectrogram->data()->interval(); + QwtColorMap *map = (QwtColorMap*)(&d_spectrogram->colorMap()); + rightAxis->setColorMap(intv, map); + setAxisScale(QwtPlot::yRight, intv.minValue(), intv.maxValue()); +#endif + enableAxis(QwtPlot::yRight); plotLayout()->setAlignCanvasToScales(true); @@ -571,10 +585,10 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() } void -WaterfallDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) +WaterfallDisplayPlot::OnPickerPointSelected(const QPointF & p) { QPointF point = p; - //fprintf(stderr,"OnPickerPointSelected %f %f %d\n", point.x(), point.y(), _xAxisMultiplier); + //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } -- cgit From 4496fae2deea200755225c007a26f4c7be0470e9 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 16:32:41 -0400 Subject: qtgui: waterfall plot mostly working under qwt6 (plots, but updates to scale and color not working yet). --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 78 +++++++++++++++++------------------- 1 file changed, 36 insertions(+), 42 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 8d0622c94..b7e511b5b 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -241,8 +241,6 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) resize(parent->width(), parent->height()); _numPoints = 1024; - _waterfallData = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); - QPalette palette; palette.setColor(canvas()->backgroundRole(), QColor("white")); canvas()->setPalette(palette); @@ -255,24 +253,26 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) _lastReplot = 0; - d_spectrogram = new PlotWaterfall(_waterfallData, "Waterfall Display"); - _intensityColorMapType = INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR; - QwtLinearColorMap colorMap(Qt::darkCyan, Qt::white); - colorMap.addColorStop(0.25, Qt::cyan); - colorMap.addColorStop(0.5, Qt::yellow); - colorMap.addColorStop(0.75, Qt::red); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::darkCyan, Qt::white); + colorMap->addColorStop(0.25, Qt::cyan); + colorMap->addColorStop(0.5, Qt::yellow); + colorMap->addColorStop(0.75, Qt::red); - d_spectrogram->setColorMap(colorMap); + d_data = new WaterfallData(_startFrequency, _stopFrequency, + _numPoints, 200); + d_spectrogram = new QwtPlotSpectrogram("Spectrogram"); + d_spectrogram->setColorMap(colorMap); + d_spectrogram->setData(d_data); d_spectrogram->attach(this); + d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size - _zoomer = new WaterfallZoomer(canvas(), 0); #if QWT_VERSION < 0x060000 _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection); @@ -298,7 +298,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); sd->setMinimumExtent( fm.width("100.00") ); - const QColor c(Qt::white); + const QColor c(Qt::black); _zoomer->setRubberBandPen(c); _zoomer->setTrackerPen(c); @@ -309,15 +309,14 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) WaterfallDisplayPlot::~WaterfallDisplayPlot() { - delete _waterfallData; delete d_spectrogram; } void WaterfallDisplayPlot::Reset() { - _waterfallData->ResizeData(_startFrequency, _stopFrequency, _numPoints); - _waterfallData->Reset(); + d_data->ResizeData(_startFrequency, _stopFrequency, _numPoints); + d_data->Reset(); setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); @@ -410,9 +409,8 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, } if(gruel::high_res_timer_now() - _lastReplot > timePerFFT*gruel::high_res_timer_tps()) { - //FIXME: We may want to average the data between these updates to smooth display - _waterfallData->addFFTData(dataPoints, numDataPoints, droppedFrames); - _waterfallData->IncrementNumLinesToUpdate(); + d_data->addFFTData(dataPoints, numDataPoints, droppedFrames); + d_data->IncrementNumLinesToUpdate(); QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); timeScale->SetSecondsPerLine(timePerFFT); @@ -423,7 +421,7 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, d_spectrogram->invalidateCache(); d_spectrogram->itemChanged(); - + replot(); _lastReplot = gruel::high_res_timer_now(); @@ -433,14 +431,8 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, void WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, - const double maxIntensity) + const double maxIntensity) { -#if QWT_VERSION < 0x060000 - _waterfallData->setRange(QwtDoubleInterval(minIntensity, maxIntensity)); -#else - _waterfallData->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity)); -#endif - emit UpdatedLowerIntensityLevel(minIntensity); emit UpdatedUpperIntensityLevel(maxIntensity); @@ -453,7 +445,8 @@ WaterfallDisplayPlot::replot() QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); timeScale->initiateUpdate(); - WaterfallFreqDisplayScaleDraw* freqScale = (WaterfallFreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom); + WaterfallFreqDisplayScaleDraw* freqScale = \ + (WaterfallFreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom); freqScale->initiateUpdate(); // Update the time axis display @@ -496,29 +489,29 @@ WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, switch(newType){ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:{ _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::darkCyan, Qt::white); - colorMap.addColorStop(0.25, Qt::cyan); - colorMap.addColorStop(0.5, Qt::yellow); - colorMap.addColorStop(0.75, Qt::red); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::darkCyan, Qt::white); + colorMap->addColorStop(0.25, Qt::cyan); + colorMap->addColorStop(0.5, Qt::yellow); + colorMap->addColorStop(0.75, Qt::red); d_spectrogram->setColorMap(colorMap); break; } case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{ _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::black, Qt::white); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::black, Qt::white); d_spectrogram->setColorMap(colorMap); break; } case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{ _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::white, Qt::black); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::white, Qt::black); d_spectrogram->setColorMap(colorMap); break; } case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:{ _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::black, Qt::white); - colorMap.addColorStop(0.5, Qt::darkRed); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::black, Qt::white); + colorMap->addColorStop(0.5, Qt::darkRed); d_spectrogram->setColorMap(colorMap); break; } @@ -526,7 +519,8 @@ WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, _userDefinedLowIntensityColor = lowColor; _userDefinedHighIntensityColor = highColor; _intensityColorMapType = newType; - QwtLinearColorMap colorMap(_userDefinedLowIntensityColor, _userDefinedHighIntensityColor); + QwtLinearColorMap *colorMap = new QwtLinearColorMap(_userDefinedLowIntensityColor, + _userDefinedHighIntensityColor); d_spectrogram->setColorMap(colorMap); break; } @@ -561,11 +555,11 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() d_spectrogram->colorMap()); setAxisScale(QwtPlot::yRight, d_spectrogram->data()->range().minValue(), - d_spectrogram->data()->range().maxValue() ); + d_spectrogram->data()->range().maxValue()); #else - QwtInterval intv = d_spectrogram->data()->interval(); - QwtColorMap *map = (QwtColorMap*)(&d_spectrogram->colorMap()); - rightAxis->setColorMap(intv, map); + QwtInterval intv = d_spectrogram->interval(Qt::ZAxis); + const QwtColorMap *map = d_spectrogram->colorMap(); + rightAxis->setColorMap(intv, (QwtColorMap*)map); setAxisScale(QwtPlot::yRight, intv.minValue(), intv.maxValue()); #endif @@ -574,8 +568,8 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() plotLayout()->setAlignCanvasToScales(true); // Tell the display to redraw everything - d_spectrogram->invalidateCache(); - d_spectrogram->itemChanged(); + ////d_spectrogram->invalidateCache(); + ////d_spectrogram->itemChanged(); // Draw again replot(); @@ -588,7 +582,7 @@ void WaterfallDisplayPlot::OnPickerPointSelected(const QPointF & p) { QPointF point = p; - //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); + fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } -- cgit From bade47de8c8e9fe92ae7a777260e900d6c708f09 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 17:35:24 -0400 Subject: qtgui: fixed waterfall color map issue under qwt6. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 93 ++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 19 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index b7e511b5b..ba15608e9 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -230,6 +230,58 @@ private: std::string _unitType; }; +class ColorMap_MultiColor: public QwtLinearColorMap +{ +public: + ColorMap_MultiColor(): + QwtLinearColorMap(Qt::darkCyan, Qt::white) + { + addColorStop(0.25, Qt::cyan); + addColorStop(0.5, Qt::yellow); + addColorStop(0.75, Qt::red); + } +}; + +class ColorMap_WhiteHot: public QwtLinearColorMap +{ +public: + ColorMap_WhiteHot(): + QwtLinearColorMap(Qt::black, Qt::white) + { + } +}; + +class ColorMap_BlackHot: public QwtLinearColorMap +{ +public: + ColorMap_BlackHot(): + QwtLinearColorMap(Qt::white, Qt::black) + { + } +}; + +class ColorMap_Incandescent: public QwtLinearColorMap +{ +public: + ColorMap_Incandescent(): + QwtLinearColorMap(Qt::black, Qt::white) + { + addColorStop(0.5, Qt::darkRed); + } +}; + +class ColorMap_UserDefined: public QwtLinearColorMap +{ +public: + ColorMap_UserDefined(QColor low, QColor high): + QwtLinearColorMap(low, high) + { + } +}; + +/********************************************************************* +MAIN WATERFALL PLOT WIDGET +*********************************************************************/ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) : QwtPlot(parent) @@ -489,39 +541,29 @@ WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, switch(newType){ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:{ _intensityColorMapType = newType; - QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::darkCyan, Qt::white); - colorMap->addColorStop(0.25, Qt::cyan); - colorMap->addColorStop(0.5, Qt::yellow); - colorMap->addColorStop(0.75, Qt::red); - d_spectrogram->setColorMap(colorMap); + d_spectrogram->setColorMap(new ColorMap_MultiColor()); break; } case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{ _intensityColorMapType = newType; - QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::black, Qt::white); - d_spectrogram->setColorMap(colorMap); + d_spectrogram->setColorMap(new ColorMap_WhiteHot()); break; } case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{ _intensityColorMapType = newType; - QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::white, Qt::black); - d_spectrogram->setColorMap(colorMap); + d_spectrogram->setColorMap(new ColorMap_BlackHot()); break; } case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:{ _intensityColorMapType = newType; - QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::black, Qt::white); - colorMap->addColorStop(0.5, Qt::darkRed); - d_spectrogram->setColorMap(colorMap); + d_spectrogram->setColorMap(new ColorMap_Incandescent()); break; } case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:{ _userDefinedLowIntensityColor = lowColor; _userDefinedHighIntensityColor = highColor; _intensityColorMapType = newType; - QwtLinearColorMap *colorMap = new QwtLinearColorMap(_userDefinedLowIntensityColor, - _userDefinedHighIntensityColor); - d_spectrogram->setColorMap(colorMap); + d_spectrogram->setColorMap(new ColorMap_UserDefined(lowColor, highColor)); break; } default: break; @@ -558,8 +600,21 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() d_spectrogram->data()->range().maxValue()); #else QwtInterval intv = d_spectrogram->interval(Qt::ZAxis); - const QwtColorMap *map = d_spectrogram->colorMap(); - rightAxis->setColorMap(intv, (QwtColorMap*)map); + switch(_intensityColorMapType) { + case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR: + rightAxis->setColorMap(intv, new ColorMap_MultiColor()); break; + case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT: + rightAxis->setColorMap(intv, new ColorMap_WhiteHot()); break; + case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT: + rightAxis->setColorMap(intv, new ColorMap_BlackHot()); break; + case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT: + rightAxis->setColorMap(intv, new ColorMap_Incandescent()); break; + case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED: + rightAxis->setColorMap(intv, new ColorMap_UserDefined(_userDefinedLowIntensityColor, + _userDefinedHighIntensityColor)); break; + default: + rightAxis->setColorMap(intv, new ColorMap_MultiColor()); break; + } setAxisScale(QwtPlot::yRight, intv.minValue(), intv.maxValue()); #endif @@ -568,8 +623,8 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() plotLayout()->setAlignCanvasToScales(true); // Tell the display to redraw everything - ////d_spectrogram->invalidateCache(); - ////d_spectrogram->itemChanged(); + d_spectrogram->invalidateCache(); + d_spectrogram->itemChanged(); // Draw again replot(); -- cgit From df09ce46e6783352e09981f61f1f25f1db1ab68c Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 17:56:51 -0400 Subject: qtgui: adjusting intensity knobs and auto scale in waterfall works in qwt6. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index ba15608e9..643370b96 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -306,11 +306,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) _lastReplot = 0; _intensityColorMapType = INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR; - - QwtLinearColorMap *colorMap = new QwtLinearColorMap(Qt::darkCyan, Qt::white); - colorMap->addColorStop(0.25, Qt::cyan); - colorMap->addColorStop(0.5, Qt::yellow); - colorMap->addColorStop(0.75, Qt::red); + QwtLinearColorMap *colorMap = new ColorMap_MultiColor(); d_data = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); @@ -488,6 +484,8 @@ WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, emit UpdatedLowerIntensityLevel(minIntensity); emit UpdatedUpperIntensityLevel(maxIntensity); + d_data->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity)); + _UpdateIntensityRangeDisplay(); } -- cgit From 0319e05a4bb9a41082d00e334ac1647314dfaacd Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 18:39:45 -0400 Subject: qtgui: wip: working to make plots backwards compatible with qwt 5.2. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 62 ++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 6 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 643370b96..84d71d76d 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -306,16 +306,21 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) _lastReplot = 0; _intensityColorMapType = INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR; - QwtLinearColorMap *colorMap = new ColorMap_MultiColor(); d_data = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); d_spectrogram = new QwtPlotSpectrogram("Spectrogram"); - d_spectrogram->setColorMap(colorMap); - d_spectrogram->setData(d_data); + d_spectrogram->setData(*d_data); d_spectrogram->attach(this); d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); + +#if QWT_VERSION < 0x060000 + ColorMap_MultiColor colorMap; + d_spectrogram->setColorMap(colorMap); +#else + d_spectrogram->setColorMap(new ColorMap_MultiColor()); +#endif // LeftButton for the zooming // MidButton for the panning @@ -336,8 +341,13 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) // emit the position of clicks on widget _picker = new QwtDblClickPlotPicker(canvas()); +#if QWT_VERSION < 0x060000 + connect(_picker, SIGNAL(selected(const QwtDoublePoint &)), + this, SLOT(OnPickerPointSelected(const QwtDoublePoint &))); +#else connect(_picker, SIGNAL(selected(const QPointF &)), this, SLOT(OnPickerPointSelected(const QPointF &))); +#endif // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically @@ -357,6 +367,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) WaterfallDisplayPlot::~WaterfallDisplayPlot() { + delete d_data; delete d_spectrogram; } @@ -484,7 +495,10 @@ WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, emit UpdatedLowerIntensityLevel(minIntensity); emit UpdatedUpperIntensityLevel(maxIntensity); +#if QWT_VERSION < 0x060000 +#else d_data->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity)); +#endif _UpdateIntensityRangeDisplay(); } @@ -539,29 +553,54 @@ WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, switch(newType){ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:{ _intensityColorMapType = newType; +#if QWT_VERSION < 0x060000 + ColorMap_MultiColor colorMap; + d_spectrogram->setColorMap(colorMap); +#else d_spectrogram->setColorMap(new ColorMap_MultiColor()); +#endif break; } case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{ _intensityColorMapType = newType; +#if QWT_VERSION < 0x060000 + ColorMap_WhiteHot colorMap; + d_spectrogram->setColorMap(colorMap); +#else d_spectrogram->setColorMap(new ColorMap_WhiteHot()); +#endif break; } case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{ _intensityColorMapType = newType; +#if QWT_VERSION < 0x060000 + ColorMap_BlackHot colorMap; + d_spectrogram->setColorMap(colorMap); +#else d_spectrogram->setColorMap(new ColorMap_BlackHot()); +#endif break; } case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:{ _intensityColorMapType = newType; +#if QWT_VERSION < 0x060000 + ColorMap_Incandescent colorMap; + d_spectrogram->setColorMap(colorMap); +#else d_spectrogram->setColorMap(new ColorMap_Incandescent()); +#endif break; } case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:{ _userDefinedLowIntensityColor = lowColor; _userDefinedHighIntensityColor = highColor; _intensityColorMapType = newType; +#if QWT_VERSION < 0x060000 + ColorMap_UserDefined colorMap(lowColor, highColor); + d_spectrogram->setColorMap(colorMap); +#else d_spectrogram->setColorMap(new ColorMap_UserDefined(lowColor, highColor)); +#endif break; } default: break; @@ -591,11 +630,11 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() rightAxis->setColorBarEnabled(true); #if QWT_VERSION < 0x060000 - rightAxis->setColorMap(d_spectrogram->data()->range(), + rightAxis->setColorMap(d_data->range(), d_spectrogram->colorMap()); setAxisScale(QwtPlot::yRight, - d_spectrogram->data()->range().minValue(), - d_spectrogram->data()->range().maxValue()); + d_data->range().minValue(), + d_data->range().maxValue()); #else QwtInterval intv = d_spectrogram->interval(Qt::ZAxis); switch(_intensityColorMapType) { @@ -631,6 +670,16 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() _lastReplot = gruel::high_res_timer_now(); } +#if QWT_VERSION < 0x060000 +void +WaterfallDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) +{ + QPointF point = p; + fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); + point.setX(point.x() * _xAxisMultiplier); + emit plotPointSelected(point); +} +#else void WaterfallDisplayPlot::OnPickerPointSelected(const QPointF & p) { @@ -639,5 +688,6 @@ WaterfallDisplayPlot::OnPickerPointSelected(const QPointF & p) point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } +#endif #endif /* WATERFALL_DISPLAY_PLOT_C */ -- cgit From 45c2212608ca66b5fadbc860771e042198e1ebcd Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 16 Oct 2011 19:45:29 -0400 Subject: qtgui: more compatability issues. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 84d71d76d..7abd9aeef 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -310,17 +310,20 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) d_data = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); - d_spectrogram = new QwtPlotSpectrogram("Spectrogram"); - d_spectrogram->setData(*d_data); - d_spectrogram->attach(this); - d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); - #if QWT_VERSION < 0x060000 + d_spectrogram = new PlotWaterfall(d_data, "Waterfall Display"); + ColorMap_MultiColor colorMap; d_spectrogram->setColorMap(colorMap); + #else + d_spectrogram = new QwtPlotSpectrogram("Spectrogram"); + d_spectrogram->setData(*d_data); + d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); d_spectrogram->setColorMap(new ColorMap_MultiColor()); #endif + + d_spectrogram->attach(this); // LeftButton for the zooming // MidButton for the panning @@ -492,14 +495,15 @@ void WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, const double maxIntensity) { - emit UpdatedLowerIntensityLevel(minIntensity); - emit UpdatedUpperIntensityLevel(maxIntensity); - #if QWT_VERSION < 0x060000 + d_data->setRange(QwtDoubleInterval(minIntensity, maxIntensity)); #else d_data->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity)); #endif + emit UpdatedLowerIntensityLevel(minIntensity); + emit UpdatedUpperIntensityLevel(maxIntensity); + _UpdateIntensityRangeDisplay(); } @@ -630,11 +634,11 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() rightAxis->setColorBarEnabled(true); #if QWT_VERSION < 0x060000 - rightAxis->setColorMap(d_data->range(), + rightAxis->setColorMap(d_spectrogram->data()->range(), d_spectrogram->colorMap()); setAxisScale(QwtPlot::yRight, - d_data->range().minValue(), - d_data->range().maxValue()); + d_spectrogram->data()->range().minValue(), + d_spectrogram->data()->range().maxValue()); #else QwtInterval intv = d_spectrogram->interval(Qt::ZAxis); switch(_intensityColorMapType) { @@ -675,7 +679,7 @@ void WaterfallDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) { QPointF point = p; - fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); + //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } @@ -684,7 +688,7 @@ void WaterfallDisplayPlot::OnPickerPointSelected(const QPointF & p) { QPointF point = p; - fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); + //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } -- cgit From b9156049149863d75e77dc619ce4d96f8ec0eafc Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 17 Oct 2011 20:49:17 -0700 Subject: qtgui: a few more fixes for qwt 5.2/6.0. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 7abd9aeef..94a8e6210 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -318,7 +318,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) #else d_spectrogram = new QwtPlotSpectrogram("Spectrogram"); - d_spectrogram->setData(*d_data); + d_spectrogram->setData(d_data); d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); d_spectrogram->setColorMap(new ColorMap_MultiColor()); #endif -- cgit From 3710dd6d3fb30966dfc0f32876a52703a9a85a60 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 25 Oct 2011 11:57:02 -0400 Subject: qtgui: Fixing slot names that can't be #if'd out for compatibility between Qwt 5.2 and 6.0. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 94a8e6210..ffb27f2aa 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -349,7 +349,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) this, SLOT(OnPickerPointSelected(const QwtDoublePoint &))); #else connect(_picker, SIGNAL(selected(const QPointF &)), - this, SLOT(OnPickerPointSelected(const QPointF &))); + this, SLOT(OnPickerPointSelected6(const QPointF &))); #endif // Avoid jumping when labels with more/less digits @@ -674,7 +674,6 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() _lastReplot = gruel::high_res_timer_now(); } -#if QWT_VERSION < 0x060000 void WaterfallDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) { @@ -683,15 +682,14 @@ WaterfallDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p) point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } -#else + void -WaterfallDisplayPlot::OnPickerPointSelected(const QPointF & p) +WaterfallDisplayPlot::OnPickerPointSelected6(const QPointF & p) { QPointF point = p; //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y()); point.setX(point.x() * _xAxisMultiplier); emit plotPointSelected(point); } -#endif #endif /* WATERFALL_DISPLAY_PLOT_C */ -- cgit From f919f9dcbb54a08e6e26d6c229ce92fb784fa1b2 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 13 Apr 2012 18:36:53 -0400 Subject: Removed whitespace and added dtools/bin/remove-whitespace as a tool to do this in the future. The sed script was provided by Moritz Fischer. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 84 ++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'gr-qtgui/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index ffb27f2aa..63eb57ffe 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -1,19 +1,19 @@ /* -*- c++ -*- */ /* * Copyright 2008,2009,2010,2011 Free Software Foundation, Inc. - * + * * This file is part of GNU Radio - * + * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. - * + * * GNU Radio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -113,16 +113,16 @@ public: _zeroTime = 0; _secondsPerLine = 1.0; } - + virtual ~TimeScaleData() - { + { } virtual gruel::high_res_timer_type GetZeroTime() const { return _zeroTime; } - + virtual void SetZeroTime(const gruel::high_res_timer_type newTime) { _zeroTime = newTime - gruel::high_res_timer_epoch(); @@ -138,13 +138,13 @@ public: return _secondsPerLine; } - + protected: gruel::high_res_timer_type _zeroTime; double _secondsPerLine; - + private: - + }; static QString @@ -164,11 +164,11 @@ class QwtTimeScaleDraw: public QwtScaleDraw, public TimeScaleData { public: QwtTimeScaleDraw():QwtScaleDraw(),TimeScaleData() - { + { } virtual ~QwtTimeScaleDraw() - { + { } virtual QwtText label(double value) const @@ -183,19 +183,19 @@ public: // updates is to prevent the display from being updated too often... invalidateCache(); } - + protected: private: }; -class WaterfallZoomer: public QwtPlotZoomer, public TimeScaleData, +class WaterfallZoomer: public QwtPlotZoomer, public TimeScaleData, public FreqOffsetAndPrecisionClass { public: WaterfallZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision) - : QwtPlotZoomer(canvas), TimeScaleData(), + : QwtPlotZoomer(canvas), TimeScaleData(), FreqOffsetAndPrecisionClass(freqPrecision) { setTrackerMode(QwtPicker::AlwaysOn); @@ -204,7 +204,7 @@ public: virtual ~WaterfallZoomer() { } - + virtual void updateTrackerText() { updateDisplay(); @@ -217,7 +217,7 @@ public: protected: using QwtPlotZoomer::trackerText; - virtual QwtText trackerText( const QwtDoublePoint& p ) const + virtual QwtText trackerText( const QwtDoublePoint& p ) const { double secs = GetZeroTime()/double(gruel::high_res_timer_tps()) - (p.y() * GetSecondsPerLine()); QwtText t(QString("%1 %2, %3"). @@ -289,13 +289,13 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) _zoomer = NULL; _startFrequency = 0; _stopFrequency = 4000; - + resize(parent->width(), parent->height()); _numPoints = 1024; QPalette palette; palette.setColor(canvas()->backgroundRole(), QColor("white")); - canvas()->setPalette(palette); + canvas()->setPalette(palette); setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)"); setAxisScaleDraw(QwtPlot::xBottom, new WaterfallFreqDisplayScaleDraw(0)); @@ -309,7 +309,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) d_data = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); - + #if QWT_VERSION < 0x060000 d_spectrogram = new PlotWaterfall(d_data, "Waterfall Display"); @@ -324,7 +324,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) #endif d_spectrogram->attach(this); - + // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 @@ -337,11 +337,11 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) Qt::RightButton, Qt::ControlModifier); _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); - + _panner = new QwtPlotPanner(canvas()); _panner->setAxisEnabled(QwtPlot::yRight, false); _panner->setMouseButton(Qt::MidButton); - + // emit the position of clicks on widget _picker = new QwtDblClickPlotPicker(canvas()); #if QWT_VERSION < 0x060000 @@ -354,11 +354,11 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically - + const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); sd->setMinimumExtent( fm.width("100.00") ); - + const QColor c(Qt::black); _zoomer->setRubberBandPen(c); _zoomer->setTrackerPen(c); @@ -374,7 +374,7 @@ WaterfallDisplayPlot::~WaterfallDisplayPlot() delete d_spectrogram; } -void +void WaterfallDisplayPlot::Reset() { d_data->ResizeData(_startFrequency, _stopFrequency, _numPoints); @@ -418,7 +418,7 @@ WaterfallDisplayPlot::SetFrequencyRange(const double constStartFreq, if(stopFreq > startFreq) { _startFrequency = startFreq; _stopFrequency = stopFreq; - + if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){ double display_units = ceil(log10(units)/2.0); setAxisScaleDraw(QwtPlot::xBottom, new WaterfallFreqDisplayScaleDraw(display_units)); @@ -448,7 +448,7 @@ WaterfallDisplayPlot::GetStopFrequency() const } void -WaterfallDisplayPlot::PlotNewData(const double* dataPoints, +WaterfallDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDataPoints, const double timePerFFT, const gruel::high_res_timer_type timestamp, @@ -457,30 +457,30 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, if(numDataPoints > 0){ if(numDataPoints != _numPoints){ _numPoints = numDataPoints; - + Reset(); - + d_spectrogram->invalidateCache(); d_spectrogram->itemChanged(); - + if(isVisible()){ replot(); } - + _lastReplot = gruel::high_res_timer_now(); } if(gruel::high_res_timer_now() - _lastReplot > timePerFFT*gruel::high_res_timer_tps()) { d_data->addFFTData(dataPoints, numDataPoints, droppedFrames); d_data->IncrementNumLinesToUpdate(); - + QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); timeScale->SetSecondsPerLine(timePerFFT); timeScale->SetZeroTime(timestamp); - + ((WaterfallZoomer*)_zoomer)->SetSecondsPerLine(timePerFFT); ((WaterfallZoomer*)_zoomer)->SetZeroTime(timestamp); - + d_spectrogram->invalidateCache(); d_spectrogram->itemChanged(); @@ -492,7 +492,7 @@ WaterfallDisplayPlot::PlotNewData(const double* dataPoints, } void -WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, +WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, const double maxIntensity) { #if QWT_VERSION < 0x060000 @@ -547,11 +547,11 @@ WaterfallDisplayPlot::GetIntensityColorMapType() const } void -WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, - const QColor lowColor, +WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, + const QColor lowColor, const QColor highColor) { - if((_intensityColorMapType != newType) || + if((_intensityColorMapType != newType) || ((newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED) && (lowColor.isValid() && highColor.isValid()))){ switch(newType){ @@ -609,7 +609,7 @@ WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, } default: break; } - + _UpdateIntensityRangeDisplay(); } } @@ -636,7 +636,7 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() #if QWT_VERSION < 0x060000 rightAxis->setColorMap(d_spectrogram->data()->range(), d_spectrogram->colorMap()); - setAxisScale(QwtPlot::yRight, + setAxisScale(QwtPlot::yRight, d_spectrogram->data()->range().minValue(), d_spectrogram->data()->range().maxValue()); #else @@ -660,7 +660,7 @@ WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() #endif enableAxis(QwtPlot::yRight); - + plotLayout()->setAlignCanvasToScales(true); // Tell the display to redraw everything -- cgit