[GRASS-SVN] r72314 - grass/trunk/gui/wxpython/gmodeler

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Mar 3 01:33:53 PST 2018


Author: martinl
Date: 2018-03-03 01:33:53 -0800 (Sat, 03 Mar 2018)
New Revision: 72314

Modified:
   grass/trunk/gui/wxpython/gmodeler/frame.py
Log:
wxGUI/gmodeler: display data if model done

Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py	2018-03-02 22:45:33 UTC (rev 72313)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py	2018-03-03 09:33:53 UTC (rev 72314)
@@ -151,7 +151,7 @@
         # rewrite default method to avoid hiding progress bar
         self._gconsole.Bind(EVT_CMD_DONE, self.OnCmdDone)
         self.Bind(EVT_CMD_PREPARE, self.OnCmdPrepare)
-        self.Bind(EVT_MODEL_DONE, self.OnDone)
+        self.Bind(EVT_MODEL_DONE, self.OnModelDone)
         
         self.notebook.AddPage(page=self.canvas, text=_('Model'), name='model')
         self.notebook.AddPage(
@@ -612,9 +612,9 @@
     def OnRunModel(self, event):
         """Run entire model"""
         self.start_time = time.time()
-        self.model.Run(self._gconsole, self.OnDone, parent=self)
+        self.model.Run(self._gconsole, self.OnModelDone, parent=self)
 
-    def OnDone(self, event):
+    def OnModelDone(self, event):
         """Computation finished
         """
         self.SetStatusText('', 0)
@@ -636,6 +636,22 @@
         # delete intermediate data
         self._deleteIntermediateData()
 
+        # display data if required
+        for data in self.model.GetData():
+            if not data.HasDisplay():
+                continue
+
+            # remove existing map layers first
+            layers =  self._giface.GetLayerList().GetLayersByName(data.GetValue())
+            if layers:
+                for layer in layers:
+                    self._giface.GetLayerList().DeleteLayer(layer)
+                
+            # add new map layer
+            self._giface.GetLayerList().AddLayer(
+                ltype=data.GetPrompt(), name=data.GetValue(), checked=True,
+                cmd=data.GetDisplayCmd())
+
     def OnValidateModel(self, event, showMsg=True):
         """Validate entire model"""
         if self.model.GetNumItems() < 1:
@@ -1683,6 +1699,7 @@
                 layers = self.frame._giface.GetLayerList().GetLayersByName(shape.GetValue())
                 for layer in layers:
                     self.frame._giface.GetLayerList().DeleteLayer(layer)
+                    
         except GException as e:
             GError(parent=self,
                    message='{}'.format(e))



More information about the grass-commit mailing list