[GRASS-SVN] r32159 - in grass/trunk/gui/wxpython: gui_modules vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jul 18 10:16:40 EDT 2008
Author: martinl
Date: 2008-07-18 10:16:39 -0400 (Fri, 18 Jul 2008)
New Revision: 32159
Modified:
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/vdigit/driver.cpp
grass/trunk/gui/wxpython/vdigit/driver.h
Log:
wxGUI/vdigit: isles filled in white
check for valid areas disabled by default
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-07-18 09:35:48 UTC (rev 32158)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-07-18 14:16:39 UTC (rev 32159)
@@ -207,7 +207,7 @@
'color' : (255, 20, 147, 255)
}, # deep pink
'symbolArea' : {
- 'enabled' : True,
+ 'enabled' : False,
'color' : (217, 255, 217, 255)
}, # green
'symbolDirection' : {
Modified: grass/trunk/gui/wxpython/vdigit/driver.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/driver.cpp 2008-07-18 09:35:48 UTC (rev 32158)
+++ grass/trunk/gui/wxpython/vdigit/driver.cpp 2008-07-18 14:16:39 UTC (rev 32159)
@@ -127,25 +127,34 @@
bool draw;
struct ilist *listAreas, *listCentroids;
struct line_pnts *points, *ipoints, **isles;
+ BOUND_BOX areaBox;
+ wxBrush *fillArea, *fillIsle;
+
+ fillArea = new wxBrush(settings.area.color);
+ fillIsle = new wxBrush(*wxWHITE_BRUSH);
+
listAreas = Vect_new_list();
listCentroids = Vect_new_list();
-
+
points = Vect_new_line_struct();
ipoints = NULL;
- Vect_select_areas_by_box(mapInfo, &(region.box),
+ Vect_select_areas_by_box(mapInfo, ®ion.box,
listAreas);
for (int i = 0; i < listAreas->n_values; i++) {
area = listAreas->value[i];
+
+ if (!Vect_area_alive (mapInfo, area))
+ return -1;
+
/* check for other centroids -- only area with one centroid is valid */
centroid = Vect_get_area_centroid(mapInfo, area);
if(centroid > 0) {
- Vect_get_area_points(mapInfo, area, points);
-
- num_isles = Vect_get_area_num_isles(mapInfo, area);
+ /* check for isles */
+ num_isles = Vect_get_area_num_isles(mapInfo, area); /* TODO */
if (num_isles < 1)
isles = NULL;
else
@@ -153,12 +162,37 @@
for (int j = 0; j < num_isles; j++) {
ipoints = Vect_new_line_struct();
isle = Vect_get_area_isle(mapInfo, area, j);
+
+ if (!Vect_isle_alive (mapInfo, isle))
+ return -1;
+
Vect_get_isle_points(mapInfo, isle, ipoints);
isles[j] = ipoints;
}
- Vect_select_lines_by_polygon(mapInfo, points,
- num_isles, isles, GV_CENTROID, listCentroids);
-
+
+ Vect_get_area_points(mapInfo, area, points);
+
+ /* avoid processing areas with large number of polygon points (ugly) */
+ if (points->n_points < 5000) {
+ Vect_select_lines_by_polygon(mapInfo, points,
+ num_isles, isles, GV_CENTROID, listCentroids);
+ }
+ else {
+ Vect_reset_list(listCentroids);
+ }
+
+ Vect_get_area_box(mapInfo, area, &areaBox);
+ if (areaBox.E > region.box.E && areaBox.W < region.box.W &&
+ areaBox.S < region.box.S && areaBox.N > region.box.N) {
+
+ Vect_reset_line(points);
+ Vect_append_point(points, region.box.W, region.box.N, 0.0);
+ Vect_append_point(points, region.box.E, region.box.N, 0.0);
+ Vect_append_point(points, region.box.E, region.box.S, 0.0);
+ Vect_append_point(points, region.box.W, region.box.S, 0.0);
+ Vect_append_point(points, region.box.W, region.box.N, 0.0);
+ }
+
draw = true;
for (int c = 0; c < listCentroids->n_values; c++) {
if(Vect_get_centroid_area(mapInfo, listCentroids->value[c]) < 0) {
@@ -168,11 +202,15 @@
}
if (draw) {
- DrawArea(area);
-
+ dc->SetBrush(*fillArea);
+ dc->SetPen(*wxTRANSPARENT_PEN);
+ DrawArea(points);
+
for (int j = 0; j < num_isles; j++) {
- isle = Vect_get_area_isle(mapInfo, area, j);
- // DrawIsle(isle) -> TODO
+ /* draw isles in white */
+ dc->SetBrush(*fillIsle);
+ dc->SetPen(*wxTRANSPARENT_PEN);
+ DrawArea(isles[j]);
}
}
@@ -186,6 +224,9 @@
}
}
+ delete fillArea;
+ delete fillIsle;
+
Vect_destroy_line_struct(points);
Vect_destroy_list(listAreas);
@@ -198,7 +239,7 @@
dc->EndDrawing();
// PrintIds();
-
+
Vect_destroy_list(listLines);
return listLines->n_values;
@@ -207,24 +248,15 @@
/**
\brief Draw area fill
- \param area area id
+ \param area boundary points
\return 1 on success
\return -1 on failure (vector object is dead, etc.)
*/
-int DisplayDriver::DrawArea(int area)
+int DisplayDriver::DrawArea(const line_pnts* points)
{
double x, y, z;
- struct line_pnts *points;
- if (!dc || !Vect_area_alive (mapInfo, area))
- return -1;
-
- points = Vect_new_line_struct();
-
- // get boundary points
- Vect_get_area_points(mapInfo, area, points);
-
// convert EN -> xy
wxPoint wxPoints[points->n_points];
@@ -235,12 +267,8 @@
}
// draw polygon
- dc->SetBrush(wxBrush(settings.area.color));
- dc->SetPen(wxPen(settings.area.color));
dc->DrawPolygon(points->n_points, wxPoints);
- Vect_destroy_line_struct(points);
-
return 1;
}
@@ -841,7 +869,11 @@
settings.area.enabled = eArea;
settings.area.color.Set(cArea);
-
+ settings.area.color.Set(settings.area.color.Red(),
+ settings.area.color.Green(),
+ settings.area.color.Blue(),
+ 100); /* transparency */
+
settings.direction.enabled = eDirection;
settings.direction.color.Set(cDirection);
Modified: grass/trunk/gui/wxpython/vdigit/driver.h
===================================================================
--- grass/trunk/gui/wxpython/vdigit/driver.h 2008-07-18 09:35:48 UTC (rev 32158)
+++ grass/trunk/gui/wxpython/vdigit/driver.h 2008-07-18 14:16:39 UTC (rev 32159)
@@ -147,7 +147,7 @@
int DrawLineNodes(int);
int DrawDirectionArrow();
- int DrawArea(int);
+ int DrawArea(const line_pnts *);
/* debug */
void PrintIds();
More information about the grass-commit
mailing list