[GRASS-SVN] r30442 - in grass/trunk/gui/wxpython: gui_modules vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 3 09:50:13 EST 2008


Author: martinl
Date: 2008-03-03 09:50:12 -0500 (Mon, 03 Mar 2008)
New Revision: 30442

Modified:
   grass/trunk/gui/wxpython/gui_modules/digit.py
   grass/trunk/gui/wxpython/gui_modules/gcmd.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/render.py
   grass/trunk/gui/wxpython/vdigit/driver.cpp
   grass/trunk/gui/wxpython/vdigit/driver.h
Log:
wxGUI: do not use g.region for zooming to selected vector layer if the layer is opened for editing (only for vdigit component)

Modified: grass/trunk/gui/wxpython/gui_modules/digit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/digit.py	2008-03-03 11:53:21 UTC (rev 30441)
+++ grass/trunk/gui/wxpython/gui_modules/digit.py	2008-03-03 14:50:12 UTC (rev 30442)
@@ -1245,6 +1245,14 @@
                                  reg['center_easting'],
                                  reg['center_northing'],
                                  map.width, map.height)
+
+    def GetMapBoundingBox(self):
+        """Return bounding box of given vector map layer
+
+        @return (w,s,b,e,n,t)
+        """
+
+        return self.__display.GetMapBoundingBox()
     
     def UpdateSettings(self):
         """Update display driver settings"""

Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-03-03 11:53:21 UTC (rev 30441)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-03-03 14:50:12 UTC (rev 30442)
@@ -277,17 +277,14 @@
                            (' '.join(cmd), wait, self.returncode, self.cmdThread.isAlive()))
             if rerr is not None and self.returncode != 0:
                 if rerr is False: # GUI dialog
-                    try:
-                        raise CmdError(cmd=self.cmd,
-                                       message="%s '%s'%s%s%s %s%s" %
-                                       (_("Execution failed:"),
-                                        ' '.join(self.cmd),
-                                        os.linesep, os.linesep,
-                                        _("Details:"),
-                                        os.linesep,
-                                        self.PrintModuleOutput()))
-                    except CmdError, e:
-                        print e
+                    raise CmdError(cmd=self.cmd,
+                                   message="%s '%s'%s%s%s %s%s" %
+                                   (_("Execution failed:"),
+                                    ' '.join(self.cmd),
+                                    os.linesep, os.linesep,
+                                    _("Details:"),
+                                    os.linesep,
+                                    self.PrintModuleOutput()))
                 elif rerr == sys.stderr: # redirect message to sys
                     stderr.write("Execution failed: '%s'" % (' '.join(self.cmd)))
                     stderr.write("%sDetails:%s%s" % (os.linesep,

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-03-03 11:53:21 UTC (rev 30441)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-03-03 14:50:12 UTC (rev 30442)
@@ -1941,7 +1941,12 @@
         if layer.type in ('raster', 'rgb', 'his', 'shaded', 'arrow'):
             self.Map.region = self.Map.GetRegion(rast="%s" % layer.name)
         elif layer.type in ('vector', 'thememap', 'themechart'):
-            self.Map.region = self.Map.GetRegion(vect="%s" % layer.name)
+            if self.parent.digit and layer.name == self.parent.digit.map and \
+               self.parent.digit.type == 'vdigit':
+                w, s, b, e, n, t = self.parent.digit.driver.GetMapBoundingBox()
+                self.Map.region = self.Map.GetRegion(n=n, s=s, w=w, e=e)
+            else:
+                self.Map.region = self.Map.GetRegion(vect="%s" % layer.name)
         else:
             return
 

Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py	2008-03-03 11:53:21 UTC (rev 30441)
+++ grass/trunk/gui/wxpython/gui_modules/render.py	2008-03-03 14:50:12 UTC (rev 30442)
@@ -376,7 +376,8 @@
             self.height = 480
             return False
 
-    def GetRegion(self, rast=None, vect=None):
+    def GetRegion(self, rast=None, vect=None,
+                  n=None, s=None, e=None, w=None):
         """
         Get region settings
 
@@ -397,13 +398,33 @@
         # do not update & shell style output
         cmdList = ["g.region", "-u", "-g", "-p", "-c"]
 
+        if n:
+            cmdList.append('n=%s' % n)
+        if s:
+            cmdList.append('s=%s' % s)
+        if e:
+            cmdList.append('e=%s' % e)
+        if w:
+            cmdList.append('w=%s' % w)
+
         if rast:
             cmdList.append('rast=%s' % rast)
-        elif vect:
+        if vect:
             cmdList.append('vect=%s' % vect)
 
-        cmdRegion = gcmd.Command(cmdList)
+        try:
+            cmdRegion = gcmd.Command(cmdList)
+        except gcmd.CmdError, e:
+            if rast:
+                e.message = _("Unable to zoom to raster map <%s>.") % rast + \
+                '%s%s' % (os.linesep, os.linesep) + e.message
+            elif vect:
+                e.message = _("Unable to zoom to vector map <%s>.") % vect + \
+                '%s%s' % (os.linesep, os.linesep) + e.message
 
+            print e
+            return self.region
+
         for reg in cmdRegion.ReadStdOutput():
             key, val = reg.split("=", 1)
             try:

Modified: grass/trunk/gui/wxpython/vdigit/driver.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/driver.cpp	2008-03-03 11:53:21 UTC (rev 30441)
+++ grass/trunk/gui/wxpython/vdigit/driver.cpp	2008-03-03 14:50:12 UTC (rev 30442)
@@ -1109,6 +1109,33 @@
 }
 
 /**
+   \brief Get bounding box of (opened) vector map layer
+
+   \return (w,s,b,e,n,t)
+*/
+std::vector<double> DisplayDriver::GetMapBoundingBox()
+{
+    std::vector<double> region;
+    BOUND_BOX bbox;
+
+    if (!mapInfo) {
+	return region;
+    }
+    
+    Vect_get_map_box(mapInfo, &bbox);
+
+    region.push_back(bbox.W);
+    region.push_back(bbox.S);
+    region.push_back(bbox.B);
+
+    region.push_back(bbox.E);
+    region.push_back(bbox.N);
+    region.push_back(bbox.T);
+
+    return region;
+}
+
+/**
    \brief Error messages handling 
 
    \param msg message
@@ -1122,3 +1149,4 @@
     
     return 0;
 }
+

Modified: grass/trunk/gui/wxpython/vdigit/driver.h
===================================================================
--- grass/trunk/gui/wxpython/vdigit/driver.h	2008-03-03 11:53:21 UTC (rev 30441)
+++ grass/trunk/gui/wxpython/vdigit/driver.h	2008-03-03 14:50:12 UTC (rev 30442)
@@ -172,6 +172,9 @@
     void ReloadMap();
     void SetDevice(void *);
 
+    /* misc */
+    std::vector<double> GetMapBoundingBox();
+
     /* set */
     void SetRegion(double, double, double, double,
 		   double, double,



More information about the grass-commit mailing list