[GRASS-SVN] r42878 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 22 05:08:27 EDT 2010


Author: martinl
Date: 2010-07-22 09:08:27 +0000 (Thu, 22 Jul 2010)
New Revision: 42878

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py
Log:
wxGUI: clean up vdigit/nviz error messages


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2010-07-22 08:38:45 UTC (rev 42877)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2010-07-22 09:08:27 UTC (rev 42878)
@@ -324,15 +324,21 @@
             from vdigit import haveVDigit
             if not haveVDigit:
                 from vdigit import errorMsg
-                msg = _("Unable to start vector digitizer.\nThe VDigit python extension "
-                        "was not found or loaded properly.\n"
-                        "Switching back to 2D display mode.\n\nDetails: %s" % errorMsg)
+                msg = _("Unable to start wxGUI vector digitizer.\nDo you want to start "
+                        "TCL/TK digitizer (v.digit) instead?\n\n"
+                        "Details: %s" % errorMsg)
                 
+                self.mapdisplay.toolbars['map'].combo.SetValue (_("2D view"))
+                dlg = wx.MessageDialog(parent = self.mapdisplay,
+                                       message = msg,
+                                       caption=_("Vector digitizer failed"),
+                                       style = wx.YES_NO | wx.CENTRE)
+                if dlg.ShowModal() == wx.ID_YES:
+                    self.lmgr.goutput.RunCmd(['v.digit', 'map=%s' % maplayer.GetName()],
+                                             switchPage=False)
+                dlg.Destroy()
+                
                 self.toolbars['map'].combo.SetValue (_("2D view"))
-                wx.MessageBox(parent=self,
-                              message=msg,
-                              caption=_("Error"),
-                              style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
                 return
             
             if self._layerManager:

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz.py	2010-07-22 08:38:45 UTC (rev 42877)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz.py	2010-07-22 09:08:27 UTC (rev 42878)
@@ -1,4 +1,4 @@
-"""
+"""!
 @package nviz.py
 
 @brief Nviz (3D view) module
@@ -30,13 +30,10 @@
     sys.path.append(os.path.join(globalvar.ETCWXDIR, "nviz"))
     import grass6_wxnviz as wxnviz
     haveNviz = True
-except ImportError, e:
+except ImportError, err:
     haveNviz = False
-    errorMsg = _("3D view mode is not available.\n"
-                 "Reason: %s\n"
-                 "Note that the 3D view mode is currently not working under\nMS Windows "
-                 "(hopefully this will be fixed soon). "
-                 "Please keep\nan eye out for updated versions of GRASS." % e)
+    errorMsg = err
+
 if haveNviz:
     GLWindow = nviz_mapdisp.GLWindow
 else:

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2010-07-22 08:38:45 UTC (rev 42877)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2010-07-22 09:08:27 UTC (rev 42878)
@@ -178,22 +178,43 @@
         self.InitToolbar(self.ToolbarData())
         
         # optional tools
-        choices = [_('2D view')]
-        lmgr = self.parent.GetLayerManager()
+        choices = [ _('2D view'), ]
+        self.toolId = { '2d' : 0 }
+        log = self.parent.GetLayerManager().GetLogWindow()
         if haveNviz:
             choices.append(_('3D view'))
+            self.toolId['3d'] = 1
         else:
-            from nviz import errorMsg
-            lmgr.goutput.WriteWarning(errorMsg)
+            from nviz import errorMsg as errorMsg1
+            from wxnviz import errorMsg as errorMsg2
+            if errorMsg2:
+                errorMsg = str(errorMsg1) + ' (' + str(errorMsg2) + ')'
+            log.WriteCmdLog(_('3D view mode not available'))
+            log.WriteWarning(_('Reason: %s') % errorMsg)
+            log.WriteLog(_('Note that the 3D view mode is currently not working under MS Windows '
+                           '(hopefully this will be fixed soon). '
+                           'Please keep an eye out for updated versions of GRASS.'), wrap = 60)
+            
+            self.toolId['3d'] = -1
         if haveVDigit:
             choices.append(_('Digitize'))
+            if self.toolId['3d'] > -1:
+                self.toolId['vdigit'] = 2
+            else:
+                self.toolId['vdigit'] = 1
         else:
             from vdigit import errorMsg
-            lmgr.goutput.WriteWarning(errorMsg)
+            log.WriteCmdLog(_('Vector digitizer not available'))
+            log.WriteWarning(_('Reason: %s') % errorMsg)
+            log.WriteLog(_('Note that the vector digitizer is currently not working under MS Windows '
+                           '(hopefully this will be fixed soon). '
+                           'Please keep an eye out for updated versions of GRASS.'), wrap = 60)
+            
+            self.toolId['vdigit'] = -1
         
         self.combo = wx.ComboBox(parent = self, id = wx.ID_ANY,
                                  choices = choices,
-                                 style=wx.CB_READONLY, size=(90, -1))
+                                 style = wx.CB_READONLY, size = (90, -1))
         self.combo.SetSelection(0)
         
         self.comboid = self.AddControl(self.combo)
@@ -289,20 +310,21 @@
             )
     
     def OnSelectTool(self, event):
-        """!
-        Select / enable tool available in tools list
+        """!Select / enable tool available in tools list
         """
         tool =  event.GetSelection()
         
-        if tool == 0:
+        if tool == self.toolId['2d']:
             self.ExitToolbars()
             self.Enable2D(True)
         
-        elif tool == 1 and not self.parent.toolbars['nviz']:
+        elif tool == self.toolId['3d'] and \
+                not self.parent.toolbars['nviz']:
             self.ExitToolbars()
             self.parent.AddToolbar("nviz")
             
-        elif tool == 2 and not self.parent.toolbars['vdigit']:
+        elif tool == self.toolId['vdigit'] and \
+                not self.parent.toolbars['vdigit']:
             self.ExitToolbars()
             self.parent.AddToolbar("vdigit")
             self.parent.MapWindow.SetFocus()

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2010-07-22 08:38:45 UTC (rev 42877)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2010-07-22 09:08:27 UTC (rev 42878)
@@ -54,11 +54,7 @@
     haveVDigit = False
     GV_LINES = None
     PseudoDC = wx.PseudoDC
-    errorMsg = _("Vector digitizer is not available.\n"
-                 "Reason: %s\n"
-                 "Note that the vector digitizer is currently not working under\nMS Windows "
-                 "(hopefully this will be fixed soon). "
-                 "Please keep\nan eye out for updated versions of GRASS." % err)
+    errorMsg = err
     
 class AbstractDigit:
     """!Abstract digitization class

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py	2010-07-22 08:38:45 UTC (rev 42877)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/wxnviz.py	2010-07-22 09:08:27 UTC (rev 42878)
@@ -26,9 +26,9 @@
     from grass.lib.grass import *
     from grass.lib.ogsf  import *
     from grass.lib.nviz  import *
-except ImportError, e:
-    print >> sys.stderr, "\nWARNING: Nviz extension (3D view mode) disabled. Reason: %s" % e
-    sys.stderr.flush()
+    errorMsg = ''
+except ImportError, err:
+    errorMsg = err
 
 from debug import Debug
 



More information about the grass-commit mailing list