GNU Radio 3.7.0 C++ API
SpectrumGUIClass.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2008-2011 Free Software Foundation, Inc.
00004  *
00005  * This file is part of GNU Radio
00006  *
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  *
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef SPECTRUM_GUI_CLASS_HPP
00024 #define SPECTRUM_GUI_CLASS_HPP
00025 
00026 #include <gnuradio/thread/thread.h>
00027 #include <qwidget.h>
00028 #include <qapplication.h>
00029 #include <qlabel.h>
00030 #include <qslider.h>
00031 #include <gnuradio/qtgui/spectrumUpdateEvents.h>
00032 
00033 class SpectrumDisplayForm;
00034 #include <gnuradio/qtgui/spectrumdisplayform.h>
00035 
00036 #include <cmath>
00037 
00038 #include <complex>
00039 #include <vector>
00040 #include <string>
00041 
00042 /*!
00043  * \brief QWidget class for controlling plotting.
00044  * \ingroup qtgui_blk
00045  */
00046 class SpectrumGUIClass
00047 {
00048 public:
00049   SpectrumGUIClass(const uint64_t maxDataSize, const uint64_t fftSize,
00050                    const double newCenterFrequency,
00051                    const double newStartFrequency,
00052                    const double newStopFrequency);
00053   ~SpectrumGUIClass();
00054   void reset();
00055 
00056   void openSpectrumWindow(QWidget*,
00057                           const bool frequency=true, const bool waterfall=true,
00058                           const bool time=true, const bool constellation=true);
00059   void setDisplayTitle(const std::string);
00060 
00061   bool getWindowOpenFlag();
00062   void setWindowOpenFlag(const bool);
00063 
00064   void setFrequencyRange(const double, const double, const double);
00065   double getStartFrequency();
00066   double getStopFrequency();
00067   double getCenterFrequency();
00068 
00069   void updateWindow(const bool, const float*,
00070                     const uint64_t, const float*,
00071                     const uint64_t, const float*,
00072                     const uint64_t,
00073                     const gr::high_res_timer_type, const bool);
00074 
00075   float getPowerValue();
00076   void setPowerValue(const float);
00077 
00078   int getWindowType();
00079   void setWindowType(const int);
00080 
00081   int getFFTSize();
00082   int getFFTSizeIndex();
00083   void setFFTSize(const int);
00084 
00085   gr::high_res_timer_type getLastGUIUpdateTime();
00086   void setLastGUIUpdateTime(const gr::high_res_timer_type);
00087 
00088   unsigned int getPendingGUIUpdateEvents();
00089   void incrementPendingGUIUpdateEvents();
00090   void decrementPendingGUIUpdateEvents();
00091   void resetPendingGUIUpdateEvents();
00092 
00093   static const long MAX_FFT_SIZE;
00094   static const long MIN_FFT_SIZE;
00095 
00096   QWidget* qwidget();
00097 
00098   void setTimeDomainAxis(double min, double max);
00099   void setConstellationAxis(double xmin, double xmax,
00100                             double ymin, double ymax);
00101   void setConstellationPenSize(int size);
00102   void setFrequencyAxis(double min, double max);
00103 
00104   void setUpdateTime(double t);
00105 
00106 protected:
00107 
00108 private:
00109 
00110   gr::thread::mutex d_mutex;
00111   int64_t _dataPoints;
00112   std::string _title;
00113   double _centerFrequency;
00114   double _startFrequency;
00115   double _stopFrequency;
00116   float _powerValue;
00117   bool _windowOpennedFlag;
00118   int _windowType;
00119   int64_t _lastDataPointCount;
00120   int _fftSize;
00121   gr::high_res_timer_type _lastGUIUpdateTime;
00122   unsigned int _pendingGUIUpdateEventsCount;
00123   int _droppedEntriesCount;
00124   bool _fftBuffersCreatedFlag;
00125   double _updateTime;
00126 
00127   SpectrumDisplayForm* _spectrumDisplayForm;
00128 
00129   float* _fftPoints;
00130   double* _realTimeDomainPoints;
00131   double* _imagTimeDomainPoints;
00132 };
00133 
00134 #endif /* SPECTRUM_GUI_CLASS_HPP */