Просмотр исходного кода

wxGUI/vdigit: snapping value -1 -> calculate from computational resolution
(merge from devbr6, https://trac.osgeo.org/grass/changeset/33064)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@33065 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 16 лет назад
Родитель
Сommit
6b8415516f
1 измененных файлов с 20 добавлено и 11 удалено
  1. 20 11
      gui/wxpython/gui_modules/vdigit.py

+ 20 - 11
gui/wxpython/gui_modules/vdigit.py

@@ -2080,18 +2080,27 @@ class VDigitSettingsDialog(wx.Dialog):
         value = self.snappingValue.GetValue()
         
         if value < 0:
-            self.snappingInfo.SetLabel(_("No limit for snapping"))
-            return
-        
-        if self.snappingUnit.GetStringSelection() == "map units":
-            threshold = value
+            region = self.parent.MapWindow.Map.GetRegion()
+            res = (region['nsres'] + region['ewres']) / 2.
+            threshold = self.parent.digit.driver.GetThreshold(value=res)
         else:
-            threshold = self.parent.digit.driver.GetThreshold(value=value)
-
-        self.snappingInfo.SetLabel(_("Snapping threshold is %(value).1f %(units)s") % 
-                                   {'value' : threshold,
-                                    'units' : self.mapUnits})
-
+            if self.snappingUnit.GetStringSelection() == "map units":
+                threshold = value
+            else:
+                threshold = self.parent.digit.driver.GetThreshold(value=value)
+            
+        if value == 0:
+            self.snappingInfo.SetLabel(_("Snapping disabled"))
+        elif value < 0:
+            self.snappingInfo.SetLabel(_("Snapping threshold is %(value).1f %(units)s "
+                                         "(based on computation resolution)") % 
+                                       {'value' : threshold,
+                                        'units' : self.mapUnits.lower()})
+        else:
+            self.snappingInfo.SetLabel(_("Snapping threshold is %(value).1f %(units)s") % 
+                                       {'value' : threshold,
+                                        'units' : self.mapUnits.lower()})
+        
         event.Skip()
 
     def OnChangeSnappingUnits(self, event):