[GRASS-SVN] r42924 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jul 28 13:50:18 EDT 2010
Author: martinl
Date: 2010-07-28 17:50:18 +0000 (Wed, 28 Jul 2010)
New Revision: 42924
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/debug.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py
Log:
wxGUI/nviz: now working again (replaced by wxnviz python module)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/debug.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/debug.py 2010-07-28 13:39:31 UTC (rev 42923)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/debug.py 2010-07-28 17:50:18 UTC (rev 42924)
@@ -49,11 +49,15 @@
if self.debuglevel != level:
self.debuglevel = level
- def msg (self, level, message):
+ def msg (self, level, message, *args):
self._update_level()
if self.debuglevel > 0 and level > 0 and level <= self.debuglevel:
- print >> sys.stderr, "GUI D%d/%d: %s" % (level, self.debuglevel, message)
-
+ if args:
+ print >> sys.stderr, "GUI D%d/%d: " % (level, self.debuglevel) + \
+ message % args
+ else:
+ print >> sys.stderr, "GUI D%d/%d: " % (level, self.debuglevel) + \
+ message
sys.stderr.flush() # force flush (required for MS Windows)
def get_level(self):
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz.py 2010-07-28 13:39:31 UTC (rev 42923)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz.py 2010-07-28 17:50:18 UTC (rev 42924)
@@ -27,8 +27,8 @@
try:
from wx import glcanvas
import nviz_mapdisp
- sys.path.append(os.path.join(globalvar.ETCWXDIR, "nviz"))
- import grass6_wxnviz as wxnviz
+ import nviz_tools
+ import wxnviz
haveNviz = True
except ImportError, err:
haveNviz = False
@@ -36,5 +36,7 @@
if haveNviz:
GLWindow = nviz_mapdisp.GLWindow
+ NvizToolWindow = nviz_tools.NvizToolWindow
else:
GLWindow = None
+ NvizToolWindow = None
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py 2010-07-28 13:39:31 UTC (rev 42923)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py 2010-07-28 17:50:18 UTC (rev 42924)
@@ -116,7 +116,7 @@
pos = (0, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_BOTTOM)
view = ViewPositionWindow(panel, size = (175, 175),
mapwindow = self.mapWindow)
- self.win['view']['pos'] = view.GetId()
+ self.win['view']['position'] = view.GetId()
posSizer.Add(item = view,
pos = (1, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)
posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("S")),
@@ -1137,7 +1137,7 @@
pos = (0, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_BOTTOM)
pos = LightPositionWindow(panel, id = wx.ID_ANY, size = (175, 175),
mapwindow = self.mapWindow)
- self.win['light']['pos'] = pos.GetId()
+ self.win['light']['position'] = pos.GetId()
posSizer.Add(item = pos,
pos = (1, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)
posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("S")),
@@ -1407,9 +1407,9 @@
self.FindWindowById(win).SetValue(value)
- viewWin = self.FindWindowById(self.win['view']['pos'])
- x, y = viewWin.UpdatePos(self.mapWindow.view['pos']['x'],
- self.mapWindow.view['pos']['y'])
+ viewWin = self.FindWindowById(self.win['view']['position'])
+ x, y = viewWin.UpdatePos(self.mapWindow.view['position']['x'],
+ self.mapWindow.view['position']['y'])
viewWin.Draw(pos = (x, y), scale = True)
viewWin.Refresh(False)
@@ -1433,7 +1433,7 @@
return
val = event.GetInt()
- self.mapWindow.light['pos']['z'] = val / 100.
+ self.mapWindow.light['position']['z'] = val / 100.
for win in self.win['light'][winName].itervalues():
self.FindWindowById(win).SetValue(val)
@@ -1557,32 +1557,32 @@
"""!Look at (view page)"""
sel = event.GetSelection()
if sel == 0: # top
- self.mapWindow.view['pos']['x'] = 0.5
- self.mapWindow.view['pos']['y'] = 0.5
+ self.mapWindow.view['position']['x'] = 0.5
+ self.mapWindow.view['position']['y'] = 0.5
elif sel == 1: # north
- self.mapWindow.view['pos']['x'] = 0.5
- self.mapWindow.view['pos']['y'] = 0.0
+ self.mapWindow.view['position']['x'] = 0.5
+ self.mapWindow.view['position']['y'] = 0.0
elif sel == 2: # south
- self.mapWindow.view['pos']['x'] = 0.5
- self.mapWindow.view['pos']['y'] = 1.0
+ self.mapWindow.view['position']['x'] = 0.5
+ self.mapWindow.view['position']['y'] = 1.0
elif sel == 3: # east
- self.mapWindow.view['pos']['x'] = 1.0
- self.mapWindow.view['pos']['y'] = 0.5
+ self.mapWindow.view['position']['x'] = 1.0
+ self.mapWindow.view['position']['y'] = 0.5
elif sel == 4: # west
- self.mapWindow.view['pos']['x'] = 0.0
- self.mapWindow.view['pos']['y'] = 0.5
+ self.mapWindow.view['position']['x'] = 0.0
+ self.mapWindow.view['position']['y'] = 0.5
elif sel == 5: # north-west
- self.mapWindow.view['pos']['x'] = 0.0
- self.mapWindow.view['pos']['y'] = 0.0
+ self.mapWindow.view['position']['x'] = 0.0
+ self.mapWindow.view['position']['y'] = 0.0
elif sel == 6: # north-east
- self.mapWindow.view['pos']['x'] = 1.0
- self.mapWindow.view['pos']['y'] = 0.0
+ self.mapWindow.view['position']['x'] = 1.0
+ self.mapWindow.view['position']['y'] = 0.0
elif sel == 7: # south-east
- self.mapWindow.view['pos']['x'] = 1.0
- self.mapWindow.view['pos']['y'] = 1.0
+ self.mapWindow.view['position']['x'] = 1.0
+ self.mapWindow.view['position']['y'] = 1.0
elif sel == 8: # south-west
- self.mapWindow.view['pos']['x'] = 0.0
- self.mapWindow.view['pos']['y'] = 1.0
+ self.mapWindow.view['position']['x'] = 0.0
+ self.mapWindow.view['position']['y'] = 1.0
self.PostViewEvent(zExag = True)
@@ -2427,7 +2427,7 @@
elif pageId == 'volume':
self.UpdateVectorPage(layer, data['vector'])
elif pageId == 'light':
- zval = self.mapWindow.light['pos']['z']
+ zval = self.mapWindow.light['position']['z']
bval = self.mapWindow.light['bright']
aval = self.mapWindow.light['ambient']
for control in ('spin', 'slider'):
@@ -2785,8 +2785,8 @@
elif ycoord > 1.0:
ycoord = 1.0
- self.data['pos']['x'] = xcoord
- self.data['pos']['y'] = ycoord
+ self.data['position']['x'] = xcoord
+ self.data['position']['y'] = ycoord
return xcoord, ycoord
@@ -2803,8 +2803,8 @@
event.Skip()
def PostDraw(self):
- x, y = self.UpdatePos(self.data['pos']['x'],
- self.data['pos']['y'])
+ x, y = self.UpdatePos(self.data['position']['x'],
+ self.data['position']['y'])
self.Draw(pos = (x, y), scale = True)
class ViewPositionWindow(PositionWindow):
@@ -2923,8 +2923,8 @@
flag = wx.ALIGN_CENTER_VERTICAL)
# position
- self.win['view']['pos'] = {}
- posvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'pos')
+ self.win['view']['position'] = {}
+ posvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'position')
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Position:")),
pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
@@ -2936,7 +2936,7 @@
initial = posvals['x'] * 100,
min = 0,
max = 100)
- self.win['view']['pos']['x'] = px.GetId()
+ self.win['view']['position']['x'] = px.GetId()
gridSizer.Add(item = px, pos = (1, 2),
flag = wx.ALIGN_CENTER_VERTICAL)
@@ -2948,7 +2948,7 @@
initial = posvals['y'] * 100,
min = 0,
max = 100)
- self.win['view']['pos']['y'] = py.GetId()
+ self.win['view']['position']['y'] = py.GetId()
gridSizer.Add(item = py, pos = (1, 4),
flag = wx.ALIGN_CENTER_VERTICAL)
@@ -3193,7 +3193,7 @@
for subvalue in value.keys():
win = self.FindWindowById(self.win[subgroup][subkey][subvalue])
val = settings[subgroup][subkey][subvalue]
- if subkey == 'pos':
+ if subkey == 'position':
val = int(val * 100)
win.SetValue(val)
@@ -3218,7 +3218,7 @@
value = tuple(win.GetColour())
else:
value = win.GetValue()
- if subkey == 'pos':
+ if subkey == 'position':
value = float(value) / 100
settings[subgroup][subkey][subvalue] = value
@@ -3288,8 +3288,8 @@
continue
self.toolWin.UpdateSettings()
- self.FindWindowById(self.win['view']['pos']).Draw()
- self.FindWindowById(self.win['view']['pos']).Refresh(False)
+ self.FindWindowById(self.win['view']['position']).Draw()
+ self.FindWindowById(self.win['view']['position']).Refresh(False)
self.mapWindow.render['quick'] = False
self.mapWindow.Refresh(False)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2010-07-28 13:39:31 UTC (rev 42923)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2010-07-28 17:50:18 UTC (rev 42924)
@@ -189,6 +189,8 @@
from wxnviz import errorMsg as errorMsg2
if errorMsg2:
errorMsg = str(errorMsg1) + ' (' + str(errorMsg2) + ')'
+ else:
+ errorMsg = str(errorMsg1)
log.WriteCmdLog(_('3D view mode not available'))
log.WriteWarning(_('Reason: %s') % errorMsg)
log.WriteLog(_('Note that the 3D view mode is currently not working under MS Windows '
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py 2010-07-28 13:39:31 UTC (rev 42923)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py 2010-07-28 17:50:18 UTC (rev 42924)
@@ -37,8 +37,7 @@
from preferences import globalSettings as UserSettings
try:
- sys.path.append(os.path.join(globalvar.ETCWXDIR, "nviz"))
- import grass6_wxnviz as wxnviz
+ import wxnviz
except ImportError:
wxnviz = None
@@ -455,11 +454,11 @@
data['draw'][control] = { 'value' : value }
data['draw'][control]['update'] = None
-
+
value, desc = self.GetDrawMode(UserSettings.Get(group='nviz', key='surface', subkey=['draw', 'mode']),
UserSettings.Get(group='nviz', key='surface', subkey=['draw', 'style']),
UserSettings.Get(group='nviz', key='surface', subkey=['draw', 'shading']))
-
+
data['draw']['mode'] = { 'value' : value,
'desc' : desc,
'update': None }
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py 2010-07-28 13:39:31 UTC (rev 42923)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py 2010-07-28 17:50:18 UTC (rev 42924)
@@ -195,7 +195,7 @@
@return object id
@return -1 on failure
"""
- mapset = G_find_raster2(name, "")
+ mapset = G_find_cell2(name, "")
if mapset is None:
G_warning(_("Raster map <%s> not found"), name)
return -1
@@ -206,7 +206,7 @@
self.data)
if color_name: # check for color map
- mapset = G_find_raster2(color_name, "")
+ mapset = G_find_cell2(color_name, "")
if mapset is None:
G_warning(_("Raster map <%s> not found"), color_name)
GS_delete_surface(id)
@@ -487,8 +487,11 @@
Debug.msg(3, "Nviz::SetSurfaceAttr(): id=%d, attr=%d, map=%d, value=%s",
id, attr, map, value)
- return 1 if ret else -2
-
+ if ret < 0:
+ return -2
+
+ return 1
+
def UnsetSurfaceMask(self, id):
"""!Unset surface mask
@@ -541,7 +544,10 @@
ret = Nviz_unset_attr(id, MAP_OBJ_SURF, attr)
- return 1 if ret else -2
+ if ret < 0:
+ return -2
+
+ return 1
def SetSurfaceRes(self, id, fine, coarse):
"""!Set surface resolution
@@ -852,7 +858,10 @@
ret = GVL_isosurf_del(id, isosurf_id)
- return -3 if ret < 0 else 1
+ if ret < 0:
+ return -3
+
+ return 1
def MoveIsosurface(self, id, isosurf_id, up):
"""!Move isosurface up/down in the list
@@ -877,8 +886,11 @@
else:
ret = GVL_isosurf_move_down(id, isosurf_id)
- return -3 if ret < 0 else 1
+ if ret < 0:
+ return -3
+ return 1
+
def SetIsosurfaceColor(self, id, isosurf_id, map, value):
"""!Set isosurface color
@@ -990,7 +1002,10 @@
"attr=%d, map=%d, value=%s",
id, isosurf_id, attr, map, value)
- return 1 if ret > 0 else -2
+ if ret < 0:
+ return -2
+
+ return 1
def UnsetIsosurfaceMask(self, id, isosurf_id):
"""!Unset isosurface mask
@@ -1054,7 +1069,10 @@
ret = GVL_isosurf_unset_att(id, isosurf_id, attr)
- return 1 if ret > 0 else -2
+ if ret < 0:
+ return -2
+
+ return 1
def SetIsosurfaceMode(self, id, mode):
"""!Set draw mode for isosurfaces
@@ -1070,7 +1088,10 @@
ret = GVL_isosurf_set_drawmode(id, mode)
- return -2 if ret < 0 else 1
+ if ret < 0:
+ return -2
+
+ return 1
def SetIsosurfaceRes(self, id, res):
"""!Set draw resolution for isosurfaces
@@ -1086,7 +1107,10 @@
ret = GVL_isosurf_set_drawres(id, res, res, res)
- return -2 if ret < 0 else 1
+ if ret < 0:
+ return -2
+
+ return 1
def SaveToFile(self, filename, width = 20, height = 20, itype = 'ppm'):
"""!Save current GL screen to ppm/tif file
More information about the grass-commit
mailing list