[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11327 - in gnuradio/branches/developers/jblum/grc/grc
From: |
jblum |
Subject: |
[Commit-gnuradio] r11327 - in gnuradio/branches/developers/jblum/grc/grc: blocks python |
Date: |
Thu, 2 Jul 2009 12:31:39 -0600 (MDT) |
Author: jblum
Date: 2009-07-02 12:31:38 -0600 (Thu, 02 Jul 2009)
New Revision: 11327
Modified:
gnuradio/branches/developers/jblum/grc/grc/blocks/notebook.xml
gnuradio/branches/developers/jblum/grc/grc/python/FlowGraph.py
gnuradio/branches/developers/jblum/grc/grc/python/Generator.py
gnuradio/branches/developers/jblum/grc/grc/python/expr_utils.py
Log:
Added a sort objects function to expr utils that can be used to sort variables,
and notebooks.
Notebooks are now sorted according to dependencies, and variables use this as
well.
Added a tab orientation/style param to the notebook.
Modified: gnuradio/branches/developers/jblum/grc/grc/blocks/notebook.xml
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/notebook.xml
2009-07-02 06:58:32 UTC (rev 11326)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/notebook.xml
2009-07-02 18:31:38 UTC (rev 11327)
@@ -9,7 +9,7 @@
<key>notebook</key>
<import>from grc_gnuradio import wxgui as grc_wxgui</import>
<make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook()
or 'self'
-self.$(id) = wx.Notebook($(parent).GetWin())
+self.$(id) = wx.Notebook($(parent).GetWin(), style=$style)
#for $label in $labels()
self.$(id).AddPage(grc_wxgui.Panel(self.$(id)), "$label")
#end for
@@ -19,6 +19,28 @@
$(parent).GridAdd(self.$(id), $(', '.join(map(str, $grid_pos()))))
#end if</make>
<param>
+ <name>Tab Orientation</name>
+ <key>style</key>
+ <value>wx.NB_TOP</value>
+ <type>enum</type>
+ <option>
+ <name>Top</name>
+ <key>wx.NB_TOP</key>
+ </option>
+ <option>
+ <name>Right</name>
+ <key>wx.NB_RIGHT</key>
+ </option>
+ <option>
+ <name>Bottom</name>
+ <key>wx.NB_BOTTOM</key>
+ </option>
+ <option>
+ <name>Left</name>
+ <key>wx.NB_LEFT</key>
+ </option>
+ </param>
+ <param>
<name>Labels</name>
<key>labels</key>
<value>['tab1', 'tab2', 'tab3']</value>
Modified: gnuradio/branches/developers/jblum/grc/grc/python/FlowGraph.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/FlowGraph.py
2009-07-02 06:58:32 UTC (rev 11326)
+++ gnuradio/branches/developers/jblum/grc/grc/python/FlowGraph.py
2009-07-02 18:31:38 UTC (rev 11327)
@@ -99,16 +99,7 @@
@return a sorted list of variable blocks in order of dependency
(indep -> dep)
"""
variables = filter(lambda b:
_variable_matcher.match(b.get_key()), self.get_enabled_blocks())
- #map var id to variable block
- id2var = dict([(var.get_id(), var) for var in variables])
- #map var id to variable code
- #variable code is a concatenation of all param code (without
the id param)
- id2expr = dict([(var.get_id(), var.get_var_make()) for var in
variables])
- #sort according to dependency
- sorted_ids = expr_utils.sort_variables(id2expr)
- #create list of sorted variable blocks
- variables = [id2var[id] for id in sorted_ids]
- return variables
+ return expr_utils.sort_objects(variables, lambda v: v.get_id(),
lambda v: v.get_var_make())
def get_parameters(self):
"""
Modified: gnuradio/branches/developers/jblum/grc/grc/python/Generator.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/Generator.py
2009-07-02 06:58:32 UTC (rev 11326)
+++ gnuradio/branches/developers/jblum/grc/grc/python/Generator.py
2009-07-02 18:31:38 UTC (rev 11327)
@@ -90,7 +90,12 @@
#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
- notebooks = filter(lambda b: b.get_key() == 'notebook', blocks)
+ #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(),
+ )
+ #list of regular blocks (all blocks minus the special ones)
blocks = filter(lambda b: b not in (imports + parameters +
variables + probes + notebooks), blocks) + probes
#list of connections where each endpoint is enabled
connections = self._flow_graph.get_enabled_connections()
Modified: gnuradio/branches/developers/jblum/grc/grc/python/expr_utils.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/expr_utils.py
2009-07-02 06:58:32 UTC (rev 11326)
+++ gnuradio/branches/developers/jblum/grc/grc/python/expr_utils.py
2009-07-02 18:31:38 UTC (rev 11327)
@@ -133,5 +133,21 @@
for var in indep_vars: var_graph.remove_node(var)
return reversed(sorted_vars)
+def sort_objects(objects, get_id, get_expr):
+ """
+ Sort a list of objects according to their expressions.
+ @param objects the list of objects to sort
+ @param get_id the function to extract an id from the object
+ @param get_expr the function to extract an expression from the object
+ @return a list of sorted objects
+ """
+ id2obj = dict([(get_id(obj), obj) for obj in objects])
+ #map obj id to expression code
+ id2expr = dict([(get_id(obj), get_expr(obj)) for obj in objects])
+ #sort according to dependency
+ sorted_ids = sort_variables(id2expr)
+ #return list of sorted objects
+ return [id2obj[id] for id in sorted_ids]
+
if __name__ == '__main__':
for i in sort_variables({'x':'1', 'y':'x+1', 'a':'x+y', 'b':'y+1',
'c':'a+b+x+y'}): print i
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11327 - in gnuradio/branches/developers/jblum/grc/grc: blocks python,
jblum <=