GNU Radio 3.3.0 C++ API
qtgui_sink_c.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2008,2009 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 INCLUDED_QTGUI_SINK_C_H
00024 #define INCLUDED_QTGUI_SINK_C_H
00025 
00026 #include <gr_block.h>
00027 #include <gr_firdes.h>
00028 #include <gri_fft.h>
00029 #include <qapplication.h>
00030 #include <qtgui.h>
00031 #include <Python.h>
00032 #include "SpectrumGUIClass.h"
00033 
00034 class qtgui_sink_c;
00035 typedef boost::shared_ptr<qtgui_sink_c> qtgui_sink_c_sptr;
00036 
00037 qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
00038                                      double fc=0, double bandwidth=1.0,
00039                                      const std::string &name="Spectrum Display",
00040                                      bool plotfreq=true, bool plotwaterfall=true,
00041                                      bool plotwaterfall3d=true, bool plottime=true,
00042                                      bool plotconst=true,
00043                                      bool use_openGL=true,
00044                                      QWidget *parent=NULL);
00045 
00046 class qtgui_sink_c : public gr_block
00047 {
00048 private:
00049   friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
00050                                               double fc, double bw,
00051                                               const std::string &name,
00052                                               bool plotfreq, bool plotwaterfall,
00053                                               bool plotwaterfall3d, bool plottime,
00054                                               bool plotconst,
00055                                               bool use_openGL,
00056                                               QWidget *parent);
00057   qtgui_sink_c (int fftsize, int wintype,
00058                 double fc, double bw, 
00059                 const std::string &name,
00060                 bool plotfreq, bool plotwaterfall,
00061                 bool plotwaterfall3d, bool plottime,
00062                 bool plotconst,
00063                 bool use_openGL,
00064                 QWidget *parent);
00065 
00066   void forecast(int noutput_items, gr_vector_int &ninput_items_required);
00067 
00068   // use opengl to force OpenGL on or off
00069   // this might be necessary for sessions over SSH
00070   void initialize(const bool opengl=true);
00071 
00072   int d_fftsize;
00073   gr_firdes::win_type d_wintype;
00074   std::vector<float> d_window;
00075   double d_center_freq;
00076   double d_bandwidth;
00077   std::string d_name;
00078   
00079   pthread_mutex_t d_pmutex;
00080 
00081   bool d_shift;
00082   gri_fft_complex *d_fft;
00083 
00084   int d_index;
00085   gr_complex *d_residbuf;
00086 
00087   bool d_plotfreq, d_plotwaterfall, d_plotwaterfall3d, d_plottime, d_plotconst;
00088   
00089   double d_update_time;
00090 
00091   QWidget *d_parent;
00092   SpectrumGUIClass *d_main_gui;
00093 
00094   void windowreset();
00095   void buildwindow();
00096   void fftresize();
00097   void fft(const gr_complex *data_in, int size);
00098   
00099 public:
00100   ~qtgui_sink_c();
00101   void exec_();
00102   void lock();
00103   void unlock();
00104   QWidget*  qwidget();
00105   PyObject* pyqwidget();
00106 
00107   void set_frequency_range(const double centerfreq,
00108                            const double bandwidth);
00109 
00110   void set_time_domain_axis(double min, double max);
00111   void set_constellation_axis(double xmin, double xmax,
00112                               double ymin, double ymax);
00113   void set_constellation_pen_size(int size);
00114   void set_frequency_axis(double min, double max);
00115 
00116   void set_update_time(double t);
00117 
00118   QApplication *d_qApplication;
00119   qtgui_obj *d_object;
00120 
00121   int general_work (int noutput_items,
00122                     gr_vector_int &ninput_items,
00123                     gr_vector_const_void_star &input_items,
00124                     gr_vector_void_star &output_items);
00125 };
00126 
00127 #endif /* INCLUDED_QTGUI_SINK_C_H */