[GRASS-SVN] r69579 - in grass/trunk/gui/wxpython: core vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 26 08:02:43 PDT 2016


Author: annakrat
Date: 2016-09-26 08:02:42 -0700 (Mon, 26 Sep 2016)
New Revision: 69579

Modified:
   grass/trunk/gui/wxpython/core/settings.py
   grass/trunk/gui/wxpython/vdigit/preferences.py
   grass/trunk/gui/wxpython/vdigit/wxdisplay.py
Log:
wxGUI/vdigit: better fix for #2848

Modified: grass/trunk/gui/wxpython/core/settings.py
===================================================================
--- grass/trunk/gui/wxpython/core/settings.py	2016-09-26 14:05:26 UTC (rev 69578)
+++ grass/trunk/gui/wxpython/core/settings.py	2016-09-26 15:02:42 UTC (rev 69579)
@@ -394,7 +394,7 @@
                 # snapping
                 'snapping': {
                     'value': 10,
-                    'units': 'screen pixels'
+                    'units': 0
                 },
                 'snapToVertex': {
                     'enabled': True

Modified: grass/trunk/gui/wxpython/vdigit/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/preferences.py	2016-09-26 14:05:26 UTC (rev 69578)
+++ grass/trunk/gui/wxpython/vdigit/preferences.py	2016-09-26 15:02:42 UTC (rev 69579)
@@ -217,11 +217,12 @@
         self.snappingValue.Bind(wx.EVT_TEXT, self.OnChangeSnappingValue)
         self.snappingUnit = wx.Choice(parent=panel, id=wx.ID_ANY, size=(
             125, -1), choices=[_("screen pixels"), _("map units")])
-        self.snappingUnit.SetStringSelection(
-            UserSettings.Get(
-                group='vdigit',
-                key="snapping",
-                subkey='units'))
+        try:
+            self.snappingUnit.SetSelection(UserSettings.Get(group='vdigit',
+                                                            key="snapping",
+                                                            subkey='units'))
+        except:
+            self.snappingUnit.SetSelection(0)
         self.snappingUnit.Bind(wx.EVT_CHOICE, self.OnChangeSnappingUnits)
         flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
         flexSizer.Add(
@@ -885,7 +886,7 @@
             res = (region['nsres'] + region['ewres']) / 2.
             threshold = self.digit.GetDisplay().GetThreshold(value=res)
         else:
-            if self.snappingUnit.GetStringSelection() == "map units":
+            if self.snappingUnit.GetSelection() == 1:  # map units
                 threshold = value
             else:
                 threshold = self.digit.GetDisplay().GetThreshold(value=value)
@@ -909,10 +910,10 @@
         """Snapping units change -> update static text
         """
         value = self.snappingValue.GetValue()
-        units = self.snappingUnit.GetStringSelection()
+        units = self.snappingUnit.GetSelection()
         threshold = self.digit.GetDisplay().GetThreshold(value=value, units=units)
 
-        if units == "map units":
+        if units == 1:  # map units
             self.snappingInfo.SetLabel(
                 _("Snapping threshold is %(value).1f %(units)s") %
                 {'value': value, 'units': self.mapUnits})
@@ -1003,7 +1004,7 @@
         UserSettings.Set(group='vdigit', key="snapping", subkey='value',
                          value=int(self.snappingValue.GetValue()))
         UserSettings.Set(group='vdigit', key="snapping", subkey='units',
-                         value=self.snappingUnit.GetStringSelection())
+                         value=self.snappingUnit.GetSelection())
         UserSettings.Set(group='vdigit', key="snapToVertex", subkey='enabled',
                          value=self.snapVertex.IsChecked())
 

Modified: grass/trunk/gui/wxpython/vdigit/wxdisplay.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/wxdisplay.py	2016-09-26 14:05:26 UTC (rev 69578)
+++ grass/trunk/gui/wxpython/vdigit/wxdisplay.py	2016-09-26 15:02:42 UTC (rev 69579)
@@ -1099,7 +1099,7 @@
 
         :param type: snapping mode (node, vertex)
         :param value: threshold to be set up
-        :param units: units (map, screen)
+        :param units: units (0 for screen pixels, 1 for map units)
 
         :return: threshold value
         """
@@ -1112,7 +1112,7 @@
         if value < 0:
             value = (self.region['nsres'] + self.region['ewres']) / 2.0
 
-        if units == _("screen pixels"):
+        if units == 0:
             # pixel -> cell
             res = max(self.region['nsres'], self.region['ewres'])
             return value * res



More information about the grass-commit mailing list