[GRASS-SVN] r48763 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 12 10:31:18 EDT 2011


Author: annakrat
Date: 2011-10-12 07:31:17 -0700 (Wed, 12 Oct 2011)
New Revision: 48763

Modified:
   grass/trunk/gui/wxpython/gui_modules/gcpmapdisp.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
Log:
wxGUI: moving code to MapFrameBase (co-author V. Petras)

Modified: grass/trunk/gui/wxpython/gui_modules/gcpmapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcpmapdisp.py	2011-10-12 14:07:31 UTC (rev 48762)
+++ grass/trunk/gui/wxpython/gui_modules/gcpmapdisp.py	2011-10-12 14:31:17 UTC (rev 48763)
@@ -86,9 +86,12 @@
         """
         
         MapFrameBase.__init__(self, parent = parent, title = title, toolbars = toolbars,
-                              tree = tree, notebook = notebook, lmgr = lmgr, page = page,
                               Map = Map, auimgr = auimgr, name = name, **kwargs)
         
+        self._layerManager = lmgr   # Layer Manager object
+        self.tree       = tree      # Layer Manager layer tree object
+        self.page       = page      # Notebook page holding the layer tree
+        self.layerbook  = notebook  # Layer Manager layer tree notebook
         #
         # Add toolbars
         #
@@ -158,7 +161,8 @@
         #
         # initialize region values
         #
-        self.__InitDisplay() 
+        self._initMap(map = self.SrcMap) 
+        self._initMap(map = self.TgtMap) 
 
         #
         # Bind various events
@@ -284,22 +288,6 @@
             
         self._mgr.Update()
 
-    def __InitDisplay(self):
-        """
-        Initialize map display, set dimensions and map region
-        """
-        self.width, self.height = self.GetClientSize()
-
-        Debug.msg(2, "MapFrame.__InitDisplay():")
-        self.grwiz.SwitchEnv('source')
-        self.SrcMap.ChangeMapSize(self.GetClientSize())
-        self.SrcMap.region = self.SrcMap.GetRegion() # g.region -upgc
-        self.grwiz.SwitchEnv('target')
-        self.TgtMap.ChangeMapSize(self.GetClientSize())
-        self.TgtMap.region = self.TgtMap.GetRegion() # g.region -upgc
-        # self.SrcMap.SetRegion() # adjust region to match display window
-        # self.TgtMap.SetRegion() # adjust region to match display window
-
     def OnUpdateProgress(self, event):
         """
         Update progress bar info
@@ -696,4 +684,8 @@
     def GetShowTarget(self):
         return self.show_target
         
+    def GetMapToolbar(self):
+        """!Returns toolbar with zooming tools"""
+        return self.toolbars['gcpdisp']
+        
 # end of class MapFrame

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2011-10-12 14:07:31 UTC (rev 48762)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2011-10-12 14:31:17 UTC (rev 48763)
@@ -82,26 +82,17 @@
     """
     def __init__(self, parent = None, id = wx.ID_ANY, title = None,
                  style = wx.DEFAULT_FRAME_STYLE, toolbars = None,
-                 tree = None, notebook = None, lmgr = None, page = None,
                  Map = None, auimgr = None, name = None, **kwargs):
         """!
-        
         @param toolbars array of activated toolbars, e.g. ['map', 'digit']
-        @param tree reference to layer tree
-        @param notebook control book ID in Layer Manager
-        @param lmgr Layer Manager
-        @param page notebook page with layer tree
         @param Map instance of render.Map
         @param auimgs AUI manager
         @param name frame name
         @param kwargs wx.Frame attributes
         """
         
-        self._layerManager = lmgr   # Layer Manager object
+
         self.Map        = Map       # instance of render.Map
-        self.tree       = tree      # Layer Manager layer tree object
-        self.page       = page      # Notebook page holding the layer tree
-        self.layerbook  = notebook  # Layer Manager layer tree notebook
         self.parent     = parent
         
         wx.Frame.__init__(self, parent, id, title, style = style, name = name, **kwargs)
@@ -129,7 +120,21 @@
         # Fancy gui
         #
         self._mgr = wx.aui.AuiManager(self)
-	
+        
+    def _initMap(self, map):
+        """!Initialize map display, set dimensions and map region
+        """
+        if not grass.find_program('g.region', ['--help']):
+            sys.exit(_("GRASS module '%s' not found. Unable to start map "
+                       "display window.") % 'g.region')
+        
+        self.width, self.height = self.GetClientSize()
+        
+        Debug.msg(2, "MapFrame._initMap():")
+        map.ChangeMapSize(self.GetClientSize())
+        map.region = map.GetRegion() # g.region -upgc
+        # self.Map.SetRegion() # adjust region to match display window
+        
     def SetProperty(self, name, value):
         """!Sets property"""
         self.statusbarManager.SetProperty(name, value)
@@ -225,7 +230,7 @@
         Progress bar can be used by other classes.
         """
         return self.statusbarManager.GetProgressBar()
-	
+        
     def GetRender(self):
         """!Returns current instance of render.Map()
         
@@ -241,32 +246,40 @@
     def GetWindow(self):
         """!Get map window"""
         return self.MapWindow
-	
+        
+    def GetMapToolbar(self):
+       """!Returns toolbar with zooming tools"""
+       raise NotImplementedError()
+       
     def StatusbarUpdate(self):
         """!Update statusbar content"""
         self.statusbarManager.Update()
-	
+        
     def IsAutoRendered(self):
         """!Check if auto-rendering is enabled"""
         return self.GetProperty('render')
-            
+        
     def CoordinatesChanged(self):
         """!Shows current coordinates on statusbar.
         
         Used in BufferedWindow to report change of map coordinates (under mouse cursor).
         """
         self.statusbarManager.ShowItem('coordinates')
-	
+        
     def StatusbarReposition(self):
         """!Reposition items in statusbar"""
         self.statusbarManager.Reposition()
-	
+        
     def StatusbarEnableLongHelp(self, enable = True):
         """!Enable/disable toolbars long help"""
         for toolbar in self.toolbars.itervalues():
             if toolbar:
                 toolbar.EnableLongHelp(enable)
-		
+        
+    def IsStandalone(self):
+        """!Check if Map display is standalone"""
+        raise NotImplementedError("IsStandalone")
+        
 class MapFrame(MapFrameBase):
     """!Main frame for map display window. Drawing takes place in
     child double buffered drawing window.
@@ -288,9 +301,12 @@
         @param kwargs wx.Frame attributes
         """
         MapFrameBase.__init__(self, parent = parent, title = title, toolbars = toolbars,
-                              tree = tree, notebook = notebook, lmgr = lmgr, page = page,
                               Map = Map, auimgr = auimgr, name = name, **kwargs)
         
+        self._layerManager = lmgr   # Layer Manager object
+        self.tree       = tree      # Layer Manager layer tree object
+        self.page       = page      # Notebook page holding the layer tree
+        self.layerbook  = notebook  # Layer Manager layer tree notebook
         #
         # Add toolbars
         #
@@ -354,7 +370,7 @@
         #
         # initialize region values
         #
-        self._initDisplay() 
+        self._initMap(map = self.Map) 
 
         #
         # Bind various events
@@ -632,21 +648,7 @@
         if self._mgr.GetPane(name).IsOk():
             return self._mgr.GetPane(name).IsShown()
         return False
-    
-    def _initDisplay(self):
-        """!Initialize map display, set dimensions and map region
-        """
-        if not grass.find_program('g.region', ['--help']):
-            sys.exit(_("GRASS module '%s' not found. Unable to start map "
-                       "display window.") % 'g.region')
         
-        self.width, self.height = self.GetClientSize()
-        
-        Debug.msg(2, "MapFrame._initDisplay():")
-        self.Map.ChangeMapSize(self.GetClientSize())
-        self.Map.region = self.Map.GetRegion() # g.region -upgc
-        # self.Map.SetRegion() # adjust region to match display window
-        
     def OnUpdateProgress(self, event):
         """!Update progress bar info
         """
@@ -670,7 +672,6 @@
                 if pgnum > -1:
                     self.layerbook.SetSelection(pgnum)
                     self._layerManager.curr_page = self.layerbook.GetCurrentPage()
-                    self.layerbook
         
         event.Skip()
         
@@ -1684,6 +1685,10 @@
         """
         return self._layerManager
     
+    def GetMapToolbar(self):
+        """!Returns toolbar with zooming tools"""
+        return self.toolbars['map']
+    
 class MapApp(wx.App):
     def OnInit(self):
         wx.InitAllImageHandlers()

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2011-10-12 14:07:31 UTC (rev 48762)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2011-10-12 14:31:17 UTC (rev 48763)
@@ -834,7 +834,7 @@
         if not self.parent.IsStandalone() and \
                 self.parent.GetLayerManager().gcpmanagement:
             # -> georectifier (redraw GCPs)
-            if self.parent.toolbars['gcpdisp']:
+            if self.parent.GetMapToolbar():
                 if self == self.parent.TgtMapWindow:
                     coordtype = 'target'
                 else:
@@ -1705,12 +1705,7 @@
         else:
             enable = False
         
-        if self.parent.GetName() == 'MapWindow':
-            toolbar = self.parent.toolbars['map']
-        elif self.parent.GetName() == 'GRMapWindow':
-            toolbar = self.parent.toolbars['georect']
-        elif self.parent.GetName() == 'GCPMapWindow':
-            toolbar = self.parent.toolbars['gcpdisp']
+        toolbar = self.parent.GetMapToolbar()
         
         toolbar.Enable('zoomback', enable)
         



More information about the grass-commit mailing list