diff options
Diffstat (limited to 'generic/Curve.c')
-rw-r--r-- | generic/Curve.c | 1422 |
1 files changed, 711 insertions, 711 deletions
diff --git a/generic/Curve.c b/generic/Curve.c index 0b61722..261f242 100644 --- a/generic/Curve.c +++ b/generic/Curve.c @@ -1,8 +1,8 @@ /* * Curve.c -- Implementation of curve item. * - * Authors : Patrick Lecoanet. - * Creation date : Fri Mar 25 15:32:17 1994 + * Authors : Patrick Lecoanet. + * Creation date : Fri Mar 25 15:32:17 1994 * * $Id$ */ @@ -46,16 +46,16 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " /* * Bit offset of flags. */ -#define FILLED_BIT 1<<0 /* If the item is filled with color/pattern */ -#define MARKED_BIT 1<<1 /* If the vertices are marked by a symbol */ -#define CLOSED_BIT 1<<2 /* If the outline should be closed automatically */ -#define SMOOTH_RELIEF_BIT 1<<3 /* If the relief should be continuous (arc) or discrete (angle) */ +#define FILLED_BIT 1<<0 /* If the item is filled with color/pattern */ +#define MARKED_BIT 1<<1 /* If the vertices are marked by a symbol */ +#define CLOSED_BIT 1<<2 /* If the outline should be closed automatically */ +#define SMOOTH_RELIEF_BIT 1<<3 /* If the relief should be continuous (arc) or discrete (angle) */ -#define FIRST_END_OK 1<<6 -#define LAST_END_OK 1<<7 -#define FILLED_OK 1<<8 -#define RELIEF_OK 1<<10 -#define MARKER_OK 1<<12 +#define FIRST_END_OK 1<<6 +#define LAST_END_OK 1<<7 +#define FILLED_OK 1<<8 +#define RELIEF_OK 1<<10 +#define MARKER_OK 1<<12 /* @@ -66,34 +66,34 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " ********************************************************************************** */ typedef struct _CurveItemStruct { - ZnItemStruct header; + ZnItemStruct header; /* Public data */ - ZnPoly shape; + ZnPoly shape; unsigned short flags; - ZnImage marker; - ZnLineEnd first_end; /* These two are considered only if relief is flat */ - ZnLineEnd last_end; - ZnLineStyle line_style; /* This is considered only if relief is flat */ - int cap_style; - int join_style; - ZnReliefStyle relief; - ZnDim line_width; /* If 0 the path is not drawn, if <2 relief is flat */ - ZnGradient *fill_color; - ZnImage line_pattern; - ZnGradient *line_color; - ZnGradient *marker_color; - int fill_rule; - ZnImage tile; + ZnImage marker; + ZnLineEnd first_end; /* These two are considered only if relief is flat */ + ZnLineEnd last_end; + ZnLineStyle line_style; /* This is considered only if relief is flat */ + int cap_style; + int join_style; + ZnReliefStyle relief; + ZnDim line_width; /* If 0 the path is not drawn, if <2 relief is flat */ + ZnGradient *fill_color; + ZnImage line_pattern; + ZnGradient *line_color; + ZnGradient *marker_color; + int fill_rule; + ZnImage tile; /* Private data */ - ZnPoly outlines; - ZnGradient *gradient; - ZnTriStrip tristrip; - ZnPoint *grad_geo; + ZnPoly outlines; + ZnGradient *gradient; + ZnTriStrip tristrip; + ZnPoint *grad_geo; } CurveItemStruct, *CurveItem; -static ZnAttrConfig cv_attrs[] = { +static ZnAttrConfig cv_attrs[] = { { ZN_CONFIG_CAP_STYLE, "-capstyle", NULL, Tk_Offset(CurveItemStruct, cap_style), 0, ZN_COORDS_FLAG, False }, @@ -168,15 +168,15 @@ static ZnAttrConfig cv_attrs[] = { ********************************************************************************** */ static int -Init(ZnItem item, - int *argc, - Tcl_Obj *CONST *args[]) +Init(ZnItem item, + int *argc, + Tcl_Obj *CONST *args[]) { - ZnWInfo *wi = item->wi; - CurveItem cv = (CurveItem) item; - unsigned int i, num_points, count; - ZnPoint *p, *points; - char *controls; + ZnWInfo *wi = item->wi; + CurveItem cv = (CurveItem) item; + unsigned int i, num_points, count; + ZnPoint *p, *points; + char *controls; cv->outlines.num_contours = 0; cv->outlines.contours = NULL; @@ -201,7 +201,7 @@ Init(ZnItem item, return TCL_ERROR; } if (ZnParseCoordList(wi, (*args)[0], &points, - &controls, &num_points, NULL) == TCL_ERROR) { + &controls, &num_points, NULL) == TCL_ERROR) { return TCL_ERROR; } @@ -216,25 +216,25 @@ Init(ZnItem item, if (controls) { count = 0; if ((controls[0]) || (controls[num_points-1])) { - goto contr_err; + goto contr_err; } for (i = 1; i < num_points-1; i++) { - switch (controls[i]) { - case 'c': - count++; - if (count > 2) { - goto contr_err; - } - break; - case 0: - count = 0; - break; - default: - contr_err: - ZnFree(controls); - Tcl_AppendResult(wi->interp, " curve coords expected", NULL); - return TCL_ERROR; - } + switch (controls[i]) { + case 'c': + count++; + if (count > 2) { + goto contr_err; + } + break; + case 0: + count = 0; + break; + default: + contr_err: + ZnFree(controls); + Tcl_AppendResult(wi->interp, " curve coords expected", NULL); + return TCL_ERROR; + } } } /* @@ -284,11 +284,11 @@ Init(ZnItem item, ********************************************************************************** */ static void -Clone(ZnItem item) +Clone(ZnItem item) { - CurveItem cv = (CurveItem) item; - unsigned int i; - ZnContour *conts; + CurveItem cv = (CurveItem) item; + unsigned int i; + ZnContour *conts; if (cv->shape.num_contours) { @@ -301,12 +301,12 @@ Clone(ZnItem item) cv->shape.contours[i].cw = conts[i].cw; cv->shape.contours[i].points = ZnMalloc(conts[i].num_points*sizeof(ZnPoint)); memcpy(cv->shape.contours[i].points, conts[i].points, - conts[i].num_points*sizeof(ZnPoint)); + conts[i].num_points*sizeof(ZnPoint)); cv->shape.contours[i].controls = NULL; if (conts[i].controls) { - cv->shape.contours[i].controls = ZnMalloc(conts[i].num_points*sizeof(char)); - memcpy(cv->shape.contours[i].controls, conts[i].controls, - conts[i].num_points*sizeof(char)); + cv->shape.contours[i].controls = ZnMalloc(conts[i].num_points*sizeof(char)); + memcpy(cv->shape.contours[i].controls, conts[i].controls, + conts[i].num_points*sizeof(char)); } } } @@ -348,10 +348,10 @@ Clone(ZnItem item) ********************************************************************************** */ static void -Destroy(ZnItem item) +Destroy(ZnItem item) { - CurveItem cv = (CurveItem) item; - unsigned int i; + CurveItem cv = (CurveItem) item; + unsigned int i; /* * Need to free the control array here, it is only known @@ -410,32 +410,32 @@ Destroy(ZnItem item) ********************************************************************************** */ static void -SetRenderFlags(CurveItem cv) +SetRenderFlags(CurveItem cv) { ASSIGN(cv->flags, FILLED_OK, - ISSET(cv->flags, FILLED_BIT) && (cv->shape.num_contours >= 1)); + ISSET(cv->flags, FILLED_BIT) && (cv->shape.num_contours >= 1)); ASSIGN(cv->flags, RELIEF_OK, - (cv->relief != ZN_RELIEF_FLAT) && - (cv->shape.num_contours >= 1) && - (cv->line_width > 1)); + (cv->relief != ZN_RELIEF_FLAT) && + (cv->shape.num_contours >= 1) && + (cv->line_width > 1)); ASSIGN(cv->flags, MARKER_OK, - (cv->marker != ZnUnspecifiedImage) && - ISCLEAR(cv->flags, RELIEF_OK)); + (cv->marker != ZnUnspecifiedImage) && + ISCLEAR(cv->flags, RELIEF_OK)); ASSIGN(cv->flags, FIRST_END_OK, - (cv->first_end != NULL) && - (cv->shape.num_contours == 1) && (cv->shape.contours[0].num_points > 1) && - ISCLEAR(cv->flags, FILLED_BIT) && cv->line_width && - ISCLEAR(cv->flags, RELIEF_OK) && - ISCLEAR(cv->flags, CLOSED_BIT)); + (cv->first_end != NULL) && + (cv->shape.num_contours == 1) && (cv->shape.contours[0].num_points > 1) && + ISCLEAR(cv->flags, FILLED_BIT) && cv->line_width && + ISCLEAR(cv->flags, RELIEF_OK) && + ISCLEAR(cv->flags, CLOSED_BIT)); ASSIGN(cv->flags, LAST_END_OK, - (cv->last_end != NULL) && - (cv->shape.num_contours == 1) && (cv->shape.contours[0].num_points > 1) && - ISCLEAR(cv->flags, FILLED_BIT) && cv->line_width && - ISCLEAR(cv->flags, RELIEF_OK) && - ISCLEAR(cv->flags, CLOSED_BIT)); + (cv->last_end != NULL) && + (cv->shape.num_contours == 1) && (cv->shape.contours[0].num_points > 1) && + ISCLEAR(cv->flags, FILLED_BIT) && cv->line_width && + ISCLEAR(cv->flags, RELIEF_OK) && + ISCLEAR(cv->flags, CLOSED_BIT)); } @@ -447,15 +447,15 @@ SetRenderFlags(CurveItem cv) ********************************************************************************** */ static int -Configure(ZnItem item, - int argc, - Tcl_Obj *CONST argv[], - int *flags) +Configure(ZnItem item, + int argc, + Tcl_Obj *CONST argv[], + int *flags) { - ZnWInfo *wi = item->wi; - CurveItem cv = (CurveItem) item; - int status = TCL_OK; - XColor *color; + ZnWInfo *wi = item->wi; + CurveItem cv = (CurveItem) item; + int status = TCL_OK; + XColor *color; unsigned short alpha; status = ZnConfigureAttributes(wi, item, item, cv_attrs, argc, argv, flags); @@ -468,7 +468,7 @@ Configure(ZnItem item, if ((cv->relief != ZN_RELIEF_FLAT) && !cv->gradient) { color = ZnGetGradientColor(cv->line_color, 51.0, &alpha); cv->gradient = ZnGetReliefGradient(wi->interp, wi->win, - Tk_NameOfColor(color), alpha); + Tk_NameOfColor(color), alpha); if (cv->gradient == NULL) { status = TCL_ERROR; } @@ -486,9 +486,9 @@ Configure(ZnItem item, ********************************************************************************** */ static int -Query(ZnItem item, - int argc, - Tcl_Obj *CONST argv[]) +Query(ZnItem item, + int argc, + Tcl_Obj *CONST argv[]) { if (ZnQueryAttribute(item->wi->interp, item, cv_attrs, argv[0]) == TCL_ERROR) { return TCL_ERROR; @@ -498,14 +498,14 @@ Query(ZnItem item, } static void -UpdateTristrip(CurveItem cv, - ZnPoly *poly, - ZnBool revert) +UpdateTristrip(CurveItem cv, + ZnPoly *poly, + ZnBool revert) { - ZnCombineData *cdata, *cnext; - GLdouble v[3]; - unsigned int j, k; - int i; + ZnCombineData *cdata, *cnext; + GLdouble v[3]; + unsigned int j, k; + int i; //printf("UpdateTristrips sur %d\n", ((ZnItem) cv)->id); gluTessProperty(ZnTesselator.tess, GLU_TESS_WINDING_RULE, (GLdouble) cv->fill_rule); @@ -520,39 +520,39 @@ UpdateTristrip(CurveItem cv, */ if (!revert) { for (j = 0; j < poly->num_contours; j++){ - gluTessBeginContour(ZnTesselator.tess); - //printf("Début contour %d num_points %d\n", j, poly->contours[j].num_points); - for (k = 0; k < poly->contours[j].num_points; k++) { - /*printf("%g@%g ", poly->contours[j].points[k].x, poly->contours[j].points[k].y);*/ - v[0] = poly->contours[j].points[k].x; - v[1] = poly->contours[j].points[k].y; - v[2] = 0; - gluTessVertex(ZnTesselator.tess, v, &poly->contours[j].points[k]); - } - //printf("\n"); - gluTessEndContour(ZnTesselator.tess); + gluTessBeginContour(ZnTesselator.tess); + //printf("Début contour %d num_points %d\n", j, poly->contours[j].num_points); + for (k = 0; k < poly->contours[j].num_points; k++) { + /*printf("%g@%g ", poly->contours[j].points[k].x, poly->contours[j].points[k].y);*/ + v[0] = poly->contours[j].points[k].x; + v[1] = poly->contours[j].points[k].y; + v[2] = 0; + gluTessVertex(ZnTesselator.tess, v, &poly->contours[j].points[k]); + } + //printf("\n"); + gluTessEndContour(ZnTesselator.tess); } } else { for (j = 0; j < poly->num_contours; j++){ - gluTessBeginContour(ZnTesselator.tess); - //printf("revert Début contour %d num_points %d\n", j, poly->contours[j].num_points); - for (i = (int) (poly->contours[j].num_points-1); i >= 0; i--) { - /*printf("%g@%g ", poly->contours[j].points[i].x, poly->contours[j].points[i].y);*/ - v[0] = poly->contours[j].points[i].x; - v[1] = poly->contours[j].points[i].y; - v[2] = 0; - gluTessVertex(ZnTesselator.tess, v, &poly->contours[j].points[i]); - } - //printf("\n"); - gluTessEndContour(ZnTesselator.tess); + gluTessBeginContour(ZnTesselator.tess); + //printf("revert Début contour %d num_points %d\n", j, poly->contours[j].num_points); + for (i = (int) (poly->contours[j].num_points-1); i >= 0; i--) { + /*printf("%g@%g ", poly->contours[j].points[i].x, poly->contours[j].points[i].y);*/ + v[0] = poly->contours[j].points[i].x; + v[1] = poly->contours[j].points[i].y; + v[2] = 0; + gluTessVertex(ZnTesselator.tess, v, &poly->contours[j].points[i]); + } + //printf("\n"); + gluTessEndContour(ZnTesselator.tess); } } gluTessEndPolygon(ZnTesselator.tess); cdata = ZnTesselator.combine_list; - //printf("Combine length: %d\n", ZnTesselator.combine_length); + //printf("Combine length: %d\n", ZnTesselator.combine_length); while (cdata) { - ZnTesselator.combine_length--; + ZnTesselator.combine_length--; cnext = cdata->next; ZnFree(cdata); cdata = cnext; @@ -563,14 +563,14 @@ UpdateTristrip(CurveItem cv, } static void -UpdateOutlines(CurveItem cv, - ZnPoly *poly, - ZnBool revert) +UpdateOutlines(CurveItem cv, + ZnPoly *poly, + ZnBool revert) { - ZnCombineData *cdata, *cnext; - GLdouble v[3]; - unsigned int j, k; - int i; + ZnCombineData *cdata, *cnext; + GLdouble v[3]; + unsigned int j, k; + int i; //printf("UpdateOutlines sur %d\n", ((ZnItem) cv)->id); gluTessProperty(ZnTesselator.tess, GLU_TESS_WINDING_RULE, (GLdouble) cv->fill_rule); @@ -586,32 +586,32 @@ UpdateOutlines(CurveItem cv, */ if (!revert) { for (j = 0; j < poly->num_contours; j++){ - gluTessBeginContour(ZnTesselator.tess); - for (k = 0; k < poly->contours[j].num_points; k++) { - v[0] = poly->contours[j].points[k].x; - v[1] = poly->contours[j].points[k].y; - v[2] = 0; - gluTessVertex(ZnTesselator.tess, v, &poly->contours[j].points[k]); - } - gluTessEndContour(ZnTesselator.tess); + gluTessBeginContour(ZnTesselator.tess); + for (k = 0; k < poly->contours[j].num_points; k++) { + v[0] = poly->contours[j].points[k].x; + v[1] = poly->contours[j].points[k].y; + v[2] = 0; + gluTessVertex(ZnTesselator.tess, v, &poly->contours[j].points[k]); + } + gluTessEndContour(ZnTesselator.tess); } } else { for (j = 0; j < poly->num_contours; j++){ - gluTessBeginContour(ZnTesselator.tess); - for (i = (int) (poly->contours[j].num_points-1); i >= 0; i--) { - v[0] = poly->contours[j].points[i].x; - v[1] = poly->contours[j].points[i].y; - v[2] = 0; - gluTessVertex(ZnTesselator.tess, v, &poly->contours[j].points[i]); - } - gluTessEndContour(ZnTesselator.tess); + gluTessBeginContour(ZnTesselator.tess); + for (i = (int) (poly->contours[j].num_points-1); i >= 0; i--) { + v[0] = poly->contours[j].points[i].x; + v[1] = poly->contours[j].points[i].y; + v[2] = 0; + gluTessVertex(ZnTesselator.tess, v, &poly->contours[j].points[i]); + } + gluTessEndContour(ZnTesselator.tess); } } gluTessEndPolygon(ZnTesselator.tess); cdata = ZnTesselator.combine_list; while (cdata) { - ZnTesselator.combine_length--; + ZnTesselator.combine_length--; cnext = cdata->next; ZnFree(cdata); cdata = cnext; @@ -630,20 +630,20 @@ UpdateOutlines(CurveItem cv, ********************************************************************************** */ static void -ComputeCoordinates(ZnItem item, - ZnBool force) +ComputeCoordinates(ZnItem item, + ZnBool force) { - ZnWInfo *wi = item->wi; - CurveItem cv = (CurveItem) item; - unsigned int i, j; - ZnPoint end_points[ZN_LINE_END_POINTS]; - ZnPoint *points; - unsigned int num_points, num_contours, segment_start; - ZnBBox bbox; - ZnDim lw; - ZnContour *c1, *c2; - ZnPoly dev; - ZnBool revert; + ZnWInfo *wi = item->wi; + CurveItem cv = (CurveItem) item; + unsigned int i, j; + ZnPoint end_points[ZN_LINE_END_POINTS]; + ZnPoint *points; + unsigned int num_points, num_contours, segment_start; + ZnBBox bbox; + ZnDim lw; + ZnContour *c1, *c2; + ZnPoly dev; + ZnBool revert; ZnResetBBox(&item->item_bounding_box); @@ -683,11 +683,11 @@ ComputeCoordinates(ZnItem item, * closed by the tesselator. */ if ((num_contours == 1) && - (c1->num_points > 2) && - ISSET(cv->flags, CLOSED_BIT) && - ((c1->points[0].x != c1->points[c1->num_points-1].x) || - (c1->points[0].y != c1->points[c1->num_points-1].y)) && - (c1->num_points > 2)) { + (c1->num_points > 2) && + ISSET(cv->flags, CLOSED_BIT) && + ((c1->points[0].x != c1->points[c1->num_points-1].x) || + (c1->points[0].y != c1->points[c1->num_points-1].y)) && + (c1->num_points > 2)) { c2->num_points++; } c2->points = ZnMalloc((c2->num_points)*sizeof(ZnPoint)); @@ -705,23 +705,23 @@ ComputeCoordinates(ZnItem item, ZnListAdd(ZnWorkPoints, &c2->points[0], ZnListTail); /*printf("moveto %g@%g\n", c2->points[0].x, c2->points[0].y);*/ for (j = 1; j < c1->num_points; j++) { - if (!c1->controls[j]) { - if (segment_start != j-1) { - /* traitement bezier */ - /*printf("arcto %g@%g %g@%g %g@%g\n", - c2->points[segment_start+1].x, c2->points[segment_start+1].y, - c2->points[j-1].x, c2->points[j-1].y, - c2->points[j].x, c2->points[j].y);*/ - ZnGetBezierPoints(&c2->points[segment_start], - &c2->points[segment_start+1], &c2->points[j-1], - &c2->points[j], ZnWorkPoints, 0.5); - } - else { - /*printf("lineto %g@%g\n", c2->points[j].x, c2->points[j].y);*/ - ZnListAdd(ZnWorkPoints, &c2->points[j], ZnListTail); - } - segment_start = j; - } + if (!c1->controls[j]) { + if (segment_start != j-1) { + /* traitement bezier */ + /*printf("arcto %g@%g %g@%g %g@%g\n", + c2->points[segment_start+1].x, c2->points[segment_start+1].y, + c2->points[j-1].x, c2->points[j-1].y, + c2->points[j].x, c2->points[j].y);*/ + ZnGetBezierPoints(&c2->points[segment_start], + &c2->points[segment_start+1], &c2->points[j-1], + &c2->points[j], ZnWorkPoints, 0.5); + } + else { + /*printf("lineto %g@%g\n", c2->points[j].x, c2->points[j].y);*/ + ZnListAdd(ZnWorkPoints, &c2->points[j], ZnListTail); + } + segment_start = j; + } } /* * Must test if the last point is a control and the contour @@ -729,9 +729,9 @@ ComputeCoordinates(ZnItem item, * multiple contours). */ if (c1->controls[c1->num_points-1]) { - ZnGetBezierPoints(&c2->points[segment_start], - &c2->points[segment_start+1], &c2->points[c1->num_points-1], - &c2->points[0], ZnWorkPoints, 0.5); + ZnGetBezierPoints(&c2->points[segment_start], + &c2->points[segment_start+1], &c2->points[c1->num_points-1], + &c2->points[0], ZnWorkPoints, 0.5); } /* @@ -740,12 +740,12 @@ ComputeCoordinates(ZnItem item, */ num_points =ZnListSize(ZnWorkPoints); if (c2->num_points != c1->num_points) { - num_points++; + num_points++; } c2->points = ZnRealloc(c2->points, num_points*sizeof(ZnPoint)); memcpy(c2->points, ZnListArray(ZnWorkPoints), num_points*sizeof(ZnPoint)); if (c2->num_points != c1->num_points) { - c2->points[num_points-1] = c2->points[0]; + c2->points[num_points-1] = c2->points[0]; } c2->num_points = num_points; } @@ -760,29 +760,29 @@ ComputeCoordinates(ZnItem item, if (cv->shape.contours[0].num_points > 2) { UpdateTristrip(cv, &dev, revert); /*if (!cv->tristrip.num_strips) { - int kk; - ZnPrintTransfo(wi->current_transfo); - printf("id: %d, NumCont: %d, NumPoints: %d, Original: %d, Resultat: %d, NumTri: %d\n", - item->id, num_contours,cv->shape.contours[0].num_points, - cv->shape.contours[0].cw, cw_dev_contour1, cv->tristrip.num_strips); - for (kk = 0; kk < cv->shape.contours[0].num_points; kk++) { - printf("%g@%g ", cv->shape.contours[0].points[kk].x, - cv->shape.contours[0].points[kk].y); - } - printf("\n"); - }*/ + int kk; + ZnPrintTransfo(wi->current_transfo); + printf("id: %d, NumCont: %d, NumPoints: %d, Original: %d, Resultat: %d, NumTri: %d\n", + item->id, num_contours,cv->shape.contours[0].num_points, + cv->shape.contours[0].cw, cw_dev_contour1, cv->tristrip.num_strips); + for (kk = 0; kk < cv->shape.contours[0].num_points; kk++) { + printf("%g@%g ", cv->shape.contours[0].points[kk].x, + cv->shape.contours[0].points[kk].y); + } + printf("\n"); + }*/ } ZnPolyContour1(&cv->outlines, dev.contours[0].points, dev.contours[0].num_points, - cv->shape.contours[0].cw); + cv->shape.contours[0].cw); } else { UpdateTristrip(cv, &dev, revert); /*if (!cv->tristrip.num_strips) { ZnPrintTransfo(wi->current_transfo); printf("id: %d, NumCont: %d, NumPoints: %d, Original: %d, Resultat: %d, NumTri: %d\n", - item->id, num_contours,cv->shape.contours[0].num_points, - cv->shape.contours[0].cw, cw_dev_contour1, cv->tristrip.num_strips); - }*/ + item->id, num_contours,cv->shape.contours[0].num_points, + cv->shape.contours[0].cw, cw_dev_contour1, cv->tristrip.num_strips); + }*/ UpdateOutlines(cv, &dev, revert); ZnPolyFree(&dev); } @@ -821,34 +821,34 @@ ComputeCoordinates(ZnItem item, c2 = cv->outlines.contours; for (j = 0; j < num_contours; j++, c2++) { if (c2->cw) { - continue; + continue; } if (cv->join_style == JoinMiter) { - ZnPoint miter_i, miter_o; - for (i = c2->num_points-1, points = c2->points; i >= 3; i--, points++) { - ZnGetMiterPoints(points, points+1, points+2, lw, &miter_i, &miter_o); - ZnAddPointToBBox(&item->item_bounding_box, miter_i.x, miter_i.y); - ZnAddPointToBBox(&item->item_bounding_box, miter_o.x, miter_o.y); - } + ZnPoint miter_i, miter_o; + for (i = c2->num_points-1, points = c2->points; i >= 3; i--, points++) { + ZnGetMiterPoints(points, points+1, points+2, lw, &miter_i, &miter_o); + ZnAddPointToBBox(&item->item_bounding_box, miter_i.x, miter_i.y); + ZnAddPointToBBox(&item->item_bounding_box, miter_o.x, miter_o.y); + } } /* * Add the markers. */ if (ISSET(cv->flags, MARKER_OK)) { - int w, h; - ZnBBox bbox; - - ZnSizeOfImage(cv->marker, &w, &h); - w = w/2 + 2; - h = h/2 + 2; - num_points = c2->num_points; - for (i = 0, points = c2->points; i < num_points; i++, points++) { - bbox.orig.x = points->x - w; - bbox.orig.y = points->y - h; - bbox.corner.x = points->x + w; - bbox.corner.y = points->y + h; - ZnAddBBoxToBBox(&item->item_bounding_box, &bbox); - } + int w, h; + ZnBBox bbox; + + ZnSizeOfImage(cv->marker, &w, &h); + w = w/2 + 2; + h = h/2 + 2; + num_points = c2->num_points; + for (i = 0, points = c2->points; i < num_points; i++, points++) { + bbox.orig.x = points->x - w; + bbox.orig.y = points->y - h; + bbox.corner.x = points->x + w; + bbox.corner.y = points->y + h; + ZnAddBBoxToBBox(&item->item_bounding_box, &bbox); + } } /* * Process arrows. @@ -856,14 +856,14 @@ ComputeCoordinates(ZnItem item, num_points = c2->num_points; points = c2->points; if (ISSET(cv->flags, FIRST_END_OK)) { - ZnGetLineEnd(&points[0], &points[1], lw, cv->cap_style, - cv->first_end, end_points); - ZnAddPointsToBBox(&item->item_bounding_box, end_points, ZN_LINE_END_POINTS); + ZnGetLineEnd(&points[0], &points[1], lw, cv->cap_style, + cv->first_end, end_points); + ZnAddPointsToBBox(&item->item_bounding_box, end_points, ZN_LINE_END_POINTS); } if (ISSET(cv->flags, LAST_END_OK)) { - ZnGetLineEnd(&points[num_points-1], &points[num_points-2], - lw, cv->cap_style, cv->last_end, end_points); - ZnAddPointsToBBox(&item->item_bounding_box, end_points, ZN_LINE_END_POINTS); + ZnGetLineEnd(&points[num_points-1], &points[num_points-2], + lw, cv->cap_style, cv->last_end, end_points); + ZnAddPointsToBBox(&item->item_bounding_box, end_points, ZN_LINE_END_POINTS); } } @@ -899,23 +899,23 @@ ComputeCoordinates(ZnItem item, ********************************************************************************** * * ToArea -- - * Tell if the object is entirely outside (-1), - * entirely inside (1) or in between (0). + * Tell if the object is entirely outside (-1), + * entirely inside (1) or in between (0). * ********************************************************************************** */ static int -ToArea(ZnItem item, - ZnToArea ta) +ToArea(ZnItem item, + ZnToArea ta) { - CurveItem cv = (CurveItem) item; - ZnBBox bbox, *area = ta->area; - ZnPoint *points; - ZnPoint triangle[3]; - ZnPoint end_points[ZN_LINE_END_POINTS]; - unsigned int i, j, num_points, stop; - int width, height, result=-1, result2; - ZnBool first_done = False; + CurveItem cv = (CurveItem) item; + ZnBBox bbox, *area = ta->area; + ZnPoint *points; + ZnPoint triangle[3]; + ZnPoint end_points[ZN_LINE_END_POINTS]; + unsigned int i, j, num_points, stop; + int width, height, result=-1, result2; + ZnBool first_done = False; if (cv->outlines.num_contours == 0) { return -1; @@ -930,31 +930,31 @@ ToArea(ZnItem item, j = 0; stop = num_points-2; if (cv->tristrip.strips[i].fan) { - triangle[0] = points[0]; - j++; - points++; - stop++; + triangle[0] = points[0]; + j++; + points++; + stop++; } for (; j < stop; j++, points++) { - if (cv->tristrip.strips[i].fan) { - triangle[1] = points[0]; - triangle[2] = points[1]; - } - else { - triangle[0] = points[0]; - triangle[1] = points[1]; - triangle[2] = points[2]; - } - if (!first_done) { - first_done = True; - result = ZnPolygonInBBox(triangle, 3, area, NULL); - } - else { - result2 = ZnPolygonInBBox(triangle, 3, area, NULL); - if (result2 != result) { - return 0; - } - } + if (cv->tristrip.strips[i].fan) { + triangle[1] = points[0]; + triangle[2] = points[1]; + } + else { + triangle[0] = points[0]; + triangle[1] = points[1]; + triangle[2] = points[2]; + } + if (!first_done) { + first_done = True; + result = ZnPolygonInBBox(triangle, 3, area, NULL); + } + else { + result2 = ZnPolygonInBBox(triangle, 3, area, NULL); + if (result2 != result) { + return 0; + } + } } } } @@ -965,29 +965,29 @@ ToArea(ZnItem item, num_points = cv->outlines.contours[i].num_points; points = cv->outlines.contours[i].points; if (!first_done) { - first_done = True; - if (ISCLEAR(cv->flags, RELIEF_OK)) { - result = ZnPolylineInBBox(points, num_points, - cv->line_width, cv->cap_style, cv->join_style, area); - } - else { - result = ZnPolygonReliefInBBox(points, num_points, cv->line_width, area); - } - if (result == 0) { - return 0; - } + first_done = True; + if (ISCLEAR(cv->flags, RELIEF_OK)) { + result = ZnPolylineInBBox(points, num_points, + cv->line_width, cv->cap_style, cv->join_style, area); + } + else { + result = ZnPolygonReliefInBBox(points, num_points, cv->line_width, area); + } + if (result == 0) { + return 0; + } } else { - if (ISCLEAR(cv->flags, RELIEF_OK)) { - result2 = ZnPolylineInBBox(points, num_points, - cv->line_width, cv->cap_style, cv->join_style, area); - } - else { - result2 = ZnPolygonReliefInBBox(points, num_points, cv->line_width, area); - } - if (result2 != result) { - return 0; - } + if (ISCLEAR(cv->flags, RELIEF_OK)) { + result2 = ZnPolylineInBBox(points, num_points, + cv->line_width, cv->cap_style, cv->join_style, area); + } + else { + result2 = ZnPolygonReliefInBBox(points, num_points, cv->line_width, area); + } + if (result2 != result) { + return 0; + } } } @@ -998,16 +998,16 @@ ToArea(ZnItem item, num_points = cv->outlines.contours[0].num_points; if (ISSET(cv->flags, FIRST_END_OK)) { ZnGetLineEnd(&points[0], &points[1], cv->line_width, cv->cap_style, - cv->first_end, end_points); + cv->first_end, end_points); if (ZnPolygonInBBox(end_points, ZN_LINE_END_POINTS, area, NULL) != result) { - return 0; + return 0; } } if (ISSET(cv->flags, LAST_END_OK)) { ZnGetLineEnd(&points[num_points-1], &points[num_points-2], cv->line_width, - cv->cap_style, cv->last_end, end_points); + cv->cap_style, cv->last_end, end_points); if (ZnPolygonInBBox(end_points, ZN_LINE_END_POINTS, area, NULL) != result) { - return 0; + return 0; } } } @@ -1021,22 +1021,22 @@ ToArea(ZnItem item, num_points = cv->outlines.contours[i].num_points; if (ISSET(cv->flags, FIRST_END_OK)) { - num_points--; - points++; + num_points--; + points++; } if (ISSET(cv->flags, LAST_END_OK)) { - num_points--; + num_points--; } ZnSizeOfImage(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 (ZnBBoxInBBox(&bbox, area) != result) { - return 0; - } + 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 (ZnBBoxInBBox(&bbox, area) != result) { + return 0; + } } } } @@ -1053,15 +1053,15 @@ ToArea(ZnItem item, ********************************************************************************** */ static void -Draw(ZnItem item) +Draw(ZnItem item) { - ZnWInfo *wi = item->wi; - CurveItem cv = (CurveItem) item; - XGCValues values; - unsigned int i, j, num_points=0; - unsigned int gc_mask; - ZnPoint *points=NULL; - XPoint *xpoints=NULL; + ZnWInfo *wi = item->wi; + CurveItem cv = (CurveItem) item; + XGCValues values; + unsigned int i, j, num_points=0; + unsigned int gc_mask; + ZnPoint *points=NULL; + XPoint *xpoints=NULL; if ((cv->outlines.num_contours == 0) || (ISCLEAR(cv->flags, FILLED_OK) && @@ -1078,18 +1078,18 @@ Draw(ZnItem item) gc_mask = GCFillStyle; if (cv->tile != ZnUnspecifiedImage) { if (!ZnImageIsBitmap(cv->tile)) { /* Fill tiled */ - values.fill_style = FillTiled; - values.tile = ZnImagePixmap(cv->tile, wi->win); - values.ts_x_origin = ZnNearestInt(item->item_bounding_box.orig.x); - values.ts_y_origin = ZnNearestInt(item->item_bounding_box.orig.y); - gc_mask |= GCTileStipXOrigin|GCTileStipYOrigin|GCTile; + values.fill_style = FillTiled; + values.tile = ZnImagePixmap(cv->tile, wi->win); + values.ts_x_origin = ZnNearestInt(item->item_bounding_box.orig.x); + values.ts_y_origin = ZnNearestInt(item->item_bounding_box.orig.y); + gc_mask |= GCTileStipXOrigin|GCTileStipYOrigin|GCTile; } else { /* Fill stippled */ - values.fill_style = FillStippled; - values.stipple = ZnImagePixmap(cv->tile, wi->win); - values.ts_x_origin = ZnNearestInt(item->item_bounding_box.orig.x); - values.ts_y_origin = ZnNearestInt(item->item_bounding_box.orig.y); - gc_mask |= GCTileStipXOrigin|GCTileStipYOrigin|GCStipple|GCForeground; + values.fill_style = FillStippled; + values.stipple = ZnImagePixmap(cv->tile, wi->win); + values.ts_x_origin = ZnNearestInt(item->item_bounding_box.orig.x); + values.ts_y_origin = ZnNearestInt(item->item_bounding_box.orig.y); + gc_mask |= GCTileStipXOrigin|GCTileStipYOrigin|GCStipple|GCForeground; } } else { /* Fill solid */ @@ -1103,30 +1103,30 @@ Draw(ZnItem item) num_points = cv->tristrip.strips[i].num_points; points = cv->tristrip.strips[i].points; if (cv->tristrip.strips[i].fan) { - XPoint xpoints[3]; - xpoints[0].x = ZnNearestInt(points[0].x); - xpoints[0].y = ZnNearestInt(points[0].y); - xpoints[1].x = ZnNearestInt(points[1].x); - xpoints[1].y = ZnNearestInt(points[1].y); - for (j = 2; j < num_points; j++) { - xpoints[2].x = ZnNearestInt(points[j].x); - xpoints[2].y = ZnNearestInt(points[j].y); - XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, - xpoints, 3, Convex, CoordModeOrigin); - xpoints[1] = xpoints[2]; - } + XPoint xpoints[3]; + xpoints[0].x = ZnNearestInt(points[0].x); + xpoints[0].y = ZnNearestInt(points[0].y); + xpoints[1].x = ZnNearestInt(points[1].x); + xpoints[1].y = ZnNearestInt(points[1].y); + for (j = 2; j < num_points; j++) { + xpoints[2].x = ZnNearestInt(points[j].x); + xpoints[2].y = ZnNearestInt(points[j].y); + XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, + xpoints, 3, Convex, CoordModeOrigin); + xpoints[1] = xpoints[2]; + } } else { - ZnListAssertSize(ZnWorkXPoints, num_points); - xpoints = ZnListArray(ZnWorkXPoints); - for (j = 0; j < num_points; j++) { - xpoints[j].x = ZnNearestInt(points[j].x); - xpoints[j].y = ZnNearestInt(points[j].y); - } - for (j = 0; j < num_points-2; j++) { - XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, - &xpoints[j], 3, Convex, CoordModeOrigin); - } + ZnListAssertSize(ZnWorkXPoints, num_points); + xpoints = ZnListArray(ZnWorkXPoints); + for (j = 0; j < num_points; j++) { + xpoints[j].x = ZnNearestInt(points[j].x); + xpoints[j].y = ZnNearestInt(points[j].y); + } + for (j = 0; j < num_points-2; j++) { + XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, + &xpoints[j], 3, Convex, CoordModeOrigin); + } } } } @@ -1135,22 +1135,22 @@ Draw(ZnItem item) * Draw the lines between points */ if (cv->line_width) { - ZnPoint end_points[ZN_LINE_END_POINTS]; - XPoint xp[ZN_LINE_END_POINTS]; + ZnPoint end_points[ZN_LINE_END_POINTS]; + XPoint xp[ZN_LINE_END_POINTS]; /* * Drawing with relief disables: ends, line style and line pattern. */ if (ISSET(cv->flags, RELIEF_OK)) { for (j = 0; j < cv->outlines.num_contours; j++) { - num_points = cv->outlines.contours[j].num_points; - points = cv->outlines.contours[j].points; - /*printf("Draw: item %d, num_points %d %g@%g %g@%g, cw %d i/o %d\n", - item->id, - num_points, points[0].x, points[0].y, - points[num_points-1].x, points[num_points-1].y, - cv->outlines.contours[j].cw);*/ - ZnDrawPolygonRelief(wi, cv->relief, cv->gradient, points, num_points, cv->line_width); + num_points = cv->outlines.contours[j].num_points; + points = cv->outlines.contours[j].points; + /*printf("Draw: item %d, num_points %d %g@%g %g@%g, cw %d i/o %d\n", + item->id, + num_points, points[0].x, points[0].y, + points[num_points-1].x, points[num_points-1].y, + cv->outlines.contours[j].cw);*/ + ZnDrawPolygonRelief(wi, cv->relief, cv->gradient, points, num_points, cv->line_width); } } else { @@ -1160,48 +1160,48 @@ Draw(ZnItem item) values.join_style = cv->join_style; values.cap_style = cv->cap_style; if (cv->line_pattern == ZnUnspecifiedImage) { - values.fill_style = FillSolid; - XChangeGC(wi->dpy, wi->gc, - GCFillStyle|GCLineWidth|GCJoinStyle|GCCapStyle|GCForeground, &values); + values.fill_style = FillSolid; + XChangeGC(wi->dpy, wi->gc, + GCFillStyle|GCLineWidth|GCJoinStyle|GCCapStyle|GCForeground, &values); } else { - values.fill_style = FillStippled; - values.stipple = ZnImagePixmap(cv->line_pattern, wi->win); - XChangeGC(wi->dpy, wi->gc, - GCFillStyle|GCStipple|GCLineWidth|GCJoinStyle|GCCapStyle|GCForeground, - &values); + values.fill_style = FillStippled; + values.stipple = ZnImagePixmap(cv->line_pattern, wi->win); + XChangeGC(wi->dpy, wi->gc, + GCFillStyle|GCStipple|GCLineWidth|GCJoinStyle|GCCapStyle|GCForeground, + &values); } for (j = 0; j < cv->outlines.num_contours; j++) { - num_points = cv->outlines.contours[j].num_points; - points = cv->outlines.contours[j].points; - ZnListAssertSize(ZnWorkXPoints, num_points); - xpoints = ZnListArray(ZnWorkXPoints); - for (i = 0; i < num_points; i++) { - xpoints[i].x = ZnNearestInt(points[i].x); - xpoints[i].y = ZnNearestInt(points[i].y); - } - XDrawLines(wi->dpy, wi->draw_buffer, wi->gc, - xpoints, (int) num_points, CoordModeOrigin); + num_points = cv->outlines.contours[j].num_points; + points = cv->outlines.contours[j].points; + ZnListAssertSize(ZnWorkXPoints, num_points); + xpoints = ZnListArray(ZnWorkXPoints); + for (i = 0; i < num_points; i++) { + xpoints[i].x = ZnNearestInt(points[i].x); + xpoints[i].y = ZnNearestInt(points[i].y); + } + XDrawLines(wi->dpy, wi->draw_buffer, wi->gc, + xpoints, (int) num_points, CoordModeOrigin); } if (ISSET(cv->flags, FIRST_END_OK)) { - ZnGetLineEnd(&points[0], &points[1], cv->line_width, cv->cap_style, - cv->first_end, end_points); - for (i = 0; i < ZN_LINE_END_POINTS; i++) { - xp[i].x = (short) end_points[i].x; - xp[i].y = (short) end_points[i].y; - } - XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xp, ZN_LINE_END_POINTS, - Nonconvex, CoordModeOrigin); + ZnGetLineEnd(&points[0], &points[1], cv->line_width, cv->cap_style, + cv->first_end, end_points); + for (i = 0; i < ZN_LINE_END_POINTS; i++) { + xp[i].x = (short) end_points[i].x; + xp[i].y = (short) end_points[i].y; + } + XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xp, ZN_LINE_END_POINTS, + Nonconvex, CoordModeOrigin); } if (ISSET(cv->flags, LAST_END_OK)) { - ZnGetLineEnd(&points[num_points-1], &points[num_points-2], cv->line_width, - cv->cap_style, cv->last_end, end_points); - for (i = 0; i < ZN_LINE_END_POINTS; i++) { - xp[i].x = (short) end_points[i].x; - xp[i].y = (short) end_points[i].y; - } - XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xp, ZN_LINE_END_POINTS, - Nonconvex, CoordModeOrigin); + ZnGetLineEnd(&points[num_points-1], &points[num_points-2], cv->line_width, + cv->cap_style, cv->last_end, end_points); + for (i = 0; i < ZN_LINE_END_POINTS; i++) { + xp[i].x = (short) end_points[i].x; + xp[i].y = (short) end_points[i].y; + } + XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xp, ZN_LINE_END_POINTS, + Nonconvex, CoordModeOrigin); } } } @@ -1212,7 +1212,7 @@ Draw(ZnItem item) */ if (ISSET(cv->flags, MARKER_OK)) { unsigned int h_width, h_height, width, height; - int tmp_x, tmp_y; + int tmp_x, tmp_y; ZnSizeOfImage(cv->marker, &width, &height); h_width = (width+1)/2; @@ -1227,25 +1227,25 @@ Draw(ZnItem item) ZnListAssertSize(ZnWorkXPoints, num_points); xpoints = (XPoint *) ZnListArray(ZnWorkXPoints); for (i = 0; i < num_points; i++) { - xpoints[i].x = (short) ZnNearestInt(points[i].x); - xpoints[i].y = (short) ZnNearestInt(points[i].y); + xpoints[i].x = (short) ZnNearestInt(points[i].x); + xpoints[i].y = (short) ZnNearestInt(points[i].y); } if (ISSET(cv->flags, FIRST_END_OK)) { - num_points--; - points++; + num_points--; + points++; } if (ISSET(cv->flags, LAST_END_OK)) { - num_points--; + num_points--; } for (; num_points > 0; num_points--, points++) { - tmp_x = ((int) points->x) - h_width; - tmp_y = ((int) points->y) - h_height; - values.ts_x_origin = tmp_x; - values.ts_y_origin = tmp_y; - XChangeGC(wi->dpy, wi->gc, - GCTileStipXOrigin|GCTileStipYOrigin|GCForeground, &values); - XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, - tmp_x, tmp_y, width, height); + tmp_x = ((int) points->x) - h_width; + tmp_y = ((int) points->y) - h_height; + values.ts_x_origin = tmp_x; + values.ts_y_origin = tmp_y; + XChangeGC(wi->dpy, wi->gc, + GCTileStipXOrigin|GCTileStipYOrigin|GCForeground, &values); + XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, + tmp_x, tmp_y, width, height); } } } @@ -1261,11 +1261,11 @@ Draw(ZnItem item) */ #ifdef GL static void -CurveRenderCB(void *closure) +CurveRenderCB(void *closure) { - CurveItem cv = (CurveItem) closure; - unsigned int i, j, num_points; - ZnPoint *points; + CurveItem cv = (CurveItem) closure; + unsigned int i, j, num_points; + ZnPoint *points; for (i = 0; i < cv->tristrip.num_strips; i++) { num_points = cv->tristrip.strips[i].num_points; @@ -1286,12 +1286,12 @@ CurveRenderCB(void *closure) #ifdef GL static void -Render(ZnItem item) +Render(ZnItem item) { - ZnWInfo *wi = item->wi; - CurveItem cv = (CurveItem) item; - unsigned int j, num_points; - ZnPoint *points; + ZnWInfo *wi = item->wi; + CurveItem cv = (CurveItem) item; + unsigned int j, num_points; + ZnPoint *points; if ((cv->outlines.num_contours == 0) || (ISCLEAR(cv->flags, FILLED_OK) && @@ -1311,19 +1311,19 @@ Render(ZnItem item) if (ISSET(cv->flags, FILLED_OK)) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (!ZnGradientFlat(cv->fill_color)) { - ZnRenderGradient(wi, cv->fill_color, CurveRenderCB, cv, cv->grad_geo, - &cv->outlines); + ZnRenderGradient(wi, cv->fill_color, CurveRenderCB, cv, cv->grad_geo, + &cv->outlines); } else if (cv->tile != ZnUnspecifiedImage) { /* Fill tiled/stippled */ - ZnRenderTile(wi, cv->tile, cv->fill_color, CurveRenderCB, cv, - (ZnPoint *) &item->item_bounding_box); + ZnRenderTile(wi, cv->tile, cv->fill_color, CurveRenderCB, cv, + (ZnPoint *) &item->item_bounding_box); } else { - unsigned short alpha; - XColor *color = ZnGetGradientColor(cv->fill_color, 0.0, &alpha); - alpha = ZnComposeAlpha(alpha, wi->alpha); - glColor4us(color->red, color->green, color->blue, alpha); - CurveRenderCB(cv); + unsigned short alpha; + XColor *color = ZnGetGradientColor(cv->fill_color, 0.0, &alpha); + alpha = ZnComposeAlpha(alpha, wi->alpha); + glColor4us(color->red, color->green, color->blue, alpha); + CurveRenderCB(cv); } } @@ -1335,30 +1335,30 @@ Render(ZnItem item) * Drawing with relief disables: ends, line style and line pattern. */ if (ISSET(cv->flags, RELIEF_OK)) { - for (j = 0; j < cv->outlines.num_contours; j++) { - num_points = cv->outlines.contours[j].num_points; - points = cv->outlines.contours[j].points; - /*printf("Render: item %d, num_points %d %g@%g %g@%g, cw %d i/o %d\n", - item->id, - num_points, points[0].x, points[0].y, - points[num_points-1].x, points[num_points-1].y, - cv->outlines.contours[j].cw);*/ - ZnRenderPolygonRelief(wi, cv->relief, cv->gradient, - ISSET(cv->flags, SMOOTH_RELIEF_BIT), - points, num_points, cv->line_width); - } + for (j = 0; j < cv->outlines.num_contours; j++) { + num_points = cv->outlines.contours[j].num_points; + points = cv->outlines.contours[j].points; + /*printf("Render: item %d, num_points %d %g@%g %g@%g, cw %d i/o %d\n", + item->id, + num_points, points[0].x, points[0].y, + points[num_points-1].x, points[num_points-1].y, + cv->outlines.contours[j].cw);*/ + ZnRenderPolygonRelief(wi, cv->relief, cv->gradient, + ISSET(cv->flags, SMOOTH_RELIEF_BIT), + points, num_points, cv->line_width); + } } else { - ZnLineEnd first = ISSET(cv->flags, FIRST_END_OK) ? cv->first_end : NULL; - ZnLineEnd last = ISSET(cv->flags, LAST_END_OK) ? cv->last_end : NULL; - - for (j = 0; j < cv->outlines.num_contours; j++) { - ZnRenderPolyline(wi, - cv->outlines.contours[j].points, - cv->outlines.contours[j].num_points, - cv->line_width, cv->line_style, cv->cap_style, - cv->join_style, first, last, cv->line_color); - } + ZnLineEnd first = ISSET(cv->flags, FIRST_END_OK) ? cv->first_end : NULL; + ZnLineEnd last = ISSET(cv->flags, LAST_END_OK) ? cv->last_end : NULL; + + for (j = 0; j < cv->outlines.num_contours; j++) { + ZnRenderPolyline(wi, + cv->outlines.contours[j].points, + cv->outlines.contours[j].num_points, + cv->line_width, cv->line_style, cv->cap_style, + cv->join_style, first, last, cv->line_color); + } } } @@ -1367,28 +1367,28 @@ Render(ZnItem item) * if last point join first point suppress markers at end points. */ if (ISSET(cv->flags, MARKER_OK)) { - int i_width, i_height; - ZnReal r_width, r_height; - ZnPoint ptmp; + int i_width, i_height; + ZnReal r_width, r_height; + ZnPoint ptmp; ZnSizeOfImage(cv->marker, &i_width, &i_height); r_width = (i_width+1.0)/2.0; r_height = (i_height+1.0)/2.0; for (j = 0; j < cv->outlines.num_contours; j++) { - num_points = cv->outlines.contours[j].num_points; - points = cv->outlines.contours[j].points; - if (ISSET(cv->flags, FIRST_END_OK)) { - num_points--; - points++; - } - if (ISSET(cv->flags, LAST_END_OK)) { - num_points--; - } - for (; num_points > 0; num_points--, points++) { - ptmp.x = points->x - r_width; - ptmp.y = points->y - r_height; - ZnRenderIcon(wi, cv->marker, cv->marker_color, &ptmp, True); - } + num_points = cv->outlines.contours[j].num_points; + points = cv->outlines.contours[j].points; + if (ISSET(cv->flags, FIRST_END_OK)) { + num_points--; + points++; + } + if (ISSET(cv->flags, LAST_END_OK)) { + num_points--; + } + for (; num_points > 0; num_points--, points++) { + ptmp.x = points->x - r_width; + ptmp.y = points->y - r_height; + ZnRenderIcon(wi, cv->marker, cv->marker_color, &ptmp, True); + } } } #ifdef GL_LIST @@ -1400,7 +1400,7 @@ Render(ZnItem item) } #else static void -Render(ZnItem item) +Render(ZnItem item) { } #endif @@ -1414,11 +1414,11 @@ Render(ZnItem item) ********************************************************************************** */ static ZnBool -IsSensitive(ZnItem item, - int item_part) +IsSensitive(ZnItem item, + int item_part) { return (ISSET(item->flags, ZN_SENSITIVE_BIT) && - item->parent->class->IsSensitive(item->parent, ZN_NO_PART)); + item->parent->class->IsSensitive(item->parent, ZN_NO_PART)); } @@ -1430,17 +1430,17 @@ IsSensitive(ZnItem item, ********************************************************************************** */ static double -Pick(ZnItem item, - ZnPick ps) +Pick(ZnItem item, + ZnPick ps) { - CurveItem cv = (CurveItem) item; - ZnBBox bbox; - double dist=1.0e40, new_dist; - ZnPoint *points, *p = ps->point; - ZnPoint end_points[ZN_LINE_END_POINTS]; - ZnPoint triangle[3]; - unsigned int num_points, i, j, stop; - int width, height; + CurveItem cv = (CurveItem) item; + ZnBBox bbox; + double dist=1.0e40, new_dist; + ZnPoint *points, *p = ps->point; + ZnPoint end_points[ZN_LINE_END_POINTS]; + ZnPoint triangle[3]; + unsigned int num_points, i, j, stop; + int width, height; if (cv->outlines.num_contours == 0) { return dist; @@ -1454,28 +1454,28 @@ Pick(ZnItem item, j = 0; stop = num_points-2; if (cv->tristrip.strips[i].fan) { - triangle[0] = points[0]; - j++; - points++; - stop++; + triangle[0] = points[0]; + j++; + points++; + stop++; } for (; j < stop; j++, points++) { - if (cv->tristrip.strips[i].fan) { - triangle[1] = points[0]; - triangle[2] = points[1]; - } - else { - triangle[0] = points[0]; - triangle[1] = points[1]; - triangle[2] = points[2]; - } - new_dist = ZnPolygonToPointDist(triangle, 3, p); - if (new_dist < dist) { - dist = new_dist; - } - if (dist <= 0.0) { - return 0.0; - } + if (cv->tristrip.strips[i].fan) { + triangle[1] = points[0]; + triangle[2] = points[1]; + } + else { + triangle[0] = points[0]; + triangle[1] = points[1]; + triangle[2] = points[2]; + } + new_dist = ZnPolygonToPointDist(triangle, 3, p); + if (new_dist < dist) { + dist = new_dist; + } + if (dist <= 0.0) { + return 0.0; + } } } } @@ -1488,25 +1488,25 @@ Pick(ZnItem item, points = cv->outlines.contours[i].points; num_points = cv->outlines.contours[i].num_points; if (ISCLEAR(cv->flags, RELIEF_OK)) { - new_dist = ZnPolylineToPointDist(points, num_points, - cv->line_width, cv->cap_style, cv->join_style, p); - if (new_dist < dist) { - dist = new_dist; - } - if (dist <= 0.0) { - /*printf("dist %g\n", dist);*/ - return 0.0; - } + new_dist = ZnPolylineToPointDist(points, num_points, + cv->line_width, cv->cap_style, cv->join_style, p); + if (new_dist < dist) { + dist = new_dist; + } + if (dist <= 0.0) { + /*printf("dist %g\n", dist);*/ + return 0.0; + } } else { - new_dist = ZnPolygonReliefToPointDist(points, num_points, cv->line_width, p); - if (new_dist < dist) { - dist = new_dist; - } - if (dist <= 0.0) { - /*printf("dist %g\n", dist);*/ - return 0.0; - } + new_dist = ZnPolygonReliefToPointDist(points, num_points, cv->line_width, p); + if (new_dist < dist) { + dist = new_dist; + } + if (dist <= 0.0) { + /*printf("dist %g\n", dist);*/ + return 0.0; + } } } } @@ -1521,7 +1521,7 @@ Pick(ZnItem item, */ if (ISSET(cv->flags, FIRST_END_OK)) { ZnGetLineEnd(&points[0], &points[1], cv->line_width, cv->cap_style, - cv->first_end, end_points); + cv->first_end, end_points); new_dist = ZnPolygonToPointDist(end_points, ZN_LINE_END_POINTS, p); if (new_dist < dist) { dist = new_dist; @@ -1533,7 +1533,7 @@ Pick(ZnItem item, } if (ISSET(cv->flags, LAST_END_OK)) { ZnGetLineEnd(&points[num_points-1], &points[num_points-2], cv->line_width, - cv->cap_style, cv->last_end, end_points); + cv->cap_style, cv->last_end, end_points); new_dist = ZnPolygonToPointDist(end_points, ZN_LINE_END_POINTS, p); if (new_dist < dist) { dist = new_dist; @@ -1553,27 +1553,27 @@ Pick(ZnItem item, num_points = cv->outlines.contours[i].num_points; if (ISSET(cv->flags, FIRST_END_OK)) { - num_points--; - points++; + num_points--; + points++; } if (ISSET(cv->flags, LAST_END_OK)) { - num_points--; + num_points--; } ZnSizeOfImage(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; - new_dist = ZnRectangleToPointDist(&bbox, p); - if (new_dist < dist) { - dist = new_dist; - } - if (dist <= 0.0) { - /*printf("dist %g\n", dist);*/ - return 0.0; - } + 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; + new_dist = ZnRectangleToPointDist(&bbox, p); + if (new_dist < dist) { + dist = new_dist; + } + if (dist <= 0.0) { + /*printf("dist %g\n", dist);*/ + return 0.0; + } } } } @@ -1591,8 +1591,8 @@ Pick(ZnItem item, ********************************************************************************** */ static void -PostScript(ZnItem item, - ZnBool prepass) +PostScript(ZnItem item, + ZnBool prepass) { } @@ -1601,24 +1601,24 @@ PostScript(ZnItem item, ********************************************************************************** * * GetClipVertices -- - * Get the clipping shape. - * Never ever call ZnTriFree on the tristrip returned by GetClipVertices. + * Get the clipping shape. + * Never ever call ZnTriFree on the tristrip returned by GetClipVertices. * ********************************************************************************** */ static ZnBool -GetClipVertices(ZnItem item, - ZnTriStrip *tristrip) +GetClipVertices(ZnItem item, + ZnTriStrip *tristrip) { - CurveItem cv = (CurveItem) item; + CurveItem cv = (CurveItem) item; tristrip->num_strips = 0; if (cv->tristrip.num_strips == 1) { ZnTriStrip1(tristrip, - cv->tristrip.strips[0].points, - cv->tristrip.strips[0].num_points, - cv->tristrip.strips[0].fan); + cv->tristrip.strips[0].points, + cv->tristrip.strips[0].num_points, + cv->tristrip.strips[0].fan); } else if (cv->tristrip.num_strips > 1) { tristrip->num_strips = cv->tristrip.num_strips; @@ -1633,21 +1633,21 @@ GetClipVertices(ZnItem item, ********************************************************************************** * * GetContours -- - * Get the external contour(s). - * Never ever call ZnPolyFree on the poly returned by GetContours. + * Get the external contour(s). + * Never ever call ZnPolyFree on the poly returned by GetContours. * ********************************************************************************** */ static ZnBool -GetContours(ZnItem item, - ZnPoly *poly) +GetContours(ZnItem item, + ZnPoly *poly) { - CurveItem cv = (CurveItem) item; + CurveItem cv = (CurveItem) item; if (cv->outlines.num_contours == 1) { ZnPolyContour1(poly, cv->outlines.contours[0].points, - cv->outlines.contours[0].num_points, - cv->outlines.contours[0].cw); + cv->outlines.contours[0].num_points, + cv->outlines.contours[0].cw); } else if (cv->outlines.num_contours > 1) { poly->num_contours = cv->outlines.num_contours; @@ -1662,23 +1662,23 @@ GetContours(ZnItem item, ********************************************************************************** * * Coords -- - * Return or edit the item vertices. + * Return or edit the item vertices. * ********************************************************************************** */ static int -Coords(ZnItem item, - int contour, - int index, - int cmd, - ZnPoint **pts, - char **controls, - unsigned int *num_pts) +Coords(ZnItem item, + int contour, + int index, + int cmd, + ZnPoint **pts, + char **controls, + unsigned int *num_pts) { - CurveItem cv = (CurveItem) item; - unsigned int j, num_controls; - int i; - ZnContour *c=NULL; + CurveItem cv = (CurveItem) item; + unsigned int j, num_controls; + int i; + ZnContour *c=NULL; /*printf("contour %d, num_pts %d, index %d, cmd %d\n", contour, *num_pts, index, cmd);*/ @@ -1697,7 +1697,7 @@ Coords(ZnItem item, } if ((contour < 0) || ((unsigned int) contour >= cv->shape.num_contours)) { Tcl_AppendResult(item->wi->interp, - " curve contour index out of range", NULL); + " curve contour index out of range", NULL); return TCL_ERROR; } if (cv->shape.num_contours != 0) { @@ -1713,79 +1713,79 @@ Coords(ZnItem item, * is also legal, resulting in the contour being removed. */ if (*num_pts) { - if (c->points) { - ZnFree(c->points); - } - c->points = ZnMalloc(*num_pts*sizeof(ZnPoint)); - c->num_points = *num_pts; - memcpy(c->points, *pts, *num_pts*sizeof(ZnPoint)); - if (c->controls) { - ZnFree(c->controls); - c->controls = NULL; - } - if (*controls) { - c->controls = ZnMalloc(*num_pts*sizeof(char)); - memcpy(c->controls, *controls, *num_pts*sizeof(char)); - } + if (c->points) { + ZnFree(c->points); + } + c->points = ZnMalloc(*num_pts*sizeof(ZnPoint)); + c->num_points = *num_pts; + memcpy(c->points, *pts, *num_pts*sizeof(ZnPoint)); + if (c->controls) { + ZnFree(c->controls); + c->controls = NULL; + } + if (*controls) { + c->controls = ZnMalloc(*num_pts*sizeof(char)); + memcpy(c->controls, *controls, *num_pts*sizeof(char)); + } } } else { if (*num_pts == 0) { - Tcl_AppendResult(item->wi->interp, - " coords replace command need at least 1 point on curves", NULL); - return TCL_ERROR; + Tcl_AppendResult(item->wi->interp, + " coords replace command need at least 1 point on curves", NULL); + return TCL_ERROR; } if (index < 0) { - index += c->num_points; + index += c->num_points; } if ((index < 0) || ((unsigned int) index >= c->num_points)) { range_err: - Tcl_AppendResult(item->wi->interp, " coord index out of range", NULL); - return TCL_ERROR; + Tcl_AppendResult(item->wi->interp, " coord index out of range", NULL); + return TCL_ERROR; } /*printf("--->%g@%g\n", (*pts)[0].x, (*pts)[0].y);*/ c->points[index] = (*pts)[0]; if (!c->controls && *controls && (*controls)[0]) { - c->controls = ZnMalloc(c->num_points*sizeof(char)); - memset(c->controls, 0, c->num_points*sizeof(char)); + c->controls = ZnMalloc(c->num_points*sizeof(char)); + memset(c->controls, 0, c->num_points*sizeof(char)); } if (c->controls) { - if (!*controls) { - c->controls[index] = 0; - } - else { - if ((*controls)[0]) { - /* Check if the edit is allowable, there should be - * no more than 2 consecutive control points. The first - * point must not be a control and the last one can - * be one only if the curve is closed. - */ - num_controls = 0; - if (!index) { - control_first: - Tcl_AppendResult(item->wi->interp, " the first point must not be a control", NULL); - return TCL_ERROR; - } - else if ((unsigned int) index == c->num_points-1) { - if (ISCLEAR(cv->flags, CLOSED_BIT) && - (cv->shape.num_contours == 1)) { - control_last: - Tcl_AppendResult(item->wi->interp, " the last point must not be a control", NULL); - return TCL_ERROR; - } - } - else { - for (i = index-1; c->controls[i] && (i >= 0); i--, num_controls++); - } - for (j = index+1; c->controls[j] && (j < c->num_points); j++, num_controls++); - if (num_controls > 1) { - control_err: - Tcl_AppendResult(item->wi->interp, " too many consecutive control points in a curve", NULL); - return TCL_ERROR; - } - } - c->controls[index] = (*controls)[0]; - } + if (!*controls) { + c->controls[index] = 0; + } + else { + if ((*controls)[0]) { + /* Check if the edit is allowable, there should be + * no more than 2 consecutive control points. The first + * point must not be a control and the last one can + * be one only if the curve is closed. + */ + num_controls = 0; + if (!index) { + control_first: + Tcl_AppendResult(item->wi->interp, " the first point must not be a control", NULL); + return TCL_ERROR; + } + else if ((unsigned int) index == c->num_points-1) { + if (ISCLEAR(cv->flags, CLOSED_BIT) && + (cv->shape.num_contours == 1)) { + control_last: + Tcl_AppendResult(item->wi->interp, " the last point must not be a control", NULL); + return TCL_ERROR; + } + } + else { + for (i = index-1; c->controls[i] && (i >= 0); i--, num_controls++); + } + for (j = index+1; c->controls[j] && (j < c->num_points); j++, num_controls++); + if (num_controls > 1) { + control_err: + Tcl_AppendResult(item->wi->interp, " too many consecutive control points in a curve", NULL); + return TCL_ERROR; + } + } + c->controls[index] = (*controls)[0]; + } } } ZnITEM.Invalidate(item, ZN_COORDS_FLAG); @@ -1798,25 +1798,25 @@ Coords(ZnItem item, *num_pts = c->num_points; *pts = c->points; if (c->controls) { - *controls = c->controls; + *controls = c->controls; } } else { /* Special case for an empty contour. */ if (c->num_points == 0) { - *num_pts = 0; - return TCL_OK; + *num_pts = 0; + return TCL_OK; } if (index < 0) { - index += c->num_points; + index += c->num_points; } if ((index < 0) || ((unsigned int) index >= c->num_points)) { - goto range_err; + goto range_err; } *num_pts = 1; *pts = &c->points[index]; if (c->controls) { - *controls = &c->controls[index]; + *controls = &c->controls[index]; } } } @@ -1843,50 +1843,50 @@ Coords(ZnItem item, * be one only if the curve is closed. */ if ((index == 0) && (*controls)[0]) { - goto control_first; + goto control_first; } else if (((unsigned int) index == (c->num_points-1)) && - (*controls)[*num_pts-1] && - ISCLEAR(cv->flags, CLOSED_BIT) && - (cv->shape.num_contours == 1)) { - goto control_last; + (*controls)[*num_pts-1] && + ISCLEAR(cv->flags, CLOSED_BIT) && + (cv->shape.num_contours == 1)) { + goto control_last; } num_controls = 0; if (c->controls) { - if (index) { - for (i = index-1; c->controls[i] && (i >= 0); i--, num_controls++); - } + if (index) { + for (i = index-1; c->controls[i] && (i >= 0); i--, num_controls++); + } } /*printf("******* num controls: %d\n", num_controls);*/ for (j = 0; j < *num_pts; j++) { - if (!(*controls)[j]) { - num_controls = 0; - } - else { - num_controls++; - if (num_controls > 2) { - goto control_err; - } - } + if (!(*controls)[j]) { + num_controls = 0; + } + else { + num_controls++; + if (num_controls > 2) { + goto control_err; + } + } } /*printf("******* num controls(2): %d\n", num_controls);*/ if (c->controls) { - for (j = index; c->controls[j] && (j < c->num_points); j++, num_controls++); + for (j = index; c->controls[j] && (j < c->num_points); j++, num_controls++); } /*printf("******* num controls(3): %d\n", num_controls);*/ if (num_controls > 2) { - goto control_err; + goto control_err; } } c->points = ZnRealloc(c->points, (c->num_points+*num_pts)*sizeof(ZnPoint)); if (*controls || c->controls) { if (c->controls) { - c->controls = ZnRealloc(c->controls, (c->num_points+*num_pts)*sizeof(char)); + c->controls = ZnRealloc(c->controls, (c->num_points+*num_pts)*sizeof(char)); } else { - c->controls = ZnMalloc((c->num_points+*num_pts)*sizeof(char)); - memset(c->controls, 0, (c->num_points+*num_pts)*sizeof(char)); + c->controls = ZnMalloc((c->num_points+*num_pts)*sizeof(char)); + memset(c->controls, 0, (c->num_points+*num_pts)*sizeof(char)); } } /* @@ -1895,13 +1895,13 @@ Coords(ZnItem item, for (i = c->num_points-1; i >= index; i--) { c->points[i+*num_pts] = c->points[i]; if (c->controls) { - c->controls[i+*num_pts] = c->controls[i]; + c->controls[i+*num_pts] = c->controls[i]; } } for (j = 0; j < *num_pts; j++, index++) { c->points[index] = (*pts)[j]; if (c->controls) { - c->controls[index] = (*controls)?(*controls)[j]:0; + c->controls[index] = (*controls)?(*controls)[j]:0; } } c->num_points += *num_pts; @@ -1925,17 +1925,17 @@ Coords(ZnItem item, for (num_controls = 0, i = index-1; !c->controls[i]; i--, num_controls++); for (i = index+1; !c->controls[i]; i++, num_controls++); if (num_controls > 2) { - goto control_err; + goto control_err; } } c->num_points--; if ((c->num_points != 0) && ((unsigned int) index != c->num_points)) { for (j = index; j < c->num_points; j++) { - c->points[j] = c->points[j+1]; - if (c->controls) { - c->controls[j] = c->controls[j+1]; - } + c->points[j] = c->points[j+1]; + if (c->controls) { + c->controls[j] = c->controls[j+1]; + } } } c->points = ZnRealloc(c->points, (c->num_points)*sizeof(ZnPoint)); @@ -1953,19 +1953,19 @@ Coords(ZnItem item, ********************************************************************************** * * Contour -- - * Perform geometric operations on curve contours. + * Perform geometric operations on curve contours. * ********************************************************************************** */ static int -Contour(ZnItem item, - int cmd, - int index, - ZnPoly *poly) +Contour(ZnItem item, + int cmd, + int index, + ZnPoly *poly) { - CurveItem cv = (CurveItem) item; - unsigned int j, num_contours; - int i; + CurveItem cv = (CurveItem) item; + unsigned int j, num_contours; + int i; switch (cmd) { case ZN_CONTOUR_ADD: @@ -2005,11 +2005,11 @@ Contour(ZnItem item, cv->shape.contours[index].points = poly->contours[j].points; cv->shape.contours[index].controls = NULL; if (poly->contours[j].controls) { - /* - * The controls array in poly is shared, duplicate it - * to keep a locally owned copy. - */ - cv->shape.contours[index].controls = poly->contours[j].controls; + /* + * The controls array in poly is shared, duplicate it + * to keep a locally owned copy. + */ + cv->shape.contours[index].controls = poly->contours[j].controls; } } cv->shape.num_contours = num_contours; @@ -2032,10 +2032,10 @@ Contour(ZnItem item, else { ZnFree(cv->shape.contours[index].points); if (cv->shape.contours[index].controls) { - ZnFree(cv->shape.contours[index].controls); + ZnFree(cv->shape.contours[index].controls); } for (j = index; j < cv->shape.num_contours; j++) { - cv->shape.contours[j] = cv->shape.contours[j+1]; + cv->shape.contours[j] = cv->shape.contours[j+1]; } } ZnITEM.Invalidate(item, ZN_COORDS_FLAG); @@ -2050,24 +2050,24 @@ Contour(ZnItem item, ********************************************************************************** * * PickVertex -- - * Return in 'vertex' the vertex closest to p and in 'o_vertex' the - * opposite vertex on the closest edge, if such an edge exists or -1 - * in the other case. + * Return in 'vertex' the vertex closest to p and in 'o_vertex' the + * opposite vertex on the closest edge, if such an edge exists or -1 + * in the other case. * ********************************************************************************** */ static void -PickVertex(ZnItem item, - ZnPoint *p, - int *contour, - int *vertex, - int *o_vertex) +PickVertex(ZnItem item, + ZnPoint *p, + int *contour, + int *vertex, + int *o_vertex) { - CurveItem cv = (CurveItem) item; - unsigned int i, j, k, num_points; - ZnPoint *points, po; - ZnReal dist=1.0e40, new_dist, dist2; - ZnTransfo t, inv; + CurveItem cv = (CurveItem) item; + unsigned int i, j, k, num_points; + ZnPoint *points, po; + ZnReal dist=1.0e40, new_dist, dist2; + ZnTransfo t, inv; *contour = *vertex = *o_vertex = -1; @@ -2089,28 +2089,28 @@ PickVertex(ZnItem item, points = cv->shape.contours[i].points; num_points = cv->shape.contours[i].num_points; for (j = 0; j < num_points; j++) { - new_dist = hypot(points[j].x - po.x, points[j].y - po.y); - if (new_dist < dist) { - dist = new_dist; - *contour = i; - *vertex = j; - } + new_dist = hypot(points[j].x - po.x, points[j].y - po.y); + if (new_dist < dist) { + dist = new_dist; + *contour = i; + *vertex = j; + } } /* * If the closest vertex is in the current contour update * the opposite vertex. */ if (i == (unsigned int) *contour) { - j = (*vertex+1) % num_points; - new_dist = ZnLineToPointDist(&points[*vertex], &points[j], &po, NULL); - k = ((unsigned int)(*vertex-1)) % num_points; - dist2 = ZnLineToPointDist(&points[*vertex], &points[k], &po, NULL); - if (dist2 < new_dist) { - *o_vertex = k; - } - else { - *o_vertex = j; - } + j = (*vertex+1) % num_points; + new_dist = ZnLineToPointDist(&points[*vertex], &points[j], &po, NULL); + k = ((unsigned int)(*vertex-1)) % num_points; + dist2 = ZnLineToPointDist(&points[*vertex], &points[k], &po, NULL); + if (dist2 < new_dist) { + *o_vertex = k; + } + else { + *o_vertex = j; + } } } } @@ -2124,16 +2124,16 @@ PickVertex(ZnItem item, ********************************************************************************** */ static void -GetAnchor(ZnItem item, - Tk_Anchor anchor, - ZnPoint *p) +GetAnchor(ZnItem item, + Tk_Anchor anchor, + ZnPoint *p) { ZnBBox *bbox = &item->item_bounding_box; ZnOrigin2Anchor(&bbox->orig, - bbox->corner.x - bbox->orig.x, - bbox->corner.y - bbox->orig.y, - anchor, p); + bbox->corner.x - bbox->orig.x, + bbox->corner.y - bbox->orig.y, + anchor, p); } @@ -2148,25 +2148,25 @@ static ZnItemClassStruct CURVE_ITEM_CLASS = { "curve", sizeof(CurveItemStruct), cv_attrs, - 0, /* num_parts */ - 0, /* flags */ + 0, /* num_parts */ + 0, /* flags */ -1, Init, Clone, Destroy, Configure, Query, - NULL, /* GetFieldSet */ + NULL, /* GetFieldSet */ GetAnchor, GetClipVertices, GetContours, Coords, - NULL, /* InsertChars */ - NULL, /* DeleteChars */ - NULL, /* Cursor */ - NULL, /* Index */ - NULL, /* Part */ - NULL, /* Selection */ + NULL, /* InsertChars */ + NULL, /* DeleteChars */ + NULL, /* Cursor */ + NULL, /* Index */ + NULL, /* Part */ + NULL, /* Selection */ Contour, ComputeCoordinates, ToArea, @@ -2174,7 +2174,7 @@ static ZnItemClassStruct CURVE_ITEM_CLASS = { Render, IsSensitive, Pick, - PickVertex, /* PickVertex */ + PickVertex, /* PickVertex */ PostScript }; |