GNU Radio Manual and C++ API Reference  v3.9.2.0-89-gb7c7001e
The Free & Open Software Radio Ecosystem
freq_sink_c.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012,2014-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_FREQ_SINK_C_H
12 #define INCLUDED_QTGUI_FREQ_SINK_C_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/fft/window.h>
22 #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 multiple signals in frequency.
32  * \ingroup instrumentation_blk
33  * \ingroup qtgui_blk
34  *
35  * \details
36  * This is a QT-based graphical sink the takes set of a complex
37  * streams and plots the PSD. Each signal is plotted with a
38  * different color, and the \a set_title and \a set_color
39  * functions can be used to change the label and color for a given
40  * input number.
41  *
42  * The sink supports plotting streaming complex data or
43  * messages. The message port is named "in". The two modes cannot
44  * be used simultaneously, and \p nconnections should be set to 0
45  * when using the message mode. GRC handles this issue by
46  * providing the "Complex Message" type that removes the streaming
47  * port(s).
48  *
49  * This sink can plot messages that contain either uniform vectors
50  * of complex 32 values (pmt::is_c32vector) or PDUs where the data
51  * is a uniform vector of complex 32 values.
52  *
53  * Message Ports:
54  *
55  * - freq (input):
56  * Receives a PMT pair: (intern("freq"), double(frequency)).
57  * This is used to retune the center frequency of the
58  * display's x-axis.
59  *
60  * - bw (input):
61  * Receives a PMT pair: (intern("bw"), double(bandwidth)).
62  * This is used to programmatically change the bandwidth of
63  * of the display's x-axis.
64  *
65  * - freq (output):
66  * Produces a PMT pair with (intern("freq"), double(frequency)).
67  * When a user double-clicks on the display, the block
68  * produces and emits a message containing the frequency of
69  * where on the x-axis the user clicked. This value can be
70  * used by other blocks to update their frequency setting.
71  *
72  * To perform click-to-tune behavior, this output 'freq'
73  * port can be redirected to this block's input 'freq' port
74  * to catch the message and update the center frequency of
75  * the display.
76  */
77 class QTGUI_API freq_sink_c : virtual public sync_block
78 {
79 public:
80  // gr::qtgui::freq_sink_c::sptr
81  typedef std::shared_ptr<freq_sink_c> sptr;
82 
83  /*!
84  * \brief Build a complex PSD sink.
85  *
86  * \param fftsize size of the FFT to compute and display. If using
87  * the PDU message port to plot samples, the length of
88  * each PDU must be a multiple of the FFT size.
89  * \param wintype type of window to apply (see gr::fft::window::win_type).
90  * By setting bit 16 to one, this block will normalize the window
91  * before applying it. This allows switching between windows without
92  * sacrificing signal power due to tapering, but it will also
93  * amplify some samples. See also set_fft_window_normalized().
94  * \param fc center frequency of signal (use for x-axis labels)
95  * \param bw bandwidth of signal (used to set x-axis labels)
96  * \param name title for the plot
97  * \param nconnections number of signals to be connected to the
98  * sink. The PDU message port is always available for a
99  * connection, and this value must be set to 0 if only
100  * the PDU message port is being used.
101  * \param parent a QWidget parent object, if any
102  */
103  static sptr make(int fftsize,
104  int wintype,
105  double fc,
106  double bw,
107  const std::string& name,
108  int nconnections = 1,
109  QWidget* parent = NULL);
110 
111  virtual void exec_() = 0;
112  virtual QWidget* qwidget() = 0;
113 
114 #ifdef ENABLE_PYTHON
115  virtual PyObject* pyqwidget() = 0;
116 #else
117  virtual void* pyqwidget() = 0;
118 #endif
119 
120  virtual void set_fft_size(const int fftsize) = 0;
121  virtual int fft_size() const = 0;
122  virtual void set_fft_average(const float fftavg) = 0;
123  virtual float fft_average() const = 0;
124  virtual void set_fft_window(const gr::fft::window::win_type win) = 0;
126  //! If true, normalize window to unit power
127  virtual void set_fft_window_normalized(const bool enable) = 0;
128 
129  virtual void set_frequency_range(const double centerfreq, const double bandwidth) = 0;
130  virtual void set_y_axis(double min, double max) = 0;
131 
132  virtual void set_update_time(double t) = 0;
133 
134  virtual void set_title(const std::string& title) = 0;
135  virtual void set_y_label(const std::string& label, const std::string& unit) = 0;
136  virtual void set_line_label(unsigned int which, const std::string& label) = 0;
137  virtual void set_line_color(unsigned int which, const std::string& color) = 0;
138  virtual void set_line_width(unsigned int which, int width) = 0;
139  virtual void set_line_style(unsigned int which, int style) = 0;
140  virtual void set_line_marker(unsigned int which, int marker) = 0;
141  virtual void set_line_alpha(unsigned int which, double alpha) = 0;
142 
143  /*!
144  * Set up a trigger for the sink to know when to start
145  * plotting. Useful to isolate events and avoid noise.
146  *
147  * The trigger modes are Free, Auto, Normal, and Tag (see
148  * gr::qtgui::trigger_mode). The first three are like a normal
149  * trigger function. Free means free running with no trigger,
150  * auto will trigger if the trigger event is seen, but will
151  * still plot otherwise, and normal will hold until the trigger
152  * event is observed. The Tag trigger mode allows us to trigger
153  * off a specific stream tag. The tag trigger is based only on
154  * the name of the tag, so when a tag of the given name is seen,
155  * the trigger is activated.
156  *
157  * In auto and normal mode, we look to see if the magnitude of
158  * the any FFT point is over the set level.
159  *
160  * \param mode The trigger_mode: free, auto, normal, or tag.
161  * \param level The magnitude of the trigger even for auto or normal modes.
162  * \param channel Which input channel to use for the trigger events.
163  * \param tag_key The name (as a string) of the tag to trigger off
164  * of if using the tag mode.
165  */
166  virtual void set_trigger_mode(trigger_mode mode,
167  float level,
168  int channel,
169  const std::string& tag_key = "") = 0;
170 
171  virtual std::string title() = 0;
172  virtual std::string line_label(unsigned int which) = 0;
173  virtual std::string line_color(unsigned int which) = 0;
174  virtual int line_width(unsigned int which) = 0;
175  virtual int line_style(unsigned int which) = 0;
176  virtual int line_marker(unsigned int which) = 0;
177  virtual double line_alpha(unsigned int which) = 0;
178 
179  virtual void set_size(int width, int height) = 0;
180 
181  virtual void enable_menu(bool en = true) = 0;
182  virtual void enable_grid(bool en = true) = 0;
183  virtual void enable_autoscale(bool en = true) = 0;
184  virtual void enable_control_panel(bool en = true) = 0;
185  virtual void enable_max_hold(bool en) = 0;
186  virtual void enable_min_hold(bool en) = 0;
187  virtual void clear_max_hold() = 0;
188  virtual void clear_min_hold() = 0;
189  virtual void disable_legend() = 0;
190  virtual void reset() = 0;
191  virtual void enable_axis_labels(bool en = true) = 0;
192 
193  QApplication* d_qApplication;
194 };
195 
196 } /* namespace qtgui */
197 } /* namespace gr */
198 
199 #endif /* INCLUDED_QTGUI_FREQ_SINK_C_H */
win_type
Definition: window.h:25
A graphical sink to display multiple signals in frequency.
Definition: freq_sink_c.h:78
std::shared_ptr< freq_sink_c > sptr
Definition: freq_sink_c.h:81
virtual void set_fft_size(const int fftsize)=0
virtual void enable_min_hold(bool en)=0
virtual void enable_menu(bool en=true)=0
virtual void set_y_label(const std::string &label, const std::string &unit)=0
virtual std::string line_color(unsigned int which)=0
virtual void disable_legend()=0
virtual void set_trigger_mode(trigger_mode mode, float level, int channel, const std::string &tag_key="")=0
virtual void set_line_label(unsigned int which, const std::string &label)=0
virtual void * pyqwidget()=0
virtual int line_marker(unsigned int which)=0
virtual void set_size(int width, int height)=0
virtual void set_fft_average(const float fftavg)=0
virtual int line_width(unsigned int which)=0
virtual void set_title(const std::string &title)=0
virtual void reset()=0
virtual std::string line_label(unsigned int which)=0
virtual void enable_max_hold(bool en)=0
virtual std::string title()=0
virtual void enable_grid(bool en=true)=0
virtual void set_update_time(double t)=0
virtual void set_fft_window_normalized(const bool enable)=0
If true, normalize window to unit power.
virtual void clear_min_hold()=0
virtual void set_line_color(unsigned int which, const std::string &color)=0
virtual void set_y_axis(double min, double max)=0
virtual void set_line_style(unsigned int which, int style)=0
virtual int line_style(unsigned int which)=0
virtual void set_frequency_range(const double centerfreq, const double bandwidth)=0
virtual void exec_()=0
virtual QWidget * qwidget()=0
virtual void enable_autoscale(bool en=true)=0
QApplication * d_qApplication
Definition: freq_sink_c.h:193
virtual float fft_average() const =0
virtual void set_line_width(unsigned int which, int width)=0
static sptr make(int fftsize, int wintype, double fc, double bw, const std::string &name, int nconnections=1, QWidget *parent=NULL)
Build a complex PSD sink.
virtual double line_alpha(unsigned int which)=0
virtual void set_line_marker(unsigned int which, int marker)=0
virtual void set_fft_window(const gr::fft::window::win_type win)=0
virtual void enable_axis_labels(bool en=true)=0
virtual void enable_control_panel(bool en=true)=0
virtual void clear_max_hold()=0
virtual int fft_size() const =0
virtual gr::fft::window::win_type fft_window()=0
virtual void set_line_alpha(unsigned int which, double alpha)=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
trigger_mode
Definition: trigger_mode.h:17
float min(float a, float b)
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:29