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

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 17 16:03:10 EDT 2008


Author: martinl
Date: 2008-05-17 16:03:10 -0400 (Sat, 17 May 2008)
New Revision: 31399

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
Log:
wxGUI/vdigit: show segment and total length when digitizing linear feature

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-05-17 19:59:23 UTC (rev 31398)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-05-17 20:03:10 UTC (rev 31399)
@@ -2201,12 +2201,26 @@
         if tmpreg:
             os.environ["GRASS_REGION"] = tmpreg
 
-    def Distance(self, beginpt, endpt):
-        """Calculete distance"""
+    def Distance(self, beginpt, endpt, screen=True):
+        """Calculete distance
+
+        LL-locations not supported
+
+        @todo Use m.distance
+
+        @param beginpt first point
+        @param endpt second point
+        @param screen True for screen coordinates otherwise EN
+        """
         x1, y1 = beginpt
         x2, y2 = endpt
-        dEast  = (x2-x1) * self.Map.region["ewres"]
-        dNorth = (y2-y1) * self.Map.region["nsres"]
+        if screen:
+            dEast  = (x2 - x1) * self.Map.region["ewres"]
+            dNorth = (y2 - y1) * self.Map.region["nsres"]
+        else:
+            dEast  = (x2 - x1)
+            dNorth = (y2 - y1)
+            
 
         return (math.sqrt(math.pow((dEast),2) + math.pow((dNorth),2)), (dEast, dNorth))
 
@@ -2506,7 +2520,22 @@
         # update statusbar if required
         if self.toggleStatus.GetSelection() == 0: # Coordinates
             e, n = self.MapWindow.Pixel2Cell(event.GetPositionTuple())
-            self.statusbar.SetStatusText("%.2f, %.2f" % (e, n), 0)
+            if self.digittoolbar and \
+                    self.digittoolbar.action == 'addLine' and \
+                    self.digittoolbar.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],
+                                                       (e, n), screen=False)[0]
+                distance_tot = distance_seg
+                for idx in range(1, len(self.MapWindow.polycoords)):
+                    distance_tot += self.MapWindow.Distance(self.MapWindow.polycoords[idx-1],
+                                                            self.MapWindow.polycoords[idx],
+                                                            screen=False )[0]
+                self.statusbar.SetStatusText("%.2f, %.2f (seg: %.2f; tot: %.2f)" % \
+                                                 (e, n, distance_seg, distance_tot), 0)
+            else:
+                self.statusbar.SetStatusText("%.2f, %.2f" % (e, n), 0)
 
         event.Skip()
 



More information about the grass-commit mailing list