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

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jun 1 17:55:37 EDT 2010


Author: martinl
Date: 2010-06-01 17:55:36 -0400 (Tue, 01 Jun 2010)
New Revision: 42431

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py
Log:
wxGUI/nviz: cosmetics in vector layer properties tab
siplified gselect.Select()
(merge r42429 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2010-06-01 21:51:40 UTC (rev 42430)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2010-06-01 21:55:36 UTC (rev 42431)
@@ -48,13 +48,20 @@
 wxGdalSelect, EVT_GDALSELECT = NewEvent()
 
 class Select(wx.combo.ComboCtrl):
-    def __init__(self, parent, id, size = globalvar.DIALOG_GSELECT_SIZE,
-                 type = None, multiple = False, mapsets = None, exclude = [],
-                 updateOnPopup = True):
-        """!Custom control to create a ComboBox with a tree control
-        to display and select GIS elements within acessible mapsets.
-        Elements can be selected with mouse. Can allow multiple selections, when
-        argument multiple=True. Multiple selections are separated by commas.
+    def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
+                 type = None, multiple = False, mapsets = None,
+                 updateOnPopup = True, onPopup = None):
+        """!Custom control to create a ComboBox with a tree control to
+        display and select GIS elements within acessible mapsets.
+        Elements can be selected with mouse. Can allow multiple
+        selections, when argument multiple=True. Multiple selections
+        are separated by commas.
+
+        @param type type of GIS elements ('raster, 'vector', ...)
+        @param multiple multiple input allowed?
+        @param mapsets force list of mapsets (otherwise search path)
+        @param updateOnPopup True for updating list of elements on popup
+        @param onPopup function to be called on Popup
         """
         wx.combo.ComboCtrl.__init__(self, parent=parent, id=id, size=size)
         self.GetChildren()[0].SetName("Select")
@@ -65,19 +72,17 @@
         self.SetPopupExtents(0,100)
         if type:
             self.tcp.SetData(type = type, mapsets = mapsets,
-                             exclude = exclude, multiple = multiple,
-                             updateOnPopup = updateOnPopup)
+                             multiple = multiple,
+                             updateOnPopup = updateOnPopup, onPopup = onPopup)
         
-    def SetElementList(self, type, mapsets = None, exclude = []):
+    def SetElementList(self, type, mapsets = None):
         """!Set element list
 
         @param type GIS element type
         @param mapsets list of acceptable mapsets (None for all in search path)
-        @param exclude list of GIS elements to be excluded
         """
-        self.tcp.SetData(type = type, mapsets = mapsets,
-                         exclude = exclude)
-
+        self.tcp.SetData(type = type, mapsets = mapsets)
+        
     def GetElementList(self):
         """!Load elements"""
         self.tcp.GetElementList()
@@ -118,9 +123,10 @@
         self.curitem = None
         self.multiple = False
         self.type = None
-        self.mapsets = []
-        self.exclude = []
-
+        self.mapsets = None
+        self.updateOnPopup = True
+        self.onPopup = None
+        
         self.SetFilter(None)
         
     def Create(self, parent):
@@ -172,17 +178,22 @@
         """!Limited only for first selected"""
         if not force and not self.updateOnPopup:
             return
+        if self.onPopup:
+            selected, exclude = self.onPopup()
+        else:
+            selected = None
+            exclude  = False
+            
+        self.GetElementList(selected, exclude)
     
-        self.GetElementList()
-    
-    def GetElementList(self):
+    def GetElementList(self, elements = None, exclude = False):
         """!Get filtered list of GIS elements in accessible mapsets
         and display as tree with all relevant elements displayed
         beneath each mapset branch
         """
         # update list
         self.seltree.DeleteAllItems()
-        self._getElementList(self.type, self.mapsets, self.exclude)
+        self._getElementList(self.type, self.mapsets, elements, exclude)
         
         if len(self.value) > 0:
             root = self.seltree.GetRootItem()
@@ -208,13 +219,14 @@
     def GetAdjustedSize(self, minWidth, prefHeight, maxHeight):
         return wx.Size(minWidth, min(200, maxHeight))
 
-    def _getElementList(self, element, mapsets=None, exclude=[]):
+    def _getElementList(self, element, mapsets = None, elements = None, exclude = False):
         """!Get list of GIS elements in accessible mapsets and display as tree
         with all relevant elements displayed beneath each mapset branch
 
         @param element GIS element
         @param mapsets list of acceptable mapsets (None for all mapsets in search path)
-        @param exclude list of GIS elements to be excluded
+        @param elements list of forced GIS elements
+        @param exclude True to exclude, False for forcing the list (elements)
         """
         # get current mapset
         curr_mapset = grass.gisenv()['MAPSET']
@@ -222,7 +234,7 @@
         # list of mapsets in current location
         if mapsets is None:
             mapsets = utils.ListOfMapsets()
-
+        
         # map element types to g.mlist types
         elementdict = {'cell':'rast',
                        'raster':'rast',
@@ -268,11 +280,11 @@
                        '3dview':'3dview',
                        '3D viewing parameters':'3dview',
                        '3D view parameters':'3dview'}
-
+        
         if element not in elementdict:
             self.AddItem(_('Not selectable element'))
             return
-
+        
         # get directory tree nodes
         # reorder mapsets based on search path (TODO)
         for i in range(len(mapsets)):
@@ -298,9 +310,11 @@
                 for elem in elem_list:
                     if elem != '':
                         fullqElem = elem + '@' + dir
-                        if len(exclude) > 0 and fullqElem in exclude:
-                            continue
-
+                        if elements:
+                            if (exclude and fullqElem in elements) or \
+                                    (not exclude and fullqElem not in elements):
+                                continue
+                        
                         if self.filterElements:
                             if self.filterElements(fullqElem):
                                 self.AddItem(fullqElem, parent=dir_node)
@@ -392,12 +406,12 @@
             self.type = kargs['type']
         if kargs.has_key('mapsets'):
             self.mapsets = kargs['mapsets']
-        if kargs.has_key('exclude'):
-            self.exclude = kargs['exclude']
         if kargs.has_key('multiple'):
             self.multiple = kargs['multiple']
         if kargs.has_key('updateOnPopup'):
             self.updateOnPopup = kargs['updateOnPopup']
+        if kargs.has_key('onPopup'):
+            self.onPopup = kargs['onPopup']
         
 class VectorDBInfo:
     """!Class providing information about attribute tables

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py	2010-06-01 21:51:40 UTC (rev 42430)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py	2010-06-01 21:55:36 UTC (rev 42431)
@@ -525,14 +525,25 @@
         self.win['vector'] = {}
         
         #
-        # desc
+        # selection
         #
-        desc = wx.StaticText(parent = panel, id = wx.ID_ANY,
-                             label = "")
+        box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
+                            label = " %s " % (_("Vector map")))
+        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+        vmaps = gselect.Select(parent = panel, type = 'vector',
+                               onPopup = self.GselectOnPopup)
+        self.win['vector']['map'] = vmaps.GetId()
+        desc = wx.StaticText(parent = panel, id = wx.ID_ANY)
         self.win['vector']['desc'] = desc.GetId()
-        pageSizer.Add(item = desc, proportion = 0,
-                      flag = wx.EXPAND | wx.ALL,
-                      border = 10)
+        boxSizer.Add(item = vmaps, proportion = 0,
+                     flag = wx.ALL,
+                     border = 3)
+        boxSizer.Add(item = desc, proportion = 0,
+                     flag = wx.ALL,
+                     border = 3)
+        pageSizer.Add(item = boxSizer, proportion = 0,
+                      flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
+                      border = 3)
         
         #
         # vector lines
@@ -757,6 +768,13 @@
         panel.Layout()
         return panel.GetBestSize()
 
+    def GselectOnPopup(self, exclude = False):
+        """Update gselect.Select() items"""
+        maps = list()
+        for layer in self.mapWindow.Map.GetListOfLayers(l_type='vector'):
+            maps.append(layer.GetName())
+        return maps, exclude
+    
     def _createVolumePage(self):
         """!Create view settings page"""
         panel = SP.ScrolledPanel(parent = self, id = wx.ID_ANY)
@@ -2656,10 +2674,10 @@
                 nprimitives += int(value)
         
         if mapIs3D:
-            desc = _("Vector map <%s> is 3D") % layer.name
+            desc = _("Vector map is 3D")
             enable = False
         else:
-            desc = _("Vector map <%s> is 2D") % layer.name
+            desc = _("Vector map is 2D")
             enable = True
         desc += " - " + _("%(primitives)d primitives (%(points)d points)") % \
             { 'primitives' : nprimitives, 'points' : npoints }
@@ -2670,6 +2688,7 @@
             self.FindWindowById(self.win['vector'][v]['height']['slider']).Enable(enable)
             self.FindWindowById(self.win['vector'][v]['height']['spin']).Enable(enable)
             
+        self.FindWindowById(self.win['vector']['map']).SetValue(layer.name)
         self.FindWindowById(self.win['vector']['desc']).SetLabel(desc)
         #
         # lines



More information about the grass-commit mailing list