[GRASS-SVN] r33398 - in grass/branches/develbranch_6/gui/wxpython: gui_modules vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 11 02:36:14 EDT 2008


Author: martinl
Date: 2008-09-11 02:36:13 -0400 (Thu, 11 Sep 2008)
New Revision: 33398

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
   grass/branches/develbranch_6/gui/wxpython/vdigit/cats.cpp
   grass/branches/develbranch_6/gui/wxpython/vdigit/line.cpp
Log:
wxGUI: attribute dialog fixes
vdigit: start with category 1


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2008-09-11 06:11:22 UTC (rev 33397)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2008-09-11 06:36:13 UTC (rev 33398)
@@ -3189,7 +3189,10 @@
                     name, value = item.split(':')
                     name = name.strip()
                     # append value to the column
-                    value = self.tables[table][name]['ctype'] (value.strip())
+                    if len(value) < 1:
+                        value = None
+                    else:
+                        value = self.tables[table][name]['ctype'] (value.strip())
                     self.tables[table][name]['values'].append(value)
                 else:
                     if not data.has_key(key):

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-09-11 06:11:22 UTC (rev 33397)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-09-11 06:36:13 UTC (rev 33398)
@@ -1140,7 +1140,8 @@
                     else:
                         point = False
 
-                    if digitClass.AddPoint(map, point, east, north) < 0:
+                    fid = digitClass.AddPoint(map, point, east, north)
+                    if fid < 0:
                         return
 
                     self.UpdateMap(render=False) # redraw map
@@ -1148,9 +1149,10 @@
                     # add new record into atribute table
                     if UserSettings.Get(group='vdigit', key="addRecord", subkey='enabled')  is True:
                         # select attributes based on layer and category
-                        cats = {}
-                        cats[UserSettings.Get(group='vdigit', key="layer", subkey='value')] = \
-                                                              (UserSettings.Get(group='vdigit', key="category", subkey='value'), )
+                        cats = { fid : {
+                                UserSettings.Get(group='vdigit', key="layer", subkey='value') :
+                                    (UserSettings.Get(group='vdigit', key="category", subkey='value'), )
+                                }}
                         addRecordDlg = dbm.DisplayAttributesDialog(parent=self, map=map,
                                                                    cats=cats,
                                                                    pos=posWindow,
@@ -1763,7 +1765,8 @@
                     if len(self.polycoords) < 2: # ignore 'one-point' lines
                         return
                     
-                    if digitClass.AddLine(map, line, self.polycoords) < 0:
+                    fid = digitClass.AddLine(map, line, self.polycoords)
+                    if fid < 0:
                         return
                     
                     position = self.Cell2Pixel(self.polycoords[-1])
@@ -1776,9 +1779,11 @@
                                                          position[1] + self.dialogOffset))
 
                         # select attributes based on layer and category
-                        cats = {}
-                        cats[UserSettings.Get(group='vdigit', key="layer", subkey='value')] = \
-                                                              (UserSettings.Get(group='vdigit', key="category", subkey='value'), )
+                        cats = { fid : {
+                                UserSettings.Get(group='vdigit', key="layer", subkey='value') :
+                                    (UserSettings.Get(group='vdigit', key="category", subkey='value'), )
+                                }}
+
                         addRecordDlg = dbm.DisplayAttributesDialog(parent=self, map=map,
                                                                    cats=cats,
                                                                    pos=posWindow,

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2008-09-11 06:11:22 UTC (rev 33397)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2008-09-11 06:36:13 UTC (rev 33398)
@@ -124,8 +124,9 @@
                         return True
             else:
                 cat = self.digit.GetCategory(UserSettings.Get(group='vdigit', key='layer', subkey='value'))
+                cat += 1
                 UserSettings.Set(group='vdigit', key='category', subkey='value',
-                                  value=cat + 1)
+                                 value=cat)
     
     def SetCategory(self):
         """Return category number to use (according Settings)"""
@@ -820,7 +821,7 @@
         else:
             layer = UserSettings.Get(group='vdigit', key="layer", subkey='value')
             cat   = self.SetCategory()
-
+            
         if point:
             type = wxvdigit.GV_POINT 
         else:
@@ -1281,9 +1282,12 @@
         if units is None:
             units = UserSettings.Get(group='vdigit', key=type, subkey='units')
 
+        reg = self.mapwindow.Map.region
+        if value < 0:
+            value = (reg['nsres'] + reg['ewres']) / 2.
+        
         if units == "screen pixels":
             # pixel -> cell
-            reg = self.mapwindow.Map.region
             if reg['nsres'] > reg['ewres']:
                 res = reg['nsres']
             else:
@@ -1740,6 +1744,7 @@
                                          initial=UserSettings.Get(group='vdigit', key="snapping", subkey='value'),
                                          min=-1, max=1e6)
         self.snappingValue.Bind(wx.EVT_SPINCTRL, self.OnChangeSnappingValue)
+        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'))
@@ -2103,7 +2108,7 @@
             self.snappingInfo.SetLabel(_("Snapping disabled"))
         elif value < 0:
             self.snappingInfo.SetLabel(_("Snapping threshold is %(value).1f %(units)s "
-                                         "(based on computation resolution)") % 
+                                         "(based on comp. resolution)") % 
                                        {'value' : threshold,
                                         'units' : self.mapUnits.lower()})
         else:

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/cats.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/cats.cpp	2008-09-11 06:11:22 UTC (rev 33397)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/cats.cpp	2008-09-11 06:36:13 UTC (rev 33398)
@@ -75,7 +75,7 @@
     for(std::map<int, int>::const_iterator b = cats.begin(), e = cats.end();
 	b != e; ++b ) {
 	if (b->second == PORT_INT_MIN) {
-	    cats[b->first] = 0;
+	    cats[b->first] = 0; /* first category 1 */
 	    G_debug(3, "wxDigit.InitCats(): layer=%d, cat=%d", b->first, cats[b->first]);
 	}
 
@@ -89,7 +89,7 @@
 
    \param layer layer number
 
-   \return category number (1 if no category found)
+   \return category number (0 if no category found)
    \return -1 on error
 */
 int Digit::GetCategory(int layer)
@@ -99,7 +99,7 @@
 	return cats[layer];
     }
 
-    return -1;
+    return 0;
 }
 
 /**

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/line.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/line.cpp	2008-09-11 06:11:22 UTC (rev 33397)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/line.cpp	2008-09-11 06:36:13 UTC (rev 33398)
@@ -32,7 +32,7 @@
    \param snap   snapping mode (see vedit.h)
    \param thresh threshold value for snapping
 
-   \return 0 on success
+   \return fid on success
    \return -1 on failure
 */
 int Digit::AddLine(int type, std::vector<double> coords, int layer, int cat,
@@ -148,7 +148,7 @@
 	Vect_close(BgMap[0]);
     }
 
-    return 0;
+    return newline;
 }
 
 /**



More information about the grass-commit mailing list