summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-qtgui/grc/qtgui_freq_sink_x.block.yml70
-rw-r--r--gr-qtgui/grc/qtgui_sink_x.block.yml16
-rw-r--r--gr-qtgui/grc/qtgui_tab_widget.block.yml24
-rw-r--r--gr-qtgui/grc/qtgui_waterfall_sink_x.block.yml52
-rw-r--r--gr-qtgui/include/gnuradio/qtgui/freq_sink_c.h5
-rw-r--r--gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h5
-rw-r--r--gr-qtgui/include/gnuradio/qtgui/sink_c.h5
-rw-r--r--gr-qtgui/include/gnuradio/qtgui/sink_f.h5
-rw-r--r--gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h5
-rw-r--r--gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h5
-rw-r--r--grc/core/generator/cpp_templates/flow_graph.cpp.mako3
-rw-r--r--grc/core/generator/cpp_top_block.py4
-rw-r--r--grc/core/params/param.py44
13 files changed, 152 insertions, 91 deletions
diff --git a/gr-qtgui/grc/qtgui_freq_sink_x.block.yml b/gr-qtgui/grc/qtgui_freq_sink_x.block.yml
index 5e323130c7..d0f9b4216e 100644
--- a/gr-qtgui/grc/qtgui_freq_sink_x.block.yml
+++ b/gr-qtgui/grc/qtgui_freq_sink_x.block.yml
@@ -468,9 +468,12 @@ cpp_templates:
- set_update_time(${update_time})
- set_y_axis(${ymin}, ${ymax})
- this->${id}.set_trigger_mode(${tr_mode.cpp_opts}, ${tr_level}, ${tr_chan}, ${tr_tag})
- link: ['gnuradio::gnuradio-qtgui', 'Qt5::Widgets']
+ link: ['gnuradio::gnuradio-qtgui']
make: |-
- this->${id} = qtgui::${type.fcn}::make(
+ <%
+ win = '_%s_win'%id
+ %>\
+ ${id} = qtgui::${type.fcn}::make(
${fftsize}, // size
${wintype.cpp_opts}, // wintype
${fc}, // fc
@@ -479,29 +482,20 @@ cpp_templates:
${ 0 if (type == 'msg_complex' or type == 'msg_float') else nconnections } // nconnections
);
- std::string labels[10] = {"${label1.strip("'")}", "${label2.strip("'")}", "${label3.strip("'")}", "${label4.strip("'")}", "${label5.strip("'")}",
- "${label6.strip("'")}", "${label7.strip("'")}", "${label8.strip("'")}", "${label9.strip("'")}", "${label10.strip("'")}"};
- int widths[10] = {${width1}, ${width2}, ${width3}, ${width4}, ${width5},
- ${width6}, ${width7}, ${width8}, ${width9}, ${width10}};
- std::string colors[10] = {${color1}, ${color2}, ${color3}, ${color4}, ${color5},
- ${color6}, ${color7}, ${color8}, ${color9}, ${color10}};
- double alphas[10] = {${alpha1}, ${alpha2}, ${alpha3}, ${alpha4}, ${alpha5},
- ${alpha6}, ${alpha7}, ${alpha8}, ${alpha9}, ${alpha10}};
-
QWidget* _${id}_win;
- this->${id}->set_update_time(${update_time});
- this->${id}->set_y_axis(${ymin}, ${ymax});
- this->${id}->set_y_label("${label.strip("'")}", "${units.strip("'")}");
- this->${id}->set_trigger_mode(${tr_mode.replace('qtgui.','gr::qtgui::')}, ${tr_level}, ${tr_chan}, ${tr_tag});
- this->${id}->enable_autoscale(${autoscale});
- this->${id}->enable_grid(${grid});
- this->${id}->set_fft_average(${average});
- this->${id}->enable_axis_labels(${axislabels});
- this->${id}->enable_control_panel(${ctrlpanel});
+ ${id}->set_update_time(${update_time});
+ ${id}->set_y_axis(${ymin}, ${ymax});
+ ${id}->set_y_label("${label.strip("'")}", "${units.strip("'")}");
+ ${id}->set_trigger_mode(${tr_mode.replace('qtgui.','gr::qtgui::')}, ${tr_level}, ${tr_chan}, ${tr_tag});
+ ${id}->enable_autoscale(${autoscale});
+ ${id}->enable_grid(${grid});
+ ${id}->set_fft_average(${average});
+ ${id}->enable_axis_labels(${axislabels});
+ ${id}->enable_control_panel(${ctrlpanel});
if (!${legend}) {
- this->${id}->disable_legend(); // if (!legend)
+ ${id}->disable_legend(); // if (!legend)
}
/* C++ doesn't have this
@@ -509,23 +503,29 @@ cpp_templates:
this->${id}->set_plot_pos_half(not ${freqhalf});
}*/
- for (int i = 0; i < ${ 1 if (type == 'msg_complex' or type == 'msg_float') else nconnections }; i++) {
- if (sizeof(labels[i]) == 0) {
- this->${id}->set_line_label(i, "Data " + std::to_string(i));
- } else {
- this->${id}->set_line_label(i, labels[i]);
+ {
+ std::string labels[10] = {"${label1.strip("'")}", "${label2.strip("'")}", "${label3.strip("'")}", "${label4.strip("'")}", "${label5.strip("'")}",
+ "${label6.strip("'")}", "${label7.strip("'")}", "${label8.strip("'")}", "${label9.strip("'")}", "${label10.strip("'")}"};
+ int widths[10] = {${width1}, ${width2}, ${width3}, ${width4}, ${width5},
+ ${width6}, ${width7}, ${width8}, ${width9}, ${width10}};
+ std::string colors[10] = {${color1}, ${color2}, ${color3}, ${color4}, ${color5},
+ ${color6}, ${color7}, ${color8}, ${color9}, ${color10}};
+ double alphas[10] = {${alpha1}, ${alpha2}, ${alpha3}, ${alpha4}, ${alpha5},
+ ${alpha6}, ${alpha7}, ${alpha8}, ${alpha9}, ${alpha10}};
+ for (int i = 0; i < ${ 1 if (type == 'msg_complex' or type == 'msg_float') else nconnections }; i++) {
+ if (sizeof(labels[i]) == 0) {
+ ${id}->set_line_label(i, "Data " + std::to_string(i));
+ } else {
+ ${id}->set_line_label(i, labels[i]);
+ }
+ ${id}->set_line_width(i, widths[i]);
+ ${id}->set_line_color(i, colors[i]);
+ ${id}->set_line_alpha(i, alphas[i]);
}
- this->${id}->set_line_width(i, widths[i]);
- this->${id}->set_line_color(i, colors[i]);
- this->${id}->set_line_alpha(i, alphas[i]);
}
-
_${id}_win = this->${id}->qwidget();
- % if len(gui_hint) > 0:
- this->top_grid_layout->addWidget(_${id}_win,${gui_hint});
- % else:
- this->top_layout->addWidget(_${id}_win);
- % endif
+
+ ${gui_hint() % win}
translations:
'True': 'true'
diff --git a/gr-qtgui/grc/qtgui_sink_x.block.yml b/gr-qtgui/grc/qtgui_sink_x.block.yml
index c0a5bdf6b1..00304dc288 100644
--- a/gr-qtgui/grc/qtgui_sink_x.block.yml
+++ b/gr-qtgui/grc/qtgui_sink_x.block.yml
@@ -138,6 +138,9 @@ cpp_templates:
includes: ['#include <gnuradio/qtgui/${type.fcn}.h>', '#include <gnuradio/filter/firdes.h>']
declarations: gr::qtgui::${type.fcn}::sptr ${id};
make: |-
+ <%
+ win = '_%s_win'%id
+ %>\
${id} = gr::qtgui::${type.fcn}::make(
${fftsize}, //fftsize
${wintype.cpp_opts}, // wintype
@@ -151,14 +154,11 @@ cpp_templates:
);
${id}->set_update_time(1.0/${rate});
${id}->enable_rf_freq(${showrf});
- ## Attempt to replicate logic of Python gui_hint() method
- % if len(gui_hint) > 0:
- this->top_grid_layout->addWidget(${id + '->qwidget()'},${gui_hint});
- % else:
- this->top_layout->addWidget(${id + '->qwidget()'});
- % endif
-
- link: ['gnuradio::gnuradio-qtgui', 'Qt5Widgets', 'Qt5Core']
+ QWidget* _${id}_win;
+ _${id}_win = this->${id}->qwidget();
+ ${gui_hint() % win}
+
+ link: ['gnuradio::gnuradio-qtgui']
translations:
'True': 'true'
'False': 'false'
diff --git a/gr-qtgui/grc/qtgui_tab_widget.block.yml b/gr-qtgui/grc/qtgui_tab_widget.block.yml
index a69267b872..5043128803 100644
--- a/gr-qtgui/grc/qtgui_tab_widget.block.yml
+++ b/gr-qtgui/grc/qtgui_tab_widget.block.yml
@@ -1,6 +1,6 @@
id: qtgui_tab_widget
label: QT GUI Tab Widget
-flags: [show_id, python ]
+flags: [show_id, python, cpp ]
parameters:
- id: num_tabs
@@ -134,6 +134,28 @@ templates:
% endfor
${gui_hint() % win}
+cpp_templates:
+ includes: ['#include <QTabWidget>']
+ declarations: QTabWidget *${id};
+ link: ['gnuradio::gnuradio-qtgui']
+ make: |-
+ <%
+ win = '%s'%id
+ all_labels = [label0, label1, label2, label3, label4,
+ label5, label6, label7, label8, label9,
+ label10, label11, label12, label13, label14,
+ label15, label16, label17, label18,label19][:int(num_tabs)]
+ %>\
+ ${id} = new QTabWidget();
+ % for i,label in enumerate(all_labels):
+ QWidget* ${id}_widget_${i} = new QWidget();
+ QBoxLayout* ${id}_layout_${i} =new QBoxLayout(QBoxLayout::TopToBottom,${id}_widget_${i});
+ QGridLayout* ${id}_grid_layout_${i} = new QGridLayout();
+ ${id}_layout_${i}->addLayout(${id}_grid_layout_${i});
+ ${win}->addTab(${id}_widget_${i},"${label.strip("'")}");
+ % endfor
+ ${gui_hint() % win}
+
documentation: |-
This block creates a tabbed widget to organize other widgets. The ID of this block can be used as the tab_id in the GUI hints of other widgets.
diff --git a/gr-qtgui/grc/qtgui_waterfall_sink_x.block.yml b/gr-qtgui/grc/qtgui_waterfall_sink_x.block.yml
index 5b45841c95..671ce80d5a 100644
--- a/gr-qtgui/grc/qtgui_waterfall_sink_x.block.yml
+++ b/gr-qtgui/grc/qtgui_waterfall_sink_x.block.yml
@@ -302,6 +302,7 @@ templates:
self.${id}.set_intensity_range(${int_min}, ${int_max})
${win} = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget)
+
${gui_hint() % win}
cpp_templates:
@@ -310,9 +311,12 @@ cpp_templates:
callbacks:
- set_frequency_range(${fc}, ${bw})
- set_update_time(${update_time})
- link: ['gnuradio::gnuradio-qtgui', 'Qt5::Widgets']
+ link: ['gnuradio::gnuradio-qtgui']
make: |-
- this->${id} = qtgui::${type.fcn}::make(
+ <%
+ win = '_%s_win'%id
+ %>\
+ ${id} = qtgui::${type.fcn}::make(
${fftsize}, // size
${wintype.cpp_opts}, // wintype
${fc}, // fc
@@ -321,18 +325,12 @@ cpp_templates:
${ (0 if type.startswith('msg') else nconnections) } // number of inputs
);
- std::string labels[10] = {"${label1.strip("'")}", "${label2.strip("'")}", "${label3.strip("'")}", "${label4.strip("'")}", "${label5.strip("'")}",
- "${label6.strip("'")}", "${label7.strip("'")}", "${label8.strip("'")}", "${label9.strip("'")}", "${label10.strip("'")}"};
- int colors[10] = {${color1 or 0}, ${color2 or 0}, ${color3 or 0}, ${color4 or 0}, ${color5 or 0},
- ${color6 or 0}, ${color7 or 0}, ${color8 or 0}, ${color9 or 0}, ${color10 or 0}};
- double alphas[10] = {${alpha1 or 1.0}, ${alpha2 or 1.0}, ${alpha3 or 1.0}, ${alpha4 or 1.0}, ${alpha5 or 1.0},
- ${alpha6 or 1.0}, ${alpha7 or 1.0}, ${alpha8 or 1.0}, ${alpha9 or 1.0}, ${alpha10 or 1.0}};
QWidget* _${id}_win;
- this->${id}->set_update_time(${update_time});
- this->${id}->enable_grid(${grid});
- this->${id}->enable_axis_labels(${axislabels});
+ ${id}->set_update_time(${update_time});
+ ${id}->enable_grid(${grid});
+ ${id}->enable_axis_labels(${axislabels});
if (!${legend}) {
this->${id}->disable_legend(); // if (!legend)
@@ -342,28 +340,32 @@ cpp_templates:
if ("${type}" == "float" or "${type}" == "msg_float") {
this->${id}->set_plot_pos_half(not ${freqhalf});
}*/
+ {
+ std::string labels[10] = {"${label1.strip("'")}", "${label2.strip("'")}", "${label3.strip("'")}", "${label4.strip("'")}", "${label5.strip("'")}",
+ "${label6.strip("'")}", "${label7.strip("'")}", "${label8.strip("'")}", "${label9.strip("'")}", "${label10.strip("'")}"};
+ int colors[10] = {${color1 or 0}, ${color2 or 0}, ${color3 or 0}, ${color4 or 0}, ${color5 or 0},
+ ${color6 or 0}, ${color7 or 0}, ${color8 or 0}, ${color9 or 0}, ${color10 or 0}};
+ double alphas[10] = {${alpha1 or 1.0}, ${alpha2 or 1.0}, ${alpha3 or 1.0}, ${alpha4 or 1.0}, ${alpha5 or 1.0},
+ ${alpha6 or 1.0}, ${alpha7 or 1.0}, ${alpha8 or 1.0}, ${alpha9 or 1.0}, ${alpha10 or 1.0}};
- for (int i = 0; i < ${ 1 if (type == 'msg_complex' or type == 'msg_float') else nconnections }; i++) {
- if (sizeof(labels[i]) == 0) {
- this->${id}->set_line_label(i, "Data " + std::to_string(i));
- } else {
- this->${id}->set_line_label(i, labels[i]);
+ for (int i = 0; i < ${ 1 if (type == 'msg_complex' or type == 'msg_float') else nconnections }; i++) {
+ if (sizeof(labels[i]) == 0) {
+ ${id}->set_line_label(i, "Data " + std::to_string(i));
+ } else {
+ ${id}->set_line_label(i, labels[i]);
+ }
+ ${id}->set_color_map(i, colors[i]);
+ ${id}->set_line_alpha(i, alphas[i]);
}
- this->${id}->set_color_map(i, colors[i]);
- this->${id}->set_line_alpha(i, alphas[i]);
}
this->${id}->set_intensity_range(${int_min}, ${int_max});
_${id}_win = this->${id}->qwidget();
- % if len(gui_hint) > 0:
- this->top_grid_layout->addWidget(_${id}_win,${gui_hint});
- % else:
- this->top_layout->addWidget(_${id}_win);
- % endif
-
+
+ ${gui_hint() % win}
+
translations:
- firdes.: 'filter::firdes::'
'True': 'true'
'False': 'false'
diff --git a/gr-qtgui/include/gnuradio/qtgui/freq_sink_c.h b/gr-qtgui/include/gnuradio/qtgui/freq_sink_c.h
index 1738ad8b34..f04e099d07 100644
--- a/gr-qtgui/include/gnuradio/qtgui/freq_sink_c.h
+++ b/gr-qtgui/include/gnuradio/qtgui/freq_sink_c.h
@@ -12,7 +12,10 @@
#define INCLUDED_QTGUI_FREQ_SINK_C_H
#ifdef ENABLE_PYTHON
-#include <Python.h>
+#pragma push_macro("slots")
+#undef slots
+#include "Python.h"
+#pragma pop_macro("slots")
#endif
#include <gnuradio/fft/window.h>
diff --git a/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h b/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h
index a28e7c8d20..aacd14e0b8 100644
--- a/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h
+++ b/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h
@@ -12,7 +12,10 @@
#define INCLUDED_QTGUI_FREQ_SINK_F_H
#ifdef ENABLE_PYTHON
-#include <Python.h>
+#pragma push_macro("slots")
+#undef slots
+#include "Python.h"
+#pragma pop_macro("slots")
#endif
#include <gnuradio/fft/window.h>
diff --git a/gr-qtgui/include/gnuradio/qtgui/sink_c.h b/gr-qtgui/include/gnuradio/qtgui/sink_c.h
index 10dca2f3d1..139f057fea 100644
--- a/gr-qtgui/include/gnuradio/qtgui/sink_c.h
+++ b/gr-qtgui/include/gnuradio/qtgui/sink_c.h
@@ -12,7 +12,10 @@
#define INCLUDED_QTGUI_SINK_C_H
#ifdef ENABLE_PYTHON
-#include <Python.h>
+#pragma push_macro("slots")
+#undef slots
+#include "Python.h"
+#pragma pop_macro("slots")
#endif
#include <gnuradio/block.h>
diff --git a/gr-qtgui/include/gnuradio/qtgui/sink_f.h b/gr-qtgui/include/gnuradio/qtgui/sink_f.h
index 09b0457ea1..0fe1e3960e 100644
--- a/gr-qtgui/include/gnuradio/qtgui/sink_f.h
+++ b/gr-qtgui/include/gnuradio/qtgui/sink_f.h
@@ -12,7 +12,10 @@
#define INCLUDED_QTGUI_SINK_F_H
#ifdef ENABLE_PYTHON
-#include <Python.h>
+#pragma push_macro("slots")
+#undef slots
+#include "Python.h"
+#pragma pop_macro("slots")
#endif
#include <gnuradio/block.h>
diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h
index dc541a78c1..9a4bd9a5fd 100644
--- a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h
+++ b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h
@@ -12,7 +12,10 @@
#define INCLUDED_QTGUI_WATERFALL_SINK_C_H
#ifdef ENABLE_PYTHON
-#include <Python.h>
+#pragma push_macro("slots")
+#undef slots
+#include "Python.h"
+#pragma pop_macro("slots")
#endif
#include <gnuradio/fft/window.h>
diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
index cbe10bc783..792d93ce4e 100644
--- a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
+++ b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
@@ -12,7 +12,10 @@
#define INCLUDED_QTGUI_WATERFALL_SINK_F_H
#ifdef ENABLE_PYTHON
-#include <Python.h>
+#pragma push_macro("slots")
+#undef slots
+#include "Python.h"
+#pragma pop_macro("slots")
#endif
#include <gnuradio/fft/window.h>
diff --git a/grc/core/generator/cpp_templates/flow_graph.cpp.mako b/grc/core/generator/cpp_templates/flow_graph.cpp.mako
index f806de62b2..83d3fee5ff 100644
--- a/grc/core/generator/cpp_templates/flow_graph.cpp.mako
+++ b/grc/core/generator/cpp_templates/flow_graph.cpp.mako
@@ -67,7 +67,6 @@ ${class_name}::${class_name} (${param_str}) ${initializer_str} {
% if blocks:
// Blocks:
% for blk, blk_make, declarations in blocks:
- {
${doubleindent(blk_make)}
## % if 'alias' in blk.params and blk.params['alias'].get_evaluated():
## ${blk.name}.set_block_alias("${blk.params['alias'].get_evaluated()}")
@@ -81,7 +80,7 @@ ${class_name}::${class_name} (${param_str}) ${initializer_str} {
## % if len(blk.sources) > 0 and 'maxoutbuf' in blk.params and int(blk.params['maxoutbuf'].get_evaluated()) > 0:
## ${blk.name}.set_max_output_buffer(${blk.params['maxoutbuf'].get_evaluated()})
## % endif
- }
+
% endfor
% endif
diff --git a/grc/core/generator/cpp_top_block.py b/grc/core/generator/cpp_top_block.py
index 002128a1e9..d0bc4c172b 100644
--- a/grc/core/generator/cpp_top_block.py
+++ b/grc/core/generator/cpp_top_block.py
@@ -222,9 +222,9 @@ class CppTopBlockGenerator(TopBlockGenerator):
fg = self._flow_graph
parameters = fg.get_parameters()
- # List of blocks not including variables and imports and parameters and disabled
+ # List of blocks not including variables and parameters and disabled
def _get_block_sort_text(block):
- code = block.cpp_templates.render('make').replace(block.name, ' ')
+ code = block.cpp_templates.render('declarations')
try:
code += block.params['gui_hint'].get_value() # Newer gui markup w/ qtgui
except:
diff --git a/grc/core/params/param.py b/grc/core/params/param.py
index fae008935e..9e612abf91 100644
--- a/grc/core/params/param.py
+++ b/grc/core/params/param.py
@@ -403,20 +403,40 @@ class Param(Element):
row, col, row_span, col_span = parse_pos()
collision_detection(row, col, row_span, col_span)
- widget_str = textwrap.dedent("""
- self.{layout}.addWidget({widget}, {row}, {col}, {row_span}, {col_span})
- for r in range({row}, {row_end}):
- self.{layout}.setRowStretch(r, 1)
- for c in range({col}, {col_end}):
- self.{layout}.setColumnStretch(c, 1)
- """.strip('\n')).format(
- layout=layout, widget=widget,
- row=row, row_span=row_span, row_end=row+row_span,
- col=col, col_span=col_span, col_end=col+col_span,
- )
+ if self.parent_flowgraph.get_option('output_language') == 'python':
+ widget_str = textwrap.dedent("""
+ self.{layout}.addWidget({widget}, {row}, {col}, {row_span}, {col_span})
+ for r in range({row}, {row_end}):
+ self.{layout}.setRowStretch(r, 1)
+ for c in range({col}, {col_end}):
+ self.{layout}.setColumnStretch(c, 1)
+ """.strip('\n')).format(
+ layout=layout, widget=widget,
+ row=row, row_span=row_span, row_end=row+row_span,
+ col=col, col_span=col_span, col_end=col+col_span,
+ )
+ elif self.parent_flowgraph.get_option('output_language') == 'cpp':
+ widget_str = textwrap.dedent("""
+ {layout}->addWidget({widget}, {row}, {col}, {row_span}, {col_span});
+ for(int r = {row};r < {row_end}; r++)
+ {layout}->setRowStretch(r, 1);
+ for(int c = {col}; c <{col_end}; c++)
+ {layout}->setColumnStretch(c, 1);
+ """.strip('\n')).format(
+ layout=layout, widget=widget,
+ row=row, row_span=row_span, row_end=row+row_span,
+ col=col, col_span=col_span, col_end=col+col_span,
+ )
+ else:
+ widget_str = ''
else:
- widget_str = 'self.{layout}.addWidget({widget})'.format(layout=layout, widget=widget)
+ if self.parent_flowgraph.get_option('output_language') == 'python':
+ widget_str = 'self.{layout}.addWidget({widget})'.format(layout=layout, widget=widget)
+ elif self.parent_flowgraph.get_option('output_language') == 'cpp':
+ widget_str = '{layout}->addWidget({widget});'.format(layout=layout, widget=widget)
+ else:
+ widget_str = ''
return widget_str