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()][
'layer'].IsActive():
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 layer = overlay[
'layer']
496 if not layer.IsActive()
or oid == 0:
498 if oid
not in [t.GetId()
for t
in self.
imagelist]:
503 if not t.Corresponds(layer):
504 self.imagelist.remove(t)
507 t.SetCoords(overlay[
'coords'])
511 for textId
in self.textdict.keys():
512 if textId
not in [t.GetId()
for t
in self.
imagelist]:
516 if t.GetId() == textId:
517 self.
textdict[textId][
'bbox'] = t.textDict[
'bbox']
518 if not t.Corresponds(self.
textdict[textId]):
519 self.imagelist.remove(t)
522 t.SetCoords(self.
textdict[textId][
'coords'])
525 """!Create texture from overlay image or from textdict"""
528 coords = list(self.
overlays[overlay.id][
'coords']),
529 cmd = overlay.GetCmd())
534 self.
textdict[textId][
'coords'] = coords
535 self.
textdict[textId][
'bbox'] = bbox
538 coords = coords, textDict = self.
textdict[textId])
539 bbox.OffsetXY(*relCoords)
540 texture.SetBounds(bbox)
542 if not texture.textureId:
543 GMessage(parent = self, message =
544 _(
"Image is too large, your OpenGL implementation "
545 "supports maximum texture size %d px.") % texture.maxSize)
548 self.imagelist.append(texture)
553 """Find object which was clicked on"""
555 if texture.HitTest(mouseX, mouseY, radius):
560 self.animation.Update()
568 Used for fly-through mode.
570 if not self.
mouse[
'use'] ==
'fly':
573 key = event.GetKeyCode()
574 if key == wx.WXK_CONTROL:
577 elif key == wx.WXK_SHIFT:
578 self.
fly[
'exag'][
'move'] *= self.
fly[
'exagMultiplier']
579 self.
fly[
'exag'][
'turn'] *= self.
fly[
'exagMultiplier']
581 elif key == wx.WXK_ESCAPE
and self.timerFly.IsRunning()
and not self.
fly[
'mouseControl']:
583 self.
fly[
'mouseControl'] =
None
584 self.
render[
'quick'] =
False
587 elif key
in (wx.WXK_UP, wx.WXK_DOWN, wx.WXK_LEFT, wx.WXK_RIGHT):
588 if not self.
fly[
'mouseControl']:
589 if not self.timerFly.IsRunning():
590 sx, sy = self.GetClientSizeTuple()
591 self.
fly[
'pos'][
'x'] = sx / 2
592 self.
fly[
'pos'][
'y'] = sy / 2
593 self.
fly[
'mouseControl'] =
False
594 self.timerFly.Start(self.
fly[
'interval'])
602 elif key == wx.WXK_DOWN:
605 elif key
in (wx.WXK_HOME, wx.WXK_PAGEUP)
and self.timerFly.IsRunning():
607 elif key
in (wx.WXK_END, wx.WXK_PAGEDOWN)
and self.timerFly.IsRunning():
613 """!Process arrow key during fly-through"""
614 step = self.
fly[
'arrowStep']
615 if keyCode == wx.WXK_UP:
616 self.
fly[
'pos'][
'y'] -= step
617 elif keyCode == wx.WXK_DOWN:
618 self.
fly[
'pos'][
'y'] += step
619 elif keyCode == wx.WXK_LEFT:
620 self.
fly[
'pos'][
'x'] -= step
621 elif keyCode == wx.WXK_RIGHT:
622 self.
fly[
'pos'][
'x'] += step
625 """!Key was released.
627 Used for fly-through mode.
629 if not self.
mouse[
'use'] ==
'fly':
632 key = event.GetKeyCode()
633 if key == wx.WXK_CONTROL:
635 elif key == wx.WXK_SHIFT:
636 self.
fly[
'exag'][
'move'] = math.floor(self.
fly[
'exag'][
'move'] / self.
fly[
'exagMultiplier'])
637 self.
fly[
'exag'][
'turn'] = math.floor(self.
fly[
'exag'][
'turn'] / self.
fly[
'exagMultiplier'])
642 """!Handle mouse events"""
644 if event.GetWheelRotation() != 0:
648 elif event.LeftDown():
656 elif event.Dragging():
660 elif event.ButtonDClick():
666 """!Change perspective"""
667 if UserSettings.Get(group =
'display',
668 key =
'mouseWheelZoom',
669 subkey =
'selection') == 2:
673 wheel = event.GetWheelRotation()
674 Debug.msg (5,
"GLWindow.OnMouseMotion(): wheel = %d" % wheel)
675 if self.timerFly.IsRunning()
and self.
fly[
'mouseControl']:
681 if UserSettings.Get(group =
'display',
682 key =
'scrollDirection',
683 subkey =
'selection'):
685 self.
DoZoom(zoomtype = wheel, pos = event.GetPositionTuple())
691 """!On left mouse down"""
692 self.
mouse[
'begin'] = event.GetPositionTuple()
693 self.
mouse[
'tmp'] = event.GetPositionTuple()
694 if self.
mouse[
'use'] ==
"lookHere":
695 size = self.GetClientSize()
696 self._display.LookHere(self.
mouse[
'begin'][0], size[1] - self.
mouse[
'begin'][1])
697 focus = self._display.GetFocus()
698 for i, coord
in enumerate((
'x',
'y',
'z')):
699 self.
iview[
'focus'][coord] = focus[i]
702 toggle = self.lmgr.nviz.FindWindowByName(
'here')
703 toggle.SetValue(
False)
704 self.
mouse[
'use'] =
'pointer'
705 self.SetCursor(self.
cursors[
'default'])
707 if self.
mouse[
'use'] ==
'arrow':
708 pos = event.GetPosition()
709 size = self.GetClientSize()
712 if self.
mouse[
'use'] ==
'scalebar':
713 pos = event.GetPosition()
714 size = self.GetClientSize()
717 if self.
mouse[
'use'] ==
'pointer':
722 if self.
mouse[
'use'] ==
'fly':
723 if not self.timerFly.IsRunning():
724 self.timerFly.Start(self.
fly[
'interval'])
725 self.
fly[
'mouseControl'] =
True
730 if self.
mouse[
'use'] ==
'pointer':
735 if self.
mouse[
'use'] ==
'rotate':
736 dx, dy = event.GetX() - self.
mouse[
'tmp'][0], event.GetY() - self.
mouse[
'tmp'][1]
738 angle, x, y, z = self._display.GetRotationParameters(dx, dy)
739 self._display.Rotate(angle, x, y, z)
741 self.
render[
'quick'] =
True
744 if self.
mouse[
'use'] ==
'pan':
747 self.
mouse[
'tmp'] = event.GetPositionTuple()
752 """!Convert image coordinates to real word coordinates
754 @param x, y image coordinates
756 @return easting, northing
757 @return None on error
759 size = self.GetClientSize()
761 sid, x, y, z = self._display.GetPointOnSurface(x, size[1] - y)
769 """!Change perspective and focus"""
771 prev_value = self.
view[
'persp'][
'value']
773 value = -1 * self.
view[
'persp'][
'step']
775 value = self.
view[
'persp'][
'step']
776 self.
view[
'persp'][
'value'] += value
777 if self.
view[
'persp'][
'value'] < 1:
778 self.
view[
'persp'][
'value'] = 1
779 elif self.
view[
'persp'][
'value'] > 180:
780 self.
view[
'persp'][
'value'] = 180
782 if prev_value != self.
view[
'persp'][
'value']:
783 if hasattr(self.
lmgr,
"nviz"):
784 self.lmgr.nviz.UpdateSettings()
785 x, y = pos[0], self.GetClientSize()[1] - pos[1]
786 result = self._display.GetPointOnSurface(x, y)
788 self._display.LookHere(x, y)
789 focus = self._display.GetFocus()
790 for i, coord
in enumerate((
'x',
'y',
'z')):
791 self.
iview[
'focus'][coord] = focus[i]
792 self._display.SetView(self.
view[
'position'][
'x'], self.
view[
'position'][
'y'],
793 self.
iview[
'height'][
'value'],
794 self.
view[
'persp'][
'value'],
795 self.
view[
'twist'][
'value'])
801 self.
mouse[
'end'] = event.GetPositionTuple()
802 if self.
mouse[
"use"] ==
"query":
804 if self.parent.IsStandalone():
805 GMessage(parent = self.
parent,
806 message = _(
"Querying is not implemented in standalone mode of Map Display"))
811 self.parent.Query(self.
mouse[
'begin'][0],self.
mouse[
'begin'][1], layers)
813 elif self.
mouse[
"use"]
in (
'arrow',
'scalebar'):
814 self.lmgr.nviz.FindWindowById(
815 self.lmgr.nviz.win[
'decoration'][self.
mouse[
"use"]][
'place']).
SetValue(
False)
816 self.
mouse[
'use'] =
'pointer'
817 self.SetCursor(self.
cursors[
'default'])
818 elif self.
mouse[
'use'] ==
'pointer':
820 dx = self.
mouse[
'end'][0] - self.
mouse[
'begin'][0]
821 dy = self.
mouse[
'end'][1] - self.
mouse[
'begin'][1]
824 self.
overlays[self.
dragid][
'coords'] = [coords[0] + dx, coords[1] + dy]
827 self.
textdict[self.
dragid][
'coords'] = [coords[0] + dx, coords[1] + dy]
829 self.
render[
'quick'] =
False
832 elif self.
mouse[
'use'] ==
'rotate':
833 self._display.UnsetRotation()
834 self.
iview[
'rotation'] = self._display.GetRotationMatrix()
836 self.
render[
'quick'] =
False
839 elif self.
mouse[
'use'] ==
'pan':
841 self.
render[
'quick'] =
False
844 elif self.
mouse[
'use'] ==
'fly':
845 if self.
fly[
'mouseControl']:
847 self.
fly[
'mouseControl'] =
None
854 self.
render[
'quick'] =
False
857 elif self.
mouse[
'use'] ==
'zoom':
858 self.
DoZoom(zoomtype = self.zoomtype, pos = self.
mouse[
'end'])
862 """!On mouse double click"""
863 if self.
mouse[
'use'] !=
'pointer':
return
864 pos = event.GetPositionTuple()
868 self.parent.OnAddLegend(
None)
870 self.parent.OnAddText(
None)
875 """!Simulation of panning using focus"""
876 size = self.GetClientSizeTuple()
877 id1, x1, y1, z1 = self._display.GetPointOnSurface(
878 self.
mouse[
'tmp'][0], size[1] - self.
mouse[
'tmp'][1])
879 id2, x2, y2, z2 = self._display.GetPointOnSurface(
880 event.GetX(), size[1] - event.GetY())
881 if id1
and id1 == id2:
882 dx, dy, dz = x2 - x1, y2 - y1, z2 - z1
883 focus = self.
iview[
'focus']
884 focus[
'x'], focus[
'y'], focus[
'z'] = self._display.GetFocus()
892 self.
mouse[
'tmp'] = event.GetPositionTuple()
893 self.
render[
'quick'] =
True
897 """!Move all layers in horizontal (x, y) direction.
900 size = self.GetClientSizeTuple()
901 id1, x1, y1, z1 = self._display.GetPointOnSurface(
902 self.
mouse[
'tmp'][0], size[1] - self.
mouse[
'tmp'][1])
903 id2, x2, y2, z2 = self._display.GetPointOnSurface(
904 event.GetX(), size[1] - event.GetY())
906 if id1
and id1 == id2:
907 dx, dy = x2 - x1, y2 - y1
910 mapLayer = self.tree.GetPyData(item)[0][
'maplayer']
912 data = self.tree.GetPyData(item)[0][
'nviz']
913 if mapLayer.GetType() ==
'raster':
914 data[
'surface'][
'position'][
'x'] += dx
915 data[
'surface'][
'position'][
'y'] += dy
916 data[
'surface'][
'position'][
'update'] =
None
919 evt = wxUpdateProperties(data = data)
920 wx.PostEvent(self, evt)
922 if event.CmdDown()
and id1 == data[
'surface'][
'object'][
'id']:
925 elif mapLayer.GetType() ==
'3d-raster':
926 if 'x' not in data[
'volume'][
'position']:
927 data[
'volume'][
'position'][
'x'] = 0
928 data[
'volume'][
'position'][
'y'] = 0
929 data[
'volume'][
'position'][
'z'] = 0
930 data[
'volume'][
'position'][
'x'] += dx
931 data[
'volume'][
'position'][
'y'] += dy
932 data[
'volume'][
'position'][
'update'] =
None
935 evt = wxUpdateProperties(data = data)
936 wx.PostEvent(self, evt)
938 self.
mouse[
'tmp'] = event.GetPositionTuple()
939 self.
render[
'quick'] =
True
943 """!Drag an overlay decoration item
946 Debug.msg (5,
"GLWindow.DragItem(): id=%d" % id)
947 x, y = self.
mouse[
'tmp']
948 dx = event.GetX() - x
949 dy = event.GetY() - y
952 texture.MoveTexture(dx, dy)
955 self.
render[
'quick'] =
True
958 self.
mouse[
'tmp'] = (event.GetX(), event.GetY())
961 """!Set previous view in history list
965 self.viewhistory.pop()
970 toolbar = self.parent.GetMapToolbar()
971 toolbar.Enable(
'zoomback', enable =
False)
974 self.lmgr.nviz.UpdateState(view = view[0], iview = view[1])
975 self.lmgr.nviz.UpdatePage(
'view')
980 """!Manages a list of last 10 views
982 @param view view dictionary
983 @param iview view dictionary (internal)
985 @return removed history item if exists (or None)
988 hview = copy.deepcopy(view)
989 hiview = copy.deepcopy(iview)
992 self.viewhistory.append((hview, hiview))
995 removed = self.viewhistory.pop(0)
998 Debug.msg(4,
"GLWindow.ViewHistory(): hist=%s, removed=%s" %
1001 Debug.msg(4,
"GLWindow.ViewHistory(): hist=%s" %
1010 toolbar = self.parent.GetMapToolbar()
1011 toolbar.Enable(
'zoomback', enable)
1016 """!Reset view history"""
1020 """!Focus on given point"""
1021 w = self.Map.region[
'w']
1022 s = self.Map.region[
's']
1025 focus = self.
iview[
'focus']
1026 focus[
'x'], focus[
'y'] = e, n
1031 self.
render[
'quick'] =
False
1035 """!Query surface on given position"""
1036 size = self.GetClientSizeTuple()
1037 result = self._display.QueryMap(x, size[1] - y)
1039 self.qpoints.append((result[
'x'], result[
'y'], result[
'z']))
1040 self.log.WriteLog(
"%-30s: %.3f" % (_(
"Easting"), result[
'x']))
1041 self.log.WriteLog(
"%-30s: %.3f" % (_(
"Northing"), result[
'y']))
1042 self.log.WriteLog(
"%-30s: %.3f" % (_(
"Elevation"), result[
'z']))
1045 self.tree.GetPyData(item)[0][
'nviz']
1046 if self.tree.GetPyData(item)[0][
'maplayer'].type ==
'raster' and\
1047 self.tree.GetPyData(item)[0][
'nviz'][
'surface'][
'object'][
'id'] == result[
'id']:
1048 name = self.tree.GetPyData(item)[0][
'maplayer'].name
1049 self.log.WriteLog(
"%-30s: %s" % (_(
"Surface map name"), name))
1050 self.log.WriteLog(
"%-30s: %s" % (_(
"Surface map elevation"), result[
'elevation']))
1051 self.log.WriteLog(
"%-30s: %s" % (_(
"Surface map color"), result[
'color']))
1055 dxy = math.sqrt(pow(prev[0]-curr[0], 2) +
1056 pow(prev[1]-curr[1], 2))
1057 dxyz = math.sqrt(pow(prev[0]-curr[0], 2) +
1058 pow(prev[1]-curr[1], 2) +
1059 pow(prev[2]-curr[2], 2))
1060 self.log.WriteLog(
"%-30s: %.3f" % (_(
"XY distance from previous"), dxy))
1061 self.log.WriteLog(
"%-30s: %.3f" % (_(
"XYZ distance from previous"), dxyz))
1062 self.log.WriteLog(
"%-30s: %.3f" % (_(
"Distance along surface"),
1063 self._display.GetDistanceAlongSurface(result[
'id'],
1067 self.log.WriteLog(
"%-30s: %.3f" % (_(
"Distance along exag. surface"),
1068 self._display.GetDistanceAlongSurface(result[
'id'],
1072 self.log.WriteCmdLog(
'-' * 80)
1074 self.log.WriteLog(_(
"No point on surface"))
1075 self.log.WriteCmdLog(
'-' * 80)
1078 """!Change view settings"""
1079 event = wxUpdateView(zExag = zExag)
1080 wx.PostEvent(self, event)
1083 """!Query vector on given position"""
1084 self.parent.QueryVector(*event.GetPosition())
1087 """!Get current viewdir and viewpoint and set view"""
1090 (view[
'position'][
'x'], view[
'position'][
'y'],
1091 iview[
'height'][
'value']) = self._display.GetViewpointPosition()
1092 for key, val
in zip((
'x',
'y',
'z'), self._display.GetViewdir()):
1093 iview[
'dir'][key] = val
1095 iview[
'dir'][
'use'] =
True
1098 """!Change view settings"""
1108 """!Change view settings"""
1111 if zexag
and 'value' in view[
'z-exag']:
1112 self._display.SetZExag(view[
'z-exag'][
'value'] / iview[
'z-exag'][
'llRatio'])
1114 self._display.SetView(view[
'position'][
'x'], view[
'position'][
'y'],
1115 iview[
'height'][
'value'],
1116 view[
'persp'][
'value'],
1117 view[
'twist'][
'value'])
1119 if iview[
'dir'][
'use']:
1120 self._display.SetViewdir(iview[
'dir'][
'x'], iview[
'dir'][
'y'], iview[
'dir'][
'z'])
1122 elif iview[
'focus'][
'x'] != -1:
1123 self._display.SetFocus(self.
iview[
'focus'][
'x'], self.
iview[
'focus'][
'y'],
1124 self.
iview[
'focus'][
'z'])
1126 if 'rotation' in iview:
1127 if iview[
'rotation']:
1128 self._display.SetRotationMatrix(iview[
'rotation'])
1130 self._display.ResetRotation()
1133 """!Change light settings"""
1135 self._display.SetLight(x = data[
'position'][
'x'], y = data[
'position'][
'y'],
1136 z = data[
'position'][
'z'] / 100., color = data[
'color'],
1137 bright = data[
'bright'] / 100.,
1138 ambient = data[
'ambient'] / 100.)
1139 self._display.DrawLightingModel()
1144 """!Updates the canvas anytime there is a change to the
1145 underlaying images or to the geometry of the canvas.
1147 @param render re-render map composition
1149 start = time.clock()
1153 if self.
render[
'quick']
is False:
1154 self.parent.GetProgressBar().Show()
1155 self.parent.GetProgressBar().
SetRange(2)
1156 self.parent.GetProgressBar().
SetValue(0)
1158 if self.
render[
'quick']
is False:
1159 self.parent.GetProgressBar().
SetValue(1)
1160 self._display.Draw(
False, -1)
1164 elif self.
render[
'quick']
is True:
1166 mode = wxnviz.DRAW_QUICK_SURFACE | wxnviz.DRAW_QUICK_VOLUME
1167 if self.
render[
'vlines']:
1168 mode |= wxnviz.DRAW_QUICK_VLINES
1169 if self.
render[
'vpoints']:
1170 mode |= wxnviz.DRAW_QUICK_VPOINTS
1171 self._display.Draw(
True, mode)
1178 if self.
render[
'quick']
is False:
1179 self._display.DrawFringe()
1181 self._display.DrawArrow()
1183 self._display.DrawScalebar()
1187 self._display.Start2D()
1194 if self.
render[
'quick']
is False:
1195 self.parent.GetProgressBar().
SetValue(2)
1197 self.parent.GetProgressBar().Hide()
1199 Debug.msg(3,
"GLWindow.UpdateMap(): quick = %d, -> time = %g" % \
1200 (self.
render[
'quick'], (stop-start)))
1203 """!Erase the canvas
1205 self._display.EraseMap()
1208 def _getDecorationSize(self):
1209 """!Get initial size of north arrow/scalebar"""
1210 size = self._display.GetLongDim() / 8.
1214 return int(size * coef)/coef
1218 if self._display.SetArrow(pos[0], pos[1],
1221 self._display.DrawArrow()
1224 self.
decoration[
'arrow'][
'position'][
'x'] = pos[0]
1225 self.
decoration[
'arrow'][
'position'][
'y'] = pos[1]
1229 """!Add scale bar, sets properties and draw"""
1232 self.nvizDefault.SetDecorDefaultProp(type =
'scalebar')[
'scalebar'])
1238 ret = self._display.SetScalebar(self.
decoration[
'scalebar'][-1][
'id'], pos[0], pos[1],
1242 self._display.DrawScalebar()
1244 self.
decoration[
'scalebar'][-1][
'position'][
'x'] = pos[0]
1245 self.
decoration[
'scalebar'][-1][
'position'][
'y'] = pos[1]
1249 """!Check if layer (item) is already loaded
1251 @param item layer item
1253 layer = self.tree.GetPyData(item)[0][
'maplayer']
1254 data = self.tree.GetPyData(item)[0][
'nviz']
1259 if layer.type ==
'raster':
1260 if 'object' not in data[
'surface']:
1262 elif layer.type ==
'vector':
1263 if 'object' not in data[
'vlines']
and \
1264 'object' not in data[
'points']:
1269 def _GetDataLayers(self, item, litems):
1270 """!Return get list of enabled map layers"""
1272 while item
and item.IsOk():
1273 type = self.tree.GetPyData(item)[0][
'type']
1275 subItem = self.tree.GetFirstChild(item)[0]
1277 item = self.tree.GetNextSibling(item)
1279 if not item.IsChecked()
or \
1280 type
not in (
'raster',
'vector',
'3d-raster'):
1281 item = self.tree.GetNextSibling(item)
1286 item = self.tree.GetNextSibling(item)
1289 """!Load raster/vector from current layer tree
1297 item = self.tree.GetFirstChild(self.tree.root)[0]
1302 while(len(listOfItems) > 0):
1303 item = listOfItems.pop()
1304 type = self.tree.GetPyData(item)[0][
'type']
1309 if ' ' in self.tree.GetPyData(item)[0][
'maplayer'].name:
1312 if type ==
'raster':
1314 elif type ==
'3d-raster':
1316 elif type ==
'vector':
1317 layer = self.tree.GetPyData(item)[0][
'maplayer']
1318 vInfo = grass.vector_info_topo(layer.GetName())
1319 if (vInfo[
'points']) > 0:
1322 if (vInfo[
'lines'] + vInfo[
'boundaries']) > 0:
1324 if vInfo[
'map3d']
and (vInfo[
'kernels'] + vInfo[
'faces']) > 0:
1327 except GException, e:
1328 GError(parent = self,
1333 Debug.msg(1,
"GLWindow.LoadDataLayers(): time = %f" % (stop-start))
1336 """!Unload any layers that have been deleted from layer tree
1338 @param force True to unload all data layers
1345 item = self.tree.GetFirstChild(self.tree.root)[0]
1351 layersTmp = self.
layers[:]
1352 for layer
in layersTmp:
1353 if layer
in listOfItems:
1355 ltype = self.tree.GetPyData(layer)[0][
'type']
1357 if ltype ==
'raster':
1359 elif ltype ==
'3d-raster':
1361 elif ltype ==
'vector':
1362 maplayer = self.tree.GetPyData(layer)[0][
'maplayer']
1363 vInfo = grass.vector_info_topo(maplayer.GetName())
1364 if (vInfo[
'points'] + vInfo[
'centroids']) > 0:
1366 if (vInfo[
'lines'] + vInfo[
'boundaries']) > 0
or vInfo[
'map3d']:
1369 except GException, e:
1370 GError(parent = self,
1373 if force
and self.
baseId > 0:
1374 ret = self._display.UnloadSurface(self.
baseId)
1377 self.lmgr.nviz.UpdateSettings()
1382 Debug.msg(1,
"GLWindow.UnloadDataLayers(): time = %f" % (stop-start))
1385 """!Set reference surfaces of vector"""
1386 data[
'mode'][
'surface'] = {}
1387 data[
'mode'][
'surface'][
'value'] = list()
1388 data[
'mode'][
'surface'][
'show'] = list()
1390 data[
'mode'][
'surface'][
'value'].append(name)
1391 data[
'mode'][
'surface'][
'show'].append(
True)
1394 """!Set 3D view properties from cmd (d.vect)
1396 @param item Layer Tree item
1399 cmd = self.tree.GetPyData(item)[0][
'cmd']
1400 if cmd[0] !=
'd.vect':
1404 key, value = opt.split(
'=')
1408 data[
'lines'][
'color'][
'value'] = value
1409 data[
'points'][
'color'][
'value'] = value
1412 """!Set map object properties
1414 Properties must be afterwards updated by
1415 UpdateMapObjProperties().
1417 @param item layer item
1418 @param id nviz layer id (or -1)
1419 @param nvizType nviz data type (surface, points, vector)
1421 if nvizType !=
'constant':
1422 mapType = self.tree.GetPyData(item)[0][
'maplayer'].type
1424 data = self.tree.GetPyData(item)[0][
'nviz']
1431 if nvizType !=
'constant':
1432 self.tree.GetPyData(item)[0][
'nviz'] = {}
1433 data = self.tree.GetPyData(item)[0][
'nviz']
1435 if mapType ==
'raster':
1437 data[nvizType] = self.nvizDefault.SetSurfaceDefaultProp()
1439 elif mapType ==
'vector':
1441 data[
'vector'] = self.nvizDefault.SetVectorDefaultProp()
1446 elif mapType ==
'3d-raster':
1448 data[nvizType] = self.nvizDefault.SetVolumeDefaultProp()
1450 elif mapType ==
'constant':
1451 data[
'constant'] = self.nvizDefault.SetConstantDefaultProp()
1455 if mapType ==
'raster':
1456 if not data[
'surface']:
1457 data[
'surface'] = self.nvizDefault.SetSurfaceDefaultProp()
1458 if mapType ==
'vector':
1459 if not data[
'vector'][
'lines']:
1460 self.nvizDefault.SetVectorLinesDefaultProp(data[
'vector'][
'lines'])
1461 if not data[
'vector'][
'points']:
1462 self.nvizDefault.SetVectorPointsDefaultProp(data[
'vector'][
'points'])
1464 for sec
in data.keys():
1465 for sec1
in data[sec].keys():
1466 if sec1 ==
'position':
1467 data[sec][sec1][
'update'] =
None
1469 if type(data[sec][sec1]) == types.DictType:
1470 for sec2
in data[sec][sec1].keys():
1471 if sec2
not in (
'all',
'init',
'id'):
1472 data[sec][sec1][sec2][
'update'] =
None
1473 elif type(data[sec][sec1]) == types.ListType:
1474 for i
in range(len(data[sec][sec1])):
1475 for sec2
in data[sec][sec1][i].keys():
1476 data[sec][sec1][i][sec2][
'update'] =
None
1477 event = wxUpdateProperties(data = data)
1478 wx.PostEvent(self, event)
1482 if mapType
in (
'raster',
'3d-raster'):
1483 data[nvizType][
'object'] = {
'id' : id,
1485 elif mapType ==
'vector':
1486 data[
'vector'][nvizType][
'object'] = {
'id' : id,
1488 elif mapType ==
'constant':
1489 data[nvizType][
'object'] = {
'id' : id,
1495 """!Load 2d raster map and set surface attributes
1502 """!Load 3d raster map and set surface attributes
1508 def _loadRaster(self, item):
1509 """!Load 2d/3d raster map and set its attributes
1513 layer = self.tree.GetPyData(item)[0][
'maplayer']
1515 if layer.type
not in (
'raster',
'3d-raster'):
1518 if layer.type ==
'raster':
1519 id = self._display.LoadSurface(str(layer.name),
None,
None)
1520 nvizType =
'surface'
1521 errorMsg = _(
"Loading raster map")
1522 elif layer.type ==
'3d-raster':
1523 id = self._display.LoadVolume(str(layer.name),
None,
None)
1525 errorMsg = _(
"Loading 3d raster map")
1530 if layer.type
in (
'raster',
'3d-raster'):
1531 self.log.WriteError(
"%s <%s> %s" % (errorMsg, layer.name, _(
"failed")))
1533 self.log.WriteError(_(
"Unsupported layer type '%s'") % layer.type)
1535 self.layers.append(item)
1541 event = wxUpdateProperties(data = data)
1542 wx.PostEvent(self, event)
1545 if hasattr(self.
lmgr,
"nviz")
and \
1547 toolWin = self.lmgr.nviz
1548 if layer.type ==
'raster':
1549 win = toolWin.FindWindowById( \
1550 toolWin.win[
'vector'][
'lines'][
'surface'])
1559 """!Create new constant"""
1562 name = self.
constants[-1][
'constant'][
'object'][
'name'] + 1
1566 self.constants.append(data)
1572 """!Add new constant"""
1573 id = self._display.AddConstant(value = data[
'constant'][
'value'], color = data[
'constant'][
'color'])
1574 self._display.SetSurfaceRes(id, data[
'constant'][
'resolution'], data[
'constant'][
'resolution'])
1575 data[
'constant'][
'object'] = {
'id' : id,
1580 """!Delete constant layer"""
1581 id = self.
constants[index][
'constant'][
'object'][
'id']
1582 self._display.UnloadSurface(id)
1586 """!Select cutting plane"""
1587 for plane
in range (self._display.GetCPlanesCount()):
1589 self._display.SelectCPlane(plane)
1590 self.
cplanes[plane][
'on'] =
True
1591 self._display.SetFenceColor(self.
cplanes[plane][
'shading'])
1593 self._display.UnselectCPlane(plane)
1595 self.
cplanes[plane][
'on'] =
False
1600 """!Change cutting plane settings"""
1604 """!Change cutting plane settings"""
1605 for each
in changes:
1606 if each ==
'rotation':
1607 self._display.SetCPlaneRotation(0, self.
cplanes[index][
'rotation'][
'tilt'],
1608 self.
cplanes[index][
'rotation'][
'rot'])
1609 if each ==
'position':
1610 self._display.SetCPlaneTranslation(self.
cplanes[index][
'position'][
'x'],
1611 self.
cplanes[index][
'position'][
'y'],
1612 self.
cplanes[index][
'position'][
'z'])
1613 if each ==
'shading':
1614 self._display.SetFenceColor(self.
cplanes[index][
'shading'])
1617 """!Unload 2d raster map
1624 """!Unload 3d raster map
1630 def _unloadRaster(self, item):
1631 """!Unload 2d/3d raster map
1633 @param item layer item
1635 layer = self.tree.GetPyData(item)[0][
'maplayer']
1637 if layer.type
not in (
'raster',
'3d-raster'):
1640 data = self.tree.GetPyData(item)[0][
'nviz']
1642 if layer.type ==
'raster':
1643 nvizType =
'surface'
1644 unloadFn = self._display.UnloadSurface
1645 errorMsg = _(
"Unable to unload raster map")
1646 successMsg = _(
"Raster map")
1649 unloadFn = self._display.UnloadVolume
1650 errorMsg = _(
"Unable to unload 3d raster map")
1651 successMsg = _(
"3d raster map")
1654 id = data[nvizType][
'object'][
'id']
1658 if unloadFn(id) == 0:
1659 self.log.WriteError(
"%s <%s>" % (errorMsg, layer.name))
1661 self.log.WriteLog(
"%s <%s> %s" % (successMsg, layer.name, _(
"unloaded successfully")))
1663 data[nvizType].pop(
'object')
1665 self.layers.remove(item)
1668 if hasattr(self.
lmgr,
"nviz"):
1669 toolWin = self.lmgr.nviz
1670 if layer.type ==
'raster':
1671 win = toolWin.FindWindowById(toolWin.win[
'vector'][
'lines'][
'surface'])
1673 win = toolWin.FindWindowById(toolWin.win[
'surface'][
'map'])
1675 if layer.type ==
'3d-raster':
1676 win = toolWin.FindWindowById(toolWin.win[
'volume'][
'map'])
1678 if layer.type ==
'vector':
1679 win = toolWin.FindWindowById(toolWin.win[
'vector'][
'map'])
1683 """!Load 2D or 3D vector map overlay
1685 @param item layer item
1686 @param points True to load points, False to load lines, None
1688 @param append append vector to layer list
1690 layer = self.tree.GetPyData(item)[0][
'maplayer']
1691 if layer.type !=
'vector':
1698 vecTypes = (
'points',
'lines')
1701 vecTypes = (
'points', )
1704 vecTypes = (
'lines', )
1707 for vecType
in vecTypes:
1708 if vecType ==
'lines':
1709 id, baseId = self._display.LoadVector(str(layer.GetName()),
False)
1711 id, baseId = self._display.LoadVector(str(layer.GetName()),
True)
1713 self.log.WriteError(_(
"Loading vector map <%(name)s> (%(type)s) failed") % \
1714 {
'name' : layer.name,
'type' : vecType })
1720 self.layers.append(item)
1723 data = self.tree.GetPyData(item)[0][
'nviz']
1724 event = wxUpdateProperties(data = data)
1725 wx.PostEvent(self, event)
1728 if hasattr(self.
lmgr,
"nviz")
and \
1730 toolWin = self.lmgr.nviz
1732 toolWin.UpdatePage(
'vector')
1738 """!Unload vector map overlay
1740 @param item layer item
1741 @param points,lines True to unload given feature type
1742 @param remove remove layer from list
1744 layer = self.tree.GetPyData(item)[0][
'maplayer']
1745 data = self.tree.GetPyData(item)[0][
'nviz'][
'vector']
1755 vecTypes = (
'points',
'lines')
1757 vecTypes = (
'points', )
1759 vecTypes = (
'lines', )
1761 for vecType
in vecTypes:
1762 if 'object' not in data[vecType]:
1765 id = data[vecType][
'object'][
'id']
1767 if vecType ==
'lines':
1768 ret = self._display.UnloadVector(id,
False)
1770 ret = self._display.UnloadVector(id,
True)
1772 self.log.WriteError(_(
"Unable to unload vector map <%(name)s> (%(type)s)") % \
1773 {
'name': layer.name,
'type' : vecType })
1775 self.log.WriteLog(_(
"Vector map <%(name)s> (%(type)s) unloaded successfully") % \
1776 {
'name' : layer.name,
'type' : vecType })
1778 data[vecType].pop(
'object')
1780 if remove
and item
in self.
layers:
1781 self.layers.remove(item)
1784 """!Reset to default view"""
1786 self.
iview[
'height'][
'value'], \
1787 self.
iview[
'height'][
'min'], \
1788 self.
iview[
'height'][
'max'] = self._display.SetViewDefault()
1792 self.
iview[
'z-exag'][
'llRatio'] = 1
1793 if grass.locn_is_latlong():
1794 self.
iview[
'z-exag'][
'llRatio'] = \
1795 math.pi / 180 * 6371000 * math.cos((grass.region()[
'n'] + grass.region()[
's']) / 2)
1797 self.
view[
'z-exag'][
'value'] =
round(zexagOriginal * self.
iview[
'z-exag'][
'llRatio'])
1798 self.
view[
'z-exag'][
'min'] = UserSettings.Get(group =
'nviz', key =
'view',
1799 subkey = (
'z-exag',
'min'))
1800 zexagMax = UserSettings.Get(group =
'nviz', key =
'view',
1801 subkey = (
'z-exag',
'max'))
1802 if zexagMax <= self.
view[
'z-exag'][
'value']:
1803 self.
view[
'z-exag'][
'max'] = self.
view[
'z-exag'][
'value'] * 2
1804 elif self.
view[
'z-exag'][
'value'] < 1:
1805 if self.
view[
'z-exag'][
'value'] == 0:
1806 self.
view[
'z-exag'][
'value'] = 1
1807 self.
view[
'z-exag'][
'max'] = 10 * self.
view[
'z-exag'][
'value']
1809 self.
view[
'z-exag'][
'max'] = zexagMax
1811 self.
view[
'position'][
'x'] = UserSettings.Get(group =
'nviz', key =
'view',
1812 subkey = (
'position',
'x'))
1813 self.
view[
'position'][
'y'] = UserSettings.Get(group =
'nviz', key =
'view',
1814 subkey = (
'position',
'y'))
1815 self.
view[
'persp'][
'value'] = UserSettings.Get(group =
'nviz', key =
'view',
1816 subkey = (
'persp',
'value'))
1818 self.
view[
'twist'][
'value'] = UserSettings.Get(group =
'nviz', key =
'view',
1819 subkey = (
'twist',
'value'))
1820 self._display.ResetRotation()
1821 self.
iview[
'rotation'] =
None
1822 self._display.LookAtCenter()
1823 focus = self.
iview[
'focus']
1824 focus[
'x'], focus[
'y'], focus[
'z'] = self._display.GetFocus()
1829 """!Generic method to update data layer properties"""
1832 if 'surface' in data:
1834 id = data[
'surface'][
'object'][
'id']
1839 data[
'surface'][
'object'][
'init'] =
True
1841 elif 'constant' in data:
1842 id = data[
'constant'][
'object'][
'id']
1845 data[
'constant'][
'object'][
'init'] =
True
1847 elif 'volume' in data:
1848 id = data[
'volume'][
'object'][
'id']
1851 data[
'volume'][
'object'][
'init'] =
True
1853 elif 'vector' in data:
1854 for type
in (
'lines',
'points'):
1855 if 'object' in data[
'vector'][type]:
1856 id = data[
'vector'][type][
'object'][
'id']
1859 data[
'vector'][type][
'object'][
'init'] =
True
1862 """!Update surface map object properties"""
1863 self._display.SetSurfaceColor(id = id, map =
False, value = data[
'color'])
1864 self._display.SetSurfaceTopo(id = id, map =
False, value = data[
'value'])
1865 self._display.SetSurfaceRes(id, data[
'resolution'], data[
'resolution'])
1866 if data[
'transp'] == 0:
1867 self._display.UnsetSurfaceTransp(id)
1869 self._display.SetSurfaceTransp(id, map =
False, value = data[
'transp'])
1872 """!Update surface map object properties"""
1874 for attrb
in (
'color',
'mask',
1876 if attrb
not in data[
'attribute']
or \
1877 'update' not in data[
'attribute'][attrb]:
1880 map = data[
'attribute'][attrb][
'map']
1881 value = data[
'attribute'][attrb][
'value']
1888 self._display.UnsetSurfaceMask(id)
1889 elif attrb ==
'transp':
1890 self._display.UnsetSurfaceTransp(id)
1892 if type(value) == types.StringType
and \
1895 if attrb ==
'color':
1896 self._display.SetSurfaceColor(id, map, str(value))
1897 elif attrb ==
'mask':
1900 self._display.SetSurfaceMask(id,
False, str(value))
1901 elif attrb ==
'transp':
1902 self._display.SetSurfaceTransp(id, map, str(value))
1903 elif attrb ==
'shine':
1904 self._display.SetSurfaceShine(id, map, str(value))
1905 data[
'attribute'][attrb].pop(
'update')
1908 if 'update' in data[
'draw'][
'resolution']:
1909 coarse = data[
'draw'][
'resolution'][
'coarse']
1910 fine = data[
'draw'][
'resolution'][
'fine']
1912 if data[
'draw'][
'all']:
1913 self._display.SetSurfaceRes(-1, fine, coarse)
1915 self._display.SetSurfaceRes(id, fine, coarse)
1916 data[
'draw'][
'resolution'].pop(
'update')
1919 if 'update' in data[
'draw'][
'mode']:
1920 if data[
'draw'][
'mode'][
'value'] < 0:
1921 data[
'draw'][
'mode'][
'value'] = \
1922 self.nvizDefault.GetDrawMode(mode = data[
'draw'][
'mode'][
'desc'][
'mode'],
1923 style = data[
'draw'][
'mode'][
'desc'][
'style'],
1924 shade = data[
'draw'][
'mode'][
'desc'][
'shading'],
1926 style = data[
'draw'][
'mode'][
'value']
1927 if data[
'draw'][
'all']:
1928 self._display.SetSurfaceStyle(-1, style)
1930 self._display.SetSurfaceStyle(id, style)
1931 data[
'draw'][
'mode'].pop(
'update')
1934 if 'update' in data[
'draw'][
'wire-color']:
1935 color = data[
'draw'][
'wire-color'][
'value']
1936 if data[
'draw'][
'all']:
1937 self._display.SetWireColor(-1, str(color))
1939 self._display.SetWireColor(id, str(color))
1940 data[
'draw'][
'wire-color'].pop(
'update')
1943 if 'update' in data[
'position']:
1944 x = data[
'position'][
'x']
1945 y = data[
'position'][
'y']
1946 z = data[
'position'][
'z']
1947 self._display.SetSurfacePosition(id, x, y, z)
1948 data[
'position'].pop(
'update')
1949 data[
'draw'][
'all'] =
False
1952 """!Update volume (isosurface/slice) map object properties"""
1953 if 'update' in data[
'draw'][
'resolution']:
1954 if data[
'draw'][
'mode'][
'value'] == 0:
1955 self._display.SetIsosurfaceRes(id, data[
'draw'][
'resolution'][
'isosurface'][
'value'])
1957 self._display.SetSliceRes(id, data[
'draw'][
'resolution'][
'slice'][
'value'])
1958 data[
'draw'][
'resolution'].pop(
'update')
1960 if 'update' in data[
'draw'][
'shading']:
1961 if data[
'draw'][
'mode'][
'value'] == 0:
1962 if data[
'draw'][
'shading'][
'isosurface'][
'value'] < 0:
1963 mode = data[
'draw'][
'shading'][
'isosurface'][
'value'] = \
1964 self.nvizDefault.GetDrawMode(shade = data[
'draw'][
'shading'][
'isosurface'],
1966 self._display.SetIsosurfaceMode(id, mode)
1968 if data[
'draw'][
'shading'][
'slice'][
'value'] < 0:
1969 mode = data[
'draw'][
'shading'][
'slice'][
'value'] = \
1970 self.nvizDefault.GetDrawMode(shade = data[
'draw'][
'shading'][
'slice'],
1972 self._display.SetSliceMode(id, mode)
1973 data[
'draw'][
'shading'].pop(
'update')
1979 for isosurf
in data[
'isosurface']:
1980 self._display.AddIsosurface(id, 0, isosurf_id = isosurfId)
1981 for attrb
in (
'topo',
'color',
'mask',
1983 if attrb
not in isosurf
or \
1984 'update' not in isosurf[attrb]:
1986 map = isosurf[attrb][
'map']
1987 value = isosurf[attrb][
'value']
1991 if attrb ==
'topo' :
1992 self._display.SetIsosurfaceTopo(id, isosurfId, map, str(value))
1993 elif attrb ==
'mask':
1996 self._display.UnsetIsosurfaceMask(id, isosurfId)
1997 elif attrb ==
'transp':
1998 self._display.UnsetIsosurfaceTransp(id, isosurfId)
2000 if type(value) == types.StringType
and \
2003 elif attrb ==
'color':
2004 self._display.SetIsosurfaceColor(id, isosurfId, map, str(value))
2005 elif attrb ==
'mask':
2008 self._display.SetIsosurfaceMask(id, isosurfId,
False, str(value))
2009 elif attrb ==
'transp':
2010 self._display.SetIsosurfaceTransp(id, isosurfId, map, str(value))
2011 elif attrb ==
'shine':
2012 self._display.SetIsosurfaceShine(id, isosurfId, map, str(value))
2013 isosurf[attrb].pop(
'update')
2019 for slice
in data[
'slice']:
2020 ret = self._display.AddSlice(id, slice_id = sliceId)
2021 if 'update' in slice[
'position']:
2022 pos = slice[
'position']
2023 ret = self._display.SetSlicePosition(id, sliceId, pos[
'x1'], pos[
'x2'],
2024 pos[
'y1'], pos[
'y2'], pos[
'z1'], pos[
'z2'], pos[
'axis'])
2026 slice[
'position'].pop(
'update')
2027 if 'update' in slice[
'transp']:
2028 tr = slice[
'transp'][
'value']
2029 self._display.SetSliceTransp(id, sliceId, tr)
2033 if 'update' in data[
'position']
and 'x' in data[
'position']:
2034 x = data[
'position'][
'x']
2035 y = data[
'position'][
'y']
2036 z = data[
'position'][
'z']
2037 self._display.SetVolumePosition(id, x, y, z)
2038 data[
'position'].pop(
'update')
2041 """!Update vector layer properties
2044 @param data properties
2045 @param type lines/points
2047 if type ==
'points':
2053 """!Update vector line map object properties"""
2055 if 'update' in data[
'color']
or \
2056 'update' in data[
'width']
or \
2057 'update' in data[
'mode']:
2058 width = data[
'width'][
'value']
2059 color = data[
'color'][
'value']
2060 if data[
'mode'][
'type'] ==
'flat':
2062 if 'surface' in data[
'mode']:
2063 data[
'mode'].pop(
'surface')
2067 self._display.SetVectorLineMode(id, color,
2070 if 'update' in data[
'color']:
2071 data[
'color'].pop(
'update')
2072 if 'update' in data[
'width']:
2073 data[
'width'].pop(
'update')
2076 if 'update' in data[
'height']:
2077 self._display.SetVectorLineHeight(id,
2078 data[
'height'][
'value'])
2079 data[
'height'].pop(
'update')
2082 if 'surface' in data[
'mode']
and 'update' in data[
'mode']:
2083 for item
in range(len(data[
'mode'][
'surface'][
'value'])):
2084 for type
in (
'raster',
'constant'):
2086 name = data[
'mode'][
'surface'][
'value'][item])
2088 if data[
'mode'][
'surface'][
'show'][item]:
2089 self._display.SetVectorLineSurface(id, sid)
2091 self._display.UnsetVectorLineSurface(id, sid)
2094 if 'update' in data[
'mode']:
2095 data[
'mode'].pop(
'update')
2098 """!Update vector point map object properties"""
2099 if 'update' in data[
'size']
or \
2100 'update' in data[
'width']
or \
2101 'update' in data[
'marker']
or \
2102 'update' in data[
'color']:
2104 ret = self._display.SetVectorPointMode(id, data[
'color'][
'value'],
2105 data[
'width'][
'value'], float(data[
'size'][
'value']),
2106 data[
'marker'][
'value'] + 1)
2110 error = _(
"Vector point layer not found (id = %d)") % id
2112 error = _(
"Unable to set data layer properties (id = %d)") % id
2115 raise GException(_(
"Setting data layer properties failed.\n\n%s") % error)
2117 for prop
in (
'size',
'width',
'marker',
'color'):
2118 if 'update' in data[prop]:
2119 data[prop].pop(
'update')
2122 if 'update' in data[
'height']:
2123 self._display.SetVectorPointHeight(id,
2124 data[
'height'][
'value'])
2125 data[
'height'].pop(
'update')
2128 if 'update' in data[
'mode']:
2129 if data[
'mode'].get(
'3d',
False):
2130 self._display.SetVectorPointZMode(id,
True)
2131 elif 'surface' in data[
'mode']:
2132 self._display.SetVectorPointZMode(id,
False)
2133 for item
in range(len(data[
'mode'][
'surface'][
'value'])):
2134 for type
in (
'raster',
'constant'):
2136 name=data[
'mode'][
'surface'][
'value'][item])
2138 if data[
'mode'][
'surface'][
'show'][item]:
2139 self._display.SetVectorPointSurface(id, sid)
2141 self._display.UnsetVectorPointSurface(id, sid)
2143 data[
'mode'].pop(
'update')
2146 """!Return list of map layer names of given type"""
2149 if type ==
'constant':
2151 layerName.append(_(
"constant#") + str(item[
'constant'][
'object'][
'name']))
2154 mapLayer = self.tree.GetPyData(item)[0][
'maplayer']
2155 if type != mapLayer.GetType():
2158 layerName.append(mapLayer.GetName())
2163 """!Get layer object id or -1"""
2167 if type ==
'constant':
2169 if _(
"constant#") + str(item[
'constant'][
'object'][
'name']) == name:
2170 return item[
'constant'][
'object'][
'id']
2174 mapLayer = self.tree.GetPyData(item)[0][
'maplayer']
2175 if type != mapLayer.GetType()
or \
2176 name != mapLayer.GetName():
2179 data = self.tree.GetPyData(item)[0][
'nviz']
2182 if type ==
'raster':
2183 return data[
'surface'][
'object'][
'id']
2184 elif type ==
'vector':
2185 if vsubtyp ==
'vpoint':
2186 return data[
'vector'][
'points'][
'object'][
'id']
2187 elif vsubtyp ==
'vline':
2188 return data[
'vector'][
'lines'][
'object'][
'id']
2189 elif type ==
'3d-raster':
2190 return data[
'volume'][
'object'][
'id']
2196 """!Delete nviz data of all loaded layers and reload them from current settings"""
2198 type = self.tree.GetPyData(item)[0][
'type']
2199 layer = self.tree.GetPyData(item)[0][
'maplayer']
2200 data = self.tree.GetPyData(item)[0][
'nviz']
2202 if type ==
'raster':
2203 self.nvizDefault.SetSurfaceDefaultProp(data[
'surface'])
2204 if type ==
'vector':
2205 vInfo = grass.vector_info_topo(layer.GetName())
2206 if (vInfo[
'points'] + vInfo[
'centroids']) > 0:
2207 self.nvizDefault.SetVectorPointsDefaultProp(data[
'vector'][
'points'])
2208 if (vInfo[
'lines'] + vInfo[
'boundaries']) > 0:
2209 self.nvizDefault.SetVectorLinesDefaultProp(data[
'vector'][
'lines'])
2212 """!Generate command for m.nviz.image according to current state"""
2213 cmd =
'm.nviz.image '
2219 if self.tree.GetPyData(item)[0][
'type'] ==
'raster':
2220 rasters.append(item)
2221 elif self.tree.GetPyData(item)[0][
'type'] ==
'3d-raster':
2222 volumes.append(item)
2223 elif self.tree.GetPyData(item)[0][
'type'] ==
'vector':
2224 vectors.append(item)
2226 return _(
"At least one raster map required")
2229 subcmd =
"elevation_value="
2231 subcmd +=
"%d," % constant[
'constant'][
'value']
2232 subcmd = subcmd.strip(
', ') +
' '
2235 subcmd =
"elevation_map="
2236 for item
in rasters:
2237 subcmd +=
"%s," % self.tree.GetPyData(item)[0][
'maplayer'].GetName()
2238 subcmd = subcmd.strip(
', ') +
' '
2244 cmdFine =
"resolution_fine="
2245 cmdCoarse =
"resolution_coarse="
2246 cmdShading =
"shading="
2248 cmdWire =
"wire_color="
2251 nvizDataFirst = self.tree.GetPyData(rasters[0])[0][
'nviz'][
'surface'][
'draw']
2252 for item
in rasters:
2253 nvizData = self.tree.GetPyData(item)[0][
'nviz'][
'surface'][
'draw']
2254 if nvizDataFirst != nvizData:
2257 for item
in rasters:
2258 nvizData = self.tree.GetPyData(item)[0][
'nviz'][
'surface'][
'draw']
2260 cmdMode +=
"%s," % nvizData[
'mode'][
'desc'][
'mode']
2261 cmdFine +=
"%s," % nvizData[
'resolution'][
'fine']
2262 cmdCoarse +=
"%s," % nvizData[
'resolution'][
'coarse']
2263 cmdShading +=
"%s," % nvizData[
'mode'][
'desc'][
'shading']
2264 cmdStyle +=
"%s," % nvizData[
'mode'][
'desc'][
'style']
2265 cmdWire +=
"%s," % nvizData[
'wire-color'][
'value']
2268 cmdFine +=
"%s," % item[
'constant'][
'resolution']
2269 cmdCoarse +=
"%s," % item[
'constant'][
'resolution']
2270 cmdShading +=
"gouraud,"
2271 cmdStyle +=
"surface,"
2274 for subcmd
in (cmdMode, cmdFine, cmdCoarse, cmdShading, cmdStyle, cmdWire):
2276 mode.append(subcmd.split(
',')[0] +
' ')
2278 subcmd = subcmd.strip(
', ') +
' '
2282 if 'fine' in mode[0]:
2284 elif 'coarse' in mode[0]:
2286 elif 'both' in mode[0]:
2289 if 'flat' in mode[3]:
2291 if 'wire' in mode[4]:
2293 if 'coarse' in mode[0]
or 'both' in mode[0]
and 'wire' in mode[3]:
2298 cmdColorMap =
"color_map="
2299 cmdColorVal =
"color="
2300 for item
in rasters:
2301 nvizData = self.tree.GetPyData(item)[0][
'nviz'][
'surface'][
'attribute']
2302 if 'color' not in nvizData:
2303 cmdColorMap +=
"%s," % self.tree.GetPyData(item)[0][
'maplayer'].GetName()
2305 if nvizData[
'color'][
'map']:
2306 cmdColorMap +=
"%s," % nvizData[
'color'][
'value']
2308 cmdColorVal +=
"%s," % nvizData[
'color'][
'value']
2312 cmdColorVal +=
"%s," % item[
'constant'][
'color']
2313 if cmdColorMap.split(
"=")[1]:
2314 cmd += cmdColorMap.strip(
', ') +
' '
2315 if cmdColorVal.split(
"=")[1]:
2316 cmd += cmdColorVal.strip(
', ') +
' '
2322 cmdLines = cmdLWidth = cmdLHeight = cmdLColor = cmdLMode = cmdLPos = \
2323 cmdPoints = cmdPWidth = cmdPSize = cmdPColor = cmdPMarker = cmdPPos = cmdPLayer =
""
2324 markers = [
'x',
'box',
'sphere',
'cube',
'diamond',
2325 'dec_tree',
'con_tree',
'aster',
'gyro',
'histogram']
2326 for vector
in vectors:
2327 layerName = self.tree.GetPyData(vector)[0][
'maplayer'].GetName()
2328 vInfo = grass.vector_info_topo(layerName)
2329 nvizData = self.tree.GetPyData(vector)[0][
'nviz'][
'vector']
2330 if (vInfo[
'lines'] + vInfo[
'boundaries']) > 0:
2331 cmdLines +=
"%s," % self.tree.GetPyData(vector)[0][
'maplayer'].GetName()
2332 cmdLWidth +=
"%d," % nvizData[
'lines'][
'width'][
'value']
2333 cmdLHeight +=
"%d," % nvizData[
'lines'][
'height'][
'value']
2334 cmdLColor +=
"%s," % nvizData[
'lines'][
'color'][
'value']
2335 cmdLMode +=
"%s," % nvizData[
'lines'][
'mode'][
'type']
2336 cmdLPos +=
"0,0,%d," % nvizData[
'lines'][
'height'][
'value']
2337 if (vInfo[
'points'] + vInfo[
'centroids']) > 0:
2338 cmdPoints +=
"%s," % self.tree.GetPyData(vector)[0][
'maplayer'].GetName()
2339 cmdPWidth +=
"%d," % nvizData[
'points'][
'width'][
'value']
2340 cmdPSize +=
"%d," % nvizData[
'points'][
'size'][
'value']
2341 cmdPColor +=
"%s," % nvizData[
'points'][
'color'][
'value']
2342 cmdPMarker +=
"%s," % markers[nvizData[
'points'][
'marker'][
'value']]
2343 cmdPPos +=
"0,0,%d," % nvizData[
'points'][
'height'][
'value']
2346 cmd +=
"vline=" + cmdLines.strip(
',') +
' '
2347 cmd +=
"vline_width=" + cmdLWidth.strip(
',') +
' '
2348 cmd +=
"vline_color=" + cmdLColor.strip(
',') +
' '
2349 cmd +=
"vline_height=" + cmdLHeight.strip(
',') +
' '
2350 cmd +=
"vline_mode=" + cmdLMode.strip(
',') +
' '
2351 cmd +=
"vline_position=" + cmdLPos.strip(
',') +
' '
2353 cmd +=
"vpoint=" + cmdPoints.strip(
',') +
' '
2354 cmd +=
"vpoint_width=" + cmdPWidth.strip(
',') +
' '
2355 cmd +=
"vpoint_color=" + cmdPColor.strip(
',') +
' '
2356 cmd +=
"vpoint_size=" + cmdPSize.strip(
',') +
' '
2357 cmd +=
"vpoint_marker=" + cmdPMarker.strip(
',') +
' '
2358 cmd +=
"vpoint_position=" + cmdPPos.strip(
',') +
' '
2365 cmdName = cmdShade = cmdRes = cmdPos = cmdIso =
""
2366 cmdIsoColorMap = cmdIsoColorVal = cmdIsoTrMap = cmdIsoTrVal =
""
2367 cmdSlice = cmdSliceTransp = cmdSlicePos =
""
2368 for i, volume
in enumerate(volumes):
2369 nvizData = self.tree.GetPyData(volume)[0][
'nviz'][
'volume']
2370 cmdName +=
"%s," % self.tree.GetPyData(volume)[0][
'maplayer'].GetName()
2371 cmdShade +=
"%s," % nvizData[
'draw'][
'shading'][
'isosurface'][
'desc']
2372 cmdRes +=
"%d," % nvizData[
'draw'][
'resolution'][
'isosurface'][
'value']
2373 if nvizData[
'position']:
2374 cmdPos +=
"%d,%d,%d," % (nvizData[
'position'][
'x'], nvizData[
'position'][
'y'],
2375 nvizData[
'position'][
'z'])
2376 for iso
in nvizData[
'isosurface']:
2377 level = iso[
'topo'][
'value']
2378 cmdIso +=
"%d:%s," % (i + 1, level)
2379 if iso[
'color'][
'map']:
2380 cmdIsoColorMap +=
"%s," % iso[
'color'][
'value']
2382 cmdIsoColorVal +=
"%s," % iso[
'color'][
'value']
2384 if iso[
'transp'][
'map']:
2385 cmdIsoTrMap +=
"%s," % iso[
'transp'][
'value']
2387 cmdIsoTrVal +=
"%s," % iso[
'transp'][
'value']
2389 for slice
in nvizData[
'slice']:
2390 axis = (
'x',
'y',
'z')[slice[
'position'][
'axis']]
2391 cmdSlice +=
"%d:%s," % (i + 1, axis)
2392 for coord
in (
'x1',
'x2',
'y1',
'y2',
'z1',
'z2'):
2393 cmdSlicePos +=
"%f," % slice[
'position'][coord]
2394 cmdSliceTransp +=
"%s," % slice[
'transp'][
'value']
2396 cmd +=
"volume=" + cmdName.strip(
',') +
' '
2397 cmd +=
"volume_shading=" + cmdShade.strip(
',') +
' '
2398 cmd +=
"volume_resolution=" + cmdRes.strip(
',') +
' '
2399 if nvizData[
'position']:
2400 cmd +=
"volume_position=" + cmdPos.strip(
',') +
' '
2402 cmd +=
"isosurf_level=" + cmdIso.strip(
',') +
' '
2404 cmd +=
"isosurf_color_map=" + cmdIsoColorMap.strip(
',') +
' '
2406 cmd +=
"isosurf_color_value=" + cmdIsoColorVal.strip(
',') +
' '
2408 cmd +=
"isosurf_transparency_map=" + cmdIsoTrMap.strip(
',') +
' '
2410 cmd +=
"isosurf_transparency_value=" + cmdIsoTrVal.strip(
',') +
' '
2412 cmd +=
"slice=" + cmdSlice.strip(
',') +
' '
2413 cmd +=
"slice_position=" + cmdSlicePos.strip(
',') +
' '
2414 cmd +=
"slice_transparency=" + cmdSliceTransp.strip(
',') +
' '
2419 cplane = self.lmgr.nviz.FindWindowById(self.lmgr.nviz.win[
'cplane'][
'planes']).GetStringSelection()
2421 planeIndex = int(cplane.split()[-1]) - 1
2422 except (IndexError, ValueError):
2424 if planeIndex
is not None:
2425 shading = [
'clear',
'top',
'bottom',
'blend',
'shaded']
2426 cmd +=
"cplane=%d " % planeIndex
2427 cmd +=
"cplane_rotation=%d " % self.
cplanes[planeIndex][
'rotation'][
'rot']
2428 cmd +=
"cplane_tilt=%d " % self.
cplanes[planeIndex][
'rotation'][
'tilt']
2429 cmd +=
"cplane_position=%d,%d,%d " % (self.
cplanes[planeIndex][
'position'][
'x'],
2430 self.
cplanes[planeIndex][
'position'][
'y'],
2431 self.
cplanes[planeIndex][
'position'][
'z'])
2432 cmd +=
"cplane_shading=%s " % shading[self.
cplanes[planeIndex][
'shading']]
2437 subcmd =
"position=%.2f,%.2f " % (self.
view[
'position'][
'x'], self.
view[
'position'][
'y'])
2438 subcmd +=
"height=%d " % (self.
iview[
'height'][
'value'])
2439 subcmd +=
"perspective=%d " % (self.
view[
'persp'][
'value'])
2440 subcmd +=
"twist=%d " % (self.
view[
'twist'][
'value'])
2441 subcmd +=
"zexag=%f " % (self.
view[
'z-exag'][
'value'] / self.
iview[
'z-exag'][
'llRatio'])
2442 subcmd +=
"focus=%d,%d,%d " % (self.
iview[
'focus'][
'x'],self.
iview[
'focus'][
'y'],self.
iview[
'focus'][
'z'])
2446 subcmd =
"bgcolor=%d:%d:%d " % (self.
view[
'background'][
'color'][:3])
2447 if self.
view[
'background'][
'color'] != (255, 255, 255):
2451 subcmd =
"light_position=%.2f,%.2f,%.2f " % (self.
light[
'position'][
'x'],
2452 self.
light[
'position'][
'y'],
2453 self.
light[
'position'][
'z']/100.)
2454 subcmd +=
"light_brightness=%d " % (self.
light[
'bright'])
2455 subcmd +=
"light_ambient=%d " % (self.
light[
'ambient'])
2456 subcmd +=
"light_color=%d:%d:%d " % (self.
light[
'color'][:3])
2460 toolWindow = self.lmgr.nviz
2462 for dir
in (
'nw',
'ne',
'sw',
'se'):
2463 if toolWindow.FindWindowById(toolWindow.win[
'fringe'][dir]).IsChecked():
2464 direction +=
"%s," % dir
2466 subcmd =
"fringe=%s " % (direction.strip(
','))
2467 color = toolWindow.FindWindowById(toolWindow.win[
'fringe'][
'color']).
GetValue()
2468 subcmd +=
"fringe_color=%d:%d:%d " % (color[0], color[1], color[2])
2469 subcmd +=
"fringe_elevation=%d " % (toolWindow.FindWindowById(toolWindow.win[
'fringe'][
'elev']).
GetValue())
2474 subcmd =
"arrow_position=%d,%d " % (self.
decoration[
'arrow'][
'position'][
'x'],
2476 subcmd +=
"arrow_color=%s " % self.
decoration[
'arrow'][
'color']
2477 subcmd +=
"arrow_size=%d " % self.
decoration[
'arrow'][
'size']
2481 subcmd =
'output=nviz_output '
2482 subcmd +=
'format=ppm '
2483 subcmd +=
'size=%d,%d ' % self.GetClientSizeTuple()
2489 """!Generate and write command to command output"""
2493 """!This draws the DC to a buffer that can be saved to a file.
2495 @todo fix BufferedPaintDC
2497 @param FileName file name
2498 @param FileType type of bitmap
2499 @param width image width
2500 @param height image height
2502 self._display.SaveToFile(FileName, width, height, FileType)
2513 """!Get display instance"""
2519 self.lmgr.nviz.OnResetView(
None)
2522 """!Return text boundary data
2524 @param textinfo text metadata (text, font, color, rotation)
2526 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.