GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
nviz/preferences.py
Go to the documentation of this file.
1 """
2 @package nviz.preferences
3 
4 @brief Nviz (3D view) preferences window
5 
6 Classes:
7  - preferences::NvizPreferencesDialog
8 
9 (C) 2008-2011 by the GRASS Development Team
10 
11 This program is free software under the GNU General Public License
12 (>=v2). Read the file COPYING that comes with GRASS for details.
13 
14 @author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
15 @author Enhancements by Michael Barton <michael.barton asu.edu>
16 @author Anna Kratochvilova <KratochAnna seznam.cz> (Google SoC 2011)
17 """
18 
19 import os
20 import copy
21 
22 import wx
23 import wx.lib.colourselect as csel
24 
25 from core import globalvar
26 from core.settings import UserSettings
27 from gui_core.preferences import PreferencesBaseDialog
28 
30  """!Nviz preferences dialog"""
31  def __init__(self, parent, title = _("3D view settings"),
32  settings = UserSettings):
33  PreferencesBaseDialog.__init__(self, parent = parent, title = title,
34  settings = settings)
35  self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass_nviz.ico'), wx.BITMAP_TYPE_ICO))
36 
37  self.toolWin = self.parent.nviz
38 
39  # create notebook pages
40  self._createViewPage(self.notebook)
41  self._createFlyPage(self.notebook)
42  self._createLightPage(self.notebook)
43  self._createSurfacePage(self.notebook)
44  self._createVectorPage(self.notebook)
45 
46  self.SetMinSize(self.GetBestSize())
47  self.SetSize(self.size)
48  self.btnDefault.SetToolTipString(_("Revert settings to default, changes are not applied"))
49 
50  def _createViewPage(self, notebook):
51  """!Create notebook page for view settings"""
52  panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
53 
54  notebook.AddPage(page = panel,
55  text = " %s " % _("View"))
56 
57  pageSizer = wx.BoxSizer(wx.VERTICAL)
58 
59  box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
60  label = " %s " % (_("View")))
61  boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
62  gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
63  row = 0
64  # perspective
65  pvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'persp')
66  ipvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'persp', internal = True)
67  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
68  label = _("Perspective:")),
69  pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
70  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
71  label = _("value:")),
72  pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
73 
74  pval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
75  initial = pvals['value'],
76  min = ipvals['min'],
77  max = ipvals['max'])
78  self.winId['nviz:view:persp:value'] = pval.GetId()
79  gridSizer.Add(item = pval, pos = (row, 2),
80  flag = wx.ALIGN_CENTER_VERTICAL)
81 
82  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
83  label = _("step:")),
84  pos = (row, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
85 
86  pstep = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
87  initial = pvals['step'],
88  min = ipvals['min'],
89  max = ipvals['max']-1)
90  self.winId['nviz:view:persp:step'] = pstep.GetId()
91  gridSizer.Add(item = pstep, pos = (row, 4),
92  flag = wx.ALIGN_CENTER_VERTICAL)
93  row += 1
94 
95  # position
96  posvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'position')
97  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
98  label = _("Position:")),
99  pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
100  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
101  label = _("x:")),
102  pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
103 
104  px = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
105  initial = posvals['x'] * 100,
106  min = 0,
107  max = 100)
108  self.winId['nviz:view:position:x'] = px.GetId()
109  gridSizer.Add(item = px, pos = (row, 2),
110  flag = wx.ALIGN_CENTER_VERTICAL)
111 
112  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
113  label = "y:"),
114  pos = (row, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
115 
116  py = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
117  initial = posvals['y'] * 100,
118  min = 0,
119  max = 100)
120  self.winId['nviz:view:position:y'] = py.GetId()
121  gridSizer.Add(item = py, pos = (row, 4),
122  flag = wx.ALIGN_CENTER_VERTICAL)
123  row += 1
124 
125  # height is computed dynamically
126 
127  # twist
128  tvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'twist')
129  itvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'twist', internal = True)
130  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
131  label = _("Twist:")),
132  pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
133  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
134  label = _("value:")),
135  pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
136 
137  tval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
138  initial = tvals['value'],
139  min = itvals['min'],
140  max = itvals['max'])
141  self.winId['nviz:view:twist:value'] = tval.GetId()
142  gridSizer.Add(item = tval, pos = (row, 2),
143  flag = wx.ALIGN_CENTER_VERTICAL)
144  row += 1
145 
146  # z-exag
147  zvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'z-exag')
148  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
149  label = _("Z-exag:")),
150  pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
151  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
152  label = _("value:")),
153  pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
154 
155  zval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
156  initial = zvals['value'],
157  min = -1e6,
158  max = 1e6)
159  self.winId['nviz:view:z-exag:value'] = zval.GetId()
160  gridSizer.Add(item = zval, pos = (row, 2),
161  flag = wx.ALIGN_CENTER_VERTICAL)
162 
163 
164  boxSizer.Add(item = gridSizer, proportion = 1,
165  flag = wx.ALL | wx.EXPAND, border = 3)
166  pageSizer.Add(item = boxSizer, proportion = 0,
167  flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
168  border = 3)
169 
170  box = wx.StaticBox(parent = panel, id = wx.ID_ANY,
171  label = " %s " % (_("Image Appearance")))
172  boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
173  gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
174  gridSizer.AddGrowableCol(0)
175 
176  # background color
177  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
178  label = _("Background color:")),
179  pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
180 
181  color = csel.ColourSelect(panel, id = wx.ID_ANY,
182  colour = UserSettings.Get(group = 'nviz', key = 'view',
183  subkey = ['background', 'color']),
184  size = globalvar.DIALOG_COLOR_SIZE)
185  color.SetName('GetColour')
186  self.winId['nviz:view:background:color'] = color.GetId()
187  gridSizer.Add(item = color, pos = (0, 1))
188 
189  boxSizer.Add(item = gridSizer, proportion = 1,
190  flag = wx.ALL | wx.EXPAND, border = 5)
191  pageSizer.Add(item = boxSizer, proportion = 0,
192  flag = wx.EXPAND | wx.ALL,
193  border = 5)
194 
195  panel.SetSizer(pageSizer)
196 
197  return panel
198 
199  def _createFlyPage(self, notebook):
200  """!Create notebook page for view settings"""
201  panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
202 
203  notebook.AddPage(page = panel,
204  text = " %s " % _("Fly-through"))
205  pageSizer = wx.BoxSizer(wx.VERTICAL)
206  # fly throuhg mode
207  box = wx.StaticBox(parent = panel, id = wx.ID_ANY,
208  label = " %s " % (_("Fly-through mode")))
209  boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
210  gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
211  gridSizer.AddGrowableCol(0)
212 
213  # move exag
214  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
215  label = _("Move exag:")),
216  pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
217 
218  moveExag = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 20,
219  initial = UserSettings.Get(group = 'nviz', key = 'fly',
220  subkey = ['exag', 'move']),
221  size = (65, -1))
222  self.winId['nviz:fly:exag:move'] = moveExag.GetId()
223  gridSizer.Add(item = moveExag, pos = (0, 1))
224 
225  # turn exag
226  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
227  label = _("Turn exag:")),
228  pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
229 
230  turnExag = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 20,
231  initial = UserSettings.Get(group = 'nviz', key = 'fly',
232  subkey = ['exag', 'turn']),
233  size = (65, -1))
234  self.winId['nviz:fly:exag:turn'] = turnExag.GetId()
235  gridSizer.Add(item = turnExag, pos = (1, 1))
236 
237  boxSizer.Add(item = gridSizer, proportion = 1,
238  flag = wx.ALL | wx.EXPAND, border = 5)
239  pageSizer.Add(item = boxSizer, proportion = 0,
240  flag = wx.EXPAND | wx.ALL,
241  border = 5)
242 
243  panel.SetSizer(pageSizer)
244 
245  return panel
246 
247  def _createLightPage(self, notebook):
248  """!Create notebook page for light settings"""
249  panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
250 
251  notebook.AddPage(page = panel,
252  text = " %s " % _("Lighting"))
253 
254  pageSizer = wx.BoxSizer(wx.VERTICAL)
255 
256  box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
257  label = " %s " % (_("Light")))
258  boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
259  gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
260 
261 
262  # position
263  posvals = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'position')
264  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
265  label = _("Position:")),
266  pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
267  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
268  label = _("x:")),
269  pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
270 
271  px = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
272  initial = posvals['x'] * 100,
273  min = -100,
274  max = 100)
275  self.winId['nviz:light:position:x'] = px.GetId()
276  gridSizer.Add(item = px, pos = (0, 2),
277  flag = wx.ALIGN_CENTER_VERTICAL)
278 
279  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
280  label = "y:"),
281  pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
282 
283  py = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
284  initial = posvals['y'] * 100,
285  min = -100,
286  max = 100)
287  self.winId['nviz:light:position:y'] = py.GetId()
288  gridSizer.Add(item = py, pos = (0, 4),
289  flag = wx.ALIGN_CENTER_VERTICAL)
290 
291  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
292  label = _("z:")),
293  pos = (0, 5), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
294 
295  pz = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
296  initial = posvals['z'],
297  min = 0,
298  max = 100)
299  self.winId['nviz:light:position:z'] = pz.GetId()
300  gridSizer.Add(item = pz, pos = (0, 6),
301  flag = wx.ALIGN_CENTER_VERTICAL)
302 
303  # brightness
304  brightval = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'bright')
305  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
306  label = _("Brightness:")),
307  pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
308 
309  bright = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
310  initial = brightval,
311  min = 0,
312  max = 100)
313  self.winId['nviz:light:bright'] = bright.GetId()
314  gridSizer.Add(item = bright, pos = (1, 2),
315  flag = wx.ALIGN_CENTER_VERTICAL)
316 
317  # ambient
318  ambval = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'ambient')
319  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
320  label = _("Ambient:")),
321  pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL)
322 
323  amb = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
324  initial = ambval,
325  min = 0,
326  max = 100)
327  self.winId['nviz:light:ambient'] = amb.GetId()
328  gridSizer.Add(item = amb, pos = (2, 2),
329  flag = wx.ALIGN_CENTER_VERTICAL)
330 
331  # light color
332  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
333  label = _("Color:")),
334  pos = (3, 0), flag = wx.ALIGN_CENTER_VERTICAL)
335 
336  color = csel.ColourSelect(panel, id = wx.ID_ANY,
337  colour = UserSettings.Get(group = 'nviz', key = 'light',
338  subkey = 'color'),
339  size = globalvar.DIALOG_COLOR_SIZE)
340  color.SetName('GetColour')
341  self.winId['nviz:light:color'] = color.GetId()
342  gridSizer.Add(item = color, pos = (3, 2))
343 
344 
345  boxSizer.Add(item = gridSizer, proportion = 1,
346  flag = wx.ALL | wx.EXPAND, border = 5)
347  pageSizer.Add(item = boxSizer, proportion = 0,
348  flag = wx.EXPAND | wx.ALL,
349  border = 5)
350 
351  panel.SetSizer(pageSizer)
352 
353  return panel
354 
355  def _createSurfacePage(self, notebook):
356  """!Create notebook page for surface settings"""
357  panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
358 
359  notebook.AddPage(page = panel,
360  text = " %s " % _("Surface"))
361 
362  pageSizer = wx.BoxSizer(wx.VERTICAL)
363 
364  # draw
365 
366  box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
367  label = " %s " % (_("Draw")))
368  boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
369  gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
370 
371  # mode
372  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
373  label = _("Mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
374  pos = (0, 0))
375  mode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (-1, -1),
376  choices = [_("coarse"),
377  _("fine"),
378  _("both")])
379  self.winId['nviz:surface:draw:mode'] = mode.GetId()
380  mode.SetName('GetSelection')
381  mode.SetSelection(UserSettings.Get(group = 'nviz', key = 'surface',
382  subkey = ['draw', 'mode']))
383  gridSizer.Add(item = mode, flag = wx.ALIGN_CENTER_VERTICAL,
384  pos = (0, 1))
385 
386  # fine
387  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
388  label = _("Fine mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
389  pos = (1, 0))
390  res = UserSettings.Get(group = 'nviz', key = 'surface', subkey = ['draw','res-fine'])
391  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
392  label = _("resolution:")), flag = wx.ALIGN_CENTER_VERTICAL,
393  pos = (1, 1))
394  fine = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
395  initial = res,
396  min = 1,
397  max = 100)
398  self.winId['nviz:surface:draw:res-fine'] = fine.GetId()
399 
400  gridSizer.Add(item = fine, flag = wx.ALIGN_CENTER_VERTICAL,
401  pos = (1, 2))
402 
403  # coarse
404  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
405  label = _("Coarse mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
406  pos = (2, 0))
407  res = UserSettings.Get(group = 'nviz', key = 'surface', subkey = ['draw','res-coarse'])
408  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
409  label = _("resolution:")), flag = wx.ALIGN_CENTER_VERTICAL,
410  pos = (2, 1))
411  coarse = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
412  initial = res,
413  min = 1,
414  max = 100)
415  self.winId['nviz:surface:draw:res-coarse'] = coarse.GetId()
416 
417  gridSizer.Add(item = coarse, flag = wx.ALIGN_CENTER_VERTICAL,
418  pos = (2, 2))
419  #style
420  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
421  label = _("style:")), flag = wx.ALIGN_CENTER_VERTICAL,
422  pos = (3, 1))
423  style = wx.Choice(parent = panel, id = wx.ID_ANY, size = (-1, -1),
424  choices = [_("wire"),
425  _("surface")])
426  self.winId['nviz:surface:draw:style'] = style.GetId()
427  style.SetName('GetSelection')
428  style.SetSelection(UserSettings.Get(group = 'nviz', key = 'surface',
429  subkey = ['draw', 'style']))
430  self.winId['nviz:surface:draw:style'] = style.GetId()
431 
432  gridSizer.Add(item = style, flag = wx.ALIGN_CENTER_VERTICAL,
433  pos = (3, 2))
434  #wire color
435  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
436  label = _("wire color:")), flag = wx.ALIGN_CENTER_VERTICAL,
437  pos = (4, 1))
438  color = csel.ColourSelect(panel, id = wx.ID_ANY,
439  colour = UserSettings.Get(group = 'nviz', key = 'surface',
440  subkey = ['draw', 'wire-color']),
441  size = globalvar.DIALOG_COLOR_SIZE)
442  color.SetName('GetColour')
443  self.winId['nviz:surface:draw:wire-color'] = color.GetId()
444  gridSizer.Add(item = color, flag = wx.ALIGN_CENTER_VERTICAL,
445  pos = (4, 2))
446 
447  boxSizer.Add(item = gridSizer, proportion = 1,
448  flag = wx.ALL | wx.EXPAND, border = 5)
449  pageSizer.Add(item = boxSizer, proportion = 0,
450  flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
451  border = 5)
452 
453  panel.SetSizer(pageSizer)
454 
455  return panel
456 
457  def _createVectorPage(self, notebook):
458  """!Create notebook page for vector settings"""
459  panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
460 
461  notebook.AddPage(page = panel,
462  text = " %s " % _("Vector"))
463 
464  pageSizer = wx.BoxSizer(wx.VERTICAL)
465 
466  # vector lines
467  box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
468  label = " %s " % (_("Vector lines")))
469  boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
470  gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
471 
472  row = 0
473  # icon size
474  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
475  label = _("Width:")),
476  pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
477 
478  iwidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
479  initial = 12,
480  min = 1,
481  max = 100)
482  self.winId['nviz:vector:lines:width'] = iwidth.GetId()
483  iwidth.SetValue(UserSettings.Get(group = 'nviz', key = 'vector',
484  subkey = ['lines', 'width']))
485  gridSizer.Add(item = iwidth, pos = (row, 1),
486  flag = wx.ALIGN_CENTER_VERTICAL)
487 
488  # icon color
489  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
490  label = _("Color:")),
491  pos = (row, 4), flag = wx.ALIGN_CENTER_VERTICAL)
492  icolor = csel.ColourSelect(panel, id = wx.ID_ANY,
493  size = globalvar.DIALOG_COLOR_SIZE)
494  icolor.SetName('GetColour')
495  self.winId['nviz:vector:lines:color'] = icolor.GetId()
496  icolor.SetColour(UserSettings.Get(group = 'nviz', key = 'vector',
497  subkey = ['lines', 'color']))
498  gridSizer.Add(item = icolor, flag = wx.ALIGN_CENTER_VERTICAL,
499  pos = (row, 5))
500  boxSizer.Add(item = gridSizer, proportion = 1,
501  flag = wx.ALL | wx.EXPAND, border = 5)
502  pageSizer.Add(item = boxSizer, proportion = 0,
503  flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
504  border = 5)
505 
506  # vector points
507  box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
508  label = " %s " % (_("Vector points")))
509  boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
510  gridSizer = wx.GridBagSizer(vgap = 3, hgap = 5)
511 
512  row = 0
513  # icon size
514  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
515  label = _("Size:")),
516  pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
517 
518  isize = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
519  initial = 100,
520  min = 1,
521  max = 1e6)
522  self.winId['nviz:vector:points:size'] = isize.GetId()
523  isize.SetValue(UserSettings.Get(group = 'nviz', key = 'vector',
524  subkey = ['points', 'size']))
525  gridSizer.Add(item = isize, pos = (row, 1),
526  flag = wx.ALIGN_CENTER_VERTICAL)
527 
528  # icon symbol
529  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
530  label = _("Marker:")),
531  pos = (row, 2), flag = wx.ALIGN_CENTER_VERTICAL)
532  isym = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
533  choices = UserSettings.Get(group = 'nviz', key = 'vector',
534  subkey = ['points', 'marker'], internal = True))
535  isym.SetName("GetSelection")
536  self.winId['nviz:vector:points:marker'] = isym.GetId()
537  isym.SetSelection(UserSettings.Get(group = 'nviz', key = 'vector',
538  subkey = ['points', 'marker']))
539  gridSizer.Add(item = isym, flag = wx.ALIGN_CENTER_VERTICAL,
540  pos = (row, 3))
541 
542  # icon color
543  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
544  label = _("Color:")),
545  pos = (row, 4), flag = wx.ALIGN_CENTER_VERTICAL)
546  icolor = csel.ColourSelect(panel, id = wx.ID_ANY,
547  size = globalvar.DIALOG_COLOR_SIZE)
548  icolor.SetName('GetColour')
549  self.winId['nviz:vector:points:color'] = icolor.GetId()
550  icolor.SetColour(UserSettings.Get(group = 'nviz', key = 'vector',
551  subkey = ['points', 'color']))
552  gridSizer.Add(item = icolor, flag = wx.ALIGN_CENTER_VERTICAL,
553  pos = (row, 5))
554 
555  boxSizer.Add(item = gridSizer, proportion = 1,
556  flag = wx.ALL | wx.EXPAND, border = 5)
557  pageSizer.Add(item = boxSizer, proportion = 0,
558  flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
559  border = 5)
560 
561  panel.SetSizer(pageSizer)
562 
563  return panel
564 
565  def OnDefault(self, event):
566  """!Button 'Set to default' pressed"""
567  self.settings.userSettings = copy.deepcopy(self.settings.defaultSettings)
568 
569  # update widgets
570  for gks in self.winId.keys():
571  subkey1 = None
572  try:
573  group, key, subkey = gks.split(':')
574  value = self.settings.Get(group, key, subkey)
575  except ValueError:
576  group, key, subkey, subkey1 = gks.split(':')
577  value = self.settings.Get(group, key, [subkey, subkey1])
578  if subkey == 'position':
579  if subkey1 in ('x', 'y'):
580  value = float(value) * 100
581  win = self.FindWindowById(self.winId[gks])
582  if win.GetName() == 'GetSelection':
583  value = win.SetSelection(value)
584  else:
585  value = win.SetValue(value)
586 
587  def OnApply(self, event):
588  """Apply Nviz settings for current session"""
589  for item in self.winId.keys():
590  try:
591  group, key, subkey = item.split(':')
592  subkey1 = None
593  except ValueError:
594  group, key, subkey, subkey1 = item.split(':')
595 
596  id = self.winId[item]
597  win = self.FindWindowById(id)
598  if win.GetName() == 'GetSelection':
599  value = win.GetSelection()
600  elif win.GetName() == 'GetColour':
601  value = tuple(win.GetValue())
602  else:
603  value = win.GetValue()
604 
605  if subkey == 'position':
606  if subkey1 in ('x', 'y'):
607  value = float(value) / 100
608  if subkey1:
609  self.settings.Set(group, value, key, [subkey, subkey1])
610  else:
611  self.settings.Set(group, value, key, subkey)
612 
613  self.toolWin.LoadSettings()
614 
615 
616  def OnSave(self, event):
617  """!Save button pressed
618 
619  Apply changes and save settings to configuration file
620  """
621  self.OnApply(None)
622  fileSettings = {}
623  UserSettings.ReadSettingsFile(settings = fileSettings)
624  fileSettings['nviz'] = UserSettings.Get(group = 'nviz')
625 
626  UserSettings.SaveToFile(fileSettings)
627  self.parent.goutput.WriteLog(
628  _('3D view settings saved to file <%s>.') % UserSettings.filePath)
629 
630  self.Destroy()
def _createFlyPage
Create notebook page for view settings.
def _createSurfacePage
Create notebook page for surface settings.
def _createVectorPage
Create notebook page for vector settings.
def OnApply
Button &#39;Apply&#39; pressed Posts event EVT_SETTINGS_CHANGED.
def OnSave
Save button pressed.
def OnDefault
Button &#39;Set to default&#39; pressed.
def _createViewPage
Create notebook page for view settings.
User preferences dialog.
def _createLightPage
Create notebook page for light settings.
Default GUI settings.
Nviz preferences dialog.