GNU Radio Manual and C++ API Reference 3.7.14.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
36namespace gr {
37namespace 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 */
65class QTGUI_API number_sink : virtual public sync_block
66{
67public:
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 set_color(int which, const std::string& min, const std::string& max) = 0;
99 virtual void set_color(int which, int min, int max) = 0;
100 virtual void set_label(int which, const std::string& label) = 0;
101 virtual void set_min(int which, float min) = 0;
102 virtual void set_max(int which, float max) = 0;
103 virtual void set_title(const std::string& title) = 0;
104 virtual void set_unit(int which, const std::string& unit) = 0;
105 virtual void set_factor(int which, float factor) = 0;
106
107 virtual float average() const = 0;
108 virtual graph_t graph_type() const = 0;
109 virtual std::string color_min(int which) const = 0;
110 virtual std::string color_max(int which) const = 0;
111 virtual std::string label(int which) const = 0;
112 virtual float min(int which) const = 0;
113 virtual float max(int which) const = 0;
114 virtual std::string title() const = 0;
115 virtual std::string unit(int which) const = 0;
116 virtual float factor(int which) const = 0;
117
118 virtual void enable_menu(bool en = true) = 0;
119 virtual void enable_autoscale(bool en = true) = 0;
120
121 virtual void reset() = 0;
122
123 QApplication* d_qApplication;
124};
125
126} /* namespace qtgui */
127} /* namespace gr */
128
129#endif /* INCLUDED_QTGUI_NUMBER_SINK_H */
A graphical sink to display numerical values of input streams.
Definition: number_sink.h:66
virtual void * pyqwidget()=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_unit(int which, const std::string &unit)=0
virtual void set_label(int which, const std::string &label)=0
virtual float average() const =0
virtual float max(int which) const =0
virtual std::string title() const =0
virtual void enable_menu(bool en=true)=0
virtual void reset()=0
virtual void set_graph_type(const graph_t type)=0
virtual std::string color_max(int which) const =0
virtual void set_factor(int which, float factor)=0
QApplication * d_qApplication
Definition: number_sink.h:123
boost::shared_ptr< number_sink > sptr
Definition: number_sink.h:69
virtual float min(int which) const =0
virtual std::string color_min(int which) const =0
virtual void set_min(int which, float min)=0
virtual void set_color(int which, int min, int max)=0
virtual float factor(int which) const =0
virtual void set_title(const std::string &title)=0
virtual void set_color(int which, const std::string &min, const std::string &max)=0
virtual void set_average(const float avg)=0
virtual std::string unit(int which) const =0
virtual void enable_autoscale(bool en=true)=0
virtual void set_update_time(double t)=0
virtual QWidget * qwidget()=0
virtual std::string label(int which) const =0
virtual void set_max(int which, float max)=0
virtual void exec_()=0
virtual graph_t graph_type() const =0
synchronous 1:1 input to output with history
Definition: sync_block.h:38
#define QTGUI_API
Definition: gr-qtgui/include/gnuradio/qtgui/api.h:30
BLOCKS_API size_t itemsize(vector_type type)
graph_t
Definition: qtgui_types.h:130
@ NUM_GRAPH_HORIZ
Definition: qtgui_types.h:132
float min(float a, float b)
Include this header to use the message passing features.
Definition: basic_block.h:45