[GRASS-SVN] r57448 - grass/trunk/gui/wxpython/vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Aug 13 02:48:15 PDT 2013


Author: martinl
Date: 2013-08-13 02:48:14 -0700 (Tue, 13 Aug 2013)
New Revision: 57448

Modified:
   grass/trunk/gui/wxpython/vdigit/mapwindow.py
   grass/trunk/gui/wxpython/vdigit/toolbars.py
   grass/trunk/gui/wxpython/vdigit/wxdigit.py
   grass/trunk/gui/wxpython/vdigit/wxdisplay.py
Log:
wxGUI/vdigit: allow to open temporary vector map for editing


Modified: grass/trunk/gui/wxpython/vdigit/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/mapwindow.py	2013-08-11 21:34:24 UTC (rev 57447)
+++ grass/trunk/gui/wxpython/vdigit/mapwindow.py	2013-08-13 09:48:14 UTC (rev 57448)
@@ -65,6 +65,10 @@
             return self.digit.GetDisplay()
         return None
 
+    def GetDigit(self):
+        """!Get digit class"""
+        return self.digit
+    
     def SetToolbar(self, toolbar):
         """!Set up related toolbar
         """

Modified: grass/trunk/gui/wxpython/vdigit/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/toolbars.py	2013-08-11 21:34:24 UTC (rev 57447)
+++ grass/trunk/gui/wxpython/vdigit/toolbars.py	2013-08-13 09:48:14 UTC (rev 57448)
@@ -758,8 +758,8 @@
         self.digit = self.MapWindow.digit = self.digitClass(mapwindow = self.MapWindow)
         
         self.mapLayer = mapLayer
-        # open vector map
-        if self.digit.OpenMap(mapLayer.GetName()) is None:
+        # open vector map (assume that 'hidden' map layer is temporary vector map)
+        if self.digit.OpenMap(mapLayer.GetName(), tmp = mapLayer.IsHidden()) is None:
             self.mapLayer = None
             self.StopEditing()
             return False

Modified: grass/trunk/gui/wxpython/vdigit/wxdigit.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/wxdigit.py	2013-08-11 21:34:24 UTC (rev 57447)
+++ grass/trunk/gui/wxpython/vdigit/wxdigit.py	2013-08-13 09:48:14 UTC (rev 57448)
@@ -1281,10 +1281,11 @@
         """!Get display driver instance"""
         return self._display
     
-    def OpenMap(self, name):
+    def OpenMap(self, name, tmp = False):
         """!Open vector map for editing
         
         @param map name of vector map to be set up
+        @param tmp True to open temporary vector map
         """
         Debug.msg (3, "AbstractDigit.SetMapName map=%s" % name)
 
@@ -1293,7 +1294,7 @@
         else:
             mapset = grass.gisenv()['MAPSET']
         
-        self.poMapInfo = self._display.OpenMap(str(name), str(mapset), True)
+        self.poMapInfo = self._display.OpenMap(str(name), str(mapset), True, tmp)
         
         if self.poMapInfo:
             self.InitCats()

Modified: grass/trunk/gui/wxpython/vdigit/wxdisplay.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/wxdisplay.py	2013-08-11 21:34:24 UTC (rev 57447)
+++ grass/trunk/gui/wxpython/vdigit/wxdisplay.py	2013-08-13 09:48:14 UTC (rev 57448)
@@ -857,12 +857,14 @@
         
         return ret
     
-    def OpenMap(self, name, mapset, update = True):
+    def OpenMap(self, name, mapset, update = True, tmp = False):
         """!Open vector map by the driver
         
         @param name name of vector map to be open
         @param mapset name of mapset where the vector map lives
-   
+        @param update True to open vector map in update mode
+        @param tmp True to open temporary vector map
+        
         @return map_info
         @return None on error
         """
@@ -874,16 +876,24 @@
         
         # open existing map
         if update:
-            ret = Vect_open_update(self.poMapInfo, name, mapset)
-            Vect_set_updated(self.poMapInfo, True) # track updated lines
+            if tmp:
+                open_fn = Vect_open_tmp_update
+            else:
+                open_fn = Vect_open_update
         else:
-            ret = Vect_open_old(self.poMapInfo, name, mapset)
-        self.is3D = Vect_is_3d(self.poMapInfo)
+            if tmp:
+                open_fn = Vect_open_tmp_old
+            else:
+                open_fn = Vect_open_old
         
-        if ret == -1: # error
+        ret = open_fn(self.poMapInfo, name, mapset)
+        
+        if ret == -1:
+             # fatal error detected
             del self.mapInfo
             self.poMapInfo = self.mapInfo = None
         elif ret < 2:
+            # map open at level 1, try to build topology
             dlg = wx.MessageDialog(parent = self.window,
                                    message = _("Topology for vector map <%s> is not available. "
                                                "Topology is required by digitizer. Do you want to "
@@ -898,8 +908,13 @@
             else:
                 Vect_build(self.poMapInfo)
         
+        if update:
+            Vect_set_updated(self.poMapInfo, True) # track updated lines at update mode
+        
+        self.is3D = Vect_is_3d(self.poMapInfo)
+        
         return self.poMapInfo
-    
+
     def GetMapBoundingBox(self):
         """!Get bounding box of (opened) vector map layer
 



More information about the grass-commit mailing list