diff options
author | trondeau | 2009-04-15 03:49:04 +0000 |
---|---|---|
committer | trondeau | 2009-04-15 03:49:04 +0000 |
commit | 322e065b19c922e2a9cc1710876e32d100453181 (patch) | |
tree | acc0c5d9643fd647d128ca4215147eef79189af3 /gr-qtgui/src/lib | |
parent | ae5fa9430882f5140a3c9a9b61e4a5f7c4ed9127 (diff) | |
download | gnuradio-322e065b19c922e2a9cc1710876e32d100453181.tar.gz gnuradio-322e065b19c922e2a9cc1710876e32d100453181.tar.bz2 gnuradio-322e065b19c922e2a9cc1710876e32d100453181.zip |
Merging qtdevel2 branch -r10565:10849. This adds a lot of fixes and capabilities to the qtgui package. Most importantly, it allows interaction between PyQt and the C++ Qt routines in the gnuradio library.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10850 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gr-qtgui/src/lib')
-rw-r--r-- | gr-qtgui/src/lib/ConstellationDisplayPlot.cc | 7 | ||||
-rw-r--r-- | gr-qtgui/src/lib/FrequencyDisplayPlot.cc | 139 | ||||
-rw-r--r-- | gr-qtgui/src/lib/FrequencyDisplayPlot.h | 9 | ||||
-rw-r--r-- | gr-qtgui/src/lib/Makefile.am | 2 | ||||
-rw-r--r-- | gr-qtgui/src/lib/SpectrumGUIClass.cc | 174 | ||||
-rw-r--r-- | gr-qtgui/src/lib/SpectrumGUIClass.h | 19 | ||||
-rw-r--r-- | gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc | 14 | ||||
-rw-r--r-- | gr-qtgui/src/lib/Waterfall3DDisplayPlot.h | 4 | ||||
-rw-r--r-- | gr-qtgui/src/lib/WaterfallDisplayPlot.cc | 47 | ||||
-rw-r--r-- | gr-qtgui/src/lib/WaterfallDisplayPlot.h | 9 | ||||
-rw-r--r-- | gr-qtgui/src/lib/qtgui.i | 66 | ||||
-rw-r--r-- | gr-qtgui/src/lib/qtgui_sink_c.cc | 158 | ||||
-rw-r--r-- | gr-qtgui/src/lib/qtgui_sink_c.h | 44 | ||||
-rw-r--r-- | gr-qtgui/src/lib/qtgui_sink_f.cc | 164 | ||||
-rw-r--r-- | gr-qtgui/src/lib/qtgui_sink_f.h | 57 | ||||
-rw-r--r-- | gr-qtgui/src/lib/spectrumUpdateEvents.cc | 106 | ||||
-rw-r--r-- | gr-qtgui/src/lib/spectrumdisplayform.cc | 421 | ||||
-rw-r--r-- | gr-qtgui/src/lib/spectrumdisplayform.h | 25 | ||||
-rw-r--r-- | gr-qtgui/src/lib/spectrumdisplayform.ui | 6 |
19 files changed, 1044 insertions, 427 deletions
diff --git a/gr-qtgui/src/lib/ConstellationDisplayPlot.cc b/gr-qtgui/src/lib/ConstellationDisplayPlot.cc index c422c8f52..6f423d9aa 100644 --- a/gr-qtgui/src/lib/ConstellationDisplayPlot.cc +++ b/gr-qtgui/src/lib/ConstellationDisplayPlot.cc @@ -100,11 +100,8 @@ ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent):QwtPlot(pare _zoomer->setRubberBandPen(c); _zoomer->setTrackerPen(c); - QwtLegend* legendDisplay = new QwtLegend(this); - legendDisplay->setItemMode(QwtLegend::CheckableItem); - insertLegend(legendDisplay); - - connect(this, SIGNAL( legendChecked(QwtPlotItem *, bool ) ), this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) )); + connect(this, SIGNAL( legendChecked(QwtPlotItem *, bool ) ), + this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) )); } ConstellationDisplayPlot::~ConstellationDisplayPlot(){ diff --git a/gr-qtgui/src/lib/FrequencyDisplayPlot.cc b/gr-qtgui/src/lib/FrequencyDisplayPlot.cc index 9fb9253b5..4f9bfdd95 100644 --- a/gr-qtgui/src/lib/FrequencyDisplayPlot.cc +++ b/gr-qtgui/src/lib/FrequencyDisplayPlot.cc @@ -8,18 +8,22 @@ class FreqPrecisionClass { public: - FreqPrecisionClass(const int freqPrecision){ + FreqPrecisionClass(const int freqPrecision) + { _frequencyPrecision = freqPrecision; } - virtual ~FreqPrecisionClass(){ + virtual ~FreqPrecisionClass() + { } - virtual unsigned int GetFrequencyPrecision()const{ + virtual unsigned int GetFrequencyPrecision() const + { return _frequencyPrecision; } - virtual void SetFrequencyPrecision(const unsigned int newPrecision){ + virtual void SetFrequencyPrecision(const unsigned int newPrecision) + { _frequencyPrecision = newPrecision; } protected: @@ -29,17 +33,20 @@ private: }; -class FreqDisplayScaleDraw: public QwtScaleDraw, public FreqPrecisionClass{ +class FreqDisplayScaleDraw: public QwtScaleDraw, public FreqPrecisionClass +{ public: - FreqDisplayScaleDraw(const unsigned int precision):QwtScaleDraw(), FreqPrecisionClass(precision){ - + FreqDisplayScaleDraw(const unsigned int precision) + : QwtScaleDraw(), FreqPrecisionClass(precision) + { } - virtual ~FreqDisplayScaleDraw(){ - + virtual ~FreqDisplayScaleDraw() + { } - virtual QwtText label(double value)const{ + virtual QwtText label(double value) const + { return QString("%1").arg(value, 0, 'f', GetFrequencyPrecision()); } @@ -52,7 +59,8 @@ private: class FreqDisplayZoomer: public QwtPlotZoomer, public FreqPrecisionClass { public: - FreqDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision):QwtPlotZoomer(canvas),FreqPrecisionClass(freqPrecision) + FreqDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision) + : QwtPlotZoomer(canvas),FreqPrecisionClass(freqPrecision) { setTrackerMode(QwtPicker::AlwaysOn); } @@ -74,7 +82,9 @@ protected: } }; -FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent):QwtPlot(parent){ +FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) + : QwtPlot(parent) +{ _startFrequency = 0; _stopFrequency = 4000; @@ -199,10 +209,10 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent):QwtPlot(parent){ const QColor c(Qt::darkRed); _zoomer->setRubberBandPen(c); _zoomer->setTrackerPen(c); - } -FrequencyDisplayPlot::~FrequencyDisplayPlot(){ +FrequencyDisplayPlot::~FrequencyDisplayPlot() +{ delete[] _dataPoints; delete[] _maxFFTPoints; delete[] _minFFTPoints; @@ -212,49 +222,37 @@ FrequencyDisplayPlot::~FrequencyDisplayPlot(){ // _zoomer and _panner deleted when parent deleted } -void FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq, const double constStopFreq, const double centerFrequency, const bool useCenterFrequencyFlag){ - double startFreq = constStartFreq; - double stopFreq = constStopFreq; +void +FrequencyDisplayPlot::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 + centerFrequency) / 1000.0; - stopFreq = (stopFreq + centerFrequency) / 1000.0; - } - - if((stopFreq > 0) && (stopFreq > startFreq)){ - _startFrequency = startFreq; - _stopFrequency = stopFreq; - _resetXAxisPoints(); - - // Load up the new base zoom settings - QwtDoubleRect newSize = _zoomer->zoomBase(); - newSize.setLeft(_startFrequency); - newSize.setWidth(_stopFrequency-_startFrequency); - _zoomer->setZoomBase(newSize); - - // Zooms back to the base and clears any other zoom levels - _zoomer->zoom(0); - - setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); + startFreq = (startFreq + centerFreq); + stopFreq = (stopFreq + centerFreq); } - if(useCenterFrequencyFlag){ - setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(3)); - setAxisTitle(QwtPlot::xBottom, "RF Frequency (kHz)"); - ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(3); - } - else{ - setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0)); - setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)"); - ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(0); - } + _startFrequency = startFreq; + _stopFrequency = stopFreq; + _resetXAxisPoints(); + + setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); + setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(2)); + setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str())); + ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(2); // Load up the new base zoom settings QwtDoubleRect newSize = _zoomer->zoomBase(); newSize.setLeft(_startFrequency); - newSize.setWidth(_stopFrequency-_startFrequency); + newSize.setWidth(_stopFrequency-_startFrequency); _zoomer->setZoomBase(newSize); // Zooms back to the base and clears any other zoom levels @@ -262,16 +260,21 @@ void FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq, const } -double FrequencyDisplayPlot::GetStartFrequency()const{ +double +FrequencyDisplayPlot::GetStartFrequency() const +{ return _startFrequency; } -double FrequencyDisplayPlot::GetStopFrequency()const{ +double +FrequencyDisplayPlot::GetStopFrequency() const +{ return _stopFrequency; } -void FrequencyDisplayPlot::replot(){ - +void +FrequencyDisplayPlot::replot() +{ const timespec startTime = get_highres_clock(); _markerNoiseFloorAmplitude->setYValue(_noiseFloorAmplitude); @@ -296,7 +299,11 @@ void FrequencyDisplayPlot::replot(){ } } -void FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDataPoints, const double noiseFloorAmplitude, const double peakFrequency, const double peakAmplitude){ +void +FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDataPoints, + const double noiseFloorAmplitude, const double peakFrequency, + const double peakAmplitude) +{ if(numDataPoints > 0){ if(numDataPoints != _numPoints){ @@ -345,27 +352,37 @@ void FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t n } } -void FrequencyDisplayPlot::ClearMaxData(){ +void +FrequencyDisplayPlot::ClearMaxData() +{ for(int64_t number = 0; number < _numPoints; number++){ _maxFFTPoints[number] = -280.0; } } -void FrequencyDisplayPlot::ClearMinData(){ +void +FrequencyDisplayPlot::ClearMinData() +{ for(int64_t number = 0; number < _numPoints; number++){ _minFFTPoints[number] = 200.0; } } -void FrequencyDisplayPlot::SetMaxFFTVisible(const bool visibleFlag){ +void +FrequencyDisplayPlot::SetMaxFFTVisible(const bool visibleFlag) +{ _max_fft_plot_curve->setVisible(visibleFlag); } -void FrequencyDisplayPlot::SetMinFFTVisible(const bool visibleFlag){ +void +FrequencyDisplayPlot::SetMinFFTVisible(const bool visibleFlag) +{ _min_fft_plot_curve->setVisible(visibleFlag); } -void FrequencyDisplayPlot::_resetXAxisPoints(){ +void +FrequencyDisplayPlot::_resetXAxisPoints() +{ double fft_bin_size = (_stopFrequency-_startFrequency) / static_cast<double>(_numPoints); double freqValue = _startFrequency; for(int64_t loc = 0; loc < _numPoints; loc++){ @@ -374,11 +391,15 @@ void FrequencyDisplayPlot::_resetXAxisPoints(){ } } -void FrequencyDisplayPlot::SetLowerIntensityLevel(const double lowerIntensityLevel){ +void +FrequencyDisplayPlot::SetLowerIntensityLevel(const double lowerIntensityLevel) +{ _lower_intensity_marker->setYValue( lowerIntensityLevel ); } -void FrequencyDisplayPlot::SetUpperIntensityLevel(const double upperIntensityLevel){ +void +FrequencyDisplayPlot::SetUpperIntensityLevel(const double upperIntensityLevel) +{ _upper_intensity_marker->setYValue( upperIntensityLevel ); } diff --git a/gr-qtgui/src/lib/FrequencyDisplayPlot.h b/gr-qtgui/src/lib/FrequencyDisplayPlot.h index fb647d964..061ef6ef8 100644 --- a/gr-qtgui/src/lib/FrequencyDisplayPlot.h +++ b/gr-qtgui/src/lib/FrequencyDisplayPlot.h @@ -20,11 +20,16 @@ public: FrequencyDisplayPlot(QWidget*); virtual ~FrequencyDisplayPlot(); - void SetFrequencyRange(const double, const double, const double, const bool); + void SetFrequencyRange(const double, const double, + const double, const bool, + const double units=1000.0, + const std::string &strunits = "kHz"); double GetStartFrequency()const; double GetStopFrequency()const; - void PlotNewData(const double* dataPoints, const int64_t numDataPoints, const double noiseFloorAmplitude, const double peakFrequency, const double peakAmplitude); + void PlotNewData(const double* dataPoints, const int64_t numDataPoints, + const double noiseFloorAmplitude, const double peakFrequency, + const double peakAmplitude); void ClearMaxData(); void ClearMinData(); diff --git a/gr-qtgui/src/lib/Makefile.am b/gr-qtgui/src/lib/Makefile.am index eee58990d..3c05d28f9 100644 --- a/gr-qtgui/src/lib/Makefile.am +++ b/gr-qtgui/src/lib/Makefile.am @@ -108,7 +108,7 @@ TOP_SWIG_IFILES = \ # This ends up at: # ${prefix}/lib/python${python_version}/site-packages/gnuradio qtgui_pythondir_category = \ - gnuradio + gnuradio/qtgui # additional libraries for linking with the SWIG-generated library qtgui_la_swig_libadd = \ diff --git a/gr-qtgui/src/lib/SpectrumGUIClass.cc b/gr-qtgui/src/lib/SpectrumGUIClass.cc index f9988d8f5..06450845a 100644 --- a/gr-qtgui/src/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/src/lib/SpectrumGUIClass.cc @@ -9,8 +9,11 @@ const long SpectrumGUIClass::MAX_FFT_SIZE; const long SpectrumGUIClass::MIN_FFT_SIZE; -SpectrumGUIClass::SpectrumGUIClass(const uint64_t maxDataSize, const uint64_t fftSize, - const double newStartFrequency, const double newStopFrequency){ +SpectrumGUIClass::SpectrumGUIClass(const uint64_t maxDataSize, + const uint64_t fftSize, + const double newStartFrequency, + const double newStopFrequency) +{ _dataPoints = maxDataSize; if(_dataPoints < 2){ _dataPoints = 2; @@ -40,7 +43,8 @@ SpectrumGUIClass::SpectrumGUIClass(const uint64_t maxDataSize, const uint64_t ff _powerValue = 1; } -SpectrumGUIClass::~SpectrumGUIClass(){ +SpectrumGUIClass::~SpectrumGUIClass() +{ if(GetWindowOpenFlag()){ delete _spectrumDisplayForm; } @@ -54,7 +58,12 @@ SpectrumGUIClass::~SpectrumGUIClass(){ //delete _windowStateLock; } -void SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent){ +void +SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, + const bool frequency, const bool waterfall, + const bool waterfall3d, const bool time, + const bool constellation) +{ //_windowStateLock->Lock(); if(!_windowOpennedFlag){ @@ -73,6 +82,13 @@ void SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent){ // Called from the Event Thread _spectrumDisplayForm = new SpectrumDisplayForm(parent); + + // Toggle Windows on/off + _spectrumDisplayForm->ToggleTabFrequency(frequency); + _spectrumDisplayForm->ToggleTabWaterfall(waterfall); + _spectrumDisplayForm->ToggleTabWaterfall3D(waterfall3d); + _spectrumDisplayForm->ToggleTabTime(time); + _spectrumDisplayForm->ToggleTabConstellation(constellation); _windowOpennedFlag = true; @@ -86,9 +102,8 @@ void SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent){ SetDisplayTitle(_title); Reset(); - qApp->postEvent(_spectrumDisplayForm, new QEvent(QEvent::Type(QEvent::User+3))); - - _spectrumDisplayForm->show(); + qApp->postEvent(_spectrumDisplayForm, + new QEvent(QEvent::Type(QEvent::User+3))); qApp->processEvents(); @@ -101,11 +116,14 @@ void SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent){ qApp->processEvents(); } -void SpectrumGUIClass::Reset(){ - if(GetWindowOpenFlag()){ - qApp->postEvent(_spectrumDisplayForm, new SpectrumFrequencyRangeEvent(_centerFrequency, - _startFrequency, - _stopFrequency)); +void +SpectrumGUIClass::Reset() +{ + if(GetWindowOpenFlag()) { + qApp->postEvent(_spectrumDisplayForm, + new SpectrumFrequencyRangeEvent(_centerFrequency, + _startFrequency, + _stopFrequency)); qApp->postEvent(_spectrumDisplayForm, new SpectrumWindowResetEvent()); } _droppedEntriesCount = 0; @@ -113,16 +131,20 @@ void SpectrumGUIClass::Reset(){ // ResetPendingGUIUpdateEvents(); } -void SpectrumGUIClass::SetDisplayTitle(const std::string newString){ +void +SpectrumGUIClass::SetDisplayTitle(const std::string newString) +{ _title.assign(newString); if(GetWindowOpenFlag()){ - qApp->postEvent(_spectrumDisplayForm, new SpectrumWindowCaptionEvent(_title.c_str())); + qApp->postEvent(_spectrumDisplayForm, + new SpectrumWindowCaptionEvent(_title.c_str())); } - } -bool SpectrumGUIClass::GetWindowOpenFlag(){ +bool +SpectrumGUIClass::GetWindowOpenFlag() +{ bool returnFlag = false; //_windowStateLock->Lock(); returnFlag = _windowOpennedFlag; @@ -131,21 +153,33 @@ bool SpectrumGUIClass::GetWindowOpenFlag(){ } -void SpectrumGUIClass::SetWindowOpenFlag(const bool newFlag){ +void +SpectrumGUIClass::SetWindowOpenFlag(const bool newFlag) +{ //_windowStateLock->Lock(); _windowOpennedFlag = newFlag; //_windowStateLock->Unlock(); } -void SpectrumGUIClass::SetFrequencyRange(const double centerFreq, const double startFreq, const double stopFreq){ +void +SpectrumGUIClass::SetFrequencyRange(const double centerFreq, + const double startFreq, + const double stopFreq) +{ //_windowStateLock->Lock(); _centerFrequency = centerFreq; _startFrequency = startFreq; _stopFrequency = stopFreq; + + _spectrumDisplayForm->SetFrequencyRange(_centerFrequency, + _startFrequency, + _stopFrequency); //_windowStateLock->Unlock(); } -double SpectrumGUIClass::GetStartFrequency()const{ +double +SpectrumGUIClass::GetStartFrequency() const +{ double returnValue = 0.0; //_windowStateLock->Lock(); returnValue = _startFrequency; @@ -153,7 +187,9 @@ double SpectrumGUIClass::GetStartFrequency()const{ return returnValue; } -double SpectrumGUIClass::GetStopFrequency()const{ +double +SpectrumGUIClass::GetStopFrequency() const +{ double returnValue = 0.0; //_windowStateLock->Lock(); returnValue = _stopFrequency; @@ -161,7 +197,9 @@ double SpectrumGUIClass::GetStopFrequency()const{ return returnValue; } -double SpectrumGUIClass::GetCenterFrequency()const{ +double +SpectrumGUIClass::GetCenterFrequency() const +{ double returnValue = 0.0; //_windowStateLock->Lock(); returnValue = _centerFrequency; @@ -170,8 +208,18 @@ double SpectrumGUIClass::GetCenterFrequency()const{ } -void SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag, const std::complex<float>* fftBuffer, const uint64_t inputBufferSize, const float* realTimeDomainData, const uint64_t realTimeDomainDataSize, const float* complexTimeDomainData, const uint64_t complexTimeDomainDataSize, const double timePerFFT, const timespec timestamp, const bool lastOfMultipleFFTUpdateFlag){ - +void +SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag, + const std::complex<float>* fftBuffer, + const uint64_t inputBufferSize, + const float* realTimeDomainData, + const uint64_t realTimeDomainDataSize, + const float* complexTimeDomainData, + const uint64_t complexTimeDomainDataSize, + const double timePerFFT, + const timespec timestamp, + const bool lastOfMultipleFFTUpdateFlag) +{ int64_t bufferSize = inputBufferSize; bool repeatDataFlag = false; if(bufferSize > _dataPoints){ @@ -179,7 +227,7 @@ void SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag, const std::com } int64_t timeDomainBufferSize = 0; - if( updateDisplayFlag){ + if(updateDisplayFlag){ if((fftBuffer != NULL) && (bufferSize > 0)){ memcpy(_fftPoints, fftBuffer, bufferSize * sizeof(std::complex<float>)); } @@ -225,25 +273,36 @@ void SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag, const std::com const timespec currentTime = get_highres_clock(); const timespec lastUpdateGUITime = GetLastGUIUpdateTime(); - if((diff_timespec(currentTime, lastUpdateGUITime) > (4*timePerFFT)) && (GetPendingGUIUpdateEvents() > 0) && !timespec_empty(&lastUpdateGUITime)){ + if((diff_timespec(currentTime, lastUpdateGUITime) > (4*timePerFFT)) && + (GetPendingGUIUpdateEvents() > 0) && !timespec_empty(&lastUpdateGUITime)) { // Do not update the display if too much data is pending to be displayed _droppedEntriesCount++; } else{ // Draw the Data IncrementPendingGUIUpdateEvents(); - qApp->postEvent(_spectrumDisplayForm, new SpectrumUpdateEvent(_fftPoints, bufferSize, _realTimeDomainPoints, _imagTimeDomainPoints, timeDomainBufferSize, timePerFFT, timestamp, repeatDataFlag, lastOfMultipleFFTUpdateFlag, currentTime, _droppedEntriesCount)); + qApp->postEvent(_spectrumDisplayForm, + new SpectrumUpdateEvent(_fftPoints, bufferSize, + _realTimeDomainPoints, + _imagTimeDomainPoints, + timeDomainBufferSize, + timePerFFT, timestamp, + repeatDataFlag, + lastOfMultipleFFTUpdateFlag, + currentTime, + _droppedEntriesCount)); - // Only reset the dropped entries counter if this is not repeat data since repeat data is dropped by the display systems + // Only reset the dropped entries counter if this is not + // repeat data since repeat data is dropped by the display systems if(!repeatDataFlag){ _droppedEntriesCount = 0; } - - //qApp->wakeUpGuiThread(); } } -float SpectrumGUIClass::GetPowerValue()const{ +float +SpectrumGUIClass::GetPowerValue() const +{ float returnValue = 0; //_windowStateLock->Lock(); returnValue = _powerValue; @@ -251,13 +310,17 @@ float SpectrumGUIClass::GetPowerValue()const{ return returnValue; } -void SpectrumGUIClass::SetPowerValue(const float value){ +void +SpectrumGUIClass::SetPowerValue(const float value) +{ //_windowStateLock->Lock(); _powerValue = value; //_windowStateLock->Unlock(); } -int SpectrumGUIClass::GetWindowType()const{ +int +SpectrumGUIClass::GetWindowType() const +{ int returnValue = 0; //_windowStateLock->Lock(); returnValue = _windowType; @@ -265,13 +328,17 @@ int SpectrumGUIClass::GetWindowType()const{ return returnValue; } -void SpectrumGUIClass::SetWindowType(const int newType){ +void +SpectrumGUIClass::SetWindowType(const int newType) +{ //_windowStateLock->Lock(); _windowType = newType; //_windowStateLock->Unlock(); } -int SpectrumGUIClass::GetFFTSize()const{ +int +SpectrumGUIClass::GetFFTSize() const +{ int returnValue = 0; //_windowStateLock->Lock(); returnValue = _fftSize; @@ -279,7 +346,9 @@ int SpectrumGUIClass::GetFFTSize()const{ return returnValue; } -int SpectrumGUIClass::GetFFTSizeIndex()const{ +int +SpectrumGUIClass::GetFFTSizeIndex() const +{ int fftsize = GetFFTSize(); switch(fftsize) { case(1024): return 0; break; @@ -292,13 +361,17 @@ int SpectrumGUIClass::GetFFTSizeIndex()const{ } } -void SpectrumGUIClass::SetFFTSize(const int newSize){ +void +SpectrumGUIClass::SetFFTSize(const int newSize) +{ //_windowStateLock->Lock(); _fftSize = newSize; //_windowStateLock->Unlock(); } -timespec SpectrumGUIClass::GetLastGUIUpdateTime()const{ +timespec +SpectrumGUIClass::GetLastGUIUpdateTime() const +{ timespec returnValue; //_windowStateLock->Lock(); returnValue = _lastGUIUpdateTime; @@ -306,13 +379,17 @@ timespec SpectrumGUIClass::GetLastGUIUpdateTime()const{ return returnValue; } -void SpectrumGUIClass::SetLastGUIUpdateTime(const timespec newTime){ +void +SpectrumGUIClass::SetLastGUIUpdateTime(const timespec newTime) +{ //_windowStateLock->Lock(); _lastGUIUpdateTime = newTime; //_windowStateLock->Unlock(); } -unsigned int SpectrumGUIClass::GetPendingGUIUpdateEvents()const{ +unsigned int +SpectrumGUIClass::GetPendingGUIUpdateEvents() const +{ unsigned int returnValue = 0; //_windowStateLock->Lock(); returnValue = _pendingGUIUpdateEventsCount; @@ -320,13 +397,17 @@ unsigned int SpectrumGUIClass::GetPendingGUIUpdateEvents()const{ return returnValue; } -void SpectrumGUIClass::IncrementPendingGUIUpdateEvents(){ +void +SpectrumGUIClass::IncrementPendingGUIUpdateEvents() +{ //_windowStateLock->Lock(); _pendingGUIUpdateEventsCount++; //_windowStateLock->Unlock(); } -void SpectrumGUIClass::DecrementPendingGUIUpdateEvents(){ +void +SpectrumGUIClass::DecrementPendingGUIUpdateEvents() +{ //_windowStateLock->Lock(); if(_pendingGUIUpdateEventsCount > 0){ _pendingGUIUpdateEventsCount--; @@ -334,11 +415,20 @@ void SpectrumGUIClass::DecrementPendingGUIUpdateEvents(){ //_windowStateLock->Unlock(); } -void SpectrumGUIClass::ResetPendingGUIUpdateEvents(){ +void +SpectrumGUIClass::ResetPendingGUIUpdateEvents() +{ //_windowStateLock->Lock(); _pendingGUIUpdateEventsCount = 0; //_windowStateLock->Unlock(); } +QWidget* +SpectrumGUIClass::qwidget() +{ + return (QWidget*)_spectrumDisplayForm; +} + + #endif /* SPECTRUM_GUI_CLASS_CPP */ diff --git a/gr-qtgui/src/lib/SpectrumGUIClass.h b/gr-qtgui/src/lib/SpectrumGUIClass.h index 4f8fb9782..fafae0c6c 100644 --- a/gr-qtgui/src/lib/SpectrumGUIClass.h +++ b/gr-qtgui/src/lib/SpectrumGUIClass.h @@ -19,13 +19,18 @@ class SpectrumDisplayForm; #include <vector> #include <string> -class SpectrumGUIClass{ +class SpectrumGUIClass +{ public: - SpectrumGUIClass(const uint64_t, const uint64_t, const double, const double); + SpectrumGUIClass(const uint64_t maxDataSize, const uint64_t fftSize, + const double newStartFrequency, const double newStopFrequency); ~SpectrumGUIClass(); void Reset(); - void OpenSpectrumWindow(QWidget*); + void OpenSpectrumWindow(QWidget*, + const bool frequency=true, const bool waterfall=true, + const bool waterfall3d=true, const bool time=true, + const bool constellation=true); void SetDisplayTitle(const std::string); bool GetWindowOpenFlag(); @@ -36,7 +41,11 @@ public: double GetStopFrequency()const; double GetCenterFrequency()const; - void UpdateWindow(const bool, const std::complex<float>*, const uint64_t, const float*, const uint64_t, const float*, const uint64_t, const double, const timespec, const bool); + void UpdateWindow(const bool, const std::complex<float>*, + const uint64_t, const float*, + const uint64_t, const float*, + const uint64_t, const double, + const timespec, const bool); float GetPowerValue()const; void SetPowerValue(const float); @@ -59,6 +68,8 @@ public: static const long MAX_FFT_SIZE = /*1048576*/32768; static const long MIN_FFT_SIZE = 1024; + QWidget* qwidget(); + protected: private: diff --git a/gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc b/gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc index 21011ed68..1b6650613 100644 --- a/gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc +++ b/gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc @@ -111,8 +111,18 @@ void Waterfall3DDisplayPlot::Reset(){ _timePerFFT = 1.0; } -void Waterfall3DDisplayPlot::SetFrequencyRange(const double startFreq, const double stopFreq, const double centerFreq, const bool useCenterFrequencyFlag){ - if((stopFreq > 0) && (stopFreq > startFreq)){ +void +Waterfall3DDisplayPlot::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; + + if(stopFreq > startFreq) { _startFrequency = startFreq; _stopFrequency = stopFreq; diff --git a/gr-qtgui/src/lib/Waterfall3DDisplayPlot.h b/gr-qtgui/src/lib/Waterfall3DDisplayPlot.h index dcdbf380c..8af5f6b54 100644 --- a/gr-qtgui/src/lib/Waterfall3DDisplayPlot.h +++ b/gr-qtgui/src/lib/Waterfall3DDisplayPlot.h @@ -130,7 +130,9 @@ public: bool loadFromData(double** data, unsigned int columns, unsigned int rows ,double minx, double maxx, double miny, double maxy); - void SetFrequencyRange(const double, const double, const double, const bool); + void SetFrequencyRange(const double, const double, + const double, const bool, + const double units, const std::string &strunits); double GetStartFrequency()const; double GetStopFrequency()const; diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc index 0f15d95fd..ad167f097 100644 --- a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc @@ -182,7 +182,9 @@ const int WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_BLACK_HOT; const int WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_INCANDESCENT; const int WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED; -WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent):QwtPlot(parent){ +WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) + : QwtPlot(parent) +{ _zoomer = NULL; _startFrequency = 0; _stopFrequency = 4000; @@ -253,11 +255,14 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent):QwtPlot(parent){ _UpdateIntensityRangeDisplay(); } -WaterfallDisplayPlot::~WaterfallDisplayPlot(){ +WaterfallDisplayPlot::~WaterfallDisplayPlot() +{ delete _waterfallData; } -void WaterfallDisplayPlot::Reset(){ +void +WaterfallDisplayPlot::Reset() +{ _waterfallData->ResizeData(_startFrequency, _stopFrequency, _numPoints); _waterfallData->Reset(); @@ -270,25 +275,31 @@ void WaterfallDisplayPlot::Reset(){ _zoomer->zoom(0); } -void WaterfallDisplayPlot::SetFrequencyRange(const double startFreq, const double stopFreq, const double centerFreq, const bool useCenterFrequencyFlag){ - if((stopFreq > 0) && (stopFreq > startFreq)){ - _startFrequency = startFreq; - _stopFrequency = stopFreq; +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; + + if(stopFreq > startFreq) { + _startFrequency = 1000*startFreq; + _stopFrequency = 1000*stopFreq; + + setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){ WaterfallFreqDisplayScaleDraw* freqScale = ((WaterfallFreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom)); freqScale->SetCenterFrequency(centerFreq); ((WaterfallZoomer*)_zoomer)->SetCenterFrequency(centerFreq); - if(useCenterFrequencyFlag){ - freqScale->SetFrequencyPrecision( 3 ); - ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision( 3 ); - setAxisTitle(QwtPlot::xBottom, "Frequency (kHz)"); - } - else{ - freqScale->SetFrequencyPrecision( 0 ); - ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision( 0 ); - setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)"); - } + + freqScale->SetFrequencyPrecision( 2 ); + ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision( 2 ); + setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str())); } Reset(); @@ -461,7 +472,7 @@ void WaterfallDisplayPlot::_UpdateIntensityRangeDisplay(){ 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() ); diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.h b/gr-qtgui/src/lib/WaterfallDisplayPlot.h index 71fb76aaf..d5371a037 100644 --- a/gr-qtgui/src/lib/WaterfallDisplayPlot.h +++ b/gr-qtgui/src/lib/WaterfallDisplayPlot.h @@ -18,11 +18,16 @@ public: void Reset(); - void SetFrequencyRange(const double, const double, const double, const bool); + void SetFrequencyRange(const double, const double, + const double, const bool, + const double units=1000.0, + const std::string &strunits = "kHz"); double GetStartFrequency()const; double GetStopFrequency()const; - void PlotNewData(const double* dataPoints, const int64_t numDataPoints, const double timePerFFT, const timespec timestamp, const int droppedFrames); + void PlotNewData(const double* dataPoints, const int64_t numDataPoints, + const double timePerFFT, const timespec timestamp, + const int droppedFrames); void SetIntensityRange(const double minIntensity, const double maxIntensity); diff --git a/gr-qtgui/src/lib/qtgui.i b/gr-qtgui/src/lib/qtgui.i index eba37833e..1113d647c 100644 --- a/gr-qtgui/src/lib/qtgui.i +++ b/gr-qtgui/src/lib/qtgui.i @@ -31,22 +31,37 @@ GR_SWIG_BLOCK_MAGIC(qtgui,sink_c) qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, float fmin=-0.5, float fmax=0.5, - const std::string &name="Display"); + const std::string &name="Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + QWidget *parent=NULL); class qtgui_sink_c : public gr_block { private: friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, float fmin, float fmax, - const std::string &name); + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent); qtgui_sink_c (int fftsize, int wintype, - float fmin, float fmax, const std::string &name); + float fmin, float fmax, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent); public: - void start_app(); - void initialize(); - void initialize(QApplication *qapp); - QApplication* get_qapplication(); + void exec_(); + PyObject* pyqwidget(); + + void set_frequency_range(const double centerfreq, + const double startfreq, + const double stopfreq); }; @@ -56,25 +71,34 @@ public: GR_SWIG_BLOCK_MAGIC(qtgui,sink_f) -qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, - const std::vector<float> &window, - float fmin, float fmax, - const std::string &name="Display"); +qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + float fmin=-0.5, float fmax=0.5, + const std::string &name="Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + QWidget *parent=NULL); class qtgui_sink_f : public gr_block { private: - friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, - const std::vector<float> &window, - float fmin, float fmax, - const std::string &name); - qtgui_sink_f (int fftsize, - const std::vector<float> &window, + friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + float fmin, float fmax, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent); + qtgui_sink_f (int fftsize, int wintype, float fmin, float fmax, - const std::string &name); - + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent); + public: - void start_app(); + void exec_(); + PyObject* pyqwidget(); }; - diff --git a/gr-qtgui/src/lib/qtgui_sink_c.cc b/gr-qtgui/src/lib/qtgui_sink_c.cc index fdd069e7f..a2b1366e5 100644 --- a/gr-qtgui/src/lib/qtgui_sink_c.cc +++ b/gr-qtgui/src/lib/qtgui_sink_c.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,24 +32,46 @@ qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, - float fmin, float fmax, const std::string &name) + float fmin, float fmax, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent) { - return qtgui_sink_c_sptr (new qtgui_sink_c (fftsize, wintype, fmin, fmax, name)); + return qtgui_sink_c_sptr (new qtgui_sink_c (fftsize, wintype, + fmin, fmax, name, + plotfreq, plotwaterfall, + plotwaterfall3d, plottime, + plotconst, + parent)); } qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, - float fmin, float fmax, const std::string &name) + float fmin, float fmax, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent) : gr_block ("sink_c", gr_make_io_signature (1, -1, sizeof(gr_complex)), gr_make_io_signature (0, 0, 0)), - d_fftsize(fftsize), d_wintype((gr_firdes::win_type)(wintype)), - d_fmin(fmin), d_fmax(fmax), d_name(name) + d_fftsize(fftsize), + d_wintype((gr_firdes::win_type)(wintype)), + d_fmin(fmin), d_fmax(fmax), d_name(name), + d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall), + d_plotwaterfall3d(plotwaterfall3d), d_plottime(plottime), + d_plotconst(plotconst), + d_parent(parent) { d_main_gui = NULL; pthread_mutex_init(&d_pmutex, NULL); lock(); - d_shift = true; // Perform fftshift operation; this is usually desired when plotting + // Perform fftshift operation; + // this is usually desired when plotting + d_shift = true; d_fft = new gri_fft_complex (d_fftsize, true); @@ -60,7 +82,7 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, buildwindow(); - //initialize(); + initialize(); } qtgui_sink_c::~qtgui_sink_c() @@ -68,7 +90,6 @@ qtgui_sink_c::~qtgui_sink_c() delete d_object; delete [] d_fftdata; delete [] d_residbuf; - delete d_main_gui; delete d_fft; } @@ -86,47 +107,60 @@ void qtgui_sink_c::unlock() void qtgui_sink_c::initialize() { - int argc; - char **argv = NULL; - d_qApplication = new QApplication(argc, argv); - __initialize(); -} - - -void -qtgui_sink_c::initialize(QApplication *qapp) -{ - d_qApplication = qapp; - __initialize(); -} + if(qApp != NULL) { + d_qApplication = qApp; + } + else { + int argc; + char **argv = NULL; + d_qApplication = new QApplication(argc, argv); + } -void -qtgui_sink_c::__initialize() -{ uint64_t maxBufferSize = 32768; - d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize, d_fmin, d_fmax); + d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize, + d_fmin, d_fmax); + d_main_gui->SetDisplayTitle(d_name); d_main_gui->SetFFTSize(d_fftsize); d_main_gui->SetWindowType((int)d_wintype); - d_main_gui->OpenSpectrumWindow(NULL); + + d_main_gui->OpenSpectrumWindow(d_parent, + d_plotfreq, d_plotwaterfall, + d_plotwaterfall3d, d_plottime, + d_plotconst); d_object = new qtgui_obj(d_qApplication); qApp->postEvent(d_object, new qtgui_event(&d_pmutex)); } -QApplication* -qtgui_sink_c::get_qapplication() + +void +qtgui_sink_c::exec_() { - return d_qApplication; + d_qApplication->exec(); } +QWidget* +qtgui_sink_c::qwidget() +{ + return d_main_gui->qwidget(); +} -void -qtgui_sink_c::start_app() +PyObject* +qtgui_sink_c::pyqwidget() { - d_qApplication->exec(); + PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget()); + PyObject *retarg = Py_BuildValue("N", w); + return retarg; } +void +qtgui_sink_c::set_frequency_range(const double centerfreq, + const double startfreq, + const double stopfreq) +{ + d_main_gui->SetFrequencyRange(centerfreq, startfreq, stopfreq); +} void qtgui_sink_c::fft(const gr_complex *data_in, int size, gr_complex *data_out) @@ -221,37 +255,45 @@ qtgui_sink_c::general_work (int noutput_items, // Update the FFT size from the application fftresize(); windowreset(); + + const timespec currentTime = get_highres_clock(); + const timespec lastUpdateGUITime = d_main_gui->GetLastGUIUpdateTime(); - if(d_index) { - int filler = std::min(d_fftsize - d_index, noutput_items); + if(diff_timespec(currentTime, lastUpdateGUITime) > 0.25) { - memcpy(&d_residbuf[d_index], &in[0], sizeof(gr_complex)*filler); - d_index += filler; - i = filler; - j = filler; - } - - if(d_index == d_fftsize) { - d_index = 0; - fft(d_residbuf, d_fftsize, d_fftdata); + if(d_index) { + int filler = std::min(d_fftsize - d_index, noutput_items); + + memcpy(&d_residbuf[d_index], &in[0], sizeof(gr_complex)*filler); + d_index += filler; + i = filler; + j = filler; + } - d_main_gui->UpdateWindow(true, d_fftdata, d_fftsize, NULL, 0, (float*)d_residbuf, d_fftsize, - 1.0/4.0, convert_to_timespec(0.0), true); - } - - for(; i < noutput_items; i+=d_fftsize) { - if(noutput_items - i > d_fftsize) { - j += d_fftsize; - fft(&in[i], d_fftsize, d_fftdata); + if(d_index == d_fftsize) { + d_index = 0; + fft(d_residbuf, d_fftsize, d_fftdata); - d_main_gui->UpdateWindow(true, d_fftdata, d_fftsize, NULL, 0, (float*)&in[i], d_fftsize, + d_main_gui->UpdateWindow(true, d_fftdata, d_fftsize, NULL, 0, + (float*)d_residbuf, d_fftsize, 1.0/4.0, convert_to_timespec(0.0), true); } - } - - if(noutput_items > j) { - d_index = noutput_items - j; - memcpy(d_residbuf, &in[j], sizeof(gr_complex)*d_index); + + for(; i < noutput_items; i+=d_fftsize) { + if(noutput_items - i > d_fftsize) { + j += d_fftsize; + fft(&in[i], d_fftsize, d_fftdata); + + d_main_gui->UpdateWindow(true, d_fftdata, d_fftsize, NULL, 0, + (float*)&in[i], d_fftsize, + 1.0/4.0, convert_to_timespec(0.0), true); + } + } + + if(noutput_items > j) { + d_index = noutput_items - j; + memcpy(d_residbuf, &in[j], sizeof(gr_complex)*d_index); + } } pthread_mutex_unlock(&d_pmutex); diff --git a/gr-qtgui/src/lib/qtgui_sink_c.h b/gr-qtgui/src/lib/qtgui_sink_c.h index a1eb05649..305b1cf26 100644 --- a/gr-qtgui/src/lib/qtgui_sink_c.h +++ b/gr-qtgui/src/lib/qtgui_sink_c.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -28,25 +28,40 @@ #include <gri_fft.h> #include <qapplication.h> #include <qtgui.h> +#include <Python.h> #include "SpectrumGUIClass.h" - class qtgui_sink_c; typedef boost::shared_ptr<qtgui_sink_c> qtgui_sink_c_sptr; qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, - float fmin=-0.5, float fmax=0.5, const std::string &name="Display"); + float fmin=-0.5, float fmax=0.5, + const std::string &name="Spectrum Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + QWidget *parent=NULL); class qtgui_sink_c : public gr_block { private: friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, - float fmin, float fmax, const std::string &name); + float fmin, float fmax, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent); qtgui_sink_c (int fftsize, int wintype, - float fmin, float fmax, const std::string &name); + float fmin, float fmax, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent); + + void initialize(); - void __initialize(); - int d_fftsize; gr_firdes::win_type d_wintype; std::vector<float> d_window; @@ -63,7 +78,10 @@ private: int d_index; gr_complex *d_residbuf; - SpectrumGUIClass *d_main_gui; + bool d_plotfreq, d_plotwaterfall, d_plotwaterfall3d, d_plottime, d_plotconst; + + QWidget *d_parent; + SpectrumGUIClass *d_main_gui; void windowreset(); void buildwindow(); @@ -72,13 +90,15 @@ private: public: ~qtgui_sink_c(); - void initialize(); - void initialize(QApplication *qapp); - void start_app(); + void exec_(); void lock(); void unlock(); + QWidget* qwidget(); + PyObject* pyqwidget(); - QApplication* get_qapplication(); + void set_frequency_range(const double centerfreq, + const double startfreq, + const double stopfreq); QApplication *d_qApplication; qtgui_obj *d_object; diff --git a/gr-qtgui/src/lib/qtgui_sink_f.cc b/gr-qtgui/src/lib/qtgui_sink_f.cc index b27718bd7..94d4cf279 100644 --- a/gr-qtgui/src/lib/qtgui_sink_f.cc +++ b/gr-qtgui/src/lib/qtgui_sink_f.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,39 +31,65 @@ #include <QTimer> qtgui_sink_f_sptr -qtgui_make_sink_f (int fftsize, const std::vector<float> &window, - float fmin, float fmax, const std::string &name) +qtgui_make_sink_f (int fftsize, int wintype, + float fmin, float fmax, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent) { - return qtgui_sink_f_sptr (new qtgui_sink_f (fftsize, window, fmin, fmax, name)); + return qtgui_sink_f_sptr (new qtgui_sink_f (fftsize, wintype, + fmin, fmax, name, + plotfreq, plotwaterfall, + plotwaterfall3d, plottime, + plotconst, + parent)); } -qtgui_sink_f::qtgui_sink_f (int fftsize, const std::vector<float> &window, - float fmin, float fmax, const std::string &name) +qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype, + float fmin, float fmax, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent) : gr_block ("sink_f", gr_make_io_signature (1, 1, sizeof(float)), gr_make_io_signature (0, 0, 0)), - d_fftsize(fftsize), d_window(window), - d_fmin(fmin), d_fmax(fmax), d_name(name) + d_fftsize(fftsize), + d_wintype((gr_firdes::win_type)(wintype)), + d_fmin(fmin), d_fmax(fmax), d_name(name), + d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall), + d_plotwaterfall3d(plotwaterfall3d), d_plottime(plottime), + d_plotconst(plotconst), + d_parent(parent) { d_main_gui = NULL; pthread_mutex_init(&d_pmutex, NULL); lock(); - d_shift = true; // Perform fftshift operation; this is usually desired when plotting + // Perform fftshift operation; + // this is usually desired when plotting + d_shift = true; d_fft = new gri_fft_complex (d_fftsize, true); - fftdata = new gr_complex[d_fftsize]; + d_fftdata = new gr_complex[d_fftsize]; d_index = 0; d_residbuf = new float[d_fftsize]; + + buildwindow(); + + initialize(); } qtgui_sink_f::~qtgui_sink_f() { - delete [] fftdata; + delete d_object; + delete [] d_fftdata; delete [] d_residbuf; - delete d_main_gui; delete d_fft; } @@ -78,21 +104,61 @@ void qtgui_sink_f::unlock() } void -qtgui_sink_f::start_app() +qtgui_sink_f::initialize() { - d_qApplication = new QApplication(0, NULL); + if(qApp != NULL) { + d_qApplication = qApp; + } + else { + int argc; + char **argv = NULL; + d_qApplication = new QApplication(argc, argv); + } + uint64_t maxBufferSize = 32768; - d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize, d_fmin, d_fmax); + d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize, + d_fmin, d_fmax); d_main_gui->SetDisplayTitle(d_name); - d_main_gui->OpenSpectrumWindow(NULL); + d_main_gui->SetFFTSize(d_fftsize); + d_main_gui->SetWindowType((int)d_wintype); + + d_main_gui->OpenSpectrumWindow(d_parent, + d_plotfreq, d_plotwaterfall, + d_plotwaterfall3d, d_plottime, + d_plotconst); - qtgui_obj object(d_qApplication); - qApp->postEvent(&object, new qtgui_event(&d_pmutex)); + d_object = new qtgui_obj(d_qApplication); + qApp->postEvent(d_object, new qtgui_event(&d_pmutex)); +} +void +qtgui_sink_f::exec_() +{ d_qApplication->exec(); } +QWidget* +qtgui_sink_f::qwidget() +{ + return d_main_gui->qwidget(); +} + +PyObject* +qtgui_sink_f::pyqwidget() +{ + PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget()); + PyObject *retarg = Py_BuildValue("N", w); + return retarg; +} + +void +qtgui_sink_f::set_frequency_range(const double centerfreq, + const double startfreq, + const double stopfreq) +{ + d_main_gui->SetFrequencyRange(centerfreq, startfreq, stopfreq); +} void qtgui_sink_f::fft(const float *data_in, int size, gr_complex *data_out) @@ -104,7 +170,7 @@ qtgui_sink_f::fft(const float *data_in, int size, gr_complex *data_out) } else { gr_complex *dst = d_fft->get_inbuf(); - for (unsigned int i = 0; i < size; i++) // float to complex conversion + for (int i = 0; i < size; i++) // float to complex conversion dst[i] = data_in[i]; } @@ -125,6 +191,54 @@ qtgui_sink_f::fft(const float *data_in, int size, gr_complex *data_out) } } +void +qtgui_sink_f::windowreset() +{ + gr_firdes::win_type newwintype = (gr_firdes::win_type)d_main_gui->GetWindowType(); + if(d_wintype != newwintype) { + d_wintype = newwintype; + buildwindow(); + } +} + +void +qtgui_sink_f::buildwindow() +{ + d_window.clear(); + if(d_wintype != 0) { + d_window = gr_firdes::window(d_wintype, d_fftsize, 6.76); + } +} + +void +qtgui_sink_f::fftresize() +{ + int newfftsize = d_main_gui->GetFFTSize(); + + if(newfftsize != d_fftsize) { + + // Resize the fftdata buffer; no need to preserve old data + delete [] d_fftdata; + d_fftdata = new gr_complex[newfftsize]; + + // Resize residbuf and replace data + delete [] d_residbuf; + d_residbuf = new float[newfftsize]; + + // Set new fft size and reset buffer index + // (throws away any currently held data, but who cares?) + d_fftsize = newfftsize; + d_index = 0; + + // Reset window to reflect new size + buildwindow(); + + // Reset FFTW plan for new size + delete d_fft; + d_fft = new gri_fft_complex (d_fftsize, true); + } +} + int qtgui_sink_f::general_work (int noutput_items, @@ -147,19 +261,21 @@ qtgui_sink_f::general_work (int noutput_items, if(d_index == d_fftsize) { d_index = 0; - fft(d_residbuf, d_fftsize, fftdata); + fft(d_residbuf, d_fftsize, d_fftdata); - d_main_gui->UpdateWindow(true, fftdata, d_fftsize, d_residbuf, d_fftsize, NULL, 0, + d_main_gui->UpdateWindow(true, d_fftdata, d_fftsize, + d_residbuf, d_fftsize, NULL, 0, 1.0/4.0, convert_to_timespec(0.0), true); } for(; i < noutput_items; i+=d_fftsize) { if(noutput_items - i > d_fftsize) { j += d_fftsize; - fft(&in[i], d_fftsize, fftdata); + fft(&in[i], d_fftsize, d_fftdata); - d_main_gui->UpdateWindow(true, fftdata, d_fftsize, &in[i], d_fftsize, NULL, 0, - 1.0/4.0, convert_to_timespec(0.0), true); + d_main_gui->UpdateWindow(true, d_fftdata, d_fftsize, &in[i], + d_fftsize, NULL, 0, 1.0/4.0, + convert_to_timespec(0.0), true); } } diff --git a/gr-qtgui/src/lib/qtgui_sink_f.h b/gr-qtgui/src/lib/qtgui_sink_f.h index 3f0e785c6..f220bc6c1 100644 --- a/gr-qtgui/src/lib/qtgui_sink_f.h +++ b/gr-qtgui/src/lib/qtgui_sink_f.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,27 +24,46 @@ #define INCLUDED_QTGUI_SINK_F_H #include <gr_block.h> +#include <gr_firdes.h> #include <gri_fft.h> #include <qapplication.h> #include <qtgui.h> +#include <Python.h> #include "SpectrumGUIClass.h" - class qtgui_sink_f; typedef boost::shared_ptr<qtgui_sink_f> qtgui_sink_f_sptr; -qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, const std::vector<float> &window, - float fmin=-0.5, float fmax=0.5, const std::string &name="Display"); +qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + float fmin=-0.5, float fmax=0.5, + const std::string &name="Spectrum Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + QWidget *parent=NULL); class qtgui_sink_f : public gr_block { private: - friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, const std::vector<float> &window, - float fmin, float fmax, const std::string &name); - qtgui_sink_f (int fftsize, const std::vector<float> &window, - float fmin, float fmax, const std::string &name); - + friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + float fmin, float fmax, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent); + qtgui_sink_f (int fftsize, int wintype, + float fmin, float fmax, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + QWidget *parent); + + void initialize(); + int d_fftsize; + gr_firdes::win_type d_wintype; std::vector<float> d_window; float d_fmin; float d_fmax; @@ -54,23 +73,35 @@ private: bool d_shift; gri_fft_complex *d_fft; - gr_complex *fftdata; + gr_complex *d_fftdata; int d_index; float *d_residbuf; + bool d_plotfreq, d_plotwaterfall, d_plotwaterfall3d, d_plottime, d_plotconst; + + QWidget *d_parent; SpectrumGUIClass *d_main_gui; + void windowreset(); + void buildwindow(); + void fftresize(); void fft(const float *data_in, int size, gr_complex *data_out); public: ~qtgui_sink_f(); - void start_app(); + void exec_(); void lock(); void unlock(); + QWidget* qwidget(); + PyObject* pyqwidget(); + + void set_frequency_range(const double centerfreq, + const double startfreq, + const double stopfreq); - QApplication *d_qApplication -; + QApplication *d_qApplication; + qtgui_obj *d_object; int general_work (int noutput_items, gr_vector_int &ninput_items, diff --git a/gr-qtgui/src/lib/spectrumUpdateEvents.cc b/gr-qtgui/src/lib/spectrumUpdateEvents.cc index f705e0478..2da37d350 100644 --- a/gr-qtgui/src/lib/spectrumUpdateEvents.cc +++ b/gr-qtgui/src/lib/spectrumUpdateEvents.cc @@ -3,8 +3,19 @@ #include <spectrumUpdateEvents.h> -SpectrumUpdateEvent::SpectrumUpdateEvent(const std::complex<float>* fftPoints, const uint64_t numFFTDataPoints, const double* realTimeDomainPoints, const double* imagTimeDomainPoints, const uint64_t numTimeDomainDataPoints, const double timePerFFT, const timespec dataTimestamp, const bool repeatDataFlag, const bool lastOfMultipleUpdateFlag, const timespec generatedTimestamp, const int droppedFFTFrames):QEvent(QEvent::Type(10005)){ - +SpectrumUpdateEvent::SpectrumUpdateEvent(const std::complex<float>* fftPoints, + const uint64_t numFFTDataPoints, + const double* realTimeDomainPoints, + const double* imagTimeDomainPoints, + const uint64_t numTimeDomainDataPoints, + const double timePerFFT, + const timespec dataTimestamp, + const bool repeatDataFlag, + const bool lastOfMultipleUpdateFlag, + const timespec generatedTimestamp, + const int droppedFFTFrames) + : QEvent(QEvent::Type(10005)) +{ _numFFTDataPoints = numFFTDataPoints; if(_numFFTDataPoints < 1){ _numFFTDataPoints = 1; @@ -22,13 +33,15 @@ SpectrumUpdateEvent::SpectrumUpdateEvent(const std::complex<float>* fftPoints, c _realDataTimeDomainPoints = new double[_numTimeDomainDataPoints]; memset(_realDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double)); if(numTimeDomainDataPoints > 0){ - memcpy(_realDataTimeDomainPoints, realTimeDomainPoints, numTimeDomainDataPoints*sizeof(double)); + memcpy(_realDataTimeDomainPoints, realTimeDomainPoints, + numTimeDomainDataPoints*sizeof(double)); } _imagDataTimeDomainPoints = new double[_numTimeDomainDataPoints]; memset(_imagDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double)); if(numTimeDomainDataPoints > 0){ - memcpy(_imagDataTimeDomainPoints, imagTimeDomainPoints, numTimeDomainDataPoints*sizeof(double)); + memcpy(_imagDataTimeDomainPoints, imagTimeDomainPoints, + numTimeDomainDataPoints*sizeof(double)); } _dataTimestamp = dataTimestamp; _timePerFFT = timePerFFT; @@ -44,87 +57,126 @@ SpectrumUpdateEvent::~SpectrumUpdateEvent(){ delete[] _imagDataTimeDomainPoints; } -const std::complex<float>* SpectrumUpdateEvent::getFFTPoints()const{ +const std::complex<float>* +SpectrumUpdateEvent::getFFTPoints() const +{ return _fftPoints; } -const double* SpectrumUpdateEvent::getRealTimeDomainPoints()const{ +const double* +SpectrumUpdateEvent::getRealTimeDomainPoints() const +{ return _realDataTimeDomainPoints; } -const double* SpectrumUpdateEvent::getImagTimeDomainPoints()const{ +const double* +SpectrumUpdateEvent::getImagTimeDomainPoints() const +{ return _imagDataTimeDomainPoints; } -uint64_t SpectrumUpdateEvent::getNumFFTDataPoints()const{ +uint64_t +SpectrumUpdateEvent::getNumFFTDataPoints() const +{ return _numFFTDataPoints; } -uint64_t SpectrumUpdateEvent::getNumTimeDomainDataPoints()const{ +uint64_t +SpectrumUpdateEvent::getNumTimeDomainDataPoints() const +{ return _numTimeDomainDataPoints; } -double SpectrumUpdateEvent::getTimePerFFT()const{ +double +SpectrumUpdateEvent::getTimePerFFT() const +{ return _timePerFFT; } -timespec SpectrumUpdateEvent::getDataTimestamp()const{ +timespec +SpectrumUpdateEvent::getDataTimestamp() const +{ return _dataTimestamp; } -bool SpectrumUpdateEvent::getRepeatDataFlag()const{ +bool +SpectrumUpdateEvent::getRepeatDataFlag() const +{ return _repeatDataFlag; } -bool SpectrumUpdateEvent::getLastOfMultipleUpdateFlag()const{ +bool +SpectrumUpdateEvent::getLastOfMultipleUpdateFlag() const +{ return _lastOfMultipleUpdateFlag; } -timespec SpectrumUpdateEvent::getEventGeneratedTimestamp()const{ +timespec +SpectrumUpdateEvent::getEventGeneratedTimestamp() const +{ return _eventGeneratedTimestamp; } -int SpectrumUpdateEvent::getDroppedFFTFrames()const{ +int +SpectrumUpdateEvent::getDroppedFFTFrames() const +{ return _droppedFFTFrames; } -SpectrumWindowCaptionEvent::SpectrumWindowCaptionEvent(const QString& newLbl):QEvent(QEvent::Type(10008)){ +SpectrumWindowCaptionEvent::SpectrumWindowCaptionEvent(const QString& newLbl) + : QEvent(QEvent::Type(10008)) +{ _labelString = newLbl; } -SpectrumWindowCaptionEvent::~SpectrumWindowCaptionEvent(){ +SpectrumWindowCaptionEvent::~SpectrumWindowCaptionEvent() +{ } -QString SpectrumWindowCaptionEvent::getLabel(){ +QString +SpectrumWindowCaptionEvent::getLabel() +{ return _labelString; } -SpectrumWindowResetEvent::SpectrumWindowResetEvent():QEvent(QEvent::Type(10009)){ +SpectrumWindowResetEvent::SpectrumWindowResetEvent() + : QEvent(QEvent::Type(10009)) +{ } -SpectrumWindowResetEvent::~SpectrumWindowResetEvent(){ - +SpectrumWindowResetEvent::~SpectrumWindowResetEvent() +{ } - SpectrumFrequencyRangeEvent::SpectrumFrequencyRangeEvent(const double centerFreq, const double startFreq, const double stopFreq):QEvent(QEvent::Type(10010)){ +SpectrumFrequencyRangeEvent::SpectrumFrequencyRangeEvent(const double centerFreq, + const double startFreq, + const double stopFreq) + : QEvent(QEvent::Type(10010)) +{ _centerFrequency = centerFreq; _startFrequency = startFreq; _stopFrequency = stopFreq; } -SpectrumFrequencyRangeEvent::~SpectrumFrequencyRangeEvent(){ - +SpectrumFrequencyRangeEvent::~SpectrumFrequencyRangeEvent() +{ } -double SpectrumFrequencyRangeEvent::GetCenterFrequency()const{ +double +SpectrumFrequencyRangeEvent::GetCenterFrequency() const +{ return _centerFrequency; } -double SpectrumFrequencyRangeEvent::GetStartFrequency()const{ +double +SpectrumFrequencyRangeEvent::GetStartFrequency() const +{ return _startFrequency; } -double SpectrumFrequencyRangeEvent::GetStopFrequency()const{ +double +SpectrumFrequencyRangeEvent::GetStopFrequency() const +{ return _stopFrequency; } diff --git a/gr-qtgui/src/lib/spectrumdisplayform.cc b/gr-qtgui/src/lib/spectrumdisplayform.cc index 4beec9bd6..3249463d7 100644 --- a/gr-qtgui/src/lib/spectrumdisplayform.cc +++ b/gr-qtgui/src/lib/spectrumdisplayform.cc @@ -5,14 +5,16 @@ int SpectrumDisplayForm::_openGLWaterfall3DFlag = -1; -SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) : QDialog(parent){ +SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) + : QWidget(parent) +{ setupUi(this); - + _systemSpecifiedFlag = false; _intValidator = new QIntValidator(this); _intValidator->setBottom(0); - _frequencyDisplayPlot = new FrequencyDisplayPlot(Tab1PlotDisplayFrame); - _waterfallDisplayPlot = new WaterfallDisplayPlot(Tab2PlotDisplayFrame); + _frequencyDisplayPlot = new FrequencyDisplayPlot(FrequencyPlotDisplayFrame); + _waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame); _waterfall3DDisplayPlot = new Waterfall3DDisplayPlot(Waterfall3DPlotDisplayFrame); _timeDomainDisplayPlot = new TimeDomainDisplayPlot(TimeDomainDisplayFrame); _constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame); @@ -42,7 +44,7 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) : QDialog(parent){ _peakAmplitude = -HUGE_VAL; _noiseFloorAmplitude = -HUGE_VAL; - + connect(_waterfallDisplayPlot, SIGNAL(UpdatedLowerIntensityLevel(const double)), _frequencyDisplayPlot, SLOT(SetLowerIntensityLevel(const double))); connect(_waterfallDisplayPlot, SIGNAL(UpdatedUpperIntensityLevel(const double)), @@ -50,16 +52,23 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) : QDialog(parent){ _frequencyDisplayPlot->SetLowerIntensityLevel(-200); _frequencyDisplayPlot->SetUpperIntensityLevel(-200); - + // Load up the acceptable FFT sizes... FFTSizeComboBox->clear(); for(long fftSize = SpectrumGUIClass::MIN_FFT_SIZE; fftSize <= SpectrumGUIClass::MAX_FFT_SIZE; fftSize *= 2){ FFTSizeComboBox->insertItem(FFTSizeComboBox->count(), QString("%1").arg(fftSize)); } Reset(); + + ToggleTabFrequency(false); + ToggleTabWaterfall(false); + ToggleTabWaterfall3D(false); + ToggleTabTime(false); + ToggleTabConstellation(false); } -SpectrumDisplayForm::~SpectrumDisplayForm(){ +SpectrumDisplayForm::~SpectrumDisplayForm() +{ // Qt deletes children when parent is deleted // Don't worry about deleting Display Plots - they are deleted when parents are deleted @@ -75,9 +84,10 @@ SpectrumDisplayForm::~SpectrumDisplayForm(){ delete _historyVector; } -void SpectrumDisplayForm::setSystem( SpectrumGUIClass * newSystem, - const uint64_t numFFTDataPoints, - const uint64_t numTimeDomainDataPoints ) +void +SpectrumDisplayForm::setSystem( SpectrumGUIClass * newSystem, + const uint64_t numFFTDataPoints, + const uint64_t numTimeDomainDataPoints ) { ResizeBuffers(numFFTDataPoints, numTimeDomainDataPoints); @@ -90,7 +100,8 @@ void SpectrumDisplayForm::setSystem( SpectrumGUIClass * newSystem, } } -void SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdateEvent) +void +SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdateEvent) { const std::complex<float>* complexDataPoints = spectrumUpdateEvent->getFFTPoints(); const uint64_t numFFTDataPoints = spectrumUpdateEvent->getNumFFTDataPoints(); @@ -116,12 +127,14 @@ void SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumU // 75 ohm load assumption // 10 * log10 (v^2 / (2 * 75.0 * .001)) = 10 * log10( v^2 * 15) - *realFFTDataPointsPtr = 10.0*log10((((*complexDataPointsPtr).real() * (*complexDataPointsPtr).real()) + ((*complexDataPointsPtr).imag()*(*complexDataPointsPtr).imag())) + 1e-20); + *realFFTDataPointsPtr = 10.0*log10((((*complexDataPointsPtr).real() * (*complexDataPointsPtr).real()) + + ((*complexDataPointsPtr).imag()*(*complexDataPointsPtr).imag())) + 1e-20); complexDataPointsPtr++; realFFTDataPointsPtr++; } + int tabindex = SpectrumTypeTab->currentIndex(); // Don't update the averaging history if this is repeated data if(!repeatDataFlag){ @@ -167,36 +180,46 @@ void SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumU } if(lastOfMultipleUpdatesFlag){ - _frequencyDisplayPlot->PlotNewData(_averagedValues, numFFTDataPoints, - _noiseFloorAmplitude, _peakFrequency, - _peakAmplitude); - _timeDomainDisplayPlot->PlotNewData(realTimeDomainDataPoints, - imagTimeDomainDataPoints, - numTimeDomainDataPoints); - _constellationDisplayPlot->PlotNewData(realTimeDomainDataPoints, - imagTimeDomainDataPoints, - numTimeDomainDataPoints); - } - // Don't update the repeated data for the waterfall - if(!repeatDataFlag){ - _waterfallDisplayPlot->PlotNewData(_realFFTDataPoints, numFFTDataPoints, - timePerFFT, dataTimestamp, - spectrumUpdateEvent->getDroppedFFTFrames()); - if( _openGLWaterfall3DFlag == 1 ){ - _waterfall3DDisplayPlot->PlotNewData(_realFFTDataPoints, numFFTDataPoints, + if(tabindex == d_plot_fft) { + _frequencyDisplayPlot->PlotNewData(_averagedValues, numFFTDataPoints, + _noiseFloorAmplitude, _peakFrequency, + _peakAmplitude); + } + if(tabindex == d_plot_time) { + _timeDomainDisplayPlot->PlotNewData(realTimeDomainDataPoints, + imagTimeDomainDataPoints, + numTimeDomainDataPoints); + } + if(tabindex == d_plot_constellation) { + _constellationDisplayPlot->PlotNewData(realTimeDomainDataPoints, + imagTimeDomainDataPoints, + numTimeDomainDataPoints); + } + + // Don't update the repeated data for the waterfall + if(!repeatDataFlag){ + if(tabindex == d_plot_waterfall) { + _waterfallDisplayPlot->PlotNewData(_realFFTDataPoints, numFFTDataPoints, timePerFFT, dataTimestamp, spectrumUpdateEvent->getDroppedFFTFrames()); + } + if( _openGLWaterfall3DFlag == 1 && (tabindex == d_plot_waterfall3d)) { + _waterfall3DDisplayPlot->PlotNewData(_realFFTDataPoints, numFFTDataPoints, + timePerFFT, dataTimestamp, + spectrumUpdateEvent->getDroppedFFTFrames()); + } + } + + // Tell the system the GUI has been updated + if(_systemSpecifiedFlag){ + _system->SetLastGUIUpdateTime(generatedTimestamp); + _system->DecrementPendingGUIUpdateEvents(); } - } - - // Tell the system the GUI has been updated - if(_systemSpecifiedFlag){ - _system->SetLastGUIUpdateTime(generatedTimestamp); - _system->DecrementPendingGUIUpdateEvents(); } } -void SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) +void +SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) { // Let the actual window resize its width, but not its height QSize newSize(e->size().width(), e->oldSize().height()); @@ -207,29 +230,38 @@ void SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) SpectrumTypeTab->resize( e->size().width(), e->size().height()-60); // Tell the TabXFreqDisplay to resize - //Tab1PlotDisplayFrame->resize(e->size().width()-4, - //Tab1PlotDisplayFrame->height()); - Tab1PlotDisplayFrame->resize(e->size().width()-4, - e->size().height()-140); - Tab2PlotDisplayFrame->resize(e->size().width()-4, - e->size().height()-140); - Waterfall3DPlotDisplayFrame->resize(e->size().width()-4, - e->size().height()-140); - TimeDomainDisplayFrame->resize(e->size().width()-4, - e->size().height()-140); - ConstellationDisplayFrame->resize(e->size().width()-4, + FrequencyPlotDisplayFrame->resize(e->size().width()-4, e->size().height()-140); - _frequencyDisplayPlot->resize( Tab1PlotDisplayFrame->width()-4, - e->size().height()-140); - _waterfallDisplayPlot->resize( Tab2PlotDisplayFrame->width()-4, + _frequencyDisplayPlot->resize( FrequencyPlotDisplayFrame->width()-4, e->size().height()-140); - _waterfall3DDisplayPlot->resize( Waterfall3DPlotDisplayFrame->width()-4, - e->size().height()-140); - _timeDomainDisplayPlot->resize( TimeDomainDisplayFrame->width()-4, - e->size().height()-140); - _constellationDisplayPlot->resize( TimeDomainDisplayFrame->width()-4, - e->size().height()-140); + + // Move the Power Lbl and Line Edit + PowerLabel->move(e->size().width()-(415-324) - PowerLabel->width(), + e->size().height()-135); + PowerLineEdit->move(e->size().width()-(415-318) - PowerLineEdit->width(), + e->size().height()-115); + + // Move the Avg Lbl and Line Edit + AvgLabel->move(e->size().width()-(415-406) - AvgLabel->width(), + e->size().height()-135); + AvgLineEdit->move(e->size().width()-(415-400) - AvgLineEdit->width(), + e->size().height()-115); + + // Move Max and Min check boxes + MaxHoldCheckBox->move(MaxHoldCheckBox->x(), + e->size().height()-135); + MaxHoldResetBtn->move(MaxHoldResetBtn->x(), + e->size().height()-135); + MinHoldCheckBox->move(MinHoldCheckBox->x(), + e->size().height()-115); + MinHoldResetBtn->move(MinHoldResetBtn->x(), + e->size().height()-115); + WaterfallPlotDisplayFrame->resize(e->size().width()-4, + e->size().height()-140); + _waterfallDisplayPlot->resize( WaterfallPlotDisplayFrame->width()-4, + e->size().height()-140); + // Move the IntensityWheels and Labels WaterfallMaximumIntensityLabel->move(width() - 5 - WaterfallMaximumIntensityLabel->width(), @@ -237,7 +269,7 @@ void SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) WaterfallMaximumIntensityWheel->resize(WaterfallMaximumIntensityLabel->x() - 5 - WaterfallMaximumIntensityWheel->x(), WaterfallMaximumIntensityWheel->height()); - + WaterfallMinimumIntensityLabel->move(width() - 5 - WaterfallMinimumIntensityLabel->width(), height() - 115); @@ -246,14 +278,20 @@ void SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) WaterfallMaximumIntensityWheel->height()); WaterfallMinimumIntensityWheel->move(WaterfallMinimumIntensityWheel->x(), height() - 115); - + WaterfallAutoScaleBtn->move(WaterfallAutoScaleBtn->x(), + e->size().height()-115); + + Waterfall3DPlotDisplayFrame->resize(e->size().width()-4, + e->size().height()-140); + _waterfall3DDisplayPlot->resize( Waterfall3DPlotDisplayFrame->width()-4, + e->size().height()-140); + Waterfall3DMaximumIntensityLabel->move(width() - 5 - Waterfall3DMaximumIntensityLabel->width(), Waterfall3DMaximumIntensityLabel->y()); Waterfall3DMaximumIntensityWheel->resize(Waterfall3DMaximumIntensityLabel->x() - 5 - Waterfall3DMaximumIntensityWheel->x(), Waterfall3DMaximumIntensityWheel->height()); - Waterfall3DMinimumIntensityLabel->move(width() - 5 - Waterfall3DMinimumIntensityLabel->width(), height() - 115); @@ -262,42 +300,25 @@ void SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) Waterfall3DMaximumIntensityWheel->height()); Waterfall3DMinimumIntensityWheel->move(Waterfall3DMinimumIntensityWheel->x(), height() - 115); - - // Move Waterfall and Waterfall3D Auto Scan button - WaterfallAutoScaleBtn->move(WaterfallAutoScaleBtn->x(), - e->size().height()-115); Waterfall3DAutoScaleBtn->move(WaterfallAutoScaleBtn->x(), - e->size().height()-115); + e->size().height()-115); - - // Move the Power Lbl and Line Edit - PowerLabel->move(e->size().width()-(415-324) - PowerLabel->width(), - e->size().height()-135); - PowerLineEdit->move(e->size().width()-(415-318) - PowerLineEdit->width(), - e->size().height()-115); - - // Move the Avg Lbl and Line Edit - AvgLabel->move(e->size().width()-(415-406) - AvgLabel->width(), - e->size().height()-135); - AvgLineEdit->move(e->size().width()-(415-400) - AvgLineEdit->width(), - e->size().height()-115); - - // Move Max and Min check boxes - MaxHoldCheckBox->move(MaxHoldCheckBox->x(), - e->size().height()-135); - MaxHoldResetBtn->move(MaxHoldResetBtn->x(), - e->size().height()-135); - MinHoldCheckBox->move(MinHoldCheckBox->x(), - e->size().height()-115); - MinHoldResetBtn->move(MinHoldResetBtn->x(), - e->size().height()-115); + TimeDomainDisplayFrame->resize(e->size().width()-4, + e->size().height()-140); + _timeDomainDisplayPlot->resize( TimeDomainDisplayFrame->width()-4, + e->size().height()-140); + + ConstellationDisplayFrame->resize(e->size().width()-4, + e->size().height()-140); + _constellationDisplayPlot->resize( TimeDomainDisplayFrame->width()-4, + e->size().height()-140); // Move the FFT Size Combobox and label FFTSizeComboBox->move(width() - 5 - FFTSizeComboBox->width(), height()-50); FFTSizeLabel->move(width() - 10 - FFTSizeComboBox->width() - FFTSizeLabel->width(), height()-50); - + // Move the lower check and combo boxes UseRFFrequenciesCheckBox->move(UseRFFrequenciesCheckBox->x(), height()-50); WindowLbl->move(WindowLbl->x(), height()-25); @@ -305,7 +326,8 @@ void SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) } -void SpectrumDisplayForm::customEvent( QEvent * e) +void +SpectrumDisplayForm::customEvent( QEvent * e) { if(e->type() == QEvent::User+3){ if(_systemSpecifiedFlag){ @@ -337,15 +359,13 @@ void SpectrumDisplayForm::customEvent( QEvent * e) _openGLWaterfall3DFlag = 1; } } - + if(_openGLWaterfall3DFlag != 1){ - SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(Waterfall3DPage)); + ToggleTabWaterfall3D(false); } // Clear any previous display Reset(); - - show(); } else if(e->type() == 10005){ SpectrumUpdateEvent* spectrumUpdateEvent = (SpectrumUpdateEvent*)e; @@ -369,7 +389,8 @@ void SpectrumDisplayForm::customEvent( QEvent * e) } } -void SpectrumDisplayForm::AvgLineEdit_textChanged( const QString &valueString ) +void +SpectrumDisplayForm::AvgLineEdit_textChanged( const QString &valueString ) { if(!valueString.isEmpty()){ int value = valueString.toInt(); @@ -382,7 +403,8 @@ void SpectrumDisplayForm::AvgLineEdit_textChanged( const QString &valueString ) } -void SpectrumDisplayForm::MaxHoldCheckBox_toggled( bool newState ) +void +SpectrumDisplayForm::MaxHoldCheckBox_toggled( bool newState ) { MaxHoldResetBtn->setEnabled(newState); _frequencyDisplayPlot->SetMaxFFTVisible(newState); @@ -390,7 +412,8 @@ void SpectrumDisplayForm::MaxHoldCheckBox_toggled( bool newState ) } -void SpectrumDisplayForm::MinHoldCheckBox_toggled( bool newState ) +void +SpectrumDisplayForm::MinHoldCheckBox_toggled( bool newState ) { MinHoldResetBtn->setEnabled(newState); _frequencyDisplayPlot->SetMinFFTVisible(newState); @@ -398,21 +421,24 @@ void SpectrumDisplayForm::MinHoldCheckBox_toggled( bool newState ) } -void SpectrumDisplayForm::MinHoldResetBtn_clicked() +void +SpectrumDisplayForm::MinHoldResetBtn_clicked() { _frequencyDisplayPlot->ClearMinData(); _frequencyDisplayPlot->replot(); } -void SpectrumDisplayForm::MaxHoldResetBtn_clicked() +void +SpectrumDisplayForm::MaxHoldResetBtn_clicked() { _frequencyDisplayPlot->ClearMaxData(); _frequencyDisplayPlot->replot(); } -void SpectrumDisplayForm::PowerLineEdit_textChanged( const QString &valueString ) +void +SpectrumDisplayForm::PowerLineEdit_textChanged( const QString &valueString ) { if(_systemSpecifiedFlag){ if(!valueString.isEmpty()){ @@ -435,18 +461,47 @@ void SpectrumDisplayForm::PowerLineEdit_textChanged( const QString &valueString } } -void SpectrumDisplayForm::SetFrequencyRange(const double newStartFrequency, const double newStopFrequency, const double newCenterFrequency){ - _frequencyDisplayPlot->SetFrequencyRange(newStartFrequency, newStopFrequency, newCenterFrequency, UseRFFrequenciesCheckBox->isChecked()); - _waterfallDisplayPlot->SetFrequencyRange(newStartFrequency, newStopFrequency, newCenterFrequency, UseRFFrequenciesCheckBox->isChecked()); - _waterfall3DDisplayPlot->SetFrequencyRange(newStartFrequency, newStopFrequency, newCenterFrequency, UseRFFrequenciesCheckBox->isChecked()); - +void +SpectrumDisplayForm::SetFrequencyRange(const double newStartFrequency, + const double newStopFrequency, + const double newCenterFrequency) +{ + double fdiff = abs(newStartFrequency - newStopFrequency); + + if(fdiff > 0) { + std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"}; + double units10 = floor(log10(fdiff)); + double units3 = floor(units10 / 3.0); + double units = pow(10, units10); + int iunit = static_cast<int>(units3); + + _frequencyDisplayPlot->SetFrequencyRange(newStartFrequency, + newStopFrequency, + newCenterFrequency, + UseRFFrequenciesCheckBox->isChecked(), + units, strunits[iunit]); + _waterfallDisplayPlot->SetFrequencyRange(newStartFrequency, + newStopFrequency, + newCenterFrequency, + UseRFFrequenciesCheckBox->isChecked(), + units, strunits[iunit]); + _waterfall3DDisplayPlot->SetFrequencyRange(newStartFrequency, + newStopFrequency, + newCenterFrequency, + UseRFFrequenciesCheckBox->isChecked(), + units, strunits[iunit]); + } } -int SpectrumDisplayForm::GetAverageCount(){ +int +SpectrumDisplayForm::GetAverageCount() +{ return _historyVector->size(); } -void SpectrumDisplayForm::SetAverageCount(const int newCount){ +void +SpectrumDisplayForm::SetAverageCount(const int newCount) +{ if(newCount > -1){ if(newCount != static_cast<int>(_historyVector->size())){ std::vector<double*>::iterator pos; @@ -464,10 +519,13 @@ void SpectrumDisplayForm::SetAverageCount(const int newCount){ } } -void SpectrumDisplayForm::_AverageHistory(const double* newBuffer){ +void +SpectrumDisplayForm::_AverageHistory(const double* newBuffer) +{ if(_numRealDataPoints > 0){ if(_historyVector->size() > 0){ - memcpy(_historyVector->operator[](_historyEntry), newBuffer, _numRealDataPoints*sizeof(double)); + memcpy(_historyVector->operator[](_historyEntry), newBuffer, + _numRealDataPoints*sizeof(double)); // Increment the next location to store data _historyEntryCount++; @@ -492,7 +550,10 @@ void SpectrumDisplayForm::_AverageHistory(const double* newBuffer){ } } -void SpectrumDisplayForm::ResizeBuffers( const uint64_t numFFTDataPoints, const uint64_t /*numTimeDomainDataPoints*/ ){ +void +SpectrumDisplayForm::ResizeBuffers( const uint64_t numFFTDataPoints, + const uint64_t /*numTimeDomainDataPoints*/ ) +{ // Convert from Complex to Real for certain Displays if(_numRealDataPoints != numFFTDataPoints){ _numRealDataPoints = numFFTDataPoints; @@ -511,7 +572,9 @@ void SpectrumDisplayForm::ResizeBuffers( const uint64_t numFFTDataPoints, const } } -void SpectrumDisplayForm::Reset(){ +void +SpectrumDisplayForm::Reset() +{ AverageDataReset(); _waterfallDisplayPlot->Reset(); @@ -519,7 +582,9 @@ void SpectrumDisplayForm::Reset(){ } -void SpectrumDisplayForm::AverageDataReset(){ +void +SpectrumDisplayForm::AverageDataReset() +{ _historyEntry = 0; _historyEntryCount = 0; @@ -530,7 +595,8 @@ void SpectrumDisplayForm::AverageDataReset(){ } -void SpectrumDisplayForm::closeEvent( QCloseEvent *e ) +void +SpectrumDisplayForm::closeEvent( QCloseEvent *e ) { if(_systemSpecifiedFlag){ _system->SetWindowOpenFlag(false); @@ -542,7 +608,8 @@ void SpectrumDisplayForm::closeEvent( QCloseEvent *e ) } -void SpectrumDisplayForm::WindowTypeChanged( int newItem ) +void +SpectrumDisplayForm::WindowTypeChanged( int newItem ) { if(_systemSpecifiedFlag){ _system->SetWindowType(newItem); @@ -550,7 +617,8 @@ void SpectrumDisplayForm::WindowTypeChanged( int newItem ) } -void SpectrumDisplayForm::UseRFFrequenciesCB( bool useRFFlag ) +void +SpectrumDisplayForm::UseRFFrequenciesCB( bool useRFFlag ) { if(useRFFlag){ SetFrequencyRange(_startFrequency, _stopFrequency, _centerFrequency); @@ -561,7 +629,8 @@ void SpectrumDisplayForm::UseRFFrequenciesCB( bool useRFFlag ) } -void SpectrumDisplayForm::waterfallMaximumIntensityChangedCB( double newValue ) +void +SpectrumDisplayForm::waterfallMaximumIntensityChangedCB( double newValue ) { if(newValue > WaterfallMinimumIntensityWheel->value()){ WaterfallMaximumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); @@ -569,11 +638,14 @@ void SpectrumDisplayForm::waterfallMaximumIntensityChangedCB( double newValue ) else{ WaterfallMaximumIntensityWheel->setValue(WaterfallMinimumIntensityWheel->value()); } - _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), WaterfallMaximumIntensityWheel->value()); + + _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), + WaterfallMaximumIntensityWheel->value()); } -void SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue ) +void +SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue ) { if(newValue < WaterfallMaximumIntensityWheel->value()){ WaterfallMinimumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); @@ -581,10 +653,13 @@ void SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue ) else{ WaterfallMinimumIntensityWheel->setValue(WaterfallMaximumIntensityWheel->value()); } - _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), WaterfallMaximumIntensityWheel->value()); + + _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), + WaterfallMaximumIntensityWheel->value()); } -void SpectrumDisplayForm::waterfall3DMaximumIntensityChangedCB( double newValue ) +void +SpectrumDisplayForm::waterfall3DMaximumIntensityChangedCB( double newValue ) { if(newValue > Waterfall3DMinimumIntensityWheel->value()){ Waterfall3DMaximumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); @@ -592,11 +667,14 @@ void SpectrumDisplayForm::waterfall3DMaximumIntensityChangedCB( double newValue else{ Waterfall3DMaximumIntensityWheel->setValue(Waterfall3DMinimumIntensityWheel->value()); } - _waterfall3DDisplayPlot->SetIntensityRange(Waterfall3DMinimumIntensityWheel->value(), Waterfall3DMaximumIntensityWheel->value()); + + _waterfall3DDisplayPlot->SetIntensityRange(Waterfall3DMinimumIntensityWheel->value(), + Waterfall3DMaximumIntensityWheel->value()); } -void SpectrumDisplayForm::waterfall3DMinimumIntensityChangedCB( double newValue ) +void +SpectrumDisplayForm::waterfall3DMinimumIntensityChangedCB( double newValue ) { if(newValue < Waterfall3DMaximumIntensityWheel->value()){ Waterfall3DMinimumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); @@ -604,11 +682,14 @@ void SpectrumDisplayForm::waterfall3DMinimumIntensityChangedCB( double newValue else{ Waterfall3DMinimumIntensityWheel->setValue(Waterfall3DMaximumIntensityWheel->value()); } - _waterfall3DDisplayPlot->SetIntensityRange(Waterfall3DMinimumIntensityWheel->value(), Waterfall3DMaximumIntensityWheel->value()); + + _waterfall3DDisplayPlot->SetIntensityRange(Waterfall3DMinimumIntensityWheel->value(), + Waterfall3DMaximumIntensityWheel->value()); } -void SpectrumDisplayForm::FFTComboBoxSelectedCB( const QString &fftSizeString ) +void +SpectrumDisplayForm::FFTComboBoxSelectedCB( const QString &fftSizeString ) { if(_systemSpecifiedFlag){ _system->SetFFTSize(fftSizeString.toLong()); @@ -616,7 +697,8 @@ void SpectrumDisplayForm::FFTComboBoxSelectedCB( const QString &fftSizeString ) } -void SpectrumDisplayForm::WaterfallAutoScaleBtnCB() +void +SpectrumDisplayForm::WaterfallAutoScaleBtnCB() { double minimumIntensity = _noiseFloorAmplitude - 5; if(minimumIntensity < WaterfallMinimumIntensityWheel->minValue()){ @@ -631,7 +713,8 @@ void SpectrumDisplayForm::WaterfallAutoScaleBtnCB() waterfallMaximumIntensityChangedCB(maximumIntensity); } -void SpectrumDisplayForm::Waterfall3DAutoScaleBtnCB() +void +SpectrumDisplayForm::Waterfall3DAutoScaleBtnCB() { double minimumIntensity = _noiseFloorAmplitude - 5; if(minimumIntensity < Waterfall3DMinimumIntensityWheel->minValue()){ @@ -646,7 +729,8 @@ void SpectrumDisplayForm::Waterfall3DAutoScaleBtnCB() waterfallMaximumIntensityChangedCB(maximumIntensity); } -void SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) +void +SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) { QColor lowIntensityColor; QColor highIntensityColor; @@ -658,7 +742,7 @@ void SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) } QMessageBox::information(this, "Low Intensity Color Selection", "In the next window, select the low intensity color for the waterfall display", QMessageBox::Ok); lowIntensityColor = QColorDialog::getColor(lowIntensityColor, this); - + // Select the High Intensity Color highIntensityColor = _waterfallDisplayPlot->GetUserDefinedHighIntensityColor(); if(!highIntensityColor.isValid()){ @@ -667,10 +751,12 @@ void SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) QMessageBox::information(this, "High Intensity Color Selection", "In the next window, select the high intensity color for the waterfall display", QMessageBox::Ok); highIntensityColor = QColorDialog::getColor(highIntensityColor, this); } + _waterfallDisplayPlot->SetIntensityColorMapType(newType, lowIntensityColor, highIntensityColor); } -void SpectrumDisplayForm::Waterfall3DIntensityColorTypeChanged( int newType ) +void +SpectrumDisplayForm::Waterfall3DIntensityColorTypeChanged( int newType ) { QColor lowIntensityColor; QColor highIntensityColor; @@ -682,7 +768,7 @@ void SpectrumDisplayForm::Waterfall3DIntensityColorTypeChanged( int newType ) } QMessageBox::information(this, "Low Intensity Color Selection", "In the next window, select the low intensity color for the waterfall display", QMessageBox::Ok); lowIntensityColor = QColorDialog::getColor(lowIntensityColor, this); - + // Select the High Intensity Color highIntensityColor = _waterfallDisplayPlot->GetUserDefinedHighIntensityColor(); if(!highIntensityColor.isValid()){ @@ -691,5 +777,82 @@ void SpectrumDisplayForm::Waterfall3DIntensityColorTypeChanged( int newType ) QMessageBox::information(this, "High Intensity Color Selection", "In the next window, select the high intensity color for the waterfall display", QMessageBox::Ok); highIntensityColor = QColorDialog::getColor(highIntensityColor, this); } - _waterfall3DDisplayPlot->SetIntensityColorMapType(newType, lowIntensityColor, highIntensityColor); + _waterfall3DDisplayPlot->SetIntensityColorMapType(newType, lowIntensityColor, + highIntensityColor); +} + + +void +SpectrumDisplayForm::ToggleTabFrequency(const bool state) +{ + if(state == true) { + if(d_plot_fft == -1) { + SpectrumTypeTab->addTab(FrequencyPage, "Frequency Display"); + d_plot_fft = SpectrumTypeTab->count()-1; + } + } + else { + SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(FrequencyPage)); + d_plot_fft = -1; + } +} + +void +SpectrumDisplayForm::ToggleTabWaterfall(const bool state) +{ + if(state == true) { + if(d_plot_waterfall == -1) { + SpectrumTypeTab->addTab(WaterfallPage, "Waterfall Display"); + d_plot_waterfall = SpectrumTypeTab->count()-1; + } + } + else { + SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(WaterfallPage)); + d_plot_waterfall = -1; + } +} + +void +SpectrumDisplayForm::ToggleTabWaterfall3D(const bool state) +{ + if(state == true) { + if(d_plot_waterfall3d == -1) { + SpectrumTypeTab->addTab(Waterfall3DPage, "3D Waterfall Display"); + d_plot_waterfall3d = SpectrumTypeTab->count()-1; + } + } + else { + SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(Waterfall3DPage)); + d_plot_waterfall3d = -1; + } +} + +void +SpectrumDisplayForm::ToggleTabTime(const bool state) +{ + if(state == true) { + if(d_plot_time == -1) { + SpectrumTypeTab->addTab(TimeDomainPage, "Time Domain Display"); + d_plot_time = SpectrumTypeTab->count()-1; + } + } + else { + 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"); + d_plot_constellation = SpectrumTypeTab->count()-1; + } + } + else { + SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(ConstellationPage)); + d_plot_constellation = -1; + } } diff --git a/gr-qtgui/src/lib/spectrumdisplayform.h b/gr-qtgui/src/lib/spectrumdisplayform.h index 6e57e2cec..eba087bf5 100644 --- a/gr-qtgui/src/lib/spectrumdisplayform.h +++ b/gr-qtgui/src/lib/spectrumdisplayform.h @@ -15,7 +15,7 @@ class SpectrumGUIClass; #include <QValidator> #include <vector> -class SpectrumDisplayForm : public QDialog, public Ui::SpectrumDisplayForm +class SpectrumDisplayForm : public QWidget, public Ui::SpectrumDisplayForm { Q_OBJECT @@ -23,13 +23,15 @@ class SpectrumDisplayForm : public QDialog, public Ui::SpectrumDisplayForm SpectrumDisplayForm(QWidget* parent = 0); ~SpectrumDisplayForm(); - void setSystem( SpectrumGUIClass * newSystem, const uint64_t numFFTDataPoints, const uint64_t numTimeDomainDataPoints ); + void setSystem( SpectrumGUIClass * newSystem, const uint64_t numFFTDataPoints, + const uint64_t numTimeDomainDataPoints ); int GetAverageCount(); void SetAverageCount( const int newCount ); void Reset(); void AverageDataReset(); - void ResizeBuffers( const uint64_t numFFTDataPoints, const uint64_t numTimeDomainDataPoints ); + void ResizeBuffers( const uint64_t numFFTDataPoints, + const uint64_t numTimeDomainDataPoints ); public slots: void resizeEvent( QResizeEvent * e ); @@ -40,7 +42,9 @@ public slots: void MinHoldResetBtn_clicked(); void MaxHoldResetBtn_clicked(); void PowerLineEdit_textChanged( const QString& valueString ); - void SetFrequencyRange( const double newStartFrequency, const double newStopFrequency, const double newCenterFrequency ); + void SetFrequencyRange( const double newStartFrequency, + const double newStopFrequency, + const double newCenterFrequency ); void closeEvent( QCloseEvent * e ); void WindowTypeChanged( int newItem ); void UseRFFrequenciesCB( bool useRFFlag ); @@ -54,6 +58,12 @@ public slots: void Waterfall3DAutoScaleBtnCB(); void FFTComboBoxSelectedCB(const QString&); + void ToggleTabFrequency(const bool state); + void ToggleTabWaterfall(const bool state); + void ToggleTabWaterfall3D(const bool state); + void ToggleTabTime(const bool state); + void ToggleTabConstellation(const bool state); + private slots: void newFrequencyData( const SpectrumUpdateEvent* ); @@ -84,6 +94,13 @@ private: double _peakAmplitude; static int _openGLWaterfall3DFlag; double _stopFrequency; + + // whether or not to use a particular display + int d_plot_fft; + int d_plot_waterfall; + int d_plot_waterfall3d; + int d_plot_time; + int d_plot_constellation; }; #endif /* SPECTRUM_DISPLAY_FORM_H */ diff --git a/gr-qtgui/src/lib/spectrumdisplayform.ui b/gr-qtgui/src/lib/spectrumdisplayform.ui index 561be64cb..96096030d 100644 --- a/gr-qtgui/src/lib/spectrumdisplayform.ui +++ b/gr-qtgui/src/lib/spectrumdisplayform.ui @@ -1,6 +1,6 @@ <ui version="4.0" > <class>SpectrumDisplayForm</class> - <widget class="QDialog" name="SpectrumDisplayForm" > + <widget class="QWidget" name="SpectrumDisplayForm" > <property name="geometry" > <rect> <x>0</x> @@ -286,7 +286,7 @@ <bool>false</bool> </property> </widget> - <widget class="QFrame" name="Tab1PlotDisplayFrame" > + <widget class="QFrame" name="FrequencyPlotDisplayFrame" > <property name="geometry" > <rect> <x>5</x> @@ -402,7 +402,7 @@ <bool>false</bool> </property> </widget> - <widget class="QFrame" name="Tab2PlotDisplayFrame" > + <widget class="QFrame" name="WaterfallPlotDisplayFrame" > <property name="geometry" > <rect> <x>5</x> |