[GRASS-SVN] r32685 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 11 09:47:35 EDT 2008
Author: martinl
Date: 2008-08-11 09:47:35 -0400 (Mon, 11 Aug 2008)
New Revision: 32685
Modified:
grass/trunk/gui/wxpython/gui_modules/dbm.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/toolbars.py
Log:
wxGUI: Fix trac #208, "Additional tools" menu dialog broken in digitizer
(merge from devbr6, r32684)
Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py 2008-08-11 13:33:53 UTC (rev 32684)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py 2008-08-11 13:47:35 UTC (rev 32685)
@@ -2739,7 +2739,6 @@
{'vector' : self.map, 'msg' : label},
caption=_("Message"), style=wx.OK | wx.ICON_EXCLAMATION | wx.CENTRE)
self.mapDBInfo = None
- return
wx.Dialog.__init__(self, parent=self.parent, id=wx.ID_ANY,
title="", style=style, pos=pos)
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-08-11 13:33:53 UTC (rev 32684)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-08-11 13:47:35 UTC (rev 32685)
@@ -1095,20 +1095,20 @@
posWindow = self.ClientToScreen((position[0] + self.dialogOffset,
position[1] + self.dialogOffset))
- if digitToolbar.action not in ("moveVertex", "addVertex",
- "removeVertex", "editLine"):
+ if digitToolbar.GetAction() not in ("moveVertex", "addVertex",
+ "removeVertex", "editLine"):
# set pen
self.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
self.polypen = wx.Pen(colour='dark green', width=2, style=wx.SOLID)
- if digitToolbar.action in ("addVertex", "removeVertex"):
+ if digitToolbar.GetAction() in ("addVertex", "removeVertex"):
# unselect
digitClass.driver.SetSelected([])
- if digitToolbar.action == "addLine":
- if digitToolbar.type in ["point", "centroid"]:
+ if digitToolbar.GetAction() == "addLine":
+ if digitToolbar.GetAction('type') in ["point", "centroid"]:
# add new point
- if digitToolbar.type == 'point':
+ if digitToolbar.GetAction('type') == 'point':
point = True
else:
point = False
@@ -1137,20 +1137,20 @@
"--q",
"input=%s" % sqlfile.name])
- elif digitToolbar.type in ["line", "boundary"]:
+ elif digitToolbar.GetAction('type') in ["line", "boundary"]:
# add new point to the line
self.polycoords.append(self.Pixel2Cell(event.GetPositionTuple()[:]))
self.DrawLines(pdc=self.pdcTmp)
- elif digitToolbar.action == "editLine" and hasattr(self, "moveIds"):
+ elif digitToolbar.GetAction() == "editLine" and hasattr(self, "moveIds"):
self.polycoords.append(self.Pixel2Cell(self.mouse['begin']))
self.moveIds.append(wx.NewId())
self.DrawLines(pdc=self.pdcTmp)
- elif digitToolbar.action == "deleteLine":
+ elif digitToolbar.GetAction() == "deleteLine":
pass
- elif digitToolbar.action in ["moveLine", "moveVertex", "editLine"] and \
+ elif digitToolbar.GetAction() in ["moveLine", "moveVertex", "editLine"] and \
not hasattr(self, "moveBegin"):
# incremental value
self.moveBegin = [0, 0]
@@ -1158,7 +1158,7 @@
self.moveCoords = []
# list of ids to modify
self.moveIds = []
- if digitToolbar.action in ["moveVertex", "editLine"]:
+ if digitToolbar.GetAction() in ["moveVertex", "editLine"]:
# set pen
pcolor = UserSettings.Get(group='vdigit', key="symbol",
subkey=["highlight", "color"])
@@ -1166,14 +1166,14 @@
width=2, style=wx.SHORT_DASH)
self.pdcTmp.SetPen(self.polypen)
- elif digitToolbar.action == "splitLine":
+ elif digitToolbar.GetAction() == "splitLine":
# unselect
digitClass.driver.SetSelected([])
- elif digitToolbar.action in ["displayAttrs", "displayCats"]:
+ elif digitToolbar.GetAction() in ["displayAttrs", "displayCats"]:
qdist = digitClass.driver.GetThreshold(type='selectThresh')
coords = (east, north)
- if digitToolbar.action == "displayAttrs":
+ if digitToolbar.GetAction() == "displayAttrs":
# select attributes based on coordinates (all layers)
if self.parent.dialogs['attributes'] is None:
if digitClass.type == 'vedit':
@@ -1215,7 +1215,8 @@
self.parent.dialogs['attributes'].Show()
else:
digitClass.driver.SetSelected([])
- if self.parent.dialogs['attributes'].IsShown():
+ if self.parent.dialogs['attributes'] and \
+ self.parent.dialogs['attributes'].IsShown():
self.parent.dialogs['attributes'].Hide()
else: # displayCats
@@ -1268,18 +1269,18 @@
self.UpdateMap(render=False)
- elif digitToolbar.action == "copyCats":
+ elif digitToolbar.GetAction() == "copyCats":
if not hasattr(self, "copyCatsList"):
self.copyCatsList = []
else:
self.copyCatsIds = []
self.mouse['box'] = 'box'
- elif digitToolbar.action == "copyLine":
+ elif digitToolbar.GetAction() == "copyLine":
self.copyIds = []
self.layerTmp = None
- elif digitToolbar.action == "zbulkLine":
+ elif digitToolbar.GetAction() == "zbulkLine":
if len(self.polycoords) > 1: # start new line
self.polycoords = []
self.ClearLines(pdc=self.pdcTmp)
@@ -1382,16 +1383,16 @@
# eliminate initial mouse moving efect
self.mouse['begin'] = self.mouse['end']
- if digitToolbar.action in ["deleteLine", "moveLine", "moveVertex",
- "copyCats", "editLine", "flipLine",
- "mergeLine", "snapLine",
- "queryLine", "breakLine", "typeConv", "connectLine"]:
+ if digitToolbar.GetAction() in ["deleteLine", "moveLine", "moveVertex",
+ "copyCats", "editLine", "flipLine",
+ "mergeLine", "snapLine",
+ "queryLine", "breakLine", "typeConv", "connectLine"]:
nselected = 0
# -> delete line || move line || move vertex
- if digitToolbar.action in ["moveVertex", "editLine"]:
+ if digitToolbar.GetAction() in ["moveVertex", "editLine"]:
if len(digitClass.driver.GetSelected()) == 0:
nselected = digitClass.driver.SelectLineByPoint(pos1, type=VDigit_Lines_Type)
- if digitToolbar.action == "editLine":
+ if digitToolbar.GetAction() == "editLine":
try:
selVertex = digitClass.driver.GetSelectedVertex(pos1)[0]
except IndexError:
@@ -1423,7 +1424,7 @@
self.UpdateMap(render=False)
- elif digitToolbar.action == "copyCats":
+ elif digitToolbar.GetAction() == "copyCats":
if not hasattr(self, "copyCatsIds"):
# collect categories
nselected = digitClass.driver.SelectLineByPoint(pos1, type=VDigit_Lines_Type)
@@ -1455,7 +1456,7 @@
if nselected > 0:
self.copyCatsIds = digitClass.driver.GetSelected()
- elif digitToolbar.action == "queryLine":
+ elif digitToolbar.GetAction() == "queryLine":
selected = digitClass.SelectLinesByQuery(pos1, pos2)
nselected = len(selected)
if nselected > 0:
@@ -1463,7 +1464,7 @@
else:
# -> moveLine || deleteLine, etc. (select by point/box)
- if digitToolbar.action == 'moveLine' and \
+ if digitToolbar.GetAction() == 'moveLine' and \
len(digitClass.driver.GetSelected()) > 0:
nselected = 0
else:
@@ -1476,13 +1477,13 @@
nselected = 1
if nselected > 0:
- if digitToolbar.action in ["moveLine", "moveVertex"]:
+ if digitToolbar.GetAction() in ["moveLine", "moveVertex"]:
# get pseudoDC id of objects which should be redrawn
- if digitToolbar.action == "moveLine":
+ if digitToolbar.GetAction() == "moveLine":
# -> move line
self.moveIds = digitClass.driver.GetSelected(grassId=False)
- elif digitToolbar.action == "moveVertex":
+ elif digitToolbar.GetAction() == "moveVertex":
# -> move vertex
self.moveIds = digitClass.driver.GetSelectedVertex(pos1)
if len(self.moveIds) == 0: # no vertex found
@@ -1507,22 +1508,22 @@
# update selected
self.UpdateMap(render=False)
- if digitToolbar.action != "editLine":
+ if digitToolbar.GetAction() != "editLine":
# -> move line || move vertex
self.UpdateMap(render=False)
else: # no vector object found
self.UpdateMap(render=False, renderVector=False)
- elif digitToolbar.action in ["splitLine", "addVertex", "removeVertex"]:
+ elif digitToolbar.GetAction() in ["splitLine", "addVertex", "removeVertex"]:
pointOnLine = digitClass.driver.SelectLineByPoint(pos1,
type=VDigit_Lines_Type)
if pointOnLine:
- if digitToolbar.action in ["splitLine", "addVertex"]:
+ if digitToolbar.GetAction() in ["splitLine", "addVertex"]:
self.UpdateMap(render=False) # highlight object
self.DrawCross(pdc=self.pdcTmp, coords=self.Cell2Pixel(pointOnLine),
size=5)
- elif digitToolbar.action == "removeVertex":
+ elif digitToolbar.GetAction() == "removeVertex":
# get only id of vertex
try:
id = digitClass.driver.GetSelectedVertex(pos1)[0]
@@ -1540,7 +1541,7 @@
digitClass.driver.SetSelected([])
self.UpdateMap(render=False)
- elif digitToolbar.action == "copyLine":
+ elif digitToolbar.GetAction() == "copyLine":
if UserSettings.Get(group='vdigit', key='backgroundMap', subkey='value') == '':
# no background map -> copy from current vector map layer
nselected = digitClass.driver.SelectLinesByBox(pos1, pos2,
@@ -1575,7 +1576,7 @@
else:
self.UpdateMap(render=False, renderVector=False)
- elif digitToolbar.action == "zbulkLine" and len(self.polycoords) == 2:
+ elif digitToolbar.GetAction() == "zbulkLine" and len(self.polycoords) == 2:
# select lines to be labeled
pos1 = self.polycoords[0]
pos2 = self.polycoords[1]
@@ -1589,7 +1590,7 @@
else:
self.UpdateMap(render=False, renderVector=False)
- elif digitToolbar.action == "connectLine":
+ elif digitToolbar.GetAction() == "connectLine":
if len(digitClass.driver.GetSelected()) > 0:
self.UpdateMap(render=False)
@@ -1678,17 +1679,17 @@
if digitToolbar:
digitClass = self.parent.digit
# digitization tool (confirm action)
- if digitToolbar.action in ["moveLine", "moveVertex"] and \
+ if digitToolbar.GetAction() in ["moveLine", "moveVertex"] and \
hasattr(self, "moveBegin"):
pTo = self.Pixel2Cell(event.GetPositionTuple())
pFrom = self.moveCoords
move = (pTo[0]-pFrom[0], pTo[1]-pFrom[1])
- if digitToolbar.action == "moveLine":
+ if digitToolbar.GetAction() == "moveLine":
# move line
digitClass.MoveSelectedLines(move)
- elif digitToolbar.action == "moveVertex":
+ elif digitToolbar.GetAction() == "moveVertex":
# move vertex
digitClass.MoveSelectedVertex(pFrom,
move)
@@ -1710,8 +1711,8 @@
if digitToolbar:
digitClass = self.parent.digit
# digitization tool (confirm action)
- if digitToolbar.action == "addLine" and \
- digitToolbar.type in ["line", "boundary"]:
+ if digitToolbar.GetAction() == "addLine" and \
+ digitToolbar.GetAction('type') in ["line", "boundary"]:
# -> add new line / boundary
try:
map = digitToolbar.GetLayer().GetName()
@@ -1726,7 +1727,7 @@
# xy -> EN
# for coord in self.polycoords:
# mapcoords.append(self.Pixel2Cell(coord))
- if digitToolbar.type == 'line':
+ if digitToolbar.GetAction('type') == 'line':
line = True
else:
line = False
@@ -1762,19 +1763,19 @@
executeCommand = gcmd.Command(cmd=["db.execute",
"--q",
"input=%s" % sqlfile.name])
- elif digitToolbar.action == "deleteLine":
+ elif digitToolbar.GetAction() == "deleteLine":
# -> delete selected vector features
digitClass.DeleteSelectedLines()
- elif digitToolbar.action == "splitLine":
+ elif digitToolbar.GetAction() == "splitLine":
# split line
digitClass.SplitLine(self.Pixel2Cell(self.mouse['begin']))
- elif digitToolbar.action == "addVertex":
+ elif digitToolbar.GetAction() == "addVertex":
# add vertex
digitClass.AddVertex(self.Pixel2Cell(self.mouse['begin']))
- elif digitToolbar.action == "removeVertex":
+ elif digitToolbar.GetAction() == "removeVertex":
# remove vertex
digitClass.RemoveVertex(self.Pixel2Cell(self.mouse['begin']))
- elif digitToolbar.action == "copyCats":
+ elif digitToolbar.GetAction() == "copyCats":
try:
digitClass.CopyCats(self.copyCatsList,
self.copyCatsIds)
@@ -1782,25 +1783,25 @@
del self.copyCatsIds
except:
pass
- elif digitToolbar.action == "editLine" and hasattr(self, "moveBegin"):
+ elif digitToolbar.GetAction() == "editLine" and hasattr(self, "moveBegin"):
line = digitClass.driver.GetSelected()
digitClass.EditLine(line, self.polycoords)
del self.moveBegin
del self.moveCoords
del self.moveIds
- elif digitToolbar.action == "flipLine":
+ elif digitToolbar.GetAction() == "flipLine":
digitClass.FlipLine()
- elif digitToolbar.action == "mergeLine":
+ elif digitToolbar.GetAction() == "mergeLine":
digitClass.MergeLine()
- elif digitToolbar.action == "breakLine":
+ elif digitToolbar.GetAction() == "breakLine":
digitClass.BreakLine()
- elif digitToolbar.action == "snapLine":
+ elif digitToolbar.GetAction() == "snapLine":
digitClass.SnapLine()
- elif digitToolbar.action == "connectLine":
+ elif digitToolbar.GetAction() == "connectLine":
if len(digitClass.driver.GetSelected()) > 1:
digitClass.ConnectLine()
- elif digitToolbar.action == "copyLine":
+ elif digitToolbar.GetAction() == "copyLine":
digitClass.CopyLine(self.copyIds)
del self.copyIds
if self.layerTmp:
@@ -1808,7 +1809,7 @@
self.UpdateMap(render=True, renderVector=False)
del self.layerTmp
- elif digitToolbar.action == "zbulkLine" and len(self.polycoords) == 2:
+ elif digitToolbar.GetAction() == "zbulkLine" and len(self.polycoords) == 2:
pos1 = self.polycoords[0]
pos2 = self.polycoords[1]
@@ -1819,13 +1820,13 @@
digitClass.ZBulkLine(pos1, pos2, dlg.value.GetValue(), dlg.step.GetValue())
self.UpdateMap(render=False, renderVector=True)
- elif digitToolbar.action == "typeConv":
+ elif digitToolbar.GetAction() == "typeConv":
# -> feature type conversion
# - point <-> centroid
# - line <-> boundary
digitClass.TypeConvForSelectedLines()
- if digitToolbar.action != "addLine":
+ if digitToolbar.GetAction() != "addLine":
# unselect and re-render
digitClass.driver.SetSelected([])
self.polycoords = []
@@ -1839,8 +1840,8 @@
# digitization tool
if self.mouse["use"] == "pointer" and digitToolbar:
digitClass = self.parent.digit
- if (digitToolbar.action == "addLine" and digitToolbar.type in ["line", "boundary"]) or \
- digitToolbar.action == "editLine":
+ if (digitToolbar.GetAction() == "addLine" and digitToolbar.GetAction('type') in ["line", "boundary"]) or \
+ digitToolbar.GetAction() == "editLine":
# add line or boundary -> remove last point from the line
try:
removed = self.polycoords.pop()
@@ -1851,33 +1852,33 @@
except:
pass
- if digitToolbar.action == "editLine":
+ if digitToolbar.GetAction() == "editLine":
# remove last vertex & line
if len(self.moveIds) > 1:
self.moveIds.pop()
self.UpdateMap(render=False, renderVector=False)
- elif digitToolbar.action in ["deleteLine", "moveLine", "splitLine",
- "addVertex", "removeVertex", "moveVertex",
- "copyCats", "flipLine", "mergeLine",
- "snapLine", "connectLine", "copyLine",
- "queryLine", "breakLine", "typeConv"]:
+ elif digitToolbar.GetAction() in ["deleteLine", "moveLine", "splitLine",
+ "addVertex", "removeVertex", "moveVertex",
+ "copyCats", "flipLine", "mergeLine",
+ "snapLine", "connectLine", "copyLine",
+ "queryLine", "breakLine", "typeConv"]:
# varios tools -> unselected selected features
digitClass.driver.SetSelected([])
- if digitToolbar.action in ["moveLine", "moveVertex", "editLine"] and \
+ if digitToolbar.GetAction() in ["moveLine", "moveVertex", "editLine"] and \
hasattr(self, "moveBegin"):
del self.moveBegin
del self.moveCoords
del self.moveIds
- elif digitToolbar.action == "copyCats":
+ elif digitToolbar.GetAction() == "copyCats":
try:
del self.copyCatsList
del self.copyCatsIds
except:
pass
- elif digitToolbar.action == "copyLine":
+ elif digitToolbar.GetAction() == "copyLine":
del self.copyIds
if self.layerTmp:
self.Map.DeleteLayer(self.layerTmp)
@@ -1887,7 +1888,7 @@
self.polycoords = []
self.UpdateMap(render=False) # render vector
- elif digitToolbar.action == "zbulkLine":
+ elif digitToolbar.GetAction() == "zbulkLine":
# reset polyline
self.polycoords = []
digitClass.driver.SetSelected([])
@@ -1903,10 +1904,10 @@
self.mouse['end'] = event.GetPositionTuple()[:]
Debug.msg (5, "BufferedWindow.OnMouseMoving(): coords=%f,%f" % \
(self.mouse['end'][0], self.mouse['end'][1]))
- if digitToolbar.action == "addLine" and digitToolbar.type in ["line", "boundary"]:
+ if digitToolbar.GetAction() == "addLine" and digitToolbar.GetAction('type') in ["line", "boundary"]:
if len(self.polycoords) > 0:
self.MouseDraw(pdc=self.pdcTmp, begin=self.Cell2Pixel(self.polycoords[-1]))
- elif digitToolbar.action in ["moveLine", "moveVertex", "editLine"] \
+ elif digitToolbar.GetAction() in ["moveLine", "moveVertex", "editLine"] \
and hasattr(self, "moveBegin"):
dx = self.mouse['end'][0] - self.mouse['begin'][0]
dy = self.mouse['end'][1] - self.mouse['begin'][1]
@@ -1914,17 +1915,17 @@
self.moveBegin[1] += dy
if len(self.moveIds) > 0:
# draw lines on new position
- if digitToolbar.action == "moveLine":
+ if digitToolbar.GetAction() == "moveLine":
# move line
for id in self.moveIds:
self.pdcVector.TranslateId(id, dx, dy)
- elif digitToolbar.action in ["moveVertex", "editLine"]:
+ elif digitToolbar.GetAction() in ["moveVertex", "editLine"]:
# move vertex ->
# (vertex, left vertex, left line,
# right vertex, right line)
# do not draw static lines
- if digitToolbar.action == "moveVertex":
+ if digitToolbar.GetAction() == "moveVertex":
self.polycoords = []
self.pdcVector.TranslateId(self.moveIds[0], dx, dy)
if self.moveIds[1] > 0: # previous vertex
@@ -1953,7 +1954,7 @@
self.Refresh() # TODO: use RefreshRect()
self.mouse['begin'] = self.mouse['end']
- elif digitToolbar.action == "zbulkLine":
+ elif digitToolbar.GetAction() == "zbulkLine":
if len(self.polycoords) == 1:
# draw mouse moving
self.MouseDraw(self.pdcTmp)
@@ -2782,8 +2783,8 @@
if self.toggleStatus.GetSelection() == 0: # Coordinates
e, n = self.MapWindow.Pixel2Cell(event.GetPositionTuple())
if self.toolbars['vdigit'] and \
- self.toolbars['vdigit'].action == 'addLine' and \
- self.toolbars['vdigit'].type in ('line', 'boundary') and \
+ self.toolbars['vdigit'].GetAction() == 'addLine' and \
+ self.toolbars['vdigit'].GetAction('type') in ('line', 'boundary') and \
len(self.MapWindow.polycoords) > 0:
# for linear feature show segment and total length
distance_seg = self.MapWindow.Distance(self.MapWindow.polycoords[-1],
@@ -2835,14 +2836,14 @@
self.MapWindow.SetCursor(self.cursors["cross"])
# reset mouse['box'] if needed
- if self.toolbars['vdigit'].action in ['addLine']:
- if self.toolbars['vdigit'].type in ['point', 'centroid']:
+ if self.toolbars['vdigit'].GetAction() in ['addLine']:
+ if self.toolbars['vdigit'].GetAction('type') in ['point', 'centroid']:
self.MapWindow.mouse['box'] = 'point'
else: # line, boundary
self.MapWindow.mouse['box'] = 'line'
- elif self.toolbars['vdigit'].action in ['addVertex', 'removeVertex', 'splitLine',
- 'editLine', 'displayCats', 'displayAttrs',
- 'copyCats']:
+ elif self.toolbars['vdigit'].GetAction() in ['addVertex', 'removeVertex', 'splitLine',
+ 'editLine', 'displayCats', 'displayAttrs',
+ 'copyCats']:
self.MapWindow.mouse['box'] = 'point'
else: # moveLine, deleteLine
self.MapWindow.mouse['box'] = 'box'
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-08-11 13:33:53 UTC (rev 32684)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-08-11 13:47:35 UTC (rev 32685)
@@ -364,11 +364,6 @@
# list of vector layers from Layer Manager (only in the current mapset)
self.layers = []
- # default action (digitize new point, line, etc.)
- self.action = "addLine"
- self.type = "point"
- self.addString = ""
-
self.comboid = None
# only one dialog can be open
@@ -389,6 +384,11 @@
rowdata = row
self.InitToolbar(self.parent, self.toolbar[row], self.ToolbarData(rowdata))
+ # default action (digitize new point, line, etc.)
+ self.action = { 'desc' : 'addLine',
+ 'type' : 'point',
+ 'id' : self.addPoint }
+
# list of available vector maps
self.UpdateListOfLayers(updateTool=True)
@@ -430,49 +430,49 @@
data = [("", "", "", "", "", "", ""),
(self.addPoint, "digAddPoint", Icons["digAddPoint"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digAddPoint"].GetLabel(), Icons["digAddPoint"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digAddPoint"].GetLabel(), Icons["digAddPoint"].GetDesc(),
self.OnAddPoint),
(self.addLine, "digAddLine", Icons["digAddLine"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digAddLine"].GetLabel(), Icons["digAddLine"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digAddLine"].GetLabel(), Icons["digAddLine"].GetDesc(),
self.OnAddLine),
(self.addBoundary, "digAddBoundary", Icons["digAddBoundary"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digAddBoundary"].GetLabel(), Icons["digAddBoundary"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digAddBoundary"].GetLabel(), Icons["digAddBoundary"].GetDesc(),
self.OnAddBoundary),
(self.addCentroid, "digAddCentroid", Icons["digAddCentroid"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digAddCentroid"].GetLabel(), Icons["digAddCentroid"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digAddCentroid"].GetLabel(), Icons["digAddCentroid"].GetDesc(),
self.OnAddCentroid),
(self.moveVertex, "digMoveVertex", Icons["digMoveVertex"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digMoveVertex"].GetLabel(), Icons["digMoveVertex"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digMoveVertex"].GetLabel(), Icons["digMoveVertex"].GetDesc(),
self.OnMoveVertex),
(self.addVertex, "digAddVertex", Icons["digAddVertex"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digAddVertex"].GetLabel(), Icons["digAddVertex"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digAddVertex"].GetLabel(), Icons["digAddVertex"].GetDesc(),
self.OnAddVertex),
(self.removeVertex, "digRemoveVertex", Icons["digRemoveVertex"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digRemoveVertex"].GetLabel(), Icons["digRemoveVertex"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digRemoveVertex"].GetLabel(), Icons["digRemoveVertex"].GetDesc(),
self.OnRemoveVertex),
(self.splitLine, "digSplitLine", Icons["digSplitLine"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digSplitLine"].GetLabel(), Icons["digSplitLine"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digSplitLine"].GetLabel(), Icons["digSplitLine"].GetDesc(),
self.OnSplitLine),
(self.editLine, "digEditLine", Icons["digEditLine"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digEditLine"].GetLabel(), Icons["digEditLine"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digEditLine"].GetLabel(), Icons["digEditLine"].GetDesc(),
self.OnEditLine),
(self.moveLine, "digMoveLine", Icons["digMoveLine"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digMoveLine"].GetLabel(), Icons["digMoveLine"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digMoveLine"].GetLabel(), Icons["digMoveLine"].GetDesc(),
self.OnMoveLine),
(self.deleteLine, "digDeleteLine", Icons["digDeleteLine"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digDeleteLine"].GetLabel(), Icons["digDeleteLine"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digDeleteLine"].GetLabel(), Icons["digDeleteLine"].GetDesc(),
self.OnDeleteLine),
(self.displayCats, "digDispCats", Icons["digDispCats"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digDispCats"].GetLabel(), Icons["digDispCats"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digDispCats"].GetLabel(), Icons["digDispCats"].GetDesc(),
self.OnDisplayCats),
(self.copyCats, "digCopyCats", Icons["digCopyCats"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digCopyCats"].GetLabel(), Icons["digCopyCats"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digCopyCats"].GetLabel(), Icons["digCopyCats"].GetDesc(),
self.OnCopyCats),
(self.displayAttr, "digDispAttr", Icons["digDispAttr"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digDispAttr"].GetLabel(), Icons["digDispAttr"].GetDesc(),
+ wx.ITEM_CHECK, Icons["digDispAttr"].GetLabel(), Icons["digDispAttr"].GetDesc(),
self.OnDisplayAttr),
(self.additionalTools, "digAdditionalTools", Icons["digAdditionalTools"].GetBitmap(),
- wx.ITEM_RADIO, Icons["digAdditionalTools"].GetLabel(),
+ wx.ITEM_CHECK, Icons["digAdditionalTools"].GetLabel(),
Icons["digAdditionalTools"].GetDesc(),
self.OnAdditionalToolMenu)]
@@ -502,37 +502,50 @@
id = self.parent.toolbars['map'].pointer
self.parent.toolbars['map'].toolbar.ToggleTool(id, True)
self.parent.toolbars['map'].mapdisplay.OnPointer(event)
+
if event:
+ # deselect previously selected tool
+ if self.action.has_key('id'):
+ self.toolbar[0].ToggleTool(self.action['id'], False)
+
+ self.action['id'] = event.GetId()
event.Skip()
+ else:
+ # initialize toolbar
+ self.toolbar[0].ToggleTool(self.action['id'], True)
def OnAddPoint(self, event):
"""Add point to the vector map Laier"""
Debug.msg (2, "VDigitToolbar.OnAddPoint()")
- self.action = "addLine"
- self.type = "point"
+ self.action = { 'desc' : "addLine",
+ 'type' : "point",
+ 'id' : self.addPoint }
self.parent.MapWindow.mouse['box'] = 'point'
def OnAddLine(self, event):
"""Add line to the vector map layer"""
Debug.msg (2, "VDigitToolbar.OnAddLine()")
- self.action = "addLine"
- self.type = "line"
+ self.action = { 'desc' : "addLine",
+ 'type' : "line",
+ 'id' : self.addLine }
self.parent.MapWindow.mouse['box'] = 'line'
self.parent.MapWindow.polycoords = [] # reset temp line
def OnAddBoundary(self, event):
"""Add boundary to the vector map layer"""
Debug.msg (2, "VDigitToolbar.OnAddBoundary()")
- self.action = "addLine"
- self.type = "boundary"
+ self.action = { 'desc' : "addLine",
+ 'type' : "boundary",
+ 'id' : self.addBoundary }
self.parent.MapWindow.mouse['box'] = 'line'
self.parent.MapWindow.polycoords = [] # reset temp line
def OnAddCentroid(self, event):
"""Add centroid to the vector map layer"""
Debug.msg (2, "VDigitToolbar.OnAddCentroid()")
- self.action = "addLine"
- self.type = "centroid"
+ self.action = { 'desc' : "addLine",
+ 'type' : "centroid",
+ 'id' : self.addCentroid }
self.parent.MapWindow.mouse['box'] = 'point'
def OnExit (self, event=None):
@@ -557,63 +570,73 @@
def OnMoveVertex(self, event):
"""Move line vertex"""
Debug.msg(2, "Digittoolbar.OnMoveVertex():")
- self.action = "moveVertex"
+ self.action = { 'desc' : "moveVertex",
+ 'id' : self.moveVertex }
self.parent.MapWindow.mouse['box'] = 'point'
def OnAddVertex(self, event):
"""Add line vertex"""
Debug.msg(2, "Digittoolbar.OnAddVertex():")
- self.action = "addVertex"
+ self.action = { 'desc' : "addVertex",
+ 'id' : self.addVertex }
self.parent.MapWindow.mouse['box'] = 'point'
def OnRemoveVertex(self, event):
"""Remove line vertex"""
Debug.msg(2, "Digittoolbar.OnRemoveVertex():")
- self.action = "removeVertex"
+ self.action = { 'desc' : "removeVertex",
+ 'id' : self.removeVertex }
self.parent.MapWindow.mouse['box'] = 'point'
def OnSplitLine(self, event):
"""Split line"""
Debug.msg(2, "Digittoolbar.OnSplitLine():")
- self.action = "splitLine"
+ self.action = { 'desc' : "splitLine",
+ 'id' : self.splitLine }
self.parent.MapWindow.mouse['box'] = 'point'
def OnEditLine(self, event):
"""Edit line"""
Debug.msg(2, "Digittoolbar.OnEditLine():")
- self.action="editLine"
+ self.action = { 'desc' : "editLine",
+ 'id' : self.editLine }
self.parent.MapWindow.mouse['box'] = 'line'
def OnMoveLine(self, event):
"""Move line"""
Debug.msg(2, "Digittoolbar.OnMoveLine():")
- self.action = "moveLine"
+ self.action = { 'desc' : "moveLine",
+ 'id' : self.moveLine }
self.parent.MapWindow.mouse['box'] = 'box'
def OnDeleteLine(self, event):
"""Delete line"""
Debug.msg(2, "Digittoolbar.OnDeleteLine():")
- self.action = "deleteLine"
+ self.action = { 'desc' : "deleteLine",
+ 'id' : self.deleteLine }
self.parent.MapWindow.mouse['box'] = 'box'
def OnDisplayCats(self, event):
"""Display/update categories"""
Debug.msg(2, "Digittoolbar.OnDisplayCats():")
- self.action="displayCats"
+ self.action = { 'desc' : "displayCats",
+ 'id' : self.displayCats }
self.parent.MapWindow.mouse['box'] = 'point'
def OnDisplayAttr(self, event):
"""Display/update attributes"""
Debug.msg(2, "Digittoolbar.OnDisplayAttr():")
- self.action="displayAttrs"
+ self.action = { 'desc' : "displayAttrs",
+ 'id' : self.displayAttr }
self.parent.MapWindow.mouse['box'] = 'point'
def OnCopyCats(self, event):
"""Copy categories"""
Debug.msg(2, "Digittoolbar.OnCopyCats():")
- self.action="copyCats"
+ self.action = { 'desc' : "copyCats",
+ 'id' : self.copyCats }
self.parent.MapWindow.mouse['box'] = 'point'
def OnUndo(self, event):
@@ -655,94 +678,181 @@
point = wx.GetMousePosition()
toolMenu = wx.Menu()
# Add items to the menu
- copy = wx.MenuItem(toolMenu, wx.ID_ANY, _('Copy features from (background) vector map'))
+ copy = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Copy features from (background) vector map'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(copy)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnCopy, copy)
+ if self.action['desc'] == "copyLine":
+ copy.Check(True)
- flip = wx.MenuItem(toolMenu, wx.ID_ANY, _('Flip selected lines/boundaries'))
+ flip = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Flip selected lines/boundaries'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(flip)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnFlip, flip)
+ if self.action['desc'] == "flipLine":
+ flip.Check(True)
- merge = wx.MenuItem(toolMenu, wx.ID_ANY, _('Merge selected lines/boundaries'))
+ merge = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Merge selected lines/boundaries'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(merge)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnMerge, merge)
+ if self.action['desc'] == "mergeLine":
+ merge.Check(True)
- breakL = wx.MenuItem(toolMenu, wx.ID_ANY, _('Break selected lines/boundaries at intersection'))
+ breakL = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Break selected lines/boundaries at intersection'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(breakL)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnBreak, breakL)
+ if self.action['desc'] == "breakLine":
+ breakL.Check(True)
- snap = wx.MenuItem(toolMenu, wx.ID_ANY, _('Snap selected lines/boundaries (only to nodes)'))
+ snap = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Snap selected lines/boundaries (only to nodes)'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(snap)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnSnap, snap)
+ if self.action['desc'] == "snapLine":
+ snap.Check(True)
- connect = wx.MenuItem(toolMenu, wx.ID_ANY, _('Connect selected lines/boundaries'))
+ connect = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Connect selected lines/boundaries'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(connect)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnConnect, connect)
+ if self.action['desc'] == "connectLine":
+ connect.Check(True)
- query = wx.MenuItem(toolMenu, wx.ID_ANY, _('Query tool'))
+ query = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Query features'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(query)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnQuery, query)
+ if self.action['desc'] == "queryLine":
+ query.Check(True)
- zbulk = wx.MenuItem(toolMenu, wx.ID_ANY, _('Z bulk-labeling of 3D lines'))
+ zbulk = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Z bulk-labeling of 3D lines'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(zbulk)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnZBulk, zbulk)
+ if self.action['desc'] == "zbulkLine":
+ zbulk.Check(True)
- typeconv = wx.MenuItem(toolMenu, wx.ID_ANY, _('Feature type conversion'))
+ typeconv = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Feature type conversion'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(typeconv)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnTypeConversion, typeconv)
+ if self.action['desc'] == "typeConv":
+ typeconv.Check(True)
# Popup the menu. If an item is selected then its handler
# will be called before PopupMenu returns.
self.parent.MapWindow.PopupMenu(toolMenu)
toolMenu.Destroy()
+ id = self.parent.toolbars['vdigit'].additionalTools
+ self.parent.toolbars['vdigit'].toolbar[0].ToggleTool(id, True)
+
def OnCopy(self, event):
"""Copy selected features from (background) vector map"""
+ if self.action['desc'] == 'copyLine': # select previous action
+ self.toolbar[0].ToggleTool(self.addPoint, True)
+ self.OnAddPoint(event)
+ return
+
Debug.msg(2, "Digittoolbar.OnCopy():")
- self.action="copyLine"
+ self.action = { 'desc' : "copyLine",
+ 'id' : self.additionalTools }
self.parent.MapWindow.mouse['box'] = 'box'
def OnFlip(self, event):
"""Flip selected lines/boundaries"""
+ if self.action['desc'] == 'flipLine': # select previous action
+ self.toolbar[0].ToggleTool(self.addPoint, True)
+ self.OnAddPoint(event)
+ return
+
Debug.msg(2, "Digittoolbar.OnFlip():")
- self.action="flipLine"
+ self.action = { 'desc' : "flipLine",
+ 'id' : self.additionalTools }
self.parent.MapWindow.mouse['box'] = 'box'
def OnMerge(self, event):
"""Merge selected lines/boundaries"""
+ if self.action['desc'] == 'mergeLine': # select previous action
+ self.toolbar[0].ToggleTool(self.addPoint, True)
+ self.OnAddPoint(event)
+ return
+
Debug.msg(2, "Digittoolbar.OnMerge():")
- self.action="mergeLine"
+ self.action = { 'desc' : "mergeLine",
+ 'id' : self.additionalTools }
self.parent.MapWindow.mouse['box'] = 'box'
def OnBreak(self, event):
"""Break selected lines/boundaries"""
+ if self.action['desc'] == 'breakLine': # select previous action
+ self.toolbar[0].ToggleTool(self.addPoint, True)
+ self.OnAddPoint(event)
+ return
+
Debug.msg(2, "Digittoolbar.OnBreak():")
- self.action="breakLine"
+ self.action = { 'desc' : "breakLine",
+ 'id' : self.additionalTools }
self.parent.MapWindow.mouse['box'] = 'box'
def OnSnap(self, event):
"""Snap selected features"""
+ if self.action['desc'] == 'snapLine': # select previous action
+ self.toolbar[0].ToggleTool(self.addPoint, True)
+ self.OnAddPoint(event)
+ return
+
Debug.msg(2, "Digittoolbar.OnSnap():")
- self.action="snapLine"
+ self.action = { 'desc' : "snapLine",
+ 'id' : self.additionalTools }
self.parent.MapWindow.mouse['box'] = 'box'
def OnConnect(self, event):
"""Connect selected lines/boundaries"""
+ if self.action['desc'] == 'connectLine': # select previous action
+ self.toolbar[0].ToggleTool(self.addPoint, True)
+ self.OnAddPoint(event)
+ return
+
Debug.msg(2, "Digittoolbar.OnConnect():")
- self.action="connectLine"
+ self.action = { 'desc' : "connectLine",
+ 'id' : self.additionalTools }
self.parent.MapWindow.mouse['box'] = 'box'
def OnQuery(self, event):
"""Query selected lines/boundaries"""
+ if self.action['desc'] == 'queryLine': # select previous action
+ self.toolbar[0].ToggleTool(self.addPoint, True)
+ self.OnAddPoint(event)
+ return
+
Debug.msg(2, "Digittoolbar.OnQuery(): %s" % \
UserSettings.Get(group='vdigit', key='query', subkey='selection'))
- self.action="queryLine"
+ self.action = { 'desc' : "queryLine",
+ 'id' : self.additionalTools }
self.parent.MapWindow.mouse['box'] = 'box'
def OnZBulk(self, event):
"""Z bulk-labeling selected lines/boundaries"""
+ if self.action['desc'] == 'zbulkLine': # select previous action
+ self.toolbar[0].ToggleTool(self.addPoint, True)
+ self.OnAddPoint(event)
+ return
+
Debug.msg(2, "Digittoolbar.OnZBulk():")
- self.action="zbulkLine"
+ self.action = { 'desc' : "zbulkLine",
+ 'id' : self.additionalTools }
self.parent.MapWindow.mouse['box'] = 'line'
def OnTypeConversion(self, event):
@@ -752,8 +862,14 @@
- point <-> centroid
- line <-> boundary
"""
+ if self.action['desc'] == 'typeConv': # select previous action
+ self.toolbar[0].ToggleTool(self.addPoint, True)
+ self.OnAddPoint(event)
+ return
+
Debug.msg(2, "Digittoolbar.OnTypeConversion():")
- self.action="typeConv"
+ self.action = { 'desc' : "typeConv",
+ 'id' : self.additionalTools }
self.parent.MapWindow.mouse['box'] = 'box'
def OnSelectMap (self, event):
@@ -941,6 +1057,10 @@
def GetLayer(self):
"""Get selected layer for editing -- MapLayer instance"""
return self.mapLayer
+
+ def GetAction(self, type='desc'):
+ """Get current action info"""
+ return self.action[type]
class ProfileToolbar(AbstractToolbar):
"""
More information about the grass-commit
mailing list