[GRASS-SVN] r74136 - in grass/trunk/gui/wxpython: core lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Feb 27 07:11:08 PST 2019


Author: annakrat
Date: 2019-02-27 07:11:08 -0800 (Wed, 27 Feb 2019)
New Revision: 74136

Modified:
   grass/trunk/gui/wxpython/core/render.py
   grass/trunk/gui/wxpython/lmgr/giface.py
   grass/trunk/gui/wxpython/lmgr/layertree.py
Log:
wxGUI: add function to LM interface to programatically change layer

Modified: grass/trunk/gui/wxpython/core/render.py
===================================================================
--- grass/trunk/gui/wxpython/core/render.py	2019-02-26 09:30:25 UTC (rev 74135)
+++ grass/trunk/gui/wxpython/core/render.py	2019-02-27 15:11:08 UTC (rev 74136)
@@ -415,6 +415,8 @@
         env_cmd.update(self._render_env)
         env_cmd['GRASS_RENDER_FILE'] = self.layer.mapfile
         if self.layer.GetType() in ('vector', 'thememap'):
+            if not self.layer._legrow:
+                self.layer._legrow = grass.tempfile(create=True)
             if os.path.isfile(self.layer._legrow):
                 os.remove(self.layer._legrow)
             env_cmd['GRASS_LEGEND_FILE'] = text_to_string(self.layer._legrow)

Modified: grass/trunk/gui/wxpython/lmgr/giface.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/giface.py	2019-02-26 09:30:25 UTC (rev 74135)
+++ grass/trunk/gui/wxpython/lmgr/giface.py	2019-02-27 15:11:08 UTC (rev 74136)
@@ -21,6 +21,7 @@
 
 from grass.pydispatch.signal import Signal
 from core.giface import Notification
+from core.utils import GetLayerNameFromCmd
 
 
 class Layer(object):
@@ -123,6 +124,22 @@
         "Select or unselect layer"
         self._tree.SelectItem(layer._layer, select)
 
+    def ChangeLayer(self, layer, **kwargs):
+        "Change layer (cmd, ltype, opacity)"
+        if 'cmd' in kwargs:
+            layer._pydata[0]['cmd'] = kwargs['cmd']
+            layerName, found = GetLayerNameFromCmd(kwargs['cmd'], fullyQualified=True)
+            if found:
+                layer._pydata[0]['label'] = layerName
+        if 'ltype' in kwargs:
+            layer._pydata[0]['type'] = kwargs['ltype']
+        if 'opacity' in kwargs:
+            layer._pydata[0]['maplayer'].SetOpacity(kwargs['opacity'])
+
+        self._tree.ChangeLayer(layer._layer)
+        self._tree.SetItemIcon(layer._layer)
+        self._tree.SetItemText(layer._layer, self._tree._getLayerName(layer._layer))
+
     def IsLayerChecked(self, layer):
         """Returns True if layer is checked, False otherwise"""
         return self._tree.IsItemChecked(layer._layer)

Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py	2019-02-26 09:30:25 UTC (rev 74135)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py	2019-02-27 15:11:08 UTC (rev 74136)
@@ -2132,7 +2132,7 @@
             layer=self.GetLayerInfo(
                 item,
                 key='maplayer'),
-            type=type,
+            ltype=type,
             command=cmdlist,
             name=layerName,
             active=chk,



More information about the grass-commit mailing list