[GRASS-SVN] r58938 - in grass/trunk/gui/wxpython: gui_core lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Feb 7 09:38:34 PST 2014


Author: martinl
Date: 2014-02-07 09:38:34 -0800 (Fri, 07 Feb 2014)
New Revision: 58938

Modified:
   grass/trunk/gui/wxpython/gui_core/dialogs.py
   grass/trunk/gui/wxpython/lmgr/layertree.py
Log:
wxGUI/lmgr: simplify checking first layer


Modified: grass/trunk/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/dialogs.py	2014-02-07 15:34:54 UTC (rev 58937)
+++ grass/trunk/gui/wxpython/gui_core/dialogs.py	2014-02-07 17:38:34 UTC (rev 58938)
@@ -473,10 +473,10 @@
     # return fully qualified map name
     if '@' not in outmap:
         outmap += '@' + grass.gisenv()['MAPSET']
+    
+    # if giface:
+    #     giface.WriteLog(_("New vector map <%s> created") % outmap)
         
-    if giface:
-        giface.WriteLog(_("New vector map <%s> created") % outmap)
-        
     return dlg
 
 class SavedRegion(wx.Dialog):

Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py	2014-02-07 15:34:54 UTC (rev 58937)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py	2014-02-07 17:38:34 UTC (rev 58938)
@@ -131,7 +131,6 @@
         self.optpage = {}                    # dictionary of notebook option pages for each map layer
         self.saveitem = {}                   # dictionary to preserve layer attributes for drag and drop
         self.first = True                    # indicates if a layer is just added or not
-        self.firstNewLayer = True            # indicates if first layer has been newly added to the layer tree
         self.flag = ''                       # flag for drag and drop hittest
         # layer change requires a rerendering
         # (used to request rendering only when layer changes are finished)
@@ -1042,8 +1041,6 @@
                         return
                 item = self.GetNextVisible(item)
         
-        self.first = True
-        
         selectedLayer = self.GetSelectedLayer()
         # deselect active item
         if selectedLayer:
@@ -1094,7 +1091,7 @@
                                             text = '', ct_type = 1, wnd = ctrl)
         else: # add first layer to the layer tree (first child of root)
             layer = self.PrependItem(parent = self.root, text = '', ct_type = 1, wnd = ctrl)
-
+        
         # layer is initially unchecked as inactive (beside 'command')
         # use predefined value if given
         if lchecked is not None:
@@ -1162,8 +1159,6 @@
             self.SetItemImage(layer, self.cmd_icon)
             self.SetItemText(layer, '%s %s' % (_('unknown'), label))
         
-        self.first = False
-        
         if ltype != 'group':
             if lcmd and len(lcmd) > 1:
                 cmd = lcmd
@@ -1218,6 +1213,8 @@
             # run properties dialog if no properties given
             if len(cmd) == 0:
                 self.PropertiesDialog(layer, show = True)
+            else:
+                self.first = False
         
         else: # group
             self.SetPyData(layer, ({'cmd'      : None,
@@ -1242,7 +1239,8 @@
         else:
             if ltype == 'group':
                 self.OnRenameLayer(None)
-                
+
+        
         return layer
 
     def PropertiesDialog(self, layer, show = True):
@@ -1335,7 +1333,7 @@
         self.rerender = True
         nlayers = self.GetVisibleLayers()
         if not nlayers:
-            self.firstNewLayer = True # layer tree is empty
+            self.first = True # layer tree is empty
         self.Map.SetLayers(nlayers)
         
         if self.mapdisplay.GetToolbar('vdigit'):
@@ -1383,8 +1381,8 @@
                     child = self.GetNextSibling(child)
             else:
                 mapLayer = self.GetLayerInfo(item, key = 'maplayer')
-                if not digitToolbar or \
-                       (digitToolbar and digitToolbar.GetLayer() != mapLayer):
+                if mapLayer and (not digitToolbar or \
+                       (digitToolbar and digitToolbar.GetLayer() != mapLayer)):
                     # ignore when map layer is edited
                     self.Map.ChangeLayerActive(mapLayer, checked)
         
@@ -1697,15 +1695,15 @@
         # set region if auto-zooming is enabled or layer tree contains
         # only one map layer
         if dcmd:
-            if self.firstNewLayer or \
+            if self.first or \
                     UserSettings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled'):
                 mapLayer = self.GetLayerInfo(layer, key = 'maplayer')
                 if mapLayer.GetType() in ('raster', 'vector'):
                     self.mapdisplay.MapWindow.ZoomToMap(layers = [mapLayer,],
                                                         render = False)
             
-            self.firstNewLayer = False # first layer has been already
-                                       # added to the layer tree
+            self.first = False # first layer has been already added to
+                               # the layer tree
         
         # update nviz session        
         if self.lmgr.IsPaneShown('toolbarNviz') and dcmd:



More information about the grass-commit mailing list