GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
nviz_tools.py
Go to the documentation of this file.
1 """!
2 @package nviz_tools.py
3 
4 @brief Nviz (3D view) tools window
5 
6 Classes:
7  - NvizToolWindow
8  - PositionWindow
9  - ViewPositionWindow
10  - LightPositionWindow
11 
12 (C) 2008-2010 by the GRASS Development Team
13 
14 This program is free software under the GNU General Public
15 License (>=v2). Read the file COPYING that comes with GRASS
16 for details.
17 
18 @author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
19 @author Enhancements by Michael Barton <michael.barton@asu.edu>
20 """
21 
22 import os
23 import sys
24 import copy
25 import types
26 
27 import wx
28 import wx.lib.colourselect as csel
29 import wx.lib.scrolledpanel as SP
30 try:
31  import wx.lib.agw.flatnotebook as FN
32 except ImportError:
33  import wx.lib.flatnotebook as FN
34 
35 import grass.script as grass
36 
37 import globalvar
38 import gselect
39 import gcmd
40 from preferences import globalSettings as UserSettings
41 from preferences import PreferencesBaseDialog
42 try:
43  from nviz_mapdisp import wxUpdateView, wxUpdateLight, wxUpdateProperties
44  import wxnviz
45 except (ImportError, NameError):
46  pass
47 from debug import Debug
48 
49 class NvizToolWindow(FN.FlatNotebook):
50  """!Nviz (3D view) tools panel
51  """
52  def __init__(self, parent, display, id = wx.ID_ANY,
53  style = globalvar.FNPageStyle, **kwargs):
54  self.parent = parent # GMFrame
55  self.mapDisplay = display
56  self.mapWindow = display.GetWindow()
57  self._display = self.mapWindow.GetDisplay()
58 
59  if globalvar.hasAgw:
60  kwargs['agwStyle'] = style
61  else:
62  kwargs['style'] = style
63  FN.FlatNotebook.__init__(self, parent, id, **kwargs)
64  self.SetTabAreaColour(globalvar.FNPageColor)
65 
66  self.win = {} # window ids
67  self.page = {} # page ids
68 
69  # view page
70  self.AddPage(page = self._createViewPage(),
71  text = " %s " % _("View"))
72 
73  # data page
74  self.AddPage(page = self._createDataPage(),
75  text = " %s " % _("Data"))
76 
77  # appearance page
78  self.AddPage(page = self._createAppearancePage(),
79  text = " %s " % _("Appearance"))
80 
81  self.UpdateSettings()
82  self.pageChanging = False
83  self.mapWindow.render['quick'] = False
84  self.mapWindow.Refresh(False)
85 
86  # bindings
87  self.Bind(wx.EVT_CLOSE, self.OnClose)
88  self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
89 
90  self.Update()
91  wx.CallAfter(self.SetPage, 'view')
92  wx.CallAfter(self.notebookData.SetSelection, 0)
93  wx.CallAfter(self.notebookAppearance.SetSelection, 0)
94 
95  def OnPageChanged(self, event):
96  new = event.GetSelection()
97  # self.ChangeSelection(new)
98 
99  def PostViewEvent(self, zExag = False):
100  """!Change view settings"""
101  event = wxUpdateView(zExag = zExag)
102  wx.PostEvent(self.mapWindow, event)
103 
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()}
110 
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)
116 
117  self.win['view'] = {}
118 
119  # position
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)
125  view = ViewPositionWindow(panel, size = (175, 175),
126  mapwindow = self.mapWindow)
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))
135 
136  # perspective
137  # set initial defaults here (or perhaps in a default values file), not in user settings
138  self._createControl(panel, data = self.win['view'], name = 'persp',
139  range = (1,100),
140  bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedSpin))
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)
146 
147  # twist
148  self._createControl(panel, data = self.win['view'], name = 'twist',
149  range = (-180,180),
150  bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedSpin))
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)
156 
157  # height + z-exag
158  self._createControl(panel, data = self.win['view'], name = 'height', sliderHor = False,
159  range = (0, 1),
160  bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedSpin))
161 
162  self._createControl(panel, data = self.win['view'], name = 'z-exag', sliderHor = False,
163  range = (0, 5),
164  bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedSpin))
165  self.FindWindowById(self.win['view']['z-exag']['slider']).SetValue(1)
166  self.FindWindowById(self.win['view']['z-exag']['spin']).SetValue(1)
167 
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))
183 
184  gridSizer.Add(item = heightSizer, pos = (0, 1), flag = wx.ALIGN_RIGHT)
185 
186  # view setup + reset
187  viewSizer = wx.BoxSizer(wx.HORIZONTAL)
188 
189  viewSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY,
190  label = _("Look at:")),
191  flag = wx.ALL | wx.ALIGN_CENTER_VERTICAL,
192  border = 5)
193 
194  viewType = wx.Choice (parent = panel, id = wx.ID_ANY, size = (125, -1),
195  choices = [_("top"),
196  _("north"),
197  _("south"),
198  _("east"),
199  _("west"),
200  _("north-west"),
201  _("north-east"),
202  _("south-east"),
203  _("south-west")])
204  viewType.SetSelection(0)
205  viewType.Bind(wx.EVT_CHOICE, self.OnLookAt)
206  # self.win['lookAt'] = viewType.GetId()
207  viewSizer.Add(item = viewType,
208  flag = wx.ALL | wx.ALIGN_CENTER_VERTICAL,
209  border = 5)
210 
211  reset = wx.Button(panel, id = wx.ID_ANY, label = _("Reset"))
212  reset.SetToolTipString(_("Reset to default view"))
213  # self.win['reset'] = reset.GetId()
214  reset.Bind(wx.EVT_BUTTON, self.OnResetView)
215 
216  viewSizer.Add(item = wx.Size(-1, -1), proportion = 1,
217  flag = wx.EXPAND)
218  viewSizer.Add(item = reset, proportion = 0,
219  flag = wx.ALL | wx.ALIGN_RIGHT,
220  border = 5)
221 
222  gridSizer.AddGrowableCol(2)
223  gridSizer.Add(item = viewSizer, pos = (4, 0), span = (1, 2),
224  flag = wx.EXPAND)
225 
226  # body
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,
231  border = 3)
232 
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)
238 
239  # background color
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)
243 
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))
251 
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,
256  border = 3)
257 
258  panel.SetSizer(pageSizer)
259 
260  return panel
261 
262  def _createDataPage(self):
263  """!Create data (surface, vector, volume) settings page"""
264  if globalvar.hasAgw:
265  self.notebookData = FN.FlatNotebook(parent = self, id = wx.ID_ANY,
266  agwStyle = globalvar.FNPageDStyle)
267  else:
268  self.notebookData = FN.FlatNotebook(parent = self, id = wx.ID_ANY,
269  style = globalvar.FNPageDStyle)
270 
271  # surface page
272  self.notebookData.AddPage(page = self._createSurfacePage(),
273  text = " %s " % _("Surface"))
274  self.EnablePage('surface', False)
275 
276  # vector page
277  self.notebookData.AddPage(page = self._createVectorPage(),
278  text = " %s " % _("Vector"))
279  self.EnablePage('vector', False)
280 
281  # volume page
282  self.notebookData.AddPage(page = self._createVolumePage(),
283  text = " %s " % _("Volume"))
284  self.EnablePage('volume', False)
285 
286  return self.notebookData
287 
288  def _createAppearancePage(self):
289  """!Create data (surface, vector, volume) settings page"""
290  if globalvar.hasAgw:
291  self.notebookAppearance = FN.FlatNotebook(parent = self, id = wx.ID_ANY,
292  agwStyle = globalvar.FNPageDStyle)
293  else:
294  self.notebookAppearance = FN.FlatNotebook(parent = self, id = wx.ID_ANY,
295  style = globalvar.FNPageDStyle)
296 
297  # light page
298  self.notebookAppearance.AddPage(page = self._createLightPage(),
299  text = " %s " % _("Lighting"))
300 
301  # fringe page
302  self.notebookAppearance.AddPage(page = self._createFringePage(),
303  text = " %s " % _("Fringe"))
304  self.EnablePage('fringe', False)
305 
306  return self.notebookAppearance
307 
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)
316 
317  self.win['surface'] = {}
318 
319  # selection
320  box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
321  label = " %s " % (_("Raster map")))
322  boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
323  rmaps = gselect.Select(parent = panel, type = 'raster',
324  onPopup = self.GselectOnPopup)
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,
330  flag = wx.ALL,
331  border = 3)
332  boxSizer.Add(item = desc, proportion = 0,
333  flag = wx.ALL,
334  border = 3)
335  pageSizer.Add(item = boxSizer, proportion = 0,
336  flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
337  border = 3)
338 
339  #
340  # surface attributes
341  #
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)
346 
347  # type
348  self.win['surface']['attr'] = {}
349  row = 0
350  for code, attrb in (('topo', _("Topography")),
351  ('color', _("Color")),
352  ('mask', _("Mask")),
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")])
362 
363  if code not in ('topo', 'color', 'shine'):
364  use.Insert(item = _("unset"), pos = 0)
365  self.win['surface'][code]['required'] = False
366  else:
367  self.win['surface'][code]['required'] = True
368  if code != 'mask':
369  use.Append(item = _('constant'))
370  self.win['surface'][code]['use'] = use.GetId()
371  use.Bind(wx.EVT_CHOICE, self.OnMapObjUse)
372  gridSizer.Add(item = use, flag = wx.ALIGN_CENTER_VERTICAL,
373  pos = (row, 1))
374 
375  map = gselect.Select(parent = panel, id = wx.ID_ANY,
376  # size = globalvar.DIALOG_GSELECT_SIZE,
377  size = (200, -1),
378  type = "raster")
379  self.win['surface'][code]['map'] = map.GetId() - 1 # FIXME
380  map.Bind(wx.EVT_TEXT, self.OnSurfaceMap)
381  # changing map topography not allowed
382  if code == 'topo':
383  map.Enable(False)
384  gridSizer.Add(item = map, flag = wx.ALIGN_CENTER_VERTICAL,
385  pos = (row, 2))
386 
387  if code == 'color':
388  value = csel.ColourSelect(panel, id = wx.ID_ANY,
389  colour = (0,0,0),
390  size = globalvar.DIALOG_COLOR_SIZE)
391  value.Bind(csel.EVT_COLOURSELECT, self.OnSurfaceMap)
392  elif code == 'mask':
393  value = None
394  else:
395  value = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
396  initial = 0)
397  if code == 'topo':
398  value.SetRange(minVal = -1e9, maxVal = 1e9)
399  elif code in ('shine', 'transp', 'emit'):
400  value.SetRange(minVal = 0, maxVal = 255)
401  else:
402  value.SetRange(minVal = 0, maxVal = 100)
403  value.Bind(wx.EVT_TEXT, self.OnSurfaceMap)
404 
405  if value:
406  self.win['surface'][code]['const'] = value.GetId()
407  value.Enable(False)
408  gridSizer.Add(item = value, flag = wx.ALIGN_CENTER_VERTICAL,
409  pos = (row, 3))
410  else:
411  self.win['surface'][code]['const'] = None
412 
413  self.SetMapObjUseMap(nvizType = 'surface',
414  attrb = code) # -> enable map / disable constant
415 
416  row += 1
417 
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,
422  border = 3)
423 
424  #
425  # draw
426  #
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)
433 
434  # mode
435  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
436  label = _("Mode:")),
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"),
440  _("fine"),
441  _("both")])
442  mode.SetSelection(0)
443  mode.SetName("selection")
444  mode.Bind(wx.EVT_CHOICE, self.OnSurfaceMode)
445  self.win['surface']['draw']['mode'] = mode.GetId()
446  gridSizer.Add(item = mode, flag = wx.ALIGN_CENTER_VERTICAL,
447  pos = (0, 1))
448 
449  # shading
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"),
455  _("gouraud")])
456  shade.SetName("selection")
457  self.win['surface']['draw']['shading'] = shade.GetId()
458  shade.Bind(wx.EVT_CHOICE, self.OnSurfaceMode)
459  gridSizer.Add(item = shade, flag = wx.ALIGN_CENTER_VERTICAL,
460  pos = (0, 3))
461 
462  # set to all
463  all = wx.Button(panel, id = wx.ID_ANY, label = _("Set to all"))
464  all.SetToolTipString(_("Use draw settings for all loaded surfaces"))
465  all.Bind(wx.EVT_BUTTON, self.OnSurfaceModeAll)
466  gridSizer.Add(item = all, flag = wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
467  pos = (0, 4), span = (1,2), border = 3 )
468 
469  # resolution coarse
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,
475  label = _("res.")),
476  flag = wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
477  border = 3)
478  resC = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
479  initial = 6,
480  min = 1,
481  max = 100)
482  resC.SetName("value")
483  resC.SetValue(6)
484 
485  self.win['surface']['draw']['res-coarse'] = resC.GetId()
486  resC.Bind(wx.EVT_SPINCTRL, self.OnSurfaceResolution)
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)
490 
491  # Coarse style
492  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
493  label = _("style")),
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"),
497  _("surface")])
498  style.SetName("selection")
499  self.win['surface']['draw']['style'] = style.GetId()
500  style.Bind(wx.EVT_CHOICE, self.OnSurfaceMode)
501  gridSizer.Add(item = style, flag = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
502  pos = (1, 3))
503 
504  # color
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")
513  color.Bind(csel.EVT_COLOURSELECT, self.OnSurfaceWireColor)
514  self.win['surface']['draw']['wire-color'] = color.GetId()
515  gridSizer.Add(item = color, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT,
516  pos = (1, 5))
517 
518  # resolution fine
519  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
520  label = _("Fine:")),
521  pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL)
522 
523  resSizer = wx.BoxSizer(wx.HORIZONTAL)
524  resSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
525  label = _("res.")),
526  flag = wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
527  border = 3)
528  resF = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
529  initial = 3,
530  min = 1,
531  max = 100)
532  resF.SetName("value")
533  resF.SetValue(3)
534  self.win['surface']['draw']['res-fine'] = resF.GetId()
535  resF.Bind(wx.EVT_SPINCTRL, self.OnSurfaceResolution)
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)
539 
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,
544  border = 3)
545 
546  #
547  # mask
548  #
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)
553 
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)
557 
558  elev = wx.CheckBox(parent = panel, id = wx.ID_ANY,
559  label = _("by elevation"))
560  elev.Enable(False) # TODO: not implemented yet
561  gridSizer.Add(item = elev, pos = (0, 1))
562 
563  color = wx.CheckBox(parent = panel, id = wx.ID_ANY,
564  label = _("by color"))
565  color.Enable(False) # TODO: not implemented yet
566  gridSizer.Add(item = color, pos = (0, 2))
567 
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,
572  border = 3)
573 
574  #
575  # position
576  #
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)
582 
583  # position
584  self._createControl(panel, data = self.win['surface'], name = 'position',
585  range = (-10000, 10000),
586  bind = (self.OnSurfacePosition, self.OnSurfacePosition, self.OnSurfacePosition))
587 
588  axis = wx.Choice (parent = panel, id = wx.ID_ANY, size = (75, -1),
589  choices = ["X",
590  "Y",
591  "Z"])
592 
593  self.win['surface']['position']['axis'] = axis.GetId()
594  axis.SetSelection(0)
595  axis.Bind(wx.EVT_CHOICE, self.OnSurfaceAxis)
596 
597  pslide = self.FindWindowById(self.win['surface']['position']['slider'])
598  pspin = self.FindWindowById(self.win['surface']['position']['spin'])
599 
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))
603 
604  boxSizer.Add(item = gridSizer, proportion = 1,
605  flag = wx.ALL | wx.EXPAND, border = 3)
606  box.SetSizer(boxSizer)
607  box.Layout()
608 
609  pageSizer.Add(item = boxSizer, proportion = 0,
610  flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
611  border = 3)
612 
613  panel.SetSizer(pageSizer)
614 
615  return panel
616 
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)
625 
626  self.win['vector'] = {}
627 
628  # selection
629  box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
630  label = " %s " % (_("Vector map")))
631  boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
632  vmaps = gselect.Select(parent = panel, type = 'vector',
633  onPopup = self.GselectOnPopup)
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,
639  flag = wx.ALL,
640  border = 3)
641  boxSizer.Add(item = desc, proportion = 0,
642  flag = wx.ALL,
643  border = 3)
644  pageSizer.Add(item = boxSizer, proportion = 0,
645  flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
646  border = 3)
647 
648  #
649  # vector lines
650  #
651  self.win['vector']['lines'] = {}
652 
653  showLines = wx.CheckBox(parent = panel, id = wx.ID_ANY,
654  label = _("Show vector lines"))
655  showLines.SetValue(True)
656 
657  self.win['vector']['lines']['show'] = showLines.GetId()
658  showLines.Bind(wx.EVT_CHECKBOX, self.OnVectorShow)
659 
660  pageSizer.Add(item = showLines, proportion = 0,
661  flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 5)
662 
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)
667 
668  # width
669  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
670  label = _("Line:")),
671  pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
672  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
673  label = _("width")),
674  pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL |
675  wx.ALIGN_RIGHT)
676 
677  width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
678  initial = 1,
679  min = 0,
680  max = 100)
681  width.SetValue(1)
682  self.win['vector']['lines']['width'] = width.GetId()
683  width.Bind(wx.EVT_SPINCTRL, self.OnVectorLines)
684  gridSizer.Add(item = width, pos = (0, 2),
685  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
686 
687  # color
688  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
689  label = _("color")),
690  pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL |
691  wx.ALIGN_RIGHT)
692 
693  color = csel.ColourSelect(panel, id = wx.ID_ANY,
694  colour = (0,0,0),
695  size = globalvar.DIALOG_COLOR_SIZE)
696  self.win['vector']['lines']['color'] = color.GetId()
697  color.Bind(csel.EVT_COLOURSELECT, self.OnVectorLines)
698 
699  gridSizer.Add(item = color, pos = (0, 4), flag = wx.ALIGN_CENTER_VERTICAL |
700  wx.ALIGN_LEFT)
701 
702  # display
703  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
704  label = _("display")),
705  pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL |
706  wx.ALIGN_RIGHT)
707 
708  display = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
709  choices = [_("on surface"),
710  _("flat")])
711  self.win['vector']['lines']['flat'] = display.GetId()
712  display.Bind(wx.EVT_CHOICE, self.OnVectorDisplay)
713 
714  gridSizer.Add(item = display, flag = wx.ALIGN_CENTER_VERTICAL |
715  wx.ALIGN_LEFT, pos = (1, 2), span = (1,2))
716 
717  # height
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,
721  span = (1, 3))
722 
723  surface = wx.ComboBox(parent = panel, id = wx.ID_ANY, size = (250, -1),
724  style = wx.CB_SIMPLE | wx.CB_READONLY,
725  choices = [])
726  surface.Bind(wx.EVT_COMBOBOX, self.OnVectorSurface)
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)
731 
732  self._createControl(panel, data = self.win['vector']['lines'], name = 'height', size = 300,
733  range = (0, 1000),
734  bind = (self.OnVectorHeight, self.OnVectorHeightFull, self.OnVectorHeightSpin))
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']),
740  pos = (3, 7),
741  flag = wx.ALIGN_CENTER)
742 
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,
747  border = 3)
748 
749  #
750  # vector points
751  #
752  self.win['vector']['points'] = {}
753 
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()
758  showPoints.Bind(wx.EVT_CHECKBOX, self.OnVectorShow)
759 
760  pageSizer.Add(item = showPoints, proportion = 0,
761  flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 5)
762 
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)
767 
768  # icon size
769  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
770  label = _("Icon:")),
771  pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
772  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
773  label = _("size")),
774  pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL |
775  wx.ALIGN_RIGHT)
776 
777  isize = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
778  initial = 1,
779  min = 1,
780  max = 1e6)
781  isize.SetName('value')
782  isize.SetValue(100)
783  self.win['vector']['points']['size'] = isize.GetId()
784  isize.Bind(wx.EVT_SPINCTRL, self.OnVectorPoints)
785  isize.Bind(wx.EVT_TEXT, self.OnVectorPoints)
786  gridSizer.Add(item = isize, pos = (0, 2),
787  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
788 
789  # icon color
790  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
791  label = _("color")),
792  pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL |
793  wx.ALIGN_RIGHT)
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()
799  icolor.Bind(csel.EVT_COLOURSELECT, self.OnVectorPoints)
800  gridSizer.Add(item = icolor, flag = wx.ALIGN_CENTER_VERTICAL |
801  wx.ALIGN_LEFT,
802  pos = (0, 4))
803 
804  # icon width
805  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
806  label = _("width")),
807  pos = (0, 5), flag = wx.ALIGN_CENTER_VERTICAL |
808  wx.ALIGN_RIGHT)
809 
810  iwidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
811  initial = 1,
812  min = 1,
813  max = 1e6)
814  iwidth.SetName('value')
815  iwidth.SetValue(100)
816  self.win['vector']['points']['width'] = iwidth.GetId()
817  iwidth.Bind(wx.EVT_SPINCTRL, self.OnVectorPoints)
818  iwidth.Bind(wx.EVT_TEXT, self.OnVectorPoints)
819  gridSizer.Add(item = iwidth, pos = (0, 6),
820  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
821 
822  # icon symbol
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()
831  isym.Bind(wx.EVT_CHOICE, self.OnVectorPoints)
832  gridSizer.Add(item = isym, flag = wx.ALIGN_CENTER_VERTICAL,
833  pos = (1, 2), span = (1,2))
834 
835  # high
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,
839  span = (1, 3))
840 
841  surface = wx.ComboBox(parent = panel, id = wx.ID_ANY, size = (250, -1),
842  style = wx.CB_SIMPLE | wx.CB_READONLY,
843  choices = [])
844  surface.Bind(wx.EVT_COMBOBOX, self.OnVectorSurface)
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)
849 
850  self._createControl(panel, data = self.win['vector']['points'], name = 'height', size = 300,
851  range = (0, 1000),
852  bind = (self.OnVectorHeight, self.OnVectorHeightFull, self.OnVectorHeightSpin))
853 
854  self.FindWindowById(self.win['vector']['points']['height']['slider']).SetValue(0)
855  self.FindWindowById(self.win['vector']['points']['height']['spin']).SetValue(0)
856 
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']),
860  pos = (3, 7),
861  flag = wx.ALIGN_CENTER)
862 
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,
867  border = 3)
868 
869  panel.SetSizer(pageSizer)
870 
871  return panel
872 
873  def GselectOnPopup(self, ltype, exclude = False):
874  """Update gselect.Select() items"""
875  maps = list()
876  for layer in self.mapWindow.Map.GetListOfLayers(l_type = ltype):
877  maps.append(layer.GetName())
878  return maps, exclude
879 
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)
888 
889  self.win['volume'] = {}
890 
891  # selection
892  box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
893  label = " %s " % (_("3D raster map")))
894  boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
895  rmaps = gselect.Select(parent = panel, type = 'raster3d',
896  onPopup = self.GselectOnPopup)
897  rmaps.GetChildren()[0].Bind(wx.EVT_TEXT, self.OnSetRaster3D)
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,
902  flag = wx.ALL,
903  border = 3)
904  boxSizer.Add(item = desc, proportion = 0,
905  flag = wx.ALL,
906  border = 3)
907  pageSizer.Add(item = boxSizer, proportion = 0,
908  flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
909  border = 3)
910 
911  #
912  # draw
913  #
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)
920 
921  # mode
922  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
923  label = _("Mode:")),
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"),
927  _("slides")])
928  mode.SetSelection(0)
929  mode.SetName("selection")
930  # mode.Bind(wx.EVT_CHOICE, self.OnSurfaceMode)
931  self.win['volume']['draw']['mode'] = mode.GetId()
932  gridSizer.Add(item = mode, flag = wx.ALIGN_CENTER_VERTICAL,
933  pos = (0, 1))
934 
935  # shading
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"),
941  _("gouraud")])
942  shade.SetName("selection")
943  self.win['volume']['draw']['shading'] = shade.GetId()
944  shade.Bind(wx.EVT_CHOICE, self.OnVolumeIsosurfMode)
945  gridSizer.Add(item = shade, flag = wx.ALIGN_CENTER_VERTICAL,
946  pos = (0, 3))
947 
948  # resolution (mode)
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),
953  initial = 1,
954  min = 1,
955  max = 100)
956  resol.SetName("value")
957  self.win['volume']['draw']['resolution'] = resol.GetId()
958  resol.Bind(wx.EVT_SPINCTRL, self.OnVolumeIsosurfResolution)
959  resol.Bind(wx.EVT_TEXT, self.OnVolumeIsosurfResolution)
960  gridSizer.Add(item = resol, pos = (0, 5))
961 
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,
966  border = 3)
967 
968  #
969  # manage isosurfaces
970  #
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)
975 
976  # list
977  isolevel = wx.CheckListBox(parent = panel, id = wx.ID_ANY,
978  size = (300, 150))
979  self.Bind(wx.EVT_CHECKLISTBOX, self.OnVolumeIsosurfCheck, isolevel)
980  self.Bind(wx.EVT_LISTBOX, self.OnVolumeIsosurfSelect, isolevel)
981 
982  self.win['volume']['isosurfs'] = isolevel.GetId()
983  gridSizer.Add(item = isolevel, pos = (0, 0), span = (4, 1))
984 
985  # buttons (add, delete, move up, move down)
986  btnAdd = wx.Button(parent = panel, id = wx.ID_ADD)
987  self.win['volume']['btnIsosurfAdd'] = btnAdd.GetId()
988  btnAdd.Bind(wx.EVT_BUTTON, self.OnVolumeIsosurfAdd)
989  gridSizer.Add(item = btnAdd,
990  pos = (0, 1))
991  btnDelete = wx.Button(parent = panel, id = wx.ID_DELETE)
992  self.win['volume']['btnIsosurfDelete'] = btnDelete.GetId()
993  btnDelete.Bind(wx.EVT_BUTTON, self.OnVolumeIsosurfDelete)
994  btnDelete.Enable(False)
995  gridSizer.Add(item = btnDelete,
996  pos = (1, 1))
997  btnMoveUp = wx.Button(parent = panel, id = wx.ID_UP)
998  self.win['volume']['btnIsosurfMoveUp'] = btnMoveUp.GetId()
999  btnMoveUp.Bind(wx.EVT_BUTTON, self.OnVolumeIsosurfMoveUp)
1000  btnMoveUp.Enable(False)
1001  gridSizer.Add(item = btnMoveUp,
1002  pos = (2, 1))
1003  btnMoveDown = wx.Button(parent = panel, id = wx.ID_DOWN)
1004  self.win['volume']['btnIsosurfMoveDown'] = btnMoveDown.GetId()
1005  btnMoveDown.Bind(wx.EVT_BUTTON, self.OnVolumeIsosurfMoveDown)
1006  btnMoveDown.Enable(False)
1007  gridSizer.Add(item = btnMoveDown,
1008  pos = (3, 1))
1009 
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,
1014  border = 3)
1015 
1016  #
1017  # isosurface attributes
1018  #
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)
1023 
1024  self.win['volume']['attr'] = {}
1025  row = 0
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] = {}
1033  # label
1034  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1035  label = attrb + ':'),
1036  pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
1037  if code != 'topo':
1038  use = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
1039  choices = [_("map")])
1040  else:
1041  use = None
1042  # check for required properties
1043  if code not in ('topo', 'color', 'shine'):
1044  use.Insert(item = _("unset"), pos = 0)
1045  self.win['volume'][code]['required'] = False
1046  else:
1047  self.win['volume'][code]['required'] = True
1048  if use and code != 'mask':
1049  use.Append(item = _('constant'))
1050  if use:
1051  self.win['volume'][code]['use'] = use.GetId()
1052  use.Bind(wx.EVT_CHOICE, self.OnMapObjUse)
1053  gridSizer.Add(item = use, flag = wx.ALIGN_CENTER_VERTICAL,
1054  pos = (row, 1))
1055 
1056  if code != 'topo':
1057  map = gselect.Select(parent = panel, id = wx.ID_ANY,
1058  # size = globalvar.DIALOG_GSELECT_SIZE,
1059  size = (200, -1),
1060  type = "grid3")
1061  self.win['volume'][code]['map'] = map.GetId() - 1 # FIXME
1062  map.Bind(wx.EVT_TEXT, self.OnVolumeIsosurfMap)
1063  gridSizer.Add(item = map, flag = wx.ALIGN_CENTER_VERTICAL,
1064  pos = (row, 2))
1065  else:
1066  map = None
1067 
1068  if code == 'color':
1069  value = csel.ColourSelect(panel, id = wx.ID_ANY,
1070  colour = (0,0,0),
1071  size = globalvar.DIALOG_COLOR_SIZE)
1072  value.Bind(csel.EVT_COLOURSELECT, self.OnVolumeIsosurfMap)
1073  elif code == 'mask':
1074  value = None
1075  else:
1076  if code == 'topo':
1077  size = (200, -1)
1078  else:
1079  size = (65, -1)
1080  value = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = size,
1081  initial = 0)
1082  if code == 'topo':
1083  value.SetRange(minVal = -1e9, maxVal = 1e9)
1084  elif code in ('shine', 'transp', 'emit'):
1085  value.SetRange(minVal = 0, maxVal = 255)
1086  else:
1087  value.SetRange(minVal = 0, maxVal = 100)
1088  value.Bind(wx.EVT_SPINCTRL, self.OnVolumeIsosurfMap)
1089  value.Bind(wx.EVT_TEXT, self.OnVolumeIsosurfMap)
1090 
1091  if value:
1092  self.win['volume'][code]['const'] = value.GetId()
1093  if code == 'topo':
1094  gridSizer.Add(item = value, flag = wx.ALIGN_CENTER_VERTICAL,
1095  pos = (row, 2))
1096  else:
1097  value.Enable(False)
1098  gridSizer.Add(item = value, flag = wx.ALIGN_CENTER_VERTICAL,
1099  pos = (row, 3))
1100  else:
1101  self.win['volume'][code]['const'] = None
1102 
1103  if code != 'topo':
1104  self.SetMapObjUseMap(nvizType = 'volume',
1105  attrb = code) # -> enable map / disable constant
1106 
1107  row += 1
1108 
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,
1113  border = 3)
1114 
1115  panel.SetSizer(pageSizer)
1116 
1117  return panel
1118 
1119  def _createLightPage(self):
1120  """!Create light page"""
1121  panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
1122  panel.SetupScrolling(scroll_x = False)
1123 
1124  self.page['light'] = { 'id' : 0,
1125  'notebook' : self.notebookAppearance.GetId() }
1126  self.win['light'] = {}
1127 
1128  pageSizer = wx.BoxSizer(wx.VERTICAL)
1129 
1130  show = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1131  label = _("Show light model"))
1132  show.Bind(wx.EVT_CHECKBOX, self.OnShowLightModel)
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)
1139 
1140  # position
1141  box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
1142  label = " %s " % (_("Light source position")))
1143  boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1144 
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)
1151  pos = LightPositionWindow(panel, id = wx.ID_ANY, size = (175, 175),
1152  mapwindow = self.mapWindow)
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))
1161 
1162  # height
1163  self._createControl(panel, data = self.win['light'], name = 'z', sliderHor = False,
1164  range = (0, 100),
1165  bind = (self.OnLightChange, None, self.OnLightChange))
1166 
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))
1175 
1176  gridSizer.Add(item = heightSizer, pos = (0, 1), flag = wx.ALIGN_RIGHT)
1177 
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,
1182  border = 3)
1183 
1184  # position
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)
1189 
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',
1194  subkey = 'color'),
1195  size = globalvar.DIALOG_COLOR_SIZE)
1196  self.win['light']['color'] = color.GetId()
1197  color.Bind(csel.EVT_COLOURSELECT, self.OnLightColor)
1198  gridSizer.Add(item = color, pos = (0, 2))
1199 
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,
1203  range = (0, 100),
1204  bind = (self.OnLightValue, None, self.OnLightValue))
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']),
1208  pos = (1, 2),
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,
1213  range = (0, 100),
1214  bind = (self.OnLightValue, None, self.OnLightValue))
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']),
1218  pos = (2, 2),
1219  flag = wx.ALIGN_CENTER)
1220 
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,
1225  border = 3)
1226 
1227  # reset = wx.Button(panel, id = wx.ID_ANY, label = _("Reset"))
1228  # reset.SetToolTipString(_("Reset to default view"))
1229  # # self.win['reset'] = reset.GetId()
1230  # reset.Bind(wx.EVT_BUTTON, self.OnResetView)
1231 
1232  # viewSizer.Add(item = reset, proportion = 1,
1233  # flag = wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT,
1234  # border = 5)
1235 
1236  # gridSizer.AddGrowableCol(3)
1237  # gridSizer.Add(item = viewSizer, pos = (4, 0), span = (1, 2),
1238  # flag = wx.EXPAND)
1239 
1240  panel.SetSizer(pageSizer)
1241 
1242  return panel
1243 
1244  def _createFringePage(self):
1245  """!Create fringe page"""
1246  panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
1247  panel.SetupScrolling(scroll_x = False)
1248 
1249  self.page['fringe'] = { 'id' : 1,
1250  'notebook' : self.notebookAppearance.GetId() }
1251  self.win['fringe'] = {}
1252 
1253  pageSizer = wx.BoxSizer(wx.VERTICAL)
1254 
1255  # selection
1256  rbox = wx.StaticBox (parent = panel, id = wx.ID_ANY,
1257  label = " %s " % (_("Surface")))
1258  rboxSizer = wx.StaticBoxSizer(rbox, wx.VERTICAL)
1259  rmaps = gselect.Select(parent = panel, type = 'raster',
1260  onPopup = self.GselectOnPopup)
1261  rmaps.GetChildren()[0].Bind(wx.EVT_TEXT, self.OnSetSurface)
1262  self.win['fringe']['map'] = rmaps.GetId()
1263  rboxSizer.Add(item = rmaps, proportion = 0,
1264  flag = wx.ALL,
1265  border = 3)
1266  pageSizer.Add(item = rboxSizer, proportion = 0,
1267  flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
1268  border = 3)
1269 
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,
1278  label = edge[0],
1279  name = edge[1])
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)
1284 
1285  pageSizer.Add(item = eboxSizer, proportion = 0,
1286  flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
1287  border = 3)
1288 
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)
1293 
1294  # elevation
1295  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1296  label = _("Elevation of fringe from bottom:")),
1297  pos = (0, 0),
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))
1305 
1306  # color
1307  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1308  label = _("Color:")),
1309  pos = (1, 0),
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',
1314  subkey = 'color'))
1315  color.Bind(csel.EVT_COLOURSELECT, self.OnFringe)
1316  self.win['fringe']['color'] = color.GetId()
1317  gridSizer.Add(item = color, pos = (1, 1))
1318 
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,
1323  border = 3)
1324 
1325  panel.SetSizer(pageSizer)
1326 
1327  return panel
1328 
1329  def GetLayerData(self, nvizType):
1330  """!Get nviz data"""
1331  name = self.FindWindowById(self.win[nvizType]['map']).GetValue()
1332 
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')
1339 
1340  return None
1341 
1342  def OnFringe(self, event):
1343  """!Show/hide fringe"""
1344  enabled = event.IsChecked()
1345  win = self.FindWindowById(event.GetId())
1346 
1347  data = self.GetLayerData('fringe')['surface']
1348 
1349  sid = data['object']['id']
1350  elev = self.FindWindowById(self.win['fringe']['elev']).GetValue()
1351  color = self.FindWindowById(self.win['fringe']['color']).GetValue()
1352 
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)
1359 
1360  def OnScroll(self, event, win, data):
1361  """!Generic scrolling handler"""
1362  winName = self.__GetWindowName(win, event.GetId())
1363  if not winName:
1364  return
1365  data[winName] = event.GetInt()
1366  for w in win[winName].itervalues():
1367  self.FindWindowById(w).SetValue(data[winName])
1368 
1369  event.Skip()
1370 
1371  def _createControl(self, parent, data, name, range, bind = (None, None, None),
1372  sliderHor = True, size = 200):
1373  """!Add control (Slider + SpinCtrl)"""
1374  data[name] = dict()
1375  if sliderHor:
1376  style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | \
1377  wx.SL_BOTTOM
1378  sizeW = (size, -1)
1379  else:
1380  style = wx.SL_VERTICAL | wx.SL_AUTOTICKS | \
1381  wx.SL_INVERSE
1382  sizeW = (-1, size)
1383 
1384  slider = wx.Slider(parent = parent, id = wx.ID_ANY,
1385  minValue = range[0],
1386  maxValue = range[1],
1387  style = style,
1388  size = sizeW)
1389  slider.SetName('slider')
1390  if bind[0]:
1391  slider.Bind(wx.EVT_SCROLL, bind[0])
1392 
1393  # slider.Bind(wx.EVT_SCROLL_THUMBRELEASE, bind[1])
1394  if bind[1]:
1395  slider.Bind(wx.EVT_SCROLL_CHANGED, bind[1]) # this only works in MSW
1396  data[name]['slider'] = slider.GetId()
1397 
1398  spin = wx.SpinCtrl(parent = parent, id = wx.ID_ANY, size = (65, -1),
1399  min = range[0],
1400  max = range[1])
1401 
1402  # no 'changed' event ... (FIXME)
1403  spin.SetName('spin')
1404  if bind[2]:
1405  spin.Bind(wx.EVT_SPINCTRL, bind[2])
1406 
1407  data[name]['spin'] = spin.GetId()
1408 
1409  def __GetWindowName(self, data, id):
1410  for name in data.iterkeys():
1411  if type(data[name]) is type({}):
1412  for win in data[name].itervalues():
1413  if win == id:
1414  return name
1415  else:
1416  if data[name] == id:
1417  return name
1418 
1419  return None
1420 
1421  def UpdateSettings(self):
1422  """!Update view from settings values
1423  stored in self.mapWindow.view dictionary"""
1424  for control in ('height',
1425  'persp',
1426  'twist',
1427  'z-exag'):
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)
1432  else:
1433  try:
1434  value = self.mapWindow.view[control]['value']
1435  except KeyError:
1436  value = -1
1437 
1438  self.FindWindowById(win).SetValue(value)
1439 
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)
1445 
1446  # bgcolor = self.FindWindowById(self.win['settings']['general']['bgcolor']).GetColour()
1447  # self.OnBgColor(event = bgcolor)
1448  self.Update()
1449 
1450  self.mapWindow.Refresh(eraseBackground = False)
1451  self.mapWindow.render['quick'] = False
1452  self.mapWindow.Refresh(False)
1453 
1454  def OnShowLightModel(self, event):
1455  """!Show light model"""
1456  self._display.showLight = event.IsChecked()
1457  self._display.DrawLightingModel()
1458 
1459  def OnLightChange(self, event):
1460  """!Position of the light changed"""
1461  winName = self.__GetWindowName(self.win['light'], event.GetId())
1462  if not winName:
1463  return
1464 
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)
1469 
1470  event = wxUpdateLight()
1471  wx.PostEvent(self.mapWindow, event)
1472 
1473  event.Skip()
1474 
1475  def OnLightColor(self, event):
1476  """!Color of the light changed"""
1477  self.mapWindow.light['color'] = event.GetValue()
1478 
1479  event = wxUpdateLight()
1480  wx.PostEvent(self.mapWindow, event)
1481 
1482  event.Skip()
1483 
1484  def OnLightValue(self, event):
1485  """!Light brightness changed"""
1486  data = self.mapWindow.light
1487  self.OnScroll(event, self.win['light'], data)
1488 
1489  event = wxUpdateLight()
1490  wx.PostEvent(self.mapWindow, event)
1491 
1492  event.Skip()
1493 
1494  def OnBgColor(self, event):
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])
1499 
1500  self._display.SetBgColor(str(color))
1501 
1502  if self.mapDisplay.statusbarWin['render'].IsChecked():
1503  self.mapWindow.Refresh(False)
1504 
1505  def OnSetSurface(self, event):
1506  """!Surface selected, currently used for fringes"""
1507  name = event.GetString()
1508  try:
1509  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')['surface']
1510  except:
1511  self.EnablePage('fringe', False)
1512  return
1513 
1514  layer = self.mapWindow.GetLayerByName(name, mapType = 'raster')
1515  self.EnablePage('fringe', True)
1516 
1517  def OnSetRaster(self, event):
1518  """!Raster map selected, update surface page"""
1519  name = event.GetString()
1520  try:
1521  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')['surface']
1522  except:
1523  self.EnablePage('surface', False)
1524  return
1525 
1526  layer = self.mapWindow.GetLayerByName(name, mapType = 'raster')
1527  self.EnablePage('surface', True)
1528  self.UpdateSurfacePage(layer, data, updateName = False)
1529 
1530  def OnSetVector(self, event):
1531  """!Vector map selected, update properties page"""
1532  name = event.GetString()
1533  try:
1534  data = self.mapWindow.GetLayerByName(name, mapType = 'vector', dataType = 'nviz')['vector']
1535  except:
1536  self.EnablePage('vector', False)
1537  return
1538 
1539  layer = self.mapWindow.GetLayerByName(name, mapType = 'vector')
1540  self.EnablePage('vector', True)
1541  self.UpdateVectorPage(layer, data, updateName = False)
1542 
1543  def OnSetRaster3D(self, event):
1544  """!3D Raster map selected, update surface page"""
1545  name = event.GetString()
1546  try:
1547  data = self.mapWindow.GetLayerByName(name, mapType = '3d-raster', dataType = 'nviz')['volume']
1548  except:
1549  self.EnablePage('volume', False)
1550  return
1551 
1552  layer = self.mapWindow.GetLayerByName(name, mapType = '3d-raster')
1553  self.EnablePage('volume', True)
1554  self.UpdateVolumePage(layer, data, updateName = False)
1555 
1556  def OnViewChange(self, event):
1557  """!Change view, render in quick mode"""
1558  # find control
1559  winName = self.__GetWindowName(self.win['view'], event.GetId())
1560  if not winName:
1561  return
1562 
1563  if winName == 'height':
1564  view = self.mapWindow.iview # internal
1565  else:
1566  view = self.mapWindow.view
1567 
1568  if winName == 'z-exag' and event.GetInt() >= 0:
1569  self.PostViewEvent(zExag = True)
1570  else:
1571  self.PostViewEvent(zExag = False)
1572 
1573  view[winName]['value'] = event.GetInt()
1574 
1575  for win in self.win['view'][winName].itervalues():
1576  self.FindWindowById(win).SetValue(view[winName]['value'])
1577 
1578  self.mapWindow.render['quick'] = True
1579  self.mapWindow.Refresh(False)
1580 
1581  event.Skip()
1582 
1583  def OnViewChanged(self, event):
1584  """!View changed, render in full resolution"""
1585  self.mapWindow.render['quick'] = False
1586  self.mapWindow.Refresh(False)
1587 
1588  self.UpdateSettings()
1589 
1590  def OnViewChangedSpin(self, event):
1591  """!View changed, render in full resolution"""
1592  self.mapWindow.render['quick'] = False
1593  self.OnViewChange(event)
1594  self.OnViewChanged(None)
1595  self.Update()
1596 
1597  event.Skip()
1598 
1599  def OnResetView(self, event):
1600  """!Reset to default view (view page)"""
1601  self.mapWindow.ResetView()
1602  self.UpdateSettings()
1603  self.mapWindow.Refresh(False)
1604 
1605  def OnLookAt(self, event):
1606  """!Look at (view page)"""
1607  sel = event.GetSelection()
1608  if sel == 0: # top
1609  self.mapWindow.view['position']['x'] = 0.5
1610  self.mapWindow.view['position']['y'] = 0.5
1611  elif sel == 1: # north
1612  self.mapWindow.view['position']['x'] = 0.5
1613  self.mapWindow.view['position']['y'] = 0.0
1614  elif sel == 2: # south
1615  self.mapWindow.view['position']['x'] = 0.5
1616  self.mapWindow.view['position']['y'] = 1.0
1617  elif sel == 3: # east
1618  self.mapWindow.view['position']['x'] = 1.0
1619  self.mapWindow.view['position']['y'] = 0.5
1620  elif sel == 4: # west
1621  self.mapWindow.view['position']['x'] = 0.0
1622  self.mapWindow.view['position']['y'] = 0.5
1623  elif sel == 5: # north-west
1624  self.mapWindow.view['position']['x'] = 0.0
1625  self.mapWindow.view['position']['y'] = 0.0
1626  elif sel == 6: # north-east
1627  self.mapWindow.view['position']['x'] = 1.0
1628  self.mapWindow.view['position']['y'] = 0.0
1629  elif sel == 7: # south-east
1630  self.mapWindow.view['position']['x'] = 1.0
1631  self.mapWindow.view['position']['y'] = 1.0
1632  elif sel == 8: # south-west
1633  self.mapWindow.view['position']['x'] = 0.0
1634  self.mapWindow.view['position']['y'] = 1.0
1635 
1636  self.PostViewEvent(zExag = True)
1637 
1638  self.UpdateSettings()
1639  self.mapWindow.render['quick'] = False
1640  self.mapWindow.Refresh(False)
1641 
1642  def OnClose(self, event):
1643  """!Close button pressed
1644 
1645  Close dialog
1646  """
1647  self.Hide()
1648 
1649  def OnMapObjUse(self, event):
1650  """!Set surface attribute -- use -- map/constant"""
1651  if not self.mapWindow.init:
1652  return
1653 
1654  wx.Yield()
1655 
1656  # find attribute row
1657  attrb = self.__GetWindowName(self.win['surface'], event.GetId())
1658  if not attrb:
1659  attrb = self.__GetWindowName(self.win['volume'], event.GetId())
1660  nvizType = 'volume'
1661  else:
1662  nvizType = 'surface'
1663 
1664  selection = event.GetSelection()
1665  if self.win[nvizType][attrb]['required']: # no 'unset'
1666  selection += 1
1667  if selection == 0: # unset
1668  useMap = None
1669  value = ''
1670  elif selection == 1: # map
1671  useMap = True
1672  value = self.FindWindowById(self.win[nvizType][attrb]['map']).GetValue()
1673  elif selection == 2: # constant
1674  useMap = False
1675  if attrb == 'color':
1676  value = self.FindWindowById(self.win[nvizType][attrb]['const']).GetColour()
1677  value = self._getColorString(value)
1678  else:
1679  value = self.FindWindowById(self.win[nvizType][attrb]['const']).GetValue()
1680 
1681  self.SetMapObjUseMap(nvizType = nvizType,
1682  attrb = attrb, map = useMap)
1683 
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),
1689  'update' : None }
1690  else: # volume / isosurface
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),
1696  'update' : None }
1697 
1698  # update properties
1699  event = wxUpdateProperties(data = data)
1700  wx.PostEvent(self.mapWindow, event)
1701 
1702  if self.mapDisplay.statusbarWin['render'].IsChecked():
1703  self.mapWindow.Refresh(False)
1704 
1705  def EnablePage(self, name, enabled = True):
1706  """!Enable/disable all widgets on page"""
1707  for key, item in self.win[name].iteritems():
1708  if key == 'map' or key == 'surface':
1709  continue
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)
1714  else:
1715  if type(item) == types.IntType:
1716  self.FindWindowById(item).Enable(enabled)
1717 
1718  def SetMapObjUseMap(self, nvizType, attrb, map = None):
1719  """!Update dialog widgets when attribute type changed"""
1720  if attrb in ('topo', 'color', 'shine'):
1721  incSel = -1 # decrement selection (no 'unset')
1722  else:
1723  incSel = 0
1724 
1725  if map is True: # map
1726  if attrb != 'topo': # changing map topography not allowed
1727  # not sure why, but here must be disabled both ids, should be fixed!
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)
1732  elif map is False: # const
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)
1737  else: # unset
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)
1742 
1743  def OnSurfaceMap(self, event):
1744  """!Set surface attribute"""
1745  self.SetMapObjAttrb(nvizType = 'surface', winId = event.GetId())
1746 
1747  def SetMapObjAttrb(self, nvizType, winId):
1748  """!Set map object (surface/isosurface) attribute (map/constant)"""
1749  if not self.mapWindow.init:
1750  return
1751 
1752  attrb = self.__GetWindowName(self.win[nvizType], winId)
1753  if not attrb:
1754  return
1755 
1756  if nvizType == 'volume' and attrb == 'topo':
1757  return
1758 
1759  selection = self.FindWindowById(self.win[nvizType][attrb]['use']).GetSelection()
1760  if self.win[nvizType][attrb]['required']:
1761  selection += 1
1762 
1763  if selection == 0: # unset
1764  useMap = None
1765  value = ''
1766  elif selection == 1: # map
1767  value = self.FindWindowById(self.win[nvizType][attrb]['map']).GetValue()
1768  useMap = True
1769  else: # constant
1770  if attrb == 'color':
1771  value = self.FindWindowById(self.win[nvizType][attrb]['const']).GetColour()
1772  # tuple to string
1773  value = self._getColorString(value)
1774  else:
1775  value = self.FindWindowById(self.win[nvizType][attrb]['const']).GetValue()
1776  useMap = False
1777 
1778  if not self.pageChanging:
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),
1784  'update' : None }
1785  else:
1786  data = self.mapWindow.GetLayerByName(name, mapType = '3d-raster', dataType = 'nviz')
1787  list = self.FindWindowById(self.win['volume']['isosurfs'])
1788  id = list.GetSelection()
1789  if id > -1:
1790  data[nvizType]['isosurface'][id][attrb] = { 'map' : useMap,
1791  'value' : str(value),
1792  'update' : None }
1793 
1794  # update properties
1795  event = wxUpdateProperties(data = data)
1796  wx.PostEvent(self.mapWindow, event)
1797 
1798  if self.mapDisplay.statusbarWin['render'].IsChecked():
1799  self.mapWindow.Refresh(False)
1800 
1801  def OnSurfaceResolution(self, event):
1802  """!Draw resolution changed"""
1803  self.SetSurfaceResolution()
1804 
1805  if self.mapDisplay.statusbarWin['render'].IsChecked():
1806  self.mapWindow.Refresh(False)
1807 
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()
1812 
1813  data = self.GetLayerData('surface')
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868 
1869  data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
1870  if not data:
1871  continue # shouldy no happen
1872 
1873  data['surface']['draw']['all'] = True
1874  data['surface']['draw']['mode'] = { 'value' : value,
1875  'desc' : desc,
1876  'update' : None }
1877  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1878  'fine' : fine,
1879  'update' : None }
1880  data['surface']['draw']['wire-color'] = { 'value' : cvalue,
1814  data['surface']['draw']['resolution'] = { 'coarse' : coarse,
1815  'fine' : fine,
1816  'update' : None }
1817 
1818  # update properties
1819  event = wxUpdateProperties(data = data)
1820  wx.PostEvent(self.mapWindow, event)
1821 
1822  def SetSurfaceMode(self):
1823  """!Set draw mode"""
1824  mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
1825  if mode == 0: # coarse
1826  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1827  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
1828  elif mode == 1: # fine
1829  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
1830  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1831  else: # both
1832  self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
1833  self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
1834 
1835  style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
1836 
1837  shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
1838 
1839  value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
1840 
1841  return value, desc
1842 
1843  def OnSurfaceMode(self, event):
1844  """!Set draw mode"""
1845  value, desc = self.SetSurfaceMode()
1846 
1847  data = self.GetLayerData('surface')
1848  data['surface']['draw']['mode'] = { 'value' : value,
1849  'desc' : desc,
1850  'update' : None }
1851 
1852  # update properties
1853  event = wxUpdateProperties(data = data)
1854  wx.PostEvent(self.mapWindow, event)
1855 
1856  if self.mapDisplay.statusbarWin['render'].IsChecked():
1857  self.mapWindow.Refresh(False)
1858 
1859  def OnSurfaceModeAll(self, event):
1860  """!Set draw mode (including wire color) for all loaded surfaces"""
1861  value, desc = self.SetSurfaceMode()
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()
1865  cvalue = self._getColorString(color)
1866 
1867  for name in self.mapWindow.GetLayerNames(type = 'raster'):
1868