47c928d17ce55e0ab508b506ff26471c8c6bc8ee
[debian/gnuradio] / gr-qtgui / src / lib / qtgui_sink_f.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008,2009 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #ifndef INCLUDED_QTGUI_SINK_F_H
24 #define INCLUDED_QTGUI_SINK_F_H
25
26 #include <gr_block.h>
27 #include <gr_firdes.h>
28 #include <gri_fft.h>
29 #include <qapplication.h>
30 #include <qtgui.h>
31 #include <Python.h>
32 #include "SpectrumGUIClass.h"
33
34 class qtgui_sink_f;
35 typedef boost::shared_ptr<qtgui_sink_f> qtgui_sink_f_sptr;
36
37 qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
38                                      double fc=0, double bw=1.0,
39                                      const std::string &name="Spectrum Display",
40                                      bool plotfreq=true, bool plotwaterfall=true,
41                                      bool plotwaterfall3d=true, bool plottime=true,
42                                      bool plotconst=true,
43                                      bool use_openGL=true,
44                                      QWidget *parent=NULL);
45
46 class qtgui_sink_f : public gr_block
47 {
48 private:
49   friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
50                                               double fc, double bw,
51                                               const std::string &name,
52                                               bool plotfreq, bool plotwaterfall,
53                                               bool plotwaterfall3d, bool plottime,
54                                               bool plotconst,
55                                               bool use_openGL,
56                                               QWidget *parent);
57   qtgui_sink_f (int fftsize, int wintype,
58                 double fc, double bw,
59                 const std::string &name,
60                 bool plotfreq, bool plotwaterfall,
61                 bool plotwaterfall3d, bool plottime,
62                 bool plotconst,
63                 bool use_openGL,
64                 QWidget *parent);
65
66   void forecast(int noutput_items, gr_vector_int &ninput_items_required);
67
68   void initialize(const bool opengl=true);
69
70   int d_fftsize;
71   gr_firdes::win_type d_wintype;
72   std::vector<float> d_window;
73   double d_center_freq;
74   double d_bandwidth;
75   std::string d_name;
76   
77   pthread_mutex_t d_pmutex;
78
79   bool d_shift;
80   gri_fft_complex *d_fft;
81
82   int d_index;
83   float *d_residbuf;
84
85   bool d_plotfreq, d_plotwaterfall, d_plotwaterfall3d, d_plottime, d_plotconst;
86
87   QWidget *d_parent;
88   SpectrumGUIClass *d_main_gui; 
89
90   void windowreset();
91   void buildwindow();
92   void fftresize();
93   void fft(const float *data_in, int size);
94   
95 public:
96   ~qtgui_sink_f();
97   void exec_();
98   void lock();
99   void unlock();
100   QWidget*  qwidget();
101   PyObject* pyqwidget();
102
103   void set_frequency_range(const double centerfreq,
104                            const double bandwidth);
105
106   void set_time_domain_axis(double min, double max);
107   void set_constellation_axis(double xmin, double xmax,
108                               double ymin, double ymax);
109   void set_constellation_pen_size(int size);
110   void set_frequency_axis(double min, double max);
111
112   QApplication *d_qApplication;
113   qtgui_obj *d_object;
114
115   int general_work (int noutput_items,
116                     gr_vector_int &ninput_items,
117                     gr_vector_const_void_star &input_items,
118                     gr_vector_void_star &output_items);
119 };
120
121 #endif /* INCLUDED_QTGUI_SINK_F_H */