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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 21 07:57:16 EDT 2010


Author: martinl
Date: 2010-07-21 11:57:16 +0000 (Wed, 21 Jul 2010)
New Revision: 42872

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
   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/nviz_mapdisp.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
Log:
bug fix #628 (wingrass native: vdigit error on new map)
(merge r42871 trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py	2010-07-21 11:53:14 UTC (rev 42871)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py	2010-07-21 11:57:16 UTC (rev 42872)
@@ -508,28 +508,32 @@
         return True
 
     def OnStartEditing(self, event):
+        """!Start editing vector map layer requested by the user
         """
-        Start editing vector map layer requested by the user
-        """
+        try:
+            maplayer = self.GetPyData(self.layer_selected)[0]['maplayer']
+        except:
+            event.Skip()
+            return
+        
         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"))
-            wx.MessageBox(parent=self.mapdisplay,
-                          message=msg,
-                          caption=_("Error"),
-                          style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+            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()
             return
         
-        try:
-            maplayer = self.GetPyData(self.layer_selected)[0]['maplayer']
-        except:
-            event.Skip()
-            return
-
         if not self.mapdisplay.toolbars['vdigit']: # enable tool
             self.mapdisplay.AddToolbar('vdigit')
         else: # tool already enabled
@@ -1133,11 +1137,10 @@
         #
         if self.mapdisplay.toolbars['nviz'] and \
                 self.GetPyData(self.layer_selected) is not None:
-
             if self.layer_selected.IsChecked():
                 # update Nviz tool window
                 type = self.GetPyData(self.layer_selected)[0]['maplayer'].type
-
+                
                 if type == 'raster':
                     self.lmgr.nviz.UpdatePage('surface')
                     self.lmgr.nviz.SetPage('surface')
@@ -1147,14 +1150,7 @@
                 elif type == '3d-raster':
                     self.lmgr.nviz.UpdatePage('volume')
                     self.lmgr.nviz.SetPage('volume')
-            else:
-                for page in ('surface', 'vector', 'volume'):
-                    pageId = self.lmgr.nviz.page[page]['id']
-                    if pageId > -1:
-                        self.lmgr.nviz.notebook.RemovePage(pageId)
-                        self.lmgr.nviz.page[page]['id'] = -1
-                        self.lmgr.nviz.page['settings']['id'] = 1 
-
+        
     def OnCollapseNode(self, event):
         """!Collapse node
         """

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2010-07-21 11:53:14 UTC (rev 42871)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2010-07-21 11:57:16 UTC (rev 42872)
@@ -373,23 +373,14 @@
             import nviz
             
             # check for GLCanvas and OpenGL
-            msg = None
-            if not nviz.haveGLCanvas:
-                msg = _("Unable to switch to 3D display mode.\nThe GLCanvas class has not been "
-                        "included with this build "
-                        "of wxPython!\nSwitching back to "
-                        "2D display mode.\n\nDetails: %s" % nviz.errorMsg)
             if not nviz.haveNviz:
-                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"),
-                              style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+                wx.MessageBox(parent = self,
+                              message = _("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),
+                              caption = _("Error"),
+                              style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
                 return
             
             # add Nviz toolbar and disable 2D display mode tools

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz.py	2010-07-21 11:53:14 UTC (rev 42871)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz.py	2010-07-21 11:57:16 UTC (rev 42872)
@@ -23,24 +23,20 @@
 import sys
 
 import wx
-try:
-    from wx import glcanvas
-    haveGLCanvas = True
-except ImportError, e:
-    haveGLCanvas = False
-    errorMsg = e
-
 import globalvar
 try:
+    from wx import glcanvas
     import nviz_mapdisp
     sys.path.append(os.path.join(globalvar.ETCWXDIR, "nviz"))
     import grass6_wxnviz as wxnviz
     haveNviz = True
 except ImportError, e:
     haveNviz = False
-    errorMsg = e
-    print >> sys.stderr, "\nWARNING: Nviz extension (3D view) is not available (%s). " % e
-
+    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)
 if haveNviz:
     GLWindow = nviz_mapdisp.GLWindow
 else:

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py	2010-07-21 11:53:14 UTC (rev 42871)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py	2010-07-21 11:57:16 UTC (rev 42872)
@@ -40,8 +40,8 @@
 
 import wxnviz
 
-wxUpdateProperties, EVT_UPDATE_PROP = NewEvent()
-wxUpdateView,       EVT_UPDATE_VIEW = NewEvent()
+wxUpdateProperties, EVT_UPDATE_PROP  = NewEvent()
+wxUpdateView,       EVT_UPDATE_VIEW  = NewEvent()
 wxUpdateLight,      EVT_UPDATE_LIGHT = NewEvent()
 
 class NvizThread(Thread):
@@ -152,9 +152,9 @@
                                        size.height)
         
         event.Skip()
-
+        
     def OnPaint(self, event):
-        Debug.msg(3, "GLCanvas.OnPaint()")
+        Debug.msg(1, "GLCanvas.OnPaint()")
         
         dc = wx.PaintDC(self)
         self.SetCurrent()

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2010-07-21 11:53:14 UTC (rev 42871)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2010-07-21 11:57:16 UTC (rev 42872)
@@ -36,9 +36,10 @@
 import gcmd
 import gdialogs
 import vdigit
-from vdigit import VDigitSettingsDialog as VDigitSettingsDialog
-from debug import Debug as Debug
+from vdigit import VDigitSettingsDialog, haveVDigit
+from debug import Debug
 from preferences import globalSettings as UserSettings
+from nviz import haveNviz
 from nviz_preferences import NvizPreferencesDialog
 
 gmpath = os.path.join(globalvar.ETCWXDIR, "icons")
@@ -177,9 +178,23 @@
         self.InitToolbar(self.ToolbarData())
         
         # optional tools
-        self.combo = wx.ComboBox(parent=self, id=wx.ID_ANY, value=_('2D view'),
-                                 choices=[_('2D view'), _('3D view'), _('Digitize')],
+        choices = [_('2D view')]
+        lmgr = self.parent.GetLayerManager()
+        if haveNviz:
+            choices.append(_('3D view'))
+        else:
+            from nviz import errorMsg
+            lmgr.goutput.WriteWarning(errorMsg)
+        if haveVDigit:
+            choices.append(_('Digitize'))
+        else:
+            from vdigit import errorMsg
+            lmgr.goutput.WriteWarning(errorMsg)
+        
+        self.combo = wx.ComboBox(parent = self, id = wx.ID_ANY,
+                                 choices = choices,
                                  style=wx.CB_READONLY, size=(90, -1))
+        self.combo.SetSelection(0)
         
         self.comboid = self.AddControl(self.combo)
         self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2010-07-21 11:53:14 UTC (rev 42871)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2010-07-21 11:57:16 UTC (rev 42872)
@@ -1,14 +1,8 @@
 """!
 @package vdigit
 
- at brief Vector digitizer extension
+ at brief wxGUI vector digitizer user interface
 
-Usage:
-
- at code
-  from vdigit import VDigit as VDigit
- at endcode
-
 Classes:
  - AbstractDigit 
  - VDigit
@@ -60,17 +54,15 @@
     haveVDigit = False
     GV_LINES = None
     PseudoDC = wx.PseudoDC
-    errorMsg = err
-    # is there a way to have this display on the terminal before the wx gui exits?
-    print >> sys.stderr, "\nWARNING: Vector digitizer is not available (%s).\n\n" \
-        "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." % err
-
+    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)
+    
 class AbstractDigit:
+    """!Abstract digitization class
     """
-    Abstract digitization class
-    """
     def __init__(self, mapwindow):
         """!Initialization
 



More information about the grass-commit mailing list