diff options
Diffstat (limited to 'generic/Curve.c')
-rw-r--r-- | generic/Curve.c | 486 |
1 files changed, 243 insertions, 243 deletions
diff --git a/generic/Curve.c b/generic/Curve.c index 5942fda..0d17e09 100644 --- a/generic/Curve.c +++ b/generic/Curve.c @@ -47,20 +47,20 @@ 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 SMOOTHED_BIT 1<<2 /* If we `smooth' the path with Bezier curves */ -#define BEZIER_BIT 1<<3 /* If we interpret the vertices as Bezier controls. */ - -#define CCW 1<<5 /* Tell if the vertices are described in - * clockwise or ccw order. */ -#define FIRST_END_OK 1<<6 -#define LAST_END_OK 1<<7 -#define FILLED_OK 1<<8 -#define SMOOTHED_OK 1<<9 -#define RELIEF_OK 1<<10 -#define BEZIER_OK 1<<11 -#define MARKER_OK 1<<12 +#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 SMOOTHED_BIT 1<<2 /* If we `smooth' the path with Bezier curves */ +#define BEZIER_BIT 1<<3 /* If we interpret the vertices as Bezier controls. */ + +#define CCW 1<<5 /* Tell if the vertices are described in + * clockwise or ccw order. */ +#define FIRST_END_OK 1<<6 +#define LAST_END_OK 1<<7 +#define FILLED_OK 1<<8 +#define SMOOTHED_OK 1<<9 +#define RELIEF_OK 1<<10 +#define BEZIER_OK 1<<11 +#define MARKER_OK 1<<12 /* @@ -74,7 +74,7 @@ typedef struct _CurveItemStruct { ItemStruct header; /* Public data */ - RadarList points; + ZnList points; unsigned int flags; Pixmap marker; LineEnd first_end; /* These two are considered only if relief is flat */ @@ -85,84 +85,84 @@ typedef struct _CurveItemStruct { ReliefStyle relief; int line_width; /* If 0 the path is not drawn, if <2 relief is flat */ Pixmap fill_pattern; - RadarColor fill_color; + ZnColor fill_color; Pixmap line_pattern; - RadarColor line_color; - RadarColor marker_color; + ZnColor line_color; + ZnColor marker_color; char *tile_name; /* Private data */ - RadarImage tile; - RadarList dev_points; - RadarColorGradient gradient; + ZnImage tile; + ZnList dev_points; + ZnColorGradient gradient; } CurveItemStruct, *CurveItem; /* - * Need RADAR_COORDS_FLAG in -smoothed and -bezier because + * Need ZN_COORDS_FLAG in -smoothed and -bezier because * -relief may need a reversing of vertices and this is done * lazily. */ -static RadarAttrConfig cv_attrs[] = { - { RADAR_CONFIG_BOOL, "-bezier", NULL, +static ZnAttrConfig cv_attrs[] = { + { ZN_CONFIG_BOOL, "-bezier", NULL, Tk_Offset(CurveItemStruct, flags), BEZIER_BIT, - RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_CAP_STYLE, "-capstyle", NULL, + ZN_COORDS_FLAG, False }, + { ZN_CONFIG_CAP_STYLE, "-capstyle", NULL, Tk_Offset(CurveItemStruct, cap_style), 0, - RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_BOOL, "-composerotation", NULL, + ZN_COORDS_FLAG, False }, + { ZN_CONFIG_BOOL, "-composerotation", NULL, Tk_Offset(CurveItemStruct, header.flags), COMPOSE_ROTATION_BIT, - RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_BOOL, "-composescale", NULL, + ZN_COORDS_FLAG, False }, + { ZN_CONFIG_BOOL, "-composescale", NULL, Tk_Offset(CurveItemStruct, header.flags), COMPOSE_SCALE_BIT, - RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_COLOR, "-fillcolor", NULL, + ZN_COORDS_FLAG, False }, + { ZN_CONFIG_COLOR, "-fillcolor", NULL, Tk_Offset(CurveItemStruct, fill_color), 0, - RADAR_DRAW_FLAG|RADAR_BORDER_FLAG, False }, - { RADAR_CONFIG_PATTERN, "-fillpattern", NULL, - Tk_Offset(CurveItemStruct, fill_pattern), 0, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_BOOL, "-filled", NULL, - Tk_Offset(CurveItemStruct, flags), FILLED_BIT, RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_LINE_END, "-firstend", NULL, - Tk_Offset(CurveItemStruct, first_end), 0, RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_JOIN_STYLE, "-joinstyle", NULL, + ZN_DRAW_FLAG|ZN_BORDER_FLAG, False }, + { ZN_CONFIG_PATTERN, "-fillpattern", NULL, + Tk_Offset(CurveItemStruct, fill_pattern), 0, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_BOOL, "-filled", NULL, + Tk_Offset(CurveItemStruct, flags), FILLED_BIT, ZN_COORDS_FLAG, False }, + { ZN_CONFIG_LINE_END, "-firstend", NULL, + Tk_Offset(CurveItemStruct, first_end), 0, ZN_COORDS_FLAG, False }, + { ZN_CONFIG_JOIN_STYLE, "-joinstyle", NULL, Tk_Offset(CurveItemStruct, join_style), 0, - RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_LINE_END, "-lastend", NULL, - Tk_Offset(CurveItemStruct, last_end), 0, RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_COLOR, "-linecolor", NULL, + ZN_COORDS_FLAG, False }, + { ZN_CONFIG_LINE_END, "-lastend", NULL, + Tk_Offset(CurveItemStruct, last_end), 0, ZN_COORDS_FLAG, False }, + { ZN_CONFIG_COLOR, "-linecolor", NULL, Tk_Offset(CurveItemStruct, line_color), 0, - RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_PATTERN, "-linepattern", NULL, - Tk_Offset(CurveItemStruct, line_pattern), 0, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_LINE_STYLE, "-linestyle", NULL, - Tk_Offset(CurveItemStruct, line_style), 0, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_DIM, "-linewidth", NULL, - Tk_Offset(CurveItemStruct, line_width), 0, RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_PRI, "-priority", NULL, + ZN_DRAW_FLAG, False }, + { ZN_CONFIG_PATTERN, "-linepattern", NULL, + Tk_Offset(CurveItemStruct, line_pattern), 0, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_LINE_STYLE, "-linestyle", NULL, + Tk_Offset(CurveItemStruct, line_style), 0, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_DIM, "-linewidth", NULL, + Tk_Offset(CurveItemStruct, line_width), 0, ZN_COORDS_FLAG, False }, + { ZN_CONFIG_PRI, "-priority", NULL, Tk_Offset(CurveItemStruct, header.priority), 0, - RADAR_DRAW_FLAG|RADAR_REPICK_FLAG, False }, - { RADAR_CONFIG_PATTERN, "-marker", NULL, - Tk_Offset(CurveItemStruct, marker), 0, RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_COLOR, "-markercolor", NULL, - Tk_Offset(CurveItemStruct, marker_color), 0, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_RELIEF, "-relief", NULL, Tk_Offset(CurveItemStruct, relief), 0, - RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_BOOL, "-sensitive", NULL, + ZN_DRAW_FLAG|ZN_REPICK_FLAG, False }, + { ZN_CONFIG_PATTERN, "-marker", NULL, + Tk_Offset(CurveItemStruct, marker), 0, ZN_COORDS_FLAG, False }, + { ZN_CONFIG_COLOR, "-markercolor", NULL, + Tk_Offset(CurveItemStruct, marker_color), 0, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_RELIEF, "-relief", NULL, Tk_Offset(CurveItemStruct, relief), 0, + ZN_COORDS_FLAG, False }, + { ZN_CONFIG_BOOL, "-sensitive", NULL, Tk_Offset(CurveItemStruct, header.flags), SENSITIVE_BIT, - RADAR_REPICK_FLAG, False }, - { RADAR_CONFIG_BOOL, "-smoothed", NULL, + ZN_REPICK_FLAG, False }, + { ZN_CONFIG_BOOL, "-smoothed", NULL, Tk_Offset(CurveItemStruct, flags), SMOOTHED_BIT, - RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_TAGS, "-tags", NULL, + ZN_COORDS_FLAG, False }, + { ZN_CONFIG_TAGS, "-tags", NULL, Tk_Offset(CurveItemStruct, header.tags), 0, 0, False }, - { RADAR_CONFIG_IMAGE, "-tile", NULL, + { ZN_CONFIG_IMAGE, "-tile", NULL, Tk_Offset(CurveItemStruct, tile_name), 0, - RADAR_DRAW_FLAG|RADAR_TILE_FLAG, False }, - { RADAR_CONFIG_BOOL, "-visible", NULL, + ZN_DRAW_FLAG|ZN_TILE_FLAG, False }, + { ZN_CONFIG_BOOL, "-visible", NULL, Tk_Offset(CurveItemStruct, header.flags), VISIBLE_BIT, - RADAR_DRAW_FLAG|RADAR_REPICK_FLAG|RADAR_VIS_FLAG, False }, + ZN_DRAW_FLAG|ZN_REPICK_FLAG|ZN_VIS_FLAG, False }, - { RADAR_CONFIG_END, NULL, NULL, 0, 0, 0 } + { ZN_CONFIG_END, NULL, NULL, 0, 0, 0 } }; @@ -175,17 +175,17 @@ static RadarAttrConfig cv_attrs[] = { */ static void CvTileChange(ClientData client_data, - int x, - int y, - int width, - int height, - int image_width, - int image_height) + int x, + int y, + int width, + int height, + int image_width, + int image_height) { CurveItem cv = (CurveItem) client_data; InvalidateImage(cv->tile); - ITEM.Invalidate((Item) cv, RADAR_COORDS_FLAG); + ITEM.Invalidate((Item) cv, ZN_COORDS_FLAG); } @@ -205,7 +205,7 @@ Init(Item item, CurveItem cv = (CurveItem) item; Arg *elems; int i, result, num_elems; - RadarPoint p; + ZnPoint p; #ifdef PTK LangFreeProc *freeProc = NULL; #endif @@ -222,10 +222,10 @@ Init(Item item, if (*argc < 1) { Tcl_AppendResult(wi->interp, " curve coords expected", NULL); - return RADAR_ERROR; + return ZN_ERROR; } result = Lang_SplitList(wi->interp, (*args)[0], &num_elems, &elems, &freeProc); - if ((result == RADAR_ERROR) || ((num_elems%2) != 0)) { + if ((result == ZN_ERROR) || ((num_elems%2) != 0)) { cv_error: #ifdef PTK if (elems != NULL && freeProc) { @@ -233,24 +233,24 @@ Init(Item item, } #endif Tcl_AppendResult(wi->interp, " malformed curve coords", NULL); - return RADAR_ERROR; + return ZN_ERROR; } - cv->points = RadarListNew(num_elems/2, sizeof(RadarPoint)); + cv->points = ZnListNew(num_elems/2, sizeof(ZnPoint)); for (i = 0; i < num_elems; i += 2) { - if (Tcl_GetDouble(wi->interp, elems[i], &p.x) == RADAR_ERROR) { + if (Tcl_GetDouble(wi->interp, elems[i], &p.x) == ZN_ERROR) { cv_error2: #ifndef PTK Tcl_Free((char *) elems); #endif - RadarListFree(cv->points); + ZnListFree(cv->points); cv->points = NULL; goto cv_error; } - if (Tcl_GetDouble(wi->interp, elems[i+1], &p.y) == RADAR_ERROR) { + if (Tcl_GetDouble(wi->interp, elems[i+1], &p.y) == ZN_ERROR) { goto cv_error2; } - RadarListAdd(cv->points, &p, RadarListTail); + ZnListAdd(cv->points, &p, ZnListTail); } (*args)++; (*argc)--; @@ -271,9 +271,9 @@ Init(Item item, cv->relief = RELIEF_FLAT; cv->line_width = 1; cv->tile_name = ""; - cv->tile = RadarUnspecifiedImage; - cv->fill_pattern = RadarUnspecifiedPattern; - cv->line_pattern = RadarUnspecifiedPattern; + cv->tile = ZnUnspecifiedImage; + cv->fill_pattern = ZnUnspecifiedPattern; + cv->line_pattern = ZnUnspecifiedPattern; cv->cap_style = CapRound; cv->join_style = JoinRound; @@ -282,12 +282,12 @@ Init(Item item, * being unspecified. */ SET(cv->flags, MARKED_BIT); - cv->marker = RadarUnspecifiedPattern; - cv->fill_color = RadarGetColorByValue(wi->win, wi->fore_color); - cv->line_color = RadarGetColorByValue(wi->win, wi->fore_color); - cv->marker_color = RadarGetColorByValue(wi->win, wi->fore_color); + cv->marker = ZnUnspecifiedPattern; + cv->fill_color = ZnGetColorByValue(wi->win, wi->fore_color); + cv->line_color = ZnGetColorByValue(wi->win, wi->fore_color); + cv->marker_color = ZnGetColorByValue(wi->win, wi->fore_color); - return RADAR_OK; + return ZN_OK; } @@ -308,12 +308,12 @@ Clone(Item item) cv->dev_points = NULL; if (cv->gradient) { - cv->gradient = RadarGetColorGradientByValue(cv->gradient); + cv->gradient = ZnGetColorGradientByValue(cv->gradient); } if (cv->points) { - cv->points = RadarListDuplicate(cv->points); + cv->points = ZnListDuplicate(cv->points); } - if (cv->line_pattern != RadarUnspecifiedPattern) { + if (cv->line_pattern != ZnUnspecifiedPattern) { cv->line_pattern = Tk_GetBitmap(wi->interp, wi->win, Tk_NameOfBitmap(wi->dpy, cv->line_pattern)); } @@ -324,23 +324,23 @@ Clone(Item item) LineEndDuplicate(cv->last_end); } if (strlen(cv->tile_name) != 0) { - text = RadarMalloc((strlen(cv->tile_name) + 1) * sizeof(char)); + text = ZnMalloc((strlen(cv->tile_name) + 1) * sizeof(char)); strcpy(text, cv->tile_name); cv->tile_name = text; cv->tile = Tk_GetImage(wi->interp, wi->win, cv->tile_name, CvTileChange, (ClientData) cv); } - if (cv->fill_pattern != RadarUnspecifiedPattern) { + if (cv->fill_pattern != ZnUnspecifiedPattern) { cv->fill_pattern = Tk_GetBitmap(wi->interp, wi->win, Tk_NameOfBitmap(wi->dpy, cv->fill_pattern)); } - if (cv->marker != RadarUnspecifiedPattern) { + if (cv->marker != ZnUnspecifiedPattern) { cv->marker = Tk_GetBitmap(wi->interp, wi->win, Tk_NameOfBitmap(wi->dpy, cv->marker)); } - cv->line_color = RadarGetColorByValue(wi->win, cv->line_color); - cv->fill_color = RadarGetColorByValue(wi->win, cv->fill_color); - cv->marker_color = RadarGetColorByValue(wi->win, cv->marker_color); + cv->line_color = ZnGetColorByValue(wi->win, cv->line_color); + cv->fill_color = ZnGetColorByValue(wi->win, cv->fill_color); + cv->marker_color = ZnGetColorByValue(wi->win, cv->marker_color); } @@ -358,10 +358,10 @@ Destroy(Item item) CurveItem cv = (CurveItem) item; if (cv->points) { - RadarListFree(cv->points); + ZnListFree(cv->points); } if (cv->dev_points) { - RadarListFree(cv->dev_points); + ZnListFree(cv->dev_points); } if (cv->first_end) { LineEndDelete(cv->first_end); @@ -370,27 +370,27 @@ Destroy(Item item) LineEndDelete(cv->last_end); } if (cv->gradient) { - RadarFreeColorGradient(cv->gradient); + ZnFreeColorGradient(cv->gradient); } if (strlen(cv->tile_name) != 0) { - RadarFree(cv->tile_name); + ZnFree(cv->tile_name); } - if (cv->tile != RadarUnspecifiedImage) { + if (cv->tile != ZnUnspecifiedImage) { Tk_FreeImage(cv->tile); - cv->tile = RadarUnspecifiedImage; + cv->tile = ZnUnspecifiedImage; } - if (cv->line_pattern != RadarUnspecifiedPattern) { + if (cv->line_pattern != ZnUnspecifiedPattern) { Tk_FreeBitmap(wi->dpy, cv->line_pattern); } - if (cv->fill_pattern != RadarUnspecifiedPattern) { + if (cv->fill_pattern != ZnUnspecifiedPattern) { Tk_FreeBitmap(wi->dpy, cv->fill_pattern); } - if (cv->marker != RadarUnspecifiedPattern) { + if (cv->marker != ZnUnspecifiedPattern) { Tk_FreeBitmap(wi->dpy, cv->marker); } - RadarFreeColor(cv->fill_color); - RadarFreeColor(cv->line_color); - RadarFreeColor(cv->marker_color); + ZnFreeColor(cv->fill_color); + ZnFreeColor(cv->line_color); + ZnFreeColor(cv->marker_color); } @@ -406,33 +406,33 @@ static void SetRenderFlags(CurveItem cv) { ASSIGN(cv->flags, FILLED_OK, - ISSET(cv->flags, FILLED_BIT) && (RadarListSize(cv->points) > 2)); + ISSET(cv->flags, FILLED_BIT) && (ZnListSize(cv->points) > 2)); ASSIGN(cv->flags, BEZIER_OK, - ISSET(cv->flags, BEZIER_BIT) && (RadarListSize(cv->points) > 2) && + ISSET(cv->flags, BEZIER_BIT) && (ZnListSize(cv->points) > 2) && (ISSET(cv->flags, FILLED_BIT) || cv->line_width)); ASSIGN(cv->flags, SMOOTHED_OK, - ISSET(cv->flags, SMOOTHED_BIT) && (RadarListSize(cv->points) > 2) && + ISSET(cv->flags, SMOOTHED_BIT) && (ZnListSize(cv->points) > 2) && ISCLEAR(cv->flags, BEZIER_OK) && (ISSET(cv->flags, FILLED_BIT) || cv->line_width)); ASSIGN(cv->flags, RELIEF_OK, - (cv->relief != RELIEF_FLAT) && (RadarListSize(cv->points) > 1) && + (cv->relief != RELIEF_FLAT) && (ZnListSize(cv->points) > 1) && (cv->line_width > 1) && ISCLEAR(cv->flags, SMOOTHED_OK) && ISCLEAR(cv->flags, BEZIER_OK)); ASSIGN(cv->flags, MARKER_OK, - (cv->marker != RadarUnspecifiedPattern) && ISCLEAR(cv->flags, BEZIER_OK) && + (cv->marker != ZnUnspecifiedPattern) && ISCLEAR(cv->flags, BEZIER_OK) && ISCLEAR(cv->flags, SMOOTHED_OK) && ISCLEAR(cv->flags, RELIEF_OK)); ASSIGN(cv->flags, FIRST_END_OK, - (cv->first_end != NULL) && (RadarListSize(cv->points) > 1) && + (cv->first_end != NULL) && (ZnListSize(cv->points) > 1) && ISCLEAR(cv->flags, FILLED_BIT) && cv->line_width && ISCLEAR(cv->flags, RELIEF_OK)); ASSIGN(cv->flags, LAST_END_OK, - (cv->last_end != NULL) && (RadarListSize(cv->points) > 1) && + (cv->last_end != NULL) && (ZnListSize(cv->points) > 1) && ISCLEAR(cv->flags, FILLED_BIT) && cv->line_width && ISCLEAR(cv->flags, RELIEF_OK)); } @@ -448,26 +448,26 @@ SetRenderFlags(CurveItem cv) static int Configure(Item item, int argc, - RadarAttrList argv, + ZnAttrList argv, int *flags) { WidgetInfo *wi = item->wi; CurveItem cv = (CurveItem) item; - if (ITEM_P.ConfigureAttributes((char *) item, -1, argc, argv, flags) == RADAR_ERROR) { - return RADAR_ERROR; + if (ITEM_P.ConfigureAttributes((char *) item, -1, argc, argv, flags) == ZN_ERROR) { + return ZN_ERROR; } if (cv->gradient && - (ISSET(*flags, RADAR_BORDER_FLAG) || (cv->relief == RELIEF_FLAT))) { - RadarFreeColorGradient(cv->gradient); + (ISSET(*flags, ZN_BORDER_FLAG) || (cv->relief == RELIEF_FLAT))) { + ZnFreeColorGradient(cv->gradient); cv->gradient = NULL; } if ((cv->relief != RELIEF_FLAT) && !cv->gradient) { - cv->gradient = RadarGetReliefGradient(wi->interp, wi->win, - RadarNameOfColor(cv->fill_color)); + cv->gradient = ZnGetReliefGradient(wi->interp, wi->win, + ZnNameOfColor(cv->fill_color)); } - if (ISSET(*flags, RADAR_TILE_FLAG)) { + if (ISSET(*flags, ZN_TILE_FLAG)) { Tk_Image tile; if (strcmp(cv->tile_name, "") != 0) { @@ -478,13 +478,13 @@ Configure(Item item, * The name will not be in sync with the image in * this case. */ - return RADAR_ERROR; + return ZN_ERROR; } } else { - tile = RadarUnspecifiedImage; + tile = ZnUnspecifiedImage; } - if (cv->tile != RadarUnspecifiedImage) { + if (cv->tile != ZnUnspecifiedImage) { Tk_FreeImage(cv->tile); } cv->tile = tile; @@ -492,7 +492,7 @@ Configure(Item item, SetRenderFlags(cv); - return RADAR_OK; + return ZN_OK; } @@ -506,22 +506,22 @@ Configure(Item item, static int Query(Item item, int argc, - RadarAttrList argv) + ZnAttrList argv) { - if (ITEM_P.QueryAttribute((char *) item, -1, argv[0]) == RADAR_ERROR) { - return RADAR_ERROR; + if (ITEM_P.QueryAttribute((char *) item, -1, argv[0]) == ZN_ERROR) { + return ZN_ERROR; } - return RADAR_OK; + return ZN_OK; } -static RadarBool -TestCCW(RadarPoint *points, - int num_points) +static ZnBool +TestCCW(ZnPoint *points, + int num_points) { - RadarPoint *p, *p_p, *p_n, min; - RadarReal xprod; + ZnPoint *p, *p_p, *p_n, min; + ZnReal xprod; int i, min_index; if (num_points < 3) { @@ -565,16 +565,16 @@ TestCCW(RadarPoint *points, */ static void ComputeCoordinates(Item item, - RadarBool force) + ZnBool force) { WidgetInfo *wi = item->wi; CurveItem cv = (CurveItem) item; int i, j; - RadarPoint *points; - RadarPoint end_points[LINE_END_POINTS]; - RadarPoint *dev_points, *p; + ZnPoint *points; + ZnPoint end_points[LINE_END_POINTS]; + ZnPoint *dev_points, *p; int num_points; - RadarBBox bbox; + ZnBBox bbox; int lw; ResetBBox(&item->item_bounding_box); @@ -582,17 +582,17 @@ ComputeCoordinates(Item item, return; } - points = (RadarPoint *) RadarListArray(cv->points); - num_points = RadarListSize(cv->points); + points = (ZnPoint *) ZnListArray(cv->points); + num_points = ZnListSize(cv->points); /* * Allocate space for devices coordinates */ if (cv->dev_points == NULL) { - cv->dev_points = RadarListNew(num_points, sizeof(RadarPoint)); + cv->dev_points = ZnListNew(num_points, sizeof(ZnPoint)); } - RadarListAssertSize(cv->dev_points, num_points); - dev_points = (RadarPoint *) RadarListArray(cv->dev_points); + ZnListAssertSize(cv->dev_points, num_points); + dev_points = (ZnPoint *) ZnListArray(cv->dev_points); /* * Process all points, skipping adjacent points that transform @@ -603,7 +603,7 @@ ComputeCoordinates(Item item, * Identical vertices are no longer skipped to allow a better control * on Bezier curves and smoothing. */ - RadarTransformPoint(wi->current_transfo, &points[i], &dev_points[j]); + ZnTransformPoint(wi->current_transfo, &points[i], &dev_points[j]); /* if ((j == 0) || (dev_points[j].x != dev_points[j-1].x) || (dev_points[j].y != dev_points[j-1].y)) { @@ -615,15 +615,15 @@ ComputeCoordinates(Item item, /* * Adjust the device coords list to the actual size. */ - RadarListTruncate(cv->dev_points, j); - /*printf("==========num_points %d=============\n", RadarListSize(cv->dev_points));*/ + ZnListTruncate(cv->dev_points, j); + /*printf("==========num_points %d=============\n", ZnListSize(cv->dev_points));*/ lw = cv->line_width; ASSIGN(cv->flags, CCW, TestCCW(dev_points, num_points)); if (ISCLEAR(cv->flags, CCW)) { if (ISSET(cv->flags, RELIEF_OK)) { - RadarPoint tmp; + ZnPoint tmp; int mid = num_points/2; /* * Revert the points to draw the relief inside. @@ -664,7 +664,7 @@ ComputeCoordinates(Item item, * Take care of miters. */ if (cv->join_style == JoinMiter) { - RadarPoint miter_i, miter_o; + ZnPoint miter_i, miter_o; for (i = j, p = dev_points; i >= 3; i--, p++) { GetMiterPoints(p, p+1, p+2, lw, &miter_i, &miter_o); AddPointToBBox(&item->item_bounding_box, miter_i.x, miter_i.y); @@ -676,8 +676,8 @@ ComputeCoordinates(Item item, * Add the markers. */ if (ISSET(cv->flags, MARKER_OK)) { - int w, h; - RadarBBox bbox; + int w, h; + ZnBBox bbox; Tk_SizeOfBitmap(wi->dpy, cv->marker, &w, &h); w = w/2 + 2; @@ -727,24 +727,24 @@ ComputeCoordinates(Item item, ********************************************************************************** */ static int -ToArea(Item item, - RadarBBox *area, - Tk_Uid tag_uid, - int enclosed, - RadarBool report) +ToArea(Item item, + ZnBBox *area, + Tk_Uid tag_uid, + int enclosed, + ZnBool report) { CurveItem cv = (CurveItem) item; WidgetInfo *wi = item->wi; - RadarBBox bbox; - RadarPoint *points; - RadarPoint end_points[LINE_END_POINTS]; + ZnBBox bbox; + ZnPoint *points; + ZnPoint end_points[LINE_END_POINTS]; int num_points, result, result2; - RadarList actual_points; + ZnList actual_points; if (cv->dev_points == NULL) { return -1; } - printf("============== poly %d ==============\n", item->id); + /*printf("============== poly %d ==============\n", item->id);*/ if (ISSET(cv->flags, SMOOTHED_OK)) { SmoothPathWithBezier(cv->dev_points, wi->work_pts); actual_points = wi->work_pts; @@ -757,8 +757,8 @@ ToArea(Item item, actual_points = cv->dev_points; } - points = (RadarPoint *) RadarListArray(actual_points); - num_points = RadarListSize(actual_points); + points = (ZnPoint *) ZnListArray(actual_points); + num_points = ZnListSize(actual_points); if (ISSET(cv->flags, FILLED_OK)) { result = PolygonInBBox(points, num_points, area); @@ -808,10 +808,10 @@ ToArea(Item item, */ if (ISSET(cv->flags, MARKER_OK)) { int num_points, width, height; - RadarPoint *points; + ZnPoint *points; - points = (RadarPoint *) RadarListArray(actual_points); - num_points = RadarListSize(actual_points); + points = (ZnPoint *) ZnListArray(actual_points); + num_points = ZnListSize(actual_points); if (ISSET(cv->flags, FIRST_END_OK)) { num_points--; @@ -855,7 +855,7 @@ Draw(Item item) XGCValues values; int i, num_points; unsigned int gc_mask; - RadarPoint *points; + ZnPoint *points; XPoint *xpoints = NULL; if (cv->dev_points == NULL) { @@ -864,26 +864,26 @@ Draw(Item item) if (ISSET(cv->flags, SMOOTHED_OK)) { SmoothPathWithBezier(cv->dev_points, wi->work_pts); - points = (RadarPoint *) RadarListArray(wi->work_pts); - num_points = RadarListSize(wi->work_pts); + points = (ZnPoint *) ZnListArray(wi->work_pts); + num_points = ZnListSize(wi->work_pts); } else if (ISSET(cv->flags, BEZIER_OK)) { GetBezierPath(cv->dev_points, wi->work_pts); - points = (RadarPoint *) RadarListArray(wi->work_pts); - num_points = RadarListSize(wi->work_pts); + points = (ZnPoint *) ZnListArray(wi->work_pts); + num_points = ZnListSize(wi->work_pts); } else { - points = (RadarPoint *) RadarListArray(cv->dev_points); - num_points = RadarListSize(cv->dev_points); + points = (ZnPoint *) ZnListArray(cv->dev_points); + num_points = ZnListSize(cv->dev_points); } /* * Fill if requested. */ if (ISSET(cv->flags, FILLED_OK)) { - values.foreground = RadarPixel(cv->fill_color); + values.foreground = ZnPixel(cv->fill_color); gc_mask = GCFillStyle; - if (cv->tile != RadarUnspecifiedImage) { /* Fill tiled */ + if (cv->tile != ZnUnspecifiedImage) { /* Fill tiled */ Pixmap pmap = GetImagePixmap(wi->win, cv->tile); values.fill_style = FillTiled; values.tile = pmap; @@ -891,7 +891,7 @@ Draw(Item item) values.ts_y_origin = REAL_TO_INT(item->item_bounding_box.orig.y); gc_mask |= GCTileStipXOrigin|GCTileStipYOrigin|GCTile; } - else if (cv->fill_pattern != RadarUnspecifiedPattern) { /* Fill stippled */ + else if (cv->fill_pattern != ZnUnspecifiedPattern) { /* Fill stippled */ values.fill_style = FillStippled; values.stipple = cv->fill_pattern; values.ts_x_origin = REAL_TO_INT(item->item_bounding_box.orig.x); @@ -919,7 +919,7 @@ Draw(Item item) * Draw the lines between points */ if (cv->line_width) { - RadarPoint end_points[LINE_END_POINTS]; + ZnPoint end_points[LINE_END_POINTS]; XPoint xp[LINE_END_POINTS]; /* @@ -931,11 +931,11 @@ Draw(Item item) } else { SetLineStyle(wi->dpy, wi->gc, cv->line_style); - values.foreground = RadarPixel(cv->line_color); + values.foreground = ZnPixel(cv->line_color); values.line_width = (cv->line_width == 1) ? 0 : cv->line_width; values.join_style = cv->join_style; values.cap_style = cv->cap_style; - if (cv->line_pattern == RadarUnspecifiedPattern) { + if (cv->line_pattern == ZnUnspecifiedPattern) { values.fill_style = FillSolid; XChangeGC(wi->dpy, wi->gc, GCFillStyle|GCLineWidth|GCJoinStyle|GCCapStyle|GCForeground, &values); @@ -987,7 +987,7 @@ Draw(Item item) */ if (ISSET(cv->flags, MARKER_OK)) { int width, h_width, height, h_height; - RadarPoint ptmp, *p; + ZnPoint ptmp, *p; int i; i = num_points; @@ -1002,7 +1002,7 @@ Draw(Item item) i--; } - values.foreground = RadarPixel(cv->marker_color); + values.foreground = ZnPixel(cv->marker_color); Tk_SizeOfBitmap(wi->dpy, cv->marker, &width, &height); h_width = (width+1)/2; h_height = (height+1)/2; @@ -1027,8 +1027,8 @@ Draw(Item item) * guess that drawing points is useful. */ if (ISCLEAR(cv->flags, FILLED_OK) && !cv->line_width && - (cv->marker == RadarUnspecifiedPattern)) { - values.foreground = RadarPixel(cv->marker_color); + (cv->marker == ZnUnspecifiedPattern)) { + values.foreground = ZnPixel(cv->marker_color); values.fill_style = FillSolid; XChangeGC(wi->dpy, wi->gc, GCForeground | GCFillStyle, &values); @@ -1051,12 +1051,12 @@ Draw(Item item) * ********************************************************************************** */ -static RadarBool +static ZnBool IsSensitive(Item item, int item_part) { return (ISSET(item->flags, SENSITIVE_BIT) && - item->parent->class->IsSensitive(item->parent, RADAR_NO_PART)); + item->parent->class->IsSensitive(item->parent, ZN_NO_PART)); } @@ -1069,7 +1069,7 @@ IsSensitive(Item item, */ static double Pick(Item item, - RadarPoint *p, + ZnPoint *p, Item start_item, int aperture, Item *a_item, @@ -1077,12 +1077,12 @@ Pick(Item item, { CurveItem cv = (CurveItem) item; WidgetInfo *wi = item->wi; - RadarBBox bbox; + ZnBBox bbox; double dist=1.0e40, new_dist; - RadarPoint *points; - RadarPoint end_points[LINE_END_POINTS]; + ZnPoint *points; + ZnPoint end_points[LINE_END_POINTS]; int num_points; - RadarList actual_points; + ZnList actual_points; if (cv->dev_points == NULL) { return dist; @@ -1101,8 +1101,8 @@ Pick(Item item, actual_points = cv->dev_points; } - points = (RadarPoint *) RadarListArray(actual_points); - num_points = RadarListSize(actual_points); + points = (ZnPoint *) ZnListArray(actual_points); + num_points = ZnListSize(actual_points); if (ISSET(cv->flags, FILLED_OK)) { dist = PolygonToPointDist(points, num_points, p); @@ -1164,10 +1164,10 @@ Pick(Item item, */ if (ISSET(cv->flags, MARKER_OK)) { int num_points, width, height; - RadarPoint *points; + ZnPoint *points; - points = (RadarPoint *) RadarListArray(actual_points); - num_points = RadarListSize(actual_points); + points = (ZnPoint *) ZnListArray(actual_points); + num_points = ZnListSize(actual_points); if (ISSET(cv->flags, FIRST_END_OK)) { num_points--; @@ -1221,10 +1221,10 @@ PostScript(Item item, * ********************************************************************************** */ -static RadarBool -GetClipVertices(Item item, - RadarPoint **points, - int *num_points) +static ZnBool +GetClipVertices(Item item, + ZnPoint **points, + int *num_points) { CurveItem cv = (CurveItem) item; @@ -1232,8 +1232,8 @@ GetClipVertices(Item item, *num_points = 0; if (cv->dev_points) { - *points = (RadarPoint *) RadarListArray(cv->dev_points); - *num_points = RadarListSize(cv->dev_points); + *points = (ZnPoint *) ZnListArray(cv->dev_points); + *num_points = ZnListSize(cv->dev_points); } return False; @@ -1249,64 +1249,64 @@ GetClipVertices(Item item, ********************************************************************************** */ static int -Coords(Item item, - int index, - int cmd, - RadarPoint **pts, - int *num_pts) +Coords(Item item, + int index, + int cmd, + ZnPoint **pts, + int *num_pts) { CurveItem cv = (CurveItem) item; int num_points, i; - RadarPoint *points; + ZnPoint *points; if ((cmd == COORDS_REPLACE) || (cmd == COORDS_REPLACE_ALL)) { if (*num_pts == 0) { Tcl_AppendResult(item->wi->interp, " coords command need at least 1 point on curves", NULL); - return RADAR_ERROR; + return ZN_ERROR; } if (cmd == COORDS_REPLACE_ALL) { - RadarList tmp; + ZnList tmp; replace_all: - tmp = RadarListFromArray(*pts, *num_pts, sizeof(RadarPoint)); + tmp = ZnListFromArray(*pts, *num_pts, sizeof(ZnPoint)); if (!cv->points) { - RadarListEmpty(cv->points); + ZnListEmpty(cv->points); } else { - cv->points = RadarListNew(*num_pts, sizeof(RadarPoint)); + cv->points = ZnListNew(*num_pts, sizeof(ZnPoint)); } - RadarListAppend(cv->points, tmp); - RadarListFree(tmp); + ZnListAppend(cv->points, tmp); + ZnListFree(tmp); } else { if (!cv->points) { edit_err: Tcl_AppendResult(item->wi->interp, " coords command cannot edit empty curves", NULL); - return RADAR_ERROR; + return ZN_ERROR; } - points = RadarListArray(cv->points); - num_points = RadarListSize(cv->points); + points = ZnListArray(cv->points); + num_points = ZnListSize(cv->points); if (index < 0) { index += num_points; } if ((index < 0) || (index >= num_points)) { range_err: Tcl_AppendResult(item->wi->interp, " coord index out of range", NULL); - return RADAR_ERROR; + return ZN_ERROR; } points[index] = (*pts)[0]; } - ITEM.Invalidate(item, RADAR_COORDS_FLAG); + ITEM.Invalidate(item, ZN_COORDS_FLAG); } else if ((cmd == COORDS_READ) || (cmd == COORDS_READ_ALL)) { if (!cv->points) { *num_pts = 0; *pts = NULL; - return RADAR_OK; + return ZN_OK; } - points = RadarListArray(cv->points); - num_points = RadarListSize(cv->points); + points = ZnListArray(cv->points); + num_points = ZnListSize(cv->points); if (cmd == COORDS_READ_ALL) { *num_pts = num_points; *pts = points; @@ -1327,7 +1327,7 @@ Coords(Item item, goto replace_all; } else if (cmd == COORDS_ADD) { - num_points = RadarListSize(cv->points); + num_points = ZnListSize(cv->points); if (index < 0) { index += num_points; } @@ -1335,34 +1335,34 @@ Coords(Item item, goto range_err; } for (i = 0; i < *num_pts; i++, index++) { - RadarListAdd(cv->points, &(*pts)[i], index); + ZnListAdd(cv->points, &(*pts)[i], index); } } else { - RadarList tmp; - tmp = RadarListFromArray(*pts, *num_pts, sizeof(RadarPoint)); - RadarListAppend(cv->points, tmp); - RadarListFree(tmp); + ZnList tmp; + tmp = ZnListFromArray(*pts, *num_pts, sizeof(ZnPoint)); + ZnListAppend(cv->points, tmp); + ZnListFree(tmp); } - ITEM.Invalidate(item, RADAR_COORDS_FLAG); + ITEM.Invalidate(item, ZN_COORDS_FLAG); } else if (cmd == COORDS_REMOVE) { if (!cv->points) { goto edit_err; } - points = RadarListArray(cv->points); - num_points = RadarListSize(cv->points); + points = ZnListArray(cv->points); + num_points = ZnListSize(cv->points); if (index < 0) { index += num_points; } if ((index < 0) || (index >= num_points)) { goto range_err; } - RadarListDelete(cv->points, index); - ITEM.Invalidate(item, RADAR_COORDS_FLAG); + ZnListDelete(cv->points, index); + ITEM.Invalidate(item, ZN_COORDS_FLAG); } - return RADAR_OK; + return ZN_OK; } @@ -1397,4 +1397,4 @@ static ItemClassStruct CURVE_ITEM_CLASS = { PostScript }; -RadarItemClassId RadarCurve = (RadarItemClassId) &CURVE_ITEM_CLASS; +ZnItemClassId ZnCurve = (ZnItemClassId) &CURVE_ITEM_CLASS; |