[GRASS-SVN] r29933 - in grass/trunk/gui/wxpython: . gui_modules vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Feb 2 13:49:03 EST 2008


Author: martinl
Date: 2008-02-02 13:49:03 -0500 (Sat, 02 Feb 2008)
New Revision: 29933

Modified:
   grass/trunk/gui/wxpython/gui_modules/dbm.py
   grass/trunk/gui/wxpython/gui_modules/digit.py
   grass/trunk/gui/wxpython/gui_modules/location_wizard.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/utils.py
   grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
   grass/trunk/gui/wxpython/vdigit/cats.cpp
   grass/trunk/gui/wxpython/vdigit/digit.h
   grass/trunk/gui/wxpython/vdigit/driver.cpp
   grass/trunk/gui/wxpython/vdigit/line.cpp
   grass/trunk/gui/wxpython/vdigit/vertex.cpp
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: Various improvements in vdigit and v.edit interface.
Drop also attribute record when deleting vector objects (optional).
Select vector objects by click/box.
Fix moving vector objects, #29.
Various minor improvements.


Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py	2008-02-02 18:49:03 UTC (rev 29933)
@@ -2909,7 +2909,7 @@
             # use scrolled panel instead (and fix initial max height of the window to 480px)
             ### panel = wx.Panel(parent=self.notebook, id=wx.ID_ANY)
             panel = scrolled.ScrolledPanel(parent=self.notebook, id=wx.ID_ANY,
-                                           size=(-1, 300))
+                                           size=(-1, 150))
             panel.SetupScrolling(scroll_x=False)
             
             self.notebook.AddPage(page=panel, text=_(" %s %d ") % (_("Layer"), layer))
@@ -3001,7 +3001,7 @@
         """Check DB connection"""
         layerCommand = gcmd.Command(cmd=["v.db.connect",
                                          "-g", "--q",
-                                         "map=%s" % self.map,],
+                                         "map=%s" % self.map],
                                     rerr=None, stderr=None)
         if layerCommand.returncode != 0:
             return False

Modified: grass/trunk/gui/wxpython/gui_modules/digit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/digit.py	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/gui_modules/digit.py	2008-02-02 18:49:03 UTC (rev 29933)
@@ -107,6 +107,9 @@
             self.settings["layer"] = 1
             self.settings["category"] = 1
             self.settings["categoryMode"] = "Next to use"
+            
+            # delete existing feature(s)
+            self.settings["delRecord"] = True
 
             # query tool
             self.settings["query"]       = ("length", True)   # name, select by box
@@ -292,7 +295,7 @@
         @param input feature definition in GRASS ASCII format
         @param flags additional flags
         """
-        if self.settings['snapping'][0] <= 0:
+        if self.settings['snapping'][0] <= 0.0:
             snap = "no"
         else:
             if self.settings['snapToVertex']:
@@ -315,7 +318,7 @@
 
         # run the command
         Debug.msg(4, "VEdit.AddFeature(): input=%s" % input)
-        vedit = gcmd.Command(cmd=command, stdin=input)
+        vedit = gcmd.Command(cmd=command, stdin=input, stderr=None)
 
         # reload map (needed for v.edit)
         self.driver.ReloadMap()
@@ -332,13 +335,49 @@
         Debug.msg(4, "Digit.DeleteSelectedLines(): ids=%s" % \
                       ids)
 
+        # delete also attributes if requested
+        if self.settings['delRecord'] is True:
+            layerCommand = gcmd.Command(cmd=["v.db.connect",
+                                             "-g", "--q",
+                                             "map=%s" % self.map],
+                                        rerr=None, stderr=None)
+            if layerCommand.returncode == 0:
+                layers = {}
+                for line in layerCommand.ReadStdOutput():
+                    lineList = line.split(' ')
+                    layers[int(lineList[0])] = { "table"    : lineList[1],
+                                                 "key"      : lineList[2],
+                                                 "database" : lineList[3],
+                                                 "driver"   : lineList[4] }
+                for layer in layers.keys():
+                    printCats = gcmd.Command(['v.category',
+                                              '--q',
+                                              'input=%s' % self.map,
+                                              'layer=%d' % layer,
+                                              'option=print',
+                                              'id=%s' % ids])
+                    sql = 'DELETE FROM %s WHERE' % layers[layer]['table']
+                    n_cats = 0
+                    for cat in printCats.ReadStdOutput():
+                        for c in cat.split('/'):
+                            sql += ' cat = %d or' % int(c)
+                            n_cats += 1
+                    sql = sql.rstrip(' or')
+                    if n_cats > 0:
+                        gcmd.Command(['db.execute',
+                                      '--q',
+                                      'driver=%s' % layers[layer]['driver'],
+                                      'database=%s' % layers[layer]['database']],
+                                     stdin=sql,
+                                     rerr=None, stderr=None)
+
         command = [ "v.edit",
                     "map=%s" % self.map,
                     "tool=delete",
                     "ids=%s" % ids]
 
         # run the command
-        vedit = gcmd.Command(cmd=command)
+        vedit = gcmd.Command(cmd=command, stderr=None)
 
         # reload map (needed for v.edit)
         self.driver.ReloadMap()
@@ -401,7 +440,7 @@
             command.append("-1") # modify only first selected
                                              
         # run the command
-        vedit = gcmd.Command(cmd=command)
+        vedit = gcmd.Command(cmd=command, stderr=None)
 
         # reload map (needed for v.edit)
         self.driver.ReloadMap()
@@ -441,7 +480,7 @@
                    "thresh=%f" % self.driver.GetThreshold()]
 
         # run the command
-        vedit = gcmd.Command(cmd=command)
+        vedit = gcmd.Command(cmd=command, stderr=None)
 
         # reload map (needed for v.edit)
         self.driver.ReloadMap()
@@ -466,7 +505,7 @@
                    "thresh=%f" % self.driver.GetThreshold()]
 
         # run the command
-        vedit = gcmd.Command(cmd=command)
+        vedit = gcmd.Command(cmd=command, stderr=None)
 
         # redraw map
         self.driver.ReloadMap()
@@ -484,7 +523,7 @@
                                    '--q',
                                    'map=%s' % self.map,
                                    'tool=delete',
-                                   'ids=%s' % line])
+                                   'ids=%s' % line], stderr=None)
 
         # add line
         if len(coords) > 0:
@@ -767,7 +806,7 @@
 
         @return number of deleted lines
         """
-        nlines = self.digit.DeleteLines()
+        nlines = self.digit.DeleteLines(self.settings['delRecord'])
 
         return nlines
 
@@ -909,7 +948,11 @@
                       ",".join(["%d" % v for v in ids]))
         
         return ids
-    
+
+    def GetLineCats(self):
+        """Get layer/category pairs from given (selected) line"""
+        return self.digit.GetLineCats()
+        
     def __getSnapThreshold(self):
         """Get snap mode and threshold value
 
@@ -932,11 +975,13 @@
         """Default digit class"""
         def __init__(self, mapwindow):
             VEdit.__init__(self, mapwindow)
+            self.type = 'vedit'
 else:
     class Digit(VDigit):
         """Default digit class"""
         def __init__(self, mapwindow):
             VDigit.__init__(self, mapwindow)
+            self.type = 'vdigit'
 
 class AbstractDisplayDriver:
     """Abstract classs for display driver"""
@@ -1390,7 +1435,7 @@
         sizer.Add(item=flexSizer1, proportion=1, flag=wx.TOP | wx.LEFT | wx.EXPAND, border=1)
         sizer.Add(item=flexSizer2, proportion=1, flag=wx.TOP | wx.LEFT | wx.EXPAND, border=1)
         sizer.Add(item=vertexSizer, proportion=1, flag=wx.BOTTOM | wx.LEFT | wx.EXPAND, border=1)
-        border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)
+        border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
 
         #
         # attributes
@@ -1436,11 +1481,21 @@
         sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1)
         border.Add(item=sizer, proportion=0,
                    flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
+        # delete existing feature
+        box   = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Delete existing feature(s)"))
+        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+        # checkbox
+        self.deleteRecord = wx.CheckBox(parent=panel, id=wx.ID_ANY,
+                                        label=_("Delete record from table"))
+        self.deleteRecord.SetValue(self.parent.digit.settings["delRecord"])
+        sizer.Add(item=self.deleteRecord, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)
+        border.Add(item=sizer, proportion=0,
+                   flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
 
         # bindings
         self.Bind(wx.EVT_CHECKBOX, self.OnChangeAddRecord, self.addRecord)
         self.Bind(wx.EVT_COMBOBOX, self.OnChangeCategoryMode, self.categoryMode)
-        
+
         panel.SetSizer(border)
         
         return panel
@@ -1660,6 +1715,9 @@
             self.parent.digit.settings["category"] = int(self.category.GetValue())
         self.parent.digit.settings["categoryMode"] = self.categoryMode.GetValue()
 
+        # delete existing feature
+        self.parent.digit.settings["delRecord"] = self.deleteRecord.IsChecked()
+
         # threshold
         try:
             self.parent.digit.threshold = self.parent.digit.driver.GetThreshold()
@@ -1686,9 +1744,17 @@
 class DigitCategoryDialog(wx.Dialog, listmix.ColumnSorterMixin):
     """
     Dialog used to display/modify categories of vector objects
+    
+    @param parent
+    @param title dialog title
+    @param query {coordinates, qdist}    - v.edit/v.what
+    @param cats  directory of categories - vdigit
+    @param line  line id                 - vdigit
+    @param pos
+    @param style
     """
     def __init__(self, parent, title,
-                 map, queryCoords, qdist,
+                 map, query=None, cats=None, line=None,
                  pos=wx.DefaultPosition,
                  style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
 
@@ -1705,9 +1771,13 @@
         self.cats = {}
 
         # do not display dialog if no line is found (-> self.cats)
-        if self.__GetCategories(queryCoords, qdist) == 0 or not self.line:
-            Debug.msg(3, "DigitCategoryDialog(): nothing found!")
-            return
+        if cats is None:
+            if self.__GetCategories(query[0], query[1]) == 0 or not self.line:
+                Debug.msg(3, "DigitCategoryDialog(): nothing found!")
+                return
+        else:
+            self.cats = cats
+            self.line = line
         
         # make copy of cats (used for 'reload')
         self.cats_orig = copy.deepcopy(self.cats)
@@ -2038,9 +2108,11 @@
         """Get id of selected line of 'None' if no line is selected"""
         return self.line
 
-    def UpdateDialog(self, queryCoords, qdist):
+    def UpdateDialog(self, query=None, cats=None, line=None):
         """Update dialog
         
+        @param query {coordinates, distance} - v.edit/v.what
+        @param cats  directory layer/cats    - vdigit
         Return True if updated otherwise False
         """
 
@@ -2051,7 +2123,13 @@
         self.cats = {}
 
         # do not display dialog if no line is found (-> self.cats)
-        if self.__GetCategories(queryCoords, qdist) == 0 or not self.line:
+        if cats is None:
+            ret = self.__GetCategories(query[0], query[1])
+        else:
+            self.cats = cats
+            ret = 1
+            self.line = line
+        if ret == 0 or not self.line:
             Debug.msg(3, "DigitCategoryDialog(): nothing found!")
             return False
         

Modified: grass/trunk/gui/wxpython/gui_modules/location_wizard.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/location_wizard.py	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/gui_modules/location_wizard.py	2008-02-02 18:49:03 UTC (rev 29933)
@@ -115,7 +115,7 @@
 
         self.SetAutoLayout(True)
         self.SetSizer(tmpsizer)
-        tmpsizer.Fit(self)
+        # tmpsizer.Fit(self)
         self.Layout()
 
 class DatabasePage(TitledPage):

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-02-02 18:49:03 UTC (rev 29933)
@@ -951,9 +951,12 @@
 
             elif digitToolbar.action in ["moveLine", "moveVertex", "editLine"] and \
                     not hasattr(self, "moveBegin"):
-                self.moveBegin = [0, 0]
-                self.moveCoords = self.Pixel2Cell(self.mouse['begin'])
-                self.moveIds   = []
+                # incremental value
+                self.moveBegin = [0, 0] 
+                # geographic coordinates of initial position (self.mouse['end'])
+                self.moveCoords = []
+                # list of ids to modify    
+                self.moveIds   = [] 
                 if digitToolbar.action in ["moveVertex", "editLine"]:
                     # set pen
                     self.pen = self.polypen = wx.Pen(colour=digitClass.settings["symbolHighlight"][1],
@@ -992,18 +995,32 @@
                             digitToolbar.attributesDialog.Hide()
 
                 else: # displayCats
+                    coords = (east, north)
                     if digitToolbar.categoryDialog is None:
                         # open new dialog
-                        digitToolbar.categoryDialog = DigitCategoryDialog(parent=self,
-                                                                          map=map,
-                                                                          queryCoords=(east, north),
-                                                                          qdist=qdist,
-                                                                          pos=posWindow,
-                                                                          title=_("Update categories"))
+                        if digitClass.type == 'vedit':
+                            digitToolbar.categoryDialog = DigitCategoryDialog(parent=self,
+                                                                              map=map,
+                                                                              query=(coords, qdist),
+                                                                              pos=posWindow,
+                                                                              title=_("Update categories"))
+                        else:
+                            if digitClass.driver.SelectLineByPoint(coords) is not None:
+                                print '#', digitClass.driver.GetSelected()[0], \
+                                    digitClass.GetLineCats()
+                                digitToolbar.categoryDialog = DigitCategoryDialog(parent=self,
+                                                                                  map=map,
+                                                                                  cats=digitClass.GetLineCats(),
+                                                                                  line=digitClass.driver.GetSelected()[0],
+                                                                                  pos=posWindow,
+                                                                                  title=_("Update categories"))
+                            
                     else:
                         # update currently open dialog
-                        digitToolbar.categoryDialog.UpdateDialog(queryCoords=(east, north),
-                                                                 qdist=qdist)
+                        if digitClass.type == 'vedit':
+                            digitToolbar.categoryDialog.UpdateDialog(query=(coords, qdist))
+                        else:
+                            digitToolbar.categoryDialog.UpdateDialog(cats=digitClass.GetLineCats())
 
                     line = digitToolbar.categoryDialog.GetLine()
                     redraw = False
@@ -1118,6 +1135,11 @@
             pos1 = self.Pixel2Cell(self.mouse['begin'])
             pos2 = self.Pixel2Cell(self.mouse['end'])
 
+            if hasattr(self, "moveBegin"):
+                self.moveCoords = pos2
+                # eliminate initial mouse moving efect
+                self.mouse['begin'] = self.mouse['end'] 
+
             if digitToolbar.action in ["deleteLine", "moveLine", "moveVertex",
                                        "copyCats", "editLine", "flipLine",
                                        "mergeLine", "snapLine",
@@ -1179,15 +1201,19 @@
                         digitClass.driver.SetSelected(selected)
 
                 else:
-                    # -> moveLine || deleteLine, etc. (select by box)
-                    nselected = digitClass.driver.SelectLinesByBox(pos1, pos2)
-
+                    # -> moveLine || deleteLine, etc. (select by point/box)
+                    if digitClass.driver.SelectLineByPoint(pos1) is not None:
+                        nselected = 1
+                    else:
+                        nselected = digitClass.driver.SelectLinesByBox(pos1, pos2)
+                    
                 if nselected > 0:
                     if digitToolbar.action in ["moveLine", "moveVertex"]:
                         # get pseudoDC id of objects which should be redrawn
                         if digitToolbar.action == "moveLine":
                             # -> move line
                             self.moveIds = digitClass.driver.GetSelected(grassId=False)
+                            print self.moveIds, nselected
 
                         elif digitToolbar.action == "moveVertex":
                             # -> move vertex
@@ -1201,7 +1227,6 @@
 
                 else: # no vector object found
                     self.UpdateMap(render=False, renderVector=False)
-                    pass
 
             elif digitToolbar.action in ["splitLine", "addVertex", "removeVertex"]:
                 pointOnLine = digitClass.driver.SelectLineByPoint(pos1,

Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py	2008-02-02 18:49:03 UTC (rev 29933)
@@ -57,6 +57,8 @@
     for item in dcmd:
         if 'map=' in item:
             mapname = item.split('=')[1]
+        elif 'input=' in item:
+            mapname = item.split('=')[1]
         elif 'red=' in item:
             mapname = item.split('=')[1]
         elif 'h_map=' in item:

Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2008-02-02 18:49:03 UTC (rev 29933)
@@ -1291,7 +1291,7 @@
             if len(line) == 0:
                 continue
 
-            if 'GRASS_INFO_PERCENT:' in line:
+            if 'GRASS_INFO_PERCENT' in line:
                 # 'GRASS_INFO_PERCENT: 10' -> value=10
                 value = int(line.split(':')[1].strip())
                 if value < 100:

Modified: grass/trunk/gui/wxpython/vdigit/cats.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/cats.cpp	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/vdigit/cats.cpp	2008-02-02 18:49:03 UTC (rev 29933)
@@ -121,3 +121,52 @@
 
   return 0;
 }
+
+/**
+   \brief Get list of layer/category(ies) for selected line.
+
+   \return list of layer/cats
+*/
+std::map<int, std::vector<int> > Digit::GetLineCats()
+{
+    std::map<int, std::vector<int> > lc;
+    int line, n_dblinks;
+    struct line_cats *Cats;
+    struct field_info *fi;
+
+    if (!display->mapInfo || display->selected->n_values < 1) {
+	return lc;
+    }
+
+    line = display->selected->value[0];
+
+    if (!Vect_line_alive(display->mapInfo, line)) {
+	return lc;
+    }
+
+    Cats = Vect_new_cats_struct();
+
+    if (Vect_read_line(display->mapInfo, NULL, Cats, line) < 0) {
+	Vect_destroy_cats_struct(Cats);
+	return lc;
+    }
+
+    n_dblinks = Vect_get_num_dblinks(display->mapInfo);
+
+    for (int dblink = 0; dblink < n_dblinks; dblink++) {
+	fi = Vect_get_dblink(display->mapInfo, dblink);
+	if (fi == NULL) {
+	    continue;
+	}
+	std::vector<int> cats;
+	lc[fi->number] = cats;
+    }
+
+    for (int i = 0; i < Cats->n_cats; i++) {
+	lc[Cats->field[i]].push_back(Cats->cat[i]);
+    }
+
+    Vect_destroy_cats_struct(Cats);
+
+    return lc;
+}

Modified: grass/trunk/gui/wxpython/vdigit/digit.h
===================================================================
--- grass/trunk/gui/wxpython/vdigit/digit.h	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/vdigit/digit.h	2008-02-02 18:49:03 UTC (rev 29933)
@@ -1,6 +1,10 @@
 #ifndef __DIGIT_H__
 #define __DIGIT_H__
 
+#define GSQL_MAX 4000
+
+#include <map>
+
 class Digit
 {
 private:
@@ -25,7 +29,7 @@
     int SplitLine(double, double, double,
 		  double);
 
-    int DeleteLines();
+    int DeleteLines(bool);
     int MoveLines(double, double, double,
 		  int, double);
     int FlipLines();
@@ -48,8 +52,8 @@
 					int, int, double);
 
     int CopyCats(std::vector<std::vector<int> >, std::vector<int>);
-
     int GetCategory(int);
+    std::map<int, std::vector<int> > GetLineCats();
 
 };
 

Modified: grass/trunk/gui/wxpython/vdigit/driver.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/driver.cpp	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/vdigit/driver.cpp	2008-02-02 18:49:03 UTC (rev 29933)
@@ -738,6 +738,8 @@
     struct ilist *list;
     struct line_pnts *bbox;
 
+    drawSegments = false;
+
     type = -1; // all types
 
     list = Vect_new_list();

Modified: grass/trunk/gui/wxpython/vdigit/line.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/line.cpp	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/vdigit/line.cpp	2008-02-02 18:49:03 UTC (rev 29933)
@@ -16,6 +16,7 @@
 
 extern "C" {
 #include <grass/vedit.h>
+#include <grass/dbmi.h>
 }
 #include "driver.h"
 #include "digit.h"
@@ -244,19 +245,98 @@
 /**
    \brief Delete selected vector features
 
+   \param delete_records delete also attribute records
+
    \return number of deleted lines
    \return -1 on error
 */
-int Digit::DeleteLines()
+int Digit::DeleteLines(bool delete_records)
 {
     int ret;
+    int n_dblinks;
+    struct line_cats *Cats, *Cats_del;
 
     if (!display->mapInfo) {
 	return -1;
     }
 
+    n_dblinks = Vect_get_num_dblinks(display->mapInfo);
+    Cats_del = NULL;
+
+    /* collect categories if needed */
+    if (delete_records) {
+	Cats = Vect_new_cats_struct();
+	Cats_del = Vect_new_cats_struct();
+	for (int i = 0; i < display->selected->n_values; i++) {
+	    if (Vect_read_line(display->mapInfo, NULL, Cats, display->selected->value[i]) < 0) {
+		Vect_destroy_cats_struct(Cats_del);
+		return -1;
+	    }
+	    for (int j = 0; j < Cats->n_cats; j++) {
+		Vect_cat_set(Cats_del, Cats->field[j], Cats->cat[j]);
+	    }
+	}
+	Vect_destroy_cats_struct(Cats);
+    }
+
     ret = Vedit_delete_lines(display->mapInfo, display->selected);
 
+    if (ret > 0 && delete_records) {
+	struct field_info *fi;
+	char buf[GSQL_MAX];
+	dbDriver *driver;
+	dbHandle handle;
+	dbString stmt;
+
+	for (int dblink = 0; dblink < n_dblinks; dblink++) {
+	    fi = Vect_get_dblink(display->mapInfo, dblink);
+	    if (fi == NULL) {
+		return -1;
+	    }
+
+	    driver = db_start_driver(fi->driver);
+	    if (driver == NULL) {
+		return -1;
+	    }
+
+	    db_init_handle (&handle);
+	    db_set_handle (&handle, fi->database, NULL);
+	    if (db_open_database(driver, &handle) != DB_OK) {
+		return -1;
+	    }
+
+	    db_init_string (&stmt);
+	    sprintf (buf, "DELETE FROM %s WHERE", fi->table);
+	    db_set_string(&stmt, buf);
+	    int n_cats = 0;
+	    for (int c = 0; c < Cats_del->n_cats; c++) {
+		if (Cats_del->field[c] == fi->number) {
+		    sprintf (buf, " %s = %d", fi->key, Cats_del->cat[c]);
+		    db_append_string(&stmt, buf);
+		    if (n_cats > 0) {
+			sprintf (buf, " or");
+			db_append_string(&stmt, buf);
+		    }
+		    n_cats++;
+		}
+	    }
+
+	    Vect_cat_del(Cats_del, fi->number);
+
+	    if (n_cats &&
+		db_execute_immediate (driver, &stmt) != DB_OK ) {
+		return -1;
+	    }
+	    
+	    db_close_database(driver);
+	    db_shutdown_driver(driver);
+	}
+    }
+
+    if (Cats_del) {
+	Vect_destroy_cats_struct(Cats_del);
+    }
+
     return ret;
 }
 

Modified: grass/trunk/gui/wxpython/vdigit/vertex.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/vertex.cpp	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/vdigit/vertex.cpp	2008-02-02 18:49:03 UTC (rev 29933)
@@ -50,7 +50,7 @@
 			    display->selected,
 			    point, thresh,
 			    move_x, move_y, move_z,
-			    1, (snap == SNAPVERTEX) ? 1 : 0); 
+			    1, snap); 
 
     Vect_destroy_line_struct(point);
 

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-02-02 18:33:34 UTC (rev 29932)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-02-02 18:49:03 UTC (rev 29933)
@@ -398,7 +398,6 @@
     def GetMenuCmd(self, event):
         """Get GRASS command from menu item
 
-
         Return command as a list"""
         cmd = self.menucmd[event.GetId()]
         try:
@@ -406,6 +405,13 @@
         except: # already list?
             cmdlist = cmd
 
+        layer = self.curr_page.maptree.layer_selected
+        name = self.curr_page.maptree.GetPyData(layer)[0]['maplayer'].name
+        type = self.curr_page.maptree.GetPyData(layer)[0]['type']
+        if type == 'raster' and cmdlist[0][0] == 'r' and cmdlist[0][1] != '3':
+            cmdlist.append(name) # TODO map/input=
+        elif type == 'vector' and cmdlist[0][0] == 'v':
+            cmdlist.append(name) # TODO map/input=
         return cmdlist
 
     def RunMenuCmd(self, event):



More information about the grass-commit mailing list