From: Tom Rondeau Date: Mon, 13 Sep 2010 18:49:00 +0000 (-0400) Subject: Removing Waterfall3DPlot. The qwt_plot3d is too much of a hassle to deal with and... X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=0be1b700a2ca7886c92a9a913d5ae00e3d17fa9e;p=debian%2Fgnuradio Removing Waterfall3DPlot. The qwt_plot3d is too much of a hassle to deal with and the plotting is not that stable even when it does work. This does not change the API. --- diff --git a/gr-qtgui/src/lib/Makefile.am b/gr-qtgui/src/lib/Makefile.am index 6d4a9125..bd9c945b 100644 --- a/gr-qtgui/src/lib/Makefile.am +++ b/gr-qtgui/src/lib/Makefile.am @@ -31,7 +31,6 @@ QMAKE_SOURCES = \ FrequencyDisplayPlot_moc.cc \ TimeDomainDisplayPlot_moc.cc \ WaterfallDisplayPlot_moc.cc \ - Waterfall3DDisplayPlot_moc.cc \ ConstellationDisplayPlot_moc.cc \ spectrumdisplayform_ui.h @@ -47,7 +46,6 @@ libgnuradio_qtgui_la_SOURCES = \ FrequencyDisplayPlot.cc \ TimeDomainDisplayPlot.cc \ WaterfallDisplayPlot.cc \ - Waterfall3DDisplayPlot.cc \ waterfallGlobalData.cc \ ConstellationDisplayPlot.cc \ spectrumdisplayform.cc \ @@ -62,7 +60,6 @@ grinclude_HEADERS = \ FrequencyDisplayPlot.h \ TimeDomainDisplayPlot.h \ WaterfallDisplayPlot.h \ - Waterfall3DDisplayPlot.h \ waterfallGlobalData.h \ ConstellationDisplayPlot.h \ highResTimeFunctions.h \ @@ -74,8 +71,6 @@ grinclude_HEADERS = \ qtgui_sink_c.h \ qtgui_sink_f.h -nodist_libqtsrc_la_SOURCES = $(QMAKE_SOURCES) - %_moc.cc : %.h $(QT_MOC_EXEC) -DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -p $(srcdir) $< -o $@ diff --git a/gr-qtgui/src/lib/SpectrumGUIClass.cc b/gr-qtgui/src/lib/SpectrumGUIClass.cc index 8c1b3670..563ed34b 100644 --- a/gr-qtgui/src/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/src/lib/SpectrumGUIClass.cc @@ -61,8 +61,7 @@ SpectrumGUIClass::~SpectrumGUIClass() void SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, const bool frequency, const bool waterfall, - const bool waterfall3d, const bool time, - const bool constellation, + const bool time, const bool constellation, const bool use_openGL) { //_windowStateLock->Lock(); @@ -87,7 +86,6 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, // Toggle Windows on/off _spectrumDisplayForm->ToggleTabFrequency(frequency); _spectrumDisplayForm->ToggleTabWaterfall(waterfall); - _spectrumDisplayForm->ToggleTabWaterfall3D(waterfall3d); _spectrumDisplayForm->ToggleTabTime(time); _spectrumDisplayForm->ToggleTabConstellation(constellation); diff --git a/gr-qtgui/src/lib/SpectrumGUIClass.h b/gr-qtgui/src/lib/SpectrumGUIClass.h index 17d3a54c..63a340c3 100644 --- a/gr-qtgui/src/lib/SpectrumGUIClass.h +++ b/gr-qtgui/src/lib/SpectrumGUIClass.h @@ -31,8 +31,7 @@ public: void OpenSpectrumWindow(QWidget*, const bool frequency=true, const bool waterfall=true, - const bool waterfall3d=true, const bool time=true, - const bool constellation=true, + const bool time=true, const bool constellation=true, const bool use_openGL=true); void SetDisplayTitle(const std::string); diff --git a/gr-qtgui/src/lib/qtgui_sink_c.cc b/gr-qtgui/src/lib/qtgui_sink_c.cc index f7704593..c12c451b 100644 --- a/gr-qtgui/src/lib/qtgui_sink_c.cc +++ b/gr-qtgui/src/lib/qtgui_sink_c.cc @@ -64,10 +64,13 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, d_wintype((gr_firdes::win_type)(wintype)), d_center_freq(fc), d_bandwidth(bw), d_name(name), d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall), - d_plotwaterfall3d(plotwaterfall3d), d_plottime(plottime), - d_plotconst(plotconst), + d_plottime(plottime), d_plotconst(plotconst), d_parent(parent) { + if(plotwaterfall3d == true) { + fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); + } + d_main_gui = NULL; pthread_mutex_init(&d_pmutex, NULL); lock(); @@ -141,8 +144,7 @@ qtgui_sink_c::initialize(const bool opengl) d_main_gui->OpenSpectrumWindow(d_parent, d_plotfreq, d_plotwaterfall, - d_plotwaterfall3d, d_plottime, - d_plotconst, + d_plottime, d_plotconst, opengl); // initialize update time to 10 times a second diff --git a/gr-qtgui/src/lib/qtgui_sink_c.h b/gr-qtgui/src/lib/qtgui_sink_c.h index 1f6c2847..2f3cc566 100644 --- a/gr-qtgui/src/lib/qtgui_sink_c.h +++ b/gr-qtgui/src/lib/qtgui_sink_c.h @@ -84,7 +84,7 @@ private: int d_index; gr_complex *d_residbuf; - bool d_plotfreq, d_plotwaterfall, d_plotwaterfall3d, d_plottime, d_plotconst; + bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst; double d_update_time; diff --git a/gr-qtgui/src/lib/qtgui_sink_f.cc b/gr-qtgui/src/lib/qtgui_sink_f.cc index 976b1761..ab4fd082 100644 --- a/gr-qtgui/src/lib/qtgui_sink_f.cc +++ b/gr-qtgui/src/lib/qtgui_sink_f.cc @@ -64,10 +64,13 @@ qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype, d_wintype((gr_firdes::win_type)(wintype)), d_center_freq(fc), d_bandwidth(bw), d_name(name), d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall), - d_plotwaterfall3d(plotwaterfall3d), d_plottime(plottime), - d_plotconst(plotconst), + d_plottime(plottime), d_plotconst(plotconst), d_parent(parent) { + if(plotwaterfall3d == true) { + fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); + } + d_main_gui = NULL; pthread_mutex_init(&d_pmutex, NULL); lock(); @@ -136,8 +139,7 @@ qtgui_sink_f::initialize(const bool opengl) d_main_gui->OpenSpectrumWindow(d_parent, d_plotfreq, d_plotwaterfall, - d_plotwaterfall3d, d_plottime, - d_plotconst, + d_plottime, d_plotconst, opengl); // initialize update time to 10 times a second diff --git a/gr-qtgui/src/lib/qtgui_sink_f.h b/gr-qtgui/src/lib/qtgui_sink_f.h index f603da7b..5b96136f 100644 --- a/gr-qtgui/src/lib/qtgui_sink_f.h +++ b/gr-qtgui/src/lib/qtgui_sink_f.h @@ -82,7 +82,7 @@ private: int d_index; float *d_residbuf; - bool d_plotfreq, d_plotwaterfall, d_plotwaterfall3d, d_plottime, d_plotconst; + bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst; double d_update_time; diff --git a/gr-qtgui/src/lib/spectrumdisplayform.cc b/gr-qtgui/src/lib/spectrumdisplayform.cc index f52a63d1..e0509a29 100644 --- a/gr-qtgui/src/lib/spectrumdisplayform.cc +++ b/gr-qtgui/src/lib/spectrumdisplayform.cc @@ -17,10 +17,6 @@ SpectrumDisplayForm::SpectrumDisplayForm(bool useOpenGL, QWidget* parent) _frequencyDisplayPlot = new FrequencyDisplayPlot(FrequencyPlotDisplayFrame); _waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame); - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - //_waterfall3DDisplayPlot = new Waterfall3DDisplayPlot(Waterfall3DPlotDisplayFrame); - } - _timeDomainDisplayPlot = new TimeDomainDisplayPlot(TimeDomainDisplayFrame); _constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame); _numRealDataPoints = 1024; @@ -38,14 +34,6 @@ SpectrumDisplayForm::SpectrumDisplayForm(bool useOpenGL, QWidget* parent) WaterfallMinimumIntensityWheel->setTickCnt(50); WaterfallMinimumIntensityWheel->setValue(-200); - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - Waterfall3DMaximumIntensityWheel->setRange(-200, 0); - Waterfall3DMaximumIntensityWheel->setTickCnt(50); - Waterfall3DMinimumIntensityWheel->setRange(-200, 0); - Waterfall3DMinimumIntensityWheel->setTickCnt(50); - Waterfall3DMinimumIntensityWheel->setValue(-200); - } - _peakFrequency = 0; _peakAmplitude = -HUGE_VAL; @@ -68,7 +56,6 @@ SpectrumDisplayForm::SpectrumDisplayForm(bool useOpenGL, QWidget* parent) ToggleTabFrequency(false); ToggleTabWaterfall(false); - ToggleTabWaterfall3D(false); ToggleTabTime(false); ToggleTabConstellation(false); @@ -134,11 +121,11 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate const std::complex* complexDataPointsPtr = complexDataPoints+numFFTDataPoints/2; double* realFFTDataPointsPtr = _realFFTDataPoints; - double sumMean, localPeakAmplitude, localPeakFrequency; + double sumMean = 0.0; + double localPeakAmplitude = -HUGE_VAL; + double localPeakFrequency = 0.0; const double fftBinSize = (_stopFrequency-_startFrequency) / static_cast(numFFTDataPoints); - localPeakAmplitude = -HUGE_VAL; - sumMean = 0.0; // Run this twice to perform the fftshift operation on the data here as well std::complex scaleFactor = std::complex((float)numFFTDataPoints); @@ -229,15 +216,6 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate d_update_time, dataTimestamp, spectrumUpdateEvent->getDroppedFFTFrames()); } - /* - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - if( _openGLWaterfall3DFlag == 1 && (tabindex == d_plot_waterfall3d)) { - _waterfall3DDisplayPlot->PlotNewData(_realFFTDataPoints, numFFTDataPoints, - d_update_time, dataTimestamp, - spectrumUpdateEvent->getDroppedFFTFrames()); - } - } - */ } @@ -265,12 +243,6 @@ SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) s.setHeight(WaterfallPlotDisplayFrame->height()); emit _waterfallDisplayPlot->resizeSlot(&s); - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - s.setWidth(Waterfall3DPlotDisplayFrame->width()); - s.setHeight(Waterfall3DPlotDisplayFrame->height()); - //emit _waterfall3DDisplayPlot->resizeSlot(&s); - } - s.setWidth(ConstellationDisplayFrame->width()); s.setHeight(ConstellationDisplayFrame->height()); emit _constellationDisplayPlot->resizeSlot(&s); @@ -289,32 +261,6 @@ SpectrumDisplayForm::customEvent( QEvent * e) waterfallMinimumIntensityChangedCB(WaterfallMinimumIntensityWheel->value()); waterfallMaximumIntensityChangedCB(WaterfallMaximumIntensityWheel->value()); - // If the video card doesn't support OpenGL then don't display the 3D Waterfall - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - waterfall3DMinimumIntensityChangedCB(Waterfall3DMinimumIntensityWheel->value()); - waterfall3DMaximumIntensityChangedCB(Waterfall3DMaximumIntensityWheel->value()); - - // Check for Hardware Acceleration of the OpenGL - /* - if(!_waterfall3DDisplayPlot->format().directRendering()){ - // Only ask this once while the program is running... - if(_openGLWaterfall3DFlag == -1){ - _openGLWaterfall3DFlag = 0; - if(QMessageBox::warning(this, "OpenGL Direct Rendering NOT Supported", "
The system's video card hardware or current drivers do not support direct hardware rendering of the OpenGL modules.

Software rendering is VERY processor intensive.

Do you want to use software rendering?
", QMessageBox::Yes, QMessageBox::No | QMessageBox::Default | QMessageBox::Escape) == QMessageBox::Yes){ - _openGLWaterfall3DFlag = 1; - } - } - } - else{ - _openGLWaterfall3DFlag = 1; - } - */ - } - - if(_openGLWaterfall3DFlag != 1){ - ToggleTabWaterfall3D(false); - } - // Clear any previous display Reset(); } @@ -347,8 +293,6 @@ SpectrumDisplayForm::UpdateGuiTimer() // all of the plots. _frequencyDisplayPlot->canvas()->update(); _waterfallDisplayPlot->canvas()->update(); - //if((QGLFormat::hasOpenGL()) && (_useOpenGL)) - //_waterfall3DDisplayPlot->canvas()->update(); _timeDomainDisplayPlot->canvas()->update(); _constellationDisplayPlot->canvas()->update(); } @@ -437,15 +381,6 @@ SpectrumDisplayForm::SetFrequencyRange(const double newCenterFrequency, _centerFrequency, UseRFFrequenciesCheckBox->isChecked(), units, strunits[iunit]); - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - /* - _waterfall3DDisplayPlot->SetFrequencyRange(_startFrequency, - _stopFrequency, - _centerFrequency, - UseRFFrequenciesCheckBox->isChecked(), - units, strunits[iunit]); - */ - } _timeDomainDisplayPlot->SetSampleRate(_stopFrequency - _startFrequency, units, strtime[iunit]); } @@ -536,9 +471,6 @@ SpectrumDisplayForm::Reset() AverageDataReset(); _waterfallDisplayPlot->Reset(); - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - //_waterfall3DDisplayPlot->Reset(); - } } @@ -613,44 +545,6 @@ SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue ) WaterfallMaximumIntensityWheel->value()); } -void -SpectrumDisplayForm::waterfall3DMaximumIntensityChangedCB( double newValue ) -{ - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - if(newValue > Waterfall3DMinimumIntensityWheel->value()){ - Waterfall3DMaximumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); - } - else{ - Waterfall3DMaximumIntensityWheel->setValue(Waterfall3DMinimumIntensityWheel->value()); - } - - /* - _waterfall3DDisplayPlot->SetIntensityRange(Waterfall3DMinimumIntensityWheel->value(), - Waterfall3DMaximumIntensityWheel->value()); - */ - } -} - - -void -SpectrumDisplayForm::waterfall3DMinimumIntensityChangedCB( double newValue ) -{ - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - if(newValue < Waterfall3DMaximumIntensityWheel->value()){ - Waterfall3DMinimumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); - } - else{ - Waterfall3DMinimumIntensityWheel->setValue(Waterfall3DMaximumIntensityWheel->value()); - } - - /* - _waterfall3DDisplayPlot->SetIntensityRange(Waterfall3DMinimumIntensityWheel->value(), - Waterfall3DMaximumIntensityWheel->value()); - */ - } -} - - void SpectrumDisplayForm::FFTComboBoxSelectedCB( const QString &fftSizeString ) { @@ -676,24 +570,6 @@ SpectrumDisplayForm::WaterfallAutoScaleBtnCB() waterfallMaximumIntensityChangedCB(maximumIntensity); } -void -SpectrumDisplayForm::Waterfall3DAutoScaleBtnCB() -{ - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - double minimumIntensity = _noiseFloorAmplitude - 5; - if(minimumIntensity < Waterfall3DMinimumIntensityWheel->minValue()){ - minimumIntensity = Waterfall3DMinimumIntensityWheel->minValue(); - } - Waterfall3DMinimumIntensityWheel->setValue(minimumIntensity); - double maximumIntensity = _peakAmplitude + 10; - if(maximumIntensity > Waterfall3DMaximumIntensityWheel->maxValue()){ - maximumIntensity = Waterfall3DMaximumIntensityWheel->maxValue(); - } - Waterfall3DMaximumIntensityWheel->setValue(maximumIntensity); - waterfallMaximumIntensityChangedCB(maximumIntensity); - } -} - void SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) { @@ -720,37 +596,6 @@ SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) _waterfallDisplayPlot->SetIntensityColorMapType(newType, lowIntensityColor, highIntensityColor); } -void -SpectrumDisplayForm::Waterfall3DIntensityColorTypeChanged( int newType ) -{ - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - QColor lowIntensityColor; - QColor highIntensityColor; - if(newType == Waterfall3DDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED){ - // Select the Low Intensity Color - lowIntensityColor = _waterfallDisplayPlot->GetUserDefinedLowIntensityColor(); - if(!lowIntensityColor.isValid()){ - lowIntensityColor = Qt::black; - } - 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()){ - highIntensityColor = Qt::white; - } - 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); - */ - } -} - - void SpectrumDisplayForm::ToggleTabFrequency(const bool state) { @@ -781,28 +626,6 @@ SpectrumDisplayForm::ToggleTabWaterfall(const bool state) } } -void -SpectrumDisplayForm::ToggleTabWaterfall3D(const bool state) -{ - if(state == true) { - /* - if((QGLFormat::hasOpenGL()) && (_useOpenGL)) { - if(d_plot_waterfall3d == -1) { - SpectrumTypeTab->addTab(Waterfall3DPage, "3D Waterfall Display"); - d_plot_waterfall3d = SpectrumTypeTab->count()-1; - } - } - */ - SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(Waterfall3DPage)); - d_plot_waterfall3d = -1; - fprintf(stderr, "\nWARNING: The Waterfall3D plot has been disabled until we get it working.\n\n"); - } - else { - SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(Waterfall3DPage)); - d_plot_waterfall3d = -1; - } -} - void SpectrumDisplayForm::ToggleTabTime(const bool state) { diff --git a/gr-qtgui/src/lib/spectrumdisplayform.h b/gr-qtgui/src/lib/spectrumdisplayform.h index bf2af703..80310200 100644 --- a/gr-qtgui/src/lib/spectrumdisplayform.h +++ b/gr-qtgui/src/lib/spectrumdisplayform.h @@ -9,7 +9,6 @@ class SpectrumGUIClass; #include #include #include -#include #include #include #include @@ -54,15 +53,10 @@ public slots: void waterfallMinimumIntensityChangedCB(double); void WaterfallIntensityColorTypeChanged(int); void WaterfallAutoScaleBtnCB(); - void waterfall3DMaximumIntensityChangedCB(double); - void waterfall3DMinimumIntensityChangedCB(double); - void Waterfall3DIntensityColorTypeChanged(int); - 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); @@ -92,7 +86,6 @@ private: QIntValidator* _intValidator; FrequencyDisplayPlot* _frequencyDisplayPlot; WaterfallDisplayPlot* _waterfallDisplayPlot; - Waterfall3DDisplayPlot* _waterfall3DDisplayPlot; TimeDomainDisplayPlot* _timeDomainDisplayPlot; ConstellationDisplayPlot* _constellationDisplayPlot; SpectrumGUIClass* _system; diff --git a/gr-qtgui/src/lib/spectrumdisplayform.ui b/gr-qtgui/src/lib/spectrumdisplayform.ui index 0e652d83..5a23bc8a 100644 --- a/gr-qtgui/src/lib/spectrumdisplayform.ui +++ b/gr-qtgui/src/lib/spectrumdisplayform.ui @@ -467,190 +467,6 @@ - - - 3D Waterfall Display - - - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - Intensity Display: - - - false - - - - - - - - 100 - 16777215 - - - - - Color - - - - - White Hot - - - - - Black Hot - - - - - Incandescent - - - - - User Defined - - - - - - - - - 200 - 0 - - - - true - - - Qt::WheelFocus - - - true - - - 200.000000000000000 - - - 20.000000000000000 - - - 0.000000000000000 - - - - - - - - 100 - 16777215 - - - - 100 dB - - - false - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - - - - - - 0 - 0 - - - - - 80 - 16777215 - - - - - 0 - 0 - - - - Scales the Intensity to the current data extremes. - - - Auto Scale - - - - - - - - 200 - 0 - - - - true - - - 200.000000000000000 - - - 20.000000000000000 - - - 0.000000000000000 - - - - - - - - 100 - 16777215 - - - - -100 dB - - - false - - - - - Time Domain Display @@ -721,7 +537,6 @@ SpectrumGUIClass.h FrequencyDisplayPlot.h WaterfallDisplayPlot.h - Waterfall3DDisplayPlot.h TimeDomainDisplayPlot.h qvalidator.h vector @@ -857,38 +672,6 @@ - - Waterfall3DMaximumIntensityWheel - valueChanged(double) - SpectrumDisplayForm - waterfall3DMaximumIntensityChangedCB(double) - - - 217 - 44 - - - 20 - 20 - - - - - Waterfall3DMinimumIntensityWheel - valueChanged(double) - SpectrumDisplayForm - waterfall3DMinimumIntensityChangedCB(double) - - - 217 - 349 - - - 20 - 20 - - - FFTSizeComboBox activated(QString) diff --git a/gr-qtgui/src/lib/waterfallGlobalData.cc b/gr-qtgui/src/lib/waterfallGlobalData.cc index 0cbef4ec..1ba153f0 100644 --- a/gr-qtgui/src/lib/waterfallGlobalData.cc +++ b/gr-qtgui/src/lib/waterfallGlobalData.cc @@ -3,11 +3,13 @@ #include -#include - -WaterfallData::WaterfallData(const double minimumFrequency, const double maximumFrequency, const uint64_t fftPoints, const unsigned int historyExtent): - QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */, 0 /* Y START */, maximumFrequency - minimumFrequency /* WIDTH */, static_cast(historyExtent)/* HEIGHT */)) - +WaterfallData::WaterfallData(const double minimumFrequency, + const double maximumFrequency, + const uint64_t fftPoints, + const unsigned int historyExtent) + : QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */, 0 /* Y START */, + maximumFrequency - minimumFrequency /* WIDTH */, + static_cast(historyExtent)/* HEIGHT */)) { _intensityRange = QwtDoubleInterval(-200.0, 0.0); @@ -19,17 +21,20 @@ WaterfallData::WaterfallData(const double minimumFrequency, const double maximum Reset(); } -WaterfallData::~WaterfallData(){ +WaterfallData::~WaterfallData() +{ delete[] _spectrumData; } -void WaterfallData::Reset(){ +void WaterfallData::Reset() +{ memset(_spectrumData, 0x0, _fftPoints*_historyLength*sizeof(double)); _numLinesToUpdate = -1; } -void WaterfallData::Copy(const WaterfallData* rhs){ +void WaterfallData::Copy(const WaterfallData* rhs) +{ if((_fftPoints != rhs->GetNumFFTPoints()) || (boundingRect() != rhs->boundingRect()) ){ _fftPoints = rhs->GetNumFFTPoints(); @@ -43,7 +48,10 @@ void WaterfallData::Copy(const WaterfallData* rhs){ setRange(rhs->range()); } -void WaterfallData::ResizeData(const double startFreq, const double stopFreq, const uint64_t fftPoints){ +void WaterfallData::ResizeData(const double startFreq, + const double stopFreq, + const uint64_t fftPoints) +{ if((fftPoints != GetNumFFTPoints()) || (boundingRect().width() != (stopFreq - startFreq)) || (boundingRect().left() != startFreq)){ @@ -57,21 +65,27 @@ void WaterfallData::ResizeData(const double startFreq, const double stopFreq, co Reset(); } -QwtRasterData *WaterfallData::copy() const{ - WaterfallData* returnData = new WaterfallData(boundingRect().left(), boundingRect().right(), _fftPoints, _historyLength); +QwtRasterData *WaterfallData::copy() const +{ + WaterfallData* returnData = new WaterfallData(boundingRect().left(), + boundingRect().right(), + _fftPoints, _historyLength); returnData->Copy(this); return returnData; } -QwtDoubleInterval WaterfallData::range() const{ +QwtDoubleInterval WaterfallData::range() const +{ return _intensityRange; } -void WaterfallData::setRange(const QwtDoubleInterval& newRange){ +void WaterfallData::setRange(const QwtDoubleInterval& newRange) +{ _intensityRange = newRange; } -double WaterfallData::value(double x, double y) const{ +double WaterfallData::value(double x, double y) const +{ double returnValue = 0.0; const unsigned int intY = static_cast((1.0 - (y/boundingRect().height())) * @@ -87,11 +101,14 @@ double WaterfallData::value(double x, double y) const{ return returnValue; } -uint64_t WaterfallData::GetNumFFTPoints()const{ +uint64_t WaterfallData::GetNumFFTPoints() const +{ return _fftPoints; } -void WaterfallData::addFFTData(const double* fftData, const uint64_t fftDataSize, const int droppedFrames){ +void WaterfallData::addFFTData(const double* fftData, + const uint64_t fftDataSize, + const int droppedFrames){ if(fftDataSize == _fftPoints){ int64_t heightOffset = _historyLength - 1 - droppedFrames; uint64_t drawingDroppedFrames = droppedFrames; @@ -104,155 +121,44 @@ void WaterfallData::addFFTData(const double* fftData, const uint64_t fftDataSize // Copy the old data over if any available if(heightOffset > 0){ - memmove( _spectrumData, &_spectrumData[(drawingDroppedFrames+1) * _fftPoints], heightOffset * _fftPoints * sizeof(double)) ; + memmove( _spectrumData, &_spectrumData[(drawingDroppedFrames+1) * _fftPoints], + heightOffset * _fftPoints * sizeof(double)) ; } if(drawingDroppedFrames > 0){ // Fill in zeros data for dropped data - memset(&_spectrumData[heightOffset * _fftPoints], 0x00, static_cast(drawingDroppedFrames) * _fftPoints * sizeof(double)); + memset(&_spectrumData[heightOffset * _fftPoints], 0x00, + static_cast(drawingDroppedFrames) * _fftPoints * sizeof(double)); } // add the new buffer memcpy(&_spectrumData[(_historyLength - 1) * _fftPoints], fftData, _fftPoints*sizeof(double)); - } } -double* WaterfallData::GetSpectrumDataBuffer()const{ +double* WaterfallData::GetSpectrumDataBuffer() const +{ return _spectrumData; } -void WaterfallData::SetSpectrumDataBuffer(const double* newData){ +void WaterfallData::SetSpectrumDataBuffer(const double* newData) +{ memcpy(_spectrumData, newData, _fftPoints * _historyLength * sizeof(double)); } -int WaterfallData::GetNumLinesToUpdate()const{ +int WaterfallData::GetNumLinesToUpdate() const +{ return _numLinesToUpdate; } -void WaterfallData::SetNumLinesToUpdate(const int newNum){ +void WaterfallData::SetNumLinesToUpdate(const int newNum) +{ _numLinesToUpdate = newNum; } -void WaterfallData::IncrementNumLinesToUpdate(){ - _numLinesToUpdate++; -} - -Waterfall3DData::Waterfall3DData(const double minimumFrequency, const double maximumFrequency, const uint64_t fftPoints, const unsigned int historyExtent): - WaterfallData(minimumFrequency, maximumFrequency, fftPoints, historyExtent), Qwt3D::Function(){ - - _floorValue = 0.0; - setMinZ(0.0); - setMaxZ(200.0); - - // Create the dummy mesh data until _ResizeMesh is called - data = new double*[1]; - data[0] = new double[1]; - Qwt3D::Function::setMesh(1,1); - - _ResizeMesh(); -} - -Waterfall3DData::~Waterfall3DData(){ - for ( unsigned i = 0; i < umesh_p; i++){ - delete[] data[i]; - } - delete[] data; - -} - -void Waterfall3DData::ResizeData(const double startFreq, const double stopFreq, const uint64_t fftPoints){ - if((fftPoints != GetNumFFTPoints()) || - (boundingRect().width() != (stopFreq - startFreq)) || - (boundingRect().left() != startFreq)){ - WaterfallData::ResizeData(startFreq, stopFreq, fftPoints); - _ResizeMesh(); - } - - Reset(); -} - -bool Waterfall3DData::create() +void WaterfallData::IncrementNumLinesToUpdate() { - if ((umesh_p<=2) || (vmesh_p<=2) || !plotwidget_p) - return false; - - // Almost the same as the old create, except that here we store our own data buffer in the class rather than re-creating it each time... - - unsigned i,j; - - /* get the data */ - double dx = (maxu_p - minu_p) / (umesh_p - 1); - double dy = (maxv_p - minv_p) / (vmesh_p - 1); - - for (i = 0; i < umesh_p; ++i) - { - for (j = 0; j < vmesh_p; ++j) - { - data[i][j] = operator()(minu_p + i*dx, minv_p + j*dy); - - if (data[i][j] > range_p.maxVertex.z) - data[i][j] = range_p.maxVertex.z; - else if (data[i][j] < range_p.minVertex.z) - data[i][j] = range_p.minVertex.z; - } - } - - Q_ASSERT(plotwidget_p); - if (!plotwidget_p) - { - fprintf(stderr,"Function: no valid Plot3D Widget assigned"); - } - else - { - ((Waterfall3DDisplayPlot*)plotwidget_p)->loadFromData(data, umesh_p, vmesh_p, minu_p, maxu_p, minv_p, maxv_p); - } - - return true; -} - -double Waterfall3DData::operator()(double x, double y){ - return value(x,y) - _floorValue; -} - -double Waterfall3DData::GetFloorValue()const{ - return _floorValue; -} - -void Waterfall3DData::SetFloorValue(const double newValue){ - _floorValue = newValue; -} - -double Waterfall3DData::minZ()const{ - return range_p.minVertex.z; -} - -double Waterfall3DData::maxZ()const{ - return range_p.maxVertex.z; -} - -void Waterfall3DData::setMesh(unsigned int, unsigned int){ - // Do Nothing - printf("Should Not Reach this Function\n"); -} - -void Waterfall3DData::_ResizeMesh(){ - // Clear out the old mesh - for ( unsigned i = 0; i < umesh_p; i++){ - delete[] data[i]; - } - delete[] data; - - Qwt3D::Function::setMesh(static_cast(boundingRect().width()/20.0), _historyLength); - setDomain( boundingRect().left(), static_cast(boundingRect().right()), 0, _historyLength); - - /* allocate some space for the mesh */ - unsigned i; - data = new double* [umesh_p] ; - for ( i = 0; i < umesh_p; i++) - { - data[i] = new double [vmesh_p]; - } + _numLinesToUpdate++; } #endif /* WATERFALL_GLOBAL_DATA_CPP */ diff --git a/gr-qtgui/src/lib/waterfallGlobalData.h b/gr-qtgui/src/lib/waterfallGlobalData.h index 247e0ae9..568b88fa 100644 --- a/gr-qtgui/src/lib/waterfallGlobalData.h +++ b/gr-qtgui/src/lib/waterfallGlobalData.h @@ -5,7 +5,6 @@ #include #include -class Waterfall3DDisplayPlot; class WaterfallData: public QwtRasterData { @@ -46,34 +45,4 @@ private: }; -class Waterfall3DData: public WaterfallData, public Qwt3D::Function -{ -public: - Waterfall3DData(const double, const double, const uint64_t, const unsigned int); - virtual ~Waterfall3DData(); - - virtual void ResizeData(const double, const double, const uint64_t); - - virtual bool create(); - virtual void setMesh(unsigned int columns, unsigned int rows); //!< Sets number of rows and columns. - - virtual double operator()(double x, double y); - - virtual double GetFloorValue()const; - virtual void SetFloorValue(const double); - - virtual double minZ()const; - virtual double maxZ()const; - -protected: - void _ResizeMesh(); - - double** data; - double _floorValue; - -private: - -}; - - #endif /* WATERFALL_GLOBAL_DATA_HPP */