From b2a294302e5cd72ec41b5471f3f8dc5da9abff66 Mon Sep 17 00:00:00 2001 From: Spencer Ross <brashendeavours@gmail.com> Date: Thu, 17 Aug 2017 19:41:04 -0400 Subject: Fixes #1297, adds grc gui_hint collision detection --- grc/core/Param.py | 128 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 106 insertions(+), 22 deletions(-) (limited to 'grc') diff --git a/grc/core/Param.py b/grc/core/Param.py index 00c9e7d827..6c2c83fda8 100644 --- a/grc/core/Param.py +++ b/grc/core/Param.py @@ -533,37 +533,121 @@ class Param(Element): # GUI Position/Hint ######################### elif t == 'gui_hint': - if ':' in v: - tab, pos = v.split(':') - elif '@' in v: - tab, pos = v, '' - else: - tab, pos = '', v - - if '@' in tab: - tab, index = tab.split('@') - else: - index = '?' - - # TODO: Problem with this code. Produces bad tabs - widget_str = ({ - (True, True): 'self.%(tab)s_grid_layout_%(index)s.addWidget(%(widget)s, %(pos)s)', - (True, False): 'self.%(tab)s_layout_%(index)s.addWidget(%(widget)s)', - (False, True): 'self.top_grid_layout.addWidget(%(widget)s, %(pos)s)', - (False, False): 'self.top_layout.addWidget(%(widget)s)', - }[bool(tab), bool(pos)]) % {'tab': tab, 'index': index, 'widget': '%s', 'pos': pos} - + # FIXME: Move replace(...) into the make template of the qtgui blocks # Return a string here class GuiHint(object): def __init__(self, ws): self._ws = ws - + def __call__(self, w): return (self._ws.replace('addWidget', 'addLayout') if 'layout' in w else self._ws) % w - + def __str__(self): return self._ws + + if (self.get_parent().get_state() == Constants.BLOCK_DISABLED): + return GuiHint('') + + # Parsing + if ':' in v: + tab, pos = v.split(':') + elif '@' in v: + tab, pos = v, '' + else: + tab, pos = '', v + + if '@' in tab: + tab, index = tab.split('@') + else: + index = '0' + + position_set = bool(pos) + tab_set = bool(tab) + + # Validation + if position_set: + e = self.get_parent().get_parent().evaluate(pos) + + if len(e) == 2: + e = e + (1,1) + row, col, row_span, col_span = e + + if not isinstance(e, (list, tuple)) or not (len(e) == 2 or len(e) == 4) or not all([isinstance(ei, int) for ei in e]): + raise Exception('Invalid GUI Hint entered: {e!s:s} (Must be a list of {{2,4}} non-negative integers).'.format(e=e)) + + if (row < 0) or (col < 0): + raise Exception('Invalid GUI Hint entered: {e!s:s} (non-negative integers only).'.format(e=e)) + + if (row_span < 1) or (col_span < 1): + raise Exception('Invalid GUI Hint entered: {e!s:s} (positive row/column span required).'.format(e=e)) + + if tab_set: + enabled_blocks = self.get_parent().get_parent().get_enabled_blocks() + tab_list = filter(lambda block: str(block.get_key()) == 'qtgui_tab_widget', enabled_blocks) + tab_match = filter(lambda t: t.get_id() == tab, tab_list) + if not tab_match: + raise Exception('Invalid tab name entered: {tab!s:s} (Tab name not found).'.format(tab=tab)) + + tab_index_size = tab_match[0].get_param('num_tabs').get_value() + if index >= tab_index_size: + raise Exception('Invalid tab index entered: {tab!s:s}@{index!s:s} (Index out of range).'.format(tab=tab, + index=index)) + + # Code Generation + if position_set and tab_set: + widget_str = 'self.{tab:s}_grid_layout_{index:s}.addWidget({widget:s}, {e!s:s})' + widget_str += '\n[self.{tab:s}_grid_layout_{index:s}.setRowStretch(r,1) for r in range({fRow:d},{lRow:d})]' + widget_str += '\n[self.{tab:s}_grid_layout_{index:s}.setColumnStretch(c,1) for c in range({fCol:d},{lCol:d})]' + widget_str = widget_str.format(tab=tab, + index=index, + widget='%s', + e=str(e)[1:-1], + fRow=row, + lRow=(row + row_span), + fCol=col, + lCol=(col + col_span)) + + elif position_set and not tab_set: + widget_str = 'self.top_grid_layout.addWidget({widget:s}, {e!s:s})' + widget_str += '\n[self.top_grid_layout.setRowStretch(r,1) for r in range({fRow:d},{lRow:d})]' + widget_str += '\n[self.top_grid_layout.setColumnStretch(c,1) for c in range({fCol:d},{lCol:d})]' + widget_str = widget_str.format(widget='%s', + e=str(e)[1:-1], + fRow=row, + lRow=(row + row_span), + fCol=col, + lCol=(col + col_span)) + + elif not position_set and tab_set: + widget_str = 'self.{tab:s}_layout_{index:s}.addWidget({widget:s})' + widget_str = widget_str.format(tab=tab, + index=index, + widget='%s') + + elif not position_set and not tab_set: + widget_str = 'self.top_layout.addWidget({widget:s})' + widget_str = widget_str.format(widget='%s') + + # Collision Detection + if position_set: + if tab_set: + my_parent = '{tab:s}@{index:s}'.format(tab=tab, + index=index) + else: + my_parent = 'main' + # Calculate hostage cells + for r in range(row, row + row_span): + for c in range(col, col + col_span): + self._hostage_cells.append((my_parent, (r, c))) + # Avoid collisions + params = filter(lambda p: p is not self, self.get_all_params('gui_hint')) + for param in params: + for parent, cell in param._hostage_cells: + if (parent, cell) in self._hostage_cells: + raise Exception('Another graphical element is using parent "{parent!s:s}", cell "{cell!s:s}".'.format(parent=parent, + cell=cell)) + return GuiHint(widget_str) ######################### # Grid Position Type -- cgit v1.2.3 From 2b35d7086f9585bb18fff3456b9d37d027d0f901 Mon Sep 17 00:00:00 2001 From: Spencer Ross <brashendeavours@gmail.com> Date: Sat, 19 Aug 2017 23:16:38 -0400 Subject: moves gui_hint logic into parsing function, removes GuiHint class from Param.py, cleans up gr-qtgui blocks <make> functions --- gr-qtgui/grc/qtgui_ber_sink_b.xml | 2 +- gr-qtgui/grc/qtgui_check_box.xml | 3 +- gr-qtgui/grc/qtgui_chooser.xml | 3 +- gr-qtgui/grc/qtgui_const_sink_x.xml | 3 +- gr-qtgui/grc/qtgui_edit_box_msg.xml | 2 +- gr-qtgui/grc/qtgui_entry.xml | 5 +- gr-qtgui/grc/qtgui_freq_sink_x.xml | 3 +- gr-qtgui/grc/qtgui_histogram_sink_x.xml | 4 +- gr-qtgui/grc/qtgui_label.xml | 3 +- gr-qtgui/grc/qtgui_number_sink.xml | 3 +- gr-qtgui/grc/qtgui_push_button.xml | 4 +- gr-qtgui/grc/qtgui_range.xml | 3 +- gr-qtgui/grc/qtgui_sink_x.xml | 2 +- gr-qtgui/grc/qtgui_tab_widget.xml | 3 +- gr-qtgui/grc/qtgui_time_raster_x.xml | 3 +- gr-qtgui/grc/qtgui_time_sink_x.xml | 3 +- gr-qtgui/grc/qtgui_vector_sink_f.xml | 3 +- gr-qtgui/grc/qtgui_waterfall_sink_x.xml | 3 +- grc/core/Param.py | 232 ++++++++++++++++---------------- grc/core/generator/Generator.py | 2 +- 20 files changed, 154 insertions(+), 135 deletions(-) (limited to 'grc') diff --git a/gr-qtgui/grc/qtgui_ber_sink_b.xml b/gr-qtgui/grc/qtgui_ber_sink_b.xml index da3fc6ebf8..851502a774 100644 --- a/gr-qtgui/grc/qtgui_ber_sink_b.xml +++ b/gr-qtgui/grc/qtgui_ber_sink_b.xml @@ -47,7 +47,7 @@ for i in xrange($num_curves): self.$(id).set_line_alpha(i, alphas[i]) self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> <param> <name>esno</name> diff --git a/gr-qtgui/grc/qtgui_check_box.xml b/gr-qtgui/grc/qtgui_check_box.xml index 67c8848a22..a02c83e3cf 100644 --- a/gr-qtgui/grc/qtgui_check_box.xml +++ b/gr-qtgui/grc/qtgui_check_box.xml @@ -20,7 +20,8 @@ self._$(id)_choices_inv = dict((v,k) for k,v in self._$(id)_choices.iteritems()) self._$(id)_callback = lambda i: Qt.QMetaObject.invokeMethod($(win), "setChecked", Qt.Q_ARG("bool", self._$(id)_choices_inv[i])) self._$(id)_callback(self.$id) $(win).stateChanged.connect(lambda i: self.set_$(id)(self._$(id)_choices[bool(i)])) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>self.set_$(id)($value)</callback> <callback>self._$(id)_callback($id)</callback> <param> diff --git a/gr-qtgui/grc/qtgui_chooser.xml b/gr-qtgui/grc/qtgui_chooser.xml index f018354dd4..b91566ae74 100644 --- a/gr-qtgui/grc/qtgui_chooser.xml +++ b/gr-qtgui/grc/qtgui_chooser.xml @@ -86,7 +86,8 @@ self._$(id)_callback(self.$id) self._$(id)_button_group.buttonClicked[int].connect( lambda i: self.set_$(id)(self._$(id)_options[i])) #end if -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>self.set_$(id)($value)</callback> <callback>self._$(id)_callback($id)</callback> <param> diff --git a/gr-qtgui/grc/qtgui_const_sink_x.xml b/gr-qtgui/grc/qtgui_const_sink_x.xml index 755f12f964..6bf31d5190 100644 --- a/gr-qtgui/grc/qtgui_const_sink_x.xml +++ b/gr-qtgui/grc/qtgui_const_sink_x.xml @@ -51,7 +51,8 @@ for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): self.$(id).set_line_alpha(i, alphas[i]) self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>set_resize($width, $height)</callback> <callback>set_update_time($update_time)</callback> <callback>set_title($which, $title)</callback> diff --git a/gr-qtgui/grc/qtgui_edit_box_msg.xml b/gr-qtgui/grc/qtgui_edit_box_msg.xml index c7c758a612..276cfe9801 100644 --- a/gr-qtgui/grc/qtgui_edit_box_msg.xml +++ b/gr-qtgui/grc/qtgui_edit_box_msg.xml @@ -13,7 +13,7 @@ <make>#set $win = 'self._%s_win'%$id qtgui.edit_box_msg($(type.t), $value, $label, $is_pair, $is_static, $key) self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> <param> <name>Type</name> diff --git a/gr-qtgui/grc/qtgui_entry.xml b/gr-qtgui/grc/qtgui_entry.xml index cce2edb4b2..ab35aec858 100644 --- a/gr-qtgui/grc/qtgui_entry.xml +++ b/gr-qtgui/grc/qtgui_entry.xml @@ -21,9 +21,12 @@ self._$(id)_line_edit = Qt.QLineEdit(str(self.$id)) self._$(id)_tool_bar.addWidget(self._$(id)_line_edit) self._$(id)_line_edit.returnPressed.connect( lambda: self.set_$(id)($(type.conv)(str(self._$(id)_line_edit.text().toAscii())))) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>self.set_$(id)($value)</callback> + <callback>Qt.QMetaObject.invokeMethod(self._$(id)_line_edit, "setText", Qt.Q_ARG("QString", $(type.str)($id)))</callback> + <param> <name>Label</name> <key>label</key> diff --git a/gr-qtgui/grc/qtgui_freq_sink_x.xml b/gr-qtgui/grc/qtgui_freq_sink_x.xml index 009a184327..5c6595cb33 100644 --- a/gr-qtgui/grc/qtgui_freq_sink_x.xml +++ b/gr-qtgui/grc/qtgui_freq_sink_x.xml @@ -54,7 +54,8 @@ for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): self.$(id).set_line_alpha(i, alphas[i]) self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>set_frequency_range($fc, $bw)</callback> <callback>set_update_time($update_time)</callback> <callback>set_title($which, $title)</callback> diff --git a/gr-qtgui/grc/qtgui_histogram_sink_x.xml b/gr-qtgui/grc/qtgui_histogram_sink_x.xml index a789d2e4fa..8bf9662b74 100644 --- a/gr-qtgui/grc/qtgui_histogram_sink_x.xml +++ b/gr-qtgui/grc/qtgui_histogram_sink_x.xml @@ -53,8 +53,8 @@ for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): self.$(id).set_line_alpha(i, alphas[i]) self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win)) - </make> +$(gui_hint() % $win)</make> + <callback>set_update_time($update_time)</callback> <callback>set_title($which, $title)</callback> <callback>set_color($which, $color)</callback> diff --git a/gr-qtgui/grc/qtgui_label.xml b/gr-qtgui/grc/qtgui_label.xml index d67f3d7500..90b77fa968 100644 --- a/gr-qtgui/grc/qtgui_label.xml +++ b/gr-qtgui/grc/qtgui_label.xml @@ -26,8 +26,7 @@ else: $(win).addWidget(Qt.QLabel($label+": ")) self._$(id)_label = Qt.QLabel(str(self._$(id)_formatter(self.$id))) self._$(id)_tool_bar.addWidget(self._$(id)_label) -$(gui_hint()($win)) - </make> +$(gui_hint() % $win)</make> <callback>self.set_$(id)(self._$(id)_formatter($value))</callback> <callback>Qt.QMetaObject.invokeMethod(self._$(id)_label, "setText", Qt.Q_ARG("QString", $id))</callback> diff --git a/gr-qtgui/grc/qtgui_number_sink.xml b/gr-qtgui/grc/qtgui_number_sink.xml index d10b7325c0..264baae667 100644 --- a/gr-qtgui/grc/qtgui_number_sink.xml +++ b/gr-qtgui/grc/qtgui_number_sink.xml @@ -41,7 +41,8 @@ for i in xrange($nconnections): self.$(id).enable_autoscale($autoscale) self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>set_update_time($update_time)</callback> <param_tab_order> diff --git a/gr-qtgui/grc/qtgui_push_button.xml b/gr-qtgui/grc/qtgui_push_button.xml index a535bb6473..e4f598e725 100644 --- a/gr-qtgui/grc/qtgui_push_button.xml +++ b/gr-qtgui/grc/qtgui_push_button.xml @@ -18,8 +18,10 @@ $win = Qt.QPushButton($label) self._$(id)_choices = {'Pressed': $pressed, 'Released': $released} $(win).pressed.connect(lambda: self.set_$(id)(self._$(id)_choices['Pressed'])) $(win).released.connect(lambda: self.set_$(id)(self._$(id)_choices['Released'])) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>self.set_$(id)($value)</callback> + <param> <name>Label</name> <key>label</key> diff --git a/gr-qtgui/grc/qtgui_range.xml b/gr-qtgui/grc/qtgui_range.xml index 71b614cc5e..0999311a0b 100644 --- a/gr-qtgui/grc/qtgui_range.xml +++ b/gr-qtgui/grc/qtgui_range.xml @@ -17,7 +17,8 @@ #end if $(range) = Range($start, $stop, $step, $value, $min_len) $(win) = RangeWidget($range, self.set_$(id), $label, "$widget", $rangeType) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>self.set_$(id)($value)</callback> <param> diff --git a/gr-qtgui/grc/qtgui_sink_x.xml b/gr-qtgui/grc/qtgui_sink_x.xml index 7488ea59d8..4dbf0e6375 100644 --- a/gr-qtgui/grc/qtgui_sink_x.xml +++ b/gr-qtgui/grc/qtgui_sink_x.xml @@ -25,7 +25,7 @@ qtgui.$(type.fcn)( ) self.$(id).set_update_time(1.0/$rate) self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win)) +$(gui_hint() % $win) self.$(id).enable_rf_freq($showrf) diff --git a/gr-qtgui/grc/qtgui_tab_widget.xml b/gr-qtgui/grc/qtgui_tab_widget.xml index 1bbadc8e51..fc8ad0553a 100644 --- a/gr-qtgui/grc/qtgui_tab_widget.xml +++ b/gr-qtgui/grc/qtgui_tab_widget.xml @@ -21,7 +21,8 @@ self.$(id)_grid_layout_$(i) = Qt.QGridLayout() self.$(id)_layout_$(i).addLayout(self.$(id)_grid_layout_$(i)) $(win).addTab(self.$(id)_widget_$(i), $label) #end for -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <param> <name>Num Tabs</name> <key>num_tabs</key> diff --git a/gr-qtgui/grc/qtgui_time_raster_x.xml b/gr-qtgui/grc/qtgui_time_raster_x.xml index 0359dc3b71..2d2f3cbff4 100644 --- a/gr-qtgui/grc/qtgui_time_raster_x.xml +++ b/gr-qtgui/grc/qtgui_time_raster_x.xml @@ -41,7 +41,8 @@ for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): self.$(id).set_line_alpha(i, alphas[i]) self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>set_num_rows($nrows)</callback> <callback>set_num_cols($ncols)</callback> <callback>set_multiplier($mult)</callback> diff --git a/gr-qtgui/grc/qtgui_time_sink_x.xml b/gr-qtgui/grc/qtgui_time_sink_x.xml index fbee4ca483..726e9fdf34 100644 --- a/gr-qtgui/grc/qtgui_time_sink_x.xml +++ b/gr-qtgui/grc/qtgui_time_sink_x.xml @@ -74,7 +74,8 @@ for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): #end if self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>set_time_domain_axis($min, $max)</callback> <callback>set_update_time($update_time)</callback> <callback>set_title($which, $title)</callback> diff --git a/gr-qtgui/grc/qtgui_vector_sink_f.xml b/gr-qtgui/grc/qtgui_vector_sink_f.xml index 9f40d57729..1c17b8256a 100644 --- a/gr-qtgui/grc/qtgui_vector_sink_f.xml +++ b/gr-qtgui/grc/qtgui_vector_sink_f.xml @@ -46,7 +46,8 @@ for i in xrange($nconnections): self.$(id).set_line_alpha(i, alphas[i]) self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>set_update_time($update_time)</callback> <callback>set_title($title)</callback> <callback>set_color($which, $color)</callback> diff --git a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml b/gr-qtgui/grc/qtgui_waterfall_sink_x.xml index cdecd5cce1..206318e30d 100644 --- a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml +++ b/gr-qtgui/grc/qtgui_waterfall_sink_x.xml @@ -47,7 +47,8 @@ for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): self.$(id).set_intensity_range($int_min, $int_max) self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> +$(gui_hint() % $win)</make> + <callback>set_frequency_range($fc, $bw)</callback> <callback>set_update_time($update_time)</callback> <callback>set_title($which, $title)</callback> diff --git a/grc/core/Param.py b/grc/core/Param.py index 6c2c83fda8..00336737b0 100644 --- a/grc/core/Param.py +++ b/grc/core/Param.py @@ -533,122 +533,10 @@ class Param(Element): # GUI Position/Hint ######################### elif t == 'gui_hint': - - # FIXME: Move replace(...) into the make template of the qtgui blocks - # Return a string here - class GuiHint(object): - def __init__(self, ws): - self._ws = ws - - def __call__(self, w): - return (self._ws.replace('addWidget', 'addLayout') if 'layout' in w else self._ws) % w - - def __str__(self): - return self._ws - if (self.get_parent().get_state() == Constants.BLOCK_DISABLED): - return GuiHint('') - - # Parsing - if ':' in v: - tab, pos = v.split(':') - elif '@' in v: - tab, pos = v, '' - else: - tab, pos = '', v - - if '@' in tab: - tab, index = tab.split('@') + return '' else: - index = '0' - - position_set = bool(pos) - tab_set = bool(tab) - - # Validation - if position_set: - e = self.get_parent().get_parent().evaluate(pos) - - if len(e) == 2: - e = e + (1,1) - row, col, row_span, col_span = e - - if not isinstance(e, (list, tuple)) or not (len(e) == 2 or len(e) == 4) or not all([isinstance(ei, int) for ei in e]): - raise Exception('Invalid GUI Hint entered: {e!s:s} (Must be a list of {{2,4}} non-negative integers).'.format(e=e)) - - if (row < 0) or (col < 0): - raise Exception('Invalid GUI Hint entered: {e!s:s} (non-negative integers only).'.format(e=e)) - - if (row_span < 1) or (col_span < 1): - raise Exception('Invalid GUI Hint entered: {e!s:s} (positive row/column span required).'.format(e=e)) - - if tab_set: - enabled_blocks = self.get_parent().get_parent().get_enabled_blocks() - tab_list = filter(lambda block: str(block.get_key()) == 'qtgui_tab_widget', enabled_blocks) - tab_match = filter(lambda t: t.get_id() == tab, tab_list) - if not tab_match: - raise Exception('Invalid tab name entered: {tab!s:s} (Tab name not found).'.format(tab=tab)) - - tab_index_size = tab_match[0].get_param('num_tabs').get_value() - if index >= tab_index_size: - raise Exception('Invalid tab index entered: {tab!s:s}@{index!s:s} (Index out of range).'.format(tab=tab, - index=index)) - - # Code Generation - if position_set and tab_set: - widget_str = 'self.{tab:s}_grid_layout_{index:s}.addWidget({widget:s}, {e!s:s})' - widget_str += '\n[self.{tab:s}_grid_layout_{index:s}.setRowStretch(r,1) for r in range({fRow:d},{lRow:d})]' - widget_str += '\n[self.{tab:s}_grid_layout_{index:s}.setColumnStretch(c,1) for c in range({fCol:d},{lCol:d})]' - widget_str = widget_str.format(tab=tab, - index=index, - widget='%s', - e=str(e)[1:-1], - fRow=row, - lRow=(row + row_span), - fCol=col, - lCol=(col + col_span)) - - elif position_set and not tab_set: - widget_str = 'self.top_grid_layout.addWidget({widget:s}, {e!s:s})' - widget_str += '\n[self.top_grid_layout.setRowStretch(r,1) for r in range({fRow:d},{lRow:d})]' - widget_str += '\n[self.top_grid_layout.setColumnStretch(c,1) for c in range({fCol:d},{lCol:d})]' - widget_str = widget_str.format(widget='%s', - e=str(e)[1:-1], - fRow=row, - lRow=(row + row_span), - fCol=col, - lCol=(col + col_span)) - - elif not position_set and tab_set: - widget_str = 'self.{tab:s}_layout_{index:s}.addWidget({widget:s})' - widget_str = widget_str.format(tab=tab, - index=index, - widget='%s') - - elif not position_set and not tab_set: - widget_str = 'self.top_layout.addWidget({widget:s})' - widget_str = widget_str.format(widget='%s') - - # Collision Detection - if position_set: - if tab_set: - my_parent = '{tab:s}@{index:s}'.format(tab=tab, - index=index) - else: - my_parent = 'main' - # Calculate hostage cells - for r in range(row, row + row_span): - for c in range(col, col + col_span): - self._hostage_cells.append((my_parent, (r, c))) - # Avoid collisions - params = filter(lambda p: p is not self, self.get_all_params('gui_hint')) - for param in params: - for parent, cell in param._hostage_cells: - if (parent, cell) in self._hostage_cells: - raise Exception('Another graphical element is using parent "{parent!s:s}", cell "{cell!s:s}".'.format(parent=parent, - cell=cell)) - - return GuiHint(widget_str) + return self.parse_gui_hint(v) ######################### # Grid Position Type ######################### @@ -837,3 +725,119 @@ class Param(Element): n['key'] = self.get_key() n['value'] = self.get_value() return n + + ############################################## + # GUI Hint + ############################################## + def parse_gui_hint(self, v): + """ + Parse/validate gui hint value. + + Args: + v: gui_hint string from a block's 'gui_hint' param + + Returns: + string of python code for positioning GUI elements in pyQT + """ + + # Parsing + if ':' in v: + tab, pos = v.split(':') + elif ',' in v: + tab, pos = '', v + else: + tab, pos = v, '' + + if '@' in tab: + tab, index = tab.split('@') + else: + index = '0' + index = int(index) + + position_set = bool(pos) + tab_set = bool(tab) + + # Validation + if position_set: + e = self.get_parent().get_parent().evaluate(pos) + + if len(e) == 2: + e = e + (1,1) + row, col, row_span, col_span = e + + if not isinstance(e, (list, tuple)) or not (len(e) == 2 or len(e) == 4) or not all([isinstance(ei, int) for ei in e]): + raise Exception('Invalid GUI Hint entered: {e!s:s} (Must be a list of {{2,4}} non-negative integers).'.format(e=e)) + + if (row < 0) or (col < 0): + raise Exception('Invalid GUI Hint entered: {e!s:s} (non-negative integers only).'.format(e=e)) + + if (row_span < 1) or (col_span < 1): + raise Exception('Invalid GUI Hint entered: {e!s:s} (positive row/column span required).'.format(e=e)) + + if tab_set: + enabled_blocks = self.get_parent().get_parent().get_enabled_blocks() + tab_list = filter(lambda block: str(block.get_key()) == 'qtgui_tab_widget', enabled_blocks) + tab_match = filter(lambda t: t.get_id() == tab, tab_list) + if not tab_match: + raise Exception('Invalid tab name entered: {tab!s:s} (Tab name not found).'.format(tab=tab)) + + tab_index_size = int(tab_match[0].get_param('num_tabs').get_value()) + if index >= tab_index_size: + raise Exception('Invalid tab index entered: {tab!s:s}@{index!s:s} (Index out of range).'.format(tab=tab, + index=index)) + + # Code Generation + if position_set and tab_set: + widget_str = 'self.{tab:s}_grid_layout_{index!s:s}.addWidget({widget:s}, {e!s:s})' + widget_str += '\n[self.{tab:s}_grid_layout_{index!s:s}.setRowStretch(r,1) for r in range({fRow:d},{lRow:d})]' + widget_str += '\n[self.{tab:s}_grid_layout_{index!s:s}.setColumnStretch(c,1) for c in range({fCol:d},{lCol:d})]' + widget_str = widget_str.format(tab=tab, + index=index, + widget='%s', + e=str(e)[1:-1], + fRow=row, + lRow=(row + row_span), + fCol=col, + lCol=(col + col_span)) + + elif position_set and not tab_set: + widget_str = 'self.top_grid_layout.addWidget({widget:s}, {e!s:s})' + widget_str += '\n[self.top_grid_layout.setRowStretch(r,1) for r in range({fRow:d},{lRow:d})]' + widget_str += '\n[self.top_grid_layout.setColumnStretch(c,1) for c in range({fCol:d},{lCol:d})]' + widget_str = widget_str.format(widget='%s', + e=str(e)[1:-1], + fRow=row, + lRow=(row + row_span), + fCol=col, + lCol=(col + col_span)) + + elif not position_set and tab_set: + widget_str = 'self.{tab:s}_layout_{index!s:s}.addWidget({widget:s})' + widget_str = widget_str.format(tab=tab, + index=index, + widget='%s') + + elif not position_set and not tab_set: + widget_str = 'self.top_layout.addWidget({widget:s})' + widget_str = widget_str.format(widget='%s') + + # Collision Detection + if position_set: + if tab_set: + my_parent = '{tab:s}@{index!s:s}'.format(tab=tab, + index=index) + else: + my_parent = 'main' + # Calculate hostage cells + for r in range(row, row + row_span): + for c in range(col, col + col_span): + self._hostage_cells.append((my_parent, (r, c))) + # Avoid collisions + params = filter(lambda p: p is not self, self.get_all_params('gui_hint')) + for param in params: + for parent, cell in param._hostage_cells: + if (parent, cell) in self._hostage_cells: + raise Exception('Another graphical element is using parent "{parent!s:s}", cell "{cell!s:s}".'.format(parent=parent, + cell=cell)) + + return widget_str \ No newline at end of file diff --git a/grc/core/generator/Generator.py b/grc/core/generator/Generator.py index 8c1cd9a6b0..2e639d4985 100644 --- a/grc/core/generator/Generator.py +++ b/grc/core/generator/Generator.py @@ -398,6 +398,6 @@ class QtHierBlockGenerator(HierBlockGenerator): block_n['make'] += ( "\n#set $win = 'self.%s' % $id" - "\n${gui_hint()($win)}" + "\n${gui_hint() % $win}" ) return n -- cgit v1.2.3 From 4804d1fdb6950d2b2ec5707cd8a362f01ed2cf90 Mon Sep 17 00:00:00 2001 From: Håkon Vågsether <haakonsv@gmail.com> Date: Thu, 5 Oct 2017 11:57:24 +0200 Subject: Added YAML blocks that needed manual editing --- gr-qtgui/grc/CMakeLists.txt | 26 +- gr-qtgui/grc/qtgui.tree.yml | 23 + gr-qtgui/grc/qtgui_ber_sink_b.block.yml | 366 ++++++++++ gr-qtgui/grc/qtgui_ber_sink_b.xml | 684 ------------------ gr-qtgui/grc/qtgui_block_tree.xml | 61 -- gr-qtgui/grc/qtgui_check_box.block.yml | 66 ++ gr-qtgui/grc/qtgui_check_box.xml | 82 --- gr-qtgui/grc/qtgui_chooser.block.yml | 191 +++++ gr-qtgui/grc/qtgui_chooser.xml | 257 ------- gr-qtgui/grc/qtgui_const_sink_x.block.yml | 457 ++++++++++++ gr-qtgui/grc/qtgui_const_sink_x.xml | 859 ----------------------- gr-qtgui/grc/qtgui_edit_box_msg.block.yml | 69 ++ gr-qtgui/grc/qtgui_edit_box_msg.xml | 152 ---- gr-qtgui/grc/qtgui_entry.block.yml | 57 ++ gr-qtgui/grc/qtgui_entry.xml | 67 -- gr-qtgui/grc/qtgui_freq_sink_x.block.yml | 447 ++++++++++++ gr-qtgui/grc/qtgui_freq_sink_x.xml | 791 --------------------- gr-qtgui/grc/qtgui_histogram_sink_x.block.yml | 419 +++++++++++ gr-qtgui/grc/qtgui_histogram_sink_x.xml | 794 --------------------- gr-qtgui/grc/qtgui_label.block.yml | 66 ++ gr-qtgui/grc/qtgui_label.xml | 87 --- gr-qtgui/grc/qtgui_number_sink.block.yml | 283 ++++++++ gr-qtgui/grc/qtgui_number_sink.xml | 496 ------------- gr-qtgui/grc/qtgui_push_button.block.yml | 60 ++ gr-qtgui/grc/qtgui_push_button.xml | 79 --- gr-qtgui/grc/qtgui_range.block.yml | 86 +++ gr-qtgui/grc/qtgui_range.xml | 131 ---- gr-qtgui/grc/qtgui_sink_x.block.yml | 148 ++++ gr-qtgui/grc/qtgui_sink_x.xml | 232 ------ gr-qtgui/grc/qtgui_tab_widget.block.yml | 141 ++++ gr-qtgui/grc/qtgui_tab_widget.xml | 206 ------ gr-qtgui/grc/qtgui_time_raster_x.block.yml | 266 +++++++ gr-qtgui/grc/qtgui_time_raster_x.xml | 466 ------------- gr-qtgui/grc/qtgui_time_sink_x.block.yml | 559 +++++++++++++++ gr-qtgui/grc/qtgui_time_sink_x.xml | 948 ------------------------- gr-qtgui/grc/qtgui_vector_sink_f.block.yml | 352 ++++++++++ gr-qtgui/grc/qtgui_vector_sink_f.xml | 603 ---------------- gr-qtgui/grc/qtgui_waterfall_sink_x.block.yml | 303 ++++++++ gr-qtgui/grc/qtgui_waterfall_sink_x.xml | 557 --------------- gr-uhd/grc/CMakeLists.txt | 26 +- gr-uhd/grc/gen_uhd_usrp_blocks.py | 968 +++++++++----------------- gr-uhd/grc/uhd.tree.yml | 5 + gr-uhd/grc/uhd_amsg_source.block.yml | 18 + gr-uhd/grc/uhd_amsg_source.xml | 24 - gr-uhd/grc/uhd_block_tree.xml | 15 - grc/blocks/CMakeLists.txt | 35 +- grc/blocks/block_tree.xml | 24 - grc/blocks/grc.tree.yml | 15 + grc/blocks/import.block.yml | 20 + grc/blocks/import.xml | 26 - grc/blocks/note.block.yml | 9 + grc/blocks/note.xml | 17 - grc/blocks/options.block.yml | 146 ++++ grc/blocks/options.xml | 250 ------- grc/blocks/pad_sink.block.yml | 51 ++ grc/blocks/pad_sink.xml | 103 --- grc/blocks/pad_source.block.yml | 51 ++ grc/blocks/pad_source.xml | 104 --- grc/blocks/parameter.block.yml | 55 ++ grc/blocks/parameter.xml | 118 ---- grc/blocks/variable.block.yml | 19 + grc/blocks/variable.xml | 23 - grc/blocks/variable_config.block.yml | 58 ++ grc/blocks/variable_config.xml | 88 --- grc/blocks/variable_function_probe.block.yml | 54 ++ grc/blocks/variable_function_probe.xml | 78 --- grc/blocks/variable_struct.block.yml.py | 105 +++ grc/blocks/variable_struct.xml.py | 97 --- grc/blocks/virtual_sink.block.yml | 13 + grc/blocks/virtual_sink.xml | 21 - grc/blocks/virtual_source.block.yml | 13 + grc/blocks/virtual_source.xml | 21 - grc/tests/resources/file1.block.yml | 38 + grc/tests/resources/file1.xml | 58 -- grc/tests/resources/file2.block.yml | 31 + grc/tests/resources/file2.xml | 80 --- grc/tests/resources/file3.block.yml | 66 ++ grc/tests/resources/file3.xml | 100 --- 78 files changed, 5491 insertions(+), 9489 deletions(-) create mode 100644 gr-qtgui/grc/qtgui.tree.yml create mode 100644 gr-qtgui/grc/qtgui_ber_sink_b.block.yml delete mode 100644 gr-qtgui/grc/qtgui_ber_sink_b.xml delete mode 100644 gr-qtgui/grc/qtgui_block_tree.xml create mode 100644 gr-qtgui/grc/qtgui_check_box.block.yml delete mode 100644 gr-qtgui/grc/qtgui_check_box.xml create mode 100644 gr-qtgui/grc/qtgui_chooser.block.yml delete mode 100644 gr-qtgui/grc/qtgui_chooser.xml create mode 100644 gr-qtgui/grc/qtgui_const_sink_x.block.yml delete mode 100644 gr-qtgui/grc/qtgui_const_sink_x.xml create mode 100644 gr-qtgui/grc/qtgui_edit_box_msg.block.yml delete mode 100644 gr-qtgui/grc/qtgui_edit_box_msg.xml create mode 100644 gr-qtgui/grc/qtgui_entry.block.yml delete mode 100644 gr-qtgui/grc/qtgui_entry.xml create mode 100644 gr-qtgui/grc/qtgui_freq_sink_x.block.yml delete mode 100644 gr-qtgui/grc/qtgui_freq_sink_x.xml create mode 100644 gr-qtgui/grc/qtgui_histogram_sink_x.block.yml delete mode 100644 gr-qtgui/grc/qtgui_histogram_sink_x.xml create mode 100644 gr-qtgui/grc/qtgui_label.block.yml delete mode 100644 gr-qtgui/grc/qtgui_label.xml create mode 100644 gr-qtgui/grc/qtgui_number_sink.block.yml delete mode 100644 gr-qtgui/grc/qtgui_number_sink.xml create mode 100644 gr-qtgui/grc/qtgui_push_button.block.yml delete mode 100644 gr-qtgui/grc/qtgui_push_button.xml create mode 100644 gr-qtgui/grc/qtgui_range.block.yml delete mode 100644 gr-qtgui/grc/qtgui_range.xml create mode 100644 gr-qtgui/grc/qtgui_sink_x.block.yml delete mode 100644 gr-qtgui/grc/qtgui_sink_x.xml create mode 100644 gr-qtgui/grc/qtgui_tab_widget.block.yml delete mode 100644 gr-qtgui/grc/qtgui_tab_widget.xml create mode 100644 gr-qtgui/grc/qtgui_time_raster_x.block.yml delete mode 100644 gr-qtgui/grc/qtgui_time_raster_x.xml create mode 100644 gr-qtgui/grc/qtgui_time_sink_x.block.yml delete mode 100644 gr-qtgui/grc/qtgui_time_sink_x.xml create mode 100644 gr-qtgui/grc/qtgui_vector_sink_f.block.yml delete mode 100644 gr-qtgui/grc/qtgui_vector_sink_f.xml create mode 100644 gr-qtgui/grc/qtgui_waterfall_sink_x.block.yml delete mode 100644 gr-qtgui/grc/qtgui_waterfall_sink_x.xml create mode 100644 gr-uhd/grc/uhd.tree.yml create mode 100644 gr-uhd/grc/uhd_amsg_source.block.yml delete mode 100644 gr-uhd/grc/uhd_amsg_source.xml delete mode 100644 gr-uhd/grc/uhd_block_tree.xml delete mode 100644 grc/blocks/block_tree.xml create mode 100644 grc/blocks/grc.tree.yml create mode 100644 grc/blocks/import.block.yml delete mode 100644 grc/blocks/import.xml create mode 100644 grc/blocks/note.block.yml delete mode 100644 grc/blocks/note.xml create mode 100644 grc/blocks/options.block.yml delete mode 100644 grc/blocks/options.xml create mode 100644 grc/blocks/pad_sink.block.yml delete mode 100644 grc/blocks/pad_sink.xml create mode 100644 grc/blocks/pad_source.block.yml delete mode 100644 grc/blocks/pad_source.xml create mode 100644 grc/blocks/parameter.block.yml delete mode 100644 grc/blocks/parameter.xml create mode 100644 grc/blocks/variable.block.yml delete mode 100644 grc/blocks/variable.xml create mode 100644 grc/blocks/variable_config.block.yml delete mode 100644 grc/blocks/variable_config.xml create mode 100644 grc/blocks/variable_function_probe.block.yml delete mode 100644 grc/blocks/variable_function_probe.xml create mode 100644 grc/blocks/variable_struct.block.yml.py delete mode 100644 grc/blocks/variable_struct.xml.py create mode 100644 grc/blocks/virtual_sink.block.yml delete mode 100644 grc/blocks/virtual_sink.xml create mode 100644 grc/blocks/virtual_source.block.yml delete mode 100644 grc/blocks/virtual_source.xml create mode 100644 grc/tests/resources/file1.block.yml delete mode 100644 grc/tests/resources/file1.xml create mode 100644 grc/tests/resources/file2.block.yml delete mode 100644 grc/tests/resources/file2.xml create mode 100644 grc/tests/resources/file3.block.yml delete mode 100644 grc/tests/resources/file3.xml (limited to 'grc') diff --git a/gr-qtgui/grc/CMakeLists.txt b/gr-qtgui/grc/CMakeLists.txt index 74e6958639..f9ccf116cb 100644 --- a/gr-qtgui/grc/CMakeLists.txt +++ b/gr-qtgui/grc/CMakeLists.txt @@ -18,30 +18,30 @@ # Boston, MA 02110-1301, USA. ######################################################################## -file(GLOB xml_files "*.xml") +file(GLOB yml_files "*.yml") -macro(REPLACE_IN_FILE _xml_block match replace) - set(xml_block_src "${CMAKE_CURRENT_SOURCE_DIR}/${_xml_block}") - set(xml_block "${CMAKE_CURRENT_BINARY_DIR}/${_xml_block}") +macro(REPLACE_IN_FILE _yml_block match replace) + set(yml_block_src "${CMAKE_CURRENT_SOURCE_DIR}/${_yml_block}") + set(yml_block "${CMAKE_CURRENT_BINARY_DIR}/${_yml_block}") - list(REMOVE_ITEM xml_files "${xml_block_src}") - file(READ "${xml_block_src}" xml_block_src_text) + list(REMOVE_ITEM yml_files "${yml_block_src}") + file(READ "${yml_block_src}" yml_block_src_text) string(REPLACE "${match}" "${replace}" - xml_block_text "${xml_block_src_text}") - file(WRITE "${xml_block}" "${xml_block_text}") + yml_block_text "${yml_block_src_text}") + file(WRITE "${yml_block}" "${yml_block_text}") - list(APPEND generated_xml_files "${xml_block}") + list(APPEND generated_yml_files "${yml_block}") endmacro() if(DESIRED_QT_VERSION EQUAL 4) - foreach(xml_block_src ${xml_files}) - get_filename_component(xml_block "${xml_block_src}" NAME) - REPLACE_IN_FILE("${xml_block}" "PyQt5" "PyQt4") + foreach(yml_block_src ${yml_files}) + get_filename_component(yml_block "${yml_block_src}" NAME) + REPLACE_IN_FILE("${yml_block}" "PyQt5" "PyQt4") endforeach() endif() install( - FILES ${xml_files} ${generated_xml_files} + FILES ${yml_files} ${generated_yml_files} DESTINATION "${GRC_BLOCKS_DIR}" ) diff --git a/gr-qtgui/grc/qtgui.tree.yml b/gr-qtgui/grc/qtgui.tree.yml new file mode 100644 index 0000000000..e479adf6af --- /dev/null +++ b/gr-qtgui/grc/qtgui.tree.yml @@ -0,0 +1,23 @@ +'[Core]': +- Instrumentation: + - QT: + - qtgui_freq_sink_x + - qtgui_time_sink_x + - qtgui_const_sink_x + - qtgui_waterfall_sink_x + - qtgui_time_raster_sink_x + - qtgui_bercurve_sink + - qtgui_histogram_sink_x + - qtgui_number_sink + - qtgui_vector_sink_f + - qtgui_sink_x +- GUI Widgets: + - QT: + - qtgui_tab_widget + - variable_qtgui_range + - variable_qtgui_chooser + - variable_qtgui_check_box + - variable_qtgui_push_button + - variable_qtgui_entry + - variable_qtgui_label + - qtgui_edit_box_msg diff --git a/gr-qtgui/grc/qtgui_ber_sink_b.block.yml b/gr-qtgui/grc/qtgui_ber_sink_b.block.yml new file mode 100644 index 0000000000..3060862299 --- /dev/null +++ b/gr-qtgui/grc/qtgui_ber_sink_b.block.yml @@ -0,0 +1,366 @@ +id: qtgui_bercurve_sink +label: QT GUI Bercurve Sink + +parameters: +- id: esno + label: esno + dtype: raw + default: numpy.arange(0.0, 4.0, .5) + hide: part +- id: berminerrors + label: Min. BER Errs. + dtype: int + default: '100' +- id: berlimit + label: BER Limit + dtype: real + default: '-7.0' +- id: num_curves + label: Num Curves + dtype: int + default: '1' + hide: part +- id: curvenames + label: Curve Names + dtype: raw + default: '[]' + hide: part +- id: ymin + label: Y min + dtype: real + default: '-10' + hide: part +- id: ymax + label: Y max + dtype: real + default: '0' + hide: part +- id: update_time + label: Update Period + dtype: real + default: '0.10' + hide: part +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +- id: label1 + label: Line 1 Label + category: Config + dtype: string + hide: ${ ('part' if int(num_curves) >= 1 else 'all') } +- id: width1 + label: Line 1 Width + category: Config + dtype: int + default: '1' + hide: ${ ('part' if int(num_curves) >= 1 else 'all') } +- id: color1 + label: Line 1 Color + category: Config + dtype: enum + options: ['"blue"', '"red"', '"green"', '"black"', '"cyan"', '"magenta"', '"yellow"', + '"dark red"', '"dark green"', '"Dark Blue"'] + option_labels: [Blue, Red, Green, Black, Cyan, Magenta, Yellow, Dark Red, Dark + Green, Dark Blue] + hide: ${ ('part' if int(num_curves) >= 1 else 'all') } +- id: style1 + label: Line 1 Style + category: Config + dtype: enum + options: ['1', '2', '3', '4', '5', '0'] + option_labels: [Solid, Dash, Dots, Dash-Dot, Dash-Dot-Dot, None] + hide: ${ ('part' if int(num_curves) >= 1 else 'all') } +- id: marker1 + label: Line 1 Marker + category: Config + dtype: enum + options: ['0', '1', '2', '3', '4', '6', '7', '8', '9', '-1'] + option_labels: [Circle, Rectangle, Diamond, Triangle, Down Triangle, Left Triangle, + Right Triangle, Cross, X-Cross, None] + hide: ${ ('part' if int(num_curves) >= 1 else 'all') } +- id: alpha1 + label: Line 1 Alpha + category: Config + dtype: float + default: '1.0' + hide: ${ ('part' if int(num_curves) >= 1 else 'all') } +- id: label2 + label: Line 2 Label + dtype: '' + hide: ${ ('part' if int(num_curves) >= 2 else 'all') } +- id: width2 + label: Line 2 Width + dtype: '' + hide: ${ ('part' if int(num_curves) >= 2 else 'all') } +- id: color2 + label: Line 2 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(num_curves) >= 2 else 'all') } +- id: style2 + label: Line 2 Style + dtype: '' + hide: ${ ('part' if int(num_curves) >= 2 else 'all') } +- id: marker2 + label: Line 2 Marker + dtype: '' + hide: ${ ('part' if int(num_curves) >= 2 else 'all') } +- id: alpha2 + label: Line 2 Alpha + dtype: '' + hide: ${ ('part' if int(num_curves) >= 2 else 'all') } +- id: label3 + label: Line 3 Label + dtype: '' + hide: ${ ('part' if int(num_curves) >= 3 else 'all') } +- id: width3 + label: Line 3 Width + dtype: '' + hide: ${ ('part' if int(num_curves) >= 3 else 'all') } +- id: color3 + label: Line 3 Color + dtype: '' + default: '"green"' + hide: ${ ('part' if int(num_curves) >= 3 else 'all') } +- id: style3 + label: Line 3 Style + dtype: '' + hide: ${ ('part' if int(num_curves) >= 3 else 'all') } +- id: marker3 + label: Line 3 Marker + dtype: '' + hide: ${ ('part' if int(num_curves) >= 3 else 'all') } +- id: alpha3 + label: Line 3 Alpha + dtype: '' + hide: ${ ('part' if int(num_curves) >= 3 else 'all') } +- id: label4 + label: Line 4 Label + dtype: '' + hide: ${ ('part' if int(num_curves) >= 4 else 'all') } +- id: width4 + label: Line 4 Width + dtype: '' + hide: ${ ('part' if int(num_curves) >= 4 else 'all') } +- id: color4 + label: Line 4 Color + dtype: '' + default: '"black"' + hide: ${ ('part' if int(num_curves) >= 4 else 'all') } +- id: style4 + label: Line 4 Style + dtype: '' + hide: ${ ('part' if int(num_curves) >= 4 else 'all') } +- id: marker4 + label: Line 4 Marker + dtype: '' + hide: ${ ('part' if int(num_curves) >= 4 else 'all') } +- id: alpha4 + label: Line 4 Alpha + dtype: '' + hide: ${ ('part' if int(num_curves) >= 4 else 'all') } +- id: label5 + label: Line 5 Label + dtype: '' + hide: ${ ('part' if int(num_curves) >= 5 else 'all') } +- id: width5 + label: Line 5 Width + dtype: '' + hide: ${ ('part' if int(num_curves) >= 5 else 'all') } +- id: color5 + label: Line 5 Color + dtype: '' + default: '"cyan"' + hide: ${ ('part' if int(num_curves) >= 5 else 'all') } +- id: style5 + label: Line 5 Style + dtype: '' + hide: ${ ('part' if int(num_curves) >= 5 else 'all') } +- id: marker5 + label: Line 5 Marker + dtype: '' + hide: ${ ('part' if int(num_curves) >= 5 else 'all') } +- id: alpha5 + label: Line 5 Alpha + dtype: '' + hide: ${ ('part' if int(num_curves) >= 5 else 'all') } +- id: label6 + label: Line 6 Label + dtype: '' + hide: ${ ('part' if int(num_curves) >= 6 else 'all') } +- id: width6 + label: Line 6 Width + dtype: '' + hide: ${ ('part' if int(num_curves) >= 6 else 'all') } +- id: color6 + label: Line 6 Color + dtype: '' + default: '"magenta"' + hide: ${ ('part' if int(num_curves) >= 6 else 'all') } +- id: style6 + label: Line 6 Style + dtype: '' + hide: ${ ('part' if int(num_curves) >= 6 else 'all') } +- id: marker6 + label: Line 6 Marker + dtype: '' + hide: ${ ('part' if int(num_curves) >= 6 else 'all') } +- id: alpha6 + label: Line 6 Alpha + dtype: '' + hide: ${ ('part' if int(num_curves) >= 6 else 'all') } +- id: label7 + label: Line 7 Label + dtype: '' + hide: ${ ('part' if int(num_curves) >= 7 else 'all') } +- id: width7 + label: Line 7 Width + dtype: '' + hide: ${ ('part' if int(num_curves) >= 7 else 'all') } +- id: color7 + label: Line 7 Color + dtype: '' + default: '"yellow"' + hide: ${ ('part' if int(num_curves) >= 7 else 'all') } +- id: style7 + label: Line 7 Style + dtype: '' + hide: ${ ('part' if int(num_curves) >= 7 else 'all') } +- id: marker7 + label: Line 7 Marker + dtype: '' + hide: ${ ('part' if int(num_curves) >= 7 else 'all') } +- id: alpha7 + label: Line 7 Alpha + dtype: '' + hide: ${ ('part' if int(num_curves) >= 7 else 'all') } +- id: label8 + label: Line 8 Label + dtype: '' + hide: ${ ('part' if int(num_curves) >= 8 else 'all') } +- id: width8 + label: Line 8 Width + dtype: '' + hide: ${ ('part' if int(num_curves) >= 8 else 'all') } +- id: color8 + label: Line 8 Color + dtype: '' + default: '"dark red"' + hide: ${ ('part' if int(num_curves) >= 8 else 'all') } +- id: style8 + label: Line 8 Style + dtype: '' + hide: ${ ('part' if int(num_curves) >= 8 else 'all') } +- id: marker8 + label: Line 8 Marker + dtype: '' + hide: ${ ('part' if int(num_curves) >= 8 else 'all') } +- id: alpha8 + label: Line 8 Alpha + dtype: '' + hide: ${ ('part' if int(num_curves) >= 8 else 'all') } +- id: label9 + label: Line 9 Label + dtype: '' + hide: ${ ('part' if int(num_curves) >= 9 else 'all') } +- id: width9 + label: Line 9 Width + dtype: '' + hide: ${ ('part' if int(num_curves) >= 9 else 'all') } +- id: color9 + label: Line 9 Color + dtype: '' + default: '"dark green"' + hide: ${ ('part' if int(num_curves) >= 9 else 'all') } +- id: style9 + label: Line 9 Style + dtype: '' + hide: ${ ('part' if int(num_curves) >= 9 else 'all') } +- id: marker9 + label: Line 9 Marker + dtype: '' + hide: ${ ('part' if int(num_curves) >= 9 else 'all') } +- id: alpha9 + label: Line 9 Alpha + dtype: '' + hide: ${ ('part' if int(num_curves) >= 9 else 'all') } +- id: label10 + label: Line 10 Label + dtype: '' + hide: ${ ('part' if int(num_curves) >= 10 else 'all') } +- id: width10 + label: Line 10 Width + dtype: '' + hide: ${ ('part' if int(num_curves) >= 10 else 'all') } +- id: color10 + label: Line 10 Color + dtype: '' + default: '"dark blue"' + hide: ${ ('part' if int(num_curves) >= 10 else 'all') } +- id: style10 + label: Line 10 Style + dtype: '' + hide: ${ ('part' if int(num_curves) >= 10 else 'all') } +- id: marker10 + label: Line 10 Marker + dtype: '' + hide: ${ ('part' if int(num_curves) >= 10 else 'all') } +- id: alpha10 + label: Line 10 Alpha + dtype: '' + hide: ${ ('part' if int(num_curves) >= 10 else 'all') } + +inputs: +- domain: stream + dtype: byte + multiplicity: ${ len(esno)*2*num_curves } + +templates: + imports: |- + from PyQt5import Qt + from gnuradio import qtgui + import sip + import numpy + make: |- + <% + win = 'self._%s_win'%id + %>\ + qtgui.ber_sink_b( + ${esno}, #range of esnos + ${num_curves}, #number of curves + ${berminerrors}, #ensure at least + ${berlimit}, #cutoff + ${curvenames} #indiv. curve names + ) + self.${id}.set_update_time(${update_time}) + self.${id}.set_y_axis(${ymin}, ${ymax}) + self.${id}.set_x_axis(${esno}[0], ${esno}[-1]) + + labels = [${label1}, ${label2}, ${label3}, ${label4}, ${label5}, + ${label6}, ${label7}, ${label8}, ${label9}, ${label10}] + widths = [${width1}, ${width2}, ${width3}, ${width4}, ${width5}, + ${width6}, ${width7}, ${width8}, ${width9}, ${width10}] + colors = [${color1}, ${color2}, ${color3}, ${color4}, ${color5}, + ${color6}, ${color7}, ${color8}, ${color9}, ${color10}] + alphas = [${alpha1}, ${alpha2}, ${alpha3}, ${alpha4}, ${alpha5}, + ${alpha6}, ${alpha7}, ${alpha8}, ${alpha9}, ${alpha10}] + + for i in range(${num_curves}): + if len(labels[i]) == 0: + self.${id}.set_line_label(i, "Data {0}".format(i)) + else: + self.${id}.set_line_label(i, labels[i]) + self.${id}.set_line_width(i, widths[i]) + self.${id}.set_line_color(i, colors[i]) + self.${id}.set_line_style(i, styles[i]) + self.${id}.set_line_marker(i, markers[i]) + self.${id}.set_line_alpha(i, alphas[i]) + + ${win} = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget) + ${gui_hint()(win)} + +documentation: |- + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_ber_sink_b.xml b/gr-qtgui/grc/qtgui_ber_sink_b.xml deleted file mode 100644 index 05a36dfbc0..0000000000 --- a/gr-qtgui/grc/qtgui_ber_sink_b.xml +++ /dev/null @@ -1,684 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##QT GUI Sink -################################################### - --> -<block> - <name>QT GUI Bercurve Sink</name> - <key>qtgui_bercurve_sink</key> - <import>from PyQt5import Qt</import> - <import>from gnuradio import qtgui</import> - <import>import sip</import> - <import>import numpy</import> - <make>#set $win = 'self._%s_win'%$id - qtgui.ber_sink_b( - $esno, \#range of esnos - $num_curves, \#number of curves - $berminerrors, \#ensure at least - $berlimit, \#cutoff - $curvenames, \#indiv. curve names - ) -self.$(id).set_update_time($update_time) -self.$(id).set_y_axis($ymin, $ymax) -self.$(id).set_x_axis($(esno)[0], $(esno)[-1]) - -labels = [$label1, $label2, $label3, $label4, $label5, - $label6, $label7, $label8, $label9, $label10] -widths = [$width1, $width2, $width3, $width4, $width5, - $width6, $width7, $width8, $width9, $width10] -colors = [$color1, $color2, $color3, $color4, $color5, - $color6, $color7, $color8, $color9, $color10] -styles = [$style1, $style2, $style3, $style4, $style5, - $style6, $style7, $style8, $style9, $style10] -markers = [$marker1, $marker2, $marker3, $marker4, $marker5, - $marker6, $marker7, $marker8, $marker9, $marker10] -alphas = [$alpha1, $alpha2, $alpha3, $alpha4, $alpha5, - $alpha6, $alpha7, $alpha8, $alpha9, $alpha10] -for i in xrange($num_curves): - if len(labels[i]) == 0: - self.$(id).set_line_label(i, "Data {0}".format(i)) - else: - self.$(id).set_line_label(i, labels[i]) - self.$(id).set_line_width(i, widths[i]) - self.$(id).set_line_color(i, colors[i]) - self.$(id).set_line_style(i, styles[i]) - self.$(id).set_line_marker(i, markers[i]) - self.$(id).set_line_alpha(i, alphas[i]) - -self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> - - <param> - <name>esno</name> - <key>esno</key> - <value>numpy.arange(0.0, 4.0, .5)</value> - <type>raw</type> - </param> - - <param> - <name>Min. BER Errs.</name> - <key>berminerrors</key> - <value>100</value> - <type>int</type> - </param> - - <param> - <name>BER Limit</name> - <key>berlimit</key> - <value>-7.0</value> - <type>real</type> - </param> - - <param> - <name>Num Curves</name> - <key>num_curves</key> - <value>1</value> - <type>int</type> - </param> - - <param> - <name>Curve Names</name> - <key>curvenames</key> - <value>[]</value> - <type>raw</type> - <hide>part</hide> - </param> - - <param> - <name>Y min</name> - <key>ymin</key> - <value>-10</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>Y max</name> - <key>ymax</key> - <value>0</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>Update Period</name> - <key>update_time</key> - <value>0.10</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - <param> - <name>Line 1 Label</name> - <key>label1</key> - <type>string</type> - <hide>#if int($num_curves()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Width</name> - <key>width1</key> - <value>1</value> - <type>int</type> - <hide>#if int($num_curves()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Color</name> - <key>color1</key> - <type>enum</type> - <hide>#if int($num_curves()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Blue</name> - <key>"blue"</key> - </option> - <option> - <name>Red</name> - <key>"red"</key> - </option> - <option> - <name>Green</name> - <key>"green"</key> - </option> - <option> - <name>Black</name> - <key>"black"</key> - </option> - <option> - <name>Cyan</name> - <key>"cyan"</key> - </option> - <option> - <name>Magenta</name> - <key>"magenta"</key> - </option> - <option> - <name>Yellow</name> - <key>"yellow"</key> - </option> - <option> - <name>Dark Red</name> - <key>"dark red"</key> - </option> - <option> - <name>Dark Green</name> - <key>"dark green"</key> - </option> - <option> - <name>Dark Blue</name> - <key>"Dark Blue"</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Style</name> - <key>style1</key> - <type>enum</type> - <hide>#if int($num_curves()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Solid</name> - <key>1</key> - </option> - <option> - <name>Dash</name> - <key>2</key> - </option> - <option> - <name>Dots</name> - <key>3</key> - </option> - <option> - <name>Dash-Dot</name> - <key>4</key> - </option> - <option> - <name>Dash-Dot-Dot</name> - <key>5</key> - </option> - <option> - <name>None</name> - <key>0</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Marker</name> - <key>marker1</key> - <type>enum</type> - <hide>#if int($num_curves()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Circle</name> - <key>0</key> - </option> - <option> - <name>Rectangle</name> - <key>1</key> - </option> - <option> - <name>Diamond</name> - <key>2</key> - </option> - <option> - <name>Triangle</name> - <key>3</key> - </option> - <option> - <name>Down Triangle</name> - <key>4</key> - </option> - <option> - <name>Left Triangle</name> - <key>6</key> - </option> - <option> - <name>Right Triangle</name> - <key>7</key> - </option> - <option> - <name>Cross</name> - <key>8</key> - </option> - <option> - <name>X-Cross</name> - <key>9</key> - </option> - <option> - <name>None</name> - <key>-1</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Alpha</name> - <key>alpha1</key> - <value>1.0</value> - <type>float</type> - <hide>#if int($num_curves()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 2 Label</name> - <key>label2</key> - <hide>#if int($num_curves()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 2 Width</name> - <key>width2</key> - <hide>#if int($num_curves()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 2 Color</name> - <key>color2</key> - <value>"red"</value> - <hide>#if int($num_curves()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 2 Style</name> - <key>style2</key> - <hide>#if int($num_curves()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 2 Marker</name> - <key>marker2</key> - <hide>#if int($num_curves()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 2 Alpha</name> - <key>alpha2</key> - <hide>#if int($num_curves()) >= 2 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 3 Label</name> - <key>label3</key> - <hide>#if int($num_curves()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 3 Width</name> - <key>width3</key> - <hide>#if int($num_curves()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 3 Color</name> - <key>color3</key> - <value>"green"</value> - <hide>#if int($num_curves()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 3 Style</name> - <key>style3</key> - <hide>#if int($num_curves()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 3 Marker</name> - <key>marker3</key> - <hide>#if int($num_curves()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 3 Alpha</name> - <key>alpha3</key> - <hide>#if int($num_curves()) >= 3 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 4 Label</name> - <key>label4</key> - <hide>#if int($num_curves()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 4 Width</name> - <key>width4</key> - <hide>#if int($num_curves()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 4 Color</name> - <key>color4</key> - <value>"black"</value> - <hide>#if int($num_curves()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 4 Style</name> - <key>style4</key> - <hide>#if int($num_curves()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 4 Marker</name> - <key>marker4</key> - <hide>#if int($num_curves()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 4 Alpha</name> - <key>alpha4</key> - <hide>#if int($num_curves()) >= 4 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 5 Label</name> - <key>label5</key> - <hide>#if int($num_curves()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 5 Width</name> - <key>width5</key> - <hide>#if int($num_curves()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 5 Color</name> - <key>color5</key> - <value>"cyan"</value> - <hide>#if int($num_curves()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 5 Style</name> - <key>style5</key> - <hide>#if int($num_curves()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 5 Marker</name> - <key>marker5</key> - <hide>#if int($num_curves()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 5 Alpha</name> - <key>alpha5</key> - <hide>#if int($num_curves()) >= 5 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 6 Label</name> - <key>label6</key> - <hide>#if int($num_curves()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 6 Width</name> - <key>width6</key> - <hide>#if int($num_curves()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 6 Color</name> - <key>color6</key> - <value>"magenta"</value> - <hide>#if int($num_curves()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 6 Style</name> - <key>style6</key> - <hide>#if int($num_curves()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 6 Marker</name> - <key>marker6</key> - <hide>#if int($num_curves()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 6 Alpha</name> - <key>alpha6</key> - <hide>#if int($num_curves()) >= 6 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 7 Label</name> - <key>label7</key> - <hide>#if int($num_curves()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 7 Width</name> - <key>width7</key> - <hide>#if int($num_curves()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 7 Color</name> - <key>color7</key> - <value>"yellow"</value> - <hide>#if int($num_curves()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 7 Style</name> - <key>style7</key> - <hide>#if int($num_curves()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 7 Marker</name> - <key>marker7</key> - <hide>#if int($num_curves()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 7 Alpha</name> - <key>alpha7</key> - <hide>#if int($num_curves()) >= 7 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 8 Label</name> - <key>label8</key> - <hide>#if int($num_curves()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 8 Width</name> - <key>width8</key> - <hide>#if int($num_curves()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 8 Color</name> - <key>color8</key> - <value>"dark red"</value> - <hide>#if int($num_curves()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 8 Style</name> - <key>style8</key> - <hide>#if int($num_curves()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 8 Marker</name> - <key>marker8</key> - <hide>#if int($num_curves()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 8 Alpha</name> - <key>alpha8</key> - <hide>#if int($num_curves()) >= 8 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 9 Label</name> - <key>label9</key> - <hide>#if int($num_curves()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 9 Width</name> - <key>width9</key> - <hide>#if int($num_curves()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 9 Color</name> - <key>color9</key> - <value>"dark green"</value> - <hide>#if int($num_curves()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 9 Style</name> - <key>style9</key> - <hide>#if int($num_curves()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 9 Marker</name> - <key>marker9</key> - <hide>#if int($num_curves()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 9 Alpha</name> - <key>alpha9</key> - <hide>#if int($num_curves()) >= 9 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 10 Label</name> - <key>label10</key> - <hide>#if int($num_curves()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 10 Width</name> - <key>width10</key> - <hide>#if int($num_curves()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 10 Color</name> - <key>color10</key> - <value>"dark blue"</value> - <hide>#if int($num_curves()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 10 Style</name> - <key>style10</key> - <hide>#if int($num_curves()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 10 Marker</name> - <key>marker10</key> - <hide>#if int($num_curves()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 10 Alpha</name> - <key>alpha10</key> - <hide>#if int($num_curves()) >= 10 then 'part' else 'all'#</hide> - </param> - - - <sink> - <name>out</name> - <type>byte</type> - <nports>len($esno)*2*$num_curves</nports> - </sink> - - <bus_structure_sink>map(lambda b: map(lambda a: b * len($esno) * 2 + a, range(len($esno)*2)), range($num_curves))</bus_structure_sink> - - <doc> - The GUI hint can be used to position the widget within the application. \ - The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ - Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_block_tree.xml b/gr-qtgui/grc/qtgui_block_tree.xml deleted file mode 100644 index 33fb12a7b5..0000000000 --- a/gr-qtgui/grc/qtgui_block_tree.xml +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0"?> - -<!-- - Copyright 2012-2013 Free Software Foundation, Inc. - - This file is part of GNU Radio - - GNU Radio is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - GNU Radio is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNU Radio; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, - Boston, MA 02110-1301, USA. ---> - -<!-- -################################################### -##Block Tree for GR QTGUI blocks. -################################################### - --> -<cat> - <name>[Core]</name> - <cat> - <name>Instrumentation</name> - <cat> - <name>QT</name> - <block>qtgui_freq_sink_x</block> - <block>qtgui_time_sink_x</block> - <block>qtgui_const_sink_x</block> - <block>qtgui_waterfall_sink_x</block> - <block>qtgui_time_raster_sink_x</block> - <block>qtgui_bercurve_sink</block> - <block>qtgui_histogram_sink_x</block> - <block>qtgui_number_sink</block> - <block>qtgui_vector_sink_f</block> - <block>qtgui_sink_x</block> - </cat> - </cat> - <cat> - <name>GUI Widgets</name> - <cat> - <name>QT</name> - <block>qtgui_tab_widget</block> - <block>variable_qtgui_range</block> - <block>variable_qtgui_chooser</block> - <block>variable_qtgui_check_box</block> - <block>variable_qtgui_push_button</block> - <block>variable_qtgui_entry</block> - <block>variable_qtgui_label</block> - <block>qtgui_edit_box_msg</block> - </cat> - </cat> -</cat> diff --git a/gr-qtgui/grc/qtgui_check_box.block.yml b/gr-qtgui/grc/qtgui_check_box.block.yml new file mode 100644 index 0000000000..3f58b3cc78 --- /dev/null +++ b/gr-qtgui/grc/qtgui_check_box.block.yml @@ -0,0 +1,66 @@ +id: variable_qtgui_check_box +label: QT GUI Check Box + +parameters: +- id: label + label: Label + dtype: string + hide: ${ ('none' if label else 'part') } +- id: type + label: Type + dtype: enum + default: int + options: [real, int, string, bool, raw] + option_labels: [Float, Integer, String, Boolean, Any] + option_attributes: + conv: [float, int, str, bool, eval] + hide: part +- id: value + label: Default Value + dtype: ${ type } + default: 'True' +- id: 'true' + label: 'True' + dtype: ${ type } + default: 'True' +- id: 'false' + label: 'False' + dtype: ${ type } + default: 'False' +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +value: ${ value } + +asserts: +- ${value in (true, false)} + +templates: + imports: from PyQt5 import Qt + var_make: self.${id} = ${id} = ${value} + callbacks: + - self.set_${id}(${value}) + - self._${id}_callback(${id}) + make: |- + <% + win = '_%s_check_box'%id + if not label: + label = id + %> + ${win} = Qt.QCheckBox(${label}) + self._${id}_choices = {True: ${true}, False: ${false}} + self._${id}_choices_inv = dict((v,k) for k,v in self._${id}_choices.iteritems()) + self._${id}_callback = lambda i: Qt.QMetaObject.invokeMethod(${win}, "setChecked", Qt.Q_ARG("bool", self._${id}_choices_inv[i])) + self._${id}_callback(self.${id}) + ${win}.stateChanged.connect(lambda i: self.set_${id}(self._${id}_choices[bool(i)])) + ${gui_hint()(win)} + +documentation: |- + This block creates a variable check box. Leave the label blank to use the variable id as the label. + + A check box selects between two values of similar type. Te values do not necessarily need to be of boolean type. + + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_check_box.xml b/gr-qtgui/grc/qtgui_check_box.xml deleted file mode 100644 index ccee59dd92..0000000000 --- a/gr-qtgui/grc/qtgui_check_box.xml +++ /dev/null @@ -1,82 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable Check Box: -## a gui check box form -################################################### - --> -<block> - <name>QT GUI Check Box</name> - <key>variable_qtgui_check_box</key> - <import>from PyQt5 import Qt</import> - <var_make>self.$(id) = $(id) = $value</var_make> - <make>#set $win = '_%s_check_box'%$id -#if not $label() - #set $label = '"%s"'%$id -#end if -$win = Qt.QCheckBox($label) -self._$(id)_choices = {True: $true, False: $false} -self._$(id)_choices_inv = dict((v,k) for k,v in self._$(id)_choices.iteritems()) -self._$(id)_callback = lambda i: Qt.QMetaObject.invokeMethod($(win), "setChecked", Qt.Q_ARG("bool", self._$(id)_choices_inv[i])) -self._$(id)_callback(self.$id) -$(win).stateChanged.connect(lambda i: self.set_$(id)(self._$(id)_choices[bool(i)])) -$(gui_hint()($win))</make> - <callback>self.set_$(id)($value)</callback> - <callback>self._$(id)_callback($id)</callback> - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - <hide>#if $label() then 'none' else 'part'#</hide> - </param> - <param> - <name>Type</name> - <key>type</key> - <value>int</value> - <type>enum</type> - <hide>part</hide> - <option><name>Float</name><key>real</key><opt>conv:float</opt></option> - <option><name>Integer</name><key>int</key><opt>conv:int</opt></option> - <option><name>String</name><key>string</key><opt>conv:str</opt></option> - <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt></option> - <option><name>Any</name><key>raw</key><opt>conv:eval</opt></option> - </param> - <param> - <name>Default Value</name> - <key>value</key> - <value>True</value> - <type>$type</type> - </param> - <param> - <name>True</name> - <key>true</key> - <value>True</value> - <type>$type</type> - </param> - <param> - <name>False</name> - <key>false</key> - <value>False</value> - <type>$type</type> - </param> - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - <check>$value in ($true, $false)</check> - <doc> -This block creates a variable check box. \ -Leave the label blank to use the variable id as the label. - -A check box selects between two values of similar type. \ -Te values do not necessarily need to be of boolean type. - -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_chooser.block.yml b/gr-qtgui/grc/qtgui_chooser.block.yml new file mode 100644 index 0000000000..12087d8b94 --- /dev/null +++ b/gr-qtgui/grc/qtgui_chooser.block.yml @@ -0,0 +1,191 @@ +id: variable_qtgui_chooser +label: QT GUI Chooser +flags: has_python + +parameters: +- id: label + label: Label + dtype: string + hide: ${ ('none' if label else 'part') } +- id: type + label: Type + dtype: enum + default: int + options: [real, int, string, raw] + option_labels: [Float, Integer, String, Any] + hide: part +- id: num_opts + label: Num Options + dtype: enum + default: '3' + options: ['0', '1', '2', '3', '4', '5'] + option_labels: [List, '1', '2', '3', '4', '5'] +- id: value + label: Default Value + dtype: ${ type } + default: '0' +- id: options + label: Options + dtype: raw + default: '[0, 1, 2]' + hide: ${ ('all' if int(num_opts) else 'none') } +- id: labels + label: Labels + dtype: raw + default: '[]' + hide: ${ ('all' if int(num_opts) else 'none') } +- id: option0 + label: Option 0 + dtype: ${ type } + default: '0' + hide: ${ ('none' if int(num_opts) > 0 else 'all') } +- id: label0 + label: Label 0 + dtype: string + hide: ${ (int(num_opts) > 0) and (label0 and 'none' or 'part') or 'all' } +- id: option1 + label: Option 1 + dtype: ${ type } + default: '1' + hide: ${ ('none' if int(num_opts) > 1 else 'all') } +- id: label1 + label: Label 1 + dtype: string + hide: ${ (int(num_opts) > 1) and (label1 and 'none' or 'part') or 'all' } +- id: option2 + label: Option 2 + dtype: ${ type } + default: '2' + hide: ${ ('none' if int(num_opts) > 2 else 'all') } +- id: label2 + label: Label 2 + dtype: string + hide: ${ (int(num_opts) > 2) and (label2 and 'none' or 'part') or 'all' } +- id: option3 + label: Option 3 + dtype: ${ type } + default: '3' + hide: ${ ('none' if int(num_opts) > 3 else 'all') } +- id: label3 + label: Label 3 + dtype: string + hide: ${ (int(num_opts) > 3) and (label3 and 'none' or 'part') or 'all' } +- id: option4 + label: Option 4 + dtype: ${ type } + default: '4' + hide: ${ ('none' if int(num_opts) > 4 else 'all') } +- id: label4 + label: Label 4 + dtype: string + hide: ${ (int(num_opts) > 4) and (label4 and 'none' or 'part') or 'all' } +- id: widget + label: Widget + dtype: enum + default: combo_box + options: [combo_box, radio_buttons] + option_labels: [Combo Box, Radio Buttons] + hide: part +- id: orient + label: Orientation + dtype: enum + default: Qt.QVBoxLayout + options: [Qt.QHBoxLayout, Qt.QVBoxLayout] + option_labels: [Horizontal, Vertical] + hide: ${ ('part' if widget == 'radio_buttons' else 'all') } +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +value: ${ value } + +templates: + imports: |- + from PyQt5 import Qt + from PyQt5.QtCore import QObject, pyqtSlot + var_make: self.${id} = ${id} = ${value} + callbacks: + - self.set_${id}(${value}) + - self._${id}_callback(${id}) + make: |- + <% + all_options = [ option0, option1, option2, option3, option4 ][:int(num_opts)] + all_labels = [ label0, label1, label2, label3, label4 ][:int(num_opts)] + if not label: + label = id + %>\ + # Create the options list + % if int(num_opts): + self._${id}_options = (\ + % for ch in all_options: + ${ch}, \ + % endfor + ) + % else: + self._${id]_options = ${options} + % endif + # Create the labels list + % if int(num_opts): + self._${id}_labels = (\ + % for i, lbl in all_labels: + % if lbl: + ${lbl}, \ + % else: + str(self._${id}_options[${i}], \ + % endif + % endfor + ) + % elif labels: + self._${id]_labels = ${labels} + % else: + self._${id}_map(str, self._${id}_options) + % endif + # Create the combo box + % if widget == 'combo_box': + <% + win = 'self._%s_tool_bar'%id + %>\ + ${win} = Qt.QToolBar(self) + ${win}.addWidget(Qt.QLabel(${label} + ": ")) + self._${id}_combo_box = Qt.QComboBox() + ${win}.addWidget(self._${id}_combo_box) + for label in self._${id}_labels: self._${id}_combo_box.addItem(label) + self._${id}_callback = lambda i: Qt.QMetaObject.invokeMethod(self._${id}_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._${id}_options.index(i))) + self._${id}_callback(self.${id}) + self._${id}_combo_box.currentIndexChanged.connect( + lambda i: self.set_${id}(self._${id}_options[i])) + % endif + # Create the radio buttons + % if widget == 'radio_buttons': + <% + win = 'self._%s_group_box'%id + %>\ + ${win} = QtQGroupBox(${label}) + self._${id}_box = ${orient}() + class variable_chooser_button_group(Qt.QButtonGroup): + def __init__(self, parent=None): + Qt.QButtonGroup.__init__(self, parent) + @pyqtSlot(int) + def updateButtonChecked(self, button_id): + self.button(button_id).setChecked(True) + self._${id}_button_group = variable_chooser_button_group() + ${win}.setLayout(self._${id}_box) + for i, label in enumerate(self._${id}_labels): + radio_button = Qt.QRadioButton(label) + self._${id}_box.addWidget(radio_button) + self._${id}_button_group.addButton(radio_button, i) + self._${id}_callback = lambda i: Qt.QMetaObject.invokeMethod(self._${id}_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._${id}_options.index(i))) + self._${id}_callback(self.${id}) + self._${id}_button_group.buttonClicked[int].connect( + lambda i: self.set_${id}(self._${id}_options[i])) + % endif + ${gui_hint()(win)} + +documentation: |- + This block creates a variable with enumerated options. The gui widget is implemented as a combo box or radio button group. Leave the label blank to use the variable id as the label. + + Choose the number of options available to your chooser. When the label is left blank, the option will be used as the label. Set the number of options to "list" to enter a single list of options and labels. When the labels is an empty list, the options will be used as the label. + + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_chooser.xml b/gr-qtgui/grc/qtgui_chooser.xml deleted file mode 100644 index f79bb8ccb3..0000000000 --- a/gr-qtgui/grc/qtgui_chooser.xml +++ /dev/null @@ -1,257 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable Chooser: -## A chooser, radio buttons -################################################### - --> -<block> - <name>QT GUI Chooser</name> - <key>variable_qtgui_chooser</key> - <import>from PyQt5 import Qt</import> - <import>from PyQt5.QtCore import QObject, pyqtSlot</import> - <var_make>self.$(id) = $(id) = $value</var_make> - <make>#slurp -#set $all_options = [$option0, $option1, $option2, $option3, $option4][:int($num_opts())] -#set $all_labels = [$label0, $label1, $label2, $label3, $label4][:int($num_opts())] -#if not $label() - #set $label = '"%s"'%$id -#end if -######################################################################## -## Create the options list -######################################################################## -#if int($num_opts()) -self._$(id)_options = (#slurp - #for $ch in $all_options -$ch, #slurp - #end for -) -#else -self._$(id)_options = $options -#end if -######################################################################## -## Create the labels list -######################################################################## -#if int($num_opts()) -self._$(id)_labels = (#slurp - #for i, $lbl in enumerate($all_labels) - #if $lbl() -$lbl, #slurp - #else -str(self._$(id)_options[$i]), #slurp - #end if - #end for -) -#elif $labels() -self._$(id)_labels = $labels -#else -self._$(id)_labels = map(str, self._$(id)_options) -#end if -######################################################################## -## Create the combo box -######################################################################## -#if $widget() == 'combo_box' -#set $win = 'self._%s_tool_bar'%$id -$win = Qt.QToolBar(self) -$(win).addWidget(Qt.QLabel($label+": ")) -self._$(id)_combo_box = Qt.QComboBox() -$(win).addWidget(self._$(id)_combo_box) -for label in self._$(id)_labels: self._$(id)_combo_box.addItem(label) -self._$(id)_callback = lambda i: Qt.QMetaObject.invokeMethod(self._$(id)_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._$(id)_options.index(i))) -self._$(id)_callback(self.$id) -self._$(id)_combo_box.currentIndexChanged.connect( - lambda i: self.set_$(id)(self._$(id)_options[i])) -#end if -######################################################################## -## Create the radio buttons -######################################################################## -#if $widget() == 'radio_buttons' -#set $win = 'self._%s_group_box'%$id -$win = Qt.QGroupBox($label) -self._$(id)_box = $(orient)() -class variable_chooser_button_group(Qt.QButtonGroup): - def __init__(self, parent=None): - Qt.QButtonGroup.__init__(self, parent) - @pyqtSlot(int) - def updateButtonChecked(self, button_id): - self.button(button_id).setChecked(True) -self._$(id)_button_group = variable_chooser_button_group() -$(win).setLayout(self._$(id)_box) -for i, label in enumerate(self._$(id)_labels): - radio_button = Qt.QRadioButton(label) - self._$(id)_box.addWidget(radio_button) - self._$(id)_button_group.addButton(radio_button, i) -self._$(id)_callback = lambda i: Qt.QMetaObject.invokeMethod(self._$(id)_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._$(id)_options.index(i))) -self._$(id)_callback(self.$id) -self._$(id)_button_group.buttonClicked[int].connect( - lambda i: self.set_$(id)(self._$(id)_options[i])) -#end if -$(gui_hint()($win))</make> - <callback>self.set_$(id)($value)</callback> - <callback>self._$(id)_callback($id)</callback> - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - <hide>#if $label() then 'none' else 'part'#</hide> - </param> - <param> - <name>Type</name> - <key>type</key> - <value>int</value> - <type>enum</type> - <hide>part</hide> - <option><name>Float</name><key>real</key></option> - <option><name>Integer</name><key>int</key></option> - <option><name>String</name><key>string</key></option> - <option><name>Any</name><key>raw</key></option> - </param> - <param> - <name>Num Options</name> - <key>num_opts</key> - <value>3</value> - <type>enum</type> - <option><name>List</name><key>0</key></option> - <option><name>1</name><key>1</key></option> - <option><name>2</name><key>2</key></option> - <option><name>3</name><key>3</key></option> - <option><name>4</name><key>4</key></option> - <option><name>5</name><key>5</key></option> - </param> - <param> - <name>Default Value</name> - <key>value</key> - <value>0</value> - <type>$type</type> - </param> - <param> - <name>Options</name> - <key>options</key> - <value>[0, 1, 2]</value> - <type>raw</type> - <hide>#if int($num_opts()) then 'all' else 'none'#</hide> - </param> - <param> - <name>Labels</name> - <key>labels</key> - <value>[]</value> - <type>raw</type> - <hide>#if int($num_opts()) then 'all' else 'none'#</hide> - </param> - <param> - <name>Option 0</name> - <key>option0</key> - <value>0</value> - <type>$type</type> - <hide>#if int($num_opts()) > 0 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 0</name> - <key>label0</key> - <value></value> - <type>string</type> - <hide>$((int($num_opts()) > 0) and ($label0() and 'none' or 'part') or 'all')</hide> - </param> - <param> - <name>Option 1</name> - <key>option1</key> - <value>1</value> - <type>$type</type> - <hide>#if int($num_opts()) > 1 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 1</name> - <key>label1</key> - <value></value> - <type>string</type> - <hide>$((int($num_opts()) > 1) and ($label1() and 'none' or 'part') or 'all')</hide> - </param> - <param> - <name>Option 2</name> - <key>option2</key> - <value>2</value> - <type>$type</type> - <hide>#if int($num_opts()) > 2 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 2</name> - <key>label2</key> - <value></value> - <type>string</type> - <hide>$((int($num_opts()) > 2) and ($label2() and 'none' or 'part') or 'all')</hide> - </param> - <param> - <name>Option 3</name> - <key>option3</key> - <value>3</value> - <type>$type</type> - <hide>#if int($num_opts()) > 3 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 3</name> - <key>label3</key> - <value></value> - <type>string</type> - <hide>$((int($num_opts()) > 3) and ($label3() and 'none' or 'part') or 'all')</hide> - </param> - <param> - <name>Option 4</name> - <key>option4</key> - <value>4</value> - <type>$type</type> - <hide>#if int($num_opts()) > 4 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 4</name> - <key>label4</key> - <value></value> - <type>string</type> - <hide>$((int($num_opts()) > 4) and ($label4() and 'none' or 'part') or 'all')</hide> - </param> - <param> - <name>Widget</name> - <key>widget</key> - <value>combo_box</value> - <type>enum</type> - <hide>part</hide> - <option><name>Combo Box</name><key>combo_box</key></option> - <option><name>Radio Buttons</name><key>radio_buttons</key></option> - </param> - <param> - <name>Orientation</name> - <key>orient</key> - <value>Qt.QVBoxLayout</value> - <type>enum</type> - <hide>#if $widget() == 'radio_buttons' then 'part' else 'all'#</hide> - <option> - <name>Horizontal</name> - <key>Qt.QHBoxLayout</key> - </option> - <option> - <name>Vertical</name> - <key>Qt.QVBoxLayout</key> - </option> - </param> - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - <doc> -This block creates a variable with enumerated options. \ -The gui widget is implemented as a combo box or radio button group. \ -Leave the label blank to use the variable id as the label. - -Choose the number of options available to your chooser. \ -When the label is left blank, the option will be used as the label. \ -Set the number of options to "list" to enter a single list of options and labels. \ -When the labels is an empty list, the options will be used as the label. - -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_const_sink_x.block.yml b/gr-qtgui/grc/qtgui_const_sink_x.block.yml new file mode 100644 index 0000000000..af6b166df1 --- /dev/null +++ b/gr-qtgui/grc/qtgui_const_sink_x.block.yml @@ -0,0 +1,457 @@ +id: qtgui_const_sink_x +label: QT GUI Constellation Sink + +parameters: +- id: type + label: Type + dtype: enum + default: complex + options: [complex, msg_complex] + option_labels: [Complex, Complex Message] + option_attributes: + fcn: [const_sink_c, const_sink_c] + t: [complex, message] + hide: part +- id: name + label: Name + dtype: string + default: '""' + hide: ${ ('none' if len(name) > 0 else 'part') } +- id: size + label: Number of Points + dtype: int + default: '1024' + hide: ${ ('all' if type.startswith('msg') else 'none') } +- id: grid + label: Grid + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: autoscale + label: Autoscale + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] +- id: ymin + label: Y min + dtype: real + default: '-2' + hide: part +- id: ymax + label: Y max + dtype: real + default: '2' + hide: part +- id: xmin + label: X min + dtype: real + default: '-2' + hide: part +- id: xmax + label: X max + dtype: real + default: '2' + hide: part +- id: nconnections + label: Number of Inputs + dtype: int + default: '1' + hide: ${ ('all' if type.startswith('msg') else 'part') } +- id: update_time + label: Update Period + dtype: real + default: '0.10' + hide: part +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +- id: tr_mode + label: Trigger Mode + category: Trigger + dtype: enum + default: qtgui.TRIG_MODE_FREE + options: [qtgui.TRIG_MODE_FREE, qtgui.TRIG_MODE_AUTO, qtgui.TRIG_MODE_NORM, qtgui.TRIG_MODE_TAG] + option_labels: [Free, Auto, Normal, Tag] + hide: part +- id: tr_slope + label: Trigger Slope + category: Trigger + dtype: enum + default: qtgui.TRIG_MODE_POS + options: [qtgui.TRIG_SLOPE_POS, qtgui.TRIG_SLOPE_NEG] + option_labels: [Positive, Negative] + hide: part +- id: tr_level + label: Trigger Level + category: Trigger + dtype: float + default: '0.0' + hide: part +- id: tr_chan + label: Trigger Channel + category: Trigger + dtype: int + default: '0' + hide: part +- id: tr_tag + label: Trigger Tag Key + category: Trigger + dtype: string + default: '""' + hide: part +- id: legend + label: Legend + category: Config + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: axislabels + label: Axis Labels + category: Config + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: label1 + label: Line 1 Label + category: Config + dtype: string + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: width1 + label: Line 1 Width + category: Config + dtype: int + default: '1' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: color1 + label: Line 1 Color + category: Config + dtype: enum + options: ['"blue"', '"red"', '"green"', '"black"', '"cyan"', '"magenta"', '"yellow"', + '"dark red"', '"dark green"', '"Dark Blue"'] + option_labels: [Blue, Red, Green, Black, Cyan, Magenta, Yellow, Dark Red, Dark + Green, Dark Blue] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: style1 + label: Line 1 Style + category: Config + dtype: enum + options: ['0', '1', '2', '3', '4', '5'] + option_labels: [None, Solid, Dash, Dots, Dash-Dot, Dash-Dot-Dot] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: marker1 + label: Line 1 Marker + category: Config + dtype: enum + options: ['0', '1', '2', '3', '4', '6', '7', '8', '9', '-1'] + option_labels: [Circle, Rectangle, Diamond, Triangle, Down Triangle, Left Triangle, + Right Triangle, Cross, X-Cross, None] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: alpha1 + label: Line 1 Alpha + category: Config + dtype: float + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: label2 + label: Line 2 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: width2 + label: Line 2 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: color2 + label: Line 2 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: style2 + label: Line 2 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: marker2 + label: Line 2 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: alpha2 + label: Line 2 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: label3 + label: Line 3 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: width3 + label: Line 3 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: color3 + label: Line 3 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: style3 + label: Line 3 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: marker3 + label: Line 3 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: alpha3 + label: Line 3 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: label4 + label: Line 4 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: width4 + label: Line 4 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: color4 + label: Line 4 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: style4 + label: Line 4 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: marker4 + label: Line 4 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: alpha4 + label: Line 4 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: label5 + label: Line 5 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: width5 + label: Line 5 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: color5 + label: Line 5 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: style5 + label: Line 5 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: marker5 + label: Line 5 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: alpha5 + label: Line 5 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: label6 + label: Line 6 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: width6 + label: Line 6 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: color6 + label: Line 6 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: style6 + label: Line 6 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: marker6 + label: Line 6 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: alpha6 + label: Line 6 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: label7 + label: Line 7 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: width7 + label: Line 7 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: color7 + label: Line 7 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: style7 + label: Line 7 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: marker7 + label: Line 7 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: alpha7 + label: Line 7 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: label8 + label: Line 8 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: width8 + label: Line 8 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: color8 + label: Line 8 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: style8 + label: Line 8 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: marker8 + label: Line 8 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: alpha8 + label: Line 8 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: label9 + label: Line 9 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: width9 + label: Line 9 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: color9 + label: Line 9 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: style9 + label: Line 9 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: marker9 + label: Line 9 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: alpha9 + label: Line 9 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: label10 + label: Line 10 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: width10 + label: Line 10 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: color10 + label: Line 10 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: style10 + label: Line 10 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: marker10 + label: Line 10 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: alpha10 + label: Line 10 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } + +inputs: +- domain: stream + dtype: ${ type.t } + multiplicity: ${ (0 if type.startswith('msg') else nconnections) } + optional: true + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import qtgui + import sip + callbacks: + - set_resize(${width}, ${height}) + - set_update_time(${update_time}) + - set_title(${which}, ${title}) + - set_color(${which}, ${color}) + - self.${id}.set_trigger_mode(${tr_mode}, ${tr_slope}, ${tr_level}, ${tr_chan}, + ${tr_tag}) + make: |- + <% + win = 'self._%s_win'%id + %>\ + qtgui.${type.fcn}( + ${size}, #size + ${name}, #name + ${0 if type.startswith('msg') else nconnections} #number of inputs + ) + self.${id}.set_update_time(${update_time}) + self.${id}.set_y_axis(${ymin}, ${ymax}) + self.${id}.set_x_axis(${xmin}, ${xmax}) + self.${id}.set_trigger_mode(${tr_mode}, ${tr_slope}, ${tr_level}, ${tr_chan}, ${tr_tag}) + self.${id}.enable_autoscale(${autoscale}) + self.${id}.enable_grid(${grid}) + self.${id}.enable_axis_labels(${axislabels}) + + if not ${legend}: + self.${id}.disable_legend() + + labels = [${label1}, ${label2}, ${label3}, ${label4}, ${label5}, + ${label6}, ${label7}, ${label8}, ${label9}, ${label10}] + widths = [${width1}, ${width2}, ${width3}, ${width4}, ${width5}, + ${width6}, ${width7}, ${width8}, ${width9}, ${width10}] + colors = [${color1}, ${color2}, ${color3}, ${color4}, ${color5}, + ${color6}, ${color7}, ${color8}, ${color9}, ${color10}] + styles = [${style1}, ${style2}, ${style3}, ${style4}, ${style5}, + ${style6}, ${style7}, ${style8}, ${style9}, ${style10}] + markers = [${marker1}, ${marker2}, ${marker3}, ${marker4}, ${marker5}, + ${marker6}, ${marker7}, ${marker8}, ${marker9}, ${marker10}] + alphas = [${alpha1}, ${alpha2}, ${alpha3}, ${alpha4}, ${alpha5}, + ${alpha6}, ${alpha7}, ${alpha8}, ${alpha9}, ${alpha10}] + + for i in range(${1 if type.startswith('msg') else nconnections}): + if len(labels[i]) == 0: + self.${id}.set_line_label(i, "Data {0}".format(i)) + else: + self.${id}.set_line_label(i, labels[i]) + self.${id}.set_line_width(i, widths[i]) + self.${id}.set_line_color(i, colors[i]) + self.${id}.set_line_style(i, styles[i]) + self.${id}.set_line_marker(i, markers[i]) + self.${id}.set_line_alpha(i, alphas[i]) + + self._${id}_win = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget) + ${gui_hint()(win)} + +documentation: |- + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_const_sink_x.xml b/gr-qtgui/grc/qtgui_const_sink_x.xml deleted file mode 100644 index 10f82cce82..0000000000 --- a/gr-qtgui/grc/qtgui_const_sink_x.xml +++ /dev/null @@ -1,859 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##QT GUI Sink -################################################### - --> -<block> - <name>QT GUI Constellation Sink</name> - <key>qtgui_const_sink_x</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import qtgui</import> - <import>import sip</import> - <make>#set $win = 'self._%s_win'%$id -qtgui.$(type.fcn)( - $size, \#size - $name, \#name - #if $type.t == 'message' then 0 else $nconnections# \#number of inputs -) -self.$(id).set_update_time($update_time) -self.$(id).set_y_axis($ymin, $ymax) -self.$(id).set_x_axis($xmin, $xmax) -self.$(id).set_trigger_mode($tr_mode, $tr_slope, $tr_level, $tr_chan, $tr_tag) -self.$(id).enable_autoscale($autoscale) -self.$(id).enable_grid($grid) -self.$(id).enable_axis_labels($axislabels) - -if not $legend: - self.$(id).disable_legend() - -labels = [$label1, $label2, $label3, $label4, $label5, - $label6, $label7, $label8, $label9, $label10] -widths = [$width1, $width2, $width3, $width4, $width5, - $width6, $width7, $width8, $width9, $width10] -colors = [$color1, $color2, $color3, $color4, $color5, - $color6, $color7, $color8, $color9, $color10] -styles = [$style1, $style2, $style3, $style4, $style5, - $style6, $style7, $style8, $style9, $style10] -markers = [$marker1, $marker2, $marker3, $marker4, $marker5, - $marker6, $marker7, $marker8, $marker9, $marker10] -alphas = [$alpha1, $alpha2, $alpha3, $alpha4, $alpha5, - $alpha6, $alpha7, $alpha8, $alpha9, $alpha10] -for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): - if len(labels[i]) == 0: - self.$(id).set_line_label(i, "Data {0}".format(i)) - else: - self.$(id).set_line_label(i, labels[i]) - self.$(id).set_line_width(i, widths[i]) - self.$(id).set_line_color(i, colors[i]) - self.$(id).set_line_style(i, styles[i]) - self.$(id).set_line_marker(i, markers[i]) - self.$(id).set_line_alpha(i, alphas[i]) - -self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> - <callback>set_resize($width, $height)</callback> - <callback>set_update_time($update_time)</callback> - <callback>set_title($which, $title)</callback> - <callback>set_color($which, $color)</callback> - <callback>self.$(id).set_trigger_mode($tr_mode, $tr_slope, $tr_level, $tr_chan, $tr_tag)</callback> - - <param_tab_order> - <tab>General</tab> - <tab>Trigger</tab> - <tab>Config</tab> - </param_tab_order> - - <param> - <name>Type</name> - <key>type</key> - <value>complex</value> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:const_sink_c</opt> - <opt>t:complex</opt> - </option> - <option> - <name>Complex Message</name> - <key>msg_complex</key> - <opt>fcn:const_sink_c</opt> - <opt>t:message</opt> - </option> - </param> - - <param> - <name>Name</name> - <key>name</key> - <value>""</value> - <type>string</type> - <hide>#if len($name()) > 0 then 'none' else 'part'#</hide> - </param> - - <param> - <name>Number of Points</name> - <key>size</key> - <value>1024</value> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'none'#</hide> - </param> - - <param> - <name>Grid</name> - <key>grid</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Autoscale</name> - <key>autoscale</key> - <value>False</value> - <type>enum</type> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Y min</name> - <key>ymin</key> - <value>-2</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>Y max</name> - <key>ymax</key> - <value>2</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>X min</name> - <key>xmin</key> - <value>-2</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>X max</name> - <key>xmax</key> - <value>2</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>Number of Inputs</name> - <key>nconnections</key> - <value>1</value> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'part'#</hide> - </param> - - <param> - <name>Update Period</name> - <key>update_time</key> - <value>0.10</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - - <param> - <name>Trigger Mode</name> - <key>tr_mode</key> - <value>qtgui.TRIG_MODE_FREE</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Free</name> - <key>qtgui.TRIG_MODE_FREE</key> - </option> - <option> - <name>Auto</name> - <key>qtgui.TRIG_MODE_AUTO</key> - </option> - <option> - <name>Normal</name> - <key>qtgui.TRIG_MODE_NORM</key> - </option> - <option> - <name>Tag</name> - <key>qtgui.TRIG_MODE_TAG</key> - </option> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Slope</name> - <key>tr_slope</key> - <value>qtgui.TRIG_MODE_POS</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Positive</name> - <key>qtgui.TRIG_SLOPE_POS</key> - </option> - <option> - <name>Negative</name> - <key>qtgui.TRIG_SLOPE_NEG</key> - </option> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Level</name> - <key>tr_level</key> - <value>0.0</value> - <type>float</type> - <hide>part</hide> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Channel</name> - <key>tr_chan</key> - <value>0</value> - <type>int</type> - <hide>part</hide> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Tag Key</name> - <key>tr_tag</key> - <value>""</value> - <type>string</type> - <hide>part</hide> - <tab>Trigger</tab> - </param> - - - - <!-- Begin Config Tab items --> - <param> - <name>Legend</name> - <key>legend</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Axis Labels</name> - <key>axislabels</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Label</name> - <key>label1</key> - <type>string</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Width</name> - <key>width1</key> - <value>1</value> - <type>int</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Color</name> - <key>color1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Blue</name> - <key>"blue"</key> - </option> - <option> - <name>Red</name> - <key>"red"</key> - </option> - <option> - <name>Green</name> - <key>"green"</key> - </option> - <option> - <name>Black</name> - <key>"black"</key> - </option> - <option> - <name>Cyan</name> - <key>"cyan"</key> - </option> - <option> - <name>Magenta</name> - <key>"magenta"</key> - </option> - <option> - <name>Yellow</name> - <key>"yellow"</key> - </option> - <option> - <name>Dark Red</name> - <key>"dark red"</key> - </option> - <option> - <name>Dark Green</name> - <key>"dark green"</key> - </option> - <option> - <name>Dark Blue</name> - <key>"Dark Blue"</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Style</name> - <key>style1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>None</name> - <key>0</key> - </option> - <option> - <name>Solid</name> - <key>1</key> - </option> - <option> - <name>Dash</name> - <key>2</key> - </option> - <option> - <name>Dots</name> - <key>3</key> - </option> - <option> - <name>Dash-Dot</name> - <key>4</key> - </option> - <option> - <name>Dash-Dot-Dot</name> - <key>5</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Marker</name> - <key>marker1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Circle</name> - <key>0</key> - </option> - <option> - <name>Rectangle</name> - <key>1</key> - </option> - <option> - <name>Diamond</name> - <key>2</key> - </option> - <option> - <name>Triangle</name> - <key>3</key> - </option> - <option> - <name>Down Triangle</name> - <key>4</key> - </option> - <option> - <name>Left Triangle</name> - <key>6</key> - </option> - <option> - <name>Right Triangle</name> - <key>7</key> - </option> - <option> - <name>Cross</name> - <key>8</key> - </option> - <option> - <name>X-Cross</name> - <key>9</key> - </option> - <option> - <name>None</name> - <key>-1</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Alpha</name> - <key>alpha1</key> - <value>1.0</value> - <type>float</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 2 Label</name> - <key>label2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 2 Width</name> - <key>width2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 2 Color</name> - <key>color2</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 2 Style</name> - <key>style2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 2 Marker</name> - <key>marker2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 2 Alpha</name> - <key>alpha2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 3 Label</name> - <key>label3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 3 Width</name> - <key>width3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 3 Color</name> - <key>color3</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 3 Style</name> - <key>style3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 3 Marker</name> - <key>marker3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 3 Alpha</name> - <key>alpha3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 4 Label</name> - <key>label4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 4 Width</name> - <key>width4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 4 Color</name> - <key>color4</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 4 Style</name> - <key>style4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 4 Marker</name> - <key>marker4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 4 Alpha</name> - <key>alpha4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 5 Label</name> - <key>label5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 5 Width</name> - <key>width5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 5 Color</name> - <key>color5</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 5 Style</name> - <key>style5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 5 Marker</name> - <key>marker5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 5 Alpha</name> - <key>alpha5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 6 Label</name> - <key>label6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 6 Width</name> - <key>width6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 6 Color</name> - <key>color6</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 6 Style</name> - <key>style6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 6 Marker</name> - <key>marker6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 6 Alpha</name> - <key>alpha6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 7 Label</name> - <key>label7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 7 Width</name> - <key>width7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 7 Color</name> - <key>color7</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 7 Style</name> - <key>style7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 7 Marker</name> - <key>marker7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 7 Alpha</name> - <key>alpha7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 8 Label</name> - <key>label8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 8 Width</name> - <key>width8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 8 Color</name> - <key>color8</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 8 Style</name> - <key>style8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 8 Marker</name> - <key>marker8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 8 Alpha</name> - <key>alpha8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 9 Label</name> - <key>label9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 9 Width</name> - <key>width9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 9 Color</name> - <key>color9</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 9 Style</name> - <key>style9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 9 Marker</name> - <key>marker9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 9 Alpha</name> - <key>alpha9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 10 Label</name> - <key>label10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 10 Width</name> - <key>width10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 10 Color</name> - <key>color10</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 10 Style</name> - <key>style10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 10 Marker</name> - <key>marker10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 10 Alpha</name> - <key>alpha10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - - <sink> - <name>in</name> - <type>$type.t</type> - <nports>#if $type.t == 'message' then 0 else $nconnections#</nports> - <optional>1</optional> - </sink> - - <doc> -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_edit_box_msg.block.yml b/gr-qtgui/grc/qtgui_edit_box_msg.block.yml new file mode 100644 index 0000000000..37aa0ce071 --- /dev/null +++ b/gr-qtgui/grc/qtgui_edit_box_msg.block.yml @@ -0,0 +1,69 @@ +id: qtgui_edit_box_msg +label: QT GUI Message Edit Box + +parameters: +- id: type + label: Type + dtype: enum + default: string + options: [string, int, float, double, complex, int_vec, flt_vec, dbl_vec, cpx_vec] + option_labels: [String, Int, Float, Double, Complex, Int (Vec), Float (Vec), Double + (Vec), Complex (Vec)] + option_attributes: + t: [qtgui.STRING, qtgui.INT, qtgui.FLOAT, qtgui.DOUBLE, qtgui.COMPLEX, qtgui.INT_VEC, + qtgui.FLOAT_VEC, qtgui.DOUBLE_VEC, qtgui.COMPLEX_VEC] +- id: value + label: Value + dtype: string +- id: label + label: Label + dtype: string +- id: is_pair + label: Pair Mode + dtype: enum + default: 'True' + options: ['False', 'True'] +- id: is_static + label: Static Mode + dtype: enum + default: 'True' + options: ['False', 'True'] +- id: key + label: Key + dtype: string + hide: ${ ('none' if is_pair == 'True' else 'all') } +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part + +asserts: +- ${(is_pair and is_static and len(key) > 0) or not (is_pair and is_static)} + +inputs: +- domain: message + id: val + optional: true + +outputs: +- domain: message + id: msg + optional: true + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import qtgui + import sip + make: + <% + win = 'self._%s_win'%id + %>\ + qtgui.edit_box_msg(${type.t)}, ${value}, ${label}, ${is_pair}, ${is_static}, ${key}) + ${win} = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget) + ${gui_hint()(win)} + +documentation: |- + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_edit_box_msg.xml b/gr-qtgui/grc/qtgui_edit_box_msg.xml deleted file mode 100644 index d77a4b3e1b..0000000000 --- a/gr-qtgui/grc/qtgui_edit_box_msg.xml +++ /dev/null @@ -1,152 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##QT GUI Edit Box that sends messages -################################################### - --> -<block> - <name>QT GUI Message Edit Box</name> - <key>qtgui_edit_box_msg</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import qtgui</import> - <import>import sip</import> - <make>#set $win = 'self._%s_win'%$id -qtgui.edit_box_msg($(type.t), $value, $label, $is_pair, $is_static, $key) -self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> - - <param> - <name>Type</name> - <key>type</key> - <value>string</value> - <type>enum</type> - <option> - <name>String</name> - <key>string</key> - <opt>t:qtgui.STRING</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>t:qtgui.INT</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>t:qtgui.FLOAT</opt> - </option> - <option> - <name>Double</name> - <key>double</key> - <opt>t:qtgui.DOUBLE</opt> - </option> - <option> - <name>Complex</name> - <key>complex</key> - <opt>t:qtgui.COMPLEX</opt> - </option> - <option> - <name>Int (Vec)</name> - <key>int_vec</key> - <opt>t:qtgui.INT_VEC</opt> - </option> - <option> - <name>Float (Vec)</name> - <key>flt_vec</key> - <opt>t:qtgui.FLOAT_VEC</opt> - </option> - <option> - <name>Double (Vec)</name> - <key>dbl_vec</key> - <opt>t:qtgui.DOUBLE_VEC</opt> - </option> - <option> - <name>Complex (Vec)</name> - <key>cpx_vec</key> - <opt>t:qtgui.COMPLEX_VEC</opt> - </option> - </param> - - <param> - <name>Value</name> - <key>value</key> - <value></value> - <type>string</type> - </param> - - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - </param> - - <param> - <name>Pair Mode</name> - <key>is_pair</key> - <value>True</value> - <type>enum</type> - <option> - <name>False</name> - <key>False</key> - </option> - <option> - <name>True</name> - <key>True</key> - </option> - </param> - - <param> - <name>Static Mode</name> - <key>is_static</key> - <value>True</value> - <type>enum</type> - <option> - <name>False</name> - <key>False</key> - </option> - <option> - <name>True</name> - <key>True</key> - </option> - </param> - - <param> - <name>Key</name> - <key>key</key> - <value></value> - <type>string</type> - <hide>#if $is_pair() == 'True' then 'none' else 'all'#</hide> - </param> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - <!-- If both is_pair and is_static are True, we require a default key. - If either or both are false, we don't care about a default key. - --> - <check>($is_pair and $is_static and len($key) > 0) or not ($is_pair and $is_static)</check> - - <sink> - <name>val</name> - <type>message</type> - <optional>1</optional> - </sink> - - <source> - <name>msg</name> - <type>message</type> - <optional>1</optional> - </source> - - <doc> -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_entry.block.yml b/gr-qtgui/grc/qtgui_entry.block.yml new file mode 100644 index 0000000000..25b7bcf33f --- /dev/null +++ b/gr-qtgui/grc/qtgui_entry.block.yml @@ -0,0 +1,57 @@ +id: variable_qtgui_entry +label: QT GUI Entry + +parameters: +- id: label + label: Label + dtype: string + hide: ${ ('none' if label else 'part') } +- id: type + label: Type + dtype: enum + default: int + options: [real, int, string, bool, raw] + option_labels: [Float, Integer, String, Boolean, Any] + option_attributes: + conv: [eng_notation.str_to_num, int, str, bool, eval] + str: [eng_notation.num_to_str, str, str, str, repr] + hide: part +- id: value + label: Default Value + dtype: ${ type } + default: '0' +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +value: ${ value } + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import eng_notation + var_make: self.${id} = ${id} = ${value} + callbacks: + - self.set_${id}(${value}) + - Qt.QMetaObject.invokeMethod(self._${id}_line_edit, "setText", Qt.Q_ARG("QString", + ${type.str}(${id}))) + make: |- + <% + win = 'self._%s_tool_bar'%id + if not label: + label = '"%s"'%id + %> + ${win} = Qt.QToolBar(self) + ${win}.addWidget(Qt.QLabel(${label}+": ")) + self._${id}_line_edit = Qt.QLineEdit(str(self.${id})) + self._${id}_tool_bar.addWidget(self._${id}_line_edit) + self._${id}_line_edit.returnPressed.connect( + lambda: self.set_${id}(${type.conv}(str(self._${id}_line_edit.text().toAscii())))) + ${gui_hint()(win)} + +documentation: |- + This block creates a variable with a text entry box. Leave the label blank to use the variable id as the label. + + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_entry.xml b/gr-qtgui/grc/qtgui_entry.xml deleted file mode 100644 index fc0f4089d1..0000000000 --- a/gr-qtgui/grc/qtgui_entry.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable Text Entry: -## a gui text box form -################################################### - --> -<block> - <name>QT GUI Entry</name> - <key>variable_qtgui_entry</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import eng_notation</import> - <var_make>self.$(id) = $(id) = $value</var_make> - <make>#set $win = 'self._%s_tool_bar'%$id -$win = Qt.QToolBar(self) -#if not $label() - #set $label = '"%s"'%$id -#end if -$(win).addWidget(Qt.QLabel($label+": ")) -self._$(id)_line_edit = Qt.QLineEdit(str(self.$id)) -self._$(id)_tool_bar.addWidget(self._$(id)_line_edit) -self._$(id)_line_edit.returnPressed.connect( - lambda: self.set_$(id)($(type.conv)(str(self._$(id)_line_edit.text().toAscii())))) -$(gui_hint()($win))</make> - <callback>self.set_$(id)($value)</callback> - <callback>Qt.QMetaObject.invokeMethod(self._$(id)_line_edit, "setText", Qt.Q_ARG("QString", $(type.str)($id)))</callback> - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - <hide>#if $label() then 'none' else 'part'#</hide> - </param> - <param> - <name>Type</name> - <key>type</key> - <value>int</value> - <type>enum</type> - <hide>part</hide> - <option><name>Float</name><key>real</key><opt>conv:eng_notation.str_to_num</opt><opt>str:eng_notation.num_to_str</opt></option> - <option><name>Integer</name><key>int</key><opt>conv:int</opt><opt>str:str</opt></option> - <option><name>String</name><key>string</key><opt>conv:str</opt><opt>str:str</opt></option> - <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt><opt>str:str</opt></option> - <option><name>Any</name><key>raw</key><opt>conv:eval</opt><opt>str:repr</opt></option> - </param> - <param> - <name>Default Value</name> - <key>value</key> - <value>0</value> - <type>$type</type> - </param> - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - <doc> -This block creates a variable with a text entry box. \ -Leave the label blank to use the variable id as the label. - -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_freq_sink_x.block.yml b/gr-qtgui/grc/qtgui_freq_sink_x.block.yml new file mode 100644 index 0000000000..d935f04c4e --- /dev/null +++ b/gr-qtgui/grc/qtgui_freq_sink_x.block.yml @@ -0,0 +1,447 @@ +id: qtgui_freq_sink_x +label: QT GUI Frequency Sink + +parameters: +- id: type + label: Type + dtype: enum + default: complex + options: [complex, float, msg_complex, msg_float] + option_labels: [Complex, Float, Complex Message, Float Message] + option_attributes: + fcn: [freq_sink_c, freq_sink_f, freq_sink_c, freq_sink_f] + t: [complex, float, message, message] + hide: part +- id: name + label: Name + dtype: string + default: '""' + hide: ${ ('none' if len(name) > 0 else 'part') } +- id: fftsize + label: FFT Size + dtype: int + default: '1024' + hide: ${ ('all' if (type == 'msg_complex' or type == 'msg_float') else 'none') } +- id: freqhalf + label: Spectrum Width + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: [Full, Half] + hide: ${ ('part' if type == "float" or type == "msg_float" else 'all') } +- id: wintype + label: Window Type + dtype: enum + default: firdes.WIN_BLACKMAN_hARRIS + options: [firdes.WIN_BLACKMAN_hARRIS, firdes.WIN_HAMMING, firdes.WIN_HANN, firdes.WIN_BLACKMAN, + firdes.WIN_RECTANGULAR, firdes.WIN_KAISER, firdes.WIN_FLATTOP] + option_labels: [Blackman-harris, Hamming, Hann, Blackman, Rectangular, Kaiser, + Flat-top] + hide: part +- id: fc + label: Center Frequency (Hz) + dtype: real + default: '0' +- id: bw + label: Bandwidth (Hz) + dtype: real + default: samp_rate +- id: grid + label: Grid + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: autoscale + label: Autoscale + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: average + label: Average + dtype: enum + default: 'False' + options: ['1.0', '0.2', '0.1', '0.05'] + option_labels: [None, Low, Medium, High] + hide: part +- id: ymin + label: Y min + dtype: real + default: '-140' + hide: part +- id: ymax + label: Y max + dtype: real + default: '10' + hide: part +- id: label + label: Y label + dtype: string + default: Relative Gain + hide: part +- id: units + label: Y units + dtype: string + default: dB + hide: part +- id: nconnections + label: Number of Inputs + dtype: int + default: '1' + hide: ${ ('all' if (type == 'msg_complex' or type == 'msg_float') else 'part') } +- id: update_time + label: Update Period + dtype: real + default: '0.10' + hide: part +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +- id: showports + label: Show Msg Ports + dtype: enum + default: 'True' + options: ['False', 'True'] + option_labels: ['Yes', 'No'] + hide: part +- id: tr_mode + label: Trigger Mode + category: Trigger + dtype: enum + default: qtgui.TRIG_MODE_FREE + options: [qtgui.TRIG_MODE_FREE, qtgui.TRIG_MODE_AUTO, qtgui.TRIG_MODE_NORM, qtgui.TRIG_MODE_TAG] + option_labels: [Free, Auto, Normal, Tag] + hide: part +- id: tr_level + label: Trigger Level + category: Trigger + dtype: float + default: '0.0' + hide: part +- id: tr_chan + label: Trigger Channel + category: Trigger + dtype: int + default: '0' + hide: part +- id: tr_tag + label: Trigger Tag Key + category: Trigger + dtype: string + default: '""' + hide: part +- id: ctrlpanel + label: Control Panel + category: Config + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: legend + label: Legend + category: Config + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: axislabels + label: Axis Labels + category: Config + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: label1 + label: Line 1 Label + category: Config + dtype: string + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: width1 + label: Line 1 Width + category: Config + dtype: int + default: '1' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: color1 + label: Line 1 Color + category: Config + dtype: enum + options: ['"blue"', '"red"', '"green"', '"black"', '"cyan"', '"magenta"', '"yellow"', + '"dark red"', '"dark green"', '"dark blue"'] + option_labels: [Blue, Red, Green, Black, Cyan, Magenta, Yellow, Dark Red, Dark + Green, Dark Blue] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: alpha1 + label: Line 1 Alpha + category: Config + dtype: float + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: label2 + label: Line 2 Label + dtype: '' + default: "''" + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: width2 + label: Line 2 Width + dtype: '' + default: '1' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: color2 + label: Line 2 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: alpha2 + label: Line 2 Alpha + dtype: '' + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: label3 + label: Line 3 Label + dtype: '' + default: "''" + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: width3 + label: Line 3 Width + dtype: '' + default: '1' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: color3 + label: Line 3 Color + dtype: '' + default: '"green"' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: alpha3 + label: Line 3 Alpha + dtype: '' + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: label4 + label: Line 4 Label + dtype: '' + default: "''" + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: width4 + label: Line 4 Width + dtype: '' + default: '1' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: color4 + label: Line 4 Color + dtype: '' + default: '"black"' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: alpha4 + label: Line 4 Alpha + dtype: '' + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: label5 + label: Line 5 Label + dtype: '' + default: "''" + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: width5 + label: Line 5 Width + dtype: '' + default: '1' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: color5 + label: Line 5 Color + dtype: '' + default: '"cyan"' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: alpha5 + label: Line 5 Alpha + dtype: '' + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: label6 + label: Line 6 Label + dtype: '' + default: "''" + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: width6 + label: Line 6 Width + dtype: '' + default: '1' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: color6 + label: Line 6 Color + dtype: '' + default: '"magenta"' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: alpha6 + label: Line 6 Alpha + dtype: '' + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: label7 + label: Line 7 Label + dtype: '' + default: "''" + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: width7 + label: Line 7 Width + dtype: '' + default: '1' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: color7 + label: Line 7 Color + dtype: '' + default: '"yellow"' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: alpha7 + label: Line 7 Alpha + dtype: '' + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: label8 + label: Line 8 Label + dtype: '' + default: "''" + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: width8 + label: Line 8 Width + dtype: '' + default: '1' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: color8 + label: Line 8 Color + dtype: '' + default: '"dark red"' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: alpha8 + label: Line 8 Alpha + dtype: '' + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: label9 + label: Line 9 Label + dtype: '' + default: "''" + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: width9 + label: Line 9 Width + dtype: '' + default: '1' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: color9 + label: Line 9 Color + dtype: '' + default: '"dark green"' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: alpha9 + label: Line 9 Alpha + dtype: '' + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: label10 + label: Line 10 Label + dtype: '' + default: "''" + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: width10 + label: Line 10 Width + dtype: '' + default: '1' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: color10 + label: Line 10 Color + dtype: '' + default: '"dark blue"' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: alpha10 + label: Line 10 Alpha + dtype: '' + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } + +inputs: +- domain: stream + dtype: ${ type.t } + multiplicity: ${ (0 if (type == 'msg_complex' or type == 'msg_float') else nconnections) } + optional: true +- domain: message + id: freq + optional: true + hide: ${ showports } + +outputs: +- domain: message + id: freq + optional: true + hide: ${ showports } + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import qtgui + from gnuradio.filter import firdes + import sip + callbacks: + - set_frequency_range(${fc}, ${bw}) + - set_update_time(${update_time}) + - set_y_axis(${ymin}, ${ymax}) + - self.${id}.set_trigger_mode(${tr_mode}, ${tr_level}, ${tr_chan}, ${tr_tag}) + make: |- + <% + win = 'self._%s_win'%id + %>\ + qtgui.${type.fcn}( + ${fftsize}, #size + ${wintype}, #wintype + ${fc}, #fc + ${bw}, #bw + ${name}, #name + ${ 0 if (type == 'msg_complex' or type == 'msg_float') else nconnections } + ) + self.${id}.set_update_time(${update_time}) + self.${id}.set_y_axis(${ymin}, ${ymax}) + self.${id}.set_y_label(${label}, ${units}) + self.${id}.set_trigger_mode(${tr_mode}, ${tr_level}, ${tr_chan}, ${tr_tag}) + self.${id}.enable_autoscale(${autoscale}) + self.${id}.enable_grid(${grid}) + self.${id}.set_fft_average(${average}) + self.${id}.enable_axis_labels(${axislabels}) + self.${id}.enable_control_panel(${ctrlpanel}) + + if not ${legend}: + self.${id}.disable_legend() + + if ${type} == "float" or ${type} == "msg_float": + self.${id}.set_plot_pos_half(not ${freqhalf}) + + labels = [${label1}, ${label2}, ${label3}, ${label4}, ${label5}, + ${label6}, ${label7}, ${label8}, ${label9}, ${label10}] + widths = [${width1}, ${width2}, ${width3}, ${width4}, ${width5}, + ${width6}, ${width7}, ${width8}, ${width9}, ${width10}] + colors = [${color1}, ${color2}, ${color3}, ${color4}, ${color5}, + ${color6}, ${color7}, ${color8}, ${color9}, ${color10}] + alphas = [${alpha1}, ${alpha2}, ${alpha3}, ${alpha4}, ${alpha5}, + ${alpha6}, ${alpha7}, ${alpha8}, ${alpha9}, ${alpha10}] + + for i in range(${1 if (type == 'msg_complex' or type == 'msg_float') else nconnections}): + if len(labels[i]) == 0: + self.${id}.set_line_label(i, "Data {0}".format(i)) + else: + self.${id}.set_line_label(i, labels[i]) + self.${id}.set_line_width(i, widths[i]) + self.${id}.set_line_color(i, colors[i]) + self.${id}.set_line_alpha(i, alphas[i]) + + ${win} = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget) + ${ gui_hint()(win)} + +documentation: |- + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_freq_sink_x.xml b/gr-qtgui/grc/qtgui_freq_sink_x.xml deleted file mode 100644 index ed39db7781..0000000000 --- a/gr-qtgui/grc/qtgui_freq_sink_x.xml +++ /dev/null @@ -1,791 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##QT GUI Sink -################################################### - --> -<block> - <name>QT GUI Frequency Sink</name> - <key>qtgui_freq_sink_x</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import qtgui</import> - <import>from gnuradio.filter import firdes</import> - <import>import sip</import> - <make>#set $win = 'self._%s_win'%$id -qtgui.$(type.fcn)( - $fftsize, \#size - $wintype, \#wintype - $fc, \#fc - $bw, \#bw - $name, \#name - #if $type.t == 'message' then 0 else $nconnections# \#number of inputs -) -self.$(id).set_update_time($update_time) -self.$(id).set_y_axis($ymin, $ymax) -self.$(id).set_y_label($label, $units) -self.$(id).set_trigger_mode($tr_mode, $tr_level, $tr_chan, $tr_tag) -self.$(id).enable_autoscale($autoscale) -self.$(id).enable_grid($grid) -self.$(id).set_fft_average($average) -self.$(id).enable_axis_labels($axislabels) -self.$(id).enable_control_panel($ctrlpanel) - -if not $legend: - self.$(id).disable_legend() - -if "$type" == "float" or "$type" == "msg_float": - self.$(id).set_plot_pos_half(not $freqhalf) - -labels = [$label1, $label2, $label3, $label4, $label5, - $label6, $label7, $label8, $label9, $label10] -widths = [$width1, $width2, $width3, $width4, $width5, - $width6, $width7, $width8, $width9, $width10] -colors = [$color1, $color2, $color3, $color4, $color5, - $color6, $color7, $color8, $color9, $color10] -alphas = [$alpha1, $alpha2, $alpha3, $alpha4, $alpha5, - $alpha6, $alpha7, $alpha8, $alpha9, $alpha10] -for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): - if len(labels[i]) == 0: - self.$(id).set_line_label(i, "Data {0}".format(i)) - else: - self.$(id).set_line_label(i, labels[i]) - self.$(id).set_line_width(i, widths[i]) - self.$(id).set_line_color(i, colors[i]) - self.$(id).set_line_alpha(i, alphas[i]) - -self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> - <callback>set_frequency_range($fc, $bw)</callback> - <callback>set_update_time($update_time)</callback> - <callback>set_title($which, $title)</callback> - <callback>set_color($which, $color)</callback> - <callback>set_y_axis($ymin, $ymax)</callback> - <callback>self.$(id).set_trigger_mode($tr_mode, $tr_level, $tr_chan, $tr_tag)</callback> - - <param_tab_order> - <tab>General</tab> - <tab>Trigger</tab> - <tab>Config</tab> - </param_tab_order> - - <param> - <name>Type</name> - <key>type</key> - <value>complex</value> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:freq_sink_c</opt> - <opt>t:complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:freq_sink_f</opt> - <opt>t:float</opt> - </option> - <option> - <name>Complex Message</name> - <key>msg_complex</key> - <opt>fcn:freq_sink_c</opt> - <opt>t:message</opt> - </option> - <option> - <name>Float Message</name> - <key>msg_float</key> - <opt>fcn:freq_sink_f</opt> - <opt>t:message</opt> - </option> - </param> - - <param> - <name>Name</name> - <key>name</key> - <value>""</value> - <type>string</type> - <hide>#if len($name()) > 0 then 'none' else 'part'#</hide> - </param> - - <param> - <name>FFT Size</name> - <key>fftsize</key> - <value>1024</value> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'none'#</hide> - </param> - - <param> - <name>Spectrum Width</name> - <key>freqhalf</key> - <value>True</value> - <type>enum</type> - <hide>#if $type() == "float" or $type() == "msg_float" then 'part' else 'all'#</hide> - <option> - <name>Full</name> - <key>True</key> - </option> - <option> - <name>Half</name> - <key>False</key> - </option> - </param> - - <param> - <name>Window Type</name> - <key>wintype</key> - <value>firdes.WIN_BLACKMAN_hARRIS</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Blackman-harris</name> - <key>firdes.WIN_BLACKMAN_hARRIS</key> - </option> - <option> - <name>Hamming</name> - <key>firdes.WIN_HAMMING</key> - </option> - <option> - <name>Hann</name> - <key>firdes.WIN_HANN</key> - </option> - <option> - <name>Blackman</name> - <key>firdes.WIN_BLACKMAN</key> - </option> - <option> - <name>Rectangular</name> - <key>firdes.WIN_RECTANGULAR</key> - </option> - <option> - <name>Kaiser</name> - <key>firdes.WIN_KAISER</key> - </option> - <option> - <name>Flat-top</name> - <key>firdes.WIN_FLATTOP</key> - </option> - </param> - - <param> - <name>Center Frequency (Hz)</name> - <key>fc</key> - <value>0</value> - <type>real</type> - </param> - - <param> - <name>Bandwidth (Hz)</name> - <key>bw</key> - <value>samp_rate</value> - <type>real</type> - </param> - - <param> - <name>Grid</name> - <key>grid</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Autoscale</name> - <key>autoscale</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Average</name> - <key>average</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>None</name> - <key>1.0</key> - </option> - <option> - <name>Low</name> - <key>0.2</key> - </option> - <option> - <name>Medium</name> - <key>0.1</key> - </option> - <option> - <name>High</name> - <key>0.05</key> - </option> - </param> - - <param> - <name>Y min</name> - <key>ymin</key> - <value>-140</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>Y max</name> - <key>ymax</key> - <value>10</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>Y label</name> - <key>label</key> - <value>Relative Gain</value> - <type>string</type> - <hide>part</hide> - </param> - - <param> - <name>Y units</name> - <key>units</key> - <value>dB</value> - <type>string</type> - <hide>part</hide> - </param> - - <param> - <name>Number of Inputs</name> - <key>nconnections</key> - <value>1</value> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'part'#</hide> - </param> - - <param> - <name>Update Period</name> - <key>update_time</key> - <value>0.10</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - <param> - <name>Show Msg Ports</name> - <key>showports</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>False</key> - </option> - <option> - <name>No</name> - <key>True</key> - </option> - </param> - - - <!-- Begin Trigger Tab items --> - <param> - <name>Trigger Mode</name> - <key>tr_mode</key> - <value>qtgui.TRIG_MODE_FREE</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Free</name> - <key>qtgui.TRIG_MODE_FREE</key> - </option> - <option> - <name>Auto</name> - <key>qtgui.TRIG_MODE_AUTO</key> - </option> - <option> - <name>Normal</name> - <key>qtgui.TRIG_MODE_NORM</key> - </option> - <option> - <name>Tag</name> - <key>qtgui.TRIG_MODE_TAG</key> - </option> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Level</name> - <key>tr_level</key> - <value>0.0</value> - <type>float</type> - <hide>part</hide> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Channel</name> - <key>tr_chan</key> - <value>0</value> - <type>int</type> - <hide>part</hide> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Tag Key</name> - <key>tr_tag</key> - <value>""</value> - <type>string</type> - <hide>part</hide> - <tab>Trigger</tab> - </param> - - - - <!-- Begin Config Tab items --> - <param> - <name>Control Panel</name> - <key>ctrlpanel</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Legend</name> - <key>legend</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Axis Labels</name> - <key>axislabels</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Label</name> - <key>label1</key> - <type>string</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Width</name> - <key>width1</key> - <value>1</value> - <type>int</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Color</name> - <key>color1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Blue</name> - <key>"blue"</key> - </option> - <option> - <name>Red</name> - <key>"red"</key> - </option> - <option> - <name>Green</name> - <key>"green"</key> - </option> - <option> - <name>Black</name> - <key>"black"</key> - </option> - <option> - <name>Cyan</name> - <key>"cyan"</key> - </option> - <option> - <name>Magenta</name> - <key>"magenta"</key> - </option> - <option> - <name>Yellow</name> - <key>"yellow"</key> - </option> - <option> - <name>Dark Red</name> - <key>"dark red"</key> - </option> - <option> - <name>Dark Green</name> - <key>"dark green"</key> - </option> - <option> - <name>Dark Blue</name> - <key>"dark blue"</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Alpha</name> - <key>alpha1</key> - <value>1.0</value> - <type>float</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 2 Label</name> - <key>label2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 2 Width</name> - <key>width2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 2 Color</name> - <key>color2</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 2 Alpha</name> - <key>alpha2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 3 Label</name> - <key>label3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 3 Width</name> - <key>width3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 3 Color</name> - <key>color3</key> - <value>"green"</value> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 3 Alpha</name> - <key>alpha3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 4 Label</name> - <key>label4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 4 Width</name> - <key>width4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 4 Color</name> - <key>color4</key> - <value>"black"</value> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 4 Alpha</name> - <key>alpha4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 5 Label</name> - <key>label5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 5 Width</name> - <key>width5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 5 Color</name> - <key>color5</key> - <value>"cyan"</value> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 5 Alpha</name> - <key>alpha5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 6 Label</name> - <key>label6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 6 Width</name> - <key>width6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 6 Color</name> - <key>color6</key> - <value>"magenta"</value> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 6 Alpha</name> - <key>alpha6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 7 Label</name> - <key>label7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 7 Width</name> - <key>width7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 7 Color</name> - <key>color7</key> - <value>"yellow"</value> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 7 Alpha</name> - <key>alpha7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 8 Label</name> - <key>label8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 8 Width</name> - <key>width8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 8 Color</name> - <key>color8</key> - <value>"dark red"</value> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 8 Alpha</name> - <key>alpha8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 9 Label</name> - <key>label9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 9 Width</name> - <key>width9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 9 Color</name> - <key>color9</key> - <value>"dark green"</value> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 9 Alpha</name> - <key>alpha9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 10 Label</name> - <key>label10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 10 Width</name> - <key>width10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 10 Color</name> - <key>color10</key> - <value>"dark blue"</value> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 10 Alpha</name> - <key>alpha10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - - <sink> - <name>in</name> - <type>$type.t</type> - <nports>#if $type.t == 'message' then 0 else $nconnections#</nports> - <optional>1</optional> - </sink> - - <sink> - <name>freq</name> - <type>message</type> - <optional>1</optional> - <hide>$showports</hide> - </sink> - - <source> - <name>freq</name> - <type>message</type> - <optional>1</optional> - <hide>$showports</hide> - </source> - - <doc> -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_histogram_sink_x.block.yml b/gr-qtgui/grc/qtgui_histogram_sink_x.block.yml new file mode 100644 index 0000000000..e1451144c2 --- /dev/null +++ b/gr-qtgui/grc/qtgui_histogram_sink_x.block.yml @@ -0,0 +1,419 @@ +id: qtgui_histogram_sink_x +label: QT GUI Histogram Sink + +parameters: +- id: type + label: Type + dtype: enum + default: float + options: [float, msg_float] + option_labels: [Float, Float Message] + option_attributes: + fcn: [histogram_sink_f, histogram_sink_f] + t: [float, message] + hide: part +- id: name + label: Name + dtype: string + default: '""' + hide: ${ ('none' if len(name) > 0 else 'part') } +- id: size + label: Number of Points + dtype: int + default: '1024' + hide: ${ ('all' if type.startwith('msg') else 'none') } +- id: bins + label: Number of Bins + dtype: int + default: '100' +- id: grid + label: Grid + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: autoscale + label: Autoscale + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] +- id: accum + label: Accumulate + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] +- id: xmin + label: Min x-axis + dtype: real + default: '-1' +- id: xmax + label: Max x-axis + dtype: real + default: '1' +- id: nconnections + label: Number of Inputs + dtype: int + default: '1' + hide: ${ ('all' if type.startwith('msg') else 'part') } +- id: update_time + label: Update Period + dtype: float + default: '0.10' + hide: part +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +- id: legend + label: Legend + category: Config + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: axislabels + label: Axis Labels + category: Config + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: label1 + label: Line 1 Label + category: Config + dtype: string + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: width1 + label: Line 1 Width + category: Config + dtype: int + default: '1' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: color1 + label: Line 1 Color + category: Config + dtype: enum + options: ['"blue"', '"red"', '"green"', '"black"', '"cyan"', '"magenta"', '"yellow"', + '"dark red"', '"dark green"', '"dark blue"'] + option_labels: [Blue, Red, Green, Black, Cyan, Magenta, Yellow, Dark Red, Dark + Green, Dark Blue] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: style1 + label: Line 1 Style + category: Config + dtype: enum + options: ['1', '2', '3', '4', '5', '0'] + option_labels: [Solid, Dash, Dots, Dash-Dot, Dash-Dot-Dot, None] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: marker1 + label: Line 1 Marker + category: Config + dtype: enum + options: ['-1', '0', '1', '2', '3', '4', '6', '7', '8', '9'] + option_labels: [None, Circle, Rectangle, Diamond, Triangle, Down Triangle, Left + Triangle, Right Triangle, Cross, X-Cross] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: alpha1 + label: Line 1 Alpha + category: Config + dtype: float + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: label2 + label: Line 2 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: width2 + label: Line 2 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: color2 + label: Line 2 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: style2 + label: Line 2 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: marker2 + label: Line 2 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: alpha2 + label: Line 2 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: label3 + label: Line 3 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: width3 + label: Line 3 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: color3 + label: Line 3 Color + dtype: '' + default: '"green"' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: style3 + label: Line 3 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: marker3 + label: Line 3 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: alpha3 + label: Line 3 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: label4 + label: Line 4 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: width4 + label: Line 4 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: color4 + label: Line 4 Color + dtype: '' + default: '"black"' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: style4 + label: Line 4 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: marker4 + label: Line 4 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: alpha4 + label: Line 4 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: label5 + label: Line 5 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: width5 + label: Line 5 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: color5 + label: Line 5 Color + dtype: '' + default: '"cyan"' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: style5 + label: Line 5 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: marker5 + label: Line 5 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: alpha5 + label: Line 5 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: label6 + label: Line 6 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: width6 + label: Line 6 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: color6 + label: Line 6 Color + dtype: '' + default: '"magenta"' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: style6 + label: Line 6 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: marker6 + label: Line 6 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: alpha6 + label: Line 6 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: label7 + label: Line 7 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: width7 + label: Line 7 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: color7 + label: Line 7 Color + dtype: '' + default: '"yellow"' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: style7 + label: Line 7 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: marker7 + label: Line 7 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: alpha7 + label: Line 7 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: label8 + label: Line 8 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: width8 + label: Line 8 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: color8 + label: Line 8 Color + dtype: '' + default: '"dark red"' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: style8 + label: Line 8 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: marker8 + label: Line 8 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: alpha8 + label: Line 8 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: label9 + label: Line 9 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: width9 + label: Line 9 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: color9 + label: Line 9 Color + dtype: '' + default: '"dark green"' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: style9 + label: Line 9 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: marker9 + label: Line 9 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: alpha9 + label: Line 9 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: label10 + label: Line 10 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: width10 + label: Line 10 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: color10 + label: Line 10 Color + dtype: '' + default: '"dark blue"' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: style10 + label: Line 10 Style + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: marker10 + label: Line 10 Marker + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: alpha10 + label: Line 10 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } + +inputs: +- domain: stream + dtype: ${ type.t } + multiplicity: ${ (0 if type.startswith('msg') else nconnections) } + optional: true + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import qtgui + import sip + callbacks: + - set_update_time(${update_time}) + - set_title(${which}, ${title}) + - set_color(${which}, ${color}) + - set_bins(${bins}) + - set_bins(${bins}) + - set_x_axis(${xmin}, ${xmax}) + make: |- + <% + win = 'self._%s_win'%id + %>\ + qtgui.histogram_sink_f( + $size, + $bins, + $xmin, + $xmax, + $name, + ${ 0 if type.startswith('msg') else nconnections} + ) + + self.${id}.set_update_time(${update_time}) + self.${id}.enable_autoscale(${autoscale}) + self.${id}.enable_accumulate(${accum}) + self.${id}.enable_grid(${grid}) + self.${id}.enable_axis_labels(${axislabels}) + + if not ${legend}: + self.${id}.disable_legend() + + labels = [${label1}, ${label2}, ${label3}, ${label4}, ${label5}, + ${label6}, ${label7}, ${label8}, ${label9}, ${label10}] + widths = [${width1}, ${width2}, ${width3}, ${width4}, ${width5}, + ${width6}, ${width7}, ${width8}, ${width9}, ${width10}] + colors = [${color1}, ${color2}, ${color3}, ${color4}, ${color5}, + ${color6}, ${color7}, ${color8}, ${color9}, ${color10}] + alphas = [${alpha1}, ${alpha2}, ${alpha3}, ${alpha4}, ${alpha5}, + ${alpha6}, ${alpha7}, ${alpha8}, ${alpha9}, ${alpha10}] + + for i in range(${1 if type.startswith('msg') else nconnections}): + if len(labels[i]) == 0: + self.${id}.set_line_label(i, "Data {0}".format(i)) + else: + self.${id}.set_line_label(i, labels[i]) + self.${id}.set_line_width(i, widths[i]) + self.${id}.set_line_color(i, colors[i]) + self.${id}.set_line_style(i, styles[i]) + self.${id}.set_line_marker(i, markers[i]) + self.${id}.set_line_alpha(i, alphas[i]) + + ${win} = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget) + ${gui_hint()(win)} + +documentation: |- + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_histogram_sink_x.xml b/gr-qtgui/grc/qtgui_histogram_sink_x.xml deleted file mode 100644 index 9e3dcb104f..0000000000 --- a/gr-qtgui/grc/qtgui_histogram_sink_x.xml +++ /dev/null @@ -1,794 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##QT GUI Histogram Sink -################################################### - --> -<block> - <name>QT GUI Histogram Sink</name> - <key>qtgui_histogram_sink_x</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import qtgui</import> - <import>import sip</import> - <make>#set $win = 'self._%s_win'%$id -qtgui.histogram_sink_f( - $size, - $bins, - $xmin, - $xmax, - $name, - #if $type.t == 'message' then 0 else $nconnections# -) - -self.$(id).set_update_time($update_time) -self.$(id).enable_autoscale($autoscale) -self.$(id).enable_accumulate($accum) -self.$(id).enable_grid($grid) -self.$(id).enable_axis_labels($axislabels) - -if not $legend: - self.$(id).disable_legend() - -labels = [$label1, $label2, $label3, $label4, $label5, - $label6, $label7, $label8, $label9, $label10] -widths = [$width1, $width2, $width3, $width4, $width5, - $width6, $width7, $width8, $width9, $width10] -colors = [$color1, $color2, $color3, $color4, $color5, - $color6, $color7, $color8, $color9, $color10] -styles = [$style1, $style2, $style3, $style4, $style5, - $style6, $style7, $style8, $style9, $style10] -markers = [$marker1, $marker2, $marker3, $marker4, $marker5, - $marker6, $marker7, $marker8, $marker9, $marker10] -alphas = [$alpha1, $alpha2, $alpha3, $alpha4, $alpha5, - $alpha6, $alpha7, $alpha8, $alpha9, $alpha10] -for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): - if len(labels[i]) == 0: - self.$(id).set_line_label(i, "Data {0}".format(i)) - else: - self.$(id).set_line_label(i, labels[i]) - self.$(id).set_line_width(i, widths[i]) - self.$(id).set_line_color(i, colors[i]) - self.$(id).set_line_style(i, styles[i]) - self.$(id).set_line_marker(i, markers[i]) - self.$(id).set_line_alpha(i, alphas[i]) - -self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win)) - </make> - <callback>set_update_time($update_time)</callback> - <callback>set_title($which, $title)</callback> - <callback>set_color($which, $color)</callback> - <callback>set_bins($bins)</callback> - <callback>set_bins($bins)</callback> - <callback>set_x_axis($xmin, $xmax)</callback> - - <param_tab_order> - <tab>General</tab> - <tab>Config</tab> - </param_tab_order> - - <param> - <name>Type</name> - <key>type</key> - <value>float</value> - <type>enum</type> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:histogram_sink_f</opt> - <opt>t:float</opt> - </option> - <option> - <name>Float Message</name> - <key>msg_float</key> - <opt>fcn:histogram_sink_f</opt> - <opt>t:message</opt> - </option> - </param> - - <param> - <name>Name</name> - <key>name</key> - <value>""</value> - <type>string</type> - <hide>#if len($name()) > 0 then 'none' else 'part'#</hide> - </param> - - <param> - <name>Number of Points</name> - <key>size</key> - <value>1024</value> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'none'#</hide> - </param> - - <param> - <name>Number of Bins</name> - <key>bins</key> - <value>100</value> - <type>int</type> - </param> - - <param> - <name>Grid</name> - <key>grid</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Autoscale</name> - <key>autoscale</key> - <value>True</value> - <type>enum</type> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Accumulate</name> - <key>accum</key> - <value>False</value> - <type>enum</type> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Min x-axis</name> - <key>xmin</key> - <value>-1</value> - <type>real</type> - </param> - - <param> - <name>Max x-axis</name> - <key>xmax</key> - <value>1</value> - <type>real</type> - </param> - - <param> - <name>Number of Inputs</name> - <key>nconnections</key> - <value>1</value> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'part'#</hide> - </param> - - <param> - <name>Update Period</name> - <key>update_time</key> - <value>0.10</value> - <type>float</type> - <hide>part</hide> - </param> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - <!-- Begin Config Tab items --> - <param> - <name>Legend</name> - <key>legend</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Axis Labels</name> - <key>axislabels</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Label</name> - <key>label1</key> - <type>string</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Width</name> - <key>width1</key> - <value>1</value> - <type>int</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Color</name> - <key>color1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Blue</name> - <key>"blue"</key> - </option> - <option> - <name>Red</name> - <key>"red"</key> - </option> - <option> - <name>Green</name> - <key>"green"</key> - </option> - <option> - <name>Black</name> - <key>"black"</key> - </option> - <option> - <name>Cyan</name> - <key>"cyan"</key> - </option> - <option> - <name>Magenta</name> - <key>"magenta"</key> - </option> - <option> - <name>Yellow</name> - <key>"yellow"</key> - </option> - <option> - <name>Dark Red</name> - <key>"dark red"</key> - </option> - <option> - <name>Dark Green</name> - <key>"dark green"</key> - </option> - <option> - <name>Dark Blue</name> - <key>"dark blue"</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Style</name> - <key>style1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Solid</name> - <key>1</key> - </option> - <option> - <name>Dash</name> - <key>2</key> - </option> - <option> - <name>Dots</name> - <key>3</key> - </option> - <option> - <name>Dash-Dot</name> - <key>4</key> - </option> - <option> - <name>Dash-Dot-Dot</name> - <key>5</key> - </option> - <option> - <name>None</name> - <key>0</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Marker</name> - <key>marker1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>None</name> - <key>-1</key> - </option> - <option> - <name>Circle</name> - <key>0</key> - </option> - <option> - <name>Rectangle</name> - <key>1</key> - </option> - <option> - <name>Diamond</name> - <key>2</key> - </option> - <option> - <name>Triangle</name> - <key>3</key> - </option> - <option> - <name>Down Triangle</name> - <key>4</key> - </option> - <option> - <name>Left Triangle</name> - <key>6</key> - </option> - <option> - <name>Right Triangle</name> - <key>7</key> - </option> - <option> - <name>Cross</name> - <key>8</key> - </option> - <option> - <name>X-Cross</name> - <key>9</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Alpha</name> - <key>alpha1</key> - <value>1.0</value> - <type>float</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 2 Label</name> - <key>label2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 2 Width</name> - <key>width2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 2 Color</name> - <key>color2</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 2 Style</name> - <key>style2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 2 Marker</name> - <key>marker2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 2 Alpha</name> - <key>alpha2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 3 Label</name> - <key>label3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 3 Width</name> - <key>width3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 3 Color</name> - <key>color3</key> - <value>"green"</value> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 3 Style</name> - <key>style3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 3 Marker</name> - <key>marker3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 3 Alpha</name> - <key>alpha3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 4 Label</name> - <key>label4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 4 Width</name> - <key>width4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 4 Color</name> - <key>color4</key> - <value>"black"</value> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 4 Style</name> - <key>style4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 4 Marker</name> - <key>marker4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 4 Alpha</name> - <key>alpha4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 5 Label</name> - <key>label5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 5 Width</name> - <key>width5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 5 Color</name> - <key>color5</key> - <value>"cyan"</value> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 5 Style</name> - <key>style5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 5 Marker</name> - <key>marker5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 5 Alpha</name> - <key>alpha5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 6 Label</name> - <key>label6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 6 Width</name> - <key>width6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 6 Color</name> - <key>color6</key> - <value>"magenta"</value> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 6 Style</name> - <key>style6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 6 Marker</name> - <key>marker6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 6 Alpha</name> - <key>alpha6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 7 Label</name> - <key>label7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 7 Width</name> - <key>width7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 7 Color</name> - <key>color7</key> - <value>"yellow"</value> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 7 Style</name> - <key>style7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 7 Marker</name> - <key>marker7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 7 Alpha</name> - <key>alpha7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 8 Label</name> - <key>label8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 8 Width</name> - <key>width8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 8 Color</name> - <key>color8</key> - <value>"dark red"</value> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 8 Style</name> - <key>style8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 8 Marker</name> - <key>marker8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 8 Alpha</name> - <key>alpha8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 9 Label</name> - <key>label9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 9 Width</name> - <key>width9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 9 Color</name> - <key>color9</key> - <value>"dark green"</value> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 9 Style</name> - <key>style9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 9 Marker</name> - <key>marker9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 9 Alpha</name> - <key>alpha9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 10 Label</name> - <key>label10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 10 Width</name> - <key>width10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 10 Color</name> - <key>color10</key> - <value>"dark blue"</value> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 10 Style</name> - <key>style10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 10 Marker</name> - <key>marker10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 10 Alpha</name> - <key>alpha10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - - <sink> - <name>in</name> - <type>$type.t</type> - <nports>#if $type.t == 'message' then 0 else $nconnections#</nports> - <optional>1</optional> - </sink> - - <doc> -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_label.block.yml b/gr-qtgui/grc/qtgui_label.block.yml new file mode 100644 index 0000000000..68a46acb27 --- /dev/null +++ b/gr-qtgui/grc/qtgui_label.block.yml @@ -0,0 +1,66 @@ +id: variable_qtgui_label +label: QT GUI Label + +parameters: +- id: label + label: Label + dtype: string + hide: ${ ('none' if label else 'part') } +- id: type + label: Type + dtype: enum + default: int + options: [real, int, string, bool, raw] + option_labels: [Float, Integer, String, Boolean, Any] + option_attributes: + conv: [eng_notation.str_to_num, int, str, bool, eval] + str: [eng_notation.num_to_str, str, str, str, repr] + hide: part +- id: value + label: Default Value + dtype: ${ type } + default: '0' +- id: formatter + label: Formatter + dtype: raw + default: None + hide: part +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +value: ${ value } + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import eng_notation + var_make: self.${id} = ${id} = ${value} + callbacks: + - self.set_${id}(self._${id}_formatter(${value})) + - Qt.QMetaObject.invokeMethod(self._${id}_label, "setText", Qt.Q_ARG("QString", + ${id})) + make: |- + <% + win = 'self._%s_win'%id + if not label: + label = 'self._%s_tool_bar'%id + %>\ + ${win} = Qt.QToolBar(self) + + if ${formatter}: + self._${id}_formatter = ${formatter} + else: + self._${id}_formatter = lambda x: ${type.str}(x) + + ${win}.addWidget(Qt.QLabel(${label}+": ")) + self._${id}_label = Qt.QLabel(str(self._${id}_formatter(self.${id}))) + self._${id}_tool_bar.addWidget(self._${id}_label) + ${gui_hint()(win)} + +documentation: |- + This block creates a variable with a label widget for text. Leave the label blank to use the variable id as the label. + + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_label.xml b/gr-qtgui/grc/qtgui_label.xml deleted file mode 100644 index 946cee36ab..0000000000 --- a/gr-qtgui/grc/qtgui_label.xml +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable Label Text: -## a gui static text form -################################################### - --> - -<block> - <name>QT GUI Label</name> - <key>variable_qtgui_label</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import eng_notation</import> - <var_make>self.$(id) = $(id) = $value</var_make> - <make>#set $win = 'self._%s_tool_bar'%$id -$win = Qt.QToolBar(self) -#if not $label() - #set $label = '"%s"'%$id -#end if - -if $(formatter): - self._$(id)_formatter = $formatter -else: - self._$(id)_formatter = lambda x: $(type.str)(x) - -$(win).addWidget(Qt.QLabel($label+": ")) -self._$(id)_label = Qt.QLabel(str(self._$(id)_formatter(self.$id))) -self._$(id)_tool_bar.addWidget(self._$(id)_label) -$(gui_hint()($win)) - </make> - - <callback>self.set_$(id)(self._$(id)_formatter($value))</callback> - <callback>Qt.QMetaObject.invokeMethod(self._$(id)_label, "setText", Qt.Q_ARG("QString", $id))</callback> - - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - <hide>#if $label() then 'none' else 'part'#</hide> - </param> - - <param> - <name>Type</name> - <key>type</key> - <value>int</value> - <type>enum</type> - <hide>part</hide> - <option><name>Float</name><key>real</key><opt>conv:eng_notation.str_to_num</opt><opt>str:eng_notation.num_to_str</opt></option> - <option><name>Integer</name><key>int</key><opt>conv:int</opt><opt>str:str</opt></option> - <option><name>String</name><key>string</key><opt>conv:str</opt><opt>str:str</opt></option> - <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt><opt>str:str</opt></option> - <option><name>Any</name><key>raw</key><opt>conv:eval</opt><opt>str:repr</opt></option> - </param> - - <param> - <name>Default Value</name> - <key>value</key> - <value>0</value> - <type>$type</type> - </param> - - <param> - <name>Formatter</name> - <key>formatter</key> - <value>None</value> - <type>raw</type> - <hide>part</hide> - </param> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - <doc> -This block creates a variable with a label widget for text. \ -Leave the label blank to use the variable id as the label. - -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_number_sink.block.yml b/gr-qtgui/grc/qtgui_number_sink.block.yml new file mode 100644 index 0000000000..559958a9ae --- /dev/null +++ b/gr-qtgui/grc/qtgui_number_sink.block.yml @@ -0,0 +1,283 @@ +id: qtgui_number_sink +label: QT GUI Number Sink + +parameters: +- id: name + label: Name + dtype: string + default: '""' + hide: ${ ('none' if len(name) > 0 else 'part') } +- id: type + label: Input Type + category: General + dtype: enum + options: [float, int, short, byte] + option_attributes: + size: [gr.sizeof_float, gr.sizeof_int, gr.sizeof_short, gr.sizeof_char] + hide: part +- id: autoscale + label: Autoscale + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] +- id: avg + label: Average + category: General + dtype: float + default: '0' +- id: graph_type + label: Graph Type + category: General + dtype: enum + options: [qtgui.NUM_GRAPH_HORIZ, qtgui.NUM_GRAPH_VERT, qtgui.NUM_GRAPH_NONE] + option_labels: [Horizontal, Vertical, None] +- id: nconnections + label: Number of Inputs + category: General + dtype: int + default: '1' + hide: part +- id: min + label: Min + dtype: float + default: '-1' + hide: part +- id: max + label: Max + dtype: float + default: '1' + hide: part +- id: update_time + label: Update Period + category: General + dtype: float + default: '0.10' + hide: part +- id: gui_hint + label: GUI Hint + category: General + dtype: gui_hint + hide: part +- id: label1 + label: Line 1 Label + category: Config + dtype: string + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: unit1 + label: Line 1 Unit + category: Config + dtype: string + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: color1 + label: Line 1 Color + category: Config + dtype: enum + options: ['("black", "black")', '("blue", "red")', '("black", "white")', '("white", + "black")', '("black", "red")'] + option_labels: [Black, Blue-Red, White Hot, Black Hot, Black-Red] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: factor1 + label: Line 1 Factor + category: Config + dtype: float + default: '1' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: label2 + label: Line 2 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: unit2 + label: Line 2 Unit + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: color2 + label: Line 2 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: factor2 + label: Line 2 Factor + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: label3 + label: Line 3 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: unit3 + label: Line 3 Unit + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: color3 + label: Line 3 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: factor3 + label: Line 3 Factor + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: label4 + label: Line 4 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: unit4 + label: Line 4 Unit + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: color4 + label: Line 4 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: factor4 + label: Line 4 Factor + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: label5 + label: Line 5 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: unit5 + label: Line 5 Unit + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: color5 + label: Line 5 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: factor5 + label: Line 5 Factor + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: label6 + label: Line 6 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: unit6 + label: Line 6 Unit + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: color6 + label: Line 6 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: factor6 + label: Line 6 Factor + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: label7 + label: Line 7 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: unit7 + label: Line 7 Unit + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: color7 + label: Line 7 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: factor7 + label: Line 7 Factor + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: label8 + label: Line 8 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: unit8 + label: Line 8 Unit + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: color8 + label: Line 8 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: factor8 + label: Line 8 Factor + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: label9 + label: Line 9 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: unit9 + label: Line 9 Unit + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: color9 + label: Line 9 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: factor9 + label: Line 9 Factor + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: label10 + label: Line 10 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: unit10 + label: Line 10 Unit + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: color10 + label: Line 10 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: factor10 + label: Line 10 Factor + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } + +inputs: +- domain: stream + dtype: ${ type } + multiplicity: ${ nconnections } + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import qtgui + import sip + callbacks: + - set_update_time(${update_time}) + make: |- + <% + win = 'self._%s_win'%id + %>\ + qtgui.number_sink( + ${type.size}, + ${avg}, + ${graph_type}, + ${nconnections} + ) + self.${id}.set_update_time(${update_time}) + self.${id}.set_title(${name}) + + labels = [${label1}, ${label2}, ${label3}, ${label4}, ${label5}, + ${label6}, ${label7}, ${label8}, ${label9}, ${label10}] + units = [${unit1}, ${unit2}, ${unit3}, ${unit4}, ${unit5}, + ${unit6}, ${unit7}, ${unit8}, ${unit9}, ${unit10}] + colors = [${color1}, ${color2}, ${color3}, ${color4}, ${color5}, + ${color6}, ${color7}, ${color8}, ${color9}, ${color10}] + factor = [${factor1}, ${factor2}, ${factor3}, ${factor4}, ${factor5}, + ${factor6}, ${factor7}, ${factor8}, ${factor9}, ${factor10}] + + for i in range(${nconnections}): + self.${id}.set_min(i, ${min}) + self.${id}.set_max(i, ${max}) + self.${id}.set_color(i, colors[i][0], colors[i][1]) + if len(labels[i]) == 0: + self.${id}.set_label(i, "Data {0}".format(i)) + else: + self.${id}.set_label(i, labels[i]) + self.${id}.set_unit(i, units[i]) + self.${id}.set_factor(i, factor[i]) + + self.${id}.enable_autoscale(${autoscale}) + ${win} = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget) + ${gui_hint()(win)} + +documentation: |- + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_number_sink.xml b/gr-qtgui/grc/qtgui_number_sink.xml deleted file mode 100644 index 06837493c3..0000000000 --- a/gr-qtgui/grc/qtgui_number_sink.xml +++ /dev/null @@ -1,496 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##QT GUI Number Sink -################################################### - --> -<block> - <name>QT GUI Number Sink</name> - <key>qtgui_number_sink</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import qtgui</import> - <import>import sip</import> - <make>#set $win = 'self._%s_win'%$id -qtgui.number_sink( - $type.size, - $avg, - $graph_type, - $nconnections -) -self.$(id).set_update_time($update_time) -self.$(id).set_title($name) - -labels = [$label1, $label2, $label3, $label4, $label5, - $label6, $label7, $label8, $label9, $label10] -units = [$unit1, $unit2, $unit3, $unit4, $unit5, - $unit6, $unit7, $unit8, $unit9, $unit10] -colors = [$color1, $color2, $color3, $color4, $color5, - $color6, $color7, $color8, $color9, $color10] -factor = [$factor1, $factor2, $factor3, $factor4, $factor5, - $factor6, $factor7, $factor8, $factor9, $factor10] -for i in xrange($nconnections): - self.$(id).set_min(i, $min) - self.$(id).set_max(i, $max) - self.$(id).set_color(i, colors[i][0], colors[i][1]) - if len(labels[i]) == 0: - self.$(id).set_label(i, "Data {0}".format(i)) - else: - self.$(id).set_label(i, labels[i]) - self.$(id).set_unit(i, units[i]) - self.$(id).set_factor(i, factor[i]) - -self.$(id).enable_autoscale($autoscale) -self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> - <callback>set_update_time($update_time)</callback> - - <param_tab_order> - <tab>General</tab> - <tab>Config</tab> - </param_tab_order> - - <param> - <name>Name</name> - <key>name</key> - <value>""</value> - <type>string</type> - <hide>#if len($name()) > 0 then 'none' else 'part'#</hide> - </param> - - <param> - <name>Input Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - <tab>General</tab> - </param> - - <param> - <name>Autoscale</name> - <key>autoscale</key> - <value>False</value> - <type>enum</type> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Average</name> - <key>avg</key> - <value>0</value> - <type>float</type> - <tab>General</tab> - </param> - - <param> - <name>Graph Type</name> - <key>graph_type</key> - <type>enum</type> - <option> - <name>Horizontal</name> - <key>qtgui.NUM_GRAPH_HORIZ</key> - </option> - <option> - <name>Vertical</name> - <key>qtgui.NUM_GRAPH_VERT</key> - </option> - <option> - <name>None</name> - <key>qtgui.NUM_GRAPH_NONE</key> - </option> - <tab>General</tab> - </param> - - <param> - <name>Number of Inputs</name> - <key>nconnections</key> - <value>1</value> - <type>int</type> - <hide>part</hide> - <tab>General</tab> - </param> - - <param> - <name>Min</name> - <key>min</key> - <value>-1</value> - <type>float</type> - <hide>part</hide> - </param> - <param> - <name>Max</name> - <key>max</key> - <value>1</value> - <type>float</type> - <hide>part</hide> - </param> - - <param> - <name>Update Period</name> - <key>update_time</key> - <value>0.10</value> - <type>float</type> - <hide>part</hide> - <tab>General</tab> - </param> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - <tab>General</tab> - </param> - - <param> - <name>Line 1 Label</name> - <key>label1</key> - <type>string</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Unit</name> - <key>unit1</key> - <type>string</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Color</name> - <key>color1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Black</name> - <key>("black", "black")</key> - </option> - <option> - <name>Blue-Red</name> - <key>("blue", "red")</key> - </option> - <option> - <name>White Hot</name> - <key>("black", "white")</key> - </option> - <option> - <name>Black Hot</name> - <key>("white", "black")</key> - </option> - <option> - <name>Black-Red</name> - <key>("black", "red")</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Factor</name> - <key>factor1</key> - <value>1</value> - <type>float</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 2 Label</name> - <key>label2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>unit1</base_key> - <name>Line 2 Unit</name> - <key>unit2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 2 Color</name> - <key>color2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>factor1</base_key> - <name>Line 2 Factor</name> - <key>factor2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 3 Label</name> - <key>label3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>unit1</base_key> - <name>Line 3 Unit</name> - <key>unit3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 3 Color</name> - <key>color3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>factor1</base_key> - <name>Line 3 Factor</name> - <key>factor3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 4 Label</name> - <key>label4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>unit1</base_key> - <name>Line 4 Unit</name> - <key>unit4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 4 Color</name> - <key>color4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>factor1</base_key> - <name>Line 4 Factor</name> - <key>factor4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 5 Label</name> - <key>label5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>unit1</base_key> - <name>Line 5 Unit</name> - <key>unit5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 5 Color</name> - <key>color5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>factor1</base_key> - <name>Line 5 Factor</name> - <key>factor5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 6 Label</name> - <key>label6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>unit1</base_key> - <name>Line 6 Unit</name> - <key>unit6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 6 Color</name> - <key>color6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>factor1</base_key> - <name>Line 6 Factor</name> - <key>factor6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 7 Label</name> - <key>label7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>unit1</base_key> - <name>Line 7 Unit</name> - <key>unit7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 7 Color</name> - <key>color7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>factor1</base_key> - <name>Line 7 Factor</name> - <key>factor7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 8 Label</name> - <key>label8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>unit1</base_key> - <name>Line 8 Unit</name> - <key>unit8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 8 Color</name> - <key>color8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>factor1</base_key> - <name>Line 8 Factor</name> - <key>factor8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 9 Label</name> - <key>label9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>unit1</base_key> - <name>Line 9 Unit</name> - <key>unit9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 9 Color</name> - <key>color9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>factor1</base_key> - <name>Line 9 Factor</name> - <key>factor9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 10 Label</name> - <key>label10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>unit1</base_key> - <name>Line 10 Unit</name> - <key>unit10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 10 Color</name> - <key>color10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>factor1</base_key> - <name>Line 10 Factor</name> - <key>factor10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - - <sink> - <name>in</name> - <type>$type</type> - <nports>$nconnections</nports> - </sink> - <doc> - The GUI hint can be used to position the widget within the application. \ - The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ - Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_push_button.block.yml b/gr-qtgui/grc/qtgui_push_button.block.yml new file mode 100644 index 0000000000..8c62e92f08 --- /dev/null +++ b/gr-qtgui/grc/qtgui_push_button.block.yml @@ -0,0 +1,60 @@ +id: variable_qtgui_push_button +label: QT GUI Push Button + +parameters: +- id: label + label: Label + dtype: string + hide: ${ ('none' if label else 'part') } +- id: type + label: Type + dtype: enum + default: int + options: [real, int, string, bool, raw] + option_labels: [Float, Integer, String, Boolean, Any] + option_attributes: + conv: [float, int, str, bool, eval] + hide: part +- id: value + label: Default Value + dtype: ${ type } + default: '0' +- id: pressed + label: Pressed + dtype: ${ type } + default: '1' +- id: released + label: Released + dtype: ${ type } + default: '0' +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +value: ${ value } + +templates: + imports: from PyQt5 import Qt + var_make: self.${id} = ${id} = ${value} + callbacks: + - self.set_${id}(${value}) + make: |- + <% + win = '_%s_push_button'%id + if not label: + label = '"%s"'%id + %>\ + ${win} = Qt.QPushButton(${label}) + self._${id}_choices = {'Pressed': ${pressed}, 'Released': ${released}} + ${win}.pressed.connect(lambda: self.set_${id}(self._${id}_choices['Pressed'])) + ${win}.released.connect(lambda: self.set_${id}(self._${id}_choices['Released'])) + ${gui_hint()(win)} + +documentation: |- + This block creates a variable push button. Leave the label blank to use the variable id as the label. + + A push button selects between two values of similar type. The variable will take on one value or the other depending on whether the button is pressed or released. + + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_push_button.xml b/gr-qtgui/grc/qtgui_push_button.xml deleted file mode 100644 index 49c2e9d6f0..0000000000 --- a/gr-qtgui/grc/qtgui_push_button.xml +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable Push Button: -## a gui push button form -################################################### - --> -<block> - <name>QT GUI Push Button</name> - <key>variable_qtgui_push_button</key> - <import>from PyQt5 import Qt</import> - <var_make>self.$(id) = $(id) = $value</var_make> - <make>#set $win = '_%s_push_button'%$id -#if not $label() - #set $label = '"%s"'%$id -#end if -$win = Qt.QPushButton($label) -self._$(id)_choices = {'Pressed': $pressed, 'Released': $released} -$(win).pressed.connect(lambda: self.set_$(id)(self._$(id)_choices['Pressed'])) -$(win).released.connect(lambda: self.set_$(id)(self._$(id)_choices['Released'])) -$(gui_hint()($win))</make> - <callback>self.set_$(id)($value)</callback> - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - <hide>#if $label() then 'none' else 'part'#</hide> - </param> - <param> - <name>Type</name> - <key>type</key> - <value>int</value> - <type>enum</type> - <hide>part</hide> - <option><name>Float</name><key>real</key><opt>conv:float</opt></option> - <option><name>Integer</name><key>int</key><opt>conv:int</opt></option> - <option><name>String</name><key>string</key><opt>conv:str</opt></option> - <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt></option> - <option><name>Any</name><key>raw</key><opt>conv:eval</opt></option> - </param> - <param> - <name>Default Value</name> - <key>value</key> - <value>0</value> - <type>$type</type> - </param> - <param> - <name>Pressed</name> - <key>pressed</key> - <value>1</value> - <type>$type</type> - </param> - <param> - <name>Released</name> - <key>released</key> - <value>0</value> - <type>$type</type> - </param> - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - <doc> -This block creates a variable push button. \ -Leave the label blank to use the variable id as the label. - -A push button selects between two values of similar type. \ -The variable will take on one value or the other depending \ -on whether the button is pressed or released. - -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_range.block.yml b/gr-qtgui/grc/qtgui_range.block.yml new file mode 100644 index 0000000000..0c75489533 --- /dev/null +++ b/gr-qtgui/grc/qtgui_range.block.yml @@ -0,0 +1,86 @@ +id: variable_qtgui_range +label: QT GUI Range + +parameters: +- id: label + label: Label + dtype: string + hide: ${ ('none' if label else 'part') } +- id: rangeType + label: Type + dtype: enum + default: '"float"' + options: [float, int] + option_attributes: + type: [float, int] + hide: part +- id: value + label: Default Value + dtype: ${ rangeType.type } + default: '50' +- id: start + label: Start + dtype: ${ rangeType.type } + default: '0' +- id: stop + label: Stop + dtype: ${ rangeType.type } + default: '100' +- id: step + label: Step + dtype: ${ rangeType.type } + default: '1' +- id: widget + label: Widget + dtype: enum + default: counter_slider + options: [counter_slider, counter, slider, dial] + option_labels: [Counter + Slider, Counter, Slider, Knob] + hide: part +- id: orient + label: Orientation + dtype: enum + default: Qt.Horizontal + options: [Qt.Horizontal, Qt.Vertical] + option_labels: [Horizontal, Vertical] + option_attributes: + minfcn: [setMinimumWidth, setMinimumHeight] + scalepos: [BottomScale, LeftScale] + hide: ${ ('part' if widget == "slider" else 'all') } +- id: min_len + label: Minimum Length + dtype: int + default: '200' + hide: part +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +value: ${ value } + +asserts: +- ${start <= value <= stop} +- ${start <= stop} + +templates: + imports: from gnuradio.qtgui import Range, RangeWidget + var_make: self.${id} = ${id} = ${value} + callbacks: + - self.set_${id}(${value}) + make: |- + <% + win = 'self._%s_win'%id + range = 'self._%s_range'%id + if not label: + label = '"%s"'%id + %>\ + ${range} = Range(${start}, ${stop}, ${step}, ${value}, ${min_len}) + ${win} = RangeWidget(${range}, self.set_${id}, ${label}, "${widget}", ${rangeType}) + ${gui_hint()(win)} + +documentation: |- + This block creates a variable with a slider. Leave the label blank to use the variable id as the label. The value must be a real number. The value must be between the start and the stop. + + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_range.xml b/gr-qtgui/grc/qtgui_range.xml deleted file mode 100644 index 71b614cc5e..0000000000 --- a/gr-qtgui/grc/qtgui_range.xml +++ /dev/null @@ -1,131 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable Range: -## ranged widgets like a slider or a knob -################################################### - --> -<block> - <name>QT GUI Range</name> - <key>variable_qtgui_range</key> - <import>from gnuradio.qtgui import Range, RangeWidget</import> - <var_make>self.$(id) = $(id) = $value</var_make> - <make>#set $win = 'self._%s_win'%$id - #set $range = 'self._%s_range'%$id -#if not $label() - #set $label = '"%s"'%$id -#end if -$(range) = Range($start, $stop, $step, $value, $min_len) -$(win) = RangeWidget($range, self.set_$(id), $label, "$widget", $rangeType) -$(gui_hint()($win))</make> - <callback>self.set_$(id)($value)</callback> - - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - <hide>#if $label() then 'none' else 'part'#</hide> - </param> - - <param> - <name>Type</name> - <key>rangeType</key> - <value>"float"</value> - <type>enum</type> - <hide>part</hide> - <option><name>Float</name><key>float</key><opt>type:float</opt></option> - <option><name>Int</name><key>int</key><opt>type:int</opt></option> - </param> - - <param> - <name>Default Value</name> - <key>value</key> - <value>50</value> - <type>$rangeType.type</type> - </param> - - <param> - <name>Start</name> - <key>start</key> - <value>0</value> - <type>$rangeType.type</type> - </param> - - <param> - <name>Stop</name> - <key>stop</key> - <value>100</value> - <type>$rangeType.type</type> - </param> - - <param> - <name>Step</name> - <key>step</key> - <value>1</value> - <type>$rangeType.type</type> - </param> - - <param> - <name>Widget</name> - <key>widget</key> - <value>counter_slider</value> - <type>enum</type> - <hide>part</hide> - <option><name>Counter + Slider</name><key>counter_slider</key></option> - <option><name>Counter</name><key>counter</key></option> - <option><name>Slider</name><key>slider</key></option> - <option><name>Knob</name><key>dial</key></option> - </param> - - <param> - <name>Orientation</name> - <key>orient</key> - <value>Qt.Horizontal</value> - <type>enum</type> - <hide>#if $widget() == "slider" then 'part' else 'all'#</hide> - <option> - <name>Horizontal</name> - <key>Qt.Horizontal</key> - <opt>scalepos:BottomScale</opt> - <opt>minfcn:setMinimumWidth</opt> - </option> - <option> - <name>Vertical</name> - <key>Qt.Vertical</key> - <opt>scalepos:LeftScale</opt> - <opt>minfcn:setMinimumHeight</opt> - </option> - </param> - - <param> - <name>Minimum Length</name> - <key>min_len</key> - <value>200</value> - <type>int</type> - <hide>part</hide> - </param> - <!-- from min_len <hide>#if $widget().split('_')[0] in ("slider", "counter") then 'part' else 'all'#</hide>--> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - <check>$start <= $value <= $stop</check> - <check>$start < $stop</check> - - <doc> - This block creates a variable with a slider. \ - Leave the label blank to use the variable id as the label. \ - The value must be a real number. \ - The value must be between the start and the stop. - - The GUI hint can be used to position the widget within the application. \ - The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ - Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_sink_x.block.yml b/gr-qtgui/grc/qtgui_sink_x.block.yml new file mode 100644 index 0000000000..30194a7a57 --- /dev/null +++ b/gr-qtgui/grc/qtgui_sink_x.block.yml @@ -0,0 +1,148 @@ +id: qtgui_sink_x +label: QT GUI Sink +flags: has_python + +parameters: +- id: type + label: Type + dtype: enum + default: complex + options: [complex, float] + option_attributes: + fcn: [sink_c, sink_f] + hide: part +- id: name + label: Name + dtype: string + default: '""' +- id: fftsize + label: FFT Size + dtype: int + default: '1024' +- id: wintype + label: Window Type + dtype: int + default: firdes.WIN_BLACKMAN_hARRIS + options: [firdes.WIN_BLACKMAN_hARRIS, firdes.WIN_HAMMING, firdes.WIN_HANN, firdes.WIN_BLACKMAN, + firdes.WIN_RECTANGULAR, firdes.WIN_KAISER] + option_labels: [Blackman-harris, Hamming, Hann, Blackman, Rectangular, Kaiser] + hide: part +- id: fc + label: Center Frequency (Hz) + dtype: real + default: '0' +- id: bw + label: Bandwidth (Hz) + dtype: real + default: samp_rate +- id: rate + label: Update Rate + dtype: real + default: '10' +- id: showrf + label: Show RF Freq + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: plotfreq + label: Plot Frequency + dtype: bool + default: 'True' + options: ['True', 'False'] + option_labels: ['On', 'Off'] + hide: part +- id: plotwaterfall + label: Plot Waterfall + dtype: bool + default: 'True' + options: ['True', 'False'] + option_labels: ['On', 'Off'] + hide: part +- id: plottime + label: Plot Time + dtype: bool + default: 'True' + options: ['True', 'False'] + option_labels: ['On', 'Off'] + hide: part +- id: plotconst + label: Plot Const + dtype: bool + default: 'True' + options: ['True', 'False'] + option_labels: ['On', 'Off'] + hide: part +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +- id: freqchangevar + label: Clicked freq variable + dtype: raw + default: None + hide: part +- id: showports + label: Show Msg Ports + dtype: enum + default: 'True' + options: ['False', 'True'] + option_labels: ['Yes', 'No'] + hide: part + +inputs: +- domain: stream + dtype: ${ type } + multiplicity: ${ num_inputs } +- domain: message + id: freq + optional: true + hide: ${ showports } + +outputs: +- domain: message + id: freq + optional: true + hide: ${ showports } + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import qtgui + from gnuradio.filter import firdes + import sip + callbacks: + - set_frequency_range(${fc}, ${bw}) + make: |- + <% + win = 'self._%s_win'%id + %>\ + qtgui.${type.fcn}( + ${fftsize}, #fftsize + ${wintype}, #wintype + ${fc}, #fc + ${bw}, #bw + ${name}, #name + ${plotfreq}, #plotfreq + ${plotwaterfall}, #plotwaterfall + ${plottime}, #plottime + ${plotconst} #plotconst + ) + self.${id}.set_update_time(1.0/${rate}) + ${win} = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget) + + self.${id}.enable_rf_freq($showrf) + + % if freqchangevar is not None: + def ${id}_callback(p, num): + if num == 1 or num == 2: + self.set_${freqchangevar}(p.x()) + + Qt.QObject.connect(self._${id}_win, Qt.SIGNAL("plotPointSelected(QPointF, int)"), ${id}_callback) + % endif + +documentation: |- + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_sink_x.xml b/gr-qtgui/grc/qtgui_sink_x.xml deleted file mode 100644 index a9bc469cd2..0000000000 --- a/gr-qtgui/grc/qtgui_sink_x.xml +++ /dev/null @@ -1,232 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##QT GUI Sink -################################################### - --> -<block> - <name>QT GUI Sink</name> - <key>qtgui_sink_x</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import qtgui</import> - <import>from gnuradio.filter import firdes</import> - <import>import sip</import> - <make>#set $win = 'self._%s_win'%$id -qtgui.$(type.fcn)( - $fftsize, \#fftsize - $wintype, \#wintype - $fc, \#fc - $bw, \#bw - $name, \#name - $plotfreq, \#plotfreq - $plotwaterfall, \#plotwaterfall - $plottime, \#plottime - $plotconst, \#plotconst -) -self.$(id).set_update_time(1.0/$rate) -self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win)) - -self.$(id).enable_rf_freq($showrf) - -#if $freqchangevar() is not None -def $(id)_callback(p, num): - if num == 1 or num == 2: self.set_$(freqchangevar)(p.x()) - -Qt.QObject.connect(self._$(id)_win, Qt.SIGNAL("plotPointSelected(QPointF, int)"), $(id)_callback ) -#end if - - </make> - <callback>set_frequency_range($fc, $bw)</callback> - - <param> - <name>Type</name> - <key>type</key> - <value>complex</value> - <type>enum</type> - <option><name>Complex</name><key>complex</key><opt>fcn:sink_c</opt></option> - <option><name>Float</name><key>float</key><opt>fcn:sink_f</opt></option> - </param> - - <param> - <name>Name</name> - <key>name</key> - <value>""</value> - <type>string</type> - <hide>#if len($name()) > 0 then 'none' else 'part'#</hide> - </param> - - <param> - <name>FFT Size</name> - <key>fftsize</key> - <value>1024</value> - <type>int</type> - </param> - - <param> - <name>Window Type</name> - <key>wintype</key> - <value>firdes.WIN_BLACKMAN_hARRIS</value> - <type>int</type> - <hide>part</hide> - <option> - <name>Blackman-harris</name> - <key>firdes.WIN_BLACKMAN_hARRIS</key> - </option> - <option> - <name>Hamming</name> - <key>firdes.WIN_HAMMING</key> - </option> - <option> - <name>Hann</name> - <key>firdes.WIN_HANN</key> - </option> - <option> - <name>Blackman</name> - <key>firdes.WIN_BLACKMAN</key> - </option> - <option> - <name>Rectangular</name> - <key>firdes.WIN_RECTANGULAR</key> - </option> - <option> - <name>Kaiser</name> - <key>firdes.WIN_KAISER</key> - </option> - </param> - - <param> - <name>Center Frequency (Hz)</name> - <key>fc</key> - <value>0</value> - <type>real</type> - </param> - - <param> - <name>Bandwidth (Hz)</name> - <key>bw</key> - <value>samp_rate</value> - <type>real</type> - </param> - - <param> - <name>Update Rate</name> - <key>rate</key> - <value>10</value> - <type>real</type> - </param> - - <param> - <name>Show RF Freq</name> - <key>showrf</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Plot Frequency</name> - <key>plotfreq</key> - <value>True</value> - <type>bool</type> - <hide>part</hide> - <option><name>On</name><key>True</key></option> - <option><name>Off</name><key>False</key></option> - </param> - - <param> - <name>Plot Waterfall</name> - <key>plotwaterfall</key> - <value>True</value> - <type>bool</type> - <hide>part</hide> - <option><name>On</name><key>True</key></option> - <option><name>Off</name><key>False</key></option> - </param> - - <param> - <name>Plot Time</name> - <key>plottime</key> - <value>True</value> - <type>bool</type> - <hide>part</hide> - <option><name>On</name><key>True</key></option> - <option><name>Off</name><key>False</key></option> - </param> - - <param> - <name>Plot Const</name> - <key>plotconst</key> - <value>True</value> - <type>bool</type> - <hide>part</hide> - <option><name>On</name><key>True</key></option> - <option><name>Off</name><key>False</key></option> - </param> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - <param> - <name>Clicked freq variable</name> - <key>freqchangevar</key> - <value>None</value> - <type>raw</type> - <hide>part</hide> - </param> - - <param> - <name>Show Msg Ports</name> - <key>showports</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>False</key> - </option> - <option> - <name>No</name> - <key>True</key> - </option> - </param> - - <sink> - <name>in</name> - <type>$type</type> - <nports>$num_inputs</nports> - </sink> - - <sink> - <name>freq</name> - <type>message</type> - <optional>1</optional> - <hide>$showports</hide> - </sink> - - <source> - <name>freq</name> - <type>message</type> - <optional>1</optional> - <hide>$showports</hide> - </source> - - <doc> -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_tab_widget.block.yml b/gr-qtgui/grc/qtgui_tab_widget.block.yml new file mode 100644 index 0000000000..79cbf70cae --- /dev/null +++ b/gr-qtgui/grc/qtgui_tab_widget.block.yml @@ -0,0 +1,141 @@ +id: qtgui_tab_widget +label: QT GUI Tab Widget + +parameters: +- id: num_tabs + label: Num Tabs + dtype: enum + default: '1' + options: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', + '14', '15', '16', '17', '18', '19', '20'] +- id: label0 + label: Label 0 + dtype: string + default: Tab 0 + hide: ${ ('none' if int(num_tabs) > 0 else 'all') } +- id: label1 + label: Label 1 + dtype: string + default: Tab 1 + hide: ${ ('none' if int(num_tabs) > 1 else 'all') } +- id: label2 + label: Label 2 + dtype: string + default: Tab 2 + hide: ${ ('none' if int(num_tabs) > 2 else 'all') } +- id: label3 + label: Label 3 + dtype: string + default: Tab 3 + hide: ${ ('none' if int(num_tabs) > 3 else 'all') } +- id: label4 + label: Label 4 + dtype: string + default: Tab 4 + hide: ${ ('none' if int(num_tabs) > 4 else 'all') } +- id: label5 + label: Label 5 + dtype: string + default: Tab 5 + hide: ${ ('none' if int(num_tabs) > 5 else 'all') } +- id: label6 + label: Label 6 + dtype: string + default: Tab 6 + hide: ${ ('none' if int(num_tabs) > 6 else 'all') } +- id: label7 + label: Label 7 + dtype: string + default: Tab 7 + hide: ${ ('none' if int(num_tabs) > 7 else 'all') } +- id: label8 + label: Label 8 + dtype: string + default: Tab 8 + hide: ${ ('none' if int(num_tabs) > 8 else 'all') } +- id: label9 + label: Label 9 + dtype: string + default: Tab 9 + hide: ${ ('none' if int(num_tabs) > 9 else 'all') } +- id: label10 + label: Label 10 + dtype: string + default: Tab 10 + hide: ${ ('none' if int(num_tabs) > 10 else 'all') } +- id: label11 + label: Label 11 + dtype: string + default: Tab 11 + hide: ${ ('none' if int(num_tabs) > 11 else 'all') } +- id: label12 + label: Label 12 + dtype: string + default: Tab 12 + hide: ${ ('none' if int(num_tabs) > 12 else 'all') } +- id: label13 + label: Label 13 + dtype: string + default: Tab 13 + hide: ${ ('none' if int(num_tabs) > 13 else 'all') } +- id: label14 + label: Label 14 + dtype: string + default: Tab 14 + hide: ${ ('none' if int(num_tabs) > 14 else 'all') } +- id: label15 + label: Label 15 + dtype: string + default: Tab 15 + hide: ${ ('none' if int(num_tabs) > 15 else 'all') } +- id: label16 + label: Label 16 + dtype: string + default: Tab 16 + hide: ${ ('none' if int(num_tabs) > 16 else 'all') } +- id: label17 + label: Label 17 + dtype: string + default: Tab 17 + hide: ${ ('none' if int(num_tabs) > 17 else 'all') } +- id: label18 + label: Label 18 + dtype: string + default: Tab 18 + hide: ${ ('none' if int(num_tabs) > 18 else 'all') } +- id: label19 + label: Label 19 + dtype: string + default: Tab 19 + hide: ${ ('none' if int(num_tabs) > 19 else 'all') } +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part + +templates: + imports: from PyQt5 import Qt + make: |- + <% + win = 'self._%s_win'%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())] + %>\ + Qt.QTabWidget() + % for i, label in enumrate(all_labels): + self.${id}_widget_${i} = Qt.QWidget() + self.${id}_layout_${i} = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.${id}_widget_${i}) + self.${id}_grid_layout_${i} = Qt.QGridLayout() + self.${id}_layout_${i}.addLayout(self.${id}_grid_layout_${i}) + ${win}.addTab(self.${id}_widget_${i}, ${label}) + % 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. + + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_tab_widget.xml b/gr-qtgui/grc/qtgui_tab_widget.xml deleted file mode 100644 index 805542cc8b..0000000000 --- a/gr-qtgui/grc/qtgui_tab_widget.xml +++ /dev/null @@ -1,206 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##WX GUI Notebook -################################################### - --> -<block> - <name>QT GUI Tab Widget</name> - <key>qtgui_tab_widget</key> - <import>from PyQt5 import Qt</import> - <make>#set $win = 'self.%s'%$id -Qt.QTabWidget() -#set $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())] -#for i, label in enumerate($all_labels) -self.$(id)_widget_$(i) = Qt.QWidget() -self.$(id)_layout_$(i) = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.$(id)_widget_$(i)) -self.$(id)_grid_layout_$(i) = Qt.QGridLayout() -self.$(id)_layout_$(i).addLayout(self.$(id)_grid_layout_$(i)) -$(win).addTab(self.$(id)_widget_$(i), $label) -#end for -$(gui_hint()($win))</make> - <param> - <name>Num Tabs</name> - <key>num_tabs</key> - <value>1</value> - <type>enum</type> - <option><name>1</name><key>1</key></option> - <option><name>2</name><key>2</key></option> - <option><name>3</name><key>3</key></option> - <option><name>4</name><key>4</key></option> - <option><name>5</name><key>5</key></option> - <option><name>6</name><key>6</key></option> - <option><name>7</name><key>7</key></option> - <option><name>8</name><key>8</key></option> - <option><name>9</name><key>9</key></option> - <option><name>10</name><key>10</key></option> - <option><name>11</name><key>11</key></option> - <option><name>12</name><key>12</key></option> - <option><name>13</name><key>13</key></option> - <option><name>14</name><key>14</key></option> - <option><name>15</name><key>15</key></option> - <option><name>16</name><key>16</key></option> - <option><name>17</name><key>17</key></option> - <option><name>18</name><key>18</key></option> - <option><name>19</name><key>19</key></option> - <option><name>20</name><key>20</key></option> - </param> - <param> - <name>Label 0</name> - <key>label0</key> - <value>Tab 0</value> - <type>string</type> - <hide>#if int($num_tabs()) > 0 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 1</name> - <key>label1</key> - <value>Tab 1</value> - <type>string</type> - <hide>#if int($num_tabs()) > 1 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 2</name> - <key>label2</key> - <value>Tab 2</value> - <type>string</type> - <hide>#if int($num_tabs()) > 2 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 3</name> - <key>label3</key> - <value>Tab 3</value> - <type>string</type> - <hide>#if int($num_tabs()) > 3 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 4</name> - <key>label4</key> - <value>Tab 4</value> - <type>string</type> - <hide>#if int($num_tabs()) > 4 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 5</name> - <key>label5</key> - <value>Tab 5</value> - <type>string</type> - <hide>#if int($num_tabs()) > 5 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 6</name> - <key>label6</key> - <value>Tab 6</value> - <type>string</type> - <hide>#if int($num_tabs()) > 6 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 7</name> - <key>label7</key> - <value>Tab 7</value> - <type>string</type> - <hide>#if int($num_tabs()) > 7 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 8</name> - <key>label8</key> - <value>Tab 8</value> - <type>string</type> - <hide>#if int($num_tabs()) > 8 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 9</name> - <key>label9</key> - <value>Tab 9</value> - <type>string</type> - <hide>#if int($num_tabs()) > 9 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 10</name> - <key>label10</key> - <value>Tab 10</value> - <type>string</type> - <hide>#if int($num_tabs()) > 10 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 11</name> - <key>label11</key> - <value>Tab 11</value> - <type>string</type> - <hide>#if int($num_tabs()) > 11 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 12</name> - <key>label12</key> - <value>Tab 12</value> - <type>string</type> - <hide>#if int($num_tabs()) > 12 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 13</name> - <key>label13</key> - <value>Tab 13</value> - <type>string</type> - <hide>#if int($num_tabs()) > 13 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 14</name> - <key>label14</key> - <value>Tab 14</value> - <type>string</type> - <hide>#if int($num_tabs()) > 14 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 15</name> - <key>label15</key> - <value>Tab 15</value> - <type>string</type> - <hide>#if int($num_tabs()) > 15 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 16</name> - <key>label16</key> - <value>Tab 16</value> - <type>string</type> - <hide>#if int($num_tabs()) > 16 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 17</name> - <key>label17</key> - <value>Tab 17</value> - <type>string</type> - <hide>#if int($num_tabs()) > 17 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 18</name> - <key>label18</key> - <value>Tab 18</value> - <type>string</type> - <hide>#if int($num_tabs()) > 18 then 'none' else 'all'#</hide> - </param> - <param> - <name>Label 19</name> - <key>label19</key> - <value>Tab 19</value> - <type>string</type> - <hide>#if int($num_tabs()) > 19 then 'none' else 'all'#</hide> - </param> - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - <doc> -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. - -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_time_raster_x.block.yml b/gr-qtgui/grc/qtgui_time_raster_x.block.yml new file mode 100644 index 0000000000..77ae0a4ad1 --- /dev/null +++ b/gr-qtgui/grc/qtgui_time_raster_x.block.yml @@ -0,0 +1,266 @@ +id: qtgui_time_raster_sink_x +label: QT GUI Time Raster Sink + +parameters: +- id: type + label: Type + dtype: enum + default: complex + options: [byte, float, msg_byte, msg_float] + option_labels: [Byte, Float, Byte Message, Float Message] + option_attributes: + fcn: [time_raster_sink_b, time_raster_sink_f, time_raster_sink_b, time_raster_sink_f] + t: [byte, float, message, message] + hide: part +- id: name + label: Name + dtype: string + default: '""' + hide: ${ ('none' if len(name) > 0 else 'part') } +- id: samp_rate + label: Sample Rate + dtype: real + default: samp_rate +- id: nrows + label: Num. Rows + dtype: int + hide: ${ ('all' if type.startswith('msg') else 'none') } +- id: ncols + label: Num. Cols + dtype: int +- id: grid + label: Grid + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: zmin + label: Int. min + dtype: real + default: '-1' + hide: part +- id: zmax + label: Int. max + dtype: real + default: '1' + hide: part +- id: mult + label: Multiplier + dtype: real_vector + default: '[]' + hide: part +- id: offset + label: Offset + dtype: real_vector + default: '[]' + hide: part +- id: nconnections + label: Number of Inputs + dtype: int + default: '1' + hide: ${ ('all' if type.startswith('msg') else 'part') } +- id: update_time + label: Update Period + dtype: real + default: '0.10' + hide: part +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +- id: axislabels + label: Axis Labels + category: Config + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: label1 + label: Line 1 Label + category: Config + dtype: string + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: color1 + label: Line 1 Color + category: Config + dtype: enum + options: ['0', '1', '2', '3', '5', '6'] + option_labels: [Multi Color, White Hot, Black Hot, Incandescent, Sunset, Cool] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: alpha1 + label: Line 1 Alpha + category: Config + dtype: float + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: label2 + label: Line 2 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: color2 + label: Line 2 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: alpha2 + label: Line 2 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: label3 + label: Line 3 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: color3 + label: Line 3 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: alpha3 + label: Line 3 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: label4 + label: Line 4 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: color4 + label: Line 4 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: alpha4 + label: Line 4 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: label5 + label: Line 5 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: color5 + label: Line 5 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: alpha5 + label: Line 5 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: label6 + label: Line 6 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: color6 + label: Line 6 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: alpha6 + label: Line 6 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: label7 + label: Line 7 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: color7 + label: Line 7 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: alpha7 + label: Line 7 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: label8 + label: Line 8 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: color8 + label: Line 8 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: alpha8 + label: Line 8 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: label9 + label: Line 9 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: color9 + label: Line 9 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: alpha9 + label: Line 9 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: label10 + label: Line 10 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: color10 + label: Line 10 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: alpha10 + label: Line 10 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } + +inputs: +- domain: stream + dtype: ${ type.t } + multiplicity: ${ (0 if type.startswith('msg') else nconnections) } + optional: true + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import qtgui + import sip + callbacks: + - set_num_rows(${nrows}) + - set_num_cols(${ncols}) + - set_multiplier(${mult}) + - set_offset(${offset}) + - set_update_time(${update_time}) + - set_title(${which}, ${title}) + - set_color(${which}, ${color}) + make: |- + <% + win = 'self._%s_win'%id + %>\ + qtgui.${type.fcn}( + ${samp_rate}, + ${nrows}, + ${ncols}, + ${mult}, + ${offset}, + ${name}, + ${0 if type.startswith('msg') else nconnections} + ) + + self.${id}.set_update_time(${update_time}) + self.${id}.set_intensity_range(${zmin}, ${zmax}) + self.${id}.enable_grid(${grid}) + self.${id}.enable_axis_labels(${axislabels}) + + labels = [${label1}, ${label2}, ${label3}, ${label4}, ${label5}, + ${label6}, ${label7}, ${label8}, ${label9}, ${label10}] + colors = [${color1}, ${color2}, ${color3}, ${color4}, ${color5}, + ${color6}, ${color7}, ${color8}, ${color9}, ${color10}] + alphas = [${alpha1}, ${alpha2}, ${alpha3}, ${alpha4}, ${alpha5}, + ${alpha6}, ${alpha7}, ${alpha8}, ${alpha9}, ${alpha10}] + + for i in range(${1 if type.startswith('msg') else nconnections}): + if len(labels[i]) == 0: + self.${id}.set_line_label(i, "Data {0}".format(i)) + else: + self.${id}.set_line_label(i, labels[i]) + self.${id}.set_color_map(i, colors[i]) + self.${id}.set_line_alpha(i, alphas[i]) + + ${win} = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget) + ${gui_hint()(win)} + +documentation: |- + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_time_raster_x.xml b/gr-qtgui/grc/qtgui_time_raster_x.xml deleted file mode 100644 index d458f67eb9..0000000000 --- a/gr-qtgui/grc/qtgui_time_raster_x.xml +++ /dev/null @@ -1,466 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##QT GUI Sink -################################################### - --> -<block> - <name>QT GUI Time Raster Sink</name> - <key>qtgui_time_raster_sink_x</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import qtgui</import> - <import>import sip</import> - <make>#set $win = 'self._%s_win'%$id -qtgui.$(type.fcn)( - $samp_rate, - $nrows, - $ncols, - $mult, - $offset, - $name, - #if $type.t == 'message' then 0 else $nconnections#, - ) - -self.$(id).set_update_time($update_time) -self.$(id).set_intensity_range($zmin, $zmax) -self.$(id).enable_grid($grid) -self.$(id).enable_axis_labels($axislabels) - -labels = [$label1, $label2, $label3, $label4, $label5, - $label6, $label7, $label8, $label9, $label10] -colors = [$color1, $color2, $color3, $color4, $color5, - $color6, $color7, $color8, $color9, $color10] -alphas = [$alpha1, $alpha2, $alpha3, $alpha4, $alpha5, - $alpha6, $alpha7, $alpha8, $alpha9, $alpha10] -for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): - if len(labels[i]) == 0: - self.$(id).set_line_label(i, "Data {0}".format(i)) - else: - self.$(id).set_line_label(i, labels[i]) - self.$(id).set_color_map(i, colors[i]) - self.$(id).set_line_alpha(i, alphas[i]) - -self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> - <callback>set_num_rows($nrows)</callback> - <callback>set_num_cols($ncols)</callback> - <callback>set_multiplier($mult)</callback> - <callback>set_offset($offset)</callback> - <callback>set_update_time($update_time)</callback> - <callback>set_title($which, $title)</callback> - <callback>set_color($which, $color)</callback> - - <param_tab_order> - <tab>General</tab> - <tab>Config</tab> - </param_tab_order> - - <param> - <name>Type</name> - <key>type</key> - <value>complex</value> - <type>enum</type> - <option> - <name>Byte</name> - <key>byte</key> - <opt>fcn:time_raster_sink_b</opt> - <opt>t:byte</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:time_raster_sink_f</opt> - <opt>t:float</opt> - </option> - <option> - <name>Byte Message</name> - <key>msg_byte</key> - <opt>fcn:time_raster_sink_b</opt> - <opt>t:message</opt> - </option> - <option> - <name>Float Message</name> - <key>msg_float</key> - <opt>fcn:time_raster_sink_f</opt> - <opt>t:message</opt> - </option> - </param> - - <param> - <name>Name</name> - <key>name</key> - <value>""</value> - <type>string</type> - <hide>#if len($name()) > 0 then 'none' else 'part'#</hide> - </param> - - <param> - <name>Sample Rate</name> - <key>samp_rate</key> - <value>samp_rate</value> - <type>real</type> - </param> - - <param> - <name>Num. Rows</name> - <key>nrows</key> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'none'#</hide> - </param> - - <param> - <name>Num. Cols</name> - <key>ncols</key> - <type>int</type> - </param> - - <param> - <name>Grid</name> - <key>grid</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Int. min</name> - <key>zmin</key> - <value>-1</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>Int. max</name> - <key>zmax</key> - <value>1</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>Multiplier</name> - <key>mult</key> - <value>[]</value> - <type>real_vector</type> - <hide>part</hide> - </param> - - <param> - <name>Offset</name> - <key>offset</key> - <value>[]</value> - <type>real_vector</type> - <hide>part</hide> - </param> - - <param> - <name>Number of Inputs</name> - <key>nconnections</key> - <value>1</value> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'part'#</hide> - </param> - - <param> - <name>Update Period</name> - <key>update_time</key> - <value>0.10</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - <param> - <name>Axis Labels</name> - <key>axislabels</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Label</name> - <key>label1</key> - <type>string</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Color</name> - <key>color1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Multi Color</name> - <key>0</key> - </option> - <option> - <name>White Hot</name> - <key>1</key> - </option> - <option> - <name>Black Hot</name> - <key>2</key> - </option> - <option> - <name>Incandescent</name> - <key>3</key> - </option> - <option> - <name>Sunset</name> - <key>5</key> - </option> - <option> - <name>Cool</name> - <key>6</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Alpha</name> - <key>alpha1</key> - <value>1.0</value> - <type>float</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 2 Label</name> - <key>label2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 2 Color</name> - <key>color2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 2 Alpha</name> - <key>alpha2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 3 Label</name> - <key>label3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 3 Color</name> - <key>color3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 3 Alpha</name> - <key>alpha3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 4 Label</name> - <key>label4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 4 Color</name> - <key>color4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 4 Alpha</name> - <key>alpha4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 5 Label</name> - <key>label5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 5 Color</name> - <key>color5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 5 Alpha</name> - <key>alpha5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 6 Label</name> - <key>label6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 6 Color</name> - <key>color6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 6 Alpha</name> - <key>alpha6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 7 Label</name> - <key>label7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 7 Color</name> - <key>color7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 7 Alpha</name> - <key>alpha7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 8 Label</name> - <key>label8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 8 Color</name> - <key>color8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 8 Alpha</name> - <key>alpha8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 9 Label</name> - <key>label9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 9 Color</name> - <key>color9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 9 Alpha</name> - <key>alpha9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 10 Label</name> - <key>label10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 10 Color</name> - <key>color10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 10 Alpha</name> - <key>alpha10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - - <sink> - <name>in</name> - <type>$type.t</type> - <nports>#if $type.t == 'message' then 0 else $nconnections#</nports> - <optional>1</optional> - </sink> - - <doc> -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_time_sink_x.block.yml b/gr-qtgui/grc/qtgui_time_sink_x.block.yml new file mode 100644 index 0000000000..dfe53527eb --- /dev/null +++ b/gr-qtgui/grc/qtgui_time_sink_x.block.yml @@ -0,0 +1,559 @@ +id: qtgui_time_sink_x +label: QT GUI Time Sink + +parameters: +- id: type + label: Type + dtype: enum + default: complex + options: [complex, float, msg_complex, msg_float] + option_labels: [Complex, Float, Complex Message, Float Message] + option_attributes: + fcn: [time_sink_c, time_sink_f, time_sink_c, time_sink_f] + t: [complex, float, message, message] + hide: part +- id: name + label: Name + dtype: string + default: '""' + hide: ${ ('none' if len(name) > 0 else 'part') } +- id: ylabel + label: Y Axis Label + dtype: string + default: Amplitude + hide: part +- id: yunit + label: Y Axis Unit + dtype: string + default: '""' + hide: part +- id: size + label: Number of Points + dtype: int + default: '1024' + hide: ${ ('all' if type.startswith('msg') else 'none') } +- id: srate + label: Sample Rate + dtype: float + default: samp_rate +- id: grid + label: Grid + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: autoscale + label: Autoscale + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] +- id: ymin + label: Y min + dtype: float + default: '-1' + hide: part +- id: ymax + label: Y max + dtype: float + default: '1' + hide: part +- id: nconnections + label: Number of Inputs + dtype: int + default: '1' + hide: ${ ('all' if type.startswith('msg') else 'part') } +- id: update_time + label: Update Period + dtype: float + default: '0.10' + hide: part +- id: entags + label: Disp. Tags + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: ${ ('all' if type.startswith('msg') else 'part') } +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +- id: tr_mode + label: Trigger Mode + category: Trigger + dtype: enum + default: qtgui.TRIG_MODE_FREE + options: [qtgui.TRIG_MODE_FREE, qtgui.TRIG_MODE_AUTO, qtgui.TRIG_MODE_NORM, qtgui.TRIG_MODE_TAG] + option_labels: [Free, Auto, Normal, Tag] + hide: part +- id: tr_slope + label: Trigger Slope + category: Trigger + dtype: enum + default: qtgui.TRIG_MODE_POS + options: [qtgui.TRIG_SLOPE_POS, qtgui.TRIG_SLOPE_NEG] + option_labels: [Positive, Negative] + hide: part +- id: tr_level + label: Trigger Level + category: Trigger + dtype: float + default: '0.0' + hide: part +- id: tr_delay + label: Trigger Delay + category: Trigger + dtype: float + default: '0' + hide: part +- id: tr_chan + label: Trigger Channel + category: Trigger + dtype: int + default: '0' + hide: part +- id: tr_tag + label: Trigger Tag Key + category: Trigger + dtype: string + default: '""' + hide: part +- id: ctrlpanel + label: Control Panel + category: Config + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: legend + label: Legend + category: Config + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: axislabels + label: Axis Labels + category: Config + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: label1 + label: Line 1 Label + category: Config + dtype: string + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: width1 + label: Line 1 Width + category: Config + dtype: int + default: '1' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: color1 + label: Line 1 Color + category: Config + dtype: enum + options: ['"blue"', '"red"', '"green"', '"black"', '"cyan"', '"magenta"', '"yellow"', + '"dark red"', '"dark green"', '"Dark Blue"'] + option_labels: [Blue, Red, Green, Black, Cyan, Magenta, Yellow, Dark Red, Dark + Green, Dark Blue] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: style1 + label: Line 1 Style + category: Config + dtype: enum + options: ['1', '2', '3', '4', '5', '0'] + option_labels: [Solid, Dash, Dots, Dash-Dot, Dash-Dot-Dot, None] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: marker1 + label: Line 1 Marker + category: Config + dtype: enum + options: ['-1', '0', '1', '2', '3', '4', '6', '7', '8', '9'] + option_labels: [None, Circle, Rectangle, Diamond, Triangle, Down Triangle, Left + Triangle, Right Triangle, Cross, X-Cross] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: alpha1 + label: Line 1 Alpha + category: Config + dtype: float + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: label2 + label: Line 2 Label + dtype: '' + hide: ${ ('part' if (int(nconnections) >= 2 or (type == "complex" and int(nconnections) + >= 1) or (type == "msg_complex")) and (not type == "msg_float") else 'all') + } +- id: width2 + label: Line 2 Width + dtype: '' + hide: ${ ('part' if (int(nconnections) >= 2 or (type == "complex" and int(nconnections) + >= 1) or (type == "msg_complex")) and (not type == "msg_float") else 'all') + } +- id: color2 + label: Line 2 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if (int(nconnections) >= 2 or (type == "complex" and int(nconnections) + >= 1) or (type == "msg_complex")) and (not type == "msg_float") else 'all') + } +- id: style2 + label: Line 2 Style + dtype: '' + hide: ${ ('part' if (int(nconnections) >= 2 or (type == "complex" and int(nconnections) + >= 1) or (type == "msg_complex")) and (not type == "msg_float") else 'all') + } +- id: marker2 + label: Line 2 Marker + dtype: '' + hide: ${ ('part' if (int(nconnections) >= 2 or (type == "complex" and int(nconnections) + >= 1) or (type == "msg_complex")) and (not type == "msg_float") else 'all') + } +- id: alpha2 + label: Line 2 Alpha + dtype: '' + hide: ${ ('part' if (int(nconnections) >= 2 or (type == "complex" and int(nconnections) + >= 1) or (type == "msg_complex")) and (not type == "msg_float") else 'all') + } +- id: label3 + label: Line 3 Label + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 3 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: width3 + label: Line 3 Width + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 3 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: color3 + label: Line 3 Color + dtype: '' + default: '"green"' + hide: ${ ('part' if ((int(nconnections) >= 3 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: style3 + label: Line 3 Style + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 3 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: marker3 + label: Line 3 Marker + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 3 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: alpha3 + label: Line 3 Alpha + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 3 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: label4 + label: Line 4 Label + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 4 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: width4 + label: Line 4 Width + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 4 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: color4 + label: Line 4 Color + dtype: '' + default: '"black"' + hide: ${ ('part' if ((int(nconnections) >= 4 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: style4 + label: Line 4 Style + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 4 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: marker4 + label: Line 4 Marker + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 4 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: alpha4 + label: Line 4 Alpha + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 4 or (type == "complex" and int(nconnections) + >= 2)) and not type.t == "message") else 'all') } +- id: label5 + label: Line 5 Label + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 5 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: width5 + label: Line 5 Width + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 5 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: color5 + label: Line 5 Color + dtype: '' + default: '"cyan"' + hide: ${ ('part' if ((int(nconnections) >= 5 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: style5 + label: Line 5 Style + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 5 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: marker5 + label: Line 5 Marker + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 5 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: alpha5 + label: Line 5 Alpha + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 5 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: label6 + label: Line 6 Label + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 6 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: width6 + label: Line 6 Width + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 6 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: color6 + label: Line 6 Color + dtype: '' + default: '"magenta"' + hide: ${ ('part' if ((int(nconnections) >= 6 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: style6 + label: Line 6 Style + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 6 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: marker6 + label: Line 6 Marker + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 6 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: alpha6 + label: Line 6 Alpha + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 6 or (type == "complex" and int(nconnections) + >= 3)) and not type.t == "message") else 'all') } +- id: label7 + label: Line 7 Label + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 7 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: width7 + label: Line 7 Width + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 7 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: color7 + label: Line 7 Color + dtype: '' + default: '"yellow"' + hide: ${ ('part' if ((int(nconnections) >= 7 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: style7 + label: Line 7 Style + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 7 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: marker7 + label: Line 7 Marker + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 7 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: alpha7 + label: Line 7 Alpha + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 7 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: label8 + label: Line 8 Label + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 8 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: width8 + label: Line 8 Width + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 8 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: color8 + label: Line 8 Color + dtype: '' + default: '"dark red"' + hide: ${ ('part' if ((int(nconnections) >= 8 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: style8 + label: Line 8 Style + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 8 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: marker8 + label: Line 8 Marker + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 8 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: alpha8 + label: Line 8 Alpha + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 8 or (type == "complex" and int(nconnections) + >= 4)) and not type.t == "message") else 'all') } +- id: label9 + label: Line 9 Label + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 9 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } +- id: width9 + label: Line 9 Width + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 9 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } +- id: color9 + label: Line 9 Color + dtype: '' + default: '"dark green"' + hide: ${ ('part' if ((int(nconnections) >= 9 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } +- id: style9 + label: Line 9 Style + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 9 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } +- id: marker9 + label: Line 9 Marker + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 9 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } +- id: alpha9 + label: Line 9 Alpha + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 9 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } +- id: label10 + label: Line 10 Label + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 10 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } +- id: width10 + label: Line 10 Width + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 10 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } +- id: color10 + label: Line 10 Color + dtype: '' + default: '"dark blue"' + hide: ${ ('part' if ((int(nconnections) >= 10 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } +- id: style10 + label: Line 10 Style + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 10 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } +- id: marker10 + label: Line 10 Marker + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 10 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } +- id: alpha10 + label: Line 10 Alpha + dtype: '' + hide: ${ ('part' if ((int(nconnections) >= 10 or (type == "complex" and int(nconnections) + >= 5)) and not type.t == "message") else 'all') } + +asserts: +- ${nconnections <= (5 if type == 'complex' else 10)} + +inputs: +- domain: stream + dtype: ${ type.t } + multiplicity: ${ (0 if type.startswith('msg') else nconnections) } + optional: true + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import qtgui + from gnuradio.filter import firdes + import sip + callbacks: + - set_time_domain_axis(${min}, ${max}) + - set_update_time(${update_time}) + - set_title(${which}, ${title}) + - set_color(${which}, ${color}) + - set_y_axis(${ymin}, ${ymax}) + - set_samp_rate(${srate}) + - self.${id}.set_trigger_mode(${tr_mode}, ${tr_slope}, ${tr_level}, ${tr_delay}, + ${tr_chan}, ${tr_tag}) + make: |- + <% + win = 'self._%s_win'%id + %>\ + qtgui.${type.fcn}( + ${size}, #size + ${srate}, #samp_rate + ${name}, #name + ${0 if type.startswith('msg') else nconnections} #number of inputs + ) + self.${id}.set_update_time(${update_time}) + self.${id}.set_y_axis(${ymin}, ${ymax}) + + self.${id}.set_y_label(${ylabel}, ${yunit}) + + self.${id}.enable_tags(-1, ${entags}) + self.${id}.set_trigger_mode(${tr_mode}, ${tr_slope}, ${tr_level}, ${tr_delay}, ${tr_chan}, ${tr_tag}) + self.${id}.enable_autoscale(${autoscale}) + self.${id}.enable_grid(${grid}) + self.${id}.enable_axis_labels(${axislabels}) + self.${id}.enable_control_panel(${ctrlpanel}) + + if not ${legend}: + self.${id}.disable_legend() + + labels = [${label1}, ${label2}, ${label3}, ${label4}, ${label5}, + ${label6}, ${label7}, ${label8}, ${label9}, ${label10}] + widths = [${width1}, ${width2}, ${width3}, ${width4}, ${width5}, + ${width6}, ${width7}, ${width8}, ${width9}, ${width10}] + colors = [${color1}, ${color2}, ${color3}, ${color4}, ${color5}, + ${color6}, ${color7}, ${color8}, ${color9}, ${color10}] + alphas = [${alpha1}, ${alpha2}, ${alpha3}, ${alpha4}, ${alpha5}, + ${alpha6}, ${alpha7}, ${alpha8}, ${alpha9}, ${alpha10}] + styles = [${style1}, ${style2}, ${style3}, ${style4}, ${style5}, + ${style6}, ${style7}, ${style8}, ${style9}, ${style10}] + markers = [${marker1}, ${marker2}, ${marker3}, ${marker4}, ${marker5}, + ${marker6}, ${marker7}, ${marker8}, ${marker9}, ${marker10}] + + + % if type.endswith('complex'): + for i in range(${2 if type.startswith('msg') else 2*nconnections}): + if len(labels[i]) == 0: + if (i % 2 == 0): + self.${id}.set_line_label(i, "Re{{Data {0}}}".format(i/2)) + else: + self.${id}.set_line_label(i, "Im{{Data {0}}}".format(i/2)) + else: + self.${id}.set_line_label(i, labels[i]) + self.${id].set_line_width(i, widths[i]) + self.${id].set_line_color(i, colors[i]) + self.${id].set_line_style(i, styles[i]) + self.${id].set_line_marker(i, markers[i]) + self.${id].set_line_alpha(i, alphas[i]) + % endif + + ${win} = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget) + ${gui_hint()(win)} + +documentation: |- + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_time_sink_x.xml b/gr-qtgui/grc/qtgui_time_sink_x.xml deleted file mode 100644 index d4347950ea..0000000000 --- a/gr-qtgui/grc/qtgui_time_sink_x.xml +++ /dev/null @@ -1,948 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##QT GUI Sink -################################################### - --> -<block> - <name>QT GUI Time Sink</name> - <key>qtgui_time_sink_x</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import qtgui</import> - <import>from gnuradio.filter import firdes</import> - <import>import sip</import> - <make>#set $win = 'self._%s_win'%$id -qtgui.$(type.fcn)( - $size, \#size - $srate, \#samp_rate - $name, \#name - #if $type.t == 'message' then 0 else $nconnections# \#number of inputs -) -self.$(id).set_update_time($update_time) -self.$(id).set_y_axis($ymin, $ymax) - -self.$(id).set_y_label($ylabel, $yunit) - -self.$(id).enable_tags(-1, $entags) -self.$(id).set_trigger_mode($tr_mode, $tr_slope, $tr_level, $tr_delay, $tr_chan, $tr_tag) -self.$(id).enable_autoscale($autoscale) -self.$(id).enable_grid($grid) -self.$(id).enable_axis_labels($axislabels) -self.$(id).enable_control_panel($ctrlpanel) - -if not $legend: - self.$(id).disable_legend() - -labels = [$label1, $label2, $label3, $label4, $label5, - $label6, $label7, $label8, $label9, $label10] -widths = [$width1, $width2, $width3, $width4, $width5, - $width6, $width7, $width8, $width9, $width10] -colors = [$color1, $color2, $color3, $color4, $color5, - $color6, $color7, $color8, $color9, $color10] -styles = [$style1, $style2, $style3, $style4, $style5, - $style6, $style7, $style8, $style9, $style10] -markers = [$marker1, $marker2, $marker3, $marker4, $marker5, - $marker6, $marker7, $marker8, $marker9, $marker10] -alphas = [$alpha1, $alpha2, $alpha3, $alpha4, $alpha5, - $alpha6, $alpha7, $alpha8, $alpha9, $alpha10] - -#if ($type() == 'complex' or $type() == 'msg_complex') -for i in xrange(#if $type.t == 'message' then 2 else 2*$nconnections()#): - if len(labels[i]) == 0: - if(i % 2 == 0): - self.$(id).set_line_label(i, "Re{{Data {0}}}".format(i/2)) - else: - self.$(id).set_line_label(i, "Im{{Data {0}}}".format(i/2)) - else: - self.$(id).set_line_label(i, labels[i]) - self.$(id).set_line_width(i, widths[i]) - self.$(id).set_line_color(i, colors[i]) - self.$(id).set_line_style(i, styles[i]) - self.$(id).set_line_marker(i, markers[i]) - self.$(id).set_line_alpha(i, alphas[i]) -#else -for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): - if len(labels[i]) == 0: - self.$(id).set_line_label(i, "Data {0}".format(i)) - else: - self.$(id).set_line_label(i, labels[i]) - self.$(id).set_line_width(i, widths[i]) - self.$(id).set_line_color(i, colors[i]) - self.$(id).set_line_style(i, styles[i]) - self.$(id).set_line_marker(i, markers[i]) - self.$(id).set_line_alpha(i, alphas[i]) -#end if - -self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> - <callback>set_time_domain_axis($min, $max)</callback> - <callback>set_update_time($update_time)</callback> - <callback>set_title($which, $title)</callback> - <callback>set_color($which, $color)</callback> - <callback>set_y_axis($ymin, $ymax)</callback> - <callback>set_samp_rate($srate)</callback> - <callback>self.$(id).set_trigger_mode($tr_mode, $tr_slope, $tr_level, $tr_delay, $tr_chan, $tr_tag)</callback> - - <param_tab_order> - <tab>General</tab> - <tab>Trigger</tab> - <tab>Config</tab> - </param_tab_order> - - <param> - <name>Type</name> - <key>type</key> - <value>complex</value> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:time_sink_c</opt> - <opt>t:complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:time_sink_f</opt> - <opt>t:float</opt> - </option> - <option> - <name>Complex Message</name> - <key>msg_complex</key> - <opt>fcn:time_sink_c</opt> - <opt>t:message</opt> - </option> - <option> - <name>Float Message</name> - <key>msg_float</key> - <opt>fcn:time_sink_f</opt> - <opt>t:message</opt> - </option> - </param> - - <param> - <name>Name</name> - <key>name</key> - <value>""</value> - <type>string</type> - <hide>#if len($name()) > 0 then 'none' else 'part'#</hide> - </param> - - <param> - <name>Y Axis Label</name> - <key>ylabel</key> - <value>Amplitude</value> - <type>string</type> - <hide>part</hide> - </param> - - <param> - <name>Y Axis Unit</name> - <key>yunit</key> - <value>""</value> - <type>string</type> - <hide>part</hide> - </param> - - <param> - <name>Number of Points</name> - <key>size</key> - <value>1024</value> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'none'#</hide> - </param> - - <param> - <name>Sample Rate</name> - <key>srate</key> - <value>samp_rate</value> - <type>float</type> - </param> - - <param> - <name>Grid</name> - <key>grid</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Autoscale</name> - <key>autoscale</key> - <value>False</value> - <type>enum</type> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Y min</name> - <key>ymin</key> - <value>-1</value> - <type>float</type> - <hide>part</hide> - </param> - - <param> - <name>Y max</name> - <key>ymax</key> - <value>1</value> - <type>float</type> - <hide>part</hide> - </param> - - <param> - <name>Number of Inputs</name> - <key>nconnections</key> - <value>1</value> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'part'#</hide> - </param> - - <param> - <name>Update Period</name> - <key>update_time</key> - <value>0.10</value> - <type>float</type> - <hide>part</hide> - </param> - - <param> - <name>Disp. Tags</name> - <key>entags</key> - <value>True</value> - <type>enum</type> - <hide>#if $type.t == 'message' then 'all' else 'part'#</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - - <param> - <name>Trigger Mode</name> - <key>tr_mode</key> - <value>qtgui.TRIG_MODE_FREE</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Free</name> - <key>qtgui.TRIG_MODE_FREE</key> - </option> - <option> - <name>Auto</name> - <key>qtgui.TRIG_MODE_AUTO</key> - </option> - <option> - <name>Normal</name> - <key>qtgui.TRIG_MODE_NORM</key> - </option> - <option> - <name>Tag</name> - <key>qtgui.TRIG_MODE_TAG</key> - </option> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Slope</name> - <key>tr_slope</key> - <value>qtgui.TRIG_MODE_POS</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Positive</name> - <key>qtgui.TRIG_SLOPE_POS</key> - </option> - <option> - <name>Negative</name> - <key>qtgui.TRIG_SLOPE_NEG</key> - </option> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Level</name> - <key>tr_level</key> - <value>0.0</value> - <type>float</type> - <hide>part</hide> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Delay</name> - <key>tr_delay</key> - <value>0</value> - <type>float</type> - <hide>part</hide> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Channel</name> - <key>tr_chan</key> - <value>0</value> - <type>int</type> - <hide>part</hide> - <tab>Trigger</tab> - </param> - - <param> - <name>Trigger Tag Key</name> - <key>tr_tag</key> - <value>""</value> - <type>string</type> - <hide>part</hide> - <tab>Trigger</tab> - </param> - - - - <!-- Begin Config Tab items --> - - <param> - <name>Control Panel</name> - <key>ctrlpanel</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Legend</name> - <key>legend</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Axis Labels</name> - <key>axislabels</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Label</name> - <key>label1</key> - <type>string</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Width</name> - <key>width1</key> - <value>1</value> - <type>int</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Color</name> - <key>color1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Blue</name> - <key>"blue"</key> - </option> - <option> - <name>Red</name> - <key>"red"</key> - </option> - <option> - <name>Green</name> - <key>"green"</key> - </option> - <option> - <name>Black</name> - <key>"black"</key> - </option> - <option> - <name>Cyan</name> - <key>"cyan"</key> - </option> - <option> - <name>Magenta</name> - <key>"magenta"</key> - </option> - <option> - <name>Yellow</name> - <key>"yellow"</key> - </option> - <option> - <name>Dark Red</name> - <key>"dark red"</key> - </option> - <option> - <name>Dark Green</name> - <key>"dark green"</key> - </option> - <option> - <name>Dark Blue</name> - <key>"Dark Blue"</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Style</name> - <key>style1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Solid</name> - <key>1</key> - </option> - <option> - <name>Dash</name> - <key>2</key> - </option> - <option> - <name>Dots</name> - <key>3</key> - </option> - <option> - <name>Dash-Dot</name> - <key>4</key> - </option> - <option> - <name>Dash-Dot-Dot</name> - <key>5</key> - </option> - <option> - <name>None</name> - <key>0</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Marker</name> - <key>marker1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>None</name> - <key>-1</key> - </option> - <option> - <name>Circle</name> - <key>0</key> - </option> - <option> - <name>Rectangle</name> - <key>1</key> - </option> - <option> - <name>Diamond</name> - <key>2</key> - </option> - <option> - <name>Triangle</name> - <key>3</key> - </option> - <option> - <name>Down Triangle</name> - <key>4</key> - </option> - <option> - <name>Left Triangle</name> - <key>6</key> - </option> - <option> - <name>Right Triangle</name> - <key>7</key> - </option> - <option> - <name>Cross</name> - <key>8</key> - </option> - <option> - <name>X-Cross</name> - <key>9</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Alpha</name> - <key>alpha1</key> - <value>1.0</value> - <type>float</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - - - <param> - <base_key>label1</base_key> - <name>Line 2 Label</name> - <key>label2</key> - <hide>#if (int($nconnections()) >= 2 or ($type() == "complex" and int($nconnections()) >= 1) or ($type() == "msg_complex")) and (not $type() == "msg_float") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 2 Width</name> - <key>width2</key> - <hide>#if (int($nconnections()) >= 2 or ($type() == "complex" and int($nconnections()) >= 1) or ($type() == "msg_complex")) and (not $type() == "msg_float") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 2 Color</name> - <key>color2</key> - <value>"red"</value> - <hide>#if (int($nconnections()) >= 2 or ($type() == "complex" and int($nconnections()) >= 1) or ($type() == "msg_complex")) and (not $type() == "msg_float") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 2 Style</name> - <key>style2</key> - <hide>#if (int($nconnections()) >= 2 or ($type() == "complex" and int($nconnections()) >= 1) or ($type() == "msg_complex")) and (not $type() == "msg_float") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 2 Marker</name> - <key>marker2</key> - <hide>#if (int($nconnections()) >= 2 or ($type() == "complex" and int($nconnections()) >= 1) or ($type() == "msg_complex")) and (not $type() == "msg_float") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 2 Alpha</name> - <key>alpha2</key> - <hide>#if (int($nconnections()) >= 2 or ($type() == "complex" and int($nconnections()) >= 1) or ($type() == "msg_complex")) and (not $type() == "msg_float") then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 3 Label</name> - <key>label3</key> - <hide>#if ((int($nconnections()) >= 3 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 3 Width</name> - <key>width3</key> - <hide>#if ((int($nconnections()) >= 3 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 3 Color</name> - <key>color3</key> - <value>"green"</value> - <hide>#if ((int($nconnections()) >= 3 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 3 Style</name> - <key>style3</key> - <hide>#if ((int($nconnections()) >= 3 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 3 Marker</name> - <key>marker3</key> - <hide>#if ((int($nconnections()) >= 3 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 3 Alpha</name> - <key>alpha3</key> - <hide>#if ((int($nconnections()) >= 3 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 4 Label</name> - <key>label4</key> - <hide>#if ((int($nconnections()) >= 4 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 4 Width</name> - <key>width4</key> - <hide>#if ((int($nconnections()) >= 4 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 4 Color</name> - <key>color4</key> - <value>"black"</value> - <hide>#if ((int($nconnections()) >= 4 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 4 Style</name> - <key>style4</key> - <hide>#if ((int($nconnections()) >= 4 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 4 Marker</name> - <key>marker4</key> - <hide>#if ((int($nconnections()) >= 4 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 4 Alpha</name> - <key>alpha4</key> - <hide>#if ((int($nconnections()) >= 4 or ($type() == "complex" and int($nconnections()) >= 2)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 5 Label</name> - <key>label5</key> - <hide>#if ((int($nconnections()) >= 5 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 5 Width</name> - <key>width5</key> - <hide>#if ((int($nconnections()) >= 5 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 5 Color</name> - <key>color5</key> - <value>"cyan"</value> - <hide>#if ((int($nconnections()) >= 5 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 5 Style</name> - <key>style5</key> - <hide>#if ((int($nconnections()) >= 5 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 5 Marker</name> - <key>marker5</key> - <hide>#if ((int($nconnections()) >= 5 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 5 Alpha</name> - <key>alpha5</key> - <hide>#if ((int($nconnections()) >= 5 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 6 Label</name> - <key>label6</key> - <hide>#if ((int($nconnections()) >= 6 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 6 Width</name> - <key>width6</key> - <hide>#if ((int($nconnections()) >= 6 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 6 Color</name> - <key>color6</key> - <value>"magenta"</value> - <hide>#if ((int($nconnections()) >= 6 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 6 Style</name> - <key>style6</key> - <hide>#if ((int($nconnections()) >= 6 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 6 Marker</name> - <key>marker6</key> - <hide>#if ((int($nconnections()) >= 6 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 6 Alpha</name> - <key>alpha6</key> - <hide>#if ((int($nconnections()) >= 6 or ($type() == "complex" and int($nconnections()) >= 3)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 7 Label</name> - <key>label7</key> - <hide>#if ((int($nconnections()) >= 7 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 7 Width</name> - <key>width7</key> - <hide>#if ((int($nconnections()) >= 7 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 7 Color</name> - <key>color7</key> - <value>"yellow"</value> - <hide>#if ((int($nconnections()) >= 7 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 7 Style</name> - <key>style7</key> - <hide>#if ((int($nconnections()) >= 7 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 7 Marker</name> - <key>marker7</key> - <hide>#if ((int($nconnections()) >= 7 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 7 Alpha</name> - <key>alpha7</key> - <hide>#if ((int($nconnections()) >= 7 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 8 Label</name> - <key>label8</key> - <hide>#if ((int($nconnections()) >= 8 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 8 Width</name> - <key>width8</key> - <hide>#if ((int($nconnections()) >= 8 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 8 Color</name> - <key>color8</key> - <value>"dark red"</value> - <hide>#if ((int($nconnections()) >= 8 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 8 Style</name> - <key>style8</key> - <hide>#if ((int($nconnections()) >= 8 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 8 Marker</name> - <key>marker8</key> - <hide>#if ((int($nconnections()) >= 8 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 8 Alpha</name> - <key>alpha8</key> - <hide>#if ((int($nconnections()) >= 8 or ($type() == "complex" and int($nconnections()) >= 4)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 9 Label</name> - <key>label9</key> - <hide>#if ((int($nconnections()) >= 9 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 9 Width</name> - <key>width9</key> - <hide>#if ((int($nconnections()) >= 9 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 9 Color</name> - <key>color9</key> - <value>"dark green"</value> - <hide>#if ((int($nconnections()) >= 9 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 9 Style</name> - <key>style9</key> - <hide>#if ((int($nconnections()) >= 9 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 9 Marker</name> - <key>marker9</key> - <hide>#if ((int($nconnections()) >= 9 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 9 Alpha</name> - <key>alpha9</key> - <hide>#if ((int($nconnections()) >= 9 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 10 Label</name> - <key>label10</key> - <hide>#if ((int($nconnections()) >= 10 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 10 Width</name> - <key>width10</key> - <hide>#if ((int($nconnections()) >= 10 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 10 Color</name> - <key>color10</key> - <value>"dark blue"</value> - <hide>#if ((int($nconnections()) >= 10 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>style1</base_key> - <name>Line 10 Style</name> - <key>style10</key> - <hide>#if ((int($nconnections()) >= 10 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>marker1</base_key> - <name>Line 10 Marker</name> - <key>marker10</key> - <hide>#if ((int($nconnections()) >= 10 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 10 Alpha</name> - <key>alpha10</key> - <hide>#if ((int($nconnections()) >= 10 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> - </param> - - <check>$nconnections <= #if $type() == "complex" then 5 else 10#</check> - - <sink> - <name>in</name> - <type>$type.t</type> - <nports>#if $type.t == 'message' then 0 else $nconnections#</nports> - <optional>1</optional> - </sink> - - <doc> -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_vector_sink_f.block.yml b/gr-qtgui/grc/qtgui_vector_sink_f.block.yml new file mode 100644 index 0000000000..d30349dceb --- /dev/null +++ b/gr-qtgui/grc/qtgui_vector_sink_f.block.yml @@ -0,0 +1,352 @@ +id: qtgui_vector_sink_f +label: QT GUI Vector Sink + +parameters: +- id: name + label: Name + dtype: string + default: '""' + hide: ${ ('none' if len(name) > 0 else 'part') } +- id: vlen + label: Vector Size + dtype: int + default: '1024' + hide: ${ 'part' if vlen == 1 else 'none' } +- id: x_start + label: X-Axis Start Value + dtype: real + default: '0' +- id: x_step + label: X-Axis Step Value + dtype: real + default: '1.0' +- id: x_axis_label + label: X-Axis Label + dtype: string + default: '"x-Axis"' + hide: ${ ('none' if (len(x_axis_label) > 0 and x_axis_label != "x-Axis") else + 'part') } +- id: y_axis_label + label: Y-Axis Label + dtype: string + default: '"y-Axis"' + hide: ${ ('none' if (len(y_axis_label) > 0 and y_axis_label != "y-Axis") else + 'part') } +- id: x_units + label: X-Axis Units + dtype: string + default: '""' + hide: '''part''' +- id: y_units + label: Y-Axis Units + dtype: string + default: '""' + hide: '''part''' +- id: ref_level + label: Ref Level + dtype: real + default: '0' +- id: grid + label: Grid + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: autoscale + label: Autoscale + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: average + label: Average + dtype: enum + default: 'False' + options: ['1.0', '0.2', '0.1', '0.05'] + option_labels: [None, Low, Medium, High] + hide: part +- id: ymin + label: Y min + dtype: real + default: '-140' + hide: part +- id: ymax + label: Y max + dtype: real + default: '10' + hide: part +- id: nconnections + label: Number of Inputs + dtype: int + default: '1' + hide: part +- id: update_time + label: Update Period + dtype: real + default: '0.10' + hide: part +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +- id: showports + label: Show Msg Ports + dtype: enum + default: 'True' + options: ['False', 'True'] + option_labels: ['Yes', 'No'] + hide: part +- id: label1 + label: Line 1 Label + category: Config + dtype: string + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: width1 + label: Line 1 Width + category: Config + dtype: int + default: '1' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: color1 + label: Line 1 Color + category: Config + dtype: enum + options: ['"blue"', '"red"', '"green"', '"black"', '"cyan"', '"magenta"', '"yellow"', + '"dark red"', '"dark green"', '"dark blue"'] + option_labels: [Blue, Red, Green, Black, Cyan, Magenta, Yellow, Dark Red, Dark + Green, Dark Blue] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: alpha1 + label: Line 1 Alpha + category: Config + dtype: float + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: label2 + label: Line 2 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: width2 + label: Line 2 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: color2 + label: Line 2 Color + dtype: '' + default: '"red"' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: alpha2 + label: Line 2 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: label3 + label: Line 3 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: width3 + label: Line 3 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: color3 + label: Line 3 Color + dtype: '' + default: '"green"' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: alpha3 + label: Line 3 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: label4 + label: Line 4 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: width4 + label: Line 4 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: color4 + label: Line 4 Color + dtype: '' + default: '"black"' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: alpha4 + label: Line 4 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: label5 + label: Line 5 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: width5 + label: Line 5 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: color5 + label: Line 5 Color + dtype: '' + default: '"cyan"' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: alpha5 + label: Line 5 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: label6 + label: Line 6 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: width6 + label: Line 6 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: color6 + label: Line 6 Color + dtype: '' + default: '"magenta"' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: alpha6 + label: Line 6 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: label7 + label: Line 7 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: width7 + label: Line 7 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: color7 + label: Line 7 Color + dtype: '' + default: '"yellow"' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: alpha7 + label: Line 7 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: label8 + label: Line 8 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: width8 + label: Line 8 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: color8 + label: Line 8 Color + dtype: '' + default: '"dark red"' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: alpha8 + label: Line 8 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: label9 + label: Line 9 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: width9 + label: Line 9 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: color9 + label: Line 9 Color + dtype: '' + default: '"dark green"' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: alpha9 + label: Line 9 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: label10 + label: Line 10 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: width10 + label: Line 10 Width + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: color10 + label: Line 10 Color + dtype: '' + default: '"dark blue"' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: alpha10 + label: Line 10 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } + +inputs: +- domain: stream + dtype: float + vlen: ${ vlen } + multiplicity: ${ nconnections } + +outputs: +- domain: message + id: xval + optional: true + hide: ${ showports } + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import qtgui + import sip + callbacks: + - set_update_time(${update_time}) + - set_title(${title}) + - set_color(${which}, ${color}) + - set_x_axis(${x_start}, ${x_step}) + - set_y_axis(${ymin}, ${ymax}) + - set_ref_level(${ref_level}) + - set_x_axis_units(${x_units}) + - set_y_axis_units(${y_units}) + make: |- + <% + win = 'self._%s_win'%id + %>\ + qtgui.vector_sink_f( + ${vlen}, + ${x_start}, + ${x_step}, + ${x_axis_label}, + ${y_axis_label}, + ${name}, + ${nconnections} # Number of inputs + ) + self.${id}.set_update_time(${update_time}) + self.${id}.set_y_axis(${ymin}, ${ymax}) + self.${id}.enable_autoscale(${autoscale}) + self.${id}.enable_grid(${grid}) + self.${id}.set_x_axis_units(${x_units}) + self.${id}.set_y_axis_units(${y_units}) + self.${id}.set_ref_level(${ref_level}) + + labels = [${label1}, ${label2}, ${label3}, ${label4}, ${label5}, + ${label6}, ${label7}, ${label8}, ${label9}, ${label10}] + widths = [${width1}, ${width2}, ${width3}, ${width4}, ${width5}, + ${width6}, ${width7}, ${width8}, ${width9}, ${width10}] + colors = [${color1}, ${color2}, ${color3}, ${color4}, ${color5}, + ${color6}, ${color7}, ${color8}, ${color9}, ${color10}] + alphas = [${alpha1}, ${alpha2}, ${alpha3}, ${alpha4}, ${alpha5}, + ${alpha6}, ${alpha7}, ${alpha8}, ${alpha9}, ${alpha10}] + + for i in range(${nconnections}): + if len(labels[i]) == 0: + self.${id}.set_line_label(i, "Data {0}".format(i)) + else: + self.${id}.set_line_label(i, labels[i]) + self.${id}.set_line_width(i, widths[i]) + self.${id}.set_line_color(i, colors[i]) + self.${id}.set_line_alpha(i, alphas[i]) + + ${win} = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget) + ${gui_hint()(win)} + +documentation: |- + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_vector_sink_f.xml b/gr-qtgui/grc/qtgui_vector_sink_f.xml deleted file mode 100644 index 0f456323bf..0000000000 --- a/gr-qtgui/grc/qtgui_vector_sink_f.xml +++ /dev/null @@ -1,603 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##QT GUI Sink -################################################### - --> -<block> - <name>QT GUI Vector Sink</name> - <key>qtgui_vector_sink_f</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import qtgui</import> - <import>import sip</import> - <make>#set $win = 'self._%s_win'%$id -qtgui.vector_sink_f( - $vlen, - $x_start, - $x_step, - $x_axis_label, - $y_axis_label, - $name, - $nconnections \# Number of inputs -) -self.$(id).set_update_time($update_time) -self.$(id).set_y_axis($ymin, $ymax) -self.$(id).enable_autoscale($autoscale) -self.$(id).enable_grid($grid) -self.$(id).set_x_axis_units($x_units) -self.$(id).set_y_axis_units($y_units) -self.$(id).set_ref_level($ref_level) - -labels = [$label1, $label2, $label3, $label4, $label5, - $label6, $label7, $label8, $label9, $label10] -widths = [$width1, $width2, $width3, $width4, $width5, - $width6, $width7, $width8, $width9, $width10] -colors = [$color1, $color2, $color3, $color4, $color5, - $color6, $color7, $color8, $color9, $color10] -alphas = [$alpha1, $alpha2, $alpha3, $alpha4, $alpha5, - $alpha6, $alpha7, $alpha8, $alpha9, $alpha10] -for i in xrange($nconnections): - if len(labels[i]) == 0: - self.$(id).set_line_label(i, "Data {0}".format(i)) - else: - self.$(id).set_line_label(i, labels[i]) - self.$(id).set_line_width(i, widths[i]) - self.$(id).set_line_color(i, colors[i]) - self.$(id).set_line_alpha(i, alphas[i]) - -self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> - <callback>set_update_time($update_time)</callback> - <callback>set_title($title)</callback> - <callback>set_color($which, $color)</callback> - <callback>set_x_axis($x_start, $x_step)</callback> - <callback>set_y_axis($ymin, $ymax)</callback> - <callback>set_ref_level($ref_level)</callback> - <callback>set_x_axis_units($x_units)</callback> - <callback>set_y_axis_units($y_units)</callback> - - <param_tab_order> - <tab>General</tab> - <tab>Config</tab> - </param_tab_order> - - <param> - <name>Name</name> - <key>name</key> - <value>""</value> - <type>string</type> - <hide>#if len($name()) > 0 then 'none' else 'part'#</hide> - </param> - - <param> - <name>Vector Size</name> - <key>vlen</key> - <value>1024</value> - <type>int</type> - </param> - - <param> - <name>X-Axis Start Value</name> - <key>x_start</key> - <value>0</value> - <type>real</type> - </param> - - <param> - <name>X-Axis Step Value</name> - <key>x_step</key> - <value>1.0</value> - <type>real</type> - </param> - - <param> - <name>X-Axis Label</name> - <key>x_axis_label</key> - <value>"x-Axis"</value> - <type>string</type> - <hide>#if (len($x_axis_label()) > 0 and $x_axis_label != "x-Axis") then 'none' else 'part'#</hide> - </param> - - <param> - <name>Y-Axis Label</name> - <key>y_axis_label</key> - <value>"y-Axis"</value> - <type>string</type> - <hide>#if (len($y_axis_label()) > 0 and $y_axis_label != "y-Axis") then 'none' else 'part'#</hide> - </param> - - <param> - <name>X-Axis Units</name> - <key>x_units</key> - <value>""</value> - <type>string</type> - <hide>'part'</hide> - </param> - - <param> - <name>Y-Axis Units</name> - <key>y_units</key> - <value>""</value> - <type>string</type> - <hide>'part'</hide> - </param> - - <param> - <name>Ref Level</name> - <key>ref_level</key> - <value>0</value> - <type>real</type> - </param> - - <param> - <name>Grid</name> - <key>grid</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Autoscale</name> - <key>autoscale</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Average</name> - <key>average</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>None</name> - <key>1.0</key> - </option> - <option> - <name>Low</name> - <key>0.2</key> - </option> - <option> - <name>Medium</name> - <key>0.1</key> - </option> - <option> - <name>High</name> - <key>0.05</key> - </option> - </param> - - <param> - <name>Y min</name> - <key>ymin</key> - <value>-140</value> - <type>real</type> - <hide>part</hide> - </param> - <param> - <name>Y max</name> - <key>ymax</key> - <value>10</value> - <type>real</type> - <hide>part</hide> - </param> - <param> - <name>Number of Inputs</name> - <key>nconnections</key> - <value>1</value> - <type>int</type> - <hide>part</hide> - </param> - <param> - <name>Update Period</name> - <key>update_time</key> - <value>0.10</value> - <type>real</type> - <hide>part</hide> - </param> - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - <param> - <name>Show Msg Ports</name> - <key>showports</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>False</key> - </option> - <option> - <name>No</name> - <key>True</key> - </option> - </param> - - <param> - <name>Line 1 Label</name> - <key>label1</key> - <type>string</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Width</name> - <key>width1</key> - <value>1</value> - <type>int</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Color</name> - <key>color1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Blue</name> - <key>"blue"</key> - </option> - <option> - <name>Red</name> - <key>"red"</key> - </option> - <option> - <name>Green</name> - <key>"green"</key> - </option> - <option> - <name>Black</name> - <key>"black"</key> - </option> - <option> - <name>Cyan</name> - <key>"cyan"</key> - </option> - <option> - <name>Magenta</name> - <key>"magenta"</key> - </option> - <option> - <name>Yellow</name> - <key>"yellow"</key> - </option> - <option> - <name>Dark Red</name> - <key>"dark red"</key> - </option> - <option> - <name>Dark Green</name> - <key>"dark green"</key> - </option> - <option> - <name>Dark Blue</name> - <key>"dark blue"</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Alpha</name> - <key>alpha1</key> - <value>1.0</value> - <type>float</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 2 Label</name> - <key>label2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 2 Width</name> - <key>width2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 2 Color</name> - <key>color2</key> - <value>"red"</value> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 2 Alpha</name> - <key>alpha2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 3 Label</name> - <key>label3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 3 Width</name> - <key>width3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 3 Color</name> - <key>color3</key> - <value>"green"</value> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 3 Alpha</name> - <key>alpha3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 4 Label</name> - <key>label4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 4 Width</name> - <key>width4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 4 Color</name> - <key>color4</key> - <value>"black"</value> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 4 Alpha</name> - <key>alpha4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 5 Label</name> - <key>label5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 5 Width</name> - <key>width5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 5 Color</name> - <key>color5</key> - <value>"cyan"</value> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 5 Alpha</name> - <key>alpha5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 6 Label</name> - <key>label6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 6 Width</name> - <key>width6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 6 Color</name> - <key>color6</key> - <value>"magenta"</value> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 6 Alpha</name> - <key>alpha6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 7 Label</name> - <key>label7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 7 Width</name> - <key>width7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 7 Color</name> - <key>color7</key> - <value>"yellow"</value> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 7 Alpha</name> - <key>alpha7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 8 Label</name> - <key>label8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 8 Width</name> - <key>width8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 8 Color</name> - <key>color8</key> - <value>"dark red"</value> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 8 Alpha</name> - <key>alpha8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 9 Label</name> - <key>label9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 9 Width</name> - <key>width9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 9 Color</name> - <key>color9</key> - <value>"dark green"</value> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 9 Alpha</name> - <key>alpha9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 10 Label</name> - <key>label10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>width1</base_key> - <name>Line 10 Width</name> - <key>width10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 10 Color</name> - <key>color10</key> - <value>"dark blue"</value> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 10 Alpha</name> - <key>alpha10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <sink> - <name>in</name> - <type>float</type> - <vlen>$vlen</vlen> - <nports>$nconnections</nports> - </sink> - - <source> - <name>xval</name> - <type>message</type> - <optional>1</optional> - <hide>$showports</hide> - </source> - - <doc> -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-qtgui/grc/qtgui_waterfall_sink_x.block.yml b/gr-qtgui/grc/qtgui_waterfall_sink_x.block.yml new file mode 100644 index 0000000000..4b1cc055bc --- /dev/null +++ b/gr-qtgui/grc/qtgui_waterfall_sink_x.block.yml @@ -0,0 +1,303 @@ +id: qtgui_waterfall_sink_x +label: QT GUI Waterfall Sink + +parameters: +- id: type + label: Type + dtype: enum + default: complex + options: [complex, float, msg_complex, msg_float] + option_labels: [Complex, Float, Complex Message, Float Message] + option_attributes: + fcn: [waterfall_sink_c, waterfall_sink_f, waterfall_sink_c, waterfall_sink_f] + t: [complex, float, message, message] + hide: part +- id: name + label: Name + dtype: string + default: '""' + hide: ${ ('none' if len(name) > 0 else 'part') } +- id: fftsize + label: FFT Size + dtype: int + default: '1024' + hide: ${ ('all' if type.startswith('msg') else 'none') } +- id: freqhalf + label: Spectrum Width + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: [Full, Half] + hide: ${ ('part' if type == "float" or type == "msg_float" else 'all') } +- id: wintype + label: Window Type + dtype: int + default: firdes.WIN_BLACKMAN_hARRIS + options: [firdes.WIN_BLACKMAN_hARRIS, firdes.WIN_HAMMING, firdes.WIN_HANN, firdes.WIN_BLACKMAN, + firdes.WIN_RECTANGULAR, firdes.WIN_KAISER, firdes.WIN_FLATTOP] + option_labels: [Blackman-harris, Hamming, Hann, Blackman, Rectangular, Kaiser, + Flat-top] + hide: part +- id: fc + label: Center Frequency (Hz) + dtype: real + default: '0' +- id: bw + label: Bandwidth (Hz) + dtype: real + default: samp_rate +- id: int_min + label: Intensity Min + dtype: float + default: '-140' + hide: part +- id: int_max + label: Intensity Max + dtype: float + default: '10' + hide: part +- id: grid + label: Grid + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: nconnections + label: Number of Inputs + dtype: int + default: '1' + hide: ${ ('all' if type.startswith('msg') else 'part') } +- id: update_time + label: Update Period + dtype: real + default: '0.10' + hide: part +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +- id: showports + label: Show Msg Ports + dtype: enum + default: 'True' + options: ['False', 'True'] + option_labels: ['Yes', 'No'] + hide: part +- id: legend + label: Legend + category: Config + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: label1 + label: Line 1 Label + category: Config + dtype: string + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: axislabels + label: Axis Labels + category: Config + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + hide: part +- id: color1 + label: Line 1 Color + category: Config + dtype: enum + options: ['0', '1', '2', '3', '5', '6'] + option_labels: [Multi Color, White Hot, Black Hot, Incandescent, Sunset, Cool] + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: alpha1 + label: Line 1 Alpha + category: Config + dtype: float + default: '1.0' + hide: ${ ('part' if int(nconnections) >= 1 else 'all') } +- id: label2 + label: Line 2 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: color2 + label: Line 2 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: alpha2 + label: Line 2 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 2 else 'all') } +- id: label3 + label: Line 3 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: color3 + label: Line 3 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: alpha3 + label: Line 3 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 3 else 'all') } +- id: label4 + label: Line 4 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: color4 + label: Line 4 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: alpha4 + label: Line 4 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 4 else 'all') } +- id: label5 + label: Line 5 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: color5 + label: Line 5 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: alpha5 + label: Line 5 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 5 else 'all') } +- id: label6 + label: Line 6 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: color6 + label: Line 6 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: alpha6 + label: Line 6 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 6 else 'all') } +- id: label7 + label: Line 7 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: color7 + label: Line 7 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: alpha7 + label: Line 7 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 7 else 'all') } +- id: label8 + label: Line 8 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: color8 + label: Line 8 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: alpha8 + label: Line 8 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 8 else 'all') } +- id: label9 + label: Line 9 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: color9 + label: Line 9 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: alpha9 + label: Line 9 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 9 else 'all') } +- id: label10 + label: Line 10 Label + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: color10 + label: Line 10 Color + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } +- id: alpha10 + label: Line 10 Alpha + dtype: '' + hide: ${ ('part' if int(nconnections) >= 10 else 'all') } + +inputs: +- domain: stream + dtype: ${ type.t } + multiplicity: ${ (0 if type.startswith('msg') else nconnections) } + optional: true +- domain: message + id: freq + optional: true + hide: ${ showports } + +outputs: +- domain: message + id: freq + optional: true + hide: ${ showports } + +templates: + imports: |- + from PyQt5 import Qt + from gnuradio import qtgui + from gnuradio.filter import firdes + import sip + callbacks: + - set_frequency_range(${fc}, ${bw}) + - set_update_time(${update_time}) + - set_title(${which}, ${title}) + - set_color(${which}, ${color}) + - set_intensity_range(${int_min}, ${int_max}) + make: |- + <% + win = 'self._%s_win'%id + %>\ + qtgui.${type.fcn}( + ${fftsize}, #size + ${wintype}, #wintype + ${fc}, #fc + ${bw}, #bw + ${name}, #name + ${ (0 if type.startswith('msg') else nconnections) } #number of inputs + ) + self.${id}.set_update_time(${update_time}) + self.${id}.enable_grid(${grid}) + self.${id}.enable_axis_labels(${axislabels}) + + if not ${legend}: + self.${id}.disable_legend() + + if "${type}" == "float" or "${type}" == "msg_float": + self.${id}.set_plot_pos_half(not ${freqhalf}) + + labels = [${label1}, ${label2}, ${label3}, ${label4}, ${label5}, + ${label6}, ${label7}, ${label8}, ${label9}, ${label10}] + colors = [${color1}, ${color2}, ${color3}, ${color4}, ${color5}, + ${color6}, ${color7}, ${color8}, ${color9}, ${color10}] + alphas = [${alpha1}, ${alpha2}, ${alpha3}, ${alpha4}, ${alpha5}, + ${alpha6}, ${alpha7}, ${alpha8}, ${alpha9}, ${alpha10}] + + for i in range(${1 if type.startswith('msg') else nconnections}): + if len(labels[i]) == 0: + self.${id}.set_line_label(i, "Data {0}".format(i)) + else: + self.${id}.set_line_label(i, labels[i]) + self.${id}.set_color_map(i, colors[i]) + self.${id}.set_line_alpha(i, alphas[i]) + + self.${id}.set_intensity_range(${int_min}, ${int_max}) + + ${win} = sip.wrapinstance(self.${id}.pyqwidget(), Qt.QWidget) + ${gui_hint()(win)} + +documentation: |- + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml b/gr-qtgui/grc/qtgui_waterfall_sink_x.xml deleted file mode 100644 index a684492246..0000000000 --- a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml +++ /dev/null @@ -1,557 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##QT GUI Sink -################################################### - --> -<block> - <name>QT GUI Waterfall Sink</name> - <key>qtgui_waterfall_sink_x</key> - <import>from PyQt5 import Qt</import> - <import>from gnuradio import qtgui</import> - <import>from gnuradio.filter import firdes</import> - <import>import sip</import> - <make>#set $win = 'self._%s_win'%$id -qtgui.$(type.fcn)( - $fftsize, \#size - $wintype, \#wintype - $fc, \#fc - $bw, \#bw - $name, \#name - #if $type.t == 'message' then 0 else $nconnections# \#number of inputs -) -self.$(id).set_update_time($update_time) -self.$(id).enable_grid($grid) -self.$(id).enable_axis_labels($axislabels) - -if not $legend: - self.$(id).disable_legend() - -if "$type" == "float" or "$type" == "msg_float": - self.$(id).set_plot_pos_half(not $freqhalf) - -labels = [$label1, $label2, $label3, $label4, $label5, - $label6, $label7, $label8, $label9, $label10] -colors = [$color1, $color2, $color3, $color4, $color5, - $color6, $color7, $color8, $color9, $color10] -alphas = [$alpha1, $alpha2, $alpha3, $alpha4, $alpha5, - $alpha6, $alpha7, $alpha8, $alpha9, $alpha10] -for i in xrange(#if $type.t == 'message' then 1 else $nconnections#): - if len(labels[i]) == 0: - self.$(id).set_line_label(i, "Data {0}".format(i)) - else: - self.$(id).set_line_label(i, labels[i]) - self.$(id).set_color_map(i, colors[i]) - self.$(id).set_line_alpha(i, alphas[i]) - -self.$(id).set_intensity_range($int_min, $int_max) - -self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) -$(gui_hint()($win))</make> - <callback>set_frequency_range($fc, $bw)</callback> - <callback>set_update_time($update_time)</callback> - <callback>set_title($which, $title)</callback> - <callback>set_color($which, $color)</callback> - <callback>set_intensity_range($int_min, $int_max)</callback> - - <param_tab_order> - <tab>General</tab> - <tab>Config</tab> - </param_tab_order> - - <param> - <name>Type</name> - <key>type</key> - <value>complex</value> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:waterfall_sink_c</opt> - <opt>t:complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:waterfall_sink_f</opt> - <opt>t:float</opt> - </option> - <option> - <name>Complex Message</name> - <key>msg_complex</key> - <opt>fcn:waterfall_sink_c</opt> - <opt>t:message</opt> - </option> - <option> - <name>Float Message</name> - <key>msg_float</key> - <opt>fcn:waterfall_sink_f</opt> - <opt>t:message</opt> - </option> - </param> - - <param> - <name>Name</name> - <key>name</key> - <value>""</value> - <type>string</type> - <hide>#if len($name()) > 0 then 'none' else 'part'#</hide> - </param> - - <param> - <name>FFT Size</name> - <key>fftsize</key> - <value>1024</value> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'none'#</hide> - </param> - - <param> - <name>Spectrum Width</name> - <key>freqhalf</key> - <value>True</value> - <type>enum</type> - <hide>#if $type() == "float" or $type() == "msg_float" then 'part' else 'all'#</hide> - <option> - <name>Full</name> - <key>True</key> - </option> - <option> - <name>Half</name> - <key>False</key> - </option> - </param> - - <param> - <name>Window Type</name> - <key>wintype</key> - <value>firdes.WIN_BLACKMAN_hARRIS</value> - <type>int</type> - <hide>part</hide> - <option> - <name>Blackman-harris</name> - <key>firdes.WIN_BLACKMAN_hARRIS</key> - </option> - <option> - <name>Hamming</name> - <key>firdes.WIN_HAMMING</key> - </option> - <option> - <name>Hann</name> - <key>firdes.WIN_HANN</key> - </option> - <option> - <name>Blackman</name> - <key>firdes.WIN_BLACKMAN</key> - </option> - <option> - <name>Rectangular</name> - <key>firdes.WIN_RECTANGULAR</key> - </option> - <option> - <name>Kaiser</name> - <key>firdes.WIN_KAISER</key> - </option> - <option> - <name>Flat-top</name> - <key>firdes.WIN_FLATTOP</key> - </option> - </param> - - <param> - <name>Center Frequency (Hz)</name> - <key>fc</key> - <value>0</value> - <type>real</type> - </param> - - <param> - <name>Bandwidth (Hz)</name> - <key>bw</key> - <value>samp_rate</value> - <type>real</type> - </param> - - <param> - <name>Intensity Min</name> - <key>int_min</key> - <value>-140</value> - <type>float</type> - <hide>part</hide> - </param> - - <param> - <name>Intensity Max</name> - <key>int_max</key> - <value>10</value> - <type>float</type> - <hide>part</hide> - </param> - - <param> - <name>Grid</name> - <key>grid</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - - <param> - <name>Number of Inputs</name> - <key>nconnections</key> - <value>1</value> - <type>int</type> - <hide>#if $type.t == 'message' then 'all' else 'part'#</hide> - </param> - - <param> - <name>Update Period</name> - <key>update_time</key> - <value>0.10</value> - <type>real</type> - <hide>part</hide> - </param> - - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - - <param> - <name>Show Msg Ports</name> - <key>showports</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>False</key> - </option> - <option> - <name>No</name> - <key>True</key> - </option> - </param> - - - <!-- Begin Config Tab items --> - <param> - <name>Legend</name> - <key>legend</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Label</name> - <key>label1</key> - <type>string</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - <param> - <name>Axis Labels</name> - <key>axislabels</key> - <value>True</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Color</name> - <key>color1</key> - <type>enum</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <option> - <name>Multi Color</name> - <key>0</key> - </option> - <option> - <name>White Hot</name> - <key>1</key> - </option> - <option> - <name>Black Hot</name> - <key>2</key> - </option> - <option> - <name>Incandescent</name> - <key>3</key> - </option> - <option> - <name>Sunset</name> - <key>5</key> - </option> - <option> - <name>Cool</name> - <key>6</key> - </option> - <tab>Config</tab> - </param> - - <param> - <name>Line 1 Alpha</name> - <key>alpha1</key> - <value>1.0</value> - <type>float</type> - <hide>#if int($nconnections()) >= 1 then 'part' else 'all'#</hide> - <tab>Config</tab> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 2 Label</name> - <key>label2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 2 Color</name> - <key>color2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 2 Alpha</name> - <key>alpha2</key> - <hide>#if int($nconnections()) >= 2 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 3 Label</name> - <key>label3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 3 Color</name> - <key>color3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 3 Alpha</name> - <key>alpha3</key> - <hide>#if int($nconnections()) >= 3 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 4 Label</name> - <key>label4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 4 Color</name> - <key>color4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 4 Alpha</name> - <key>alpha4</key> - <hide>#if int($nconnections()) >= 4 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 5 Label</name> - <key>label5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 5 Color</name> - <key>color5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 5 Alpha</name> - <key>alpha5</key> - <hide>#if int($nconnections()) >= 5 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 6 Label</name> - <key>label6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 6 Color</name> - <key>color6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 6 Alpha</name> - <key>alpha6</key> - <hide>#if int($nconnections()) >= 6 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 7 Label</name> - <key>label7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 7 Color</name> - <key>color7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 7 Alpha</name> - <key>alpha7</key> - <hide>#if int($nconnections()) >= 7 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 8 Label</name> - <key>label8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 8 Color</name> - <key>color8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 8 Alpha</name> - <key>alpha8</key> - <hide>#if int($nconnections()) >= 8 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 9 Label</name> - <key>label9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 9 Color</name> - <key>color9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 9 Alpha</name> - <key>alpha9</key> - <hide>#if int($nconnections()) >= 9 then 'part' else 'all'#</hide> - </param> - - - <param> - <base_key>label1</base_key> - <name>Line 10 Label</name> - <key>label10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>color1</base_key> - <name>Line 10 Color</name> - <key>color10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - <param> - <base_key>alpha1</base_key> - <name>Line 10 Alpha</name> - <key>alpha10</key> - <hide>#if int($nconnections()) >= 10 then 'part' else 'all'#</hide> - </param> - - - <sink> - <name>in</name> - <type>$type.t</type> - <nports>#if $type.t == 'message' then 0 else $nconnections#</nports> - <optional>1</optional> - </sink> - - <sink> - <name>freq</name> - <type>message</type> - <optional>1</optional> - <hide>$showports</hide> - </sink> - - <source> - <name>freq</name> - <type>message</type> - <optional>1</optional> - <hide>$showports</hide> - </source> - - <doc> -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/gr-uhd/grc/CMakeLists.txt b/gr-uhd/grc/CMakeLists.txt index d748bfacef..72a6543df3 100644 --- a/gr-uhd/grc/CMakeLists.txt +++ b/gr-uhd/grc/CMakeLists.txt @@ -18,28 +18,28 @@ # Boston, MA 02110-1301, USA. ######################################################################## -# Rules for generating the source and sink xml wrappers +# Rules for generating the source and sink yml wrappers ######################################################################## include(GrPython) -macro(GEN_BLOCK_XML _generator _xml_block) +macro(GEN_BLOCK_YML _generator _yml_block) set(generator ${CMAKE_CURRENT_SOURCE_DIR}/${_generator}) - set(xml_block ${CMAKE_CURRENT_BINARY_DIR}/${_xml_block}) - list(APPEND xml_blocks ${xml_block}) + set(yml_block ${CMAKE_CURRENT_BINARY_DIR}/${_yml_block}) + list(APPEND yml_blocks ${yml_block}) add_custom_command( - DEPENDS ${generator} OUTPUT ${xml_block} - COMMAND ${PYTHON_EXECUTABLE} ${generator} ${xml_block} + DEPENDS ${generator} OUTPUT ${yml_block} + COMMAND ${PYTHON_EXECUTABLE} ${generator} ${yml_block} ) -endmacro(GEN_BLOCK_XML) +endmacro(GEN_BLOCK_YML) -GEN_BLOCK_XML(gen_uhd_usrp_blocks.py uhd_usrp_source.xml) -GEN_BLOCK_XML(gen_uhd_usrp_blocks.py uhd_usrp_sink.xml) +GEN_BLOCK_YML(gen_uhd_usrp_blocks.py uhd_usrp_source.block.yml) +GEN_BLOCK_YML(gen_uhd_usrp_blocks.py uhd_usrp_sink.block.yml) -add_custom_target(uhd_grc_xml_blocks ALL DEPENDS ${xml_blocks}) +add_custom_target(uhd_grc_yml_blocks ALL DEPENDS ${yml_blocks}) install(FILES - ${xml_blocks} - uhd_amsg_source.xml - uhd_block_tree.xml + ${yml_blocks} + uhd_amsg_source.block.yml + uhd.tree.yml DESTINATION ${GRC_BLOCKS_DIR} ) diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py index 1bba490a23..4a7b484f7d 100644 --- a/gr-uhd/grc/gen_uhd_usrp_blocks.py +++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py @@ -19,669 +19,344 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ MAIN_TMPL = """\ -<?xml version="1.0"?> -<block> - <name>UHD: USRP $sourk.title()</name> - <key>uhd_usrp_$(sourk)</key> - <flags>throttle</flags> - <import>from gnuradio import uhd</import> - <import>import time</import> - <make>uhd.usrp_$(sourk)( - ",".join((\$dev_addr, \$dev_args)), - uhd.stream_args( - cpu_format="\$type", - \#if \$otw() - otw_format=\$otw, - \#end if - \#if \$stream_args() - args=\$stream_args, - \#end if - \#if \$stream_chans() - channels=\$stream_chans, - \#else - channels=range(\$nchan), - \#end if - ),$lentag_arg -) -\#if \$clock_rate() -self.\$(id).set_clock_rate(\$clock_rate, uhd.ALL_MBOARDS) -\#end if -#for $m in range($max_mboards) -######################################################################## -\#if \$num_mboards() > $m and \$clock_source$(m)() -self.\$(id).set_clock_source(\$clock_source$(m), $m) -\#end if -######################################################################## -\#if \$num_mboards() > $m and \$time_source$(m)() -self.\$(id).set_time_source(\$time_source$(m), $m) -\#end if -######################################################################## -\#if \$num_mboards() > $m and \$sd_spec$(m)() -self.\$(id).set_subdev_spec(\$sd_spec$(m), $m) -\#end if -######################################################################## -#end for -self.\$(id).set_samp_rate(\$samp_rate) -\#if \$sync() == 'sync' -self.\$(id).set_time_unknown_pps(uhd.time_spec()) -\#elif \$sync() == 'pc_clock' -self.\$(id).set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) -\#end if -#for $n in range($max_nchan) -\#if \$nchan() > $n -self.\$(id).set_center_freq(\$center_freq$(n), $n) -\#if \$norm_gain${n}() -self.\$(id).set_normalized_gain(\$gain$(n), $n) -\#else -self.\$(id).set_gain(\$gain$(n), $n) -\#end if - \#if \$ant$(n)() -self.\$(id).set_antenna(\$ant$(n), $n) - \#end if - \#if \$bw$(n)() -self.\$(id).set_bandwidth(\$bw$(n), $n) - \#end if -#if $sourk == 'source' - \#if \$lo_export$(n)() and not \$hide_lo_controls() -self.\$(id).set_lo_export_enabled(\$lo_export$(n), uhd.ALL_LOS, $n) - \#end if - \#if \$lo_source$(n)() and not \$hide_lo_controls() -self.\$(id).set_lo_source(\$lo_source$(n), uhd.ALL_LOS, $n) - \#end if - \#if \$dc_offs_enb$(n)() -self.\$(id).set_auto_dc_offset(\$dc_offs_enb$(n), $n) - \#end if - \#if \$iq_imbal_enb$(n)() -self.\$(id).set_auto_iq_balance(\$iq_imbal_enb$(n), $n) - \#end if -#end if -\#end if -#end for -</make> - <callback>set_samp_rate(\$samp_rate)</callback> - #for $n in range($max_nchan) - <callback>set_center_freq(\$center_freq$(n), $n)</callback> - <callback>\#if \$norm_gain${n}() -self.\$(id).set_normalized_gain(\$gain$(n), $n) -\#else -self.\$(id).set_gain(\$gain$(n), $n) -\#end if - </callback> - <callback>\#if not \$hide_lo_controls() -set_lo_source(\$lo_source$(n), uhd.ALL_LOS, $n) -\#end if - </callback> - <callback>\#if not \$hide_lo_controls() -set_lo_export_enabled(\$lo_export$(n), uhd.ALL_LOS, $n) -\#end if - </callback> - <callback>set_antenna(\$ant$(n), $n)</callback> - <callback>set_bandwidth(\$bw$(n), $n)</callback> - #end for - <param> - <name>$(direction.title())put Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex float32</name> - <key>fc32</key> - <opt>type:fc32</opt> - </option> - <option> - <name>Complex int16</name> - <key>sc16</key> - <opt>type:sc16</opt> - </option> - <option> - <name>VITA word32</name> - <key>item32</key> - <opt>type:s32</opt> - </option> - </param> - <param> - <name>Wire Format</name> - <key>otw</key> - <value></value> - <type>string</type> - <hide> - \#if \$otw() - none - \#else - part - \#end if - </hide> - <option> - <name>Automatic</name> - <key></key> - </option> - <option> - <name>Complex int16</name> - <key>sc16</key> - </option> - <option> - <name>Complex int12</name> - <key>sc12</key> - </option> - <option> - <name>Complex int8</name> - <key>sc8</key> - </option> - </param> - <param> - <name>Stream args</name> - <key>stream_args</key> - <value></value> - <type>string</type> - <hide> - \#if \$stream_args() - none - \#else - part - \#end if - </hide> - <option> - <name>peak=0.003906</name> - <key>peak=0.003906</key> - </option> - </param> - <param> - <name>Stream channels</name> - <key>stream_chans</key> - <value>[]</value> - <type>int_vector</type> - <hide> - \#if \$stream_chans() - none - \#else - part - \#end if - </hide> - </param> - <param> - <name>Device Address</name> - <key>dev_addr</key> - <value>""</value> - <type>string</type> - <hide> - \#if \$dev_addr() - none - \#else - part - \#end if - </hide> - </param> - <param> - <name>Device Arguments</name> - <key>dev_args</key> - <value>""</value> - <type>string</type> - <hide> - \#if \$dev_args() - none - \#else - part - \#end if - </hide> - </param> - <param> - <name>Sync</name> - <key>sync</key> - <value></value> - <type>enum</type> - <hide>\#if \$sync() then 'none' else 'part'#</hide> - <option> - <name>unknown PPS</name> - <key>sync</key> - </option> - <option> - <name>PC Clock</name> - <key>pc_clock</key> - </option> - <option> - <name>don't sync</name> - <key></key> - </option> - </param> - <param> - <name>Clock Rate (Hz)</name> - <key>clock_rate</key> - <value>0.0</value> - <type>real</type> - <hide>\#if \$clock_rate() then 'none' else 'part'#</hide> - <option> - <name>Default</name> - <key>0.0</key> - </option> - <option> - <name>200 MHz</name> - <key>200e6</key> - </option> - <option> - <name>184.32 MHz</name> - <key>184.32e6</key> - </option> - <option> - <name>120 MHz</name> - <key>120e6</key> - </option> - <option> - <name>30.72 MHz</name> - <key>30.72e6</key> - </option> - </param> - <param> - <name>Num Mboards</name> - <key>num_mboards</key> - <value>1</value> - <type>int</type> - <hide>part</hide> - #for $m in range(1, $max_mboards+1) - <option> - <name>$(m)</name> - <key>$m</key> - </option> - #end for - </param> - #for $m in range($max_mboards) - <param> - <name>Mb$(m): Clock Source</name> - <key>clock_source$(m)</key> - <value></value> - <type>string</type> - <hide> - \#if not \$num_mboards() > $m - all - \#elif \$clock_source$(m)() - none - \#else - part - \#end if - </hide> - <option><name>Default</name><key></key></option> - <option><name>Internal</name><key>internal</key></option> - <option><name>External</name><key>external</key></option> - <option><name>MIMO Cable</name><key>mimo</key></option> - <option><name>O/B GPSDO</name><key>gpsdo</key></option> - </param> - <param> - <name>Mb$(m): Time Source</name> - <key>time_source$(m)</key> - <value></value> - <type>string</type> - <hide> - \#if not \$num_mboards() > $m - all - \#elif \$time_source$(m)() - none - \#else - part - \#end if - </hide> - <option><name>Default</name><key></key></option> - <option><name>External</name><key>external</key></option> - <option><name>MIMO Cable</name><key>mimo</key></option> - <option><name>O/B GPSDO</name><key>gpsdo</key></option> - </param> - <param> - <name>Mb$(m): Subdev Spec</name> - <key>sd_spec$(m)</key> - <value></value> - <type>string</type> - <hide> - \#if not \$num_mboards() > $m - all - \#elif \$sd_spec$(m)() - none - \#else - part - \#end if - </hide> - </param> - #end for - <param> - <name>Num Channels</name> - <key>nchan</key> - <value>1</value> - <type>int</type> - #for $n in range(1, $max_nchan+1) - <option> - <name>$(n)</name> - <key>$n</key> - </option> - #end for - </param> - <param> - <name>Samp Rate (Sps)</name> - <key>samp_rate</key> - <value>samp_rate</value> - <type>real</type> - </param> - $params - <check>$max_nchan >= \$nchan</check> - <check>\$nchan > 0</check> - <check>$max_mboards >= \$num_mboards</check> - <check>\$num_mboards > 0</check> - <check>\$nchan >= \$num_mboards</check> - <check>(not \$stream_chans()) or (\$nchan == len(\$stream_chans))</check> - #for $n in range($max_nchan) - <check>(\$norm_gain${n} and \$gain${n} >= 0 and \$gain${n} <= 1) or not \$norm_gain${n}</check> - #end for - <sink> - <name>command</name> - <type>message</type> - <optional>1</optional> - <hide>\$hide_cmd_port</hide> - </sink> - <$sourk> - <name>$direction</name> - <type>\$type.type</type> - <nports>\$nchan</nports> - </$sourk> - <doc> -The UHD USRP $sourk.title() Block: - -Device Address: -The device address is a delimited string used to locate UHD devices on your system. \\ -If left blank, the first UHD device found will be used. \\ -Use the device address to specify a specific device or list of devices. -USRP1 Example: serial=12345678 -USRP2 Example: addr=192.168.10.2 -USRP2 Example: addr0=192.168.10.2, addr1=192.168.10.3 - -$(direction.title()) Type: -This parameter controls the data type of the stream in gnuradio. - -Wire Format: -This parameter controls the form of the data over the bus/network. \ -Complex bytes may be used to trade off precision for bandwidth. \ -Not all formats are supported on all devices. - -Stream Args: -Optional arguments to be passed in the UHD streamer object. \ -Streamer args is a list of key/value pairs; usage is determined by the implementation. -Ex: the scalar key affects the scaling between 16 and 8 bit integers in sc8 wire format. - -Num Motherboards: -Selects the number of USRP motherboards in this device configuration. - -Reference Source: -Where the motherboard should sync its time and clock references. -If source and sink blocks reference the same device, -it is only necessary to set the reference source on one of the blocks. - -Subdevice specification: -Each motherboard should have its own subdevice specification \\ -and all subdevice specifications should be the same length. \\ -Select the subdevice or subdevices for each channel using a markup string. \\ -The markup string consists of a list of dboard_slot:subdev_name pairs (one pair per channel). \\ -If left blank, the UHD will try to select the first subdevice on your system. \\ -See the application notes for further details. -Single channel example: :AB -Dual channel example: :A :B - -Num Channels: -Selects the total number of channels in this multi-USRP configuration. -Ex: 4 motherboards with 2 channels per board = 8 channels total - -Sample rate: -The sample rate is the number of samples per second input by this block. \\ -The UHD device driver will try its best to match the requested sample rate. \\ -If the requested rate is not possible, the UHD block will print an error at runtime. - -Center frequency: -The center frequency is the overall frequency of the RF chain. \\ -For greater control of how the UHD tunes elements in the RF chain, \\ +id: uhd_usrp_sink +label: 'UHD: USRP ${sourk.title()}' +flags: throttle + +parameters: +- id: type + label: ${'$'}{direction.title()}put Type + dtype: enum + options: [fc32, sc16, item32] + option_labels: [Complex float32, Complex int16, VITA word32] + option_attributes: + type: [fc32, sc16, s32] + hide: part +- id: otw + label: Wire Format + dtype: enum + options: ['', sc16, sc12, sc8] + option_labels: [Automatic, Complex int16, Complex int12, Complex int8] + hide: ${'$'}{ 'none' if otw else 'part'} +- id: stream_args + label: Stream args + dtype: string + options: [peak=0.003906] + option_labels: [peak=0.003906] + hide: ${'$'}{ 'none' if stream_args else 'part'} +- id: stream_chans + label: Stream channels + dtype: int_vector + default: '[]' + hide: ${'$'}{ 'none' if stream_chans else 'part'} +- id: dev_addr + label: Device Address + dtype: string + default: '""' + hide: ${'$'}{ 'none' if dev_addr else 'part'} +- id: dev_args + label: Device Arguments + dtype: string + default: '""' + hide: ${'$'}{ 'none' if dev_args else 'part'} +- id: sync + label: Sync + dtype: enum + options: [sync, pc_clock, ''] + option_labels: [unknown PPS, PC Clock, don't sync] + hide: ${'$'}{ 'none' if sync else 'part'} +- id: clock_rate + label: Clock Rate (Hz) + dtype: real + default: '0.0' + options: ['0.0', 200e6, 184.32e6, 120e6, 30.72e6] + option_labels: [Default, 200 MHz, 184.32 MHz, 120 MHz, 30.72 MHz] + hide: ${'$'}{ 'none' if clock_rate else 'part' } +- id: num_mboards + label: Num Mboards + dtype: int + default: '1' + options: ['1', '2', '3', '4', '5', '6', '7', '8'] + hide: part +% for m in range(max_mboards): +- id: clock_source${m} + label: 'Mb${m}: Clock Source' + dtype: string + options: ['', internal, external, mimo, gpsdo] + option_labels: [Default, Internal, External, MIMO Cable, O/B GPSDO] + hide: ${'$'}{ 'all' if not (num_mboards > ${m}) else ( 'none' if clock_source${m}) else 'part')} +- id: time_source${m} + label: 'Mb${m}: Time Source' + dtype: string + options: ['', external, mimo, gpsdo] + option_labels: [Default, External, MIMO Cable, O/B GPSDO] + hide: ${'$'}{ 'all' if not (num_mboards > ${m}) else ('none' if time_source${m}) else 'part')} +- id: sd_spec${m} + label: 'Mb${m}: Subdev Spec' + dtype: string + hide: ${'$'}{ 'all' if not (num_mboards > ${m}) else ('none' if sd_spec${m}) else 'part')} +% endfor +- id: nchan + label: Num Channels + dtype: int + default: 1 + options: [ ${", ".join([str(n) for n in range(1, max_nchan+1)])} ] + hide: part +- id: samp_rate + label: Smp rate (Sps) + dtype: real +${params} + + + +inputs: +- domain: message + id: command + optional: true + hide: ${'$'}{hide_cmd_port} +% if sourk == 'sink': +- domain: stream +% else: + +outputs: +- domain: stream +% endif + dtype: ${'$'}{type.type} + multiplicity: ${'$'}{nchan} + +templates: + imports: |- + from gnuradio import uhd + import time + make: | + uhd.usrp_sink( + ",".join((${'$'}{dev_addr}, ${'$'}{dev_args})), + uhd.stream_args( + cpu_format="${'$'}{type}", + ${'%'} if otw: + otw_format=${'$'}{otw}, + ${'%'} endif + ${'%'} if stream_args: + args=${'$'}{stream_args}, + ${'%'} endif + ${'%'} if stream_chans: + channels=${'$'}{stream_chans}, + ${'%'} else: + channels=range(${'$'}{nchan}), + ${'%'} endif + ), + ${'%'} if len_tag_name: + ${'$'}{len_tag_name}, + ${'%'} endif + ) + ${'%'} if clock_rate: + self.${'$'}{id}.set_clock_rate(${'$'}{clock_rate}, uhd.ALL_MBOARDS) + ${'%'} endif + self.${'$'}{id}.set_samp_rate(${'$'}{samp_rate}) + ${'%'} if sync == 'sync': + self.${'$'}{id}.set_time_unknown_pps(uhd.time_spec()) + #elif ${'$'}{sync} == 'pc_clock' + self.${'$'}{id}.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) + ${'%'} endif + callbacks: + - set_samp_rate(${'$'}{samp_rate}) + % for n in range(max_nchan): + - set_center_freq(${'center_freq' + str(n)}, ${n}) + - self.${'$'}{id}.set_${'$'}{'normalized_' if eval('norm_gain' + str(n))}gain(gain${n}, ${n}) + - ${'$'}{'set_lo_source(lo_source${n}, uhd.ALL_LOS, ${n})' if not hide_lo_controls()} + - ${'$'}{'set_lo_export_enabled(lo_export${n}, uhd.ALL_LOS, ${n})' if not hide_lo_controls()} + - set_antenna(${'ant' + str(n)}, ${n}) + - set_bandwidth(${'bw' + str(n)}, ${n}) + % endfor + + +documentation: |- + The UHD USRP ${sourk.title()} Block: + + Device Address: + The device address is a delimited string used to locate UHD devices on your system. \\ + If left blank, the first UHD device found will be used. \\ + Use the device address to specify a specific device or list of devices. + USRP1 Example: serial=12345678 + USRP2 Example: addr=192.168.10.2 + USRP2 Example: addr0=192.168.10.2, addr1=192.168.10.3 + + ${direction.title()} Type: + This parameter controls the data type of the stream in gnuradio. + + Wire Format: + This parameter controls the form of the data over the bus/network. \ + Complex bytes may be used to trade off precision for bandwidth. \ + Not all formats are supported on all devices. + + Stream Args: + Optional arguments to be passed in the UHD streamer object. \ + Streamer args is a list of key/value pairs; usage is determined by the implementation. + Ex: the scalar key affects the scaling between 16 and 8 bit integers in sc8 wire format. + + Num Motherboards: + Selects the number of USRP motherboards in this device configuration. + + Reference Source: + Where the motherboard should sync its time and clock references. + If source and sink blocks reference the same device, + it is only necessary to set the reference source on one of the blocks. + + Subdevice specification: + Each motherboard should have its own subdevice specification \\ + and all subdevice specifications should be the same length. \\ + Select the subdevice or subdevices for each channel using a markup string. \\ + The markup string consists of a list of dboard_slot:subdev_name pairs (one pair per channel). \\ + If left blank, the UHD will try to select the first subdevice on your system. \\ + See the application notes for further details. + Single channel example: :AB + Dual channel example: :A :B + + Num Channels: + Selects the total number of channels in this multi-USRP configuration. + Ex: 4 motherboards with 2 channels per board = 8 channels total + + Sample rate: + The sample rate is the number of samples per second input by this block. \\ + The UHD device driver will try its best to match the requested sample rate. \\ + If the requested rate is not possible, the UHD block will print an error at runtime. + + Center frequency: + The center frequency is the overall frequency of the RF chain. \\ + For greater control of how the UHD tunes elements in the RF chain, \\ pass a tune_request object rather than a simple target frequency. -Tuning with an LO offset example: uhd.tune_request(freq, lo_off) -Tuning without DSP: uhd.tune_request(target_freq, dsp_freq=0, \\ + Tuning with an LO offset example: uhd.tune_request(freq, lo_off) + Tuning without DSP: uhd.tune_request(target_freq, dsp_freq=0, \\ dsp_freq_policy=uhd.tune_request.POLICY_MANUAL) -Antenna: -For subdevices with only one antenna, this may be left blank. \\ -Otherwise, the user should specify one of the possible antenna choices. \\ -See the daughterboard application notes for the possible antenna choices. + Antenna: + For subdevices with only one antenna, this may be left blank. \\ + Otherwise, the user should specify one of the possible antenna choices. \\ + See the daughterboard application notes for the possible antenna choices. + + Bandwidth: + To use the default bandwidth filter setting, this should be zero. \\ + Only certain subdevices have configurable bandwidth filters. \\ + See the daughterboard application notes for possible configurations. -Bandwidth: -To use the default bandwidth filter setting, this should be zero. \\ -Only certain subdevices have configurable bandwidth filters. \\ -See the daughterboard application notes for possible configurations. + Length tag key (Sink only): + When a nonempty string is given, the USRP sink will look for length tags \\ + to determine transmit burst lengths. -Length tag key (Sink only): -When a nonempty string is given, the USRP sink will look for length tags \\ -to determine transmit burst lengths. + See the UHD manual for more detailed documentation: + http://uhd.ettus.com -See the UHD manual for more detailed documentation: -http://uhd.ettus.com - </doc> -</block> +file_format: 1 """ -PARAMS_TMPL = """ <param> - <name>Ch$(n): Center Freq (Hz)</name> - <key>center_freq$(n)</key> - <value>0</value> - <type>real</type> - <hide>\#if \$nchan() > $n then 'none' else 'all'#</hide> - <tab>RF Options</tab> - </param> - <param> - <name>Ch$(n): Gain Value</name> - <key>gain$(n)</key> - <value>0</value> - <type>float</type> - <hide>\#if \$nchan() > $n then 'none' else 'all'#</hide> - <tab>RF Options</tab> - </param> - <param> - <name>Ch$(n): Gain Type</name> - <key>norm_gain$(n)</key> - <value>False</value> - <type>bool</type> - <hide>\#if \$nchan() <= $n - all - \#elif bool(\$norm_gain${n}()) - none - \#else - part - \#end if</hide> - <option> - <name>Absolute (dB)</name> - <key>False</key> - </option> - <option> - <name>Normalized</name> - <key>True</key> - </option> - <tab>RF Options</tab> - </param> - <param> - <name>Ch$(n): Antenna</name> - <key>ant$(n)</key> - <value></value> - <type>string</type> - <hide> - \#if not \$nchan() > $n - all - \#elif \$ant$(n)() - none - \#else - part - \#end if - </hide> - <option> - <name>TX/RX</name> - <key>TX/RX</key> - </option> -#if $sourk == 'source' - <option> - <name>RX2</name> - <key>RX2</key> - </option> - <option> - <name>RX1</name> - <key>RX1</key> - </option> -#end if - <tab>RF Options</tab> - </param> - <param> - <name>Ch$(n): Bandwidth (Hz)</name> - <key>bw$(n)</key> - <value>0</value> - <type>real</type> - <hide> - \#if not \$nchan() > $n - all - \#elif \$bw$(n)() - none - \#else - part - \#end if - </hide> - <tab>RF Options</tab> - </param> -#if $sourk == 'source' - <param> - <name>Ch$(n): LO Source</name> - <key>lo_source$(n)</key> - <value>internal</value> - <type>string</type> - <hide> - \#if not \$nchan() > $n - all - \#elif \$hide_lo_controls() - all - \#else - none - \#end if - </hide> - <option> - <name>Internal</name> - <key>internal</key> - </option> - <option> - <name>External</name> - <key>external</key> - </option> - <option> - <name>Companion</name> - <key>companion</key> - </option> - <tab>RF Options</tab> - </param> -#end if -#if $sourk == 'source' - <param> - <name>Ch$(n): LO Export</name> - <key>lo_export$(n)</key> - <value>False</value> - <type>bool</type> - <hide> - \#if not \$nchan() > $n - all - \#elif \$hide_lo_controls() - all - \#else - none - \#end if - </hide> - <option> - <name>True</name> - <key>True</key> - </option> - <option> - <name>False</name> - <key>False</key> - </option> - <tab>RF Options</tab> - </param> -#end if -#if $sourk == 'source' - <param> - <name>Ch$(n): Enable DC Offset Correction</name> - <key>dc_offs_enb$(n)</key> - <value>""</value> - <type>raw</type> - <hide> - \#if not \$nchan() > $n - all - \#else - part - \#end if - </hide> - <tab>FE Corrections</tab> - </param> - <param> - <name>Ch$(n): Enable IQ Imbalance Correction</name> - <key>iq_imbal_enb$(n)</key> - <value>""</value> - <type>raw</type> - <hide> - \#if not \$nchan() > $n - all - \#else - part - \#end if - </hide> - <tab>FE Corrections</tab> - </param> -#end if +PARAMS_TMPL = """ +- id: center_freq${n} + label: 'Ch${n}: Center Freq (Hz)' + category: RF Options + dtype: real + default: '0' + hide: ${'$'}{ 'none' if (nchan > ${n}) else 'all' } +- id: gain${n} + label: 'Ch${n}: Gain Value' + category: RF Options + dtype: float + default: '0' + hide: ${'$'}{ 'none' if nchan > ${n} else 'all' } +- id: norm_gain${n} + label: 'Ch${n}: Gain Type' + category: RF Options + dtype: bool + default: 'False' + options: ['False', 'True'] + option_labels: [Absolute (dB), Normalized] + hide: ${'$'}{ 'all' if nchan <= ${n} else ('none' if bool(eval('norm_gain' + str(n))) else 'part')} +- id: ant${n} + label: 'Ch${n}: Antenna' + category: RF Options + dtype: string +% if sourk == 'source': + options: [TX/RX, RX2, RX1] + option_labels: [TX/RX, RX2, RX1] +% else: + options: [TX/RX] + option_labels: [TX/RX] +% endif + hide: ${'$'}{ 'all' if not nchan > ${n} else ('none' if eval('ant' + str(n)) else 'part')} +- id: bw${n} + label: 'Ch${n}: Bandwidth (Hz)' + category: RF Options + dtype: real + default: '0' + hide: ${'$'}{ 'all' if not nchan > ${n} else ('none' if eval('bw' + str(n)) else 'part')} +% if sourk == 'source': +- id: lo_source${n} + label: 'Ch${n}: LO Source' + category: RF Options + dtype: string + default: internal + options: [internal, external, companion] + hide: ${'$'}{ 'all' if not nchan > ${n} else ('all' if hide_lo_controls else 'none')} +- id: lo_export + label: 'Ch${n}: LO Export' + category: RF Options + dtype: bool + default: 'False' + options: ['True', 'False'] + hide: ${'$'}{ 'all' if not nchan > ${n} else ('all' if hide_lo_controls else 'none')} +- id: dc_offs_enb${n} + label: 'Ch${n}: Enable DC Offset Correction' + category: FE Corrections + dtype: raw + default: '""' + hide: ${'$'}{ 'all' if not nchan > ${n} else 'part'} +- id: iq_imbal_enb${n} + label: 'Ch${n}: Enable IQ Imbalance Correction' + category: FE Corrections + dtype: raw + default: '""' + hide: ${'$'}{ 'all' if not nchan > ${n} else 'part'} +% endif """ SHOW_CMD_PORT_PARAM = """ - <param> - <name>Show Command Port</name> - <key>hide_cmd_port</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>False</key> - </option> - <option> - <name>No</name> - <key>True</key> - </option> - <tab>Advanced</tab> - </param> +- id: hide_cmd_port + label: Show Command Port + category: Advanced + dtype: enum + default: 'False' + options: ['False', 'True'] + option_labels: ['Yes', 'No'] + hide: part """ SHOW_LO_CONTROLS_PARAM = """ - <param> - <name>Show LO Controls</name> - <key>hide_lo_controls</key> - <value>True</value> - <type>bool</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>False</key> - </option> - <option> - <name>No</name> - <key>True</key> - </option> - <tab>Advanced</tab> - </param> +- id: hide_lo_controls + label: Show LO Controls + category: Advanced + dtype: bool + default: 'True' + options: ['False', 'True'] + option_labels: ['Yes', 'No'] + hide: part """ -TSBTAG_PARAM = """ <param> - <name>TSB tag name</name> - <key>len_tag_name</key> - <value></value> - <type>string</type> - <hide>\#if len(str(\$len_tag_name())) then 'none' else 'part'#</hide> - </param>""" +TSBTAG_PARAM = """ +- id: len_tag_name + label: TSB tag name + dtype: string + hide: ${ 'none' if len(str(len_tag_name)) else 'part'} +""" TSBTAG_ARG = """ - #if $len_tag_name() - $len_tag_name, - #end if""" +${'%'} if len_tag_name(): +${'$'}{len_tag_name}, +${'%'} endif +""" def parse_tmpl(_tmpl, **kwargs): - from Cheetah import Template - return str(Template.Template(_tmpl, kwargs)) + from mako.template import Template + block_template = Template(_tmpl) + return str(block_template.render(**kwargs)) max_num_mboards = 8 max_num_channels = max_num_mboards*4 @@ -689,13 +364,13 @@ max_num_channels = max_num_mboards*4 if __name__ == '__main__': import sys for file in sys.argv[1:]: - if file.endswith ('source.xml'): + if file.endswith ('source.block.yml'): sourk = 'source' direction = 'out' - elif file.endswith ('sink.xml'): + elif file.endswith ('sink.block.yml'): sourk = 'sink' direction = 'in' - else: raise Exception('is %s a source or sink?'%file) + else: raise Exception('is % a source or sink?'%file) params = ''.join([parse_tmpl(PARAMS_TMPL, n=n, sourk=sourk) for n in range(max_num_channels)]) params += SHOW_CMD_PORT_PARAM @@ -704,6 +379,7 @@ if __name__ == '__main__': params += TSBTAG_PARAM lentag_arg = TSBTAG_ARG else: lentag_arg = '' + open(file, 'w').write(parse_tmpl(MAIN_TMPL, lentag_arg=lentag_arg, max_nchan=max_num_channels, diff --git a/gr-uhd/grc/uhd.tree.yml b/gr-uhd/grc/uhd.tree.yml new file mode 100644 index 0000000000..a4d140d779 --- /dev/null +++ b/gr-uhd/grc/uhd.tree.yml @@ -0,0 +1,5 @@ +'[Core]': +- UHD: + - uhd_usrp_source + - uhd_usrp_sink + - uhd_amsg_source diff --git a/gr-uhd/grc/uhd_amsg_source.block.yml b/gr-uhd/grc/uhd_amsg_source.block.yml new file mode 100644 index 0000000000..b07ab77913 --- /dev/null +++ b/gr-uhd/grc/uhd_amsg_source.block.yml @@ -0,0 +1,18 @@ +id: uhd_amsg_source +label: 'UHD: USRP Async Msg Source' + +parameters: +- id: dev_addr + label: Device Addr + dtype: string + hide: ${ 'none' if dev_addr else 'part' } + +outputs: +- domain: stream + dtype: msg + +templates: + imports: from gnuradio import uhd + make: uhd.amsg_source(device_addr=${dev_addr}, msgq=${id}_msgq_out) + +file_format: 1 diff --git a/gr-uhd/grc/uhd_amsg_source.xml b/gr-uhd/grc/uhd_amsg_source.xml deleted file mode 100644 index 78c9d7b58e..0000000000 --- a/gr-uhd/grc/uhd_amsg_source.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0"?> -<block> - <name>UHD: USRP Async Msg Source</name> - <key>uhd_amsg_source</key> - <import>from gnuradio import uhd</import> - <make>uhd.amsg_source(device_addr=$dev_addr, msgq=$(id)_msgq_out)</make> - <param> - <name>Device Addr</name> - <key>dev_addr</key> - <value></value> - <type>string</type> - <hide> - #if $dev_addr() - none - #else - part - #end if - </hide> - </param> - <source> - <name>out</name> - <type>msg</type> - </source> -</block> diff --git a/gr-uhd/grc/uhd_block_tree.xml b/gr-uhd/grc/uhd_block_tree.xml deleted file mode 100644 index c598645526..0000000000 --- a/gr-uhd/grc/uhd_block_tree.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Block Tree for uhd blocks. -################################################### - --> -<cat> - <name>[Core]</name> <!-- Blank for Root Name --> - <cat> - <name>UHD</name> - <block>uhd_usrp_source</block> - <block>uhd_usrp_sink</block> - <block>uhd_amsg_source</block> - </cat> -</cat> diff --git a/grc/blocks/CMakeLists.txt b/grc/blocks/CMakeLists.txt index 2dbc7c6d0d..f5ec6dd214 100644 --- a/grc/blocks/CMakeLists.txt +++ b/grc/blocks/CMakeLists.txt @@ -21,40 +21,39 @@ include(GrPython) file(GLOB yml_files "*.yml") -file(GLOB xml_files "*.xml") -macro(REPLACE_IN_FILE _xml_block match replace) - set(xml_block_src "${CMAKE_CURRENT_SOURCE_DIR}/${_xml_block}") - set(xml_block "${CMAKE_CURRENT_BINARY_DIR}/${_xml_block}") +macro(REPLACE_IN_FILE _yml_block match replace) + set(yml_block_src "${CMAKE_CURRENT_SOURCE_DIR}/${_yml_block}") + set(yml_block "${CMAKE_CURRENT_BINARY_DIR}/${_yml_block}") - list(REMOVE_ITEM xml_files "${xml_block_src}") - file(READ "${xml_block_src}" xml_block_src_text) + list(REMOVE_ITEM yml_files "${yml_block_src}") + file(READ "${yml_block_src}" yml_block_src_text) string(REPLACE "${match}" "${replace}" - xml_block_text "${xml_block_src_text}") - file(WRITE "${xml_block}" "${xml_block_text}") + yml_block_text "${yml_block_src_text}") + file(WRITE "${yml_block}" "${yml_block_text}") - list(APPEND generated_xml_files "${xml_block}") + list(APPEND generated_yml_files "${yml_block}") endmacro() -macro(GEN_BLOCK_XML _generator _xml_block) +macro(GEN_BLOCK_YML _generator _yml_block) set(generator ${CMAKE_CURRENT_SOURCE_DIR}/${_generator}) - set(xml_block ${CMAKE_CURRENT_BINARY_DIR}/${_xml_block}) - list(APPEND generated_xml_files ${xml_block}) + set(yml_block ${CMAKE_CURRENT_BINARY_DIR}/${_yml_block}) + list(APPEND generated_yml_files ${yml_block}) add_custom_command( - DEPENDS ${generator} OUTPUT ${xml_block} - COMMAND ${PYTHON_EXECUTABLE} ${generator} ${xml_block} + DEPENDS ${generator} OUTPUT ${yml_block} + COMMAND ${PYTHON_EXECUTABLE} ${generator} ${yml_block} ) endmacro() -GEN_BLOCK_XML(variable_struct.xml.py variable_struct.xml) +GEN_BLOCK_YML(variable_struct.block.yml.py variable_struct.block.yml) if(DESIRED_QT_VERSION EQUAL 4) - REPLACE_IN_FILE(options.xml PyQt5 PyQt4) + REPLACE_IN_FILE(options.yml PyQt5 PyQt4) endif() -add_custom_target(grc_generated_xml ALL DEPENDS ${generated_xml_files}) +add_custom_target(grc_generated_yml ALL DEPENDS ${generated_yml_files}) install( - FILES ${yml_files} ${xml_files} ${generated_xml_files} + FILES ${yml_files} ${generated_yml_files} DESTINATION ${GRC_BLOCKS_DIR} ) diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml deleted file mode 100644 index 2a063f1f60..0000000000 --- a/grc/blocks/block_tree.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0"?> -<cat> - <name>[Core]</name> - <cat> - <name>Misc</name> - <block>pad_source</block> - <block>pad_sink</block> - <block>virtual_source</block> - <block>virtual_sink</block> - - <block>epy_module</block> - - <block>note</block> - <block>import</block> - </cat> - <cat> - <name>Variables</name> - <block>variable</block> - <block>variable_struct</block> - <block>variable_config</block> - <block>variable_function_probe</block> - <block>parameter</block> - </cat> -</cat> diff --git a/grc/blocks/grc.tree.yml b/grc/blocks/grc.tree.yml new file mode 100644 index 0000000000..c84a6dc478 --- /dev/null +++ b/grc/blocks/grc.tree.yml @@ -0,0 +1,15 @@ +'[Core]': +- Misc: + - pad_source + - pad_sink + - virtual_source + - virtual_sink + - epy_module + - note + - import +- Variables: + - variable + - variable_struct + - variable_config + - variable_function_probe + - parameter diff --git a/grc/blocks/import.block.yml b/grc/blocks/import.block.yml new file mode 100644 index 0000000000..2d36b7396d --- /dev/null +++ b/grc/blocks/import.block.yml @@ -0,0 +1,20 @@ +id: import_ +label: Import + +parameters: +- id: imports + label: Import + dtype: import + +templates: + imports: ${imports} + +documentation: |- + Import additional python modules into the namespace. + + Examples: + from gnuradio.filter import firdes + import math,cmath + from math import pi + +file_format: 1 diff --git a/grc/blocks/import.xml b/grc/blocks/import.xml deleted file mode 100644 index 58e99a2d01..0000000000 --- a/grc/blocks/import.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Import python modules into the namespace -################################################### - --> -<block> - <name>Import</name> - <key>import</key> - <import>$imports</import> - <make></make> - <param> - <name>Import</name> - <key>imports</key> - <value></value> - <type>import</type> - </param> - <doc> -Import additional python modules into the namespace. - -Examples: -from gnuradio.filter import firdes -import math,cmath -from math import pi - </doc> -</block> diff --git a/grc/blocks/note.block.yml b/grc/blocks/note.block.yml new file mode 100644 index 0000000000..3f21a75ceb --- /dev/null +++ b/grc/blocks/note.block.yml @@ -0,0 +1,9 @@ +id: note +label: Note + +parameters: +- id: note + label: Note + dtype: string + +file_format: 1 diff --git a/grc/blocks/note.xml b/grc/blocks/note.xml deleted file mode 100644 index db6687c033..0000000000 --- a/grc/blocks/note.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Note Block (dummy) -################################################### - --> -<block> - <name>Note</name> - <key>note</key> - <make></make> - <param> - <name>Note</name> - <key>note</key> - <value></value> - <type>string</type> - </param> -</block> diff --git a/grc/blocks/options.block.yml b/grc/blocks/options.block.yml new file mode 100644 index 0000000000..ab18f8ae5f --- /dev/null +++ b/grc/blocks/options.block.yml @@ -0,0 +1,146 @@ +id: options +label: Options + +parameters: +- id: title + label: Title + dtype: string + hide: ${ ('none' if title else 'part') } +- id: author + label: Author + dtype: string + hide: ${ ('none' if author else 'part') } +- id: description + label: Description + dtype: string + hide: ${ ('none' if description else 'part') } +- id: window_size + label: Canvas Size + dtype: int_vector + hide: part +- id: generate_options + label: Generate Options + dtype: enum + default: qt_gui + options: [qt_gui, bokeh_gui, no_gui, hb, hb_qt_gui] + option_labels: [QT GUI, Bokeh GUI, No GUI, Hier Block, Hier Block (QT GUI)] +- id: category + label: Category + dtype: string + default: '[GRC Hier Blocks]' + hide: ${ ('none' if generate_options.startswith('hb') else 'all') } +- id: run_options + label: Run Options + dtype: enum + default: prompt + options: [run, prompt] + option_labels: [Run to Completion, Prompt for Exit] + hide: ${ ('none' if generate_options == 'no_gui' else 'all') } +- id: placement + label: Widget Placement + dtype: int_vector + default: (0,0) + hide: ${ ('part' if generate_options == 'bokeh_gui' else 'all') } +- id: sizing_mode + label: Sizing Mode + dtype: enum + default: fixed + options: [fixed, stretch_both, scale_width, scale_height, scale_both] + option_labels: [Fixed, Stretch Both, Scale Width, Scale Height, Scale Both] + hide: ${ ('part' if generate_options == 'bokeh_gui' else 'all') } +- id: run + label: Run + dtype: bool + default: 'True' + options: ['True', 'False'] + option_labels: [Autostart, 'Off'] + hide: ${ ('all' if generate_options not in ('qt_gui', 'bokeh_gui') else ('part' + if run else 'none')) } +- id: max_nouts + label: Max Number of Output + dtype: int + default: '0' + hide: ${ ('all' if generate_options.startswith('hb') else ('none' if max_nouts + else 'part')) } +- id: realtime_scheduling + label: Realtime Scheduling + dtype: enum + options: ['', '1'] + option_labels: ['Off', 'On'] + hide: ${ ('all' if generate_options.startswith('hb') else ('none' if realtime_scheduling + else 'part')) } +- id: qt_qss_theme + label: QSS Theme + dtype: file_open + hide: ${ ('all' if generate_options != 'qt_gui' else ('none' if qt_qss_theme else + 'part')) } +- id: thread_safe_setters + label: Thread-safe setters + category: Advanced + dtype: enum + options: ['', '1'] + option_labels: ['Off', 'On'] + hide: part +- id: run_command + label: Run Command + category: Advanced + dtype: string + default: '{python} -u {filename}' + hide: ${ ('all' if generate_options.startswith('hb') else 'part') } +- id: hier_block_src_path + label: Hier Block Source Path + category: Advanced + dtype: string + default: '.:' + hide: part + +asserts: +- ${ not window_size or len(window_size) == 2 } +- ${ not window_size or 300 <= window_size[0] <= 4096 } +- ${ not window_size or 300 <= window_size[1] <= 4096 } +- ${ len(placement) == 4 or len(placement) == 2 } +- ${ all(i >= 0 for i in placement) } + +templates: + imports: |- + from gnuradio import gr + from gnuradio.filter import firdes + % if generate_options == 'qt_gui': + from PyQt5 import Qt + import sys + % endif + % if generate_options == 'bokeh_gui': + import time + import signal + import functools + from bokeh.client import push_session + from bokeh.plotting import curdoc + % endif + % if not generate_options.startswith('hb'): + from argparse import ArgumentParser + from gnuradio.eng_arg import eng_float, intx + from gnuradio import eng_notation + % endif + callbacks: + - 'if ${run}: self.start() + + else: self.stop(); self.wait()' + +documentation: |- + The options block sets special parameters for the flow graph. Only one option block is allowed per flow graph. + + Title, author, and description parameters are for identification purposes. + + The window size controls the dimensions of the flow graph editor. The window size (width, height) must be between (300, 300) and (4096, 4096). + + The generate options controls the type of code generated. Non-graphical flow graphs should avoid using graphical sinks or graphical variable controls. + + In a graphical application, run can be controlled by a variable to start and stop the flowgraph at runtime. + + The id of this block determines the name of the generated file and the name of the class. For example, an id of my_block will generate the file my_block.py and class my_block(gr.... + + The category parameter determines the placement of the block in the block selection window. The category only applies when creating hier blocks. To put hier blocks into the root category, enter / for the category. + + The Max Number of Output is the maximum number of output items allowed for any block in the flowgraph; to disable this set the max_nouts equal to 0.Use this to adjust the maximum latency a flowgraph can exhibit. + +file_format: 1 diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml deleted file mode 100644 index 21d1c9ddee..0000000000 --- a/grc/blocks/options.xml +++ /dev/null @@ -1,250 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Options Block: -## options for window size, -## and flow graph building. -################################################### - --> -<block> - <name>Options</name> - <key>options</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.filter import firdes</import> - <import>#if $generate_options() == 'qt_gui' -from PyQt5 import Qt -import sys -#end if -#if $generate_options() == 'bokeh_gui' -import time -import signal -import functools -from bokeh.client import push_session -from bokeh.plotting import curdoc -#end if -#if not $generate_options().startswith('hb') -from argparse import ArgumentParser -from gnuradio.eng_arg import eng_float, intx -from gnuradio import eng_notation -#end if</import> - <make></make> - <callback>if $run: self.start() -else: self.stop(); self.wait()</callback> - <param> - <name>Title</name> - <key>title</key> - <value></value> - <type>string</type> - <hide>#if $title() then 'none' else 'part'#</hide> - </param> - <param> - <name>Author</name> - <key>author</key> - <value></value> - <type>string</type> - <hide>#if $author() then 'none' else 'part'#</hide> - </param> - <param> - <name>Description</name> - <key>description</key> - <value></value> - <type>string</type> - <hide>#if $description() then 'none' else 'part'#</hide> - </param> - <param> - <name>Canvas Size</name> - <key>window_size</key> - <value></value> - <type>int_vector</type> - <hide>part</hide> - </param> - <param> - <name>Generate Options</name> - <key>generate_options</key> - <value>qt_gui</value> - <type>enum</type> - <option> - <name>Bokeh GUI</name> - <key>bokeh_gui</key> - </option> - <option> - <name>QT GUI</name> - <key>qt_gui</key> - </option> - <option> - <name>No GUI</name> - <key>no_gui</key> - </option> - <option> - <name>Hier Block</name> - <key>hb</key> - </option> - <option> - <name>Hier Block (QT GUI)</name> - <key>hb_qt_gui</key> - </option> - </param> - <param> - <name>Category</name> - <key>category</key> - <value>[GRC Hier Blocks]</value> - <type>string</type> - <hide>#if $generate_options().startswith('hb') then 'none' else 'all'#</hide> - </param> - <param> - <name>Run Options</name> - <key>run_options</key> - <value>prompt</value> - <type>enum</type> - <hide>#if $generate_options() == 'no_gui' then 'none' else 'all'#</hide> - <option> - <name>Run to Completion</name> - <key>run</key> - </option> - <option> - <name>Prompt for Exit</name> - <key>prompt</key> - </option> - </param> - <param> - <name>Widget Placement</name> - <key>placement</key> - <value>(0,0)</value> - <type>int_vector</type> - <hide>#if $generate_options() == 'bokeh_gui' then 'part' else 'all'#</hide> - </param> - <param> - <name>Sizing Mode</name> - <key>sizing_mode</key> - <value>fixed</value> - <type>enum</type> - <hide>#if $generate_options() == 'bokeh_gui' then 'part' else 'all'#</hide> - <option> - <name>Fixed</name> - <key>fixed</key> - </option> - <option> - <name>Stretch Both</name> - <key>stretch_both</key> - </option> - <option> - <name>Scale Width</name> - <key>scale_width</key> - </option> - <option> - <name>Scale Height</name> - <key>scale_height</key> - </option> - <option> - <name>Scale Both</name> - <key>scale_both</key> - </option> - </param> - <param> - <name>Run</name> - <key>run</key> - <value>True</value> - <type>bool</type> - <hide>#if $generate_options() not in ('qt_gui', 'bokeh_gui') then 'all' else ('part' if $run() else 'none')#</hide> - <option> - <name>Autostart</name> - <key>True</key> - </option> - <option> - <name>Off</name> - <key>False</key> - </option> - </param> - <param> - <name>Max Number of Output</name> - <key>max_nouts</key> - <value>0</value> - <type>int</type> - <hide>#if $generate_options().startswith('hb') then 'all' else ('none' if $max_nouts() else 'part')#</hide> - </param> - <param> - <name>Realtime Scheduling</name> - <key>realtime_scheduling</key> - <value></value> - <type>enum</type> - <hide>#if $generate_options().startswith('hb') then 'all' else ('none' if $realtime_scheduling() else 'part')#</hide> - <option> - <name>Off</name> - <key></key> - </option> - <option> - <name>On</name> - <key>1</key> - </option> - </param> - <param> - <name>QSS Theme</name> - <key>qt_qss_theme</key> - <value></value> - <type>file_open</type> - <hide>#if $generate_options() != 'qt_gui' then 'all' else ('none' if $qt_qss_theme() else 'part')#</hide> - </param> - <param> - <name>Thread-safe setters</name> - <key>thread_safe_setters</key> - <value></value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Off</name> - <key></key> - </option> - <option> - <name>On</name> - <key>1</key> - </option> - <tab>Advanced</tab> - </param> - <param> - <name>Run Command</name> - <key>run_command</key> - <value>{python} -u {filename}</value> - <type>string</type> - <hide>#if $generate_options().startswith('hb') then 'all' else 'part'</hide> - <tab>Advanced</tab> - </param> - <param> - <name>Hier Block Source Path</name> - <key>hier_block_src_path</key> - <value>.:</value> - <type>string</type> - <hide>part</hide> - <tab>Advanced</tab> - </param> - <check>not $window_size or len($window_size) == 2</check> - <check>not $window_size or 300 <= $(window_size)[0] <= 4096</check> - <check>not $window_size or 300 <= $(window_size)[1] <= 4096</check> - <check>len($placement) == 4 or len($placement) == 2</check> - <check>all(i >= 0 for i in $(placement))</check> - <doc> -The options block sets special parameters for the flow graph. \ -Only one option block is allowed per flow graph. - -Title, author, and description parameters are for identification purposes. - -The window size controls the dimensions of the flow graph editor. \ -The window size (width, height) must be between (300, 300) and (4096, 4096). - -The generate options controls the type of code generated. \ -Non-graphical flow graphs should avoid using graphical sinks or graphical variable controls. - -In a graphical application, \ -run can be controlled by a variable to start and stop the flowgraph at runtime. - -The id of this block determines the name of the generated file and the name of the class. \ -For example, an id of my_block will generate the file my_block.py and class my_block(gr.... - -The category parameter determines the placement of the block in the block selection window. \ -The category only applies when creating hier blocks. \ -To put hier blocks into the root category, enter / for the category. - -The Max Number of Output is the maximum number of output items allowed for any block \ -in the flowgraph; to disable this set the max_nouts equal to 0.\ -Use this to adjust the maximum latency a flowgraph can exhibit. - </doc> -</block> diff --git a/grc/blocks/pad_sink.block.yml b/grc/blocks/pad_sink.block.yml new file mode 100644 index 0000000000..d304a998b4 --- /dev/null +++ b/grc/blocks/pad_sink.block.yml @@ -0,0 +1,51 @@ +id: pad_sink +label: Pad Sink + +parameters: +- id: label + label: Label + dtype: string + default: out +- id: type + label: Input Type + dtype: enum + options: [complex, float, int, short, byte, bit, message, ''] + option_labels: [Complex, Float, Int, Short, Byte, Bits, Message, Wildcard] + option_attributes: + size: [gr.sizeof_gr_complex, gr.sizeof_float, gr.sizeof_int, gr.sizeof_short, + gr.sizeof_char, gr.sizeof_char, '0', '0'] + hide: part +- id: vlen + label: Vec Length + dtype: int + default: '1' + hide: ${ 'part' if vlen == 1 else 'none' } +- id: num_streams + label: Num Streams + dtype: int + default: '1' + hide: part +- id: optional + label: Optional + dtype: bool + default: 'False' + options: ['True', 'False'] + option_labels: [Optional, Required] + hide: part + +inputs: +- domain: stream + dtype: ${ type } + vlen: ${ vlen } + multiplicity: ${ num_streams } + +asserts: +- ${ vlen > 0 } +- ${ num_streams > 0 } + +documentation: |- + The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block. + + Pad sink will be ordered alphabetically by their ids. The first pad sink will have an index of 0. + +file_format: 1 diff --git a/grc/blocks/pad_sink.xml b/grc/blocks/pad_sink.xml deleted file mode 100644 index 8ea8871d2e..0000000000 --- a/grc/blocks/pad_sink.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Pad Sink: IO Pads -################################################### - --> -<block> - <name>Pad Sink</name> - <key>pad_sink</key> - <make></make> - <param> - <name>Label</name> - <key>label</key> - <value>out</value> - <type>string</type> - </param> - <param> - <name>Input Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - <option> - <name>Bits</name> - <key>bit</key> - <opt>size:gr.sizeof_char</opt> - </option> - <option> - <name>Message</name> - <key>message</key> - <opt>size:0</opt> - </option> - <option> - <name>Wildcard</name> - <key></key> - <opt>size:0</opt> - </option> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - - <param> - <name>Num Streams</name> - <key>num_streams</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Optional</name> - <key>optional</key> - <value>False</value> - <type>bool</type> - <hide>part</hide> - <option> - <name>Optional</name> - <key>True</key> - </option> - <option> - <name>Required</name> - <key>False</key> - </option> - </param> - <check>$vlen > 0</check> - <check>$num_streams > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_streams</nports> - </sink> - <doc> -The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block. - -Pad sink will be ordered alphabetically by their ids. The first pad sink will have an index of 0. - </doc> -</block> diff --git a/grc/blocks/pad_source.block.yml b/grc/blocks/pad_source.block.yml new file mode 100644 index 0000000000..92f7a8b822 --- /dev/null +++ b/grc/blocks/pad_source.block.yml @@ -0,0 +1,51 @@ +id: pad_source +label: Pad Source + +parameters: +- id: label + label: Label + dtype: string + default: in +- id: type + label: Output Type + dtype: enum + options: [complex, float, int, short, byte, bit, message, ''] + option_labels: [Complex, Float, Int, Short, Byte, Bits, Message, Wildcard] + option_attributes: + size: [gr.sizeof_gr_complex, gr.sizeof_float, gr.sizeof_int, gr.sizeof_short, + gr.sizeof_char, gr.sizeof_char, '0', '0'] + hide: part +- id: vlen + label: Vec Length + dtype: int + default: '1' + hide: ${ 'part' if vlen == 1 else 'none' } +- id: num_streams + label: Num Streams + dtype: int + default: '1' + hide: part +- id: optional + label: Optional + dtype: bool + default: 'False' + options: ['True', 'False'] + option_labels: [Optional, Required] + hide: part + +outputs: +- domain: stream + dtype: ${ type } + vlen: ${ vlen } + multiplicity: ${ num_streams } + +asserts: +- ${ vlen > 0 } +- ${ num_streams > 0 } + +documentation: |- + The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block. + + Pad sources will be ordered alphabetically by their ids. The first pad source will have an index of 0. + +file_format: 1 diff --git a/grc/blocks/pad_source.xml b/grc/blocks/pad_source.xml deleted file mode 100644 index 3d8ccbed6a..0000000000 --- a/grc/blocks/pad_source.xml +++ /dev/null @@ -1,104 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Pad Source: IO Pads -################################################### - --> -<block> - <name>Pad Source</name> - <key>pad_source</key> - <make></make> - <param> - <name>Label</name> - <key>label</key> - <value>in</value> - <type>string</type> - </param> - <param> - <name>Output Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - <option> - <name>Bits</name> - <key>bit</key> - <opt>size:gr.sizeof_char</opt> - </option> - <option> - <name>Message</name> - <key>message</key> - <opt>size:0</opt> - </option> - <option> - <name>Wildcard</name> - <key></key> - <opt>size:0</opt> - </option> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - - <param> - <name>Num Streams</name> - <key>num_streams</key> - <value>1</value> - <type>int</type> - </param> - - <param> - <name>Optional</name> - <key>optional</key> - <value>False</value> - <type>bool</type> - <hide>part</hide> - <option> - <name>Optional</name> - <key>True</key> - </option> - <option> - <name>Required</name> - <key>False</key> - </option> - </param> - <check>$vlen > 0</check> - <check>$num_streams > 0</check> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_streams</nports> - </source> - <doc> -The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block. - -Pad sources will be ordered alphabetically by their ids. The first pad source will have an index of 0. - </doc> -</block> diff --git a/grc/blocks/parameter.block.yml b/grc/blocks/parameter.block.yml new file mode 100644 index 0000000000..ac97c7d319 --- /dev/null +++ b/grc/blocks/parameter.block.yml @@ -0,0 +1,55 @@ +id: parameter +label: Parameter + +parameters: +- id: label + label: Label + dtype: string + hide: ${ ('none' if label else 'part') } +- id: value + label: Value + dtype: ${ type.type } + default: '0' +- id: type + label: Type + dtype: enum + options: ['', complex, eng_float, intx, long, str] + option_labels: [None, Complex, Float, Int, Long, String] + option_attributes: + type: [raw, complex, real, int, int, string] + hide: ${ ('none' if type else 'part') } +- id: short_id + label: Short ID + dtype: string + hide: ${ 'all' if not type else ('none' if short_id else 'part') } +- id: hide + label: Show + dtype: enum + options: [none, part] + option_labels: [Always, Only in Properties] + hide: part + +asserts: +- ${ len(short_id) in (0, 1) } +- ${ short_id == '' or short_id.isalpha() } + +templates: + var_make: self.${id} = ${id} + make: ${value} + +documentation: |- + This block represents a parameter to the flow graph. A parameter can be used to pass command line arguments into a top block. Or, parameters can pass arguments into an instantiated hierarchical block. + + The paramater value cannot depend on any variables. + + Leave the label blank to use the parameter id as the label. + + When type is not None, this parameter also becomes a command line option of the form: + + -[short_id] --[id] [value] + + The Short ID field may be left blank. + + To disable showing the parameter on the hierarchical block in GRC, use Only in Properties option in the Show field. + +file_format: 1 diff --git a/grc/blocks/parameter.xml b/grc/blocks/parameter.xml deleted file mode 100644 index f01527acb0..0000000000 --- a/grc/blocks/parameter.xml +++ /dev/null @@ -1,118 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Parameter block: a grc variable with key, value -################################################### - --> -<block> - <name>Parameter</name> - <key>parameter</key> - <var_make>self.$(id) = $(id)</var_make> - <make>$value</make> - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - <hide>#if $label() then 'none' else 'part'#</hide> - </param> - <param> - <name>Value</name> - <key>value</key> - <value>0</value> - <type>$type.type</type> - </param> - <param> - <name>Type</name> - <key>type</key> - <value></value> - <type>enum</type> - <hide>#if $type() then 'none' else 'part'#</hide> - <option> - <name>None</name> - <key></key> - <opt>type:raw</opt> - </option> - <option> - <name>Complex</name> - <key>complex</key> - <opt>type:complex</opt> - </option> - <option> - <name>Float</name> - <key>eng_float</key> - <opt>type:real</opt> - </option> - <option> - <name>Int</name> - <key>intx</key> - <opt>type:int</opt> - </option> - <option> - <name>Long</name> - <key>long</key> - <opt>type:int</opt> - </option> - <option> - <name>String</name> - <key>str</key> - <opt>type:string</opt> - </option> - <!-- Do not forget to add option value type handler import into - grc/python/flow_graph.tmpl for each new type. --> - <!-- not supported yet in tmpl - <option> - <name>Boolean</name> - <key>bool</key> - <opt>type:bool</opt> - </option> - --> - </param> - <param> - <name>Short ID</name> - <key>short_id</key> - <value></value> - <type>string</type> - <hide>#if not $type() -all#slurp -#elif $short_id() -none#slurp -#else -part#slurp -#end if</hide> - </param> - <param> - <name>Show</name> - <key>hide</key> - <value></value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Always</name> - <key>none</key> <!--## Do not hide the parameter value--> - </option> - <option> - <name>Only in Properties</name> - <key>part</key> <!--## Partially hide the parameter value--> - </option> - </param> - <check>len($short_id) in (0, 1)</check> - <check>$short_id == '' or $(short_id).isalpha()</check> - <doc> -This block represents a parameter to the flow graph. \ -A parameter can be used to pass command line arguments into a top block. \ -Or, parameters can pass arguments into an instantiated hierarchical block. - -The paramater value cannot depend on any variables. - -Leave the label blank to use the parameter id as the label. - -When type is not None, this parameter also becomes a command line option of the form: - --[short_id] --[id] [value] - -The Short ID field may be left blank. - -To disable showing the parameter on the hierarchical block in GRC, use Only in Properties option in the Show field. - </doc> -</block> diff --git a/grc/blocks/variable.block.yml b/grc/blocks/variable.block.yml new file mode 100644 index 0000000000..fa62dabe87 --- /dev/null +++ b/grc/blocks/variable.block.yml @@ -0,0 +1,19 @@ +id: variable +label: Variable + +parameters: +- id: value + label: Value + dtype: raw + default: '0' +value: ${ value } + +templates: + var_make: self.${id} = ${id} = ${value} + callbacks: + - self.set_${id}(${value}) + +documentation: |- + This block maps a value to a unique variable. This variable block has no graphical representation. + +file_format: 1 diff --git a/grc/blocks/variable.xml b/grc/blocks/variable.xml deleted file mode 100644 index afee0f5d4a..0000000000 --- a/grc/blocks/variable.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable block: a grc variable with key, value -################################################### - --> -<block> - <name>Variable</name> - <key>variable</key> - <var_make>self.$(id) = $(id) = $value</var_make> - <make></make> - <callback>self.set_$(id)($value)</callback> - <param> - <name>Value</name> - <key>value</key> - <value>0</value> - <type>raw</type> - </param> - <doc> -This block maps a value to a unique variable. \ -This variable block has no graphical representation. - </doc> -</block> diff --git a/grc/blocks/variable_config.block.yml b/grc/blocks/variable_config.block.yml new file mode 100644 index 0000000000..bb64ea2a8f --- /dev/null +++ b/grc/blocks/variable_config.block.yml @@ -0,0 +1,58 @@ +id: variable_config +label: Variable Config + +parameters: +- id: value + label: Default Value + dtype: ${ type } + default: '0' +- id: type + label: Type + dtype: enum + default: real + options: [real, int, bool, string] + option_labels: [Float, Int, Bool, String] + option_attributes: + get: [getfloat, getint, getboolean, get] +- id: config_file + label: Config File + dtype: file_open + default: default +- id: section + label: Section + dtype: string + default: main +- id: option + label: Option + dtype: string + default: key +- id: writeback + label: WriteBack + dtype: raw + default: None +value: ${ value } + +templates: + imports: import ConfigParser + var_make: 'self._${id}_config = ConfigParser.ConfigParser() + + self._${id}_config.read(${config_file}) + + try: ${id} = self._${id}_config.${type.get}(${section}, ${option}) + + except: ${id} = ${value} + + self.${id} = ${id}' + callbacks: + - self.set_${id}(${value}) + - "self._${id}_config = ConfigParser.ConfigParser()\nself._${id}_config.read(${config_file})\n\ + if not self._${id}_config.has_section(${section}):\n\tself._${id}_config.add_section(${section})\n\ + self._${id}_config.set(${section}, ${option}, str(${writeback}))\nself._${id}_config.write(open(${config_file},\ + \ 'w'))" + +documentation: |- + This block represents a variable that can be read from a config file. + + To save the value back into the config file: enter the name of another variable into the writeback param. When the other variable is changed at runtime, the config file will be re-written. + +file_format: 1 diff --git a/grc/blocks/variable_config.xml b/grc/blocks/variable_config.xml deleted file mode 100644 index 11bff9edc2..0000000000 --- a/grc/blocks/variable_config.xml +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable Config block: -## a variable that reads and writes to a config file -################################################### - --> -<block> - <name>Variable Config</name> - <key>variable_config</key> - <import>import ConfigParser</import> - <var_make>self._$(id)_config = ConfigParser.ConfigParser() -self._$(id)_config.read($config_file) -try: $(id) = self._$(id)_config.$(type.get)($section, $option) -except: $(id) = $value -self.$(id) = $(id)</var_make> - <make></make> - <callback>self.set_$(id)($value)</callback> - <callback>self._$(id)_config = ConfigParser.ConfigParser() -self._$(id)_config.read($config_file) -if not self._$(id)_config.has_section($section): - self._$(id)_config.add_section($section) -self._$(id)_config.set($section, $option, str($writeback)) -self._$(id)_config.write(open($config_file, 'w'))</callback> - <param> - <name>Default Value</name> - <key>value</key> - <value>0</value> - <type>$type</type> - </param> - <param> - <name>Type</name> - <key>type</key> - <value>real</value> - <type>enum</type> - <option> - <name>Float</name> - <key>real</key> - <opt>get:getfloat</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>get:getint</opt> - </option> - <option> - <name>Bool</name> - <key>bool</key> - <opt>get:getboolean</opt> - </option> - <option> - <name>String</name> - <key>string</key> - <opt>get:get</opt> - </option> - </param> - <param> - <name>Config File</name> - <key>config_file</key> - <value>default</value> - <type>file_open</type> - </param> - <param> - <name>Section</name> - <key>section</key> - <value>main</value> - <type>string</type> - </param> - <param> - <name>Option</name> - <key>option</key> - <value>key</value> - <type>string</type> - </param> - <param> - <name>WriteBack</name> - <key>writeback</key> - <value>None</value> - <type>raw</type> - </param> - <doc> -This block represents a variable that can be read from a config file. - -To save the value back into the config file: \ -enter the name of another variable into the writeback param. \ -When the other variable is changed at runtime, the config file will be re-written. - </doc> -</block> diff --git a/grc/blocks/variable_function_probe.block.yml b/grc/blocks/variable_function_probe.block.yml new file mode 100644 index 0000000000..702ab5d60e --- /dev/null +++ b/grc/blocks/variable_function_probe.block.yml @@ -0,0 +1,54 @@ +id: variable_function_probe +label: Function Probe + +parameters: +- id: block_id + label: Block ID + dtype: string + default: my_block_0 +- id: function_name + label: Function Name + dtype: string + default: get_number +- id: function_args + label: Function Args + dtype: string + hide: ${ ('none' if function_args else 'part') } +- id: poll_rate + label: Poll Rate (Hz) + dtype: real + default: '10' +- id: value + label: Initial Value + dtype: raw + default: '0' + hide: part +value: ${ value } + +templates: + imports: |- + import time + import threading + var_make: self.${id} = ${id} = ${value} + make: "\ndef _${id}_probe():\n while True:\n <% obj = 'self' + ('.'\ + \ + block_id if block_id else '') %>\n val = ${obj}.${function_name}(${function_args})\n\ + \ try:\n self.set_${id}(val)\n except AttributeError:\n\ + \ pass\n time.sleep(1.0 / (${poll_rate}))\n_${id}_thread\ + \ = threading.Thread(target=_${id}_probe)\n_${id}_thread.daemon = True\n_${id}_thread.start()\n\ + \ " + callbacks: + - self.set_${id}(${value}) + +documentation: |- + Periodically probe a function and set its value to this variable. + + Set the values for block ID, function name, and function args appropriately: Block ID should be the ID of another block in this flow graph. An empty Block ID references the flow graph itself. Function name should be the name of a class method on that block. Function args are the parameters passed into that function. For a function with no arguments, leave function args blank. When passing a string for the function arguments, quote the string literal: '"arg"'. + + The values will used literally, and generated into the following form: + self.block_id.function_name(function_args) + or, if the Block ID is empty, + self.function_name(function_args) + + To poll a stream for a level, use this with the probe signal block. + +file_format: 1 diff --git a/grc/blocks/variable_function_probe.xml b/grc/blocks/variable_function_probe.xml deleted file mode 100644 index 47c11b29fe..0000000000 --- a/grc/blocks/variable_function_probe.xml +++ /dev/null @@ -1,78 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable function probe -################################################### - --> -<block> - <name>Function Probe</name> - <key>variable_function_probe</key> - <import>import time</import> - <import>import threading</import> - <var_make>self.$(id) = $(id) = $value</var_make> - <make> -def _$(id)_probe(): - while True: - #set $obj = 'self' + ('.' + $block_id() if $block_id() else '') - val = $(obj).$(function_name())($(function_args())) - try: - self.set_$(id)(val) - except AttributeError: - pass - time.sleep(1.0 / ($poll_rate)) -_$(id)_thread = threading.Thread(target=_$(id)_probe) -_$(id)_thread.daemon = True -_$(id)_thread.start() - </make> - <callback>self.set_$(id)($value)</callback> - <param> - <name>Block ID</name> - <key>block_id</key> - <value>my_block_0</value> - <type>string</type> - </param> - <param> - <name>Function Name</name> - <key>function_name</key> - <value>get_number</value> - <type>string</type> - </param> - <param> - <name>Function Args</name> - <key>function_args</key> - <value></value> - <type>string</type> - <hide>#if $function_args() then 'none' else 'part'#</hide> - </param> - <param> - <name>Poll Rate (Hz)</name> - <key>poll_rate</key> - <value>10</value> - <type>real</type> - </param> - <param> - <name>Initial Value</name> - <key>value</key> - <value>0</value> - <type>raw</type> - <hide>part</hide> - </param> - <doc> -Periodically probe a function and set its value to this variable. - -Set the values for block ID, function name, and function args appropriately: \ -Block ID should be the ID of another block in this flow graph. \ -An empty Block ID references the flow graph itself. \ -Function name should be the name of a class method on that block. \ -Function args are the parameters passed into that function. \ -For a function with no arguments, leave function args blank. \ -When passing a string for the function arguments, quote the string literal: '"arg"'. - -The values will used literally, and generated into the following form: - self.block_id.function_name(function_args) -or, if the Block ID is empty, - self.function_name(function_args) - -To poll a stream for a level, use this with the probe signal block. - </doc> -</block> diff --git a/grc/blocks/variable_struct.block.yml.py b/grc/blocks/variable_struct.block.yml.py new file mode 100644 index 0000000000..19b29982e7 --- /dev/null +++ b/grc/blocks/variable_struct.block.yml.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python + +MAX_NUM_FIELDS = 20 + +HEADER = """\ +id: variable_struct +label: Struct Variable + +parameters: +""" + +TEMPLATES = """\ + +templates: + imports: "def struct(data): return type('Struct', (object,), data)()" + var_make: |- + self.${{id}} = ${{id}} = struct({{ + % for i in range({0}): + <% + field = getVar('field' + str(i)) + %> + % if len(str(field)) > 2: + ${{field}}: getVar('value' + str(i)), + % endif + % endfor + }}) + var_value: |- + struct({{ + % for i in range({0}): + <% + field = getVar('field' + str(i)) + %> + % if len(str(field)) > 2: + ${{field}}: getVar('field' + str(i)), + % endif + % endfor + }}) +""" + +FIELD0 = """\ +- id: field0 + label: Field 0 + category: Fields + dtype: string + default: ${field0} + hide: part +""" + +FIELDS = """\ +- id: field{0} + label: Field {0} + category: Fields + dtype: string + hide: part +""" + +VALUES = """\ +- id: value{0} + label: ${{field{0}}} + dtype: raw + default: '0' + hide: ${{ 'none' if field{0} else 'all' }} +""" + +ASSERTS = """\ +- ${{ (str(field{0}) or "a")[0].isalpha() }} +- ${{ (str(field{0}) or "a").isalnum() }} +""" + +FOOTER = """\ + +documentation: |- + This is a simple struct/record like variable. + + Attribute/field names can be specified in the tab 'Fields'. + For each non-empty field a parameter with type raw is shown. + Value access via the dot operator, e.g. "variable_struct_0.field0" + +file_format: 1 +""" + + +def make_yml(num_fields): + return ''.join(( + HEADER.format(num_fields), + FIELD0, ''.join(FIELDS.format(i) for i in range(1, num_fields)), + ''.join(VALUES.format(i) for i in range(num_fields)), + 'value: ${value}\n\nasserts:\n', + ''.join(ASSERTS.format(i) for i in range(num_fields)), + ''.join(TEMPLATES.format(num_fields)), + FOOTER + )) + + +if __name__ == '__main__': + import sys + try: + filename = sys.argv[1] + except IndexError: + filename = __file__[:-3] + + data = make_yml(MAX_NUM_FIELDS) + + with open(filename, 'wb') as fp: + fp.write(data.encode()) diff --git a/grc/blocks/variable_struct.xml.py b/grc/blocks/variable_struct.xml.py deleted file mode 100644 index c0d3dac355..0000000000 --- a/grc/blocks/variable_struct.xml.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python - -MAX_NUM_FIELDS = 20 - -HEADER = """\ -<block> - <name>Struct Variable</name> - <key>variable_struct</key> - <import>def struct(data): return type('Struct', (object,), data)()</import> - <var_make>self.$id = $id = struct({{#slurp -#for $i in range({0}): -#set $field = $getVar('field' + str(i)) -#if len(str($field)) > 2 -$field: $getVar('value' + str(i)), #slurp -#end if -#end for -}})</var_make> - <var_value>struct({{#slurp -#for $i in range({0}): -#set $field = $getVar('field' + str(i)) -#if len(str($field)) > 2 -$field: $getVar('value' + str(i)), #slurp -#end if -#end for -}})</var_value> - <make></make> -""" - -FIELD0 = """\ - <param> - <name>Field 0</name> - <key>field0</key> - <value>field0</value> - <type>string</type> - <hide>part</hide> - <tab>Fields</tab> - </param> -""" - -FIELDS = """\ - <param> - <name>Field {0}</name> - <key>field{0}</key> - <value></value> - <type>string</type> - <hide>part</hide> - <tab>Fields</tab> - </param> -""" - -VALUES = """\ - <param> - <name>$field{0}()</name> - <key>value{0}</key> - <value>0</value> - <type>raw</type> - <hide>#if $field{0}() then 'none' else 'all'#</hide> - </param> -""" - -CHECKS = """\ - <check>($str($field{0}) or "a")[0].isalpha()</check> - <check>($str($field{0}) or "a").isalnum()</check> -""" - -FOOTER = """\ - <doc>This is a simple struct/record like variable. - -Attribute/field names can be specified in the tab 'Fields'. -For each non-empty field a parameter with type raw is shown. -Value access via the dot operator, e.g. "variable_struct_0.field0" - </doc> -</block> -""" - - -def make_xml(num_fields): - return ''.join(( - HEADER.format(num_fields), - FIELD0, ''.join(FIELDS.format(i) for i in range(1, num_fields)), - ''.join(VALUES.format(i) for i in range(num_fields)), - ''.join(CHECKS.format(i) for i in range(num_fields)), - FOOTER - )) - - -if __name__ == '__main__': - import sys - try: - filename = sys.argv[1] - except IndexError: - filename = __file__[:-3] - - data = make_xml(MAX_NUM_FIELDS) - - with open(filename, 'wb') as fp: - fp.write(data.encode()) diff --git a/grc/blocks/virtual_sink.block.yml b/grc/blocks/virtual_sink.block.yml new file mode 100644 index 0000000000..4a2fd0108e --- /dev/null +++ b/grc/blocks/virtual_sink.block.yml @@ -0,0 +1,13 @@ +id: virtual_sink +label: Virtual Sink + +parameters: +- id: stream_id + label: Stream ID + dtype: stream_id + +inputs: +- domain: stream + dtype: '' + +file_format: 1 diff --git a/grc/blocks/virtual_sink.xml b/grc/blocks/virtual_sink.xml deleted file mode 100644 index 35fb27e67c..0000000000 --- a/grc/blocks/virtual_sink.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Virtual Sink -################################################### - --> -<block> - <name>Virtual Sink</name> - <key>virtual_sink</key> - <make></make> - <param> - <name>Stream ID</name> - <key>stream_id</key> - <value></value> - <type>stream_id</type> - </param> - <sink> - <name>in</name> - <type></type> - </sink> -</block> diff --git a/grc/blocks/virtual_source.block.yml b/grc/blocks/virtual_source.block.yml new file mode 100644 index 0000000000..cec987702a --- /dev/null +++ b/grc/blocks/virtual_source.block.yml @@ -0,0 +1,13 @@ +id: virtual_source +label: Virtual Source + +parameters: +- id: stream_id + label: Stream ID + dtype: stream_id + +outputs: +- domain: stream + dtype: '' + +file_format: 1 diff --git a/grc/blocks/virtual_source.xml b/grc/blocks/virtual_source.xml deleted file mode 100644 index e0c7754492..0000000000 --- a/grc/blocks/virtual_source.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Virtual Source -################################################### - --> -<block> - <name>Virtual Source</name> - <key>virtual_source</key> - <make></make> - <param> - <name>Stream ID</name> - <key>stream_id</key> - <value></value> - <type>stream_id</type> - </param> - <source> - <name>out</name> - <type></type> - </source> -</block> diff --git a/grc/tests/resources/file1.block.yml b/grc/tests/resources/file1.block.yml new file mode 100644 index 0000000000..f486c89ea8 --- /dev/null +++ b/grc/tests/resources/file1.block.yml @@ -0,0 +1,38 @@ +id: block_key +label: testname + +parameters: +- id: vlen + label: Vec Length + category: test + dtype: int + default: '1' + hide: ${ 'part' if vlen == 1 else 'none' } +- id: out_type + label: Vec Length + dtype: string + default: complex + hide: part +- id: a + label: Alpha + dtype: ${ (out_type) } + default: '0' + +inputs: +- domain: stream + dtype: complex + vlen: ${ 2 * vlen } +- domain: message + id: in2 + +outputs: +- domain: stream + dtype: ${ out_type } + vlen: ${ vlen } +asserts: +- ${ vlen > 0 } + +templates: + make: blocks.complex_to_mag_squared(${vlen}) + +file_format: 1 diff --git a/grc/tests/resources/file1.xml b/grc/tests/resources/file1.xml deleted file mode 100644 index f03288b85d..0000000000 --- a/grc/tests/resources/file1.xml +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0"?> -<!-- -Copyright 2014 Free Software Foundation, Inc. -This file is part of GNU Radio - -GNU Radio Companion is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -GNU Radio Companion is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ---> -<block> - <name>testname</name> - <key>block_key</key> - <make>blocks.complex_to_mag_squared($(vlen))</make> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - <tab>test</tab> - </param> - <param> - <name>Vec Length</name> - <key>out_type</key> - <value>complex</value> - <type>string</type> - </param> - <param> - <name>Alpha</name> - <key>a</key> - <value>0</value> - <type>($out_type)</type> - </param> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>complex</type> - <vlen>2 * $vlen</vlen> - </sink> - <sink> - <name>in2</name> - <type>message</type> - </sink> - <source> - <name>out</name> - <type>$out_type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/tests/resources/file2.block.yml b/grc/tests/resources/file2.block.yml new file mode 100644 index 0000000000..459527260c --- /dev/null +++ b/grc/tests/resources/file2.block.yml @@ -0,0 +1,31 @@ +id: blocks_and_const_xx +label: And Const + +parameters: +- id: type + label: IO Type + dtype: enum + options: [int, short, byte] + option_attributes: + fcn: [ii, ss, bb] + hide: part +- id: const + label: Constant + dtype: int + default: '0' + +inputs: +- domain: stream + dtype: ${ type } + +outputs: +- domain: stream + dtype: ${ type } + +templates: + imports: from gnuradio import blocks + make: blocks.and_const_${type.fcn}(${const}) + callbacks: + - set_k(${const}) + +file_format: 1 diff --git a/grc/tests/resources/file2.xml b/grc/tests/resources/file2.xml deleted file mode 100644 index 1300c7f5a1..0000000000 --- a/grc/tests/resources/file2.xml +++ /dev/null @@ -1,80 +0,0 @@ -<?xml version="1.0"?> -<!-- -Copyright 2014 Free Software Foundation, Inc. -This file is part of GNU Radio - -GNU Radio Companion is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -GNU Radio Companion is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ---> -<!-- -################################################### -## And Const Block: -## all types, 1 output, 1 input & const -################################################### - --> -<block> - <name>And Const</name> - <key>blocks_and_const_xx</key> - <category>test</category> - <throttle>1</throttle> - <import>from gnuradio import blocks</import> - <make>blocks.and_const_$(type.fcn)($const)</make> - <callback>set_k($const)</callback> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>fcn:bb</opt> - </option> - </param> - <param> - <name>Constant</name> - <key>const</key> - <value>0</value> - <type>${type}</type> - <hide>#if $log then 'none' else 'part'#</hide> - </param> - <sink> - <name>in</name> - <type>$type</type> - </sink> - <source> - <name>out</name> - <type>$(type.fcn)</type> - </source> - <doc> -This block creates a variable check box. \ -Leave the label blank to use the variable id as the label. - -A check box selects between two values of similar type. \ -Te values do not necessarily need to be of boolean type. - -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/grc/tests/resources/file3.block.yml b/grc/tests/resources/file3.block.yml new file mode 100644 index 0000000000..e53515d134 --- /dev/null +++ b/grc/tests/resources/file3.block.yml @@ -0,0 +1,66 @@ +id: variable_qtgui_check_box +label: QT GUI Check Box + +parameters: +- id: label + label: Label + dtype: string + hide: ${ ('none' if label else 'part') } +- id: type + label: Type + dtype: enum + default: int + options: [real, int, string, bool, raw] + option_labels: [Float, Integer, String, Boolean, Any] + option_attributes: + conv: [float, int, str, bool, eval] + hide: part +- id: value + label: Default Value + dtype: ${ type } + default: 'True' +- id: 'true' + label: 'True' + dtype: ${ type } + default: 'True' +- id: 'false' + label: 'False' + dtype: ${ type } + default: 'False' +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +value: ${ value } + +asserts: +- ${value in (true, false)} + +templates: + imports: from PyQt4 import Qt + var_make: self.${id} = ${id} = ${value} + callbacks: + - self.set_${id}(${value}) + - self._${id}_callback(${id}) + make: |- + <% + win = '_%s_check_box'%id + if not label: + label = id + %> + ${win} = Qt.QCheckBox(${label}) + self._${id}_choices = {True: ${true}, False: ${false}} + self._${id}_choices_inv = dict((v,k) for k,v in self._${id}_choices.iteritems()) + self._${id}_callback = lambda i: Qt.QMetaObject.invokeMethod(${win}, "setChecked", Qt.Q_ARG("bool", self._${id}_choices_inv[i])) + self._${id}_callback(self.${id}) + ${win}.stateChanged.connect(lambda i: self.set_${id}(self._${id}_choices[bool(i)])) + ${gui_hint()(win)} + +documentation: |- + This block creates a variable check box. Leave the label blank to use the variable id as the label. + + A check box selects between two values of similar type. Te values do not necessarily need to be of boolean type. + + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/grc/tests/resources/file3.xml b/grc/tests/resources/file3.xml deleted file mode 100644 index 71753badb1..0000000000 --- a/grc/tests/resources/file3.xml +++ /dev/null @@ -1,100 +0,0 @@ -<?xml version="1.0"?> -<!-- -Copyright 2014 Free Software Foundation, Inc. -This file is part of GNU Radio - -GNU Radio Companion is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -GNU Radio Companion is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ---> -<!-- -################################################### -##Variable Check Box: -## a gui check box form -################################################### - --> -<block> - <name>QT GUI Check Box</name> - <key>variable_qtgui_check_box</key> - <import>from PyQt4 import Qt</import> - <var_make>self.$(id) = $(id) = $value</var_make> - <make>#set $win = '_%s_check_box'%$id -#if not $label() - #set $label = '"%s"'%$id -#end if -$win = Qt.QCheckBox($label) -self._$(id)_choices = {True: $true, False: $false} -self._$(id)_choices_inv = dict((v,k) for k,v in self._$(id)_choices.iteritems()) -self._$(id)_callback = lambda i: Qt.QMetaObject.invokeMethod($(win), "setChecked", Qt.Q_ARG("bool", self._$(id)_choices_inv[i])) -self._$(id)_callback(self.$id) -$(win).stateChanged.connect(lambda i: self.set_$(id)(self._$(id)_choices[bool(i)])) -$(gui_hint()($win))</make> - <callback>self.set_$(id)($value)</callback> - <callback>self._$(id)_callback($id)</callback> - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - <hide>#if $label() then 'none' else 'part'#</hide> - </param> - <param> - <name>Type</name> - <key>type</key> - <value>int</value> - <type>enum</type> - <hide>part</hide> - <option><name>Float</name><key>real</key><opt>conv:float</opt></option> - <option><name>Integer</name><key>int</key><opt>conv:int</opt></option> - <option><name>String</name><key>string</key><opt>conv:str</opt></option> - <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt></option> - <option><name>Any</name><key>raw</key><opt>conv:eval</opt></option> - </param> - <param> - <name>Default Value</name> - <key>value</key> - <value>True</value> - <type>$type</type> - </param> - <param> - <name>True</name> - <key>true</key> - <value>True</value> - <type>$type</type> - </param> - <param> - <name>False</name> - <key>false</key> - <value>False</value> - <type>$type</type> - </param> - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - <check>$value in ($true, $false)</check> - <doc> -This block creates a variable check box. \ -Leave the label blank to use the variable id as the label. - -A check box selects between two values of similar type. \ -Te values do not necessarily need to be of boolean type. - -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> -- cgit v1.2.3 From 5a8799f5bd477d5e8e520dd0dab1b8874db0e68e Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <sebastian.koslowski@gmail.com> Date: Sat, 30 Sep 2017 21:11:09 +0200 Subject: [grc] refactor #1418 --- grc/core/Param.py | 142 ++++++++++++++++++++++++++---------------------------- 1 file changed, 68 insertions(+), 74 deletions(-) (limited to 'grc') diff --git a/grc/core/Param.py b/grc/core/Param.py index 00336737b0..01697919d0 100644 --- a/grc/core/Param.py +++ b/grc/core/Param.py @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import ast import weakref import re +import textwrap from . import Constants from .Constants import VECTOR_TYPES, COMPLEX_TYPES, REAL_TYPES, INT_TYPES @@ -212,7 +213,7 @@ class Param(Element): self._value = value or '' self._default = value self._init = False - self._hostage_cells = list() + self.hostage_cells = set() self.template_arg = TemplateArg(self) def get_types(self): @@ -395,7 +396,6 @@ class Param(Element): self._init = True self._lisitify_flag = False self._stringify_flag = False - self._hostage_cells = list() t = self.get_type() v = self.get_value() @@ -562,12 +562,12 @@ class Param(Element): # Calculate hostage cells for r in range(row_span): for c in range(col_span): - self._hostage_cells.append((my_parent, (row+r, col+c))) + self.hostage_cells.append((my_parent, (row + r, col + c))) # Avoid collisions params = filter(lambda p: p is not self, self.get_all_params('grid_pos')) for param in params: for parent, cell in param._hostage_cells: - if (parent, cell) in self._hostage_cells: + if (parent, cell) in self.hostage_cells: raise Exception('Another graphical element is using parent "{0}", cell "{1}".'.format(str(parent), str(cell))) return e ######################### @@ -739,6 +739,7 @@ class Param(Element): Returns: string of python code for positioning GUI elements in pyQT """ + self.hostage_cells.clear() # Parsing if ':' in v: @@ -754,90 +755,83 @@ class Param(Element): index = '0' index = int(index) - position_set = bool(pos) - tab_set = bool(tab) - # Validation - if position_set: + def parse_pos(): e = self.get_parent().get_parent().evaluate(pos) - if len(e) == 2: - e = e + (1,1) - row, col, row_span, col_span = e + if not isinstance(e, (list, tuple)) or len(e) not in (2, 4) or not all(isinstance(ei, int) for ei in e): + raise Exception('Invalid GUI Hint entered: {e!r} (Must be a list of {{2,4}} non-negative integers).'.format(e=e)) - if not isinstance(e, (list, tuple)) or not (len(e) == 2 or len(e) == 4) or not all([isinstance(ei, int) for ei in e]): - raise Exception('Invalid GUI Hint entered: {e!s:s} (Must be a list of {{2,4}} non-negative integers).'.format(e=e)) + if len(e) == 2: + row, col = e + row_span = col_span = 1 + else: + row, col, row_span, col_span = e if (row < 0) or (col < 0): - raise Exception('Invalid GUI Hint entered: {e!s:s} (non-negative integers only).'.format(e=e)) + raise Exception('Invalid GUI Hint entered: {e!r} (non-negative integers only).'.format(e=e)) if (row_span < 1) or (col_span < 1): - raise Exception('Invalid GUI Hint entered: {e!s:s} (positive row/column span required).'.format(e=e)) + raise Exception('Invalid GUI Hint entered: {e!r} (positive row/column span required).'.format(e=e)) - if tab_set: - enabled_blocks = self.get_parent().get_parent().get_enabled_blocks() - tab_list = filter(lambda block: str(block.get_key()) == 'qtgui_tab_widget', enabled_blocks) - tab_match = filter(lambda t: t.get_id() == tab, tab_list) - if not tab_match: - raise Exception('Invalid tab name entered: {tab!s:s} (Tab name not found).'.format(tab=tab)) + return row, col, row_span, col_span - tab_index_size = int(tab_match[0].get_param('num_tabs').get_value()) - if index >= tab_index_size: - raise Exception('Invalid tab index entered: {tab!s:s}@{index!s:s} (Index out of range).'.format(tab=tab, - index=index)) + def validate_tab(): + enabled_blocks = self.get_parent().get_parent().iter_enabled_blocks() + tabs = (block for block in enabled_blocks + if block.get_key() == 'qtgui_tab_widget' and block.get_id() == tab) + tab_block = next(iter(tabs), None) + if not tab_block: + raise Exception('Invalid tab name entered: {tab} (Tab name not found).'.format(tab=tab)) - # Code Generation - if position_set and tab_set: - widget_str = 'self.{tab:s}_grid_layout_{index!s:s}.addWidget({widget:s}, {e!s:s})' - widget_str += '\n[self.{tab:s}_grid_layout_{index!s:s}.setRowStretch(r,1) for r in range({fRow:d},{lRow:d})]' - widget_str += '\n[self.{tab:s}_grid_layout_{index!s:s}.setColumnStretch(c,1) for c in range({fCol:d},{lCol:d})]' - widget_str = widget_str.format(tab=tab, - index=index, - widget='%s', - e=str(e)[1:-1], - fRow=row, - lRow=(row + row_span), - fCol=col, - lCol=(col + col_span)) - - elif position_set and not tab_set: - widget_str = 'self.top_grid_layout.addWidget({widget:s}, {e!s:s})' - widget_str += '\n[self.top_grid_layout.setRowStretch(r,1) for r in range({fRow:d},{lRow:d})]' - widget_str += '\n[self.top_grid_layout.setColumnStretch(c,1) for c in range({fCol:d},{lCol:d})]' - widget_str = widget_str.format(widget='%s', - e=str(e)[1:-1], - fRow=row, - lRow=(row + row_span), - fCol=col, - lCol=(col + col_span)) - - elif not position_set and tab_set: - widget_str = 'self.{tab:s}_layout_{index!s:s}.addWidget({widget:s})' - widget_str = widget_str.format(tab=tab, - index=index, - widget='%s') - - elif not position_set and not tab_set: - widget_str = 'self.top_layout.addWidget({widget:s})' - widget_str = widget_str.format(widget='%s') + tab_index_size = int(tab_block.get_param('num_tabs').get_value()) + if index >= tab_index_size: + raise Exception('Invalid tab index entered: {tab}@{index} (Index out of range).'.format( + tab=tab, index=index)) # Collision Detection - if position_set: - if tab_set: - my_parent = '{tab:s}@{index!s:s}'.format(tab=tab, - index=index) - else: - my_parent = 'main' + def collision_detection(row, col, row_span, col_span): + my_parent = '{tab}@{index}'.format(tab=tab, index=index) if tab else 'main' # Calculate hostage cells for r in range(row, row + row_span): for c in range(col, col + col_span): - self._hostage_cells.append((my_parent, (r, c))) - # Avoid collisions - params = filter(lambda p: p is not self, self.get_all_params('gui_hint')) - for param in params: - for parent, cell in param._hostage_cells: - if (parent, cell) in self._hostage_cells: - raise Exception('Another graphical element is using parent "{parent!s:s}", cell "{cell!s:s}".'.format(parent=parent, - cell=cell)) + self.hostage_cells.add((my_parent, (r, c))) + + for other in self.get_all_params('gui_hint'): + if other is self: + continue + collision = next(iter(self.hostage_cells & other.hostage_cells), None) + if collision: + raise Exception('Block {block!r} is also using parent {parent!r}, cell {cell!r}.'.format( + block=other.get_parent().get_id(), parent=collision[0], cell=collision[1] + )) + + # Code Generation + if tab: + validate_tab() + layout = '{tab}_grid_layout_{index}'.format(tab=tab, index=index) + else: + layout = 'top_grid_layout' + + widget = '%s' # to be fill-out in the mail template + + if pos: + 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, + ) + + else: + widget_str = 'self.{layout}.addWidget({widget})'.format(layout=layout, widget=widget) - return widget_str \ No newline at end of file + return widget_str -- cgit v1.2.3 From a3d5c7fdcef630a902b62305c2b0c57121e24209 Mon Sep 17 00:00:00 2001 From: Ethan Trewhitt <ethan@trewhitt.org> Date: Wed, 25 Oct 2017 13:36:33 -0400 Subject: Added parent (aka 'transient for') references to most (if not all) dialog boxes. First attempt at fixing #1494. --- grc/gui/ActionHandler.py | 24 ++++++++++---------- grc/gui/Dialogs.py | 58 ++++++++++++++++++++++++++++-------------------- grc/gui/FileDialogs.py | 20 ++++++++--------- grc/gui/FlowGraph.py | 4 ++-- grc/gui/MainWindow.py | 2 +- grc/gui/Param.py | 9 ++++---- grc/gui/PropsDialog.py | 6 +++-- 7 files changed, 68 insertions(+), 55 deletions(-) (limited to 'grc') diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index 017dab3346..aba9033d74 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -384,13 +384,13 @@ class ActionHandler: ################################################## elif action == Actions.ABOUT_WINDOW_DISPLAY: platform = flow_graph.get_parent() - Dialogs.AboutDialog(platform.config) + Dialogs.AboutDialog(platform.config, main) elif action == Actions.HELP_WINDOW_DISPLAY: - Dialogs.HelpDialog() + Dialogs.HelpDialog(main) elif action == Actions.TYPES_WINDOW_DISPLAY: - Dialogs.TypesDialog(flow_graph.get_parent()) + Dialogs.TypesDialog(flow_graph.get_parent(), main) elif action == Actions.ERRORS_WINDOW_DISPLAY: - Dialogs.ErrorsDialog(flow_graph) + Dialogs.ErrorsDialog(flow_graph, main) elif action == Actions.TOGGLE_CONSOLE_WINDOW: main.update_panel_visibility(main.CONSOLE, action.get_active()) action.save_to_preferences() @@ -406,7 +406,7 @@ class ActionHandler: elif action == Actions.CLEAR_CONSOLE: main.text_display.clear() elif action == Actions.SAVE_CONSOLE: - file_path = SaveConsoleFileDialog(page.get_file_path()).run() + file_path = SaveConsoleFileDialog(page.get_file_path(), main).run() if file_path is not None: main.text_display.save(file_path) elif action == Actions.TOGGLE_HIDE_DISABLED_BLOCKS: @@ -461,7 +461,7 @@ class ActionHandler: else: selected_block = flow_graph.get_selected_block() if selected_block: - self.dialog = PropsDialog(selected_block) + self.dialog = PropsDialog(selected_block, main) response = gtk.RESPONSE_APPLY while response == gtk.RESPONSE_APPLY: # rerun the dialog if Apply was hit response = self.dialog.run() @@ -520,7 +520,7 @@ class ActionHandler: flow_graph._options_block.get_param('generate_options').set_value(args[0]) flow_graph_update(flow_graph) elif action == Actions.FLOW_GRAPH_OPEN: - file_paths = args if args else OpenFlowGraphFileDialog(page.get_file_path()).run() + file_paths = args if args else OpenFlowGraphFileDialog(main, page.get_file_path()).run() if file_paths: #open a new page for each file, show only the first for i,file_path in enumerate(file_paths): main.new_page(file_path, show=(i==0)) @@ -530,7 +530,7 @@ class ActionHandler: main.vars.update_gui() elif action == Actions.FLOW_GRAPH_OPEN_QSS_THEME: - file_paths = OpenQSSFileDialog(self.platform.config.install_prefix + + file_paths = OpenQSSFileDialog(main, self.platform.config.install_prefix + '/share/gnuradio/themes/').run() if file_paths: try: @@ -555,7 +555,7 @@ class ActionHandler: Messages.send_fail_save(page.get_file_path()) page.set_saved(False) elif action == Actions.FLOW_GRAPH_SAVE_AS: - file_path = SaveFlowGraphFileDialog(page.get_file_path()).run() + file_path = SaveFlowGraphFileDialog(main, page.get_file_path()).run() if file_path is not None: page.set_file_path(file_path) Actions.FLOW_GRAPH_SAVE() @@ -574,7 +574,7 @@ class ActionHandler: while os.path.exists(dup_file_path_temp): dup_file_path_temp = dup_file_name+'('+str(count)+').grc' count += 1 - dup_file_path_user = SaveFlowGraphFileDialog(dup_file_path_temp).run() + dup_file_path_user = SaveFlowGraphFileDialog(main, dup_file_path_temp).run() if dup_file_path_user is not None: ParseXML.to_file(flow_graph.export_data(), dup_file_path_user) Messages.send('Saved Copy to: "' + dup_file_path_user + '"\n') @@ -589,7 +589,7 @@ class ActionHandler: flow_graph_update(new_flow_graph) curr_page.set_saved(False) elif action == Actions.FLOW_GRAPH_SCREEN_CAPTURE: - file_path, background_transparent = SaveScreenShotDialog(page.get_file_path()).run() + file_path, background_transparent = SaveScreenShotDialog(main, page.get_file_path()).run() if file_path is not None: pixbuf = flow_graph.get_drawing_area().get_screenshot(background_transparent) pixbuf.save(file_path, Constants.IMAGE_FILE_EXTENSION[1:]) @@ -615,7 +615,7 @@ class ActionHandler: xterm = self.platform.config.xterm_executable if Preferences.xterm_missing() != xterm: if not os.path.exists(xterm): - Dialogs.MissingXTermDialog(xterm) + Dialogs.MissingXTermDialog(xterm, main) Preferences.xterm_missing(xterm) if page.get_saved() and page.get_file_path(): Executor.ExecFlowGraphThread( diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py index 83ad9651b2..e23f42759a 100644 --- a/grc/gui/Dialogs.py +++ b/grc/gui/Dialogs.py @@ -128,16 +128,18 @@ class TextDisplay(SimpleTextDisplay): return False -def MessageDialogHelper(type, buttons, title=None, markup=None, default_response=None, extra_buttons=None): +def MessageDialogHelper(type, buttons, parent, title=None, markup=None, default_response=None, extra_buttons=None): """ Create a modal message dialog and run it. - Args: + Required args: type: the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR buttons: the predefined set of buttons to use: - gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL + gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, + gtk.BUTTONS_OK_CANCEL + parent: gtk parent window (which will be blocked explicitly by this modal dialog) - Args: + Optional args: title: the title of the window (string) markup: the message text with pango markup default_response: if set, determines which button is highlighted by default @@ -146,7 +148,7 @@ def MessageDialogHelper(type, buttons, title=None, markup=None, default_response Returns: the gtk response from run() """ - message_dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type, buttons) + message_dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, type, buttons) if title: message_dialog.set_title(title) if markup: message_dialog.set_markup(markup) if extra_buttons: message_dialog.add_buttons(*extra_buttons) @@ -164,20 +166,23 @@ $encode($err_msg.replace('\t', ' ')) #end for""" -def ErrorsDialog(flowgraph): MessageDialogHelper( - type=gtk.MESSAGE_ERROR, - buttons=gtk.BUTTONS_CLOSE, - title='Flow Graph Errors', - markup=Utils.parse_template(ERRORS_MARKUP_TMPL, errors=flowgraph.get_error_messages()), -) +def ErrorsDialog(flowgraph, parent): + MessageDialogHelper( + type=gtk.MESSAGE_ERROR, + buttons=gtk.BUTTONS_CLOSE, + parent=parent, + title='Flow Graph Errors', + markup=Utils.parse_template(ERRORS_MARKUP_TMPL, errors=flowgraph.get_error_messages()), + ) class AboutDialog(gtk.AboutDialog): """A cute little about dialog.""" - def __init__(self, config): + def __init__(self, config, parent): """AboutDialog constructor.""" gtk.AboutDialog.__init__(self) + self.set_transient_for(parent) self.set_name(config.name) self.set_version(config.version) self.set_license(config.license) @@ -187,11 +192,13 @@ class AboutDialog(gtk.AboutDialog): self.destroy() -def HelpDialog(): MessageDialogHelper( - type=gtk.MESSAGE_INFO, - buttons=gtk.BUTTONS_CLOSE, - title='Help', - markup="""\ +def HelpDialog(parent): + MessageDialogHelper( + type=gtk.MESSAGE_INFO, + buttons=gtk.BUTTONS_CLOSE, + parent=parent, + title='Help', + markup="""\ <b>Usage Tips</b> <u>Add block</u>: drag and drop or double click a block in the block selection window. @@ -201,7 +208,8 @@ def HelpDialog(): MessageDialogHelper( <u>Make connection</u>: click on the source port of one block, then click on the sink port of another block. <u>Remove connection</u>: select the connection and press delete, or drag the connection. -* See the menu for other keyboard shortcuts.""") +* See the menu for other keyboard shortcuts.""" + ) COLORS_DIALOG_MARKUP_TMPL = """\ <b>Color Mapping</b> @@ -215,20 +223,22 @@ COLORS_DIALOG_MARKUP_TMPL = """\ """ -def TypesDialog(platform): +def TypesDialog(platform, parent): MessageDialogHelper( type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_CLOSE, + parent=parent, title='Types', markup=Utils.parse_template(COLORS_DIALOG_MARKUP_TMPL, colors=platform.get_colors()) ) -def MissingXTermDialog(xterm): +def MissingXTermDialog(xterm, parent): MessageDialogHelper( type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK, + parent=parent, title='Warning: missing xterm executable', markup=("The xterm executable {0!r} is missing.\n\n" "You can change this setting in your gnuradio.conf, in " @@ -238,7 +248,7 @@ def MissingXTermDialog(xterm): ) -def ChooseEditorDialog(config): +def ChooseEditorDialog(config, parent): # Give the option to either choose an editor or use the default # Always return true/false so the caller knows it was successful buttons = ( @@ -247,15 +257,15 @@ def ChooseEditorDialog(config): gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL ) response = MessageDialogHelper( - gtk.MESSAGE_QUESTION, gtk.BUTTONS_NONE, 'Choose Editor', - 'Would you like to choose the editor to use?', gtk.RESPONSE_YES, buttons + gtk.MESSAGE_QUESTION, gtk.BUTTONS_NONE, parent, + 'Choose Editor', 'Would you like to choose the editor to use?', gtk.RESPONSE_YES, buttons ) # Handle the inital default/choose/cancel response # User wants to choose the editor to use if response == gtk.RESPONSE_YES: file_dialog = gtk.FileChooserDialog( - 'Select an Editor...', None, + 'Select an Editor...', parent, gtk.FILE_CHOOSER_ACTION_OPEN, ('gtk-cancel', gtk.RESPONSE_CANCEL, 'gtk-open', gtk.RESPONSE_OK) ) diff --git a/grc/gui/FileDialogs.py b/grc/gui/FileDialogs.py index 9d047b1ffd..c4daae3ad6 100644 --- a/grc/gui/FileDialogs.py +++ b/grc/gui/FileDialogs.py @@ -88,7 +88,7 @@ class FileDialogHelper(gtk.FileChooserDialog): Implement a file chooser dialog with only necessary parameters. """ - def __init__(self, action, title): + def __init__(self, action, title, parent): """ FileDialogHelper contructor. Create a save or open dialog with cancel and ok buttons. @@ -99,7 +99,7 @@ class FileDialogHelper(gtk.FileChooserDialog): title: the title of the dialog (string) """ ok_stock = {gtk.FILE_CHOOSER_ACTION_OPEN : 'gtk-open', gtk.FILE_CHOOSER_ACTION_SAVE : 'gtk-save'}[action] - gtk.FileChooserDialog.__init__(self, title, None, action, ('gtk-cancel', gtk.RESPONSE_CANCEL, ok_stock, gtk.RESPONSE_OK)) + gtk.FileChooserDialog.__init__(self, title, parent, action, ('gtk-cancel', gtk.RESPONSE_CANCEL, ok_stock, gtk.RESPONSE_OK)) self.set_select_multiple(False) self.set_local_only(True) self.add_filter(get_all_files_filter()) @@ -108,7 +108,7 @@ class FileDialogHelper(gtk.FileChooserDialog): class FileDialog(FileDialogHelper): """A dialog box to save or open flow graph files. This is a base class, do not use.""" - def __init__(self, current_file_path=''): + def __init__(self, parent, current_file_path=''): """ FileDialog constructor. @@ -117,25 +117,25 @@ class FileDialog(FileDialogHelper): """ if not current_file_path: current_file_path = path.join(DEFAULT_FILE_PATH, NEW_FLOGRAPH_TITLE + Preferences.file_extension()) if self.type == OPEN_FLOW_GRAPH: - FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_OPEN, 'Open a Flow Graph from a File...') + FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_OPEN, 'Open a Flow Graph from a File...', parent) self.add_and_set_filter(get_flow_graph_files_filter()) self.set_select_multiple(True) elif self.type == SAVE_FLOW_GRAPH: - FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save a Flow Graph to a File...') + FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save a Flow Graph to a File...', parent) self.add_and_set_filter(get_flow_graph_files_filter()) self.set_current_name(path.basename(current_file_path)) elif self.type == SAVE_CONSOLE: - FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save Console to a File...') + FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save Console to a File...', parent) self.add_and_set_filter(get_text_files_filter()) file_path = path.splitext(path.basename(current_file_path))[0] self.set_current_name(file_path) #show the current filename elif self.type == SAVE_IMAGE: - FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save a Flow Graph Screen Shot...') + FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save a Flow Graph Screen Shot...', parent) self.add_and_set_filter(get_image_files_filter()) current_file_path = current_file_path + IMAGE_FILE_EXTENSION self.set_current_name(path.basename(current_file_path)) #show the current filename elif self.type == OPEN_QSS_THEME: - FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_OPEN, 'Open a QSS theme...') + FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_OPEN, 'Open a QSS theme...', parent) self.add_and_set_filter(get_qss_themes_filter()) self.set_select_multiple(False) self.set_current_folder(path.dirname(current_file_path)) #current directory @@ -228,8 +228,8 @@ class SaveImageFileDialog(FileDialog): class SaveScreenShotDialog(SaveImageFileDialog): - def __init__(self, current_file_path=''): - SaveImageFileDialog.__init__(self, current_file_path) + def __init__(self, parent, current_file_path=''): + SaveImageFileDialog.__init__(self, parent, current_file_path) self._button = button = gtk.CheckButton('_Background transparent') self._button.set_active(Preferences.screen_shot_background_transparent()) self.set_extra_widget(button) diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index e0cd7d1441..ea52a13c0c 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -82,7 +82,7 @@ class FlowGraph(Element, _Flowgraph): break return block_id - def install_external_editor(self, param): + def install_external_editor(self, param, parent=None): target = (param.get_parent().get_id(), param.get_key()) if target in self._external_updaters: @@ -90,7 +90,7 @@ class FlowGraph(Element, _Flowgraph): else: config = self.get_parent().config editor = (find_executable(config.editor) or - Dialogs.ChooseEditorDialog(config)) + Dialogs.ChooseEditorDialog(config, parent)) if not editor: return updater = functools.partial( diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py index 9a2823a7ab..205881f2e5 100644 --- a/grc/gui/MainWindow.py +++ b/grc/gui/MainWindow.py @@ -453,7 +453,7 @@ class MainWindow(gtk.Window): gtk.STOCK_SAVE, gtk.RESPONSE_OK ) return MessageDialogHelper( - gtk.MESSAGE_QUESTION, gtk.BUTTONS_NONE, 'Unsaved Changes!', + gtk.MESSAGE_QUESTION, gtk.BUTTONS_NONE, self, 'Unsaved Changes!', 'Would you like to save changes before closing?', gtk.RESPONSE_OK, buttons ) diff --git a/grc/gui/Param.py b/grc/gui/Param.py index c71e1c0aa5..71acffe743 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -34,9 +34,10 @@ class InputParam(gtk.HBox): """The base class for an input parameter inside the input parameters dialog.""" expand = False - def __init__(self, param, changed_callback=None, editing_callback=None): + def __init__(self, param, parent, changed_callback=None, editing_callback=None): gtk.HBox.__init__(self) self.param = param + self._parent = parent self._changed_callback = changed_callback self._editing_callback = editing_callback self.label = gtk.Label() #no label, markup is added by set_markup @@ -236,7 +237,7 @@ class PythonEditorParam(InputParam): def open_editor(self, widget=None): flowgraph = self.param.get_parent().get_parent() - flowgraph.install_external_editor(self.param) + flowgraph.install_external_editor(self.param, self._parent) def get_text(self): pass # we never update the value from here @@ -339,10 +340,10 @@ class FileParam(EntryParam): #build the dialog if self.param.get_type() == 'file_open': - file_dialog = gtk.FileChooserDialog('Open a Data File...', None, + file_dialog = gtk.FileChooserDialog('Open a Data File...', self._parent, gtk.FILE_CHOOSER_ACTION_OPEN, ('gtk-cancel',gtk.RESPONSE_CANCEL,'gtk-open',gtk.RESPONSE_OK)) elif self.param.get_type() == 'file_save': - file_dialog = gtk.FileChooserDialog('Save a Data File...', None, + file_dialog = gtk.FileChooserDialog('Save a Data File...', self._parent, gtk.FILE_CHOOSER_ACTION_SAVE, ('gtk-cancel',gtk.RESPONSE_CANCEL, 'gtk-save',gtk.RESPONSE_OK)) file_dialog.set_do_overwrite_confirmation(True) file_dialog.set_current_name(basename) #show the current filename diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py index cfea13e1a8..b299804b47 100644 --- a/grc/gui/PropsDialog.py +++ b/grc/gui/PropsDialog.py @@ -55,7 +55,7 @@ class PropsDialog(gtk.Dialog): A dialog to set block parameters, view errors, and view documentation. """ - def __init__(self, block): + def __init__(self, block, parent): """ Properties dialog constructor. @@ -67,6 +67,7 @@ class PropsDialog(gtk.Dialog): gtk.Dialog.__init__( self, title='Properties: %s' % block.get_name(), + parent=parent, buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT, gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) @@ -76,6 +77,7 @@ class PropsDialog(gtk.Dialog): (MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT) )) self._block = block + self._parent = parent vpaned = gtk.VPaned() self.vbox.pack_start(vpaned) @@ -190,7 +192,7 @@ class PropsDialog(gtk.Dialog): if param.get_hide() == 'all': continue box_all_valid = box_all_valid and param.is_valid() - input_widget = param.get_input(self._handle_changed, self._activate_apply) + input_widget = param.get_input(self, self._handle_changed, self._activate_apply) vbox.pack_start(input_widget, input_widget.expand) label.set_markup(Utils.parse_template(TAB_LABEL_MARKUP_TMPL, valid=box_all_valid, tab=tab)) # show params box with new params -- cgit v1.2.3 From 3808e137e0719d4d92f9698a4d2d020667826afd Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <sebastian.koslowski@gmail.com> Date: Wed, 25 Oct 2017 22:02:21 +0200 Subject: grc: make props dialog dark-theme friendly --- grc/gui/Colors.py | 1 - grc/gui/Param.py | 19 ++++++++----------- grc/gui/PropsDialog.py | 4 ++-- 3 files changed, 10 insertions(+), 14 deletions(-) (limited to 'grc') diff --git a/grc/gui/Colors.py b/grc/gui/Colors.py index d322afa410..023a4e7038 100644 --- a/grc/gui/Colors.py +++ b/grc/gui/Colors.py @@ -30,7 +30,6 @@ try: MISSING_BLOCK_BACKGROUND_COLOR = get_color('#FFF2F2') MISSING_BLOCK_BORDER_COLOR = get_color('red') #param entry boxes - PARAM_ENTRY_TEXT_COLOR = get_color('black') ENTRYENUM_CUSTOM_COLOR = get_color('#EEEEEE') #flow graph color constants FLOWGRAPH_BACKGROUND_COLOR = get_color('#FFFFFF') diff --git a/grc/gui/Param.py b/grc/gui/Param.py index 71acffe743..7f90a7bea1 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -23,7 +23,7 @@ import pygtk pygtk.require('2.0') import gtk -from . import Colors, Utils, Constants +from . import Colors, Constants from .Element import Element from . import Utils @@ -133,17 +133,18 @@ class EntryParam(InputParam): def set_color(self, color): need_status_color = self.label not in self.get_children() text_color = ( - Colors.PARAM_ENTRY_TEXT_COLOR if not need_status_color else + None if not need_status_color else gtk.gdk.color_parse('blue') if self._have_pending_changes else gtk.gdk.color_parse('red') if not self.param.is_valid() else - Colors.PARAM_ENTRY_TEXT_COLOR) + None) base_color = ( Colors.BLOCK_DISABLED_COLOR if need_status_color and not self.param.get_parent().get_enabled() else gtk.gdk.color_parse(color) ) self._input.modify_base(gtk.STATE_NORMAL, base_color) - self._input.modify_text(gtk.STATE_NORMAL, text_color) + if text_color: + self._input.modify_text(gtk.STATE_NORMAL, text_color) def set_tooltip_text(self, text): try: @@ -179,7 +180,6 @@ class MultiLineEntryParam(InputParam): def set_color(self, color): self._view.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) - self._view.modify_text(gtk.STATE_NORMAL, Colors.PARAM_ENTRY_TEXT_COLOR) def set_tooltip_text(self, text): try: @@ -243,8 +243,7 @@ class PythonEditorParam(InputParam): pass # we never update the value from here def set_color(self, color): - # self._button.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) - self._button.modify_text(gtk.STATE_NORMAL, Colors.PARAM_ENTRY_TEXT_COLOR) + pass def _apply_change(self, *args): pass @@ -305,10 +304,8 @@ class EnumEntryParam(InputParam): def set_color(self, color): if self._input.get_active() == -1: #custom entry, use color self._input.get_child().modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) - self._input.get_child().modify_text(gtk.STATE_NORMAL, Colors.PARAM_ENTRY_TEXT_COLOR) else: #from enum, make pale background self._input.get_child().modify_base(gtk.STATE_NORMAL, Colors.ENTRYENUM_CUSTOM_COLOR) - self._input.get_child().modify_text(gtk.STATE_NORMAL, Colors.PARAM_ENTRY_TEXT_COLOR) class FileParam(EntryParam): @@ -365,9 +362,9 @@ PARAM_MARKUP_TMPL="""\ <span foreground="$foreground" font_desc="$font"><b>$encode($param.get_name()): </b>$encode(repr($param).replace('\\n',' '))</span>""" PARAM_LABEL_MARKUP_TMPL="""\ -#set $foreground = $modified and 'blue' or $param.is_valid() and 'black' or 'red' +#set $foreground = $modified and 'foreground="blue"' or not $param.is_valid() and 'foreground="red"' or '' #set $underline = $has_cb and 'low' or 'none' -<span underline="$underline" foreground="$foreground" font_desc="Sans 9">$encode($param.get_name())</span>""" +<span underline="$underline" $foreground font_desc="Sans 9">$encode($param.get_name())</span>""" TIP_MARKUP_TMPL="""\ ######################################## diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py index b299804b47..36c792cbe7 100644 --- a/grc/gui/PropsDialog.py +++ b/grc/gui/PropsDialog.py @@ -28,8 +28,8 @@ import Utils import pango TAB_LABEL_MARKUP_TMPL="""\ -#set $foreground = $valid and 'black' or 'red' -<span foreground="$foreground">$encode($tab)</span>""" +#set $foreground = not $valid and 'foreground="red"' or '' +<span $foreground>$encode($tab)</span>""" def get_title_label(title): -- cgit v1.2.3 From 1fa89b3704d7f476e4395eb9358d5a6d7642251b Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <sebastian.koslowski@gmail.com> Date: Thu, 26 Oct 2017 20:15:22 +0200 Subject: grc: disable auto-conversion and implement json cache --- grc/core/Config.py | 6 -- grc/core/Constants.py | 2 + grc/core/blocks/__init__.py | 1 + grc/core/blocks/_build.py | 10 +-- grc/core/cache.py | 99 +++++++++++++++++++++++++++++ grc/core/platform.py | 109 +++++++++++++++----------------- grc/core/schema_checker/block.py | 2 +- grc/core/utils/__init__.py | 12 ++++ grc/core/utils/descriptors/evaluated.py | 6 +- grc/gui/Platform.py | 4 +- 10 files changed, 178 insertions(+), 73 deletions(-) create mode 100644 grc/core/cache.py (limited to 'grc') diff --git a/grc/core/Config.py b/grc/core/Config.py index eb53e1751d..4accb74c63 100644 --- a/grc/core/Config.py +++ b/grc/core/Config.py @@ -31,8 +31,6 @@ class Config(object): hier_block_lib_dir = os.environ.get('GRC_HIER_PATH', Constants.DEFAULT_HIER_BLOCK_LIB_DIR) - yml_block_cache = os.path.expanduser('~/.cache/grc_gnuradio') # FIXME: remove this as soon as converter is stable - def __init__(self, version, version_parts=None, name=None, prefs=None): self._gr_prefs = prefs if prefs else DummyPrefs() self.version = version @@ -40,9 +38,6 @@ class Config(object): if name: self.name = name - if not os.path.exists(self.yml_block_cache): - os.mkdir(self.yml_block_cache) - @property def block_paths(self): path_list_sep = {'/': ':', '\\': ';'}[os.path.sep] @@ -50,7 +45,6 @@ class Config(object): paths_sources = ( self.hier_block_lib_dir, os.environ.get('GRC_BLOCKS_PATH', ''), - self.yml_block_cache, self._gr_prefs.get_string('grc', 'local_blocks_path', ''), self._gr_prefs.get_string('grc', 'global_blocks_path', ''), ) diff --git a/grc/core/Constants.py b/grc/core/Constants.py index fc5383378c..59c5dff35e 100644 --- a/grc/core/Constants.py +++ b/grc/core/Constants.py @@ -31,6 +31,8 @@ BLOCK_DTD = os.path.join(DATA_DIR, 'block.dtd') DEFAULT_FLOW_GRAPH = os.path.join(DATA_DIR, 'default_flow_graph.grc') DEFAULT_HIER_BLOCK_LIB_DIR = os.path.expanduser('~/.grc_gnuradio') +CACHE_FILE = os.path.expanduser('~/.cache/grc_gnuradio/cache.json') + BLOCK_DESCRIPTION_FILE_FORMAT_VERSION = 1 # File format versions: # 0: undefined / legacy diff --git a/grc/core/blocks/__init__.py b/grc/core/blocks/__init__.py index e4a085d477..4ca0d5d2bc 100644 --- a/grc/core/blocks/__init__.py +++ b/grc/core/blocks/__init__.py @@ -29,6 +29,7 @@ build_ins = {} def register_build_in(cls): + cls.loaded_from = '(build-in)' build_ins[cls.key] = cls return cls diff --git a/grc/core/blocks/_build.py b/grc/core/blocks/_build.py index 9221433387..ce3496d9c4 100644 --- a/grc/core/blocks/_build.py +++ b/grc/core/blocks/_build.py @@ -29,7 +29,7 @@ def build(id, label='', category='', flags='', documentation='', parameters=None, inputs=None, outputs=None, templates=None, **kwargs): block_id = id - cls = type(block_id, (Block,), {}) + cls = type(str(block_id), (Block,), {}) cls.key = block_id cls.label = label or block_id.title() @@ -63,7 +63,9 @@ def build(id, label='', category='', flags='', documentation='', def _single_mako_expr(value, block_id): - match = re.match(r'\s*\$\{\s*(.*?)\s*\}\s*', str(value)) - if value and not match: + if not value: + return None + value = value.strip() + if not (value.startswith('${') and value.endswith('}')): raise ValueError('{} is not a mako substitution in {}'.format(value, block_id)) - return match.group(1) if match else None + return value[2:-1].strip() diff --git a/grc/core/cache.py b/grc/core/cache.py new file mode 100644 index 0000000000..b72255ce1f --- /dev/null +++ b/grc/core/cache.py @@ -0,0 +1,99 @@ +# Copyright 2017 Free Software Foundation, Inc. +# This file is part of GNU Radio +# +# GNU Radio Companion is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# GNU Radio Companion is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +from __future__ import absolute_import, print_function + +from io import open +import json +import logging +import os + +import six + +from .io import yaml + +logger = logging.getLogger(__name__) + + +class Cache(object): + + def __init__(self, filename): + self.cache_file = filename + self.cache = {} + self.need_cache_write = True + self._accessed_items = set() + try: + os.makedirs(os.path.dirname(filename)) + except OSError: + pass + try: + self._converter_mtime = os.path.getmtime(filename) + except OSError: + self._converter_mtime = -1 + + def load(self): + try: + logger.debug("Loading block cache from: {}".format(self.cache_file)) + with open(self.cache_file, encoding='utf-8') as cache_file: + self.cache = json.load(cache_file) + self.need_cache_write = False + except (IOError, ValueError): + self.need_cache_write = True + + def get_or_load(self, filename): + self._accessed_items.add(filename) + if os.path.getmtime(filename) <= self._converter_mtime: + try: + return self.cache[filename] + except KeyError: + pass + + with open(filename, encoding='utf-8') as fp: + data = yaml.safe_load(fp) + self.cache[filename] = data + self.need_cache_write = True + return data + + def save(self): + if not self.need_cache_write: + return + + logger.info('Saving %d entries to json cache', len(self.cache)) + with open(self.cache_file, 'wb') as cache_file: + json.dump(self.cache, cache_file, encoding='utf-8') + + def prune(self): + for filename in (set(self.cache) - self._accessed_items): + del self.cache[filename] + + def __enter__(self): + self.load() + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.save() + + +def byteify(data): + if isinstance(data, dict): + return {byteify(key): byteify(value) for key, value in six.iteritems(data)} + elif isinstance(data, list): + return [byteify(element) for element in data] + elif isinstance(data, six.text_type) and six.PY2: + return data.encode('utf-8') + else: + return data diff --git a/grc/core/platform.py b/grc/core/platform.py index 538bacade2..54deef3455 100644 --- a/grc/core/platform.py +++ b/grc/core/platform.py @@ -19,7 +19,6 @@ from __future__ import absolute_import, print_function from codecs import open from collections import namedtuple -import glob import os import logging from itertools import chain @@ -33,6 +32,7 @@ from . import ( ) from .Config import Config +from .cache import Cache from .base import Element from .io import yaml from .generator import Generator @@ -141,44 +141,41 @@ class Platform(Element): self.connection_templates.clear() self._block_categories.clear() - # FIXME: remove this as soon as converter is stable - from ..converter import Converter - converter = Converter(self.config.block_paths, self.config.yml_block_cache) - converter.run() - logging.info('XML converter done.') - - for file_path in self._iter_files_in_block_path(path): - try: - data = converter.cache[file_path] - except KeyError: - with open(file_path, encoding='utf-8') as fp: - data = yaml.safe_load(fp) - - if file_path.endswith('.block.yml'): - loader = self.load_block_description - scheme = schema_checker.BLOCK_SCHEME - elif file_path.endswith('.domain.yml'): - loader = self.load_domain_description - scheme = schema_checker.DOMAIN_SCHEME - elif file_path.endswith('.tree.yml'): - loader = self.load_category_tree_description - scheme = None - else: - continue - - try: - checker = schema_checker.Validator(scheme) - passed = checker.run(data) - for msg in checker.messages: - logger.warning('{:<40s} {}'.format(os.path.basename(file_path), msg)) - if not passed: - logger.info('YAML schema check failed for: ' + file_path) - - loader(data, file_path) - except Exception as error: - logger.exception('Error while loading %s', file_path) - logger.exception(error) - raise + # # FIXME: remove this as soon as converter is stable + # from ..converter import Converter + # converter = Converter(self.config.block_paths, self.config.yml_block_cache) + # converter.run() + # logging.info('XML converter done.') + + with Cache(Constants.CACHE_FILE) as cache: + for file_path in self._iter_files_in_block_path(path): + data = cache.get_or_load(file_path) + + if file_path.endswith('.block.yml'): + loader = self.load_block_description + scheme = schema_checker.BLOCK_SCHEME + elif file_path.endswith('.domain.yml'): + loader = self.load_domain_description + scheme = schema_checker.DOMAIN_SCHEME + elif file_path.endswith('.tree.yml'): + loader = self.load_category_tree_description + scheme = None + else: + continue + + try: + checker = schema_checker.Validator(scheme) + passed = checker.run(data) + for msg in checker.messages: + logger.warning('{:<40s} {}'.format(os.path.basename(file_path), msg)) + if not passed: + logger.info('YAML schema check failed for: ' + file_path) + + loader(data, file_path) + except Exception as error: + logger.exception('Error while loading %s', file_path) + logger.exception(error) + raise for key, block in six.iteritems(self.blocks): category = self._block_categories.get(key, block.category) @@ -201,10 +198,9 @@ class Platform(Element): if os.path.isfile(entry): yield entry elif os.path.isdir(entry): - pattern = os.path.join(entry, '**.' + ext) - yield_from = glob.iglob(pattern) - for file_path in yield_from: - yield file_path + for dirpath, dirnames, filenames in os.walk(entry): + for filename in sorted(filter(lambda f: f.endswith('.' + ext), filenames)): + yield os.path.join(dirpath, filename) else: logger.debug('Ignoring invalid path entry %r', entry) @@ -232,16 +228,18 @@ class Platform(Element): log.error('Unknown format version %d in %s', file_format, file_path) return - block_id = data.pop('id').rstrip('_') + block_id = data['id'] = data['id'].rstrip('_') if block_id in self.block_classes_build_in: log.warning('Not overwriting build-in block %s with %s', block_id, file_path) return if block_id in self.blocks: - log.warning('Block with id "%s" overwritten by %s', block_id, file_path) + log.warning('Block with id "%s" loaded from\n %s\noverwritten by\n %s', + block_id, self.blocks[block_id].loaded_from, file_path) try: - block_cls = self.blocks[block_id] = self.new_block_class(block_id, **data) + block_cls = self.blocks[block_id] = self.new_block_class(**data) + block_cls.loaded_from = file_path except errors.BlockLoadError as error: log.error('Unable to load block %s', block_id) log.exception(error) @@ -288,19 +286,12 @@ class Platform(Element): path = [] def load_category(name, elements): - if not isinstance(name, str): - log.debug('invalid name %r', name) - return - if isinstance(elements, list): - pass - elif isinstance(elements, str): - elements = [elements] - else: - log.debug('Ignoring elements of %s', name) + if not isinstance(name, six.string_types): + log.debug('Invalid name %r', name) return path.append(name) - for element in elements: - if isinstance(element, str): + for element in utils.to_list(elements): + if isinstance(element, six.string_types): block_id = element self._block_categories[block_id] = list(path) elif isinstance(element, dict): @@ -415,8 +406,8 @@ class Platform(Element): fg.import_data(data) return fg - def new_block_class(self, block_id, **data): - return blocks.build(block_id, **data) + def new_block_class(self, **data): + return blocks.build(**data) def make_block(self, parent, block_id, **kwargs): cls = self.block_classes[block_id] diff --git a/grc/core/schema_checker/block.py b/grc/core/schema_checker/block.py index ea079b4276..d511e36887 100644 --- a/grc/core/schema_checker/block.py +++ b/grc/core/schema_checker/block.py @@ -37,7 +37,7 @@ TEMPLATES_SCHEME = expand( BLOCK_SCHEME = expand( id=Spec(types=str_, required=True, item_scheme=None), label=str_, - category=(list, str_), + category=str_, flags=(list, str_), parameters=Spec(types=list, required=False, item_scheme=PARAM_SCHEME), diff --git a/grc/core/utils/__init__.py b/grc/core/utils/__init__.py index 660eb594a5..f2ac986fb4 100644 --- a/grc/core/utils/__init__.py +++ b/grc/core/utils/__init__.py @@ -17,5 +17,17 @@ from __future__ import absolute_import +import six + from . import epy_block_io, expr_utils, extract_docs, flow_graph_complexity from .hide_bokeh_gui_options_if_not_installed import hide_bokeh_gui_options_if_not_installed + + +def to_list(value): + if not value: + return [] + elif isinstance(value, six.string_types): + return [value] + else: + return list(value) + diff --git a/grc/core/utils/descriptors/evaluated.py b/grc/core/utils/descriptors/evaluated.py index 313cee5b96..e8bce6e6ed 100644 --- a/grc/core/utils/descriptors/evaluated.py +++ b/grc/core/utils/descriptors/evaluated.py @@ -15,6 +15,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +from __future__ import absolute_import + +import six + class Evaluated(object): def __init__(self, expected_type, default, name=None): @@ -62,7 +66,7 @@ class Evaluated(object): def __set__(self, instance, value): attribs = instance.__dict__ value = value or self.default - if isinstance(value, str) and value.startswith('${') and value.endswith('}'): + if isinstance(value, six.text_type) and value.startswith('${') and value.endswith('}'): attribs[self.name_raw] = value[2:-1].strip() else: attribs[self.name] = type(self.default)(value) diff --git a/grc/gui/Platform.py b/grc/gui/Platform.py index 2a38bc619e..8eb79f3459 100644 --- a/grc/gui/Platform.py +++ b/grc/gui/Platform.py @@ -63,8 +63,8 @@ class Platform(CorePlatform): FlowGraph = canvas.FlowGraph Connection = canvas.Connection - def new_block_class(self, block_id, **data): - cls = CorePlatform.new_block_class(self, block_id, **data) + def new_block_class(self, **data): + cls = CorePlatform.new_block_class(self, **data) return canvas.Block.make_cls_with_base(cls) block_classes_build_in = {key: canvas.Block.make_cls_with_base(cls) -- cgit v1.2.3 From fbc1627340ea3ed4bedc3424d5a2ec3736e66b4b Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <sebastian.koslowski@gmail.com> Date: Wed, 8 Nov 2017 19:05:19 +0100 Subject: grc: move port and param init to block builder --- grc/core/blocks/_build.py | 76 ++++++++++++++++++++++++++++++++++++++++---- grc/core/blocks/_flags.py | 16 +++++----- grc/core/blocks/block.py | 81 ++++++++--------------------------------------- 3 files changed, 91 insertions(+), 82 deletions(-) (limited to 'grc') diff --git a/grc/core/blocks/_build.py b/grc/core/blocks/_build.py index ce3496d9c4..6db06040cf 100644 --- a/grc/core/blocks/_build.py +++ b/grc/core/blocks/_build.py @@ -17,8 +17,13 @@ from __future__ import absolute_import +import collections +import itertools import re +from ..Constants import ADVANCED_PARAM_TAB +from ..utils import to_list + from .block import Block from ._flags import Flags from ._templates import MakoTemplates @@ -35,17 +40,18 @@ def build(id, label='', category='', flags='', documentation='', cls.label = label or block_id.title() cls.category = [cat.strip() for cat in category.split('/') if cat.strip()] - cls.flags = Flags(flags) + cls.flags = Flags(to_list(flags)) if re.match(r'options$|variable|virtual', block_id): - cls.flags += Flags.NOT_DSP + Flags.DISABLE_BYPASS + cls.flags.set(Flags.NOT_DSP, Flags.DISABLE_BYPASS) cls.documentation = {'': documentation.strip('\n\t ').replace('\\\n', '')} - cls.asserts = [_single_mako_expr(a, block_id) for a in (asserts or [])] + cls.asserts = [_single_mako_expr(a, block_id) for a in to_list(asserts)] - cls.parameters_data = parameters or [] - cls.inputs_data = inputs or [] - cls.outputs_data = outputs or [] + cls.inputs_data = _build_ports(inputs, 'sink') if inputs else [] + cls.outputs_data = _build_ports(outputs, 'source') if outputs else [] + cls.parameters_data = _build_params(parameters or [], + bool(cls.inputs_data), bool(cls.outputs_data), cls.flags) cls.extra_data = kwargs templates = templates or {} @@ -62,6 +68,64 @@ def build(id, label='', category='', flags='', documentation='', return cls +def _build_ports(ports_raw, direction): + ports = [] + port_ids = set() + stream_port_ids = itertools.count() + + for i, port_params in enumerate(ports_raw): + port = port_params.copy() + port['direction'] = direction + + port_id = port.setdefault('id', str(next(stream_port_ids))) + if port_id in port_ids: + raise Exception('Port id "{}" already exists in {}s'.format(port_id, direction)) + port_ids.add(port_id) + + ports.append(port) + return ports + + +def _build_params(params_raw, have_inputs, have_outputs, flags): + params = [] + + def add_param(**data): + params.append(data) + + add_param(id='id', name='ID', dtype='id', hide='part') + + if not flags.not_dsp: + add_param(id='alias', name='Block Alias', dtype='string', + hide='part', category=ADVANCED_PARAM_TAB) + + if have_outputs or have_inputs: + add_param(id='affinity', name='Core Affinity', dtype='int_vector', + hide='part', category=ADVANCED_PARAM_TAB) + + if have_outputs: + add_param(id='minoutbuf', name='Min Output Buffer', dtype='int', + hide='part', value='0', category=ADVANCED_PARAM_TAB) + add_param(id='maxoutbuf', name='Max Output Buffer', dtype='int', + hide='part', value='0', category=ADVANCED_PARAM_TAB) + + base_params_n = {} + for param_data in params_raw: + param_id = param_data['id'] + if param_id in params: + raise Exception('Param id "{}" is not unique'.format(param_id)) + + base_key = param_data.get('base_key', None) + param_data_ext = base_params_n.get(base_key, {}).copy() + param_data_ext.update(param_data) + + add_param(**param_data_ext) + base_params_n[param_id] = param_data_ext + + add_param(id='comment', name='Comment', dtype='_multiline', hide='part', + value='', category=ADVANCED_PARAM_TAB) + return params + + def _single_mako_expr(value, block_id): if not value: return None diff --git a/grc/core/blocks/_flags.py b/grc/core/blocks/_flags.py index ffea2ad569..bbedd6a2d7 100644 --- a/grc/core/blocks/_flags.py +++ b/grc/core/blocks/_flags.py @@ -17,10 +17,8 @@ from __future__ import absolute_import -import six - -class Flags(six.text_type): +class Flags(object): THROTTLE = 'throttle' DISABLE_BYPASS = 'disable_bypass' @@ -28,12 +26,14 @@ class Flags(six.text_type): DEPRECATED = 'deprecated' NOT_DSP = 'not_dsp' + def __init__(self, flags): + self.data = set(flags) + def __getattr__(self, item): return item in self - def __add__(self, other): - if not isinstance(other, six.string_types): - return NotImplemented - return self.__class__(str(self) + other) + def __contains__(self, item): + return item in self.data - __iadd__ = __add__ + def set(self, *flags): + self.data.update(flags) diff --git a/grc/core/blocks/block.py b/grc/core/blocks/block.py index adc046936d..3a3de43fce 100644 --- a/grc/core/blocks/block.py +++ b/grc/core/blocks/block.py @@ -29,7 +29,6 @@ from six.moves import range from ._templates import MakoTemplates from ._flags import Flags -from ..Constants import ADVANCED_PARAM_TAB from ..base import Element from ..utils.descriptors import lazy_property @@ -63,82 +62,28 @@ class Block(Element): outputs_data = [] extra_data = {} + loaded_from = '(unknown)' - # region Init def __init__(self, parent): """Make a new block from nested data.""" super(Block, self).__init__(parent) - self.params = self._init_params() - self.sinks = self._init_ports(self.inputs_data, direction='sink') - self.sources = self._init_ports(self.outputs_data, direction='source') - - self.active_sources = [] # on rewrite - self.active_sinks = [] # on rewrite - - self.states = {'state': True} - - def _init_params(self): - is_dsp_block = not self.flags.not_dsp - has_inputs = bool(self.inputs_data) - has_outputs = bool(self.outputs_data) - - params = collections.OrderedDict() param_factory = self.parent_platform.make_param - - def add_param(id, **kwargs): - params[id] = param_factory(self, id=id, **kwargs) - - add_param(id='id', name='ID', dtype='id', - hide='none' if (self.key == 'options' or self.is_variable) else 'part') - - if is_dsp_block: - add_param(id='alias', name='Block Alias', dtype='string', - hide='part', category=ADVANCED_PARAM_TAB) - - if has_outputs or has_inputs: - add_param(id='affinity', name='Core Affinity', dtype='int_vector', - hide='part', category=ADVANCED_PARAM_TAB) - - if has_outputs: - add_param(id='minoutbuf', name='Min Output Buffer', dtype='int', - hide='part', value='0', category=ADVANCED_PARAM_TAB) - add_param(id='maxoutbuf', name='Max Output Buffer', dtype='int', - hide='part', value='0', category=ADVANCED_PARAM_TAB) - - base_params_n = {} - for param_data in self.parameters_data: - param_id = param_data['id'] - if param_id in params: - raise Exception('Param id "{}" is not unique'.format(param_id)) - - base_key = param_data.get('base_key', None) - param_data_ext = base_params_n.get(base_key, {}).copy() - param_data_ext.update(param_data) - - add_param(**param_data_ext) - base_params_n[param_id] = param_data_ext - - add_param(id='comment', name='Comment', dtype='_multiline', hide='part', - value='', category=ADVANCED_PARAM_TAB) - return params - - def _init_ports(self, ports_n, direction): - ports = [] port_factory = self.parent_platform.make_port - port_ids = set() - stream_port_ids = itertools.count() + self.params = collections.OrderedDict( + (data['id'], param_factory(parent=self, **data)) + for data in self.parameters_data + ) + if self.key == 'options' or self.is_variable: + self.params['id'].hide = 'part' - for i, port_data in enumerate(ports_n): - port_id = port_data.setdefault('id', str(next(stream_port_ids))) - if port_id in port_ids: - raise Exception('Port id "{}" already exists in {}s'.format(port_id, direction)) - port_ids.add(port_id) + self.sinks = [port_factory(parent=self, **params) for params in self.inputs_data] + self.sources = [port_factory(parent=self, **params) for params in self.outputs_data] - port = port_factory(parent=self, direction=direction, **port_data) - ports.append(port) - return ports - # endregion + self.active_sources = [] # on rewrite + self.active_sinks = [] # on rewrite + + self.states = {'state': True} # region Rewrite_and_Validation def rewrite(self): -- cgit v1.2.3 From cd9c3479e17fbdb84918e255cf6de74edf0ceab1 Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <sebastian.koslowski@gmail.com> Date: Tue, 3 Oct 2017 18:47:06 +0200 Subject: grc: refactor: move Param cls to core.params --- grc/core/Param.py | 517 ---------------------------------------- grc/core/blocks/block.py | 1 - grc/core/params/__init__.py | 18 ++ grc/core/params/param.py | 485 +++++++++++++++++++++++++++++++++++++ grc/core/params/template_arg.py | 50 ++++ grc/core/platform.py | 5 +- grc/gui/canvas/param.py | 4 +- 7 files changed, 556 insertions(+), 524 deletions(-) delete mode 100644 grc/core/Param.py create mode 100644 grc/core/params/__init__.py create mode 100644 grc/core/params/param.py create mode 100644 grc/core/params/template_arg.py (limited to 'grc') diff --git a/grc/core/Param.py b/grc/core/Param.py deleted file mode 100644 index 13439f43b4..0000000000 --- a/grc/core/Param.py +++ /dev/null @@ -1,517 +0,0 @@ -""" -Copyright 2008-2015 Free Software Foundation, Inc. -This file is part of GNU Radio - -GNU Radio Companion is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -GNU Radio Companion is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -""" - -from __future__ import absolute_import - -import ast -import numbers -import re -import collections -import textwrap - -import six -from six.moves import builtins, range - -from . import Constants, blocks -from .base import Element -from .utils.descriptors import Evaluated, EvaluatedEnum, setup_names - -# Blacklist certain ids, its not complete, but should help -ID_BLACKLIST = ['self', 'options', 'gr', 'math', 'firdes'] + dir(builtins) -try: - from gnuradio import gr - ID_BLACKLIST.extend(attr for attr in dir(gr.top_block()) if not attr.startswith('_')) -except (ImportError, AttributeError): - pass - - -class TemplateArg(str): - """ - A cheetah template argument created from a param. - The str of this class evaluates to the param's to code method. - The use of this class as a dictionary (enum only) will reveal the enum opts. - The __call__ or () method can return the param evaluated to a raw python data type. - """ - - def __new__(cls, param): - value = param.to_code() - instance = str.__new__(cls, value) - setattr(instance, '_param', param) - return instance - - def __getitem__(self, item): - return str(self._param.get_opt(item)) if self._param.is_enum() else NotImplemented - - def __getattr__(self, item): - if not self._param.is_enum(): - raise AttributeError() - try: - return str(self._param.get_opt(item)) - except KeyError: - raise AttributeError() - - def __str__(self): - return str(self._param.to_code()) - - def __call__(self): - return self._param.get_evaluated() - - -@setup_names -class Param(Element): - - is_param = True - - name = Evaluated(str, default='no name') - dtype = EvaluatedEnum(Constants.PARAM_TYPE_NAMES, default='raw') - hide = EvaluatedEnum('none all part') - - # region init - def __init__(self, parent, id, label='', dtype='raw', default='', - options=None, option_labels=None, option_attributes=None, - category='', hide='none', **_): - """Make a new param from nested data""" - super(Param, self).__init__(parent) - self.key = id - self.name = label.strip() or id.title() - self.category = category or Constants.DEFAULT_PARAM_TAB - - self.dtype = dtype - self.value = self.default = str(default) - - self.options = self._init_options(options or [], option_labels or [], - option_attributes or {}) - self.hide = hide or 'none' - # end of args ######################################################## - - self._evaluated = None - self._stringify_flag = False - self._lisitify_flag = False - self.hostage_cells = set() - self._init = False - - @property - def template_arg(self): - return TemplateArg(self) - - def _init_options(self, values, labels, attributes): - """parse option and option attributes""" - options = collections.OrderedDict() - options.attributes = collections.defaultdict(dict) - - padding = [''] * max(len(values), len(labels)) - attributes = {key: value + padding for key, value in six.iteritems(attributes)} - - for i, option in enumerate(values): - # Test against repeated keys - if option in options: - raise KeyError('Value "{}" already exists in options'.format(option)) - # get label - try: - label = str(labels[i]) - except IndexError: - label = str(option) - # Store the option - options[option] = label - options.attributes[option] = {attrib: values[i] for attrib, values in six.iteritems(attributes)} - - default = next(iter(options)) if options else '' - if not self.value: - self.value = self.default = default - - if self.is_enum() and self.value not in options: - self.value = self.default = default # TODO: warn - # raise ValueError('The value {!r} is not in the possible values of {}.' - # ''.format(self.get_value(), ', '.join(self.options))) - return options - # endregion - - def __str__(self): - return 'Param - {}({})'.format(self.name, self.key) - - def __repr__(self): - return '{!r}.param[{}]'.format(self.parent, self.key) - - def is_enum(self): - return self.get_raw('dtype') == 'enum' - - def get_value(self): - value = self.value - if self.is_enum() and value not in self.options: - value = self.default - self.set_value(value) - return value - - def set_value(self, value): - # Must be a string - self.value = str(value) - - def set_default(self, value): - if self.default == self.value: - self.set_value(value) - self.default = str(value) - - def rewrite(self): - Element.rewrite(self) - del self.name - del self.dtype - del self.hide - - self._evaluated = None - try: - self._evaluated = self.evaluate() - except Exception as e: - self.add_error_message(str(e)) - - def validate(self): - """ - Validate the param. - The value must be evaluated and type must a possible type. - """ - Element.validate(self) - if self.dtype not in Constants.PARAM_TYPE_NAMES: - self.add_error_message('Type "{}" is not a possible type.'.format(self.dtype)) - - def get_evaluated(self): - return self._evaluated - - def evaluate(self): - """ - Evaluate the value. - - Returns: - evaluated type - """ - self._init = True - self._lisitify_flag = False - self._stringify_flag = False - dtype = self.dtype - expr = self.get_value() - - ######################### - # Enum Type - ######################### - if self.is_enum(): - return expr - - ######################### - # Numeric Types - ######################### - elif dtype in ('raw', 'complex', 'real', 'float', 'int', 'hex', 'bool'): - # Raise exception if python cannot evaluate this value - try: - value = self.parent_flowgraph.evaluate(expr) - except Exception as value: - raise Exception('Value "{}" cannot be evaluated:\n{}'.format(expr, value)) - # Raise an exception if the data is invalid - if dtype == 'raw': - return value - elif dtype == 'complex': - if not isinstance(value, Constants.COMPLEX_TYPES): - raise Exception('Expression "{}" is invalid for type complex.'.format(str(value))) - return value - elif dtype in ('real', 'float'): - if not isinstance(value, Constants.REAL_TYPES): - raise Exception('Expression "{}" is invalid for type float.'.format(str(value))) - return value - elif dtype == 'int': - if not isinstance(value, Constants.INT_TYPES): - raise Exception('Expression "{}" is invalid for type integer.'.format(str(value))) - return value - elif dtype == 'hex': - return hex(value) - elif dtype == 'bool': - if not isinstance(value, bool): - raise Exception('Expression "{}" is invalid for type bool.'.format(str(value))) - return value - else: - raise TypeError('Type "{}" not handled'.format(dtype)) - ######################### - # Numeric Vector Types - ######################### - elif dtype in ('complex_vector', 'real_vector', 'float_vector', 'int_vector'): - default = [] - - if not expr: - return default # Turn a blank string into an empty list, so it will eval - - try: - value = self.parent.parent.evaluate(expr) - except Exception as value: - raise Exception('Value "{}" cannot be evaluated:\n{}'.format(expr, value)) - - if not isinstance(value, Constants.VECTOR_TYPES): - self._lisitify_flag = True - value = [value] - - # Raise an exception if the data is invalid - if dtype == 'complex_vector' and not all(isinstance(item, numbers.Complex) for item in value): - raise Exception('Expression "{}" is invalid for type complex vector.'.format(value)) - elif dtype in ('real_vector', 'float_vector') and not all(isinstance(item, numbers.Real) for item in value): - raise Exception('Expression "{}" is invalid for type float vector.'.format(value)) - elif dtype == 'int_vector' and not all(isinstance(item, Constants.INT_TYPES) for item in value): - raise Exception('Expression "{}" is invalid for type integer vector.'.format(str(value))) - return value - ######################### - # String Types - ######################### - elif dtype in ('string', 'file_open', 'file_save', '_multiline', '_multiline_python_external'): - # Do not check if file/directory exists, that is a runtime issue - try: - value = self.parent.parent.evaluate(expr) - if not isinstance(value, str): - raise Exception() - except: - self._stringify_flag = True - value = str(expr) - if dtype == '_multiline_python_external': - ast.parse(value) # Raises SyntaxError - return value - ######################### - # Unique ID Type - ######################### - elif dtype == 'id': - self.validate_block_id() - return expr - - ######################### - # Stream ID Type - ######################### - elif dtype == 'stream_id': - self.validate_stream_id() - return expr - - ######################### - # GUI Position/Hint - ######################### - elif dtype == 'gui_hint': - if self.parent_block.state == 'disabled': - return '' - else: - return self.parse_gui_hint(expr) - - ######################### - # Import Type - ######################### - elif dtype == 'import': - # New namespace - n = dict() - try: - exec(expr, n) - except ImportError: - raise Exception('Import "{}" failed.'.format(expr)) - except Exception: - raise Exception('Bad import syntax: "{}".'.format(expr)) - return [k for k in list(n.keys()) if str(k) != '__builtins__'] - - ######################### - else: - raise TypeError('Type "{}" not handled'.format(dtype)) - - def validate_block_id(self): - value = self.value - # Can python use this as a variable? - if not re.match(r'^[a-z|A-Z]\w*$', value): - raise Exception('ID "{}" must begin with a letter and may contain letters, numbers, ' - 'and underscores.'.format(value)) - if value in ID_BLACKLIST: - raise Exception('ID "{}" is blacklisted.'.format(value)) - block_names = [block.name for block in self.parent_flowgraph.iter_enabled_blocks()] - # Id should only appear once, or zero times if block is disabled - if self.key == 'id' and block_names.count(value) > 1: - raise Exception('ID "{}" is not unique.'.format(value)) - elif value not in block_names: - raise Exception('ID "{}" does not exist.'.format(value)) - return value - - def validate_stream_id(self): - value = self.value - stream_ids = [ - block.params['stream_id'].value - for block in self.parent_flowgraph.iter_enabled_blocks() - if isinstance(block, blocks.VirtualSink) - ] - # Check that the virtual sink's stream id is unique - if isinstance(self.parent_block, blocks.VirtualSink) and stream_ids.count(value) >= 2: - # Id should only appear once, or zero times if block is disabled - raise Exception('Stream ID "{}" is not unique.'.format(value)) - # Check that the virtual source's steam id is found - elif isinstance(self.parent_block, blocks.VirtualSource) and value not in stream_ids: - raise Exception('Stream ID "{}" is not found.'.format(value)) - - def to_code(self): - """ - Convert the value to code. - For string and list types, check the init flag, call evaluate(). - This ensures that evaluate() was called to set the xxxify_flags. - - Returns: - a string representing the code - """ - self._init = True - v = self.get_value() - t = self.dtype - # String types - if t in ('string', 'file_open', 'file_save', '_multiline', '_multiline_python_external'): - if not self._init: - self.evaluate() - return repr(v) if self._stringify_flag else v - - # Vector types - elif t in ('complex_vector', 'real_vector', 'float_vector', 'int_vector'): - if not self._init: - self.evaluate() - if self._lisitify_flag: - return '(%s, )' % v - else: - return '(%s)' % v - else: - return v - - def get_opt(self, item): - return self.options.attributes[self.get_value()][item] - - ############################################## - # GUI Hint - ############################################## - def parse_gui_hint(self, expr): - """ - Parse/validate gui hint value. - - Args: - expr: gui_hint string from a block's 'gui_hint' param - - Returns: - string of python code for positioning GUI elements in pyQT - """ - self.hostage_cells.clear() - - # Parsing - if ':' in expr: - tab, pos = expr.split(':') - elif ',' in expr: - tab, pos = '', expr - else: - tab, pos = expr, '' - - if '@' in tab: - tab, index = tab.split('@') - else: - index = '0' - index = int(index) - - # Validation - def parse_pos(): - e = self.parent_flowgraph.evaluate(pos) - - if not isinstance(e, (list, tuple)) or len(e) not in (2, 4) or not all(isinstance(ei, int) for ei in e): - raise Exception('Invalid GUI Hint entered: {e!r} (Must be a list of {{2,4}} non-negative integers).'.format(e=e)) - - if len(e) == 2: - row, col = e - row_span = col_span = 1 - else: - row, col, row_span, col_span = e - - if (row < 0) or (col < 0): - raise Exception('Invalid GUI Hint entered: {e!r} (non-negative integers only).'.format(e=e)) - - if (row_span < 1) or (col_span < 1): - raise Exception('Invalid GUI Hint entered: {e!r} (positive row/column span required).'.format(e=e)) - - return row, col, row_span, col_span - - def validate_tab(): - tabs = (block for block in self.parent_flowgraph.iter_enabled_blocks() - if block.key == 'qtgui_tab_widget' and block.name == tab) - tab_block = next(iter(tabs), None) - if not tab_block: - raise Exception('Invalid tab name entered: {tab} (Tab name not found).'.format(tab=tab)) - - tab_index_size = int(tab_block.params['num_tabs'].value) - if index >= tab_index_size: - raise Exception('Invalid tab index entered: {tab}@{index} (Index out of range).'.format( - tab=tab, index=index)) - - # Collision Detection - def collision_detection(row, col, row_span, col_span): - my_parent = '{tab}@{index}'.format(tab=tab, index=index) if tab else 'main' - # Calculate hostage cells - for r in range(row, row + row_span): - for c in range(col, col + col_span): - self.hostage_cells.add((my_parent, (r, c))) - - for other in self.get_all_params('gui_hint'): - if other is self: - continue - collision = next(iter(self.hostage_cells & other.hostage_cells), None) - if collision: - raise Exception('Block {block!r} is also using parent {parent!r}, cell {cell!r}.'.format( - block=other.parent_block.name, parent=collision[0], cell=collision[1] - )) - - # Code Generation - if tab: - validate_tab() - layout = '{tab}_grid_layout_{index}'.format(tab=tab, index=index) - else: - layout = 'top_grid_layout' - - widget = '%s' # to be fill-out in the mail template - - if pos: - 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, - ) - - else: - widget_str = 'self.{layout}.addWidget({widget})'.format(layout=layout, widget=widget) - - return widget_str - - def get_all_params(self, dtype, key=None): - """ - Get all the params from the flowgraph that have the given type and - optionally a given key - - Args: - type: the specified type - key: the key to match against - - Returns: - a list of params - """ - params = [] - for block in self.parent_flowgraph.iter_enabled_blocks(): - params.extend( - param for param in block.params.values() - if param.dtype == dtype and (key is None or key == param.name) - ) - return params diff --git a/grc/core/blocks/block.py b/grc/core/blocks/block.py index 3a3de43fce..0cb3f61237 100644 --- a/grc/core/blocks/block.py +++ b/grc/core/blocks/block.py @@ -19,7 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA from __future__ import absolute_import -import ast import collections import itertools diff --git a/grc/core/params/__init__.py b/grc/core/params/__init__.py new file mode 100644 index 0000000000..93663bdada --- /dev/null +++ b/grc/core/params/__init__.py @@ -0,0 +1,18 @@ +# Copyright 2017 Free Software Foundation, Inc. +# This file is part of GNU Radio +# +# GNU Radio Companion is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# GNU Radio Companion is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +from .param import Param diff --git a/grc/core/params/param.py b/grc/core/params/param.py new file mode 100644 index 0000000000..787be9a19f --- /dev/null +++ b/grc/core/params/param.py @@ -0,0 +1,485 @@ +# Copyright 2008-2017 Free Software Foundation, Inc. +# This file is part of GNU Radio +# +# GNU Radio Companion is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# GNU Radio Companion is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +from __future__ import absolute_import + +import ast +import numbers +import re +import collections +import textwrap + +import six +from six.moves import builtins, range + +from .. import Constants, blocks +from ..base import Element +from ..utils.descriptors import Evaluated, EvaluatedEnum, setup_names + +from .template_arg import TemplateArg + +# Blacklist certain ids, its not complete, but should help +ID_BLACKLIST = ['self', 'options', 'gr', 'math', 'firdes'] + dir(builtins) +try: + from gnuradio import gr + ID_BLACKLIST.extend(attr for attr in dir(gr.top_block()) if not attr.startswith('_')) +except (ImportError, AttributeError): + pass + + +@setup_names +class Param(Element): + + is_param = True + + name = Evaluated(str, default='no name') + dtype = EvaluatedEnum(Constants.PARAM_TYPE_NAMES, default='raw') + hide = EvaluatedEnum('none all part') + + # region init + def __init__(self, parent, id, label='', dtype='raw', default='', + options=None, option_labels=None, option_attributes=None, + category='', hide='none', **_): + """Make a new param from nested data""" + super(Param, self).__init__(parent) + self.key = id + self.name = label.strip() or id.title() + self.category = category or Constants.DEFAULT_PARAM_TAB + + self.dtype = dtype + self.value = self.default = str(default) + + self.options = self._init_options(options or [], option_labels or [], + option_attributes or {}) + self.hide = hide or 'none' + # end of args ######################################################## + + self._evaluated = None + self._stringify_flag = False + self._lisitify_flag = False + self.hostage_cells = set() + self._init = False + + def _init_options(self, values, labels, attributes): + """parse option and option attributes""" + options = collections.OrderedDict() + options.attributes = collections.defaultdict(dict) + + padding = [''] * max(len(values), len(labels)) + attributes = {key: value + padding for key, value in six.iteritems(attributes)} + + for i, option in enumerate(values): + # Test against repeated keys + if option in options: + raise KeyError('Value "{}" already exists in options'.format(option)) + # get label + try: + label = str(labels[i]) + except IndexError: + label = str(option) + # Store the option + options[option] = label + options.attributes[option] = {attrib: values[i] for attrib, values in six.iteritems(attributes)} + + default = next(iter(options)) if options else '' + if not self.value: + self.value = self.default = default + + if self.is_enum() and self.value not in options: + self.value = self.default = default # TODO: warn + # raise ValueError('The value {!r} is not in the possible values of {}.' + # ''.format(self.get_value(), ', '.join(self.options))) + return options + # endregion + + @property + def template_arg(self): + return TemplateArg(self) + + def __str__(self): + return 'Param - {}({})'.format(self.name, self.key) + + def __repr__(self): + return '{!r}.param[{}]'.format(self.parent, self.key) + + def is_enum(self): + return self.get_raw('dtype') == 'enum' + + def get_value(self): + value = self.value + if self.is_enum() and value not in self.options: + value = self.default + self.set_value(value) + return value + + def set_value(self, value): + # Must be a string + self.value = str(value) + + def set_default(self, value): + if self.default == self.value: + self.set_value(value) + self.default = str(value) + + def rewrite(self): + Element.rewrite(self) + del self.name + del self.dtype + del self.hide + + self._evaluated = None + try: + self._evaluated = self.evaluate() + except Exception as e: + self.add_error_message(str(e)) + + def validate(self): + """ + Validate the param. + The value must be evaluated and type must a possible type. + """ + Element.validate(self) + if self.dtype not in Constants.PARAM_TYPE_NAMES: + self.add_error_message('Type "{}" is not a possible type.'.format(self.dtype)) + + def get_evaluated(self): + return self._evaluated + + def evaluate(self): + """ + Evaluate the value. + + Returns: + evaluated type + """ + self._init = True + self._lisitify_flag = False + self._stringify_flag = False + dtype = self.dtype + expr = self.get_value() + + ######################### + # Enum Type + ######################### + if self.is_enum(): + return expr + + ######################### + # Numeric Types + ######################### + elif dtype in ('raw', 'complex', 'real', 'float', 'int', 'hex', 'bool'): + # Raise exception if python cannot evaluate this value + try: + value = self.parent_flowgraph.evaluate(expr) + except Exception as value: + raise Exception('Value "{}" cannot be evaluated:\n{}'.format(expr, value)) + # Raise an exception if the data is invalid + if dtype == 'raw': + return value + elif dtype == 'complex': + if not isinstance(value, Constants.COMPLEX_TYPES): + raise Exception('Expression "{}" is invalid for type complex.'.format(str(value))) + return value + elif dtype in ('real', 'float'): + if not isinstance(value, Constants.REAL_TYPES): + raise Exception('Expression "{}" is invalid for type float.'.format(str(value))) + return value + elif dtype == 'int': + if not isinstance(value, Constants.INT_TYPES): + raise Exception('Expression "{}" is invalid for type integer.'.format(str(value))) + return value + elif dtype == 'hex': + return hex(value) + elif dtype == 'bool': + if not isinstance(value, bool): + raise Exception('Expression "{}" is invalid for type bool.'.format(str(value))) + return value + else: + raise TypeError('Type "{}" not handled'.format(dtype)) + ######################### + # Numeric Vector Types + ######################### + elif dtype in ('complex_vector', 'real_vector', 'float_vector', 'int_vector'): + default = [] + + if not expr: + return default # Turn a blank string into an empty list, so it will eval + + try: + value = self.parent.parent.evaluate(expr) + except Exception as value: + raise Exception('Value "{}" cannot be evaluated:\n{}'.format(expr, value)) + + if not isinstance(value, Constants.VECTOR_TYPES): + self._lisitify_flag = True + value = [value] + + # Raise an exception if the data is invalid + if dtype == 'complex_vector' and not all(isinstance(item, numbers.Complex) for item in value): + raise Exception('Expression "{}" is invalid for type complex vector.'.format(value)) + elif dtype in ('real_vector', 'float_vector') and not all(isinstance(item, numbers.Real) for item in value): + raise Exception('Expression "{}" is invalid for type float vector.'.format(value)) + elif dtype == 'int_vector' and not all(isinstance(item, Constants.INT_TYPES) for item in value): + raise Exception('Expression "{}" is invalid for type integer vector.'.format(str(value))) + return value + ######################### + # String Types + ######################### + elif dtype in ('string', 'file_open', 'file_save', '_multiline', '_multiline_python_external'): + # Do not check if file/directory exists, that is a runtime issue + try: + value = self.parent.parent.evaluate(expr) + if not isinstance(value, str): + raise Exception() + except: + self._stringify_flag = True + value = str(expr) + if dtype == '_multiline_python_external': + ast.parse(value) # Raises SyntaxError + return value + ######################### + # Unique ID Type + ######################### + elif dtype == 'id': + self.validate_block_id() + return expr + + ######################### + # Stream ID Type + ######################### + elif dtype == 'stream_id': + self.validate_stream_id() + return expr + + ######################### + # GUI Position/Hint + ######################### + elif dtype == 'gui_hint': + if self.parent_block.state == 'disabled': + return '' + else: + return self.parse_gui_hint(expr) + + ######################### + # Import Type + ######################### + elif dtype == 'import': + # New namespace + n = dict() + try: + exec(expr, n) + except ImportError: + raise Exception('Import "{}" failed.'.format(expr)) + except Exception: + raise Exception('Bad import syntax: "{}".'.format(expr)) + return [k for k in list(n.keys()) if str(k) != '__builtins__'] + + ######################### + else: + raise TypeError('Type "{}" not handled'.format(dtype)) + + def validate_block_id(self): + value = self.value + # Can python use this as a variable? + if not re.match(r'^[a-z|A-Z]\w*$', value): + raise Exception('ID "{}" must begin with a letter and may contain letters, numbers, ' + 'and underscores.'.format(value)) + if value in ID_BLACKLIST: + raise Exception('ID "{}" is blacklisted.'.format(value)) + block_names = [block.name for block in self.parent_flowgraph.iter_enabled_blocks()] + # Id should only appear once, or zero times if block is disabled + if self.key == 'id' and block_names.count(value) > 1: + raise Exception('ID "{}" is not unique.'.format(value)) + elif value not in block_names: + raise Exception('ID "{}" does not exist.'.format(value)) + return value + + def validate_stream_id(self): + value = self.value + stream_ids = [ + block.params['stream_id'].value + for block in self.parent_flowgraph.iter_enabled_blocks() + if isinstance(block, blocks.VirtualSink) + ] + # Check that the virtual sink's stream id is unique + if isinstance(self.parent_block, blocks.VirtualSink) and stream_ids.count(value) >= 2: + # Id should only appear once, or zero times if block is disabled + raise Exception('Stream ID "{}" is not unique.'.format(value)) + # Check that the virtual source's steam id is found + elif isinstance(self.parent_block, blocks.VirtualSource) and value not in stream_ids: + raise Exception('Stream ID "{}" is not found.'.format(value)) + + def to_code(self): + """ + Convert the value to code. + For string and list types, check the init flag, call evaluate(). + This ensures that evaluate() was called to set the xxxify_flags. + + Returns: + a string representing the code + """ + self._init = True + v = self.get_value() + t = self.dtype + # String types + if t in ('string', 'file_open', 'file_save', '_multiline', '_multiline_python_external'): + if not self._init: + self.evaluate() + return repr(v) if self._stringify_flag else v + + # Vector types + elif t in ('complex_vector', 'real_vector', 'float_vector', 'int_vector'): + if not self._init: + self.evaluate() + if self._lisitify_flag: + return '(%s, )' % v + else: + return '(%s)' % v + else: + return v + + def get_opt(self, item): + return self.options.attributes[self.get_value()][item] + + ############################################## + # GUI Hint + ############################################## + def parse_gui_hint(self, expr): + """ + Parse/validate gui hint value. + + Args: + expr: gui_hint string from a block's 'gui_hint' param + + Returns: + string of python code for positioning GUI elements in pyQT + """ + self.hostage_cells.clear() + + # Parsing + if ':' in expr: + tab, pos = expr.split(':') + elif ',' in expr: + tab, pos = '', expr + else: + tab, pos = expr, '' + + if '@' in tab: + tab, index = tab.split('@') + else: + index = '0' + index = int(index) + + # Validation + def parse_pos(): + e = self.parent_flowgraph.evaluate(pos) + + if not isinstance(e, (list, tuple)) or len(e) not in (2, 4) or not all(isinstance(ei, int) for ei in e): + raise Exception('Invalid GUI Hint entered: {e!r} (Must be a list of {{2,4}} non-negative integers).'.format(e=e)) + + if len(e) == 2: + row, col = e + row_span = col_span = 1 + else: + row, col, row_span, col_span = e + + if (row < 0) or (col < 0): + raise Exception('Invalid GUI Hint entered: {e!r} (non-negative integers only).'.format(e=e)) + + if (row_span < 1) or (col_span < 1): + raise Exception('Invalid GUI Hint entered: {e!r} (positive row/column span required).'.format(e=e)) + + return row, col, row_span, col_span + + def validate_tab(): + tabs = (block for block in self.parent_flowgraph.iter_enabled_blocks() + if block.key == 'qtgui_tab_widget' and block.name == tab) + tab_block = next(iter(tabs), None) + if not tab_block: + raise Exception('Invalid tab name entered: {tab} (Tab name not found).'.format(tab=tab)) + + tab_index_size = int(tab_block.params['num_tabs'].value) + if index >= tab_index_size: + raise Exception('Invalid tab index entered: {tab}@{index} (Index out of range).'.format( + tab=tab, index=index)) + + # Collision Detection + def collision_detection(row, col, row_span, col_span): + my_parent = '{tab}@{index}'.format(tab=tab, index=index) if tab else 'main' + # Calculate hostage cells + for r in range(row, row + row_span): + for c in range(col, col + col_span): + self.hostage_cells.add((my_parent, (r, c))) + + for other in self.get_all_params('gui_hint'): + if other is self: + continue + collision = next(iter(self.hostage_cells & other.hostage_cells), None) + if collision: + raise Exception('Block {block!r} is also using parent {parent!r}, cell {cell!r}.'.format( + block=other.parent_block.name, parent=collision[0], cell=collision[1] + )) + + # Code Generation + if tab: + validate_tab() + layout = '{tab}_grid_layout_{index}'.format(tab=tab, index=index) + else: + layout = 'top_grid_layout' + + widget = '%s' # to be fill-out in the mail template + + if pos: + 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, + ) + + else: + widget_str = 'self.{layout}.addWidget({widget})'.format(layout=layout, widget=widget) + + return widget_str + + def get_all_params(self, dtype, key=None): + """ + Get all the params from the flowgraph that have the given type and + optionally a given key + + Args: + type: the specified type + key: the key to match against + + Returns: + a list of params + """ + params = [] + for block in self.parent_flowgraph.iter_enabled_blocks(): + params.extend( + param for param in block.params.values() + if param.dtype == dtype and (key is None or key == param.name) + ) + return params diff --git a/grc/core/params/template_arg.py b/grc/core/params/template_arg.py new file mode 100644 index 0000000000..5c8c610b4f --- /dev/null +++ b/grc/core/params/template_arg.py @@ -0,0 +1,50 @@ +# Copyright 2008-2017 Free Software Foundation, Inc. +# This file is part of GNU Radio +# +# GNU Radio Companion is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# GNU Radio Companion is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +from __future__ import absolute_import + + +class TemplateArg(str): + """ + A cheetah template argument created from a param. + The str of this class evaluates to the param's to code method. + The use of this class as a dictionary (enum only) will reveal the enum opts. + The __call__ or () method can return the param evaluated to a raw python data type. + """ + + def __new__(cls, param): + value = param.to_code() + instance = str.__new__(cls, value) + setattr(instance, '_param', param) + return instance + + def __getitem__(self, item): + return str(self._param.get_opt(item)) if self._param.is_enum() else NotImplemented + + def __getattr__(self, item): + if not self._param.is_enum(): + raise AttributeError() + try: + return str(self._param.get_opt(item)) + except KeyError: + raise AttributeError() + + def __str__(self): + return str(self._param.to_code()) + + def __call__(self): + return self._param.get_evaluated() diff --git a/grc/core/platform.py b/grc/core/platform.py index 54deef3455..6d02cb6441 100644 --- a/grc/core/platform.py +++ b/grc/core/platform.py @@ -28,7 +28,7 @@ from six.moves import range from . import ( Messages, Constants, - blocks, ports, errors, utils, schema_checker + blocks, params, ports, errors, utils, schema_checker ) from .Config import Config @@ -38,7 +38,6 @@ from .io import yaml from .generator import Generator from .FlowGraph import FlowGraph from .Connection import Connection -from .Param import Param logger = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) @@ -395,7 +394,7 @@ class Platform(Element): 'clone': ports.PortClone, # clone of ports with multiplicity > 1 } param_classes = { - None: Param, # default + None: params.Param, # default } def make_flow_graph(self, from_filename=None): diff --git a/grc/gui/canvas/param.py b/grc/gui/canvas/param.py index e2c335d9cf..845ff5a926 100644 --- a/grc/gui/canvas/param.py +++ b/grc/gui/canvas/param.py @@ -18,10 +18,8 @@ from __future__ import absolute_import from .drawable import Drawable - from .. import ParamWidgets, Utils, Constants - -from ...core.Param import Param as CoreParam +from ...core.params import Param as CoreParam class Param(CoreParam): -- cgit v1.2.3 From 14d79b777e773e299a1ffa0dd12d2508a46370a0 Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <sebastian.koslowski@gmail.com> Date: Wed, 8 Nov 2017 21:28:35 +0100 Subject: grc: move some of the param checkers to separate file --- grc/core/Constants.py | 20 ++--- grc/core/params/dtypes.py | 103 +++++++++++++++++++++ grc/core/params/param.py | 154 ++++++++------------------------ grc/core/utils/descriptors/evaluated.py | 7 +- grc/gui/Utils.py | 4 +- grc/gui/canvas/param.py | 4 +- 6 files changed, 161 insertions(+), 131 deletions(-) create mode 100644 grc/core/params/dtypes.py (limited to 'grc') diff --git a/grc/core/Constants.py b/grc/core/Constants.py index 59c5dff35e..8ed8899c70 100644 --- a/grc/core/Constants.py +++ b/grc/core/Constants.py @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA from __future__ import absolute_import import os +import numbers import stat import numpy @@ -54,7 +55,7 @@ TOP_BLOCK_FILE_MODE = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP stat.S_IWGRP | stat.S_IXGRP | stat.S_IROTH HIER_BLOCK_FILE_MODE = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH -PARAM_TYPE_NAMES = ( +PARAM_TYPE_NAMES = { 'raw', 'enum', 'complex', 'real', 'float', 'int', 'complex_vector', 'real_vector', 'float_vector', 'int_vector', @@ -63,18 +64,17 @@ PARAM_TYPE_NAMES = ( 'id', 'stream_id', 'gui_hint', 'import', -) +} + +PARAM_TYPE_MAP = { + 'complex': numbers.Complex, + 'float': numbers.Real, + 'real': numbers.Real, + 'int': numbers.Integral, +} # Define types, native python + numpy VECTOR_TYPES = (tuple, list, set, numpy.ndarray) -COMPLEX_TYPES = [complex, numpy.complex, numpy.complex64, numpy.complex128] -REAL_TYPES = [float, numpy.float, numpy.float32, numpy.float64] -INT_TYPES = [int, numpy.int, numpy.int8, numpy.int16, numpy.int32, numpy.uint64, - numpy.uint, numpy.uint8, numpy.uint16, numpy.uint32, numpy.uint64] -# Cast to tuple for isinstance, concat subtypes -COMPLEX_TYPES = tuple(COMPLEX_TYPES + REAL_TYPES + INT_TYPES) -REAL_TYPES = tuple(REAL_TYPES + INT_TYPES) -INT_TYPES = tuple(INT_TYPES) # Updating colors. Using the standard color palette from: # http://www.google.com/design/spec/style/color.html#color-color-palette diff --git a/grc/core/params/dtypes.py b/grc/core/params/dtypes.py new file mode 100644 index 0000000000..cddfdefe45 --- /dev/null +++ b/grc/core/params/dtypes.py @@ -0,0 +1,103 @@ +# Copyright 2008-2017 Free Software Foundation, Inc. +# This file is part of GNU Radio +# +# GNU Radio Companion is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# GNU Radio Companion is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +from __future__ import absolute_import + +import re + +from six.moves import builtins + +from .. import blocks +from .. import Constants + + +# Blacklist certain ids, its not complete, but should help +ID_BLACKLIST = ['self', 'options', 'gr', 'math', 'firdes'] + dir(builtins) +try: + from gnuradio import gr + ID_BLACKLIST.extend(attr for attr in dir(gr.top_block()) if not attr.startswith('_')) +except (ImportError, AttributeError): + pass + + +validators = {} + + +def validates(*dtypes): + def decorator(func): + for dtype in dtypes: + assert dtype in Constants.PARAM_TYPE_NAMES + validators[dtype] = func + return func + return decorator + + +class ValidateError(Exception): + """Raised by validate functions""" + + +@validates('id') +def validate_block_id(param): + value = param.value + # Can python use this as a variable? + if not re.match(r'^[a-z|A-Z]\w*$', value): + raise ValidateError('ID "{}" must begin with a letter and may contain letters, numbers, ' + 'and underscores.'.format(value)) + if value in ID_BLACKLIST: + raise ValidateError('ID "{}" is blacklisted.'.format(value)) + block_names = [block.name for block in param.parent_flowgraph.iter_enabled_blocks()] + # Id should only appear once, or zero times if block is disabled + if param.key == 'id' and block_names.count(value) > 1: + raise ValidateError('ID "{}" is not unique.'.format(value)) + elif value not in block_names: + raise ValidateError('ID "{}" does not exist.'.format(value)) + return value + + +@validates('stream_id') +def validate_stream_id(param): + value = param.value + stream_ids = [ + block.params['stream_id'].value + for block in param.parent_flowgraph.iter_enabled_blocks() + if isinstance(block, blocks.VirtualSink) + ] + # Check that the virtual sink's stream id is unique + if isinstance(param.parent_block, blocks.VirtualSink) and stream_ids.count(value) >= 2: + # Id should only appear once, or zero times if block is disabled + raise ValidateError('Stream ID "{}" is not unique.'.format(value)) + # Check that the virtual source's steam id is found + elif isinstance(param.parent_block, blocks.VirtualSource) and value not in stream_ids: + raise ValidateError('Stream ID "{}" is not found.'.format(value)) + + +@validates('complex', 'real', 'float', 'int') +def validate_scalar(param): + valid_types = Constants.PARAM_TYPE_MAP[param.dtype] + if not isinstance(param.value, valid_types): + raise ValidateError('Expression {!r} is invalid for type {!r}.'.format( + param.value, param.dtype)) + + +@validates('complex_vector', 'real_vector', 'float_vector', 'int_vector') +def validate_vector(param): + # todo: check vector types + + valid_types = Constants.PARAM_TYPE_MAP[param.dtype.split('_', 1)[0]] + if not all(isinstance(item, valid_types) for item in param.value): + raise ValidateError('Expression {!r} is invalid for type {!r}.'.format( + param.value, param.dtype)) diff --git a/grc/core/params/param.py b/grc/core/params/param.py index 787be9a19f..30a48bb434 100644 --- a/grc/core/params/param.py +++ b/grc/core/params/param.py @@ -18,28 +18,19 @@ from __future__ import absolute_import import ast -import numbers -import re import collections import textwrap import six -from six.moves import builtins, range +from six.moves import range -from .. import Constants, blocks +from .. import Constants from ..base import Element from ..utils.descriptors import Evaluated, EvaluatedEnum, setup_names +from . import dtypes from .template_arg import TemplateArg -# Blacklist certain ids, its not complete, but should help -ID_BLACKLIST = ['self', 'options', 'gr', 'math', 'firdes'] + dir(builtins) -try: - from gnuradio import gr - ID_BLACKLIST.extend(attr for attr in dir(gr.top_block()) if not attr.startswith('_')) -except (ImportError, AttributeError): - pass - @setup_names class Param(Element): @@ -147,6 +138,10 @@ class Param(Element): except Exception as e: self.add_error_message(str(e)) + rewriter = getattr(dtypes, 'rewrite_' + self.dtype, None) + if rewriter: + rewriter(self) + def validate(self): """ Validate the param. @@ -156,6 +151,13 @@ class Param(Element): if self.dtype not in Constants.PARAM_TYPE_NAMES: self.add_error_message('Type "{}" is not a possible type.'.format(self.dtype)) + validator = dtypes.validators.get(self.dtype, None) + if self._init and validator: + try: + validator(self) + except dtypes.ValidateError as e: + self.add_error_message(e.message) + def get_evaluated(self): return self._evaluated @@ -173,68 +175,41 @@ class Param(Element): expr = self.get_value() ######################### - # Enum Type + # ID and Enum types (not evaled) ######################### - if self.is_enum(): + if dtype in ('id', 'stream_id') or self.is_enum(): return expr ######################### # Numeric Types ######################### elif dtype in ('raw', 'complex', 'real', 'float', 'int', 'hex', 'bool'): - # Raise exception if python cannot evaluate this value - try: - value = self.parent_flowgraph.evaluate(expr) - except Exception as value: - raise Exception('Value "{}" cannot be evaluated:\n{}'.format(expr, value)) - # Raise an exception if the data is invalid - if dtype == 'raw': - return value - elif dtype == 'complex': - if not isinstance(value, Constants.COMPLEX_TYPES): - raise Exception('Expression "{}" is invalid for type complex.'.format(str(value))) - return value - elif dtype in ('real', 'float'): - if not isinstance(value, Constants.REAL_TYPES): - raise Exception('Expression "{}" is invalid for type float.'.format(str(value))) - return value - elif dtype == 'int': - if not isinstance(value, Constants.INT_TYPES): - raise Exception('Expression "{}" is invalid for type integer.'.format(str(value))) - return value - elif dtype == 'hex': - return hex(value) - elif dtype == 'bool': - if not isinstance(value, bool): - raise Exception('Expression "{}" is invalid for type bool.'.format(str(value))) - return value + if expr: + try: + value = self.parent_flowgraph.evaluate(expr) + except Exception as e: + raise Exception('Value "{}" cannot be evaluated:\n{}'.format(expr, e)) else: - raise TypeError('Type "{}" not handled'.format(dtype)) + value = 0 + if dtype == 'hex': + value = hex(value) + elif dtype == 'bool': + value = bool(value) + return value + ######################### # Numeric Vector Types ######################### elif dtype in ('complex_vector', 'real_vector', 'float_vector', 'int_vector'): - default = [] - if not expr: - return default # Turn a blank string into an empty list, so it will eval - + return [] # Turn a blank string into an empty list, so it will eval try: value = self.parent.parent.evaluate(expr) except Exception as value: raise Exception('Value "{}" cannot be evaluated:\n{}'.format(expr, value)) - if not isinstance(value, Constants.VECTOR_TYPES): self._lisitify_flag = True value = [value] - - # Raise an exception if the data is invalid - if dtype == 'complex_vector' and not all(isinstance(item, numbers.Complex) for item in value): - raise Exception('Expression "{}" is invalid for type complex vector.'.format(value)) - elif dtype in ('real_vector', 'float_vector') and not all(isinstance(item, numbers.Real) for item in value): - raise Exception('Expression "{}" is invalid for type float vector.'.format(value)) - elif dtype == 'int_vector' and not all(isinstance(item, Constants.INT_TYPES) for item in value): - raise Exception('Expression "{}" is invalid for type integer vector.'.format(str(value))) return value ######################### # String Types @@ -242,7 +217,7 @@ class Param(Element): elif dtype in ('string', 'file_open', 'file_save', '_multiline', '_multiline_python_external'): # Do not check if file/directory exists, that is a runtime issue try: - value = self.parent.parent.evaluate(expr) + value = self.parent_flowgraph.evaluate(expr) if not isinstance(value, str): raise Exception() except: @@ -252,28 +227,10 @@ class Param(Element): ast.parse(value) # Raises SyntaxError return value ######################### - # Unique ID Type - ######################### - elif dtype == 'id': - self.validate_block_id() - return expr - - ######################### - # Stream ID Type - ######################### - elif dtype == 'stream_id': - self.validate_stream_id() - return expr - - ######################### # GUI Position/Hint ######################### elif dtype == 'gui_hint': - if self.parent_block.state == 'disabled': - return '' - else: - return self.parse_gui_hint(expr) - + return self.parse_gui_hint(expr) if self.parent_block.state == 'enabled' else '' ######################### # Import Type ######################### @@ -292,37 +249,6 @@ class Param(Element): else: raise TypeError('Type "{}" not handled'.format(dtype)) - def validate_block_id(self): - value = self.value - # Can python use this as a variable? - if not re.match(r'^[a-z|A-Z]\w*$', value): - raise Exception('ID "{}" must begin with a letter and may contain letters, numbers, ' - 'and underscores.'.format(value)) - if value in ID_BLACKLIST: - raise Exception('ID "{}" is blacklisted.'.format(value)) - block_names = [block.name for block in self.parent_flowgraph.iter_enabled_blocks()] - # Id should only appear once, or zero times if block is disabled - if self.key == 'id' and block_names.count(value) > 1: - raise Exception('ID "{}" is not unique.'.format(value)) - elif value not in block_names: - raise Exception('ID "{}" does not exist.'.format(value)) - return value - - def validate_stream_id(self): - value = self.value - stream_ids = [ - block.params['stream_id'].value - for block in self.parent_flowgraph.iter_enabled_blocks() - if isinstance(block, blocks.VirtualSink) - ] - # Check that the virtual sink's stream id is unique - if isinstance(self.parent_block, blocks.VirtualSink) and stream_ids.count(value) >= 2: - # Id should only appear once, or zero times if block is disabled - raise Exception('Stream ID "{}" is not unique.'.format(value)) - # Check that the virtual source's steam id is found - elif isinstance(self.parent_block, blocks.VirtualSource) and value not in stream_ids: - raise Exception('Stream ID "{}" is not found.'.format(value)) - def to_code(self): """ Convert the value to code. @@ -333,24 +259,20 @@ class Param(Element): a string representing the code """ self._init = True - v = self.get_value() - t = self.dtype + value = self.get_value() # String types - if t in ('string', 'file_open', 'file_save', '_multiline', '_multiline_python_external'): + if self.dtype in ('string', 'file_open', 'file_save', '_multiline', '_multiline_python_external'): if not self._init: self.evaluate() - return repr(v) if self._stringify_flag else v + return repr(value) if self._stringify_flag else value # Vector types - elif t in ('complex_vector', 'real_vector', 'float_vector', 'int_vector'): + elif self.dtype in ('complex_vector', 'real_vector', 'float_vector', 'int_vector'): if not self._init: self.evaluate() - if self._lisitify_flag: - return '(%s, )' % v - else: - return '(%s)' % v + return '[' + value + ']' if self._lisitify_flag else value else: - return v + return value def get_opt(self, item): return self.options.attributes[self.get_value()][item] @@ -470,7 +392,7 @@ class Param(Element): optionally a given key Args: - type: the specified type + dtype: the specified type key: the key to match against Returns: diff --git a/grc/core/utils/descriptors/evaluated.py b/grc/core/utils/descriptors/evaluated.py index e8bce6e6ed..0e1b68761c 100644 --- a/grc/core/utils/descriptors/evaluated.py +++ b/grc/core/utils/descriptors/evaluated.py @@ -79,9 +79,10 @@ class Evaluated(object): class EvaluatedEnum(Evaluated): def __init__(self, allowed_values, default=None, name=None): - self.allowed_values = allowed_values if isinstance(allowed_values, (list, tuple)) else \ - allowed_values.split() - default = default if default is not None else self.allowed_values[0] + if isinstance(allowed_values, six.string_types): + allowed_values = set(allowed_values.split()) + self.allowed_values = allowed_values + default = default if default is not None else next(iter(self.allowed_values)) super(EvaluatedEnum, self).__init__(str, default, name) def default_eval_func(self, instance): diff --git a/grc/gui/Utils.py b/grc/gui/Utils.py index f47c2e6b97..1b32e91439 100644 --- a/grc/gui/Utils.py +++ b/grc/gui/Utils.py @@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA from __future__ import absolute_import +import numbers + from gi.repository import GLib import cairo import six @@ -91,7 +93,7 @@ def num_to_str(num): return template.format(value / factor, symbol.strip()) return template.format(value, '') - if isinstance(num, Constants.COMPLEX_TYPES): + if isinstance(num, numbers.Complex): num = complex(num) # Cast to python complex if num == 0: return '0' diff --git a/grc/gui/canvas/param.py b/grc/gui/canvas/param.py index 845ff5a926..5777423c68 100644 --- a/grc/gui/canvas/param.py +++ b/grc/gui/canvas/param.py @@ -17,6 +17,8 @@ from __future__ import absolute_import +import numbers + from .drawable import Drawable from .. import ParamWidgets, Utils, Constants from ...core.params import Param as CoreParam @@ -126,7 +128,7 @@ class Param(CoreParam): t = self.dtype if isinstance(e, bool): return str(e) - elif isinstance(e, Constants.COMPLEX_TYPES): + elif isinstance(e, numbers.Complex): dt_str = Utils.num_to_str(e) elif isinstance(e, Constants.VECTOR_TYPES): # Vector types -- cgit v1.2.3 From b33bb4d18fabaf3f34f44288d5628475e6f4c69e Mon Sep 17 00:00:00 2001 From: Håkon Vågsether <haakonsv@gmail.com> Date: Mon, 30 Oct 2017 13:29:04 +0100 Subject: Added the Delete key to the delete action --- grc/gui/Actions.py | 1 + 1 file changed, 1 insertion(+) (limited to 'grc') diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py index d214f28049..14b0422764 100644 --- a/grc/gui/Actions.py +++ b/grc/gui/Actions.py @@ -302,6 +302,7 @@ ELEMENT_DELETE = actions.register("win.delete", label='_Delete', tooltip='Delete the selected blocks', icon_name='edit-delete', + keypresses=["Delete"], ) BLOCK_MOVE = actions.register("win.block_move") BLOCK_ROTATE_CCW = actions.register("win.block_rotate_ccw", -- cgit v1.2.3 From c7c77d2dfa934697268db204745341a72be924a0 Mon Sep 17 00:00:00 2001 From: Andrej Rode <mail@andrejro.de> Date: Sun, 3 Dec 2017 23:18:25 +0100 Subject: grc: fix json cache dumping to work with python 3.5 --- grc/core/cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'grc') diff --git a/grc/core/cache.py b/grc/core/cache.py index b72255ce1f..f438d58bd9 100644 --- a/grc/core/cache.py +++ b/grc/core/cache.py @@ -73,8 +73,8 @@ class Cache(object): return logger.info('Saving %d entries to json cache', len(self.cache)) - with open(self.cache_file, 'wb') as cache_file: - json.dump(self.cache, cache_file, encoding='utf-8') + with open(self.cache_file, 'w', encoding='utf8') as cache_file: + json.dump(self.cache, cache_file) def prune(self): for filename in (set(self.cache) - self._accessed_items): -- cgit v1.2.3 From 11e90f0fd4ba7151fee6be1886de57829bdbbab4 Mon Sep 17 00:00:00 2001 From: Andrej Rode <mail@andrejro.de> Date: Mon, 4 Dec 2017 00:47:20 +0100 Subject: grc: add default id: to top_block --- grc/core/default_flow_graph.grc | 1 + 1 file changed, 1 insertion(+) (limited to 'grc') diff --git a/grc/core/default_flow_graph.grc b/grc/core/default_flow_graph.grc index 9df289f327..d57ec75aea 100644 --- a/grc/core/default_flow_graph.grc +++ b/grc/core/default_flow_graph.grc @@ -5,6 +5,7 @@ options: parameters: + id: 'top_block' title: 'top_block' states: coordinate: -- cgit v1.2.3 From 6ca908b8be68a1ced5849f6fcbe06086ce7584ce Mon Sep 17 00:00:00 2001 From: Andrej Rode <mail@andrejro.de> Date: Mon, 4 Dec 2017 00:47:42 +0100 Subject: grc: check evaluated parameter for correctness --- grc/core/params/dtypes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'grc') diff --git a/grc/core/params/dtypes.py b/grc/core/params/dtypes.py index cddfdefe45..f52868c080 100644 --- a/grc/core/params/dtypes.py +++ b/grc/core/params/dtypes.py @@ -88,9 +88,9 @@ def validate_stream_id(param): @validates('complex', 'real', 'float', 'int') def validate_scalar(param): valid_types = Constants.PARAM_TYPE_MAP[param.dtype] - if not isinstance(param.value, valid_types): + if not isinstance(param.get_evaluated(), valid_types): raise ValidateError('Expression {!r} is invalid for type {!r}.'.format( - param.value, param.dtype)) + param.get_evaluated(), param.dtype)) @validates('complex_vector', 'real_vector', 'float_vector', 'int_vector') @@ -98,6 +98,6 @@ def validate_vector(param): # todo: check vector types valid_types = Constants.PARAM_TYPE_MAP[param.dtype.split('_', 1)[0]] - if not all(isinstance(item, valid_types) for item in param.value): + if not all(isinstance(item, valid_types) for item in param.get_evaluated()): raise ValidateError('Expression {!r} is invalid for type {!r}.'.format( - param.value, param.dtype)) + param.get_evaluated(), param.dtype)) -- cgit v1.2.3 From e82e337d0c74fa7ea5e8b8429de29bec43818552 Mon Sep 17 00:00:00 2001 From: Andrej Rode <mail@andrejro.de> Date: Mon, 4 Dec 2017 01:23:43 +0100 Subject: grc: only add enabled blocks to flow_graph children --- grc/core/FlowGraph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grc') diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py index 3f21ec6a9c..8c59ec0bea 100644 --- a/grc/core/FlowGraph.py +++ b/grc/core/FlowGraph.py @@ -172,7 +172,7 @@ class FlowGraph(Element): return elements def children(self): - return itertools.chain(self.blocks, self.connections) + return itertools.chain(self.iter_enabled_blocks(), self.connections) def rewrite(self): """ -- cgit v1.2.3