From 47f621a14c9a6e3696155dd5a223da40bcb7721c Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sun, 27 Feb 2011 23:18:11 -0800
Subject: grc: work on generator for gui flowgraphs to simplify generation
generator does not differentiate between notebooks and controls,
they are all block, but block are now sorted by variables present in the make
also adjusted categories listed in the wx and qt widget related blocks
---
grc/blocks/Makefile.am | 3 +-
grc/blocks/block_tree.xml | 17 ++----------
grc/blocks/notebook.xml | 69 ----------------------------------------------
grc/python/Generator.py | 28 ++++++++-----------
grc/python/Param.py | 2 +-
grc/python/flow_graph.tmpl | 30 +++-----------------
6 files changed, 20 insertions(+), 129 deletions(-)
delete mode 100644 grc/blocks/notebook.xml
(limited to 'grc')
diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am
index 40353a1fa..d9ec0896e 100644
--- a/grc/blocks/Makefile.am
+++ b/grc/blocks/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2008-2010 Free Software Foundation, Inc.
+# Copyright 2008-2011 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -197,7 +197,6 @@ dist_ourdata_DATA = \
import.xml \
low_pass_filter.xml \
note.xml \
- notebook.xml \
options.xml \
pad_sink.xml \
pad_source.xml \
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index 782d6ca9b..50c463f55 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -38,17 +38,6 @@
pad_sink
virtual_sink
-
- Graphical Sinks
- wxgui_numbersink2
- wxgui_scopesink2
- wxgui_fftsink2
- wxgui_constellationsink2
- wxgui_waterfallsink2
- wxgui_histosink2
- wxgui_termsink
- qtgui_sink_x
-
Operators
gr_add_xx
@@ -139,7 +128,7 @@
gr_pll_freqdet_cf
gr_pll_refout_cc
- gr_fll_band_edge_cc
+ gr_fll_band_edge_cc
gr_correlate_access_code_bb
gr_pn_correlator_cc
@@ -263,7 +252,7 @@
gr_additive_scrambler_bb
- Vocoders
+ Vocoders
blks2_cvsd_encode
blks2_cvsd_decode
@@ -311,7 +300,5 @@
xmlrpc_server
xmlrpc_client
-
- notebook
diff --git a/grc/blocks/notebook.xml b/grc/blocks/notebook.xml
deleted file mode 100644
index d41db9e2d..000000000
--- a/grc/blocks/notebook.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
- Notebook
- notebook
- from grc_gnuradio import wxgui as grc_wxgui
- #set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-self.$(id) = wx.Notebook($(parent).GetWin(), style=$style)
-#for $label in $labels()
-self.$(id).AddPage(grc_wxgui.Panel(self.$(id)), "$label")
-#end for
-#if not $grid_pos()
-$(parent).Add(self.$(id))
-#else
-$(parent).GridAdd(self.$(id), $(', '.join(map(str, $grid_pos()))))
-#end if
-
- Tab Orientation
- style
- wx.NB_TOP
- enum
-
-
-
-
-
-
- Labels
- labels
- ['tab1', 'tab2', 'tab3']
- raw
-
-
- Grid Position
- grid_pos
-
- grid_pos
-
-
- Notebook
- notebook
-
- notebook
-
- isinstance($labels, (list, tuple))
- all(map(lambda x: isinstance(x, str), $labels))
- len($labels) > 0
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
-
-
diff --git a/grc/python/Generator.py b/grc/python/Generator.py
index 7d08b914b..b669fa65a 100644
--- a/grc/python/Generator.py
+++ b/grc/python/Generator.py
@@ -1,5 +1,5 @@
"""
-Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+Copyright 2008-2011 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
@@ -90,22 +90,20 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''')
imports = self._flow_graph.get_imports()
variables = self._flow_graph.get_variables()
parameters = self._flow_graph.get_parameters()
- #list of variables with controls
- controls = filter(lambda v: v.get_make(), variables)
#list of blocks not including variables and imports and parameters and disabled
- blocks = sorted(self._flow_graph.get_enabled_blocks(), lambda x, y: cmp(x.get_id(), y.get_id()))
- probes = filter(lambda b: b.get_key().startswith('probe_'), blocks) #ensure probes are last in the block list
- #get a list of notebooks and sort them according dependencies
- notebooks = expr_utils.sort_objects(
- filter(lambda b: b.get_key() == 'notebook', blocks),
- lambda n: n.get_id(), lambda n: n.get_param('notebook').get_value(),
- )
- notebooks += expr_utils.sort_objects(
- filter(lambda b: b.get_key() == 'qtgui_tab_widget', blocks),
- lambda n: n.get_id(), lambda n: n.get_param('gui_hint').get_value(),
+ def _get_block_sort_text(block):
+ code = block.get_make().replace(block.get_id(), ' ')
+ try: code += block.get_param('notebook').get_value() #older gui markup w/ wxgui
+ except: pass
+ try: code += block.get_param('gui_hint').get_value() #newer gui markup w/ qtgui
+ except: pass
+ return code
+ blocks = expr_utils.sort_objects(
+ self._flow_graph.get_enabled_blocks(),
+ lambda b: b.get_id(), _get_block_sort_text
)
#list of regular blocks (all blocks minus the special ones)
- blocks = filter(lambda b: b not in (imports + parameters + variables + probes + notebooks), blocks) + probes
+ blocks = filter(lambda b: b not in (imports + parameters), blocks)
#list of connections where each endpoint is enabled
connections = filter(lambda c: not c.is_msg(), self._flow_graph.get_enabled_connections())
messages = filter(lambda c: c.is_msg(), self._flow_graph.get_enabled_connections())
@@ -129,8 +127,6 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''')
'imports': imports,
'flow_graph': self._flow_graph,
'variables': variables,
- 'notebooks': notebooks,
- 'controls': controls,
'parameters': parameters,
'blocks': blocks,
'connections': connections,
diff --git a/grc/python/Param.py b/grc/python/Param.py
index 27258faab..303ab3ed8 100644
--- a/grc/python/Param.py
+++ b/grc/python/Param.py
@@ -1,5 +1,5 @@
"""
-Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+Copyright 2008-2011 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index 88049a9ef..8757b5204 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -5,8 +5,6 @@
##@param imports the import statements
##@param flow_graph the flow_graph
##@param variables the variable blocks
-##@param notebooks a list of notebook blocks
-##@param controls the variables with gui controls
##@param parameters the paramater blocks
##@param blocks the signal blocks
##@param connections the connections
@@ -121,30 +119,6 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
$indent($var.get_var_make())
#end for
########################################################
-##Create Notebooks
-########################################################
-#if $notebooks
-
- $DIVIDER
- # Notebooks
- $DIVIDER
-#end if
-#for $notebook in $notebooks
- $indent($notebook.get_make())
-#end for
-########################################################
-##Create Controls
-########################################################
-#if $controls
-
- $DIVIDER
- # Controls
- $DIVIDER
-#end if
-#for $ctrl in $controls
- $indent($ctrl.get_make())
-#end for
-########################################################
##Create Message Queues
########################################################
#if $messages
@@ -166,7 +140,11 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
$DIVIDER
#end if
#for $blk in filter(lambda b: b.get_make(), $blocks)
+ #if $blk in $variables
+ $indent($blk.get_make())
+ #else
self.$blk.get_id() = $indent($blk.get_make())
+ #end if
#end for
########################################################
##Create Connections
--
cgit