2 @package nviz.mapwindow
4 @brief wxGUI 3D view mode (map canvas)
6 This module implements 3D visualization mode for map display.
9 - mapwindow::NvizThread
12 (C) 2008-2011 by the GRASS Development Team
14 This program is free software under the GNU General Public License
15 (>=v2). Read the file COPYING that comes with GRASS for details.
17 @author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
18 @author Anna Kratochvilova <kratochanna gmail.com> (Google SoC 2011)
29 from threading
import Thread
32 from wx.lib.newevent
import NewEvent
33 from wx
import glcanvas
34 from wx.glcanvas
import WX_GL_DEPTH_SIZE
38 from core.gcmd import GMessage, GException, GError
45 from nviz
import wxnviz
48 wxUpdateProperties, EVT_UPDATE_PROP = NewEvent()
49 wxUpdateView, EVT_UPDATE_VIEW = NewEvent()
50 wxUpdateLight, EVT_UPDATE_LIGHT = NewEvent()
51 wxUpdateCPlane, EVT_UPDATE_CPLANE = NewEvent()
56 Debug.msg(5,
"NvizThread.__init__():")
69 """!Get display instance"""
73 """!OpenGL canvas for Map Display Window"""
74 def __init__(self, parent, id = wx.ID_ANY,
75 Map =
None, tree =
None, lmgr =
None):
82 sys.platform
not in (
'win32',
'darwin'):
83 depthBuffer = int(UserSettings.Get(group=
'display', key=
'nvizDepthBuffer', subkey=
'value'))
84 attribs=[WX_GL_DEPTH_SIZE, depthBuffer, 0]
85 glcanvas.GLCanvas.__init__(self, parent, id, attribList=attribs)
87 glcanvas.GLCanvas.__init__(self, parent, id)
90 MapWindow.__init__(self, parent, id,
98 self.
context = glcanvas.GLContext(self)
110 'default' : wx.StockCursor(wx.CURSOR_ARROW),
111 'cross' : wx.StockCursor(wx.CURSOR_CROSS),
140 self.
log = self.lmgr.goutput
141 logerr = self.lmgr.goutput.GetLog(err =
True)
142 logmsg = self.lmgr.goutput.GetLog()
144 self.
log = logmsg = sys.stdout
148 os.environ[
'GRASS_REGION'] = self.Map.SetRegion(windres =
True)
151 self.parent.GetProgressBar(),
153 self.nvizThread.start()
155 self.
_display = self.nvizThread.GetDisplay()
158 del os.environ[
'GRASS_REGION']
160 self.
img = wx.Image(self.Map.mapfile, wx.BITMAP_TYPE_ANY)
167 self.
view = copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'view'))
168 self.
iview = UserSettings.Get(group =
'nviz', key =
'view', internal =
True)
169 self.
light = copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'light'))
170 self.
decoration = self.nvizDefault.SetDecorDefaultProp(type =
'arrow')
182 self.Bind(wx.EVT_SIZE, self.
OnSize)
183 self.Bind(wx.EVT_PAINT, self.
OnPaint)
193 self.Bind(wx.EVT_KEY_DOWN, self.
OnKeyDown)
194 self.Bind(wx.EVT_KEY_UP, self.
OnKeyUp)
196 self.Bind(wx.EVT_CLOSE, self.
OnClose)
199 sys.platform
not in (
'win32',
'darwin'):
205 def _warningDepthBuffer(self):
207 message=_(
"Opening 3D view was not successful. "
208 "Please try to change the value of depth buffer "
209 "in GUI Settings dialog > tab Map Display > Advanced "
214 """!Initialize fly through dictionary"""
215 fly = {
'interval' : 10,
219 'move' : UserSettings.Get(group =
'nviz', key =
'fly', subkey = [
'exag',
'move']),
220 'turn' : UserSettings.Get(group =
'nviz', key =
'fly', subkey = [
'exag',
'turn'])},
221 'exagMultiplier' : 3,
223 'mouseControl' :
None,
224 'pos' : {
'x' : 0,
'y' : 0},
232 """!Fly event was emitted, move the scene"""
233 if self.
mouse[
'use'] !=
'fly':
236 if self.
fly[
'mouseControl']:
242 self._display.FlyThrough(flyInfo = self.
fly[
'value'], mode = self.
fly[
'mode'],
243 exagInfo = self.
fly[
'exag'])
245 self.
render[
'quick'] =
True
249 """!Compute values for flythrough navigation
250 (ComputeFlyValues should follow).
252 Based on visualization/nviz/src/togl_flythrough.c.
253 @param x,y screen coordinates
255 sx, sy = self.GetClientSizeTuple()
258 mx = 2 * (float(x) / sx) - 1
259 my = 2 * (float(y) / sy) - 1
284 """!Compute parameters for fly-through navigation
286 @params mx,my results from ComputeMxMy method
288 self.
fly[
'value'] = [0, 0, 0]
290 if self.
fly[
'mode'] == 0:
291 self.
fly[
'value'][0] = self.
fly[
'flySpeed'] * self.
fly[
'interval'] / 1000.
292 self.
fly[
'value'][1] = mx * 0.1 * self.
fly[
'interval'] / 1000.
293 self.
fly[
'value'][2] = my * 0.1 * self.
fly[
'interval'] / 1000.
295 self.
fly[
'value'][0] = mx * 100.0 * self.
fly[
'interval'] /1000.
296 self.
fly[
'value'][2] = - my * 100.0 * self.
fly[
'interval'] /1000.
299 """!Increase/decrease flight spped"""
301 self.
fly[
'flySpeed'] += self.
fly[
'flySpeedStep']
303 self.
fly[
'flySpeed'] -= self.
fly[
'flySpeedStep']
306 """!Stop timers if running, unload data"""
312 """!Stop timer if running"""
313 if timer.IsRunning():
316 def _bindMouseEvents(self):
318 self.Bind(wx.EVT_MOTION, self.
OnMotion)
321 """!Initialize cutting planes list"""
322 for i
in range(self._display.GetCPlanesCount()):
323 cplane = copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'cplane'))
325 self.cplanes.append(cplane)
328 """!Sets reference to nviz toolwindow in layer manager"""
332 """!Returns reference to nviz toolwindow in layer manager"""
345 size = self.GetClientSize()
349 context = self.GetContext()
350 if self.
size != size \
352 Debug.msg(3,
"GLCanvas.OnSize(): w = %d, h = %d" % \
353 (size.width, size.height))
358 self._display.ResizeWindow(size.width,
362 self.parent.StatusbarReposition()
365 self.parent.StatusbarUpdate()
372 Debug.msg(1,
"GLCanvas.OnPaint()")
374 self.
render[
'overlays'] =
True
375 dc = wx.PaintDC(self)
386 self._display.InitView()
395 if hasattr(self.
lmgr,
"nviz"):
396 self.lmgr.nviz.UpdatePage(
'view')
397 self.lmgr.nviz.UpdatePage(
'light')
398 self.lmgr.nviz.UpdatePage(
'cplane')
399 self.lmgr.nviz.UpdatePage(
'decoration')
400 self.lmgr.nviz.UpdatePage(
'animation')
403 if layer.type ==
'raster':
404 self.lmgr.nviz.UpdatePage(
'surface')
405 self.lmgr.nviz.UpdatePage(
'fringe')
406 elif layer.type ==
'vector':
407 self.lmgr.nviz.UpdatePage(
'vector')
409 self.lmgr.nviz.UpdateSettings()
412 win = self.lmgr.nviz.FindWindowById( \
413 self.lmgr.nviz.win[
'vector'][
'lines'][
'surface'])
421 """!Draw overlay image"""
423 if texture.IsActive():
427 """!Estimates legend size for dragging"""
430 for param
in self.
overlays[1].cmd[1:]:
431 if param.startswith(
"at="):
432 size = map(int, param.split(
"=")[-1].
split(
','))
435 wSize = self.GetClientSizeTuple()
436 x, y = size[2]/100. * wSize[0], wSize[1] - (size[1]/100. * wSize[1])
439 w = (size[3] - size[2])/100. * wSize[0]
440 h = (size[1] - size[0])/100. * wSize[1]
442 rect = wx.Rect(x, y, w, h)
448 """!Draw overlay text"""
449 bmp = wx.EmptyBitmap(textDict[
'bbox'][2], textDict[
'bbox'][3])
450 memDC = wx.MemoryDC()
451 memDC.SelectObject(bmp)
453 mask = self.
view[
'background'][
'color']
454 if mask == textDict[
'color']:
456 memDC.SetBackground(wx.Brush(mask))
458 memDC.SetFont(textDict[
'font'])
459 memDC.SetTextForeground(textDict[
'color'])
460 if textDict[
'rotation'] == 0:
461 memDC.DrawText(textDict[
'text'], 0, 0)
463 memDC.DrawRotatedText(textDict[
'text'], relCoords[0], relCoords[1],
464 textDict[
'rotation'])
465 bmp.SetMaskColour(mask)
466 memDC.DrawBitmap(bmp, 0, 0, 1)
468 filename = tempfile.mktemp() +
'.png'
469 bmp.SaveFile(filename, wx.BITMAP_TYPE_PNG)
470 memDC.SelectObject(wx.NullBitmap)
475 """!Converts rendered overlay files and text labels to wx.Image
476 and then to textures so that they can be rendered by OpenGL.
477 Updates self.imagelist"""
478 self.Map.ChangeMapSize(self.GetClientSize())
479 self.Map.RenderOverlays(force =
True)
484 if texture.GetId() < 100:
485 if not self.
overlays[texture.GetId()].IsShown():
486 texture.SetActive(
False)
488 texture.SetActive(
True)
490 if texture.GetId()
not in self.
textdict:
491 self.imagelist.remove(texture)
494 for oid, overlay
in self.overlays.iteritems():
495 if not overlay.IsShown()
or oid == 0:
497 if oid
not in [t.GetId()
for t
in self.
imagelist]:
502 if not t.Corresponds(overlay):
503 self.imagelist.remove(t)
506 t.SetCoords(overlay.coords)
510 for textId
in self.textdict.keys():
511 if textId
not in [t.GetId()
for t
in self.
imagelist]:
515 if t.GetId() == textId:
516 self.
textdict[textId][
'bbox'] = t.textDict[
'bbox']
517 if not t.Corresponds(self.
textdict[textId]):
518 self.imagelist.remove(t)
521 t.SetCoords(self.
textdict[textId][
'coords'])
524 """!Create texture from overlay image or from textdict"""
527 coords = list(self.
overlays[overlay.id].coords),
528 cmd = overlay.GetCmd())
533 self.
textdict[textId][
'coords'] = coords
534 self.
textdict[textId][
'bbox'] = bbox
537 coords = coords, textDict = self.
textdict[textId])
538 bbox.OffsetXY(*relCoords)
539 texture.SetBounds(bbox)
541 if not texture.textureId:
542 GMessage(parent = self, message =
543 _(
"Image is too large, your OpenGL implementation "
544 "supports maximum texture size %d px.") % texture.maxSize)
547 self.imagelist.append(texture)
552 """Find object which was clicked on"""
554 if texture.HitTest(mouseX, mouseY, radius):
559 self.animation.Update()
567 Used for fly-through mode.
569 if not self.
mouse[
'use'] ==
'fly':
572 key = event.GetKeyCode()
573 if key == wx.WXK_CONTROL:
576 elif key == wx.WXK_SHIFT:
577 self.
fly[
'exag'][
'move'] *= self.
fly[
'exagMultiplier']
578 self.
fly[
'exag'][
'turn'] *= self.
fly[
'exagMultiplier']
580 elif key == wx.WXK_ESCAPE
and self.timerFly.IsRunning()
and not self.
fly[
'mouseControl']:
582 self.
fly[
'mouseControl'] =
None
583 self.
render[
'quick'] =
False
586 elif key
in (wx.WXK_UP, wx.WXK_DOWN, wx.WXK_LEFT, wx.WXK_RIGHT):
587 if not self.
fly[
'mouseControl']:
588 if not self.timerFly.IsRunning():
589 sx, sy = self.GetClientSizeTuple()
590 self.
fly[
'pos'][
'x'] = sx / 2
591 self.
fly[
'pos'][
'y'] = sy / 2
592 self.
fly[
'mouseControl'] =
False
593 self.timerFly.Start(self.
fly[
'interval'])
601 elif key == wx.WXK_DOWN:
604 elif key
in (wx.WXK_HOME, wx.WXK_PAGEUP)
and self.timerFly.IsRunning():
606 elif key
in (wx.WXK_END, wx.WXK_PAGEDOWN)
and self.timerFly.IsRunning():
612 """!Process arrow key during fly-through"""
613 step = self.
fly[
'arrowStep']
614 if keyCode == wx.WXK_UP:
615 self.
fly[
'pos'][
'y'] -= step
616 elif keyCode == wx.WXK_DOWN:
617 self.
fly[
'pos'][
'y'] += step
618 elif keyCode == wx.WXK_LEFT:
619 self.
fly[
'pos'][
'x'] -= step
620 elif keyCode == wx.WXK_RIGHT:
621 self.
fly[
'pos'][
'x'] += step
624 """!Key was released.
626 Used for fly-through mode.
628 if not self.
mouse[
'use'] ==
'fly':
631 key = event.GetKeyCode()
632 if key == wx.WXK_CONTROL:
634 elif key == wx.WXK_SHIFT:
635 self.
fly[
'exag'][
'move'] = math.floor(self.
fly[
'exag'][
'move'] / self.
fly[
'exagMultiplier'])
636 self.
fly[
'exag'][
'turn'] = math.floor(self.
fly[
'exag'][
'turn'] / self.
fly[
'exagMultiplier'])
641 """!Handle mouse events"""
643 if event.GetWheelRotation() != 0:
647 elif event.LeftDown():
655 elif event.Dragging():
659 elif event.ButtonDClick():
665 """!Change perspective"""
666 if UserSettings.Get(group =
'display',
667 key =
'mouseWheelZoom',
668 subkey =
'selection') == 2:
672 wheel = event.GetWheelRotation()
673 Debug.msg (5,
"GLWindow.OnMouseMotion(): wheel = %d" % wheel)
674 if self.timerFly.IsRunning()
and self.
fly[
'mouseControl']:
680 if UserSettings.Get(group =
'display',
681 key =
'scrollDirection',
682 subkey =
'selection'):
684 self.
DoZoom(zoomtype = wheel, pos = event.GetPositionTuple())
690 """!On left mouse down"""
691 self.
mouse[
'begin'] = event.GetPositionTuple()
692 self.
mouse[
'tmp'] = event.GetPositionTuple()
693 if self.
mouse[
'use'] ==
"lookHere":
694 size = self.GetClientSize()
695 self._display.LookHere(self.
mouse[
'begin'][0], size[1] - self.
mouse[
'begin'][1])
696 focus = self._display.GetFocus()
697 for i, coord
in enumerate((
'x',
'y',
'z')):
698 self.
iview[
'focus'][coord] = focus[i]
701 toggle = self.lmgr.nviz.FindWindowByName(
'here')
702 toggle.SetValue(
False)
703 self.
mouse[
'use'] =
'pointer'
704 self.SetCursor(self.
cursors[
'default'])
706 if self.
mouse[
'use'] ==
'arrow':
707 pos = event.GetPosition()
708 size = self.GetClientSize()
711 if self.
mouse[
'use'] ==
'scalebar':
712 pos = event.GetPosition()
713 size = self.GetClientSize()
716 if self.
mouse[
'use'] ==
'pointer':
721 if self.
mouse[
'use'] ==
'fly':
722 if not self.timerFly.IsRunning():
723 self.timerFly.Start(self.
fly[
'interval'])
724 self.
fly[
'mouseControl'] =
True
729 if self.
mouse[
'use'] ==
'pointer':
734 if self.
mouse[
'use'] ==
'rotate':
735 dx, dy = event.GetX() - self.
mouse[
'tmp'][0], event.GetY() - self.
mouse[
'tmp'][1]
737 angle, x, y, z = self._display.GetRotationParameters(dx, dy)
738 self._display.Rotate(angle, x, y, z)
740 self.
render[
'quick'] =
True
743 if self.
mouse[
'use'] ==
'pan':
746 self.
mouse[
'tmp'] = event.GetPositionTuple()
751 """!Convert image coordinates to real word coordinates
753 @param x, y image coordinates
755 @return easting, northing
756 @return None on error
758 size = self.GetClientSize()
760 sid, x, y, z = self._display.GetPointOnSurface(x, size[1] - y)
768 """!Change perspective and focus"""
770 prev_value = self.
view[
'persp'][
'value']
772 value = -1 * self.
view[
'persp'][
'step']
774 value = self.
view[
'persp'][
'step']
775 self.
view[
'persp'][
'value'] += value
776 if self.
view[
'persp'][
'value'] < 1:
777 self.
view[
'persp'][
'value'] = 1
778 elif self.
view[
'persp'][
'value'] > 180:
779 self.
view[
'persp'][
'value'] = 180
781 if prev_value != self.
view[
'persp'][
'value']:
782 if hasattr(self.
lmgr,
"nviz"):
783 self.lmgr.nviz.UpdateSettings()
784 x, y = pos[0], self.GetClientSize()[1] - pos[1]
785 result = self._display.GetPointOnSurface(x, y)
787 self._display.LookHere(x, y)
788 focus = self._display.GetFocus()
789 for i, coord
in enumerate((
'x',
'y',
'z')):
790 self.
iview[
'focus'][coord] = focus[i]
791 self._display.SetView(self.
view[
'position'][
'x'], self.
view[
'position'][
'y'],
792 self.
iview[
'height'][
'value'],
793 self.
view[
'persp'][
'value'],
794 self.
view[
'twist'][
'value'])
800 self.
mouse[
'end'] = event.GetPositionTuple()
801 if self.
mouse[
"use"] ==
"query":
803 if self.parent.IsStandalone():
804 GMessage(parent = self.
parent,
805 message = _(
"Querying is not implemented in standalone mode of Map Display"))
810 self.parent.Query(self.
mouse[
'begin'][0],self.
mouse[
'begin'][1], layers)
812 elif self.
mouse[
"use"]
in (
'arrow',
'scalebar'):
813 self.lmgr.nviz.FindWindowById(
814 self.lmgr.nviz.win[
'decoration'][self.
mouse[
"use"]][
'place']).
SetValue(
False)
815 self.
mouse[
'use'] =
'pointer'
816 self.SetCursor(self.
cursors[
'default'])
817 elif self.
mouse[
'use'] ==
'pointer':
819 dx = self.
mouse[
'end'][0] - self.
mouse[
'begin'][0]
820 dy = self.
mouse[
'end'][1] - self.
mouse[
'begin'][1]
823 self.
overlays[self.
dragid].coords = [coords[0] + dx, coords[1] + dy]
826 self.
textdict[self.
dragid][
'coords'] = [coords[0] + dx, coords[1] + dy]
828 self.
render[
'quick'] =
False
831 elif self.
mouse[
'use'] ==
'rotate':
832 self._display.UnsetRotation()
833 self.
iview[
'rotation'] = self._display.GetRotationMatrix()
835 self.
render[
'quick'] =
False
838 elif self.
mouse[
'use'] ==
'pan':
840 self.
render[
'quick'] =
False
843 elif self.
mouse[
'use'] ==
'fly':
844 if self.
fly[
'mouseControl']:
846 self.
fly[
'mouseControl'] =
None
853 self.
render[
'quick'] =
False
856 elif self.
mouse[
'use'] ==
'zoom':
857 self.
DoZoom(zoomtype = self.zoomtype, pos = self.
mouse[
'end'])
861 """!On mouse double click"""
862 if self.
mouse[
'use'] !=
'pointer':
return
863 pos = event.GetPositionTuple()
867 self.parent.AddLegend()
869 self.parent.OnAddText(
None)
874 """!Simulation of panning using focus"""
875 size = self.GetClientSizeTuple()
876 id1, x1, y1, z1 = self._display.GetPointOnSurface(
877 self.
mouse[
'tmp'][0], size[1] - self.
mouse[
'tmp'][1])
878 id2, x2, y2, z2 = self._display.GetPointOnSurface(
879 event.GetX(), size[1] - event.GetY())
880 if id1
and id1 == id2:
881 dx, dy, dz = x2 - x1, y2 - y1, z2 - z1
882 focus = self.
iview[
'focus']
883 focus[
'x'], focus[
'y'], focus[
'z'] = self._display.GetFocus()
891 self.
mouse[
'tmp'] = event.GetPositionTuple()
892 self.
render[
'quick'] =
True
896 """!Move all layers in horizontal (x, y) direction.
899 size = self.GetClientSizeTuple()
900 id1, x1, y1, z1 = self._display.GetPointOnSurface(
901 self.
mouse[
'tmp'][0], size[1] - self.
mouse[
'tmp'][1])
902 id2, x2, y2, z2 = self._display.GetPointOnSurface(
903 event.GetX(), size[1] - event.GetY())
905 if id1
and id1 == id2:
906 dx, dy = x2 - x1, y2 - y1
909 mapLayer = self.tree.GetPyData(item)[0][
'maplayer']
911 data = self.tree.GetPyData(item)[0][
'nviz']
912 if mapLayer.GetType() ==
'raster':
913 data[
'surface'][
'position'][
'x'] += dx
914 data[
'surface'][
'position'][
'y'] += dy
915 data[
'surface'][
'position'][
'update'] =
None
918 evt = wxUpdateProperties(data = data)
919 wx.PostEvent(self, evt)
921 if event.CmdDown()
and id1 == data[
'surface'][
'object'][
'id']:
924 elif mapLayer.GetType() ==
'3d-raster':
925 if 'x' not in data[
'volume'][
'position']:
926 data[
'volume'][
'position'][
'x'] = 0
927 data[
'volume'][
'position'][
'y'] = 0
928 data[
'volume'][
'position'][
'z'] = 0
929 data[
'volume'][
'position'][
'x'] += dx
930 data[
'volume'][
'position'][
'y'] += dy
931 data[
'volume'][
'position'][
'update'] =
None
934 evt = wxUpdateProperties(data = data)
935 wx.PostEvent(self, evt)
937 self.
mouse[
'tmp'] = event.GetPositionTuple()
938 self.
render[
'quick'] =
True
942 """!Drag an overlay decoration item
945 Debug.msg (5,
"GLWindow.DragItem(): id=%d" % id)
946 x, y = self.
mouse[
'tmp']
947 dx = event.GetX() - x
948 dy = event.GetY() - y
951 texture.MoveTexture(dx, dy)
954 self.
render[
'quick'] =
True
957 self.
mouse[
'tmp'] = (event.GetX(), event.GetY())
960 """!Set previous view in history list
964 self.viewhistory.pop()
969 toolbar = self.parent.GetMapToolbar()
970 toolbar.Enable(
'zoomback', enable =
False)
973 self.lmgr.nviz.UpdateState(view = view[0], iview = view[1])
974 self.lmgr.nviz.UpdatePage(
'view')
979 """!Manages a list of last 10 views
981 @param view view dictionary
982 @param iview view dictionary (internal)
984 @return removed history item if exists (or None)
987 hview = copy.deepcopy(view)
988 hiview = copy.deepcopy(iview)
991 self.viewhistory.append((hview, hiview))
994 removed = self.viewhistory.pop(0)
997 Debug.msg(4,
"GLWindow.ViewHistory(): hist=%s, removed=%s" %
1000 Debug.msg(4,
"GLWindow.ViewHistory(): hist=%s" %
1009 toolbar = self.parent.GetMapToolbar()
1010 toolbar.Enable(
'zoomback', enable)
1015 """!Reset view history"""
1019 """!Focus on given point"""
1020 w = self.Map.region[
'w']
1021 s = self.Map.region[
's']
1024 focus = self.
iview[
'focus']
1025 focus[
'x'], focus[
'y'] = e, n
1030 self.
render[
'quick'] =
False
1034 """!Query surface on given position"""
1035 size = self.GetClientSizeTuple()
1036 result = self._display.QueryMap(x, size[1] - y)
1038 self.qpoints.append((result[
'x'], result[
'y'], result[
'z']))
1039 self.log.WriteLog(
"%-30s: %.3f" % (_(
"Easting"), result[
'x']))
1040 self.log.WriteLog(
"%-30s: %.3f" % (_(
"Northing"), result[
'y']))
1041 self.log.WriteLog(
"%-30s: %.3f" % (_(
"Elevation"), result[
'z']))
1044 self.tree.GetPyData(item)[0][
'nviz']
1045 if self.tree.GetPyData(item)[0][
'maplayer'].type ==
'raster' and\
1046 self.tree.GetPyData(item)[0][
'nviz'][
'surface'][
'object'][
'id'] == result[
'id']:
1047 name = self.tree.GetPyData(item)[0][
'maplayer'].name
1048 self.log.WriteLog(
"%-30s: %s" % (_(
"Surface map name"), name))
1049 self.log.WriteLog(
"%-30s: %s" % (_(
"Surface map elevation"), result[
'elevation']))
1050 self.log.WriteLog(
"%-30s: %s" % (_(
"Surface map color"), result[
'color']))
1054 dxy = math.sqrt(pow(prev[0]-curr[0], 2) +
1055 pow(prev[1]-curr[1], 2))
1056 dxyz = math.sqrt(pow(prev[0]-curr[0], 2) +
1057 pow(prev[1]-curr[1], 2) +
1058 pow(prev[2]-curr[2], 2))
1059 self.log.WriteLog(
"%-30s: %.3f" % (_(
"XY distance from previous"), dxy))
1060 self.log.WriteLog(
"%-30s: %.3f" % (_(
"XYZ distance from previous"), dxyz))
1061 self.log.WriteLog(
"%-30s: %.3f" % (_(
"Distance along surface"),
1062 self._display.GetDistanceAlongSurface(result[
'id'],
1066 self.log.WriteLog(
"%-30s: %.3f" % (_(
"Distance along exag. surface"),
1067 self._display.GetDistanceAlongSurface(result[
'id'],
1071 self.log.WriteCmdLog(
'-' * 80)
1073 self.log.WriteLog(_(
"No point on surface"))
1074 self.log.WriteCmdLog(
'-' * 80)
1077 """!Change view settings"""
1078 event = wxUpdateView(zExag = zExag)
1079 wx.PostEvent(self, event)
1082 """!Query vector on given position"""
1083 self.parent.QueryVector(*event.GetPosition())
1086 """!Get current viewdir and viewpoint and set view"""
1089 (view[
'position'][
'x'], view[
'position'][
'y'],
1090 iview[
'height'][
'value']) = self._display.GetViewpointPosition()
1091 for key, val
in zip((
'x',
'y',
'z'), self._display.GetViewdir()):
1092 iview[
'dir'][key] = val
1094 iview[
'dir'][
'use'] =
True
1097 """!Change view settings"""
1107 """!Change view settings"""
1110 if zexag
and 'value' in view[
'z-exag']:
1111 self._display.SetZExag(view[
'z-exag'][
'value'] / iview[
'z-exag'][
'llRatio'])
1113 self._display.SetView(view[
'position'][
'x'], view[
'position'][
'y'],
1114 iview[
'height'][
'value'],
1115 view[
'persp'][
'value'],
1116 view[
'twist'][
'value'])
1118 if iview[
'dir'][
'use']:
1119 self._display.SetViewdir(iview[
'dir'][
'x'], iview[
'dir'][
'y'], iview[
'dir'][
'z'])
1121 elif iview[
'focus'][
'x'] != -1:
1122 self._display.SetFocus(self.
iview[
'focus'][
'x'], self.
iview[
'focus'][
'y'],
1123 self.
iview[
'focus'][
'z'])
1125 if 'rotation' in iview:
1126 if iview[
'rotation']:
1127 self._display.SetRotationMatrix(iview[
'rotation'])
1129 self._display.ResetRotation()
1132 """!Change light settings"""
1134 self._display.SetLight(x = data[
'position'][
'x'], y = data[
'position'][
'y'],
1135 z = data[
'position'][
'z'] / 100., color = data[
'color'],
1136 bright = data[
'bright'] / 100.,
1137 ambient = data[
'ambient'] / 100.)
1138 self._display.DrawLightingModel()
1143 """!Updates the canvas anytime there is a change to the
1144 underlaying images or to the geometry of the canvas.
1146 @param render re-render map composition
1148 start = time.clock()
1152 if self.
render[
'quick']
is False:
1153 self.parent.GetProgressBar().Show()
1154 self.parent.GetProgressBar().
SetRange(2)
1155 self.parent.GetProgressBar().
SetValue(0)
1157 if self.
render[
'quick']
is False:
1158 self.parent.GetProgressBar().
SetValue(1)
1159 self._display.Draw(
False, -1)
1163 elif self.
render[
'quick']
is True:
1165 mode = wxnviz.DRAW_QUICK_SURFACE | wxnviz.DRAW_QUICK_VOLUME
1166 if self.
render[
'vlines']:
1167 mode |= wxnviz.DRAW_QUICK_VLINES
1168 if self.
render[
'vpoints']:
1169 mode |= wxnviz.DRAW_QUICK_VPOINTS
1170 self._display.Draw(
True, mode)
1177 if self.
render[
'quick']
is False:
1178 self._display.DrawFringe()
1180 self._display.DrawArrow()
1182 self._display.DrawScalebar()
1186 self._display.Start2D()
1193 if self.
render[
'quick']
is False:
1194 self.parent.GetProgressBar().
SetValue(2)
1196 self.parent.GetProgressBar().Hide()
1198 Debug.msg(3,
"GLWindow.UpdateMap(): quick = %d, -> time = %g" % \
1199 (self.
render[
'quick'], (stop-start)))
1202 """!Erase the canvas
1204 self._display.EraseMap()
1207 def _getDecorationSize(self):
1208 """!Get initial size of north arrow/scalebar"""
1209 size = self._display.GetLongDim() / 8.
1213 return int(size * coef)/coef
1217 if self._display.SetArrow(pos[0], pos[1],
1220 self._display.DrawArrow()
1223 self.
decoration[
'arrow'][
'position'][
'x'] = pos[0]
1224 self.
decoration[
'arrow'][
'position'][
'y'] = pos[1]
1228 """!Add scale bar, sets properties and draw"""
1231 self.nvizDefault.SetDecorDefaultProp(type =
'scalebar')[
'scalebar'])
1237 ret = self._display.SetScalebar(self.
decoration[
'scalebar'][-1][
'id'], pos[0], pos[1],
1241 self._display.DrawScalebar()
1243 self.
decoration[
'scalebar'][-1][
'position'][
'x'] = pos[0]
1244 self.
decoration[
'scalebar'][-1][
'position'][
'y'] = pos[1]
1248 """!Check if layer (item) is already loaded
1250 @param item layer item
1252 layer = self.tree.GetPyData(item)[0][
'maplayer']
1253 data = self.tree.GetPyData(item)[0][
'nviz']
1258 if layer.type ==
'raster':
1259 if 'object' not in data[
'surface']:
1261 elif layer.type ==
'vector':
1262 if 'object' not in data[
'vlines']
and \
1263 'object' not in data[
'points']:
1268 def _GetDataLayers(self, item, litems):
1269 """!Return get list of enabled map layers"""
1271 while item
and item.IsOk():
1272 type = self.tree.GetPyData(item)[0][
'type']
1274 subItem = self.tree.GetFirstChild(item)[0]
1276 item = self.tree.GetNextSibling(item)
1278 if not item.IsChecked()
or \
1279 type
not in (
'raster',
'vector',
'3d-raster'):
1280 item = self.tree.GetNextSibling(item)
1285 item = self.tree.GetNextSibling(item)
1288 """!Load raster/vector from current layer tree
1296 item = self.tree.GetFirstChild(self.tree.root)[0]
1301 while(len(listOfItems) > 0):
1302 item = listOfItems.pop()
1303 type = self.tree.GetPyData(item)[0][
'type']
1308 if ' ' in self.tree.GetPyData(item)[0][
'maplayer'].name:
1311 if type ==
'raster':
1313 elif type ==
'3d-raster':
1315 elif type ==
'vector':
1316 layer = self.tree.GetPyData(item)[0][
'maplayer']
1317 vInfo = grass.vector_info_topo(layer.GetName())
1318 if (vInfo[
'points']) > 0:
1321 if (vInfo[
'lines'] + vInfo[
'boundaries']) > 0:
1323 if vInfo[
'map3d']
and (vInfo[
'kernels'] + vInfo[
'faces']) > 0:
1326 except GException, e:
1327 GError(parent = self,
1332 Debug.msg(1,
"GLWindow.LoadDataLayers(): time = %f" % (stop-start))
1335 """!Unload any layers that have been deleted from layer tree
1337 @param force True to unload all data layers
1344 item = self.tree.GetFirstChild(self.tree.root)[0]
1350 layersTmp = self.
layers[:]
1351 for layer
in layersTmp:
1352 if layer
in listOfItems:
1354 ltype = self.tree.GetPyData(layer)[0][
'type']
1356 if ltype ==
'raster':
1358 elif ltype ==
'3d-raster':
1360 elif ltype ==
'vector':
1361 maplayer = self.tree.GetPyData(layer)[0][
'maplayer']
1362 vInfo = grass.vector_info_topo(maplayer.GetName())
1363 if (vInfo[
'points'] + vInfo[
'centroids']) > 0:
1365 if (vInfo[
'lines'] + vInfo[
'boundaries']) > 0
or vInfo[
'map3d']:
1368 except GException, e:
1369 GError(parent = self,
1372 if force
and self.
baseId > 0:
1373 ret = self._display.UnloadSurface(self.
baseId)
1376 self.lmgr.nviz.UpdateSettings()
1381 Debug.msg(1,
"GLWindow.UnloadDataLayers(): time = %f" % (stop-start))
1384 """!Set reference surfaces of vector"""
1385 data[
'mode'][
'surface'] = {}
1386 data[
'mode'][
'surface'][
'value'] = list()
1387 data[
'mode'][
'surface'][
'show'] = list()
1389 data[
'mode'][
'surface'][
'value'].append(name)
1390 data[
'mode'][
'surface'][
'show'].append(
True)
1393 """!Set 3D view properties from cmd (d.vect)
1395 @param item Layer Tree item
1398 cmd = self.tree.GetPyData(item)[0][
'cmd']
1399 if cmd[0] !=
'd.vect':
1403 key, value = opt.split(
'=')
1407 data[
'lines'][
'color'][
'value'] = value
1408 data[
'points'][
'color'][
'value'] = value
1411 """!Set map object properties
1413 Properties must be afterwards updated by
1414 UpdateMapObjProperties().
1416 @param item layer item
1417 @param id nviz layer id (or -1)
1418 @param nvizType nviz data type (surface, points, vector)
1420 if nvizType !=
'constant':
1421 mapType = self.tree.GetPyData(item)[0][
'maplayer'].type
1423 data = self.tree.GetPyData(item)[0][
'nviz']
1430 if nvizType !=
'constant':
1431 self.tree.GetPyData(item)[0][
'nviz'] = {}
1432 data = self.tree.GetPyData(item)[0][
'nviz']
1434 if mapType ==
'raster':
1436 data[nvizType] = self.nvizDefault.SetSurfaceDefaultProp()
1438 elif mapType ==
'vector':
1440 data[
'vector'] = self.nvizDefault.SetVectorDefaultProp()
1445 elif mapType ==
'3d-raster':
1447 data[nvizType] = self.nvizDefault.SetVolumeDefaultProp()
1449 elif mapType ==
'constant':
1450 data[
'constant'] = self.nvizDefault.SetConstantDefaultProp()
1454 if mapType ==
'raster':
1455 if not data[
'surface']:
1456 data[
'surface'] = self.nvizDefault.SetSurfaceDefaultProp()
1457 if mapType ==
'vector':
1458 if not data[
'vector'][
'lines']:
1459 self.nvizDefault.SetVectorLinesDefaultProp(data[
'vector'][
'lines'])
1460 if not data[
'vector'][
'points']:
1461 self.nvizDefault.SetVectorPointsDefaultProp(data[
'vector'][
'points'])
1463 for sec
in data.keys():
1464 for sec1
in data[sec].keys():
1465 if sec1 ==
'position':
1466 data[sec][sec1][
'update'] =
None
1468 if type(data[sec][sec1]) == types.DictType:
1469 for sec2
in data[sec][sec1].keys():
1470 if sec2
not in (
'all',
'init',
'id'):
1471 data[sec][sec1][sec2][
'update'] =
None
1472 elif type(data[sec][sec1]) == types.ListType:
1473 for i
in range(len(data[sec][sec1])):
1474 for sec2
in data[sec][sec1][i].keys():
1475 data[sec][sec1][i][sec2][
'update'] =
None
1476 event = wxUpdateProperties(data = data)
1477 wx.PostEvent(self, event)
1481 if mapType
in (
'raster',
'3d-raster'):
1482 data[nvizType][
'object'] = {
'id' : id,
1484 elif mapType ==
'vector':
1485 data[
'vector'][nvizType][
'object'] = {
'id' : id,
1487 elif mapType ==
'constant':
1488 data[nvizType][
'object'] = {
'id' : id,
1494 """!Load 2d raster map and set surface attributes
1501 """!Load 3d raster map and set surface attributes
1507 def _loadRaster(self, item):
1508 """!Load 2d/3d raster map and set its attributes
1512 layer = self.tree.GetPyData(item)[0][
'maplayer']
1514 if layer.type
not in (
'raster',
'3d-raster'):
1517 if layer.type ==
'raster':
1518 id = self._display.LoadSurface(str(layer.name),
None,
None)
1519 nvizType =
'surface'
1520 errorMsg = _(
"Loading raster map")
1521 elif layer.type ==
'3d-raster':
1522 id = self._display.LoadVolume(str(layer.name),
None,
None)
1524 errorMsg = _(
"Loading 3d raster map")
1529 if layer.type
in (
'raster',
'3d-raster'):
1530 self.log.WriteError(
"%s <%s> %s" % (errorMsg, layer.name, _(
"failed")))
1532 self.log.WriteError(_(
"Unsupported layer type '%s'") % layer.type)
1534 self.layers.append(item)
1540 event = wxUpdateProperties(data = data)
1541 wx.PostEvent(self, event)
1544 if hasattr(self.
lmgr,
"nviz")
and \
1546 toolWin = self.lmgr.nviz
1547 if layer.type ==
'raster':
1548 win = toolWin.FindWindowById( \
1549 toolWin.win[
'vector'][
'lines'][
'surface'])
1558 """!Create new constant"""
1561 name = self.
constants[-1][
'constant'][
'object'][
'name'] + 1
1565 self.constants.append(data)
1571 """!Add new constant"""
1572 id = self._display.AddConstant(value = data[
'constant'][
'value'], color = data[
'constant'][
'color'])
1573 self._display.SetSurfaceRes(id, data[
'constant'][
'resolution'], data[
'constant'][
'resolution'])
1574 data[
'constant'][
'object'] = {
'id' : id,
1579 """!Delete constant layer"""
1580 id = self.
constants[index][
'constant'][
'object'][
'id']
1581 self._display.UnloadSurface(id)
1585 """!Select cutting plane"""
1586 for plane
in range (self._display.GetCPlanesCount()):
1588 self._display.SelectCPlane(plane)
1589 self.
cplanes[plane][
'on'] =
True
1590 self._display.SetFenceColor(self.
cplanes[plane][
'shading'])
1592 self._display.UnselectCPlane(plane)
1594 self.
cplanes[plane][
'on'] =
False
1599 """!Change cutting plane settings"""
1603 """!Change cutting plane settings"""
1604 for each
in changes:
1605 if each ==
'rotation':
1606 self._display.SetCPlaneRotation(0, self.
cplanes[index][
'rotation'][
'tilt'],
1607 self.
cplanes[index][
'rotation'][
'rot'])
1608 if each ==
'position':
1609 self._display.SetCPlaneTranslation(self.
cplanes[index][
'position'][
'x'],
1610 self.
cplanes[index][
'position'][
'y'],
1611 self.
cplanes[index][
'position'][
'z'])
1612 if each ==
'shading':
1613 self._display.SetFenceColor(self.
cplanes[index][
'shading'])
1616 """!Unload 2d raster map
1623 """!Unload 3d raster map
1629 def _unloadRaster(self, item):
1630 """!Unload 2d/3d raster map
1632 @param item layer item
1634 layer = self.tree.GetPyData(item)[0][
'maplayer']
1636 if layer.type
not in (
'raster',
'3d-raster'):
1639 data = self.tree.GetPyData(item)[0][
'nviz']
1641 if layer.type ==
'raster':
1642 nvizType =
'surface'
1643 unloadFn = self._display.UnloadSurface
1644 errorMsg = _(
"Unable to unload raster map")
1645 successMsg = _(
"Raster map")
1648 unloadFn = self._display.UnloadVolume
1649 errorMsg = _(
"Unable to unload 3d raster map")
1650 successMsg = _(
"3d raster map")
1653 id = data[nvizType][
'object'][
'id']
1657 if unloadFn(id) == 0:
1658 self.log.WriteError(
"%s <%s>" % (errorMsg, layer.name))
1660 self.log.WriteLog(
"%s <%s> %s" % (successMsg, layer.name, _(
"unloaded successfully")))
1662 data[nvizType].pop(
'object')
1664 self.layers.remove(item)
1667 if hasattr(self.
lmgr,
"nviz"):
1668 toolWin = self.lmgr.nviz
1669 if layer.type ==
'raster':
1670 win = toolWin.FindWindowById(toolWin.win[
'vector'][
'lines'][
'surface'])
1672 win = toolWin.FindWindowById(toolWin.win[
'surface'][
'map'])
1674 if layer.type ==
'3d-raster':
1675 win = toolWin.FindWindowById(toolWin.win[
'volume'][
'map'])
1677 if layer.type ==
'vector':
1678 win = toolWin.FindWindowById(toolWin.win[
'vector'][
'map'])
1682 """!Load 2D or 3D vector map overlay
1684 @param item layer item
1685 @param points True to load points, False to load lines, None
1687 @param append append vector to layer list
1689 layer = self.tree.GetPyData(item)[0][
'maplayer']
1690 if layer.type !=
'vector':
1697 vecTypes = (
'points',
'lines')
1700 vecTypes = (
'points', )
1703 vecTypes = (
'lines', )
1706 for vecType
in vecTypes:
1707 if vecType ==
'lines':
1708 id, baseId = self._display.LoadVector(str(layer.GetName()),
False)
1710 id, baseId = self._display.LoadVector(str(layer.GetName()),
True)
1712 self.log.WriteError(_(
"Loading vector map <%(name)s> (%(type)s) failed") % \
1713 {
'name' : layer.name,
'type' : vecType })
1719 self.layers.append(item)
1722 data = self.tree.GetPyData(item)[0][
'nviz']
1723 event = wxUpdateProperties(data = data)
1724 wx.PostEvent(self, event)
1727 if hasattr(self.
lmgr,
"nviz")
and \
1729 toolWin = self.lmgr.nviz
1731 toolWin.UpdatePage(
'vector')
1737 """!Unload vector map overlay
1739 @param item layer item
1740 @param points,lines True to unload given feature type
1741 @param remove remove layer from list
1743 layer = self.tree.GetPyData(item)[0][
'maplayer']
1744 data = self.tree.GetPyData(item)[0][
'nviz'][
'vector']
1754 vecTypes = (
'points',
'lines')
1756 vecTypes = (
'points', )
1758 vecTypes = (
'lines', )
1760 for vecType
in vecTypes:
1761 if 'object' not in data[vecType]:
1764 id = data[vecType][
'object'][
'id']
1766 if vecType ==
'lines':
1767 ret = self._display.UnloadVector(id,
False)
1769 ret = self._display.UnloadVector(id,
True)
1771 self.log.WriteError(_(
"Unable to unload vector map <%(name)s> (%(type)s)") % \
1772 {
'name': layer.name,
'type' : vecType })
1774 self.log.WriteLog(_(
"Vector map <%(name)s> (%(type)s) unloaded successfully") % \
1775 {
'name' : layer.name,
'type' : vecType })
1777 data[vecType].pop(
'object')
1779 if remove
and item
in self.
layers:
1780 self.layers.remove(item)
1783 """!Reset to default view"""
1785 self.
iview[
'height'][
'value'], \
1786 self.
iview[
'height'][
'min'], \
1787 self.
iview[
'height'][
'max'] = self._display.SetViewDefault()
1791 self.
iview[
'z-exag'][
'llRatio'] = 1
1792 if grass.locn_is_latlong():
1793 self.
iview[
'z-exag'][
'llRatio'] = \
1794 math.pi / 180 * 6371000 * math.cos((grass.region()[
'n'] + grass.region()[
's']) / 2)
1796 self.
view[
'z-exag'][
'value'] =
round(zexagOriginal * self.
iview[
'z-exag'][
'llRatio'])
1797 self.
view[
'z-exag'][
'min'] = UserSettings.Get(group =
'nviz', key =
'view',
1798 subkey = (
'z-exag',
'min'))
1799 zexagMax = UserSettings.Get(group =
'nviz', key =
'view',
1800 subkey = (
'z-exag',
'max'))
1801 if zexagMax <= self.
view[
'z-exag'][
'value']:
1802 self.
view[
'z-exag'][
'max'] = self.
view[
'z-exag'][
'value'] * 2
1803 elif self.
view[
'z-exag'][
'value'] < 1:
1804 if self.
view[
'z-exag'][
'value'] == 0:
1805 self.
view[
'z-exag'][
'value'] = 1
1806 self.
view[
'z-exag'][
'max'] = 10 * self.
view[
'z-exag'][
'value']
1808 self.
view[
'z-exag'][
'max'] = zexagMax
1810 self.
view[
'position'][
'x'] = UserSettings.Get(group =
'nviz', key =
'view',
1811 subkey = (
'position',
'x'))
1812 self.
view[
'position'][
'y'] = UserSettings.Get(group =
'nviz', key =
'view',
1813 subkey = (
'position',
'y'))
1814 self.
view[
'persp'][
'value'] = UserSettings.Get(group =
'nviz', key =
'view',
1815 subkey = (
'persp',
'value'))
1817 self.
view[
'twist'][
'value'] = UserSettings.Get(group =
'nviz', key =
'view',
1818 subkey = (
'twist',
'value'))
1819 self._display.ResetRotation()
1820 self.
iview[
'rotation'] =
None
1821 self._display.LookAtCenter()
1822 focus = self.
iview[
'focus']
1823 focus[
'x'], focus[
'y'], focus[
'z'] = self._display.GetFocus()
1828 """!Generic method to update data layer properties"""
1831 if 'surface' in data:
1833 id = data[
'surface'][
'object'][
'id']
1838 data[
'surface'][
'object'][
'init'] =
True
1840 elif 'constant' in data:
1841 id = data[
'constant'][
'object'][
'id']
1844 data[
'constant'][
'object'][
'init'] =
True
1846 elif 'volume' in data:
1847 id = data[
'volume'][
'object'][
'id']
1850 data[
'volume'][
'object'][
'init'] =
True
1852 elif 'vector' in data:
1853 for type
in (
'lines',
'points'):
1854 if 'object' in data[
'vector'][type]:
1855 id = data[
'vector'][type][
'object'][
'id']
1858 data[
'vector'][type][
'object'][
'init'] =
True
1861 """!Update surface map object properties"""
1862 self._display.SetSurfaceColor(id = id, map =
False, value = data[
'color'])
1863 self._display.SetSurfaceTopo(id = id, map =
False, value = data[
'value'])
1864 self._display.SetSurfaceRes(id, data[
'resolution'], data[
'resolution'])
1865 if data[
'transp'] == 0:
1866 self._display.UnsetSurfaceTransp(id)
1868 self._display.SetSurfaceTransp(id, map =
False, value = data[
'transp'])
1871 """!Update surface map object properties"""
1873 for attrb
in (
'color',
'mask',
1875 if attrb
not in data[
'attribute']
or \
1876 'update' not in data[
'attribute'][attrb]:
1879 map = data[
'attribute'][attrb][
'map']
1880 value = data[
'attribute'][attrb][
'value']
1887 self._display.UnsetSurfaceMask(id)
1888 elif attrb ==
'transp':
1889 self._display.UnsetSurfaceTransp(id)
1891 if type(value) == types.StringType
and \
1894 if attrb ==
'color':
1895 self._display.SetSurfaceColor(id, map, str(value))
1896 elif attrb ==
'mask':
1899 self._display.SetSurfaceMask(id,
False, str(value))
1900 elif attrb ==
'transp':
1901 self._display.SetSurfaceTransp(id, map, str(value))
1902 elif attrb ==
'shine':
1903 self._display.SetSurfaceShine(id, map, str(value))
1904 data[
'attribute'][attrb].pop(
'update')
1907 if 'update' in data[
'draw'][
'resolution']:
1908 coarse = data[
'draw'][
'resolution'][
'coarse']
1909 fine = data[
'draw'][
'resolution'][
'fine']
1911 if data[
'draw'][
'all']:
1912 self._display.SetSurfaceRes(-1, fine, coarse)
1914 self._display.SetSurfaceRes(id, fine, coarse)
1915 data[
'draw'][
'resolution'].pop(
'update')
1918 if 'update' in data[
'draw'][
'mode']:
1919 if data[
'draw'][
'mode'][
'value'] < 0:
1920 data[
'draw'][
'mode'][
'value'] = \
1921 self.nvizDefault.GetDrawMode(mode = data[
'draw'][
'mode'][
'desc'][
'mode'],
1922 style = data[
'draw'][
'mode'][
'desc'][
'style'],
1923 shade = data[
'draw'][
'mode'][
'desc'][
'shading'],
1925 style = data[
'draw'][
'mode'][
'value']
1926 if data[
'draw'][
'all']:
1927 self._display.SetSurfaceStyle(-1, style)
1929 self._display.SetSurfaceStyle(id, style)
1930 data[
'draw'][
'mode'].pop(
'update')
1933 if 'update' in data[
'draw'][
'wire-color']:
1934 color = data[
'draw'][
'wire-color'][
'value']
1935 if data[
'draw'][
'all']:
1936 self._display.SetWireColor(-1, str(color))
1938 self._display.SetWireColor(id, str(color))
1939 data[
'draw'][
'wire-color'].pop(
'update')
1942 if 'update' in data[
'position']:
1943 x = data[
'position'][
'x']
1944 y = data[
'position'][
'y']
1945 z = data[
'position'][
'z']
1946 self._display.SetSurfacePosition(id, x, y, z)
1947 data[
'position'].pop(
'update')
1948 data[
'draw'][
'all'] =
False
1951 """!Update volume (isosurface/slice) map object properties"""
1952 if 'update' in data[
'draw'][
'resolution']:
1953 if data[
'draw'][
'mode'][
'value'] == 0:
1954 self._display.SetIsosurfaceRes(id, data[
'draw'][
'resolution'][
'isosurface'][
'value'])
1956 self._display.SetSliceRes(id, data[
'draw'][
'resolution'][
'slice'][
'value'])
1957 data[
'draw'][
'resolution'].pop(
'update')
1959 if 'update' in data[
'draw'][
'shading']:
1960 if data[
'draw'][
'mode'][
'value'] == 0:
1961 if data[
'draw'][
'shading'][
'isosurface'][
'value'] < 0:
1962 mode = data[
'draw'][
'shading'][
'isosurface'][
'value'] = \
1963 self.nvizDefault.GetDrawMode(shade = data[
'draw'][
'shading'][
'isosurface'],
1965 self._display.SetIsosurfaceMode(id, mode)
1967 if data[
'draw'][
'shading'][
'slice'][
'value'] < 0:
1968 mode = data[
'draw'][
'shading'][
'slice'][
'value'] = \
1969 self.nvizDefault.GetDrawMode(shade = data[
'draw'][
'shading'][
'slice'],
1971 self._display.SetSliceMode(id, mode)
1972 data[
'draw'][
'shading'].pop(
'update')
1978 for isosurf
in data[
'isosurface']:
1979 self._display.AddIsosurface(id, 0, isosurf_id = isosurfId)
1980 for attrb
in (
'topo',
'color',
'mask',
1982 if attrb
not in isosurf
or \
1983 'update' not in isosurf[attrb]:
1985 map = isosurf[attrb][
'map']
1986 value = isosurf[attrb][
'value']
1990 if attrb ==
'topo' :
1991 self._display.SetIsosurfaceTopo(id, isosurfId, map, str(value))
1992 elif attrb ==
'mask':
1995 self._display.UnsetIsosurfaceMask(id, isosurfId)
1996 elif attrb ==
'transp':
1997 self._display.UnsetIsosurfaceTransp(id, isosurfId)
1999 if type(value) == types.StringType
and \
2002 elif attrb ==
'color':
2003 self._display.SetIsosurfaceColor(id, isosurfId, map, str(value))
2004 elif attrb ==
'mask':
2007 self._display.SetIsosurfaceMask(id, isosurfId,
False, str(value))
2008 elif attrb ==
'transp':
2009 self._display.SetIsosurfaceTransp(id, isosurfId, map, str(value))
2010 elif attrb ==
'shine':
2011 self._display.SetIsosurfaceShine(id, isosurfId, map, str(value))
2012 isosurf[attrb].pop(
'update')
2018 for slice
in data[
'slice']:
2019 ret = self._display.AddSlice(id, slice_id = sliceId)
2020 if 'update' in slice[
'position']:
2021 pos = slice[
'position']
2022 ret = self._display.SetSlicePosition(id, sliceId, pos[
'x1'], pos[
'x2'],
2023 pos[
'y1'], pos[
'y2'], pos[
'z1'], pos[
'z2'], pos[
'axis'])
2025 slice[
'position'].pop(
'update')
2026 if 'update' in slice[
'transp']:
2027 tr = slice[
'transp'][
'value']
2028 self._display.SetSliceTransp(id, sliceId, tr)
2032 if 'update' in data[
'position']
and 'x' in data[
'position']:
2033 x = data[
'position'][
'x']
2034 y = data[
'position'][
'y']
2035 z = data[
'position'][
'z']
2036 self._display.SetVolumePosition(id, x, y, z)
2037 data[
'position'].pop(
'update')
2040 """!Update vector layer properties
2043 @param data properties
2044 @param type lines/points
2046 if type ==
'points':
2052 """!Update vector line map object properties"""
2054 if 'update' in data[
'color']
or \
2055 'update' in data[
'width']
or \
2056 'update' in data[
'mode']:
2057 width = data[
'width'][
'value']
2058 color = data[
'color'][
'value']
2059 if data[
'mode'][
'type'] ==
'flat':
2061 if 'surface' in data[
'mode']:
2062 data[
'mode'].pop(
'surface')
2066 self._display.SetVectorLineMode(id, color,
2069 if 'update' in data[
'color']:
2070 data[
'color'].pop(
'update')
2071 if 'update' in data[
'width']:
2072 data[
'width'].pop(
'update')
2075 if 'update' in data[
'height']:
2076 self._display.SetVectorLineHeight(id,
2077 data[
'height'][
'value'])
2078 data[
'height'].pop(
'update')
2081 if 'surface' in data[
'mode']
and 'update' in data[
'mode']:
2082 for item
in range(len(data[
'mode'][
'surface'][
'value'])):
2083 for type
in (
'raster',
'constant'):
2085 name = data[
'mode'][
'surface'][
'value'][item])
2087 if data[
'mode'][
'surface'][
'show'][item]:
2088 self._display.SetVectorLineSurface(id, sid)
2090 self._display.UnsetVectorLineSurface(id, sid)
2093 if 'update' in data[
'mode']:
2094 data[
'mode'].pop(
'update')
2097 """!Update vector point map object properties"""
2098 if 'update' in data[
'size']
or \
2099 'update' in data[
'width']
or \
2100 'update' in data[
'marker']
or \
2101 'update' in data[
'color']:
2103 ret = self._display.SetVectorPointMode(id, data[
'color'][
'value'],
2104 data[
'width'][
'value'], float(data[
'size'][
'value']),
2105 data[
'marker'][
'value'] + 1)
2109 error = _(
"Vector point layer not found (id = %d)") % id
2111 error = _(
"Unable to set data layer properties (id = %d)") % id
2114 raise GException(_(
"Setting data layer properties failed.\n\n%s") % error)
2116 for prop
in (
'size',
'width',
'marker',
'color'):
2117 if 'update' in data[prop]:
2118 data[prop].pop(
'update')
2121 if 'update' in data[
'height']:
2122 self._display.SetVectorPointHeight(id,
2123 data[
'height'][
'value'])
2124 data[
'height'].pop(
'update')
2127 if 'update' in data[
'mode']:
2128 if data[
'mode'].get(
'3d',
False):
2129 self._display.SetVectorPointZMode(id,
True)
2130 elif 'surface' in data[
'mode']:
2131 self._display.SetVectorPointZMode(id,
False)
2132 for item
in range(len(data[
'mode'][
'surface'][
'value'])):
2133 for type
in (
'raster',
'constant'):
2135 name=data[
'mode'][
'surface'][
'value'][item])
2137 if data[
'mode'][
'surface'][
'show'][item]:
2138 self._display.SetVectorPointSurface(id, sid)
2140 self._display.UnsetVectorPointSurface(id, sid)
2142 data[
'mode'].pop(
'update')
2145 """!Return list of map layer names of given type"""
2148 if type ==
'constant':
2150 layerName.append(_(
"constant#") + str(item[
'constant'][
'object'][
'name']))
2153 mapLayer = self.tree.GetPyData(item)[0][
'maplayer']
2154 if type != mapLayer.GetType():
2157 layerName.append(mapLayer.GetName())
2162 """!Get layer object id or -1"""
2166 if type ==
'constant':
2168 if _(
"constant#") + str(item[
'constant'][
'object'][
'name']) == name:
2169 return item[
'constant'][
'object'][
'id']
2173 mapLayer = self.tree.GetPyData(item)[0][
'maplayer']
2174 if type != mapLayer.GetType()
or \
2175 name != mapLayer.GetName():
2178 data = self.tree.GetPyData(item)[0][
'nviz']
2181 if type ==
'raster':
2182 return data[
'surface'][
'object'][
'id']
2183 elif type ==
'vector':
2184 if vsubtyp ==
'vpoint':
2185 return data[
'vector'][
'points'][
'object'][
'id']
2186 elif vsubtyp ==
'vline':
2187 return data[
'vector'][
'lines'][
'object'][
'id']
2188 elif type ==
'3d-raster':
2189 return data[
'volume'][
'object'][
'id']
2195 """!Delete nviz data of all loaded layers and reload them from current settings"""
2197 type = self.tree.GetPyData(item)[0][
'type']
2198 layer = self.tree.GetPyData(item)[0][
'maplayer']
2199 data = self.tree.GetPyData(item)[0][
'nviz']
2201 if type ==
'raster':
2202 self.nvizDefault.SetSurfaceDefaultProp(data[
'surface'])
2203 if type ==
'vector':
2204 vInfo = grass.vector_info_topo(layer.GetName())
2205 if (vInfo[
'points'] + vInfo[
'centroids']) > 0:
2206 self.nvizDefault.SetVectorPointsDefaultProp(data[
'vector'][
'points'])
2207 if (vInfo[
'lines'] + vInfo[
'boundaries']) > 0:
2208 self.nvizDefault.SetVectorLinesDefaultProp(data[
'vector'][
'lines'])
2211 """!Generate command for m.nviz.image according to current state"""
2212 cmd =
'm.nviz.image '
2218 if self.tree.GetPyData(item)[0][
'type'] ==
'raster':
2219 rasters.append(item)
2220 elif self.tree.GetPyData(item)[0][
'type'] ==
'3d-raster':
2221 volumes.append(item)
2222 elif self.tree.GetPyData(item)[0][
'type'] ==
'vector':
2223 vectors.append(item)
2225 return _(
"At least one raster map required")
2228 subcmd =
"elevation_value="
2230 subcmd +=
"%d," % constant[
'constant'][
'value']
2231 subcmd = subcmd.strip(
', ') +
' '
2234 subcmd =
"elevation_map="
2235 for item
in rasters:
2236 subcmd +=
"%s," % self.tree.GetPyData(item)[0][
'maplayer'].GetName()
2237 subcmd = subcmd.strip(
', ') +
' '
2243 cmdFine =
"resolution_fine="
2244 cmdCoarse =
"resolution_coarse="
2245 cmdShading =
"shading="
2247 cmdWire =
"wire_color="
2250 nvizDataFirst = self.tree.GetPyData(rasters[0])[0][
'nviz'][
'surface'][
'draw']
2251 for item
in rasters:
2252 nvizData = self.tree.GetPyData(item)[0][
'nviz'][
'surface'][
'draw']
2253 if nvizDataFirst != nvizData:
2256 for item
in rasters:
2257 nvizData = self.tree.GetPyData(item)[0][
'nviz'][
'surface'][
'draw']
2259 cmdMode +=
"%s," % nvizData[
'mode'][
'desc'][
'mode']
2260 cmdFine +=
"%s," % nvizData[
'resolution'][
'fine']
2261 cmdCoarse +=
"%s," % nvizData[
'resolution'][
'coarse']
2262 cmdShading +=
"%s," % nvizData[
'mode'][
'desc'][
'shading']
2263 cmdStyle +=
"%s," % nvizData[
'mode'][
'desc'][
'style']
2264 cmdWire +=
"%s," % nvizData[
'wire-color'][
'value']
2267 cmdFine +=
"%s," % item[
'constant'][
'resolution']
2268 cmdCoarse +=
"%s," % item[
'constant'][
'resolution']
2269 cmdShading +=
"gouraud,"
2270 cmdStyle +=
"surface,"
2273 for subcmd
in (cmdMode, cmdFine, cmdCoarse, cmdShading, cmdStyle, cmdWire):
2275 mode.append(subcmd.split(
',')[0] +
' ')
2277 subcmd = subcmd.strip(
', ') +
' '
2281 if 'fine' in mode[0]:
2283 elif 'coarse' in mode[0]:
2285 elif 'both' in mode[0]:
2288 if 'flat' in mode[3]:
2290 if 'wire' in mode[4]:
2292 if 'coarse' in mode[0]
or 'both' in mode[0]
and 'wire' in mode[3]:
2297 cmdColorMap =
"color_map="
2298 cmdColorVal =
"color="
2299 for item
in rasters:
2300 nvizData = self.tree.GetPyData(item)[0][
'nviz'][
'surface'][
'attribute']
2301 if 'color' not in nvizData:
2302 cmdColorMap +=
"%s," % self.tree.GetPyData(item)[0][
'maplayer'].GetName()
2304 if nvizData[
'color'][
'map']:
2305 cmdColorMap +=
"%s," % nvizData[
'color'][
'value']
2307 cmdColorVal +=
"%s," % nvizData[
'color'][
'value']
2311 cmdColorVal +=
"%s," % item[
'constant'][
'color']
2312 if cmdColorMap.split(
"=")[1]:
2313 cmd += cmdColorMap.strip(
', ') +
' '
2314 if cmdColorVal.split(
"=")[1]:
2315 cmd += cmdColorVal.strip(
', ') +
' '
2321 cmdLines = cmdLWidth = cmdLHeight = cmdLColor = cmdLMode = cmdLPos = \
2322 cmdPoints = cmdPWidth = cmdPSize = cmdPColor = cmdPMarker = cmdPPos = cmdPLayer =
""
2323 markers = [
'x',
'box',
'sphere',
'cube',
'diamond',
2324 'dec_tree',
'con_tree',
'aster',
'gyro',
'histogram']
2325 for vector
in vectors:
2326 layerName = self.tree.GetPyData(vector)[0][
'maplayer'].GetName()
2327 vInfo = grass.vector_info_topo(layerName)
2328 nvizData = self.tree.GetPyData(vector)[0][
'nviz'][
'vector']
2329 if (vInfo[
'lines'] + vInfo[
'boundaries']) > 0:
2330 cmdLines +=
"%s," % self.tree.GetPyData(vector)[0][
'maplayer'].GetName()
2331 cmdLWidth +=
"%d," % nvizData[
'lines'][
'width'][
'value']
2332 cmdLHeight +=
"%d," % nvizData[
'lines'][
'height'][
'value']
2333 cmdLColor +=
"%s," % nvizData[
'lines'][
'color'][
'value']
2334 cmdLMode +=
"%s," % nvizData[
'lines'][
'mode'][
'type']
2335 cmdLPos +=
"0,0,%d," % nvizData[
'lines'][
'height'][
'value']
2336 if (vInfo[
'points'] + vInfo[
'centroids']) > 0:
2337 cmdPoints +=
"%s," % self.tree.GetPyData(vector)[0][
'maplayer'].GetName()
2338 cmdPWidth +=
"%d," % nvizData[
'points'][
'width'][
'value']
2339 cmdPSize +=
"%d," % nvizData[
'points'][
'size'][
'value']
2340 cmdPColor +=
"%s," % nvizData[
'points'][
'color'][
'value']
2341 cmdPMarker +=
"%s," % markers[nvizData[
'points'][
'marker'][
'value']]
2342 cmdPPos +=
"0,0,%d," % nvizData[
'points'][
'height'][
'value']
2345 cmd +=
"vline=" + cmdLines.strip(
',') +
' '
2346 cmd +=
"vline_width=" + cmdLWidth.strip(
',') +
' '
2347 cmd +=
"vline_color=" + cmdLColor.strip(
',') +
' '
2348 cmd +=
"vline_height=" + cmdLHeight.strip(
',') +
' '
2349 cmd +=
"vline_mode=" + cmdLMode.strip(
',') +
' '
2350 cmd +=
"vline_position=" + cmdLPos.strip(
',') +
' '
2352 cmd +=
"vpoint=" + cmdPoints.strip(
',') +
' '
2353 cmd +=
"vpoint_width=" + cmdPWidth.strip(
',') +
' '
2354 cmd +=
"vpoint_color=" + cmdPColor.strip(
',') +
' '
2355 cmd +=
"vpoint_size=" + cmdPSize.strip(
',') +
' '
2356 cmd +=
"vpoint_marker=" + cmdPMarker.strip(
',') +
' '
2357 cmd +=
"vpoint_position=" + cmdPPos.strip(
',') +
' '
2364 cmdName = cmdShade = cmdRes = cmdPos = cmdIso =
""
2365 cmdIsoColorMap = cmdIsoColorVal = cmdIsoTrMap = cmdIsoTrVal =
""
2366 cmdSlice = cmdSliceTransp = cmdSlicePos =
""
2367 for i, volume
in enumerate(volumes):
2368 nvizData = self.tree.GetPyData(volume)[0][
'nviz'][
'volume']
2369 cmdName +=
"%s," % self.tree.GetPyData(volume)[0][
'maplayer'].GetName()
2370 cmdShade +=
"%s," % nvizData[
'draw'][
'shading'][
'isosurface'][
'desc']
2371 cmdRes +=
"%d," % nvizData[
'draw'][
'resolution'][
'isosurface'][
'value']
2372 if nvizData[
'position']:
2373 cmdPos +=
"%d,%d,%d," % (nvizData[
'position'][
'x'], nvizData[
'position'][
'y'],
2374 nvizData[
'position'][
'z'])
2375 for iso
in nvizData[
'isosurface']:
2376 level = iso[
'topo'][
'value']
2377 cmdIso +=
"%d:%s," % (i + 1, level)
2378 if iso[
'color'][
'map']:
2379 cmdIsoColorMap +=
"%s," % iso[
'color'][
'value']
2381 cmdIsoColorVal +=
"%s," % iso[
'color'][
'value']
2383 if iso[
'transp'][
'map']:
2384 cmdIsoTrMap +=
"%s," % iso[
'transp'][
'value']
2386 cmdIsoTrVal +=
"%s," % iso[
'transp'][
'value']
2388 for slice
in nvizData[
'slice']:
2389 axis = (
'x',
'y',
'z')[slice[
'position'][
'axis']]
2390 cmdSlice +=
"%d:%s," % (i + 1, axis)
2391 for coord
in (
'x1',
'x2',
'y1',
'y2',
'z1',
'z2'):
2392 cmdSlicePos +=
"%f," % slice[
'position'][coord]
2393 cmdSliceTransp +=
"%s," % slice[
'transp'][
'value']
2395 cmd +=
"volume=" + cmdName.strip(
',') +
' '
2396 cmd +=
"volume_shading=" + cmdShade.strip(
',') +
' '
2397 cmd +=
"volume_resolution=" + cmdRes.strip(
',') +
' '
2398 if nvizData[
'position']:
2399 cmd +=
"volume_position=" + cmdPos.strip(
',') +
' '
2401 cmd +=
"isosurf_level=" + cmdIso.strip(
',') +
' '
2403 cmd +=
"isosurf_color_map=" + cmdIsoColorMap.strip(
',') +
' '
2405 cmd +=
"isosurf_color_value=" + cmdIsoColorVal.strip(
',') +
' '
2407 cmd +=
"isosurf_transparency_map=" + cmdIsoTrMap.strip(
',') +
' '
2409 cmd +=
"isosurf_transparency_value=" + cmdIsoTrVal.strip(
',') +
' '
2411 cmd +=
"slice=" + cmdSlice.strip(
',') +
' '
2412 cmd +=
"slice_position=" + cmdSlicePos.strip(
',') +
' '
2413 cmd +=
"slice_transparency=" + cmdSliceTransp.strip(
',') +
' '
2418 cplane = self.lmgr.nviz.FindWindowById(self.lmgr.nviz.win[
'cplane'][
'planes']).GetStringSelection()
2420 planeIndex = int(cplane.split()[-1]) - 1
2421 except (IndexError, ValueError):
2423 if planeIndex
is not None:
2424 shading = [
'clear',
'top',
'bottom',
'blend',
'shaded']
2425 cmd +=
"cplane=%d " % planeIndex
2426 cmd +=
"cplane_rotation=%d " % self.
cplanes[planeIndex][
'rotation'][
'rot']
2427 cmd +=
"cplane_tilt=%d " % self.
cplanes[planeIndex][
'rotation'][
'tilt']
2428 cmd +=
"cplane_position=%d,%d,%d " % (self.
cplanes[planeIndex][
'position'][
'x'],
2429 self.
cplanes[planeIndex][
'position'][
'y'],
2430 self.
cplanes[planeIndex][
'position'][
'z'])
2431 cmd +=
"cplane_shading=%s " % shading[self.
cplanes[planeIndex][
'shading']]
2436 subcmd =
"position=%.2f,%.2f " % (self.
view[
'position'][
'x'], self.
view[
'position'][
'y'])
2437 subcmd +=
"height=%d " % (self.
iview[
'height'][
'value'])
2438 subcmd +=
"perspective=%d " % (self.
view[
'persp'][
'value'])
2439 subcmd +=
"twist=%d " % (self.
view[
'twist'][
'value'])
2440 subcmd +=
"zexag=%f " % (self.
view[
'z-exag'][
'value'] / self.
iview[
'z-exag'][
'llRatio'])
2441 subcmd +=
"focus=%d,%d,%d " % (self.
iview[
'focus'][
'x'],self.
iview[
'focus'][
'y'],self.
iview[
'focus'][
'z'])
2445 subcmd =
"bgcolor=%d:%d:%d " % (self.
view[
'background'][
'color'][:3])
2446 if self.
view[
'background'][
'color'] != (255, 255, 255):
2450 subcmd =
"light_position=%.2f,%.2f,%.2f " % (self.
light[
'position'][
'x'],
2451 self.
light[
'position'][
'y'],
2452 self.
light[
'position'][
'z']/100.)
2453 subcmd +=
"light_brightness=%d " % (self.
light[
'bright'])
2454 subcmd +=
"light_ambient=%d " % (self.
light[
'ambient'])
2455 subcmd +=
"light_color=%d:%d:%d " % (self.
light[
'color'][:3])
2459 toolWindow = self.lmgr.nviz
2461 for dir
in (
'nw',
'ne',
'sw',
'se'):
2462 if toolWindow.FindWindowById(toolWindow.win[
'fringe'][dir]).IsChecked():
2463 direction +=
"%s," % dir
2465 subcmd =
"fringe=%s " % (direction.strip(
','))
2466 color = toolWindow.FindWindowById(toolWindow.win[
'fringe'][
'color']).
GetValue()
2467 subcmd +=
"fringe_color=%d:%d:%d " % (color[0], color[1], color[2])
2468 subcmd +=
"fringe_elevation=%d " % (toolWindow.FindWindowById(toolWindow.win[
'fringe'][
'elev']).
GetValue())
2473 subcmd =
"arrow_position=%d,%d " % (self.
decoration[
'arrow'][
'position'][
'x'],
2475 subcmd +=
"arrow_color=%s " % self.
decoration[
'arrow'][
'color']
2476 subcmd +=
"arrow_size=%d " % self.
decoration[
'arrow'][
'size']
2480 subcmd =
'output=nviz_output '
2481 subcmd +=
'format=ppm '
2482 subcmd +=
'size=%d,%d ' % self.GetClientSizeTuple()
2488 """!Generate and write command to command output"""
2492 """!This draws the DC to a buffer that can be saved to a file.
2494 @todo fix BufferedPaintDC
2496 @param FileName file name
2497 @param FileType type of bitmap
2498 @param width image width
2499 @param height image height
2501 self._display.SaveToFile(FileName, width, height, FileType)
2512 """!Get display instance"""
2518 self.lmgr.nviz.OnResetView(
None)
2521 """!Return text boundary data
2523 @param textinfo text metadata (text, font, color, rotation)
2525 return self.parent.MapWindow2D.TextBounds(textinfo, relcoords =
True)
def UpdateSurfaceProperties
Update surface map object properties.
def _loadRaster
Load 2d/3d raster map and set its attributes.
def ChangeInnerView
Get current viewdir and viewpoint and set view.
def QuerySurface
Query surface on given position.
def ReloadLayersData
Delete nviz data of all loaded layers and reload them from current settings.
def NvizCmdCommand
Generate command for m.nviz.image according to current state.
Abstract map display window class.
wxNviz workspace settings
def UpdateVectorLinesProperties
Update vector line map object properties.
def OnDClick
On mouse double click.
def CheckWxVersion
Check wx version.
def LoadVector
Load 2D or 3D vector map overlay.
def ChangeFlySpeed
Increase/decrease flight spped.
def _unloadRaster
Unload 2d/3d raster map.
def PostViewEvent
Change view settings.
def OnMouseWheel
Change perspective.
def GetSelectedLayer
Get selected layer from layer tree.
def OnMouseAction
Handle mouse events.
Map display canvas - base class for buffered window.
def DrawImages
Draw overlay image.
Class representing OpenGL texture as an overlay image.
def OnQueryVector
Query vector on given position.
def OnMotion
Tracks mouse motion and update statusbar.
Class representing OpenGL texture as a text label.
def UnloadRaster3d
Unload 3d raster map.
def OnUpdateView
Change view settings.
def HorizontalPanning
Move all layers in horizontal (x, y) direction.
def GetLayerNames
Return list of map layer names of given type.
def NewConstant
Create new constant.
def UpdateVolumeProperties
Update volume (isosurface/slice) map object properties.
def GetDisplay
Get display instance.
def GetLegendRect
Estimates legend size for dragging.
def SetToolWin
Sets reference to nviz toolwindow in layer manager.
def GetToolWin
Returns reference to nviz toolwindow in layer manager.
def FocusPanning
Simulation of panning using focus.
def InitCPlanes
Initialize cutting planes list.
def split
Platform spefic shlex.split.
def UpdateConstantProperties
Update surface map object properties.
def OnKeyDown
Key was pressed.
def CreateTexture
Create texture from overlay image or from textdict.
def TextBounds
Return text boundary data.
def UpdateLight
Change light settings.
def ProcessFlyByArrows
Process arrow key during fly-through.
def UnloadRaster
Unload 2d raster map.
def DeleteConstant
Delete constant layer.
def EraseMap
Erase the canvas.
def ResetView
Reset to default view.
def SetVectorFromCmd
Set 3D view properties from cmd (d.vect)
def UpdateOverlays
Converts rendered overlay files and text labels to wx.Image and then to textures so that they can be ...
def LoadRaster3d
Load 3d raster map and set surface attributes.
def StopTimer
Stop timer if running.
def SelectCPlane
Select cutting plane.
def SaveToFile
This draws the DC to a buffer that can be saved to a file.
def _GetDataLayers
Return get list of enabled map layers.
def ZoomBack
Set previous view in history list.
def __del__
Stop timers if running, unload data.
def ViewHistory
Manages a list of last 10 views.
def UnloadVector
Unload vector map overlay.
def IsLoaded
Check if layer (item) is already loaded.
def DrawTextImage
Draw overlay text.
def UpdateVectorProperties
Update vector layer properties.
def SetMapObjProperties
Set map object properties.
def InitFly
Initialize fly through dictionary.
def GetDisplay
Get display instance.
def LoadRaster
Load 2d raster map and set surface attributes.
def ResetViewHistory
Reset view history.
def UnloadDataLayers
Unload any layers that have been deleted from layer tree.
def UpdateVectorPointsProperties
Update vector point map object properties.
def _getDecorationSize
Get initial size of north arrow/scalebar.
Global variables used by wxGUI.
def SetVectorSurface
Set reference surfaces of vector.
def OnUpdateCPlane
Change cutting plane settings.
def SetDrawScalebar
Add scale bar, sets properties and draw.
def ComputeMxMy
Compute values for flythrough navigation (ComputeFlyValues should follow).
def OnNvizCmd
Generate and write command to command output.
def OnKeyUp
Key was released.
def UpdateView
Change view settings.
def UpdateMap
Updates the canvas anytime there is a change to the underlaying images or to the geometry of the canv...
def Pixel2Cell
Convert image coordinates to real word coordinates.
def LoadDataLayers
Load raster/vector from current layer tree.
def OnTimerFly
Fly event was emitted, move the scene.
def GoTo
Focus on given point.
def GetLayerId
Get layer object id or -1.
Nviz (3D view) animation.
OpenGL canvas for Map Display Window.
def ComputeFlyValues
Compute parameters for fly-through navigation.
def UpdateCPlane
Change cutting plane settings.
def OnLeftDown
On left mouse down.
def DragItem
Drag an overlay decoration item.
def AddConstant
Add new constant.
def UpdateMapObjProperties
Generic method to update data layer properties.
def DoZoom
Change perspective and focus.