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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Aug 21 10:22:29 EDT 2008


Author: martinl
Date: 2008-08-21 10:22:29 -0400 (Thu, 21 Aug 2008)
New Revision: 32976

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
   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: highlight areas instead of centroids if area fill is enabled
cosmetics in dbm module


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2008-08-21 14:12:59 UTC (rev 32975)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2008-08-21 14:22:29 UTC (rev 32976)
@@ -921,8 +921,8 @@
         menu.Append(self.popupDataID5, _("Select all"))
         menu.Append(self.popupDataID6, _("Deselect all"))
         menu.AppendSeparator()
-        menu.Append(self.popupDataID7, _("Display selected"))
-        menu.Append(self.popupDataID8, _("Display selected and zoom"))
+        menu.Append(self.popupDataID7, _("Highlight selected"))
+        menu.Append(self.popupDataID8, _("Highlight selected and zoom"))
         if not self.map or len(list.GetSelectedItems()) == 0:
             menu.Enable(self.popupDataID7, False)
             menu.Enable(self.popupDataID8, False)
@@ -2598,7 +2598,7 @@
                                    'table=%s' % table,
                                    'key=%s' % key,
                                    'layer=%d' % layer])
-
+        
         if connectCmd.returncode == 0:
             # update dialog (only for new layer)
             self.parentDialog.UpdateDialog(layer=layer) 

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h	2008-08-21 14:12:59 UTC (rev 32975)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h	2008-08-21 14:22:29 UTC (rev 32976)
@@ -148,7 +148,7 @@
     void PrintIds();
 
     /* select feature */
-    bool IsSelected(int);
+    bool IsSelected(int, bool force=false);
     bool IsDuplicated(int);
 
     std::vector<int> ListToVector(struct ilist *);

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver_draw.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver_draw.cpp	2008-08-21 14:12:59 UTC (rev 32975)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver_draw.cpp	2008-08-21 14:22:29 UTC (rev 32976)
@@ -62,9 +62,10 @@
 	struct ilist *listAreas, *listCentroids;
 	struct line_pnts *points, *ipoints, **isles;
 
-	wxBrush *fillArea, *fillIsle;
+	wxBrush *fillArea, *fillAreaSelected, *fillIsle;
 
 	fillArea = new wxBrush(settings.area.color);
+	fillAreaSelected = new wxBrush(settings.highlight);
 	fillIsle = new wxBrush(*wxWHITE_BRUSH);
 	
 	listAreas = Vect_new_list();
@@ -123,7 +124,14 @@
 		}
 		
 		if (draw) {
-		    dc->SetBrush(*fillArea);
+		    int cat;
+		    cat = Vect_get_area_cat(mapInfo, area, 1); /* TODO: field */
+		    if (cat > -1 && IsSelected(cat, true)) {
+			dc->SetBrush(*fillAreaSelected);
+		    }
+		    else {
+			dc->SetBrush(*fillArea);
+		    }
 		    dc->SetPen(*wxTRANSPARENT_PEN);
 		    DrawArea(points);
 

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver_select.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver_select.cpp	2008-08-21 14:12:59 UTC (rev 32975)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver_select.cpp	2008-08-21 14:22:29 UTC (rev 32976)
@@ -156,15 +156,15 @@
    \return true if vector object is selected
    \return false if vector object is not selected
 */
-bool DisplayDriver::IsSelected(int line)
+bool DisplayDriver::IsSelected(int line, bool force)
 {
-    if (selected.isId) {
+    if (selected.isId || force) {
 	if (Vect_val_in_list(selected.values, line))
 	    return true;
     }
     else {
 	for (int i = 0; i < cats->n_cats; i++) {
-	    if (cats->field[i] == 1 &&
+	    if (cats->field[i] == 1 && /* TODO: field */
 		Vect_val_in_list(selected.values, cats->cat[i])) 
 		return true;
 	}
@@ -415,6 +415,8 @@
 */
 std::vector<int> DisplayDriver::GetRegionSelected()
 {
+    int line, area;
+    
     std::vector<int> region;
 
     BOUND_BOX region_box, line_box;
@@ -454,11 +456,20 @@
     else {
 	list = selected.values;
     }
-    
+
     for (int i = 0; i < list->n_values; i++) {
-	if (!Vect_get_line_box(mapInfo, list->value[i], &line_box))
-	    continue;
+	line = list->value[i];
+	area = Vect_get_centroid_area(mapInfo, line);
 
+	if (area > 0) {
+	    if (!Vect_get_area_box(mapInfo, area, &line_box))
+		continue;
+	}
+	else {
+	    if (!Vect_get_line_box(mapInfo, line, &line_box))
+		continue;
+	}
+	
 	if (i == 0) {
 	    Vect_box_copy(&region_box, &line_box);
 	}
@@ -466,7 +477,7 @@
 	    Vect_box_extend(&region_box, &line_box);
 	}
     }
-
+    
     if (list && list != selected.values) {
 	Vect_destroy_list(list);
     }



More information about the grass-commit mailing list