[GRASS-SVN] r42521 - in grass/branches/develbranch_6:
gui/wxpython/gui_modules gui/wxpython/icons lib/nviz lib/ogsf
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jun 8 15:40:36 EDT 2010
Author: martinl
Date: 2010-06-08 15:40:35 -0400 (Tue, 08 Jun 2010)
New Revision: 42521
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py
grass/branches/develbranch_6/gui/wxpython/icons/icon.py
grass/branches/develbranch_6/lib/nviz/change_view.c
grass/branches/develbranch_6/lib/nviz/cplanes_obj.c
grass/branches/develbranch_6/lib/nviz/draw.c
grass/branches/develbranch_6/lib/nviz/exag.c
grass/branches/develbranch_6/lib/nviz/lights.c
grass/branches/develbranch_6/lib/nviz/map_obj.c
grass/branches/develbranch_6/lib/nviz/nviz.c
grass/branches/develbranch_6/lib/nviz/position.c
grass/branches/develbranch_6/lib/nviz/render.c
grass/branches/develbranch_6/lib/ogsf/GS2.c
Log:
wxGUI/nviz: lighting in progress
(merge r42519 from trunk)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-06-08 19:40:35 UTC (rev 42521)
@@ -127,7 +127,7 @@
self.view = copy.deepcopy(UserSettings.Get(group = 'nviz', key = 'view')) # copy
self.iview = UserSettings.Get(group = 'nviz', key = 'view', internal = True)
self.nvizDefault = NvizDefault()
- self.lighting = copy.deepcopy(UserSettings.Get(group = 'nviz', key = 'lighting')) # copy
+ self.light = copy.deepcopy(UserSettings.Get(group = 'nviz', key = 'light')) # copy
self.size = None
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
@@ -180,6 +180,7 @@
if hasattr(self._layermanager, "nviz"):
self._layermanager.nviz.UpdatePage('view')
+ self._layermanager.nviz.UpdatePage('light')
layer = self.GetSelectedLayer()
if layer:
if layer.type == 'raster':
@@ -226,7 +227,7 @@
if prev_value != self.view['persp']['value']:
if hasattr(self._layermanager, "nviz"):
self._layermanager.nviz.UpdateSettings()
-
+
self._display.SetView(self.view['pos']['x'], self.view['pos']['y'],
self.iview['height']['value'],
self.view['persp']['value'],
@@ -259,14 +260,12 @@
event.Skip()
def UpdateLight(self, event):
- """!Change lighting settings"""
- data = self.lighting
+ """!Change light settings"""
+ data = self.light
self._display.SetLight(x = data['pos']['x'], y = data['pos']['y'],
z = data['pos']['z'])
+ self._display.DrawLightingModel()
- if event:
- event.Skip()
-
def UpdateMap(self, render = True):
"""!Updates the canvas anytime there is a change to the
underlaying images or to the geometry of the canvas.
@@ -276,6 +275,7 @@
start = time.clock()
self.resize = False
+ self.SwapBuffers()
if self.render['quick'] is False:
self.parent.statusbarWin['progress'].Show()
@@ -296,8 +296,6 @@
else: # None -> reuse last rendered image
pass # TODO
- self.SwapBuffers()
-
stop = time.clock()
if self.render['quick'] is False:
@@ -765,11 +763,13 @@
self.iview['height']['value'], \
self.iview['height']['min'], \
self.iview['height']['max'] = self._display.SetViewDefault()
+ self.view['z-exag']['min'] = 0
+ self.view['z-exag']['max'] = self.view['z-exag']['value'] * 10
self.view['pos']['x'] = UserSettings.Get(group = 'nviz', key = 'view',
subkey = ('pos', 'x'))
self.view['pos']['y'] = UserSettings.Get(group = 'nviz', key = 'view',
- subkey = ('pos', 'x'))
+ subkey = ('pos', 'y'))
self.view['persp']['value'] = UserSettings.Get(group = 'nviz', key = 'view',
subkey = ('persp', 'value'))
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py 2010-06-08 19:40:35 UTC (rev 42521)
@@ -62,7 +62,6 @@
self.page = {} # page ids
# view page
- self.viewPos = ""
self.AddPage(page = self._createViewPage(),
text = " %s " % _("View"))
# surface page
@@ -74,9 +73,9 @@
# volume page
self.AddPage(page = self._createVolumePage(),
text = " %s " % _("Volume"))
- # lighting page
- self.AddPage(page = self._createLightingPage(),
- text = " %s " % _("Lighting"))
+ # light page
+ self.AddPage(page = self._createLightPage(),
+ text = " %s " % _("Light"))
self.UpdateSettings()
self.pageChanging = False
@@ -119,10 +118,10 @@
pos = (1, 0), flag = wx.ALIGN_CENTER)
posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("N")),
pos = (0, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_BOTTOM)
- self.viewPos = ViewPositionWindow(panel, size = (175, 175),
- mapwindow = self.mapWindow)
- self.win['view']['pos'] = self.viewPos.GetId()
- posSizer.Add(item=self.viewPos,
+ view = ViewPositionWindow(panel, size = (175, 175),
+ mapwindow = self.mapWindow)
+ self.win['view']['pos'] = 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")),
pos = (2, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_TOP)
@@ -1069,19 +1068,19 @@
return panel
- def _createLightingPage(self):
- """!Create lighting page"""
+ def _createLightPage(self):
+ """!Create light page"""
panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
panel.SetupScrolling(scroll_x = False)
- self.page['lighting'] = { 'id' : 4 }
- self.win['lighting'] = {}
+ self.page['light'] = { 'id' : 4 }
+ self.win['light'] = {}
pageSizer = wx.BoxSizer(wx.VERTICAL)
show = wx.CheckBox(parent = panel, id = wx.ID_ANY,
- label = _("Show lighting model"))
- show.Bind(wx.EVT_CHECKBOX, self.OnShowLightingModel)
+ label = _("Show light model"))
+ show.Bind(wx.EVT_CHECKBOX, self.OnShowLightModel)
pageSizer.Add(item = show, proportion = 0,
flag = wx.ALL, border = 3)
surface = wx.CheckBox(parent = panel, id = wx.ID_ANY,
@@ -1102,7 +1101,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['lighting']['pos'] = pos.GetId()
+ self.win['light']['pos'] = 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")),
@@ -1112,16 +1111,16 @@
gridSizer.Add(item = posSizer, pos = (0, 0))
# height
- self._createControl(panel, dict = self.win['lighting'], name = 'height', sliderHor = False,
- range = (0, 1),
- bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedSpin))
+ self._createControl(panel, dict = self.win['light'], name = 'z', sliderHor = False,
+ range = (0, 100),
+ bind = (self.OnLightChange, None, self.OnLightChange))
heightSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
heightSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("Height:")),
pos = (0, 0), flag = wx.ALIGN_LEFT, span = (1, 2))
- heightSizer.Add(item = self.FindWindowById(self.win['lighting']['height']['slider']),
+ heightSizer.Add(item = self.FindWindowById(self.win['light']['z']['slider']),
flag = wx.ALIGN_RIGHT, pos = (1, 0))
- heightSizer.Add(item = self.FindWindowById(self.win['lighting']['height']['spin']),
+ heightSizer.Add(item = self.FindWindowById(self.win['light']['z']['spin']),
flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.TOP |
wx.BOTTOM | wx.RIGHT, pos = (1, 1))
@@ -1143,28 +1142,28 @@
pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
color = csel.ColourSelect(panel, id = wx.ID_ANY,
colour = UserSettings.Get(group = 'nviz', key = 'settings',
- subkey = ['lighting', 'color']),
+ subkey = ['light', 'color']),
size = globalvar.DIALOG_COLOR_SIZE)
gridSizer.Add(item = color, pos = (0, 2))
gridSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("Brightness:")),
pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
- self._createControl(panel, dict = self.win['lighting'], name = 'brightness', size = 300,
+ self._createControl(panel, dict = self.win['light'], name = 'bright', size = 300,
range = (0, 1000),
bind = (self.OnVectorHeight, self.OnVectorHeightFull, self.OnVectorHeightSpin))
- gridSizer.Add(item = self.FindWindowById(self.win['lighting']['brightness']['slider']),
+ gridSizer.Add(item = self.FindWindowById(self.win['light']['bright']['slider']),
pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL)
- gridSizer.Add(item = self.FindWindowById(self.win['lighting']['brightness']['spin']),
+ gridSizer.Add(item = self.FindWindowById(self.win['light']['bright']['spin']),
pos = (1, 2),
flag = wx.ALIGN_CENTER)
gridSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("Ambient:")),
pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL)
- self._createControl(panel, dict = self.win['lighting'], name = 'ambient', size = 300,
+ self._createControl(panel, dict = self.win['light'], name = 'ambient', size = 300,
range = (0, 1000),
bind = (self.OnVectorHeight, self.OnVectorHeightFull, self.OnVectorHeightSpin))
- gridSizer.Add(item = self.FindWindowById(self.win['lighting']['ambient']['slider']),
+ gridSizer.Add(item = self.FindWindowById(self.win['light']['ambient']['slider']),
pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL)
- gridSizer.Add(item = self.FindWindowById(self.win['lighting']['ambient']['spin']),
+ gridSizer.Add(item = self.FindWindowById(self.win['light']['ambient']['spin']),
pos = (2, 2),
flag = wx.ALIGN_CENTER)
@@ -1206,9 +1205,6 @@
val = self.mapWindow.view[name]['value']
except KeyError:
val = -1
-
- if name == 'z-exag':
- val = 1
slider = wx.Slider(parent = parent, id = wx.ID_ANY,
value = val,
@@ -1218,8 +1214,9 @@
size = sizeW)
slider.SetName('slider')
slider.Bind(wx.EVT_SCROLL, bind[0])
- slider.Bind(wx.EVT_COMMAND_SCROLL_THUMBRELEASE, bind[1])
- # slider.Bind(wx.EVT_SCROLL_CHANGED, bind[1]) # this only works in MSW
+ # slider.Bind(wx.EVT_SCROLL_THUMBRELEASE, bind[1])
+ if bind[1]:
+ slider.Bind(wx.EVT_SCROLL_CHANGED, bind[1]) # this only works in MSW
dict[name]['slider'] = slider.GetId()
slider.SetValue(val)
@@ -1231,11 +1228,6 @@
spin.SetValue(val)
- # spin = wx.SpinButton(parent = parent, id = wx.ID_ANY)
- # spin.SetValue (self.mapWindow.view[name]['value'])
- # spin.SetRange(self.mapWindow.view[name]['min'],
- # self.mapWindow.view[name]['max'])
-
# no 'changed' event ... (FIXME)
spin.SetName('spin')
spin.Bind(wx.EVT_SPINCTRL, bind[2])
@@ -1269,11 +1261,11 @@
value = self.mapWindow.view[control]['value']
self.FindWindowById(win).SetValue(value)
- x = self.mapWindow.view['pos']['x']
- y = self.mapWindow.view['pos']['y']
- self.viewPos.UpdatePos(x, y)
- self.FindWindowById(self.win['view']['pos']).Draw(pos = (x, y), scale = True)
- self.FindWindowById(self.win['view']['pos']).Refresh(False)
+ viewWin = self.FindWindowById(self.win['view']['pos'])
+ x, y = viewWin.UpdatePos(self.mapWindow.view['pos']['x'],
+ self.mapWindow.view['pos']['y'])
+ viewWin.Draw(pos = (x, y), scale = True)
+ viewWin.Refresh(False)
# bgcolor = self.FindWindowById(self.win['settings']['general']['bgcolor']).GetColour()
# self.OnBgColor(event = bgcolor)
@@ -1283,11 +1275,27 @@
self.mapWindow.render['quick'] = False
self.mapWindow.Refresh(False)
- def OnShowLightingModel(self, event):
- """!Show lighting model"""
+ def OnShowLightModel(self, event):
+ """!Show light model"""
self._display.showLight = event.IsChecked()
- self.mapWindow.Refresh(False)
+ self._display.DrawLightingModel()
+ def OnLightChange(self, event):
+ """!Position of the light changed"""
+ winName = self.__GetWindowName(self.win['light'], event.GetId())
+ if not winName:
+ return
+
+ val = event.GetInt()
+ self.mapWindow.light['pos']['z'] = val / 100.
+ for win in self.win['light'][winName].itervalues():
+ self.FindWindowById(win).SetValue(val)
+
+ event = wxUpdateLight()
+ wx.PostEvent(self.mapWindow, event)
+
+ event.Skip()
+
def OnBgColor(self, event):
"""!Background color changed"""
color = event.GetValue()
@@ -1365,11 +1373,8 @@
self.UpdateSettings()
- event.Skip()
-
def OnViewChangedSpin(self, event):
"""!View changed, render in full resolution"""
- # TODO: use step value instead
self.mapWindow.render['quick'] = False
self.OnViewChange(event)
self.OnViewChanged(None)
@@ -2229,16 +2234,19 @@
if pageId == 'view':
self.SetPage('view')
- # max = self.mapWindow.view['z-exag']['value'] * 10 #this value is essentially null
hmin = self.mapWindow.iview['height']['min']
hmax = self.mapWindow.iview['height']['max']
- hval = int(0.4 * (hmax - hmin)) + hmin
+ hval = self.mapWindow.iview['height']['value']
+ zmin = self.mapWindow.view['z-exag']['min']
+ zmax = self.mapWindow.view['z-exag']['max']
+ zval = self.mapWindow.view['z-exag']['value']
for control in ('spin', 'slider'):
- # self.FindWindowById(self.win['view']['z-exag'][control]).SetRange(0,
- # max)
self.FindWindowById(self.win['view']['height'][control]).SetRange(hmin,
hmax)
self.FindWindowById(self.win['view']['height'][control]).SetValue(hval)
+ self.FindWindowById(self.win['view']['z-exag'][control]).SetRange(zmin,
+ zmax)
+ self.FindWindowById(self.win['view']['z-exag'][control]).SetValue(zval)
elif pageId in ('surface', 'vector', 'volume'):
current_page = self.GetSelection()
@@ -2251,15 +2259,18 @@
self.UpdateVectorPage(layer, data['vector'])
elif pageId == 'volume':
self.UpdateVectorPage(layer, data['vector'])
- elif pageId == 'lighting':
- print 'x'
+ elif pageId == 'light':
+ val = self.mapWindow.light['pos']['z'] * 100 # range 0.0 - 1.0
+ for control in ('spin', 'slider'):
+ self.FindWindowById(self.win['light']['z'][control]).SetRange(0,
+ 100)
+ self.FindWindowById(self.win['light']['z'][control]).SetValue(val)
self.Update()
self.pageChanging = False
def UpdateSurfacePage(self, layer, data, updateName = True):
"""!Update surface page"""
- print layer, data
ret = gcmd.RunCommand('r.info',
read = True,
flags = 'm',
@@ -2591,34 +2602,37 @@
self.pdc.DrawToDC(dc)
def UpdatePos(self, xcoord, ycoord):
- if xcoord >= 0 and xcoord <= 1.0:
- self.data['pos']['x'] = xcoord
- if ycoord >= 0 and ycoord <= 1.0:
- self.data['pos']['y'] = ycoord
+ """!Update position coordinates (origin: UL)"""
+ if xcoord < 0.0:
+ xcoord = 0.0
+ elif xcoord > 1.0:
+ xcoord = 1.0
+ if ycoord < 0.0:
+ ycoord = 0.0
+ elif ycoord > 1.0:
+ ycoord = 1.0
+
+ self.data['pos']['x'] = xcoord
+ self.data['pos']['y'] = ycoord
+ return xcoord, ycoord
+
def OnMouse(self, event):
if event.LeftIsDown():
x, y = event.GetPosition()
- self.data['pos']['x'] = x
- self.data['pos']['y'] = y
self.Draw(pos = (x, y))
- self.Refresh(False)
w, h = self.GetClientSize()
x = float(x) / w
y = float(y) / h
self.UpdatePos(x, y)
- self.mapWindow.render['quick'] = self.quick
-
- self.mapWindow.Refresh(eraseBackground = False)
- elif event.LeftUp():
- self.mapWindow.render['quick'] = False
- self.mapWindow.Refresh(eraseBackground = False)
+ self.Refresh(False)
event.Skip()
def PostDraw(self):
- self.Draw(pos = (self.data['pos']['x'],
- self.data['pos']['y']), scale = True)
+ x, y = self.UpdatePos(self.data['pos']['x'],
+ self.data['pos']['y'])
+ self.Draw(pos = (x, y), scale = True)
class ViewPositionWindow(PositionWindow):
"""!View position control widget"""
@@ -2630,35 +2644,55 @@
self.PostDraw()
def UpdatePos(self, xcoord, ycoord):
- PositionWindow.UpdatePos(self, xcoord, ycoord)
+ x, y = PositionWindow.UpdatePos(self, xcoord, ycoord)
event = wxUpdateView(zExag = True)
wx.PostEvent(self.mapWindow, event)
+ return x, y
+
+ def OnMouse(self, event):
+ PositionWindow.OnMouse(self, event)
+ if event.LeftIsDown():
+ self.mapWindow.render['quick'] = self.quick
+ self.mapWindow.Refresh(eraseBackground = False)
+ elif event.LeftUp():
+ self.mapWindow.render['quick'] = False
+ self.mapWindow.Refresh(eraseBackground = False)
+
+ event.Skip()
+
class LightPositionWindow(PositionWindow):
"""!Light position control widget"""
def __init__(self, parent, mapwindow, id = wx.ID_ANY,
**kwargs):
PositionWindow.__init__(self, parent, mapwindow, id, **kwargs)
- self.data = self.mapWindow.lighting
+ self.data = self.mapWindow.light
self.quick = False
self.PostDraw()
def UpdatePos(self, xcoord, ycoord):
- PositionWindow.UpdatePos(self, xcoord, ycoord)
+ x, y = PositionWindow.UpdatePos(self, xcoord, ycoord)
event = wxUpdateLight()
wx.PostEvent(self.mapWindow, event)
+
+ return x, y
+
+ def OnMouse(self, event):
+ PositionWindow.OnMouse(self, event)
+ if event.LeftUp():
+ self.mapWindow.render['quick'] = False
+ self.mapWindow.Refresh(eraseBackground = False)
class NvizPreferencesDialog(PreferencesBaseDialog):
"""!Nviz preferences dialog"""
def __init__(self, parent, title = _("3D view settings"),
settings = UserSettings):
-
PreferencesBaseDialog.__init__(self, parent = parent, title = title,
settings = settings)
-
+ self.toolWin = self.parent.GetLayerManager().nviz
self.win = dict()
# create notebook pages
@@ -3080,7 +3114,7 @@
except:
continue
- self.UpdateSettings()
+ self.toolWin.UpdateSettings()
self.FindWindowById(self.win['view']['pos']).Draw()
self.FindWindowById(self.win['view']['pos']).Refresh(False)
@@ -3095,11 +3129,13 @@
fileSettings = {}
UserSettings.ReadSettingsFile(settings = fileSettings)
- self.UpdateSettings()
+ self.toolWin.UpdateSettings()
nvsettings = UserSettings.Get(group = 'nviz')
for subgroup, key in nvsettings.iteritems(): # view, surface, vector...
+ print subgroup, key
for subkey, value in key.iteritems():
+ print subkey, value
if subkey == 'height': continue
for subvalue in value.keys():
if subvalue == 'step':
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2010-06-08 19:40:35 UTC (rev 42521)
@@ -441,12 +441,12 @@
'nviz' : {
'view' : {
'persp' : {
- 'value' : 40,
+ 'value' : 20,
'step' : 5,
},
'pos' : {
- 'x' : 0.85,
- 'y' : 0.85,
+ 'x' : 0.84,
+ 'y' : 0.16,
},
'height' : {
'step' : 100,
@@ -456,7 +456,6 @@
'step' : 5,
},
'z-exag' : {
- 'value': 1,
'step' : 1,
},
},
@@ -520,10 +519,10 @@
'bgcolor' : (255, 255, 255, 255), # white
},
},
- 'lighting' : {
+ 'light' : {
'color' : (255, 255, 255, 255), # white
},
- 'lighting' : {
+ 'light' : {
'pos' : {
'x' : 0.68,
'y' : 0.68,
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py 2010-06-08 19:40:35 UTC (rev 42521)
@@ -143,9 +143,6 @@
else:
Nviz_draw_all(self.data)
- if self.showLight:
- GS_draw_lighting_model()
-
def EraseMap(self):
"""!Erase map display (with background color)
"""
@@ -185,30 +182,26 @@
"""!Set default lighting model
"""
# first
- Nviz_set_light_position(self.data, 0, 0.68, 0.68, 0.80, 0.0)
- Nviz_set_light_bright(self.data, 0, 0.8)
- Nviz_set_light_color(self.data, 0, 1.0, 1.0, 1.0)
- Nviz_set_light_ambient(self.data, 0, 0.2, 0.2, 0.2)
+ Nviz_set_light_position(self.data, 1, 0.68, -0.68, 0.80, 0.0)
+ Nviz_set_light_bright(self.data, 1, 0.8)
+ Nviz_set_light_color(self.data, 1, 1.0, 1.0, 1.0)
+ Nviz_set_light_ambient(self.data, 1, 0.2, 0.2, 0.2)
# second
- Nviz_set_light_position(self.data, 1, 0.0, 0.0, 1.0, 0.0)
- Nviz_set_light_bright(self.data, 1, 0.5)
- Nviz_set_light_color(self.data, 1, 1.0, 1.0, 1.0)
- Nviz_set_light_ambient(self.data, 1, 0.3, 0.3, 0.3)
+ Nviz_set_light_position(self.data, 2, 0.0, 0.0, 1.0, 0.0)
+ Nviz_set_light_bright(self.data, 2, 0.5)
+ Nviz_set_light_color(self.data, 2, 1.0, 1.0, 1.0)
+ Nviz_set_light_ambient(self.data, 2, 0.3, 0.3, 0.3)
Debug.msg(3, "Nviz::SetLightsDefault()")
- def SetLight(self, x, y, z, lid = 1):
+ def SetLight(self, x, y, z, w = 0, lid = 1):
"""!Change lighting settings
- @param x,y position
- @param height
+ @param x,y,z position
+ @param w local coordinate (default to 0)
"""
- # Nviz_set_viewpoint_height(self.data, height)
- Nviz_set_light_position(self.data, lid, x, y, z, 0)
+ Nviz_set_light_position(self.data, lid, x, y, z, w)
- Debug.msg(3, "Nviz::SetLight(): x=%f, y=%f, z=%f" %
- (x, y, z))
-
def LoadSurface(self, name, color_name, color_value):
"""!Load raster map (surface)
@@ -1133,3 +1126,7 @@
self.ResizeWindow(widthOrig, heightOrig)
+ def DrawLightingModel(self):
+ """!Draw lighting model"""
+ if self.showLight:
+ GS_draw_lighting_model()
Modified: grass/branches/develbranch_6/gui/wxpython/icons/icon.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/icon.py 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/gui/wxpython/icons/icon.py 2010-06-08 19:40:35 UTC (rev 42521)
@@ -367,6 +367,8 @@
label=_("Show modeler settings")),
"modelProperties" : MetaIcon (img=Icons["modelProperties"],
label=_("Show model properties")),
+ "modelVariables" : MetaIcon (img=Icons["modelProperties"],
+ label=_("Manage model variables")),
}
# testing ...
Modified: grass/branches/develbranch_6/lib/nviz/change_view.c
===================================================================
--- grass/branches/develbranch_6/lib/nviz/change_view.c 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/lib/nviz/change_view.c 2010-06-08 19:40:35 UTC (rev 42521)
@@ -1,19 +1,15 @@
/*!
- \file change_view.c
+ \file lib/nviz/change_view.c
- \brief Change view settings
+ \brief Nviz library -- Change view settings
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/change_view.c
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/glocale.h>
@@ -105,10 +101,11 @@
ypos = (ypos < 0) ? 0 : (ypos > 1.0) ? 1.0 : ypos;
if (x_pos < 0.0 || x_pos > 1.0 || y_pos < 0.0 || y_pos > 1.0) {
- G_warning(_("Invalid view position coordinates, using %f,%f"),
+ G_debug(3, "Invalid view position coordinates, using %f,%f",
xpos, 1.0 - ypos);
}
+ G_debug(3, "Nviz_set_viewpoint_position(): x = %f y = %f", x_pos, y_pos);
GS_get_from(from);
tempx = xpos * RANGE - RANGE_OFFSET;
Modified: grass/branches/develbranch_6/lib/nviz/cplanes_obj.c
===================================================================
--- grass/branches/develbranch_6/lib/nviz/cplanes_obj.c 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/lib/nviz/cplanes_obj.c 2010-06-08 19:40:35 UTC (rev 42521)
@@ -1,19 +1,15 @@
/*!
- \file cplanes_obj.c
-
+ \file lib/nviz/cplanes_obj.c
+
\brief Nviz library -- Clip planes manipulation
-
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
+
Based on visualization/nviz/src/cutplanes_obj.c
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/nviz.h>
Modified: grass/branches/develbranch_6/lib/nviz/draw.c
===================================================================
--- grass/branches/develbranch_6/lib/nviz/draw.c 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/lib/nviz/draw.c 2010-06-08 19:40:35 UTC (rev 42521)
@@ -1,20 +1,16 @@
/*!
- \file draw.c
+ \file lib/nviz/draw.c
\brief Nviz library -- Draw map objects to GLX context
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/draw.c and
visualization/nviz/src/togl_flythrough.c
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/nviz.h>
Modified: grass/branches/develbranch_6/lib/nviz/exag.c
===================================================================
--- grass/branches/develbranch_6/lib/nviz/exag.c 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/lib/nviz/exag.c 2010-06-08 19:40:35 UTC (rev 42521)
@@ -1,19 +1,15 @@
/*!
- \file exag.c
+ \file lib/nviz/exag.c
\brief Nviz library -- Exaggeration functions
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/exag.c
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/nviz.h>
Modified: grass/branches/develbranch_6/lib/nviz/lights.c
===================================================================
--- grass/branches/develbranch_6/lib/nviz/lights.c 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/lib/nviz/lights.c 2010-06-08 19:40:35 UTC (rev 42521)
@@ -1,19 +1,15 @@
/*!
- \file lights.c
+ \file lib/nviz/lights.c
- \brief Nviz library -- Change view settings
+ \brief Nviz library -- Change lighting settings
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/lights.c
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/glocale.h>
@@ -23,18 +19,34 @@
\brief Set light position
\param data nviz data
- \param num light num (starts with 0)
+ \param num light num (starts at 1)
\param x,y,z,w position, model coordinates
+
+ \return 1
*/
int Nviz_set_light_position(nv_data * data, int num,
float x, float y, float z, float w)
{
+ float xpos, ypos;
+ xpos = x;
+ xpos = (xpos < 0) ? 0 : (xpos > 1.0) ? 1.0 : xpos;
+ ypos = 1.0 - y;
+ ypos = (ypos < 0) ? 0 : (ypos > 1.0) ? 1.0 : ypos;
+
+ if (x < 0.0 || x > 1.0 || y < 0.0 || y > 1.0) {
+ G_debug(3, "Invalid view position coordinates, using %f,%f",
+ xpos, 1.0 - ypos);
+ }
+
+ num--;
data->light[num].id = num + 1;
data->light[num].x = x;
data->light[num].y = y;
data->light[num].z = z;
data->light[num].w = w;
+ G_debug(3, "Nviz_set_light_position(): num = %d x = %f y = %f z = %f w = %f",
+ num + 1, x, y, z, w);
GS_setlight_position(num + 1, x, y, z, w);
return 1;
@@ -44,19 +56,22 @@
\brief Set light brightness
\param data nviz data
- \param num light num (starts with 0)
+ \param num light num (starts at 1)
\param value brightness value
*/
int Nviz_set_light_bright(nv_data * data, int num, float value)
{
float r, g, b;
+ num--;
data->light[num].brt = value;
r = data->light[num].r * data->light[num].brt;
g = data->light[num].g * data->light[num].brt;
b = data->light[num].b * data->light[num].brt;
+ G_debug(3, "Nviz_set_light_bright(): num = %d r = %f g = %f b = %f",
+ num + 1, r, g, b);
GS_setlight_color(num + 1, r, g, b);
return 1;
@@ -66,7 +81,7 @@
\brief Set light color
\param data nviz data
- \param num light num (starts with 0)
+ \param num light num (starts at 1)
\param red,green,blue rGB values (0-1)
*/
int Nviz_set_light_color(nv_data * data, int num,
@@ -74,6 +89,7 @@
{
float r, g, b;
+ num--;
data->light[num].r = red;
data->light[num].g = green;
data->light[num].b = blue;
@@ -82,6 +98,8 @@
g = data->light[num].g * data->light[num].brt;
b = data->light[num].b * data->light[num].brt;
+ G_debug(3, "Nviz_set_light_color(): num = %d r = %f g = %f b = %f",
+ num + 1, r, g, b);
GS_setlight_color(num + 1, r, g, b);
return 1;
@@ -91,16 +109,19 @@
\brief Set light ambient
\param data nviz data
- \param num light num (starts with 0)
+ \param num light num (starts at 1)
\param red,green,blue rGB values (0-1)
*/
int Nviz_set_light_ambient(nv_data * data, int num,
float red, float green, float blue)
{
+ num--;
data->light[num].ar = red;
data->light[num].ag = green;
data->light[num].ab = blue;
+ G_debug(3, "Nviz_set_light_ambient(): num = %d r = %f g = %f b = %f",
+ num + 1, red, green, blue);
GS_setlight_ambient(num + 1, red, green, blue);
return 1;
@@ -110,10 +131,11 @@
\brief Init new light
\param data nviz data
- \param num light num (starts with 0)
+ \param num light num (starts at 1)
*/
int Nviz_init_light(nv_data * data, int num)
{
+ num--;
if (num >= MAX_LIGHTS) {
return 0;
}
@@ -134,6 +156,14 @@
return 1;
}
+/*!
+ \brief Define new light
+
+ \param data nviz data
+
+ \return 1 on success
+ \return 0 on failure
+*/
int Nviz_new_light(nv_data * data)
{
int num;
@@ -145,7 +175,7 @@
return 0;
}
- Nviz_init_light(data, num - 1);
+ Nviz_init_light(data, num);
return 1;
}
Modified: grass/branches/develbranch_6/lib/nviz/map_obj.c
===================================================================
--- grass/branches/develbranch_6/lib/nviz/map_obj.c 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/lib/nviz/map_obj.c 2010-06-08 19:40:35 UTC (rev 42521)
@@ -1,22 +1,18 @@
/*!
- \file map_obj.c
+ \file lib/nviz/map_obj.c
\brief Nviz library -- Define creation and interface functions for map objects.
- Map objects are considered to be surfaces, vector plots,
- or site files.
+ Map objects are considered to be surfaces, vector plots, or site
+ files.
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/map_obj.c
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <stdlib.h>
Modified: grass/branches/develbranch_6/lib/nviz/nviz.c
===================================================================
--- grass/branches/develbranch_6/lib/nviz/nviz.c 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/lib/nviz/nviz.c 2010-06-08 19:40:35 UTC (rev 42521)
@@ -1,19 +1,15 @@
/*!
- \file nviz.c
+ \file lib/nviz/nviz.c
\brief Nviz library -- Data management
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/glocale.h>
Modified: grass/branches/develbranch_6/lib/nviz/position.c
===================================================================
--- grass/branches/develbranch_6/lib/nviz/position.c 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/lib/nviz/position.c 2010-06-08 19:40:35 UTC (rev 42521)
@@ -1,19 +1,15 @@
/*!
- \file position.c
-
+ \file lib/nviz/position.c
+
\brief Nviz library -- Position, focus settings
-
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
+
Based on visualization/nviz/src/position.c
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/glocale.h>
Modified: grass/branches/develbranch_6/lib/nviz/render.c
===================================================================
--- grass/branches/develbranch_6/lib/nviz/render.c 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/lib/nviz/render.c 2010-06-08 19:40:35 UTC (rev 42521)
@@ -1,19 +1,15 @@
/*!
- \file render.c
+ \file lib/nviz/render.c
\brief Nviz library -- GLX context manipulation
- COPYRIGHT: (C) 2008 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
Based on visualization/nviz/src/togl.c
+
+ (C) 2008, 2010 by the GRASS Development Team
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
- \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
-
- \date 2008
+ \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
*/
#include <grass/glocale.h>
Modified: grass/branches/develbranch_6/lib/ogsf/GS2.c
===================================================================
--- grass/branches/develbranch_6/lib/ogsf/GS2.c 2010-06-08 19:35:59 UTC (rev 42520)
+++ grass/branches/develbranch_6/lib/ogsf/GS2.c 2010-06-08 19:40:35 UTC (rev 42521)
@@ -314,7 +314,7 @@
/*!
\brief Get light position
- \param num light id (starts with 1?)
+ \param num light id (starts at 1)
\param[out] xpos,ypos,zpos coordinates
\param[out] local ?
*/
@@ -338,7 +338,7 @@
/*!
\brief Set light color
- \param num light id (starts with 1?)
+ \param num light id (starts at 1)
\param red,green,blue color values (from 0.0 to 1.0)
*/
void GS_setlight_color(int num, float red, float green, float blue)
@@ -360,7 +360,7 @@
/*!
\brief Get light color
- \param num light id (starts with 1?)
+ \param num light id (starts at 1)
\param[out] red,green,blue color values
*/
void GS_getlight_color(int num, float *red, float *green, float *blue)
@@ -382,7 +382,7 @@
Red, green, blue from 0.0 to 1.0
- \param num light id (starts with 1?)
+ \param num light id (starts at 1)
\param red,green,blue color values
*/
void GS_setlight_ambient(int num, float red, float green, float blue)
@@ -404,7 +404,7 @@
/*!
\brief Get light ambient
- \param num light id (starts with 1?)
+ \param num light id (starts at 1)
\param[out] red,green,blue color values
*/
void GS_getlight_ambient(int num, float *red, float *green, float *blue)
@@ -453,7 +453,7 @@
/*!
\brief Switch on/off light
- \param num light id (starts with 1?)
+ \param num light id (starts at 1)
\param on non-zero for 'on' otherwise 'off'
*/
void GS_switchlight(int num, int on)
More information about the grass-commit
mailing list