2 @package vdigit.preferences
4 @brief wxGUI vector digitizer preferences dialogs
7 - preferences::VDigitSettingsDialog
9 (C) 2007-2011 by the GRASS Development Team
11 This program is free software under the GNU General Public License
12 (>=v2). Read the file COPYING that comes with GRASS for details.
14 @author Martin Landa <landa.martin gmail.com>
20 import wx.lib.colourselect
as csel
22 from core
import globalvar
29 def __init__(self, parent, title, style = wx.DEFAULT_DIALOG_STYLE):
30 """!Standard settings dialog for digitization purposes
32 wx.Dialog.__init__(self, parent = parent, id = wx.ID_ANY, title = title, style = style)
35 self.
digit = self.parent.MapWindow.digit
38 notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
41 self.digit.SetCategory()
46 btnApply = wx.Button(self, wx.ID_APPLY)
47 btnCancel = wx.Button(self, wx.ID_CANCEL)
48 btnSave = wx.Button(self, wx.ID_SAVE)
52 btnApply.Bind(wx.EVT_BUTTON, self.
OnApply)
53 btnApply.SetToolTipString(_(
"Apply changes for this session"))
55 btnSave.Bind(wx.EVT_BUTTON, self.
OnSave)
56 btnSave.SetToolTipString(_(
"Close dialog and save changes to user settings file"))
57 btnCancel.Bind(wx.EVT_BUTTON, self.
OnCancel)
58 btnCancel.SetToolTipString(_(
"Close dialog and ignore changes"))
61 btnSizer = wx.StdDialogButtonSizer()
62 btnSizer.AddButton(btnCancel)
63 btnSizer.AddButton(btnApply)
64 btnSizer.AddButton(btnSave)
67 mainSizer = wx.BoxSizer(wx.VERTICAL)
68 mainSizer.Add(item = notebook, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)
69 mainSizer.Add(item = btnSizer, proportion = 0,
70 flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border = 5)
72 self.Bind(wx.EVT_CLOSE, self.
OnCancel)
74 self.SetSizer(mainSizer)
77 def _createSymbologyPage(self, notebook):
78 """!Create notebook page concerning symbology settings"""
79 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
80 notebook.AddPage(page = panel, text = _(
"Symbology"))
82 sizer = wx.BoxSizer(wx.VERTICAL)
84 flexSizer = wx.FlexGridSizer (cols = 3, hgap = 5, vgap = 5)
85 flexSizer.AddGrowableCol(0)
89 textLabel = wx.StaticText(panel, wx.ID_ANY, label)
90 color = csel.ColourSelect(panel, id = wx.ID_ANY,
91 colour = UserSettings.Get(group =
'vdigit', key =
'symbol',
92 subkey = [key,
'color']),
94 isEnabled = UserSettings.Get(group =
'vdigit', key =
'symbol',
95 subkey = [key,
'enabled'])
96 if isEnabled
is not None:
97 enabled = wx.CheckBox(panel, id = wx.ID_ANY, label =
"")
98 enabled.SetValue(isEnabled)
104 flexSizer.Add(textLabel, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
105 flexSizer.Add(enabled, proportion = 0, flag = wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
106 flexSizer.Add(color, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
107 color.SetName(
"GetColour")
109 sizer.Add(item = flexSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 10)
111 panel.SetSizer(sizer)
115 def _createGeneralPage(self, notebook):
116 """!Create notebook page concerning general settings"""
117 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
118 notebook.AddPage(page = panel, text = _(
"General"))
120 border = wx.BoxSizer(wx.VERTICAL)
125 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Display"))
126 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
127 flexSizer = wx.FlexGridSizer (cols = 3, hgap = 5, vgap = 5)
128 flexSizer.AddGrowableCol(0)
130 text = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Line width"))
131 self.
lineWidthValue = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (75, -1),
132 initial = UserSettings.Get(group =
'vdigit', key =
"lineWidth", subkey =
'value'),
134 units = wx.StaticText(parent = panel, id = wx.ID_ANY, size = (115, -1),
135 label = UserSettings.Get(group =
'vdigit', key =
"lineWidth", subkey =
'units'),
136 style = wx.ALIGN_LEFT)
137 flexSizer.Add(text, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
138 flexSizer.Add(self.
lineWidthValue, proportion = 0, flag = wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
139 flexSizer.Add(units, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
142 sizer.Add(item = flexSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 1)
143 border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
148 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Snapping"))
149 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
150 flexSizer = wx.FlexGridSizer(cols = 3, hgap = 5, vgap = 5)
151 flexSizer.AddGrowableCol(0)
154 text = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Snapping threshold"))
155 self.
snappingValue = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (75, -1),
156 initial = UserSettings.Get(group =
'vdigit', key =
"snapping", subkey =
'value'),
160 self.
snappingUnit = wx.Choice(parent = panel, id = wx.ID_ANY, size = (125, -1),
161 choices = [_(
"screen pixels"), _(
"map units")])
162 self.snappingUnit.SetStringSelection(UserSettings.Get(group =
'vdigit', key =
"snapping", subkey =
'units'))
164 flexSizer.Add(text, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
165 flexSizer.Add(self.
snappingValue, proportion = 0, flag = wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
166 flexSizer.Add(self.
snappingUnit, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
168 vertexSizer = wx.BoxSizer(wx.VERTICAL)
169 self.
snapVertex = wx.CheckBox(parent = panel, id = wx.ID_ANY,
170 label = _(
"Snap also to vertex"))
171 self.snapVertex.SetValue(UserSettings.Get(group =
'vdigit', key =
"snapToVertex", subkey =
'enabled'))
172 vertexSizer.Add(item = self.
snapVertex, proportion = 0, flag = wx.EXPAND)
173 self.
mapUnits = self.parent.MapWindow.Map.GetProjInfo()[
'units']
175 label = _(
"Snapping threshold is %(value).1f %(units)s") % \
176 {
'value' : self.digit.GetDisplay().GetThreshold(),
178 vertexSizer.Add(item = self.
snappingInfo, proportion = 0,
179 flag = wx.ALL | wx.EXPAND, border = 1)
181 sizer.Add(item = flexSizer, proportion = 1, flag = wx.EXPAND)
182 sizer.Add(item = vertexSizer, proportion = 1, flag = wx.EXPAND)
183 border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 5)
188 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Select vector features"))
190 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
191 inSizer = wx.BoxSizer(wx.HORIZONTAL)
193 for feature
in (
'point',
'line',
194 'centroid',
'boundary'):
195 chkbox = wx.CheckBox(parent = panel, label = feature)
197 chkbox.SetValue(UserSettings.Get(group =
'vdigit', key =
'selectType',
198 subkey = [feature,
'enabled']))
199 inSizer.Add(item = chkbox, proportion = 0,
200 flag = wx.EXPAND | wx.ALL, border = 5)
201 sizer.Add(item = inSizer, proportion = 0, flag = wx.EXPAND)
203 flexSizer = wx.FlexGridSizer (cols = 3, hgap = 5, vgap = 5)
204 flexSizer.AddGrowableCol(0)
205 text = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Select threshold"))
207 initial = UserSettings.Get(group =
'vdigit', key =
"selectThresh", subkey =
'value'),
209 units = wx.StaticText(parent = panel, id = wx.ID_ANY, size = (115, -1),
210 label = UserSettings.Get(group =
'vdigit', key =
"lineWidth", subkey =
'units'),
211 style = wx.ALIGN_LEFT)
212 flexSizer.Add(text, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
213 flexSizer.Add(self.
selectThreshValue, proportion = 0, flag = wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
214 flexSizer.Add(units, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
217 self.
selectIn = wx.CheckBox(parent = panel, id = wx.ID_ANY,
218 label = _(
"Select only features inside of selection bounding box"))
219 self.selectIn.SetValue(UserSettings.Get(group =
'vdigit', key =
"selectInside", subkey =
'enabled'))
220 self.selectIn.SetToolTipString(_(
"By default are selected all features overlapping selection bounding box "))
223 label = _(
"Check for duplicates"))
224 self.checkForDupl.SetValue(UserSettings.Get(group =
'vdigit', key =
"checkForDupl", subkey =
'enabled'))
227 sizer.Add(item = flexSizer, proportion = 0, flag = wx.EXPAND)
228 sizer.Add(item = self.
selectIn, proportion = 0, flag = wx.EXPAND | wx.ALL, border = 1)
229 sizer.Add(item = self.
checkForDupl, proportion = 0, flag = wx.EXPAND | wx.ALL, border = 1)
230 border.Add(item = sizer, proportion = 0, flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border = 5)
235 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Digitize line features"))
236 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
238 self.
intersect = wx.CheckBox(parent = panel, label = _(
"Break lines at intersection"))
239 self.intersect.SetValue(UserSettings.Get(group =
'vdigit', key =
'breakLines', subkey =
'enabled'))
241 sizer.Add(item = self.
intersect, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 1)
243 border.Add(item = sizer, proportion = 0, flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border = 5)
248 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Save changes"))
250 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
251 self.
save = wx.CheckBox(parent = panel, label = _(
"Save changes on exit"))
252 self.save.SetValue(UserSettings.Get(group =
'vdigit', key =
'saveOnExit', subkey =
'enabled'))
253 sizer.Add(item = self.
save, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 1)
254 border.Add(item = sizer, proportion = 0, flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border = 5)
256 panel.SetSizer(border)
260 def _createQueryPage(self, notebook):
261 """!Create notebook page for query tool"""
262 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
263 notebook.AddPage(page = panel, text = _(
"Query tool"))
265 border = wx.BoxSizer(wx.VERTICAL)
270 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Choose query tool"))
271 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
273 LocUnits = self.parent.MapWindow.Map.GetProjInfo()[
'units']
275 self.
queryBox = wx.CheckBox(parent = panel, id = wx.ID_ANY, label = _(
"Select by box"))
276 self.queryBox.SetValue(UserSettings.Get(group =
'vdigit', key =
"query", subkey =
'box'))
278 sizer.Add(item = self.
queryBox, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 1)
284 self.
queryLength = wx.RadioButton(parent = panel, id = wx.ID_ANY, label = _(
"length"))
285 self.queryLength.Bind(wx.EVT_RADIOBUTTON, self.
OnChangeQuery)
286 sizer.Add(item = self.
queryLength, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 1)
287 flexSizer = wx.FlexGridSizer (cols = 4, hgap = 5, vgap = 5)
288 flexSizer.AddGrowableCol(0)
289 txt = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Select lines"))
291 choices = [_(
"shorter than"), _(
"longer than")])
292 self.queryLengthSL.SetSelection(UserSettings.Get(group =
'vdigit', key =
"queryLength", subkey =
'than-selection'))
296 self.queryLengthValue.SetValue(UserSettings.Get(group =
'vdigit', key =
"queryLength", subkey =
'thresh'))
297 units = wx.StaticText(parent = panel, id = wx.ID_ANY, label =
"%s" % LocUnits)
298 flexSizer.Add(txt, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
299 flexSizer.Add(self.
queryLengthSL, proportion = 0, flag = wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
300 flexSizer.Add(self.
queryLengthValue, proportion = 0, flag = wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
301 flexSizer.Add(units, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
302 sizer.Add(item = flexSizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 1)
307 self.
queryDangle = wx.RadioButton(parent = panel, id = wx.ID_ANY, label = _(
"dangle"))
308 self.queryDangle.Bind(wx.EVT_RADIOBUTTON, self.
OnChangeQuery)
309 sizer.Add(item = self.
queryDangle, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 1)
310 flexSizer = wx.FlexGridSizer (cols = 4, hgap = 5, vgap = 5)
311 flexSizer.AddGrowableCol(0)
312 txt = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Select dangles"))
314 choices = [_(
"shorter than"), _(
"longer than")])
315 self.queryDangleSL.SetSelection(UserSettings.Get(group =
'vdigit', key =
"queryDangle", subkey =
'than-selection'))
319 self.queryDangleValue.SetValue(UserSettings.Get(group =
'vdigit', key =
"queryDangle", subkey =
'thresh'))
320 units = wx.StaticText(parent = panel, id = wx.ID_ANY, label =
"%s" % LocUnits)
321 flexSizer.Add(txt, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
322 flexSizer.Add(self.
queryDangleSL, proportion = 0, flag = wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
323 flexSizer.Add(self.
queryDangleValue, proportion = 0, flag = wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
324 flexSizer.Add(units, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
325 sizer.Add(item = flexSizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 1)
327 if UserSettings.Get(group =
'vdigit', key =
"query", subkey =
'selection') == 0:
328 self.queryLength.SetValue(
True)
330 self.queryDangle.SetValue(
True)
335 border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
337 panel.SetSizer(border)
341 def _createAttributesPage(self, notebook):
342 """!Create notebook page for attributes"""
343 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
344 notebook.AddPage(page = panel, text = _(
"Attributes"))
346 border = wx.BoxSizer(wx.VERTICAL)
351 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Digitize new feature"))
352 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
355 self.
addRecord = wx.CheckBox(parent = panel, id = wx.ID_ANY,
356 label = _(
"Add new record into table"))
357 self.addRecord.SetValue(UserSettings.Get(group =
'vdigit', key =
"addRecord", subkey =
'enabled'))
358 sizer.Add(item = self.
addRecord, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 1)
360 flexSizer = wx.FlexGridSizer(cols = 2, hgap = 3, vgap = 3)
361 flexSizer.AddGrowableCol(0)
362 settings = ((_(
"Layer"), 1), (_(
"Category"), 1), (_(
"Mode"), _(
"Next to use")))
364 text = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Layer"))
365 self.
layer = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (125, -1),
367 self.layer.SetValue(int(UserSettings.Get(group =
'vdigit', key =
"layer", subkey =
'value')))
368 flexSizer.Add(item = text, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
369 flexSizer.Add(item = self.
layer, proportion = 0,
370 flag = wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
372 text = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Category number"))
373 self.
category = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (125, -1),
374 initial = UserSettings.Get(group =
'vdigit', key =
"category", subkey =
'value'),
375 min = -1e9, max = 1e9)
376 if UserSettings.Get(group =
'vdigit', key =
"categoryMode", subkey =
'selection') != 1:
377 self.category.Enable(
False)
378 flexSizer.Add(item = text, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
379 flexSizer.Add(item = self.
category, proportion = 0,
380 flag = wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
382 text = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Category mode"))
383 self.
categoryMode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (125, -1),
384 choices = [_(
"Next to use"), _(
"Manual entry"), _(
"No category")])
385 self.categoryMode.SetSelection(UserSettings.Get(group =
'vdigit', key =
"categoryMode", subkey =
'selection'))
386 flexSizer.Add(item = text, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
388 flag = wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
390 sizer.Add(item = flexSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 1)
391 border.Add(item = sizer, proportion = 0,
392 flag = wx.ALL | wx.EXPAND, border = 5)
397 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Delete existing feature(s)"))
398 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
402 label = _(
"Delete record from table"))
403 self.deleteRecord.SetValue(UserSettings.Get(group =
'vdigit', key =
"delRecord", subkey =
'enabled'))
404 sizer.Add(item = self.
deleteRecord, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 1)
405 border.Add(item = sizer, proportion = 0,
406 flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 5)
411 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
412 label =
" %s " % _(
"Geometry attributes"))
413 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
414 gridSizer = wx.GridBagSizer(hgap = 3, vgap = 3)
415 gridSizer.AddGrowableCol(0)
416 self.
geomAttrb = {
'length' : {
'label' : _(
'length') },
417 'area' : {
'label' : _(
'area') },
418 'perimeter' : {
'label' : _(
'perimeter') } }
420 digitToolbar = self.parent.toolbars[
'vdigit']
422 vectorName = digitToolbar.GetLayer().GetName()
423 except AttributeError:
425 layer = UserSettings.Get(group =
'vdigit', key =
"layer", subkey =
'value')
426 mapLayer = self.parent.toolbars[
'vdigit'].GetLayer()
427 tree = self.parent.tree
428 item = tree.FindItemByData(
'maplayer', mapLayer)
430 for attrb
in [
'length',
'area',
'perimeter']:
432 check = wx.CheckBox(parent = panel, id = wx.ID_ANY,
437 column = ColumnSelect(parent = panel, size = (200, -1))
438 column.InsertColumns(vector = vectorName,
439 layer = layer, excludeKey =
True,
440 type = [
'integer',
'double precision'])
443 choices = Units.GetUnitsList(
'area')
445 choices = Units.GetUnitsList(
'length')
446 win_units = wx.Choice(parent = panel, id = wx.ID_ANY,
447 choices = choices, size = (120, -1))
450 check.SetValue(
False)
451 if item
and tree.GetPyData(item)[0][
'vdigit']
and \
452 'geomAttr' in tree.GetPyData(item)[0][
'vdigit']
and \
453 attrb
in tree.GetPyData(item)[0][
'vdigit'][
'geomAttr']:
455 column.SetStringSelection(tree.GetPyData(item)[0][
'vdigit'][
'geomAttr'][attrb][
'column'])
460 unitsIdx = Units.GetUnitsIndex(type,
461 tree.GetPyData(item)[0][
'vdigit'][
'geomAttr'][attrb][
'units'])
462 win_units.SetSelection(unitsIdx)
468 if not check.IsChecked():
471 self.
geomAttrb[attrb][
'check'] = check.GetId()
472 self.
geomAttrb[attrb][
'column'] = column.GetId()
473 self.
geomAttrb[attrb][
'units'] = win_units.GetId()
475 gridSizer.Add(item = check,
476 flag = wx.ALIGN_CENTER_VERTICAL,
478 gridSizer.Add(item = column,
480 gridSizer.Add(item = win_units,
484 note =
'\n'.join(textwrap.wrap(_(
"Note: These settings are stored "
485 "in the workspace not in the vector digitizer "
486 "preferences."), 55))
487 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
489 pos = (3, 0), span = (1, 3))
491 sizer.Add(item = gridSizer, proportion = 1,
492 flag = wx.ALL | wx.EXPAND, border = 1)
493 border.Add(item = sizer, proportion = 0,
494 flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 5)
501 panel.SetSizer(border)
505 def _symbologyData(self):
506 """!Data for _createSymbologyPage()
508 label | checkbox | color
512 (_(
"Digitize new line segment"),
"newSegment"),
513 (_(
"Digitize new line/boundary"),
"newLine"),
514 (_(
"Highlight"),
"highlight"),
515 (_(
"Highlight (duplicates)"),
"highlightDupl"),
516 (_(
"Point"),
"point"),
518 (_(
"Boundary (no area)"),
"boundaryNo"),
519 (_(
"Boundary (one area)"),
"boundaryOne"),
520 (_(
"Boundary (two areas)"),
"boundaryTwo"),
521 (_(
"Centroid (in area)"),
"centroidIn"),
522 (_(
"Centroid (outside area)"),
"centroidOut"),
523 (_(
"Centroid (duplicate in area)"),
"centroidDup"),
524 (_(
"Node (one line)"),
"nodeOne"),
525 (_(
"Node (two lines)"),
"nodeTwo"),
526 (_(
"Vertex"),
"vertex"),
527 (_(
"Area (closed boundary + centroid)"),
"area"),
528 (_(
"Direction"),
"direction"),)
531 """!Register geometry attributes (enable/disable)
533 checked = event.IsChecked()
536 for attrb, val
in self.geomAttrb.iteritems():
537 if val[
'check'] == id:
541 column = self.FindWindowById(self.
geomAttrb[key][
'column'])
548 """!Change category mode
550 mode = event.GetSelection()
551 UserSettings.Set(group =
'vdigit', key =
"categoryMode", subkey =
'selection', value = mode)
553 self.category.Enable(
True)
554 elif self.category.IsEnabled():
555 self.category.Enable(
False)
557 if mode == 2
and self.addRecord.IsChecked():
558 self.addRecord.SetValue(
False)
560 self.digit.SetCategory()
561 self.category.SetValue(UserSettings.Get(group =
'vdigit', key =
'category', subkey =
'value'))
566 layer = event.GetInt()
568 UserSettings.Set(group =
'vdigit', key =
'layer', subkey =
'value', value = layer)
569 self.digit.SetCategory()
570 self.category.SetValue(UserSettings.Get(group =
'vdigit', key =
'category', subkey =
'value'))
575 """!Checkbox 'Add new record' status changed
581 """!Change snapping value - update static text
583 value = self.snappingValue.GetValue()
586 region = self.parent.MapWindow.Map.GetRegion()
587 res = (region[
'nsres'] + region[
'ewres']) / 2.
588 threshold = self.digit.GetDisplay().GetThreshold(value = res)
590 if self.snappingUnit.GetStringSelection() ==
"map units":
593 threshold = self.digit.GetDisplay().GetThreshold(value = value)
596 self.snappingInfo.SetLabel(_(
"Snapping disabled"))
598 self.snappingInfo.SetLabel(_(
"Snapping threshold is %(value).1f %(units)s "
599 "(based on comp. resolution)") %
600 {
'value' : threshold,
601 'units' : self.mapUnits.lower()})
603 self.snappingInfo.SetLabel(_(
"Snapping threshold is %(value).1f %(units)s") %
604 {
'value' : threshold,
605 'units' : self.mapUnits.lower()})
610 """!Snapping units change -> update static text
612 value = self.snappingValue.GetValue()
613 units = self.snappingUnit.GetStringSelection()
614 threshold = self.digit.GetDisplay().GetThreshold(value = value, units = units)
616 if units ==
"map units":
617 self.snappingInfo.SetLabel(_(
"Snapping threshold is %(value).1f %(units)s") %
621 self.snappingInfo.SetLabel(_(
"Snapping threshold is %(value).1f %(units)s") %
622 {
'value' : threshold,
630 if self.queryLength.GetValue():
632 self.queryLengthSL.Enable(
True)
633 self.queryLengthValue.Enable(
True)
634 self.queryDangleSL.Enable(
False)
635 self.queryDangleValue.Enable(
False)
638 self.queryLengthSL.Enable(
False)
639 self.queryLengthValue.Enable(
False)
640 self.queryDangleSL.Enable(
True)
641 self.queryDangleValue.Enable(
True)
644 """!Button 'Save' pressed
647 self.parent.toolbars[
'vdigit'].settingsDialog =
None
650 UserSettings.ReadSettingsFile(settings = fileSettings)
651 fileSettings[
'vdigit'] = UserSettings.Get(group =
'vdigit')
653 file = UserSettings.SaveToFile(fileSettings)
654 self.parent.GetLayerManager().goutput.WriteLog(_(
'Vector digitizer settings saved to file <%s>.') % file)
661 """!Button 'Apply' pressed
666 """!Button 'Cancel' pressed
668 self.parent.toolbars[
'vdigit'].settingsDialog =
None
675 """!Update digitizer settings
677 self.parent.GetLayerManager().WorkspaceChanged()
679 for key, (enabled, color)
in self.symbology.iteritems():
681 UserSettings.Set(group =
'vdigit', key =
'symbol',
682 subkey = [key,
'enabled'],
683 value = enabled.IsChecked())
684 UserSettings.Set(group =
'vdigit', key =
'symbol',
685 subkey = [key,
'color'],
686 value = tuple(color.GetColour()))
688 UserSettings.Set(group =
'vdigit', key =
'symbol',
689 subkey = [key,
'color'],
690 value = tuple(color.GetColour()))
692 UserSettings.Set(group =
'vdigit', key =
"lineWidth", subkey =
'value',
693 value = int(self.lineWidthValue.GetValue()))
696 UserSettings.Set(group =
'vdigit', key =
"snapping", subkey =
'value',
697 value = int(self.snappingValue.GetValue()))
698 UserSettings.Set(group =
'vdigit', key =
"snapping", subkey =
'units',
699 value = self.snappingUnit.GetStringSelection())
700 UserSettings.Set(group =
'vdigit', key =
"snapToVertex", subkey =
'enabled',
701 value = self.snapVertex.IsChecked())
704 UserSettings.Set(group =
'vdigit', key =
"addRecord", subkey =
'enabled',
705 value = self.addRecord.IsChecked())
706 UserSettings.Set(group =
'vdigit', key =
"layer", subkey =
'value',
707 value = int(self.layer.GetValue()))
708 UserSettings.Set(group =
'vdigit', key =
"category", subkey =
'value',
709 value = int(self.category.GetValue()))
710 UserSettings.Set(group =
'vdigit', key =
"categoryMode", subkey =
'selection',
711 value = self.categoryMode.GetSelection())
714 UserSettings.Set(group =
'vdigit', key =
"delRecord", subkey =
'enabled',
715 value = self.deleteRecord.IsChecked())
718 mapLayer = self.parent.toolbars[
'vdigit'].GetLayer()
719 tree = self.parent.tree
720 item = tree.FindItemByData(
'maplayer', mapLayer)
721 for key, val
in self.geomAttrb.iteritems():
722 checked = self.FindWindowById(val[
'check']).IsChecked()
723 column = self.FindWindowById(val[
'column']).
GetValue()
724 unitsIdx = self.FindWindowById(val[
'units']).GetSelection()
725 if item
and not tree.GetPyData(item)[0][
'vdigit']:
726 tree.GetPyData(item)[0][
'vdigit'] = {
'geomAttr' : dict() }
733 unitsKey = Units.GetUnitsKey(type, unitsIdx)
734 tree.GetPyData(item)[0][
'vdigit'][
'geomAttr'][key] = {
'column' : column,
737 if item
and tree.GetPyData(item)[0][
'vdigit']
and \
738 key
in tree.GetPyData(item)[0][
'vdigit'][
'geomAttr']:
739 del tree.GetPyData(item)[0][
'vdigit'][
'geomAttr'][key]
742 if self.queryLength.GetValue():
743 UserSettings.Set(group =
'vdigit', key =
"query", subkey =
'selection',
746 UserSettings.Set(group =
'vdigit', key =
"query", subkey =
'type',
748 UserSettings.Set(group =
'vdigit', key =
"query", subkey =
'box',
749 value = self.queryBox.IsChecked())
750 UserSettings.Set(group =
'vdigit', key =
"queryLength", subkey =
'than-selection',
751 value = self.queryLengthSL.GetSelection())
752 UserSettings.Set(group =
'vdigit', key =
"queryLength", subkey =
'thresh',
753 value = int(self.queryLengthValue.GetValue()))
754 UserSettings.Set(group =
'vdigit', key =
"queryDangle", subkey =
'than-selection',
755 value = self.queryDangleSL.GetSelection())
756 UserSettings.Set(group =
'vdigit', key =
"queryDangle", subkey =
'thresh',
757 value = int(self.queryDangleValue.GetValue()))
760 for feature
in (
'point',
'line',
761 'centroid',
'boundary'):
762 UserSettings.Set(group =
'vdigit', key =
'selectType',
763 subkey = [feature,
'enabled'],
764 value = self.FindWindowById(self.
selectFeature[feature]).IsChecked())
765 UserSettings.Set(group =
'vdigit', key =
"selectThresh", subkey =
'value',
766 value = int(self.selectThreshValue.GetValue()))
767 UserSettings.Set(group =
'vdigit', key =
"checkForDupl", subkey =
'enabled',
768 value = self.checkForDupl.IsChecked())
769 UserSettings.Set(group =
'vdigit', key =
"selectInside", subkey =
'enabled',
770 value = self.selectIn.IsChecked())
773 UserSettings.Set(group =
'vdigit', key =
"saveOnExit", subkey =
'enabled',
774 value = self.save.IsChecked())
777 UserSettings.Set(group =
'vdigit', key =
"breakLines", subkey =
'enabled',
778 value = self.intersect.IsChecked())
780 self.digit.UpdateSettings()
783 if self.parent.IsAutoRendered():
784 self.parent.OnRender(
None)
def OnApply
Button 'Apply' pressed.
def UpdateSettings
Update digitizer settings.
def OnSave
Button 'Save' pressed.
def _createSymbologyPage
Create notebook page concerning symbology settings.
def __init__
Standard settings dialog for digitization purposes.
def OnChangeSnappingValue
Change snapping value - update static text.
Custom control that selects elements.
def OnCancel
Button 'Cancel' pressed.
def OnChangeAddRecord
Checkbox 'Add new record' status changed.
def OnGeomAttrb
Register geometry attributes (enable/disable)
def OnChangeSnappingUnits
Snapping units change -> update static text.
def OnChangeQuery
Change query.
def OnChangeCategoryMode
Change category mode.
def _createQueryPage
Create notebook page for query tool.
def _symbologyData
Data for _createSymbologyPage()
def _createGeneralPage
Create notebook page concerning general settings.
def _createAttributesPage
Create notebook page for attributes.
def OnChangeLayer
Layer changed.