commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11340 - gnuradio/branches/developers/trondeau/qt/gr-q


From: trondeau
Subject: [Commit-gnuradio] r11340 - gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib
Date: Sat, 4 Jul 2009 17:41:40 -0600 (MDT)

Author: trondeau
Date: 2009-07-04 17:41:39 -0600 (Sat, 04 Jul 2009)
New Revision: 11340

Modified:
   
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
   gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/SpectrumGUIClass.cc
   gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/SpectrumGUIClass.h
   gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui.i
   gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_c.cc
   gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_c.h
   gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_f.cc
   gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_f.h
   
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/spectrumdisplayform.cc
   
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/spectrumdisplayform.h
Log:
Properly handle the RF Frequency check box. This changes the API to the qtsinks 
that now take in the center frequency and bandwidth as opposed to the min and 
max frequencies.

Modified: 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
   2009-07-04 15:53:00 UTC (rev 11339)
+++ 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
   2009-07-04 23:41:39 UTC (rev 11340)
@@ -259,17 +259,14 @@
   _startFrequency = startFreq;
   _stopFrequency = stopFreq;
   _resetXAxisPoints();
-  
+
   setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency);
   setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(2));
   setAxisTitle(QwtPlot::xBottom, QString("Frequency 
(%1)").arg(strunits.c_str()));
   ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(2);
 
   // Load up the new base zoom settings
-  QwtDoubleRect newSize = _zoomer->zoomBase();
-  newSize.setLeft(_startFrequency);
-  newSize.setWidth(_stopFrequency-_startFrequency);
-  _zoomer->setZoomBase(newSize);
+  _zoomer->setZoomBase();
   
   // Zooms back to the base and clears any other zoom levels
   _zoomer->zoom(0);

Modified: 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/SpectrumGUIClass.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/SpectrumGUIClass.cc   
    2009-07-04 15:53:00 UTC (rev 11339)
+++ 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/SpectrumGUIClass.cc   
    2009-07-04 23:41:39 UTC (rev 11340)
@@ -10,7 +10,8 @@
 const long SpectrumGUIClass::MIN_FFT_SIZE;
 
 SpectrumGUIClass::SpectrumGUIClass(const uint64_t maxDataSize,
-                                  const uint64_t fftSize, 
+                                  const uint64_t fftSize,
+                                  const double newCenterFrequency,
                                   const double newStartFrequency,
                                   const double newStopFrequency)
 {
@@ -25,7 +26,7 @@
   _pendingGUIUpdateEventsCount = 0;
   _droppedEntriesCount = 0;
 
-  _centerFrequency = 0;
+  _centerFrequency = newCenterFrequency;
   _startFrequency = newStartFrequency;
   _stopFrequency = newStopFrequency;
 
@@ -113,6 +114,9 @@
   // Draw Blank Display
   UpdateWindow(false, NULL, 0, NULL, 0, NULL, 0, 1.0, get_highres_clock(), 
true);
 
+  // Set up the initial frequency axis settings
+  SetFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency);
+
   // GUI Thread only
   qApp->processEvents();
 }

Modified: 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/SpectrumGUIClass.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/SpectrumGUIClass.h    
    2009-07-04 15:53:00 UTC (rev 11339)
+++ 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/SpectrumGUIClass.h    
    2009-07-04 23:41:39 UTC (rev 11340)
@@ -23,7 +23,9 @@
 {
 public:
   SpectrumGUIClass(const uint64_t maxDataSize, const uint64_t fftSize,
-                  const double newStartFrequency, const double 
newStopFrequency);
+                  const double newCenterFrequency,
+                  const double newStartFrequency, 
+                  const double newStopFrequency);
   ~SpectrumGUIClass();
   void Reset();
 

Modified: gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui.i
===================================================================
--- gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui.i   
2009-07-04 15:53:00 UTC (rev 11339)
+++ gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui.i   
2009-07-04 23:41:39 UTC (rev 11340)
@@ -30,7 +30,7 @@
 GR_SWIG_BLOCK_MAGIC(qtgui,sink_c)
 
   qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
-                                      float fmin=-0.5, float fmax=0.5,
+                                      double fc=0, double bw=1.0,
                                       const std::string &name="Display",
                                       bool plotfreq=true, bool 
plotwaterfall=true,
                                       bool plotwaterfall3d=true, bool 
plottime=true,
@@ -42,7 +42,7 @@
 {
 private:
   friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
-                                             float fmin, float fmax,
+                                             double fc, double bw,
                                              const std::string &name,
                                              bool plotfreq, bool plotwaterfall,
                                              bool plotwaterfall3d, bool 
plottime,
@@ -50,7 +50,7 @@
                                              bool use_openGL,
                                              QWidget *parent);
   qtgui_sink_c (int fftsize, int wintype,
-               float fmin, float fmax,
+               double fc, double bw,
                const std::string &name,
                bool plotfreq, bool plotwaterfall,
                bool plotwaterfall3d, bool plottime,
@@ -63,8 +63,7 @@
   PyObject* pyqwidget();
 
   void set_frequency_range(const double centerfreq,
-                          const double startfreq,
-                          const double stopfreq);
+                          const double bandwidth);
   void set_time_domain_axis(double min, double max);
   void set_constellation_axis(double xmin, double xmax,
                              double ymin, double ymax);
@@ -79,7 +78,7 @@
 GR_SWIG_BLOCK_MAGIC(qtgui,sink_f)
   
 qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
-                                    float fmin=-0.5, float fmax=0.5,
+                                    double fc=0, double bw=0.0,
                                     const std::string &name="Display",
                                     bool plotfreq=true, bool 
plotwaterfall=true,
                                     bool plotwaterfall3d=true, bool 
plottime=true,
@@ -91,7 +90,7 @@
 {
 private:
   friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
-                                             float fmin, float fmax,
+                                             double fc, double bw,
                                              const std::string &name,
                                              bool plotfreq, bool plotwaterfall,
                                              bool plotwaterfall3d, bool 
plottime,
@@ -99,7 +98,7 @@
                                              bool use_openGL,
                                              QWidget *parent);
   qtgui_sink_f (int fftsize, int wintype,
-               float fmin, float fmax,
+               double fc, double bw,
                const std::string &name,
                bool plotfreq, bool plotwaterfall,
                bool plotwaterfall3d, bool plottime,
@@ -112,8 +111,7 @@
   PyObject* pyqwidget();
 
   void set_frequency_range(const double centerfreq,
-                          const double startfreq,
-                          const double stopfreq);
+                          const double bandwidth);
   void set_time_domain_axis(double min, double max);
   void set_constellation_axis(double xmin, double xmax,
                              double ymin, double ymax);

Modified: 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_c.cc
===================================================================
--- gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_c.cc   
2009-07-04 15:53:00 UTC (rev 11339)
+++ gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_c.cc   
2009-07-04 23:41:39 UTC (rev 11340)
@@ -32,7 +32,7 @@
 
 qtgui_sink_c_sptr
 qtgui_make_sink_c (int fftsize, int wintype,
-                  float fmin, float fmax,
+                  double fc, double bw,
                   const std::string &name,
                   bool plotfreq, bool plotwaterfall,
                   bool plotwaterfall3d, bool plottime,
@@ -41,7 +41,7 @@
                   QWidget *parent)
 {
   return qtgui_sink_c_sptr (new qtgui_sink_c (fftsize, wintype,
-                                             fmin, fmax, name,
+                                             fc, bw, name,
                                              plotfreq, plotwaterfall,
                                              plotwaterfall3d, plottime,
                                              plotconst,
@@ -50,7 +50,7 @@
 }
 
 qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype,
-                           float fmin, float fmax,
+                           double fc, double bw,
                            const std::string &name,
                            bool plotfreq, bool plotwaterfall,
                            bool plotwaterfall3d, bool plottime,
@@ -62,7 +62,7 @@
              gr_make_io_signature (0, 0, 0)),
     d_fftsize(fftsize),
     d_wintype((gr_firdes::win_type)(wintype)), 
-    d_fmin(fmin), d_fmax(fmax), d_name(name),
+    d_center_freq(fc), d_bandwidth(bw), d_name(name),
     d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall),
     d_plotwaterfall3d(plotwaterfall3d), d_plottime(plottime),
     d_plotconst(plotconst),
@@ -119,9 +119,15 @@
     d_qApplication = new QApplication(argc, argv);
   }
 
+  if(d_center_freq < 0) {
+    throw std::runtime_error("qtgui_sink_c: Received bad center frequency.\n");
+  }
+
   uint64_t maxBufferSize = 32768;
   d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize, 
-                                   d_fmin, d_fmax);
+                                   d_center_freq, 
+                                   -d_bandwidth/2.0, 
+                                   d_bandwidth/2.0);
 
   d_main_gui->SetDisplayTitle(d_name);
   d_main_gui->SetFFTSize(d_fftsize);
@@ -160,10 +166,13 @@
 
 void
 qtgui_sink_c::set_frequency_range(const double centerfreq, 
-                                 const double startfreq,
-                                 const double stopfreq)
+                                 const double bandwidth)
 {
-  d_main_gui->SetFrequencyRange(startfreq, stopfreq, centerfreq);
+  d_center_freq = centerfreq;
+  d_bandwidth = bandwidth;
+  d_main_gui->SetFrequencyRange(d_center_freq, 
+                               -d_bandwidth/2.0,
+                               d_bandwidth/2.0);
 }
 
 void

Modified: 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_c.h
===================================================================
--- gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_c.h    
2009-07-04 15:53:00 UTC (rev 11339)
+++ gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_c.h    
2009-07-04 23:41:39 UTC (rev 11340)
@@ -35,7 +35,7 @@
 typedef boost::shared_ptr<qtgui_sink_c> qtgui_sink_c_sptr;
 
 qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
-                                    float fmin=-0.5, float fmax=0.5,
+                                    double fc=0, double bandwidth=1.0,
                                     const std::string &name="Spectrum Display",
                                     bool plotfreq=true, bool 
plotwaterfall=true,
                                     bool plotwaterfall3d=true, bool 
plottime=true,
@@ -47,7 +47,7 @@
 {
 private:
   friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
-                                             float fmin, float fmax,
+                                             double fc, double bw,
                                              const std::string &name,
                                              bool plotfreq, bool plotwaterfall,
                                              bool plotwaterfall3d, bool 
plottime,
@@ -55,7 +55,7 @@
                                              bool use_openGL,
                                              QWidget *parent);
   qtgui_sink_c (int fftsize, int wintype,
-               float fmin, float fmax, 
+               double fc, double bw, 
                const std::string &name,
                bool plotfreq, bool plotwaterfall,
                bool plotwaterfall3d, bool plottime,
@@ -70,8 +70,8 @@
   int d_fftsize;
   gr_firdes::win_type d_wintype;
   std::vector<float> d_window;
-  float d_fmin;
-  float d_fmax;
+  double d_center_freq;
+  double d_bandwidth;
   std::string d_name;
   
   pthread_mutex_t d_pmutex;
@@ -102,8 +102,7 @@
   PyObject* pyqwidget();
 
   void set_frequency_range(const double centerfreq,
-                          const double startfreq,
-                          const double stopfreq);
+                          const double bandwidth);
 
   void set_time_domain_axis(double min, double max);
   void set_constellation_axis(double xmin, double xmax,

Modified: 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_f.cc
===================================================================
--- gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_f.cc   
2009-07-04 15:53:00 UTC (rev 11339)
+++ gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_f.cc   
2009-07-04 23:41:39 UTC (rev 11340)
@@ -32,7 +32,7 @@
 
 qtgui_sink_f_sptr
 qtgui_make_sink_f (int fftsize, int wintype,
-                  float fmin, float fmax,
+                  double fc, double bw,
                   const std::string &name,
                   bool plotfreq, bool plotwaterfall,
                   bool plotwaterfall3d, bool plottime,
@@ -41,7 +41,7 @@
                   QWidget *parent)
 {
   return qtgui_sink_f_sptr (new qtgui_sink_f (fftsize, wintype,
-                                             fmin, fmax, name,
+                                             fc, bw, name,
                                              plotfreq, plotwaterfall,
                                              plotwaterfall3d, plottime,
                                              plotconst,
@@ -50,7 +50,7 @@
 }
 
 qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype,
-                           float fmin, float fmax,
+                           double fc, double bw,
                            const std::string &name,
                            bool plotfreq, bool plotwaterfall,
                            bool plotwaterfall3d, bool plottime,
@@ -62,7 +62,7 @@
              gr_make_io_signature (0, 0, 0)),
     d_fftsize(fftsize),
     d_wintype((gr_firdes::win_type)(wintype)),
-    d_fmin(fmin), d_fmax(fmax), d_name(name),
+    d_center_freq(fc), d_bandwidth(bw), d_name(name),
     d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall),
     d_plotwaterfall3d(plotwaterfall3d), d_plottime(plottime),
     d_plotconst(plotconst),
@@ -121,7 +121,9 @@
 
   uint64_t maxBufferSize = 32768;
   d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize,
-                                   d_fmin, d_fmax);
+                                   d_center_freq, 
+                                   -d_bandwidth/2.0, 
+                                   d_bandwidth/2.0);
   d_main_gui->SetDisplayTitle(d_name);
   d_main_gui->SetFFTSize(d_fftsize);
   d_main_gui->SetWindowType((int)d_wintype);
@@ -158,10 +160,13 @@
 
 void
 qtgui_sink_f::set_frequency_range(const double centerfreq, 
-                                 const double startfreq,
-                                 const double stopfreq)
+                                 const double bandwidth)
 {
-  d_main_gui->SetFrequencyRange(centerfreq, startfreq, stopfreq);
+  d_center_freq = centerfreq;
+  d_bandwidth = bandwidth;
+  d_main_gui->SetFrequencyRange(d_center_freq, 
+                               -d_bandwidth/2.0,
+                               d_bandwidth/2.0);
 }
 
 void

Modified: 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_f.h
===================================================================
--- gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_f.h    
2009-07-04 15:53:00 UTC (rev 11339)
+++ gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/qtgui_sink_f.h    
2009-07-04 23:41:39 UTC (rev 11340)
@@ -35,7 +35,7 @@
 typedef boost::shared_ptr<qtgui_sink_f> qtgui_sink_f_sptr;
 
 qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
-                                    float fmin=-0.5, float fmax=0.5,
+                                    double fc=0, double bw=1.0,
                                     const std::string &name="Spectrum Display",
                                     bool plotfreq=true, bool 
plotwaterfall=true,
                                     bool plotwaterfall3d=true, bool 
plottime=true,
@@ -47,7 +47,7 @@
 {
 private:
   friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
-                                             float fmin, float fmax,
+                                             double fc, double bw,
                                              const std::string &name,
                                              bool plotfreq, bool plotwaterfall,
                                              bool plotwaterfall3d, bool 
plottime,
@@ -55,7 +55,7 @@
                                              bool use_openGL,
                                              QWidget *parent);
   qtgui_sink_f (int fftsize, int wintype,
-               float fmin, float fmax, 
+               double fc, double bw,
                const std::string &name,
                bool plotfreq, bool plotwaterfall,
                bool plotwaterfall3d, bool plottime,
@@ -68,8 +68,8 @@
   int d_fftsize;
   gr_firdes::win_type d_wintype;
   std::vector<float> d_window;
-  float d_fmin;
-  float d_fmax;
+  double d_center_freq;
+  double d_bandwidth;
   std::string d_name;
   
   pthread_mutex_t d_pmutex;
@@ -100,8 +100,7 @@
   PyObject* pyqwidget();
 
   void set_frequency_range(const double centerfreq,
-                          const double startfreq,
-                          const double stopfreq);
+                          const double bandwidth);
 
   void set_time_domain_axis(double min, double max);
   void set_constellation_axis(double xmin, double xmax,

Modified: 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/spectrumdisplayform.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/spectrumdisplayform.cc
    2009-07-04 15:53:00 UTC (rev 11339)
+++ 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/spectrumdisplayform.cc
    2009-07-04 23:41:39 UTC (rev 11340)
@@ -473,19 +473,29 @@
 }
 
 void
-SpectrumDisplayForm::SetFrequencyRange(const double newStartFrequency, 
-                                      const double newStopFrequency,
-                                      const double newCenterFrequency)
+SpectrumDisplayForm::SetFrequencyRange(const double newCenterFrequency,
+                                      const double newStartFrequency, 
+                                      const double newStopFrequency)
 {
-  double fdiff = abs(newStartFrequency - newStopFrequency);
+  double fdiff;
+  if(UseRFFrequenciesCheckBox->isChecked()) {
+    fdiff = newCenterFrequency;
+  }
+  else {
+    fdiff = std::max(fabs(newStartFrequency), fabs(newStopFrequency));
+  }
 
   if(fdiff > 0) {
     std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"};
-    double units10 = floor(log10(std::max(fabs(newStartFrequency), 
fabs(newStopFrequency))));
+    double units10 = floor(log10(fdiff));
     double units3  = std::max(floor(units10 / 3.0), 0.0);
     double units = pow(10, (units10-fmod(units10, 3.0)));
     int iunit = static_cast<int>(units3);
     
+    _startFrequency = newStartFrequency;
+    _stopFrequency = newStopFrequency;
+    _centerFrequency = newCenterFrequency;
+
     _frequencyDisplayPlot->SetFrequencyRange(newStartFrequency,
                                             newStopFrequency,
                                             newCenterFrequency,
@@ -635,12 +645,7 @@
 void
 SpectrumDisplayForm::UseRFFrequenciesCB( bool useRFFlag )
 {
-  if(useRFFlag){
-    SetFrequencyRange(_startFrequency, _stopFrequency, _centerFrequency);
-  }
-  else{
-    SetFrequencyRange(_startFrequency, _stopFrequency, 0.0 );
-  }
+  SetFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency);
 }
 
 

Modified: 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/spectrumdisplayform.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/spectrumdisplayform.h 
    2009-07-04 15:53:00 UTC (rev 11339)
+++ 
gnuradio/branches/developers/trondeau/qt/gr-qtgui/src/lib/spectrumdisplayform.h 
    2009-07-04 23:41:39 UTC (rev 11340)
@@ -42,9 +42,9 @@
   void MinHoldResetBtn_clicked();
   void MaxHoldResetBtn_clicked();
   void PowerLineEdit_textChanged( const QString& valueString );
-  void SetFrequencyRange( const double newStartFrequency,
-                         const double newStopFrequency,
-                         const double newCenterFrequency );
+  void SetFrequencyRange( const double newCenterFrequency,
+                         const double newStartFrequency,
+                         const double newStopFrequency );
   void closeEvent( QCloseEvent * e );
   void WindowTypeChanged( int newItem );
   void UseRFFrequenciesCB( bool useRFFlag );





reply via email to

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