[GRASS-SVN] r72395 - grass/branches/releasebranch_7_4/gui/wxpython/datacatalog

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 19 13:23:07 PDT 2018


Author: martinl
Date: 2018-03-19 13:23:07 -0700 (Mon, 19 Mar 2018)
New Revision: 72395

Modified:
   grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/catalog.py
   grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/frame.py
   grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/tree.py
Log:
 wxGUI/datacatalog: display layer on double click
                    remove map layer from layer tree on delete map
                    (merge r72370:72373 from trunk)


Modified: grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/catalog.py
===================================================================
--- grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/catalog.py	2018-03-19 17:13:51 UTC (rev 72394)
+++ grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/catalog.py	2018-03-19 20:23:07 UTC (rev 72395)
@@ -6,7 +6,7 @@
 Classes:
  - datacatalog::DataCatalog
 
-(C) 2014 by Tereza Fiedlerova, and the GRASS Development Team
+(C) 2014-2018 by Tereza Fiedlerova, and the GRASS Development Team
 
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS

Modified: grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/frame.py
===================================================================
--- grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/frame.py	2018-03-19 17:13:51 UTC (rev 72394)
+++ grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/frame.py	2018-03-19 20:23:07 UTC (rev 72395)
@@ -6,7 +6,7 @@
 Classes:
  - datacatalog::DataCatalogFrame
 
-(C) 2014-2016 by Tereza Fiedlerova, and the GRASS Development Team
+(C) 2014-2018 by Tereza Fiedlerova, and the GRASS Development Team
 
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS

Modified: grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/tree.py
===================================================================
--- grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/tree.py	2018-03-19 17:13:51 UTC (rev 72394)
+++ grass/branches/releasebranch_7_4/gui/wxpython/datacatalog/tree.py	2018-03-19 20:23:07 UTC (rev 72395)
@@ -7,7 +7,7 @@
  - datacatalog::LocationMapTree
  - datacatalog::DataCatalogTree
 
-(C) 2014-2015 by Tereza Fiedlerova, and the GRASS Development Team
+(C) 2014-2018 by Tereza Fiedlerova, and the GRASS Development Team
 
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
@@ -471,7 +471,19 @@
             self._popupMenuElement()
 
     def OnDoubleClick(self, node):
-        """Expand/Collapse node."""
+        """Double click on item/node.
+
+        Display selected layer if node is a map layer otherwise
+        expand/collapse node.
+        """
+        if not isinstance(self._giface, StandaloneGrassInterface):
+            self.DefineItems(node)
+            if self.selected_layer:
+                # display selected layer and return
+                self.DisplayLayer()
+                return
+
+        # expand/collapse location/mapset...
         if self.IsNodeExpanded(node):
             self.CollapseNode(node, recursive=False)
         else:
@@ -781,15 +793,9 @@
                 title=_('Delete map')) == wx.ID_YES:
             label = _("Deleting {name}...").format(name=name)
             self.showNotification.emit(message=label)
-            if self.selected_type.label == 'vector':
-                removed, cmd = self._runCommand(
-                    'g.remove', flags='f', type='vector', name=name, env=env)
-            elif self.selected_type.label == 'raster':
-                removed, cmd = self._runCommand(
-                    'g.remove', flags='f', type='raster', name=name, env=env)
-            else:
-                removed, cmd = self._runCommand(
-                    'g.remove', flags='f', type='raster_3d', name=name, env=env)
+
+            removed, cmd = self._runCommand(
+                'g.remove', flags='f', type=self.selected_type.label, name=name, env=env)
             if removed == 0:
                 self._model.RemoveNode(self.selected_layer)
                 self.RefreshNode(self.selected_type, recursive=True)
@@ -796,10 +802,22 @@
                 Debug.msg(1, "LAYER " + name + " DELETED")
                 self.showNotification.emit(
                     message=_("g.remove completed").format(cmd=cmd))
+
+                # remove map layer from layer tree if exists
+                if not isinstance(self._giface, StandaloneGrassInterface):
+                    name = self.selected_layer.label + '@' + self.selected_mapset.label
+                    layers = self._giface.GetLayerList().GetLayersByName(name)
+                    for layer in layers:
+                        self._giface.GetLayerList().DeleteLayer(layer)
+
         gscript.try_remove(gisrc)
 
     def OnDisplayLayer(self, event):
         """Display layer in current graphics view"""
+        self.DisplayLayer()
+        
+    def DisplayLayer(self):
+        """Display selected layer in current graphics view"""
         layerName = []
         if self.selected_location.label == gisenv(
         )['LOCATION_NAME'] and self.selected_mapset:



More information about the grass-commit mailing list