浏览代码

wxGUI/nviz: fix for strange vector rendering on wxGTK

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@55967 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 年之前
父节点
当前提交
b946e4ae22
共有 3 个文件被更改,包括 61 次插入2 次删除
  1. 3 0
      gui/wxpython/core/settings.py
  2. 31 0
      gui/wxpython/gui_core/preferences.py
  3. 27 2
      gui/wxpython/nviz/mapwindow.py

+ 3 - 0
gui/wxpython/core/settings.py

@@ -190,6 +190,9 @@ class Settings:
                 'scrollDirection' : {
                     'selection' : 0,
                     },
+                'nvizDepthBuffer' : {
+                    'value' : 16,
+                    },
                 },
             #
             # projection

+ 31 - 0
gui/wxpython/gui_core/preferences.py

@@ -49,6 +49,7 @@ from core.gcmd     import RunCommand, GError
 from core.utils    import ListOfMapsets, GetColorTables, ReadEpsgCodes, StoreEnvVariable
 from core.settings import UserSettings
 from gui_core.dialogs import SymbolDialog
+from gui_core.widgets import IntegerValidator
 
 class PreferencesBaseDialog(wx.Dialog):
     """!Base preferences dialog"""
@@ -784,6 +785,36 @@ class PreferencesDialog(PreferencesBaseDialog):
         sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
         border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
         
+        
+        #
+        # advanced
+        #
+        
+        # see initialization of nviz GLWindow
+        if globalvar.CheckWxVersion(version=[2, 8, 11]) and \
+           sys.platform not in ('win32', 'darwin'):
+            box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Advanced display settings"))
+            sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+    
+            gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
+            row = 0
+            gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                                               label = _("3D view depth buffer (possible values are 16, 24, 32):")),
+                          flag = wx.ALIGN_LEFT |
+                          wx.ALIGN_CENTER_VERTICAL,
+                          pos = (row, 0))
+            value = self.settings.Get(group='display', key='nvizDepthBuffer', subkey='value')
+            textCtrl = wx.TextCtrl(parent=panel, id=wx.ID_ANY, value=str(value), validator=IntegerValidator())
+            self.winId['display:nvizDepthBuffer:value'] = textCtrl.GetId()
+            gridSizer.Add(item = textCtrl,
+                          flag = wx.ALIGN_RIGHT |
+                          wx.ALIGN_CENTER_VERTICAL,
+                          pos = (row, 1))
+    
+            gridSizer.AddGrowableCol(0)
+            sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
+            border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
+        
         panel.SetSizer(border)
                 
         # bindings

+ 27 - 2
gui/wxpython/nviz/mapwindow.py

@@ -30,6 +30,7 @@ from threading import Thread
 import wx
 from   wx.lib.newevent import NewEvent
 from   wx              import glcanvas
+from wx.glcanvas       import WX_GL_DEPTH_SIZE
 
 import grass.script as grass
 
@@ -40,6 +41,7 @@ from core.settings      import UserSettings
 from nviz.workspace     import NvizSettings
 from nviz.animation     import Animation
 from nviz               import wxnviz
+from core.globalvar     import CheckWxVersion
 
 wxUpdateProperties, EVT_UPDATE_PROP  = NewEvent()
 wxUpdateView,       EVT_UPDATE_VIEW  = NewEvent()
@@ -72,8 +74,19 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
         self.parent = parent # MapFrame
         self.tree = tree
         self.lmgr = lmgr
-
-        glcanvas.GLCanvas.__init__(self, parent, id)
+        
+        # for wxGTK we need to set WX_GL_DEPTH_SIZE to draw vectors correctly
+        # but we don't know the right value
+        # in wxpython 2.9, there is IsDisplaySupported
+        if CheckWxVersion(version=[2, 8, 11]) and \
+           sys.platform not in ('win32', 'darwin'):
+            depthBuffer = int(UserSettings.Get(group='display', key='nvizDepthBuffer', subkey='value'))
+            attribs=[WX_GL_DEPTH_SIZE, depthBuffer, 0]
+            glcanvas.GLCanvas.__init__(self, parent, id, attribList=attribs)
+        else:
+            glcanvas.GLCanvas.__init__(self, parent, id)
+        
+            
         MapWindow.__init__(self, parent = parent, giface = giface, frame = frame,
                            Map = Map)
         self.Hide()
@@ -179,9 +192,21 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
         
         self.Bind(wx.EVT_CLOSE, self.OnClose)
         
+        if CheckWxVersion(version=[2, 8, 11]) and \
+           sys.platform not in ('win32', 'darwin'):
+               wx.CallLater(3000, self._warningDepthBuffer)
+        
         # cplanes cannot be initialized now
         wx.CallAfter(self.InitCPlanes)
 
+    def _warningDepthBuffer(self):
+        if not self.initView:
+            message=_("Opening 3D view was not successful. "
+                      "Please try to change the value of depth buffer "
+                      "in GUI Settings dialog > tab Map Display > Advanced "
+                      "and restart GUI.")
+            GMessage(message)
+
     def InitFly(self):
         """!Initialize fly through dictionary"""
         fly = {'interval' : 10,             # interval for timerFly