2 @package gmodeler.preferences
4 @brief wxGUI Graphical Modeler - preferences
7 - preferences::PreferencesDialog
8 - preferences::PropertiesDialog
10 (C) 2010-2012 by the GRASS Development Team
12 This program is free software under the GNU General Public License
13 (>=v2). Read the file COPYING that comes with GRASS for details.
15 @author Martin Landa <landa.martin gmail.com>
19 import wx.lib.colourselect
as csel
21 from core
import globalvar
26 """!User preferences dialog"""
27 def __init__(self, parent, settings = UserSettings,
28 title = _(
"Modeler settings")):
30 PreferencesBaseDialog.__init__(self, parent = parent, title = title,
39 self.SetMinSize(self.GetBestSize())
40 self.SetSize(self.
size)
42 def _createGeneralPage(self, notebook):
43 """!Create notebook page for action settings"""
44 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
45 notebook.AddPage(page = panel, text = _(
"General"))
48 border = wx.BoxSizer(wx.VERTICAL)
49 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
50 label =
" %s " % _(
"Item properties"))
51 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
53 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
54 gridSizer.AddGrowableCol(0)
57 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
58 label = _(
"Disabled:")),
59 flag = wx.ALIGN_LEFT |
60 wx.ALIGN_CENTER_VERTICAL,
62 rColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
63 colour = self.settings.Get(group=
'modeler', key=
'disabled', subkey=
'color'),
64 size = globalvar.DIALOG_COLOR_SIZE)
65 rColor.SetName(
'GetColour')
66 self.
winId[
'modeler:disabled:color'] = rColor.GetId()
68 gridSizer.Add(item = rColor,
69 flag = wx.ALIGN_RIGHT |
70 wx.ALIGN_CENTER_VERTICAL,
73 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
74 border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
76 panel.SetSizer(border)
80 def _createActionPage(self, notebook):
81 """!Create notebook page for action settings"""
82 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
83 notebook.AddPage(page = panel, text = _(
"Action"))
86 border = wx.BoxSizer(wx.VERTICAL)
87 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
88 label =
" %s " % _(
"Color"))
89 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
91 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
92 gridSizer.AddGrowableCol(0)
95 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
97 flag = wx.ALIGN_LEFT |
98 wx.ALIGN_CENTER_VERTICAL,
100 vColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
101 colour = self.settings.Get(group=
'modeler', key=
'action', subkey=(
'color',
'valid')),
102 size = globalvar.DIALOG_COLOR_SIZE)
103 vColor.SetName(
'GetColour')
104 self.
winId[
'modeler:action:color:valid'] = vColor.GetId()
106 gridSizer.Add(item = vColor,
107 flag = wx.ALIGN_RIGHT |
108 wx.ALIGN_CENTER_VERTICAL,
112 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
113 label = _(
"Invalid:")),
114 flag = wx.ALIGN_LEFT |
115 wx.ALIGN_CENTER_VERTICAL,
117 iColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
118 colour = self.settings.Get(group=
'modeler', key=
'action', subkey=(
'color',
'invalid')),
119 size = globalvar.DIALOG_COLOR_SIZE)
120 iColor.SetName(
'GetColour')
121 self.
winId[
'modeler:action:color:invalid'] = iColor.GetId()
123 gridSizer.Add(item = iColor,
124 flag = wx.ALIGN_RIGHT |
125 wx.ALIGN_CENTER_VERTICAL,
129 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
130 label = _(
"Running:")),
131 flag = wx.ALIGN_LEFT |
132 wx.ALIGN_CENTER_VERTICAL,
134 rColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
135 colour = self.settings.Get(group=
'modeler', key=
'action', subkey=(
'color',
'running')),
136 size = globalvar.DIALOG_COLOR_SIZE)
137 rColor.SetName(
'GetColour')
138 self.
winId[
'modeler:action:color:running'] = rColor.GetId()
140 gridSizer.Add(item = rColor,
141 flag = wx.ALIGN_RIGHT |
142 wx.ALIGN_CENTER_VERTICAL,
145 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
146 border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
149 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
150 label =
" %s " % _(
"Shape size"))
151 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
153 gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
154 gridSizer.AddGrowableCol(0)
157 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
158 label = _(
"Width:")),
159 flag = wx.ALIGN_LEFT |
160 wx.ALIGN_CENTER_VERTICAL,
163 width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
165 initial = self.settings.Get(group=
'modeler', key=
'action', subkey=(
'size',
'width')))
166 width.SetName(
'GetValue')
167 self.
winId[
'modeler:action:size:width'] = width.GetId()
169 gridSizer.Add(item = width,
170 flag = wx.ALIGN_RIGHT |
171 wx.ALIGN_CENTER_VERTICAL,
175 gridSizer.Add(item = wx.StaticText(parent=panel, id=wx.ID_ANY,
177 flag = wx.ALIGN_LEFT |
178 wx.ALIGN_CENTER_VERTICAL,
181 height = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
183 initial = self.settings.Get(group=
'modeler', key=
'action', subkey=(
'size',
'height')))
184 height.SetName(
'GetValue')
185 self.
winId[
'modeler:action:size:height'] = height.GetId()
187 gridSizer.Add(item = height,
188 flag = wx.ALIGN_RIGHT |
189 wx.ALIGN_CENTER_VERTICAL,
192 sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
193 border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
195 panel.SetSizer(border)
199 def _createDataPage(self, notebook):
200 """!Create notebook page for data settings"""
201 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
202 notebook.AddPage(page = panel, text = _(
"Data"))
205 border = wx.BoxSizer(wx.VERTICAL)
206 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
207 label =
" %s " % _(
"Type"))
208 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
210 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
211 gridSizer.AddGrowableCol(0)
214 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
215 label = _(
"Raster:")),
216 flag = wx.ALIGN_LEFT |
217 wx.ALIGN_CENTER_VERTICAL,
219 rColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
220 colour = self.settings.Get(group=
'modeler', key=
'data', subkey=(
'color',
'raster')),
221 size = globalvar.DIALOG_COLOR_SIZE)
222 rColor.SetName(
'GetColour')
223 self.
winId[
'modeler:data:color:raster'] = rColor.GetId()
225 gridSizer.Add(item = rColor,
226 flag = wx.ALIGN_RIGHT |
227 wx.ALIGN_CENTER_VERTICAL,
231 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
232 label = _(
"3D raster:")),
233 flag = wx.ALIGN_LEFT |
234 wx.ALIGN_CENTER_VERTICAL,
236 r3Color = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
237 colour = self.settings.Get(group=
'modeler', key=
'data', subkey=(
'color',
'raster3d')),
238 size = globalvar.DIALOG_COLOR_SIZE)
239 r3Color.SetName(
'GetColour')
240 self.
winId[
'modeler:data:color:raster3d'] = r3Color.GetId()
242 gridSizer.Add(item = r3Color,
243 flag = wx.ALIGN_RIGHT |
244 wx.ALIGN_CENTER_VERTICAL,
248 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
249 label = _(
"Vector:")),
250 flag = wx.ALIGN_LEFT |
251 wx.ALIGN_CENTER_VERTICAL,
253 vColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
254 colour = self.settings.Get(group=
'modeler', key=
'data', subkey=(
'color',
'vector')),
255 size = globalvar.DIALOG_COLOR_SIZE)
256 vColor.SetName(
'GetColour')
257 self.
winId[
'modeler:data:color:vector'] = vColor.GetId()
259 gridSizer.Add(item = vColor,
260 flag = wx.ALIGN_RIGHT |
261 wx.ALIGN_CENTER_VERTICAL,
264 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
265 border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
268 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
269 label =
" %s " % _(
"Shape size"))
270 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
272 gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
273 gridSizer.AddGrowableCol(0)
276 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
277 label = _(
"Width:")),
278 flag = wx.ALIGN_LEFT |
279 wx.ALIGN_CENTER_VERTICAL,
282 width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
284 initial = self.settings.Get(group=
'modeler', key=
'data', subkey=(
'size',
'width')))
285 width.SetName(
'GetValue')
286 self.
winId[
'modeler:data:size:width'] = width.GetId()
288 gridSizer.Add(item = width,
289 flag = wx.ALIGN_RIGHT |
290 wx.ALIGN_CENTER_VERTICAL,
294 gridSizer.Add(item = wx.StaticText(parent=panel, id=wx.ID_ANY,
296 flag = wx.ALIGN_LEFT |
297 wx.ALIGN_CENTER_VERTICAL,
300 height = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
302 initial = self.settings.Get(group=
'modeler', key=
'data', subkey=(
'size',
'height')))
303 height.SetName(
'GetValue')
304 self.
winId[
'modeler:data:size:height'] = height.GetId()
306 gridSizer.Add(item = height,
307 flag = wx.ALIGN_RIGHT |
308 wx.ALIGN_CENTER_VERTICAL,
311 sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
312 border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
314 panel.SetSizer(border)
318 def _createLoopPage(self, notebook):
319 """!Create notebook page for loop settings"""
320 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
321 notebook.AddPage(page = panel, text = _(
"Loop"))
324 border = wx.BoxSizer(wx.VERTICAL)
325 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
326 label =
" %s " % _(
"Color"))
327 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
329 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
330 gridSizer.AddGrowableCol(0)
333 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
334 label = _(
"Valid:")),
335 flag = wx.ALIGN_LEFT |
336 wx.ALIGN_CENTER_VERTICAL,
338 vColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
339 colour = self.settings.Get(group=
'modeler', key=
'loop', subkey=(
'color',
'valid')),
340 size = globalvar.DIALOG_COLOR_SIZE)
341 vColor.SetName(
'GetColour')
342 self.
winId[
'modeler:loop:color:valid'] = vColor.GetId()
344 gridSizer.Add(item = vColor,
345 flag = wx.ALIGN_RIGHT |
346 wx.ALIGN_CENTER_VERTICAL,
349 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
350 border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
353 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
354 label =
" %s " % _(
"Shape size"))
355 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
357 gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
358 gridSizer.AddGrowableCol(0)
361 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
362 label = _(
"Width:")),
363 flag = wx.ALIGN_LEFT |
364 wx.ALIGN_CENTER_VERTICAL,
367 width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
369 initial = self.settings.Get(group=
'modeler', key=
'loop', subkey=(
'size',
'width')))
370 width.SetName(
'GetValue')
371 self.
winId[
'modeler:loop:size:width'] = width.GetId()
373 gridSizer.Add(item = width,
374 flag = wx.ALIGN_RIGHT |
375 wx.ALIGN_CENTER_VERTICAL,
379 gridSizer.Add(item = wx.StaticText(parent=panel, id=wx.ID_ANY,
381 flag = wx.ALIGN_LEFT |
382 wx.ALIGN_CENTER_VERTICAL,
385 height = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
387 initial = self.settings.Get(group=
'modeler', key=
'loop', subkey=(
'size',
'height')))
388 height.SetName(
'GetValue')
389 self.
winId[
'modeler:loop:size:height'] = height.GetId()
391 gridSizer.Add(item = height,
392 flag = wx.ALIGN_RIGHT |
393 wx.ALIGN_CENTER_VERTICAL,
396 sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
397 border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
399 panel.SetSizer(border)
404 """!Button 'Apply' pressed"""
405 PreferencesBaseDialog.OnApply(self, event)
407 self.parent.GetModel().Update()
408 self.parent.GetCanvas().Refresh()
411 """!Button 'Save' pressed"""
412 PreferencesBaseDialog.OnSave(self, event)
414 self.parent.GetModel().Update()
415 self.parent.GetCanvas().Refresh()
418 """!Model properties dialog
420 def __init__(self, parent, id = wx.ID_ANY,
421 title = _(
'Model properties'),
423 style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
424 wx.Dialog.__init__(self, parent, id, title, size = size,
427 self.
metaBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
428 label=
" %s " % _(
"Metadata"))
429 self.
cmdBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
430 label=
" %s " % _(
"Commands"))
432 self.
name = wx.TextCtrl(parent = self, id = wx.ID_ANY,
434 self.
desc = wx.TextCtrl(parent = self, id = wx.ID_ANY,
435 style = wx.TE_MULTILINE,
437 self.
author = wx.TextCtrl(parent = self, id = wx.ID_ANY,
441 self.
overwrite = wx.CheckBox(parent = self, id=wx.ID_ANY,
442 label=_(
"Allow output files to overwrite existing files"))
443 self.overwrite.SetValue(UserSettings.Get(group=
'cmd', key=
'overwrite', subkey=
'enabled'))
446 self.
btnOk = wx.Button(self, wx.ID_OK)
448 self.btnOk.SetDefault()
450 self.btnOk.SetToolTipString(_(
"Apply properties"))
451 self.btnOk.SetDefault()
452 self.btnCancel.SetToolTipString(_(
"Close dialog and ignore changes"))
459 metaSizer = wx.StaticBoxSizer(self.
metaBox, wx.VERTICAL)
460 gridSizer = wx.GridBagSizer(hgap = 3, vgap = 3)
461 gridSizer.AddGrowableCol(1)
462 gridSizer.AddGrowableRow(1)
463 gridSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
465 flag = wx.ALIGN_LEFT |
466 wx.ALIGN_CENTER_VERTICAL,
468 gridSizer.Add(item = self.
name,
469 flag = wx.ALIGN_LEFT |
470 wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
472 gridSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
473 label = _(
"Description:")),
474 flag = wx.ALIGN_LEFT |
475 wx.ALIGN_CENTER_VERTICAL,
477 gridSizer.Add(item = self.
desc,
478 flag = wx.ALIGN_LEFT |
479 wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
481 gridSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
482 label = _(
"Author(s):")),
483 flag = wx.ALIGN_LEFT |
484 wx.ALIGN_CENTER_VERTICAL,
486 gridSizer.Add(item = self.
author,
487 flag = wx.ALIGN_LEFT |
488 wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
490 metaSizer.Add(item = gridSizer, proportion = 1, flag = wx.EXPAND)
492 cmdSizer = wx.StaticBoxSizer(self.
cmdBox, wx.VERTICAL)
494 flag = wx.EXPAND | wx.ALL, border = 3)
496 btnStdSizer = wx.StdDialogButtonSizer()
498 btnStdSizer.AddButton(self.
btnOk)
499 btnStdSizer.Realize()
501 mainSizer = wx.BoxSizer(wx.VERTICAL)
502 mainSizer.Add(item=metaSizer, proportion=1,
503 flag=wx.EXPAND | wx.ALL, border=5)
504 mainSizer.Add(item=cmdSizer, proportion=0,
505 flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
506 mainSizer.Add(item=btnStdSizer, proportion=0,
507 flag=wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT, border=5)
509 self.SetSizer(mainSizer)
517 return {
'name' : self.name.GetValue(),
518 'description' : self.desc.GetValue(),
519 'author' : self.author.GetValue(),
520 'overwrite' : self.overwrite.IsChecked() }
523 """!Initialize dialog"""
524 self.name.SetValue(prop[
'name'])
525 self.desc.SetValue(prop[
'description'])
526 self.author.SetValue(prop[
'author'])
527 if 'overwrite' in prop:
528 self.overwrite.SetValue(prop[
'overwrite'])
def _createActionPage
Create notebook page for action settings.
def OnApply
Button 'Apply' pressed.
def Init
Initialize dialog.
def OnSave
Button 'Save' pressed.
def _createLoopPage
Create notebook page for loop settings.
def _createDataPage
Create notebook page for data settings.
def _createGeneralPage
Create notebook page for action settings.