Преглед изворни кода

wxGUI: sync'ed with develb6
digit module renamed to vdigit, minor fixes in vector digitizer
profile tool fixes (GUI layout), settings


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

Martin Landa пре 17 година
родитељ
комит
7d12bb7347

+ 1 - 1
gui/wxpython/gui_modules/__init__.py

@@ -1,6 +1,5 @@
 all = [ "dbm",
         "debug",
-        "digit",
         "disp_print",
         "gcmd",
         "georect",
@@ -22,5 +21,6 @@ all = [ "dbm",
         "toolbox",
         "track",
         "utils",
+        "vdigit",
         "workspace",
         "wxgui_utils" ]

+ 20 - 20
gui/wxpython/gui_modules/mapdisp.py

@@ -60,9 +60,9 @@ import profile
 import globalvar
 import utils
 import gdialogs
-from digit import DigitCategoryDialog as DigitCategoryDialog
-from digit import DigitZBulkDialog    as DigitZBulkDialog
-from digit import GV_LINES            as Digit_Lines_Type
+from vdigit import VDigitCategoryDialog as VDigitCategoryDialog
+from vdigit import VDigitZBulkDialog    as VDigitZBulkDialog
+from vdigit import GV_LINES            as VDigit_Lines_Type
 from debug import Debug               as Debug
 from icon  import Icons               as Icons
 from preferences import globalSettings as UserSettings
@@ -1094,20 +1094,20 @@ class BufferedWindow(wx.Window):
                     if self.parent.dialogs['category'] is None:
                         # open new dialog
                         if digitClass.type == 'vedit':
-                            self.parent.dialogs['category'] = DigitCategoryDialog(parent=self,
-                                                                             map=map,
-                                                                             query=(coords, qdist),
-                                                                             pos=posWindow,
-                                                                             title=_("Update categories"))
+                            self.parent.dialogs['category'] = VDigitCategoryDialog(parent=self,
+                                                                                   map=map,
+                                                                                   query=(coords, qdist),
+                                                                                   pos=posWindow,
+                                                                                   title=_("Update categories"))
                         else:
                             if digitClass.driver.SelectLineByPoint(coords,
                                                                    digitClass.GetSelectType()) is not None:
-                                self.parent.dialogs['category'] = DigitCategoryDialog(parent=self,
-                                                                                 map=map,
-                                                                                 cats=digitClass.GetLineCats(),
-                                                                                 line=digitClass.driver.GetSelected()[0],
-                                                                                 pos=posWindow,
-                                                                                 title=_("Update categories"))
+                                self.parent.dialogs['category'] = VDigitCategoryDialog(parent=self,
+                                                                                       map=map,
+                                                                                       cats=digitClass.GetLineCats(),
+                                                                                       line=digitClass.driver.GetSelected()[0],
+                                                                                       pos=posWindow,
+                                                                                       title=_("Update categories"))
                             
                     else:
                         # update currently open dialog
@@ -1267,7 +1267,7 @@ class BufferedWindow(wx.Window):
                 # -> delete line || move line || move vertex
                 if digitToolbar.action in ["moveVertex", "editLine"]:
                     if len(digitClass.driver.GetSelected()) == 0:
-                        nselected = digitClass.driver.SelectLineByPoint(pos1, type=Digit_Lines_Type)
+                        nselected = digitClass.driver.SelectLineByPoint(pos1, type=VDigit_Lines_Type)
                         if digitToolbar.action == "editLine":
                             self.UpdateMap(render=False)
                             selVertex = digitClass.driver.GetSelectedVertex(pos1)[0]
@@ -1290,7 +1290,7 @@ class BufferedWindow(wx.Window):
                 elif digitToolbar.action == "copyCats":
                     if not hasattr(self, "copyCatsIds"):
                         # collect categories
-                        nselected = digitClass.driver.SelectLineByPoint(pos1, type=Digit_Lines_Type)
+                        nselected = digitClass.driver.SelectLineByPoint(pos1, type=VDigit_Lines_Type)
                         if nselected:
                             qdist = 10.0 * ((self.Map.region['e'] - self.Map.region['w']) / \
                                                 self.Map.width)
@@ -1360,7 +1360,7 @@ class BufferedWindow(wx.Window):
 
             elif digitToolbar.action in ["splitLine", "addVertex", "removeVertex"]:
                 pointOnLine = digitClass.driver.SelectLineByPoint(pos1,
-                                                                  type=Digit_Lines_Type)
+                                                                  type=VDigit_Lines_Type)
                 if pointOnLine:
                     self.UpdateMap(render=False) # highlight object
                     if digitToolbar.action in ["splitLine", "addVertex"]:
@@ -1643,8 +1643,8 @@ class BufferedWindow(wx.Window):
                 pos2 = self.polycoords[1]
 
                 selected = digitClass.driver.GetSelected()
-                dlg = DigitZBulkDialog(parent=self, title=_("Z bulk-labeling dialog"),
-                                       nselected=len(selected))
+                dlg = VDigitZBulkDialog(parent=self, title=_("Z bulk-labeling dialog"),
+                                        nselected=len(selected))
                 if dlg.ShowModal() == wx.ID_OK:
                     digitClass.ZBulkLine(pos1, pos2, dlg.value.GetValue(), dlg.step.GetValue())
 
@@ -2396,7 +2396,7 @@ class MapFrame(wx.Frame):
                               CloseButton(False).Layer(2))
 
         elif name == "digit":
-            self.digittoolbar = toolbars.DigitToolbar(self, self.Map, self.tree)
+            self.digittoolbar = toolbars.VDigitToolbar(self, self.Map, self.tree)
 
             for toolRow in range(0, self.digittoolbar.numOfRows):
                 self._mgr.AddPane(self.digittoolbar.toolbar[toolRow],

+ 4 - 4
gui/wxpython/gui_modules/preferences.py

@@ -132,13 +132,13 @@ class Settings:
                 'addRecord' : { 'enabled' : True },
                 'layer' : {'value' : 1 },
                 'category' : {'value' : 1 },
-                'categoryMode' : {'value' : 'Next to use' },
+                'categoryMode' : {'selection' : 0 },
                 # delete existing feature(s)
                 'delRecord' : { 'enabled' : True },
                 # query tool
-                'query'       : { 'type' : 'length', 'box' : True },
-                'queryLength' : { 'than' : 'shorter than', 'thresh' : 0 },
-                'queryDangle' : { 'than' : 'shorter than', 'thresh' : 0 },
+                'query'       : { 'selection' : 0, 'box' : True },
+                'queryLength' : { 'than-selection' : 0, 'thresh' : 0 },
+                'queryDangle' : { 'than-selection' : 0, 'thresh' : 0 },
                 # select feature (point, line, centroid, boundary)
                 'selectFeaturePoint'    : { 'enabled' : True },
                 'selectFeatureLine'     : { 'enabled' : True },

+ 10 - 10
gui/wxpython/gui_modules/profile.py

@@ -226,7 +226,7 @@ class ProfileFrame(wx.Frame):
                 self.raster[r]['name'] = dlg.raster[r]['name']
 
             # plot profile
-            if self.raster[0]['name']:
+            if self.raster[0]['name'] and len(self.mapwin.polycoords) > 0:
                 self.OnCreateProfile(event=None)
 
         dlg.Destroy()
@@ -728,15 +728,15 @@ class SetRasterDialog(wx.Dialog):
         self.parent = parent
         self.coordstr = self.parent.coordstr
 
-        if self.coordstr == '':
-            dlg = wx.MessageDialog(parent=self,
-                                   message=_('You must draw a transect to profile in the map display window.'),
-                                   caption=_('Nothing to profile'),
-                                   style=wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
-            dlg.ShowModal()
-            dlg.Destroy()
-            self.Close(True)
-            return
+        #         if self.coordstr == '':
+        #             dlg = wx.MessageDialog(parent=self,
+        #                                    message=_('You must draw a transect to profile in the map display window.'),
+        #                                    caption=_('Nothing to profile'),
+        #                                    style=wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
+        #             dlg.ShowModal()
+        #             dlg.Destroy()
+        #             self.Close(True)
+        #             return
 
         self.raster = { 0 : { 'name' : self.parent.raster[0]['name'],
                               'id' : None },

+ 18 - 18
gui/wxpython/gui_modules/toolbars.py

@@ -5,7 +5,7 @@ CLASSES:
     * AbstractToolbar
     * MapToolbar
     * GRToolbar
-    * DigitToolbar
+    * VDigitToolbar
     * ProfileToolbar
     
 PURPOSE: Toolbars for Map Display window
@@ -25,9 +25,9 @@ import os, sys
 import globalvar
 import gcmd
 import grassenv
-import digit
 import gdialogs
-from digit import DigitSettingsDialog as DigitSettingsDialog
+import vdigit
+from vdigit import VDigitSettingsDialog as VDigitSettingsDialog
 from debug import Debug as Debug
 from icon import Icons as Icons
 from preferences import globalSettings as UserSettings
@@ -255,7 +255,7 @@ class GRToolbar(AbstractToolbar):
         if tool == "Digitize" and not self.mapdisplay.digittoolbar:
             self.mapdisplay.AddToolbar("digit")
 
-class DigitToolbar(AbstractToolbar):
+class VDigitToolbar(AbstractToolbar):
     """
     Toolbar for digitization
     """
@@ -408,14 +408,14 @@ class DigitToolbar(AbstractToolbar):
         
     def OnAddPoint(self, event):
         """Add point to the vector map Laier"""
-        Debug.msg (2, "DigitToolbar.OnAddPoint()")
+        Debug.msg (2, "VDigitToolbar.OnAddPoint()")
         self.action = "addLine"
         self.type   = "point"
         self.parent.MapWindow.mouse['box'] = 'point'
 
     def OnAddLine(self, event):
         """Add line to the vector map layer"""
-        Debug.msg (2, "DigitToolbar.OnAddLine()")
+        Debug.msg (2, "VDigitToolbar.OnAddLine()")
         self.action = "addLine"
         self.type   = "line"
         self.parent.MapWindow.mouse['box'] = 'line'
@@ -423,7 +423,7 @@ class DigitToolbar(AbstractToolbar):
 
     def OnAddBoundary(self, event):
         """Add boundary to the vector map layer"""
-        Debug.msg (2, "DigitToolbar.OnAddBoundary()")
+        Debug.msg (2, "VDigitToolbar.OnAddBoundary()")
         self.action = "addLine"
         self.type   = "boundary"
         self.parent.MapWindow.mouse['box'] = 'line'
@@ -431,7 +431,7 @@ class DigitToolbar(AbstractToolbar):
 
     def OnAddCentroid(self, event):
         """Add centroid to the vector map layer"""
-        Debug.msg (2, "DigitToolbar.OnAddCentroid()")
+        Debug.msg (2, "VDigitToolbar.OnAddCentroid()")
         self.action = "addLine"
         self.type   = "centroid"
         self.parent.MapWindow.mouse['box'] = 'point'
@@ -541,13 +541,13 @@ class DigitToolbar(AbstractToolbar):
         """Show settings dialog"""
 
         if self.parent.digit is None:
-            reload(digit)
-            from digit import Digit as Digit
+            reload(vdigit)
+            from vdigit import Digit as Digit
             self.parent.digit = Digit(mapwindow=self.parent.MapWindow)
             
         if not self.settingsDialog:
-            self.settingsDialog = DigitSettingsDialog(parent=self.parent, title=_("Digitization settings"),
-                                                      style=wx.DEFAULT_DIALOG_STYLE)
+            self.settingsDialog = VDigitSettingsDialog(parent=self.parent, title=_("Digitization settings"),
+                                                       style=wx.DEFAULT_DIALOG_STYLE)
             self.settingsDialog.Show()
 
     def OnAdditionalToolMenu(self, event):
@@ -712,8 +712,8 @@ class DigitToolbar(AbstractToolbar):
         @return True on success
         @return False on error
         """
-        reload(digit)
-        from digit import Digit as Digit
+        reload(vdigit)
+        from vdigit import Digit as Digit
         self.parent.digit = Digit(mapwindow=self.parent.MapWindow)
         try:
             self.layerSelectedID = self.layers.index(layerSelected)
@@ -733,7 +733,7 @@ class DigitToolbar(AbstractToolbar):
         self.parent.maptoolbar.combo.SetValue ('Digitize')
         # set initial category number for new features (layer=1), etc.
 
-        Debug.msg (4, "DigitToolbar.StartEditing(): layerSelectedID=%d layer=%s" % \
+        Debug.msg (4, "VDigitToolbar.StartEditing(): layerSelectedID=%d layer=%s" % \
                    (self.layerSelectedID, mapLayer.name))
 
 
@@ -760,7 +760,7 @@ class DigitToolbar(AbstractToolbar):
 
         if self.layers[self.layerSelectedID] == layerSelected:
             self.layerSelectedID = None
-            Debug.msg (4, "DigitToolbar.StopEditing(): layer=%s" % \
+            Debug.msg (4, "VDigitToolbar.StopEditing(): layer=%s" % \
                        (layerSelected.name))
             self.combo.SetValue (_('Select vector map'))
 
@@ -768,7 +768,7 @@ class DigitToolbar(AbstractToolbar):
             if UserSettings.Get(group='advanced', key='digitInterface', subkey='type') == 'vdigit':
                 if UserSettings.Get(group='vdigit', key='saveOnExit', subkey='enabled') is False:
                     dlg = wx.MessageDialog(parent=self.parent, message=_("Do you want to save changes "
-                                                                         "to vector map <%s>?") % layerSelected.name,
+                                                                         "in vector map <%s>?") % layerSelected.name,
                                            caption=_("Save changes?"),
                                            style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
                     if dlg.ShowModal() == wx.ID_NO:
@@ -806,7 +806,7 @@ class DigitToolbar(AbstractToolbar):
         Optionaly also update toolbar
         """
 
-        Debug.msg (4, "DigitToolbar.UpdateListOfLayers(): updateTool=%d" % \
+        Debug.msg (4, "VDigitToolbar.UpdateListOfLayers(): updateTool=%d" % \
                    updateTool)
 
         layerNameSelected = None

+ 137 - 99
gui/wxpython/gui_modules/digit.py

@@ -1,18 +1,17 @@
 """
-MODULE: digit
+MODULE: vdigit
 
 CLASSES:
- * DigitError
  * AbstractDigit 
  * VEdit
  * VDigit
  * AbstractDisplayDriver
  * CDisplayDriver
- * DigitSettingsDialog
- * DigitCategoryDialog
- * DigitZBulkDialog
+ * VDigitSettingsDialog
+ * VDigitCategoryDialog
+ * VDigitZBulkDialog
 
-PURPOSE: Digitization tool wxPython GUI prototype
+PURPOSE: Vector digitization tool for wxPython GUI
 
          Note: Initial version under development
 
@@ -21,7 +20,7 @@ PURPOSE: Digitization tool wxPython GUI prototype
           (2) Reimplentation of v.digit (VDigit)
 
          Import:
-          from digit import Digit as Digit
+          from vdigit import VDigit as VDigit
           
 AUTHORS: The GRASS Development Team
          Martin Landa <landa.martin gmail.com>
@@ -50,8 +49,8 @@ from preferences import globalSettings as UserSettings
 try:
     digitPath = os.path.join(globalvar.ETCWXDIR, "vdigit")
     sys.path.append(digitPath)
-    import grass6_wxvdigit as vdigit
-    GV_LINES = vdigit.GV_LINES
+    import grass6_wxvdigit as wxvdigit
+    GV_LINES = wxvdigit.GV_LINES
     digitErr = ''
 except ImportError, err:
     GV_LINES = None
@@ -118,14 +117,13 @@ class AbstractDigit:
                             return False
                         return True
             else:
+                cat = self.digit.GetCategory(UserSettings.Get(group='vdigit', key='layer', subkey='value'))
                 UserSettings.Set(group='vdigit', key='category', subkey='value',
-                                  value=self.digit.GetCategory(UserSettings.Get(group='vdigit', key='layer', subkey='value') + 1))
+                                  value=cat + 1)
     
     def SetCategory(self):
         """Return category number to use (according Settings)"""
-        if UserSettings.Get(group='vdigit', key="categoryMode", subkey='value') == "No category":
-            UserSettings.Set(group='vdigit', key="category", subkey='value', value=1)
-        elif UserSettings.Get(group='vdigit', key="categoryMode", subkey='value') == "Next to use":
+        if UserSettings.Get(group='vdigit', key="categoryMode", subkey='selection') == 0:
             self.SetCategoryNextToUse()
 
         return UserSettings.Get(group='vdigit', key="category", subkey='value')
@@ -164,13 +162,13 @@ class AbstractDigit:
         """Generic method used for SelectLinesByQuery()
         -- to get threshold value"""
         thresh = 0.0
-        if UserSettings.Get(group='vdigit', key='query', subkey='type') == "length":
+        if UserSettings.Get(group='vdigit', key='query', subkey='selection') == 0:
             thresh = UserSettings.Get(group='vdigit', key='queryLength', subkey='thresh')
-            if UserSettings.Get(group='vdigit', key="queryLength", subkey='than') == "shorter than":
+            if UserSettings.Get(group='vdigit', key="queryLength", subkey='than-selection') == 0:
                 thresh = -1 * thresh
         else:
             thresh = UserSettings.Get(group='vdigit', key='queryDangle', subkey='thresh')
-            if UserSettings.Get(group='vdigit', key="queryDangle", subkey='than') == "shorter than":
+            if UserSettings.Get(group='vdigit', key="queryDangle", subkey='than-selection') == 0:
                 thresh = -1 * thresh
 
         return thresh
@@ -181,10 +179,10 @@ class AbstractDigit:
         Used by SelectLinesByBox() and SelectLinesByPoint()"""
 
         type = 0
-        for feature in (('Point', vdigit.GV_POINT),
-                        ('Line', vdigit.GV_LINE),
-                        ('Centroid', vdigit.GV_CENTROID),
-                        ('Boundary', vdigit.GV_BOUNDARY)):
+        for feature in (('Point', wxvdigit.GV_POINT),
+                        ('Line', wxvdigit.GV_LINE),
+                        ('Centroid', wxvdigit.GV_CENTROID),
+                        ('Boundary', wxvdigit.GV_BOUNDARY)):
             if UserSettings.Get(group='vdigit', key='selectFeature'+feature[0], subkey='enabled') is True:
                 type |= feature[1]
 
@@ -249,9 +247,13 @@ class VEdit(AbstractDigit):
         else:
             key = "C"
 
-        layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
-        cat   = self.SetCategory()
-        
+        if UserSettings.Get(group='vdigit', key="categoryMode", subkey='selection') == 2:
+            layer = -1 # -> no category
+            cat   = -1
+        else:
+            layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
+            cat   = self.SetCategory()
+
         if layer > 0 and cat != "None":
             addstring =  "%s 1 1\n" % (key)
         else:
@@ -281,9 +283,13 @@ class VEdit(AbstractDigit):
         if len(coords) < 2:
             return
 
-        layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
-        cat   = self.SetCategory()
-        
+        if UserSettings.Get(group='vdigit', key="categoryMode", subkey='selection') == 2:
+            layer = -1 # -> no category
+            cat   = -1
+        else:
+            layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
+            cat   = self.SetCategory()
+
         if line:
             key = "L"
             flags = []
@@ -703,12 +709,17 @@ class VEdit(AbstractDigit):
                 elif 'west' in item:
                     w = float(item.split('=')[1])
 
+        if UserSettings.Get(group='vdigit', key='query', subkey='selection') == 0:
+            qtype = 'length'
+        else:
+            qtype = 'dangle'
+
         vEdit = (['v.edit',
                   '--q',
                   'map=%s' % self.map,
                   'tool=select',
                   'bbox=%f,%f,%f,%f' % (w, n, e, s),
-                  'query=%s' % UserSettings.Get(group='vdigit', key='query', subkey='type'),
+                  'query=%s' % qtype,
                   'thresh=0,0,%f' % thresh])
 
         vEditCmd = gcmd.Command(vEdit)
@@ -761,7 +772,7 @@ class VDigit(AbstractDigit):
         AbstractDigit.__init__(self, mapwindow)
 
         try:
-            self.digit = vdigit.Digit(self.driver.GetDevice())
+            self.digit = wxvdigit.Digit(self.driver.GetDevice())
         except (ImportError, NameError):
             self.digit = None
 
@@ -777,13 +788,17 @@ class VDigit(AbstractDigit):
         @param point feature type (if true point otherwise centroid)
         @param x,y,z coordinates
         """
-        layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
-        cat   = self.SetCategory()
-        
+        if UserSettings.Get(group='vdigit', key="categoryMode", subkey='selection') == 2:
+            layer = -1 # -> no category
+            cat   = -1
+        else:
+            layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
+            cat   = self.SetCategory()
+
         if point:
-            type = vdigit.GV_POINT 
+            type = wxvdigit.GV_POINT 
         else:
-            type = vdigit.GV_CENTROID 
+            type = wxvdigit.GV_CENTROID 
 
         snap, thresh = self.__getSnapThreshold()
 
@@ -809,13 +824,17 @@ class VDigit(AbstractDigit):
         if len(coords) < 2:
             return
 
-        layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
-        cat   = self.SetCategory()
+        if UserSettings.Get(group='vdigit', key="categoryMode", subkey='selection') == 2:
+            layer = -1 # -> no category
+            cat   = -1
+        else:
+            layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
+            cat   = self.SetCategory()
 
         if line:
-            type = vdigit.GV_LINE
+            type = wxvdigit.GV_LINE
         else:
-            type = vdigit.GV_BOUNDARY
+            type = wxvdigit.GV_BOUNDARY
 
         listCoords = []
         for c in coords:
@@ -1073,13 +1092,13 @@ class VDigit(AbstractDigit):
         w, n = pos1
         e, s = pos2
 
-        query = vdigit.QUERY_UNKNOWN
-        if UserSettings.Get(group='vdigit', key='query', subkey='type') == 'length':
-            query = vdigit.QUERY_LENGTH
-        elif UserSettings.Get(group='vdigit', key='query', subkey='type') == 'dangle':
-            query = vdigit.QUERY_DANGLE
+        query = wxvdigit.QUERY_UNKNOWN
+        if UserSettings.Get(group='vdigit', key='query', subkey='selection') == 0:
+            query = wxvdigit.QUERY_LENGTH
+        else:
+            query = wxvdigit.QUERY_DANGLE
 
-        type = vdigit.GV_POINTS | vdigit.GV_LINES # TODO: 3D
+        type = wxvdigit.GV_POINTS | wxvdigit.GV_LINES # TODO: 3D
         
         ids = self.digit.SelectLinesByQuery(w, n, 0.0, e, s, 1000.0,
                                             UserSettings.Get(group='vdigit', key='query', subkey='box'),
@@ -1165,9 +1184,9 @@ class VDigit(AbstractDigit):
 
         if thresh > 0.0:
             if UserSettings.Get(group='vdigit', key='snapToVertex', subkey='enabled') is True:
-                snap = vdigit.SNAPVERTEX
+                snap = wxvdigit.SNAPVERTEX
             else:
-                snap = vdigit.SNAP
+                snap = wxvdigit.SNAP
         else:
             snap = v.digit.NO_SNAP
 
@@ -1247,7 +1266,7 @@ class CDisplayDriver(AbstractDisplayDriver):
 
         # initialize wx display driver
         try:
-            self.__display = vdigit.DisplayDriver(mapwindow.pdcVector)
+            self.__display = wxvdigit.DisplayDriver(mapwindow.pdcVector)
         except:
             self.__display = None
             
@@ -1319,8 +1338,8 @@ class CDisplayDriver(AbstractDisplayDriver):
         x1, y1 = begin
         x2, y2 = end
 
-        nselected = self.__display.SelectLinesByBox(x1, y1, -1.0 * vdigit.PORT_DOUBLE_MAX,
-                                                    x2, y2, vdigit.PORT_DOUBLE_MAX,
+        nselected = self.__display.SelectLinesByBox(x1, y1, -1.0 * wxvdigit.PORT_DOUBLE_MAX,
+                                                    x2, y2, wxvdigit.PORT_DOUBLE_MAX,
                                                     type)
         Debug.msg(4, "CDisplayDriver.SelectLinesByBox(): selected=%d" % \
                       nselected)
@@ -1481,7 +1500,7 @@ class CDisplayDriver(AbstractDisplayDriver):
                                                 255).GetRGB(),
                                        UserSettings.Get(group='vdigit', key='lineWidth', subkey='value'))
 
-class DigitSettingsDialog(wx.Dialog):
+class VDigitSettingsDialog(wx.Dialog):
     """
     Standard settings dialog for digitization purposes
     """
@@ -1725,7 +1744,7 @@ class DigitSettingsDialog(wx.Dialog):
         txt = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Select lines"))
         self.queryLengthSL = wx.Choice (parent=panel, id=wx.ID_ANY, 
                                         choices = [_("shorter than"), _("longer than")])
-        self.queryLengthSL.SetStringSelection(UserSettings.Get(group='vdigit', key="queryLength", subkey='than'))
+        self.queryLengthSL.SetSelection(UserSettings.Get(group='vdigit', key="queryLength", subkey='than-selection'))
         self.queryLengthValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(100, -1),
                                             initial=1,
                                             min=0, max=1e6)
@@ -1748,7 +1767,7 @@ class DigitSettingsDialog(wx.Dialog):
         txt = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Select dangles"))
         self.queryDangleSL = wx.Choice (parent=panel, id=wx.ID_ANY, 
                                         choices = [_("shorter than"), _("longer than")])
-        self.queryDangleSL.SetStringSelection(UserSettings.Get(group='vdigit', key="queryDangle", subkey='than'))
+        self.queryDangleSL.SetSelection(UserSettings.Get(group='vdigit', key="queryDangle", subkey='than-selection'))
         self.queryDangleValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(100, -1),
                                        initial=1,
                                        min=0, max=1e6)
@@ -1760,7 +1779,7 @@ class DigitSettingsDialog(wx.Dialog):
         flexSizer.Add(units, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
         sizer.Add(item=flexSizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)
 
-        if UserSettings.Get(group='vdigit', key="query", subkey='type') == "length":
+        if UserSettings.Get(group='vdigit', key="query", subkey='selection') == 0:
             self.queryLength.SetValue(True)
         else:
             self.queryDangle.SetValue(True)
@@ -1817,7 +1836,7 @@ class DigitSettingsDialog(wx.Dialog):
         self.category = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(125, -1),
                                     initial=UserSettings.Get(group='vdigit', key="category", subkey='value'),
                                     min=-1e9, max=1e9) 
-        if UserSettings.Get(group='vdigit', key="categoryMode", subkey='value') != "Manual entry":
+        if UserSettings.Get(group='vdigit', key="categoryMode", subkey='selection') != 1:
             self.category.Enable(False)
         flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
         flexSizer.Add(item=self.category, proportion=0,
@@ -1826,7 +1845,7 @@ class DigitSettingsDialog(wx.Dialog):
         text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Category mode"))
         self.categoryMode = wx.Choice(parent=panel, id=wx.ID_ANY, size=(125, -1),
                                       choices=[_("Next to use"), _("Manual entry"), _("No category")])
-        self.categoryMode.SetStringSelection(UserSettings.Get(group='vdigit', key="categoryMode", subkey='value'))
+        self.categoryMode.SetSelection(UserSettings.Get(group='vdigit', key="categoryMode", subkey='selection'))
         flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
         flexSizer.Add(item=self.categoryMode, proportion=0,
                       flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
@@ -1867,31 +1886,32 @@ class DigitSettingsDialog(wx.Dialog):
 
         return (
             #            ("Background", "symbolBackground"),
-            ("Highlight", "symbolHighlight"),
-            ("Point", "symbolPoint"),
-            ("Line", "symbolLine"),
-            ("Boundary (no area)", "symbolBoundaryNo"),
-            ("Boundary (one area)", "symbolBoundaryOne"),
-            ("Boundary (two areas)", "symbolBoundaryTwo"),
-            ("Centroid (in area)", "symbolCentroidIn"),
-            ("Centroid (outside area)", "symbolCentroidOut"),
-            ("Centroid (duplicate in area)", "symbolCentroidDup"),
-            ("Node (one line)", "symbolNodeOne"),
-            ("Node (two lines)", "symbolNodeTwo"),
-            ("Vertex", "symbolVertex"))
+            (_("Highlight"), "symbolHighlight"),
+            (_("Point"), "symbolPoint"),
+            (_("Line"), "symbolLine"),
+            (_("Boundary (no area)"), "symbolBoundaryNo"),
+            (_("Boundary (one area)"), "symbolBoundaryOne"),
+            (_("Boundary (two areas)"), "symbolBoundaryTwo"),
+            (_("Centroid (in area)"), "symbolCentroidIn"),
+            (_("Centroid (outside area)"), "symbolCentroidOut"),
+            (_("Centroid (duplicate in area)"), "symbolCentroidDup"),
+            (_("Node (one line)"), "symbolNodeOne"),
+            (_("Node (two lines)"), "symbolNodeTwo"),
+            (_("Vertex"), "symbolVertex"))
 
     def OnChangeCategoryMode(self, event):
         """Change category mode"""
 
-        mode = event.GetString()
-        UserSettings.Set(group='vdigit', key="categoryMode", subkey='value', value=mode)
-        if mode == "Manual entry": # enable
+        mode = event.GetSelection()
+        UserSettings.Set(group='vdigit', key="categoryMode", subkey='selection', value=mode)
+        if mode == 1: # manual entry
             self.category.Enable(True)
         elif self.category.IsEnabled(): # disable
             self.category.Enable(False)
 
-        if mode == "No category" and self.addRecord.IsChecked():
+        if mode == 2 and self.addRecord.IsChecked(): # no category
             self.addRecord.SetValue(False)
+
         self.parent.digit.SetCategory()
         self.category.SetValue(UserSettings.Get(group='vdigit', key='category', subkey='value'))
 
@@ -1989,53 +2009,71 @@ class DigitSettingsDialog(wx.Dialog):
         # symbology
         for key, (enabled, color) in self.symbology.iteritems():
             if enabled:
-                UserSettings.Set(group='vdigit', key=key, subkey='enabled', value=enabled.IsChecked())
-                UserSettings.Set(group='vdigit', key=key, subkey='color', value=color.GetColour())
+                UserSettings.Set(group='vdigit', key=key, subkey='enabled',
+                                 value=enabled.IsChecked())
+                UserSettings.Set(group='vdigit', key=key, subkey='color',
+                                 value=color.GetColour())
             else:
-                UserSettings.Set(group='vdigit', key=key, subkey='color', value=color.GetColour())
+                UserSettings.Set(group='vdigit', key=key, subkey='color',
+                                 value=color.GetColour())
         # display
-        UserSettings.Set(group='vdigit', key="lineWidth", subkey='value', value=int(self.lineWidthValue.GetValue()))
+        UserSettings.Set(group='vdigit', key="lineWidth", subkey='value',
+                         value=int(self.lineWidthValue.GetValue()))
 
         # 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="snapToVertex", subkey='enabled', value=self.snapVertex.IsChecked())
+        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="snapToVertex", subkey='enabled',
+                         value=self.snapVertex.IsChecked())
         
         # digitize new feature
-        UserSettings.Set(group='vdigit', key="addRecord", subkey='enabled', value=self.addRecord.IsChecked())
-        UserSettings.Set(group='vdigit', key="layer", subkey='value', value=int(self.layer.GetStringSelection()))
-        if UserSettings.Get(group='vdigit', key="categoryMode", subkey='value') == "No category":
-            UserSettings.Set(group='vdigit', key="category", subkey='value', value=None)
-        else:
-            UserSettings.Set(group='vdigit', key="category", subkey='value', value=int(self.category.GetValue()))
-        UserSettings.Set(group='vdigit', key="categoryMode", subkey='value', value=self.categoryMode.GetStringSelection())
+        UserSettings.Set(group='vdigit', key="addRecord", subkey='enabled',
+                         value=self.addRecord.IsChecked())
+        UserSettings.Set(group='vdigit', key="layer", subkey='value',
+                         value=int(self.layer.GetStringSelection()))
+        UserSettings.Set(group='vdigit', key="category", subkey='value',
+                         value=int(self.category.GetValue()))
+        UserSettings.Set(group='vdigit', key="categoryMode", subkey='selection',
+                         value=self.categoryMode.GetSelection())
 
         # delete existing feature
-        UserSettings.Set(group='vdigit', key="delRecord", subkey='enabled', value=self.deleteRecord.IsChecked())
+        UserSettings.Set(group='vdigit', key="delRecord", subkey='enabled',
+                         value=self.deleteRecord.IsChecked())
 
         # snapping threshold
         self.parent.digit.threshold = self.parent.digit.driver.GetThreshold()
 
         # query tool
         if self.queryLength.GetValue():
-            UserSettings.Set(group='vdigit', key="query", subkey='type', value="length")
+            UserSettings.Set(group='vdigit', key="query", subkey='selection',
+                             value=0)
         else:
-            UserSettings.Set(group='vdigit', key="query", subkey='type', value="dangle")
-        UserSettings.Set(group='vdigit', key="query", subkey='box', value=self.queryBox.IsChecked())
-        UserSettings.Set(group='vdigit', key="queryLength", subkey='than', value=self.queryLengthSL.GetStringSelection())
-        UserSettings.Set(group='vdigit', key="queryLength", subkey='thresh', value=int(self.queryLengthValue.GetValue()))
-        UserSettings.Set(group='vdigit', key="queryDangle", subkey='than', value=self.queryDangleSL.GetStringSelection())
-        UserSettings.Set(group='vdigit', key="queryDangle", subkey='thresh', value=int(self.queryDangleValue.GetValue()))
+            UserSettings.Set(group='vdigit', key="query", subkey='type',
+                             value=1)
+        UserSettings.Set(group='vdigit', key="query", subkey='box',
+                         value=self.queryBox.IsChecked())
+        UserSettings.Set(group='vdigit', key="queryLength", subkey='than-selection',
+                         value=self.queryLengthSL.GetSelection())
+        UserSettings.Set(group='vdigit', key="queryLength", subkey='thresh',
+                         value=int(self.queryLengthValue.GetValue()))
+        UserSettings.Set(group='vdigit', key="queryDangle", subkey='than-selection',
+                         value=self.queryDangleSL.GetSelection())
+        UserSettings.Set(group='vdigit', key="queryDangle", subkey='thresh',
+                         value=int(self.queryDangleValue.GetValue()))
 
         # select features
         for feature in ('Point', 'Line',
                         'Centroid', 'Boundary'):
             UserSettings.Set(group='vdigit', key='selectFeature'+feature, subkey='enabled',
                                            value=self.FindWindowById(self.selectFeature[feature]).IsChecked())
-        UserSettings.Set(group='vdigit', key="selectThresh", subkey='value', value=int(self.selectThreshValue.GetValue()))
+        UserSettings.Set(group='vdigit', key="selectThresh", subkey='value',
+                         value=int(self.selectThreshValue.GetValue()))
 
         # on-exit
-        UserSettings.Set(group='vdigit', key="saveOnExit", subkey='enabled', value=self.save.IsChecked())
+        UserSettings.Set(group='vdigit', key="saveOnExit", subkey='enabled',
+                         value=self.save.IsChecked())
         
         # update driver settings
         self.parent.digit.driver.UpdateSettings()
@@ -2044,7 +2082,7 @@ class DigitSettingsDialog(wx.Dialog):
         if self.parent.autoRender.GetValue(): 
             self.parent.OnRender(None)
 
-class DigitCategoryDialog(wx.Dialog, listmix.ColumnSorterMixin):
+class VDigitCategoryDialog(wx.Dialog, listmix.ColumnSorterMixin):
     """
     Dialog used to display/modify categories of vector objects
     
@@ -2076,7 +2114,7 @@ class DigitCategoryDialog(wx.Dialog, listmix.ColumnSorterMixin):
         # do not display dialog if no line is found (-> self.cats)
         if cats is None:
             if self.__GetCategories(query[0], query[1]) == 0 or not self.line:
-                Debug.msg(3, "DigitCategoryDialog(): nothing found!")
+                Debug.msg(3, "VDigitCategoryDialog(): nothing found!")
                 return
         else:
             # self.cats = dict(cats)
@@ -2087,7 +2125,7 @@ class DigitCategoryDialog(wx.Dialog, listmix.ColumnSorterMixin):
         # make copy of cats (used for 'reload')
         self.cats_orig = copy.deepcopy(self.cats)
 
-        Debug.msg(3, "DigitCategoryDialog(): line=%d, cats=%s" % \
+        Debug.msg(3, "VDigitCategoryDialog(): line=%d, cats=%s" % \
                       (self.line, self.cats))
 
         wx.Dialog.__init__(self, parent=self.parent, id=wx.ID_ANY, title=title,
@@ -2453,7 +2491,7 @@ class DigitCategoryDialog(wx.Dialog, listmix.ColumnSorterMixin):
             self.line = line
             ret = 1
         if ret == 0 or not self.line:
-            Debug.msg(3, "DigitCategoryDialog(): nothing found!")
+            Debug.msg(3, "VDigitCategoryDialog(): nothing found!")
             return False
         
         # make copy of cats (used for 'reload')
@@ -2515,7 +2553,7 @@ class CategoryListCtrl(wx.ListCtrl,
 
         return itemData
 
-class DigitZBulkDialog(wx.Dialog):
+class VDigitZBulkDialog(wx.Dialog):
     """
     Dialog used for Z bulk-labeling tool
     """

+ 6 - 8
gui/wxpython/vdigit/line.cpp

@@ -26,7 +26,7 @@ extern "C" {
 
    \param type   feature type
    \param coords pairs of coordinates list (2D or 3D map)
-   \param layer  layer number
+   \param layer  layer number (layer < 1 -> no category)
    \param cat    category number
    \param bgmap  map of background map or NULL
    \param snap   snapping mode (see vedit.h)
@@ -66,10 +66,6 @@ int Digit::AddLine(int type, std::vector<double> coords, int layer, int cat,
 	return -1;
     }
 
-    if (layer < -1) {
-	return -1;
-    }
-
     BgMap = NULL;
     nbgmaps = 0;
     if (bgmap && strlen(bgmap) > 0) {
@@ -85,10 +81,12 @@ int Digit::AddLine(int type, std::vector<double> coords, int layer, int cat,
     Points = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
 
-    Vect_cat_set(Cats, layer, cat);
+    if (layer > 0) {
+      Vect_cat_set(Cats, layer, cat);
 
-    if (cat > GetCategory(layer)) {
-	SetCategory(layer, cat); /* set up max category for layer */
+      if (cat > GetCategory(layer)) {
+	  SetCategory(layer, cat); /* set up max category for layer */
+      }
     }
 
     i = 0;