[GRASS-SVN] r59109 - in grass/trunk/gui/wxpython: core dbmgr gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Feb 21 07:20:19 PST 2014


Author: martinl
Date: 2014-02-21 07:20:19 -0800 (Fri, 21 Feb 2014)
New Revision: 59109

Modified:
   grass/trunk/gui/wxpython/core/settings.py
   grass/trunk/gui/wxpython/dbmgr/base.py
   grass/trunk/gui/wxpython/gui_core/preferences.py
Log:
wxGUI/dbmgr: highlight selected features in mapdisplay by default (could be disabled from preferences)


Modified: grass/trunk/gui/wxpython/core/settings.py
===================================================================
--- grass/trunk/gui/wxpython/core/settings.py	2014-02-20 20:34:45 UTC (rev 59108)
+++ grass/trunk/gui/wxpython/core/settings.py	2014-02-21 15:20:19 UTC (rev 59109)
@@ -214,7 +214,8 @@
             'atm' : {
                 'highlight' : {
                     'color' : (255, 255, 0, 255),
-                    'width' : 2
+                    'width' : 2,
+                    'auto'  : True,
                     },
                 'leftDbClick' : {
                     'selection' : 1 # draw selected

Modified: grass/trunk/gui/wxpython/dbmgr/base.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/base.py	2014-02-20 20:34:45 UTC (rev 59108)
+++ grass/trunk/gui/wxpython/dbmgr/base.py	2014-02-21 15:20:19 UTC (rev 59109)
@@ -15,8 +15,10 @@
  - base::LayerListCtrl
  - base::LayerBook
 
-(C) 2007-2009, 2011-2012 by the GRASS Development Team
+ at todo Implement giface class
 
+(C) 2007-2014 by the GRASS Development Team
+
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
 
@@ -354,6 +356,14 @@
 
         return cats
 
+    def GetItems(self):
+        """!Return list of items (category numbers)"""
+        cats = []
+        for item in range(self.GetItemCount()):
+            cats.append(self.GetItemText(item))
+        
+        return cats
+
     def GetColumnText(self, index, col):
         """!Return column text"""
         item = self.GetItem(index, col)
@@ -1557,14 +1567,19 @@
         
         event.Skip()
 
-    def _drawSelected(self, zoom):
+    def _drawSelected(self, zoom, selectedOnly=True):
         """!Highlight selected features"""
         if not self.map or not self.mapdisplay:
             return
         
         tlist = self.FindWindowById(self.layerPage[self.selLayer]['data'])
-        cats = map(int, tlist.GetSelectedItems())
-
+        if selectedOnly:
+            fn = tlist.GetSelectedItems
+        else:
+            fn = tlist.GetItems
+        
+        cats = map(int, fn())
+        
         digitToolbar = None
         if 'vdigit' in self.mapdisplay.toolbars:
             digitToolbar = self.mapdisplay.toolbars['vdigit']
@@ -1578,12 +1593,12 @@
                                               update = True)
         else:
             # add map layer with higlighted vector features
-            self.AddQueryMapLayer() # -> self.qlayer
+            self.AddQueryMapLayer(selectedOnly) # -> self.qlayer
 
             # set opacity based on queried layer
             if self.parent and self.mapdisplay.tree and \
                     self.dbMgrData['treeItem']:
-                maptree = self.mapdisplay.tree
+                maptree = self.mapdisplay.tree # TODO: giface
                 opacity = maptree.GetLayerInfo(self.dbMgrData['treeItem'], key = 'maplayer').GetOpacity()
                 self.qlayer.SetOpacity(opacity)
             if zoom:
@@ -1633,15 +1648,18 @@
         else:
             self.mapdisplay.MapWindow.UpdateMap(render = False, renderVector = True)
         
-    def AddQueryMapLayer(self):
+    def AddQueryMapLayer(self, selectedOnly = True):
         """!Redraw a map
 
         Return True if map has been redrawn, False if no map is given
         """
         tlist = self.FindWindowById(self.layerPage[self.selLayer]['data'])
-        cats = { 
-            self.selLayer : tlist.GetSelectedItems()
-            }
+        if selectedOnly:
+            fn = tlist.GetSelectedItems
+        else:
+            fn = tlist.GetItems
+
+        cats = { self.selLayer : fn() }
         
         if self.mapdisplay.Map.GetLayerIndex(self.qlayer) < 0:
             self.qlayer = None
@@ -1827,6 +1845,10 @@
         self.log.write(_("Number of loaded records: %d") % \
                            self.FindWindowById(self.layerPage[self.selLayer]['data']).GetItemCount())
 
+        # update map display if needed
+        if UserSettings.Get(group = 'atm', key = 'highlight', subkey = 'auto'):
+            self._drawSelected(zoom=False, selectedOnly=False) # TODO: replace by signals
+
     def OnBuilder(self,event):
         """!SQL Builder button pressed -> show the SQLBuilder dialog"""
         if not self.builder:

Modified: grass/trunk/gui/wxpython/gui_core/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/preferences.py	2014-02-20 20:34:45 UTC (rev 59108)
+++ grass/trunk/gui/wxpython/gui_core/preferences.py	2014-02-21 15:20:19 UTC (rev 59109)
@@ -15,7 +15,7 @@
  - preferences::MapsetAccess
  - preferences::CheckListMapset
 
-(C) 2007-2012 by the GRASS Development Team
+(C) 2007-2014 by the GRASS Development Team
 
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -1060,12 +1060,13 @@
         # highlighting
         #
         highlightBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
-                                    label = " %s " % _("Highlighting"))
+                                    label = " %s " % _("Highlight selected features"))
         highlightSizer = wx.StaticBoxSizer(highlightBox, wx.VERTICAL)
 
         flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
         flexSizer.AddGrowableCol(0)
         
+        # color
         label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Color:"))
         hlColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
                                     colour = self.settings.Get(group = 'atm', key = 'highlight', subkey = 'color'),
@@ -1076,6 +1077,7 @@
         flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
         flexSizer.Add(hlColor, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
 
+        # width
         label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Line width (in pixels):"))
         hlWidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (50, -1),
                               initial = self.settings.Get(group = 'atm', key = 'highlight',subkey = 'width'),
@@ -1085,6 +1087,13 @@
         flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
         flexSizer.Add(hlWidth, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
 
+        # auto
+        autoHighlight = wx.CheckBox(parent = panel, id = wx.ID_ANY, label = _("Automatically hightlight selected features in map display"))
+        autoHighlight.SetValue(self.settings.Get(group = 'atm', key = 'highlight', subkey = 'auto'))
+        self.winId['atm:highlight:auto'] = autoHighlight.GetId()
+        
+        flexSizer.Add(autoHighlight, proportion = 1)
+        
         highlightSizer.Add(item = flexSizer,
                            proportion = 0,
                            flag = wx.ALL | wx.EXPAND,



More information about the grass-commit mailing list