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