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

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Dec 13 11:44:33 EST 2008


Author: martinl
Date: 2008-12-13 11:44:33 -0500 (Sat, 13 Dec 2008)
New Revision: 34851

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
   grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp
   grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h
   grass/branches/develbranch_6/gui/wxpython/vdigit/driver_draw.cpp
   grass/branches/develbranch_6/gui/wxpython/vdigit/driver_select.cpp
Log:
wxGUI/vdigit: fix select features by cat (layer>1)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2008-12-13 16:16:54 UTC (rev 34850)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2008-12-13 16:44:33 UTC (rev 34851)
@@ -1094,7 +1094,7 @@
         if digitToolbar and digitToolbar.GetLayer() and \
                 digitToolbar.GetLayer().GetName() == self.vectmap:
 
-            self.mapdisplay.digit.driver.SetSelected(cats, cats=True)
+            self.mapdisplay.digit.driver.SetSelected(cats, field=self.layer)
             if zoom:
                 n, s, w, e = self.mapdisplay.digit.driver.GetRegionSelected()
                 self.mapdisplay.Map.GetRegion(n=n, s=s, w=w, e=e,
@@ -1904,7 +1904,7 @@
             digitToolbar = self.mapdisplay.toolbars['vdigit']
             if digitToolbar and digitToolbar.GetLayer() and \
                     digitToolbar.GetLayer().GetName() == self.vectmap:
-                self.mapdisplay.digit.driver.SetSelected(map(int, cats), cats=True)
+                self.mapdisplay.digit.driver.SetSelected(map(int, cats), field=self.layer)
                 self.mapdisplay.digit.DeleteSelectedLines()
             else:
                 gcmd.Command(['v.edit',

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2008-12-13 16:16:54 UTC (rev 34850)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2008-12-13 16:44:33 UTC (rev 34851)
@@ -913,16 +913,16 @@
 
         return id 
 
-    def SetSelected(self, id, cats=False):
+    def SetSelected(self, id, field=-1):
         """Set selected vector features
 
-        @param id line id to be selected
-        @param cats if True expect categories instead of feature ids
+        @param id list of feature ids/categories to be selected
+        @param field field(layer) number, -1 for ids instead of cats
         """
         Debug.msg(4, "CDisplayDriver.SetSelected(): id=%s" % \
                       id)
 
-        self.__display.SetSelected(id, cats)
+        self.__display.SetSelected(id, field)
 
     def UnSelect(self, id):
         """Unselect vector features

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp	2008-12-13 16:16:54 UTC (rev 34850)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp	2008-12-13 16:44:33 UTC (rev 34851)
@@ -42,7 +42,8 @@
     points = Vect_new_line_struct();
     pointsScreen = new wxList();
     cats = Vect_new_cats_struct();
-    
+
+    selected.field = -1;
     selected.cats = Vect_new_list();
     selected.ids = Vect_new_list();
     selected.idsDupl = Vect_new_list();

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h	2008-12-13 16:16:54 UTC (rev 34850)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h	2008-12-13 16:44:33 UTC (rev 34851)
@@ -48,9 +48,10 @@
      */
     
     struct _selected {
-	struct ilist *cats;
-	struct ilist *ids;
-	struct ilist *idsDupl;
+	int field;              // field number
+	struct ilist *cats;     // list of cats
+	struct ilist *ids;      // list of ids
+	struct ilist *idsDupl;  // list of duplicated features
     } selected;
     
     bool drawSelected;
@@ -191,7 +192,7 @@
     std::map<int, std::vector<double> > GetSelectedCoord();
     std::map<int, std::vector <int> > GetDuplicates();
     std::vector<double> GetRegionSelected();
-    int SetSelected(std::vector<int>, bool);
+    int SetSelected(std::vector<int>, int);
     int UnSelect(std::vector<int>);
     std::vector<int> GetSelectedVertex(double, double, double);
     void DrawSelected(bool);

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver_draw.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver_draw.cpp	2008-12-13 16:16:54 UTC (rev 34850)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver_draw.cpp	2008-12-13 16:44:33 UTC (rev 34851)
@@ -173,6 +173,7 @@
     /* reset list of selected features by cat 
        -> list of ids - see IsSelected()
     */
+    selected.field = -1;
     Vect_reset_list(selected.cats);
 	
     Vect_destroy_list(listLines);

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver_select.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver_select.cpp	2008-12-13 16:16:54 UTC (rev 34850)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver_select.cpp	2008-12-13 16:44:33 UTC (rev 34851)
@@ -196,7 +196,7 @@
     }
     else { /* select by cat */
 	for (int i = 0; i < cats->n_cats; i++) {
-	    if (cats->field[i] == 1 && /* TODO: field */
+	    if (cats->field[i] == selected.field &&
 		Vect_val_in_list(selected.cats, cats->cat[i])) {
 		/* remember id
 		   -> after drawing all features selected.cats is reseted */
@@ -337,19 +337,23 @@
 /**
    \brief Set selected vector objects
    
-   \param[in] list of GRASS ids to be set
-   \param[in] cat if True expect categories instead of feature ids
+   \param id list of feature ids to be set
+   \param field field number (-1 for ids instead of cats)
 
    \return 1
 */
-int DisplayDriver::SetSelected(std::vector<int> id, bool cat)
+int DisplayDriver::SetSelected(std::vector<int> id, int field)
 {
     drawSelected = true;
 
-    if (cat)
+    if (field > 0) {
+	selected.field = field;
 	VectorToList(selected.cats, id);
-    else
+    }
+    else {
+	field = -1;
 	VectorToList(selected.ids, id);
+    }
     
     if (id.size() < 1)
 	drawSegments = false;



More information about the grass-commit mailing list