1 /* -*- c++ -*- */ 2 /* 3 * Copyright 2008,2009,2011,2012,2014,2018 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_IMPL_H 24 #define INCLUDED_QTGUI_SINK_C_IMPL_H 25 26 #include <gnuradio/qtgui/sink_c.h> 27 28 #include <gnuradio/fft/fft.h> 29 #include <gnuradio/filter/firdes.h> 30 #include <gnuradio/high_res_timer.h> 31 #include <gnuradio/qtgui/SpectrumGUIClass.h> 32 33 namespace gr { 34 namespace qtgui { 35 36 class QTGUI_API sink_c_impl : public sink_c 37 { 38 private: 39 void forecast(int noutput_items, gr_vector_int& ninput_items_required); 40 41 void initialize(); 42 43 int d_fftsize; 44 filter::firdes::win_type d_wintype; 45 std::vector<float> d_window; 46 double d_center_freq; 47 double d_bandwidth; 48 std::string d_name; 49 gr::high_res_timer_type d_last_update; 50 bool d_update_active; 51 52 const pmt::pmt_t d_port; 53 54 bool d_shift; 55 fft::fft_complex* d_fft; 56 57 int d_index; 58 gr_complex* d_residbuf; 59 float* d_magbuf; 60 61 bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst; 62 63 gr::high_res_timer_type d_update_time; 64 65 int d_argc; 66 char* d_argv; 67 QWidget* d_parent; 68 SpectrumGUIClass* d_main_gui; 69 70 void windowreset(); 71 void buildwindow(); 72 void fftresize(); 73 void check_clicked(); 74 void fft(float* data_out, const gr_complex* data_in, int size); 75 76 // Handles message input port for setting new center frequency. 77 // The message is a PMT pair (intern('freq'), double(frequency)). 78 void handle_set_freq(pmt::pmt_t msg); 79 80 public: 81 sink_c_impl(int fftsize, 82 int wintype, 83 double fc, 84 double bw, 85 const std::string& name, 86 bool plotfreq, 87 bool plotwaterfall, 88 bool plottime, 89 bool plotconst, 90 QWidget* parent); 91 ~sink_c_impl(); 92 93 bool check_topology(int ninputs, int noutputs); 94 95 void exec_(); 96 QWidget* qwidget(); 97 98 #ifdef ENABLE_PYTHON 99 PyObject* pyqwidget(); 100 #else 101 void* pyqwidget(); 102 #endif 103 104 void set_fft_size(const int fftsize); 105 int fft_size() const; 106 107 void set_frequency_range(const double centerfreq, const double bandwidth); 108 void set_fft_power_db(double min, double max); 109 void enable_rf_freq(bool en); 110 111 // void set_time_domain_axis(double min, double max); 112 // void set_constellation_axis(double xmin, double xmax, 113 // double ymin, double ymax); 114 // void set_constellation_pen_size(int size); 115 116 void set_update_time(double t); 117 118 int general_work(int noutput_items, 119 gr_vector_int& ninput_items, 120 gr_vector_const_void_star& input_items, 121 gr_vector_void_star& output_items); 122 }; 123 124 } /* namespace qtgui */ 125 } /* namespace gr */ 126 127 #endif /* INCLUDED_QTGUI_SINK_C_IMPL_H */ 128