[GRASS-SVN] r35956 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Feb 19 13:35:33 EST 2009


Author: martinl
Date: 2009-02-19 13:35:32 -0500 (Thu, 19 Feb 2009)
New Revision: 35956

Modified:
   grass/trunk/gui/wxpython/gui_modules/georect.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
   grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
   grass/trunk/gui/wxpython/gui_modules/profile.py
   grass/trunk/gui/wxpython/gui_modules/vdigit.py
   grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: MapFrame standalone check


Modified: grass/trunk/gui/wxpython/gui_modules/georect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/georect.py	2009-02-19 18:09:37 UTC (rev 35955)
+++ grass/trunk/gui/wxpython/gui_modules/georect.py	2009-02-19 18:35:32 UTC (rev 35956)
@@ -190,7 +190,7 @@
             self.xy_mapdisp = mapdisp.MapFrame(self.gcpmgr, title=_("Set ground control points (GCPs)"),
                                                size=globalvar.MAP_WINDOW_SIZE,
                                                toolbars=["georect"],
-                                               Map=self.Map, gismgr=self.parent)
+                                               Map=self.Map, lmgr=self.parent)
 
             self.gcpmgr.SetMapDisplay(self.xy_mapdisp)
             

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2009-02-19 18:09:37 UTC (rev 35955)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2009-02-19 18:35:32 UTC (rev 35956)
@@ -8,7 +8,6 @@
 Can be used either from Layer Manager or as p.mon backend.
 
 Classes:
- - MapWindow
  - MapFrame
  - MapApp
 
@@ -90,7 +89,7 @@
     def __init__(self, parent=None, id=wx.ID_ANY, title=_("GRASS GIS - Map display"),
                  pos=wx.DefaultPosition, size=wx.DefaultSize,
                  style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"],
-                 tree=None, notebook=None, gismgr=None, page=None,
+                 tree=None, notebook=None, lmgr=None, page=None,
                  Map=None, auimgr=None):
         """
         Main map display window with toolbars, statusbar and
@@ -99,15 +98,15 @@
         @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 gismgr Layer Manager panel
+        @param mgr Layer Manager
         @param page notebook page with layer tree
         @param Map instance of render.Map
         """
-        self.gismanager = gismgr    # GIS Manager object
+        self._layerManager = lmgr   # Layer Manager object
         self.Map        = Map       # instance of render.Map
-        self.tree       = tree      # GIS Manager layer tree object
+        self.tree       = tree      # Layer Manager layer tree object
         self.page       = page      # Notebook page holding the layer tree
-        self.layerbook  = notebook  # GIS Manager layer tree notebook
+        self.layerbook  = notebook  # Layer Manager layer tree notebook
         self.parent     = parent
 
         #
@@ -214,7 +213,7 @@
         # Init map display (buffered DC & set default cursor)
         #
         self.MapWindow2D = BufferedWindow(self, id=wx.ID_ANY,
-                                          Map=self.Map, tree=self.tree, gismgr=self.gismanager)
+                                          Map=self.Map, tree=self.tree, lmgr=self._layerManager)
         # default is 2D display mode
         self.MapWindow = self.MapWindow2D
         self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
@@ -296,8 +295,8 @@
 	
         # vector digitizer
         elif name == "vdigit":
-            if self.gismanager:
-                log = self.gismanager.goutput
+            if self._layerManager:
+                log = self._layerManager.goutput
             else:
                 log = None
             self.toolbars['vdigit'] = toolbars.VDigitToolbar(parent=self, map=self.Map,
@@ -381,7 +380,7 @@
             #
             if not self.MapWindow3D:
                 self.MapWindow3D = nviz.GLWindow(self, id=wx.ID_ANY,
-                                                 Map=self.Map, tree=self.tree, gismgr=self.gismanager)
+                                                 Map=self.Map, tree=self.tree, lmgr=self._layerManager)
                 # -> show after paint
                 self.nvizToolWin = nviz.NvizToolWindow(self, id=wx.ID_ANY,
                                                        mapWindow=self.MapWindow3D)
@@ -485,8 +484,8 @@
         Change choicebook page to match display.
         Or set display for georectifying
         """
-        if self.gismanager and \
-                self.gismanager.georectifying:
+        if self._layerManager and \
+                self._layerManager.georectifying:
             # in georectifying session; display used to get get geographic
             # coordinates for GCPs
             self.OnPointer(event)
@@ -590,7 +589,7 @@
             else: # moveLine, deleteLine
                 self.MapWindow.mouse['box'] = 'box'
         
-        elif self.gismanager and self.gismanager.georectifying:
+        elif self._layerManager and self._layerManager.georectifying:
             self.MapWindow.SetCursor(self.cursors["cross"])
         
         else:
@@ -1026,7 +1025,7 @@
         if self.toolbars['nviz']:
             self.toolbars['nviz'].OnExit()
 
-        if not self.gismanager:
+        if not self._layerManager:
             self.Destroy()
         elif self.page:
             pgnum = self.layerbook.GetPageIndex(self.page)
@@ -1050,7 +1049,7 @@
         self.toolbars['map'].action['desc'] = 'displayAttrb'
         
         # switch GIS Manager to output console to show query results
-        self.gismanager.notebook.SetSelection(1)
+        self._layerManager.notebook.SetSelection(1)
 
         self.MapWindow.mouse['use'] = "query"
         self.MapWindow.mouse['box'] = "point"
@@ -1130,14 +1129,14 @@
                 vect = []
                 for vector in vectstr.split(','):
                     if map == vector:
-                        self.gismanager.goutput.WriteWarning("Vector map <%s> "
+                        self._layerManager.goutput.WriteWarning("Vector map <%s> "
                                                              "opened for editing - skipped." % map)
                         continue
                     vect.append(vector)
                 vectstr = ','.join(vect)
                 
             if len(vectstr) <= 1:
-                self.gismanager.goutput.WriteCmdLog("Nothing to query.")
+                self._layerManager.goutput.WriteCmdLog("Nothing to query.")
                 return
             
             vcmd.append('-a')
@@ -1146,12 +1145,12 @@
             vcmd.append('distance=%f' % float(qdist))
         
         # parse query command(s)
-        if self.gismanager:
+        if self._layerManager:
             if raststr:
-                self.gismanager.goutput.RunCmd(rcmd,
+                self._layerManager.goutput.RunCmd(rcmd,
                                                compReg=False)
             if vectstr:
-                self.gismanager.goutput.RunCmd(vcmd)
+                self._layerManager.goutput.RunCmd(vcmd)
         else:
             if raststr:
                 gcmd.RunCommand(rcmd)
@@ -1349,7 +1348,7 @@
         self.totaldist = 0.0 # total measured distance
 
         # switch GIS Manager to output console to show measure results
-        self.gismanager.notebook.SetSelection(1)
+        self._layerManager.notebook.SetSelection(1)
 
         # change mouse to draw line for measurement
         self.MapWindow.mouse['use'] = "measure"
@@ -1362,19 +1361,19 @@
         self.MapWindow.SetCursor(self.cursors["pencil"])
 
         # initiating output
-        style = self.gismanager.goutput.cmd_output.StyleWarning
-        self.gismanager.goutput.WriteLog(_('Click and drag with left mouse button '
+        style = self._layerManager.goutput.cmd_output.StyleWarning
+        self._layerManager.goutput.WriteLog(_('Click and drag with left mouse button '
                                            'to measure.%s'
                                            'Double click with left button to clear.') % \
                                              (os.linesep), style)
         if self.Map.projinfo['proj'] != 'xy':
             units = self.Map.projinfo['units']
-            style = self.gismanager.goutput.cmd_output.StyleCommand
-            self.gismanager.goutput.WriteLog(_('Measuring distance') + ' ('
+            style = self._layerManager.goutput.cmd_output.StyleCommand
+            self._layerManager.goutput.WriteLog(_('Measuring distance') + ' ('
                                              + units + '):',
                                              style)
         else:
-            self.gismanager.goutput.WriteLog(_('Measuring distance:'),
+            self._layerManager.goutput.WriteLog(_('Measuring distance:'),
                                              style)
 
     def MeasureDist(self, beginpt, endpt):
@@ -1383,8 +1382,8 @@
         and print to output window
         """
 
-        if self.gismanager.notebook.GetSelection() != 1:
-            self.gismanager.notebook.SetSelection(1)
+        if self._layerManager.notebook.GetSelection() != 1:
+            self._layerManager.notebook.SetSelection(1)
 
         dist, (north, east) = self.MapWindow.Distance(beginpt, endpt)
 
@@ -1408,7 +1407,7 @@
             mstring = 'segment = %s %s\ttotal distance = %s %s' \
                 % (strdist,dunits,strtotdist,tdunits)
 
-        self.gismanager.goutput.WriteLog(mstring)
+        self._layerManager.goutput.WriteLog(mstring)
 
         return dist
 
@@ -1684,7 +1683,22 @@
         self.compResolution.SetValue(constrainRes)
         if showCompExtent:
             self.MapWindow.regionCoords = []
+
+    def IsStandalone(self):
+        """Check if Map display is standalone"""
+        if self._layerManager:
+            return False
         
+        return True
+    
+    def GetLayerManager(self):
+        """Get reference to Layer Manager
+
+        @return window reference
+        @return None (if standalone)
+        """
+        return self._layerManager
+    
 # end of class MapFrame
 
 class MapApp(wx.App):

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2009-02-19 18:09:37 UTC (rev 35955)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2009-02-19 18:35:32 UTC (rev 35956)
@@ -48,7 +48,7 @@
                  pos=wx.DefaultPosition,
                  size=wx.DefaultSize,
                  style=wx.NO_FULL_REPAINT_ON_RESIZE,
-                 Map=None, tree=None, gismgr=None):
+                 Map=None, tree=None, lmgr=None):
         self.parent = parent # MapFrame
  
         #
@@ -151,16 +151,15 @@
                  pos = wx.DefaultPosition,
                  size = wx.DefaultSize,
                  style=wx.NO_FULL_REPAINT_ON_RESIZE,
-                 Map=None, tree=None, gismgr=None):
+                 Map=None, tree=None, lmgr=None):
 
         MapWindow.__init__(self, parent, id, pos, size, style,
-                           Map, tree, gismgr)
+                           Map, tree, lmgr)
         wx.Window.__init__(self, parent, id, pos, size, style)
 
         self.Map = Map
         self.tree = tree
-        self.gismanager = gismgr
-
+        
         #
         # Flags
         #
@@ -715,14 +714,14 @@
         if len(self.polycoords) > 0:
             self.DrawLines(self.pdcTmp)
         
-        if self.parent.gismanager and \
-                self.parent.gismanager.georectifying:
+        if not self.parent.IsStandalone() and \
+                self.parent.GetLayerManager().georectifying:
             # -> georectifier (redraw GCPs)
             if self.parent.toolbars['georect']:
                 coordtype = 'gcpcoord'
             else:
                 coordtype = 'mapcoord'
-            self.parent.gismanager.georectifying.DrawGCP(coordtype)
+            self.parent.GetLayerManager().georectifying.DrawGCP(coordtype)
             
         # 
         # clear measurement
@@ -1717,7 +1716,8 @@
             self.ClearLines(pdc=self.pdcTmp)
             self.DrawLines(pdc=self.pdcTmp)
         
-        elif self.mouse["use"] == "pointer" and self.parent.gismanager.georectifying:
+        elif self.mouse["use"] == "pointer" and \
+                self.parent.GetLayerManager().georectifying:
             # -> georectifying
             coord = self.Pixel2Cell(self.mouse['end'])
             if self.parent.toolbars['georect']:
@@ -1725,7 +1725,7 @@
             else:
                 coordtype = 'mapcoord'
 
-            self.parent.gismanager.georectifying.SetGCPData(coordtype, coord, self)
+            self.parent.GetLayerManager().georectifying.SetGCPData(coordtype, coord, self)
             self.UpdateMap(render=False, renderVector=False)
 
         elif self.mouse["use"] == "pointer" and self.parent.toolbars['vdigit']:

Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py	2009-02-19 18:09:37 UTC (rev 35955)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py	2009-02-19 18:35:32 UTC (rev 35956)
@@ -66,16 +66,16 @@
                  pos=wx.DefaultPosition,
                  size=wx.DefaultSize,
                  style=wx.NO_FULL_REPAINT_ON_RESIZE,
-                 Map=None, tree=None, gismgr=None):
+                 Map=None, tree=None, lmgr=None):
 
         self.parent = parent # MapFrame
         self.Map = Map
         self.tree = tree
-        self.gismgr = gismgr
+        self._layermanager = lmgr
         
         glcanvas.GLCanvas.__init__(self, parent, id)
         MapWindow.__init__(self, parent, id, pos, size, style,
-                           Map, tree, gismgr)
+                           Map, tree, self._layermanager)
         self.Hide()
         
         self.init = False
@@ -98,9 +98,9 @@
         #
         # create nviz instance
         #
-        if self.gismgr:
-            logerr = self.gismgr.goutput.cmd_stderr
-            logmsg = self.gismgr.goutput.cmd_output
+        if self._layermanager:
+            logerr = self._layermanager.goutput.cmd_stderr
+            logmsg = self._layermanager.goutput.cmd_output
         else:
             logerr = logmsg = None
         self.nvizThread = NvizThread(logerr,

Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py	2009-02-19 18:09:37 UTC (rev 35955)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py	2009-02-19 18:35:32 UTC (rev 35956)
@@ -45,7 +45,7 @@
                  style=wx.DEFAULT_FRAME_STYLE, mapWindow=None):
         
         self.parent = parent # MapFrame
-        self.lmgr = self.parent.gismanager # GMFrame
+        self.lmgr = self.parent.GetLayerManager() # GMFrame
         self.mapWindow = mapWindow
 
         wx.Frame.__init__(self, parent, id, title, pos, size, style)

Modified: grass/trunk/gui/wxpython/gui_modules/profile.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/profile.py	2009-02-19 18:09:37 UTC (rev 35955)
+++ grass/trunk/gui/wxpython/gui_modules/profile.py	2009-02-19 18:35:32 UTC (rev 35956)
@@ -1058,7 +1058,7 @@
         UserSettings.ReadSettingsFile(settings=fileSettings)
         fileSettings['profile'] = UserSettings.Get(group='profile')
         file = UserSettings.SaveToFile(fileSettings)
-        self.parent.parent.gismanager.goutput.WriteLog(_('Profile settings saved to file \'%s\'.') % file)
+        self.parent.parent.GetLayerManager().goutput.WriteLog(_('Profile settings saved to file \'%s\'.') % file)
         self.Close()
 
     def OnApply(self, event):
@@ -1403,7 +1403,7 @@
         UserSettings.ReadSettingsFile(settings=fileSettings)
         fileSettings['profile'] = UserSettings.Get(group='profile')
         file = UserSettings.SaveToFile(fileSettings)
-        self.parent.parent.gismanager.goutput.WriteLog(_('Profile settings saved to file \'%s\'.') % file)
+        self.parent.parent.GetLayerManager().goutput.WriteLog(_('Profile settings saved to file \'%s\'.') % file)
         self.Close()
 
     def OnApply(self, event):

Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py	2009-02-19 18:09:37 UTC (rev 35955)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py	2009-02-19 18:35:32 UTC (rev 35956)
@@ -766,8 +766,8 @@
 
         self.mapWindow = mapwindow
 
-        if self.mapwindow.gismanager:
-            logerr = self.mapwindow.gismanager.goutput.cmd_stderr
+        if not self.mapwindow.parent.IsStandalone():
+            logerr = self.mapwindow.parent.GetLayerManager().goutput.cmd_stderr
         else:
             logerr = None
 
@@ -1613,7 +1613,7 @@
         fileSettings['vdigit'] = UserSettings.Get(group='vdigit')
         
         file = UserSettings.SaveToFile(fileSettings)
-        self.parent.gismanager.goutput.WriteLog(_('Vector digitizer settings saved to file <%s>.') % file)
+        self.parent.GetLayerManager().goutput.WriteLog(_('Vector digitizer settings saved to file <%s>.') % file)
         
         self.Destroy()
 

Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2009-02-19 18:09:37 UTC (rev 35955)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2009-02-19 18:35:32 UTC (rev 35956)
@@ -88,7 +88,7 @@
         self.first = True          # indicates if a layer is just added or not
         self.flag = ''             # flag for drag and drop hittest
         self.disp_idx = kargs['idx']
-        self.gismgr = kargs['gismgr']
+        self.lmgr = kargs['lmgr']
         self.notebook = kargs['notebook']   # GIS Manager notebook for layer tree
         self.treepg = parent        # notebook page holding layer tree
         self.auimgr = kargs['auimgr']       # aui manager
@@ -102,7 +102,7 @@
                                            size=globalvar.MAP_WINDOW_SIZE,
                                            style=wx.DEFAULT_FRAME_STYLE,
                                            tree=self, notebook=self.notebook,
-                                           gismgr=self.gismgr, page=self.treepg,
+                                           lmgr=self.lmgr, page=self.treepg,
                                            Map=self.Map, auimgr=self.auimgr)
 
         # title
@@ -208,8 +208,8 @@
     def OnKeyUp(self, event):
         """Key pressed"""
         key = event.GetKeyCode()
-        if key == wx.WXK_DELETE and self.gismgr:
-            self.gismgr.OnDeleteLayer(None)
+        if key == wx.WXK_DELETE and self.lmgr:
+            self.lmgr.OnDeleteLayer(None)
 
         event.Skip()
 
@@ -251,7 +251,7 @@
         
         # general item
         self.popupMenu.Append(self.popupID1, text=_("Remove"))
-        self.Bind(wx.EVT_MENU, self.gismgr.OnDeleteLayer, id=self.popupID1)
+        self.Bind(wx.EVT_MENU, self.lmgr.OnDeleteLayer, id=self.popupID1)
 
         if ltype != "command": # rename
             self.popupMenu.Append(self.popupID2, text=_("Rename"))
@@ -286,7 +286,7 @@
         if mltype and mltype == "vector":
             self.popupMenu.AppendSeparator()
             self.popupMenu.Append(self.popupID4, text=_("Show attribute data"))
-            self.Bind (wx.EVT_MENU, self.gismgr.OnShowAttributeTable, id=self.popupID4)
+            self.Bind (wx.EVT_MENU, self.lmgr.OnShowAttributeTable, id=self.popupID4)
 
             self.popupMenu.Append(self.popupID5, text=_("Start editing"))
             self.popupMenu.Append(self.popupID6, text=_("Stop editing"))
@@ -388,7 +388,7 @@
         cmd.append('map=%s' % mapLayer.name)
 
         # print output to command log area
-        self.gismgr.goutput.RunCmd(cmd, switchPage=True)
+        self.lmgr.goutput.RunCmd(cmd, switchPage=True)
 
     def OnSetCompRegFromRaster(self, event):
         """Set computational region from selected raster map (ignore NULLs)"""
@@ -399,7 +399,7 @@
                'zoom=%s' % mapLayer.name]
         
         # print output to command log area
-        self.gismgr.goutput.RunCmd(cmd)
+        self.lmgr.goutput.RunCmd(cmd)
          
     def OnSetCompRegFromMap(self, event):
         """Set computational region from selected raster/vector map"""
@@ -428,7 +428,7 @@
         # print output to command log area
         if len(cmd) > 1:
             cmd.append('-p')
-            self.gismgr.goutput.RunCmd(cmd)
+            self.lmgr.goutput.RunCmd(cmd)
         
     def OnProfile(self, event):
         """Plot profile of given raster map layer"""
@@ -1064,7 +1064,7 @@
         if self.GetPyData(layer) and self.GetPyData(layer)[0]['maplayer']:
             cmd = self.GetPyData(layer)[0]['maplayer'].GetCmd(string=True)
             if len(cmd) > 0:
-                self.gismgr.SetStatusText(cmd)
+                self.lmgr.SetStatusText(cmd)
         
         #
         # update nviz tools

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2009-02-19 18:09:37 UTC (rev 35955)
+++ grass/trunk/gui/wxpython/wxgui.py	2009-02-19 18:35:32 UTC (rev 35956)
@@ -1157,7 +1157,7 @@
                                                        size=wx.DefaultSize, style=wx.TR_HAS_BUTTONS
                                                        |wx.TR_LINES_AT_ROOT|wx.TR_HIDE_ROOT
                                                        |wx.TR_DEFAULT_STYLE|wx.NO_BORDER|wx.FULL_REPAINT_ON_RESIZE,
-                                                       idx=self.disp_idx, gismgr=self, notebook=self.gm_cb,
+                                                       idx=self.disp_idx, lmgr=self, notebook=self.gm_cb,
                                                        auimgr=self._auimgr, showMapDisplay=show)
 
         # layout for controls



More information about the grass-commit mailing list