GNU Radio C++ API Reference: edit_box_msg.h Source File

| GNU Radio C++ API Reference 3.10.12.0 The Free & Open Software Radio Ecosystem |

Loading...
Searching...
No Matches
edit_box_msg.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2016 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_EDIT_BOX_MSG_H
12#define INCLUDED_QTGUI_EDIT_BOX_MSG_H
13
14#include <gnuradio/block.h>
15#include <gnuradio/qtgui/api.h>
16#include <gnuradio/qtgui/qtgui_types.h>
17#include <qapplication.h>
18
19namespace gr {
20namespace qtgui {
21
22/*!
23 * \brief Create a QT Edit Box widget where the value is posted as a message.
24 * \ingroup qtgui_blk
25 *
26 * \details
27 * This block creates a QT Edit Box widget that manages data
28 * through message passing interfaces. The 'msg' output port
29 * produces messages based on the text in the edit box and the
30 * data type set by the \p type argument (see
31 * gr::qtgui::data_type_t). The data types are checked, and WARN
32 * log messages are produced when the data is in the wrong
33 * format. Not all errors are explicitly checked for, only that
34 * conversions happen correctly. Failures are either produces as
35 * log messages or the action is simply silently dropped.
36 *
37 * The value of the edit boxes can be programmatically updated
38 * through the 'val' input message port. It is also checked for
39 * the correct data type.
40 *
41 * The \p is_pair argument to the constructor determines if the
42 * edit box handles a key:value pair. If set to True, two edit
43 * boxes are created with the left for the key and right for the
44 * value. The key is always assumed to be a string and the value
45 * is restricted by the data type setting as above.
46 *
47 * The block can take a default value. Because the block is
48 * capable of handling multiple different data types, we enter the
49 * default value as a string in the same way we expect the user to
50 * enter it into the Value edit box of the widget. We convert this
51 * default exactly the same way we convert the user-entered text
52 * in the edit box. See the next paragraph for an explanation for
53 * how to handle complex numbers.
54 *
55 * Complex numbers are currently handled a bit differently than
56 * expected. Because we use the std iostream for complex, complex numbers MUST
57 * be in the form "(a,b)" to represent "a + jb". Note that you cannot even have
58 * a space after the comma, so "(1.23,10.56)" is correct while "(1.23, 10.56)"
59 * will not parse.
60 *
61 * The 'static' mode prevents the user from changing the data type
62 * or the key used in the widget. If also in 'pair' mode, the key
63 * is not displayed and so must be set in the constructor. It is
64 * an error if using static and pair modes with no default key
65 * set.
66 *
67 * Message Ports:
68 *
69 * - msg (output):
70 * Produces a PMT message from the data in the edit box. It
71 * is packaged in the PMT container determined by the \p
72 * type argument to the ctor. If the data in the box is not of
73 * the correct type and the conversion fails, the block
74 * produces a log WARN message but does nothing else with
75 * the data. If the \p is_pair flag is set on this block, it
76 * will produce a PMT pair object where the key (car) is
77 * assumed to be a string and the value (cdr) is determined
78 * by \p type.
79 *
80 * - val (input):
81 * Accepts messages to update the value in the edit
82 * boxes. The messages, as PMTs, are first checked to make
83 * sure that they are the correct type (integer, float,
84 * string, or complex), and unpacks them and converts them
85 * to QStrings to display in the edit box. When using \p
86 * is_pair, the PMT is checked to make sure it is a PMT
87 * pair. Then the key (car) is extracted as a string before
88 * the value (cdr) is processed based on the set data type
89 * of the box.
90 */
91 class QTGUI_API edit_box_msg : virtual public block
92{
93public:
94 // gr::qtgui::edit_box_msg::sptr
95 typedef std::shared_ptr<edit_box_msg> sptr;
96
97 /*!
98 * \brief Constructs the Edit box block.
99 *
100 * \param type the data type of data in the value box.
101 * \param value the default value of the message. This is
102 * entered as a string regardless of the type and
103 * converted internally -- much like how the block
104 * extracts the value from the edit box and converts it.
105 * \param label a label to identify the box on screen.
106 * \param is_pair if we are using a key:value pair.
107 * \param is_static sets the key edit box as a static text box
108 * (cannot be edited live).
109 * \param key Set the key used in a key:value pair message.
110 * \param parent a QWidget parent in the QT app.
111 */
112 static sptr make(gr::qtgui::data_type_t type,
113 const std::string& value = "",
114 const std::string& label = "",
115 bool is_pair = true,
116 bool is_static = true,
117 const std::string& key = "",
118 QWidget* parent = NULL);
119
120 virtual void exec_() = 0;
121 virtual QWidget* qwidget() = 0;
122
123 QApplication* d_qApplication;
124};
125
126} /* namespace qtgui */
127} /* namespace gr */
128
129#endif /* INCLUDED_QTGUI_EDIT_BOX_MSG_H */
gr::block::block
block(void)
Definition gnuradio-runtime/include/gnuradio/block.h:806
gr::qtgui::edit_box_msg
Create a QT Edit Box widget where the value is posted as a message.
Definition edit_box_msg.h:92
gr::qtgui::edit_box_msg::d_qApplication
QApplication * d_qApplication
Definition edit_box_msg.h:123
gr::qtgui::edit_box_msg::sptr
std::shared_ptr< edit_box_msg > sptr
Definition edit_box_msg.h:95
gr::qtgui::edit_box_msg::exec_
virtual void exec_()=0
gr::qtgui::edit_box_msg::make
static sptr make(gr::qtgui::data_type_t type, const std::string &value="", const std::string &label="", bool is_pair=true, bool is_static=true, const std::string &key="", QWidget *parent=NULL)
Constructs the Edit box block.
gr::qtgui::edit_box_msg::qwidget
virtual QWidget * qwidget()=0
block.h
api.h
QTGUI_API
#define QTGUI_API
Definition gr-qtgui/include/gnuradio/qtgui/api.h:18
gr::qtgui
Definition ber_sink_b.h:20
gr::qtgui::data_type_t
data_type_t
Definition qtgui_types.h:22
gr
GNU Radio logging wrapper.
Definition basic_block.h:29
qtgui_types.h