瀏覽代碼

wxNviz: small changes in tooltips, default values suggested by Michael Barton

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53074 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 年之前
父節點
當前提交
93c03d0528
共有 4 個文件被更改,包括 49 次插入40 次删除
  1. 1 1
      gui/wxpython/core/settings.py
  2. 3 3
      gui/wxpython/mapdisp/frame.py
  3. 13 10
      gui/wxpython/nviz/mapwindow.py
  4. 32 26
      gui/wxpython/nviz/tools.py

+ 1 - 1
gui/wxpython/core/settings.py

@@ -706,7 +706,7 @@ class Settings:
                 'cplane' : {
                 'cplane' : {
                     'shading': 4,
                     'shading': 4,
                     'rotation':{
                     'rotation':{
-                        'rot': 0, 
+                        'rot': 180, 
                         'tilt': 0
                         'tilt': 0
                         }, 
                         }, 
                     'position':{
                     'position':{

+ 3 - 3
gui/wxpython/mapdisp/frame.py

@@ -544,9 +544,9 @@ class MapFrame(SingleMapFrame):
         """!Save map to image
         """!Save map to image
         """
         """
         if self.IsPaneShown('3d'):
         if self.IsPaneShown('3d'):
-            filetype = "PPM file (*.ppm)|*.ppm|TIF file (*.tif)|*.tif"
-            ltype = [{ 'ext' : 'ppm', 'type' : 'ppm' },
-                     { 'ext' : 'tif', 'type' : 'tif' }]
+            filetype = "TIF file (*.tif)|*.tif|PPM file (*.ppm)|*.ppm"
+            ltype = [{ 'ext' : 'tif', 'type' : 'tif' },
+                     { 'ext' : 'ppm', 'type' : 'ppm' }]
         else:
         else:
             img = self.MapWindow.img
             img = self.MapWindow.img
             if not img:
             if not img:

+ 13 - 10
gui/wxpython/nviz/mapwindow.py

@@ -168,7 +168,7 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
         self.Bind(EVT_UPDATE_PROP,   self.UpdateMapObjProperties)
         self.Bind(EVT_UPDATE_PROP,   self.UpdateMapObjProperties)
         self.Bind(EVT_UPDATE_VIEW,   self.OnUpdateView)
         self.Bind(EVT_UPDATE_VIEW,   self.OnUpdateView)
         self.Bind(EVT_UPDATE_LIGHT,  self.UpdateLight)
         self.Bind(EVT_UPDATE_LIGHT,  self.UpdateLight)
-        self.Bind(EVT_UPDATE_CPLANE, self.UpdateCPlane)
+        self.Bind(EVT_UPDATE_CPLANE, self.OnUpdateCPlane)
         
         
         self.Bind(wx.EVT_TIMER, self.OnTimerAnim, self.timerAnim)
         self.Bind(wx.EVT_TIMER, self.OnTimerAnim, self.timerAnim)
         self.Bind(wx.EVT_TIMER, self.OnTimerFly, self.timerFly)
         self.Bind(wx.EVT_TIMER, self.OnTimerFly, self.timerFly)
@@ -1566,19 +1566,22 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
                 except IndexError:
                 except IndexError:
                     pass
                     pass
                     
                     
-    def UpdateCPlane(self, event):
+    def OnUpdateCPlane(self, event):
         """!Change cutting plane settings"""
         """!Change cutting plane settings"""
-        current = event.current
-        for each in event.update:
+        self.UpdateCPlane(event.current, event.update)
+
+    def UpdateCPlane(self, index, changes):
+        """!Change cutting plane settings"""
+        for each in changes:
             if each == 'rotation':
             if each == 'rotation':
-                self._display.SetCPlaneRotation(0, self.cplanes[current]['rotation']['tilt'],
-                                                   self.cplanes[current]['rotation']['rot'])
+                self._display.SetCPlaneRotation(0, self.cplanes[index]['rotation']['tilt'],
+                                                   self.cplanes[index]['rotation']['rot'])
             if each == 'position':
             if each == 'position':
-                self._display.SetCPlaneTranslation(self.cplanes[current]['position']['x'],
-                                                   self.cplanes[current]['position']['y'],
-                                                   self.cplanes[current]['position']['z'])
+                self._display.SetCPlaneTranslation(self.cplanes[index]['position']['x'],
+                                                   self.cplanes[index]['position']['y'],
+                                                   self.cplanes[index]['position']['z'])
             if each == 'shading':
             if each == 'shading':
-                self._display.SetFenceColor(self.cplanes[current]['shading'])
+                self._display.SetFenceColor(self.cplanes[index]['shading'])
             
             
     def UnloadRaster(self, item):
     def UnloadRaster(self, item):
         """!Unload 2d raster map
         """!Unload 2d raster map

+ 32 - 26
gui/wxpython/nviz/tools.py

@@ -20,6 +20,7 @@ This program is free software under the GNU General Public License
 """
 """
 
 
 import os
 import os
+import sys
 import copy
 import copy
 import types
 import types
 
 
@@ -237,7 +238,7 @@ class NvizToolWindow(FN.FlatNotebook):
         # perspective
         # perspective
         # set initial defaults here (or perhaps in a default values file), not in user settings
         # set initial defaults here (or perhaps in a default values file), not in user settings
         #todo: consider setting an absolute max at 360 instead of undefined. (leave the default max value at pi)
         #todo: consider setting an absolute max at 360 instead of undefined. (leave the default max value at pi)
-        tooltip = _("Adjusts the viewer's angle of view")
+        tooltip = _("Adjusts the distance and angular perspective of the image viewpoint")
         self._createControl(panel, data = self.win['view'], name = 'persp',
         self._createControl(panel, data = self.win['view'], name = 'persp',
                             tooltip = tooltip, range = (1, 120),
                             tooltip = tooltip, range = (1, 120),
                             bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedText))
                             bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedText))
@@ -250,25 +251,23 @@ class NvizToolWindow(FN.FlatNotebook):
                       flag = wx.ALIGN_CENTER)        
                       flag = wx.ALIGN_CENTER)        
         
         
         # twist
         # twist
-        tooltip = _("Rotates the scene about the horizontal axis."
-                   " An angle of 0 is flat. The scene rotates between -90 and 90 degrees.")
+        tooltip = _("Tilts the plane of the surface from the horizontal")
         self._createControl(panel, data = self.win['view'], name = 'twist',
         self._createControl(panel, data = self.win['view'], name = 'twist',
                             tooltip = tooltip, range = (-180,180),
                             tooltip = tooltip, range = (-180,180),
                             bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedText))
                             bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedText))
-        gridSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("Twist:")),
+        gridSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("Tilt:")),
                       pos = (1, 1), flag = wx.ALIGN_CENTER)
                       pos = (1, 1), flag = wx.ALIGN_CENTER)
         gridSizer.Add(item = self.FindWindowById(self.win['view']['twist']['slider']), pos = (2, 1))
         gridSizer.Add(item = self.FindWindowById(self.win['view']['twist']['slider']), pos = (2, 1))
         gridSizer.Add(item = self.FindWindowById(self.win['view']['twist']['text']), pos = (3, 1),
         gridSizer.Add(item = self.FindWindowById(self.win['view']['twist']['text']), pos = (3, 1),
                       flag = wx.ALIGN_CENTER)        
                       flag = wx.ALIGN_CENTER)        
         
         
         # height + z-exag
         # height + z-exag
-        tooltip = _("Adjusts the viewer's height above the scene")
+        tooltip = _("Adjusts the viewing height above the surface"
+                    " (angle of view automatically adjusts to maintain the same center of view)")
         self._createControl(panel, data = self.win['view'], name = 'height', sliderHor = False,
         self._createControl(panel, data = self.win['view'], name = 'height', sliderHor = False,
                             tooltip = tooltip, range = (0, 1),
                             tooltip = tooltip, range = (0, 1),
                             bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedText))
                             bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedText))
-        tooltip = _("Adjusts the vertical exaggeration of the surface. "
-                    "As an example, if the easting and northing are in meters and the elevation in feet, "
-                    "a vertical exaggeration of .305 would produce a true (unexaggerated) surface. ")
+        tooltip = _("Adjusts the relative height of features above the plane of the surface")
         self._createControl(panel, data = self.win['view'], name = 'z-exag', sliderHor = False,
         self._createControl(panel, data = self.win['view'], name = 'z-exag', sliderHor = False,
                             tooltip = tooltip, range = (0, 10), floatSlider = True,
                             tooltip = tooltip, range = (0, 10), floatSlider = True,
                             bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedText))
                             bind = (self.OnViewChange, self.OnViewChanged, self.OnViewChangedText))
@@ -485,7 +484,7 @@ class NvizToolWindow(FN.FlatNotebook):
                                                           key = 'animation', subkey = 'prefix'))
                                                           key = 'animation', subkey = 'prefix'))
         prefixCtrl.SetToolTipString(_("Generated files names will look like this: prefix_1.ppm, prefix_2.ppm, ..."))
         prefixCtrl.SetToolTipString(_("Generated files names will look like this: prefix_1.ppm, prefix_2.ppm, ..."))
         fileTypeLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("File format:"))
         fileTypeLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("File format:"))
-        fileTypeCtrl = wx.Choice(parent = panel, id = wx.ID_ANY, choices = ["PPM", "TIF"])
+        fileTypeCtrl = wx.Choice(parent = panel, id = wx.ID_ANY, choices = ["TIF", "PPM"])
         
         
         save = wx.Button(parent = panel, id = wx.ID_ANY,
         save = wx.Button(parent = panel, id = wx.ID_ANY,
                          label = "Save")
                          label = "Save")
@@ -872,7 +871,7 @@ class NvizToolWindow(FN.FlatNotebook):
         self.win['surface']['position']['reset'] = reset.GetId()
         self.win['surface']['position']['reset'] = reset.GetId()
         
         
         self.win['surface']['position']['axis'] = axis.GetId()
         self.win['surface']['position']['axis'] = axis.GetId()
-        axis.SetSelection(0)
+        axis.SetSelection(2)
         axis.Bind(wx.EVT_CHOICE, self.OnSurfaceAxis)
         axis.Bind(wx.EVT_CHOICE, self.OnSurfaceAxis)
         
         
         pslide = self.FindWindowById(self.win['surface']['position']['slider'])
         pslide = self.FindWindowById(self.win['surface']['position']['slider'])
@@ -1009,8 +1008,8 @@ class NvizToolWindow(FN.FlatNotebook):
         self._createControl(panel, data = self.win['cplane']['rotation'], name = 'rot', size = 250,
         self._createControl(panel, data = self.win['cplane']['rotation'], name = 'rot', size = 250,
                             range = (0, 360), sliderHor = True, tooltip = tooltip,
                             range = (0, 360), sliderHor = True, tooltip = tooltip,
                             bind = (self.OnCPlaneChanging, self.OnCPlaneChangeDone, self.OnCPlaneChangeText))
                             bind = (self.OnCPlaneChanging, self.OnCPlaneChangeDone, self.OnCPlaneChangeText))
-        self.FindWindowById(self.win['cplane']['rotation']['rot']['slider']).SetValue(0)
-        self.FindWindowById(self.win['cplane']['rotation']['rot']['text']).SetValue(0)
+        self.FindWindowById(self.win['cplane']['rotation']['rot']['slider']).SetValue(180)
+        self.FindWindowById(self.win['cplane']['rotation']['rot']['text']).SetValue(180)
         gridSizer.Add(item = self.FindWindowById(self.win['cplane']['rotation']['rot']['slider']),
         gridSizer.Add(item = self.FindWindowById(self.win['cplane']['rotation']['rot']['slider']),
                       pos = (2, 1),  flag = wx.EXPAND|wx.ALIGN_RIGHT)
                       pos = (2, 1),  flag = wx.EXPAND|wx.ALIGN_RIGHT)
         gridSizer.Add(item = self.FindWindowById(self.win['cplane']['rotation']['rot']['text']),
         gridSizer.Add(item = self.FindWindowById(self.win['cplane']['rotation']['rot']['text']),
@@ -1681,7 +1680,7 @@ class NvizToolWindow(FN.FlatNotebook):
         self.win['volume']['position']['reset'] = reset.GetId()
         self.win['volume']['position']['reset'] = reset.GetId()
         
         
         self.win['volume']['position']['axis'] = axis.GetId()
         self.win['volume']['position']['axis'] = axis.GetId()
-        axis.SetSelection(0)
+        axis.SetSelection(2) # Z
         axis.Bind(wx.EVT_CHOICE, self.OnVolumeAxis)
         axis.Bind(wx.EVT_CHOICE, self.OnVolumeAxis)
         
         
         pslide = self.FindWindowById(self.win['volume']['position']['slider'])
         pslide = self.FindWindowById(self.win['volume']['position']['slider'])
@@ -2606,7 +2605,10 @@ class NvizToolWindow(FN.FlatNotebook):
         ne = wx.Button(panel, id = wx.ID_ANY, label = _("NE"))
         ne = wx.Button(panel, id = wx.ID_ANY, label = _("NE"))
         se = wx.Button(panel, id = wx.ID_ANY, label = _("SE"))
         se = wx.Button(panel, id = wx.ID_ANY, label = _("SE"))
         sw = wx.Button(panel, id = wx.ID_ANY, label = _("SW"))
         sw = wx.Button(panel, id = wx.ID_ANY, label = _("SW"))
-        minWidth = sw.GetTextExtent(sw.GetLabel())[0] + 15
+        padding = 15
+        if sys.platform == 'darwin':
+            padding = 20
+        minWidth = sw.GetTextExtent(sw.GetLabel())[0] + padding
         for win, name in zip((w, n, s, e, nw, ne, se, sw),
         for win, name in zip((w, n, s, e, nw, ne, se, sw),
                         ('w', 'n', 's', 'e', 'nw', 'ne', 'se', 'sw')):
                         ('w', 'n', 's', 'e', 'nw', 'ne', 'se', 'sw')):
             win.SetMinSize((minWidth, -1))
             win.SetMinSize((minWidth, -1))
@@ -2861,7 +2863,7 @@ class NvizToolWindow(FN.FlatNotebook):
         
         
         for win in self.win['surface']['position'].itervalues():
         for win in self.win['surface']['position'].itervalues():
             if win == self.win['surface']['position']['axis']:
             if win == self.win['surface']['position']['axis']:
-                self.FindWindowById(win).SetSelection(0)
+                self.FindWindowById(win).SetSelection(2) # Z
             elif win == self.win['surface']['position']['reset']:
             elif win == self.win['surface']['position']['reset']:
                 continue
                 continue
             else:
             else:
@@ -4132,7 +4134,7 @@ class NvizToolWindow(FN.FlatNotebook):
         """!Reset position of volume"""
         """!Reset position of volume"""
         for win in self.win['volume']['position'].itervalues():
         for win in self.win['volume']['position'].itervalues():
             if win == self.win['volume']['position']['axis']:
             if win == self.win['volume']['position']['axis']:
-                self.FindWindowById(win).SetSelection(0)
+                self.FindWindowById(win).SetSelection(2) # Z
             elif win == self.win['volume']['position']['reset']:
             elif win == self.win['volume']['position']['reset']:
                 continue
                 continue
             else:
             else:
@@ -4254,6 +4256,9 @@ class NvizToolWindow(FN.FlatNotebook):
             planeIndex = -1
             planeIndex = -1
             self.EnablePage("cplane", enabled = False)
             self.EnablePage("cplane", enabled = False)
         self.mapWindow.SelectCPlane(planeIndex)
         self.mapWindow.SelectCPlane(planeIndex)
+        if planeIndex >= 0:
+            self.mapWindow.UpdateCPlane(planeIndex, changes = ['rotation', 'position', 'shading'])
+
         if self.mapDisplay.IsAutoRendered():
         if self.mapDisplay.IsAutoRendered():
             self.mapWindow.Refresh(False)
             self.mapWindow.Refresh(False)
         self.UpdateCPlanePage(planeIndex)
         self.UpdateCPlanePage(planeIndex)
@@ -4320,8 +4325,10 @@ class NvizToolWindow(FN.FlatNotebook):
             planeIndex = int(plane.split()[-1]) - 1
             planeIndex = int(plane.split()[-1]) - 1
         except:#TODO disabled page
         except:#TODO disabled page
             planeIndex = -1
             planeIndex = -1
+
         self.mapWindow.cplanes[planeIndex] = copy.deepcopy(UserSettings.Get(group = 'nviz',
         self.mapWindow.cplanes[planeIndex] = copy.deepcopy(UserSettings.Get(group = 'nviz',
                                                                             key = 'cplane'))
                                                                             key = 'cplane'))
+        self.mapWindow.cplanes[planeIndex]['on'] = True
         event = wxUpdateCPlane(update = ('position','rotation','shading'), current = planeIndex)
         event = wxUpdateCPlane(update = ('position','rotation','shading'), current = planeIndex)
         wx.PostEvent(self.mapWindow, event)
         wx.PostEvent(self.mapWindow, event)
         self.OnCPlaneChangeDone(None)
         self.OnCPlaneChangeDone(None)
@@ -4647,11 +4654,11 @@ class NvizToolWindow(FN.FlatNotebook):
         #
         #
         dim = self._display.GetLongDim()
         dim = self._display.GetLongDim()
         self.FindWindowById(self.win['surface']['position']['slider']).SetRange(-2 * dim, 2 * dim)
         self.FindWindowById(self.win['surface']['position']['slider']).SetRange(-2 * dim, 2 * dim)
-        if 'x' in data['position']:
-            xval = data['position']['x']
-            self.FindWindowById(self.win['surface']['position']['axis']).SetSelection(0)
+        if 'z' in data['position']:
+            zval = data['position']['z']
+            self.FindWindowById(self.win['surface']['position']['axis']).SetSelection(2)
             for control in ('slider','text'):
             for control in ('slider','text'):
-                    self.FindWindowById(self.win['surface']['position'][control]).SetValue(xval)
+                    self.FindWindowById(self.win['surface']['position'][control]).SetValue(zval)
         # enable/disable res widget + set draw mode
         # enable/disable res widget + set draw mode
         self.OnSurfaceMode(event = None)
         self.OnSurfaceMode(event = None)
 
 
@@ -4858,11 +4865,11 @@ class NvizToolWindow(FN.FlatNotebook):
         #
         #
         # position
         # position
         #
         #
-        if 'x' in data['position']:
-            xval = data['position']['x']
-            self.FindWindowById(self.win['volume']['position']['axis']).SetSelection(0)
+        if 'z' in data['position']:
+            zval = data['position']['z']
+            self.FindWindowById(self.win['volume']['position']['axis']).SetSelection(2)
             for control in ('slider','text'):
             for control in ('slider','text'):
-                    self.FindWindowById(self.win['volume']['position'][control]).SetValue(xval)    
+                    self.FindWindowById(self.win['volume']['position'][control]).SetValue(zval)
         # set topo range
         # set topo range
         mapRange = self._get3dRange(name = layer.name)
         mapRange = self._get3dRange(name = layer.name)
         desc = self.FindWindowById(self.win['volume']['desc'])
         desc = self.FindWindowById(self.win['volume']['desc'])
@@ -5059,8 +5066,7 @@ class ViewPositionWindow(PositionWindow):
     def __init__(self, parent, mapwindow, id = wx.ID_ANY,
     def __init__(self, parent, mapwindow, id = wx.ID_ANY,
                  **kwargs):
                  **kwargs):
         PositionWindow.__init__(self, parent, mapwindow, id, **kwargs)
         PositionWindow.__init__(self, parent, mapwindow, id, **kwargs)
-        self.SetToolTipString(_("Adjusts the look direction (azimuth). "
-                                "Click and drag the puck to change the current eye position."))
+        self.SetToolTipString(_("Adjusts the distance and direction of the image viewpoint"))
         self.data = self.mapWindow.view
         self.data = self.mapWindow.view
         self.PostDraw()
         self.PostDraw()