Explorar o código

wxNviz: several bugs fixed (eg. lights), GUI improvements, new functionality: look here feature, constant surfaces

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46504 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová %!s(int64=14) %!d(string=hai) anos
pai
achega
13eb3862d1

+ 4 - 3
gui/wxpython/gui_modules/mapdisp.py

@@ -359,7 +359,7 @@ class MapFrame(wx.Frame):
         
         # check for GLCanvas and OpenGL
         if not nviz.haveNviz:
-            self.toolbars['map'].combo.SetValue (_("2D view"))
+            self.toolbars['map'].combo.SetValue(_("2D view"))
             wx.MessageBox(parent = self,
                           message = _("Unable to switch to 3D display mode.\nThe Nviz python extension "
                                       "was not found or loaded properly.\n"
@@ -398,8 +398,9 @@ class MapFrame(wx.Frame):
             self.MapWindow = self.MapWindow3D
             # add Nviz notebookpage
             self._layerManager.AddNviz()
-            self._layerManager.nviz.UpdatePage('view')
-            self._layerManager.nviz.UpdatePage('light')
+            for page in ('view', 'light', 'fringe', 'constant'):
+                self._layerManager.nviz.UpdatePage(page)
+
         
         # switch from MapWindow to MapWindowGL
         # add nviz toolbar

+ 28 - 10
gui/wxpython/gui_modules/nviz_mapdisp.py

@@ -83,9 +83,17 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
                         # do not render vector lines in quick mode
                         'vlines' : False,
                         'vpoints' : False }
-        
+        self.mouse = {
+            'use': 'default'
+            }
+        self.cursors = {
+            'default' : wx.StockCursor(wx.CURSOR_ARROW),
+            'cross'   : wx.StockCursor(wx.CURSOR_CROSS),
+            }
         # list of loaded map layers (layer tree items)
         self.layers  = list()
+        # list of constant surfaces
+        self.constants = list()
         # list of query points
         self.qpoints = list()
         
@@ -235,6 +243,17 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
                 # update statusbar
                 ### self.parent.StatusbarUpdate()
         
+        if event.LeftDown():
+            if self.mouse['use'] == "lookHere":
+                pos = event.GetPosition()
+                size = self.GetClientSize()
+                self._display.LookHere(pos[0], size[1] - pos[1])
+                self.DoPaint()
+                comboId = self.lmgr.nviz.win['view']['lookAt']
+                self.lmgr.nviz.FindWindowById(comboId).SetSelection(0)
+                self.mouse['use'] = 'default'
+                self.SetCursor(self.cursors['default'])
+                
         event.Skip()
 
     def Pixel2Cell(self, (x, y)):
@@ -323,6 +342,8 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
                                bright = data['bright'] / 100.,
                                ambient = data['ambient'] / 100.)
         self._display.DrawLightingModel()
+        if hasattr(event, 'refresh'):
+            self.Refresh(False)
         
     def UpdateMap(self, render = True):
         """!Updates the canvas anytime there is a change to the
@@ -867,7 +888,7 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
     def UpdateSurfaceProperties(self, id, data):
         """!Update surface map object properties"""
         # surface attributes
-        for attrb in ('topo', 'color', 'mask',
+        for attrb in ('color', 'mask',
                      'transp', 'shine', 'emit'):
             if attrb not in data['attribute'] or \
                     'update' not in data['attribute'][attrb]:
@@ -890,9 +911,7 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
                 if type(value) ==  type('') and \
                         len(value) <=  0: # ignore empty values (TODO: warning)
                     continue
-                if attrb ==  'topo':
-                    self._display.SetSurfaceTopo(id, map, str(value)) 
-                elif attrb ==  'color':
+                if attrb ==  'color':
                     self._display.SetSurfaceColor(id, map, str(value))
                 elif attrb ==  'mask':
                     # TODO: invert mask
@@ -1086,12 +1105,11 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
             data['height'].pop('update')
         
         # surface
-        if 'update' in data['mode']:
-            sid = self.GetLayerId(type = 'raster', name = data['mode']['surface'])
+        if 'update' in data['mode']['surface']:
+            sid = self.GetLayerId(type = 'raster', name = data['mode']['surface']['value'])
             if sid > -1:
-                self._display.SetVectorPointSurface(id, sid)
-            
-            data['mode'].pop('update')
+                ret = self._display.SetVectorPointSurface(id, sid)
+            data['mode']['surface'].pop('update')
             
     def GetLayerNames(self, type):
         """!Return list of map layer names of given type"""

+ 259 - 37
gui/wxpython/gui_modules/nviz_preferences.py

@@ -16,6 +16,7 @@ This program is free software under the GNU General Public License
 """
 
 import types
+import copy
 
 import wx
 import wx.lib.colourselect as csel
@@ -35,6 +36,8 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
         
         # create notebook pages
         self._createViewPage(self.notebook)
+        self._createLightPage(self.notebook)
+        self._createSurfacePage(self.notebook)
         self._createVectorPage(self.notebook)
         
         self.SetMinSize(self.GetBestSize())
@@ -88,7 +91,7 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
                       flag = wx.ALIGN_CENTER_VERTICAL)
         
         # position
-        self.win['view']['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:")),
@@ -101,7 +104,7 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
                            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)
         
@@ -113,7 +116,7 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
                            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)
         
@@ -208,15 +211,17 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
         gridSizer.AddGrowableCol(0)
         
         # background color
+        self.win['view']['background'] = {}
         gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
                                          label = _("Background color:")),
                       pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
         
         color = csel.ColourSelect(panel, id = wx.ID_ANY,
-                                  colour = UserSettings.Get(group = 'nviz', key = 'settings',
-                                                            subkey = ['general', 'bgcolor']),
+                                  colour = UserSettings.Get(group = 'nviz', key = 'view',
+                                                            subkey = ['background', 'color']),
                                   size = globalvar.DIALOG_COLOR_SIZE)
-        self.win['general']['bgcolor'] = color.GetId()
+        color.SetName("color")
+        self.win['view']['background']['color'] = color.GetId()
         gridSizer.Add(item = color, pos = (0, 1))
         
         boxSizer.Add(item = gridSizer, proportion = 1,
@@ -229,6 +234,220 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
         
         return panel
     
+    def _createLightPage(self, notebook):
+        """!Create notebook page for general settings"""
+        panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+        
+        notebook.AddPage(page = panel,
+                         text = " %s " % _("Lighting"))
+        
+        pageSizer = wx.BoxSizer(wx.VERTICAL)
+        
+        self.win['light'] = {}
+        box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
+                            label = " %s " % (_("Light")))
+        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+        gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
+
+        
+        # position
+        self.win['light']['position'] = {}
+        posvals = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'position')
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                                         label = _("Position:")),
+                      pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                                         label = _("(x)")),
+                      pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
+        
+        px = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
+                           initial = posvals['x'] * 100,
+                           min = -100,
+                           max = 100)
+        self.win['light']['position']['x'] = px.GetId()
+        gridSizer.Add(item = px, pos = (0, 2),
+                      flag = wx.ALIGN_CENTER_VERTICAL)
+        
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                                         label = "(y)"),
+                      pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
+        
+        py = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
+                           initial = posvals['y'] * 100,
+                           min = -100,
+                           max = 100)
+        self.win['light']['position']['y'] = py.GetId()
+        gridSizer.Add(item = py, pos = (0, 4),
+                      flag = wx.ALIGN_CENTER_VERTICAL)
+                    
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                                         label = _("(z)")),
+                      pos = (0, 5), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
+        
+        pz = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
+                           initial = posvals['z'],
+                           min = 0,
+                           max = 100)
+        self.win['light']['position']['z'] = pz.GetId()
+        gridSizer.Add(item = pz, pos = (0, 6),
+                      flag = wx.ALIGN_CENTER_VERTICAL)
+                    
+        # brightness
+        brightval = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'bright')
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                                         label = _("Brightness:")),
+                      pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
+        
+        bright = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
+                           initial = brightval,
+                           min = 0,
+                           max = 100)
+        self.win['light']['bright'] = bright.GetId()
+        gridSizer.Add(item = bright, pos = (1, 2),
+                      flag = wx.ALIGN_CENTER_VERTICAL)
+                    
+        # ambient
+        ambval = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'ambient')
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                                         label = _("Ambient:")),
+                      pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL)
+        
+        amb = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
+                           initial = ambval,
+                           min = 0,
+                           max = 100)
+        self.win['light']['ambient'] = amb.GetId()
+        gridSizer.Add(item = amb, pos = (2, 2),
+                      flag = wx.ALIGN_CENTER_VERTICAL)
+                    
+        # light color
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                                         label = _("Color:")),
+                      pos = (3, 0), flag = wx.ALIGN_CENTER_VERTICAL)
+        
+        color = csel.ColourSelect(panel, id = wx.ID_ANY,
+                                  colour = UserSettings.Get(group = 'nviz', key = 'light',
+                                                            subkey = 'color'),
+                                  size = globalvar.DIALOG_COLOR_SIZE)
+        color.SetName("color")
+        self.win['light']['color'] = color.GetId()
+        gridSizer.Add(item = color, pos = (3, 2))
+        
+        
+        boxSizer.Add(item = gridSizer, proportion = 1,
+                  flag = wx.ALL | wx.EXPAND, border = 3)
+        pageSizer.Add(item = boxSizer, proportion = 0,
+                      flag = wx.EXPAND | wx.ALL,
+                      border = 3)
+        
+        panel.SetSizer(pageSizer)
+        
+        return panel
+    
+    def _createSurfacePage(self, notebook):
+        """!Create notebook page for general settings"""
+        panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+        
+        notebook.AddPage(page = panel,
+                         text = " %s " % _("Surface"))
+        
+        pageSizer = wx.BoxSizer(wx.VERTICAL)
+        self.win['surface'] = {}
+        
+        # draw
+        
+        self.win['surface']['draw'] = {}
+        box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
+                            label = " %s " % (_("Draw")))
+        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+        gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
+        
+        # mode
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                        label = _("Mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
+                        pos = (0, 0))
+        mode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (-1, -1),
+                          choices = [_("coarse"),
+                                     _("fine"),
+                                     _("both")])
+        self.win['surface']['draw']['mode'] = mode.GetId()
+        mode.SetName('selection')
+        mode.SetSelection(UserSettings.Get(group = 'nviz', key = 'surface',
+                                            subkey = ['draw', 'mode']))
+        gridSizer.Add(item = mode, flag = wx.ALIGN_CENTER_VERTICAL,
+                      pos = (0, 1))
+                    
+        # fine
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                        label = _("Fine mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
+                        pos = (1, 0))
+        res = UserSettings.Get(group = 'nviz', key = 'surface', subkey = ['draw','res-fine'])
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                        label = _("resolution:")), flag = wx.ALIGN_CENTER_VERTICAL,
+                        pos = (1, 1))
+        fine = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
+                           initial = res,
+                           min = 1,
+                           max = 100)
+        self.win['surface']['draw']['res-fine'] = fine.GetId()
+        
+        gridSizer.Add(item = fine, flag = wx.ALIGN_CENTER_VERTICAL,
+                      pos = (1, 2))
+                    
+        # coarse
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                        label = _("Coarse mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
+                        pos = (2, 0))
+        res = UserSettings.Get(group = 'nviz', key = 'surface', subkey = ['draw','res-coarse'])
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                        label = _("resolution:")), flag = wx.ALIGN_CENTER_VERTICAL,
+                        pos = (2, 1))
+        coarse = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
+                           initial = res,
+                           min = 1,
+                           max = 100)
+        self.win['surface']['draw']['res-coarse'] = coarse.GetId()
+        
+        gridSizer.Add(item = coarse, flag = wx.ALIGN_CENTER_VERTICAL,
+                      pos = (2, 2))
+        #style
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+            label = _("style:")), flag = wx.ALIGN_CENTER_VERTICAL,
+            pos = (3, 1))
+        style = wx.Choice(parent = panel, id = wx.ID_ANY, size = (-1, -1),
+                          choices = [_("wire"),
+                                     _("surface")])
+        self.win['surface']['draw']['style'] = style.GetId()
+        style.SetName('selection')
+        style.SetSelection(UserSettings.Get(group = 'nviz', key = 'surface',
+                                            subkey = ['draw', 'style']))
+        self.win['surface']['draw']['style'] = style.GetId()
+        
+        gridSizer.Add(item = style, flag = wx.ALIGN_CENTER_VERTICAL,
+                      pos = (3, 2))
+        #wire color
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+            label = _("wire color:")), flag = wx.ALIGN_CENTER_VERTICAL,
+            pos = (4, 1))
+        color = csel.ColourSelect(panel, id = wx.ID_ANY,
+                                  colour = UserSettings.Get(group = 'nviz', key = 'surface',
+                                                            subkey = ['draw', 'wire-color']),
+                                  size = globalvar.DIALOG_COLOR_SIZE)
+        color.SetName("color")
+        self.win['surface']['draw']['wire-color'] = color.GetId() 
+        gridSizer.Add(item = color, flag = wx.ALIGN_CENTER_VERTICAL,
+                      pos = (4, 2))
+        
+        boxSizer.Add(item = gridSizer, proportion = 1,
+                  flag = wx.ALL | wx.EXPAND, border = 3)            
+        pageSizer.Add(item = boxSizer, proportion = 0,
+              flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
+              border = 3)
+        
+        panel.SetSizer(pageSizer)
+        
+        return panel
+    
     def _createVectorPage(self, notebook):
         """!Create notebook page for general settings"""
         panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
@@ -344,6 +563,16 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
         
         return panel
     
+    def _getValue(self, win):
+        if win.GetName() == "selection":
+            value = win.GetSelection()
+        elif win.GetName() == "color":
+            value = tuple(win.GetColour())
+        else:
+            value = win.GetValue()
+            
+        return value
+        
     def OnDefault(self, event):
         """Restore default settings"""
         settings = copy.deepcopy(UserSettings.GetDefaultSettings()['nviz'])
@@ -358,7 +587,8 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
                     win = self.FindWindowById(self.win[subgroup][subkey][subvalue])
                     val = settings[subgroup][subkey][subvalue]
                     if subkey == 'position':
-                        val = int(val * 100)
+                        if val < 1:
+                            val = int(val * 100)
                     
                     win.SetValue(val)
         
@@ -371,36 +601,26 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
             for subkey, value in key.iteritems():
                 if type(value) == types.DictType:
                     for subvalue in value.keys():
-                        try: # TODO
+                        try:
                             win = self.FindWindowById(self.win[subgroup][subkey][subvalue])
-                        except:
-                            # print 'e', subgroup, subkey, subvalue
+                        except KeyError, e:
+                            #print "error", str(e)+ str(subgroup)+str(subkey)+str(subvalue)
                             continue
-                        
-                        if win.GetName() == "selection":
-                            value = win.GetSelection()
-                        elif win.GetName() == "color":
-                            value = tuple(win.GetColour())
-                        else:
-                            value = win.GetValue()
-                        if subkey == 'pos':
-                            value = float(value) / 100
-                            
+                        value = self._getValue(win)
+                        if subkey == 'position':
+                            if subvalue in ('x', 'y'):
+                                value = float(value) / 100
                         settings[subgroup][subkey][subvalue] = value
+                else:
+                    try:
+                        win = self.FindWindowById(self.win[subgroup][subkey])
+                    except KeyError, e:
+                        #print "error", str(subgroup)+" "+str(subkey)+" "+str(value)
+                        continue
+                    value = self._getValue(win)
+                    settings[subgroup][subkey] = value
+                    
         
-    def OnSave(self, event):
-        """!Apply changes, update map and save settings of selected
-        layer
-        """
-        # apply changes
-        self.OnApply(None)
-        
-        if self.GetSelection() == self.page['id']:
-            fileSettings = {}
-            UserSettings.ReadSettingsFile(settings = fileSettings)
-            fileSettings['nviz'] = UserSettings.Get(group = 'nviz')
-            file = UserSettings.SaveToFile(fileSettings)
-            self.parent.goutput.WriteLog(_('Nviz settings saved to file <%s>.') % file)
         
     def OnLoad(self, event):
         """!Apply button pressed"""
@@ -453,8 +673,8 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
                                         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)
@@ -464,12 +684,14 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
         
         Save settings to configuration file
         """
+        self.OnApply(None)
         fileSettings = {}
         UserSettings.ReadSettingsFile(settings = fileSettings)
         fileSettings['nviz'] = UserSettings.Get(group = 'nviz')
         
-        fileName = UserSettings.SaveToFile(fileSettings)
-        self.parent.GetLayerManager().goutput.WriteLog(_('3D view settings saved to file <%s>.') % fileName)
+        UserSettings.SaveToFile(fileSettings)
+        self.parent.GetLayerManager().goutput.WriteLog(
+                _('3D view settings saved to file <%s>.') % UserSettings.filePath)
         
         self.Destroy()
         

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 732 - 375
gui/wxpython/gui_modules/nviz_tools.py


+ 1 - 1
gui/wxpython/gui_modules/preferences.py

@@ -541,7 +541,7 @@ class Settings:
                 'light' : {
                     'position' : {
                         'x' : 0.68,
-                        'y' : 0.68,
+                        'y' : -0.68,
                         'z' : 80,
                         },
                     'bright'  : 80,

+ 23 - 4
gui/wxpython/gui_modules/wxnviz.py

@@ -138,7 +138,15 @@ class Nviz(object):
         
         Debug.msg(3, "Nviz::SetView(): x=%f, y=%f, height=%f, persp=%f, twist=%f",
                   x, y, height, persp, twist)
+                
+    def LookHere(self, x, y):
+        """!Look here feature 
+        @param x,y screen coordinates
+        """
         
+        Nviz_look_here(x, y)
+        Debug.msg(3, "Nviz::LookHere(): x=%f, y=%f", x, y)
+            
     def SetZExag(self, z_exag):
         """!Set z-exag value
         
@@ -186,7 +194,7 @@ class Nviz(object):
         # set background color
         Nviz_set_bgcolor(self.data, Nviz_color_from_str("white"))
         
-        GS_clear(Nviz_get_bgcolor(self.data))
+        GS_clear(Nviz_get_bgcolor(self.data))        
         # initialize view, lights
         Nviz_init_view(self.data)
         
@@ -262,7 +270,19 @@ class Nviz(object):
         Debug.msg(1, "Nviz::LoadRaster(): name=%s -> id=%d", name, id)
         
         return id
-
+    
+    def AddConstant(self, value, color):
+        """!Add new constant surface"""
+        id = Nviz_new_map_obj(MAP_OBJ_SURF, None, value, self.data)
+        
+        Nviz_set_attr(id, MAP_OBJ_SURF, ATT_COLOR, CONST_ATT,
+                        None, Nviz_color_from_str(color),
+                        self.data)
+        Nviz_set_focus_map(MAP_OBJ_UNDEFINED, -1)
+        
+        Debug.msg(1, "Nviz::AddConstant(): id=%d", id)
+        return id
+        
     def UnloadSurface(self, id):
         """!Unload surface
         
@@ -420,7 +440,7 @@ class Nviz(object):
         
         @param id surface id
         @param map if true use map otherwise constant
-        @param value map name of value
+        @param value map name or value
         
         @return 1 on success
         @return -1 surface not found
@@ -1174,7 +1194,6 @@ class Nviz(object):
         @param nw,ne,sw,se fringe edges (turn on/off)
         """
         scolor = str(color[0]) + ':' + str(color[1]) + ':' + str(color[2])
-
         Nviz_set_fringe(self.data,
                         sid, Nviz_color_from_str(scolor),
                         elev, int(nw), int(ne), int(sw), int(se))

+ 1 - 1
gui/wxpython/wxgui.py

@@ -253,7 +253,7 @@ class GMFrame(wx.Frame):
     def AddNviz(self):
         """!Add nviz notebook page"""
         self.nviz = nviz_tools.NvizToolWindow(parent = self,
-                                              display = self.curr_page.maptree.GetMapDisplay()) 
+                                              display = self.curr_page.maptree.GetMapDisplay())
         self.notebook.AddPage(self.nviz, text = _("3D view"))
         self.notebook.SetSelection(self.notebook.GetPageCount() - 1)
         

+ 1 - 0
include/nviz.h

@@ -133,6 +133,7 @@ int Nviz_set_viewpoint_height(double);
 int Nviz_set_viewpoint_persp(int);
 int Nviz_set_viewpoint_twist(int);
 int Nviz_change_exag(nv_data *, double);
+int Nviz_look_here(double, double);
 
 /* cplanes_obj.c */
 int Nviz_new_cplane(nv_data *, int);

+ 15 - 0
lib/nviz/change_view.c

@@ -221,3 +221,18 @@ int Nviz_change_exag(nv_data * data, double exag)
 
     return 1;
 }
+/*!
+  \brief Change focused point
+  
+  \param sx,sy screen coordinates
+  
+  \return 1
+*/
+int Nviz_look_here(double sx, double sy)
+{
+     G_debug(1, "Nviz_look_here(): screen coordinates = %f %f", sx, sy); 
+     GS_look_here(sx, sy);
+     return 1;
+}
+
+

+ 12 - 15
lib/nviz/lights.c

@@ -39,16 +39,16 @@ int Nviz_set_light_position(nv_data * data, int num,
 		x, y, xpos, 1.0 - ypos);
     }
     */
-    num--;
-    data->light[num].id = num + 1;
+
+    data->light[num].id = num;
     data->light[num].x = x;
     data->light[num].y = y;
     data->light[num].z = z;
     data->light[num].w = w;
 
     G_debug(1, "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);
+	    num, x, y, z, w);
+    GS_setlight_position(num, x, y, z, w);
 
     return 1;
 }
@@ -64,7 +64,6 @@ int Nviz_set_light_bright(nv_data * data, int num, double value)
 {
     double r, g, b;
 
-    num--;
     data->light[num].brt = value;
 
     r = data->light[num].r * data->light[num].brt;
@@ -72,8 +71,8 @@ int Nviz_set_light_bright(nv_data * data, int num, double value)
     b = data->light[num].b * data->light[num].brt;
 
     G_debug(1, "Nviz_set_light_bright(): num = %d value = %f r = %f g = %f b = %f",
-	    num + 1, value, r, g, b);
-    GS_setlight_color(num + 1, r, g, b);
+	    num, value, r, g, b);
+    GS_setlight_color(num, r, g, b);
 
     return 1;
 }
@@ -90,7 +89,6 @@ int Nviz_set_light_color(nv_data * data, int num,
 {
     double r, g, b;
 
-    num--;
     data->light[num].r = red / 255.;
     data->light[num].g = green / 255.;
     data->light[num].b = blue / 255.;
@@ -100,8 +98,8 @@ int Nviz_set_light_color(nv_data * data, int num,
     b = data->light[num].b * data->light[num].brt;
 
     G_debug(1, "Nviz_set_light_color(): num = %d r = %d/%f g = %d/%f b = %d/%f",
-	    num + 1, red, r, green, g, blue, b);
-    GS_setlight_color(num + 1, r, g, b);
+	    num, red, r, green, g, blue, b);
+    GS_setlight_color(num, r, g, b);
 
     return 1;
 }
@@ -115,14 +113,13 @@ int Nviz_set_light_color(nv_data * data, int num,
  */
 int Nviz_set_light_ambient(nv_data * data, int num, double value)
 {
-    num--;
     data->light[num].ar = value;
     data->light[num].ag = value;
     data->light[num].ab = value;
 
     G_debug(1, "Nviz_set_light_ambient(): num = %d value = %f",
-	    num + 1, value);
-    GS_setlight_ambient(num + 1, value, value, value);
+	    num, value);
+    GS_setlight_ambient(num, value, value, value);
     
     return 1;
 }
@@ -135,8 +132,8 @@ int Nviz_set_light_ambient(nv_data * data, int num, double value)
  */
 int Nviz_init_light(nv_data * data, int num)
 {
-    num--;
-    if (num >= MAX_LIGHTS) {
+	G_debug(1, "Nviz_init_light(): num = %d", num);
+    if (num > MAX_LIGHTS) {
 	return 0;
     }
 

+ 1 - 1
lib/nviz/nviz.c

@@ -39,7 +39,7 @@ void Nviz_init_data(nv_data * data)
     }
 
     /* lights */
-    for (i = 0; i < MAX_LIGHTS; i++) {
+    for (i = 0; i < MAX_LIGHTS - 1; i++) {
 	Nviz_new_light(data);
     }