[GRASS-SVN] r55968 - in grass/branches/releasebranch_6_4/gui/wxpython: core gui_core nviz

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 24 01:11:55 PDT 2013


Author: annakrat
Date: 2013-04-24 01:11:55 -0700 (Wed, 24 Apr 2013)
New Revision: 55968

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/core/settings.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_core/preferences.py
   grass/branches/releasebranch_6_4/gui/wxpython/nviz/mapwindow.py
Log:
wxGUI/nviz: fix for strange vector rendering on wxGTK (merge from trunk, r55967)

Modified: grass/branches/releasebranch_6_4/gui/wxpython/core/settings.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/core/settings.py	2013-04-24 08:03:16 UTC (rev 55967)
+++ grass/branches/releasebranch_6_4/gui/wxpython/core/settings.py	2013-04-24 08:11:55 UTC (rev 55968)
@@ -188,6 +188,9 @@
                 'scrollDirection' : {
                     'selection' : 0,
                     },
+                'nvizDepthBuffer' : {
+                    'value' : 16,
+                    },
                 },
             #
             # projection

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_core/preferences.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_core/preferences.py	2013-04-24 08:03:16 UTC (rev 55967)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_core/preferences.py	2013-04-24 08:11:55 UTC (rev 55968)
@@ -49,6 +49,7 @@
 from core.gcmd     import RunCommand, GError
 from core.utils    import ListOfMapsets, GetColorTables, ReadEpsgCodes, GetSettingsPath
 from core.settings import UserSettings
+from gui_core.widgets import IntegerValidator
 
 wxSettingsChanged, EVT_SETTINGS_CHANGED = NewEvent()
 
@@ -776,6 +777,36 @@
         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

Modified: grass/branches/releasebranch_6_4/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/nviz/mapwindow.py	2013-04-24 08:03:16 UTC (rev 55967)
+++ grass/branches/releasebranch_6_4/gui/wxpython/nviz/mapwindow.py	2013-04-24 08:11:55 UTC (rev 55968)
@@ -31,6 +31,7 @@
 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
 
@@ -42,6 +43,7 @@
 from core.settings      import UserSettings
 from nviz.animation     import Animation
 from nviz               import wxnviz
+from core.globalvar     import CheckWxVersion
 
 wxUpdateProperties, EVT_UPDATE_PROP  = NewEvent()
 wxUpdateView,       EVT_UPDATE_VIEW  = NewEvent()
@@ -73,7 +75,18 @@
                  Map = None, tree = None, lmgr = None):
         self.parent = parent # MapFrame
         
-        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, id, 
                            Map, tree, lmgr)
         self.Hide()
@@ -179,9 +192,21 @@
         
         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



More information about the grass-commit mailing list