From: jblum Date: Tue, 9 Sep 2008 05:46:45 +0000 (+0000) Subject: show/hide param logic, usrp loopback example - neg freq X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=a6aa6eb21209cf3004381c0c9f98b303929dac7a;p=debian%2Fgnuradio show/hide param logic, usrp loopback example - neg freq git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9541 221aa14e-8319-0410-a670-987f0aec2ac5 --- diff --git a/grc/data/platforms/python/blocks/blks2_error_rate.xml b/grc/data/platforms/python/blocks/blks2_error_rate.xml index 79703f6e..852e7db0 100644 --- a/grc/data/platforms/python/blocks/blks2_error_rate.xml +++ b/grc/data/platforms/python/blocks/blks2_error_rate.xml @@ -21,10 +21,12 @@ @@ -38,6 +40,7 @@ bits_per_symbol 2 int + $type.hide_bps ref diff --git a/grc/data/platforms/python/blocks/options.xml b/grc/data/platforms/python/blocks/options.xml index 8e8f0689..3a73050a 100644 --- a/grc/data/platforms/python/blocks/options.xml +++ b/grc/data/platforms/python/blocks/options.xml @@ -39,6 +39,7 @@ import wx window_size 1280, 1024 int_vector + part Generate Options diff --git a/grc/data/platforms/python/blocks/preferences.xml b/grc/data/platforms/python/blocks/preferences.xml index 51138c12..e426b5a3 100644 --- a/grc/data/platforms/python/blocks/preferences.xml +++ b/grc/data/platforms/python/blocks/preferences.xml @@ -114,20 +114,6 @@ hide - - Show ID Label - show_id - show - enum - - - Restore Open Files diff --git a/grc/examples/usrp/usrp_two_tone_loopback.grc b/grc/examples/usrp/usrp_two_tone_loopback.grc index ccbe190e..30f5409b 100644 --- a/grc/examples/usrp/usrp_two_tone_loopback.grc +++ b/grc/examples/usrp/usrp_two_tone_loopback.grc @@ -1,6 +1,6 @@ - Thu Jul 24 14:27:46 2008 + Mon Sep 8 21:47:19 2008 options @@ -312,46 +312,22 @@ - variable_slider + variable id - tone_ampl + samp_rate _enabled True - - label - Tone Ampl - value - 5000 - - - min - 0 - - - max - 5000 - - - num_steps - 100 - - - slider_type - vertical - - - grid_pos - 1, 0, 2, 1 + 64e6/200 _coordinate - (21, 422) + (9, 166) _rotation @@ -359,104 +335,22 @@ - usrp_simple_sink_x + variable id - usrp_simple_sink_x - - - _enabled - True - - - type - complex - - - number - 0 - - - subdev_spec - None - - - frequency tun_freq - - interpolation - 400 - - - gain - 0 - - - mux - 0x0 - - - auto_tr - None - - - tx_enb - None - - - _coordinate - (835, 5) - - - _rotation - 0 - - - - gr_float_to_complex - - id - gr_float_to_complex - - - _enabled - True - - - _coordinate - (634, 226) - - - _rotation - 0 - - - - gr_add_vxx - - id - gr_add_vxx - _enabled True - type - float - - - num_inputs - 3 - - - vlen - 1 + value + int(100e6) _coordinate - (528, 78) + (116, 166) _rotation @@ -475,7 +369,7 @@ type - float + complex samp_rate @@ -518,7 +412,7 @@ type - float + complex samp_rate @@ -561,7 +455,7 @@ type - float + complex noise_type @@ -585,22 +479,30 @@ - variable + gr_add_vxx id - samp_rate + gr_add_vxx _enabled True - value - 64e6/200 + type + complex + + + num_inputs + 3 + + + vlen + 1 _coordinate - (9, 166) + (528, 78) _rotation @@ -608,22 +510,101 @@ - variable + usrp_simple_sink_x id + usrp_simple_sink_x + + + _enabled + True + + + type + complex + + + number + 0 + + + subdev_spec + None + + + frequency tun_freq + + interpolation + 400 + + + gain + 0 + + + mux + 0x0 + + + auto_tr + None + + + tx_enb + None + + + _coordinate + (835, 5) + + + _rotation + 0 + + + + variable_slider + + id + tone_ampl + _enabled True + + label + Tone Ampl + value - int(100e6) + 5000 + + + min + -samp_rate/2 + + + max + samp_rate/2 + + + num_steps + 100 + + + slider_type + vertical + + + grid_pos + 1, 0, 2, 1 _coordinate - (116, 166) + (21, 422) _rotation @@ -654,22 +635,10 @@ 0 0 - - gr_float_to_complex - usrp_simple_sink_x - 0 - 0 - gr_add_vxx - gr_float_to_complex + usrp_simple_sink_x 0 0 - - gr_add_vxx - gr_float_to_complex - 0 - 1 - \ No newline at end of file diff --git a/grc/src/gui/Preferences.py b/grc/src/gui/Preferences.py index a5591500..fc06d924 100644 --- a/grc/src/gui/Preferences.py +++ b/grc/src/gui/Preferences.py @@ -55,7 +55,6 @@ class _Preferences(object): self.file_open_param = self._prefs_block.get_param('file_open') self.files_open_param = self._prefs_block.get_param('files_open') self.show_params_param = self._prefs_block.get_param('show_params') - self.show_id_param = self._prefs_block.get_param('show_id') def save(self): try: ParseXML.to_file({'block': self._prefs_block.export_data()}, self._prefs_file_path) @@ -77,9 +76,8 @@ Snap to Grid forces the upper right corner of the signal block to align with a g ''' Show or hide the reports window at the bottom of the main window. Show or hide all paramater labels in the signal blocks. -Show or hide the ID label in the signal blocks. ''', - [self.show_reports_param, self.show_params_param, self.show_id_param], + [self.show_reports_param, self.show_params_param], ), ( 'Misc', @@ -125,6 +123,3 @@ def show_grid(): def show_params(): return _get_prefs().show_params_param.get_value() == 'show' - -def show_id(): - return _get_prefs().show_id_param.get_value() == 'show' diff --git a/grc/src/platforms/base/Param.py b/grc/src/platforms/base/Param.py index 3a8d98c3..232f6758 100644 --- a/grc/src/platforms/base/Param.py +++ b/grc/src/platforms/base/Param.py @@ -188,8 +188,6 @@ class Param(Element): def is_enum(self): return self._type == 'enum' - def is_type_dependent(self): return '$' in self._type - ############################################## # Access Options ############################################## diff --git a/grc/src/platforms/gui/Block.py b/grc/src/platforms/gui/Block.py index d38e1713..7589540b 100644 --- a/grc/src/platforms/gui/Block.py +++ b/grc/src/platforms/gui/Block.py @@ -134,10 +134,9 @@ class Block(Element): desc = pango.FontDescription(BLOCK_FONT) layout.set_font_description(desc) self.label_width, self.label_height = layout.get_pixel_size() - #display the params (except for the special params id and position) + #display the params if Preferences.show_params(): for param in filter(lambda p: p.get_hide() not in ('all', 'part'), self.get_params()): - if not Preferences.show_id() and param.get_key() == 'id': continue layout = param.get_layout() layouts.append(layout) w,h = layout.get_pixel_size() diff --git a/grc/src/platforms/gui/FlowGraph.py b/grc/src/platforms/gui/FlowGraph.py index 1e654e1b..60bb5752 100644 --- a/grc/src/platforms/gui/FlowGraph.py +++ b/grc/src/platforms/gui/FlowGraph.py @@ -187,21 +187,22 @@ class FlowGraph(Element): """ changed = False for selected_block in self.get_selected_blocks(): - for child in selected_block.get_params() + selected_block.get_ports(): - #find a param that controls a type - type_param = None - for param in selected_block.get_params(): - if not type_param and param.is_enum(): type_param = param - if param.is_enum() and param.get_key() in child._type: type_param = param - if type_param: - #try to increment the enum by direction - try: - keys = type_param.get_option_keys() - old_index = keys.index(type_param.get_value()) - new_index = (old_index + direction + len(keys))%len(keys) - type_param.set_value(keys[new_index]) - changed = True - except: pass + type_param = None + for param in filter(lambda p: p.is_enum(), selected_block.get_params()): + children = param.get_parent().get_ports() + param.get_parent().get_params() + #priority to the type controller + if param.get_key() in ' '.join(map(lambda p: p._type, children)): type_param = param + #use param if type param is unset + if not type_param: type_param = param + if type_param: + #try to increment the enum by direction + try: + keys = type_param.get_option_keys() + old_index = keys.index(type_param.get_value()) + new_index = (old_index + direction + len(keys))%len(keys) + type_param.set_value(keys[new_index]) + changed = True + except: pass return changed def port_controller_modify_selected(self, direction): @@ -212,7 +213,7 @@ class FlowGraph(Element): """ changed = False for selected_block in self.get_selected_blocks(): - for ports in (selected_block.get_sources(), selected_block.get_sinks()): + for ports in selected_block.get_ports(): if ports and hasattr(ports[0], 'get_nports') and ports[0].get_nports(): #find the param that controls port0 for param in selected_block.get_params(): diff --git a/grc/src/platforms/python/Param.py b/grc/src/platforms/python/Param.py index ed5c6406..39ec57e3 100644 --- a/grc/src/platforms/python/Param.py +++ b/grc/src/platforms/python/Param.py @@ -39,19 +39,21 @@ class Param(_Param): def get_hide(self): """ Get the hide value from the base class. - If hide was empty, and this is a type controller, set hide to part. - If hide was empty, and this is an id of a non variable, set hide to part. + Hide the ID parameter for most blocks. Exceptions below. + If the parameter controls a port type, vlen, or nports, return part. + These parameters are redundant to display in the flow graph view. @return hide the hide property string """ hide = _Param.get_hide(self) - #hide IO controlling params - if not hide and self.get_key() in ( - 'type', 'vlen', 'num_inputs', 'num_outputs' - ): hide = 'part' + if hide: return hide #hide ID in non variable blocks - elif not hide and self.get_key() == 'id' and self.get_parent().get_key() not in ( + if self.get_key() == 'id' and self.get_parent().get_key() not in ( 'variable', 'variable_slider', 'variable_chooser', 'variable_text_box', 'parameter', 'options' - ): hide = 'part' + ): return 'part' + #hide port controllers + if self.get_key() in ' '.join(map( + lambda p: ' '.join([p._type, p._vlen, p._nports]), self.get_parent().get_ports()) + ): return 'part' return hide def evaluate(self):