[GRASS-SVN] r53383 - in grass/branches/develbranch_6/gui/wxpython: core dbmgr gcp gui_core lmgr mapdisp modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Oct 13 04:15:38 PDT 2012


Author: martinl
Date: 2012-10-13 04:15:38 -0700 (Sat, 13 Oct 2012)
New Revision: 53383

Modified:
   grass/branches/develbranch_6/gui/wxpython/core/workspace.py
   grass/branches/develbranch_6/gui/wxpython/dbmgr/manager.py
   grass/branches/develbranch_6/gui/wxpython/gcp/manager.py
   grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py
   grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py
   grass/branches/develbranch_6/gui/wxpython/gui_core/prompt.py
   grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py
   grass/branches/develbranch_6/gui/wxpython/lmgr/layertree.py
   grass/branches/develbranch_6/gui/wxpython/mapdisp/frame.py
   grass/branches/develbranch_6/gui/wxpython/modules/colorrules.py
Log:
wxGUI: internal variables clean up - use methods to access them
       fix loading workspace (resize map display)
       (merge r53382 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/core/workspace.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/workspace.py	2012-10-13 11:06:28 UTC (rev 53382)
+++ grass/branches/develbranch_6/gui/wxpython/core/workspace.py	2012-10-13 11:15:38 UTC (rev 53383)
@@ -553,10 +553,11 @@
         file.write('%s</layer_manager>\n' % (' ' * self.indent))
         
         # list of displays
-        for page in range(0, self.lmgr.gm_cb.GetPageCount()):
-            dispName = self.lmgr.gm_cb.GetPageText(page)
-            mapTree = self.lmgr.gm_cb.GetPage(page).maptree
-            region = mapTree.Map.region
+        for page in range(0, self.lmgr.GetLayerNotebook().GetPageCount()):
+            dispName = self.lmgr.GetLayerNotebook().GetPageText(page)
+            mapTree = self.lmgr.GetLayerNotebook().GetPage(page).maptree
+            region = mapTree.GetMap().GetCurrentRegion()
+            mapdisp = mapTree.GetMapDisplay()
             
             displayPos = mapTree.mapdisplay.GetPosition()
             displaySize = mapTree.mapdisplay.GetSize()

Modified: grass/branches/develbranch_6/gui/wxpython/dbmgr/manager.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/dbmgr/manager.py	2012-10-13 11:06:28 UTC (rev 53382)
+++ grass/branches/develbranch_6/gui/wxpython/dbmgr/manager.py	2012-10-13 11:15:38 UTC (rev 53383)
@@ -551,7 +551,7 @@
         self.treeItem   = item   # item in layer tree
         if self.parent and self.parent.GetName() == "LayerManager" and \
                 self.treeItem and not self.vectorName:
-            maptree = self.parent.curr_page.maptree
+            maptree = self.parent.GetLayerTree()
             name = maptree.GetPyData(self.treeItem)[0]['maplayer'].GetName()
             self.vectorName = name
         

Modified: grass/branches/develbranch_6/gui/wxpython/gcp/manager.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gcp/manager.py	2012-10-13 11:06:28 UTC (rev 53382)
+++ grass/branches/develbranch_6/gui/wxpython/gcp/manager.py	2012-10-13 11:15:38 UTC (rev 53383)
@@ -1194,8 +1194,7 @@
 
         sourceMapWin = self.SrcMapWindow
         targetMapWin = self.TgtMapWindow
-        #targetMapWin = self.parent.curr_page.maptree.mapdisplay.MapWindow
-
+        
         if not sourceMapWin:
             GError(parent = self,
                    message = "%s. %s%s" % (_("source mapwin not defined"),

Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py	2012-10-13 11:06:28 UTC (rev 53382)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py	2012-10-13 11:15:38 UTC (rev 53383)
@@ -1621,7 +1621,7 @@
             return
         
         self.commandId += 1
-        maptree = self.parent.curr_page.maptree
+        maptree = self.parent.GetLayerTree()
         
         layer, output = self.list.GetLayers()[self.commandId]
         

Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py	2012-10-13 11:06:28 UTC (rev 53382)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py	2012-10-13 11:15:38 UTC (rev 53383)
@@ -229,9 +229,10 @@
             size = self.parent.GetSize()
             dim = '%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
             # opened displays
-            for page in range(0, self.parent.gm_cb.GetPageCount()):
-                pos = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetPosition()
-                size = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetSize()
+            for page in range(0, self.parent.GetLayerNotebook().GetPageCount()):
+                mapdisp = self.parent.GetLayerNotebook().GetPage(page).maptree.GetMapDisplay()
+                pos  = mapdisp.GetPosition()
+                size = mapdisp.GetSize()
 
                 dim += ',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
 

Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/prompt.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/prompt.py	2012-10-13 11:06:28 UTC (rev 53382)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/prompt.py	2012-10-13 11:15:38 UTC (rev 53383)
@@ -604,7 +604,7 @@
         if not cmdString or self.standAlone:
             return
         
-        if cmdString[:2] == 'd.' and not self.parent.parent.curr_page:
+        if cmdString[:2] == 'd.' and not self.parent.parent.GetMapDisplay():
             self.parent.parent.NewDisplay(show = True)
                 
         self.commands.append(cmdString) # trace commands

Modified: grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py	2012-10-13 11:06:28 UTC (rev 53382)
+++ grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py	2012-10-13 11:15:38 UTC (rev 53383)
@@ -90,9 +90,9 @@
         self._auimgr = wx.aui.AuiManager(self)
 
         # initialize variables
-        self.disp_idx      = 0            # index value for map displays and layer trees
-        self.curr_page     = None         # currently selected page for layer tree notebook
-        self.curr_pagenum  = None         # currently selected page number for layer tree notebook
+        self.displayIndex      = 0            # index value for map displays and layer trees
+        self.currentPage     = None         # currently selected page for layer tree notebook
+        self.currentPageNum  = None         # currently selected page number for layer tree notebook
         self.workspaceFile = workspace    # workspace file
         self.workspaceChanged = False     # track changes in workspace
         self.georectifying = None         # reference to GCP class or None
@@ -196,10 +196,10 @@
 
         # show map display widnow
         # -> OnSize() -> UpdateMap()
-        if self.curr_page and not self.curr_page.maptree.mapdisplay.IsShown():
-            self.curr_page.maptree.mapdisplay.Show()
+        for mapdisp in self.GetMapDisplay(onlyCurrent = False):
+            mapdisp.Show()
         
-        # redirect stderr to log area    
+        # redirect stderr to log area
         self.goutput.Redirect()
         
         # fix goutput's pane size (required for Mac OSX)`
@@ -208,8 +208,8 @@
         self.workspaceChanged = False
         
         # start with layer manager on top
-        if self.curr_page:
-            self.curr_page.maptree.mapdisplay.Raise()
+        if self.currentPage:
+            self.GetMapDisplay().Raise()
         wx.CallAfter(self.Raise)
         
     def _createMenuBar(self):
@@ -246,13 +246,13 @@
         # create displays notebook widget and add it to main notebook page
         cbStyle = globalvar.FNPageStyle
         if globalvar.hasAgw:
-            self.gm_cb = FN.FlatNotebook(self, id = wx.ID_ANY, agwStyle = cbStyle)
+            self.notebookLayers = FN.FlatNotebook(self, id = wx.ID_ANY, agwStyle = cbStyle)
         else:
-            self.gm_cb = FN.FlatNotebook(self, id = wx.ID_ANY, style = cbStyle)
-        self.gm_cb.SetTabAreaColour(globalvar.FNPageColor)
+            self.notebookLayers = FN.FlatNotebook(self, id = wx.ID_ANY, style = cbStyle)
+        self.notebookLayers.SetTabAreaColour(globalvar.FNPageColor)
         menu = self._createTabMenu()
-        self.gm_cb.SetRightClickMenu(menu)
-        self.notebook.AddPage(page = self.gm_cb, text = _("Map layers"), name = 'layers')
+        self.notebookLayers.SetRightClickMenu(menu)
+        self.notebook.AddPage(page = self.notebookLayers, text = _("Map layers"), name = 'layers')
         
         # create 'command output' text area
         self.goutput = GMConsole(self)
@@ -274,9 +274,9 @@
             self.pyshell = None
         
         # bindings
-        self.gm_cb.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED,    self.OnCBPageChanged)
+        self.notebookLayers.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED,    self.OnCBPageChanged)
         self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
-        self.gm_cb.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING,    self.OnCBPageClosed)
+        self.notebookLayers.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING,    self.OnCBPageClosed)
         
         return self.notebook
             
@@ -297,7 +297,7 @@
         
         # create nviz tools tab
         self.nviz = NvizToolWindow(parent = self,
-                                   display = self.curr_page.maptree.GetMapDisplay())
+                                   display = self.GetMapDisplay())
         idx = self.notebook.GetPageIndexByName('layers')
         self.notebook.InsertPage(indx = idx + 1, page = self.nviz, text = _("3D view"), name = 'nviz')
         self.notebook.SetSelectionByName('nviz')
@@ -437,11 +437,11 @@
             
     def OnCBPageChanged(self, event):
         """!Page in notebook (display) changed"""
-        self.curr_page   = self.gm_cb.GetCurrentPage()
-        self.curr_pagenum = self.gm_cb.GetSelection()
+        self.currentPage    = self.notebookLayers.GetCurrentPage()
+        self.currentPageNum = self.notebookLayers.GetSelection()
         try:
-            self.curr_page.maptree.mapdisplay.SetFocus()
-            self.curr_page.maptree.mapdisplay.Raise()
+            self.GetMapDisplay().SetFocus()
+            self.GetMapDisplay().Raise()
         except:
             pass
         
@@ -463,7 +463,7 @@
         Also close associated map display
         """
         if UserSettings.Get(group = 'manager', key = 'askOnQuit', subkey = 'enabled'):
-            maptree = self.curr_page.maptree
+            maptree = self.GetLayerTree()
             
             if self.workspaceFile:
                 message = _("Do you want to save changes in the workspace?")
@@ -473,7 +473,7 @@
             
             # ask user to save current settings
             if maptree.GetCount() > 0:
-                name = self.gm_cb.GetPageText(self.curr_pagenum)
+                name = self.notebookLayers.GetPageText(self.currentPageNum)
                 dlg = wx.MessageDialog(self,
                                        message = message,
                                        caption = _("Close Map Display %s") % name,
@@ -491,19 +491,50 @@
                     return
                 dlg.Destroy()
 
-        self.gm_cb.GetPage(event.GetSelection()).maptree.Map.Clean()
-        self.gm_cb.GetPage(event.GetSelection()).maptree.Close(True)
+        self.notebookLayers.GetPage(event.GetSelection()).maptree.Map.Clean()
+        self.notebookLayers.GetPage(event.GetSelection()).maptree.Close(True)
 
-        self.curr_page = None
+        self.currentPage = None
 
         event.Skip()
 
+    def GetLayerNotebook(self):
+        """!Get Layers Notebook"""
+        return self.notebookLayers
+    
     def GetLayerTree(self):
-        """!Get current layer tree"""
-        if self.curr_page:
-            return self.curr_page.maptree
+        """!Get current layer tree
+
+        @return LayerTree instance
+        @return None no layer tree selected
+        """
+        if self.currentPage:
+            return self.currentPage.maptree
         return None
     
+    def GetMapDisplay(self, onlyCurrent = True):
+        """!Get current map display
+
+        @param onlyCurrent True to return only active mapdisplay
+                           False for list of all mapdisplays
+
+        @return MapFrame instance (or list)
+        @return None no mapdisplay selected
+        """
+        if onlyCurrent:
+            if self.currentPage:
+                return self.GetLayerTree().GetMapDisplay()
+            else:
+                return None
+        else: # -> return list of all mapdisplays
+            mlist = list()
+            for idx in range(0, self.notebookLayers.GetPageCount()):
+                mlist.append(self.notebookLayers.GetPage(idx).maptree.GetMapDisplay())
+            
+            return mlist
+        
+        return None
+    
     def GetLogWindow(self):
         """!Get widget for command output"""
         return self.goutput
@@ -528,9 +559,9 @@
             return cmdlist
 
         try:
-            layer = self.curr_page.maptree.layer_selected
-            name = self.curr_page.maptree.GetPyData(layer)[0]['maplayer'].name
-            type = self.curr_page.maptree.GetPyData(layer)[0]['type']
+            layer = self.GetLayerTree().layer_selected
+            name = self.GetLayerTree().GetPyData(layer)[0]['maplayer'].name
+            type = self.GetLayerTree().GetPyData(layer)[0]['type']
         except:
             layer = None
 
@@ -558,7 +589,7 @@
     def OnVDigit(self, event):
         """!Start vector digitizer
         """
-        if not self.curr_page:
+        if not self.currentPage:
             self.MsgNoLayerSelected()
             return
         
@@ -732,7 +763,7 @@
         name = dlg.GetName(full = True)
         if name and dlg.IsChecked('add'):
             # add layer to map layer tree
-            self.curr_page.maptree.AddLayer(ltype = 'vector',
+            self.GetLayerTree().AddLayer(ltype = 'vector',
                                             lname = name,
                                             lcmd = ['d.vect', 'map=%s' % name])
         dlg.Destroy()
@@ -801,10 +832,10 @@
         Debug.msg(4, "GMFrame.OnWorkspaceNew():")
         
         # start new map display if no display is available
-        if not self.curr_page:
+        if not self.currentPage:
             self.NewDisplay()
         
-        maptree = self.curr_page.maptree
+        maptree = self.GetLayerTree()
         
         # ask user to save current settings
         if self.workspaceFile and self.workspaceChanged:
@@ -830,7 +861,7 @@
         
         # add new root element
         maptree.root = maptree.AddRoot("Map Layers")
-        self.curr_page.maptree.SetPyData(maptree.root, (None,None))
+        self.GetLayerTree().SetPyData(maptree.root, (None,None))
         
         # no workspace file loaded
         self.workspaceFile = None
@@ -901,7 +932,7 @@
         for display in gxwXml.displays:
             mapdisp = self.NewDisplay(name = display['name'], show = False)
             mapdisplay.append(mapdisp)
-            maptree = self.gm_cb.GetPage(displayId).maptree
+            maptree = self.notebookLayers.GetPage(displayId).maptree
             
             # set windows properties
             mapdisp.SetProperties(render = display['render'],
@@ -935,8 +966,6 @@
                                                 region['s'],
                                                 region['e'],
                                                 region['w'])
-                
-            mapdisp.Show()
             
             displayId += 1
     
@@ -947,7 +976,7 @@
         #
         for layer in gxwXml.layers:
             display = layer['display']
-            maptree = self.gm_cb.GetPage(display).maptree
+            maptree = self.notebookLayers.GetPage(display).maptree
             
             newItem = maptree.AddLayer(ltype = layer['type'],
                                        lname = layer['name'],
@@ -1005,7 +1034,7 @@
         Debug.msg(4, "GMFrame.OnWorkspaceLoadGrcFile(): filename=%s" % filename)
 
         # start new map display if no display is available
-        if not self.curr_page:
+        if not self.currentPage:
             self.NewDisplay()
 
         busy = wx.BusyInfo(message = _("Please wait, loading workspace..."),
@@ -1014,7 +1043,7 @@
 
         maptree = None
         for layer in ProcessGrcFile(filename).read(self):
-            maptree = self.gm_cb.GetPage(layer['display']).maptree
+            maptree = self.notebookLayers.GetPage(layer['display']).maptree
             newItem = maptree.AddLayer(ltype = layer['type'],
                                        lname = layer['name'],
                                        lchecked = layer['checked'],
@@ -1114,34 +1143,34 @@
         self.workspaceFile = None
         self.workspaceChanged = False
         self.SetTitle(self.baseTitle)
-        self.disp_idx = 0
-        self.curr_page = None
+        self.displayIndex = 0
+        self.currentPage = None
         
     def OnDisplayClose(self, event = None):
         """!Close current map display window
         """
-        if self.curr_page and self.curr_page.maptree.mapdisplay:
-            self.curr_page.maptree.mapdisplay.OnCloseWindow(event)
+        if self.currentPage and self.GetMapDisplay():
+            self.GetMapDisplay().OnCloseWindow(event)
         
     def OnDisplayCloseAll(self, event = None):
         """!Close all open map display windows
         """
         displays = list()
-        for page in range(0, self.gm_cb.GetPageCount()):
-            displays.append(self.gm_cb.GetPage(page).maptree.mapdisplay)
+        for page in range(0, self.notebookLayers.GetPageCount()):
+            displays.append(self.notebookLayers.GetPage(page).maptree.GetMapDisplay())
         
         for display in displays:
             display.OnCloseWindow(event)
         
     def OnRenameDisplay(self, event):
         """!Change Map Display name"""
-        name = self.gm_cb.GetPageText(self.curr_pagenum)
+        name = self.notebookLayers.GetPageText(self.currentPageNum)
         dlg = wx.TextEntryDialog(self, message = _("Enter new name:"),
                                  caption = _("Rename Map Display"), defaultValue = name)
         if dlg.ShowModal() == wx.ID_OK:
             name = dlg.GetValue()
-            self.gm_cb.SetPageText(page = self.curr_pagenum, text = name)
-            mapdisplay = self.curr_page.maptree.mapdisplay
+            self.notebookLayers.SetPageText(page = self.currentPageNum, text = name)
+            mapdisplay = self.GetMapDisplay()
             mapdisplay.SetTitle(_("GRASS GIS Map Display: %(name)s  - Location: %(loc)s") % \
                                      { 'name' : name,
                                        'loc' : grass.gisenv()["LOCATION_NAME"] })
@@ -1349,7 +1378,7 @@
                         cmd.append('styles=%s' % styles)
                     self.goutput.RunCmd(cmd, switchPage = True)
 
-                    self.curr_page.maptree.AddLayer(ltype = 'raster',
+                    self.GetLayerTree().AddLayer(ltype = 'raster',
                                                     lname = layer,
                                                     lcmd = ['d.rast', 'map=%s' % layer],
                                                     multiple = False)
@@ -1362,7 +1391,7 @@
     def OnShowAttributeTable(self, event, selection = None):
         """!Show attribute table of the given vector map layer
         """
-        if not self.curr_page:
+        if not self.currentPage:
             self.MsgNoLayerSelected()
             return
         
@@ -1424,48 +1453,48 @@
 
         @return reference to mapdisplay intance
         """
-        Debug.msg(1, "GMFrame.NewDisplay(): idx=%d" % self.disp_idx)
+        Debug.msg(1, "GMFrame.NewDisplay(): idx=%d" % self.displayIndex)
         
         # make a new page in the bookcontrol for the layer tree (on page 0 of the notebook)
-        self.pg_panel = wx.Panel(self.gm_cb, id = wx.ID_ANY, style = wx.EXPAND)
+        self.pg_panel = wx.Panel(self.notebookLayers, id = wx.ID_ANY, style = wx.EXPAND)
         if name:
             dispName = name
         else:
-            dispName = "Display " + str(self.disp_idx + 1)
-        self.gm_cb.AddPage(self.pg_panel, text = dispName, select = True)
-        self.curr_page = self.gm_cb.GetCurrentPage()
+            dispName = "Display " + str(self.displayIndex + 1)
+        self.notebookLayers.AddPage(self.pg_panel, text = dispName, select = True)
+        self.currentPage = self.notebookLayers.GetCurrentPage()
         
         # create layer tree (tree control for managing GIS layers)  and put on new notebook page
-        self.curr_page.maptree = LayerTree(self.curr_page, id = wx.ID_ANY, pos = wx.DefaultPosition,
-                                           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, lmgr = self, notebook = self.gm_cb,
-                                           auimgr = self._auimgr, showMapDisplay = show)
+        self.currentPage.maptree = LayerTree(self.currentPage, id = wx.ID_ANY, pos = wx.DefaultPosition,
+                                             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.displayIndex, lmgr = self, notebook = self.notebookLayers,
+                                             auimgr = self._auimgr, showMapDisplay = show)
         
         # layout for controls
         cb_boxsizer = wx.BoxSizer(wx.VERTICAL)
-        cb_boxsizer.Add(self.curr_page.maptree, proportion = 1, flag = wx.EXPAND, border = 1)
-        self.curr_page.SetSizer(cb_boxsizer)
-        cb_boxsizer.Fit(self.curr_page.maptree)
-        self.curr_page.Layout()
-        self.curr_page.maptree.Layout()
+        cb_boxsizer.Add(self.GetLayerTree(), proportion = 1, flag = wx.EXPAND, border = 1)
+        self.currentPage.SetSizer(cb_boxsizer)
+        cb_boxsizer.Fit(self.GetLayerTree())
+        self.currentPage.Layout()
+        self.GetLayerTree().Layout()
         
         # use default window layout
         if UserSettings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled'):
             dim = UserSettings.Get(group = 'general', key = 'defWindowPos', subkey = 'dim')
-            idx = 4 + self.disp_idx * 4
+            idx = 4 + self.displayIndex * 4
             try:
                 x, y = map(int, dim.split(',')[idx:idx + 2])
                 w, h = map(int, dim.split(',')[idx + 2:idx + 4])
-                self.curr_page.maptree.mapdisplay.SetPosition((x, y))
-                self.curr_page.maptree.mapdisplay.SetSize((w, h))
+                self.GetMapDisplay().SetPosition((x, y))
+                self.GetMapDisplay().SetSize((w, h))
             except:
                 pass
         
-        self.disp_idx += 1
+        self.displayIndex += 1
         
-        return self.curr_page.maptree.mapdisplay
+        return self.GetMapDisplay()
     
     def OnAddMaps(self, event = None):
         """!Add selected map layers into layer tree"""
@@ -1476,10 +1505,10 @@
             return
         
         # start new map display if no display is available
-        if not self.curr_page:
+        if not self.currentPage:
             self.NewDisplay()
             
-        maptree = self.curr_page.maptree
+        maptree = self.GetLayerTree()
         
         for layerName in dialog.GetMapLayers():
             ltype = dialog.GetLayerType(cmd = True)
@@ -1508,16 +1537,16 @@
     def OnAddRaster(self, event):
         """!Add raster map layer"""
         # start new map display if no display is available
-        if not self.curr_page:
+        if not self.currentPage:
             self.NewDisplay(show = True)
         
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('raster')
+        self.GetLayerTree().AddLayer('raster')
         
     def OnAddRasterMisc(self, event):
         """!Create misc raster popup-menu"""
         # start new map display if no display is available
-        if not self.curr_page:
+        if not self.currentPage:
             self.NewDisplay(show = True)
         
         self._popupMenu((('addRast3d', self.OnAddRaster3D),
@@ -1531,43 +1560,43 @@
                          ('addRNum',   self.OnAddRasterNum)))
         
         # show map display
-        self.curr_page.maptree.mapdisplay.Show()
+        self.GetMapDisplay().Show()
         
     def OnAddVector(self, event):
         """!Add vector map to the current layer tree"""
         # start new map display if no display is available
-        if not self.curr_page:
+        if not self.currentPage:
             self.NewDisplay(show = True)
         
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('vector')
+        self.GetLayerTree().AddLayer('vector')
 
     def OnAddVectorMisc(self, event):
         """!Create misc vector popup-menu"""
         # start new map display if no display is available
-        if not self.curr_page:
+        if not self.currentPage:
             self.NewDisplay(show = True)
 
         self._popupMenu((('addThematic', self.OnAddVectorTheme),
                          ('addChart',    self.OnAddVectorChart)))
         
         # show map display
-        self.curr_page.maptree.mapdisplay.Show()
+        self.GetMapDisplay().Show()
 
     def OnAddVectorTheme(self, event):
         """!Add thematic vector map to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('thememap')
+        self.GetLayerTree().AddLayer('thememap')
 
     def OnAddVectorChart(self, event):
         """!Add chart vector map to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('themechart')
+        self.GetLayerTree().AddLayer('themechart')
 
     def OnAddOverlay(self, event):
         """!Create decoration overlay menu""" 
         # start new map display if no display is available
-        if not self.curr_page:
+        if not self.currentPage:
             self.NewDisplay(show = True)
 
         self._popupMenu((('addGrid',     self.OnAddGrid),
@@ -1578,32 +1607,32 @@
                          ('addCmd',      self.OnAddCommand)))
         
         # show map display
-        self.curr_page.maptree.mapdisplay.Show()
+        self.GetMapDisplay().Show()
         
     def OnAddRaster3D(self, event):
         """!Add 3D raster map to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('3d-raster')
+        self.GetLayerTree().AddLayer('3d-raster')
 
     def OnAddRasterRGB(self, event):
         """!Add RGB raster map to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('rgb')
+        self.GetLayerTree().AddLayer('rgb')
 
     def OnAddRasterHIS(self, event):
         """!Add HIS raster map to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('his')
+        self.GetLayerTree().AddLayer('his')
 
     def OnAddRasterShaded(self, event):
         """!Add shaded relief raster map to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('shaded')
+        self.GetLayerTree().AddLayer('shaded')
 
     def OnAddRasterArrow(self, event):
         """!Add flow arrows raster map to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
-        tree = self.curr_page.maptree
+        tree = self.GetLayerTree()
         resolution = tree.GetMapDisplay().GetProperty('resolution')
         if not resolution:
             dlg = self.MsgDisplayResolution()
@@ -1611,12 +1640,12 @@
                 tree.GetMapDisplay().SetProperty('resolution', True)
             dlg.Destroy()
 
-        self.curr_page.maptree.AddLayer('rastarrow')
+        self.GetLayerTree().AddLayer('rastarrow')
 
     def OnAddRasterNum(self, event):
         """!Add cell number raster map to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
-        tree = self.curr_page.maptree
+        tree = self.GetLayerTree()
         resolution = tree.GetMapDisplay().GetProperty('resolution')
         if not resolution:
             limitText = _("Note that cell values can only be displayed for "
@@ -1629,70 +1658,70 @@
         # region = tree.GetMap().GetCurrentRegion()
         # if region['cells'] > 10000:
         #   GMessage(message = "Cell values can only be displayed for regions of < 10,000 cells.", parent = self)
-        self.curr_page.maptree.AddLayer('rastnum')
+        self.GetLayerTree().AddLayer('rastnum')
 
     def OnAddCommand(self, event):
         """!Add command line map layer to the current layer tree"""
         # start new map display if no display is available
-        if not self.curr_page:
+        if not self.currentPage:
             self.NewDisplay(show = True)
 
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('command')
+        self.GetLayerTree().AddLayer('command')
 
         # show map display
-        self.curr_page.maptree.mapdisplay.Show()
+        self.GetMapDisplay().Show()
 
     def OnAddGroup(self, event):
         """!Add layer group"""
         # start new map display if no display is available
-        if not self.curr_page:
+        if not self.currentPage:
             self.NewDisplay(show = True)
 
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('group')
+        self.GetLayerTree().AddLayer('group')
 
         # show map display
-        self.curr_page.maptree.mapdisplay.Show()
+        self.GetMapDisplay().Show()
 
     def OnAddGrid(self, event):
         """!Add grid map layer to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('grid')
+        self.GetLayerTree().AddLayer('grid')
 
     def OnAddGeodesic(self, event):
         """!Add geodesic line map layer to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('geodesic')
+        self.GetLayerTree().AddLayer('geodesic')
 
     def OnAddRhumb(self, event):
         """!Add rhumb map layer to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('rhumb')
+        self.GetLayerTree().AddLayer('rhumb')
 
     def OnAddLabels(self, event):
         """!Add vector labels map layer to the current layer tree"""
         # start new map display if no display is available
-        if not self.curr_page:
+        if not self.currentPage:
             self.NewDisplay(show = True)
 
         self.notebook.SetSelectionByName('layers')
-        self.curr_page.maptree.AddLayer('labels')
+        self.GetLayerTree().AddLayer('labels')
 
         # show map display
-        self.curr_page.maptree.mapdisplay.Show()
+        self.GetMapDisplay().Show()
 
     def OnDeleteLayer(self, event):
         """!Remove selected map layer from the current layer Tree
         """
-        if not self.curr_page or not self.curr_page.maptree.layer_selected:
+        if not self.currentPage or not self.GetLayerTree().layer_selected:
             self.MsgNoLayerSelected()
             return
 
         if UserSettings.Get(group = 'manager', key = 'askOnRemoveLayer', subkey = 'enabled'):
             layerName = ''
-            for item in self.curr_page.maptree.GetSelections():
-                name = str(self.curr_page.maptree.GetItemText(item))
+            for item in self.GetLayerTree().GetSelections():
+                name = str(self.GetLayerTree().GetItemText(item))
                 idx = name.find('(opacity')
                 if idx > -1:
                     layerName += '<' + name[:idx].strip(' ') + '>,\n'
@@ -1717,10 +1746,10 @@
             
             dlg.Destroy()
 
-        for layer in self.curr_page.maptree.GetSelections():
-            if self.curr_page.maptree.GetPyData(layer)[0]['type'] == 'group':
-                self.curr_page.maptree.DeleteChildren(layer)
-            self.curr_page.maptree.Delete(layer)
+        for layer in self.GetLayerTree().GetSelections():
+            if self.GetLayerTree().GetPyData(layer)[0]['type'] == 'group':
+                self.GetLayerTree().DeleteChildren(layer)
+            self.GetLayerTree().Delete(layer)
         
     def OnKeyDown(self, event):
         """!Key pressed"""
@@ -1754,13 +1783,13 @@
         if self.goutput.btnCmdProtocol.GetValue():
             self.goutput.CmdProtocolSave()
         
-        if not self.curr_page:
+        if not self.currentPage:
             self._auimgr.UnInit()
             self.Destroy()
             return
         
         # save changes in the workspace
-        maptree = self.curr_page.maptree
+        maptree = self.GetLayerTree()
         if self.workspaceChanged and \
                 UserSettings.Get(group = 'manager', key = 'askOnQuit', subkey = 'enabled'):
             if self.workspaceFile:
@@ -1796,7 +1825,7 @@
         
         self.OnDisplayCloseAll()
         
-        self.gm_cb.DeleteAllPages()
+        self.notebookLayers.DeleteAllPages()
         
         self._auimgr.UnInit()
         self.Destroy()

Modified: grass/branches/develbranch_6/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/lmgr/layertree.py	2012-10-13 11:06:28 UTC (rev 53382)
+++ grass/branches/develbranch_6/gui/wxpython/lmgr/layertree.py	2012-10-13 11:15:38 UTC (rev 53383)
@@ -103,7 +103,7 @@
         if 'style' in kwargs:
             ctstyle |= kwargs['style']
             del kwargs['style']
-        self.disp_idx = kwargs['idx']
+        self.displayIndex = kwargs['idx']
         del kwargs['idx']
         self.lmgr = kwargs['lmgr']
         del kwargs['lmgr']
@@ -146,7 +146,7 @@
         self._setGradient()
         
         # init associated map display
-        pos = wx.Point((self.disp_idx + 1) * 25, (self.disp_idx + 1) * 25)
+        pos = wx.Point((self.displayIndex + 1) * 25, (self.displayIndex + 1) * 25)
         self.mapdisplay = MapFrame(self,
                                    id = wx.ID_ANY, pos = pos,
                                    size = globalvar.MAP_WINDOW_SIZE,
@@ -157,7 +157,7 @@
         
         # title
         self.mapdisplay.SetTitle(_("GRASS GIS Map Display: %(id)d  - Location: %(loc)s") % \
-                                     { 'id' : self.disp_idx + 1,
+                                     { 'id' : self.displayIndex + 1,
                                        'loc' : grass.gisenv()["LOCATION_NAME"] })
         
         # show new display

Modified: grass/branches/develbranch_6/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/mapdisp/frame.py	2012-10-13 11:06:28 UTC (rev 53382)
+++ grass/branches/develbranch_6/gui/wxpython/mapdisp/frame.py	2012-10-13 11:15:38 UTC (rev 53383)
@@ -265,10 +265,11 @@
             return
         
         # disable 3D mode for other displays
-        for page in range(0, self._layerManager.gm_cb.GetPageCount()):
-            if self._layerManager.gm_cb.GetPage(page) != self._layerManager.curr_page:
-                if '3D' in self._layerManager.gm_cb.GetPage(page).maptree.mapdisplay.toolbars['map'].combo.GetString(1):
-                    self._layerManager.gm_cb.GetPage(page).maptree.mapdisplay.toolbars['map'].combo.Delete(1)
+        for page in range(0, self._layerManager.GetLayerNotebook().GetPageCount()):
+            mapdisp = self._layerManager.GetLayerNotebook().GetPage(page).maptree.GetMapDisplay()
+            if self._layerManager.GetLayerNotebook().GetPage(page) != self._layerManager.currentPage:
+                if '3D' in mapdisp.toolbars['map'].combo.GetString(1):
+                    mapdisp.toolbars['map'].combo.Delete(1)
         self.toolbars['map'].Enable2D(False)
         # add rotate tool to map toolbar
         self.toolbars['map'].InsertTool((('rotate', NvizIcons['rotate'],
@@ -335,8 +336,12 @@
     
     def RemoveNviz(self):
         """!Restore 2D view"""
-        self.toolbars['map'].RemoveTool(self.toolbars['map'].rotate)
-        self.toolbars['map'].RemoveTool(self.toolbars['map'].flyThrough)
+        try:
+            self.toolbars['map'].RemoveTool(self.toolbars['map'].rotate)
+            self.toolbars['map'].RemoveTool(self.toolbars['map'].flyThrough)
+        except AttributeError:
+            pass
+        
         # update status bar
         self.statusbarManager.ShowStatusbarChoiceItemsByClass(self.statusbarItemsHiddenInNviz)
         self.statusbarManager.SetMode(UserSettings.Get(group = 'display',
@@ -345,7 +350,8 @@
         self.SetStatusText(_("Please wait, unloading data..."), 0)
         self._layerManager.goutput.WriteCmdLog(_("Switching back to 2D view mode..."),
                                                switchPage = False)
-        self.MapWindow3D.OnClose(event = None)
+        if self.MapWindow3D:
+            self.MapWindow3D.OnClose(event = None)
         # switch from MapWindowGL to MapWindow
         self._mgr.GetPane('2d').Show()
         self._mgr.GetPane('3d').Hide()
@@ -353,9 +359,11 @@
         self.MapWindow = self.MapWindow2D
         # remove nviz notebook page
         self._layerManager.RemoveNvizTools()
-        
-        self.MapWindow2D.overlays = self.MapWindow3D.overlays
-        self.MapWindow2D.textdict = self.MapWindow3D.textdict
+        try:
+            self.MapWindow2D.overlays = self.MapWindow3D.overlays
+            self.MapWindow2D.textdict = self.MapWindow3D.textdict
+        except AttributeError:
+            pass
         self.MapWindow.UpdateMap()
         self._mgr.Update()
         
@@ -430,7 +438,7 @@
             pgnum = self.layerbook.GetPageIndex(self.page)
             if pgnum > -1:
                 self.layerbook.SetSelection(pgnum)
-                self._layerManager.curr_page = self.layerbook.GetCurrentPage()
+                self._layerManager.currentPage = self.layerbook.GetCurrentPage()
         
         event.Skip()
         

Modified: grass/branches/develbranch_6/gui/wxpython/modules/colorrules.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/modules/colorrules.py	2012-10-13 11:06:28 UTC (rev 53382)
+++ grass/branches/develbranch_6/gui/wxpython/modules/colorrules.py	2012-10-13 11:15:38 UTC (rev 53383)
@@ -348,15 +348,15 @@
         # set map layer from layer tree, first selected,
         # if not the right type, than select another
         try:
-            sel = self.parent.curr_page.maptree.layer_selected
-            if sel and self.parent.curr_page.maptree.GetPyData(sel)[0]['type'] == self.mapType:
+            sel = self.parent.GetLayerTree().layer_selected
+            if sel and self.parent.GetLayerTree().GetPyData(sel)[0]['type'] == self.mapType:
                 layer = sel
             else:
-                layer = self.parent.curr_page.maptree.FindItemByData(key = 'type', value = self.mapType)
+                layer = self.parent.GetLayerTree().FindItemByData(key = 'type', value = self.mapType)
         except:
             layer = None
         if layer:
-            mapLayer = self.parent.curr_page.maptree.GetPyData(layer)[0]['maplayer']
+            mapLayer = self.parent.GetLayerTree().GetPyData(layer)[0]['maplayer']
             name = mapLayer.GetName()
             type = mapLayer.GetType()
             self.selectionInput.SetValue(name)
@@ -1541,13 +1541,13 @@
         
     def UseAttrColumn(self, useAttrColumn):
         """!Find layers and apply the changes in d.vect command"""
-        layers = self.parent.curr_page.maptree.FindItemByData(key = 'name', value = self.inmap)
+        layers = self.parent.GetLayerTree().FindItemByData(key = 'name', value = self.inmap)
         if not layers:
             return
         for layer in layers:
-            if self.parent.curr_page.maptree.GetPyData(layer)[0]['type'] != 'vector':
+            if self.parent.GetLayerTree().GetPyData(layer)[0]['type'] != 'vector':
                 continue
-            cmdlist = self.parent.curr_page.maptree.GetPyData(layer)[0]['maplayer'].GetCmd()
+            cmdlist = self.parent.GetLayerTree().GetPyData(layer)[0]['maplayer'].GetCmd()
             
             if self.attributeType == 'color':
                 if useAttrColumn:
@@ -1561,7 +1561,7 @@
                 cmdlist[1].update({'size_column': self.properties['storeColumn']})
             elif self.attributeType == 'width':
                 cmdlist[1].update({'width_column' :self.properties['storeColumn']})
-            self.parent.curr_page.maptree.GetPyData(layer)[0]['cmd'] = cmdlist
+            self.parent.GetLayerTree().GetPyData(layer)[0]['cmd'] = cmdlist
         
     def CreateColorTable(self, tmp = False):
         """!Create color rules (color table or color column)"""
@@ -1772,7 +1772,7 @@
         if self.render:
             # extent is taken from current map display
             try:
-                self.Map.region = copy.deepcopy(self.parent.parent.curr_page.maptree.Map.region)
+                self.Map.region = copy.deepcopy(self.parent.parent.GetLayerTree().GetMap().GetCurrentRegion())
             except AttributeError:
                 self.Map.region = self.Map.GetRegion()
             # render new map images



More information about the grass-commit mailing list