1 /* -*- c++ -*- */
2 /*
3  * Copyright 2014 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_NUMBER_SINK_IMPL_H
24 #define INCLUDED_QTGUI_NUMBER_SINK_IMPL_H
25 
26 #include <gnuradio/qtgui/number_sink.h>
27 
28 #include <gnuradio/filter/single_pole_iir.h>
29 #include <gnuradio/high_res_timer.h>
30 #include <gnuradio/qtgui/numberdisplayform.h>
31 
32 namespace gr {
33 namespace qtgui {
34 
35 class QTGUI_API number_sink_impl : public number_sink
36 {
37 private:
38     void initialize();
39 
40     size_t d_itemsize;
41     float d_average;
42     graph_t d_type;
43     int d_nconnections;
44 
45     int d_index, d_start, d_end;
46     std::vector<double*> d_buffers;
47     std::vector<std::vector<gr::tag_t>> d_tags;
48 
49     int d_argc;
50     char* d_argv;
51     QWidget* d_parent;
52     NumberDisplayForm* d_main_gui;
53 
54     std::vector<float> d_avg_value;
55     std::vector<filter::single_pole_iir<float, float, float>> d_iir;
56 
57     gr::high_res_timer_type d_update_time;
58     gr::high_res_timer_type d_last_time;
59 
60     void _reset();
61     void _npoints_resize();
62     void _gui_update_trigger();
63 
64     float get_item(const void* input_items, int n);
65 
66 public:
67     number_sink_impl(size_t itemsize,
68                      float average = 0,
69                      graph_t graph_type = NUM_GRAPH_HORIZ,
70                      int nconnections = 1,
71                      QWidget* parent = NULL);
72     ~number_sink_impl();
73 
74     bool check_topology(int ninputs, int noutputs);
75 
76     void exec_();
77     QWidget* qwidget();
78 
79 #ifdef ENABLE_PYTHON
80     PyObject* pyqwidget();
81 #else
82     void* pyqwidget();
83 #endif
84 
85     void set_update_time(double t);
86     void set_average(const float avg);
87     void set_graph_type(const graph_t type);
88     void set_color(unsigned int which, const std::string& min, const std::string& max);
89     void set_color(unsigned int which, int min, int max);
90     void set_label(unsigned int which, const std::string& label);
91     void set_min(unsigned int which, float min);
92     void set_max(unsigned int which, float max);
93     void set_title(const std::string& title);
94     void set_unit(unsigned int which, const std::string& unit);
95     void set_factor(unsigned int which, float factor);
96 
97     float average() const;
98     graph_t graph_type() const;
99     std::string color_min(unsigned int which) const;
100     std::string color_max(unsigned int which) const;
101     std::string label(unsigned int which) const;
102     float min(unsigned int which) const;
103     float max(unsigned int which) const;
104     std::string title() const;
105     std::string unit(unsigned int which) const;
106     float factor(unsigned int which) const;
107 
108     void enable_menu(bool en);
109     void enable_autoscale(bool en = true);
110 
111     void reset();
112 
113     int work(int noutput_items,
114              gr_vector_const_void_star& input_items,
115              gr_vector_void_star& output_items);
116 };
117 
118 } /* namespace qtgui */
119 } /* namespace gr */
120 
121 #endif /* INCLUDED_QTGUI_NUMBER_SINK_IMPL_H */
122