summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrondeau2009-08-10 02:07:55 +0000
committertrondeau2009-08-10 02:07:55 +0000
commitb1fff92b08ccb2d0aecdea56450c79a63ab3178b (patch)
tree6b96cdf505135d16714849da0f2f5691dd8d4828
parent34791dbc3c8ab646b63d8ae6e96972b20fe6fd37 (diff)
downloadgnuradio-b1fff92b08ccb2d0aecdea56450c79a63ab3178b.tar.gz
gnuradio-b1fff92b08ccb2d0aecdea56450c79a63ab3178b.tar.bz2
gnuradio-b1fff92b08ccb2d0aecdea56450c79a63ab3178b.zip
Significantly improved performance of the Qt Gui sinks. This removes a number of redundant loops and memcopies by combining operations and reduces the CPU load greatly to run much more smoothly.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11559 221aa14e-8319-0410-a670-987f0aec2ac5
-rw-r--r--gr-qtgui/src/lib/FrequencyDisplayPlot.cc14
-rw-r--r--gr-qtgui/src/lib/SpectrumGUIClass.cc1
-rw-r--r--gr-qtgui/src/lib/TimeDomainDisplayPlot.cc20
-rw-r--r--gr-qtgui/src/lib/TimeDomainDisplayPlot.h1
-rw-r--r--gr-qtgui/src/lib/qtgui_sink_c.cc91
-rw-r--r--gr-qtgui/src/lib/qtgui_sink_c.h5
-rw-r--r--gr-qtgui/src/lib/qtgui_sink_f.cc92
-rw-r--r--gr-qtgui/src/lib/qtgui_sink_f.h5
-rw-r--r--gr-qtgui/src/lib/spectrumdisplayform.cc38
-rw-r--r--gr-qtgui/src/lib/spectrumdisplayform.h6
-rw-r--r--gr-qtgui/src/lib/spectrumdisplayform.ui72
11 files changed, 184 insertions, 161 deletions
diff --git a/gr-qtgui/src/lib/FrequencyDisplayPlot.cc b/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
index 154c8d234..e299157f5 100644
--- a/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
+++ b/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
@@ -76,7 +76,9 @@ public:
protected:
virtual QwtText trackerText( const QwtDoublePoint& p ) const
{
- QwtText t(QString("%1 %2, %3 dB").arg(p.x(), 0, 'f', GetFrequencyPrecision()).arg( (GetFrequencyPrecision() == 0) ? "Hz" : "kHz").arg(p.y(), 0, 'f', 2));
+ QString strunits = (GetFrequencyPrecision() == 0) ? "Hz" : "kHz";
+ QwtText t(QString("%1 %2, %3 dB").arg(p.x(), 0, 'f',
+ GetFrequencyPrecision()).arg(strunits).arg(p.y(), 0, 'f', 2));
return t;
}
@@ -260,10 +262,11 @@ FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq,
_stopFrequency = stopFreq;
_resetXAxisPoints();
+ double display_units = ceil(log10(units)/2.0);
setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency);
- setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(2));
+ setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(display_units));
setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str()));
- ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(2);
+ ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(display_units);
// Load up the new base zoom settings
_zoomer->setZoomBase();
@@ -339,6 +342,7 @@ FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDat
ClearMaxData();
ClearMinData();
}
+
memcpy(_dataPoints, dataPoints, numDataPoints*sizeof(double));
for(int64_t point = 0; point < numDataPoints; point++){
if(dataPoints[point] < _minFFTPoints[point]){
@@ -369,7 +373,7 @@ void
FrequencyDisplayPlot::ClearMaxData()
{
for(int64_t number = 0; number < _numPoints; number++){
- _maxFFTPoints[number] = _maxYAxis;
+ _maxFFTPoints[number] = _minYAxis;
}
}
@@ -377,7 +381,7 @@ void
FrequencyDisplayPlot::ClearMinData()
{
for(int64_t number = 0; number < _numPoints; number++){
- _minFFTPoints[number] = _minYAxis;
+ _minFFTPoints[number] = _maxYAxis;
}
}
diff --git a/gr-qtgui/src/lib/SpectrumGUIClass.cc b/gr-qtgui/src/lib/SpectrumGUIClass.cc
index f196d7c5f..34062209e 100644
--- a/gr-qtgui/src/lib/SpectrumGUIClass.cc
+++ b/gr-qtgui/src/lib/SpectrumGUIClass.cc
@@ -30,7 +30,6 @@ SpectrumGUIClass::SpectrumGUIClass(const uint64_t maxDataSize,
_startFrequency = newStartFrequency;
_stopFrequency = newStopFrequency;
-#warning SPECIFY THIS LATER...
_windowType = 5;
timespec_reset(&_lastGUIUpdateTime);
diff --git a/gr-qtgui/src/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/src/lib/TimeDomainDisplayPlot.cc
index 42f827d9a..6d8ef6ee4 100644
--- a/gr-qtgui/src/lib/TimeDomainDisplayPlot.cc
+++ b/gr-qtgui/src/lib/TimeDomainDisplayPlot.cc
@@ -44,6 +44,8 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent){
_imagDataPoints = new double[_numPoints];
_xAxisPoints = new double[_numPoints];
+ _zoomer = new TimeDomainDisplayZoomer(canvas());
+
// Disable polygon clipping
QwtPainter::setDeviceClipping(false);
@@ -56,7 +58,7 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent){
canvas()->setPalette(palette);
setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
- setAxisScale(QwtPlot::xBottom, 0, _numPoints);
+ set_xaxis(0, _numPoints);
setAxisTitle(QwtPlot::xBottom, "Sample Number");
setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
@@ -83,7 +85,6 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent){
replot();
- _zoomer = new TimeDomainDisplayZoomer(canvas());
#if QT_VERSION < 0x040000
_zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);
@@ -129,8 +130,17 @@ void
TimeDomainDisplayPlot::set_yaxis(double min, double max)
{
setAxisScale(QwtPlot::yLeft, min, max);
+ _zoomer->setZoomBase();
+}
+
+void
+TimeDomainDisplayPlot::set_xaxis(double min, double max)
+{
+ setAxisScale(QwtPlot::xBottom, min, max);
+ _zoomer->setZoomBase();
}
+
void TimeDomainDisplayPlot::replot(){
const timespec startTime = get_highres_clock();
@@ -146,7 +156,9 @@ void TimeDomainDisplayPlot::replot(){
}
}
-void TimeDomainDisplayPlot::PlotNewData(const double* realDataPoints, const double* imagDataPoints, const int64_t numDataPoints){
+void TimeDomainDisplayPlot::PlotNewData(const double* realDataPoints,
+ const double* imagDataPoints,
+ const int64_t numDataPoints){
if(numDataPoints > 0){
if(numDataPoints != _numPoints){
@@ -162,6 +174,8 @@ void TimeDomainDisplayPlot::PlotNewData(const double* realDataPoints, const doub
_real_plot_curve->setRawData(_xAxisPoints, _realDataPoints, _numPoints);
_imag_plot_curve->setRawData(_xAxisPoints, _imagDataPoints, _numPoints);
+ set_xaxis(0, numDataPoints);
+
_resetXAxisPoints();
}
memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double));
diff --git a/gr-qtgui/src/lib/TimeDomainDisplayPlot.h b/gr-qtgui/src/lib/TimeDomainDisplayPlot.h
index 9c6364af2..56d44539d 100644
--- a/gr-qtgui/src/lib/TimeDomainDisplayPlot.h
+++ b/gr-qtgui/src/lib/TimeDomainDisplayPlot.h
@@ -28,6 +28,7 @@ public:
virtual void replot();
void set_yaxis(double min, double max);
+ void set_xaxis(double min, double max);
protected slots:
void LegendEntryChecked(QwtPlotItem *plotItem, bool on);
diff --git a/gr-qtgui/src/lib/qtgui_sink_c.cc b/gr-qtgui/src/lib/qtgui_sink_c.cc
index b1fd60d34..bfb464119 100644
--- a/gr-qtgui/src/lib/qtgui_sink_c.cc
+++ b/gr-qtgui/src/lib/qtgui_sink_c.cc
@@ -78,8 +78,6 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype,
d_fft = new gri_fft_complex (d_fftsize, true);
- d_fftdata = new gr_complex[d_fftsize];
-
d_index = 0;
d_residbuf = new gr_complex[d_fftsize];
@@ -91,11 +89,19 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype,
qtgui_sink_c::~qtgui_sink_c()
{
delete d_object;
- delete [] d_fftdata;
delete [] d_residbuf;
delete d_fft;
}
+void
+qtgui_sink_c::forecast(int noutput_items, gr_vector_int &ninput_items_required)
+{
+ unsigned int ninputs = ninput_items_required.size();
+ for (unsigned int i = 0; i < ninputs; i++) {
+ ninput_items_required[i] = std::min(d_fftsize, 8191);
+ }
+}
+
void qtgui_sink_c::lock()
{
pthread_mutex_lock(&d_pmutex);
@@ -195,7 +201,7 @@ qtgui_sink_c::set_frequency_axis(double min, double max)
}
void
-qtgui_sink_c::fft(const gr_complex *data_in, int size, gr_complex *data_out)
+qtgui_sink_c::fft(const gr_complex *data_in, int size)
{
if (d_window.size()) {
gr_complex *dst = d_fft->get_inbuf();
@@ -208,20 +214,6 @@ qtgui_sink_c::fft(const gr_complex *data_in, int size, gr_complex *data_out)
}
d_fft->execute (); // compute the fft
-
- for(int i=0; i < size; i++) {
- d_fft->get_outbuf()[i] /= size;
- }
-
- // copy result to our output
- if(d_shift) { // apply a fft shift on the data
- unsigned int len = (unsigned int)(ceil(size/2.0));
- memcpy(&data_out[0], &d_fft->get_outbuf()[len], sizeof(gr_complex)*(size - len));
- memcpy(&data_out[size - len], &d_fft->get_outbuf()[0], sizeof(gr_complex)*len);
- }
- else {
- memcpy(data_out, d_fft->get_outbuf(), sizeof(gr_complex)*size);
- }
}
void
@@ -250,10 +242,6 @@ qtgui_sink_c::fftresize()
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 gr_complex[newfftsize];
@@ -279,7 +267,7 @@ qtgui_sink_c::general_work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- int i=0, j=0;
+ int j=0;
const gr_complex *in = (const gr_complex*)input_items[0];
pthread_mutex_lock(&d_pmutex);
@@ -287,49 +275,36 @@ 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(diff_timespec(currentTime, lastUpdateGUITime) > 0.05) {
+ for(int i=0; i < noutput_items; i+=d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize-d_index;
- if(d_index) {
- int filler = std::min(d_fftsize - d_index, noutput_items);
+ // If we have enough input for one full FFT, do it
+ if(datasize >= resid) {
+ const timespec currentTime = get_highres_clock();
- memcpy(&d_residbuf[d_index], &in[0], sizeof(gr_complex)*filler);
- d_index += filler;
- i = filler;
- j = filler;
- }
-
- if(d_index == d_fftsize) {
+ // Fill up residbuf with d_fftsize number of items
+ memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*resid);
d_index = 0;
- fft(d_residbuf, d_fftsize, d_fftdata);
+
+ j += resid;
+ fft(d_residbuf, 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);
- }
-
- 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);
+ d_main_gui->UpdateWindow(true, d_fft->get_outbuf(), d_fftsize,
+ NULL, 0, (float*)d_residbuf, d_fftsize,
+ 1.0/4.0, currentTime, true);
}
+ // Otherwise, copy what we received into the residbuf for next time
+ else {
+ memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*datasize);
+ d_index += datasize;
+ j += datasize;
+ }
}
pthread_mutex_unlock(&d_pmutex);
- consume_each(noutput_items);
- return noutput_items;
+ consume_each(j);
+ return j;
}
diff --git a/gr-qtgui/src/lib/qtgui_sink_c.h b/gr-qtgui/src/lib/qtgui_sink_c.h
index 1c9d59200..e36c8c9b0 100644
--- a/gr-qtgui/src/lib/qtgui_sink_c.h
+++ b/gr-qtgui/src/lib/qtgui_sink_c.h
@@ -63,6 +63,8 @@ private:
bool use_openGL,
QWidget *parent);
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
// use opengl to force OpenGL on or off
// this might be necessary for sessions over SSH
void initialize(const bool opengl=true);
@@ -78,7 +80,6 @@ private:
bool d_shift;
gri_fft_complex *d_fft;
- gr_complex *d_fftdata;
int d_index;
gr_complex *d_residbuf;
@@ -91,7 +92,7 @@ private:
void windowreset();
void buildwindow();
void fftresize();
- void fft(const gr_complex *data_in, int size, gr_complex *data_out);
+ void fft(const gr_complex *data_in, int size);
public:
~qtgui_sink_c();
diff --git a/gr-qtgui/src/lib/qtgui_sink_f.cc b/gr-qtgui/src/lib/qtgui_sink_f.cc
index 4c526f09f..d0ce24274 100644
--- a/gr-qtgui/src/lib/qtgui_sink_f.cc
+++ b/gr-qtgui/src/lib/qtgui_sink_f.cc
@@ -78,8 +78,6 @@ qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype,
d_fft = new gri_fft_complex (d_fftsize, true);
- d_fftdata = new gr_complex[d_fftsize];
-
d_index = 0;
d_residbuf = new float[d_fftsize];
@@ -91,11 +89,19 @@ qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype,
qtgui_sink_f::~qtgui_sink_f()
{
delete d_object;
- delete [] d_fftdata;
delete [] d_residbuf;
delete d_fft;
}
+void
+qtgui_sink_f::forecast(int noutput_items, gr_vector_int &ninput_items_required)
+{
+ unsigned int ninputs = ninput_items_required.size();
+ for (unsigned int i = 0; i < ninputs; i++) {
+ ninput_items_required[i] = std::min(d_fftsize, 8191);
+ }
+}
+
void qtgui_sink_f::lock()
{
pthread_mutex_lock(&d_pmutex);
@@ -189,7 +195,7 @@ qtgui_sink_f::set_frequency_axis(double min, double max)
}
void
-qtgui_sink_f::fft(const float *data_in, int size, gr_complex *data_out)
+qtgui_sink_f::fft(const float *data_in, int size)
{
if (d_window.size()) {
gr_complex *dst = d_fft->get_inbuf();
@@ -203,20 +209,6 @@ qtgui_sink_f::fft(const float *data_in, int size, gr_complex *data_out)
}
d_fft->execute (); // compute the fft
-
- for(int i=0; i < size; i++) {
- d_fft->get_outbuf()[i] /= size;
- }
-
- // copy result to our output
- if(d_shift) { // apply a fft shift on the data
- unsigned int len = (unsigned int)(ceil(size/2.0));
- memcpy(&data_out[0], &d_fft->get_outbuf()[len], sizeof(gr_complex)*(size - len));
- memcpy(&data_out[size - len], &d_fft->get_outbuf()[0], sizeof(gr_complex)*len);
- }
- else {
- memcpy(data_out, d_fft->get_outbuf(), sizeof(gr_complex)*size);
- }
}
void
@@ -245,10 +237,6 @@ qtgui_sink_f::fftresize()
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];
@@ -274,46 +262,44 @@ qtgui_sink_f::general_work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- int i=0, j=0;
+ int j=0;
const float *in = (const float*)input_items[0];
pthread_mutex_lock(&d_pmutex);
- if(d_index) {
- int filler = std::min(d_fftsize - d_index, noutput_items);
- memcpy(&d_residbuf[d_index], &in[0], sizeof(float)*filler);
- d_index += filler;
- i = filler;
- j = filler;
- }
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
- if(d_index == d_fftsize) {
- d_index = 0;
- fft(d_residbuf, d_fftsize, d_fftdata);
-
- 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, d_fftdata);
+ for(int i=0; i < noutput_items; i+=d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize-d_index;
+
+ // If we have enough input for one full FFT, do it
+ if(datasize >= resid) {
+ const timespec currentTime = get_highres_clock();
- 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);
- }
- }
+ // Fill up residbuf with d_fftsize number of items
+ memcpy(d_residbuf+d_index, &in[j], sizeof(float)*resid);
+ d_index = 0;
- if(noutput_items > j) {
- d_index = noutput_items - j;
- memcpy(d_residbuf, &in[j], sizeof(float)*d_index);
+ j += resid;
+ fft(d_residbuf, d_fftsize);
+
+ d_main_gui->UpdateWindow(true, d_fft->get_outbuf(), d_fftsize,
+ (float*)d_residbuf, d_fftsize, NULL, 0,
+ 1.0/4.0, currentTime, true);
+ }
+ // Otherwise, copy what we received into the residbuf for next time
+ else {
+ memcpy(d_residbuf+d_index, &in[j], sizeof(float)*datasize);
+ d_index += datasize;
+ j += datasize;
+ }
}
pthread_mutex_unlock(&d_pmutex);
- consume_each(noutput_items);
- return noutput_items;
+ consume_each(j);
+ return j;
}
diff --git a/gr-qtgui/src/lib/qtgui_sink_f.h b/gr-qtgui/src/lib/qtgui_sink_f.h
index 4c24b4983..027b89bea 100644
--- a/gr-qtgui/src/lib/qtgui_sink_f.h
+++ b/gr-qtgui/src/lib/qtgui_sink_f.h
@@ -63,6 +63,8 @@ private:
bool use_openGL,
QWidget *parent);
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
void initialize(const bool opengl=true);
int d_fftsize;
@@ -76,7 +78,6 @@ private:
bool d_shift;
gri_fft_complex *d_fft;
- gr_complex *d_fftdata;
int d_index;
float *d_residbuf;
@@ -89,7 +90,7 @@ private:
void windowreset();
void buildwindow();
void fftresize();
- void fft(const float *data_in, int size, gr_complex *data_out);
+ void fft(const float *data_in, int size);
public:
~qtgui_sink_f();
diff --git a/gr-qtgui/src/lib/spectrumdisplayform.cc b/gr-qtgui/src/lib/spectrumdisplayform.cc
index 427e70a27..36097d975 100644
--- a/gr-qtgui/src/lib/spectrumdisplayform.cc
+++ b/gr-qtgui/src/lib/spectrumdisplayform.cc
@@ -110,6 +110,7 @@ SpectrumDisplayForm::setSystem( SpectrumGUIClass * newSystem,
void
SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdateEvent)
{
+ //_lastSpectrumEvent = (SpectrumUpdateEvent)(*spectrumUpdateEvent);
const std::complex<float>* complexDataPoints = spectrumUpdateEvent->getFFTPoints();
const uint64_t numFFTDataPoints = spectrumUpdateEvent->getNumFFTDataPoints();
const double* realTimeDomainDataPoints = spectrumUpdateEvent->getRealTimeDomainPoints();
@@ -125,23 +126,34 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate
ResizeBuffers(numFFTDataPoints, numTimeDomainDataPoints);
// Calculate the Magnitude of the complex point
- const std::complex<float>* complexDataPointsPtr = complexDataPoints;
+ const std::complex<float>* complexDataPointsPtr = complexDataPoints+numFFTDataPoints/2;
double* realFFTDataPointsPtr = _realFFTDataPoints;
- for(uint64_t point = 0; point < numFFTDataPoints; point++){
+
+ // Run this twice to perform the fftshift operation on the data here as well
+ for(uint64_t point = 0; point < numFFTDataPoints/2; point++){
// Calculate dBm
// 50 ohm load assumption
// 10 * log10 (v^2 / (2 * 50.0 * .001)) = 10 * log10( v^2 * 10)
// 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);
+
+ // perform scaling here
+ std::complex<float> pt = (*complexDataPointsPtr) / std::complex<float>((float)numFFTDataPoints);
+ *realFFTDataPointsPtr = 10.0*log10((pt.real() * pt.real() + pt.imag()*pt.imag()) + 1e-20);
+
+ complexDataPointsPtr++;
+ realFFTDataPointsPtr++;
+ }
+
+ // This loop takes the first half of the input data and puts it in the second half of the plotted data
+ complexDataPointsPtr = complexDataPoints;
+ for(uint64_t point = 0; point < numFFTDataPoints/2; point++){
+ std::complex<float> pt = (*complexDataPointsPtr) / std::complex<float>((float)numFFTDataPoints);
+ *realFFTDataPointsPtr = 10.0*log10((pt.real() * pt.real() + pt.imag()*pt.imag()) + 1e-20);
complexDataPointsPtr++;
realFFTDataPointsPtr++;
}
-
- int tabindex = SpectrumTypeTab->currentIndex();
// Don't update the averaging history if this is repeated data
if(!repeatDataFlag){
@@ -157,7 +169,8 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate
for(uint64_t number = 0; number < numFFTDataPoints; number++){
// find peak
if(_realFFTDataPoints[number] > _peakAmplitude){
- _peakFrequency = (static_cast<float>(number) * fft_bin_size); // Calculate the frequency relative to the local bw, adjust for _startFrequency later
+ // Calculate the frequency relative to the local bw, adjust for _startFrequency later
+ _peakFrequency = (static_cast<float>(number) * fft_bin_size);
_peakAmplitude = _realFFTDataPoints[number];
// _peakBin = number;
}
@@ -187,6 +200,7 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate
}
if(lastOfMultipleUpdatesFlag){
+ int tabindex = SpectrumTypeTab->currentIndex();
if(tabindex == d_plot_fft) {
_frequencyDisplayPlot->PlotNewData(_averagedValues, numFFTDataPoints,
_noiseFloorAmplitude, _peakFrequency,
@@ -219,6 +233,7 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate
}
}
+
// Tell the system the GUI has been updated
if(_systemSpecifiedFlag){
_system->SetLastGUIUpdateTime(generatedTimestamp);
@@ -449,6 +464,13 @@ SpectrumDisplayForm::MaxHoldResetBtn_clicked()
void
+SpectrumDisplayForm::TabChanged(int index)
+{
+ _frequencyDisplayPlot->replot();
+
+}
+
+void
SpectrumDisplayForm::PowerLineEdit_textChanged( const QString &valueString )
{
if(_systemSpecifiedFlag){
diff --git a/gr-qtgui/src/lib/spectrumdisplayform.h b/gr-qtgui/src/lib/spectrumdisplayform.h
index bf8023209..dbbf2567e 100644
--- a/gr-qtgui/src/lib/spectrumdisplayform.h
+++ b/gr-qtgui/src/lib/spectrumdisplayform.h
@@ -41,6 +41,8 @@ public slots:
void MinHoldCheckBox_toggled( bool newState );
void MinHoldResetBtn_clicked();
void MaxHoldResetBtn_clicked();
+ void TabChanged(int index);
+
void PowerLineEdit_textChanged( const QString& valueString );
void SetFrequencyRange( const double newCenterFrequency,
const double newStartFrequency,
@@ -99,7 +101,9 @@ private:
double _peakAmplitude;
static int _openGLWaterfall3DFlag;
double _stopFrequency;
-
+
+ //SpectrumUpdateEvent _lastSpectrumEvent;
+
// whether or not to use a particular display
int d_plot_fft;
int d_plot_waterfall;
diff --git a/gr-qtgui/src/lib/spectrumdisplayform.ui b/gr-qtgui/src/lib/spectrumdisplayform.ui
index 96096030d..9324f150b 100644
--- a/gr-qtgui/src/lib/spectrumdisplayform.ui
+++ b/gr-qtgui/src/lib/spectrumdisplayform.ui
@@ -729,8 +729,8 @@
<slot>MaxHoldCheckBox_toggled(bool)</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>22</x>
+ <y>324</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -745,8 +745,8 @@
<slot>MaxHoldResetBtn_clicked()</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>107</x>
+ <y>324</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -761,8 +761,8 @@
<slot>MinHoldCheckBox_toggled(bool)</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>22</x>
+ <y>349</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -777,8 +777,8 @@
<slot>MinHoldResetBtn_clicked()</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>107</x>
+ <y>349</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -793,8 +793,8 @@
<slot>AvgLineEdit_textChanged(QString)</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>552</x>
+ <y>344</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -809,8 +809,8 @@
<slot>PowerLineEdit_textChanged(QString)</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>482</x>
+ <y>344</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -857,8 +857,8 @@
<slot>waterfallMaximumIntensityChangedCB(double)</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>217</x>
+ <y>44</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -873,8 +873,8 @@
<slot>waterfallMinimumIntensityChangedCB(double)</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>217</x>
+ <y>349</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -889,8 +889,8 @@
<slot>waterfall3DMaximumIntensityChangedCB(double)</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>217</x>
+ <y>44</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -905,8 +905,8 @@
<slot>waterfall3DMinimumIntensityChangedCB(double)</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>217</x>
+ <y>349</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -937,8 +937,8 @@
<slot>WaterfallAutoScaleBtnCB()</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>22</x>
+ <y>349</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -953,8 +953,8 @@
<slot>Waterfall3DAutoScaleBtnCB()</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>22</x>
+ <y>349</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -969,8 +969,8 @@
<slot>WaterfallIntensityColorTypeChanged(int)</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>92</x>
+ <y>44</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -985,8 +985,8 @@
<slot>Waterfall3DIntensityColorTypeChanged(int)</slot>
<hints>
<hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
+ <x>92</x>
+ <y>44</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
@@ -994,5 +994,21 @@
</hint>
</hints>
</connection>
+ <connection>
+ <sender>SpectrumTypeTab</sender>
+ <signal>currentChanged(int)</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>TabChanged(int)</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>314</x>
+ <y>189</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>316</x>
+ <y>217</y>
+ </hint>
+ </hints>
+ </connection>
</connections>
</ui>