From 46ea8bc12e435b7ca6593bc43498ef6aae3e261a Mon Sep 17 00:00:00 2001 From: lecoanet Date: Wed, 13 Apr 2005 14:07:59 +0000 Subject: Expanded the tabs into spaces to make the indenting independant of the editing environment (emacs vs vi for example). --- generic/Reticle.c | 280 +++++++++++++++++++++++++++--------------------------- 1 file changed, 140 insertions(+), 140 deletions(-) (limited to 'generic/Reticle.c') diff --git a/generic/Reticle.c b/generic/Reticle.c index 3011f5d..844fcc7 100644 --- a/generic/Reticle.c +++ b/generic/Reticle.c @@ -1,8 +1,8 @@ /* * Reticle.c -- Implementation of Reticle item. * - * Authors : Patrick Lecoanet. - * Creation date : Mon Feb 1 12:13:24 1999 + * Authors : Patrick Lecoanet. + * Creation date : Mon Feb 1 12:13:24 1999 * * $Id$ */ @@ -43,13 +43,13 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " /* * Draw as many circles as visible. */ -#define ANY_CIRCLES -1 +#define ANY_CIRCLES -1 /* * Some default values. */ -#define DEFAULT_RETICLE_STEP_SIZE 80 -#define DEFAULT_RETICLE_PERIOD 5 +#define DEFAULT_RETICLE_STEP_SIZE 80 +#define DEFAULT_RETICLE_PERIOD 5 /* ********************************************************************************** @@ -60,27 +60,27 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " */ typedef struct _ReticleItemStruct { - ZnItemStruct header; + ZnItemStruct header; /* Public data */ - ZnPoint pos; /* Origin world coordinates */ - ZnGradient *line_color; /* circle color */ - ZnGradient *bright_line_color; /* intermediate circle color */ - ZnDim first_radius; /* first world radius */ - ZnDim step_size; /* step world size */ - int period; /* bright circle period */ - int num_circles; /* num cercles max */ - ZnLineStyle line_style; /* circles lines styles */ - ZnLineStyle bright_line_style; + ZnPoint pos; /* Origin world coordinates */ + ZnGradient *line_color; /* circle color */ + ZnGradient *bright_line_color; /* intermediate circle color */ + ZnDim first_radius; /* first world radius */ + ZnDim step_size; /* step world size */ + int period; /* bright circle period */ + int num_circles; /* num cercles max */ + ZnLineStyle line_style; /* circles lines styles */ + ZnLineStyle bright_line_style; /* Private data */ - ZnPoint dev; /* item device coordinate */ - ZnDim first_radius_dev; /* first device radius */ - ZnDim step_size_dev; /* steps device size */ + ZnPoint dev; /* item device coordinate */ + ZnDim first_radius_dev; /* first device radius */ + ZnDim step_size_dev; /* steps device size */ } ReticleItemStruct, *ReticleItem; -static ZnAttrConfig reticle_attrs[] = { +static ZnAttrConfig reticle_attrs[] = { { ZN_CONFIG_GRADIENT, "-brightlinecolor", NULL, Tk_Offset(ReticleItemStruct, bright_line_color), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_LINE_STYLE, "-brightlinestyle", NULL, @@ -136,12 +136,12 @@ static ZnAttrConfig reticle_attrs[] = { ********************************************************************************** */ static int -Init(ZnItem item, - int *argc, - Tcl_Obj *CONST *args[]) +Init(ZnItem item, + int *argc, + Tcl_Obj *CONST *args[]) { - ReticleItem reticle = (ReticleItem) item; - ZnWInfo *wi = item->wi; + ReticleItem reticle = (ReticleItem) item; + ZnWInfo *wi = item->wi; SET(item->flags, ZN_VISIBLE_BIT); CLEAR(item->flags, ZN_SENSITIVE_BIT); @@ -177,9 +177,9 @@ Init(ZnItem item, ********************************************************************************** */ static void -Clone(ZnItem item) +Clone(ZnItem item) { - ReticleItem reticle = (ReticleItem) item; + ReticleItem reticle = (ReticleItem) item; reticle->line_color = ZnGetGradientByValue(reticle->line_color); reticle->bright_line_color = ZnGetGradientByValue(reticle->bright_line_color); @@ -194,9 +194,9 @@ Clone(ZnItem item) ********************************************************************************** */ static void -Destroy(ZnItem item) +Destroy(ZnItem item) { - ReticleItem reticle = (ReticleItem) item; + ReticleItem reticle = (ReticleItem) item; ZnFreeGradient(reticle->line_color); ZnFreeGradient(reticle->bright_line_color); @@ -211,13 +211,13 @@ Destroy(ZnItem item) ********************************************************************************** */ static int -Configure(ZnItem item, - int argc, - Tcl_Obj *CONST argv[], - int *flags) +Configure(ZnItem item, + int argc, + Tcl_Obj *CONST argv[], + int *flags) { if (ZnConfigureAttributes(item->wi, item, item, reticle_attrs, - argc, argv, flags) == TCL_ERROR) { + argc, argv, flags) == TCL_ERROR) { return TCL_ERROR; } @@ -233,9 +233,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, reticle_attrs, argv[0]) == TCL_ERROR) { return TCL_ERROR; @@ -253,13 +253,13 @@ Query(ZnItem item, ********************************************************************************** */ static void -ComputeCoordinates(ZnItem item, - ZnBool force) +ComputeCoordinates(ZnItem item, + ZnBool force) { - ZnWInfo *wi = item->wi; - ReticleItem reticle = (ReticleItem) item; - ZnDim half_width; - ZnPoint p, xp; + ZnWInfo *wi = item->wi; + ReticleItem reticle = (ReticleItem) item; + ZnDim half_width; + ZnPoint p, xp; /* Compute center device coordinates */ p.x = p.y = 0; @@ -299,14 +299,14 @@ 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) { return -1; } @@ -320,31 +320,31 @@ ToArea(ZnItem item, ********************************************************************************** */ static void -Draw(ZnItem item) +Draw(ZnItem item) { - ZnWInfo *wi = item->wi; - ReticleItem reticle = (ReticleItem) item; - ZnDim radius = reticle->first_radius_dev; - ZnDim radius_max_dev; - XGCValues values; - int i; - ZnDim l1, l2, l3, l4; -/* int count = 0;*/ + ZnWInfo *wi = item->wi; + ReticleItem reticle = (ReticleItem) item; + ZnDim radius = reticle->first_radius_dev; + ZnDim radius_max_dev; + XGCValues values; + int i; + ZnDim l1, l2, l3, l4; +/* int count = 0;*/ /* Compute radius max */ l1 = (ZnDim) hypot(wi->damaged_area.orig.x - reticle->dev.x, - wi->damaged_area.orig.y - reticle->dev.y); + wi->damaged_area.orig.y - reticle->dev.y); l2 = (ZnDim) hypot(wi->damaged_area.corner.x - reticle->dev.x, - wi->damaged_area.orig.y - reticle->dev.y); + wi->damaged_area.orig.y - reticle->dev.y); l3 = (ZnDim) hypot(wi->damaged_area.orig.x - reticle->dev.x, - wi->damaged_area.corner.y - reticle->dev.y); + wi->damaged_area.corner.y - reticle->dev.y); l4 = (ZnDim) hypot(wi->damaged_area.corner.x - reticle->dev.x, - wi->damaged_area.corner.y - reticle->dev.y); + wi->damaged_area.corner.y - reticle->dev.y); radius_max_dev = MAX(MAX(l1,l2), MAX(l3, l4)); if (reticle->num_circles > 0) { radius_max_dev = MIN(radius_max_dev, reticle->first_radius_dev + - (reticle->num_circles - 1) * reticle->step_size_dev); + (reticle->num_circles - 1) * reticle->step_size_dev); } while (radius <= radius_max_dev) { @@ -355,35 +355,35 @@ Draw(ZnItem item) XChangeGC(wi->dpy, wi->gc, GCForeground | GCLineWidth | GCFillStyle, &values); for (i = 1; ((radius <= radius_max_dev) && (i < reticle->period)); i++) { if ((reticle->dev.x >= wi->damaged_area.orig.x - radius) && - (reticle->dev.x <= wi->damaged_area.corner.x + radius) && - (reticle->dev.y >= wi->damaged_area.orig.y - radius) && - (reticle->dev.y <= wi->damaged_area.corner.y + radius)) { - XDrawArc(wi->dpy, wi->draw_buffer, wi->gc, - (int) (reticle->dev.x - radius), - (int) (reticle->dev.y - radius), - (unsigned int) (radius * 2 - 1), - (unsigned int) (radius * 2 - 1), - 0, 360 * 64); -/* count++;*/ + (reticle->dev.x <= wi->damaged_area.corner.x + radius) && + (reticle->dev.y >= wi->damaged_area.orig.y - radius) && + (reticle->dev.y <= wi->damaged_area.corner.y + radius)) { + XDrawArc(wi->dpy, wi->draw_buffer, wi->gc, + (int) (reticle->dev.x - radius), + (int) (reticle->dev.y - radius), + (unsigned int) (radius * 2 - 1), + (unsigned int) (radius * 2 - 1), + 0, 360 * 64); +/* count++;*/ } radius += (reticle->step_size_dev); } if ((radius <= radius_max_dev) && - (reticle->dev.x >= wi->damaged_area.orig.x - radius) && - (reticle->dev.x <= wi->damaged_area.corner.x + radius) && - (reticle->dev.y >= wi->damaged_area.orig.y - radius) && - (reticle->dev.y <= wi->damaged_area.corner.y + radius)) { + (reticle->dev.x >= wi->damaged_area.orig.x - radius) && + (reticle->dev.x <= wi->damaged_area.corner.x + radius) && + (reticle->dev.y >= wi->damaged_area.orig.y - radius) && + (reticle->dev.y <= wi->damaged_area.corner.y + radius)) { ZnSetLineStyle(wi, reticle->bright_line_style); values.foreground = ZnGetGradientPixel(reticle->bright_line_color, 0.0); values.line_width = 0; values.fill_style = FillSolid; XChangeGC(wi->dpy, wi->gc, GCForeground | GCLineWidth | GCFillStyle, &values); XDrawArc(wi->dpy, wi->draw_buffer, wi->gc, - (int) (reticle->dev.x - radius), - (int) (reticle->dev.y - radius), - (unsigned int) (radius * 2 - 1), - (unsigned int) (radius * 2 - 1), - 0, 360 * 64); + (int) (reticle->dev.x - radius), + (int) (reticle->dev.y - radius), + (unsigned int) (radius * 2 - 1), + (unsigned int) (radius * 2 - 1), + 0, 360 * 64); /*count++;*/ } radius += (reticle->step_size_dev); @@ -401,17 +401,17 @@ Draw(ZnItem item) */ #ifdef GL static void -Render(ZnItem item) +Render(ZnItem item) { - ZnWInfo *wi = item->wi; - ReticleItem reticle = (ReticleItem) item; - ZnDim radius = reticle->first_radius_dev; - ZnDim radius_max_dev, new, x, y, xo, yo; - int i, j; - ZnPoint *genarc; - int num_p; + ZnWInfo *wi = item->wi; + ReticleItem reticle = (ReticleItem) item; + ZnDim radius = reticle->first_radius_dev; + ZnDim radius_max_dev, new, x, y, xo, yo; + int i, j; + ZnPoint *genarc; + int num_p; unsigned short alpha; - XColor *color; + XColor *color; xo = reticle->dev.x; yo = reticle->dev.y; @@ -445,7 +445,7 @@ Render(ZnItem item) if (reticle->num_circles > 0) { radius_max_dev = MIN(radius_max_dev, reticle->first_radius_dev + - (reticle->num_circles - 1) * reticle->step_size_dev); + (reticle->num_circles - 1) * reticle->step_size_dev); } genarc = ZnGetCirclePoints(3, ZN_CIRCLE_FINER, 0.0, 2*M_PI, &num_p, NULL); @@ -457,33 +457,33 @@ Render(ZnItem item) glColor4us(color->red, color->green, color->blue, alpha); for (i = 1; ((radius <= radius_max_dev) && (i < reticle->period)); i++) { if ((xo >= wi->damaged_area.orig.x - radius) && - (xo <= wi->damaged_area.corner.x + radius) && - (yo >= wi->damaged_area.orig.y - radius) && - (yo <= wi->damaged_area.corner.y + radius)) { - glBegin(GL_LINE_LOOP); - for (j = 0; j < num_p; j++) { - x = xo + genarc[j].x * radius; - y = yo + genarc[j].y * radius; - glVertex2d(x, y); - } - glEnd(); + (xo <= wi->damaged_area.corner.x + radius) && + (yo >= wi->damaged_area.orig.y - radius) && + (yo <= wi->damaged_area.corner.y + radius)) { + glBegin(GL_LINE_LOOP); + for (j = 0; j < num_p; j++) { + x = xo + genarc[j].x * radius; + y = yo + genarc[j].y * radius; + glVertex2d(x, y); + } + glEnd(); } radius += (reticle->step_size_dev); } if ((radius <= radius_max_dev) && - (xo >= wi->damaged_area.orig.x - radius) && - (xo <= wi->damaged_area.corner.x + radius) && - (yo >= wi->damaged_area.orig.y - radius) && - (yo <= wi->damaged_area.corner.y + radius)) { + (xo >= wi->damaged_area.orig.x - radius) && + (xo <= wi->damaged_area.corner.x + radius) && + (yo >= wi->damaged_area.orig.y - radius) && + (yo <= wi->damaged_area.corner.y + radius)) { ZnSetLineStyle(wi, reticle->bright_line_style); color = ZnGetGradientColor(reticle->bright_line_color, 0.0, &alpha); alpha = ZnComposeAlpha(alpha, wi->alpha); glColor4us(color->red, color->green, color->blue, alpha); glBegin(GL_LINE_LOOP); for (j = 0; j < num_p; j++) { - x = xo + genarc[j].x * radius; - y = yo + genarc[j].y * radius; - glVertex2d(x, y); + x = xo + genarc[j].x * radius; + y = yo + genarc[j].y * radius; + glVertex2d(x, y); } glEnd(); } @@ -493,7 +493,7 @@ Render(ZnItem item) } #else static void -Render(ZnItem item) +Render(ZnItem item) { } #endif @@ -507,11 +507,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)); } @@ -519,13 +519,13 @@ IsSensitive(ZnItem item, ********************************************************************************** * * Pick -- - * Nothing to pick, we are almost transparent. + * Nothing to pick, we are almost transparent. * ********************************************************************************** */ static double -Pick(ZnItem item, - ZnPick ps) +Pick(ZnItem item, + ZnPick ps) { return 1e40; } @@ -535,30 +535,30 @@ Pick(ZnItem item, ********************************************************************************** * * Coords -- - * Return or edit the item center. + * Return or edit the item center. * ********************************************************************************** */ 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) { - ReticleItem reticle = (ReticleItem) item; + ReticleItem reticle = (ReticleItem) item; if ((cmd == ZN_COORDS_ADD) || (cmd == ZN_COORDS_ADD_LAST) || (cmd == ZN_COORDS_REMOVE)) { Tcl_AppendResult(item->wi->interp, - " reticles can't add or remove vertices", NULL); + " reticles can't add or remove vertices", NULL); return TCL_ERROR; } else if ((cmd == ZN_COORDS_REPLACE) || (cmd == ZN_COORDS_REPLACE_ALL)) { if (*num_pts == 0) { Tcl_AppendResult(item->wi->interp, - " coords command need 1 point on reticles", NULL); + " coords command need 1 point on reticles", NULL); return TCL_ERROR; } reticle->pos = (*pts)[0]; @@ -580,8 +580,8 @@ Coords(ZnItem item, ********************************************************************************** */ static void -PostScript(ZnItem item, - ZnBool prepass) +PostScript(ZnItem item, + ZnBool prepass) { } @@ -597,33 +597,33 @@ static ZnItemClassStruct RETICLE_ITEM_CLASS = { "reticle", sizeof(ReticleItemStruct), reticle_attrs, - 0, /* num_parts */ - ZN_CLASS_ONE_COORD, /* flags */ + 0, /* num_parts */ + ZN_CLASS_ONE_COORD, /* flags */ Tk_Offset(ReticleItemStruct, pos), Init, Clone, Destroy, Configure, Query, - NULL, /* GetFieldSet */ - NULL, /* GetAnchor */ - NULL, /* GetClipVertices */ - NULL, /* GetContours */ + NULL, /* GetFieldSet */ + NULL, /* GetAnchor */ + NULL, /* GetClipVertices */ + NULL, /* 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 }; -- cgit v1.1