GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
69  // gr::qtgui::number_sink::sptr
70  typedef boost::shared_ptr<number_sink> sptr;
71 
72  /*!
73  * \brief Build a number sink
74  *
75  * \param itemsize Size of input item stream
76  * \param average Averaging coefficient (0 - 1)
77  * \param graph_type Type of graph to use (number_sink::graph_t)
78  * \param nconnections number of signals connected to sink
79  * \param parent a QWidget parent object, if any
80  */
81  static sptr make(size_t itemsize,
82  float average=0,
83  graph_t graph_type=NUM_GRAPH_HORIZ,
84  int nconnections=1,
85  QWidget *parent=NULL);
86 
87  virtual void exec_() = 0;
88  virtual QWidget* qwidget() = 0;
89 
90 #ifdef ENABLE_PYTHON
91  virtual PyObject* pyqwidget() = 0;
92 #else
93  virtual void* pyqwidget() = 0;
94 #endif
95 
96  virtual void set_update_time(double t) = 0;
97  virtual void set_average(const float avg) = 0;
98  virtual void set_graph_type(const graph_t type) = 0;
99  virtual void set_color(int which,
100  const std::string &min,
101  const std::string &max) = 0;
102  virtual void set_color(int which, int min, int max) = 0;
103  virtual void set_label(int which, const std::string &label) = 0;
104  virtual void set_min(int which, float min) = 0;
105  virtual void set_max(int which, float max) = 0;
106  virtual void set_title(const std::string &title) = 0;
107  virtual void set_unit(int which, const std::string &unit) = 0;
108  virtual void set_factor(int which, float factor) = 0;
109 
110  virtual float average() const = 0;
111  virtual graph_t graph_type() const = 0;
112  virtual std::string color_min(int which) const = 0;
113  virtual std::string color_max(int which) const = 0;
114  virtual std::string label(int which) const = 0;
115  virtual float min(int which) const = 0;
116  virtual float max(int which) const = 0;
117  virtual std::string title() const = 0;
118  virtual std::string unit(int which) const = 0;
119  virtual float factor(int which) const = 0;
120 
121  virtual void enable_menu(bool en=true) = 0;
122  virtual void enable_autoscale(bool en=true) = 0;
123 
124  virtual void reset() = 0;
125 
126  QApplication *d_qApplication;
127  };
128 
129  } /* namespace qtgui */
130 } /* namespace gr */
131 
132 #endif /* INCLUDED_QTGUI_NUMBER_SINK_H */
Definition: qtgui_types.h:144
boost::shared_ptr< number_sink > sptr
Definition: number_sink.h:70
float min(float a, float b)
graph_t
Definition: qtgui_types.h:142
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
Include this header to use the message passing features.
Definition: logger.h:131
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:126
BLOCKS_API size_t itemsize(vector_type type)