[GRASS-SVN] r55370 - in grass/trunk/gui/wxpython: animation gui_core iclass lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 13 15:17:42 PDT 2013


Author: annakrat
Date: 2013-03-13 15:17:41 -0700 (Wed, 13 Mar 2013)
New Revision: 55370

Modified:
   grass/trunk/gui/wxpython/animation/dialogs.py
   grass/trunk/gui/wxpython/gui_core/dialogs.py
   grass/trunk/gui/wxpython/iclass/frame.py
   grass/trunk/gui/wxpython/lmgr/frame.py
   grass/trunk/gui/wxpython/lmgr/layertree.py
Log:
wxGUI: replace events by signals in opacity dialog and multiple maps dialog

Modified: grass/trunk/gui/wxpython/animation/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/animation/dialogs.py	2013-03-13 21:57:41 UTC (rev 55369)
+++ grass/trunk/gui/wxpython/animation/dialogs.py	2013-03-13 22:17:41 UTC (rev 55370)
@@ -34,7 +34,7 @@
 from core.gcmd import GMessage, GError, GException
 from core import globalvar
 from gui_core import gselect
-from gui_core.dialogs import MapLayersDialog, EVT_APPLY_MAP_LAYERS, GetImageHandlers
+from gui_core.dialogs import MapLayersDialog, GetImageHandlers
 from core.settings import UserSettings
 
 from utils import TemporalMode, validateTimeseriesName, validateMapNames
@@ -457,7 +457,8 @@
             index = 2
             
         dlg = MapLayersDialog(self, title = _("Select raster maps for animation"))
-        dlg.Bind(EVT_APPLY_MAP_LAYERS, self.OnApplyMapLayers)
+        dlg.applyAddingMapLayers.connect(lambda mapLayers:
+                                         self.dataSelect.SetValue(','.join(mapLayers)))
         dlg.layerType.SetSelection(index)
         dlg.LoadMapLayers(dlg.GetLayerType(cmd = True),
                            dlg.mapset.GetStringSelection())
@@ -466,9 +467,6 @@
 
         dlg.Destroy()
 
-    def OnApplyMapLayers(self, event):
-        self.dataSelect.SetValue(','.join(event.mapLayers))
-
     def _update(self):
         self.animationData.name = self.nameCtrl.GetValue()
         self.animationData.windowIndex = self.windowChoice.GetSelection()

Modified: grass/trunk/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/dialogs.py	2013-03-13 21:57:41 UTC (rev 55369)
+++ grass/trunk/gui/wxpython/gui_core/dialogs.py	2013-03-13 22:17:41 UTC (rev 55370)
@@ -45,6 +45,8 @@
 from grass.script import core as grass
 from grass.script import task as gtask
 
+from grass.pydispatch.signal import Signal
+
 from core             import globalvar
 from core.gcmd        import GError, RunCommand, GMessage
 from gui_core.gselect import LocationSelect, MapsetSelect, Select, OgrTypeSelect, GdalSelect, MapsetSelect
@@ -54,9 +56,6 @@
 from core.settings    import UserSettings, GetDisplayVectSettings
 from core.debug       import Debug
 
-wxApplyMapLayers, EVT_APPLY_MAP_LAYERS = NewEvent()
-wxApplyOpacity, EVT_APPLY_OPACITY = NewEvent()
-
 class SimpleDialog(wx.Dialog):
     def __init__(self, parent, title, id = wx.ID_ANY,
                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
@@ -1162,6 +1161,9 @@
                            style = style, **kwargs)
         
         self.parent = parent # GMFrame or ?
+        
+        self.applyAddingMapLayers = Signal('MapLayersDialogBase.applyAddingMapLayers')
+        
         self.mainSizer = wx.BoxSizer(wx.VERTICAL)
         
         # dialog body
@@ -1447,8 +1449,8 @@
         btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
 
     def OnApply(self, event):
-        event = wxApplyMapLayers(mapLayers = self.GetMapLayers(), ltype = self.GetLayerType(cmd = True))
-        wx.PostEvent(self, event)
+        self.applyAddingMapLayers.emit(mapLayers = self.GetMapLayers(),
+                                       ltype = self.GetLayerType(cmd = True))
 
 class MapLayersDialogForGroups(MapLayersDialogBase):
     """!Subclass of MapLayersDialogBase used for specyfying maps in an imagery group. 
@@ -2088,6 +2090,7 @@
         super(SetOpacityDialog, self).__init__(parent, id = id, pos = pos,
                                                size = size, style = style, title = title)
 
+        self.applyOpacity = Signal('SetOpacityDialog.applyOpacity')
         panel = wx.Panel(parent = self, id = wx.ID_ANY)
         
         sizer = wx.BoxSizer(wx.VERTICAL)
@@ -2149,9 +2152,9 @@
         return opacity
 
     def OnApply(self, event):
-        event = wxApplyOpacity(value = self.GetOpacity())
-        wx.PostEvent(self, event)
+        self.applyOpacity.emit(value = self.GetOpacity())
 
+
 def GetImageHandlers(image):
     """!Get list of supported image handlers"""
     lext = list()

Modified: grass/trunk/gui/wxpython/iclass/frame.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/frame.py	2013-03-13 21:57:41 UTC (rev 55369)
+++ grass/trunk/gui/wxpython/iclass/frame.py	2013-03-13 22:17:41 UTC (rev 55370)
@@ -1249,12 +1249,16 @@
         # works for first layer only
         oldOpacity = layers[0].GetOpacity()
         dlg = SetOpacityDialog(self.frame, opacity = oldOpacity)
+        dlg.applyOpacity.connect(lambda value:
+                                 self._changeOpacity(layer=layers[0], opacity=value))
         
         if dlg.ShowModal() == wx.ID_OK:
-            self.map.ChangeOpacity(layer = layers[0], opacity = dlg.GetOpacity())
+            self._changeOpacity(layer=layers[0], opacity=dlg.GetOpacity())
             
         dlg.Destroy()
-        
+
+    def _changeOpacity(self, layer, opacity):
+        self.map.ChangeOpacity(layer=layer, opacity=opacity)
         self.frame.Render(self.mapWindow)
         
     def _addSuffix(self, name):

Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py	2013-03-13 21:57:41 UTC (rev 55369)
+++ grass/trunk/gui/wxpython/lmgr/frame.py	2013-03-13 22:17:41 UTC (rev 55370)
@@ -55,7 +55,6 @@
     EVT_WRITE_LOG, EVT_WRITE_WARNING, EVT_WRITE_ERROR
 from gui_core.goutput      import GConsoleWindow, EVT_GC_CONTENT_CHANGED, GC_SEARCH, GC_PROMPT
 from gui_core.dialogs      import GdalOutputDialog, DxfImportDialog, GdalImportDialog, MapLayersDialog
-from gui_core.dialogs      import EVT_APPLY_MAP_LAYERS
 from gui_core.dialogs      import LocationDialog, MapsetDialog, CreateNewVector, GroupDialog
 from modules.colorrules    import RasterColorTable, VectorColorTable
 from gui_core.menu         import Menu, SearchModuleWindow
@@ -1621,15 +1620,12 @@
     def OnAddMaps(self, event = None):
         """!Add selected map layers into layer tree"""
         dialog = MapLayersDialog(parent = self, title = _("Add selected map layers into layer tree"))
-        dialog.Bind(EVT_APPLY_MAP_LAYERS, self.OnApplyMapLayers)
+        dialog.applyAddingMapLayers.connect(self.AddMaps)
         val = dialog.ShowModal()
         
         if val == wx.ID_OK:
             self.AddMaps(dialog.GetMapLayers(), dialog.GetLayerType(cmd = True))
         dialog.Destroy()
-        
-    def OnApplyMapLayers(self, event):
-        self.AddMaps(mapLayers = event.mapLayers, ltype = event.ltype)
 
     def AddMaps(self, mapLayers, ltype, check = False):
         """!Add map layers to layer tree.

Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py	2013-03-13 21:57:41 UTC (rev 55369)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py	2013-03-13 22:17:41 UTC (rev 55370)
@@ -31,7 +31,7 @@
 from grass.script import core as grass
 
 from core                 import globalvar
-from gui_core.dialogs     import SqlQueryFrame, SetOpacityDialog, EVT_APPLY_OPACITY
+from gui_core.dialogs     import SqlQueryFrame, SetOpacityDialog
 from gui_core.forms       import GUI
 from mapdisp.frame        import MapFrame
 from core.render          import Map
@@ -759,17 +759,14 @@
         
         dlg = SetOpacityDialog(self, opacity = current_opacity,
                                title = _("Set opacity of <%s>") % maplayer.GetName())
+        dlg.applyOpacity.connect(lambda value:
+                                 self.ChangeLayerOpacity(layer=self.layer_selected, value=value))
         dlg.CentreOnParent()
-        dlg.Bind(EVT_APPLY_OPACITY, self.OnApplyLayerOpacity)
 
         if dlg.ShowModal() == wx.ID_OK:
             self.ChangeLayerOpacity(layer = self.layer_selected, value = dlg.GetOpacity())
         dlg.Destroy()
 
-    def OnApplyLayerOpacity(self, event):
-        """!Handles EVT_APPLY_OPACITY event."""
-        self.ChangeLayerOpacity(layer = self.layer_selected, value = event.value)
-
     def ChangeLayerOpacity(self, layer, value):
         """!Change opacity value of layer
         @param layer layer for which to change (item in layertree)



More information about the grass-commit mailing list