aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
authorlecoanet2000-01-26 13:30:18 +0000
committerlecoanet2000-01-26 13:30:18 +0000
commite98c6305e596385d4b796f35dd21bc771873907e (patch)
tree4742ad54e8356ec8dfdb1b3104a475856ffe3515 /generic
parent8a239343fa7ddd89c0c30c10ed7c7ac11b54a2f0 (diff)
downloadtkzinc-e98c6305e596385d4b796f35dd21bc771873907e.zip
tkzinc-e98c6305e596385d4b796f35dd21bc771873907e.tar.gz
tkzinc-e98c6305e596385d4b796f35dd21bc771873907e.tar.bz2
tkzinc-e98c6305e596385d4b796f35dd21bc771873907e.tar.xz
Finalisation de ToArea.
Menage dans la structure d'item pour enlever les reliquats des anciennes fleches.
Diffstat (limited to 'generic')
-rw-r--r--generic/Curve.c139
1 files changed, 64 insertions, 75 deletions
diff --git a/generic/Curve.c b/generic/Curve.c
index f1a836b..5942fda 100644
--- a/generic/Curve.c
+++ b/generic/Curve.c
@@ -70,7 +70,6 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
*
**********************************************************************************
*/
-
typedef struct _CurveItemStruct {
ItemStruct header;
@@ -95,8 +94,6 @@ typedef struct _CurveItemStruct {
/* Private data */
RadarImage tile;
RadarList dev_points;
- RadarList first_end_points;
- RadarList last_end_points;
RadarColorGradient gradient;
} CurveItemStruct, *CurveItem;
@@ -214,8 +211,6 @@ Init(Item item,
#endif
cv->dev_points = NULL;
- cv->first_end_points = NULL;
- cv->last_end_points = NULL;
cv->gradient = NULL;
/* Init attributes */
@@ -310,8 +305,6 @@ Clone(Item item)
WidgetInfo *wi = item->wi;
char *text;
- cv->first_end_points = NULL;
- cv->last_end_points = NULL;
cv->dev_points = NULL;
if (cv->gradient) {
@@ -376,12 +369,6 @@ Destroy(Item item)
if (cv->last_end) {
LineEndDelete(cv->last_end);
}
- if (cv->first_end_points) {
- RadarListFree(cv->first_end_points);
- }
- if (cv->last_end_points) {
- RadarListFree(cv->last_end_points);
- }
if (cv->gradient) {
RadarFreeColorGradient(cv->gradient);
}
@@ -611,13 +598,18 @@ ComputeCoordinates(Item item,
* Process all points, skipping adjacent points that transform
* to the same device location.
*/
- for (i = 0, j = 0; i < num_points; i++) {
- /* Compute device coordinates */
+ for (i = 0, j = 0; i < num_points; i++, j++) {
+ /* Compute device coordinates.
+ * Identical vertices are no longer skipped to allow a better control
+ * on Bezier curves and smoothing.
+ */
RadarTransformPoint(wi->current_transfo, &points[i], &dev_points[j]);
- if ((j == 0) || (dev_points[j].x != dev_points[j-1].x) ||
+ /*
+ if ((j == 0) || (dev_points[j].x != dev_points[j-1].x) ||
(dev_points[j].y != dev_points[j-1].y)) {
j++;
}
+ */
}
/*
@@ -746,7 +738,7 @@ ToArea(Item item,
RadarBBox bbox;
RadarPoint *points;
RadarPoint end_points[LINE_END_POINTS];
- int num_points, result;
+ int num_points, result, result2;
RadarList actual_points;
if (cv->dev_points == NULL) {
@@ -770,82 +762,80 @@ ToArea(Item item,
if (ISSET(cv->flags, FILLED_OK)) {
result = PolygonInBBox(points, num_points, area);
- printf("filled = %d\n", result);
if (result == 0) {
return 0;
}
}
- else {
- result = -1;
- }
- printf("result1 = %d\n", result);
+
if (cv->line_width > 0) {
if (ISCLEAR(cv->flags, RELIEF_OK)) {
- if (PolylineInBBox(points, num_points, cv->line_width,
- cv->cap_style, cv->join_style, area) != result) {
- printf("overlap plain line\n");
- return 0;
- }
+ result2 = PolylineInBBox(points, num_points, cv->line_width,
+ cv->cap_style, cv->join_style, area);
}
else {
- if (PolygonReliefInBBox(actual_points, cv->line_width, area) != result) {
- printf("overlap relief\n");
+ result2 = PolygonReliefInBBox(actual_points, cv->line_width, area);
+ }
+ if (ISCLEAR(cv->flags, FILLED_OK)) {
+ if (result2 == 0) {
return 0;
}
+ result = result2;
}
- }
- printf("result2 = %d\n", result);
-
- /*
- * Check line ends.
- */
- if (ISSET(cv->flags, FIRST_END_OK)) {
- GetLineEnd(&points[0], &points[1], cv->line_width, cv->cap_style,
- cv->first_end, end_points);
- if (PolygonInBBox(end_points, LINE_END_POINTS, area) != result) {
- return 0;
- }
- }
- if (ISSET(cv->flags, LAST_END_OK)) {
- GetLineEnd(&points[num_points-1], &points[num_points-2], cv->line_width,
- cv->cap_style, cv->last_end, end_points);
- if (PolygonInBBox(end_points, LINE_END_POINTS, area) != result) {
+ else if (result2 != result) {
return 0;
}
- }
-
- /*
- * Last, check markers
- */
- if (ISSET(cv->flags, MARKER_OK)) {
- int num_points, width, height;
- RadarPoint *points;
-
- points = (RadarPoint *) RadarListArray(actual_points);
- num_points = RadarListSize(actual_points);
-
+
+ /*
+ * Check line ends.
+ */
if (ISSET(cv->flags, FIRST_END_OK)) {
- num_points--;
- points++;
- }
- if (ISSET(cv->flags, LAST_END_OK) ||
- ((points[0].x == points[num_points-1].x) &&
- (points[0].y == points[num_points-1].y))) {
- num_points--;
+ GetLineEnd(&points[0], &points[1], cv->line_width, cv->cap_style,
+ cv->first_end, end_points);
+ if (PolygonInBBox(end_points, LINE_END_POINTS, area) != result) {
+ return 0;
+ }
}
-
- Tk_SizeOfBitmap(wi->dpy, cv->marker, &width, &height);
- for (; num_points > 0; num_points--, points++) {
- bbox.orig.x = points->x - (width+1)/2;
- bbox.orig.y = points->y - (height+1)/2;
- bbox.corner.x = bbox.orig.x + width;
- bbox.corner.y = bbox.orig.y + height;
- if (BBoxInBBox(&bbox, area) != result) {
+ if (ISSET(cv->flags, LAST_END_OK)) {
+ GetLineEnd(&points[num_points-1], &points[num_points-2], cv->line_width,
+ cv->cap_style, cv->last_end, end_points);
+ if (PolygonInBBox(end_points, LINE_END_POINTS, area) != result) {
return 0;
}
}
+
+ /*
+ * Last, check markers
+ */
+ if (ISSET(cv->flags, MARKER_OK)) {
+ int num_points, width, height;
+ RadarPoint *points;
+
+ points = (RadarPoint *) RadarListArray(actual_points);
+ num_points = RadarListSize(actual_points);
+
+ if (ISSET(cv->flags, FIRST_END_OK)) {
+ num_points--;
+ points++;
+ }
+ if (ISSET(cv->flags, LAST_END_OK) ||
+ ((points[0].x == points[num_points-1].x) &&
+ (points[0].y == points[num_points-1].y))) {
+ num_points--;
+ }
+
+ Tk_SizeOfBitmap(wi->dpy, cv->marker, &width, &height);
+ for (; num_points > 0; num_points--, points++) {
+ bbox.orig.x = points->x - (width+1)/2;
+ bbox.orig.y = points->y - (height+1)/2;
+ bbox.corner.x = bbox.orig.x + width;
+ bbox.corner.y = bbox.orig.y + height;
+ if (BBoxInBBox(&bbox, area) != result) {
+ return 0;
+ }
+ }
+ }
}
-
+
return result;
}
@@ -1128,7 +1118,6 @@ Pick(Item item,
if (new_dist < dist) {
dist = new_dist;
}
-
if (dist <= 0.0) {
return 0.0;
}