[GRASS-SVN] r55256 - grass/trunk/gui/wxpython/vnet
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Feb 28 05:58:02 PST 2013
Author: turek
Date: 2013-02-28 05:58:02 -0800 (Thu, 28 Feb 2013)
New Revision: 55256
Modified:
grass/trunk/gui/wxpython/vnet/dialogs.py
Log:
wx.vnet: add vector map button works also for d.mon, post gUpdateMap event instead of calling UpdateMap map method
Modified: grass/trunk/gui/wxpython/vnet/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/vnet/dialogs.py 2013-02-28 13:47:17 UTC (rev 55255)
+++ grass/trunk/gui/wxpython/vnet/dialogs.py 2013-02-28 13:58:02 UTC (rev 55256)
@@ -40,8 +40,9 @@
import wx.lib.colourselect as csel
from core import globalvar, utils
+from core.gcmd import RunCommand, GMessage
+from core.events import gUpdateMap
from core.settings import UserSettings
-from core.gcmd import RunCommand, GMessage
from dbmgr.base import DbMgrBase
@@ -197,9 +198,11 @@
self.mapWin.UnregisterMouseEventHandler(wx.EVT_LEFT_DOWN,
self.OnMapClickHandler)
if update:
- self.mapWin.UpdateMap(render=True, renderVector=True)
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.mapWin, up_map_evt)
else:
- self.mapWin.UpdateMap(render=False, renderVector=False)
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.mapWin, up_map_evt)
def _addPanes(self):
@@ -321,7 +324,8 @@
cmd = self.GetLayerStyle()
self.tmp_result.AddRenderLayer(cmd)
- self.mapWin.UpdateMap(render = True, renderVector = True)
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.mapWin, up_map_evt)
def _createOutputPage(self):
"""!Tab with output console"""
@@ -363,7 +367,6 @@
self.inputData[dataSel[0]] = dataSel[2](parent = selPanels[dataSel[0]],
size = (-1, -1),
type = 'vector')
- if dataSel[0] == 'input' and self.mapWin.tree:
icon = wx.Image(os.path.join(globalvar.ETCICONDIR, "grass", "layer-vector-add.png"))
icon.Rescale(18, 18)
icon = wx.BitmapFromImage(icon)
@@ -393,7 +396,7 @@
flag = wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, border = 5)
for sel in ['input', 'alayer', 'nlayer']:
- if sel== 'input' and self.mapWin.tree:
+ if sel== 'input':
btn = self.addToTreeBtn
else:
btn = None
@@ -594,12 +597,22 @@
cmd = ['d.vect',
'map=' + vectorMap]
- if self.mapWin.tree.FindItemByData(key = 'name', value = vectorMap) is None:
+ if self.mapWin.tree and \
+ self.mapWin.tree.FindItemByData(key = 'name', value = vectorMap) is None:
self.mapWin.tree.AddLayer(ltype = "vector",
lcmd = cmd,
lname =vectorMap,
- lchecked = True)
+ lchecked = True)
+ #d.mon case
+ else:
+ self.renderLayer = self.mapWin.Map.AddLayer(ltype = "vector", command = cmd,
+ name = vectorMap, active = True,
+ opacity = 1.0, render = True,
+ pos = -1)
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.mapWin, up_map_evt)
+
def OnVectSel(self, event):
"""!When vector map is selected it populates other comboboxes in Parameters tab (layer selects, columns selects)"""
if self.snapData['snap_mode']:
@@ -607,7 +620,7 @@
vectMapName, mapSet = self._parseMapStr(self.inputData['input'].GetValue())
vectorMap = vectMapName + '@' + mapSet
-
+cd .
self.inputData['alayer'].Clear()
self.inputData['nlayer'].Clear()
@@ -617,8 +630,7 @@
items = self.inputData['alayer'].GetItems()
itemsLen = len(items)
if itemsLen < 1:
- if self.mapWin.tree:
- self.addToTreeBtn.Disable()
+ self.addToTreeBtn.Disable()
if hasattr(self, 'inpDbMgrData'):
self._updateInputDbMgrPage(show = False)
self.inputData['alayer'].SetValue("")
@@ -638,8 +650,7 @@
iItem = items.index(unicode("2"))
self.inputData['nlayer'].SetSelection(iItem)
- if self.mapWin.tree:
- self.addToTreeBtn.Enable()
+ self.addToTreeBtn.Enable()
if hasattr(self, 'inpDbMgrData'):
self._updateInputDbMgrPage(show = True)
@@ -994,7 +1005,10 @@
cmd = self.GetLayerStyle()
self.tmp_result.AddRenderLayer(cmd)
- self.mapWin.UpdateMap(render=True, renderVector=True)
+
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.mapWin, up_map_evt)
+
mainToolbar = self.toolbars['mainToolbar']
id = vars(mainToolbar)['showResult']
mainToolbar.ToggleTool(id =id,
@@ -1119,7 +1133,10 @@
cmd = self.GetLayerStyle()
self.tmp_result.AddRenderLayer(cmd)
- self.mapWin.UpdateMap(render=True, renderVector=True)
+
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.mapWin, up_map_evt)
+
mainToolbar = self.toolbars['mainToolbar']
id = vars(mainToolbar)['showResult']
mainToolbar.ToggleTool(id =id,
@@ -1246,7 +1263,8 @@
cmd = self.GetLayerStyle()
self.tmp_result.DeleteRenderLayer()
- self.mapWin.UpdateMap(render=True, renderVector=True)
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.mapWin, up_map_evt)
def OnInsertPoint(self, event):
"""!Registers/unregisters mouse handler into map window"""
@@ -1324,7 +1342,8 @@
lcmd = cmd,
lchecked = True)
else:
- self.mapWin.UpdateMap(render=True, renderVector=True)
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.mapWin, up_map_evt)
def OnSettings(self, event):
"""!Displays vnet settings dialog"""
@@ -1407,7 +1426,9 @@
toggle = False)
if self.tmpMaps.HasTmpVectMap("vnet_snap_points"):
self.snapPts.DeleteRenderLayer()
- self.mapWin.UpdateMap(render = False, renderVector = False)
+
+ up_map_evt = gUpdateMap(render = False, renderVector = False)
+ wx.PostEvent(self.mapWin, up_map_evt)
if self.snapData.has_key('cmdThread'):
self.snapData['cmdThread'].abort()
@@ -1487,18 +1508,21 @@
self.snapData["inputMapNlayer"] = self.inputData["nlayer"].GetValue()
# map is already created and up to date for input data
else:
- self.snapPts.AddRenderLayer()
- self.mapWin.UpdateMap(render = True, renderVector = True)
-
+ self.snapPts.AddRenderLayer()
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.mapWin, up_map_evt)
+
def _onToPointsDone(self, event):
"""!Update map window, when map with nodes to snap is created"""
self.stBar.RemoveStatusItem(key = 'snap')
if not event.aborted:
self.snapPts.SaveVectMapState()
self.snapPts.AddRenderLayer()
- self.mapWin.UpdateMap(render = True, renderVector = True)
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.mapWin, up_map_evt)
+
def OnUndo(self, event):
"""!Step back in history"""
histStepData = self.history.GetPrev()
@@ -1684,8 +1708,10 @@
self.OnAnalysisChanged(None)
self.list.SetUpdateMap(updateMap = True)
- self.mapWin.UpdateMap(render=True, renderVector=True)
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.mapWin, up_map_evt)
+
def _checkResultMapChanged(self, resultVectMap):
"""!Check if map was modified outside"""
if resultVectMap.VectMapState() == 0:
@@ -1953,7 +1979,8 @@
PointsList.OnItemSelected(self, event)
if self.updateMap:
- self.dialog.mapWin.UpdateMap(render=False, renderVector=False)
+ up_map_evt = gUpdateMap(render = False, renderVector = False)
+ wx.PostEvent(self.dialog.mapWin, up_map_evt)
def AdaptPointsList(self, currParamsCats):
"""Rename category values when module is changed. Expample: Start point -> Sink point"""
@@ -1979,7 +2006,8 @@
cats = self.dialog.vnetParams[currModule]["cmdParams"]["cats"]
if self.updateMap:
- self.dialog.mapWin.UpdateMap(render=False, renderVector=False)
+ up_map_evt = gUpdateMap(render = False, renderVector = False)
+ wx.PostEvent(self.dialog.mapWin, up_map_evt)
if len(cats) <= 1:
return
@@ -2235,13 +2263,17 @@
self.parent.SetPointDrawSettings()
if not self.parent.tmp_result or \
not self.parent.tmpMaps.HasTmpVectMap(self.parent.tmp_result.GetVectMapName()):
- self.parent.mapWin.UpdateMap(render=False, renderVector=False)
+ up_map_evt = gUpdateMap(render = False, renderVector = False)
+ wx.PostEvent(self.parent.mapWin, up_map_evt)
elif self.parent.tmp_result.GetRenderLayer():
cmd = self.parent.GetLayerStyle()
self.parent.tmp_result.AddRenderLayer(cmd)
- self.parent.mapWin.UpdateMap(render=True, renderVector=True)#TODO optimization
+
+ up_map_evt = gUpdateMap(render = True, renderVector = True)
+ wx.PostEvent(self.parent.mapWin, up_map_evt)#TODO optimization
else:
- self.parent.mapWin.UpdateMap(render=False, renderVector=False)
+ up_map_evt = gUpdateMap(render = False, renderVector = False)
+ wx.PostEvent(self.parent.mapWin, up_map_evt)
def OnApply(self, event):
"""!Button 'Apply' pressed"""
More information about the grass-commit
mailing list