aboutsummaryrefslogtreecommitdiff
path: root/generic/Arc.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/Arc.c')
-rw-r--r--generic/Arc.c674
1 files changed, 337 insertions, 337 deletions
diff --git a/generic/Arc.c b/generic/Arc.c
index 25f4e7b..9373d58 100644
--- a/generic/Arc.c
+++ b/generic/Arc.c
@@ -1,8 +1,8 @@
/*
* Arc.c -- Implementation of Arc item.
*
- * Authors : Patrick Lecoanet.
- * Creation date : Wed Mar 30 16:24:09 1994
+ * Authors : Patrick Lecoanet.
+ * Creation date : Wed Mar 30 16:24:09 1994
*
* $Id$
*/
@@ -43,13 +43,13 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
/*
* Bit offset of flags.
*/
-#define FILLED_BIT 1<<0 /* If the arc is filled with color/pattern */
-#define CLOSED_BIT 1<<1 /* If the arc outline is closed */
-#define PIE_SLICE_BIT 1<<2 /* If the arc is closed as a pie slice or a chord */
+#define FILLED_BIT 1<<0 /* If the arc is filled with color/pattern */
+#define CLOSED_BIT 1<<1 /* If the arc outline is closed */
+#define PIE_SLICE_BIT 1<<2 /* If the arc is closed as a pie slice or a chord */
-#define FIRST_END_OK 1<<3
-#define LAST_END_OK 1<<4
-#define USING_POLY_BIT 1<<5
+#define FIRST_END_OK 1<<3
+#define LAST_END_OK 1<<4
+#define USING_POLY_BIT 1<<5
static double Pick(ZnItem item, ZnPick ps);
@@ -63,31 +63,31 @@ static double Pick(ZnItem item, ZnPick ps);
**********************************************************************************
*/
typedef struct _ArcItemStruct {
- ZnItemStruct header;
+ ZnItemStruct header;
/* Public data */
- ZnPoint coords[2];
- int start_angle;
- int angle_extent;
- ZnImage line_pattern;
- ZnGradient *fill_color;
- ZnGradient *line_color;
- ZnDim line_width;
- ZnLineStyle line_style;
- ZnLineEnd first_end;
- ZnLineEnd last_end;
- ZnImage tile;
+ ZnPoint coords[2];
+ int start_angle;
+ int angle_extent;
+ ZnImage line_pattern;
+ ZnGradient *fill_color;
+ ZnGradient *line_color;
+ ZnDim line_width;
+ ZnLineStyle line_style;
+ ZnLineEnd first_end;
+ ZnLineEnd last_end;
+ ZnImage tile;
unsigned short flags;
/* Private data */
- ZnPoint orig;
- ZnPoint corner;
- ZnList render_shape;
- ZnPoint *grad_geo;
+ ZnPoint orig;
+ ZnPoint corner;
+ ZnList render_shape;
+ ZnPoint *grad_geo;
} ArcItemStruct, *ArcItem;
-static ZnAttrConfig arc_attrs[] = {
+static ZnAttrConfig arc_attrs[] = {
{ ZN_CONFIG_BOOL, "-closed", NULL,
Tk_Offset(ArcItemStruct, flags), CLOSED_BIT, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_BOOL, "-composealpha", NULL,
@@ -150,14 +150,14 @@ static ZnAttrConfig arc_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;
- ArcItem arc = (ArcItem) item;
- unsigned int num_points;
- ZnPoint *points;
+ ZnWInfo *wi = item->wi;
+ ArcItem arc = (ArcItem) item;
+ unsigned int num_points;
+ ZnPoint *points;
/* Init attributes */
SET(item->flags, ZN_VISIBLE_BIT);
@@ -186,7 +186,7 @@ Init(ZnItem item,
return TCL_ERROR;
}
if (ZnParseCoordList(wi, (*args)[0], &points,
- NULL, &num_points, NULL) == TCL_ERROR) {
+ NULL, &num_points, NULL) == TCL_ERROR) {
return TCL_ERROR;
}
if (num_points != 2) {
@@ -213,9 +213,9 @@ Init(ZnItem item,
**********************************************************************************
*/
static void
-Clone(ZnItem item)
+Clone(ZnItem item)
{
- ArcItem arc = (ArcItem) item;
+ ArcItem arc = (ArcItem) item;
if (arc->tile != ZnUnspecifiedImage) {
arc->tile = ZnGetImageByValue(arc->tile, ZnUpdateItemImage, item);
@@ -246,9 +246,9 @@ Clone(ZnItem item)
**********************************************************************************
*/
static void
-Destroy(ZnItem item)
+Destroy(ZnItem item)
{
- ArcItem arc = (ArcItem) item;
+ ArcItem arc = (ArcItem) item;
if (arc->render_shape) {
ZnListFree(arc->render_shape);
@@ -284,17 +284,17 @@ Destroy(ZnItem item)
**********************************************************************************
*/
static void
-SetRenderFlags(ArcItem arc)
+SetRenderFlags(ArcItem arc)
{
ASSIGN(arc->flags, FIRST_END_OK,
- (arc->first_end != NULL) && ISCLEAR(arc->flags, CLOSED_BIT) &&
- ISCLEAR(arc->flags, FILLED_BIT) && arc->line_width
- /*&& ISCLEAR(arc->flags, RELIEF_OK)*/);
+ (arc->first_end != NULL) && ISCLEAR(arc->flags, CLOSED_BIT) &&
+ ISCLEAR(arc->flags, FILLED_BIT) && arc->line_width
+ /*&& ISCLEAR(arc->flags, RELIEF_OK)*/);
ASSIGN(arc->flags, LAST_END_OK,
- (arc->last_end != NULL) && ISCLEAR(arc->flags, CLOSED_BIT) &&
- ISCLEAR(arc->flags, FILLED_BIT) && arc->line_width
- /*&& ISCLEAR(arc->flags, RELIEF_OK)*/);
+ (arc->last_end != NULL) && ISCLEAR(arc->flags, CLOSED_BIT) &&
+ ISCLEAR(arc->flags, FILLED_BIT) && arc->line_width
+ /*&& ISCLEAR(arc->flags, RELIEF_OK)*/);
}
@@ -306,13 +306,13 @@ SetRenderFlags(ArcItem arc)
**********************************************************************************
*/
static int
-Configure(ZnItem item,
- int argc,
- Tcl_Obj *CONST argv[],
- int *flags)
+Configure(ZnItem item,
+ int argc,
+ Tcl_Obj *CONST argv[],
+ int *flags)
{
- ArcItem arc = (ArcItem) item;
- int status = TCL_OK;
+ ArcItem arc = (ArcItem) item;
+ int status = TCL_OK;
status = ZnConfigureAttributes(item->wi, item, item, arc_attrs, argc, argv, flags);
if (arc->start_angle < 0) {
@@ -333,9 +333,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, arc_attrs, argv[0]) == TCL_ERROR) {
return TCL_ERROR;
@@ -353,12 +353,12 @@ Query(ZnItem item,
**********************************************************************************
*/
static void
-UpdateRenderShape(ArcItem arc)
+UpdateRenderShape(ArcItem arc)
{
- ZnPoint *p_list, p, p2, o, o2;
- ZnReal width, height, d;
- int num_p, i, quality;
- ZnTransfo *t = ((ZnItem) arc)->wi->current_transfo;
+ ZnPoint *p_list, p, p2, o, o2;
+ ZnReal width, height, d;
+ int num_p, i, quality;
+ ZnTransfo *t = ((ZnItem) arc)->wi->current_transfo;
if (!arc->render_shape) {
arc->render_shape = ZnListNew(8, sizeof(ZnPoint));
@@ -370,11 +370,11 @@ UpdateRenderShape(ArcItem arc)
d = MAX(width, height);
quality = ZN_CIRCLE_COARSE;
p_list = ZnGetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
- quality,
- ZnDegRad(arc->start_angle),
- ZnDegRad(arc->angle_extent),
- &num_p,
- arc->render_shape);
+ quality,
+ ZnDegRad(arc->start_angle),
+ ZnDegRad(arc->angle_extent),
+ &num_p,
+ arc->render_shape);
/*
* Adapt the number of arc points to the radius of the arc.
@@ -396,11 +396,11 @@ UpdateRenderShape(ArcItem arc)
if (quality != ZN_CIRCLE_COARSE) {
p_list = ZnGetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
- quality,
- ZnDegRad(arc->start_angle),
- ZnDegRad(arc->angle_extent),
- &num_p,
- arc->render_shape);
+ quality,
+ ZnDegRad(arc->start_angle),
+ ZnDegRad(arc->angle_extent),
+ &num_p,
+ arc->render_shape);
}
for (i = 0; i < num_p; i++, p_list++) {
@@ -411,15 +411,15 @@ UpdateRenderShape(ArcItem arc)
}
static void
-ComputeCoordinates(ZnItem item,
- ZnBool force)
+ComputeCoordinates(ZnItem item,
+ ZnBool force)
{
- ZnWInfo *wi = item->wi;
- ArcItem arc = (ArcItem) item;
- ZnReal angle, tmp;
- unsigned int num_p;
- ZnPoint *p_list;
- ZnPoint end_points[ZN_LINE_END_POINTS];
+ ZnWInfo *wi = item->wi;
+ ArcItem arc = (ArcItem) item;
+ ZnReal angle, tmp;
+ unsigned int num_p;
+ ZnPoint *p_list;
+ ZnPoint end_points[ZN_LINE_END_POINTS];
ZnResetBBox(&item->item_bounding_box);
/*
@@ -454,12 +454,12 @@ ComputeCoordinates(ZnItem item,
*/
if (ISSET(arc->flags, FIRST_END_OK)) {
ZnGetLineEnd(p_list, p_list+1, arc->line_width, CapRound,
- arc->first_end, end_points);
+ arc->first_end, end_points);
ZnAddPointsToBBox(&item->item_bounding_box, end_points, ZN_LINE_END_POINTS);
}
if (ISSET(arc->flags, LAST_END_OK)) {
ZnGetLineEnd(&p_list[num_p-1], &p_list[num_p-2], arc->line_width, CapRound,
- arc->last_end, end_points);
+ arc->last_end, end_points);
ZnAddPointsToBBox(&item->item_bounding_box, end_points, ZN_LINE_END_POINTS);
}
@@ -469,26 +469,26 @@ ComputeCoordinates(ZnItem item,
ZnPoint p[4];
if (!arc->grad_geo) {
- arc->grad_geo = ZnMalloc(6*sizeof(ZnPoint));
+ arc->grad_geo = ZnMalloc(6*sizeof(ZnPoint));
}
if (arc->fill_color->type == ZN_AXIAL_GRADIENT) {
- p[0] = arc->coords[0];
- p[2] = arc->coords[1];
- p[1].x = p[2].x;
- p[1].y = p[0].y;
- p[3].x = p[0].x;
- p[3].y = p[2].y;
- ZnPolyContour1(&shape, p, 4, False);
+ p[0] = arc->coords[0];
+ p[2] = arc->coords[1];
+ p[1].x = p[2].x;
+ p[1].y = p[0].y;
+ p[3].x = p[0].x;
+ p[3].y = p[2].y;
+ ZnPolyContour1(&shape, p, 4, False);
}
else {
- ZnPolyContour1(&shape, arc->coords, 2, False);
+ ZnPolyContour1(&shape, arc->coords, 2, False);
}
ZnComputeGradient(arc->fill_color, wi, &shape, arc->grad_geo);
}
else {
if (arc->grad_geo) {
- ZnFree(arc->grad_geo);
- arc->grad_geo = NULL;
+ ZnFree(arc->grad_geo);
+ arc->grad_geo = NULL;
}
}
#endif
@@ -496,9 +496,9 @@ ComputeCoordinates(ZnItem item,
}
/*
- ******* ******** **********
+ ******* ******** **********
* This part is for X drawn arcs: full extent, not rotated.
- ******* ******** **********
+ ******* ******** **********
*/
CLEAR(arc->flags, USING_POLY_BIT);
ZnTransformPoint(wi->current_transfo, &arc->coords[0], &arc->orig);
@@ -519,24 +519,24 @@ 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)
{
- ArcItem arc = (ArcItem) item;
- ZnPoint *points;
- ZnPoint pts[20]; /* Should be at least ZN_LINE_END_POINTS large */
- ZnPoint center;
- ZnBBox *area = ta->area;
- unsigned int num_points;
- int result=-1, result2;
- ZnReal lw = arc->line_width;
- ZnReal width, height;
+ ArcItem arc = (ArcItem) item;
+ ZnPoint *points;
+ ZnPoint pts[20]; /* Should be at least ZN_LINE_END_POINTS large */
+ ZnPoint center;
+ ZnBBox *area = ta->area;
+ unsigned int num_points;
+ int result=-1, result2;
+ ZnReal lw = arc->line_width;
+ ZnReal width, height;
if (ISSET(arc->flags, USING_POLY_BIT)) {
if (ISSET(arc->flags, FILLED_BIT) || (arc->line_width)) {
@@ -544,48 +544,48 @@ ToArea(ZnItem item,
num_points = ZnListSize(arc->render_shape);
if (ISSET(arc->flags, FILLED_BIT)) {
- result = ZnPolygonInBBox(points, num_points, area, NULL);
- if (result == 0) {
- return 0;
- }
+ result = ZnPolygonInBBox(points, num_points, area, NULL);
+ if (result == 0) {
+ return 0;
+ }
}
if (arc->line_width > 0) {
- result2 = ZnPolylineInBBox(points, num_points, arc->line_width,
- CapRound, JoinRound, area);
- if (ISCLEAR(arc->flags, FILLED_BIT)) {
- if (result2 == 0) {
- return 0;
- }
- result = result2;
- }
- else if (result2 != result) {
- return 0;
- }
- if (ISSET(arc->flags, CLOSED_BIT) && ISSET(arc->flags, PIE_SLICE_BIT)) {
- pts[0] = points[num_points-1];
- pts[1] = points[0];
- if (ZnPolylineInBBox(pts, 2, arc->line_width,
- CapRound, JoinRound, area) != result) {
- return 0;
- }
- }
- /*
- * Check line ends.
- */
- if (ISSET(arc->flags, FIRST_END_OK)) {
- ZnGetLineEnd(&points[0], &points[1], arc->line_width, CapRound,
- arc->first_end, pts);
- if (ZnPolygonInBBox(pts, ZN_LINE_END_POINTS, area, NULL) != result) {
- return 0;
- }
- }
- if (ISSET(arc->flags, LAST_END_OK)) {
- ZnGetLineEnd(&points[num_points-1], &points[num_points-2], arc->line_width,
- CapRound, arc->last_end, pts);
- if (ZnPolygonInBBox(pts, ZN_LINE_END_POINTS, area, NULL) != result) {
- return 0;
- }
- }
+ result2 = ZnPolylineInBBox(points, num_points, arc->line_width,
+ CapRound, JoinRound, area);
+ if (ISCLEAR(arc->flags, FILLED_BIT)) {
+ if (result2 == 0) {
+ return 0;
+ }
+ result = result2;
+ }
+ else if (result2 != result) {
+ return 0;
+ }
+ if (ISSET(arc->flags, CLOSED_BIT) && ISSET(arc->flags, PIE_SLICE_BIT)) {
+ pts[0] = points[num_points-1];
+ pts[1] = points[0];
+ if (ZnPolylineInBBox(pts, 2, arc->line_width,
+ CapRound, JoinRound, area) != result) {
+ return 0;
+ }
+ }
+ /*
+ * Check line ends.
+ */
+ if (ISSET(arc->flags, FIRST_END_OK)) {
+ ZnGetLineEnd(&points[0], &points[1], arc->line_width, CapRound,
+ arc->first_end, pts);
+ if (ZnPolygonInBBox(pts, ZN_LINE_END_POINTS, area, NULL) != result) {
+ return 0;
+ }
+ }
+ if (ISSET(arc->flags, LAST_END_OK)) {
+ ZnGetLineEnd(&points[num_points-1], &points[num_points-2], arc->line_width,
+ CapRound, arc->last_end, pts);
+ if (ZnPolygonInBBox(pts, ZN_LINE_END_POINTS, area, NULL) != result) {
+ return 0;
+ }
+ }
}
return result;
}
@@ -595,10 +595,10 @@ ToArea(ZnItem item,
}
/*
- ******* ******** **********
+ ******* ******** **********
* The rest of this code deal with non rotated, full extent *
- * arcs. It has been stolen from tkRectOval.c *
- ******* ******** **********
+ * arcs. It has been stolen from tkRectOval.c *
+ ******* ******** **********
*/
/*
* Transform both the arc and the rectangle so that the arc's oval
@@ -631,7 +631,7 @@ ToArea(ZnItem item,
y_delta2 = (area->corner.y - center.y) / height;
y_delta2 *= y_delta2;
if (((x_delta1 + y_delta1) < 1.0) && ((x_delta1 + y_delta2) < 1.0) &&
- ((x_delta2 + y_delta1) < 1.0) && ((x_delta2 + y_delta2) < 1.0)) {
+ ((x_delta2 + y_delta1) < 1.0) && ((x_delta2 + y_delta2) < 1.0)) {
return -1;
}
}
@@ -648,15 +648,15 @@ ToArea(ZnItem item,
**********************************************************************************
*/
static void
-Draw(ZnItem item)
+Draw(ZnItem item)
{
- ZnWInfo *wi = item->wi;
- ArcItem arc = (ArcItem) item;
- XGCValues values;
- unsigned int width=0, height=0;
- ZnPoint *p=NULL;
- XPoint *xp=NULL;
- unsigned int num_points=0, i;
+ ZnWInfo *wi = item->wi;
+ ArcItem arc = (ArcItem) item;
+ XGCValues values;
+ unsigned int width=0, height=0;
+ ZnPoint *p=NULL;
+ XPoint *xp=NULL;
+ unsigned int num_points=0, i;
if (ISCLEAR(arc->flags, FILLED_BIT) && !arc->line_width) {
return;
@@ -683,22 +683,22 @@ Draw(ZnItem item)
values.arc_mode = ISSET(arc->flags, PIE_SLICE_BIT) ? ArcPieSlice : ArcChord;
if (arc->tile != ZnUnspecifiedImage) {
if (!ZnImageIsBitmap(arc->tile)) { /* Fill tiled */
- values.fill_style = FillTiled;
- values.tile = ZnImagePixmap(arc->tile, wi->win);
- values.ts_x_origin = (int) item->item_bounding_box.orig.x;
- values.ts_y_origin = (int) item->item_bounding_box.orig.y;
- XChangeGC(wi->dpy, wi->gc,
- GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCTile|GCArcMode,
- &values);
+ values.fill_style = FillTiled;
+ values.tile = ZnImagePixmap(arc->tile, wi->win);
+ values.ts_x_origin = (int) item->item_bounding_box.orig.x;
+ values.ts_y_origin = (int) item->item_bounding_box.orig.y;
+ XChangeGC(wi->dpy, wi->gc,
+ GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCTile|GCArcMode,
+ &values);
}
else { /* Fill stippled */
- values.fill_style = FillStippled;
- values.stipple = ZnImagePixmap(arc->tile, wi->win);
- values.ts_x_origin = (int) item->item_bounding_box.orig.x;
- values.ts_y_origin = (int) item->item_bounding_box.orig.y;
- XChangeGC(wi->dpy, wi->gc,
- GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCStipple|GCForeground|GCArcMode,
- &values);
+ values.fill_style = FillStippled;
+ values.stipple = ZnImagePixmap(arc->tile, wi->win);
+ values.ts_x_origin = (int) item->item_bounding_box.orig.x;
+ values.ts_y_origin = (int) item->item_bounding_box.orig.y;
+ XChangeGC(wi->dpy, wi->gc,
+ GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCStipple|GCForeground|GCArcMode,
+ &values);
}
}
else { /* Fill solid */
@@ -708,15 +708,15 @@ Draw(ZnItem item)
if (ISSET(arc->flags, USING_POLY_BIT)) {
XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc,
- xp, (int) num_points, Nonconvex, CoordModeOrigin);
+ xp, (int) num_points, Nonconvex, CoordModeOrigin);
}
else {
XFillArc(wi->dpy, wi->draw_buffer, wi->gc,
- (int) arc->orig.x,
- (int) arc->orig.y,
- (unsigned int) width,
- (unsigned int) height,
- -arc->start_angle*64, -arc->angle_extent*64);
+ (int) arc->orig.x,
+ (int) arc->orig.y,
+ (unsigned int) width,
+ (unsigned int) height,
+ -arc->start_angle*64, -arc->angle_extent*64);
}
}
@@ -735,55 +735,55 @@ Draw(ZnItem item)
if (arc->line_pattern == ZnUnspecifiedImage) {
values.fill_style = FillSolid;
XChangeGC(wi->dpy, wi->gc,
- GCFillStyle|GCLineWidth|GCCapStyle|GCJoinStyle|GCForeground, &values);
+ GCFillStyle|GCLineWidth|GCCapStyle|GCJoinStyle|GCForeground, &values);
}
else {
values.fill_style = FillStippled;
values.stipple = ZnImagePixmap(arc->line_pattern, wi->win);
XChangeGC(wi->dpy, wi->gc,
- GCFillStyle|GCStipple|GCLineWidth|GCCapStyle|GCJoinStyle|GCForeground,
- &values);
+ GCFillStyle|GCStipple|GCLineWidth|GCCapStyle|GCJoinStyle|GCForeground,
+ &values);
}
if (ISSET(arc->flags, USING_POLY_BIT)) {
if (ISCLEAR(arc->flags, CLOSED_BIT) && arc->angle_extent != 360) {
- num_points--;
- if (ISSET(arc->flags, PIE_SLICE_BIT)) {
- num_points--;
- }
+ num_points--;
+ if (ISSET(arc->flags, PIE_SLICE_BIT)) {
+ num_points--;
+ }
}
XDrawLines(wi->dpy, wi->draw_buffer, wi->gc,
- xp, (int) num_points, CoordModeOrigin);
+ xp, (int) num_points, CoordModeOrigin);
if (ISSET(arc->flags, FIRST_END_OK)) {
- p = (ZnPoint *) ZnListArray(arc->render_shape);
- ZnGetLineEnd(p, p+1, arc->line_width, CapRound,
- arc->first_end, end_points);
- for (i = 0; i < ZN_LINE_END_POINTS; i++) {
- xap[i].x = (short) end_points[i].x;
- xap[i].y = (short) end_points[i].y;
- }
- XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, ZN_LINE_END_POINTS,
- Nonconvex, CoordModeOrigin);
+ p = (ZnPoint *) ZnListArray(arc->render_shape);
+ ZnGetLineEnd(p, p+1, arc->line_width, CapRound,
+ arc->first_end, end_points);
+ for (i = 0; i < ZN_LINE_END_POINTS; i++) {
+ xap[i].x = (short) end_points[i].x;
+ xap[i].y = (short) end_points[i].y;
+ }
+ XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, ZN_LINE_END_POINTS,
+ Nonconvex, CoordModeOrigin);
}
if (ISSET(arc->flags, LAST_END_OK)) {
- p = (ZnPoint *) ZnListArray(arc->render_shape);
- num_points = ZnListSize(arc->render_shape);
- ZnGetLineEnd(&p[num_points-1], &p[num_points-2], arc->line_width,
- CapRound, arc->last_end, end_points);
- for (i = 0; i < ZN_LINE_END_POINTS; i++) {
- xap[i].x = (short) end_points[i].x;
- xap[i].y = (short) end_points[i].y;
- }
- XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, ZN_LINE_END_POINTS,
- Nonconvex, CoordModeOrigin);
+ p = (ZnPoint *) ZnListArray(arc->render_shape);
+ num_points = ZnListSize(arc->render_shape);
+ ZnGetLineEnd(&p[num_points-1], &p[num_points-2], arc->line_width,
+ CapRound, arc->last_end, end_points);
+ for (i = 0; i < ZN_LINE_END_POINTS; i++) {
+ xap[i].x = (short) end_points[i].x;
+ xap[i].y = (short) end_points[i].y;
+ }
+ XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, ZN_LINE_END_POINTS,
+ Nonconvex, CoordModeOrigin);
}
}
else {
XDrawArc(wi->dpy, wi->draw_buffer, wi->gc,
- (int) arc->orig.x,
- (int) arc->orig.y,
- (unsigned int) width,
- (unsigned int) height,
- -arc->start_angle*64, -arc->angle_extent*64);
+ (int) arc->orig.x,
+ (int) arc->orig.y,
+ (unsigned int) width,
+ (unsigned int) height,
+ -arc->start_angle*64, -arc->angle_extent*64);
}
}
}
@@ -800,11 +800,11 @@ Draw(ZnItem item)
static void
ArcRenderCB(void *closure)
{
- ZnItem item = (ZnItem) closure;
- ArcItem arc = (ArcItem) item;
- int num_points=0, i;
- ZnPoint *p=NULL;
- ZnPoint center;
+ ZnItem item = (ZnItem) closure;
+ ArcItem arc = (ArcItem) item;
+ int num_points=0, i;
+ ZnPoint *p=NULL;
+ ZnPoint center;
center.x = (item->item_bounding_box.corner.x + item->item_bounding_box.orig.x) / 2.0;
center.y = (item->item_bounding_box.corner.y + item->item_bounding_box.orig.y) / 2.0;
@@ -821,12 +821,12 @@ ArcRenderCB(void *closure)
#ifdef GL
static void
-Render(ZnItem item)
+Render(ZnItem item)
{
- ZnWInfo *wi = item->wi;
- ArcItem arc = (ArcItem) item;
- unsigned int num_points=0;
- ZnPoint *p=NULL;
+ ZnWInfo *wi = item->wi;
+ ArcItem arc = (ArcItem) item;
+ unsigned int num_points=0;
+ ZnPoint *p=NULL;
if (ISCLEAR(arc->flags, FILLED_BIT) && !arc->line_width) {
return;
@@ -842,23 +842,23 @@ Render(ZnItem item)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (!ZnGradientFlat(arc->fill_color)) {
- ZnPoly poly;
-
- ZnPolyContour1(&poly, ZnListArray(arc->render_shape),
- ZnListSize(arc->render_shape), False);
- ZnRenderGradient(wi, arc->fill_color, ArcRenderCB, arc,
- arc->grad_geo, &poly);
+ ZnPoly poly;
+
+ ZnPolyContour1(&poly, ZnListArray(arc->render_shape),
+ ZnListSize(arc->render_shape), False);
+ ZnRenderGradient(wi, arc->fill_color, ArcRenderCB, arc,
+ arc->grad_geo, &poly);
}
else if (arc->tile != ZnUnspecifiedImage) { /* Fill tiled/stippled */
- ZnRenderTile(wi, arc->tile, arc->fill_color, ArcRenderCB, arc,
- (ZnPoint *) &item->item_bounding_box);
+ ZnRenderTile(wi, arc->tile, arc->fill_color, ArcRenderCB, arc,
+ (ZnPoint *) &item->item_bounding_box);
}
else {
- unsigned short alpha;
- XColor *color = ZnGetGradientColor(arc->fill_color, 0.0, &alpha);
- alpha = ZnComposeAlpha(alpha, wi->alpha);
- glColor4us(color->red, color->green, color->blue, alpha);
- ArcRenderCB(arc);
+ unsigned short alpha;
+ XColor *color = ZnGetGradientColor(arc->fill_color, 0.0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
+ ArcRenderCB(arc);
}
}
@@ -866,23 +866,23 @@ Render(ZnItem item)
* Draw the arc.
*/
if (arc->line_width) {
- ZnLineEnd first = ISSET(arc->flags, FIRST_END_OK) ? arc->first_end : NULL;
- ZnLineEnd last = ISSET(arc->flags, LAST_END_OK) ? arc->last_end : NULL;
- ZnBool closed = ISSET(arc->flags, CLOSED_BIT);
+ ZnLineEnd first = ISSET(arc->flags, FIRST_END_OK) ? arc->first_end : NULL;
+ ZnLineEnd last = ISSET(arc->flags, LAST_END_OK) ? arc->last_end : NULL;
+ ZnBool closed = ISSET(arc->flags, CLOSED_BIT);
p = ZnListArray(arc->render_shape);
num_points = ZnListSize(arc->render_shape);
if (!closed) {
- if (arc->angle_extent != 360) {
- num_points--;
- if (ISSET(arc->flags, PIE_SLICE_BIT)) {
- num_points--;
- }
- }
+ if (arc->angle_extent != 360) {
+ num_points--;
+ if (ISSET(arc->flags, PIE_SLICE_BIT)) {
+ num_points--;
+ }
+ }
}
ZnRenderPolyline(wi, p, num_points, arc->line_width,
- arc->line_style, CapRound, JoinRound, first, last,
- arc->line_color);
+ arc->line_style, CapRound, JoinRound, first, last,
+ arc->line_color);
}
#ifdef GL_LIST
glEndList();
@@ -893,7 +893,7 @@ Render(ZnItem item)
}
#else
static void
-Render(ZnItem item)
+Render(ZnItem item)
{
}
#endif
@@ -907,11 +907,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));
}
@@ -923,16 +923,16 @@ IsSensitive(ZnItem item,
**********************************************************************************
*/
static ZnReal
-Pick(ZnItem item,
- ZnPick ps)
+Pick(ZnItem item,
+ ZnPick ps)
{
- ArcItem arc = (ArcItem) item;
- double dist = 1e40, new_dist;
- ZnPoint center;
- ZnPoint *points, *p = ps->point;
- ZnPoint end_points[ZN_LINE_END_POINTS];
- unsigned int num_points;
- ZnDim lw = arc->line_width;
+ ArcItem arc = (ArcItem) item;
+ double dist = 1e40, new_dist;
+ ZnPoint center;
+ ZnPoint *points, *p = ps->point;
+ ZnPoint end_points[ZN_LINE_END_POINTS];
+ unsigned int num_points;
+ ZnDim lw = arc->line_width;
if (ISCLEAR(arc->flags, FILLED_BIT) && ! arc->line_width) {
return dist;
@@ -944,63 +944,63 @@ Pick(ZnItem item,
if (ISSET(arc->flags, FILLED_BIT)) {
dist = ZnPolygonToPointDist(points, num_points, p);
if (dist <= 0.0) {
- return 0.0;
+ return 0.0;
}
}
if (arc->line_width > 0) {
if (ISCLEAR(arc->flags, CLOSED_BIT) && arc->angle_extent != 360) {
- num_points--;
- if (ISSET(arc->flags, PIE_SLICE_BIT)) {
- num_points--;
- }
+ num_points--;
+ if (ISSET(arc->flags, PIE_SLICE_BIT)) {
+ num_points--;
+ }
}
new_dist = ZnPolylineToPointDist(points, num_points, arc->line_width,
- CapRound, JoinRound, p);
+ CapRound, JoinRound, p);
if (new_dist < dist) {
- dist = new_dist;
+ dist = new_dist;
}
if (dist <= 0.0) {
- return 0.0;
+ return 0.0;
}
/*
* Check line ends.
*/
if (ISSET(arc->flags, FIRST_END_OK)) {
- ZnGetLineEnd(&points[0], &points[1], arc->line_width, CapRound,
- arc->first_end, end_points);
- new_dist = ZnPolygonToPointDist(end_points, ZN_LINE_END_POINTS, p);
- if (new_dist < dist) {
- dist = new_dist;
- }
- if (dist <= 0.0) {
- return 0.0;
- }
+ ZnGetLineEnd(&points[0], &points[1], arc->line_width, CapRound,
+ arc->first_end, end_points);
+ new_dist = ZnPolygonToPointDist(end_points, ZN_LINE_END_POINTS, p);
+ if (new_dist < dist) {
+ dist = new_dist;
+ }
+ if (dist <= 0.0) {
+ return 0.0;
+ }
}
if (ISSET(arc->flags, LAST_END_OK)) {
- ZnGetLineEnd(&points[num_points-1], &points[num_points-2], arc->line_width,
- CapRound, arc->last_end, end_points);
- new_dist = ZnPolygonToPointDist(end_points, ZN_LINE_END_POINTS, p);
- if (new_dist < dist) {
- dist = new_dist;
- }
- if (dist <= 0.0) {
- return 0.0;
- }
+ ZnGetLineEnd(&points[num_points-1], &points[num_points-2], arc->line_width,
+ CapRound, arc->last_end, end_points);
+ new_dist = ZnPolygonToPointDist(end_points, ZN_LINE_END_POINTS, p);
+ if (new_dist < dist) {
+ dist = new_dist;
+ }
+ if (dist <= 0.0) {
+ return 0.0;
+ }
}
}
return dist;
}
/*
- ******* ******** **********
+ ******* ******** **********
* The rest of this code deal with non rotated full extent arcs. *
- ******* ******** **********
+ ******* ******** **********
*/
center.x = (arc->orig.x + arc->corner.x) / 2.0;
center.y = (arc->orig.y + arc->corner.y) / 2.0;
dist = ZnOvalToPointDist(&center, arc->corner.x - arc->orig.x,
- arc->corner.y - arc->orig.y, lw, p);
+ arc->corner.y - arc->orig.y, lw, p);
if (dist < 0.0) {
if (ISSET(arc->flags, FILLED_BIT)) {
dist = 0.0;
@@ -1016,26 +1016,26 @@ Pick(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 void
-UpdateRenderShapeX(ArcItem arc)
+UpdateRenderShapeX(ArcItem arc)
{
- ZnReal ox, oy, width_2, height_2;
- int i, num_p;
- ZnPoint *p_list;
+ ZnReal ox, oy, width_2, height_2;
+ int i, num_p;
+ ZnPoint *p_list;
if (!arc->render_shape) {
arc->render_shape = ZnListNew(8, sizeof(ZnPoint));
}
p_list = ZnGetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
- ZN_CIRCLE_FINE,
- ZnDegRad(arc->start_angle),
- ZnDegRad(arc->angle_extent),
- &num_p, arc->render_shape);
+ ZN_CIRCLE_FINE,
+ ZnDegRad(arc->start_angle),
+ ZnDegRad(arc->angle_extent),
+ &num_p, arc->render_shape);
ox = (arc->corner.x + arc->orig.x) / 2.0;
oy = (arc->corner.y + arc->orig.y) / 2.0;
width_2 = (arc->corner.x - arc->orig.x) / 2.0;
@@ -1047,11 +1047,11 @@ UpdateRenderShapeX(ArcItem arc)
}
static ZnBool
-GetClipVertices(ZnItem item,
- ZnTriStrip *tristrip)
+GetClipVertices(ZnItem item,
+ ZnTriStrip *tristrip)
{
- ArcItem arc = (ArcItem) item;
- ZnPoint center;
+ ArcItem arc = (ArcItem) item;
+ ZnPoint center;
if (ISCLEAR(arc->flags, USING_POLY_BIT) || !arc->render_shape) {
UpdateRenderShapeX(arc);
@@ -1065,7 +1065,7 @@ GetClipVertices(ZnItem item,
ZnListAdd(ZnWorkPoints, &center, ZnListTail);
ZnListAppend(ZnWorkPoints, arc->render_shape);
ZnTriStrip1(tristrip, ZnListArray(ZnWorkPoints),
- ZnListSize(ZnWorkPoints), True);
+ ZnListSize(ZnWorkPoints), True);
return False;
}
@@ -1075,23 +1075,23 @@ GetClipVertices(ZnItem item,
**********************************************************************************
*
* GetContours --
- * Get the external contour(s).
- * Never ever call ZnPolyFree on the tristrip returned by GetContours.
+ * Get the external contour(s).
+ * Never ever call ZnPolyFree on the tristrip returned by GetContours.
*
**********************************************************************************
*/
static ZnBool
-GetContours(ZnItem item,
- ZnPoly *poly)
+GetContours(ZnItem item,
+ ZnPoly *poly)
{
- ArcItem arc = (ArcItem) item;
+ ArcItem arc = (ArcItem) item;
if (ISCLEAR(arc->flags, USING_POLY_BIT) || !arc->render_shape) {
UpdateRenderShapeX(arc);
}
ZnPolyContour1(poly, ZnListArray(arc->render_shape),
- ZnListSize(arc->render_shape), True);
+ ZnListSize(arc->render_shape), True);
poly->contour1.controls = NULL;
return False;
@@ -1102,30 +1102,30 @@ 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)
{
- ArcItem arc = (ArcItem) item;
+ ArcItem arc = (ArcItem) item;
if ((cmd == ZN_COORDS_ADD) || (cmd == ZN_COORDS_ADD_LAST) || (cmd == ZN_COORDS_REMOVE)) {
Tcl_AppendResult(item->wi->interp,
- " arcs can't add or remove vertices", NULL);
+ " arcs can't add or remove vertices", NULL);
return TCL_ERROR;
}
else if (cmd == ZN_COORDS_REPLACE_ALL) {
if (*num_pts != 2) {
Tcl_AppendResult(item->wi->interp,
- " coords command need 2 points on arcs", NULL);
+ " coords command need 2 points on arcs", NULL);
return TCL_ERROR;
}
arc->coords[0] = (*pts)[0];
@@ -1135,7 +1135,7 @@ Coords(ZnItem item,
else if (cmd == ZN_COORDS_REPLACE) {
if (*num_pts < 1) {
Tcl_AppendResult(item->wi->interp,
- " coords command need at least 1 point", NULL);
+ " coords command need at least 1 point", NULL);
return TCL_ERROR;
}
if (index < 0) {
@@ -1144,7 +1144,7 @@ Coords(ZnItem item,
if ((index < 0) || (index > 1)) {
range_err:
Tcl_AppendResult(item->wi->interp,
- " incorrect coord index, should be between -2 and 1", NULL);
+ " incorrect coord index, should be between -2 and 1", NULL);
return TCL_ERROR;
}
arc->coords[index] = (*pts)[0];
@@ -1176,16 +1176,16 @@ Coords(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);
}
/*
@@ -1196,8 +1196,8 @@ GetAnchor(ZnItem item,
**********************************************************************************
*/
static void
-PostScript(ZnItem item,
- ZnBool prepass)
+PostScript(ZnItem item,
+ ZnBool prepass)
{
}
@@ -1213,33 +1213,33 @@ static ZnItemClassStruct ARC_ITEM_CLASS = {
"arc",
sizeof(ArcItemStruct),
arc_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, /* Contour */
+ NULL, /* InsertChars */
+ NULL, /* DeleteChars */
+ NULL, /* Cursor */
+ NULL, /* Index */
+ NULL, /* Part */
+ NULL, /* Selection */
+ NULL, /* Contour */
ComputeCoordinates,
ToArea,
Draw,
Render,
IsSensitive,
Pick,
- NULL, /* PickVertex */
+ NULL, /* PickVertex */
PostScript
};