[GRASS-SVN] r47623 - grass-addons/grass7/gui/wxpython/wx.stream/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 14 07:11:31 EDT 2011


Author: madi
Date: 2011-08-14 04:11:31 -0700 (Sun, 14 Aug 2011)
New Revision: 47623

Modified:
   grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream.py
   grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_panelOne.py
Log:
Added Map Display from layer manager

Modified: grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream.py	2011-08-14 11:09:49 UTC (rev 47622)
+++ grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream.py	2011-08-14 11:11:31 UTC (rev 47623)
@@ -24,7 +24,6 @@
 sys.path.append(os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'wxpython', 'gui_modules'))
 
 import wx
-#import wx.aui
 import wx.lib.flatnotebook as FN
 
 from debug import Debug as Debug
@@ -82,15 +81,13 @@
         wx.Frame.__init__(self, parent = parent, id = id, title = title, name = "RStream", size = (600, 900), **kwargs)
         self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
         
-        # create the AuiNotebook instance
-        #nb = wx.aui.AuiNotebook(self)
 
         self.nb = FN.FlatNotebook(parent = self, id = wx.ID_ANY,
                                         style = FN.FNB_NO_NAV_BUTTONS |
                                         FN.FNB_FANCY_TABS | FN.FNB_NO_X_BUTTON)
 
-        # add some pages to the notebook
-        self.pages = [(TabPanelOne(self.nb), "Network extraction"),
+        # add pages to the notebook
+        self.pages = [(TabPanelOne(self.nb, self.parent), "Network extraction"),
                       (TabPanel(self.nb), "Network ordering"),
                       (TabPanel(self.nb), "Tab 3")]
 
@@ -109,7 +106,7 @@
         
         self.SetSizer(self.sizer)
 
-        #self.mapdisp = self.parent.curr_page.maptree.mapdisplay
+        self.mapdisp = self.parent.curr_page.maptree.mapdisplay
 
     def OnClose(self, event): 
         self.Destroy()        

Modified: grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_panelOne.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_panelOne.py	2011-08-14 11:09:49 UTC (rev 47622)
+++ grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_panelOne.py	2011-08-14 11:11:31 UTC (rev 47623)
@@ -9,9 +9,7 @@
 See http://grass.osgeo.org/wiki/Wx.stream_GSoC_2011
 
 Classes:
- - SPD
- - SPDCanvas
- - TabPanelOne
+ - RStreamFrame
 
 (C) 2011 by Margherita Di Leo, and the GRASS Development Team
 This program is free software under the GNU General Public License
@@ -38,71 +36,16 @@
 import globalvar
 import utils
 import menuform
-import mapdisp_window
 
-from wxgui import GMFrame # for SPD class
-from render import MapLayer
 
+# First panel # Network extraction
 
-# SPD = Select Point Display 
-class SPD(GMFrame, wx.Frame):
-    """!Secondary Map Display that allows user to select the point which is the centre of preview region
-    """
-
-    def __init__(self, parent, grwiz = None, id = wx.ID_ANY,
-                 title = _("Select the centre of Preview region"),
-                 size = (700, 300), Map = None, lmgr = None):
-
-        GMFrame.__init__(self, parent, id = wx.ID_ANY, title = "SPDMapWindow",
-                 workspace = None,
-                 size = globalvar.GM_WINDOW_SIZE, style = wx.DEFAULT_FRAME_STYLE)  
-
-        #
-        # init variables
-        #
-        self.parent = parent # TabPanelOne
-        
-
-class SPDCanvas(MapLayer):
-    def __init__(self, type, cmd, name = None,
-                 active = True, hidden = False, opacity = 1.0): 
-        """!Represents map layer in the map canvas
-        @param type layer type ('raster', 'vector', 'command', etc.)
-        @param cmd GRASS command to render layer,
-        given as list, e.g. ['d.rast', 'map=elevation at PERMANENT']
-        @param name layer name, e.g. 'elevation at PERMANENT' (for layer tree) or None
-        @param active layer is active, will be rendered only if True
-        @param hidden layer is hidden, won't be listed in Layer Manager if True
-        @param opacity layer opacity <0;1>
-        """
-        MapLayer.__init__(self, type, cmd, name,
-                       active, hidden, opacity)
-                       
-    def GetMapset(self):
-        """!Get mapset of map layer
-        
-        @return mapset name
-        @return '' on error (no name given)
-        """
-        if not self.name:
-            return ''
-        
-        try:
-            return self.name.split('@')[1]
-        except IndexError:
-            return self.name
-        
-        
-
-
-
 class TabPanelOne(wx.Panel):
-    """!First panel for Network extraction
-    """
 
-    def __init__(self, parent):
+    def __init__(self, parent, layerManager):
         wx.Panel.__init__(self, parent, id = wx.ID_ANY)
-       
+        
+        self.layerManager = layerManager
         self.parent = parent
         self.thre = 0
         self.r_elev = 'r_elev'
@@ -110,7 +53,7 @@
         self.r_stre = 'r_stre'
         self.v_net = 'v_net'
         self.r_drain = 'r_drain'
-
+        
         self.panel = wx.Panel(self)                        
         self._layout()
         
@@ -359,7 +302,6 @@
     def OnPreview(self, event):
         """!Allows to watch a preview of the analysis on a small region
         """
-        pass
         info_region = grass.read_command('g.region', flags = 'p')
 
         # message box 
@@ -370,23 +312,10 @@
             print "OK"
 
             # get current Map Display
-            self.mapdisp = SPD(parent = self)
-            SPDCanvas(type = 'command', cmd = ['d.rast', 'map = self.r_elev']).Render() # FIXME #
-            
-            # Debug
-            print type(dir(SPDCanvas))
-            lista = []
-            lista.append(dir(SPDCanvas))
-        
-            for i in dir(SPDCanvas):
-                print i
-            
-            
+            mapdisp = self.layerManager.GetLayerTree().GetMapDisplay()
+            mapdisp.Raise()
+            #grass.run_command('d.rast', map = self.r_elev)
 
-            
-
-              
-
             # Get position by panel on mouse click
             
 
@@ -401,10 +330,8 @@
     #-------------Network extraction-------------
     
     def OnRun(self, event):
-        """!Calculates flow accumulation if it is missing, and runs stream extraction
-        """
 
-        #radioval1 = self.cb1.GetValue()
+        # radioval1 = self.cb1.GetValue()
         radioval2 = self.cb2.GetValue()
         radioval3 = self.cb3.GetValue()
         



More information about the grass-commit mailing list