commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11322 - in gnuradio/branches/developers/jblum/grc: gr


From: jblum
Subject: [Commit-gnuradio] r11322 - in gnuradio/branches/developers/jblum/grc: gr-wxgui/src/python/plotter grc grc/blocks grc/grc_gnuradio grc/grc_gnuradio/wxgui grc/python
Date: Wed, 1 Jul 2009 09:19:26 -0600 (MDT)

Author: jblum
Date: 2009-07-01 09:19:25 -0600 (Wed, 01 Jul 2009)
New Revision: 11322

Added:
   gnuradio/branches/developers/jblum/grc/grc/blocks/notebook.xml
   gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/panel.py
Modified:
   
gnuradio/branches/developers/jblum/grc/gr-wxgui/src/python/plotter/plotter_base.py
   gnuradio/branches/developers/jblum/grc/grc/blocks/Makefile.am
   gnuradio/branches/developers/jblum/grc/grc/blocks/block_tree.xml
   gnuradio/branches/developers/jblum/grc/grc/blocks/wxgui_fftsink2.xml
   gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/Makefile.am
   gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/__init__.py
   
gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/top_block_gui.py
   gnuradio/branches/developers/jblum/grc/grc/python/Generator.py
   gnuradio/branches/developers/jblum/grc/grc/python/Param.py
   gnuradio/branches/developers/jblum/grc/grc/python/flow_graph.tmpl
   gnuradio/branches/developers/jblum/grc/grc/todo.txt
Log:
Initial work on adding wx notebooks to grc.

Created a generic panel class with add and grid add.
This panel is used in the main top block gui and in notebook tabs.

Notebook page param only added to the fftsink for now.
Notebook page params not checked.
Notebook page dependencied not handled.

Made a fix in gl plotter so update will not actually draw until window is 
exposed.



Modified: 
gnuradio/branches/developers/jblum/grc/gr-wxgui/src/python/plotter/plotter_base.py
===================================================================
--- 
gnuradio/branches/developers/jblum/grc/gr-wxgui/src/python/plotter/plotter_base.py
  2009-07-01 02:47:47 UTC (rev 11321)
+++ 
gnuradio/branches/developers/jblum/grc/gr-wxgui/src/python/plotter/plotter_base.py
  2009-07-01 15:19:25 UTC (rev 11322)
@@ -168,4 +168,5 @@
                """
                Force a paint event.
                """
+               if not self._gl_init_flag: return
                wx.PostEvent(self, wx.PaintEvent())

Modified: gnuradio/branches/developers/jblum/grc/grc/blocks/Makefile.am
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/Makefile.am       
2009-07-01 02:47:47 UTC (rev 11321)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/Makefile.am       
2009-07-01 15:19:25 UTC (rev 11322)
@@ -185,6 +185,7 @@
        import.xml \
        low_pass_filter.xml \
        note.xml \
+       notebook.xml \
        options.xml \
        pad_sink.xml \
        pad_source.xml \

Modified: gnuradio/branches/developers/jblum/grc/grc/blocks/block_tree.xml
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/block_tree.xml    
2009-07-01 02:47:47 UTC (rev 11321)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/block_tree.xml    
2009-07-01 15:19:25 UTC (rev 11322)
@@ -293,5 +293,7 @@
 
                <block>xmlrpc_server</block>
                <block>xmlrpc_client</block>
+
+               <block>notebook</block>
        </cat>
 </cat>

Added: gnuradio/branches/developers/jblum/grc/grc/blocks/notebook.xml
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/notebook.xml              
                (rev 0)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/notebook.xml      
2009-07-01 15:19:25 UTC (rev 11322)
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##WX GUI Notebook
+###################################################
+ -->
+<block>
+       <name>Notebook</name>
+       <key>notebook</key>
+       <import>from grc_gnuradio import wxgui as grc_wxgui</import>
+       <make>self.$(id) = wx.Notebook(self.GetWin())
+#for $label in $labels()
+self.$(id).AddPage(grc_wxgui.Panel(self.$(id)), "$label")
+#end for
+#set $grid_pos = $grid_pos()
+#if not grid_pos
+self.Add(self.$(id))
+#else
+self.GridAdd(self.$(id), $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
+#end if</make>
+       <param>
+               <name>Labels</name>
+               <key>labels</key>
+               <value>['tab1', 'tab2', 'tab3']</value>
+               <type>raw</type>
+       </param>
+       <param>
+               <name>Grid Position</name>
+               <key>grid_pos</key>
+               <value></value>
+               <type>grid_pos</type>
+       </param>
+       <check>isinstance($labels, (list, tuple))</check>
+       <check>all(map(lambda x: isinstance(x, str), $labels))</check>
+       <check>len($labels) &gt; 0</check>
+       <doc>
+Use the Grid Position (row, column, row span, column span) to position the 
graphical element in the window.
+       </doc>
+</block>

Modified: gnuradio/branches/developers/jblum/grc/grc/blocks/wxgui_fftsink2.xml
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/wxgui_fftsink2.xml        
2009-07-01 02:47:47 UTC (rev 11321)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/wxgui_fftsink2.xml        
2009-07-01 15:19:25 UTC (rev 11322)
@@ -8,8 +8,9 @@
        <name>FFT Sink</name>
        <key>wxgui_fftsink2</key>
        <import>from gnuradio.wxgui import fftsink2</import>
-       <make>fftsink2.$(type.fcn)(
-       self.GetWin(),
+       <make>#set $parent = $notebook_page() and 
'self.%s.GetPage(%s)'%($notebook_page()) or 'self'
+fftsink2.$(type.fcn)(
+       $(parent).GetWin(),
        baseband_freq=$baseband_freq,
        y_per_div=$y_per_div,
        y_divs=$y_divs,
@@ -24,9 +25,9 @@
 )
 #set $grid_pos = $grid_pos()
 #if not grid_pos
-self.Add(self.$(id).win)
+$(parent).Add(self.$(id).win)
 #else
-self.GridAdd(self.$(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
+$(parent).GridAdd(self.$(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
 #end if</make>
        <callback>set_baseband_freq($baseband_freq)</callback>
        <callback>set_sample_rate($samp_rate)</callback>
@@ -157,6 +158,12 @@
                <value></value>
                <type>grid_pos</type>
        </param>
+       <param>
+               <name>Notebook Page</name>
+               <key>notebook_page</key>
+               <value></value>
+               <type>notebook_page</type>
+       </param>
        <sink>
                <name>in</name>
                <type>$type</type>
@@ -165,5 +172,7 @@
 Set Average Alpha to 0 for automatic setting.
 
 Use the Grid Position (row, column, row span, column span) to position the 
graphical element in the window.
+
+Use the Notebook Page (notebook-id, page-index) to place the graphical element 
inside of a notebook page.
        </doc>
 </block>

Modified: gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/Makefile.am
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/Makefile.am 
2009-07-01 02:47:47 UTC (rev 11321)
+++ gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/Makefile.am 
2009-07-01 15:19:25 UTC (rev 11322)
@@ -23,11 +23,11 @@
 
 grc_gnuradio_prefix = $(pythondir)/grc_gnuradio
 
-rootpythondir = $(grc_gnuradio_prefix)
-rootpython_PYTHON = __init__.py
+root_pythondir = $(grc_gnuradio_prefix)
+root_python_PYTHON = __init__.py
 
-blks2pythondir = $(grc_gnuradio_prefix)/blks2
-blks2python_PYTHON = \
+blks2_pythondir = $(grc_gnuradio_prefix)/blks2
+blks2_python_PYTHON = \
        blks2/__init__.py \
        blks2/error_rate.py \
        blks2/packet.py \
@@ -36,14 +36,15 @@
        blks2/tcp.py \
        blks2/variable_sink.py
 
-usrppythondir = $(grc_gnuradio_prefix)/usrp
-usrppython_PYTHON = \
+usrp_pythondir = $(grc_gnuradio_prefix)/usrp
+usrp_python_PYTHON = \
        usrp/__init__.py \
        usrp/common.py \
        usrp/dual_usrp.py \
        usrp/simple_usrp.py
 
-wxguipythondir = $(grc_gnuradio_prefix)/wxgui
-wxguipython_PYTHON = \
+wxgui_pythondir = $(grc_gnuradio_prefix)/wxgui
+wxgui_python_PYTHON = \
        wxgui/__init__.py \
+       wxgui/panel.py \
        wxgui/top_block_gui.py

Modified: 
gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/__init__.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/__init__.py   
2009-07-01 02:47:47 UTC (rev 11321)
+++ gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/__init__.py   
2009-07-01 15:19:25 UTC (rev 11322)
@@ -1,4 +1,4 @@
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008, 2009 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
 #
@@ -19,3 +19,4 @@
 #
 
 from top_block_gui import top_block_gui
+from panel import Panel

Added: gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/panel.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/panel.py      
                        (rev 0)
+++ gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/panel.py      
2009-07-01 15:19:25 UTC (rev 11322)
@@ -0,0 +1,49 @@
+# Copyright 2009 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.
+#
+
+import wx
+
+class Panel(wx.Panel):
+       def __init__(self, parent, orient=wx.VERTICAL):
+               wx.Panel.__init__(self, parent)
+               self._vbox = wx.BoxSizer(orient)
+               self._grid = wx.GridBagSizer(5, 5)
+               self.Add(self._grid)
+               self.SetSizer(self._vbox)
+
+       def GetWin(self): return self
+
+       def Add(self, win):
+               """
+               Add a window to the wx vbox.
+               @param win the wx window
+               """
+               self._vbox.Add(win, 0, wx.EXPAND)
+
+       def GridAdd(self, win, row, col, row_span=1, col_span=1):
+               """
+               Add a window to the wx grid at the given position.
+               @param win the wx window
+               @param row the row specification (integer >= 0)
+               @param col the column specification (integer >= 0)
+               @param row_span the row span specification (integer >= 1)
+               @param col_span the column span specification (integer >= 1)
+               """
+               self._grid.Add(win, wx.GBPosition(row, col), 
wx.GBSpan(row_span, col_span), wx.EXPAND)

Modified: 
gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/top_block_gui.py
===================================================================
--- 
gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/top_block_gui.py  
    2009-07-01 02:47:47 UTC (rev 11321)
+++ 
gnuradio/branches/developers/jblum/grc/grc/grc_gnuradio/wxgui/top_block_gui.py  
    2009-07-01 15:19:25 UTC (rev 11322)
@@ -1,4 +1,4 @@
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008, 2009 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
 #
@@ -21,13 +21,14 @@
 import wx
 import sys, os
 from gnuradio import gr
+import panel
 
 default_gui_size = (200, 100)
 
 class top_block_gui(gr.top_block):
        """gr top block with wx gui app and grid sizer."""
 
-       def __init__(self, title='', size=default_gui_size, icon=None):
+       def __init__(self, title='', size=default_gui_size):
                """
                Initialize the gr top block.
                Create the wx gui elements.
@@ -38,40 +39,16 @@
                #initialize
                gr.top_block.__init__(self)
                self._size = size
-               #set the icon
-               if icon and os.path.isfile(icon): self._icon = icon
-               else: self._icon = None
                #create gui elements
-               self._wx_app = wx.App()
-               self._wx_frame = wx.Frame(None , -1, title)
-               self._wx_grid = wx.GridBagSizer(5, 5)
-               self._wx_vbox = wx.BoxSizer(wx.VERTICAL)
+               self._app = wx.App()
+               self._frame = wx.Frame(None, title=title)
+               self._panel = panel.Panel(self._frame)
+               self.Add = self._panel.Add
+               self.GridAdd = self._panel.GridAdd
+               self.GetWin = self._panel.GetWin
 
-       def GetWin(self):
-               """
-               Get the window for wx elements to fit within.
-               @return the wx frame
-               """
-               return self._wx_frame
+       def SetIcon(self, *args, **kwargs): self._frame.SetIcon(*args, **kwargs)
 
-       def Add(self, win):
-               """
-               Add a window to the wx vbox.
-               @param win the wx window
-               """
-               self._wx_vbox.Add(win, 0, wx.EXPAND)
-
-       def GridAdd(self, win, row, col, row_span=1, col_span=1):
-               """
-               Add a window to the wx grid at the given position.
-               @param win the wx window
-               @param row the row specification (integer >= 0)
-               @param col the column specification (integer >= 0)
-               @param row_span the row span specification (integer >= 1)
-               @param col_span the column span specification (integer >= 1)
-               """
-               self._wx_grid.Add(win, wx.GBPosition(row, col), 
wx.GBSpan(row_span, col_span), wx.EXPAND)
-
        def start(self, start=True):
                if start:
                        gr.top_block.start(self)
@@ -85,21 +62,21 @@
                Start the gr top block.
                Block with the wx main loop.
                """
-               #set wx app icon
-               if self._icon: self._wx_frame.SetIcon(wx.Icon(self._icon, 
wx.BITMAP_TYPE_ANY))
                #set minimal window size
-               self._wx_frame.SetSizeHints(*self._size)
+               self._frame.SetSizeHints(*self._size)
                #create callback for quit
                def _quit(event):
-                       gr.top_block.stop(self)
-                       self._wx_frame.Destroy()
+                       self.start(False)
+                       self._frame.Destroy()
                #setup app
-               self._wx_vbox.Add(self._wx_grid, 0, wx.EXPAND)
-               self._wx_frame.Bind(wx.EVT_CLOSE, _quit)
-               self._wx_frame.SetSizerAndFit(self._wx_vbox)
-               self._wx_frame.Show()
-               self._wx_app.SetTopWindow(self._wx_frame)
+               self._frame.Bind(wx.EVT_CLOSE, _quit)
+               self._sizer = wx.BoxSizer(wx.VERTICAL)
+               self._sizer.Add(self._panel, 0, wx.EXPAND)
+               self._frame.SetSizerAndFit(self._sizer)
+               self._frame.SetAutoLayout(True)
+               self._frame.Show(True)
+               self._app.SetTopWindow(self._frame)
                #start flow graph
                self.start(autostart)
                #blocking main loop
-               self._wx_app.MainLoop()
+               self._app.MainLoop()

Modified: gnuradio/branches/developers/jblum/grc/grc/python/Generator.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/Generator.py      
2009-07-01 02:47:47 UTC (rev 11321)
+++ gnuradio/branches/developers/jblum/grc/grc/python/Generator.py      
2009-07-01 15:19:25 UTC (rev 11322)
@@ -90,7 +90,8 @@
                #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
-               blocks = filter(lambda b: b not in (imports + parameters + 
variables + probes), blocks) + probes
+               notebooks = filter(lambda b: b.get_key() == 'notebook', blocks)
+               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()
                #list of variable names
@@ -113,6 +114,7 @@
                        'imports': imports,
                        'flow_graph': self._flow_graph,
                        'variables': variables,
+                       'notebooks': notebooks,
                        'controls': controls,
                        'parameters': parameters,
                        'blocks': blocks,

Modified: gnuradio/branches/developers/jblum/grc/grc/python/Param.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/Param.py  2009-07-01 
02:47:47 UTC (rev 11321)
+++ gnuradio/branches/developers/jblum/grc/grc/python/Param.py  2009-07-01 
15:19:25 UTC (rev 11322)
@@ -30,7 +30,7 @@
 from gnuradio import gr
 
 _check_id_matcher = re.compile('^[a-z|A-Z]\w*$')
-_show_id_matcher = re.compile('^(variable\w*|parameter|options)$')
+_show_id_matcher = re.compile('^(variable\w*|parameter|options|notebook)$')
 
 class FileParam(EntryParam):
        """Provide an entry box for filename and a button to browse for a 
file."""
@@ -95,7 +95,8 @@
                'hex', 'string', 'bool',
                'file_open', 'file_save',
                'id',
-               'grid_pos', 'import',
+               'grid_pos', 'notebook_page',
+               'import',
        ]
 
        def __repr__(self):
@@ -201,7 +202,7 @@
                                return 'part'
                        except: pass
                #hide empty grid positions
-               if self.get_key() == 'grid_pos' and not self.get_value(): 
return 'part'
+               if self.get_key() in ('grid_pos', 'notebook_page') and not 
self.get_value(): return 'part'
                return hide
 
        def validate(self):
@@ -342,6 +343,21 @@
                                        if cell in self._hostage_cells: raise 
Exception, 'Another graphical element is using cell "%s".'%str(cell)
                        return e
                #########################
+               # Notebook Page Type
+               #########################
+               elif t == 'notebook_page':
+                       if not v: return '' #allow for empty notebook
+                       try: notebook_id, page_index = map(str.strip, 
v.split(','))
+                       except: raise Exception, 'Bad notebook page format.'
+                       
+                       #TODO check that notebook id is valid
+                       
+                       #TODO check that page index exists
+                       
+                       #TODO modify the grid params to be per notebook
+                       
+                       return notebook_id, page_index
+               #########################
                # Import Type
                #########################
                elif t == 'import':

Modified: gnuradio/branches/developers/jblum/grc/grc/python/flow_graph.tmpl
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/flow_graph.tmpl   
2009-07-01 02:47:47 UTC (rev 11321)
+++ gnuradio/branches/developers/jblum/grc/grc/python/flow_graph.tmpl   
2009-07-01 15:19:25 UTC (rev 11322)
@@ -5,6 +5,7 @@
 address@hidden imports the import statements
 address@hidden flow_graph the flow_graph
 address@hidden variables the variable blocks
address@hidden notebooks a list of notebook blocks
 address@hidden controls the variables with gui controls
 address@hidden parameters the paramater blocks
 address@hidden blocks the signal blocks
@@ -52,13 +53,11 @@
 class $(class_name)(grc_wxgui.top_block_gui):
 
        def __init__($param_str):
-               grc_wxgui.top_block_gui.__init__(
-                       self,
-                       title="$title",
+               grc_wxgui.top_block_gui.__init__(self, title="$title")
        #if $icon
-                       icon="$icon.get_filename()",
+               _icon_path = "$icon.get_filename()"
+               self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
        #end if
-               )
 #elif $generate_options == 'no_gui'
 class $(class_name)(gr.top_block):
 
@@ -71,8 +70,7 @@
 
        def __init__($param_str):
                gr.hier_block2.__init__(
-                       self,
-                       "$title",
+                       self, "$title",
                        gr.io_signature($in_sig.nports, $in_sig.nports, 
$in_sig.size*$in_sig.vlen),
                        gr.io_signature($out_sig.nports, $out_sig.nports, 
$out_sig.size*$out_sig.vlen),
                )
@@ -92,8 +90,6 @@
 #end for
 ########################################################
 ##Create Variables
-##     Set the variable to a property of self.
-##     Write the first line of the variable make.
 ########################################################
 #if $variables
 
@@ -105,9 +101,19 @@
                $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
-##     Write the variable make (excluding first line).
-##     Indent each line with 2 tabs.
 ########################################################
 #if $controls
 
@@ -120,7 +126,6 @@
 #end for
 ########################################################
 ##Create Blocks
-##     Write the block make, and indent with 2 tabs.
 ########################################################
 #if $blocks
 
@@ -161,7 +166,6 @@
 ########################################################
 ##Create Callbacks
 ##     Write a set method for this variable that calls the callbacks
-##     and sets the direct variable dependencies.
 ########################################################
 #for $var in $parameters + $variables
        #set $id = $var.get_id()

Modified: gnuradio/branches/developers/jblum/grc/grc/todo.txt
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/todo.txt 2009-07-01 02:47:47 UTC 
(rev 11321)
+++ gnuradio/branches/developers/jblum/grc/grc/todo.txt 2009-07-01 15:19:25 UTC 
(rev 11322)
@@ -22,6 +22,7 @@
   * gr_ofdm_insert_preamble
   * gr_ofdm_mapper_bcv
   * gr_ofdm_sampler
+* size params for the graphical sinks
 
 ##################################################
 # Features





reply via email to

[Prev in Thread] Current Thread [Next in Thread]