Преглед на файлове

wxGUI/vdigit: option to close boundary (snap to the first node)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54391 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa преди 12 години
родител
ревизия
935c53c90a
променени са 3 файла, в които са добавени 26 реда и са изтрити 5 реда
  1. 4 0
      gui/wxpython/core/settings.py
  2. 14 1
      gui/wxpython/vdigit/preferences.py
  3. 8 4
      gui/wxpython/vdigit/wxdigit.py

+ 4 - 0
gui/wxpython/core/settings.py

@@ -456,6 +456,10 @@ class Settings:
                 'breakLines' : {
                     'enabled' : False,
                     },
+                # close boundary (snap to the first node)
+                'closeBoundary' : {
+                    'enabled' : False,
+                    }
                 },
              # 
              # plots for profiles, histograms, and scatterplots

+ 14 - 1
gui/wxpython/vdigit/preferences.py

@@ -232,7 +232,7 @@ class VDigitSettingsDialog(wx.Dialog):
         #
         # digitize lines box
         #
-        box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Digitize line features"))
+        box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Digitize lines/boundaries"))
         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
         self.intersect = wx.CheckBox(parent = panel, label = _("Break lines at intersection"))
@@ -243,6 +243,19 @@ class VDigitSettingsDialog(wx.Dialog):
         border.Add(item = sizer, proportion = 0, flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border = 5)
 
         #
+        # digitize areas box
+        #
+        box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Digitize areas"))
+        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+        self.closeBoundary = wx.CheckBox(parent = panel, label = _("Close boundary (snap to the start node)"))
+        self.closeBoundary.SetValue(UserSettings.Get(group = 'vdigit', key = 'closeBoundary', subkey = 'enabled'))
+        
+        sizer.Add(item = self.closeBoundary, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 1)
+
+        border.Add(item = sizer, proportion = 0, flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border = 5)
+
+        #
         # save-on-exit box
         #
         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Save changes"))

+ 8 - 4
gui/wxpython/vdigit/wxdigit.py

@@ -1401,9 +1401,11 @@ class IVDigit:
             # close boundary
             points = self.poPoints.contents
             last = points.n_points - 1
-            if Vect_points_distance(points.x[0], points.x[0], points.z[0],
-                                    points.x[last], points.x[last], points.z[last],
-                                    is3D) <= threshold:
+            if self._settings['closeBoundary']:
+                Vect_append_point(self.poPoints, points.x[0], points.y[0], points.z[0])
+            elif Vect_points_distance(points.x[0], points.x[0], points.z[0],
+                                      points.x[last], points.x[last], points.z[last],
+                                      is3D) <= threshold:
                 points.x[last] = points.x[0]
                 points.y[last] = points.y[0]
                 points.z[last] = points.z[0]
@@ -1577,8 +1579,10 @@ class IVDigit:
         """
         self._display.UpdateSettings()
         
-        self._settings['breakLines']  = bool(UserSettings.Get(group = 'vdigit', key = "breakLines",
+        self._settings['breakLines']   = bool(UserSettings.Get(group = 'vdigit', key = "breakLines",
                                                               subkey = 'enabled'))
+        self._settings['closeBoundary'] = bool(UserSettings.Get(group = 'vdigit', key = "closeBoundary",
+                                                                subkey = 'enabled'))
         
     def SetCategory(self):
         """!Update self.cats based on settings"""