GNU Radio 3.6.5.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 instrumentation_blk
48  * \ingroup qtgui_blk
49  *
50  * \details
51  * This is a QT-based graphical sink the takes a complex stream and
52  * plots it. The default action is to plot the signal as a PSD (FFT),
53  * spectrogram (waterfall), time domain I&Q, and constellation (I
54  * vs. Q) plots. The plots may be turned off by setting the
55  * appropriate boolean value in the constructor to False.
56  */
57 
59 {
60 private:
61  friend GR_QTGUI_API qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
62  double fc, double bw,
63  const std::string &name,
64  bool plotfreq, bool plotwaterfall,
65  bool plottime, bool plotconst,
66  QWidget *parent);
67  qtgui_sink_c (int fftsize, int wintype,
68  double fc, double bw,
69  const std::string &name,
70  bool plotfreq, bool plotwaterfall,
71  bool plottime, bool plotconst,
72  QWidget *parent);
73 
74  void forecast(int noutput_items, gr_vector_int &ninput_items_required);
75 
76  void initialize();
77 
78  int d_fftsize;
79  gr_firdes::win_type d_wintype;
80  std::vector<float> d_window;
81  double d_center_freq;
82  double d_bandwidth;
83  std::string d_name;
84  gruel::high_res_timer_type d_last_update;
85  bool d_update_active;
86 
87  bool d_shift;
88  gri_fft_complex *d_fft;
89 
90  int d_index;
91  gr_complex *d_residbuf;
92 
93  bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst;
94 
95  gruel::high_res_timer_type d_update_time;
96 
97  QWidget *d_parent;
98  SpectrumGUIClass *d_main_gui;
99 
100  void windowreset();
101  void buildwindow();
102  void fftresize();
103  void fft(const gr_complex *data_in, int size);
104 
105 public:
106  ~qtgui_sink_c();
107  void exec_();
108  QWidget* qwidget();
109  PyObject* pyqwidget();
110 
111  void set_frequency_range(const double centerfreq,
112  const double bandwidth);
113 
114  void set_time_domain_axis(double min, double max);
115  void set_constellation_axis(double xmin, double xmax,
116  double ymin, double ymax);
117  void set_constellation_pen_size(int size);
118  void set_frequency_axis(double min, double max);
119 
120  void set_update_time(double t);
121 
122  QApplication *d_qApplication;
123 
124  int general_work (int noutput_items,
125  gr_vector_int &ninput_items,
126  gr_vector_const_void_star &input_items,
127  gr_vector_void_star &output_items);
128 };
129 
130 #endif /* INCLUDED_QTGUI_SINK_C_H */