[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/04: qtgui: Fix Y-Axis timescale issues o
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/04: qtgui: Fix Y-Axis timescale issues on gr_spectrogram_plot/gr_spectrogram_plot_* by adding a function to set the time per fft. Scale should also update when a new FFT size or sample rate is entered via the GUI |
Date: |
Sun, 4 Jan 2015 20:47:53 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 3ee2c52ccb27b54bf626721001512f6013b648c3
Author: Paul Garver <address@hidden>
Date: Tue Dec 2 13:04:25 2014 -0500
qtgui: Fix Y-Axis timescale issues on
gr_spectrogram_plot/gr_spectrogram_plot_* by adding a function to set the time
per fft. Scale should also update when a new FFT size or sample rate is
entered via the GUI
---
gr-qtgui/apps/plot_form.py | 1 +
gr-qtgui/apps/plot_spectrogram_base.py | 2 ++
gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h | 1 +
gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h | 1 +
.../include/gnuradio/qtgui/waterfalldisplayform.h | 4 ++++
gr-qtgui/lib/WaterfallDisplayPlot.cc | 4 ++--
gr-qtgui/lib/waterfall_sink_c_impl.cc | 6 ++++++
gr-qtgui/lib/waterfall_sink_c_impl.h | 1 +
gr-qtgui/lib/waterfall_sink_f_impl.cc | 6 ++++++
gr-qtgui/lib/waterfall_sink_f_impl.h | 1 +
gr-qtgui/lib/waterfalldisplayform.cc | 25 ++++++++++++++++++++--
11 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/gr-qtgui/apps/plot_form.py b/gr-qtgui/apps/plot_form.py
index 75e39ec..931565b 100644
--- a/gr-qtgui/apps/plot_form.py
+++ b/gr-qtgui/apps/plot_form.py
@@ -359,6 +359,7 @@ class plot_form(QtGui.QWidget):
sr = self.samp_rate_edit.text().toDouble()[0]
fr = self.freq_edit.text().toDouble()[0]
self.top_block.gui_snk.set_frequency_range(fr, sr)
+ self.top_block._samp_rate = sr
self.top_block.reset(self.top_block._start,
self.top_block._nsamps)
diff --git a/gr-qtgui/apps/plot_spectrogram_base.py
b/gr-qtgui/apps/plot_spectrogram_base.py
index 26c336e..b252bb8 100644
--- a/gr-qtgui/apps/plot_spectrogram_base.py
+++ b/gr-qtgui/apps/plot_spectrogram_base.py
@@ -100,6 +100,7 @@ class plot_base(gr.top_block):
self.connect(s, (self.gui_snk, i+1))
self.gui_snk.set_update_time(0);
+ self.gui_snk.set_time_per_fft(self._psd_size/self._samp_rate)
self.gui_snk.enable_menu(False)
self.gui_snk.set_fft_average(self._avg)
@@ -126,6 +127,7 @@ class plot_base(gr.top_block):
self.stop()
self.wait()
self.gui_snk.clear_data()
+ self.gui_snk.set_time_per_fft(self._psd_size/self._samp_rate)
self._start = newstart
self._nsamps = newnsamps
diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h
b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h
index bf73db3..9229682 100644
--- a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h
+++ b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h
@@ -109,6 +109,7 @@ namespace gr {
virtual void set_fft_size(const int fftsize) = 0;
virtual int fft_size() const = 0;
+ virtual void set_time_per_fft(const double t) = 0;
virtual void set_fft_average(const float fftavg) = 0;
virtual float fft_average() const = 0;
virtual void set_fft_window(const gr::filter::firdes::win_type win) = 0;
diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
index 4570ef9..0bbd7e0 100644
--- a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
+++ b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
@@ -108,6 +108,7 @@ namespace gr {
virtual void set_fft_size(const int fftsize) = 0;
virtual int fft_size() const = 0;
+ virtual void set_time_per_fft(const double t) = 0;
virtual void set_fft_average(const float fftavg) = 0;
virtual float fft_average() const = 0;
virtual void set_fft_window(const gr::filter::firdes::win_type win) = 0;
diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h
b/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h
index e885a52..10378d4 100644
--- a/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h
+++ b/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h
@@ -46,6 +46,7 @@ class WaterfallDisplayForm : public DisplayForm
WaterfallDisplayPlot* getPlot();
int getFFTSize() const;
+ double getTimePerFFT();
float getFFTAverage() const;
gr::filter::firdes::win_type getFFTWindowType() const;
@@ -87,6 +88,8 @@ public slots:
void autoScale(bool en=false);
void setPlotPosHalf(bool half);
+ void setTimePerFFT(double t);
+ void setUpdateTime(double t);
private slots:
void newData(const QEvent *updateEvent);
@@ -97,6 +100,7 @@ private:
double d_samp_rate, d_center_freq;
int d_fftsize;
+ double d_time_per_fft;
float d_fftavg;
gr::filter::firdes::win_type d_fftwintype;
double d_units;
diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc
b/gr-qtgui/lib/WaterfallDisplayPlot.cc
index 86724fe..ef1ec3b 100644
--- a/gr-qtgui/lib/WaterfallDisplayPlot.cc
+++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc
@@ -62,7 +62,7 @@ public:
virtual QwtText label(double value) const
{
double secs = double(value * getSecondsPerLine());
- return QwtText(QString("").sprintf("%.1f", secs));
+ return QwtText(QString("").sprintf("%.2e", secs));
}
virtual void initiateUpdate()
@@ -119,7 +119,7 @@ protected:
QwtText t(QString("%1 %2, %3 s")
.arg(dp.x(), 0, 'f', getFrequencyPrecision())
.arg(d_unitType.c_str())
- .arg(secs, 0, 'f', 2));
+ .arg(secs, 0, 'e', 2));
return t;
}
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.cc
b/gr-qtgui/lib/waterfall_sink_c_impl.cc
index 5e39352..a9a2d6c 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.cc
@@ -458,6 +458,12 @@ namespace gr {
}
}
+ void
+ waterfall_sink_c_impl::set_time_per_fft(double t)
+ {
+ d_main_gui->setTimePerFFT(t);
+ }
+
int
waterfall_sink_c_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.h
b/gr-qtgui/lib/waterfall_sink_c_impl.h
index d0e7eb1..6ab09bd 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.h
@@ -106,6 +106,7 @@ namespace gr {
void set_intensity_range(const double min, const double max);
void set_update_time(double t);
+ void set_time_per_fft(double t);
void set_title(const std::string &title);
void set_line_label(int which, const std::string &label);
void set_line_alpha(int which, double alpha);
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.cc
b/gr-qtgui/lib/waterfall_sink_f_impl.cc
index 0f7f9e0..0c1fbbf 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.cc
@@ -465,6 +465,12 @@ namespace gr {
}
}
}
+
+ void
+ waterfall_sink_f_impl::set_time_per_fft(double t)
+ {
+ d_main_gui->setTimePerFFT(t);
+ }
int
waterfall_sink_f_impl::work(int noutput_items,
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.h
b/gr-qtgui/lib/waterfall_sink_f_impl.h
index ca6e3f4..2710f30 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.h
@@ -106,6 +106,7 @@ namespace gr {
void set_intensity_range(const double min, const double max);
void set_update_time(double t);
+ void set_time_per_fft(double t);
void set_title(const std::string &title);
void set_line_label(int which, const std::string &label);
void set_line_alpha(int which, double alpha);
diff --git a/gr-qtgui/lib/waterfalldisplayform.cc
b/gr-qtgui/lib/waterfalldisplayform.cc
index c1dd8f7..9f87504 100644
--- a/gr-qtgui/lib/waterfalldisplayform.cc
+++ b/gr-qtgui/lib/waterfalldisplayform.cc
@@ -48,7 +48,7 @@ WaterfallDisplayForm::WaterfallDisplayForm(int nplots,
QWidget* parent)
d_clicked = false;
d_clicked_freq = 0;
-
+ d_time_per_fft = 0;
// We don't use the normal menus that are part of the displayform.
// Clear them out to get rid of their resources.
for(int i = 0; i < nplots; i++) {
@@ -138,7 +138,7 @@ WaterfallDisplayForm::newData(const QEvent *updateEvent)
d_max_val = *max_val;
}
- getPlot()->plotNewData(dataPoints, numDataPoints, d_update_time,
dataTimestamp, 0);
+ getPlot()->plotNewData(dataPoints, numDataPoints, d_time_per_fft,
dataTimestamp, 0);
}
void
@@ -337,3 +337,24 @@ WaterfallDisplayForm::setPlotPosHalf(bool half)
getPlot()->setPlotPosHalf(half);
getPlot()->replot();
}
+
+void
+WaterfallDisplayForm::setTimePerFFT(double t)
+{
+ d_time_per_fft = t;
+}
+
+double WaterfallDisplayForm::getTimePerFFT()
+{
+ return d_time_per_fft;
+}
+// Override displayform SetUpdateTime() to set FFT time
+void
+WaterfallDisplayForm::setUpdateTime(double t)
+{
+ d_update_time = t;
+ // Assume times are equal unless explictly told by setTimePerFFT()
+ // This is the case when plotting using gr_spectrogram_plot
+ d_time_per_fft = t;
+}
+