commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 03/08: qtgui: allow toggle to only show pos


From: git
Subject: [Commit-gnuradio] [gnuradio] 03/08: qtgui: allow toggle to only show positive half of waterfall spectrum.
Date: Thu, 23 Oct 2014 22:03:16 +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 6d77237c301f6f92e936989d85ad8ea92082e3a4
Author: Tom Rondeau <address@hidden>
Date:   Wed Oct 22 16:00:34 2014 -0400

    qtgui: allow toggle to only show positive half of waterfall spectrum.
---
 gr-qtgui/grc/qtgui_freq_sink_x.xml                 |  1 -
 gr-qtgui/grc/qtgui_waterfall_sink_x.xml            | 19 +++++++++++++
 .../include/gnuradio/qtgui/WaterfallDisplayPlot.h  |  2 ++
 gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h      |  6 +++++
 gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h |  7 +++++
 .../include/gnuradio/qtgui/waterfalldisplayform.h  |  1 +
 gr-qtgui/lib/WaterfallDisplayPlot.cc               | 31 +++++++++++++++++-----
 gr-qtgui/lib/waterfall_sink_f_impl.cc              | 20 +++++++++-----
 gr-qtgui/lib/waterfall_sink_f_impl.h               |  1 +
 gr-qtgui/lib/waterfalldisplayform.cc               |  7 +++++
 10 files changed, 81 insertions(+), 14 deletions(-)

diff --git a/gr-qtgui/grc/qtgui_freq_sink_x.xml 
b/gr-qtgui/grc/qtgui_freq_sink_x.xml
index 5a8a860..bf9303f 100644
--- a/gr-qtgui/grc/qtgui_freq_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_freq_sink_x.xml
@@ -26,7 +26,6 @@ self.$(id).enable_autoscale($autoscale)
 self.$(id).enable_grid($grid)
 self.$(id).set_fft_average($average)
 
-print $type, type(float())
 if $type == type(float()):
   self.$(id).set_plot_pos_half(not $freqhalf)
 
diff --git a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml 
b/gr-qtgui/grc/qtgui_waterfall_sink_x.xml
index d6e0f59..3b6e37e 100644
--- a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_waterfall_sink_x.xml
@@ -23,6 +23,9 @@ qtgui.$(type.fcn)(
 self.$(id).set_update_time($update_time)
 self.$(id).enable_grid($grid)
 
+if $type == type(float()):
+  self.$(id).set_plot_pos_half(not $freqhalf)
+
 labels = [$label1, $label2, $label3, $label4, $label5,
           $label6, $label7, $label8, $label9, $label10]
 colors = [$color1, $color2, $color3, $color4, $color5,
@@ -77,6 +80,22 @@ $(gui_hint()($win))</make>
   </param>
 
   <param>
+    <name>Spectrum Width</name>
+    <key>freqhalf</key>
+    <value>True</value>
+    <type>enum</type>
+    <hide>#if $type() == "float" then 'part' else 'all'#</hide>
+    <option>
+      <name>Full</name>
+      <key>True</key>
+    </option>
+    <option>
+      <name>Half</name>
+      <key>False</key>
+    </option>
+  </param>
+
+  <param>
     <name>Window Type</name>
     <key>wintype</key>
     <value>firdes.WIN_BLACKMAN_hARRIS</value>
diff --git a/gr-qtgui/include/gnuradio/qtgui/WaterfallDisplayPlot.h 
b/gr-qtgui/include/gnuradio/qtgui/WaterfallDisplayPlot.h
index 4fdd065..37c6183 100644
--- a/gr-qtgui/include/gnuradio/qtgui/WaterfallDisplayPlot.h
+++ b/gr-qtgui/include/gnuradio/qtgui/WaterfallDisplayPlot.h
@@ -95,6 +95,7 @@ public slots:
   void setIntensityColorMapType1(int);
   void setUserDefinedLowIntensityColor(QColor);
   void setUserDefinedHighIntensityColor(QColor);
+  void setPlotPosHalf(bool half);
 
 signals:
   void updatedLowerIntensityLevel(const double);
@@ -106,6 +107,7 @@ private:
   double d_start_frequency;
   double d_stop_frequency;
   int    d_xaxis_multiplier;
+  bool   d_half_freq;
 
   std::vector<WaterfallData*> d_data;
 
diff --git a/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h 
b/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h
index cbd8c97..f0ebe8d 100644
--- a/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h
+++ b/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h
@@ -116,6 +116,12 @@ namespace gr {
       virtual void set_line_style(int which, int style) = 0;
       virtual void set_line_marker(int which, int marker) = 0;
       virtual void set_line_alpha(int which, double alpha) = 0;
+
+      /*!
+       *  Pass "true" to this function to only show the positive half
+       *  of the spectrum. By default, this plotter shows the full
+       *  spectrum (positive and negative halves).
+       */
       virtual void set_plot_pos_half(bool half) = 0;
 
       virtual std::string title() = 0;
diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h 
b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
index bbfcc33..4570ef9 100644
--- a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
+++ b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
@@ -124,6 +124,13 @@ namespace gr {
       virtual void set_line_alpha(int which, double alpha) = 0;
       virtual void set_color_map(int which, const int color) = 0;
 
+      /*!
+       *  Pass "true" to this function to only show the positive half
+       *  of the spectrum. By default, this plotter shows the full
+       *  spectrum (positive and negative halves).
+       */
+      virtual void set_plot_pos_half(bool half) = 0;
+
       virtual std::string title() = 0;
       virtual std::string line_label(int which) = 0;
       virtual double line_alpha(int which) = 0;
diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h 
b/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h
index 8017d5c..e885a52 100644
--- a/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h
+++ b/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h
@@ -86,6 +86,7 @@ public slots:
                   const QColor highColor=QColor("white"));
 
   void autoScale(bool en=false);
+  void setPlotPosHalf(bool half);
 
 private slots:
   void newData(const QEvent *updateEvent);
diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc 
b/gr-qtgui/lib/WaterfallDisplayPlot.cc
index eb33cba..86724fe 100644
--- a/gr-qtgui/lib/WaterfallDisplayPlot.cc
+++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2008-2012 Free Software Foundation, Inc.
+ * Copyright 2008-2012,2014 Free Software Foundation, Inc.
  *
  * This file is part of GNU Radio
  *
@@ -139,6 +139,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(int nplots, 
QWidget* parent)
 
   resize(parent->width(), parent->height());
   d_numPoints = 1024;
+  d_half_freq = false;
 
   setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
   setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0));
@@ -225,8 +226,13 @@ WaterfallDisplayPlot::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_xaxis_multiplier = units;
 
@@ -273,10 +279,13 @@ WaterfallDisplayPlot::plotNewData(const 
std::vector<double*> dataPoints,
                                  const gr::high_res_timer_type timestamp,
                                  const int droppedFrames)
 {
+  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;
 
        resetAxis();
 
@@ -298,7 +307,8 @@ WaterfallDisplayPlot::plotNewData(const 
std::vector<double*> dataPoints,
       ((WaterfallZoomer*)d_zoomer)->setZeroTime(timestamp);
 
       for(int i = 0; i < d_nplots; i++) {
-       d_data[i]->addFFTData(dataPoints[i], numDataPoints, droppedFrames);
+       d_data[i]->addFFTData(&(dataPoints[i][_in_index]),
+                              _npoints_in, droppedFrames);
        d_data[i]->incrementNumLinesToUpdate();
        d_spectrogram[i]->invalidateCache();
        d_spectrogram[i]->itemChanged();
@@ -596,4 +606,13 @@ WaterfallDisplayPlot::_updateIntensityRangeDisplay()
   replot();
 }
 
+void
+WaterfallDisplayPlot::setPlotPosHalf(bool half)
+{
+  d_half_freq = half;
+  if(half)
+    d_start_frequency = 0;
+}
+
+
 #endif /* WATERFALL_DISPLAY_PLOT_C */
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.cc 
b/gr-qtgui/lib/waterfall_sink_f_impl.cc
index 14ddc2b..0f7f9e0 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.cc
@@ -53,8 +53,8 @@ namespace gr {
                                                 int nconnections,
                                                 QWidget *parent)
       : sync_block("waterfall_sink_f",
-                     io_signature::make(1, -1, sizeof(float)),
-                     io_signature::make(0, 0, 0)),
+                   io_signature::make(1, -1, sizeof(float)),
+                   io_signature::make(0, 0, 0)),
        d_fftsize(fftsize), d_fftavg(1.0),
        d_wintype((filter::firdes::win_type)(wintype)),
        d_center_freq(fc), d_bandwidth(bw), d_name(name),
@@ -107,8 +107,8 @@ namespace gr {
         d_main_gui->close();
 
       for(int i = 0; i < d_nconnections; i++) {
-       volk_free(d_residbufs[i]);
-       volk_free(d_magbufs[i]);
+       volk_free(d_residbufs[i]);
+       volk_free(d_magbufs[i]);
       }
       delete d_fft;
       volk_free(d_fbuf);
@@ -127,7 +127,7 @@ namespace gr {
     {
       unsigned int ninputs = ninput_items_required.size();
       for (unsigned int i = 0; i < ninputs; i++) {
-       ninput_items_required[i] = std::min(d_fftsize, 8191);
+       ninput_items_required[i] = std::min(d_fftsize, 8191);
       }
     }
 
@@ -135,14 +135,14 @@ namespace gr {
     waterfall_sink_f_impl::initialize()
     {
       if(qApp != NULL) {
-       d_qApplication = qApp;
+       d_qApplication = qApp;
       }
       else {
 #if QT_VERSION >= 0x040500
         std::string style = prefs::singleton()->get_string("qtgui", "style", 
"raster");
         QApplication::setGraphicsSystem(QString(style.c_str()));
 #endif
-       d_qApplication = new QApplication(d_argc, &d_argv);
+       d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
       // If a style sheet is set in the prefs file, enable it here.
@@ -290,6 +290,12 @@ namespace gr {
       d_main_gui->resize(QSize(width, height));
     }
 
+    void
+    waterfall_sink_f_impl::set_plot_pos_half(bool half)
+    {
+      d_main_gui->setPlotPosHalf(half);
+    }
+
     std::string
     waterfall_sink_f_impl::title()
     {
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.h 
b/gr-qtgui/lib/waterfall_sink_f_impl.h
index d783f31..ca6e3f4 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.h
@@ -110,6 +110,7 @@ namespace gr {
       void set_line_label(int which, const std::string &label);
       void set_line_alpha(int which, double alpha);
       void set_color_map(int which, const int color);
+      void set_plot_pos_half(bool half);
 
       std::string title();
       std::string line_label(int which);
diff --git a/gr-qtgui/lib/waterfalldisplayform.cc 
b/gr-qtgui/lib/waterfalldisplayform.cc
index fdf09d9..c1dd8f7 100644
--- a/gr-qtgui/lib/waterfalldisplayform.cc
+++ b/gr-qtgui/lib/waterfalldisplayform.cc
@@ -330,3 +330,10 @@ WaterfallDisplayForm::getClickedFreq() const
 {
   return d_clicked_freq;
 }
+
+void
+WaterfallDisplayForm::setPlotPosHalf(bool half)
+{
+  getPlot()->setPlotPosHalf(half);
+  getPlot()->replot();
+}



reply via email to

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