[GRASS-SVN] r37097 - grass/branches/releasebranch_6_4/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 10 06:58:42 EDT 2009


Author: martinl
Date: 2009-05-10 06:58:41 -0400 (Sun, 10 May 2009)
New Revision: 37097

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/vdigit.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxgui_utils.py
Log:
wxGUI: do not remove 'digitize' and '3d view' from the toolbar even if the extensions are not available (trac #586)
      (merge from trunk, r37095)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2009-05-10 10:53:49 UTC (rev 37096)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2009-05-10 10:58:41 UTC (rev 37097)
@@ -2755,6 +2755,19 @@
 	
         # vector digitizer
         elif name == "vdigit":
+            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)
+                
+                self.toolbars['map'].combo.SetValue (_("2D view"))
+                wx.MessageBox(parent=self,
+                              message=msg,
+                              caption=_("Error"))
+                return
+            
             self.toolbars['vdigit'] = toolbars.VDigitToolbar(parent=self, map=self.Map,
                                                              layerTree=self.tree,
                                                              log=self.gismanager.goutput)
@@ -2792,16 +2805,17 @@
             # check for GLCanvas and OpenGL
             msg = None
             if not nviz.haveGLCanvas:
-                msg = _("Unable to start Nviz. The GLCanvas class has not been "
+                msg = _("Unable to switch to 3D display mode.\nThe GLCanvas class has not been "
                         "included with this build "
-                        "of wxPython! Switching back to "
+                        "of wxPython!\nSwitching back to "
                         "2D display mode.\n\nDetails: %s" % nviz.errorMsg)
             if not nviz.haveNviz:
-                msg = _("Unable to start Nviz. Python extension "
-                        "for Nviz was not found or loaded properly. "
+                msg = _("Unable to switch to 3D display mode.\nThe Nviz python extension "
+                        "was not found or loaded properly.\n"
                         "Switching back to 2D display mode.\n\nDetails: %s" % nviz.errorMsg)
 
             if msg:
+                self.toolbars['map'].combo.SetValue (_("2D view"))
                 wx.MessageBox(parent=self,
                               message=msg,
                               caption=_("Error"))

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py	2009-05-10 10:53:49 UTC (rev 37096)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py	2009-05-10 10:58:41 UTC (rev 37097)
@@ -31,8 +31,6 @@
 import gdialogs
 import vdigit
 from vdigit import VDigitSettingsDialog as VDigitSettingsDialog
-from vdigit import haveVDigit
-from nviz import haveNviz
 from debug import Debug as Debug
 from icon import Icons as Icons
 from preferences import globalSettings as UserSettings
@@ -162,12 +160,8 @@
         
         # optional tools
         self.combo = wx.ComboBox(parent=self.toolbar, id=wx.ID_ANY, value=_('2D view'),
-                                 choices=[_('2D view'), ], 
+                                 choices=[_('2D view'), _('3D view'), _('Digitize')],
                                  style=wx.CB_READONLY, size=(90, -1))
-        if haveNviz:
-            self.combo.Append(_('3D view'))
-        if haveVDigit:
-            self.combo.Append(_('Digitize'))
         
         self.comboid = self.toolbar.AddControl(self.combo)
         self.mapdisplay.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/vdigit.py	2009-05-10 10:53:49 UTC (rev 37096)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/vdigit.py	2009-05-10 10:58:41 UTC (rev 37097)
@@ -55,12 +55,12 @@
     GV_LINES = wxvdigit.GV_LINES
     PseudoDC = wxvdigit.PseudoDC
     haveVDigit = True
-    digitErr = ''
+    errorMsg = ''
 except ImportError, err:
     haveVDigit = False
     GV_LINES = None
     PseudoDC = None
-    digitErr = err
+    errorMsg = err
     print >> sys.stderr, "\nWARNING: Vector digitizer is not available (%s). " % err
 
 class AbstractDigit:
@@ -122,7 +122,7 @@
             raise gcmd.DigitError(parent=self.mapWindow.parent,
                                   message="%s %s (%s)" % (_('Unable to initialize display driver, '
                                                             'see README file for more information.\n\n'
-                                                            'Details:'), e, digitErr))
+                                                            'Details:'), e, errorMsg))
         
         if map and ret == -1:
             raise gcmd.DigitError(parent=self.mapWindow.parent,

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxgui_utils.py	2009-05-10 10:53:49 UTC (rev 37096)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxgui_utils.py	2009-05-10 10:58:41 UTC (rev 37097)
@@ -291,8 +291,6 @@
             self.Bind (wx.EVT_MENU, self.gismgr.OnShowAttributeTable, id=self.popupID4)
 
             self.popupMenu.Append(self.popupID5, text=_("Start editing"))
-            if not haveVDigit:
-                self.popupMenu.Enable(self.popupID5, False)
             self.popupMenu.Append(self.popupID6, text=_("Stop editing"))
             self.popupMenu.Enable(self.popupID6, False)
             self.Bind (wx.EVT_MENU, self.OnStartEditing, id=self.popupID5)
@@ -501,6 +499,18 @@
         """
         Start editing vector map layer requested by the user
         """
+        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)
+            
+            self.mapdisplay.toolbars['map'].combo.SetValue (_("2D view"))
+            wx.MessageBox(parent=self.mapdisplay,
+                          message=msg,
+                          caption=_("Error"))
+            return
+        
         try:
             maplayer = self.GetPyData(self.layer_selected)[0]['maplayer']
         except:



More information about the grass-commit mailing list