[GRASS-SVN] r30389 - in grass/trunk/gui/wxpython: . gui_modules
icons
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Feb 28 11:04:56 EST 2008
Author: martinl
Date: 2008-02-28 11:04:55 -0500 (Thu, 28 Feb 2008)
New Revision: 30389
Modified:
grass/trunk/gui/wxpython/gui_modules/digit.py
grass/trunk/gui/wxpython/gui_modules/gselect.py
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
grass/trunk/gui/wxpython/icons/icon.py
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: digitization settings moved to UserSettings space
Modified: grass/trunk/gui/wxpython/gui_modules/digit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/digit.py 2008-02-28 12:39:28 UTC (rev 30388)
+++ grass/trunk/gui/wxpython/gui_modules/digit.py 2008-02-28 16:04:55 UTC (rev 30389)
@@ -59,7 +59,7 @@
# (os.linesep, err)
# which interface to use?
-if UserSettings.Get('digitInterface') == 'vedit' and GV_LINES is not None:
+if UserSettings.Get(group='advanced', key='digitInterface', subkey='value') == 'vedit' and GV_LINES is not None:
print >> sys.stderr, "%sWARNING: Digitization tool uses v.edit interface. " \
"This can significantly slow down some operations especially for " \
"middle-large vector maps. "\
@@ -71,7 +71,7 @@
"""
Abstract digitization class
"""
- def __init__(self, mapwindow, settings=None):
+ def __init__(self, mapwindow):
"""Initialization
@param mapwindow reference to mapwindow (MapFrame) instance
@@ -84,54 +84,6 @@
#self.SetCategory()
- # is unique for map window instance
- if not settings:
- self.settings = {}
- # symbology
- # self.settings["symbolBackground"] = (None, (255,255,255, 255)) # white
- self.settings["symbolHighlight"] = (None, (255, 255, 0, 255)) #yellow
- self.settings["symbolPoint"] = (True, (0, 0, 0, 255)) # black
- self.settings["symbolLine"] = (True, (0, 0, 0, 255)) # black
- self.settings["symbolBoundaryNo"] = (True, (126, 126, 126, 255)) # grey
- self.settings["symbolBoundaryOne"] = (True, (0, 255, 0, 255)) # green
- self.settings["symbolBoundaryTwo"] = (True, (255, 135, 0, 255)) # orange
- self.settings["symbolCentroidIn"] = (True, (0, 0, 255, 255)) # blue
- self.settings["symbolCentroidOut"] = (True, (165, 42, 42, 255)) # brown
- self.settings["symbolCentroidDup"] = (True, (156, 62, 206, 255)) # violet
- self.settings["symbolNodeOne"] = (True, (255, 0, 0, 255)) # red
- self.settings["symbolNodeTwo"] = (True, (0, 86, 45, 255)) # dark green
- self.settings["symbolVertex"] = (False, (255, 20, 147, 255)) # deep pink
-
- # display
- self.settings["lineWidth"] = (2, "screen pixels")
-
- # snapping
- self.settings["snapping"] = (10, "screen pixels") # value, unit
- self.settings["snapToVertex"] = False
- self.settings["backgroundMap"] = ''
-
- # digitize new record
- self.settings["addRecord"] = True
- self.settings["layer"] = 1
- self.settings["category"] = 1
- self.settings["categoryMode"] = "Next to use"
-
- # delete existing feature(s)
- self.settings["delRecord"] = True
-
- # query tool
- self.settings["query"] = ("length", True) # name, select by box
- self.settings["queryLength"] = ("shorter than", 0) # gt or lt, threshold
- self.settings["queryDangle"] = ("shorter than", 0)
- # select feature (point, line, centroid, boundary)
- self.settings["selectFeature"] = {}
- self.settings["selectFeature"]["point"] = {'id': None, 'val': True}
- self.settings["selectFeature"]["line"] = {'id': None, 'val': True}
- self.settings["selectFeature"]["centroid"] = {'id': None, 'val': True}
- self.settings["selectFeature"]["boundary"] = {'id': None, 'val': True}
- else:
- self.settings = settings
-
self.driver = CDisplayDriver(self, mapwindow)
def SetCategoryNextToUse(self):
@@ -141,10 +93,10 @@
@return 'True' on success, 'False' on failure
"""
# vector map layer without categories, reset to '1'
- self.settings['category'] = 1
+ UserSettings.Set(group='vdigit', key='category', subkey='value', value=1)
if self.map:
- if UserSettings.Get('digitInterface') == 'vedit':
+ if UserSettings.Get(group='advanced', key='digitInterface', subkey='value') == 'vedit':
categoryCmd = gcmd.Command(cmd=["v.category", "-g", "--q",
"input=%s" % self.map,
"option=report"])
@@ -154,25 +106,26 @@
for line in categoryCmd.ReadStdOutput():
if "all" in line:
- if self.settings['layer'] != int(line.split(' ')[0]):
+ if UserSettings.Get(group='vdigit', key='layer', subkey='value') != int(line.split(' ')[0]):
continue
try:
maxCat = int(line.split(' ')[-1]) + 1
- self.settings['category'] = maxCat
+ UserSettings.Set(group='vdigit', key='category', subkey='value', value=maxCat)
except:
return False
return True
else:
- self.settings['category'] = self.digit.GetCategory(self.settings['layer']) + 1
+ UserSettings.Set(group='vdigit', key='category', subkey='value',
+ value=self.digit.GetCategory(UserSettings.Get(group='vdigit', key='layer', subkey='value') + 1))
def SetCategory(self):
"""Return category number to use (according Settings)"""
- if self.settings["categoryMode"] == "No category":
- self.settings["category"] = 1
- elif self.settings["categoryMode"] == "Next to use":
+ if UserSettings.Get(group='vdigit', key="categoryMode", subkey='value') == "No category":
+ UserSettings.Set(group='vdigit', key="category", subkey='value', value=1)
+ elif UserSettings.Get(group='vdigit', key="categoryMode", subkey='value') == "Next to use":
self.SetCategoryNextToUse()
- return self.settings["category"]
+ return UserSettings.Get(group='vdigit', key="category", subkey='value')
def SetMapName(self, map):
"""Set map name
@@ -198,7 +151,7 @@
'Data are probably corrupted, '
'try to run v.build for rebuilding the topology.') % map)
- if UserSettings.Get('digitInterface') != 'v.edit':
+ if UserSettings.Get(group='advanced', key='digitInterface', subkey='value') != 'v.edit':
try:
self.digit.InitCats()
except:
@@ -208,13 +161,13 @@
"""Generic method used for SelectLinesByQuery()
-- to get threshold value"""
thresh = 0.0
- if self.settings['query'][0] == "length":
- thresh = self.settings['queryLength'][1]
- if self.settings["queryLength"][0] == "shorter than":
+ if UserSettings.Get(group='vdigit', key='query', subkey='type') == "length":
+ thresh = UserSettings.Get(group='vdigit', key='queryLength', subkey='thresh')
+ if UserSettings.Get(group='vdigit', key="queryLength", subkey='than') == "shorter than":
thresh = -1 * thresh
else:
- thresh = self.settings['queryDangle'][1]
- if self.settings["queryDangle"][0] == "shorter than":
+ thresh = UserSettings.Get(group='vdigit', key='queryDangle', subkey='thresh')
+ if UserSettings.Get(group='vdigit', key="queryDangle", subkey='than') == "shorter than":
thresh = -1 * thresh
return thresh
@@ -225,11 +178,11 @@
Used by SelectLinesByBox() and SelectLinesByPoint()"""
type = 0
- for feature in (('point', vdigit.GV_POINT),
- ('line', vdigit.GV_LINE),
- ('centroid', vdigit.GV_CENTROID),
- ('boundary', vdigit.GV_BOUNDARY)):
- if self.settings['selectFeature'][feature[0]]['val'] is True:
+ for feature in (('Point', vdigit.GV_POINT),
+ ('Line', vdigit.GV_LINE),
+ ('Centroid', vdigit.GV_CENTROID),
+ ('Boundary', vdigit.GV_BOUNDARY)):
+ if UserSettings.Get(group='vdigit', key='selectFeature'+feature[0], subkey='enabled') is True:
type |= feature[1]
return type
@@ -240,7 +193,7 @@
@param pos1,pos2 bounding box defifinition
"""
- if self.settings['backgroundMap'] == '':
+ if UserSettings.Get(group='vdigit', key='backgroundMap', subkey='value') == '':
Debug.msg(4, "VEdit.SelectLinesFromBackgroundMap(): []")
return []
@@ -249,7 +202,7 @@
vEditCmd = gcmd.Command(['v.edit',
'--q',
- 'map=%s' % self.settings['backgroundMap'],
+ 'map=%s' % UserSettings.Get(group='vdigit', key='backgroundMap', subkey='value'),
'tool=select',
'bbox=%f,%f,%f,%f' % (pos1[0], pos1[1], pos2[0], pos2[1])])
#'polygon=%f,%f,%f,%f,%f,%f,%f,%f,%f,%f' % \
@@ -273,13 +226,13 @@
Note: This should be replaced by VDigit class.
"""
- def __init__(self, mapwindow, settings=None):
+ def __init__(self, mapwindow):
"""Initialization
@param mapwindow reference to mapwindow (MapFrame) instance
@param settings initial settings of digitization tool
"""
- AbstractDigit.__init__(self, mapwindow, settings)
+ AbstractDigit.__init__(self, mapwindow)
def AddPoint (self, map, point, x, y, z=None):
"""Add point/centroid
@@ -293,7 +246,7 @@
else:
key = "C"
- layer = self.settings["layer"]
+ layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
cat = self.SetCategory()
if layer > 0 and cat != "None":
@@ -325,7 +278,7 @@
if len(coords) < 2:
return
- layer = self.settings["layer"]
+ layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
cat = self.SetCategory()
if line:
@@ -363,10 +316,10 @@
@param input feature definition in GRASS ASCII format
@param flags additional flags
"""
- if self.settings['snapping'][0] <= 0.0:
+ if UserSettings.Get(group='vdigit', key='snapping', subkey='value') <= 0.0:
snap = "no"
else:
- if self.settings['snapToVertex']:
+ if UserSettings.Get(group='vdigit', key='snapToVertex', subkey='enabled') is True:
snap = "vertex"
else:
snap = "node"
@@ -377,8 +330,8 @@
"thresh=%f" % self.driver.GetThreshold(),
"snap=%s" % snap]
- if self.settings['backgroundMap'] != '':
- command.append("bgmap=%s" % self.settings['backgroundMap'])
+ if UserSettings.Get(group='vdigit', key='backgroundMap', subkey='value') != '':
+ command.append("bgmap=%s" % UserSettings.Get(group='vdigit', key='backgroundMap', subkey='value'))
# additional flags
for flag in flags:
@@ -404,7 +357,7 @@
ids)
# delete also attributes if requested
- if self.settings['delRecord'] is True:
+ if UserSettings.Get(group='vdigit', key='delRecord', subkey='enabled') is True:
layerCommand = gcmd.Command(cmd=["v.db.connect",
"-g", "--q",
"map=%s" % self.map],
@@ -486,10 +439,10 @@
Debug.msg(4, "Digit.MoveSelectedLines(): ids=%s, move=%s" % \
(ids, move))
- if self.settings['snapping'][0] <= 0:
+ if UserSettings.Get(group='vdigit', key='snapping', subkey='value') <= 0.0:
snap = "no"
else:
- if self.settings['snapToVertex']:
+ if UserSettings.Get(group='vdigit', key='snapToVertex', subkey='enabled') is True:
snap = "vertex"
else:
snap = "node"
@@ -507,8 +460,8 @@
command.append("coords=%f,%f" % (float(coords[0]), float(coords[1])))
command.append("-1") # modify only first selected
- if self.settings['backgroundMap'] != '':
- command.append("bgmap=%s" % self.settings['backgroundMap'])
+ if UserSettings.Get(group='vdigit', key='backgroundMap', subkey='value') != '':
+ command.append("bgmap=%s" % UserSettings.Get(group='vdigit', key='backgroundMap', subkey='value'))
# run the command
vedit = gcmd.Command(cmd=command, stderr=None)
@@ -691,8 +644,8 @@
'tool=copy',
'ids=%s' % ",".join(["%d" % v for v in ids])]
- if self.settings['backgroundMap'] != '':
- vEdit.append('bgmap=%s' % self.settings['backgroundMap'])
+ if UserSettings.Get(group='vdigit', key='backgroundMap', subkey='value') != '':
+ vEdit.append('bgmap=%s' % UserSettings.Get(group='vdigit', key='backgroundMap', subkey='value'))
runCmd = gcmd.Command(vEdit)
@@ -733,7 +686,7 @@
w, n = pos1
e, s = pos2
- if self.settings['query'][1] == False: # select globaly
+ if UserSettings.Get(group='vdigit', key='query', subkey='box') == False: # select globaly
vInfo = gcmd.Command(['v.info',
'map=%s' % self.map,
'-g'])
@@ -752,7 +705,7 @@
'map=%s' % self.map,
'tool=select',
'bbox=%f,%f,%f,%f' % (w, n, e, s),
- 'query=%s' % self.settings['query'][0],
+ 'query=%s' % UserSettings.Get(group='vdigit', key='query', subkey='thresh'),
'thresh=%f' % thresh])
vEditCmd = gcmd.Command(vEdit)
@@ -790,13 +743,13 @@
Under development (wxWidgets C/C++ background)
"""
- def __init__(self, mapwindow, settings=None):
+ def __init__(self, mapwindow):
"""Initialization
@param mapwindow reference to mapwindow (MapFrame) instance
@param settings initial settings of digitization tool
"""
- AbstractDigit.__init__(self, mapwindow, settings)
+ AbstractDigit.__init__(self, mapwindow)
try:
self.digit = vdigit.Digit(self.driver.GetDevice())
@@ -810,7 +763,7 @@
@param point feature type (if true point otherwise centroid)
@param x,y,z coordinates
"""
- layer = self.settings["layer"]
+ layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
cat = self.SetCategory()
if point:
@@ -822,10 +775,10 @@
if z:
ret = self.digit.AddLine(type, [x, y, z], layer, cat,
- str(self.settings["backgroundMap"]), snap, thresh)
+ str(UserSettings.Get(group='vdigit', key="backgroundMap", subkey='value'), snap, thresh))
else:
ret = self.digit.AddLine(type, [x, y], layer, cat,
- str(self.settings["backgroundMap"]), snap, thresh)
+ str(UserSettings.Get(group='vdigit', key="backgroundMap", subkey='value'), snap, thresh))
if ret == -1:
raise gcmd.DigitError, _("Adding new feature to vector map <%s> failed.") % map
@@ -840,7 +793,7 @@
if len(coords) < 2:
return
- layer = self.settings["layer"]
+ layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
cat = self.SetCategory()
if line:
@@ -856,7 +809,7 @@
snap, thresh = self.__getSnapThreshold()
ret = self.digit.AddLine(type, listCoords, layer, cat,
- str(self.settings["backgroundMap"]), snap, thresh)
+ str(UserSettings.Get(group='vdigit', key="backgroundMap", subkey='value'), snap, thresh))
if ret == -1:
raise gcmd.DigitError, _("Adding new feature to vector map <%s> failed.") % map
@@ -867,7 +820,7 @@
@return number of deleted lines
"""
- nlines = self.digit.DeleteLines(self.settings['delRecord'])
+ nlines = self.digit.DeleteLines(UserSettings.Get(group='vdigit', key='delRecord', subkey='enabled'))
return nlines
@@ -879,7 +832,7 @@
snap, thresh = self.__getSnapThreshold()
nlines = self.digit.MoveLines(move[0], move[1], 0.0, # TODO 3D
- str(self.settings["backgroundMap"]), snap, thresh)
+ str(UserSettings.Get(group='vdigit', key="backgroundMap", subkey='value'), snap, thresh))
return nlines
@@ -896,7 +849,7 @@
return self.digit.MoveVertex(coords[0], coords[1], 0.0, # TODO 3D
move[0], move[1], 0.0,
- str(self.settings["backgroundMap"]), snap, thresh)
+ str(UserSettings.Get(group='vdigit', key="backgroundMap", subkey='value')), snap, thresh)
def AddVertex(self, coords):
"""Add new vertex to the selected line/boundary on position 'coords'
@@ -945,7 +898,7 @@
snap, thresh = self.__getSnapThreshold()
return self.digit.RewriteLine(lineid, listCoords,
- str(self.settings["backgroundMap"]), snap, thresh)
+ str(UserSettings.Get(group='vdigit', key="backgroundMap", subkey='value')), snap, thresh)
def FlipLine(self):
"""Flip selected lines/boundaries"""
@@ -974,7 +927,7 @@
@param ids list of line ids to be copied
"""
- return self.digit.CopyLines(ids, str(self.settings['backgroundMap']))
+ return self.digit.CopyLines(ids, str(UserSettings.Get(group='vdigit', key='backgroundMap', subkey='value')))
def CopyCats(self, cats, ids):
"""Copy given categories to objects with id listed in ids
@@ -998,14 +951,14 @@
e, s = pos2
query = vdigit.QUERY_UNKNOWN
- if self.settings['query'][0] == 'length':
+ if UserSettings.Get(group='vdigit', key='query', subkey='type') == 'length':
query = vdigit.QUERY_LENGTH
- elif self.settings['query'][0] == 'dangle':
+ elif UserSettings.Get(group='vdigit', key='query', subkey='type') == 'dangle':
query = vdigit.QUERY_DANGLE
type = vdigit.GV_POINTS | vdigit.GV_LINES # TODO: 3D
- ids = self.digit.SelectLinesByQuery(w, n, 0.0, e, s, 1000.0, self.settings['query'][1],
+ ids = self.digit.SelectLinesByQuery(w, n, 0.0, e, s, 1000.0, UserSettings.Get(group='vdigit', key='query', subkey='box'),
query, type, thresh)
Debug.msg(4, "VDigit.SelectLinesByQuery(): %s" % \
@@ -1054,7 +1007,7 @@
thresh = self.driver.GetThreshold()
if thresh > 0.0:
- if self.settings['snapToVertex']:
+ if UserSettings.Get(group='vdigit', key='snapToVertex', subkey='enabled') is True:
snap = vdigit.SNAPVERTEX
else:
snap = vdigit.SNAP
@@ -1063,7 +1016,7 @@
return (snap, thresh)
-if UserSettings.Get('digitInterface') == 'vedit':
+if UserSettings.Get(group='advanced', key='digitInterface', subkey='value') == 'vedit':
class Digit(VEdit):
"""Default digit class"""
def __init__(self, mapwindow):
@@ -1097,10 +1050,10 @@
@param units units (map, screen)
"""
if not value:
- value = self.parent.settings["snapping"][0]
+ value = UserSettings.Get(group='vdigit', key="snapping", subkey='value')
if not units:
- units = self.parent.settings["snapping"][1]
+ units = UserSettings.Get(group='vdigit', key="snapping", subkey='units')
if units == "screen pixels":
# pixel -> cell
@@ -1138,7 +1091,6 @@
except:
self.__display = None
- settings = self.parent.settings
self.UpdateSettings()
def GetDevice(self):
@@ -1167,7 +1119,7 @@
if map:
name, mapset = map.split('@')
try:
- if UserSettings.Get('digitInterface') == 'vedit':
+ if UserSettings.Get(group='advanced', key='digitInterface', subkey='value') == 'vedit':
ret = self.__display.OpenMap(str(name), str(mapset), False)
else:
ret = self.__display.OpenMap(str(name), str(mapset), True)
@@ -1295,72 +1247,71 @@
def UpdateSettings(self):
"""Update display driver settings"""
- settings = self.parent.settings
# TODO map units
if not self.__display:
return
- self.__display.UpdateSettings (wx.Color(settings['symbolHighlight'][1][0],
- settings['symbolHighlight'][1][1],
- settings['symbolHighlight'][1][2],
+ self.__display.UpdateSettings (wx.Color(UserSettings.Get(group='vdigit', key='symbolHighlight', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolHighlight', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolHighlight', subkey='color')[2],
255).GetRGB(),
- settings['symbolPoint'][0],
- wx.Color(settings['symbolPoint'][1][0],
- settings['symbolPoint'][1][1],
- settings['symbolPoint'][1][2],
+ UserSettings.Get(group='vdigit', key='symbolPoint', subkey='enabled'),
+ wx.Color(UserSettings.Get(group='vdigit', key='symbolPoint', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolPoint', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolPoint', subkey='color')[2],
255).GetRGB(),
- settings['symbolLine'][0],
- wx.Color(settings['symbolLine'][1][0],
- settings['symbolLine'][1][1],
- settings['symbolLine'][1][2],
+ UserSettings.Get(group='vdigit', key='symbolLine', subkey='enabled'),
+ wx.Color(UserSettings.Get(group='vdigit', key='symbolLine', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolLine', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolLine', subkey='color')[2],
255).GetRGB(),
- settings['symbolBoundaryNo'][0],
- wx.Color(settings['symbolBoundaryNo'][1][0],
- settings['symbolBoundaryNo'][1][1],
- settings['symbolBoundaryNo'][1][2],
+ UserSettings.Get(group='vdigit', key='symbolBoundaryNo', subkey='enabled'),
+ wx.Color(UserSettings.Get(group='vdigit', key='symbolBoundaryNo', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolBoundaryNo', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolBoundaryNo', subkey='color')[2],
255).GetRGB(),
- settings['symbolBoundaryOne'][0],
- wx.Color(settings['symbolBoundaryOne'][1][0],
- settings['symbolBoundaryOne'][1][1],
- settings['symbolBoundaryOne'][1][2],
+ UserSettings.Get(group='vdigit', key='symbolBoundaryOne', subkey='enabled'),
+ wx.Color(UserSettings.Get(group='vdigit', key='symbolBoundaryOne', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolBoundaryOne', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolBoundaryOne', subkey='color')[2],
255).GetRGB(),
- settings['symbolBoundaryTwo'][0],
- wx.Color(settings['symbolBoundaryTwo'][1][0],
- settings['symbolBoundaryTwo'][1][1],
- settings['symbolBoundaryTwo'][1][2],
+ UserSettings.Get(group='vdigit', key='symbolBoundaryTwo', subkey='enabled'),
+ wx.Color(UserSettings.Get(group='vdigit', key='symbolBoundaryTwo', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolBoundaryTwo', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolBoundaryTwo', subkey='color')[2],
255).GetRGB(),
- settings['symbolCentroidIn'][0],
- wx.Color(settings['symbolCentroidIn'][1][0],
- settings['symbolCentroidIn'][1][1],
- settings['symbolCentroidIn'][1][2],
+ UserSettings.Get(group='vdigit', key='symbolCentroidIn', subkey='enabled'),
+ wx.Color(UserSettings.Get(group='vdigit', key='symbolCentroidIn', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolCentroidIn', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolCentroidIn', subkey='color')[2],
255).GetRGB(),
- settings['symbolCentroidOut'][0],
- wx.Color(settings['symbolCentroidOut'][1][0],
- settings['symbolCentroidOut'][1][1],
- settings['symbolCentroidOut'][1][2],
+ UserSettings.Get(group='vdigit', key='symbolCentroidOut', subkey='enabled'),
+ wx.Color(UserSettings.Get(group='vdigit', key='symbolCentroidOut', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolCentroidOut', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolCentroidOut', subkey='color')[2],
255).GetRGB(),
- settings['symbolCentroidDup'][0],
- wx.Color(settings['symbolCentroidDup'][1][0],
- settings['symbolCentroidDup'][1][1],
- settings['symbolCentroidDup'][1][2],
+ UserSettings.Get(group='vdigit', key='symbolCentroidDup', subkey='enabled'),
+ wx.Color(UserSettings.Get(group='vdigit', key='symbolCentroidDup', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolCentroidDup', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolCentroidDup', subkey='color')[2],
255).GetRGB(),
- settings['symbolNodeOne'][0],
- wx.Color(settings['symbolNodeOne'][1][0],
- settings['symbolNodeOne'][1][1],
- settings['symbolNodeOne'][1][2],
+ UserSettings.Get(group='vdigit', key='symbolNodeOne', subkey='enabled'),
+ wx.Color(UserSettings.Get(group='vdigit', key='symbolNodeOne', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolNodeOne', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolNodeOne', subkey='color')[2],
255).GetRGB(),
- settings['symbolNodeTwo'][0],
- wx.Color(settings['symbolNodeTwo'][1][0],
- settings['symbolNodeTwo'][1][1],
- settings['symbolNodeTwo'][1][2],
+ UserSettings.Get(group='vdigit', key='symbolNodeTwo', subkey='enabled'),
+ wx.Color(UserSettings.Get(group='vdigit', key='symbolNodeTwo', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolNodeTwo', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolNodeTwo', subkey='color')[2],
255).GetRGB(),
- settings['symbolVertex'][0],
- wx.Color(settings['symbolVertex'][1][0],
- settings['symbolVertex'][1][1],
- settings['symbolVertex'][1][2],
+ UserSettings.Get(group='vdigit', key='symbolVertex', subkey='enabled'),
+ wx.Color(UserSettings.Get(group='vdigit', key='symbolVertex', subkey='color')[0],
+ UserSettings.Get(group='vdigit', key='symbolVertex', subkey='color')[1],
+ UserSettings.Get(group='vdigit', key='symbolVertex', subkey='color')[2],
255).GetRGB(),
- settings['lineWidth'][0])
+ UserSettings.Get(group='vdigit', key='lineWidth', subkey='value'))
class DigitSettingsDialog(wx.Dialog):
"""
@@ -1419,8 +1370,8 @@
for label, key in self.__SymbologyData():
textLabel = wx.StaticText(panel, wx.ID_ANY, label)
color = csel.ColourSelect(panel, id=wx.ID_ANY,
- colour=self.parent.digit.settings[key][1], size=(25, 25))
- isEnabled = self.parent.digit.settings[key][0]
+ colour=UserSettings.Get(group='vdigit', key=key, subkey='color'), size=(25, 25))
+ isEnabled = UserSettings.Get(group='vdigit', key=key, subkey='enabled')
if isEnabled is not None:
enabled = wx.CheckBox(panel, id=wx.ID_ANY, label="")
enabled.SetValue(isEnabled)
@@ -1456,15 +1407,16 @@
flexSizer.AddGrowableCol(0)
# line width
text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Line width"))
- self.lineWidthValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(50, -1),
- initial=self.parent.digit.settings["lineWidth"][0],
+ self.lineWidthValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(75, -1),
+ initial=UserSettings.Get(group='vdigit', key="lineWidth", subkey='value'),
min=1, max=1e6)
- self.lineWidthUnit = wx.Choice(parent=panel, id=wx.ID_ANY, size=(125, -1),
- choices=["screen pixels", "map units"])
- self.lineWidthUnit.SetStringSelection(self.parent.digit.settings["lineWidth"][1])
+ units = wx.StaticText(parent=panel, id=wx.ID_ANY, size=(115, -1),
+ label=UserSettings.Get(group='vdigit', key="lineWidth", subkey='units'),
+ style=wx.ALIGN_LEFT)
flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
flexSizer.Add(self.lineWidthValue, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
- flexSizer.Add(self.lineWidthUnit, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
+ flexSizer.Add(units, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
+ border=10)
sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1)
border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)
@@ -1480,13 +1432,13 @@
flexSizer2.AddGrowableCol(0)
# snapping
text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Snapping threshold"))
- self.snappingValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(50, -1),
- initial=self.parent.digit.settings["snapping"][0],
+ self.snappingValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(75, -1),
+ initial=UserSettings.Get(group='vdigit', key="snapping", subkey='value'),
min=1, max=1e6)
self.snappingValue.Bind(wx.EVT_SPINCTRL, self.OnChangeSnappingValue)
self.snappingUnit = wx.Choice(parent=panel, id=wx.ID_ANY, size=(125, -1),
choices=["screen pixels", "map units"])
- self.snappingUnit.SetStringSelection(self.parent.digit.settings["snapping"][1])
+ self.snappingUnit.SetStringSelection(UserSettings.Get(group='vdigit', key="snapping", subkey='units'))
self.snappingUnit.Bind(wx.EVT_CHOICE, self.OnChangeSnappingUnits)
flexSizer1.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
flexSizer1.Add(self.snappingValue, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
@@ -1495,7 +1447,7 @@
text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Backgroud vector map"))
self.backgroundMap = gselect.Select(parent=panel, id=wx.ID_ANY, size=(200,-1),
type="vector")
- self.backgroundMap.SetValue(self.parent.digit.settings["backgroundMap"])
+ self.backgroundMap.SetValue(UserSettings.Get(group='vdigit', key="backgroundMap", subkey='value'))
self.backgroundMap.Bind(wx.EVT_TEXT, self.OnChangeBackgroundMap)
flexSizer2.Add(text, proportion=1, flag=wx.ALIGN_CENTER_VERTICAL)
flexSizer2.Add(self.backgroundMap, proportion=1, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
@@ -1504,7 +1456,7 @@
vertexSizer = wx.BoxSizer(wx.VERTICAL)
self.snapVertex = wx.CheckBox(parent=panel, id=wx.ID_ANY,
label=_("Snap also to vertex"))
- self.snapVertex.SetValue(self.parent.digit.settings["snapToVertex"])
+ self.snapVertex.SetValue(UserSettings.Get(group='vdigit', key="snapToVertex", subkey='enabled'))
vertexSizer.Add(item=self.snapVertex, proportion=0, flag=wx.EXPAND)
self.mapUnits = self.parent.MapWindow.Map.ProjInfo()['units']
self.snappingInfo = wx.StaticText(parent=panel, id=wx.ID_ANY,
@@ -1527,7 +1479,7 @@
# checkbox
self.addRecord = wx.CheckBox(parent=panel, id=wx.ID_ANY,
label=_("Add new record into table"))
- self.addRecord.SetValue(self.parent.digit.settings["addRecord"])
+ self.addRecord.SetValue(UserSettings.Get(group='vdigit', key="addRecord", subkey='enabled'))
sizer.Add(item=self.addRecord, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)
# settings
flexSizer = wx.FlexGridSizer(cols=2, hgap=3, vgap=3)
@@ -1538,22 +1490,22 @@
if self.parent.digit.map:
layers = map(str, self.parent.digit.GetLayers())
if len(layers) == 0:
- layers = [str(self.parent.digit.settings["layer"]), ]
+ layers = [str(UserSettings.Get(group='vdigit', key="layer", subkey='value')), ]
else:
- layers = [str(self.parent.digit.settings["layer"]), ]
+ layers = [str(UserSettings.Get(group='vdigit', key="layer", subkey='value')), ]
self.layer = wx.Choice(parent=panel, id=wx.ID_ANY, size=(125, -1),
choices=layers)
- self.layer.SetStringSelection(str(self.parent.digit.settings["layer"]))
+ self.layer.SetStringSelection(str(UserSettings.Get(group='vdigit', key="layer", subkey='value')))
flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
flexSizer.Add(item=self.layer, proportion=0,
flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
# category number
text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Category number"))
self.category = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(125, -1),
- initial=self.parent.digit.settings["category"],
+ initial=UserSettings.Get(group='vdigit', key="category", subkey='value'),
min=-1e9, max=1e9)
- if self.parent.digit.settings["categoryMode"] != "Manual entry":
+ if UserSettings.Get(group='vdigit', key="categoryMode", subkey='value') != "Manual entry":
self.category.Enable(False)
flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
flexSizer.Add(item=self.category, proportion=0,
@@ -1562,7 +1514,7 @@
text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Category mode"))
self.categoryMode = wx.Choice(parent=panel, id=wx.ID_ANY, size=(125, -1),
choices=[_("Next to use"), _("Manual entry"), _("No category")])
- self.categoryMode.SetStringSelection(self.parent.digit.settings["categoryMode"])
+ self.categoryMode.SetStringSelection(UserSettings.Get(group='vdigit', key="categoryMode", subkey='value'))
flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
flexSizer.Add(item=self.categoryMode, proportion=0,
flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
@@ -1576,7 +1528,7 @@
# checkbox
self.deleteRecord = wx.CheckBox(parent=panel, id=wx.ID_ANY,
label=_("Delete record from table"))
- self.deleteRecord.SetValue(self.parent.digit.settings["delRecord"])
+ self.deleteRecord.SetValue(UserSettings.Get(group='vdigit', key="delRecord", subkey='enabled'))
sizer.Add(item=self.deleteRecord, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)
border.Add(item=sizer, proportion=0,
flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
@@ -1593,8 +1545,6 @@
def __CreateQueryPage(self, notebook):
"""Create notebook page for query tool"""
- settings = self.parent.digit.settings
-
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
notebook.AddPage(page=panel, text=_("Query tool"))
@@ -1609,7 +1559,7 @@
LocUnits = self.parent.MapWindow.Map.ProjInfo()['units']
self.queryBox = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_("Select by box"))
- self.queryBox.SetValue(settings["query"][1])
+ self.queryBox.SetValue(UserSettings.Get(group='vdigit', key="query", subkey='box'))
sizer.Add(item=self.queryBox, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)
sizer.Add((0, 5))
@@ -1625,11 +1575,11 @@
txt = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Select lines"))
self.queryLengthSL = wx.Choice (parent=panel, id=wx.ID_ANY,
choices = [_("shorter than"), _("longer than")])
- self.queryLengthSL.SetStringSelection(settings["queryLength"][0])
+ self.queryLengthSL.SetStringSelection(UserSettings.Get(group='vdigit', key="queryLength", subkey='than'))
self.queryLengthValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(100, -1),
initial=1,
min=0, max=1e6)
- self.queryLengthValue.SetValue(settings["queryLength"][1])
+ self.queryLengthValue.SetValue(UserSettings.Get(group='vdigit', key="queryLength", subkey='thresh'))
units = wx.StaticText(parent=panel, id=wx.ID_ANY, label="%s" % LocUnits)
flexSizer.Add(txt, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
flexSizer.Add(self.queryLengthSL, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
@@ -1648,11 +1598,11 @@
txt = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Select dangles"))
self.queryDangleSL = wx.Choice (parent=panel, id=wx.ID_ANY,
choices = [_("shorter than"), _("longer than")])
- self.queryDangleSL.SetStringSelection(settings["queryDangle"][0])
+ self.queryDangleSL.SetStringSelection(UserSettings.Get(group='vdigit', key="queryDangle", subkey='than'))
self.queryDangleValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(100, -1),
initial=1,
min=0, max=1e6)
- self.queryDangleValue.SetValue(settings["queryDangle"][1])
+ self.queryDangleValue.SetValue(UserSettings.Get(group='vdigit', key="queryDangle", subkey='thresh'))
units = wx.StaticText(parent=panel, id=wx.ID_ANY, label="%s" % LocUnits)
flexSizer.Add(txt, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
flexSizer.Add(self.queryDangleSL, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
@@ -1660,7 +1610,7 @@
flexSizer.Add(units, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
sizer.Add(item=flexSizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)
- if settings["query"][0] == "length":
+ if UserSettings.Get(group='vdigit', key="query", subkey='type') == "length":
self.queryLength.SetValue(True)
else:
self.queryDangle.SetValue(True)
@@ -1674,17 +1624,33 @@
# select box
#
box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Select vector features"))
- sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
- for feature in ('point', 'line',
- 'centroid', 'boundary'):
+ # feature type
+ sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+ inSizer = wx.BoxSizer(wx.HORIZONTAL)
+ self.selectFeature = {}
+ for feature in ('Point', 'Line',
+ 'Centroid', 'Boundary'):
chkbox = wx.CheckBox(parent=panel, label=feature)
- settings['selectFeature'][feature]['id'] = chkbox.GetId()
- chkbox.SetValue(settings['selectFeature'][feature]['val'])
- sizer.Add(item=chkbox, proportion=0,
- flag=wx.EXPAND | wx.ALL, border=3)
-
- border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)
-
+ self.selectFeature[feature] = chkbox.GetId()
+ chkbox.SetValue(UserSettings.Get(group='vdigit', key='selectFeature'+feature, subkey='enabled'))
+ inSizer.Add(item=chkbox, proportion=0,
+ flag=wx.EXPAND | wx.ALL, border=5)
+ sizer.Add(item=inSizer, proportion=0, flag=wx.EXPAND)
+ # threshold
+ flexSizer = wx.FlexGridSizer (cols=3, hgap=5, vgap=5)
+ flexSizer.AddGrowableCol(0)
+ text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Select threshold"))
+ self.selectThreshValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(75, -1),
+ initial=UserSettings.Get(group='vdigit', key="selectThresh", subkey='value'),
+ min=1, max=1e6)
+ units = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("screen pixels"))
+ flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
+ flexSizer.Add(self.selectThreshValue, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
+ flexSizer.Add(units, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
+ sizer.Add(item=flexSizer, proportion=0, flag=wx.EXPAND)
+
+ border.Add(item=sizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
+
panel.SetSizer(border)
return panel
@@ -1716,7 +1682,7 @@
"""Change category mode"""
mode = event.GetString()
- self.parent.digit.settings["categoryMode"] = mode
+ UserSettings.Set(group='vdigit', key="categoryMode", subkey='value', value=mode)
if mode == "Manual entry": # enable
self.category.Enable(True)
elif self.category.IsEnabled(): # disable
@@ -1725,15 +1691,15 @@
if mode == "No category" and self.addRecord.IsChecked():
self.addRecord.SetValue(False)
self.parent.digit.SetCategory()
- self.category.SetValue(self.parent.digit.settings['category'])
+ self.category.SetValue(UserSettings.Get(group='vdigit', key='category', subkey='value'))
def OnChangeLayer(self, event):
"""Layer changed"""
layer = int(event.GetString())
if layer > 0:
- self.parent.digit.settings['layer'] = layer
+ UserSettings.Set(group='vdigit', key='layer', subkey='value', value=layer)
self.parent.digit.SetCategory()
- self.category.SetValue(self.parent.digit.settings['category'])
+ self.category.SetValue(UserSettings.Get(group='vdigit', key='category', subkey='value'))
event.Skip()
@@ -1762,7 +1728,7 @@
threshold = self.parent.digit.driver.GetThreshold(value, units)
if units == "map units":
- self.snappingInfo.SetLabel(_("Snapping threshold is %(value).1f %(name)s") %
+ self.snappingInfo.SetLabel(_("Snapping threshold is %(value).1f %(units)s") %
{'value' : value,
'units' : self.mapUnits})
else:
@@ -1776,7 +1742,7 @@
"""Change background map"""
map = self.backgroundMap.GetValue()
- self.parent.digit.settings['backgroundMap'] = map
+ UserSettings.Set(group='vdigit', key='backgroundMap', subkey='value', value=map)
def OnChangeQuery(self, event):
"""Change query"""
@@ -1809,34 +1775,34 @@
self.Close()
def UpdateSettings(self):
- """Update self.parent.digit.settings"""
+ """Update UserSettings"""
# symbology
for key, (enabled, color) in self.symbology.iteritems():
if enabled:
- self.parent.digit.settings[key] = (enabled.IsChecked(), color.GetColour())
+ UserSettings.Set(group='vdigit', key=key, subkey='enabled', value=enabled.IsChecked())
+ UserSettings.Set(group='vdigit', key=key, subkey='color', value=color.GetColour())
else:
- self.parent.digit.settings[key] = (None, color.GetColour())
+ UserSettings.Set(group='vdigit', key=key, subkey='color', value=color.GetColour())
# display
- self.parent.digit.settings["lineWidth"] = (int(self.lineWidthValue.GetValue()),
- self.lineWidthUnit.GetStringSelection())
+ UserSettings.Set(group='vdigit', key="lineWidth", subkey='value', value=int(self.lineWidthValue.GetValue()))
# snapping
- self.parent.digit.settings["snapping"] = (int(self.snappingValue.GetValue()), # value
- self.snappingUnit.GetStringSelection()) # unit
- self.parent.digit.settings["snapToVertex"] = self.snapVertex.IsChecked()
+ UserSettings.Set(group='vdigit', key="snapping", subkey='value', value=int(self.snappingValue.GetValue()))
+ UserSettings.Set(group='vdigit', key="snapping", subkey='units', value=self.snappingUnit.GetStringSelection())
+ UserSettings.Set(group='vdigit', key="snapToVertex", subkey='enabled', value=self.snapVertex.IsChecked())
# digitize new feature
- self.parent.digit.settings["addRecord"] = self.addRecord.IsChecked()
- self.parent.digit.settings["layer"] = int(self.layer.GetStringSelection())
- if self.parent.digit.settings["categoryMode"] == "No category":
- self.parent.digit.settings["category"] = None
+ UserSettings.Set(group='vdigit', key="addRecord", subkey='enabled', value=self.addRecord.IsChecked())
+ UserSettings.Set(group='vdigit', key="layer", subkey='value', value=int(self.layer.GetStringSelection()))
+ if UserSettings.Get(group='vdigit', key="categoryMode", subkey='value') == "No category":
+ UserSettings.Set(group='vdigit', key="category", subkey='value', value=None)
else:
- self.parent.digit.settings["category"] = int(self.category.GetValue())
- self.parent.digit.settings["categoryMode"] = self.categoryMode.GetStringSelection()
+ UserSettings.Set(group='vdigit', key="category", subkey='value', value=int(self.category.GetValue()))
+ UserSettings.Set(group='vdigit', key="categoryMode", subkey='value', value=self.categoryMode.GetStringSelection())
# delete existing feature
- self.parent.digit.settings["delRecord"] = self.deleteRecord.IsChecked()
+ UserSettings.Set(group='vdigit', key="delRecord", subkey='enabled', value=self.deleteRecord.IsChecked())
# threshold
try:
@@ -1846,19 +1812,20 @@
# query tool
if self.queryLength.GetValue():
- self.parent.digit.settings["query"] = ("length", self.queryBox.IsChecked())
+ UserSettings.Set(group='vdigit', key="query", subkey='type', value="length")
else:
- self.parent.digit.settings["query"] = ("dangle", self.queryBox.IsChecked())
- self.parent.digit.settings["queryLength"] = (self.queryLengthSL.GetStringSelection(),
- int(self.queryLengthValue.GetValue()))
- self.parent.digit.settings["queryDangle"] = (self.queryDangleSL.GetStringSelection(),
- int(self.queryDangleValue.GetValue()))
+ UserSettings.Set(group='vdigit', key="query", subkey='type', value="dangle")
+ UserSettings.Set(group='vdigit', key="query", subkey='box', value=self.queryBox.IsChecked())
+ UserSettings.Set(group='vdigit', key="queryLength", subkey='than', value=self.queryLengthSL.GetStringSelection())
+ UserSettings.Set(group='vdigit', key="queryLength", subkey='thresh', value=int(self.queryLengthValue.GetValue()))
+ UserSettings.Set(group='vdigit', key="queryDangle", subkey='than', value=self.queryDangleSL.GetStringSelection())
+ UserSettings.Set(group='vdigit', key="queryDangle", subkey='thresh', value=int(self.queryDangleValue.GetValue()))
# select features
- for feature in ('point', 'line',
- 'centroid', 'boundary'):
- self.parent.digit.settings['selectFeature'][feature]['val'] = \
- self.FindWindowById(self.parent.digit.settings["selectFeature"][feature]['id']).IsChecked()
+ for feature in ('Point', 'Line',
+ 'Centroid', 'Boundary'):
+ UserSettings.Set(group='vdigit', key='selectFeature'+feature, subkey='enabled',
+ value=self.FindWindowById(self.selectFeature[feature]).IsChecked())
# update driver settings
self.parent.digit.driver.UpdateSettings()
@@ -2179,7 +2146,7 @@
cat not in cats[1][layer]:
catList.append(cat)
if catList != []:
- if UserSettings.Get('digitInterface') == 'vedit':
+ if UserSettings.Get(group='advanced', key='digitInterface', subkey='value') == 'vedit':
vEditCmd = ['v.edit', '--q',
'map=%s' % self.map,
'layer=%d' % layer,
@@ -2198,7 +2165,7 @@
if self.line < 0:
wx.MessageBox(parent=self, message=_("Unable to update vector map."),
caption=_("Error"), style=wx.OK | wx.ICON_ERROR)
- if UserSettings.Get('digitInterface') == 'vedit':
+ if UserSettings.Get(group='advanced', key='digitInterface', subkey='value') == 'vedit':
# reload map (needed for v.edit)
self.parent.parent.digit.driver.ReloadMap()
Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py 2008-02-28 12:39:28 UTC (rev 30388)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py 2008-02-28 16:04:55 UTC (rev 30389)
@@ -160,7 +160,7 @@
curr_mapset = gcmd.Command(cmdlist).ReadStdOutput()[0]
#mapsets in current location
- mapsets = UserSettings.Get('mapsetPath', internal=True)
+ mapsets = UserSettings.Get(group='general', key='mapsetPath', subkey='value', internal=True)
# map element types to g.mlist types
elementdict = {'cell':'rast',
'raster':'rast',
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-02-28 12:39:28 UTC (rev 30388)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-02-28 16:04:55 UTC (rev 30389)
@@ -39,14 +39,63 @@
# default settings
self.defaultSettings = {
+ #
# general
- 'displayFont' : '',
- 'mapsetPath' : 'p', # current mapset search path
+ #
+ 'general': {
+ 'displayFont' : { 'value' : '' },
+ 'mapsetPath' : { 'value' : 'p' }, # current mapset search path
+ },
+ #
# advanced
- 'settingsFile' : 'gisdbase', # gisdbase, location, mapset
- 'digitInterface' : 'vdigit', # vedit, vdigit
- 'iconTheme': 'silk', # grass, silk
+ #
+ 'advanced' : {
+ 'settingsFile' : { 'value' : 'gisdbase' }, # gisdbase, location, mapset
+ 'digitInterface' : { 'value' : 'vdigit' }, # vedit, vdigit
+ 'iconTheme' : { 'value' : 'silk' }, # grass, silk
+ },
+ #
+ # vdigit
+ #
+ 'vdigit' : {
+ # symbology
+ 'symbolHighlight' : { 'enabled' : None, 'color' : (255, 255, 0, 255) }, #yellow
+ 'symbolPoint' : { 'enabled' : True, 'color' : (0, 0, 0, 255) }, # black
+ 'symbolLine' : { 'enabled' : True, 'color' : (0, 0, 0, 255) }, # black
+ 'symbolBoundaryNo' : { 'enabled' : True, 'color' : (126, 126, 126, 255) }, # grey
+ 'symbolBoundaryOne' : { 'enabled' : True, 'color' : (0, 255, 0, 255) }, # green
+ 'symbolBoundaryTwo' : { 'enabled' : True, 'color' : (255, 135, 0, 255) }, # orange
+ 'symbolCentroidIn' : { 'enabled' : True, 'color' : (0, 0, 255, 255) }, # blue
+ 'symbolCentroidOut' : { 'enabled' : True, 'color' : (165, 42, 42, 255) }, # brown
+ 'symbolCentroidDup' : { 'enabled' : True, 'color' : (156, 62, 206, 255) }, # violet
+ 'symbolNodeOne' : { 'enabled' : True, 'color' : (255, 0, 0, 255) }, # red
+ 'symbolNodeTwo' : { 'enabled' : True, 'color' : (0, 86, 45, 255) }, # dark green
+ 'symbolVertex' : { 'enabled' : False, 'color' : (255, 20, 147, 255) }, # deep pink
+ # display
+ 'lineWidth' : { 'value' : 2, 'units' : 'screen pixels' },
+ # snapping
+ 'snapping' : { 'value' : 10, 'units' : 'screen pixels' },
+ 'snapToVertex' : { 'enabled' : False },
+ 'backgroundMap' : {'value' : ''},
+ # digitize new record
+ 'addRecord' : { 'enabled' : True },
+ 'layer' : {'value' : 1 },
+ 'category' : {'value' : 1 },
+ 'categoryMode' : {'value' : 'Next to use' },
+ # delete existing feature(s)
+ 'delRecord' : { 'enabled' : True },
+ # query tool
+ 'query' : { 'type' : 'length', 'box' : True },
+ 'queryLength' : { 'than' : 'shorter than', 'thresh' : 0 },
+ 'queryDangle' : { 'than' : 'shorter than', 'thresh' : 0 },
+ # select feature (point, line, centroid, boundary)
+ 'selectFeaturePoint' : { 'enabled' : True },
+ 'selectFeatureLine' : { 'enabled' : True },
+ 'selectFeatureCentroid' : { 'enabled' : True },
+ 'selectFeatureBoundary' : { 'enabled' : True },
+ 'selectThresh' : { 'value' : 10, 'units' : 'screen pixels'},
}
+ }
# user settings
self.userSettings = copy.deepcopy(self.defaultSettings)
@@ -59,13 +108,15 @@
# internal settings (based on user settings)
self.internalSettings = {}
- self.internalSettings["mapsetPath"] = self.GetMapsetPath()
+ self.internalSettings['general'] = {}
+ self.internalSettings['general']["mapsetPath"] = {}
+ self.internalSettings['general']["mapsetPath"]['value'] = self.GetMapsetPath()
def GetMapsetPath(self):
"""Store mapset search path"""
all, access = utils.ListOfMapsets()
- if self.Get('mapsetPath') == 'p':
+ if self.Get(group='general', key='mapsetPath', subkey='value') == 'p':
return access
else:
return all
@@ -100,22 +151,21 @@
settings = self.userSettings
try:
+ # print '#', filename
file = open(filename, "r")
for line in file.readlines():
- try:
- key, value = line.rstrip('%s' % os.linesep).split(':', 1)
- except:
- raise SettingsError('Reading settings from file <%s> failed. '
- 'Line \'%s\'.' % (filename, line))
- if settings.has_key(key):
- settings[key] = value
- else:
- raise SettingsError('Reading settings from file <%s> failed. '
- 'Unknow item <%s>.' % (filename, key))
+ line = line.rstrip('%s' % os.linesep)
+ group, key = line.split(':')[0:2]
+ kv = line.split(':')[2:]
+ idx = 0
+ while idx < len(kv):
+ # print group, key, kv[idx], kv[idx+1]
+ # settings.Set(grou=group, key=key, subkey=kv[idx], value=kv[idx+1])
+ idx += 2
except IOError, e:
raise gcmd.SettingsError(e)
except:
- raise gcmd.SettingsError('Reading settings from file <%s> failed.' % filename)
+ raise gcmd.SettingsError(_('Reading settings from file <%s> failed.') % filename)
file.close()
@@ -124,7 +174,7 @@
if settings is None:
settings = self.userSettings
- loc = self.Get('settingsFile')
+ loc = self.Get(group='advanced', key='settingsFile', subkey='value')
gisdbase = grassenv.GetGRASSVariable("GISDBASE")
location_name = grassenv.GetGRASSVariable("LOCATION_NAME")
mapset_name = grassenv.GetGRASSVariable("MAPSET")
@@ -141,9 +191,15 @@
try:
file = open(filePath, "w")
- for item in settings.keys():
- if settings[item] != '':
- file.write('%s:%s%s' % (item, settings[item], os.linesep))
+ for group in settings.keys():
+ for item in settings[group].keys():
+ file.write('%s:%s:' % (group, item))
+ items = settings[group][item].keys()
+ for idx in range(len(items)):
+ file.write('%s:%s' % (items[idx], settings[group][item][items[idx]]))
+ if idx < len(items) - 1:
+ file.write(':')
+ file.write('%s' % os.linesep)
except IOError, e:
raise gcmd.SettingsError(e)
except:
@@ -153,34 +209,54 @@
return filePath
- def Get(self, key, internal=False):
- """Get value by key
+ def Get(self, group, key, subkey=None, internal=False):
+ """Get value by key/subkey
+ Raise KeyError if key is not found
+
+ @param group settings group
+ @param key
+ @param subkey if not given return dict of key
+
@return value
- @return None if key not found
+
"""
if internal is True:
settings = self.internalSettings
else:
settings = self.userSettings
- if settings.has_key(key):
- return settings[key]
-
+ if settings.has_key(group) and settings[group].has_key(key):
+ if subkey is None:
+ return settings[group][key]
+ else:
+ if settings[group][key].has_key(subkey):
+ return settings[group][key][subkey]
+ else:
+ raise KeyError
+ else:
+ raise KeyError
+
return None
- def Set(self, key, value, internal=False):
- """Set value by key
+ def Set(self, group, key, subkey, value, internal=False):
+ """Set value by key/subkey
Raise KeyError if key is not found
+
+ @param group settings group
+ @param key
+ @param subkey
+ @param value
"""
if internal is True:
settings = self.internalSettings
else:
settings = self.userSettings
- if settings.has_key(key):
- settings[key] = value
+ if settings.has_key(group) and settings[group].has_key(key) and \
+ settings[group][key].has_key(subkey):
+ settings[group][key][subkey] = value
else:
raise KeyError
@@ -274,7 +350,7 @@
pos=(2, 0))
self.mapsetPath = wx.Choice(parent=panel, id=wx.ID_ANY, size=(200, -1),
choices=['mapset search path', 'all available mapsets'])
- if self.settings.Get('mapsetPath') == 'p':
+ if self.settings.Get(group='general', key='mapsetPath', subkey='value') == 'p':
self.mapsetPath.SetSelection(0)
else:
self.mapsetPath.SetSelection(1)
@@ -318,7 +394,7 @@
pos=(row, 0))
self.settingsFile = wx.Choice(parent=panel, id=wx.ID_ANY, size=(125, -1),
choices=['gisdbase', 'location', 'mapset'])
- self.settingsFile.SetStringSelection(self.settings.Get('settingsFile'))
+ self.settingsFile.SetStringSelection(self.settings.Get(group='advanced', key='settingsFile', subkey='value'))
gridSizer.Add(item=self.settingsFile,
flag=wx.ALIGN_RIGHT |
wx.ALIGN_CENTER_VERTICAL,
@@ -335,7 +411,7 @@
pos=(row, 0))
self.iconTheme = wx.Choice(parent=panel, id=wx.ID_ANY, size=(125, -1),
choices=['grass', 'silk'])
- self.iconTheme.SetStringSelection(self.settings.Get('iconTheme'))
+ self.iconTheme.SetStringSelection(self.settings.Get(group='advanced', key='iconTheme', subkey='value'))
gridSizer.Add(item=self.iconTheme,
flag=wx.ALIGN_RIGHT |
wx.ALIGN_CENTER_VERTICAL,
@@ -362,7 +438,7 @@
pos=(row, 0))
self.digitInterface = wx.Choice(parent=panel, id=wx.ID_ANY, size=(125, -1),
choices=['vdigit', 'vedit'])
- self.digitInterface.SetStringSelection(self.settings.Get('digitInterface'))
+ self.digitInterface.SetStringSelection(self.settings.Get(group='advanced', key='digitInterface', subkey='value'))
gridSizer.Add(item=self.digitInterface,
flag=wx.ALIGN_RIGHT |
wx.ALIGN_CENTER_VERTICAL,
@@ -419,12 +495,12 @@
def OnChangeMapsetPath(self, event):
"""Mapset path changed"""
if event.GetSelection() == 0:
- self.settings.Set('mapsetPath', 'p')
+ self.settings.Set(group='general', key='mapsetPath', subkey='value', value='p')
else:
- self.settings.Set('mapsetPath', 'l')
+ self.settings.Set(group='general', key='mapsetPath', subkey='value', value='l')
# update internal settings
- self.settings.Set("mapsetPath", self.settings.GetMapsetPath(), internal=True)
+ self.settings.Set(group='general', key="mapsetPath", subkey='value', value=self.settings.GetMapsetPath(), internal=True)
def OnSave(self, event):
"""Button 'Save' clicked"""
@@ -447,13 +523,13 @@
# TODO
# location
- self.settings.Set('settingsFile', self.settingsFile.GetStringSelection())
+ self.settings.Set(group='advanced', key='settingsFile', subkey='value', value=self.settingsFile.GetStringSelection())
# icon theme
- self.settings.Set('iconTheme', self.iconTheme.GetStringSelection())
+ self.settings.Set(group='advanced', key='iconTheme', subkey='value', value=self.iconTheme.GetStringSelection())
# digitization interface
- self.settings.Set('digitInterface', self.digitInterface.GetStringSelection())
+ self.settings.Set(group='advanced', key='digitInterface', subkey='value', value=self.digitInterface.GetStringSelection())
class SetDefaultFont(wx.Dialog):
"""
@@ -584,7 +660,7 @@
flag=wx.ALL | wx.EXPAND, border=5)
# check all accessible mapsets
- if globalSettings.Get('mapsetPath') == 'l':
+ if globalSettings.Get(group='general', key='mapsetPath', subkey='value') == 'l':
for mset in self.all_mapsets:
self.mapsetlb.Check(self.all_mapsets.index(mset), True)
else:
Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-02-28 12:39:28 UTC (rev 30388)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-02-28 16:04:55 UTC (rev 30389)
@@ -1502,7 +1502,7 @@
self.mapset = wx.ComboBox(parent=self, id=wx.ID_ANY,
style=wx.CB_SIMPLE | wx.CB_READONLY,
- choices=UserSettings.Get('mapsetPath', internal=True),
+ choices=UserSettings.Get(group='general', key='mapsetPath', subkey='value', internal=True),
size=(200,-1))
self.mapset.SetStringSelection(grassenv.GetGRASSVariable("MAPSET"))
bodySizer.Add(item=self.mapset,
Modified: grass/trunk/gui/wxpython/icons/icon.py
===================================================================
--- grass/trunk/gui/wxpython/icons/icon.py 2008-02-28 12:39:28 UTC (rev 30388)
+++ grass/trunk/gui/wxpython/icons/icon.py 2008-02-28 16:04:55 UTC (rev 30389)
@@ -32,7 +32,7 @@
# iconpath = grassenv.GetGRASSVariable('GRASS_ICONPATH')
# if not iconpath:
# iconpath = os.getenv("GRASS_ICONPATH")
-iconTheme = UserSettings.Get('iconTheme')
+iconTheme = UserSettings.Get(group='advanced', key='iconTheme', subkey='value')
if iconTheme and iconTheme == 'silk':
iconpath = os.path.join(globalvar.ETCWXDIR, "icons", "silk")
else:
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2008-02-28 12:39:28 UTC (rev 30388)
+++ grass/trunk/gui/wxpython/wxgui.py 2008-02-28 16:04:55 UTC (rev 30389)
@@ -343,8 +343,8 @@
# run g.mapsets with string of accessible mapsets
cmdlist = ['g.mapsets', 'mapset=%s' % ','.join(ms)]
gcmd.Command(cmdlist)
- UserSettings.Set('mapsetPath', ms, internal=True)
- print UserSettings.Get('mapsetPath', internal=True)
+ UserSettings.Set(group='general', key='mapsetPath', subkey='value', value=ms, internal=True)
+ print UserSettings.Get(group='general', key='mapsetPath', internal=True)
def OnRDigit(self, event):
"""
More information about the grass-commit
mailing list