GNU Radio Manual and C++ API Reference  3.8.1.0
The Free & Open Software Radio Ecosystem
number_sink.h
Go to the documentation of this file.
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_H
24 #define INCLUDED_QTGUI_NUMBER_SINK_H
25 
26 #ifdef ENABLE_PYTHON
27 #include <Python.h>
28 #endif
29 
30 #include <gnuradio/qtgui/api.h>
33 #include <gnuradio/sync_block.h>
34 #include <qapplication.h>
35 
36 namespace gr {
37 namespace qtgui {
38 
39 /*!
40  * \brief A graphical sink to display numerical values of input streams.
41  * \ingroup instrumentation_blk
42  * \ingroup qtgui_blk
43  *
44  * \details
45  *
46  * Displays the data stream in as a number in a simple text box
47  * GUI along with an optional bar graph. The bar graph can be set
48  * to horizontal (NUM_GRAPH_HORIZ), vertical (NUM_GRAPH_VERT), or
49  * no graph (NUM_GRAPH_NONE).
50  *
51  * The displayed value can be the average of the input stream, in
52  * which case all items received are averaged. If not averaging,
53  * the display simply samples a value in the data stream based on
54  * the update time of this block.
55  *
56  * Note that due to a flaw in the implementation, this block
57  * cannot receive integer value inputs. It will take chars,
58  * shorts, and floats and properly convert them by setting
59  * itemsize of the constructor to one of these three values
60  * (sizeof_char, sizeof_short, and sizeof_float, respectively). If
61  * using integers, the block treats these as floats. Instead, put
62  * the integer input stream through an gr::blocks::int_to_float
63  * converter block.
64  */
65 class QTGUI_API number_sink : virtual public sync_block
66 {
67 public:
68  // gr::qtgui::number_sink::sptr
69  typedef boost::shared_ptr<number_sink> sptr;
70 
71  /*!
72  * \brief Build a number sink
73  *
74  * \param itemsize Size of input item stream
75  * \param average Averaging coefficient (0 - 1)
76  * \param graph_type Type of graph to use (number_sink::graph_t)
77  * \param nconnections number of signals connected to sink
78  * \param parent a QWidget parent object, if any
79  */
80  static sptr make(size_t itemsize,
81  float average = 0,
82  graph_t graph_type = NUM_GRAPH_HORIZ,
83  int nconnections = 1,
84  QWidget* parent = NULL);
85 
86  virtual void exec_() = 0;
87  virtual QWidget* qwidget() = 0;
88 
89 #ifdef ENABLE_PYTHON
90  virtual PyObject* pyqwidget() = 0;
91 #else
92  virtual void* pyqwidget() = 0;
93 #endif
94 
95  virtual void set_update_time(double t) = 0;
96  virtual void set_average(const float avg) = 0;
97  virtual void set_graph_type(const graph_t type) = 0;
98  virtual void
99  set_color(unsigned int which, const std::string& min, const std::string& max) = 0;
100  virtual void set_color(unsigned int which, int min, int max) = 0;
101  virtual void set_label(unsigned int which, const std::string& label) = 0;
102  virtual void set_min(unsigned int which, float min) = 0;
103  virtual void set_max(unsigned int which, float max) = 0;
104  virtual void set_title(const std::string& title) = 0;
105  virtual void set_unit(unsigned int which, const std::string& unit) = 0;
106  virtual void set_factor(unsigned int which, float factor) = 0;
107 
108  virtual float average() const = 0;
109  virtual graph_t graph_type() const = 0;
110  virtual std::string color_min(unsigned int which) const = 0;
111  virtual std::string color_max(unsigned int which) const = 0;
112  virtual std::string label(unsigned int which) const = 0;
113  virtual float min(unsigned int which) const = 0;
114  virtual float max(unsigned int which) const = 0;
115  virtual std::string title() const = 0;
116  virtual std::string unit(unsigned int which) const = 0;
117  virtual float factor(unsigned int which) const = 0;
118 
119  virtual void enable_menu(bool en = true) = 0;
120  virtual void enable_autoscale(bool en = true) = 0;
121 
122  virtual void reset() = 0;
123 
124  QApplication* d_qApplication;
125 };
126 
127 } /* namespace qtgui */
128 } /* namespace gr */
129 
130 #endif /* INCLUDED_QTGUI_NUMBER_SINK_H */
Definition: qtgui_types.h:132
boost::shared_ptr< number_sink > sptr
Definition: number_sink.h:69
float min(float a, float b)
graph_t
Definition: qtgui_types.h:130
A graphical sink to display numerical values of input streams.
Definition: number_sink.h:65
#define QTGUI_API
Definition: gr-qtgui/include/gnuradio/qtgui/api.h:30
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:43
synchronous 1:1 input to output with historyOverride work to provide the signal processing implementa...
Definition: sync_block.h:37
QApplication * d_qApplication
Definition: number_sink.h:124
BLOCKS_API size_t itemsize(vector_type type)