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

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jun 13 08:32:57 EDT 2008


Author: martinl
Date: 2008-06-13 08:32:57 -0400 (Fri, 13 Jun 2008)
New Revision: 31700

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.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/wxgui_utils.py
Log:
wxGUI: disable toolbar long help for given statusbar modes ('Show comp. extent', 'Display mode' and 'Map scale'), trac #135


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-06-13 11:41:24 UTC (rev 31699)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-06-13 12:32:57 UTC (rev 31700)
@@ -605,7 +605,7 @@
         #
         # render vector map layer
         #
-        digitToolbar = self.parent.digittoolbar
+        digitToolbar = self.parent.toolbars['vdigit']
         if renderVector and digitToolbar and \
                 digitToolbar.layerSelectedID != None:
             # set region
@@ -640,7 +640,7 @@
             self.DrawLines(self.pdcTmp)
         if self.parent.gismanager.georectifying:
             # -> georectifier (redraw GCPs)
-            if self.parent.grtoolbar:
+            if self.parent.toolbars['georect']:
                 coordtype = 'gcpcoord'
             else:
                 coordtype = 'mapcoord'
@@ -935,7 +935,7 @@
                 self.DragMap(move)
 
             # dragging decoration overlay item
-            elif (self.mouse['use'] == 'pointer' and not self.parent.digittoolbar) and \
+            elif (self.mouse['use'] == 'pointer' and not self.parent.toolbars['vdigit']) and \
                     self.dragid != None and \
                     self.dragid != 99:
                 self.DragItem(self.dragid, event)
@@ -986,9 +986,9 @@
                 self.mouse['begin'] = self.mouse['end']
         elif self.mouse['use'] == 'zoom':
             pass
-        elif self.mouse["use"] == "pointer" and self.parent.digittoolbar:
+        elif self.mouse["use"] == "pointer" and self.parent.toolbars['vdigit']:
             # digitization
-            digitToolbar = self.parent.digittoolbar
+            digitToolbar = self.parent.toolbars['vdigit']
             digitClass   = self.parent.digit
             east, north = self.Pixel2Cell(self.mouse['begin'])
 
@@ -1266,7 +1266,7 @@
         elif self.mouse["use"] == "pointer" and self.parent.gismanager.georectifying:
             # -> georectifying
             coord = self.Pixel2Cell(self.mouse['end'])
-            if self.parent.grtoolbar:
+            if self.parent.toolbars['georect']:
                 coordtype = 'gcpcoord'
             else:
                 coordtype = 'mapcoord'
@@ -1274,9 +1274,9 @@
             self.parent.gismanager.georectifying.SetGCPData(coordtype, coord, self)
             self.UpdateMap(render=False, renderVector=False)
 
-        elif self.mouse["use"] == "pointer" and self.parent.digittoolbar:
+        elif self.mouse["use"] == "pointer" and self.parent.toolbars['vdigit']:
             # digitization tool active
-            digitToolbar = self.parent.digittoolbar
+            digitToolbar = self.parent.toolbars['vdigit']
             digitClass   = self.parent.digit
 
             pos1 = self.Pixel2Cell(self.mouse['begin'])
@@ -1514,7 +1514,7 @@
         #                self.polycoords = []
         #                self.mouse['begin'] = self.mouse['end'] = [0, 0]
         #                self.Refresh()
-        elif self.mouse['use'] == 'pointer' and self.parent.digittoolbar:
+        elif self.mouse['use'] == 'pointer' and self.parent.toolbars['vdigit']:
             # digitization tool
             pass
         else:
@@ -1560,7 +1560,7 @@
                 r.Inflate(4,4)
                 self.RefreshRect(r, False)
 
-        digitToolbar = self.parent.digittoolbar
+        digitToolbar = self.parent.toolbars['vdigit']
         if digitToolbar:
             digitClass = self.parent.digit
             # digitization tool (confirm action)
@@ -1592,7 +1592,7 @@
         Debug.msg (5, "BufferedWindow.OnRightUp(): use=%s" % \
                    self.mouse["use"])
 
-        digitToolbar = self.parent.digittoolbar
+        digitToolbar = self.parent.toolbars['vdigit']
         if digitToolbar:
             digitClass = self.parent.digit
             # digitization tool (confirm action)
@@ -1718,7 +1718,7 @@
 
     def OnMiddleDown(self, event):
         """Middle mouse button pressed"""
-        digitToolbar = self.parent.digittoolbar
+        digitToolbar = self.parent.toolbars['vdigit']
         # digitization tool
         if self.mouse["use"] == "pointer" and digitToolbar:
             digitClass = self.parent.digit
@@ -1779,7 +1779,7 @@
     def OnMouseMoving(self, event):
         """Motion event and no mouse buttons were pressed"""
 
-        digitToolbar = self.parent.digittoolbar
+        digitToolbar = self.parent.toolbars['vdigit']
         if self.mouse["use"] == "pointer" and digitToolbar:
             digitClass = self.parent.digit
             self.mouse['end'] = event.GetPositionTuple()[:]
@@ -2306,9 +2306,9 @@
         #
         # Add toolbars
         #
-        self.maptoolbar = None
-        self.digittoolbar = None
-        self.grtoolbar = None
+        self.toolbars = { 'map' : None,
+                          'vdigit' : None,
+                          'georect' : None }
         for toolb in toolbars:
             self.AddToolbar(toolb)
 
@@ -2436,9 +2436,9 @@
          - georect georectifier
          """
         if name == "map":
-            self.maptoolbar = toolbars.MapToolbar(self, self.Map)
+            self.toolbars['map'] = toolbars.MapToolbar(self, self.Map)
 
-            self._mgr.AddPane(self.maptoolbar.toolbar,
+            self._mgr.AddPane(self.toolbars['map'].toolbar,
                               wx.aui.AuiPaneInfo().
                               Name("maptoolbar").Caption(_("Map Toolbar")).
                               ToolbarPane().Top().
@@ -2447,12 +2447,12 @@
                               CloseButton(False).Layer(2))
 
         if name == "digit":
-            self.digittoolbar = toolbars.VDigitToolbar(self, self.Map, self.tree)
+            self.toolbars['vdigit'] = toolbars.VDigitToolbar(self, self.Map, self.tree)
 
-            for toolRow in range(0, self.digittoolbar.numOfRows):
-                self._mgr.AddPane(self.digittoolbar.toolbar[toolRow],
+            for toolRow in range(0, self.toolbars['vdigit'].numOfRows):
+                self._mgr.AddPane(self.toolbars['vdigit'].toolbar[toolRow],
                                   wx.aui.AuiPaneInfo().
-                                  Name("digittoolbar" + str(toolRow)).Caption(_("Vector digitizer toolbar")).
+                                  Name("vdigittoolbar" + str(toolRow)).Caption(_("Vector digitizer toolbar")).
                                   ToolbarPane().Top().Row(toolRow + 1).
                                   LeftDockable(False).RightDockable(False).
                                   BottomDockable(False).TopDockable(True).
@@ -2465,11 +2465,11 @@
             self.MapWindow.polypen = wx.Pen(colour='green', width=2, style=wx.SOLID)
 
         if name == "georect":
-            self.grtoolbar = toolbars.GRToolbar(self, self.Map)
+            self.toolbars['georect'] = toolbars.GRToolbar(self, self.Map)
 
-            self._mgr.AddPane(self.grtoolbar.toolbar,
+            self._mgr.AddPane(self.toolbars['georect'].toolbar,
                               wx.aui.AuiPaneInfo().
-                              Name("grtoolbar").Caption(_("Georectification Toolbar")).
+                              Name("georecttoolbar").Caption(_("Georectification Toolbar")).
                               ToolbarPane().Top().
                               LeftDockable(False).RightDockable(False).
                               BottomDockable(False).TopDockable(True).
@@ -2489,12 +2489,12 @@
             return
         elif name == "digit":
             # TODO: not destroy only hide
-            for toolRow in range(0, self.digittoolbar.numOfRows):
-                self._mgr.DetachPane (self.digittoolbar.toolbar[toolRow])
-                self.digittoolbar.toolbar[toolRow].Destroy()
-            self.digittoolbar = None
+            for toolRow in range(0, self.toolbars['vdigit'].numOfRows):
+                self._mgr.DetachPane (self.toolbars['vdigit'].toolbar[toolRow])
+                self.toolbars['vdigit'].toolbar[toolRow].Destroy()
+            self.toolbars['vdigit'] = None
 
-        self.maptoolbar.combo.SetValue ("Tools");
+        self.toolbars['map'].combo.SetValue ("Tools");
         self._mgr.Update()
 
     def __InitDisplay(self):
@@ -2534,9 +2534,9 @@
         # update statusbar if required
         if self.toggleStatus.GetSelection() == 0: # Coordinates
             e, n = self.MapWindow.Pixel2Cell(event.GetPositionTuple())
-            if self.digittoolbar and \
-                    self.digittoolbar.action == 'addLine' and \
-                    self.digittoolbar.type in ('line', 'boundary') and \
+            if self.toolbars['vdigit'] and \
+                    self.toolbars['vdigit'].action == 'addLine' and \
+                    self.toolbars['vdigit'].type in ('line', 'boundary') and \
                     len(self.MapWindow.polycoords) > 0:
                 # for linear feature show segment and total length
                 distance_seg = self.MapWindow.Distance(self.MapWindow.polycoords[-1],
@@ -2583,17 +2583,17 @@
         self.MapWindow.mouse['box'] = "point"
 
         # change the cursor
-        if self.digittoolbar:
+        if self.toolbars['vdigit']:
             # digitization tool activated
             self.MapWindow.SetCursor(self.cursors["cross"])
 
             # reset mouse['box'] if needed
-            if self.digittoolbar.action in ['addLine']:
-                if self.digittoolbar.type in ['point', 'centroid']:
+            if self.toolbars['vdigit'].action in ['addLine']:
+                if self.toolbars['vdigit'].type in ['point', 'centroid']:
                     self.MapWindow.mouse['box'] = 'point'
                 else: # line, boundary
                     self.MapWindow.mouse['box'] = 'line'
-            elif self.digittoolbar.action in ['addVertex', 'removeVertex', 'splitLine',
+            elif self.toolbars['vdigit'].action in ['addVertex', 'removeVertex', 'splitLine',
                                          'editLine', 'displayCats', 'displayAttrs',
                                          'copyCats', 'connectLine']:
                 self.MapWindow.mouse['box'] = 'point'
@@ -2737,11 +2737,15 @@
 
         if self.toggleStatus.GetSelection() == 0: # Coordinates
             self.statusbar.SetStatusText("", 0)
+            # enable long help
+            self.StatusbarEnableLongHelp()
 
         elif self.toggleStatus.GetSelection() == 1: # Extent
             self.statusbar.SetStatusText("%.2f - %.2f, %.2f - %.2f" %
                                          (self.Map.region["w"], self.Map.region["e"],
                                           self.Map.region["s"], self.Map.region["n"]), 0)
+            # enable long help
+            self.StatusbarEnableLongHelp()
 
         elif self.toggleStatus.GetSelection() == 2: # Comp. region
             compregion = self.Map.GetRegion()
@@ -2749,19 +2753,28 @@
                                          (compregion["w"], compregion["e"],
                                           compregion["s"], compregion["n"],
                                           compregion["ewres"], compregion["nsres"]), 0)
+            # enable long help
+            self.StatusbarEnableLongHelp()
 
         elif self.toggleStatus.GetSelection() == 3: # Show comp. extent
             self.statusbar.SetStatusText("", 0)
             self.showRegion.Show()
+            # disable long help
+            self.StatusbarEnableLongHelp(False)
 
         elif self.toggleStatus.GetSelection() == 4: # Display mode
             self.statusbar.SetStatusText("", 0)
             self.compResolution.Show()
-            
+            # disable long help
+            self.StatusbarEnableLongHelp(False)
+
         elif self.toggleStatus.GetSelection() == 5: # Display geometry
             self.statusbar.SetStatusText("rows=%d; cols=%d; nsres=%.2f; ewres=%.2f" %
                                          (self.Map.region["rows"], self.Map.region["cols"],
                                           self.Map.region["nsres"], self.Map.region["ewres"]), 0)
+            # enable long help
+            self.StatusbarEnableLongHelp()
+
         elif self.toggleStatus.GetSelection() == 6: # Map scale
             # TODO: need to be fixed...
             ### screen X region problem
@@ -2804,9 +2817,18 @@
             self.mapScaleValue = scale
             self.mapScale.Show()
 
+            # disable long help
+            self.StatusbarEnableLongHelp(False)
+
         else:
             self.statusbar.SetStatusText("", 1)
 
+    def StatusbarEnableLongHelp(self, enable=True):
+        """Enable/disable toolbars long help"""
+        for toolbar in self.toolbars.itervalues():
+            if toolbar:
+                toolbar.EnableLongHelp(enable)
+                
     def StatusbarReposition(self):
         """Reposition checkbox in statusbar"""
         # reposition checkbox

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2008-06-13 11:41:24 UTC (rev 31699)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2008-06-13 12:32:57 UTC (rev 31700)
@@ -40,7 +40,7 @@
     """Abstract toolbar class"""
     def __init__():
         pass
-
+        
     def InitToolbar(self, parent, toolbar, toolData):
         """Initialize toolbar, i.e. add tools to the toolbar
 
@@ -51,6 +51,7 @@
             self.CreateTool(parent, toolbar, *tool)
 
         self._toolbar = toolbar
+        self._data = toolData
         
     def ToolbarData(self):
         """Toolbar data"""
@@ -79,7 +80,21 @@
     def GetToolbar(self):
         """Get toolbar widget reference"""
         return self._toolbar
-    
+
+    def EnableLongHelp(self, enable=True):
+        """Enable/disable long help
+
+        @param enable True for enable otherwise disable
+        """
+        for tool in self._data:
+            if tool[0] == '': # separator
+                continue
+            
+            if enable:
+                self._toolbar.SetToolLongHelp(tool[0], tool[5])
+            else:
+                self._toolbar.SetToolLongHelp(tool[0], "")
+                
 class MapToolbar(AbstractToolbar):
     """
     Main Map Display toolbar
@@ -179,7 +194,7 @@
         """
         tool =  event.GetString()
 
-        if tool == "Digitize" and not self.mapdisplay.digittoolbar:
+        if tool == "Digitize" and not self.mapdisplay.toolbars['vdigit']:
             self.mapdisplay.AddToolbar("digit")
 
 class GRToolbar(AbstractToolbar):
@@ -455,9 +470,9 @@
 
     def OnTool(self, event):
         """Tool selected -> toggle tool to pointer"""
-        id = self.parent.maptoolbar.pointer
-        self.parent.maptoolbar.toolbar.ToggleTool(id, True)
-        self.parent.maptoolbar.mapdisplay.OnPointer(event)
+        id = self.parent.toolbars['map'].pointer
+        self.parent.toolbars['map'].toolbar.ToggleTool(id, True)
+        self.parent.toolbars['map'].mapdisplay.OnPointer(event)
         if event:
             event.Skip()
         
@@ -785,7 +800,7 @@
 
         # update toolbar
         self.combo.SetValue (layerSelected.name)
-        self.parent.maptoolbar.combo.SetValue ('Digitize')
+        self.parent.toolbars['map'].combo.SetValue ('Digitize')
         # set initial category number for new features (layer=1), etc.
 
         Debug.msg (4, "VDigitToolbar.StartEditing(): layerSelectedID=%d layer=%s" % \

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2008-06-13 11:41:24 UTC (rev 31699)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2008-06-13 12:32:57 UTC (rev 31700)
@@ -781,7 +781,7 @@
         except (ImportError, NameError):
             self.digit = None
 
-        self.toolbar = mapwindow.parent.digittoolbar
+        self.toolbar = mapwindow.parent.toolbars['vdigit']
 
     def __del__(self):
         del self.digit
@@ -2044,7 +2044,7 @@
     def OnSave(self, event):
         """Button 'Save' clicked"""
         self.UpdateSettings()
-        self.parent.digittoolbar.settingsDialog = None
+        self.parent.toolbars['vdigit'].settingsDialog = None
 
         fileSettings = {}
         UserSettings.ReadSettingsFile(settings=fileSettings)
@@ -2060,7 +2060,7 @@
 
     def OnCancel(self, event):
         """Button 'Cancel' clicked"""
-        self.parent.digittoolbar.settingsDialog = None
+        self.parent.toolbars['vdigit'].settingsDialog = None
         self.Close()
 
     def UpdateSettings(self):

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py	2008-06-13 11:41:24 UTC (rev 31699)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py	2008-06-13 12:32:57 UTC (rev 31700)
@@ -261,7 +261,7 @@
 
             layer = self.GetPyData(self.layer_selected)[0]['maplayer']
             # enable editing only for vector map layers available in the current mapset
-            digit = self.mapdisplay.digittoolbar
+            digit = self.mapdisplay.toolbars['vdigit']
             if layer.GetMapset() != grassenv.GetGRASSVariable("MAPSET"):
                 # only vector map in current mapset can be edited
                 self.popupMenu.Enable (self.popupID5, False)
@@ -392,13 +392,13 @@
             event.Skip()
             return
 
-        if not self.mapdisplay.digittoolbar: # enable tool
+        if not self.mapdisplay.toolbars['vdigit']: # enable tool
             self.mapdisplay.AddToolbar("digit")
         else: # tool already enabled
             pass
 
         # mark layer as 'edited'
-        self.mapdisplay.digittoolbar.StartEditing (maplayer)
+        self.mapdisplay.toolbars['vdigit'].StartEditing (maplayer)
 
     def OnStopEditing (self, event):
         """
@@ -410,7 +410,7 @@
             event.Skip()
             return
 
-        self.mapdisplay.digittoolbar.OnExit()
+        self.mapdisplay.toolbars['vdigit'].OnExit()
         self.mapdisplay.imgVectorMap = None
 
     def OnPopupProperties (self, event):
@@ -756,8 +756,8 @@
         if self.mapdisplay.autoRender.GetValue(): 
             self.mapdisplay.OnRender(None)
 
-        if self.mapdisplay.digittoolbar:
-            self.mapdisplay.digittoolbar.UpdateListOfLayers (updateTool=True)
+        if self.mapdisplay.toolbars['vdigit']:
+            self.mapdisplay.toolbars['vdigit'].UpdateListOfLayers (updateTool=True)
 
         # update progress bar range (mapwindow statusbar)
         self.mapdisplay.onRenderGauge.SetRange(len(self.Map.GetListOfLayers(l_active=True)))
@@ -1106,8 +1106,8 @@
         self.GetPyData(item)[0]['maplayer'] = maplayer
 
         # if digitization tool enabled -> update list of available vector map layers
-        if self.mapdisplay.digittoolbar:
-            self.mapdisplay.digittoolbar.UpdateListOfLayers(updateTool=True)
+        if self.mapdisplay.toolbars['vdigit']:
+            self.mapdisplay.toolbars['vdigit'].UpdateListOfLayers(updateTool=True)
 
         # redraw map if auto-rendering is enabled
         if self.mapdisplay.autoRender.GetValue(): 



More information about the grass-commit mailing list