[GRASS-SVN] r49152 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Nov 9 05:43:51 EST 2011
Author: martinl
Date: 2011-11-09 02:43:51 -0800 (Wed, 09 Nov 2011)
New Revision: 49152
Modified:
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py
grass/trunk/gui/wxpython/gui_modules/render.py
grass/trunk/gui/wxpython/gui_modules/toolbars.py
grass/trunk/gui/wxpython/gui_modules/wxvdigit.py
Log:
wxGUI/vdigit: customization in progress (second part)
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-11-08 23:12:40 UTC (rev 49151)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-11-09 10:43:51 UTC (rev 49152)
@@ -558,7 +558,7 @@
elif self._mgr.GetPane('3d').IsShown():
self._mgr.GetPane('3d').Hide()
self._mgr.GetPane('vdigit').Show()
- self.toolbars['vdigit'] = toolbars.VDigitToolbar(parent = self, mapcontent = self.Map,
+ self.toolbars['vdigit'] = toolbars.VDigitToolbar(parent = self, MapWindow = self.MapWindow,
layerTree = self.tree,
log = log)
self.MapWindowVDigit.SetToolbar(self.toolbars['vdigit'])
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py 2011-11-08 23:12:40 UTC (rev 49151)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py 2011-11-09 10:43:51 UTC (rev 49152)
@@ -108,12 +108,16 @@
# self.pdcVector.Clear()
self.pdcVector.RemoveAll()
- try:
- item = self.tree.FindItemByData('maplayer', self.toolbar.GetLayer())
- except TypeError:
- item = None
+ item = None
+ if self.tree:
+ try:
+ item = self.tree.FindItemByData('maplayer', self.toolbar.GetLayer())
+ except TypeError:
+ pass
- if item and self.tree.IsItemChecked(item):
+ if not self.tree or \
+ (self.tree and item and \
+ self.tree.IsItemChecked(item)):
self.redrawAll = True
self.digit.GetDisplay().DrawMap()
@@ -190,8 +194,12 @@
"""!Define geometry attributes
"""
mapLayer = self.toolbar.GetLayer()
- item = self.tree.FindItemByData('maplayer', mapLayer)
- vdigit = self.tree.GetPyData(item)[0]['vdigit']
+ if self.tree:
+ item = self.tree.FindItemByData('maplayer', mapLayer)
+ vdigit = self.tree.GetPyData(item)[0]['vdigit']
+ else:
+ item = vdigit = None
+
if not vdigit or \
'geomAttr' not in vdigit or \
attrb not in vdigit['geomAttr']:
@@ -222,10 +230,13 @@
"""
mapLayer = self.parent.toolbars['vdigit'].GetLayer()
vectorName = mapLayer.GetName()
- item = self.tree.FindItemByData('maplayer', mapLayer)
- vdigit = self.tree.GetPyData(item)[0]['vdigit']
+ if self.tree:
+ item = self.tree.FindItemByData('maplayer', mapLayer)
+ vdigit = self.tree.GetPyData(item)[0]['vdigit']
+ else:
+ item = vdigit = None
- if vdigit is None or 'geomAttr' not in vdigit:
+ if not vdigit or 'geomAttr' not in vdigit:
return
dbInfo = gselect.VectorDBInfo(vectorName)
Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py 2011-11-08 23:12:40 UTC (rev 49151)
+++ grass/trunk/gui/wxpython/gui_modules/render.py 2011-11-09 10:43:51 UTC (rev 49152)
@@ -843,6 +843,7 @@
layers = self.overlays
else:
layers = self.layers + self.overlays
+
for layer in layers:
# skip non-active map layers
if not layer or not layer.active:
@@ -1000,7 +1001,7 @@
os.environ["GRASS_RENDER_IMMEDIATE"] = "png"
else:
os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"
-
+
if self.cmdfile:
maps, masks, opacities = self._renderCmdFile(force, windres)
else:
@@ -1080,8 +1081,10 @@
"""
wx.BeginBusyCursor()
# l_opacity must be <0;1>
- if l_opacity < 0: l_opacity = 0
- elif l_opacity > 1: l_opacity = 1
+ if l_opacity < 0:
+ l_opacity = 0
+ elif l_opacity > 1:
+ l_opacity = 1
layer = MapLayer(type = type, name = name, cmd = command,
active = l_active, hidden = l_hidden, opacity = l_opacity)
@@ -1097,7 +1100,7 @@
raise gcmd.GException(_("Unable to render map layer <%s>.") % name)
wx.EndBusyCursor()
-
+
return layer
def DeleteAllLayers(self, overlay = False):
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2011-11-08 23:12:40 UTC (rev 49151)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2011-11-09 10:43:51 UTC (rev 49152)
@@ -496,8 +496,9 @@
class VDigitToolbar(AbstractToolbar):
"""!Toolbar for digitization
"""
- def __init__(self, parent, mapcontent, tools = [], layerTree = None, log = None):
- self.mapcontent = mapcontent # Map class instance
+ def __init__(self, parent, MapWindow, tools = [], layerTree = None, log = None):
+ self.MapWindow = MapWindow
+ self.Map = MapWindow.GetMap() # Map class instance
self.layerTree = layerTree # reference to layer tree associated to map display
self.log = log # log area
self.tools = tools
@@ -624,16 +625,20 @@
def OnTool(self, event):
"""!Tool selected -> disable selected tool in map toolbar"""
- aId = self.parent.toolbars['map'].GetAction(type = 'id')
- self.parent.toolbars['map'].ToggleTool(aId, False)
-
+ if self.parent.GetName() == 'IClassWindow':
+ toolbarName = 'iClassMap'
+ else:
+ toolbarName = 'map'
+ aId = self.parent.toolbars[toolbarName].GetAction(type = 'id')
+ self.parent.toolbars[toolbarName].ToggleTool(aId, False)
+
# set cursor
cursor = self.parent.cursors["cross"]
- self.parent.MapWindow.SetCursor(cursor)
+ self.MapWindow.SetCursor(cursor)
# pointer
self.parent.OnPointer(None)
-
+
if event:
# deselect previously selected tool
aId = self.action.get('id', -1)
@@ -652,14 +657,14 @@
# clear tmp canvas
if self.action['id'] != aId:
- self.parent.MapWindow.ClearLines(pdc = self.parent.MapWindow.pdcTmp)
+ self.MapWindow.ClearLines(pdc = self.MapWindow.pdcTmp)
if self.digit and \
- len(self.parent.MapWindow.digit.GetDisplay().GetSelected()) > 0:
+ len(self.MapWindow.digit.GetDisplay().GetSelected()) > 0:
# cancel action
- self.parent.MapWindow.OnMiddleDown(None)
+ self.MapWindow.OnMiddleDown(None)
# set focus
- self.parent.MapWindow.SetFocus()
+ self.MapWindow.SetFocus()
def OnAddPoint(self, event):
"""!Add point to the vector map Laier"""
@@ -667,7 +672,7 @@
self.action = { 'desc' : "addLine",
'type' : "point",
'id' : self.addPoint }
- self.parent.MapWindow.mouse['box'] = 'point'
+ self.MapWindow.mouse['box'] = 'point'
def OnAddLine(self, event):
"""!Add line to the vector map layer"""
@@ -675,19 +680,19 @@
self.action = { 'desc' : "addLine",
'type' : "line",
'id' : self.addLine }
- self.parent.MapWindow.mouse['box'] = 'line'
- ### self.parent.MapWindow.polycoords = [] # reset temp line
+ self.MapWindow.mouse['box'] = 'line'
+ ### self.MapWindow.polycoords = [] # reset temp line
def OnAddBoundary(self, event):
"""!Add boundary to the vector map layer"""
Debug.msg (2, "VDigitToolbar.OnAddBoundary()")
if self.action['desc'] != 'addLine' or \
self.action['type'] != 'boundary':
- self.parent.MapWindow.polycoords = [] # reset temp line
+ self.MapWindow.polycoords = [] # reset temp line
self.action = { 'desc' : "addLine",
'type' : "boundary",
'id' : self.addBoundary }
- self.parent.MapWindow.mouse['box'] = 'line'
+ self.MapWindow.mouse['box'] = 'line'
def OnAddCentroid(self, event):
"""!Add centroid to the vector map layer"""
@@ -695,7 +700,7 @@
self.action = { 'desc' : "addLine",
'type' : "centroid",
'id' : self.addCentroid }
- self.parent.MapWindow.mouse['box'] = 'point'
+ self.MapWindow.mouse['box'] = 'point'
def OnAddArea(self, event):
"""!Add area to the vector map layer"""
@@ -703,7 +708,7 @@
self.action = { 'desc' : "addLine",
'type' : "area",
'id' : self.addArea }
- self.parent.MapWindow.mouse['box'] = 'line'
+ self.MapWindow.mouse['box'] = 'line'
def OnExit (self, event=None):
"""!Quit digitization tool"""
@@ -716,9 +721,9 @@
self.settingsDialog.OnCancel(None)
# set default mouse settings
- self.parent.MapWindow.mouse['use'] = "pointer"
- self.parent.MapWindow.mouse['box'] = "point"
- self.parent.MapWindow.polycoords = []
+ self.MapWindow.mouse['use'] = "pointer"
+ self.MapWindow.mouse['box'] = "point"
+ self.MapWindow.polycoords = []
# disable the toolbar
self.parent.RemoveToolbar("vdigit")
@@ -728,56 +733,56 @@
Debug.msg(2, "Digittoolbar.OnMoveVertex():")
self.action = { 'desc' : "moveVertex",
'id' : self.moveVertex }
- self.parent.MapWindow.mouse['box'] = 'point'
+ self.MapWindow.mouse['box'] = 'point'
def OnAddVertex(self, event):
"""!Add line vertex"""
Debug.msg(2, "Digittoolbar.OnAddVertex():")
self.action = { 'desc' : "addVertex",
'id' : self.addVertex }
- self.parent.MapWindow.mouse['box'] = 'point'
+ self.MapWindow.mouse['box'] = 'point'
def OnRemoveVertex(self, event):
"""!Remove line vertex"""
Debug.msg(2, "Digittoolbar.OnRemoveVertex():")
self.action = { 'desc' : "removeVertex",
'id' : self.removeVertex }
- self.parent.MapWindow.mouse['box'] = 'point'
+ self.MapWindow.mouse['box'] = 'point'
def OnEditLine(self, event):
"""!Edit line"""
Debug.msg(2, "Digittoolbar.OnEditLine():")
self.action = { 'desc' : "editLine",
'id' : self.editLine }
- self.parent.MapWindow.mouse['box'] = 'line'
+ self.MapWindow.mouse['box'] = 'line'
def OnMoveLine(self, event):
"""!Move line"""
Debug.msg(2, "Digittoolbar.OnMoveLine():")
self.action = { 'desc' : "moveLine",
'id' : self.moveLine }
- self.parent.MapWindow.mouse['box'] = 'box'
+ self.MapWindow.mouse['box'] = 'box'
def OnDeleteLine(self, event):
"""!Delete line"""
Debug.msg(2, "Digittoolbar.OnDeleteLine():")
self.action = { 'desc' : "deleteLine",
'id' : self.deleteLine }
- self.parent.MapWindow.mouse['box'] = 'box'
+ self.MapWindow.mouse['box'] = 'box'
def OnDisplayCats(self, event):
"""!Display/update categories"""
Debug.msg(2, "Digittoolbar.OnDisplayCats():")
self.action = { 'desc' : "displayCats",
'id' : self.displayCats }
- self.parent.MapWindow.mouse['box'] = 'point'
+ self.MapWindow.mouse['box'] = 'point'
def OnDisplayAttr(self, event):
"""!Display/update attributes"""
Debug.msg(2, "Digittoolbar.OnDisplayAttr():")
self.action = { 'desc' : "displayAttrs",
'id' : self.displayAttr }
- self.parent.MapWindow.mouse['box'] = 'point'
+ self.MapWindow.mouse['box'] = 'point'
def OnUndo(self, event):
"""!Undo previous changes"""
@@ -801,9 +806,9 @@
"""!Show settings dialog"""
if self.digit is None:
try:
- self.digit = self.parent.MapWindow.digit = VDigit(mapwindow = self.parent.MapWindow)
+ self.digit = self.MapWindow.digit = VDigit(mapwindow = self.MapWindow)
except SystemExit:
- self.digit = self.parent.MapWindow.digit = None
+ self.digit = self.MapWindow.digit = None
if not self.settingsDialog:
self.settingsDialog = VDigitSettingsDialog(parent = self.parent, title = _("Digitization settings"),
@@ -845,13 +850,13 @@
text = label,
kind = itype)
toolMenu.AppendItem(item)
- self.parent.MapWindow.Bind(wx.EVT_MENU, handler, item)
+ self.MapWindow.Bind(wx.EVT_MENU, handler, item)
if self.action['desc'] == desc:
item.Check(True)
# Popup the menu. If an item is selected then its handler
# will be called before PopupMenu returns.
- self.parent.MapWindow.PopupMenu(toolMenu)
+ self.MapWindow.PopupMenu(toolMenu)
toolMenu.Destroy()
if self.action['desc'] == 'addPoint':
@@ -868,7 +873,7 @@
Debug.msg(2, "Digittoolbar.OnCopy():")
self.action = { 'desc' : "copyLine",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'box'
+ self.MapWindow.mouse['box'] = 'box'
def OnSplitLine(self, event):
"""!Split line"""
@@ -881,7 +886,7 @@
Debug.msg(2, "Digittoolbar.OnSplitLine():")
self.action = { 'desc' : "splitLine",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'point'
+ self.MapWindow.mouse['box'] = 'point'
def OnCopyCats(self, event):
@@ -895,7 +900,7 @@
Debug.msg(2, "Digittoolbar.OnCopyCats():")
self.action = { 'desc' : "copyCats",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'point'
+ self.MapWindow.mouse['box'] = 'point'
def OnCopyAttrb(self, event):
"""!Copy attributes"""
@@ -908,7 +913,7 @@
Debug.msg(2, "Digittoolbar.OnCopyAttrb():")
self.action = { 'desc' : "copyAttrs",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'point'
+ self.MapWindow.mouse['box'] = 'point'
def OnFlip(self, event):
@@ -922,7 +927,7 @@
Debug.msg(2, "Digittoolbar.OnFlip():")
self.action = { 'desc' : "flipLine",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'box'
+ self.MapWindow.mouse['box'] = 'box'
def OnMerge(self, event):
"""!Merge selected lines/boundaries"""
@@ -935,7 +940,7 @@
Debug.msg(2, "Digittoolbar.OnMerge():")
self.action = { 'desc' : "mergeLine",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'box'
+ self.MapWindow.mouse['box'] = 'box'
def OnBreak(self, event):
"""!Break selected lines/boundaries"""
@@ -948,7 +953,7 @@
Debug.msg(2, "Digittoolbar.OnBreak():")
self.action = { 'desc' : "breakLine",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'box'
+ self.MapWindow.mouse['box'] = 'box'
def OnSnap(self, event):
"""!Snap selected features"""
@@ -961,7 +966,7 @@
Debug.msg(2, "Digittoolbar.OnSnap():")
self.action = { 'desc' : "snapLine",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'box'
+ self.MapWindow.mouse['box'] = 'box'
def OnConnect(self, event):
"""!Connect selected lines/boundaries"""
@@ -974,7 +979,7 @@
Debug.msg(2, "Digittoolbar.OnConnect():")
self.action = { 'desc' : "connectLine",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'box'
+ self.MapWindow.mouse['box'] = 'box'
def OnQuery(self, event):
"""!Query selected lines/boundaries"""
@@ -988,7 +993,7 @@
UserSettings.Get(group = 'vdigit', key = 'query', subkey = 'selection'))
self.action = { 'desc' : "queryLine",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'box'
+ self.MapWindow.mouse['box'] = 'box'
def OnZBulk(self, event):
"""!Z bulk-labeling selected lines/boundaries"""
@@ -1006,7 +1011,7 @@
Debug.msg(2, "Digittoolbar.OnZBulk():")
self.action = { 'desc' : "zbulkLine",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'line'
+ self.MapWindow.mouse['box'] = 'line'
def OnTypeConversion(self, event):
"""!Feature type conversion
@@ -1024,7 +1029,7 @@
Debug.msg(2, "Digittoolbar.OnTypeConversion():")
self.action = { 'desc' : "typeConv",
'id' : self.additionalTools }
- self.parent.MapWindow.mouse['box'] = 'box'
+ self.MapWindow.mouse['box'] = 'box'
def OnSelectMap (self, event):
"""!Select vector map layer for editing
@@ -1089,10 +1094,10 @@
@param mapLayer MapLayer to be edited
"""
# deactive layer
- self.mapcontent.ChangeLayerActive(mapLayer, False)
+ self.Map.ChangeLayerActive(mapLayer, False)
# clean map canvas
- self.parent.MapWindow.EraseMap()
+ self.MapWindow.EraseMap()
# unset background map if needed
if mapLayer:
@@ -1105,11 +1110,10 @@
"opening vector map <%s> for editing...") % mapLayer.GetName(),
0)
- self.parent.MapWindow.pdcVector = wx.PseudoDC()
- self.digit = self.parent.MapWindow.digit = VDigit(mapwindow = self.parent.MapWindow)
+ self.MapWindow.pdcVector = wx.PseudoDC()
+ self.digit = self.MapWindow.digit = VDigit(mapwindow = self.MapWindow)
self.mapLayer = mapLayer
-
# open vector map
if self.digit.OpenMap(mapLayer.GetName()) is None:
self.mapLayer = None
@@ -1120,6 +1124,7 @@
fType = self.digit.GetFeatureType()
self.EnableAll()
self.EnableUndo(False)
+
if fType == 'Point':
for tool in (self.addLine, self.addBoundary, self.addCentroid,
self.addArea, self.moveVertex, self.addVertex,
@@ -1144,22 +1149,26 @@
# update toolbar
if self.combo:
self.combo.SetValue(mapLayer.GetName())
- self.parent.toolbars['map'].combo.SetValue (_('Digitize'))
- lmgr = self.parent.GetLayerManager()
- if lmgr:
- lmgr.toolbars['tools'].Enable('vdigit', enable = False)
+ if 'map' in self.parent.toolbars:
+ self.parent.toolbars['map'].combo.SetValue (_('Digitize'))
+ if self.parent.GetName() != "IClassWindow":
+ lmgr = self.parent.GetLayerManager()
+ if lmgr:
+ lmgr.toolbars['tools'].Enable('vdigit', enable = False)
+
Debug.msg (4, "VDigitToolbar.StartEditing(): layer=%s" % mapLayer.GetName())
# change cursor
- if self.parent.MapWindow.mouse['use'] == 'pointer':
- self.parent.MapWindow.SetCursor(self.parent.cursors["cross"])
+ if self.MapWindow.mouse['use'] == 'pointer':
+ self.MapWindow.SetCursor(self.parent.cursors["cross"])
- if not self.parent.MapWindow.resize:
- self.parent.MapWindow.UpdateMap(render = True)
+ if not self.MapWindow.resize:
+ self.MapWindow.UpdateMap(render = True)
# respect opacity
opacity = mapLayer.GetOpacity(float = True)
+
if opacity < 1.0:
alpha = int(opacity * 255)
self.digit.GetDisplay().UpdateSettings(alpha = alpha)
@@ -1206,11 +1215,11 @@
# re-active layer
item = self.parent.tree.FindItemByData('maplayer', self.mapLayer)
if item and self.parent.tree.IsItemChecked(item):
- self.mapcontent.ChangeLayerActive(self.mapLayer, True)
+ self.Map.ChangeLayerActive(self.mapLayer, True)
# change cursor
- self.parent.MapWindow.SetCursor(self.parent.cursors["default"])
- self.parent.MapWindow.pdcVector = None
+ self.MapWindow.SetCursor(self.parent.cursors["default"])
+ self.MapWindow.pdcVector = None
# close dialogs
for dialog in ('attributes', 'category'):
@@ -1219,11 +1228,11 @@
self.parent.dialogs[dialog] = None
del self.digit
- del self.parent.MapWindow.digit
+ del self.MapWindow.digit
self.mapLayer = None
- self.parent.MapWindow.redrawAll = True
+ self.MapWindow.redrawAll = True
return True
@@ -1243,7 +1252,7 @@
# select vector map layer in the current mapset
layerNameList = []
- self.layers = self.mapcontent.GetListOfLayers(l_type = "vector",
+ self.layers = self.Map.GetListOfLayers(l_type = "vector",
l_mapset = grass.gisenv()['MAPSET'])
for layer in self.layers:
Modified: grass/trunk/gui/wxpython/gui_modules/wxvdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxvdigit.py 2011-11-08 23:12:40 UTC (rev 49151)
+++ grass/trunk/gui/wxpython/gui_modules/wxvdigit.py 2011-11-09 10:43:51 UTC (rev 49152)
@@ -36,6 +36,8 @@
from grass.lib.vedit import *
from grass.lib.dbmi import *
+import grass.script.core as grass
+
class VDigitError:
def __init__(self, parent):
"""!Class for managing error messages of vector digitizer
@@ -1397,9 +1399,12 @@
@param map name of vector map to be set up
"""
Debug.msg (3, "AbstractDigit.SetMapName map=%s" % name)
+
+ if '@' in name:
+ name, mapset = name.split('@')
+ else:
+ mapset = grass.gisenv()['MAPSET']
- name, mapset = name.split('@')
-
self.poMapInfo = self._display.OpenMap(str(name), str(mapset), True)
if self.poMapInfo:
More information about the grass-commit
mailing list