GNU Radio 3.5.1 C++ API
qtgui_sink_f.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2008,2009,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 INCLUDED_QTGUI_SINK_F_H
00024 #define INCLUDED_QTGUI_SINK_F_H
00025 
00026 #include <Python.h>
00027 #include <gr_qtgui_api.h>
00028 #include <gr_block.h>
00029 #include <gr_firdes.h>
00030 #include <gri_fft.h>
00031 #include <qapplication.h>
00032 #include "SpectrumGUIClass.h"
00033 
00034 class qtgui_sink_f;
00035 typedef boost::shared_ptr<qtgui_sink_f> qtgui_sink_f_sptr;
00036 
00037 GR_QTGUI_API qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
00038                                      double fc=0, double bw=1.0,
00039                                      const std::string &name="Spectrum Display",
00040                                      bool plotfreq=true, bool plotwaterfall=true,
00041                                      bool plottime=true, bool plotconst=false,
00042                                      QWidget *parent=NULL);
00043 
00044 /*!
00045  * \brief A graphical sink to display freq, spec, and time.
00046  * \ingroup qtgui_blk
00047  *
00048  * This is a QT-based graphical sink the takes a float stream and
00049  * plots it. The default action is to plot the signal as a PSD (FFT),
00050  * spectrogram (waterfall), and time domain plots. The plots may be
00051  * turned off by setting the appropriate boolean value in the
00052  * constructor to False.
00053  */
00054 
00055 class GR_QTGUI_API qtgui_sink_f : public gr_block
00056 {
00057 private:
00058   friend GR_QTGUI_API qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
00059                                               double fc, double bw,
00060                                               const std::string &name,
00061                                               bool plotfreq, bool plotwaterfall,
00062                                               bool plottime, bool plotconst,
00063                                               QWidget *parent);
00064   qtgui_sink_f (int fftsize, int wintype,
00065                 double fc, double bw,
00066                 const std::string &name,
00067                 bool plotfreq, bool plotwaterfall,
00068                 bool plottime, bool plotconst,
00069                 QWidget *parent);
00070 
00071   void forecast(int noutput_items, gr_vector_int &ninput_items_required);
00072 
00073   void initialize();
00074 
00075   int d_fftsize;
00076   gr_firdes::win_type d_wintype;
00077   std::vector<float> d_window;
00078   double d_center_freq;
00079   double d_bandwidth;
00080   std::string d_name;
00081   
00082   bool d_shift;
00083   gri_fft_complex *d_fft;
00084 
00085   int d_index;
00086   float *d_residbuf;
00087 
00088   bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst;
00089 
00090   double d_update_time;
00091 
00092   QWidget *d_parent;
00093   SpectrumGUIClass *d_main_gui; 
00094 
00095   void windowreset();
00096   void buildwindow();
00097   void fftresize();
00098   void fft(const float *data_in, int size);
00099   
00100 public:
00101   ~qtgui_sink_f();
00102   void exec_();
00103   QWidget*  qwidget();
00104   PyObject* pyqwidget();
00105 
00106   void set_frequency_range(const double centerfreq,
00107                            const double bandwidth);
00108 
00109   void set_time_domain_axis(double min, double max);
00110   void set_constellation_axis(double xmin, double xmax,
00111                               double ymin, double ymax);
00112   void set_constellation_pen_size(int size);
00113   void set_frequency_axis(double min, double max);
00114 
00115   void set_update_time(double t);
00116 
00117   QApplication *d_qApplication;
00118 
00119   int general_work (int noutput_items,
00120                     gr_vector_int &ninput_items,
00121                     gr_vector_const_void_star &input_items,
00122                     gr_vector_void_star &output_items);
00123 };
00124 
00125 #endif /* INCLUDED_QTGUI_SINK_F_H */