commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 14/16: qtgui: waterfall plots


From: git
Subject: [Commit-gnuradio] [gnuradio] 14/16: qtgui: waterfall plots
Date: Tue, 21 Jul 2015 19:27: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 a73b7232ae7cb40b44891a8a70fd3e8c6bd52f3c
Author: Tom Rondeau <address@hidden>
Date:   Tue Jul 21 12:52:08 2015 -0400

    qtgui: waterfall plots
    
    Some bug fixes and safety features. Setting up to allow changing the
    number of rows plotted, though not yet exposed.
---
 .../include/gnuradio/qtgui/WaterfallDisplayPlot.h  |  4 ++
 gr-qtgui/lib/WaterfallDisplayPlot.cc               | 45 +++++++++++++-------
 gr-qtgui/lib/waterfall_sink_c_impl.cc              | 43 +++++++++----------
 gr-qtgui/lib/waterfall_sink_c_impl.h               |  1 +
 gr-qtgui/lib/waterfall_sink_f_impl.cc              | 49 +++++++++++-----------
 gr-qtgui/lib/waterfall_sink_f_impl.h               |  1 +
 6 files changed, 82 insertions(+), 61 deletions(-)

diff --git a/gr-qtgui/include/gnuradio/qtgui/WaterfallDisplayPlot.h 
b/gr-qtgui/include/gnuradio/qtgui/WaterfallDisplayPlot.h
index 42f252c..287f1cf 100644
--- a/gr-qtgui/include/gnuradio/qtgui/WaterfallDisplayPlot.h
+++ b/gr-qtgui/include/gnuradio/qtgui/WaterfallDisplayPlot.h
@@ -90,6 +90,8 @@ public:
   int  getAlpha(int which);
   void setAlpha(int which, int alpha);
 
+  int getNumRows() const;
+
 public slots:
   void setIntensityColorMapType(const int, const int, const QColor, const 
QColor);
   void setIntensityColorMapType1(int);
@@ -99,6 +101,7 @@ public slots:
   void disableLegend();
   void enableLegend();
   void enableLegend(bool en);
+  void setNumRows(int nrows);
 
 signals:
   void updatedLowerIntensityLevel(const double);
@@ -113,6 +116,7 @@ private:
   int    d_xaxis_multiplier;
   bool   d_half_freq;
   bool   d_legend_enabled;
+  int    d_nrows;
 
   std::vector<WaterfallData*> d_data;
 
diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc 
b/gr-qtgui/lib/WaterfallDisplayPlot.cc
index 111374c..d023bc1 100644
--- a/gr-qtgui/lib/WaterfallDisplayPlot.cc
+++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc
@@ -141,6 +141,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(int nplots, 
QWidget* parent)
   d_numPoints = 0;
   d_half_freq = false;
   d_legend_enabled = true;
+  d_nrows = 200;
 
   setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
   setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0));
@@ -150,7 +151,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(int nplots, 
QWidget* parent)
 
   for(int i = 0; i < d_nplots; i++) {
     d_data.push_back(new WaterfallData(d_start_frequency, d_stop_frequency,
-                                      d_numPoints, 200));
+                                      d_numPoints, d_nrows));
 
 #if QWT_VERSION < 0x060000
     d_spectrogram.push_back(new PlotWaterfall(d_data[i], "Spectrogram"));
@@ -283,12 +284,12 @@ WaterfallDisplayPlot::plotNewData(const 
std::vector<double*> dataPoints,
 {
     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 && timestamp == 0){
-            d_numPoints = numDataPoints/200;
+            d_numPoints = numDataPoints/d_nrows;
             resetAxis();
-            
+
             //you got an entire waterfall plot, just plot it
             for(int i = 0; i < d_nplots; i++) {
                 d_data[i]->setSpectrumDataBuffer(dataPoints[i]);
@@ -296,41 +297,41 @@ WaterfallDisplayPlot::plotNewData(const 
std::vector<double*> dataPoints,
                 d_spectrogram[i]->invalidateCache();
                 d_spectrogram[i]->itemChanged();
             }
-            
+
             QwtTimeScaleDraw* timeScale = 
(QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
             timeScale->setSecondsPerLine(timePerFFT);
             timeScale->setZeroTime(timestamp);
             timeScale->initiateUpdate();
-            
+
             ((WaterfallZoomer*)d_zoomer)->setSecondsPerLine(timePerFFT);
             ((WaterfallZoomer*)d_zoomer)->setZeroTime(timestamp);
             replot();
         }
-        
-        
-        
+
+
+
         else if(numDataPoints > 0) {
             if(_npoints_in != d_numPoints) {
                 d_numPoints = _npoints_in;
                 resetAxis();
-                
+
                 for(int i = 0; i < d_nplots; i++) {
                     d_spectrogram[i]->invalidateCache();
                     d_spectrogram[i]->itemChanged();
                 }
-                
+
                 if(isVisible()) {
                     replot();
                 }
             }
-            
+
             QwtTimeScaleDraw* timeScale = 
(QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
             timeScale->setSecondsPerLine(timePerFFT);
             timeScale->setZeroTime(timestamp);
-            
+
             ((WaterfallZoomer*)d_zoomer)->setSecondsPerLine(timePerFFT);
             ((WaterfallZoomer*)d_zoomer)->setZeroTime(timestamp);
-            
+
             for(int i = 0; i < d_nplots; i++) {
                 d_data[i]->addFFTData(&(dataPoints[i][_in_index]),
                                       _npoints_in, droppedFrames);
@@ -338,8 +339,8 @@ WaterfallDisplayPlot::plotNewData(const 
std::vector<double*> dataPoints,
                 d_spectrogram[i]->invalidateCache();
                 d_spectrogram[i]->itemChanged();
             }
-            
-            replot(); 
+
+            replot();
         }
     }
 }
@@ -579,6 +580,12 @@ WaterfallDisplayPlot::setAlpha(int which, int alpha)
   d_spectrogram[which]->setAlpha(alpha);
 }
 
+int
+WaterfallDisplayPlot::getNumRows() const
+{
+  return d_nrows;
+}
+
 void
 WaterfallDisplayPlot::_updateIntensityRangeDisplay()
 {
@@ -653,6 +660,12 @@ WaterfallDisplayPlot::enableLegend(bool en)
 }
 
 void
+WaterfallDisplayPlot::setNumRows(int nrows)
+{
+  d_nrows = nrows;
+}
+
+void
 WaterfallDisplayPlot::setPlotPosHalf(bool half)
 {
   d_half_freq = half;
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.cc 
b/gr-qtgui/lib/waterfall_sink_c_impl.cc
index 6b0f2de..2c4045a 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.cc
@@ -60,7 +60,7 @@ namespace gr {
        d_fftsize(fftsize), d_fftavg(1.0),
        d_wintype((filter::firdes::win_type)(wintype)),
        d_center_freq(fc), d_bandwidth(bw), d_name(name),
-       d_nconnections(nconnections), d_parent(parent)
+       d_nconnections(nconnections), d_nrows(200), d_parent(parent)
     {
       // Required now for Qt; argc must be greater than 0 and argv
       // must have at least one valid character. Must be valid through
@@ -70,18 +70,6 @@ namespace gr {
       d_argv = new char;
       d_argv[0] = '\0';
 
-      // setup output message port to post frequency when display is
-      // double-clicked
-      message_port_register_out(pmt::mp("freq"));
-      message_port_register_in(pmt::mp("freq"));
-      set_msg_handler(pmt::mp("freq"),
-                      boost::bind(&waterfall_sink_c_impl::handle_set_freq, 
this, _1));
-
-      // setup PDU handling input port
-      message_port_register_in(pmt::mp("pdus"));
-      set_msg_handler(pmt::mp("pdus"),
-                      boost::bind(&waterfall_sink_c_impl::handle_pdus, this, 
_1));
-
       d_main_gui = NULL;
 
       // Perform fftshift operation;
@@ -106,15 +94,27 @@ namespace gr {
 
       
d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
                                                      volk_get_alignment()));
-      d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*200,
+      d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*d_nrows,
                                           volk_get_alignment());
       d_magbufs.push_back(d_pdu_magbuf);
-      memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*200);
+      memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*d_nrows);
       memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(gr_complex));
 
       buildwindow();
 
       initialize();
+
+      // setup output message port to post frequency when display is
+      // double-clicked
+      message_port_register_out(pmt::mp("freq"));
+      message_port_register_in(pmt::mp("freq"));
+      set_msg_handler(pmt::mp("freq"),
+                      boost::bind(&waterfall_sink_c_impl::handle_set_freq, 
this, _1));
+
+      // setup PDU handling input port
+      message_port_register_in(pmt::mp("pdus"));
+      set_msg_handler(pmt::mp("pdus"),
+                      boost::bind(&waterfall_sink_c_impl::handle_pdus, this, 
_1));
     }
 
     waterfall_sink_c_impl::~waterfall_sink_c_impl()
@@ -446,9 +446,9 @@ namespace gr {
 
         
d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
                                                        volk_get_alignment()));
-        d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*200, 
volk_get_alignment());
+        d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*d_nrows, 
volk_get_alignment());
         d_magbufs.push_back(d_pdu_magbuf);
-        memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*200);
+        memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*d_nrows);
         memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(gr_complex));
 
         // Set new fft size and reset buffer index
@@ -584,7 +584,7 @@ namespace gr {
           throw std::runtime_error("waterfall sink: unknown data type of 
samples; must be complex.");
         }
 
-        int stride = (len - d_fftsize)/199;
+        int stride = (len - d_fftsize)/d_nrows;
 
         set_time_per_fft(1.0/d_bandwidth * stride);
         std::ostringstream title("");
@@ -595,9 +595,10 @@ namespace gr {
         windowreset();
         check_clicked();
 
-        for(size_t i=0; j < 200; i+=stride) {
+        for(size_t i=0; j < d_nrows; i+=stride) {
 
-          memcpy(d_residbufs[d_nconnections], &in[j * stride], 
sizeof(gr_complex)*d_fftsize);
+          memcpy(d_residbufs[d_nconnections], &in[j * stride],
+                 sizeof(gr_complex)*d_fftsize);
 
           fft(d_fbuf, d_residbufs[d_nconnections], d_fftsize);
           for(int x = 0; x < d_fftsize; x++) {
@@ -610,7 +611,7 @@ namespace gr {
         //update gui per-pdu
         d_qApplication->postEvent(d_main_gui,
                                   new WaterfallUpdateEvent(d_magbufs,
-                                                           d_fftsize*200,
+                                                           d_fftsize*d_nrows,
                                                            0));
 
       }
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.h 
b/gr-qtgui/lib/waterfall_sink_c_impl.h
index 2c5e72c..5fe3574 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.h
@@ -47,6 +47,7 @@ namespace gr {
       double d_bandwidth;
       std::string d_name;
       int d_nconnections;
+      int d_nrows;
 
       bool d_shift;
       fft::fft_complex *d_fft;
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.cc 
b/gr-qtgui/lib/waterfall_sink_f_impl.cc
index 3f893b8..d8ee567 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.cc
@@ -59,7 +59,8 @@ namespace gr {
        d_fftsize(fftsize), d_fftavg(1.0),
        d_wintype((filter::firdes::win_type)(wintype)),
        d_center_freq(fc), d_bandwidth(bw), d_name(name),
-       d_nconnections(nconnections), d_parent(parent)
+       d_nconnections(nconnections), d_nrows(200),
+        d_parent(parent)
     {
       // Required now for Qt; argc must be greater than 0 and argv
       // must have at least one valid character. Must be valid through
@@ -69,18 +70,6 @@ namespace gr {
       d_argv = new char;
       d_argv[0] = '\0';
 
-      // setup output message port to post frequency when display is
-      // double-clicked
-      message_port_register_out(pmt::mp("freq"));
-      message_port_register_in(pmt::mp("freq"));
-      set_msg_handler(pmt::mp("freq"),
-                      boost::bind(&waterfall_sink_f_impl::handle_set_freq, 
this, _1));
-
-      // setup PDU handling input port
-      message_port_register_in(pmt::mp("pdus"));
-      set_msg_handler(pmt::mp("pdus"),
-                      boost::bind(&waterfall_sink_f_impl::handle_pdus, this, 
_1));
-
       d_main_gui = NULL;
 
       // Perform fftshift operation;
@@ -105,15 +94,27 @@ namespace gr {
 
       d_residbufs.push_back((float*)volk_malloc(d_fftsize*sizeof(float),
                                                 volk_get_alignment()));
-      d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*200,
+      d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*d_nrows,
                                           volk_get_alignment());
       d_magbufs.push_back(d_pdu_magbuf);
-      memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*200);
+      memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*d_nrows);
       memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(float));
 
       buildwindow();
 
       initialize();
+
+      // setup output message port to post frequency when display is
+      // double-clicked
+      message_port_register_out(pmt::mp("freq"));
+      message_port_register_in(pmt::mp("freq"));
+      set_msg_handler(pmt::mp("freq"),
+                      boost::bind(&waterfall_sink_f_impl::handle_set_freq, 
this, _1));
+
+      // setup PDU handling input port
+      message_port_register_in(pmt::mp("pdus"));
+      set_msg_handler(pmt::mp("pdus"),
+                      boost::bind(&waterfall_sink_f_impl::handle_pdus, this, 
_1));
     }
 
     waterfall_sink_f_impl::~waterfall_sink_f_impl()
@@ -453,10 +454,11 @@ namespace gr {
 
         d_residbufs.push_back((float*)volk_malloc(d_fftsize*sizeof(float),
                                                   volk_get_alignment()));
-        d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*200, 
volk_get_alignment());
+        d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*d_nrows,
+                                            volk_get_alignment());
         d_magbufs.push_back(d_pdu_magbuf);
-        memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*200);
-        memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(gr_complex));
+        memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*d_nrows);
+        memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(float));
 
        // Set new fft size and reset buffer index
        // (throws away any currently held data, but who cares?)
@@ -591,7 +593,7 @@ namespace gr {
           throw std::runtime_error("waterfall sink: unknown data type of 
samples; must be float.");
         }
 
-        int stride = (len - d_fftsize)/199;
+        int stride = (len - d_fftsize)/(d_nrows-1);
 
         set_time_per_fft(1.0/d_bandwidth * stride);
         std::ostringstream title("");
@@ -602,24 +604,23 @@ namespace gr {
         windowreset();
         check_clicked();
 
-        for(size_t i=0; j < 200; i+=stride) {
+        for(size_t i=0; j < d_nrows; i+=stride) {
 
-          memcpy(d_residbufs[d_nconnections], &in[j * stride], 
sizeof(gr_complex)*d_fftsize);
+          memcpy(d_residbufs[d_nconnections], &in[j * stride],
+                 sizeof(float)*d_fftsize);
 
           fft(d_fbuf, d_residbufs[d_nconnections], d_fftsize);
           for(int x = 0; x < d_fftsize; x++) {
             d_pdu_magbuf[j * d_fftsize + x] = (double)d_fbuf[x];
           }
           j++;
-
         }
 
         //update gui per-pdu
         d_qApplication->postEvent(d_main_gui,
                                   new WaterfallUpdateEvent(d_magbufs,
-                                                           d_fftsize*200,
+                                                           d_fftsize*d_nrows,
                                                            0));
-
       }
     }
 
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.h 
b/gr-qtgui/lib/waterfall_sink_f_impl.h
index b7223b7..68aa5eb 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.h
@@ -47,6 +47,7 @@ namespace gr {
       double d_bandwidth;
       std::string d_name;
       int d_nconnections;
+      int d_nrows;
 
       bool d_shift;
       fft::fft_complex *d_fft;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]