Merging qtdevel2 branch -r10565:10849. This adds a lot of fixes and capabilities...
[debian/gnuradio] / gr-qtgui / src / lib / qtgui_sink_c.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_C_H
24 #define INCLUDED_QTGUI_SINK_C_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_c;
35 typedef boost::shared_ptr<qtgui_sink_c> qtgui_sink_c_sptr;
36
37 qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
38                                      float fmin=-0.5, float fmax=0.5,
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                                      QWidget *parent=NULL);
44
45 class qtgui_sink_c : public gr_block
46 {
47 private:
48   friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
49                                               float fmin, float fmax,
50                                               const std::string &name,
51                                               bool plotfreq, bool plotwaterfall,
52                                               bool plotwaterfall3d, bool plottime,
53                                               bool plotconst,
54                                               QWidget *parent);
55   qtgui_sink_c (int fftsize, int wintype,
56                 float fmin, float fmax, 
57                 const std::string &name,
58                 bool plotfreq, bool plotwaterfall,
59                 bool plotwaterfall3d, bool plottime,
60                 bool plotconst,
61                 QWidget *parent);
62
63   void initialize();
64
65   int d_fftsize;
66   gr_firdes::win_type d_wintype;
67   std::vector<float> d_window;
68   float d_fmin;
69   float d_fmax;
70   std::string d_name;
71   
72   pthread_mutex_t d_pmutex;
73
74   bool d_shift;
75   gri_fft_complex *d_fft;
76   gr_complex *d_fftdata;
77
78   int d_index;
79   gr_complex *d_residbuf;
80
81   bool d_plotfreq, d_plotwaterfall, d_plotwaterfall3d, d_plottime, d_plotconst;
82
83   QWidget *d_parent;
84   SpectrumGUIClass *d_main_gui;
85
86   void windowreset();
87   void buildwindow();
88   void fftresize();
89   void fft(const gr_complex *data_in, int size, gr_complex *data_out);
90   
91 public:
92   ~qtgui_sink_c();
93   void exec_();
94   void lock();
95   void unlock();
96   QWidget*  qwidget();
97   PyObject* pyqwidget();
98
99   void set_frequency_range(const double centerfreq,
100                            const double startfreq,
101                            const double stopfreq);
102
103   QApplication *d_qApplication;
104   qtgui_obj *d_object;
105
106   int general_work (int noutput_items,
107                     gr_vector_int &ninput_items,
108                     gr_vector_const_void_star &input_items,
109                     gr_vector_void_star &output_items);
110 };
111
112 #endif /* INCLUDED_QTGUI_SINK_C_H */