[GRASS-SVN] r57099 - in grass/trunk/gui/wxpython: core mapdisp vnet
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jul 14 01:34:28 PDT 2013
Author: annakrat
Date: 2013-07-14 01:34:28 -0700 (Sun, 14 Jul 2013)
New Revision: 57099
Removed:
grass/trunk/gui/wxpython/core/events.py
Modified:
grass/trunk/gui/wxpython/mapdisp/mapwindow.py
grass/trunk/gui/wxpython/vnet/dialogs.py
grass/trunk/gui/wxpython/vnet/vnet_core.py
Log:
wxGUI: remove gUpdateMap events and replace by signals
Deleted: grass/trunk/gui/wxpython/core/events.py
===================================================================
--- grass/trunk/gui/wxpython/core/events.py 2013-07-14 08:23:17 UTC (rev 57098)
+++ grass/trunk/gui/wxpython/core/events.py 2013-07-14 08:34:28 UTC (rev 57099)
@@ -1,45 +0,0 @@
-"""!
- at package core.events
-
- at brief General events
-
-Put here only truly general events. Once you find that your event can be
-generated in more than one class, put your event here. Otherwise,
-leave it in your class file. Events are expected to be grass/gis related.
-
-General notice:
-Command events are propagated to parent windows. However, they do not propagate
-beyond dialogs. Events do not propagate at all.
-Command events works only with windows, not EvtHandlers, so for other objects
-than windows you need to have extra parameter - guiparent - which can be used
-for creating command events.
-\code
-mapEvent = gMapCreated(self._guiparent.GetId(), ...)
-wx.PostEvent(self._guiparent, mapEvent)
-\endcode
-
- at todo naming conventions for events
-
-(C) 2012 by the GRASS Development Team
-
-This program is free software under the GNU General Public License
-(>=v2). Read the file COPYING that comes with GRASS for details.
-
- at author Vaclav Petras <wenzeslaus gmail.com>
-"""
-
-
-from wx.lib.newevent import NewCommandEvent
-from wx.lib.newevent import NewEvent
-
-
-# Post it to BufferedWindow instance, which you want to update.
-# For relevant attributes for the event see
-# mapdisp.mapwindow.BufferedWindow UpdateMap method arguments.
-# If event does not contain attribute corresponding to argument with default
-# value, the default value will be used.
-# Arguments with no default value must be among event attributes
-# in order to be the event processed.
-# TODO implement to NVIZ GLWindow
-# TODO change direct calling of UpdateMap method to posting this event
-gUpdateMap, EVT_UPDATE_MAP = NewEvent()
Modified: grass/trunk/gui/wxpython/mapdisp/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/mapwindow.py 2013-07-14 08:23:17 UTC (rev 57098)
+++ grass/trunk/gui/wxpython/mapdisp/mapwindow.py 2013-07-14 08:34:28 UTC (rev 57099)
@@ -36,7 +36,6 @@
from core.gcmd import RunCommand, GException, GError, GMessage
from core.debug import Debug
from core.settings import UserSettings
-from core.events import EVT_UPDATE_MAP
from gui_core.mapwindow import MapWindow
from core.utils import GetGEventAttribsForHandler
@@ -100,7 +99,6 @@
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_IDLE, self.OnIdle)
- self.Bind(EVT_UPDATE_MAP, self.OnUpdateMap)
self._bindMouseEvents()
@@ -605,17 +603,6 @@
def IsAlwaysRenderEnabled(self):
return self.alwaysRender
- def OnUpdateMap(self, event):
- """!Called when this class receives core.events.gUpdateMap event.
- """
- kwargs, missing_args = GetGEventAttribsForHandler(self.UpdateMap, event)
-
- if missing_args:
- Debug.msg (1, "Invalid call of EVT_UPDATE_MAP event.")
- return
-
- self.UpdateMap(**kwargs)
-
def UpdateMap(self, render = True, renderVector = True):
"""!Updates the canvas anytime there is a change to the
underlaying images or to the geometry of the canvas.
Modified: grass/trunk/gui/wxpython/vnet/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/vnet/dialogs.py 2013-07-14 08:23:17 UTC (rev 57098)
+++ grass/trunk/gui/wxpython/vnet/dialogs.py 2013-07-14 08:34:28 UTC (rev 57099)
@@ -40,7 +40,6 @@
from core import globalvar, utils
from core.gcmd import RunCommand, GMessage
-from core.events import gUpdateMap
from core.settings import UserSettings
from dbmgr.base import DbMgrBase
@@ -71,10 +70,9 @@
wx.Dialog.__init__(self, parent, id, style=style, title = title, **kwargs)
self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
- self.parent = parent
- self.mapDisp = giface.GetMapDisplay()
- self.mapWin = giface.GetMapWindow().GetMapWindow()
- self._giface = giface
+ self.parent = parent
+ self.mapWin = giface.GetMapWindow()
+ self.giface = giface
# contains current analysis result (do not have to be last one, when history is browsed),
# it is instance of VectMap class
@@ -292,8 +290,7 @@
cmd = self.GetLayerStyle()
self.tmp_result.AddRenderLayer(cmd)
- up_map_evt = gUpdateMap(render = True, renderVector = True)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=True, renderVector=True)
def _createOutputPage(self):
"""!Tab with output console"""
@@ -606,8 +603,7 @@
opacity = 1.0, render = True,
pos = -1)
- up_map_evt = gUpdateMap(render = True, renderVector = True)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=True, renderVector=True)
def UseTurns(self):
if self.useTurns.IsChecked():
@@ -849,8 +845,7 @@
self._updateResultDbMgrPage()
self._updateDbMgrData()
- up_map_evt = gUpdateMap(render = True, renderVector = True)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=True, renderVector=True)
def OnShowResult(self, event):
"""!Show/hide analysis result"""
Modified: grass/trunk/gui/wxpython/vnet/vnet_core.py
===================================================================
--- grass/trunk/gui/wxpython/vnet/vnet_core.py 2013-07-14 08:23:17 UTC (rev 57098)
+++ grass/trunk/gui/wxpython/vnet/vnet_core.py 2013-07-14 08:34:28 UTC (rev 57099)
@@ -26,7 +26,6 @@
from core import utils
from core.gcmd import RunCommand, GMessage
-from core.events import gUpdateMap
from core.gconsole import CmdThread, EVT_CMD_DONE, GConsole
from gui_core.gselect import VectorDBInfo
@@ -42,8 +41,8 @@
self.data = {}
self.guiparent = guiparent
- self.mapDisp = giface.GetMapDisplay()
- self.mapWin = giface.GetMapWindow().GetMapWindow()
+ self.giface = giface
+ self.mapWin = giface.GetMapWindow()
self.goutput = GConsole(guiparent = guiparent)
@@ -60,7 +59,7 @@
self.history = VNETHistory(self.guiparent, self.vnet_data, self.tmp_maps)
self.analyses = VNETAnalyses(self.vnet_data, self.RunAnDone, self.goutput, self.tmp_maps)
- self.snap_nodes = SnappingNodes(self.vnet_data, self.tmp_maps, self.mapWin)
+ self.snap_nodes = SnappingNodes(self.giface, self.vnet_data, self.tmp_maps, self.mapWin)
self.ttbCreated = Signal('VNETManager.ttbCreated')
self.analysisDone = Signal('VNETManager.analysisDone')
@@ -82,11 +81,9 @@
self.vnet_data.CleanUp()
if update:
- up_map_evt = gUpdateMap(render = True, renderVector = True)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=True, renderVector=True)
else:
- up_map_evt = gUpdateMap(render = True, renderVector = True)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=False, renderVector=False)
def GetPointsManager(self):
return self.vnet_data.GetPointsData()
@@ -157,8 +154,7 @@
else:
self.results["vect_map"].DeleteRenderLayer()
- up_map_evt = gUpdateMap(render = True, renderVector = True)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=True, renderVector=True)
def GetAnalysisProperties(self, analysis = None):
return self.vnet_data.GetAnalysisProperties(analysis = analysis)
@@ -191,8 +187,7 @@
cmd, cmd_colors = self.vnet_data.GetLayerStyle()
self.results["vect_map"].AddRenderLayer(cmd, cmd_colors)
- up_map_evt = gUpdateMap(render = True, renderVector = True)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=True, renderVector=True)
def GetHistStep(self):
return self.history.GetHistStep()
@@ -234,23 +229,19 @@
self.vnet_data.GetPointsData().SetPointDrawSettings()
if not self.results["vect_map"] or \
not self.tmp_maps.HasTmpVectMap(self.results["vect_map"].GetVectMapName()):
- up_map_evt = gUpdateMap(render = False, renderVector = False)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=False, renderVector=False)
elif self.results["vect_map"].GetRenderLayer():
cmd, cmd_colors = self.vnet_data.GetLayerStyle()
self.results["vect_map"].AddRenderLayer(cmd, cmd_colors)
- up_map_evt = gUpdateMap(render = True, renderVector = True)
- wx.PostEvent(self.mapWin, up_map_evt)#TODO optimization
+ self.giface.updateMap.emit(render=True, renderVector=True)
+ #TODO optimization
else:
- up_map_evt = gUpdateMap(render = False, renderVector = False)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=False, renderVector=False)
def PointsChanged(self, method, kwargs):
+ self.giface.updateMap.emit(render=False, renderVector=False)
- up_map_evt = gUpdateMap(render = False, renderVector = False)
- wx.PostEvent(self.mapWin, up_map_evt)
-
def CreateTttb(self, params):
outputMap = params["output"]
@@ -377,8 +368,7 @@
RunCommand(layerStyleVnetColors[0],
**layerStyleVnetColors[1])
else:
- up_map_evt = gUpdateMap(render = True, renderVector = True)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=True, renderVector=True)
class VNETAnalyses:
def __init__(self, data, onAnDone, goutput, tmp_maps):
@@ -418,8 +408,7 @@
cmdPts = []
for cat in cats:
if len(catPts[cat[0]]) < 1:#TODO
- GMessage(parent = self.guiparent,
- message=_("Please choose '%s' and '%s' point.") % (cats[0][1], cats[1][1]))
+ GMessage(message=_("Please choose '%s' and '%s' point.") % (cats[0][1], cats[1][1]))
return False
cmdPts.append(catPts[cat[0]][0])
@@ -993,8 +982,9 @@
class SnappingNodes(wx.EvtHandler):
- def __init__(self, data, tmp_maps, mapWin):
+ def __init__(self, giface, data, tmp_maps, mapWin):
+ self.giface = giface
self.data = data
self.tmp_maps = tmp_maps
self.mapWin = mapWin
@@ -1019,8 +1009,7 @@
if self.tmp_maps.HasTmpVectMap("vnet_snap_points"):
self.snapPts.DeleteRenderLayer()
- up_map_evt = gUpdateMap(render = False, renderVector = False)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=False, renderVector=False)
if self.snapData.has_key('cmdThread'):
self.snapData['cmdThread'].abort()
@@ -1050,8 +1039,7 @@
return -1
elif self.snapPts.VectMapState() == 0:
- dlg = wx.MessageDialog(parent = self.parent,
- message = _("Temporary map '%s' was changed outside " +
+ dlg = wx.MessageDialog(message = _("Temporary map '%s' was changed outside " +
"vector analysis tool.\n"
"Do you really want to activate " +
"snapping and overwrite it? ") % \
@@ -1104,8 +1092,7 @@
else:
self.snapPts.AddRenderLayer()
- up_map_evt = gUpdateMap(render = True, renderVector = True)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=True, renderVector=True)
self.snapping.emit(evt = "computing_points_done")
@@ -1117,7 +1104,6 @@
self.snapPts.SaveVectMapState()
self.snapPts.AddRenderLayer()
- up_map_evt = gUpdateMap(render = True, renderVector = True)
- wx.PostEvent(self.mapWin, up_map_evt)
+ self.giface.updateMap.emit(render=True, renderVector=True)
self.snapping.emit(evt = "computing_points_done")
More information about the grass-commit
mailing list