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