91c6b03e61e146816b642b0f8596695a0a20b9d9
[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                                      double fc=0, double bandwidth=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_c : public gr_block
47 {
48 private:
49   friend qtgui_sink_c_sptr qtgui_make_sink_c (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_c (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   // use opengl to force OpenGL on or off
69   // this might be necessary for sessions over SSH
70   void initialize(const bool opengl=true);
71
72   int d_fftsize;
73   gr_firdes::win_type d_wintype;
74   std::vector<float> d_window;
75   double d_center_freq;
76   double d_bandwidth;
77   std::string d_name;
78   
79   pthread_mutex_t d_pmutex;
80
81   bool d_shift;
82   gri_fft_complex *d_fft;
83
84   int d_index;
85   gr_complex *d_residbuf;
86
87   bool d_plotfreq, d_plotwaterfall, d_plotwaterfall3d, d_plottime, d_plotconst;
88   
89   QWidget *d_parent;
90   SpectrumGUIClass *d_main_gui;
91
92   void windowreset();
93   void buildwindow();
94   void fftresize();
95   void fft(const gr_complex *data_in, int size);
96   
97 public:
98   ~qtgui_sink_c();
99   void exec_();
100   void lock();
101   void unlock();
102   QWidget*  qwidget();
103   PyObject* pyqwidget();
104
105   void set_frequency_range(const double centerfreq,
106                            const double bandwidth);
107
108   void set_time_domain_axis(double min, double max);
109   void set_constellation_axis(double xmin, double xmax,
110                               double ymin, double ymax);
111   void set_constellation_pen_size(int size);
112   void set_frequency_axis(double min, double max);
113
114   QApplication *d_qApplication;
115   qtgui_obj *d_object;
116
117   int general_work (int noutput_items,
118                     gr_vector_int &ninput_items,
119                     gr_vector_const_void_star &input_items,
120                     gr_vector_void_star &output_items);
121 };
122
123 #endif /* INCLUDED_QTGUI_SINK_C_H */