GNU Radio Manual and C++ API Reference  v3.9.2.0-89-gb7c7001e
The Free & Open Software Radio Ecosystem
histogram_sink_f.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2013,2015 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_HISTOGRAM_SINK_F_H
12 #define INCLUDED_QTGUI_HISTOGRAM_SINK_F_H
13 
14 #ifdef ENABLE_PYTHON
15 #include <Python.h>
16 #endif
17 
18 #include <gnuradio/qtgui/api.h>
19 #include <gnuradio/sync_block.h>
20 #include <qapplication.h>
21 
22 namespace gr {
23 namespace qtgui {
24 
25 /*!
26  * \brief A graphical sink to display a histogram.
27  * \ingroup instrumentation_blk
28  * \ingroup qtgui_blk
29  *
30  * \details
31  * This is a QT-based graphical sink the displays a histogram of
32  * the data.
33  *
34  * This histogram allows you to set and change at runtime the
35  * number of points to plot at once and the number of bins in the
36  * histogram. Both x and y-axis have their own auto-scaling
37  * behavior. By default, auto-scaling the y-axis is turned on and
38  * continuously updates the y-axis max value based on the
39  * currently plotted histogram.
40  *
41  * The x-axis auto-scaling function only updates once when
42  * clicked. This resets the x-axis to the current range of minimum
43  * and maximum values represented in the histogram. It resets any
44  * values currently displayed because the location and width of
45  * the bins may have changed.
46  *
47  * The histogram also has an accumulate function that simply
48  * accumulates the data between calls to work. When accumulate is
49  * activated, the y-axis autoscaling is turned on by default as
50  * the values will quickly grow in the this direction.
51  *
52  * The sink supports plotting streaming float data or
53  * messages. The message port is named "in". The two modes cannot
54  * be used simultaneously, and \p nconnections should be set to 0
55  * when using the message mode. GRC handles this issue by
56  * providing the "Float Message" type that removes the streaming
57  * port(s).
58  *
59  * This sink can plot messages that contain either uniform vectors
60  * of float 32 values (pmt::is_f32vector) or PDUs where the data
61  * is a uniform vector of float 32 values.
62  */
63 class QTGUI_API histogram_sink_f : virtual public sync_block
64 {
65 public:
66  // gr::qtgui::histogram_sink_f::sptr
67  typedef std::shared_ptr<histogram_sink_f> sptr;
68 
69  /*!
70  * \brief Build floating point histogram sink
71  *
72  * \param size number of points to plot at once
73  * \param bins number of bins to sort the data into
74  * \param xmin minimum x-axis value
75  * \param xmax maximum x-axis value
76  * \param name title for the plot
77  * \param nconnections number of signals connected to sink
78  * \param parent a QWidget parent object, if any
79  */
80  static sptr make(int size,
81  int bins,
82  double xmin,
83  double xmax,
84  const std::string& name,
85  int nconnections = 1,
86  QWidget* parent = NULL);
87 
88  virtual void exec_() = 0;
89  virtual QWidget* qwidget() = 0;
90 
91 #ifdef ENABLE_PYTHON
92  virtual PyObject* pyqwidget() = 0;
93 #else
94  virtual void* pyqwidget() = 0;
95 #endif
96 
97 public:
98  virtual std::string title() = 0;
99  virtual std::string line_label(unsigned int which) = 0;
100  virtual std::string line_color(unsigned int which) = 0;
101  virtual int line_width(unsigned int which) = 0;
102  virtual int line_style(unsigned int which) = 0;
103  virtual int line_marker(unsigned int which) = 0;
104  virtual double line_alpha(unsigned int which) = 0;
105 
106  virtual void set_size(int width, int height) = 0;
107 
108  virtual void enable_menu(bool en = true) = 0;
109  virtual void enable_grid(bool en = true) = 0;
110  virtual void enable_autoscale(bool en = true) = 0;
111  virtual void enable_semilogx(bool en = true) = 0;
112  virtual void enable_semilogy(bool en = true) = 0;
113  virtual void enable_accumulate(bool en = true) = 0;
114  virtual void enable_axis_labels(bool en = true) = 0;
115  virtual void autoscalex() = 0;
116  virtual int nsamps() const = 0;
117  virtual int bins() const = 0;
118  virtual void reset() = 0;
119 
120  QApplication* d_qApplication;
121 
122  virtual void set_y_axis(double min, double max) = 0;
123  virtual void set_x_axis(double min, double max) = 0;
124  virtual void set_update_time(double t) = 0;
125  virtual void set_title(const std::string& title) = 0;
126  virtual void set_line_label(unsigned int which, const std::string& line) = 0;
127  virtual void set_line_color(unsigned int which, const std::string& color) = 0;
128  virtual void set_line_width(unsigned int which, int width) = 0;
129  virtual void set_line_style(unsigned int which, int style) = 0;
130  virtual void set_line_marker(unsigned int which, int marker) = 0;
131  virtual void set_line_alpha(unsigned int which, double alpha) = 0;
132  virtual void set_nsamps(const int newsize) = 0;
133  virtual void set_bins(const int bins) = 0;
134  virtual void disable_legend() = 0;
135 };
136 
137 } /* namespace qtgui */
138 } /* namespace gr */
139 
140 #endif /* INCLUDED_QTGUI_HISTOGRAM_SINK_F_H */
A graphical sink to display a histogram.
Definition: histogram_sink_f.h:64
virtual void set_line_alpha(unsigned int which, double alpha)=0
virtual void enable_axis_labels(bool en=true)=0
virtual void enable_menu(bool en=true)=0
virtual void enable_accumulate(bool en=true)=0
std::shared_ptr< histogram_sink_f > sptr
Definition: histogram_sink_f.h:67
virtual int line_style(unsigned int which)=0
virtual void set_y_axis(double min, double max)=0
virtual void disable_legend()=0
virtual int line_width(unsigned int which)=0
virtual double line_alpha(unsigned int which)=0
virtual std::string title()=0
virtual void set_line_label(unsigned int which, const std::string &line)=0
virtual QWidget * qwidget()=0
QApplication * d_qApplication
Definition: histogram_sink_f.h:120
virtual std::string line_label(unsigned int which)=0
virtual void autoscalex()=0
virtual void enable_autoscale(bool en=true)=0
virtual void set_line_marker(unsigned int which, int marker)=0
virtual void set_line_style(unsigned int which, int style)=0
virtual void * pyqwidget()=0
virtual std::string line_color(unsigned int which)=0
virtual void set_update_time(double t)=0
virtual void enable_semilogx(bool en=true)=0
virtual void set_x_axis(double min, double max)=0
virtual void set_nsamps(const int newsize)=0
virtual int nsamps() const =0
virtual void enable_semilogy(bool en=true)=0
virtual void set_bins(const int bins)=0
static sptr make(int size, int bins, double xmin, double xmax, const std::string &name, int nconnections=1, QWidget *parent=NULL)
Build floating point histogram sink.
virtual void set_line_color(unsigned int which, const std::string &color)=0
virtual void enable_grid(bool en=true)=0
virtual int line_marker(unsigned int which)=0
virtual int bins() const =0
virtual void set_size(int width, int height)=0
virtual void set_title(const std::string &title)=0
virtual void set_line_width(unsigned int which, int width)=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
float min(float a, float b)
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:29