4 @brief Nviz (3D view) tools window
12 (C) 2008-2010 by the GRASS Development Team
14 This program is free software under the GNU General Public
15 License (>=v2). Read the file COPYING that comes with GRASS
18 @author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
19 @author Enhancements by Michael Barton <michael.barton@asu.edu>
28 import wx.lib.colourselect
as csel
29 import wx.lib.scrolledpanel
as SP
31 import wx.lib.agw.flatnotebook
as FN
33 import wx.lib.flatnotebook
as FN
40 from preferences
import globalSettings
as UserSettings
41 from preferences
import PreferencesBaseDialog
43 from nviz_mapdisp
import wxUpdateView, wxUpdateLight, wxUpdateProperties
45 except (ImportError, NameError):
47 from debug
import Debug
50 """!Nviz (3D view) tools panel
52 def __init__(self, parent, display, id = wx.ID_ANY,
53 style = globalvar.FNPageStyle, **kwargs):
57 self.
_display = self.mapWindow.GetDisplay()
60 kwargs[
'agwStyle'] = style
62 kwargs[
'style'] = style
63 FN.FlatNotebook.__init__(self, parent, id, **kwargs)
64 self.SetTabAreaColour(globalvar.FNPageColor)
71 text =
" %s " % _(
"View"))
75 text =
" %s " % _(
"Data"))
79 text =
" %s " % _(
"Appearance"))
83 self.mapWindow.render[
'quick'] =
False
84 self.mapWindow.Refresh(
False)
87 self.Bind(wx.EVT_CLOSE, self.
OnClose)
91 wx.CallAfter(self.
SetPage,
'view')
92 wx.CallAfter(self.notebookData.SetSelection, 0)
93 wx.CallAfter(self.notebookAppearance.SetSelection, 0)
96 new = event.GetSelection()
100 """!Change view settings"""
101 event = wxUpdateView(zExag = zExag)
104 def _createViewPage(self):
105 """!Create view settings page"""
106 panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
107 panel.SetupScrolling(scroll_x =
False)
108 self.
page[
'view'] = {
'id' : 0,
109 'notebook' : self.GetId()}
111 pageSizer = wx.BoxSizer(wx.VERTICAL)
112 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
113 label =
" %s " % (_(
"Control View")))
114 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
115 gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
117 self.
win[
'view'] = {}
120 posSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
121 posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"W")),
122 pos = (1, 0), flag = wx.ALIGN_CENTER)
123 posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"N")),
124 pos = (0, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_BOTTOM)
127 self.
win[
'view'][
'position'] = view.GetId()
128 posSizer.Add(item = view,
129 pos = (1, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)
130 posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"S")),
131 pos = (2, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_TOP)
132 posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"E")),
133 pos = (1, 2), flag = wx.ALIGN_CENTER)
134 gridSizer.Add(item = posSizer, pos = (0, 0))
141 gridSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Perspective:")),
142 pos = (1, 0), flag = wx.ALIGN_CENTER)
143 gridSizer.Add(item = self.FindWindowById(self.
win[
'view'][
'persp'][
'slider']), pos = (2, 0))
144 gridSizer.Add(item = self.FindWindowById(self.
win[
'view'][
'persp'][
'spin']), pos = (3, 0),
145 flag = wx.ALIGN_CENTER)
151 gridSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Twist:")),
152 pos = (1, 1), flag = wx.ALIGN_CENTER)
153 gridSizer.Add(item = self.FindWindowById(self.
win[
'view'][
'twist'][
'slider']), pos = (2, 1))
154 gridSizer.Add(item = self.FindWindowById(self.
win[
'view'][
'twist'][
'spin']), pos = (3, 1),
155 flag = wx.ALIGN_CENTER)
158 self.
_createControl(panel, data = self.
win[
'view'], name =
'height', sliderHor =
False,
162 self.
_createControl(panel, data = self.
win[
'view'], name =
'z-exag', sliderHor =
False,
165 self.FindWindowById(self.
win[
'view'][
'z-exag'][
'slider']).SetValue(1)
166 self.FindWindowById(self.
win[
'view'][
'z-exag'][
'spin']).SetValue(1)
168 heightSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
169 heightSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Height:")),
170 pos = (0, 0), flag = wx.ALIGN_LEFT, span = (1, 2))
171 heightSizer.Add(item = self.FindWindowById(self.
win[
'view'][
'height'][
'slider']),
172 flag = wx.ALIGN_RIGHT, pos = (1, 0))
173 heightSizer.Add(item = self.FindWindowById(self.
win[
'view'][
'height'][
'spin']),
174 flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.TOP |
175 wx.BOTTOM | wx.RIGHT, pos = (1, 1))
176 heightSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Z-exag:")),
177 pos = (0, 2), flag = wx.ALIGN_LEFT, span = (1, 2))
178 heightSizer.Add(item = self.FindWindowById(self.
win[
'view'][
'z-exag'][
'slider']),
179 flag = wx.ALIGN_RIGHT, pos = (1, 2))
180 heightSizer.Add(item = self.FindWindowById(self.
win[
'view'][
'z-exag'][
'spin']),
181 flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.TOP |
182 wx.BOTTOM | wx.RIGHT, pos = (1, 3))
184 gridSizer.Add(item = heightSizer, pos = (0, 1), flag = wx.ALIGN_RIGHT)
187 viewSizer = wx.BoxSizer(wx.HORIZONTAL)
189 viewSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY,
190 label = _(
"Look at:")),
191 flag = wx.ALL | wx.ALIGN_CENTER_VERTICAL,
194 viewType = wx.Choice (parent = panel, id = wx.ID_ANY, size = (125, -1),
204 viewType.SetSelection(0)
205 viewType.Bind(wx.EVT_CHOICE, self.
OnLookAt)
207 viewSizer.Add(item = viewType,
208 flag = wx.ALL | wx.ALIGN_CENTER_VERTICAL,
211 reset = wx.Button(panel, id = wx.ID_ANY, label = _(
"Reset"))
212 reset.SetToolTipString(_(
"Reset to default view"))
216 viewSizer.Add(item = wx.Size(-1, -1), proportion = 1,
218 viewSizer.Add(item = reset, proportion = 0,
219 flag = wx.ALL | wx.ALIGN_RIGHT,
222 gridSizer.AddGrowableCol(2)
223 gridSizer.Add(item = viewSizer, pos = (4, 0), span = (1, 2),
227 boxSizer.Add(item = gridSizer, proportion = 1,
228 flag = wx.ALL | wx.EXPAND, border = 2)
229 pageSizer.Add(item = boxSizer, proportion = 0,
230 flag = wx.EXPAND | wx.ALL,
233 box = wx.StaticBox(parent = panel, id = wx.ID_ANY,
234 label =
" %s " % (_(
"Image Appearance")))
235 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
236 gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
237 gridSizer.AddGrowableCol(0)
240 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
241 label = _(
"Background color:")),
242 pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
244 color = csel.ColourSelect(panel, id = wx.ID_ANY,
245 colour = UserSettings.Get(group =
'nviz', key =
'view',
246 subkey = [
'background',
'color']),
247 size = globalvar.DIALOG_COLOR_SIZE)
248 self.
win[
'view'][
'bgcolor'] = color.GetId()
249 color.Bind(csel.EVT_COLOURSELECT, self.
OnBgColor)
250 gridSizer.Add(item = color, pos = (0, 1))
252 boxSizer.Add(item = gridSizer, proportion = 1,
253 flag = wx.ALL | wx.EXPAND, border = 3)
254 pageSizer.Add(item = boxSizer, proportion = 0,
255 flag = wx.EXPAND | wx.LEFT | wx.RIGHT,
258 panel.SetSizer(pageSizer)
262 def _createDataPage(self):
263 """!Create data (surface, vector, volume) settings page"""
266 agwStyle = globalvar.FNPageDStyle)
268 self.
notebookData = FN.FlatNotebook(parent = self, id = wx.ID_ANY,
269 style = globalvar.FNPageDStyle)
273 text =
" %s " % _(
"Surface"))
278 text =
" %s " % _(
"Vector"))
283 text =
" %s " % _(
"Volume"))
288 def _createAppearancePage(self):
289 """!Create data (surface, vector, volume) settings page"""
292 agwStyle = globalvar.FNPageDStyle)
295 style = globalvar.FNPageDStyle)
299 text =
" %s " % _(
"Lighting"))
303 text =
" %s " % _(
"Fringe"))
308 def _createSurfacePage(self):
309 """!Create view settings page"""
310 panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
311 panel.SetupScrolling(scroll_x =
False)
312 self.
page[
'surface'] = {
'id' : 0,
313 'panel' : panel.GetId(),
314 'notebook' : self.notebookData.GetId() }
315 pageSizer = wx.BoxSizer(wx.VERTICAL)
317 self.
win[
'surface'] = {}
320 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
321 label =
" %s " % (_(
"Raster map")))
322 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
325 rmaps.GetChildren()[0].Bind(wx.EVT_TEXT, self.
OnSetRaster)
326 self.
win[
'surface'][
'map'] = rmaps.GetId()
327 desc = wx.StaticText(parent = panel, id = wx.ID_ANY)
328 self.
win[
'surface'][
'desc'] = desc.GetId()
329 boxSizer.Add(item = rmaps, proportion = 0,
332 boxSizer.Add(item = desc, proportion = 0,
335 pageSizer.Add(item = boxSizer, proportion = 0,
336 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
342 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
343 label =
" %s " % (_(
"Surface attributes")))
344 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
345 gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
348 self.
win[
'surface'][
'attr'] = {}
350 for code, attrb
in ((
'topo', _(
"Topography")),
351 (
'color', _(
"Color")),
353 (
'transp', _(
"Transparency")),
354 (
'shine', _(
"Shininess")),
355 (
'emit', _(
"Emission"))):
356 self.
win[
'surface'][code] = {}
357 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
358 label = attrb +
':'),
359 pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
360 use = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
361 choices = [_(
"map")])
363 if code
not in (
'topo',
'color',
'shine'):
364 use.Insert(item = _(
"unset"), pos = 0)
365 self.
win[
'surface'][code][
'required'] =
False
367 self.
win[
'surface'][code][
'required'] =
True
369 use.Append(item = _(
'constant'))
370 self.
win[
'surface'][code][
'use'] = use.GetId()
372 gridSizer.Add(item = use, flag = wx.ALIGN_CENTER_VERTICAL,
379 self.
win[
'surface'][code][
'map'] = map.GetId() - 1
384 gridSizer.Add(item = map, flag = wx.ALIGN_CENTER_VERTICAL,
388 value = csel.ColourSelect(panel, id = wx.ID_ANY,
390 size = globalvar.DIALOG_COLOR_SIZE)
395 value = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
398 value.SetRange(minVal = -1e9, maxVal = 1e9)
399 elif code
in (
'shine',
'transp',
'emit'):
400 value.SetRange(minVal = 0, maxVal = 255)
402 value.SetRange(minVal = 0, maxVal = 100)
406 self.
win[
'surface'][code][
'const'] = value.GetId()
408 gridSizer.Add(item = value, flag = wx.ALIGN_CENTER_VERTICAL,
411 self.
win[
'surface'][code][
'const'] =
None
418 boxSizer.Add(item = gridSizer, proportion = 1,
419 flag = wx.ALL | wx.EXPAND, border = 3)
420 pageSizer.Add(item = boxSizer, proportion = 0,
421 flag = wx.EXPAND | wx.ALL,
427 self.
win[
'surface'][
'draw'] = {}
428 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
429 label =
" %s " % (_(
"Draw")))
430 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
431 gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
432 gridSizer.AddGrowableCol(6)
435 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
437 pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
438 mode = wx.Choice (parent = panel, id = wx.ID_ANY, size = (-1, -1),
439 choices = [_(
"coarse"),
443 mode.SetName(
"selection")
445 self.
win[
'surface'][
'draw'][
'mode'] = mode.GetId()
446 gridSizer.Add(item = mode, flag = wx.ALIGN_CENTER_VERTICAL,
450 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
451 label = _(
"Shading:")),
452 pos = (0, 2), flag = wx.ALIGN_CENTER_VERTICAL)
453 shade = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
454 choices = [_(
"flat"),
456 shade.SetName(
"selection")
457 self.
win[
'surface'][
'draw'][
'shading'] = shade.GetId()
459 gridSizer.Add(item = shade, flag = wx.ALIGN_CENTER_VERTICAL,
463 all = wx.Button(panel, id = wx.ID_ANY, label = _(
"Set to all"))
464 all.SetToolTipString(_(
"Use draw settings for all loaded surfaces"))
466 gridSizer.Add(item = all, flag = wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
467 pos = (0, 4), span = (1,2), border = 3 )
470 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
471 label = _(
"Coarse:")),
472 pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
473 resSizer = wx.BoxSizer(wx.HORIZONTAL)
474 resSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
476 flag = wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
478 resC = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
482 resC.SetName(
"value")
485 self.
win[
'surface'][
'draw'][
'res-coarse'] = resC.GetId()
487 resSizer.Add(item = resC, flag = wx.ALL | wx.ALIGN_LEFT |
488 wx.ALIGN_CENTER_VERTICAL, border = 3)
489 gridSizer.Add(item = resSizer, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL)
492 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
494 pos = (1, 2), flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
495 style = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
496 choices = [_(
"wire"),
498 style.SetName(
"selection")
499 self.
win[
'surface'][
'draw'][
'style'] = style.GetId()
501 gridSizer.Add(item = style, flag = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
505 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
506 label = _(
"wire color")),
507 pos = (1, 4), flag = wx.ALIGN_CENTER_VERTICAL |
508 wx.ALIGN_RIGHT | wx.LEFT, border = 3)
509 color = csel.ColourSelect(panel, id = wx.ID_ANY,
510 size = globalvar.DIALOG_COLOR_SIZE)
511 color.SetColour((136,136,136))
512 color.SetName(
"colour")
514 self.
win[
'surface'][
'draw'][
'wire-color'] = color.GetId()
515 gridSizer.Add(item = color, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT,
519 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
521 pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL)
523 resSizer = wx.BoxSizer(wx.HORIZONTAL)
524 resSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
526 flag = wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
528 resF = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
532 resF.SetName(
"value")
534 self.
win[
'surface'][
'draw'][
'res-fine'] = resF.GetId()
536 resSizer.Add(item = resF, flag = wx.ALL | wx.ALIGN_LEFT |
537 wx.ALIGN_CENTER_VERTICAL, border = 3)
538 gridSizer.Add(item = resSizer, pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL)
540 boxSizer.Add(item = gridSizer, proportion = 1,
541 flag = wx.ALL | wx.EXPAND, border = 3)
542 pageSizer.Add(item = boxSizer, proportion = 0,
543 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
549 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
550 label =
" %s " % (_(
"Mask")))
551 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
552 gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
554 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
555 label = _(
"Mask zeros:")),
556 pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
558 elev = wx.CheckBox(parent = panel, id = wx.ID_ANY,
559 label = _(
"by elevation"))
561 gridSizer.Add(item = elev, pos = (0, 1))
563 color = wx.CheckBox(parent = panel, id = wx.ID_ANY,
564 label = _(
"by color"))
566 gridSizer.Add(item = color, pos = (0, 2))
568 boxSizer.Add(item = gridSizer, proportion = 1,
569 flag = wx.ALL | wx.EXPAND, border = 3)
570 pageSizer.Add(item = boxSizer, proportion = 0,
571 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
577 self.
win[
'surface'][
'position'] = {}
578 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
579 label =
" %s " % (_(
"Position")))
580 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
581 gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
585 range = (-10000, 10000),
588 axis = wx.Choice (parent = panel, id = wx.ID_ANY, size = (75, -1),
593 self.
win[
'surface'][
'position'][
'axis'] = axis.GetId()
597 pslide = self.FindWindowById(self.
win[
'surface'][
'position'][
'slider'])
598 pspin = self.FindWindowById(self.
win[
'surface'][
'position'][
'spin'])
600 gridSizer.Add(item = axis, flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
601 gridSizer.Add(item = pslide, flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 1))
602 gridSizer.Add(item = pspin, flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 2))
604 boxSizer.Add(item = gridSizer, proportion = 1,
605 flag = wx.ALL | wx.EXPAND, border = 3)
606 box.SetSizer(boxSizer)
609 pageSizer.Add(item = boxSizer, proportion = 0,
610 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
613 panel.SetSizer(pageSizer)
617 def _createVectorPage(self):
618 """!Create view settings page"""
619 panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
620 panel.SetupScrolling(scroll_x =
False)
621 self.
page[
'vector'] = {
'id' : 1,
622 'panel' : panel.GetId(),
623 'notebook' : self.notebookData.GetId() }
624 pageSizer = wx.BoxSizer(wx.VERTICAL)
626 self.
win[
'vector'] = {}
629 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
630 label =
" %s " % (_(
"Vector map")))
631 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
634 vmaps.GetChildren()[0].Bind(wx.EVT_TEXT, self.
OnSetVector)
635 self.
win[
'vector'][
'map'] = vmaps.GetId()
636 desc = wx.StaticText(parent = panel, id = wx.ID_ANY)
637 self.
win[
'vector'][
'desc'] = desc.GetId()
638 boxSizer.Add(item = vmaps, proportion = 0,
641 boxSizer.Add(item = desc, proportion = 0,
644 pageSizer.Add(item = boxSizer, proportion = 0,
645 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
651 self.
win[
'vector'][
'lines'] = {}
653 showLines = wx.CheckBox(parent = panel, id = wx.ID_ANY,
654 label = _(
"Show vector lines"))
655 showLines.SetValue(
True)
657 self.
win[
'vector'][
'lines'][
'show'] = showLines.GetId()
660 pageSizer.Add(item = showLines, proportion = 0,
661 flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 5)
663 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
664 label =
" %s " % (_(
"Vector lines")))
665 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
666 gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
669 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
671 pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
672 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
674 pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL |
677 width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
682 self.
win[
'vector'][
'lines'][
'width'] = width.GetId()
684 gridSizer.Add(item = width, pos = (0, 2),
685 flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
688 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
690 pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL |
693 color = csel.ColourSelect(panel, id = wx.ID_ANY,
695 size = globalvar.DIALOG_COLOR_SIZE)
696 self.
win[
'vector'][
'lines'][
'color'] = color.GetId()
699 gridSizer.Add(item = color, pos = (0, 4), flag = wx.ALIGN_CENTER_VERTICAL |
703 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
704 label = _(
"display")),
705 pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL |
708 display = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
709 choices = [_(
"on surface"),
711 self.
win[
'vector'][
'lines'][
'flat'] = display.GetId()
714 gridSizer.Add(item = display, flag = wx.ALIGN_CENTER_VERTICAL |
715 wx.ALIGN_LEFT, pos = (1, 2), span = (1,2))
718 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
719 label = _(
"Height above surface:")),
720 pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL,
723 surface = wx.ComboBox(parent = panel, id = wx.ID_ANY, size = (250, -1),
724 style = wx.CB_SIMPLE | wx.CB_READONLY,
727 self.
win[
'vector'][
'lines'][
'surface'] = surface.GetId()
728 gridSizer.Add(item = surface,
729 pos = (2, 3), span = (1, 6),
730 flag = wx.ALIGN_CENTER_VERTICAL)
732 self.
_createControl(panel, data = self.
win[
'vector'][
'lines'], name =
'height', size = 300,
735 self.FindWindowById(self.
win[
'vector'][
'lines'][
'height'][
'slider']).SetValue(0)
736 self.FindWindowById(self.
win[
'vector'][
'lines'][
'height'][
'spin']).SetValue(0)
737 gridSizer.Add(item = self.FindWindowById(self.
win[
'vector'][
'lines'][
'height'][
'slider']),
738 pos = (3, 0), span = (1, 7))
739 gridSizer.Add(item = self.FindWindowById(self.
win[
'vector'][
'lines'][
'height'][
'spin']),
741 flag = wx.ALIGN_CENTER)
743 boxSizer.Add(item = gridSizer, proportion = 1,
744 flag = wx.ALL | wx.EXPAND, border = 3)
745 pageSizer.Add(item = boxSizer, proportion = 0,
746 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
752 self.
win[
'vector'][
'points'] = {}
754 showPoints = wx.CheckBox(parent = panel, id = wx.ID_ANY,
755 label = _(
"Show vector points"))
756 showPoints.SetValue(
True)
757 self.
win[
'vector'][
'points'][
'show'] = showPoints.GetId()
760 pageSizer.Add(item = showPoints, proportion = 0,
761 flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 5)
763 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
764 label =
" %s " % (_(
"Vector points")))
765 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
766 gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
769 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
771 pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
772 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
774 pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL |
777 isize = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
781 isize.SetName(
'value')
783 self.
win[
'vector'][
'points'][
'size'] = isize.GetId()
786 gridSizer.Add(item = isize, pos = (0, 2),
787 flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
790 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
792 pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL |
794 icolor = csel.ColourSelect(panel, id = wx.ID_ANY,
795 size = globalvar.DIALOG_COLOR_SIZE)
796 icolor.SetName(
"color")
797 icolor.SetColour((0,0,255))
798 self.
win[
'vector'][
'points'][
'color'] = icolor.GetId()
800 gridSizer.Add(item = icolor, flag = wx.ALIGN_CENTER_VERTICAL |
805 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
807 pos = (0, 5), flag = wx.ALIGN_CENTER_VERTICAL |
810 iwidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
814 iwidth.SetName(
'value')
816 self.
win[
'vector'][
'points'][
'width'] = iwidth.GetId()
819 gridSizer.Add(item = iwidth, pos = (0, 6),
820 flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
823 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
824 label = _(
"symbol")),
825 pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL)
826 isym = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
827 choices = UserSettings.Get(group =
'nviz', key =
'vector',
828 subkey = [
'points',
'marker'], internal =
True))
829 isym.SetName(
"selection")
830 self.
win[
'vector'][
'points'][
'marker'] = isym.GetId()
832 gridSizer.Add(item = isym, flag = wx.ALIGN_CENTER_VERTICAL,
833 pos = (1, 2), span = (1,2))
836 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
837 label = _(
"Height above surface:")),
838 pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL,
841 surface = wx.ComboBox(parent = panel, id = wx.ID_ANY, size = (250, -1),
842 style = wx.CB_SIMPLE | wx.CB_READONLY,
845 self.
win[
'vector'][
'points'][
'surface'] = surface.GetId()
846 gridSizer.Add(item = surface,
847 pos = (2, 3), span = (1, 5),
848 flag = wx.ALIGN_CENTER_VERTICAL)
850 self.
_createControl(panel, data = self.
win[
'vector'][
'points'], name =
'height', size = 300,
854 self.FindWindowById(self.
win[
'vector'][
'points'][
'height'][
'slider']).SetValue(0)
855 self.FindWindowById(self.
win[
'vector'][
'points'][
'height'][
'spin']).SetValue(0)
857 gridSizer.Add(item = self.FindWindowById(self.
win[
'vector'][
'points'][
'height'][
'slider']),
858 pos = (3, 0), span = (1, 7))
859 gridSizer.Add(item = self.FindWindowById(self.
win[
'vector'][
'points'][
'height'][
'spin']),
861 flag = wx.ALIGN_CENTER)
863 boxSizer.Add(item = gridSizer, proportion = 1,
864 flag = wx.ALL | wx.EXPAND, border = 3)
865 pageSizer.Add(item = boxSizer, proportion = 0,
866 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
869 panel.SetSizer(pageSizer)
874 """Update gselect.Select() items"""
876 for layer
in self.mapWindow.Map.GetListOfLayers(l_type = ltype):
877 maps.append(layer.GetName())
880 def _createVolumePage(self):
881 """!Create view settings page"""
882 panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
883 panel.SetupScrolling(scroll_x =
False)
884 self.
page[
'volume'] = {
'id' : 2,
885 'panel' : panel.GetId(),
886 'notebook' : self.notebookData.GetId() }
887 pageSizer = wx.BoxSizer(wx.VERTICAL)
889 self.
win[
'volume'] = {}
892 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
893 label =
" %s " % (_(
"3D raster map")))
894 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
898 self.
win[
'volume'][
'map'] = rmaps.GetId()
899 desc = wx.StaticText(parent = panel, id = wx.ID_ANY)
900 self.
win[
'volume'][
'desc'] = desc.GetId()
901 boxSizer.Add(item = rmaps, proportion = 0,
904 boxSizer.Add(item = desc, proportion = 0,
907 pageSizer.Add(item = boxSizer, proportion = 0,
908 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
914 self.
win[
'volume'][
'draw'] = {}
915 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
916 label =
" %s " % (_(
"Draw")))
917 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
918 gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
919 gridSizer.AddGrowableCol(4)
922 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
924 pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
925 mode = wx.Choice (parent = panel, id = wx.ID_ANY, size = (150, -1),
926 choices = [_(
"isosurfaces"),
929 mode.SetName(
"selection")
931 self.
win[
'volume'][
'draw'][
'mode'] = mode.GetId()
932 gridSizer.Add(item = mode, flag = wx.ALIGN_CENTER_VERTICAL,
936 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
937 label = _(
"Shading:")),
938 pos = (0, 2), flag = wx.ALIGN_CENTER_VERTICAL)
939 shade = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
940 choices = [_(
"flat"),
942 shade.SetName(
"selection")
943 self.
win[
'volume'][
'draw'][
'shading'] = shade.GetId()
945 gridSizer.Add(item = shade, flag = wx.ALIGN_CENTER_VERTICAL,
949 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
950 label = _(
"Resolution:")),
951 pos = (0, 4), flag = wx.ALIGN_CENTER_VERTICAL)
952 resol = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
956 resol.SetName(
"value")
957 self.
win[
'volume'][
'draw'][
'resolution'] = resol.GetId()
960 gridSizer.Add(item = resol, pos = (0, 5))
962 boxSizer.Add(item = gridSizer, proportion = 1,
963 flag = wx.ALL | wx.EXPAND, border = 3)
964 pageSizer.Add(item = boxSizer, proportion = 0,
965 flag = wx.EXPAND | wx.ALL,
971 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
972 label =
" %s " % (_(
"List of isosurfaces")))
973 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
974 gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
977 isolevel = wx.CheckListBox(parent = panel, id = wx.ID_ANY,
982 self.
win[
'volume'][
'isosurfs'] = isolevel.GetId()
983 gridSizer.Add(item = isolevel, pos = (0, 0), span = (4, 1))
986 btnAdd = wx.Button(parent = panel, id = wx.ID_ADD)
987 self.
win[
'volume'][
'btnIsosurfAdd'] = btnAdd.GetId()
989 gridSizer.Add(item = btnAdd,
991 btnDelete = wx.Button(parent = panel, id = wx.ID_DELETE)
992 self.
win[
'volume'][
'btnIsosurfDelete'] = btnDelete.GetId()
994 btnDelete.Enable(
False)
995 gridSizer.Add(item = btnDelete,
997 btnMoveUp = wx.Button(parent = panel, id = wx.ID_UP)
998 self.
win[
'volume'][
'btnIsosurfMoveUp'] = btnMoveUp.GetId()
1000 btnMoveUp.Enable(
False)
1001 gridSizer.Add(item = btnMoveUp,
1003 btnMoveDown = wx.Button(parent = panel, id = wx.ID_DOWN)
1004 self.
win[
'volume'][
'btnIsosurfMoveDown'] = btnMoveDown.GetId()
1006 btnMoveDown.Enable(
False)
1007 gridSizer.Add(item = btnMoveDown,
1010 boxSizer.Add(item = gridSizer, proportion = 1,
1011 flag = wx.ALL | wx.EXPAND, border = 3)
1012 pageSizer.Add(item = boxSizer, proportion = 0,
1013 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
1019 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
1020 label =
" %s " % (_(
"Isosurface attributes")))
1021 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1022 gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
1024 self.
win[
'volume'][
'attr'] = {}
1026 for code, attrb
in ((
'topo', _(
"Topography level")),
1027 (
'color', _(
"Color")),
1028 (
'mask', _(
"Mask")),
1029 (
'transp', _(
"Transparency")),
1030 (
'shine', _(
"Shininess")),
1031 (
'emit', _(
"Emission"))):
1032 self.
win[
'volume'][code] = {}
1034 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1035 label = attrb +
':'),
1036 pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
1038 use = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
1039 choices = [_(
"map")])
1043 if code
not in (
'topo',
'color',
'shine'):
1044 use.Insert(item = _(
"unset"), pos = 0)
1045 self.
win[
'volume'][code][
'required'] =
False
1047 self.
win[
'volume'][code][
'required'] =
True
1048 if use
and code !=
'mask':
1049 use.Append(item = _(
'constant'))
1051 self.
win[
'volume'][code][
'use'] = use.GetId()
1053 gridSizer.Add(item = use, flag = wx.ALIGN_CENTER_VERTICAL,
1061 self.
win[
'volume'][code][
'map'] = map.GetId() - 1
1063 gridSizer.Add(item = map, flag = wx.ALIGN_CENTER_VERTICAL,
1069 value = csel.ColourSelect(panel, id = wx.ID_ANY,
1071 size = globalvar.DIALOG_COLOR_SIZE)
1073 elif code ==
'mask':
1080 value = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = size,
1083 value.SetRange(minVal = -1e9, maxVal = 1e9)
1084 elif code
in (
'shine',
'transp',
'emit'):
1085 value.SetRange(minVal = 0, maxVal = 255)
1087 value.SetRange(minVal = 0, maxVal = 100)
1092 self.
win[
'volume'][code][
'const'] = value.GetId()
1094 gridSizer.Add(item = value, flag = wx.ALIGN_CENTER_VERTICAL,
1098 gridSizer.Add(item = value, flag = wx.ALIGN_CENTER_VERTICAL,
1101 self.
win[
'volume'][code][
'const'] =
None
1109 boxSizer.Add(item = gridSizer, proportion = 1,
1110 flag = wx.ALL | wx.EXPAND, border = 3)
1111 pageSizer.Add(item = boxSizer, proportion = 0,
1112 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
1115 panel.SetSizer(pageSizer)
1119 def _createLightPage(self):
1120 """!Create light page"""
1121 panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
1122 panel.SetupScrolling(scroll_x =
False)
1124 self.
page[
'light'] = {
'id' : 0,
1125 'notebook' : self.notebookAppearance.GetId() }
1126 self.
win[
'light'] = {}
1128 pageSizer = wx.BoxSizer(wx.VERTICAL)
1130 show = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1131 label = _(
"Show light model"))
1133 pageSizer.Add(item = show, proportion = 0,
1134 flag = wx.ALL, border = 3)
1135 surface = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1136 label = _(
"Follow source viewpoint"))
1137 pageSizer.Add(item = surface, proportion = 0,
1138 flag = wx.ALL, border = 3)
1141 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
1142 label =
" %s " % (_(
"Light source position")))
1143 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1145 gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
1146 posSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
1147 posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"W")),
1148 pos = (1, 0), flag = wx.ALIGN_CENTER)
1149 posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"N")),
1150 pos = (0, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_BOTTOM)
1153 self.
win[
'light'][
'position'] = pos.GetId()
1154 posSizer.Add(item = pos,
1155 pos = (1, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)
1156 posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"S")),
1157 pos = (2, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_TOP)
1158 posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"E")),
1159 pos = (1, 2), flag = wx.ALIGN_CENTER)
1160 gridSizer.Add(item = posSizer, pos = (0, 0))
1163 self.
_createControl(panel, data = self.
win[
'light'], name =
'z', sliderHor =
False,
1167 heightSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
1168 heightSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Height:")),
1169 pos = (0, 0), flag = wx.ALIGN_LEFT, span = (1, 2))
1170 heightSizer.Add(item = self.FindWindowById(self.
win[
'light'][
'z'][
'slider']),
1171 flag = wx.ALIGN_RIGHT, pos = (1, 0))
1172 heightSizer.Add(item = self.FindWindowById(self.
win[
'light'][
'z'][
'spin']),
1173 flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.TOP |
1174 wx.BOTTOM | wx.RIGHT, pos = (1, 1))
1176 gridSizer.Add(item = heightSizer, pos = (0, 1), flag = wx.ALIGN_RIGHT)
1178 boxSizer.Add(item = gridSizer, proportion = 1,
1179 flag = wx.ALL | wx.EXPAND, border = 2)
1180 pageSizer.Add(item = boxSizer, proportion = 0,
1181 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
1185 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
1186 label =
" %s " % (_(
"Light color and intensity")))
1187 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1188 gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
1190 gridSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Color:")),
1191 pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
1192 color = csel.ColourSelect(panel, id = wx.ID_ANY,
1193 colour = UserSettings.Get(group =
'nviz', key =
'light',
1195 size = globalvar.DIALOG_COLOR_SIZE)
1196 self.
win[
'light'][
'color'] = color.GetId()
1198 gridSizer.Add(item = color, pos = (0, 2))
1200 gridSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Brightness:")),
1201 pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
1202 self.
_createControl(panel, data = self.
win[
'light'], name =
'bright', size = 300,
1205 gridSizer.Add(item = self.FindWindowById(self.
win[
'light'][
'bright'][
'slider']),
1206 pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL)
1207 gridSizer.Add(item = self.FindWindowById(self.
win[
'light'][
'bright'][
'spin']),
1209 flag = wx.ALIGN_CENTER)
1210 gridSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Ambient:")),
1211 pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL)
1212 self.
_createControl(panel, data = self.
win[
'light'], name =
'ambient', size = 300,
1215 gridSizer.Add(item = self.FindWindowById(self.
win[
'light'][
'ambient'][
'slider']),
1216 pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL)
1217 gridSizer.Add(item = self.FindWindowById(self.
win[
'light'][
'ambient'][
'spin']),
1219 flag = wx.ALIGN_CENTER)
1221 boxSizer.Add(item = gridSizer, proportion = 1,
1222 flag = wx.ALL | wx.EXPAND, border = 2)
1223 pageSizer.Add(item = boxSizer, proportion = 0,
1224 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
1240 panel.SetSizer(pageSizer)
1244 def _createFringePage(self):
1245 """!Create fringe page"""
1246 panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
1247 panel.SetupScrolling(scroll_x =
False)
1249 self.
page[
'fringe'] = {
'id' : 1,
1250 'notebook' : self.notebookAppearance.GetId() }
1251 self.
win[
'fringe'] = {}
1253 pageSizer = wx.BoxSizer(wx.VERTICAL)
1256 rbox = wx.StaticBox (parent = panel, id = wx.ID_ANY,
1257 label =
" %s " % (_(
"Surface")))
1258 rboxSizer = wx.StaticBoxSizer(rbox, wx.VERTICAL)
1261 rmaps.GetChildren()[0].Bind(wx.EVT_TEXT, self.
OnSetSurface)
1262 self.
win[
'fringe'][
'map'] = rmaps.GetId()
1263 rboxSizer.Add(item = rmaps, proportion = 0,
1266 pageSizer.Add(item = rboxSizer, proportion = 0,
1267 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
1270 ebox = wx.StaticBox (parent = panel, id = wx.ID_ANY,
1271 label =
" %s " % (_(
"Edges with fringe")))
1272 eboxSizer = wx.StaticBoxSizer(ebox, wx.HORIZONTAL)
1273 for edge
in [(_(
"N && W"),
"nw"),
1274 (_(
"N && E"),
"ne"),
1275 (_(
"S && W"),
"sw"),
1276 (_(
"S && E"),
"se")]:
1277 chkbox = wx.CheckBox(parent = panel,
1280 self.
win[
'fringe'][edge[1]] = chkbox.GetId()
1281 eboxSizer.Add(item = chkbox, proportion = 0,
1282 flag = wx.ADJUST_MINSIZE | wx.LEFT | wx.RIGHT, border = 5)
1283 chkbox.Bind(wx.EVT_CHECKBOX, self.
OnFringe)
1285 pageSizer.Add(item = eboxSizer, proportion = 0,
1286 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
1289 sbox = wx.StaticBox (parent = panel, id = wx.ID_ANY,
1290 label =
" %s " % (_(
"Settings")))
1291 sboxSizer = wx.StaticBoxSizer(sbox, wx.HORIZONTAL)
1292 gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
1295 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1296 label = _(
"Elevation of fringe from bottom:")),
1298 flag = wx.ALIGN_CENTER_VERTICAL)
1299 spin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
1300 size = (65, -1), min = -1e6, max = 1e6)
1301 spin.SetValue(UserSettings.Get(group =
'nviz', key =
'fringe', subkey =
'elev'))
1302 spin.Bind(wx.EVT_SPINCTRL, self.
OnFringe)
1303 self.
win[
'fringe'][
'elev'] = spin.GetId()
1304 gridSizer.Add(item = spin, pos = (0, 1))
1307 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1308 label = _(
"Color:")),
1310 flag = wx.ALIGN_CENTER_VERTICAL)
1311 color = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
1312 size = globalvar.DIALOG_COLOR_SIZE)
1313 color.SetColour(UserSettings.Get(group =
'nviz', key =
'fringe',
1315 color.Bind(csel.EVT_COLOURSELECT, self.
OnFringe)
1316 self.
win[
'fringe'][
'color'] = color.GetId()
1317 gridSizer.Add(item = color, pos = (1, 1))
1319 sboxSizer.Add(item = gridSizer, proportion = 1,
1320 flag = wx.ALL | wx.EXPAND, border = 3)
1321 pageSizer.Add(item = sboxSizer, proportion = 0,
1322 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
1325 panel.SetSizer(pageSizer)
1330 """!Get nviz data"""
1331 name = self.FindWindowById(self.
win[nvizType][
'map']).GetValue()
1333 if nvizType ==
'surface' or nvizType ==
'fringe':
1334 return self.mapWindow.GetLayerByName(name, mapType =
'raster', dataType =
'nviz')
1335 elif nvizType ==
'vector':
1336 return self.mapWindow.GetLayerByName(name, mapType =
'vector', dataType =
'nviz')
1337 elif nvizType ==
'volume':
1338 return self.mapWindow.GetLayerByName(name, mapType =
'3d-raster', dataType =
'nviz')
1343 """!Show/hide fringe"""
1344 enabled = event.IsChecked()
1345 win = self.FindWindowById(event.GetId())
1349 sid = data[
'object'][
'id']
1350 elev = self.FindWindowById(self.
win[
'fringe'][
'elev']).GetValue()
1351 color = self.FindWindowById(self.
win[
'fringe'][
'color']).GetValue()
1353 self._display.SetFringe(sid, color, elev,
1354 self.FindWindowById(self.
win[
'fringe'][
'nw']).IsChecked(),
1355 self.FindWindowById(self.
win[
'fringe'][
'ne']).IsChecked(),
1356 self.FindWindowById(self.
win[
'fringe'][
'sw']).IsChecked(),
1357 self.FindWindowById(self.
win[
'fringe'][
'se']).IsChecked())
1358 self.mapWindow.Refresh(
False)
1361 """!Generic scrolling handler"""
1365 data[winName] = event.GetInt()
1366 for w
in win[winName].itervalues():
1367 self.FindWindowById(w).SetValue(data[winName])
1371 def _createControl(self, parent, data, name, range, bind = (
None,
None,
None),
1372 sliderHor =
True, size = 200):
1373 """!Add control (Slider + SpinCtrl)"""
1376 style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | \
1380 style = wx.SL_VERTICAL | wx.SL_AUTOTICKS | \
1384 slider = wx.Slider(parent = parent, id = wx.ID_ANY,
1385 minValue = range[0],
1386 maxValue = range[1],
1389 slider.SetName(
'slider')
1391 slider.Bind(wx.EVT_SCROLL, bind[0])
1395 slider.Bind(wx.EVT_SCROLL_CHANGED, bind[1])
1396 data[name][
'slider'] = slider.GetId()
1398 spin = wx.SpinCtrl(parent = parent, id = wx.ID_ANY, size = (65, -1),
1403 spin.SetName(
'spin')
1405 spin.Bind(wx.EVT_SPINCTRL, bind[2])
1407 data[name][
'spin'] = spin.GetId()
1409 def __GetWindowName(self, data, id):
1410 for name
in data.iterkeys():
1412 for win
in data[name].itervalues():
1416 if data[name] == id:
1422 """!Update view from settings values
1423 stored in self.mapWindow.view dictionary"""
1424 for control
in (
'height',
1428 for win
in self.
win[
'view'][control].itervalues():
1429 if control ==
'height':
1430 value = UserSettings.Get(group =
'nviz', key =
'view',
1431 subkey = [
'height',
'value'], internal =
True)
1434 value = self.mapWindow.view[control][
'value']
1438 self.FindWindowById(win).SetValue(value)
1440 viewWin = self.FindWindowById(self.
win[
'view'][
'position'])
1441 x, y = viewWin.UpdatePos(self.mapWindow.view[
'position'][
'x'],
1442 self.mapWindow.view[
'position'][
'y'])
1443 viewWin.Draw(pos = (x, y), scale =
True)
1444 viewWin.Refresh(
False)
1450 self.mapWindow.Refresh(eraseBackground =
False)
1451 self.mapWindow.render[
'quick'] =
False
1452 self.mapWindow.Refresh(
False)
1455 """!Show light model"""
1456 self._display.showLight = event.IsChecked()
1457 self._display.DrawLightingModel()
1460 """!Position of the light changed"""
1465 val = event.GetInt()
1466 self.mapWindow.light[
'position'][
'z'] = val
1467 for win
in self.
win[
'light'][winName].itervalues():
1468 self.FindWindowById(win).SetValue(val)
1470 event = wxUpdateLight()
1476 """!Color of the light changed"""
1477 self.mapWindow.light[
'color'] = event.GetValue()
1479 event = wxUpdateLight()
1485 """!Light brightness changed"""
1486 data = self.mapWindow.light
1489 event = wxUpdateLight()
1495 """!Background color changed"""
1496 color = event.GetValue()
1497 self.mapWindow.view[
'background'][
'color'] = event.GetValue()
1498 color = str(color[0]) +
':' + str(color[1]) +
':' + str(color[2])
1500 self._display.SetBgColor(str(color))
1502 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
1503 self.mapWindow.Refresh(
False)
1506 """!Surface selected, currently used for fringes"""
1507 name = event.GetString()
1509 data = self.mapWindow.GetLayerByName(name, mapType =
'raster', dataType =
'nviz')[
'surface']
1514 layer = self.mapWindow.GetLayerByName(name, mapType =
'raster')
1518 """!Raster map selected, update surface page"""
1519 name = event.GetString()
1521 data = self.mapWindow.GetLayerByName(name, mapType =
'raster', dataType =
'nviz')[
'surface']
1526 layer = self.mapWindow.GetLayerByName(name, mapType =
'raster')
1531 """!Vector map selected, update properties page"""
1532 name = event.GetString()
1534 data = self.mapWindow.GetLayerByName(name, mapType =
'vector', dataType =
'nviz')[
'vector']
1539 layer = self.mapWindow.GetLayerByName(name, mapType =
'vector')
1544 """!3D Raster map selected, update surface page"""
1545 name = event.GetString()
1547 data = self.mapWindow.GetLayerByName(name, mapType =
'3d-raster', dataType =
'nviz')[
'volume']
1552 layer = self.mapWindow.GetLayerByName(name, mapType =
'3d-raster')
1557 """!Change view, render in quick mode"""
1563 if winName ==
'height':
1564 view = self.mapWindow.iview
1566 view = self.mapWindow.view
1568 if winName ==
'z-exag' and event.GetInt() >= 0:
1573 view[winName][
'value'] = event.GetInt()
1575 for win
in self.
win[
'view'][winName].itervalues():
1576 self.FindWindowById(win).SetValue(view[winName][
'value'])
1578 self.mapWindow.render[
'quick'] =
True
1579 self.mapWindow.Refresh(
False)
1584 """!View changed, render in full resolution"""
1585 self.mapWindow.render[
'quick'] =
False
1586 self.mapWindow.Refresh(
False)
1591 """!View changed, render in full resolution"""
1592 self.mapWindow.render[
'quick'] =
False
1600 """!Reset to default view (view page)"""
1601 self.mapWindow.ResetView()
1603 self.mapWindow.Refresh(
False)
1606 """!Look at (view page)"""
1607 sel = event.GetSelection()
1609 self.mapWindow.view[
'position'][
'x'] = 0.5
1610 self.mapWindow.view[
'position'][
'y'] = 0.5
1612 self.mapWindow.view[
'position'][
'x'] = 0.5
1613 self.mapWindow.view[
'position'][
'y'] = 0.0
1615 self.mapWindow.view[
'position'][
'x'] = 0.5
1616 self.mapWindow.view[
'position'][
'y'] = 1.0
1618 self.mapWindow.view[
'position'][
'x'] = 1.0
1619 self.mapWindow.view[
'position'][
'y'] = 0.5
1621 self.mapWindow.view[
'position'][
'x'] = 0.0
1622 self.mapWindow.view[
'position'][
'y'] = 0.5
1624 self.mapWindow.view[
'position'][
'x'] = 0.0
1625 self.mapWindow.view[
'position'][
'y'] = 0.0
1627 self.mapWindow.view[
'position'][
'x'] = 1.0
1628 self.mapWindow.view[
'position'][
'y'] = 0.0
1630 self.mapWindow.view[
'position'][
'x'] = 1.0
1631 self.mapWindow.view[
'position'][
'y'] = 1.0
1633 self.mapWindow.view[
'position'][
'x'] = 0.0
1634 self.mapWindow.view[
'position'][
'y'] = 1.0
1639 self.mapWindow.render[
'quick'] =
False
1640 self.mapWindow.Refresh(
False)
1643 """!Close button pressed
1650 """!Set surface attribute -- use -- map/constant"""
1651 if not self.mapWindow.init:
1662 nvizType =
'surface'
1664 selection = event.GetSelection()
1665 if self.
win[nvizType][attrb][
'required']:
1670 elif selection == 1:
1672 value = self.FindWindowById(self.
win[nvizType][attrb][
'map']).GetValue()
1673 elif selection == 2:
1675 if attrb ==
'color':
1676 value = self.FindWindowById(self.
win[nvizType][attrb][
'const']).GetColour()
1679 value = self.FindWindowById(self.
win[nvizType][attrb][
'const']).GetValue()
1682 attrb = attrb, map = useMap)
1684 name = self.FindWindowById(self.
win[nvizType][
'map']).GetValue()
1685 if nvizType ==
'surface':
1686 data = self.mapWindow.GetLayerByName(name, mapType =
'raster', dataType =
'nviz')
1687 data[nvizType][
'attribute'][attrb] = {
'map' : useMap,
1688 'value' : str(value),
1691 data = self.mapWindow.GetLayerByName(name, mapType =
'3d-raster', dataType =
'nviz')
1692 list = self.FindWindowById(self.
win[
'volume'][
'isosurfs'])
1693 id = list.GetSelection()
1694 data[nvizType][
'isosurface'][id][attrb] = {
'map' : useMap,
1695 'value' : str(value),
1699 event = wxUpdateProperties(data = data)
1702 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
1703 self.mapWindow.Refresh(
False)
1706 """!Enable/disable all widgets on page"""
1707 for key, item
in self.
win[name].iteritems():
1708 if key ==
'map' or key ==
'surface':
1710 if type(item) == types.DictType:
1711 for sitem
in self.
win[name][key].itervalues():
1712 if type(sitem) == types.IntType:
1713 self.FindWindowById(sitem).Enable(enabled)
1715 if type(item) == types.IntType:
1716 self.FindWindowById(item).Enable(enabled)
1719 """!Update dialog widgets when attribute type changed"""
1720 if attrb
in (
'topo',
'color',
'shine'):
1728 self.FindWindowById(self.
win[nvizType][attrb][
'map'] + 1).Enable(
True)
1729 if self.
win[nvizType][attrb][
'const']:
1730 self.FindWindowById(self.
win[nvizType][attrb][
'const']).Enable(
False)
1731 self.FindWindowById(self.
win[nvizType][attrb][
'use']).SetSelection(1 + incSel)
1733 self.FindWindowById(self.
win[nvizType][attrb][
'map'] + 1).Enable(
False)
1734 if self.
win[nvizType][attrb][
'const']:
1735 self.FindWindowById(self.
win[nvizType][attrb][
'const']).Enable(
True)
1736 self.FindWindowById(self.
win[nvizType][attrb][
'use']).SetSelection(2 + incSel)
1738 self.FindWindowById(self.
win[nvizType][attrb][
'map'] + 1).Enable(
False)
1739 if self.
win[nvizType][attrb][
'const']:
1740 self.FindWindowById(self.
win[nvizType][attrb][
'const']).Enable(
False)
1741 self.FindWindowById(self.
win[nvizType][attrb][
'use']).SetSelection(0)
1744 """!Set surface attribute"""
1748 """!Set map object (surface/isosurface) attribute (map/constant)"""
1749 if not self.mapWindow.init:
1756 if nvizType ==
'volume' and attrb ==
'topo':
1759 selection = self.FindWindowById(self.
win[nvizType][attrb][
'use']).GetSelection()
1760 if self.
win[nvizType][attrb][
'required']:
1766 elif selection == 1:
1767 value = self.FindWindowById(self.
win[nvizType][attrb][
'map']).GetValue()
1770 if attrb ==
'color':
1771 value = self.FindWindowById(self.
win[nvizType][attrb][
'const']).GetColour()
1775 value = self.FindWindowById(self.
win[nvizType][attrb][
'const']).GetValue()
1779 name = self.FindWindowById(self.
win[nvizType][
'map']).GetValue()
1780 if nvizType ==
'surface':
1781 data = self.mapWindow.GetLayerByName(name, mapType =
'raster', dataType =
'nviz')
1782 data[nvizType][
'attribute'][attrb] = {
'map' : useMap,
1783 'value' : str(value),
1786 data = self.mapWindow.GetLayerByName(name, mapType =
'3d-raster', dataType =
'nviz')
1787 list = self.FindWindowById(self.
win[
'volume'][
'isosurfs'])
1788 id = list.GetSelection()
1790 data[nvizType][
'isosurface'][id][attrb] = {
'map' : useMap,
1791 'value' : str(value),
1795 event = wxUpdateProperties(data = data)
1798 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
1799 self.mapWindow.Refresh(
False)
1802 """!Draw resolution changed"""
1805 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
1806 self.mapWindow.Refresh(
False)
1809 """!Set draw resolution"""
1810 coarse = self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-coarse']).GetValue()
1811 fine = self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-fine']).GetValue()
1814 data[
'surface'][
'draw'][
'resolution'] = {
'coarse' : coarse,
1819 event = wxUpdateProperties(data = data)
1823 """!Set draw mode"""
1824 mode = self.FindWindowById(self.
win[
'surface'][
'draw'][
'mode']).GetSelection()
1826 self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-coarse']).Enable(
True)
1827 self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-fine']).Enable(
False)
1829 self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-coarse']).Enable(
False)
1830 self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-fine']).Enable(
True)
1832 self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-coarse']).Enable(
True)
1833 self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-fine']).Enable(
True)
1835 style = self.FindWindowById(self.
win[
'surface'][
'draw'][
'style']).GetSelection()
1837 shade = self.FindWindowById(self.
win[
'surface'][
'draw'][
'shading']).GetSelection()
1839 value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1844 """!Set draw mode"""
1848 data[
'surface'][
'draw'][
'mode'] = {
'value' : value,
1853 event = wxUpdateProperties(data = data)
1856 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
1857 self.mapWindow.Refresh(
False)
1860 """!Set draw mode (including wire color) for all loaded surfaces"""
1862 coarse = self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-coarse']).GetValue()
1863 fine = self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-fine']).GetValue()
1864 color = self.FindWindowById(self.
win[
'surface'][
'draw'][
'wire-color']).GetColour()
1867 for name
in self.mapWindow.GetLayerNames(type =
'raster'):
1869 data = self.mapWindow.GetLayerByName(name, mapType =
'raster', dataType =
'nviz')
1873 data[
'surface'][
'draw'][
'all'] =
True
1874 data[
'surface'][
'draw'][
'mode'] = {
'value' : value,
1877 data[
'surface'][
'draw'][
'resolution'] = {
'coarse' : coarse,
1880 data[
'surface'][
'draw'][
'wire-color'] = {
'value' : cvalue,
1884 event = wxUpdateProperties(data = data)
1887 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
1888 self.mapWindow.Refresh(
False)
1890 def _getColorString(self, color):
1891 """!Set wire color"""
1892 return str(color[0]) +
':' + str(color[1]) +
':' + str(color[2])
1895 """!Set wire color"""
1898 data[
'surface'][
'draw'][
'wire-color'] = {
'value' : value,
1902 event = wxUpdateProperties(data = data)
1905 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
1906 self.mapWindow.Refresh(
False)
1909 """!Surface position, axis changed"""
1911 id = data[
'surface'][
'object'][
'id']
1913 axis = self.FindWindowById(self.
win[
'surface'][
'position'][
'axis']).GetSelection()
1914 slider = self.FindWindowById(self.
win[
'surface'][
'position'][
'slider'])
1915 spin = self.FindWindowById(self.
win[
'surface'][
'position'][
'spin'])
1917 x, y, z = self._display.GetSurfacePosition(id)
1930 """!Surface position"""
1934 axis = self.FindWindowById(self.
win[
'surface'][
'position'][
'axis']).GetSelection()
1935 value = event.GetInt()
1937 for win
in self.
win[
'surface'][
'position'].itervalues():
1938 if win == self.
win[
'surface'][
'position'][
'axis']:
1941 self.FindWindowById(win).SetValue(value)
1944 id = data[
'surface'][
'object'][
'id']
1945 x, y, z = self._display.GetSurfacePosition(id)
1955 data[
'surface'][
'position'][
'x'] = x
1956 data[
'surface'][
'position'][
'y'] = y
1957 data[
'surface'][
'position'][
'z'] = z
1958 data[
'surface'][
'position'][
'update'] =
None
1960 event = wxUpdateProperties(data = data)
1963 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
1964 self.mapWindow.Refresh(
False)
1968 """!Enable/disable lines/points widgets
1970 @param vecType vector type (lines, points)
1972 if vecType !=
'lines' and vecType !=
'points':
1975 for win
in self.
win[
'vector'][vecType].keys():
1978 if type(self.
win[
'vector'][vecType][win]) ==
type({}):
1979 for swin
in self.
win[
'vector'][vecType][win].keys():
1981 self.FindWindowById(self.
win[
'vector'][vecType][win][swin]).Enable(
True)
1983 self.FindWindowById(self.
win[
'vector'][vecType][win][swin]).Enable(
False)
1986 self.FindWindowById(self.
win[
'vector'][vecType][win]).Enable(
True)
1988 self.FindWindowById(self.
win[
'vector'][vecType][win]).Enable(
False)
1993 """!Show vector lines/points"""
1994 winId = event.GetId()
1995 if winId == self.
win[
'vector'][
'lines'][
'show']:
2002 checked = event.IsChecked()
2003 name = self.FindWindowById(self.
win[
'vector'][
'map']).GetValue()
2004 item = self.mapWindow.GetLayerByName(name, mapType =
'vector', dataType =
'item')
2008 self.mapWindow.LoadVector(item, points = points)
2010 self.mapWindow.UnloadVector(item, points = points)
2016 id = data[vecType][
'object'][
'id']
2021 self.mapWindow.SetMapObjProperties(item, id, vecType)
2024 event = wxUpdateProperties(data = data)
2027 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
2028 self.mapWindow.Refresh(
False)
2033 """!Display vector lines on surface/flat"""
2034 rasters = self.mapWindow.GetLayerNames(
'raster')
2035 if event.GetSelection() == 0:
2036 if len(rasters) < 1:
2037 self.FindWindowById(self.
win[
'vector'][
'lines'][
'surface']).Enable(
False)
2038 self.FindWindowById(self.
win[
'vector'][
'lines'][
'flat']).SetSelection(1)
2041 self.FindWindowById(self.
win[
'vector'][
'lines'][
'surface']).Enable(
True)
2044 data[
'vector'][
'lines'][
'mode'][
'surface'] = rasters[0]
2045 self.FindWindowById(self.
win[
'vector'][
'lines'][
'surface']).SetStringSelection( \
2048 self.FindWindowById(self.
win[
'vector'][
'lines'][
'surface']).Enable(
False)
2055 """!Set vector lines mode, apply changes if auto-rendering is enabled"""
2057 width = self.FindWindowById(self.
win[
'vector'][
'lines'][
'width']).GetValue()
2060 if self.FindWindowById(self.
win[
'vector'][
'lines'][
'flat']).GetSelection() == 0:
2061 mode[
'type'] =
'surface'
2062 mode[
'surface'] = self.FindWindowById(self.
win[
'vector'][
'lines'][
'surface']).GetValue()
2063 mode[
'update'] =
None
2065 mode[
'type'] =
'flat'
2067 for attrb
in (
'width',
'mode'):
2068 data[
'vector'][
'lines'][attrb][
'update'] =
None
2069 data[
'vector'][
'lines'][
'width'][
'value'] = width
2070 data[
'vector'][
'lines'][
'mode'][
'value'] = mode
2072 color = self.FindWindowById(self.
win[
'vector'][
'lines'][
'color']).GetColour()
2074 if isinstance(color, csel.ColourSelect):
2077 color = str(color[0]) +
':' + str(color[1]) +
':' + str(color[2])
2078 data[
'vector'][
'lines'][
'color'][
'update'] =
None
2079 data[
'vector'][
'lines'][
'color'][
'value'] = color
2082 event = wxUpdateProperties(data = data)
2085 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
2086 self.mapWindow.Refresh(
False)
2089 value = event.GetInt()
2091 if id == self.
win[
'vector'][
'lines'][
'height'][
'spin']
or \
2092 id == self.
win[
'vector'][
'lines'][
'height'][
'slider']:
2097 if type(event) ==
type(wx.ScrollEvent()):
2099 win = self.FindWindowById(self.
win[
'vector'][vtype][
'height'][
'spin'])
2102 win = self.FindWindowById(self.
win[
'vector'][vtype][
'height'][
'slider'])
2106 data[
'height'] = {
'value' : value,
2110 event = wxUpdateProperties(data = data)
2113 self.mapWindow.render[
'quick'] =
True
2114 self.mapWindow.render[
'v' + vtype] =
True
2115 self.mapWindow.Refresh(
False)
2120 """!Vector height changed, render in full resolution"""
2124 if id == self.
win[
'vector'][
'lines'][
'height'][
'spin']
or \
2125 id == self.
win[
'vector'][
'lines'][
'height'][
'slider']:
2130 self.mapWindow.render[
'quick'] =
False
2131 self.mapWindow.render[
'v' + vtype] =
False
2132 self.mapWindow.Refresh(
False)
2135 """!Vector height changed, render in full resolution"""
2142 """!Reference surface for vector map (lines/points)"""
2144 if id == self.
win[
'vector'][
'lines'][
'surface']:
2149 data[
'vector'][vtype][
'mode'][
'surface'] = {
'value' : event.GetString(),
2153 event = wxUpdateProperties(data = data)
2156 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
2157 self.mapWindow.Refresh(
False)
2160 """!Set vector points mode, apply changes if auto-rendering is enabled"""
2163 size = self.FindWindowById(self.
win[
'vector'][
'points'][
'size']).GetValue()
2164 marker = self.FindWindowById(self.
win[
'vector'][
'points'][
'marker']).GetSelection()
2167 for attrb
in (
'size',
'marker'):
2168 data[
'vector'][
'points'][attrb][
'update'] =
None
2169 data[
'vector'][
'points'][
'size'][
'value'] = size
2171 data[
'vector'][
'points'][
'marker'][
'value'] = marker
2173 color = self.FindWindowById(self.
win[
'vector'][
'points'][
'color']).GetColour()
2174 if isinstance(color, csel.ColourSelect):
2177 color = str(color[0]) +
':' + str(color[1]) +
':' + str(color[2])
2178 data[
'vector'][
'points'][
'color'][
'update'] =
None
2179 data[
'vector'][
'points'][
'color'][
'value'] = color
2182 event = wxUpdateProperties(data = data)
2185 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
2186 self.mapWindow.Refresh(
False)
2189 """!Enable/disable buttons 'add', 'delete',
2190 'move up', 'move down'"""
2191 nitems = list.GetCount()
2192 add = self.parent.FindWindowById(self.
win[
'volume'][
'btnIsosurfAdd'])
2193 delete = self.parent.FindWindowById(self.
win[
'volume'][
'btnIsosurfDelete'])
2194 moveDown = self.parent.FindWindowById(self.
win[
'volume'][
'btnIsosurfMoveDown'])
2195 moveUp = self.parent.FindWindowById(self.
win[
'volume'][
'btnIsosurfMoveUp'])
2196 if nitems >= wxnviz.MAX_ISOSURFS:
2204 delete.Enable(
False)
2208 if list.GetSelection() >= nitems - 1:
2210 moveDown.Enable(
False)
2212 moveDown.Enable(
True)
2214 if list.GetSelection() < 1:
2216 moveUp.Enable(
False)
2221 """!Set isosurface draw mode"""
2225 """!Set isosurface draw mode"""
2227 id = data[
'object'][
'id']
2231 mode |= wxnviz.DM_FLAT
2233 mode |= wxnviz.DM_GOURAUD
2235 self._display.SetIsosurfaceMode(id, mode)
2237 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
2238 self.mapWindow.Refresh(
False)
2241 """!Set isosurface draw resolution"""
2245 """!Set isosurface draw resolution"""
2248 id = data[
'object'][
'id']
2249 self._display.SetIsosurfaceRes(id, res)
2251 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
2252 self.mapWindow.Refresh(
False)
2255 """!Set surface attribute"""
2259 """!Isosurface checked (->load) or unchecked (->unload)"""
2260 index = event.GetSelection()
2261 list = self.FindWindowById(self.
win[
'volume'][
'isosurfs'])
2264 id = data[
'object'][
'id']
2266 isosurfId = event.GetSelection()
2268 if list.IsChecked(index):
2269 self._display.SetIsosurfaceTransp(id, isosurfId,
False,
"0")
2272 self._display.SetIsosurfaceTransp(id, isosurfId,
False,
"255")
2274 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
2275 self.mapWindow.Refresh(
False)
2278 """!Isosurface item selected"""
2279 winUp = self.FindWindowById(self.
win[
'volume'][
'btnIsosurfMoveUp'])
2280 winDown = self.FindWindowById(self.
win[
'volume'][
'btnIsosurfMoveDown'])
2281 selection = event.GetSelection()
2284 if not winDown.IsEnabled():
2286 elif selection == self.FindWindowById(event.GetId()).GetCount() - 1:
2287 winDown.Enable(
False)
2288 if not winUp.IsEnabled():
2291 if not winDown.IsEnabled():
2293 if not winUp.IsEnabled():
2297 name = self.FindWindowById(self.
win[
'volume'][
'map']).GetValue()
2298 layer = self.mapWindow.GetLayerByName(name, mapType =
'3d-raster')
2299 data = self.
GetLayerData(
'volume')[
'volume'][
'isosurface'][selection]
2304 """!Add new isosurface to the list"""
2305 list = self.FindWindowById(self.
win[
'volume'][
'isosurfs'])
2306 level = self.FindWindowById(self.
win[
'volume'][
'topo'][
'const']).GetValue()
2308 sel = list.GetSelection()
2309 if sel < 0
or sel >= list.GetCount() - 1:
2310 item = list.Append(item =
"%s %s" % (_(
"Level"), str(level)))
2312 list.Insert(item =
"%s %s" % (_(
"Level"), str(level)),
2317 list.SetSelection(item)
2319 name = self.FindWindowById(self.
win[
'volume'][
'map']).GetValue()
2320 layer = self.mapWindow.GetLayerByName(name, mapType =
'3d-raster')
2322 id = data[
'object'][
'id']
2326 for attrb
in (
'topo',
'color',
'mask',
2327 'transp',
'shine',
'emit'):
2329 isosurfData[attrb] = {}
2330 win = self.FindWindowById(self.
win[
'volume'][attrb][
'const'])
2331 isosurfData[attrb][
'value'] = win.GetValue()
2333 uwin = self.FindWindowById(self.
win[
'volume'][attrb][
'use'])
2334 sel = uwin.GetSelection()
2335 if self.
win[
'volume'][attrb][
'required']:
2340 isosurfData[attrb] = {}
2342 isosurfData[attrb][
'map'] =
True
2343 vwin = self.FindWindowById(self.
win[
'volume'][attrb][
'map'])
2344 value = vwin.GetValue()
2346 isosurfData[attrb][
'map'] =
False
2347 vwin = self.FindWindowById(self.
win[
'volume'][attrb][
'const'])
2348 if vwin.GetName() ==
"color":
2351 value = vwin.GetValue()
2352 isosurfData[attrb][
'value'] = value
2354 data[
'isosurface'].insert(item, isosurfData)
2357 self._display.AddIsosurface(id, level)
2359 self._display.SetIsosurfaceColor(id, item,
True, str(layer.name))
2364 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
2365 self.mapWindow.Refresh(
False)
2370 """!Remove isosurface from list"""
2371 list = self.FindWindowById(self.
win[
'volume'][
'isosurfs'])
2374 isosurfId = list.GetSelection()
2375 list.Delete(isosurfId)
2377 if list.GetCount() > 0:
2378 list.SetSelection(list.GetCount()-1)
2380 name = self.FindWindowById(self.
win[
'volume'][
'map']).GetValue()
2381 layer = self.mapWindow.GetLayerByName(name, mapType =
'3d-raster')
2384 id = data[
'object'][
'id']
2387 del data[
'isosurface'][isosurfId]
2389 self._display.DeleteIsosurface(id, isosurfId)
2394 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
2395 self.mapWindow.Refresh(
False)
2400 """!Move isosurface up in the list"""
2401 list = self.FindWindowById(self.
win[
'volume'][
'isosurfs'])
2402 sel = list.GetSelection()
2407 name = self.FindWindowById(self.
win[
'volume'][
'map']).GetValue()
2408 layer = self.mapWindow.GetLayerByName(name, mapType =
'3d-raster')
2411 id = data[
'object'][
'id']
2414 text = list.GetStringSelection()
2415 list.Insert(item = text, pos = sel-1)
2417 list.SetSelection(sel-1)
2419 data[
'isosurface'].insert(sel-1, data[
'isosurface'][sel])
2420 del data[
'isosurface'][sel+1]
2421 self._display.MoveIsosurface(id, sel,
True)
2426 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
2427 self.mapWindow.Refresh(
False)
2432 """!Move isosurface dowm in the list"""
2433 list = self.FindWindowById(self.
win[
'volume'][
'isosurfs'])
2434 sel = list.GetSelection()
2436 if sel >= list.GetCount() - 1:
2439 name = self.FindWindowById(self.
win[
'volume'][
'map']).GetValue()
2440 layer = self.mapWindow.GetLayerByName(name, mapType =
'3d-raster')
2443 id = data[
'object'][
'id']
2446 text = list.GetStringSelection()
2447 list.Insert(item = text, pos = sel+2)
2449 list.SetSelection(sel+2)
2451 data[
'isosurface'].insert(sel+2, data[
'isosurface'][sel])
2452 del data[
'isosurface'][sel]
2453 self._display.MoveIsosurface(id, sel,
False)
2458 if self.mapDisplay.statusbarWin[
'render'].IsChecked():
2459 self.mapWindow.Refresh(
False)
2464 """!Update dialog (selected page)"""
2466 Debug.msg(1,
"NvizToolWindow.UpdatePage(): %s", pageId)
2468 if pageId ==
'view':
2470 hmin = self.mapWindow.iview[
'height'][
'min']
2471 hmax = self.mapWindow.iview[
'height'][
'max']
2472 hval = self.mapWindow.iview[
'height'][
'value']
2473 zmin = self.mapWindow.view[
'z-exag'][
'min']
2474 zmax = self.mapWindow.view[
'z-exag'][
'max']
2475 zval = self.mapWindow.view[
'z-exag'][
'value']
2477 for control
in (
'spin',
'slider'):
2478 self.FindWindowById(self.
win[
'view'][
'height'][control]).SetRange(hmin,
2480 self.FindWindowById(self.
win[
'view'][
'height'][control]).SetValue(hval)
2481 self.FindWindowById(self.
win[
'view'][
'z-exag'][control]).SetRange(zmin,
2483 self.FindWindowById(self.
win[
'view'][
'z-exag'][control]).SetValue(zval)
2485 self.FindWindowById(self.
win[
'view'][
'bgcolor']).SetColour(\
2486 self.mapWindow.view[
'background'][
'color'])
2488 elif pageId
in (
'surface',
'vector',
'volume'):
2489 name = self.FindWindowById(self.
win[pageId][
'map']).GetValue()
2492 if pageId ==
'surface':
2493 layer = self.mapWindow.GetLayerByName(name, mapType =
'raster')
2495 elif pageId ==
'vector':
2496 layer = self.mapWindow.GetLayerByName(name, mapType =
'vector')
2498 elif pageId ==
'volume':
2499 layer = self.mapWindow.GetLayerByName(name, mapType =
'3d-raster')
2501 elif pageId ==
'light':
2502 zval = self.mapWindow.light[
'position'][
'z']
2503 bval = self.mapWindow.light[
'bright']
2504 aval = self.mapWindow.light[
'ambient']
2505 for control
in (
'spin',
'slider'):
2506 self.FindWindowById(self.
win[
'light'][
'z'][control]).SetValue(zval)
2507 self.FindWindowById(self.
win[
'light'][
'bright'][control]).SetValue(bval)
2508 self.FindWindowById(self.
win[
'light'][
'ambient'][control]).SetValue(aval)
2509 self.FindWindowById(self.
win[
'light'][
'color']).SetColour(self.mapWindow.light[
'color'])
2510 elif pageId ==
'fringe':
2511 win = self.FindWindowById(self.
win[
'fringe'][
'map'])
2512 win.SetValue(self.FindWindowById(self.
win[
'surface'][
'map']).GetValue())
2518 """!Update surface page"""
2519 ret = gcmd.RunCommand(
'r.info',
2524 desc = ret.split(
'=')[1].rstrip(
'\n')
2528 self.FindWindowById(self.
win[
'surface'][
'map']).SetValue(layer.name)
2529 self.FindWindowById(self.
win[
'surface'][
'desc']).SetLabel(desc)
2532 for attr
in (
'topo',
'color'):
2533 if layer
and layer.type ==
'raster':
2534 self.FindWindowById(self.
win[
'surface'][attr][
'map']).SetValue(layer.name)
2536 self.FindWindowById(self.
win[
'surface'][attr][
'map']).SetValue(
'')
2538 attrb = attr, map =
True)
2540 if 'color' in data[
'attribute']:
2541 value = data[
'attribute'][
'color'][
'value']
2542 if data[
'attribute'][
'color'][
'map']:
2543 self.FindWindowById(self.
win[
'surface'][
'color'][
'map']).SetValue(value)
2545 color =
map(int, value.split(
':'))
2546 self.FindWindowById(self.
win[
'surface'][
'color'][
'const']).SetColour(color)
2548 attrb = attr, map = data[
'attribute'][
'color'][
'map'])
2551 attrb =
'shine', map = data[
'attribute'][
'shine'][
'map'])
2552 value = data[
'attribute'][
'shine'][
'value']
2553 if data[
'attribute'][
'shine'][
'map']:
2554 self.FindWindowById(self.
win[
'surface'][
'shine'][
'map']).SetValue(value)
2556 self.FindWindowById(self.
win[
'surface'][
'shine'][
'const']).SetValue(value)
2561 for control, data
in data[
'draw'].iteritems():
2562 if control ==
'all':
2564 if control ==
'resolution':
2565 self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-coarse']).SetValue(data[
'coarse'])
2566 self.FindWindowById(self.
win[
'surface'][
'draw'][
'res-fine']).SetValue(data[
'fine'])
2569 if control ==
'mode':
2570 if data[
'desc'][
'mode'] ==
'coarse':
2571 self.FindWindowById(self.
win[
'surface'][
'draw'][
'mode']).SetSelection(0)
2572 elif data[
'desc'][
'mode'] ==
'fine':
2573 self.FindWindowById(self.
win[
'surface'][
'draw'][
'mode']).SetSelection(1)
2575 self.FindWindowById(self.
win[
'surface'][
'draw'][
'mode']).SetSelection(2)
2577 if data[
'desc'][
'style'] ==
'wire':
2578 self.FindWindowById(self.
win[
'surface'][
'draw'][
'style']).SetSelection(0)
2580 self.FindWindowById(self.
win[
'surface'][
'draw'][
'style']).SetSelection(1)
2582 if data[
'desc'][
'shading'] ==
'flat':
2583 self.FindWindowById(self.
win[
'surface'][
'draw'][
'shading']).SetSelection(0)
2585 self.FindWindowById(self.
win[
'surface'][
'draw'][
'shading']).SetSelection(1)
2589 value = data[
'value']
2590 win = self.FindWindowById(self.
win[
'surface'][
'draw'][control])
2592 name = win.GetName()
2594 if name ==
"selection":
2595 win.SetSelection(value)
2596 elif name ==
"colour":
2597 color =
map(int, value.split(
':'))
2598 win.SetColour(color)
2605 """!Get number of points/lines
2607 @param layer MapLayer instance
2609 @return num of points/features (expect of points)
2612 vInfo = grass.vector_info_topo(layer.GetName())
2618 for key, value
in vInfo.iteritems():
2619 if key
in (
'points',
2625 nprimitives += value
2627 return (vInfo[
'points'], vInfo[
'lines'], nprimitives, vInfo[
'map3d'])
2630 """!Update vector page"""
2631 npoints, nlines, nfeatures, mapIs3D = self.
VectorInfo(layer)
2633 desc = _(
"Vector map is 3D")
2636 desc = _(
"Vector map is 2D")
2638 desc +=
" - " + _(
"%(features)d features (%(points)d points)") % \
2639 {
'features' : nfeatures,
'points' : npoints }
2642 self.FindWindowById(self.
win[
'vector'][
'map']).SetValue(layer.name)
2643 self.FindWindowById(self.
win[
'vector'][
'desc']).SetLabel(desc)
2645 self.FindWindowById(self.
win[
'vector'][
'lines'][
'flat']).Enable(enable)
2646 for v
in (
'lines',
'points'):
2647 self.FindWindowById(self.
win[
'vector'][v][
'surface']).Enable(enable)
2648 self.FindWindowById(self.
win[
'vector'][v][
'height'][
'slider']).Enable(enable)
2649 self.FindWindowById(self.
win[
'vector'][v][
'height'][
'spin']).Enable(enable)
2654 showLines = self.FindWindowById(self.
win[
'vector'][
'lines'][
'show'])
2655 if 'object' in data[
'lines']:
2656 showLines.SetValue(
True)
2658 showLines.SetValue(
False)
2660 showLines.Enable(
True)
2662 showLines.Enable(
False)
2665 showLines.IsChecked())
2667 width = self.FindWindowById(self.
win[
'vector'][
'lines'][
'width'])
2668 width.SetValue(data[
'lines'][
'width'][
'value'])
2670 color = self.FindWindowById(self.
win[
'vector'][
'lines'][
'color'])
2671 color.SetValue(
map(int, data[
'lines'][
'color'][
'value'].
split(
':')))
2673 for vtype
in (
'lines',
'points'):
2674 if vtype ==
'lines':
2675 display = self.FindWindowById(self.
win[
'vector'][
'lines'][
'flat'])
2676 if data[vtype][
'mode'][
'type'] ==
'flat':
2677 display.SetSelection(1)
2679 display.SetSelection(0)
2681 if data[vtype][
'mode'][
'type'] ==
'surface':
2682 rasters = self.mapWindow.GetLayerNames(
'raster')
2683 surface = self.FindWindowById(self.
win[
'vector'][vtype][
'surface'])
2684 surface.SetItems(rasters)
2685 if len(rasters) > 0:
2687 surface.SetStringSelection(data[vtype][
'mode'][
'surface'])
2691 for type
in (
'slider',
'spin'):
2692 win = self.FindWindowById(self.
win[
'vector'][
'lines'][
'height'][type])
2693 win.SetValue(data[
'lines'][
'height'][
'value'])
2698 showPoints = self.FindWindowById(self.
win[
'vector'][
'points'][
'show'])
2700 if 'object' in data[
'points']:
2701 showPoints.SetValue(
True)
2703 showPoints.SetValue(
False)
2705 showPoints.Enable(
True)
2707 showPoints.Enable(
False)
2710 showPoints.IsChecked())
2712 for prop
in (
'size',
'marker',
'color'):
2713 win = self.FindWindowById(self.
win[
'vector'][
'points'][prop])
2714 name = win.GetName()
2715 if name ==
'selection':
2716 win.SetSelection(data[
'points'][prop][
'value'])
2717 elif name ==
'color':
2718 color =
map(int, data[
'points'][prop][
'value'].
split(
':'))
2721 win.SetValue(data[
'points'][prop][
'value'])
2723 for type
in (
'slider',
'spin'):
2724 win = self.FindWindowById(self.
win[
'vector'][
'points'][
'height'][type])
2725 win.SetValue(data[
'points'][
'height'][
'value'])
2728 """!Update volume page"""
2730 self.FindWindowById(self.
win[
'volume'][
'map']).SetValue(layer.name)
2731 list = self.FindWindowById(self.
win[
'volume'][
'isosurfs'])
2734 for control, idata
in data[
'draw'].iteritems():
2735 if control ==
'all':
2738 win = self.FindWindowById(self.
win[
'volume'][
'draw'][control])
2740 if control ==
'shading':
2741 if data[
'draw'][
'shading'][
'desc'] ==
'flat':
2746 value = idata[
'value']
2748 if win.GetName() ==
"selection":
2749 win.SetSelection(value)
2759 """!Update dialog -- isosurface attributes"""
2763 for attrb
in (
'topo',
'color',
'mask',
2764 'transp',
'shine',
'emit'):
2767 self.FindWindowById(self.
win[
'volume'][attrb][
'const']).SetValue(0)
2769 if attrb ==
'color':
2770 if layer
and layer.type ==
'3d-raster':
2771 self.FindWindowById(self.
win[
'volume'][attrb][
'map']).SetValue(layer.name)
2773 self.FindWindowById(self.
win[
'volume'][attrb][
'map']).SetValue(
'')
2775 attrb = attrb, map =
True)
2779 if attrb
not in data:
2782 value = data[attrb][
'value']
2783 if attrb ==
'color':
2784 if data[attrb][
'map']:
2785 self.FindWindowById(self.
win[
'volume'][attrb][
'map']).SetValue(value)
2787 color =
map(int, value.split(
':'))
2788 self.FindWindowById(self.
win[
'volume'][attrb][
'const']).SetColour(color)
2790 if data[attrb][
'map']:
2791 win = self.FindWindowById(self.
win[
'volume'][attrb][
'map'])
2793 win = self.FindWindowById(self.
win[
'volume'][attrb][
'const'])
2797 attrb = attrb, map = data[attrb][
'map'])
2800 """!Get named page"""
2802 self.SetSelection(0)
2803 elif name
in (
'surface',
'vector',
'volume'):
2804 self.SetSelection(1)
2806 self.SetSelection(2)
2807 win = self.FindWindowById(self.
page[name][
'notebook'])
2809 win.SetSelection(self.
page[name][
'id'])
2812 """!Abstract position control window, see subclasses
2813 ViewPostionWindow and LightPositionWindow"""
2814 def __init__(self, parent, mapwindow, id = wx.ID_ANY,
2819 wx.Window.__init__(self, parent, id, **kwargs)
2821 self.SetBackgroundColour(
"WHITE")
2825 self.pdc.SetBrush(wx.Brush(colour =
'dark green', style = wx.SOLID))
2826 self.pdc.SetPen(wx.Pen(colour =
'dark green', width = 2, style = wx.SOLID))
2828 self.Bind(wx.EVT_ERASE_BACKGROUND,
lambda x:
None)
2829 self.Bind(wx.EVT_PAINT, self.
OnPaint)
2831 self.Bind(wx.EVT_MOUSE_EVENTS, self.
OnMouse)
2833 def Draw(self, pos, scale = False):
2834 w, h = self.GetClientSize()
2840 self.pdc.BeginDrawing()
2841 self.pdc.DrawLine(w / 2, h / 2, x, y)
2842 self.pdc.DrawCircle(x, y, 5)
2843 self.pdc.EndDrawing()
2846 dc = wx.BufferedPaintDC(self)
2847 dc.SetBackground(wx.Brush(
"White"))
2851 self.pdc.DrawToDC(dc)
2854 """!Update position coordinates (origin: UL)"""
2864 self.data[
'position'][
'x'] = xcoord
2865 self.data[
'position'][
'y'] = ycoord
2867 return xcoord, ycoord
2870 if event.LeftIsDown():
2871 x, y = event.GetPosition()
2872 self.
Draw(pos = (x, y))
2873 w, h = self.GetClientSize()
2882 x, y = self.
UpdatePos(self.data[
'position'][
'x'],
2883 self.data[
'position'][
'y'])
2884 self.
Draw(pos = (x, y), scale =
True)
2887 """!View position control widget"""
2888 def __init__(self, parent, mapwindow, id = wx.ID_ANY,
2890 PositionWindow.__init__(self, parent, mapwindow, id, **kwargs)
2896 x, y = PositionWindow.UpdatePos(self, xcoord, ycoord)
2898 event = wxUpdateView(zExag =
True)
2904 PositionWindow.OnMouse(self, event)
2905 if event.LeftIsDown():
2906 self.mapWindow.render[
'quick'] = self.
quick
2907 self.mapWindow.Refresh(eraseBackground =
False)
2908 elif event.LeftUp():
2909 self.mapWindow.render[
'quick'] =
False
2910 self.mapWindow.Refresh(eraseBackground =
False)
2915 """!Light position control widget"""
2916 def __init__(self, parent, mapwindow, id = wx.ID_ANY,
2918 PositionWindow.__init__(self, parent, mapwindow, id, **kwargs)
2925 x, y = PositionWindow.UpdatePos(self, xcoord, ycoord)
2927 event = wxUpdateLight()
2933 PositionWindow.OnMouse(self, event)
2935 self.mapWindow.render[
'quick'] =
False
2936 self.mapWindow.Refresh(eraseBackground =
False)
2939 """!Nviz preferences dialog"""
2940 def __init__(self, parent, title = _(
"3D view settings"),
2941 settings = UserSettings):
2942 PreferencesBaseDialog.__init__(self, parent = parent, title = title,
2943 settings = settings)
2951 self.SetMinSize(self.GetBestSize())
2952 self.SetSize(self.size)
2954 def _createViewPage(self, notebook):
2955 """!Create notebook page for general settings"""
2956 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
2958 notebook.AddPage(page = panel,
2959 text =
" %s " % _(
"View"))
2961 pageSizer = wx.BoxSizer(wx.VERTICAL)
2963 self.
win[
'general'] = {}
2964 self.
win[
'view'] = {}
2965 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
2966 label =
" %s " % (_(
"View")))
2967 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
2968 gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
2971 self.
win[
'view'][
'persp'] = {}
2972 pvals = UserSettings.Get(group =
'nviz', key =
'view', subkey =
'persp')
2973 ipvals = UserSettings.Get(group =
'nviz', key =
'view', subkey =
'persp', internal =
True)
2974 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
2975 label = _(
"Perspective:")),
2976 pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
2977 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
2978 label = _(
"(value)")),
2979 pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
2981 pval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
2982 initial = pvals[
'value'],
2983 min = ipvals[
'min'],
2984 max = ipvals[
'max'])
2985 self.
win[
'view'][
'persp'][
'value'] = pval.GetId()
2986 gridSizer.Add(item = pval, pos = (0, 2),
2987 flag = wx.ALIGN_CENTER_VERTICAL)
2989 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
2990 label = _(
"(step)")),
2991 pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
2993 pstep = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
2994 initial = pvals[
'step'],
2995 min = ipvals[
'min'],
2996 max = ipvals[
'max']-1)
2997 self.
win[
'view'][
'persp'][
'step'] = pstep.GetId()
2998 gridSizer.Add(item = pstep, pos = (0, 4),
2999 flag = wx.ALIGN_CENTER_VERTICAL)
3002 self.
win[
'view'][
'position'] = {}
3003 posvals = UserSettings.Get(group =
'nviz', key =
'view', subkey =
'position')
3004 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3005 label = _(
"Position:")),
3006 pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
3007 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3009 pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
3011 px = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
3012 initial = posvals[
'x'] * 100,
3015 self.
win[
'view'][
'position'][
'x'] = px.GetId()
3016 gridSizer.Add(item = px, pos = (1, 2),
3017 flag = wx.ALIGN_CENTER_VERTICAL)
3019 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3021 pos = (1, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
3023 py = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
3024 initial = posvals[
'y'] * 100,
3027 self.
win[
'view'][
'position'][
'y'] = py.GetId()
3028 gridSizer.Add(item = py, pos = (1, 4),
3029 flag = wx.ALIGN_CENTER_VERTICAL)
3032 self.
win[
'view'][
'height'] = {}
3033 hvals = UserSettings.Get(group =
'nviz', key =
'view', subkey =
'height')
3034 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3035 label = _(
"Height:")),
3036 pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL)
3037 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3038 label = _(
"(step)")),
3039 pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
3041 hstep = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
3042 initial = hvals[
'step'],
3045 self.
win[
'view'][
'height'][
'step'] = hstep.GetId()
3046 gridSizer.Add(item = hstep, pos = (2, 2),
3047 flag = wx.ALIGN_CENTER_VERTICAL)
3050 self.
win[
'view'][
'twist'] = {}
3051 tvals = UserSettings.Get(group =
'nviz', key =
'view', subkey =
'twist')
3052 itvals = UserSettings.Get(group =
'nviz', key =
'view', subkey =
'twist', internal =
True)
3053 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3054 label = _(
"Twist:")),
3055 pos = (3, 0), flag = wx.ALIGN_CENTER_VERTICAL)
3056 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3057 label = _(
"(value)")),
3058 pos = (3, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
3060 tval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
3061 initial = tvals[
'value'],
3062 min = itvals[
'min'],
3063 max = itvals[
'max'])
3064 self.
win[
'view'][
'twist'][
'value'] = tval.GetId()
3065 gridSizer.Add(item = tval, pos = (3, 2),
3066 flag = wx.ALIGN_CENTER_VERTICAL)
3068 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3069 label = _(
"(step)")),
3070 pos = (3, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
3072 tstep = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
3073 initial = tvals[
'step'],
3074 min = itvals[
'min'],
3075 max = itvals[
'max']-1)
3076 self.
win[
'view'][
'twist'][
'step'] = tstep.GetId()
3077 gridSizer.Add(item = tstep, pos = (3, 4),
3078 flag = wx.ALIGN_CENTER_VERTICAL)
3081 self.
win[
'view'][
'z-exag'] = {}
3082 zvals = UserSettings.Get(group =
'nviz', key =
'view', subkey =
'z-exag')
3083 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3084 label = _(
"Z-exag:")),
3085 pos = (4, 0), flag = wx.ALIGN_CENTER_VERTICAL)
3086 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3087 label = _(
"(value)")),
3088 pos = (4, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
3090 zval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
3091 initial = zvals[
'value'],
3094 self.
win[
'view'][
'z-exag'][
'value'] = zval.GetId()
3095 gridSizer.Add(item = zval, pos = (4, 2),
3096 flag = wx.ALIGN_CENTER_VERTICAL)
3098 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3099 label = _(
"(step)")),
3100 pos = (4, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
3102 zstep = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
3103 initial = zvals[
'step'],
3106 self.
win[
'view'][
'z-exag'][
'step'] = zstep.GetId()
3107 gridSizer.Add(item = zstep, pos = (4, 4),
3108 flag = wx.ALIGN_CENTER_VERTICAL)
3110 boxSizer.Add(item = gridSizer, proportion = 1,
3111 flag = wx.ALL | wx.EXPAND, border = 3)
3112 pageSizer.Add(item = boxSizer, proportion = 0,
3113 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
3116 box = wx.StaticBox(parent = panel, id = wx.ID_ANY,
3117 label =
" %s " % (_(
"Image Appearance")))
3118 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
3119 gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
3120 gridSizer.AddGrowableCol(0)
3123 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3124 label = _(
"Background color:")),
3125 pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
3127 color = csel.ColourSelect(panel, id = wx.ID_ANY,
3128 colour = UserSettings.Get(group =
'nviz', key =
'settings',
3129 subkey = [
'general',
'bgcolor']),
3130 size = globalvar.DIALOG_COLOR_SIZE)
3131 self.
win[
'general'][
'bgcolor'] = color.GetId()
3132 gridSizer.Add(item = color, pos = (0, 1))
3134 boxSizer.Add(item = gridSizer, proportion = 1,
3135 flag = wx.ALL | wx.EXPAND, border = 3)
3136 pageSizer.Add(item = boxSizer, proportion = 0,
3137 flag = wx.EXPAND | wx.ALL,
3140 panel.SetSizer(pageSizer)
3144 def _createVectorPage(self, notebook):
3145 """!Create notebook page for general settings"""
3146 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
3148 notebook.AddPage(page = panel,
3149 text =
" %s " % _(
"Vector"))
3151 pageSizer = wx.BoxSizer(wx.VERTICAL)
3154 self.
win[
'vector'] = {}
3155 self.
win[
'vector'][
'lines'] = {}
3156 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
3157 label =
" %s " % (_(
"Vector lines")))
3158 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
3159 gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
3163 showLines = wx.CheckBox(parent = panel, id = wx.ID_ANY,
3164 label = _(
"Show lines"))
3165 self.
win[
'vector'][
'lines'][
'show'] = showLines.GetId()
3166 showLines.SetValue(UserSettings.Get(group =
'nviz', key =
'vector',
3167 subkey = [
'lines',
'show']))
3168 gridSizer.Add(item = showLines, pos = (row, 0))
3170 boxSizer.Add(item = gridSizer, proportion = 1,
3171 flag = wx.ALL | wx.EXPAND, border = 3)
3172 pageSizer.Add(item = boxSizer, proportion = 0,
3173 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
3177 self.
win[
'vector'][
'points'] = {}
3178 box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
3179 label =
" %s " % (_(
"Vector points")))
3180 boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
3181 gridSizer = wx.GridBagSizer(vgap = 3, hgap = 5)
3185 showPoints = wx.CheckBox(parent = panel, id = wx.ID_ANY,
3186 label = _(
"Show points"))
3187 showPoints.SetValue(UserSettings.Get(group =
'nviz', key =
'vector',
3188 subkey = [
'points',
'show']))
3189 self.
win[
'vector'][
'points'][
'show'] = showPoints.GetId()
3190 gridSizer.Add(item = showPoints, pos = (row, 0), span = (1, 8))
3194 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3195 label = _(
"Size:")),
3196 pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
3198 isize = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
3202 self.
win[
'vector'][
'points'][
'size'] = isize.GetId()
3203 isize.SetValue(UserSettings.Get(group =
'nviz', key =
'vector',
3204 subkey = [
'points',
'size']))
3205 gridSizer.Add(item = isize, pos = (row, 1),
3206 flag = wx.ALIGN_CENTER_VERTICAL)
3209 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3210 label = _(
"Width:")),
3211 pos = (row, 2), flag = wx.ALIGN_CENTER_VERTICAL)
3213 iwidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
3217 self.
win[
'vector'][
'points'][
'width'] = isize.GetId()
3218 iwidth.SetValue(UserSettings.Get(group =
'nviz', key =
'vector',
3219 subkey = [
'points',
'width']))
3220 gridSizer.Add(item = iwidth, pos = (row, 3),
3221 flag = wx.ALIGN_CENTER_VERTICAL)
3224 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3225 label = _(
"Marker:")),
3226 pos = (row, 4), flag = wx.ALIGN_CENTER_VERTICAL)
3227 isym = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
3228 choices = UserSettings.Get(group =
'nviz', key =
'vector',
3229 subkey = [
'points',
'marker'], internal =
True))
3230 isym.SetName(
"selection")
3231 self.
win[
'vector'][
'points'][
'marker'] = isym.GetId()
3232 isym.SetSelection(UserSettings.Get(group =
'nviz', key =
'vector',
3233 subkey = [
'points',
'marker']))
3234 gridSizer.Add(item = isym, flag = wx.ALIGN_CENTER_VERTICAL,
3238 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
3239 label = _(
"Color:")),
3240 pos = (row, 6), flag = wx.ALIGN_CENTER_VERTICAL)
3241 icolor = csel.ColourSelect(panel, id = wx.ID_ANY)
3242 icolor.SetName(
"color")
3243 self.
win[
'vector'][
'points'][
'color'] = icolor.GetId()
3244 icolor.SetColour(UserSettings.Get(group =
'nviz', key =
'vector',
3245 subkey = [
'points',
'color']))
3246 gridSizer.Add(item = icolor, flag = wx.ALIGN_CENTER_VERTICAL,
3249 boxSizer.Add(item = gridSizer, proportion = 1,
3250 flag = wx.ALL | wx.EXPAND, border = 3)
3251 pageSizer.Add(item = boxSizer, proportion = 0,
3252 flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
3255 panel.SetSizer(pageSizer)
3260 """Restore default settings"""
3261 settings = copy.deepcopy(UserSettings.GetDefaultSettings()[
'nviz'])
3262 UserSettings.Set(group =
'nviz',
3265 for subgroup, key
in settings.iteritems():
3266 if subgroup !=
'view':
3268 for subkey, value
in key.iteritems():
3269 for subvalue
in value.keys():
3270 win = self.FindWindowById(self.
win[subgroup][subkey][subvalue])
3271 val = settings[subgroup][subkey][subvalue]
3272 if subkey ==
'position':
3273 val = int(val * 100)
3280 """Apply Nviz settings for current session"""
3281 settings = UserSettings.Get(group =
'nviz')
3282 for subgroup, key
in settings.iteritems():
3283 for subkey, value
in key.iteritems():
3284 for subvalue
in value.keys():
3286 win = self.FindWindowById(self.
win[subgroup][subkey][subvalue])
3291 if win.GetName() ==
"selection":
3292 value = win.GetSelection()
3293 elif win.GetName() ==
"color":
3294 value = tuple(win.GetColour())
3296 value = win.GetValue()
3297 if subkey ==
'position':
3298 value = float(value) / 100
3300 settings[subgroup][subkey][subvalue] = value
3303 """!Apply changes, update map and save settings of selected
3309 if self.GetSelection() == self.page[
'id']:
3311 UserSettings.ReadSettingsFile(settings = fileSettings)
3312 fileSettings[
'nviz'] = UserSettings.Get(group =
'nviz')
3313 file = UserSettings.SaveToFile(fileSettings)
3314 self.parent.goutput.WriteLog(_(
'Nviz settings saved to file <%s>.') % file)
3317 """!Apply button pressed"""
3324 """!Load saved Nviz settings and apply to current session"""
3325 UserSettings.ReadSettingsFile()
3326 settings = copy.deepcopy(UserSettings.Get(group =
'nviz'))
3328 for subgroup, key
in settings.iteritems():
3329 for subkey, value
in key.iteritems():
3330 for subvalue
in value.keys():
3331 if subvalue ==
'step':
3334 insetting = value[subvalue]
3335 if subgroup ==
'view':
3336 for viewkey, viewitem
in self.mapWindow.view[subkey].iteritems():
3337 if viewkey == subvalue:
3338 self.mapWindow.view[subkey][viewkey] = insetting
3342 for otherkey, otheritem
in self.
win[subgroup][subkey].iteritems():
3343 if type(otheritem) == data:
3344 for endkey, enditem
in otheritem.iteritems():
3345 if endkey == subvalue:
3346 paramwin = self.FindWindowById(enditem)
3350 if otherkey == subvalue:
3351 paramwin = self.FindWindowById(otheritem)
3354 if type(insetting)
in [tuple, list]
and len(insetting) > 2:
3355 insetting = tuple(insetting)
3356 paramwin.SetColour(insetting)
3359 paramwin.SetValue(insetting)
3362 paramwin.SetStringSelection(insetting)
3366 self.toolWin.UpdateSettings()
3367 self.FindWindowById(self.
win[
'view'][
'position']).Draw()
3368 self.FindWindowById(self.
win[
'view'][
'position']).Refresh(
False)
3370 self.mapWindow.render[
'quick'] =
False
3371 self.mapWindow.Refresh(
False)
3374 """!Save button pressed
3376 Save settings to configuration file
3379 UserSettings.ReadSettingsFile(settings = fileSettings)
3381 self.toolWin.UpdateSettings()
3383 nvsettings = UserSettings.Get(group =
'nviz')
3384 for subgroup, key
in nvsettings.iteritems():
3385 for subkey, value
in key.iteritems():
3386 if subkey ==
'height':
continue
3387 for subvalue
in value.keys():
3388 if subvalue ==
'step':
3390 nvsettings[subgroup][subkey][subvalue] = 1
3392 if subgroup ==
'view':
3393 nvsettings[subgroup][subkey][subvalue] = self.mapWindow.view[subkey][subvalue]
3394 elif subvalue ==
'map':
3395 if subkey ==
'shine':
3396 nvsettings[subgroup][subkey][subvalue] =
False
3397 if subkey ==
'color':
3398 nvsettings[subgroup][subkey][subvalue] =
True
3400 for otherkey, otheritem
in self.
win[subgroup][subkey].iteritems():
3401 if type(otheritem) == data:
3402 for endkey, enditem
in otheritem.iteritems():
3403 if endkey == subvalue:
3404 if self.FindWindowById(enditem).GetClassName() ==
'wxChoice':
3405 outsetting = self.FindWindowById(enditem).GetSelection()
3408 outsetting = self.FindWindowById(enditem).GetColour()
3409 outsetting = str(outsetting.Red())+
':'+str(outsetting.Green())+
':'+str(outsetting.Blue())
3412 outsetting = self.FindWindowById(enditem).GetValue()
3415 outsetting = self.FindWindowById(enditem).GetString()
3418 if (
type(outsetting) == list
or type(outsetting) == tuple)
and len(outsetting) > 2:
3419 outsetting = str(outsetting[0])+
':'+str(outsetting[1])+
':'+str(outsetting[2])
3421 nvsettings[subgroup][subkey][subvalue][endkey] = outsetting
3423 if otherkey == subvalue:
3424 if self.FindWindowById(otheritem).GetClassName() ==
'wxChoice':
3425 outsetting = self.FindWindowById(otheritem).GetSelection()
3428 outsetting = self.FindWindowById(otheritem).GetColour()
3429 outsetting = str(outsetting.Red())+
':'+str(outsetting.Green())+
':'+str(outsetting.Blue())
3432 outsetting = self.FindWindowById(otheritem).GetValue()
3435 outsetting = self.FindWindowById(enditem).GetString()
3438 if (
type(outsetting) == list
or type(outsetting) == tuple)
and len(outsetting) > 2:
3439 outsetting = str(outsetting[0])+
':'+str(outsetting[1])+
':'+str(outsetting[2])
3441 nvsettings[subgroup][subkey][subvalue] = outsetting
3443 UserSettings.Set(group =
'nviz', value = nvsettings)
3444 file = UserSettings.SaveToFile()
3445 self.parent.goutput.WriteLog(_(
'Nviz settings saved to file <%s>.') % file)