[GRASS-SVN] r32106 - in grass/trunk/gui/wxpython: gui_modules xml
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 14 16:23:10 EDT 2008
Author: martinl
Date: 2008-07-14 16:23:10 -0400 (Mon, 14 Jul 2008)
New Revision: 32106
Modified:
grass/trunk/gui/wxpython/gui_modules/nviz.py
grass/trunk/gui/wxpython/gui_modules/workspace.py
grass/trunk/gui/wxpython/xml/grass-gxw.dtd
Log:
nviz2/wxGUI: surface/vector lines attribute fixes
Modified: grass/trunk/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-14 18:03:49 UTC (rev 32105)
+++ grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-14 20:23:10 UTC (rev 32106)
@@ -166,6 +166,7 @@
if wheel != 0:
current = event.GetPositionTuple()[:]
Debug.msg (5, "GLWindow.OnMouseMotion(): wheel=%d" % wheel)
+ prev_value = self.view['persp']['value']
if wheel > 0:
value = -1 * self.view['persp']['step']
else:
@@ -176,19 +177,20 @@
elif self.view['persp']['value'] > 100:
self.view['persp']['value'] = 100
- if hasattr(self.parent, "nvizToolWin"):
- self.parent.nvizToolWin.UpdateSettings()
+ if prev_value != self.view['persp']['value']:
+ if hasattr(self.parent, "nvizToolWin"):
+ self.parent.nvizToolWin.UpdateSettings()
- self.nvizClass.SetView(self.view['pos']['x'], self.view['pos']['y'],
- self.iview['height']['value'],
- self.view['persp']['value'],
- self.view['twist']['value'])
+ self.nvizClass.SetView(self.view['pos']['x'], self.view['pos']['y'],
+ self.iview['height']['value'],
+ self.view['persp']['value'],
+ self.view['twist']['value'])
- # redraw map
- self.OnPaint(None)
+ # redraw map
+ self.OnPaint(None)
- # update statusbar
- ### self.parent.StatusbarUpdate()
+ # update statusbar
+ ### self.parent.StatusbarUpdate()
def OnLeftDown(self, event):
self.CaptureMouse()
@@ -266,6 +268,8 @@
Debug.msg(3, "GLWindow.UpdateMap(): render=%s, -> time=%g" % \
(self.render, (stop-start)))
+ # print stop-start
+
def EraseMap(self):
"""
Erase the canvas
@@ -299,6 +303,8 @@
item = self.tree.GetNextSibling(item)
+ start = time.time()
+
while(len(listOfItems) > 0):
item = listOfItems.pop()
type = self.tree.GetPyData(item)[0]['type']
@@ -346,6 +352,14 @@
self.UpdateLayerProperties(item)
+ # print data
+
+ stop = time.time()
+
+ Debug.msg(3, "GLWindow.LoadDataLayers(): time=%f" % (stop-start))
+
+ # print stop - start
+
def LoadRaster(self, layer):
"""Load raster map -> surface"""
if layer.type != 'raster':
@@ -364,11 +378,32 @@
raise gcmd.NvizError(parent=self.parent,
message=_("Unable to unload raster map <%s>" % layer.name))
- def GetSurfaceMode(self, mode, style, shade):
+ def GetSurfaceMode(self, mode, style, shade, string=False):
"""Determine surface draw mode"""
value = 0
desc = {}
+ if string:
+ if mode == 'coarse':
+ value |= wxnviz.DM_WIRE
+ elif mode == 'fine':
+ value |= wxnviz.DM_POLY
+ else: # both
+ value |= wxnviz.DM_WIRE_POLY
+
+ if style == 'wire':
+ value |= wxnviz.DM_GRID_WIRE
+ else: # surface
+ value |= wxnviz.DM_GRID_SURF
+
+ if shade == 'flat':
+ value |= wxnviz.DM_FLAT
+ else: # surface
+ value |= wxnviz.DM_GOURAUD
+
+ return value
+
+ # -> string is False
if mode == 0: # coarse
value |= wxnviz.DM_WIRE
desc['mode'] = 'coarse'
@@ -613,6 +648,12 @@
# draw style
if 'surface:draw:mode' in self.update:
+ if data['draw']['mode']['value'] < 0: # need to calculate
+ data['draw']['mode']['value'] = \
+ self.GetSurfaceMode(mode=data['draw']['mode']['desc']['mode'],
+ style=data['draw']['mode']['desc']['style'],
+ shade=data['draw']['mode']['desc']['shading'],
+ string=True)
style = data['draw']['mode']['value']
if data['draw']['mode']['all']:
self.nvizClass.SetSurfaceStyle(-1, style)
@@ -631,9 +672,9 @@
# position
if 'surface:position' in self.update:
- x = data['surface']['position']['x']
- y = data['surface']['position']['y']
- z = data['surface']['position']['z']
+ x = data['position']['x']
+ y = data['position']['y']
+ z = data['position']['z']
self.nvizClass.SetSurfacePosition(id, x, y, z)
self.update.remove('surface:position')
@@ -960,6 +1001,7 @@
choices = [_("coarse"),
_("fine"),
_("both")])
+ mode.SetSelection(0)
mode.SetName("selection")
mode.Bind(wx.EVT_CHOICE, self.OnSurfaceMode)
self.win['surface']['draw']['mode'] = mode.GetId()
@@ -1841,14 +1883,16 @@
value, desc = self.mapWindow.GetSurfaceMode(mode, style, shade)
+ return value, desc
+
def OnSurfaceMode(self, event):
"""Set draw mode"""
- self.SetSurfaceMode()
+ value, desc = self.SetSurfaceMode()
self.mapWindow.update.append('surface:draw:mode')
data = self.mapWindow.GetSelectedLayer(nviz=True)
data['surface']['draw']['mode'] = { 'value' : value,
- 'all' : all,
+ 'all' : False,
'desc' : desc }
self.mapWindow.UpdateLayerProperties()
@@ -2044,7 +2088,10 @@
self.SetSurfaceUseMap('shine', data['attribute']['shine']['map'])
value = data['attribute']['shine']['value']
- self.FindWindowById(self.win['surface']['shine']['const']).SetValue(value)
+ if data['attribute']['shine']['map']:
+ self.FindWindowById(self.win['surface']['shine']['map']).SetValue(value)
+ else:
+ self.FindWindowById(self.win['surface']['shine']['const']).SetValue(value)
#
# draw
Modified: grass/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py 2008-07-14 18:03:49 UTC (rev 32105)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py 2008-07-14 20:23:10 UTC (rev 32106)
@@ -129,8 +129,7 @@
elif name == 'parameter':
self.parameterName = attrs.get('name', None)
- elif name in ('value', 'x', 'y', 'z',
- 'color', 'width', 'height'):
+ elif name in ('value', 'x', 'y', 'z'):
self.value = ''
elif name == 'flag':
@@ -289,10 +288,7 @@
if self.inTag['value'] or \
self.inTag['x'] or \
self.inTag['y'] or \
- self.inTag['z'] or \
- self.inTag['color'] or \
- self.inTag['width'] or \
- self.inTag['height']:
+ self.inTag['z']:
self.value += ch
class WriteWorkspaceFile(object):
@@ -506,8 +502,11 @@
self.indent -= 4
self.file.write('%s</%s>\n' % ((' ' * self.indent, name)))
else:
- self.file.write('%s<%s>' % (' ' * self.indent, name))
- self.file.write('%s</%s>\n' % (data[attrb][name], name))
+ self.file.write('%s<%s>\n' % (' ' * self.indent, name))
+ self.indent += 4
+ self.file.write('%s<value>%s</value>\n' % (' ' * self.indent, data[attrb][name]))
+ self.indent -= 4
+ self.file.write('%s</%s>\n' % (' ' * self.indent, name))
self.indent -= 4
self.file.write('%s</%s>\n' % (' ' * self.indent, attrb))
Modified: grass/trunk/gui/wxpython/xml/grass-gxw.dtd
===================================================================
--- grass/trunk/gui/wxpython/xml/grass-gxw.dtd 2008-07-14 18:03:49 UTC (rev 32105)
+++ grass/trunk/gui/wxpython/xml/grass-gxw.dtd 2008-07-14 20:23:10 UTC (rev 32106)
@@ -77,11 +77,12 @@
<!-- nviz layer properties
-->
-<!ELEMENT nviz (attribute*, draw?)>
+<!ELEMENT nviz (attribute*, draw?, position?, lines?)>
<!-- nviz surface attribute parameter
-->
<!ELEMENT attribute (value)>
+<!ATTLIST attribute name CDATA #REQUIRED>
<!ATTLIST attribute map (0 | 1) #REQUIRED>
<!-- nviz surface draw mode parameter
@@ -98,3 +99,22 @@
<!-- nviz surface wire color
-->
<!ELEMENT wire_color (value)>
+
+<!-- nviz surface position
+-->
+<!ELEMENT position (x, y, z)>
+
+<!-- nviz surface position coordinate
+-->
+<!ELEMENT x (#PCDATA)>
+<!ELEMENT y (#PCDATA)>
+<!ELEMENT z (#PCDATA)>
+
+<!-- nviz vector lines element
+-->
+<!ELEMENT lines (color?, width?, mode?, height?)>
+<!ELEMENT color (value)>
+<!ELEMENT width (value)>
+<!ELEMENT height (value)>
+<!ELEMENT mode (map?)>
+<!ATTLIST mode type (flat | surface) #REQUIRED>
More information about the grass-commit
mailing list