GNU Radio 3.5.3.1 C++ API
qtgui_sink_c.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008,2009,2011 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 <Python.h>
27 #include <gr_qtgui_api.h>
28 #include <gr_block.h>
29 #include <gr_firdes.h>
30 #include <gri_fft.h>
31 #include <qapplication.h>
32 #include <gruel/high_res_timer.h>
33 #include "SpectrumGUIClass.h"
34 
35 class qtgui_sink_c;
37 
38 GR_QTGUI_API qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
39  double fc=0, double bandwidth=1.0,
40  const std::string &name="Spectrum Display",
41  bool plotfreq=true, bool plotwaterfall=true,
42  bool plottime=true, bool plotconst=true,
43  QWidget *parent=NULL);
44 
45 /*!
46  * \brief A graphical sink to display freq, spec, time, and const plots.
47  * \ingroup qtgui_blk
48  *
49  * This is a QT-based graphical sink the takes a complex stream and
50  * plots it. The default action is to plot the signal as a PSD (FFT),
51  * spectrogram (waterfall), time domain I&Q, and constellation (I
52  * vs. Q) plots. The plots may be turned off by setting the
53  * appropriate boolean value in the constructor to False.
54  */
55 
57 {
58 private:
59  friend GR_QTGUI_API qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
60  double fc, double bw,
61  const std::string &name,
62  bool plotfreq, bool plotwaterfall,
63  bool plottime, bool plotconst,
64  QWidget *parent);
65  qtgui_sink_c (int fftsize, int wintype,
66  double fc, double bw,
67  const std::string &name,
68  bool plotfreq, bool plotwaterfall,
69  bool plottime, bool plotconst,
70  QWidget *parent);
71 
72  void forecast(int noutput_items, gr_vector_int &ninput_items_required);
73 
74  void initialize();
75 
76  int d_fftsize;
77  gr_firdes::win_type d_wintype;
78  std::vector<float> d_window;
79  double d_center_freq;
80  double d_bandwidth;
81  std::string d_name;
82  gruel::high_res_timer_type d_last_update;
83  bool d_update_active;
84 
85  bool d_shift;
86  gri_fft_complex *d_fft;
87 
88  int d_index;
89  gr_complex *d_residbuf;
90 
91  bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst;
92 
93  gruel::high_res_timer_type d_update_time;
94 
95  QWidget *d_parent;
96  SpectrumGUIClass *d_main_gui;
97 
98  void windowreset();
99  void buildwindow();
100  void fftresize();
101  void fft(const gr_complex *data_in, int size);
102 
103 public:
104  ~qtgui_sink_c();
105  void exec_();
106  QWidget* qwidget();
107  PyObject* pyqwidget();
108 
109  void set_frequency_range(const double centerfreq,
110  const double bandwidth);
111 
112  void set_time_domain_axis(double min, double max);
113  void set_constellation_axis(double xmin, double xmax,
114  double ymin, double ymax);
115  void set_constellation_pen_size(int size);
116  void set_frequency_axis(double min, double max);
117 
118  void set_update_time(double t);
119 
120  QApplication *d_qApplication;
121 
122  int general_work (int noutput_items,
123  gr_vector_int &ninput_items,
124  gr_vector_const_void_star &input_items,
125  gr_vector_void_star &output_items);
126 };
127 
128 #endif /* INCLUDED_QTGUI_SINK_C_H */