diff options
Diffstat (limited to 'gr-qtgui/lib/FrequencyDisplayPlot.cc')
-rw-r--r-- | gr-qtgui/lib/FrequencyDisplayPlot.cc | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc b/gr-qtgui/lib/FrequencyDisplayPlot.cc index 12835bcd27..41050edfc2 100644 --- a/gr-qtgui/lib/FrequencyDisplayPlot.cc +++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008-2011 Free Software Foundation, Inc. + * Copyright 2008-2011,2014 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -94,6 +94,7 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(int nplots, QWidget* parent) d_min_fft_data = new double[d_numPoints]; d_max_fft_data = new double[d_numPoints]; d_xdata = new double[d_numPoints]; + d_half_freq = false; setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)"); setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0)); @@ -279,8 +280,13 @@ FrequencyDisplayPlot::setFrequencyRange(const double centerfreq, const double bandwidth, const double units, const std::string &strunits) { - double startFreq = (centerfreq - bandwidth/2.0f) / units; - double stopFreq = (centerfreq + bandwidth/2.0f) / units; + double startFreq; + double stopFreq = (centerfreq + bandwidth/2.0f) / units; + if(d_half_freq) + startFreq = 0; + else + startFreq = (centerfreq - bandwidth/2.0f) / units; + d_xdata_multiplier = units; @@ -346,10 +352,13 @@ FrequencyDisplayPlot::plotNewData(const std::vector<double*> dataPoints, const double noiseFloorAmplitude, const double peakFrequency, const double peakAmplitude, const double timeInterval) { + int64_t _npoints_in = d_half_freq ? numDataPoints/2 : numDataPoints; + int64_t _in_index = d_half_freq ? _npoints_in : 0; + if(!d_stop) { if(numDataPoints > 0) { - if(numDataPoints != d_numPoints) { - d_numPoints = numDataPoints; + if(_npoints_in != d_numPoints) { + d_numPoints = _npoints_in; delete[] d_min_fft_data; delete[] d_max_fft_data; @@ -383,9 +392,9 @@ FrequencyDisplayPlot::plotNewData(const std::vector<double*> dataPoints, double bottom=1e20, top=-1e20; for(int n = 0; n < d_nplots; n++) { - memcpy(d_ydata[n], dataPoints[n], numDataPoints*sizeof(double)); + memcpy(d_ydata[n], &(dataPoints[n][_in_index]), _npoints_in*sizeof(double)); - for(int64_t point = 0; point < numDataPoints; point++) { + for(int64_t point = 0; point < _npoints_in; point++) { if(dataPoints[n][point] < d_min_fft_data[point]) { d_min_fft_data[point] = dataPoints[n][point]; } @@ -462,6 +471,15 @@ FrequencyDisplayPlot::setAutoScale(bool state) } void +FrequencyDisplayPlot::setPlotPosHalf(bool half) +{ + d_half_freq = half; + if(half) + d_start_frequency = 0; +} + + +void FrequencyDisplayPlot::setMaxFFTVisible(const bool visibleFlag) { d_max_fft_visible = visibleFlag; @@ -491,7 +509,7 @@ void FrequencyDisplayPlot::_resetXAxisPoints() { double fft_bin_size = (d_stop_frequency - d_start_frequency) - / static_cast<double>(d_numPoints-1); + / static_cast<double>(d_numPoints); double freqValue = d_start_frequency; for(int64_t loc = 0; loc < d_numPoints; loc++) { d_xdata[loc] = freqValue; |