commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: trondeau
Subject: [Commit-gnuradio] r10841 - gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib
Date: Tue, 14 Apr 2009 18:48:39 -0600 (MDT)

Author: trondeau
Date: 2009-04-14 18:48:39 -0600 (Tue, 14 Apr 2009)
New Revision: 10841

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/SpectrumGUIClass.cc
   gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui.i
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.cc
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.h
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.cc
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.h
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/spectrumdisplayform.cc
Log:
Adding interface to adjust frequency axis when center frequency or bandwidth 
are changed

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:46:36 UTC (rev 10840)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/FrequencyDisplayPlot.cc
     2009-04-15 00:48:39 UTC (rev 10841)
@@ -8,18 +8,22 @@
 class FreqPrecisionClass
 {
 public:
-  FreqPrecisionClass(const int freqPrecision){
+  FreqPrecisionClass(const int freqPrecision)
+  {
     _frequencyPrecision = freqPrecision;
   }
 
-  virtual ~FreqPrecisionClass(){
+  virtual ~FreqPrecisionClass()
+  {
   }
 
-  virtual unsigned int GetFrequencyPrecision()const{
+  virtual unsigned int GetFrequencyPrecision() const
+  {
     return _frequencyPrecision;
   }
 
-  virtual void SetFrequencyPrecision(const unsigned int newPrecision){
+  virtual void SetFrequencyPrecision(const unsigned int newPrecision)
+  {
     _frequencyPrecision = newPrecision;
   }
 protected:
@@ -29,17 +33,20 @@
 
 };
 
-class FreqDisplayScaleDraw: public QwtScaleDraw, public FreqPrecisionClass{
+class FreqDisplayScaleDraw: public QwtScaleDraw, public FreqPrecisionClass
+{
 public:
-  FreqDisplayScaleDraw(const unsigned int precision):QwtScaleDraw(), 
FreqPrecisionClass(precision){
-
+  FreqDisplayScaleDraw(const unsigned int precision)
+    : QwtScaleDraw(), FreqPrecisionClass(precision)
+  {
   }
 
-  virtual ~FreqDisplayScaleDraw(){
-
+  virtual ~FreqDisplayScaleDraw() 
+  {
   }
 
-  virtual QwtText label(double value)const{
+  virtual QwtText label(double value) const
+  {
     return QString("%1").arg(value, 0, 'f', GetFrequencyPrecision());
   }
 
@@ -52,7 +59,8 @@
 class FreqDisplayZoomer: public QwtPlotZoomer, public FreqPrecisionClass
 {
 public:
-  FreqDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int 
freqPrecision):QwtPlotZoomer(canvas),FreqPrecisionClass(freqPrecision)
+  FreqDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision)
+    : QwtPlotZoomer(canvas),FreqPrecisionClass(freqPrecision)
   {
     setTrackerMode(QwtPicker::AlwaysOn);
   }
@@ -74,7 +82,9 @@
   }
 };
 
-FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent):QwtPlot(parent){
+FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent)
+  : QwtPlot(parent)
+{
   _startFrequency = 0;
   _stopFrequency = 4000;
   
@@ -199,10 +209,10 @@
   const QColor c(Qt::darkRed);
   _zoomer->setRubberBandPen(c);
   _zoomer->setTrackerPen(c);
-
 }
 
-FrequencyDisplayPlot::~FrequencyDisplayPlot(){
+FrequencyDisplayPlot::~FrequencyDisplayPlot()
+{
   delete[] _dataPoints;
   delete[] _maxFFTPoints;
   delete[] _minFFTPoints;
@@ -212,18 +222,28 @@
   // _zoomer and _panner deleted when parent deleted
 }
 
-void FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq, 
const double constStopFreq, const double centerFrequency, const bool 
useCenterFrequencyFlag){
-  double startFreq = constStartFreq;
-  double stopFreq = constStopFreq;
+void
+FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq,
+                                       const double constStopFreq,
+                                       const double constCenterFreq,
+                                       const bool useCenterFrequencyFlag,
+                                       const double units)
+{
+  double startFreq = constStartFreq / units;
+  double stopFreq = constStopFreq / units;
+  double centerFreq = constCenterFreq / units;
+  printf("startFreq: %f\nStopFreq: %f\nCenterFreq: %f\n",
+        startFreq, stopFreq, centerFreq);
 
   _useCenterFrequencyFlag = useCenterFrequencyFlag;
 
   if(_useCenterFrequencyFlag){
-    startFreq = (startFreq + centerFrequency) / 1000.0;
-    stopFreq = (stopFreq + centerFrequency) / 1000.0;
+    startFreq = (startFreq + centerFreq);
+    stopFreq = (stopFreq + centerFreq);
   }
 
-  if((stopFreq > 0) && (stopFreq > startFreq)){
+  //if((stopFreq > 0) && (stopFreq > startFreq)){
+  if((stopFreq > startFreq)){
     _startFrequency = startFreq;
     _stopFrequency = stopFreq;
     _resetXAxisPoints();
@@ -241,14 +261,14 @@
   }
 
   if(useCenterFrequencyFlag){
-    setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(3));
-    setAxisTitle(QwtPlot::xBottom, "RF Frequency (kHz)");
-    ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(3);
+    setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(2));
+    setAxisTitle(QwtPlot::xBottom, "RF Frequency (MHz)");
+    ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(2);
   }
   else{
-    setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0));
-    setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
-    ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(0);
+    setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(2));
+    setAxisTitle(QwtPlot::xBottom, "Frequency (MHz)");
+    ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(2);
   }
 
   // Load up the new base zoom settings
@@ -262,16 +282,21 @@
 }
 
 
-double FrequencyDisplayPlot::GetStartFrequency()const{
+double
+FrequencyDisplayPlot::GetStartFrequency() const
+{
   return _startFrequency;
 }
 
-double FrequencyDisplayPlot::GetStopFrequency()const{
+double
+FrequencyDisplayPlot::GetStopFrequency() const
+{
   return _stopFrequency;
 }
 
-void FrequencyDisplayPlot::replot(){
-
+void
+FrequencyDisplayPlot::replot()
+{
   const timespec startTime = get_highres_clock();
 
   _markerNoiseFloorAmplitude->setYValue(_noiseFloorAmplitude);
@@ -296,7 +321,11 @@
   }
 }
 
-void FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t 
numDataPoints, const double noiseFloorAmplitude, const double peakFrequency, 
const double peakAmplitude){
+void
+FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t 
numDataPoints,
+                                 const double noiseFloorAmplitude, const 
double peakFrequency,
+                                 const double peakAmplitude)
+{
   if(numDataPoints > 0){
 
     if(numDataPoints != _numPoints){
@@ -345,27 +374,37 @@
   }
 }
 
-void FrequencyDisplayPlot::ClearMaxData(){
+void
+FrequencyDisplayPlot::ClearMaxData()
+{
   for(int64_t number = 0; number < _numPoints; number++){
     _maxFFTPoints[number] = -280.0;
   }
 }
 
-void FrequencyDisplayPlot::ClearMinData(){
+void
+FrequencyDisplayPlot::ClearMinData()
+{
   for(int64_t number = 0; number < _numPoints; number++){
     _minFFTPoints[number] = 200.0;
   }
 }
 
-void FrequencyDisplayPlot::SetMaxFFTVisible(const bool visibleFlag){
+void
+FrequencyDisplayPlot::SetMaxFFTVisible(const bool visibleFlag)
+{
   _max_fft_plot_curve->setVisible(visibleFlag);
 }
 
-void FrequencyDisplayPlot::SetMinFFTVisible(const bool visibleFlag){
+void
+FrequencyDisplayPlot::SetMinFFTVisible(const bool visibleFlag)
+{
   _min_fft_plot_curve->setVisible(visibleFlag);
 }
 
-void FrequencyDisplayPlot::_resetXAxisPoints(){
+void
+FrequencyDisplayPlot::_resetXAxisPoints()
+{
   double fft_bin_size = (_stopFrequency-_startFrequency) / 
static_cast<double>(_numPoints);
   double freqValue = _startFrequency;
   for(int64_t loc = 0; loc < _numPoints; loc++){
@@ -374,11 +413,15 @@
   }
 }
 
-void FrequencyDisplayPlot::SetLowerIntensityLevel(const double 
lowerIntensityLevel){
+void
+FrequencyDisplayPlot::SetLowerIntensityLevel(const double lowerIntensityLevel)
+{
   _lower_intensity_marker->setYValue( lowerIntensityLevel );
 }
 
-void FrequencyDisplayPlot::SetUpperIntensityLevel(const double 
upperIntensityLevel){
+void
+FrequencyDisplayPlot::SetUpperIntensityLevel(const double upperIntensityLevel)
+{
   _upper_intensity_marker->setYValue( upperIntensityLevel );
 }
 

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:46:36 UTC (rev 10840)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/FrequencyDisplayPlot.h
      2009-04-15 00:48:39 UTC (rev 10841)
@@ -20,11 +20,14 @@
   FrequencyDisplayPlot(QWidget*);
   virtual ~FrequencyDisplayPlot();
 
-  void SetFrequencyRange(const double, const double, const double, const bool);
+  void SetFrequencyRange(const double, const double, const double, 
+                        const bool, const double);
   double GetStartFrequency()const;
   double GetStopFrequency()const;
 
-  void PlotNewData(const double* dataPoints, const int64_t numDataPoints, 
const double noiseFloorAmplitude, const double peakFrequency, const double 
peakAmplitude);
+  void PlotNewData(const double* dataPoints, const int64_t numDataPoints,
+                  const double noiseFloorAmplitude, const double peakFrequency,
+                  const double peakAmplitude);
   
   void ClearMaxData();
   void ClearMinData();

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/SpectrumGUIClass.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/SpectrumGUIClass.cc
 2009-04-15 00:46:36 UTC (rev 10840)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/SpectrumGUIClass.cc
 2009-04-15 00:48:39 UTC (rev 10841)
@@ -170,6 +170,10 @@
   _centerFrequency = centerFreq;
   _startFrequency = startFreq;
   _stopFrequency = stopFreq;
+
+  _spectrumDisplayForm->SetFrequencyRange(_centerFrequency,
+                                         _startFrequency,
+                                         _stopFrequency);
   //_windowStateLock->Unlock();
 }
 

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui.i
===================================================================
--- gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui.i     
2009-04-15 00:46:36 UTC (rev 10840)
+++ gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui.i     
2009-04-15 00:48:39 UTC (rev 10841)
@@ -58,6 +58,10 @@
 public:
   void exec_();
   PyObject* pyqwidget();
+
+  void set_frequency_range(const double centerfreq,
+                          const double startfreq,
+                          const double stopfreq);
 };
 
 
@@ -68,9 +72,12 @@
 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,
-                                      const std::string &name="Display",
-                                      QWidget *parent=NULL);
+                                    float fmin=-0.5, float fmax=0.5,
+                                    const std::string &name="Display",
+                                    bool plotfreq=true, bool 
plotwaterfall=true,
+                                    bool plotwaterfall3d=true, bool 
plottime=true,
+                                    bool plotconst=true,
+                                    QWidget *parent=NULL);
 
 class qtgui_sink_f : public gr_block
 {
@@ -78,10 +85,16 @@
   friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
                                              float fmin, float fmax,
                                              const std::string &name,
+                                             bool plotfreq, bool plotwaterfall,
+                                             bool plotwaterfall3d, bool 
plottime,
+                                             bool plotconst,
                                              QWidget *parent);
   qtgui_sink_f (int fftsize, int wintype,
                float fmin, float fmax,
                const std::string &name,
+               bool plotfreq, bool plotwaterfall,
+               bool plotwaterfall3d, bool plottime,
+               bool plotconst,
                QWidget *parent);
 
 public:

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.cc 
    2009-04-15 00:46:36 UTC (rev 10840)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.cc 
    2009-04-15 00:48:39 UTC (rev 10841)
@@ -155,6 +155,14 @@
 }
 
 void
+qtgui_sink_c::set_frequency_range(const double centerfreq, 
+                                 const double startfreq,
+                                 const double stopfreq)
+{
+  d_main_gui->SetFrequencyRange(centerfreq, startfreq, stopfreq);
+}
+
+void
 qtgui_sink_c::fft(const gr_complex *data_in, int size, gr_complex *data_out)
 {
   if (d_window.size()) {

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.h  
    2009-04-15 00:46:36 UTC (rev 10840)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.h  
    2009-04-15 00:48:39 UTC (rev 10841)
@@ -96,6 +96,10 @@
   QWidget*  qwidget();
   PyObject* pyqwidget();
 
+  void set_frequency_range(const double centerfreq,
+                          const double startfreq,
+                          const double stopfreq);
+
   QApplication *d_qApplication;
   qtgui_obj *d_object;
 

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.cc 
    2009-04-15 00:46:36 UTC (rev 10840)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.cc 
    2009-04-15 00:48:39 UTC (rev 10841)
@@ -153,6 +153,14 @@
 }
 
 void
+qtgui_sink_f::set_frequency_range(const double centerfreq, 
+                                 const double startfreq,
+                                 const double stopfreq)
+{
+  d_main_gui->SetFrequencyRange(centerfreq, startfreq, stopfreq);
+}
+
+void
 qtgui_sink_f::fft(const float *data_in, int size, gr_complex *data_out)
 {
   if (d_window.size()) {

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.h  
    2009-04-15 00:46:36 UTC (rev 10840)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.h  
    2009-04-15 00:48:39 UTC (rev 10841)
@@ -96,6 +96,10 @@
   QWidget*  qwidget();
   PyObject* pyqwidget();
 
+  void set_frequency_range(const double centerfreq,
+                          const double startfreq,
+                          const double stopfreq);
+
   QApplication *d_qApplication;
   qtgui_obj *d_object;
 

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:46:36 UTC (rev 10840)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/spectrumdisplayform.cc
      2009-04-15 00:48:39 UTC (rev 10841)
@@ -469,7 +469,8 @@
   _frequencyDisplayPlot->SetFrequencyRange(newStartFrequency,
                                           newStopFrequency,
                                           newCenterFrequency,
-                                          
UseRFFrequenciesCheckBox->isChecked());
+                                          
UseRFFrequenciesCheckBox->isChecked(),
+                                          1000000.0);
   _waterfallDisplayPlot->SetFrequencyRange(newStartFrequency,
                                           newStopFrequency,
                                           newCenterFrequency,





reply via email to

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