1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012,2014-2015 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_CONST_SINK_C_IMPL_H
24 #define INCLUDED_QTGUI_CONST_SINK_C_IMPL_H
25 
26 #include <gnuradio/qtgui/const_sink_c.h>
27 
28 #include <gnuradio/high_res_timer.h>
29 #include <gnuradio/qtgui/constellationdisplayform.h>
30 
31 namespace gr {
32 namespace qtgui {
33 
34 class QTGUI_API const_sink_c_impl : public const_sink_c
35 {
36 private:
37     void initialize();
38 
39     int d_size, d_buffer_size;
40     std::string d_name;
41     int d_nconnections;
42 
43     int d_index, d_start, d_end;
44     std::vector<double*> d_residbufs_real;
45     std::vector<double*> d_residbufs_imag;
46 
47     int d_argc;
48     char* d_argv;
49     QWidget* d_parent;
50     ConstellationDisplayForm* d_main_gui;
51 
52     gr::high_res_timer_type d_update_time;
53     gr::high_res_timer_type d_last_time;
54 
55     // Members used for triggering scope
56     trigger_mode d_trigger_mode;
57     trigger_slope d_trigger_slope;
58     float d_trigger_level;
59     int d_trigger_channel;
60     pmt::pmt_t d_trigger_tag_key;
61     bool d_triggered;
62     int d_trigger_count;
63 
64     void _reset();
65     void _npoints_resize();
66     void _gui_update_trigger();
67     void _test_trigger_tags(int nitems);
68     void _test_trigger_norm(int nitems, gr_vector_const_void_star inputs);
69     bool _test_trigger_slope(const gr_complex* in) const;
70 
71     // Handles message input port for displaying PDU samples.
72     void handle_pdus(pmt::pmt_t msg);
73 
74 public:
75     const_sink_c_impl(int size,
76                       const std::string& name,
77                       int nconnections,
78                       QWidget* parent = NULL);
79     ~const_sink_c_impl();
80 
81     bool check_topology(int ninputs, int noutputs);
82 
83     void exec_();
84     QWidget* qwidget();
85 
86 #ifdef ENABLE_PYTHON
87     PyObject* pyqwidget();
88 #else
89     void* pyqwidget();
90 #endif
91 
92     void set_y_axis(double min, double max);
93     void set_x_axis(double min, double max);
94 
95     void set_update_time(double t);
96     void set_title(const std::string& title);
97     void set_line_label(unsigned int which, const std::string& label);
98     void set_line_color(unsigned int which, const std::string& color);
99     void set_line_width(unsigned int which, int width);
100     void set_line_style(unsigned int which, int style);
101     void set_line_marker(unsigned int which, int marker);
102     void set_nsamps(const int size);
103     void set_line_alpha(unsigned int which, double alpha);
104     void set_trigger_mode(trigger_mode mode,
105                           trigger_slope slope,
106                           float level,
107                           int channel,
108                           const std::string& tag_key = "");
109 
110     std::string title();
111     std::string line_label(unsigned int which);
112     std::string line_color(unsigned int which);
113     int line_width(unsigned int which);
114     int line_style(unsigned int which);
115     int line_marker(unsigned int which);
116     double line_alpha(unsigned int which);
117 
118     void set_size(int width, int height);
119 
120     int nsamps() const;
121     void enable_menu(bool en);
122     void enable_autoscale(bool en);
123     void enable_grid(bool en);
124     void enable_axis_labels(bool en);
125     void disable_legend();
126     void reset();
127 
128     int work(int noutput_items,
129              gr_vector_const_void_star& input_items,
130              gr_vector_void_star& output_items);
131 };
132 
133 } /* namespace qtgui */
134 } /* namespace gr */
135 
136 #endif /* INCLUDED_QTGUI_CONST_SINK_C_IMPL_H */
137