Fixes the replotting update. It's now based on a QTimer so it's in the event buffer...
[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   double d_update_time;
88
89   QWidget *d_parent;
90   SpectrumGUIClass *d_main_gui; 
91
92   void windowreset();
93   void buildwindow();
94   void fftresize();
95   void fft(const float *data_in, int size);
96   
97 public:
98   ~qtgui_sink_f();
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   void set_update_time(double t);
115
116   QApplication *d_qApplication;
117   qtgui_obj *d_object;
118
119   int general_work (int noutput_items,
120                     gr_vector_int &ninput_items,
121                     gr_vector_const_void_star &input_items,
122                     gr_vector_void_star &output_items);
123 };
124
125 #endif /* INCLUDED_QTGUI_SINK_F_H */