[GRASS-SVN] r69594 - in grass/branches/releasebranch_7_2/gui/wxpython: core vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 27 19:43:08 PDT 2016


Author: annakrat
Date: 2016-09-27 19:43:08 -0700 (Tue, 27 Sep 2016)
New Revision: 69594

Modified:
   grass/branches/releasebranch_7_2/gui/wxpython/core/settings.py
   grass/branches/releasebranch_7_2/gui/wxpython/vdigit/preferences.py
   grass/branches/releasebranch_7_2/gui/wxpython/vdigit/wxdisplay.py
Log:
GUI/vdigit: fix snapping units, see #2848 (merge from trunk r69578, r69579, r69580)

Modified: grass/branches/releasebranch_7_2/gui/wxpython/core/settings.py
===================================================================
--- grass/branches/releasebranch_7_2/gui/wxpython/core/settings.py	2016-09-28 01:47:15 UTC (rev 69593)
+++ grass/branches/releasebranch_7_2/gui/wxpython/core/settings.py	2016-09-28 02:43:08 UTC (rev 69594)
@@ -394,7 +394,8 @@
                 # snapping
                 'snapping': {
                     'value': 10,
-                    'units': 'screen pixels'
+                    'unit': 0,  # new
+                    'units': 'screen pixels'  # old for backwards comp.
                 },
                 'snapToVertex': {
                     'enabled': True

Modified: grass/branches/releasebranch_7_2/gui/wxpython/vdigit/preferences.py
===================================================================
--- grass/branches/releasebranch_7_2/gui/wxpython/vdigit/preferences.py	2016-09-28 01:47:15 UTC (rev 69593)
+++ grass/branches/releasebranch_7_2/gui/wxpython/vdigit/preferences.py	2016-09-28 02:43:08 UTC (rev 69594)
@@ -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='unit'))
+        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})
@@ -1002,8 +1003,8 @@
         # snapping
         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())
+        UserSettings.Set(group='vdigit', key="snapping", subkey='unit',
+                         value=self.snappingUnit.GetSelection())
         UserSettings.Set(group='vdigit', key="snapToVertex", subkey='enabled',
                          value=self.snapVertex.IsChecked())
 

Modified: grass/branches/releasebranch_7_2/gui/wxpython/vdigit/wxdisplay.py
===================================================================
--- grass/branches/releasebranch_7_2/gui/wxpython/vdigit/wxdisplay.py	2016-09-28 01:47:15 UTC (rev 69593)
+++ grass/branches/releasebranch_7_2/gui/wxpython/vdigit/wxdisplay.py	2016-09-28 02:43:08 UTC (rev 69594)
@@ -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
         """
@@ -1107,12 +1107,12 @@
             value = UserSettings.Get(group='vdigit', key=type, subkey='value')
 
         if units is None:
-            units = UserSettings.Get(group='vdigit', key=type, subkey='units')
+            units = UserSettings.Get(group='vdigit', key=type, subkey='unit')
 
         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