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