commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10843 - gnuradio/branches/developers/trondeau/qtdevel


From: trondeau
Subject: [Commit-gnuradio] r10843 - gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib
Date: Tue, 14 Apr 2009 20:08:38 -0600 (MDT)

Author: trondeau
Date: 2009-04-14 20:08:37 -0600 (Tue, 14 Apr 2009)
New Revision: 10843

Modified:
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/FrequencyDisplayPlot.h
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/Waterfall3DDisplayPlot.h
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/WaterfallDisplayPlot.cc
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/WaterfallDisplayPlot.h
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/spectrumdisplayform.cc
Log:
Automatically set the frequency units based on the size of the frequency range

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
     2009-04-15 00:54:44 UTC (rev 10842)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
     2009-04-15 02:08:37 UTC (rev 10843)
@@ -227,7 +227,7 @@
                                        const double constStopFreq,
                                        const double constCenterFreq,
                                        const bool useCenterFrequencyFlag,
-                                       const double units)
+                                       const double units, const std::string 
&strunits)
 {
   double startFreq = constStartFreq / units;
   double stopFreq = constStopFreq / units;
@@ -240,39 +240,19 @@
     stopFreq = (stopFreq + centerFreq);
   }
 
-  //if((stopFreq > 0) && (stopFreq > startFreq)){
-  if((stopFreq > startFreq)){
-    _startFrequency = startFreq;
-    _stopFrequency = stopFreq;
-    _resetXAxisPoints();
+  _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);
-
-    // Zooms back to the base and clears any other zoom levels
-    _zoomer->zoom(0);
-
-    setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency);
-  }
-
-  if(useCenterFrequencyFlag){
-    setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(2));
-    setAxisTitle(QwtPlot::xBottom, "RF Frequency (MHz)");
-    ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(2);
-  }
-  else{
-    setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(2));
-    setAxisTitle(QwtPlot::xBottom, "Frequency (MHz)");
-    ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(2);
-  }
-
   // Load up the new base zoom settings
   QwtDoubleRect newSize = _zoomer->zoomBase();
   newSize.setLeft(_startFrequency);
-  newSize.setWidth(_stopFrequency-_startFrequency);    
+  newSize.setWidth(_stopFrequency-_startFrequency);
   _zoomer->setZoomBase(newSize);
   
   // Zooms back to the base and clears any other zoom levels

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/FrequencyDisplayPlot.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/FrequencyDisplayPlot.h
      2009-04-15 00:54:44 UTC (rev 10842)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/FrequencyDisplayPlot.h
      2009-04-15 02:08:37 UTC (rev 10843)
@@ -20,8 +20,10 @@
   FrequencyDisplayPlot(QWidget*);
   virtual ~FrequencyDisplayPlot();
 
-  void SetFrequencyRange(const double, const double, const double, 
-                        const bool, const double);
+  void SetFrequencyRange(const double, const double, 
+                        const double, const bool,
+                        const double units=1000.0, 
+                        const std::string &strunits = "kHz");
   double GetStartFrequency()const;
   double GetStopFrequency()const;
 

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc
   2009-04-15 00:54:44 UTC (rev 10842)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc
   2009-04-15 02:08:37 UTC (rev 10843)
@@ -111,8 +111,18 @@
   _timePerFFT = 1.0;
 }
 
-void Waterfall3DDisplayPlot::SetFrequencyRange(const double startFreq, const 
double stopFreq, const double centerFreq, const bool useCenterFrequencyFlag){
-  if((stopFreq > 0) && (stopFreq > startFreq)){
+void
+Waterfall3DDisplayPlot::SetFrequencyRange(const double constStartFreq,
+                                         const double constStopFreq,
+                                         const double constCenterFreq,
+                                         const bool useCenterFrequencyFlag,
+                                         const double units, const std::string 
&strunits)
+{
+  double startFreq = constStartFreq / units;
+  double stopFreq = constStopFreq / units;
+  double centerFreq = constCenterFreq / units;
+
+  if(stopFreq > startFreq) {
     _startFrequency = startFreq;
     _stopFrequency = stopFreq;
 

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/Waterfall3DDisplayPlot.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/Waterfall3DDisplayPlot.h
    2009-04-15 00:54:44 UTC (rev 10842)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/Waterfall3DDisplayPlot.h
    2009-04-15 02:08:37 UTC (rev 10843)
@@ -130,7 +130,9 @@
   bool loadFromData(double** data, unsigned int columns, unsigned int rows
                    ,double minx, double maxx, double miny, double maxy);
 
-  void SetFrequencyRange(const double, const double, const double, const bool);
+  void SetFrequencyRange(const double, const double,
+                        const double, const bool,
+                        const double units, const std::string &strunits);
   double GetStartFrequency()const;
   double GetStopFrequency()const;
 

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/WaterfallDisplayPlot.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/WaterfallDisplayPlot.cc
     2009-04-15 00:54:44 UTC (rev 10842)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/WaterfallDisplayPlot.cc
     2009-04-15 02:08:37 UTC (rev 10843)
@@ -182,7 +182,9 @@
 const int WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_INCANDESCENT;
 const int WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED;
 
-WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent):QwtPlot(parent){
+WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent)
+  : QwtPlot(parent)
+{
   _zoomer = NULL;
   _startFrequency = 0;
   _stopFrequency = 4000;
@@ -253,11 +255,14 @@
   _UpdateIntensityRangeDisplay();
 }
 
-WaterfallDisplayPlot::~WaterfallDisplayPlot(){
+WaterfallDisplayPlot::~WaterfallDisplayPlot()
+{
   delete _waterfallData;
 }
 
-void WaterfallDisplayPlot::Reset(){
+void 
+WaterfallDisplayPlot::Reset()
+{
   _waterfallData->ResizeData(_startFrequency, _stopFrequency, _numPoints);
   _waterfallData->Reset();
 
@@ -270,25 +275,31 @@
   _zoomer->zoom(0);
 }
 
-void WaterfallDisplayPlot::SetFrequencyRange(const double startFreq, const 
double stopFreq, const double centerFreq, const bool useCenterFrequencyFlag){
-  if((stopFreq > 0) && (stopFreq > startFreq)){
-    _startFrequency = startFreq;
-    _stopFrequency = stopFreq;
+void
+WaterfallDisplayPlot::SetFrequencyRange(const double constStartFreq,
+                                       const double constStopFreq,
+                                       const double constCenterFreq,
+                                       const bool useCenterFrequencyFlag,
+                                       const double units, const std::string 
&strunits)
+{
+  double startFreq = constStartFreq / units;
+  double stopFreq = constStopFreq / units;
+  double centerFreq = constCenterFreq / units;
 
+  if(stopFreq > startFreq) {
+    _startFrequency = 1000*startFreq;
+    _stopFrequency = 1000*stopFreq;
+
+    setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency);
+
     if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){
       WaterfallFreqDisplayScaleDraw* freqScale = 
((WaterfallFreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom));
       freqScale->SetCenterFrequency(centerFreq);
       ((WaterfallZoomer*)_zoomer)->SetCenterFrequency(centerFreq);
-      if(useCenterFrequencyFlag){
-       freqScale->SetFrequencyPrecision( 3 );
-       ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision( 3 );
-       setAxisTitle(QwtPlot::xBottom, "Frequency (kHz)");
-      }
-      else{
-       freqScale->SetFrequencyPrecision( 0 );
-       ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision( 0 );
-       setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
-      }
+
+      freqScale->SetFrequencyPrecision( 2 );
+      ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision( 2 );
+      setAxisTitle(QwtPlot::xBottom, QString("Frequency 
(%1)").arg(strunits.c_str()));
     }
 
     Reset();
@@ -461,7 +472,7 @@
   rightAxis->setColorBarEnabled(true);
   rightAxis->setColorMap(d_spectrogram->data()->range(),
                         d_spectrogram->colorMap());
-  
+
   setAxisScale(QwtPlot::yRight, 
               d_spectrogram->data()->range().minValue(),
               d_spectrogram->data()->range().maxValue() );

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/WaterfallDisplayPlot.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/WaterfallDisplayPlot.h
      2009-04-15 00:54:44 UTC (rev 10842)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/WaterfallDisplayPlot.h
      2009-04-15 02:08:37 UTC (rev 10843)
@@ -18,11 +18,16 @@
 
   void Reset();
 
-  void SetFrequencyRange(const double, const double, const double, const bool);
+  void SetFrequencyRange(const double, const double, 
+                        const double, const bool,
+                        const double units=1000.0, 
+                        const std::string &strunits = "kHz");
   double GetStartFrequency()const;
   double GetStopFrequency()const;
 
-  void PlotNewData(const double* dataPoints, const int64_t numDataPoints, 
const double timePerFFT, const timespec timestamp, const int droppedFrames);
+  void PlotNewData(const double* dataPoints, const int64_t numDataPoints,
+                  const double timePerFFT, const timespec timestamp,
+                  const int droppedFrames);
 
   void SetIntensityRange(const double minIntensity, const double maxIntensity);
 

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/spectrumdisplayform.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/spectrumdisplayform.cc
      2009-04-15 00:54:44 UTC (rev 10842)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/spectrumdisplayform.cc
      2009-04-15 02:08:37 UTC (rev 10843)
@@ -466,19 +466,27 @@
                                       const double newStopFrequency,
                                       const double newCenterFrequency)
 {
+  std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"};
+  double units10 = floor(log10(newStopFrequency));
+  double units3  = floor(units10 / 3.0);
+  double units = pow(10, units10);
+  int iunit = static_cast<int>(units3);
+
   _frequencyDisplayPlot->SetFrequencyRange(newStartFrequency,
                                           newStopFrequency,
                                           newCenterFrequency,
                                           
UseRFFrequenciesCheckBox->isChecked(),
-                                          1000000.0);
+                                          units, strunits[iunit]);
   _waterfallDisplayPlot->SetFrequencyRange(newStartFrequency,
                                           newStopFrequency,
                                           newCenterFrequency,
-                                          
UseRFFrequenciesCheckBox->isChecked());
+                                          
UseRFFrequenciesCheckBox->isChecked(),
+                                          units, strunits[iunit]);
   _waterfall3DDisplayPlot->SetFrequencyRange(newStartFrequency,
                                             newStopFrequency,
                                             newCenterFrequency,
-                                            
UseRFFrequenciesCheckBox->isChecked());
+                                            
UseRFFrequenciesCheckBox->isChecked(),
+                                            units, strunits[iunit]);
 }
 
 int SpectrumDisplayForm::GetAverageCount(){





reply via email to

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