aboutsummaryrefslogtreecommitdiff
path: root/generic/Curve.c
diff options
context:
space:
mode:
authorlecoanet2003-04-16 09:49:22 +0000
committerlecoanet2003-04-16 09:49:22 +0000
commit3261805fee19e346b4d1f84b23816daa1628764a (patch)
tree63ca1d7e4b0a3d9ae49cc0888e58033c3ef3fe22 /generic/Curve.c
parenteed2656db0adae2c234c3d74af0913746ed5c444 (diff)
downloadtkzinc-3261805fee19e346b4d1f84b23816daa1628764a.zip
tkzinc-3261805fee19e346b4d1f84b23816daa1628764a.tar.gz
tkzinc-3261805fee19e346b4d1f84b23816daa1628764a.tar.bz2
tkzinc-3261805fee19e346b4d1f84b23816daa1628764a.tar.xz
Update from the Windows port and general cleanup/restructure
Diffstat (limited to 'generic/Curve.c')
-rw-r--r--generic/Curve.c693
1 files changed, 353 insertions, 340 deletions
diff --git a/generic/Curve.c b/generic/Curve.c
index 6c9b5ad..b58c59a 100644
--- a/generic/Curve.c
+++ b/generic/Curve.c
@@ -35,10 +35,9 @@
#include "Image.h"
#include "Color.h"
#include "tkZinc.h"
+#include "glu.h"
#include <ctype.h>
-#include <malloc.h>
-#include <GL/glu.h>
static const char rcsid[] = "$Id$";
static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " $";
@@ -67,7 +66,7 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
**********************************************************************************
*/
typedef struct _CurveItemStruct {
- ItemStruct header;
+ ZnItemStruct header;
/* Public data */
ZnPoly shape;
@@ -75,10 +74,10 @@ typedef struct _CurveItemStruct {
ZnImage marker;
ZnLineEnd first_end; /* These two are considered only if relief is flat */
ZnLineEnd last_end;
- LineStyle line_style; /* This is considered only if relief is flat */
+ ZnLineStyle line_style; /* This is considered only if relief is flat */
int cap_style;
int join_style;
- ReliefStyle relief;
+ ZnReliefStyle relief;
ZnDim line_width; /* If 0 the path is not drawn, if <2 relief is flat */
ZnImage fill_pattern;
ZnGradient *fill_color;
@@ -102,13 +101,13 @@ static ZnAttrConfig cv_attrs[] = {
{ ZN_CONFIG_BOOL, "-closed", NULL,
Tk_Offset(CurveItemStruct, flags), CLOSED_BIT, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_BOOL, "-composealpha", NULL,
- Tk_Offset(CurveItemStruct, header.flags), COMPOSE_ALPHA_BIT,
+ Tk_Offset(CurveItemStruct, header.flags), ZN_COMPOSE_ALPHA_BIT,
ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-composerotation", NULL,
- Tk_Offset(CurveItemStruct, header.flags), COMPOSE_ROTATION_BIT,
+ Tk_Offset(CurveItemStruct, header.flags), ZN_COMPOSE_ROTATION_BIT,
ZN_COORDS_FLAG, False },
{ ZN_CONFIG_BOOL, "-composescale", NULL,
- Tk_Offset(CurveItemStruct, header.flags), COMPOSE_SCALE_BIT,
+ Tk_Offset(CurveItemStruct, header.flags), ZN_COMPOSE_SCALE_BIT,
ZN_COORDS_FLAG, False },
{ ZN_CONFIG_GRADIENT, "-fillcolor", NULL,
Tk_Offset(CurveItemStruct, fill_color), 0,
@@ -145,7 +144,7 @@ static ZnAttrConfig cv_attrs[] = {
{ 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,
+ Tk_Offset(CurveItemStruct, header.flags), ZN_SENSITIVE_BIT,
ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-smoothrelief", NULL,
Tk_Offset(CurveItemStruct, flags), SMOOTH_RELIEF_BIT,
@@ -155,10 +154,10 @@ static ZnAttrConfig cv_attrs[] = {
{ ZN_CONFIG_IMAGE, "-tile", NULL,
Tk_Offset(CurveItemStruct, tile), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-visible", NULL,
- Tk_Offset(CurveItemStruct, header.flags), VISIBLE_BIT,
+ Tk_Offset(CurveItemStruct, header.flags), ZN_VISIBLE_BIT,
ZN_DRAW_FLAG|ZN_REPICK_FLAG|ZN_VIS_FLAG, False },
- { ZN_CONFIG_END, NULL, NULL, 0, 0, 0 }
+ { ZN_CONFIG_END, NULL, NULL, 0, 0, 0, False }
};
@@ -170,13 +169,13 @@ static ZnAttrConfig cv_attrs[] = {
**********************************************************************************
*/
static int
-Init(Item item,
+Init(ZnItem item,
int *argc,
Tcl_Obj *CONST *args[])
{
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
CurveItem cv = (CurveItem) item;
- int i, num_points, count;
+ unsigned int i, num_points, count;
ZnPoint *p, *points;
char *controls;
@@ -188,28 +187,27 @@ Init(Item item,
cv->grad_geo = NULL;
/* Init attributes */
- SET(item->flags, VISIBLE_BIT);
- SET(item->flags, SENSITIVE_BIT);
- SET(item->flags, COMPOSE_ALPHA_BIT);
- SET(item->flags, COMPOSE_ROTATION_BIT);
- SET(item->flags, COMPOSE_SCALE_BIT);
+ SET(item->flags, ZN_VISIBLE_BIT);
+ SET(item->flags, ZN_SENSITIVE_BIT);
+ SET(item->flags, ZN_COMPOSE_ALPHA_BIT);
+ SET(item->flags, ZN_COMPOSE_ROTATION_BIT);
+ SET(item->flags, ZN_COMPOSE_SCALE_BIT);
CLEAR(cv->flags, CLOSED_BIT);
CLEAR(cv->flags, SMOOTH_RELIEF_BIT);
cv->fill_rule = GLU_TESS_WINDING_ODD;
-
- item->priority = DEFAULT_CURVE_PRIORITY;
+ item->priority = 1;
if (*argc < 1) {
Tcl_AppendResult(wi->interp, " curve coords expected", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (ZnParseCoordList(wi, (*args)[0], &points,
- &controls, &num_points, NULL) == ZN_ERROR) {
- return ZN_ERROR;
+ &controls, &num_points, NULL) == TCL_ERROR) {
+ return TCL_ERROR;
}
if (num_points == 0) {
- POLY_INIT(&cv->shape);
+ ZnPolyInit(&cv->shape);
}
else {
/*
@@ -236,7 +234,7 @@ Init(Item item,
contr_err:
ZnFree(controls);
Tcl_AppendResult(wi->interp, " curve coords expected", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
}
}
@@ -248,7 +246,7 @@ Init(Item item,
/*printf("plain contour, numpoints: %d %g@%g\n",
num_points, points[0].x, points[0].y);*/
memcpy(p, points, num_points * sizeof(ZnPoint));
- POLY_CONTOUR1(&cv->shape, p, num_points, False);
+ ZnPolyContour1(&cv->shape, p, num_points, False);
cv->shape.contours[0].controls = controls;
}
(*args)++;
@@ -257,8 +255,8 @@ Init(Item item,
CLEAR(cv->flags, FILLED_BIT);
cv->first_end = NULL;
cv->last_end = NULL;
- cv->line_style = LINE_SIMPLE;
- cv->relief = RELIEF_FLAT;
+ cv->line_style = ZN_LINE_SIMPLE;
+ cv->relief = ZN_RELIEF_FLAT;
cv->line_width = 1;
cv->tile = ZnUnspecifiedImage;
cv->fill_pattern = ZnUnspecifiedImage;
@@ -276,7 +274,7 @@ Init(Item item,
cv->line_color = ZnGetGradientByValue(wi->fore_color);
cv->marker_color = ZnGetGradientByValue(wi->fore_color);
- return ZN_OK;
+ return TCL_OK;
}
@@ -288,17 +286,12 @@ Init(Item item,
**********************************************************************************
*/
static void
-Clone(Item item)
+Clone(ZnItem item)
{
CurveItem cv = (CurveItem) item;
- int i;
+ unsigned int i;
ZnContour *conts;
- if (cv->grad_geo) {
- ZnPoint *grad_geo = ZnMalloc(4*sizeof(ZnPoint));
- memcpy(grad_geo, cv->grad_geo, 4*sizeof(ZnPoint));
- cv->grad_geo = grad_geo;
- }
if (cv->shape.num_contours) {
conts = cv->shape.contours;
@@ -324,10 +317,10 @@ Clone(Item item)
cv->gradient = ZnGetGradientByValue(cv->gradient);
}
if (cv->first_end) {
- LineEndDuplicate(cv->first_end);
+ ZnLineEndDuplicate(cv->first_end);
}
if (cv->last_end) {
- LineEndDuplicate(cv->last_end);
+ ZnLineEndDuplicate(cv->last_end);
}
if (cv->tile != ZnUnspecifiedImage) {
cv->tile = ZnGetImageByValue(cv->tile);
@@ -343,6 +336,7 @@ Clone(Item item)
}
cv->line_color = ZnGetGradientByValue(cv->line_color);
cv->fill_color = ZnGetGradientByValue(cv->fill_color);
+ cv->grad_geo = NULL;
cv->marker_color = ZnGetGradientByValue(cv->marker_color);
cv->tristrip.num_strips = 0;
cv->tristrip.strips = NULL;
@@ -359,10 +353,10 @@ Clone(Item item)
**********************************************************************************
*/
static void
-Destroy(Item item)
+Destroy(ZnItem item)
{
CurveItem cv = (CurveItem) item;
- int i;
+ unsigned int i;
/*
* Need to free the control array here, it is only known
@@ -373,16 +367,16 @@ Destroy(Item item)
ZnFree(cv->shape.contours[i].controls);
}
}
- POLY_FREE(&cv->shape);
+ ZnPolyFree(&cv->shape);
if (cv->grad_geo) {
ZnFree(cv->grad_geo);
}
if (cv->first_end) {
- LineEndDelete(cv->first_end);
+ ZnLineEndDelete(cv->first_end);
}
if (cv->last_end) {
- LineEndDelete(cv->last_end);
+ ZnLineEndDelete(cv->last_end);
}
if (cv->gradient) {
ZnFreeGradient(cv->gradient);
@@ -408,10 +402,10 @@ Destroy(Item item)
ZnFreeGradient(cv->marker_color);
if (cv->tristrip.num_strips) {
- TRI_FREE(&cv->tristrip);
+ ZnTriFree(&cv->tristrip);
}
if (cv->outlines.num_contours) {
- POLY_FREE(&cv->outlines);
+ ZnPolyFree(&cv->outlines);
}
}
@@ -431,7 +425,7 @@ SetRenderFlags(CurveItem cv)
ISSET(cv->flags, FILLED_BIT) && (cv->shape.num_contours >= 1));
ASSIGN(cv->flags, RELIEF_OK,
- (cv->relief != RELIEF_FLAT) &&
+ (cv->relief != ZN_RELIEF_FLAT) &&
(cv->shape.num_contours >= 1) &&
(cv->line_width > 1));
@@ -462,30 +456,30 @@ SetRenderFlags(CurveItem cv)
**********************************************************************************
*/
static int
-Configure(Item item,
+Configure(ZnItem item,
int argc,
Tcl_Obj *CONST argv[],
int *flags)
{
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
CurveItem cv = (CurveItem) item;
- int status = ZN_OK;
+ int status = TCL_OK;
XColor *color;
- int alpha;
+ unsigned short alpha;
status = ZnConfigureAttributes(wi, item, cv_attrs, argc, argv, flags);
if (cv->gradient &&
- (ISSET(*flags, ZN_BORDER_FLAG) || (cv->relief == RELIEF_FLAT))) {
+ (ISSET(*flags, ZN_BORDER_FLAG) || (cv->relief == ZN_RELIEF_FLAT))) {
ZnFreeGradient(cv->gradient);
cv->gradient = NULL;
}
- if ((cv->relief != RELIEF_FLAT) && !cv->gradient) {
+ if ((cv->relief != ZN_RELIEF_FLAT) && !cv->gradient) {
color = ZnGetGradientColor(cv->line_color, 51.0, &alpha);
cv->gradient = ZnGetReliefGradient(wi->interp, wi->win,
- ZnNameOfColor(color), alpha);
+ Tk_NameOfColor(color), alpha);
if (cv->gradient == NULL) {
- status = ZN_ERROR;
+ status = TCL_ERROR;
}
}
@@ -501,15 +495,15 @@ Configure(Item item,
**********************************************************************************
*/
static int
-Query(Item item,
- int argc,
+Query(ZnItem item,
+ int argc __unused,
Tcl_Obj *CONST argv[])
{
- if (ZnQueryAttribute(item->wi, item, cv_attrs, argv[0]) == ZN_ERROR) {
- return ZN_ERROR;
+ if (ZnQueryAttribute(item->wi, item, cv_attrs, argv[0]) == TCL_ERROR) {
+ return TCL_ERROR;
}
- return ZN_OK;
+ return TCL_OK;
}
@@ -518,7 +512,7 @@ CurveTessBegin(GLenum type,
void *data)
{
CurveItem cv = data;
- WidgetInfo *wi = ((Item) data)->wi;
+ ZnWInfo *wi = ((ZnItem) data)->wi;
ZnListEmpty(wi->work_pts);
wi->tess_type = type;
@@ -544,7 +538,7 @@ CurveTessVertex(void *vertex_data,
void *data)
{
CurveItem cv = data;
- WidgetInfo *wi = ((Item) data)->wi;
+ ZnWInfo *wi = ((ZnItem) data)->wi;
ZnPoint p;
int size;
@@ -571,9 +565,9 @@ static void
CurveTessEnd(void *data)
{
CurveItem cv = data;
- WidgetInfo *wi = ((Item) data)->wi;
- int size = ZnListSize(wi->work_pts);
- int num;
+ ZnWInfo *wi = ((ZnItem) data)->wi;
+ unsigned int size = ZnListSize(wi->work_pts);
+ unsigned int num;
if (wi->tess_type == GL_LINE_LOOP) {
/* Add the last point to close the outline */
@@ -584,7 +578,7 @@ CurveTessEnd(void *data)
memcpy(cv->outlines.contours[num-1].points,
ZnListArray(wi->work_pts), size * sizeof(ZnPoint));
cv->outlines.contours[num-1].points[size-1] = cv->outlines.contours[num-1].points[0];
- cv->outlines.contours[num-1].cw = !TestCCW(cv->outlines.contours[num-1].points, size);
+ cv->outlines.contours[num-1].cw = !ZnTestCCW(cv->outlines.contours[num-1].points, size);
}
else {
num = cv->tristrip.num_strips;
@@ -597,12 +591,12 @@ CurveTessEnd(void *data)
}
static void
CurveTessCombine(GLdouble coords[3],
- void *vertex_data[4],
- GLfloat weight[4],
+ void *vertex_data[4] __unused,
+ GLfloat weight[4] __unused,
void **out_data,
void *data)
{
- WidgetInfo *wi = ((Item) data)->wi;
+ ZnWInfo *wi = ((ZnItem) data)->wi;
ZnCombineData *cdata;
cdata = ZnMalloc(sizeof(ZnCombineData));
@@ -616,36 +610,38 @@ CurveTessCombine(GLdouble coords[3],
}
static void
CurveTessError(GLenum errno,
- void *data)
+ void *data __unused)
{
fprintf(stderr, "Tesselation error in curve item: %d\n", errno);
}
-#ifndef WIN
-#define CALLBACK
-#endif
-
static void
UpdateTristrip(CurveItem cv,
ZnPoly *poly,
ZnBool revert)
{
- WidgetInfo *wi = ((Item) cv)->wi;
+ ZnWInfo *wi = ((ZnItem) cv)->wi;
ZnCombineData *cdata, *cnext;
GLdouble v[3];
- int i, j;
+ unsigned int j, k;
+ int i;
- /*printf("UpdateTristrips sur %d\n", ((Item) cv)->id);*/
- gluTessCallback(wi->tess, GLU_TESS_BEGIN_DATA, (void (CALLBACK *)()) CurveTessBegin);
- gluTessCallback(wi->tess, GLU_TESS_VERTEX_DATA, (void (*)()) CurveTessVertex);
- gluTessCallback(wi->tess, GLU_TESS_END_DATA, (void (*)()) CurveTessEnd);
- gluTessCallback(wi->tess, GLU_TESS_COMBINE_DATA, (void (*)()) CurveTessCombine);
- gluTessCallback(wi->tess, GLU_TESS_ERROR_DATA, (void (*)()) CurveTessError);
- gluTessProperty(wi->tess, GLU_TESS_WINDING_RULE, cv->fill_rule);
- gluTessNormal(wi->tess, 0, 0, -1);
+ /*printf("UpdateTristrips sur %d\n", ((ZnItem) cv)->id);*/
+ gluTessCallback(wi->tess, GLU_TESS_BEGIN_DATA,
+ (_GLUfuncptr) CurveTessBegin);
+ gluTessCallback(wi->tess, GLU_TESS_VERTEX_DATA,
+ (_GLUfuncptr) CurveTessVertex);
+ gluTessCallback(wi->tess, GLU_TESS_END_DATA,
+ (_GLUfuncptr) CurveTessEnd);
+ gluTessCallback(wi->tess, GLU_TESS_COMBINE_DATA,
+ (_GLUfuncptr) CurveTessCombine);
+ gluTessCallback(wi->tess, GLU_TESS_ERROR_DATA,
+ (_GLUfuncptr) CurveTessError);
+ gluTessProperty(wi->tess, GLU_TESS_WINDING_RULE, (GLdouble) cv->fill_rule);
+ gluTessNormal(wi->tess, 0.0, 0.0, -1.0);
if (cv->tristrip.num_strips == 0) {
- gluTessProperty(wi->tess, GLU_TESS_BOUNDARY_ONLY, GL_FALSE);
+ gluTessProperty(wi->tess, GLU_TESS_BOUNDARY_ONLY, (GLdouble) GL_FALSE);
gluTessBeginPolygon(wi->tess, cv);
/*
* We need to take care of the final (after transformation) winding
@@ -657,13 +653,13 @@ UpdateTristrip(CurveItem cv,
gluTessBeginContour(wi->tess);
/*printf("Début contour %d num_points %d\n",
j, poly->contours[j].num_points);*/
- for (i = 0; i < poly->contours[j].num_points; 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;
+ 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(wi->tess, v, &poly->contours[j].points[i]);
- }
+ gluTessVertex(wi->tess, v, &poly->contours[j].points[k]);
+ }
/*printf("\n");*/
gluTessEndContour(wi->tess);
}
@@ -673,7 +669,7 @@ UpdateTristrip(CurveItem cv,
gluTessBeginContour(wi->tess);
/*printf("revert Début contour %d num_points %d\n",
j, poly->contours[j].num_points);*/
- for (i = poly->contours[j].num_points-1; i >= 0; i--) {
+ 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;
@@ -693,7 +689,7 @@ UpdateTristrip(CurveItem cv,
}
wi->tess_combine_list = NULL;
}
- /*printf("Fin UpdateTristrips sur %d\n", ((Item) cv)->id);*/
+ /*printf("Fin UpdateTristrips sur %d\n", ((ZnItem) cv)->id);*/
}
static void
@@ -701,22 +697,28 @@ UpdateOutlines(CurveItem cv,
ZnPoly *poly,
ZnBool revert)
{
- WidgetInfo *wi = ((Item) cv)->wi;
+ ZnWInfo *wi = ((ZnItem) cv)->wi;
ZnCombineData *cdata, *cnext;
GLdouble v[3];
- int i, j;
+ unsigned int j, k;
+ int i;
- /*printf("UpdateOutlines sur %d\n", ((Item) cv)->id);*/
- gluTessCallback(wi->tess, GLU_TESS_BEGIN_DATA, (void (*)()) CurveTessBegin);
- gluTessCallback(wi->tess, GLU_TESS_VERTEX_DATA, (void (*)()) CurveTessVertex);
- gluTessCallback(wi->tess, GLU_TESS_END_DATA, (void (*)()) CurveTessEnd);
- gluTessCallback(wi->tess, GLU_TESS_COMBINE_DATA, (void (*)()) CurveTessCombine);
- gluTessCallback(wi->tess, GLU_TESS_ERROR_DATA, (void (*)()) CurveTessError);
- gluTessProperty(wi->tess, GLU_TESS_WINDING_RULE, cv->fill_rule);
- gluTessNormal(wi->tess, 0, 0, -1);
+ /*printf("UpdateOutlines sur %d\n", ((ZnItem) cv)->id);*/
+ gluTessCallback(wi->tess, GLU_TESS_BEGIN_DATA,
+ (_GLUfuncptr) CurveTessBegin);
+ gluTessCallback(wi->tess, GLU_TESS_VERTEX_DATA,
+ (_GLUfuncptr) CurveTessVertex);
+ gluTessCallback(wi->tess, GLU_TESS_END_DATA,
+ (_GLUfuncptr) CurveTessEnd);
+ gluTessCallback(wi->tess, GLU_TESS_COMBINE_DATA,
+ (_GLUfuncptr) CurveTessCombine);
+ gluTessCallback(wi->tess, GLU_TESS_ERROR_DATA,
+ (_GLUfuncptr) CurveTessError);
+ gluTessProperty(wi->tess, GLU_TESS_WINDING_RULE, (GLdouble) cv->fill_rule);
+ gluTessNormal(wi->tess, 0.0, 0.0, -1.0);
if (cv->outlines.num_contours == 0) {
- gluTessProperty(wi->tess, GLU_TESS_BOUNDARY_ONLY, GL_TRUE);
+ gluTessProperty(wi->tess, GLU_TESS_BOUNDARY_ONLY, (GLdouble) GL_TRUE);
gluTessBeginPolygon(wi->tess, cv);
/*
@@ -727,11 +729,11 @@ UpdateOutlines(CurveItem cv,
if (!revert) {
for (j = 0; j < poly->num_contours; j++){
gluTessBeginContour(wi->tess);
- for (i = 0; i < poly->contours[j].num_points; i++) {
- v[0] = poly->contours[j].points[i].x;
- v[1] = poly->contours[j].points[i].y;
+ 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(wi->tess, v, &poly->contours[j].points[i]);
+ gluTessVertex(wi->tess, v, &poly->contours[j].points[k]);
}
gluTessEndContour(wi->tess);
}
@@ -739,7 +741,7 @@ UpdateOutlines(CurveItem cv,
else {
for (j = 0; j < poly->num_contours; j++){
gluTessBeginContour(wi->tess);
- for (i = poly->contours[j].num_points-1; i >= 0; i--) {
+ 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;
@@ -757,7 +759,7 @@ UpdateOutlines(CurveItem cv,
}
wi->tess_combine_list = NULL;
}
- /*printf("Fin UpdateOutlines sur %d\n", ((Item) cv)->id);*/
+ /*printf("Fin UpdateOutlines sur %d\n", ((ZnItem) cv)->id);*/
}
@@ -769,22 +771,22 @@ UpdateOutlines(CurveItem cv,
**********************************************************************************
*/
static void
-ComputeCoordinates(Item item,
- ZnBool force)
+ComputeCoordinates(ZnItem item,
+ ZnBool force __unused)
{
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
CurveItem cv = (CurveItem) item;
- int i, j;
- ZnPoint end_points[LINE_END_POINTS];
+ unsigned int i, j;
+ ZnPoint end_points[ZN_LINE_END_POINTS];
ZnPoint *points;
- int num_points, num_contours, segment_start;
+ unsigned int num_points, num_contours, segment_start;
ZnBBox bbox;
- int lw;
+ ZnDim lw;
ZnContour *c1, *c2;
ZnPoly dev;
ZnBool revert;
- ResetBBox(&item->item_bounding_box);
+ ZnResetBBox(&item->item_bounding_box);
/*printf("Curve CC: flags %x\n", cv->flags);*/
SetRenderFlags(cv);
@@ -795,13 +797,13 @@ ComputeCoordinates(Item item,
}
if (cv->tristrip.num_strips) {
- TRI_FREE(&cv->tristrip);
+ ZnTriFree(&cv->tristrip);
}
if (cv->outlines.num_contours) {
- POLY_FREE(&cv->outlines);
+ ZnPolyFree(&cv->outlines);
};
- POLY_INIT(&dev);
+ ZnPolyInit(&dev);
if (num_contours != 1) {
dev.contours = ZnMalloc(num_contours * sizeof(ZnContour));
dev.num_contours = num_contours;
@@ -851,9 +853,9 @@ ComputeCoordinates(Item item,
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);*/
- GetBezierPoints(&c2->points[segment_start],
- &c2->points[segment_start+1], &c2->points[j-1],
- &c2->points[j], wi->work_pts, 0.5);
+ ZnGetBezierPoints(&c2->points[segment_start],
+ &c2->points[segment_start+1], &c2->points[j-1],
+ &c2->points[j], wi->work_pts, 0.5);
}
else {
/*printf("lineto %g@%g\n", c2->points[j].x, c2->points[j].y);*/
@@ -868,9 +870,9 @@ ComputeCoordinates(Item item,
* multiple contours).
*/
if (c1->controls[c1->num_points-1]) {
- GetBezierPoints(&c2->points[segment_start],
- &c2->points[segment_start+1], &c2->points[c1->num_points-1],
- &c2->points[0], wi->work_pts, 0.5);
+ ZnGetBezierPoints(&c2->points[segment_start],
+ &c2->points[segment_start+1], &c2->points[c1->num_points-1],
+ &c2->points[0], wi->work_pts, 0.5);
}
/*
@@ -911,8 +913,8 @@ ComputeCoordinates(Item item,
printf("\n");
}*/
}
- POLY_CONTOUR1(&cv->outlines, dev.contours[0].points, dev.contours[0].num_points,
- cv->shape.contours[0].cw);
+ ZnPolyContour1(&cv->outlines, dev.contours[0].points, dev.contours[0].num_points,
+ cv->shape.contours[0].cw);
}
else {
UpdateTristrip(cv, &dev, revert);
@@ -923,7 +925,7 @@ ComputeCoordinates(Item item,
cv->shape.contours[0].cw, cw_dev_contour1, cv->tristrip.num_strips);
}*/
UpdateOutlines(cv, &dev, revert);
- POLY_FREE(&dev);
+ ZnPolyFree(&dev);
}
lw = cv->line_width;
@@ -935,13 +937,13 @@ ComputeCoordinates(Item item,
* Add to bounding box.
*/
ZnGetPolygonReliefBBox(c2->points, c2->num_points, lw, &bbox);
- AddBBoxToBBox(&item->item_bounding_box, &bbox);
+ ZnAddBBoxToBBox(&item->item_bounding_box, &bbox);
}
}
else {
c2 = cv->outlines.contours;
for (i = 0; i < num_contours; i++, c2++) {
- AddPointsToBBox(&item->item_bounding_box, c2->points, c2->num_points);
+ ZnAddPointsToBBox(&item->item_bounding_box, c2->points, c2->num_points);
}
/*
@@ -965,9 +967,9 @@ ComputeCoordinates(Item item,
if (cv->join_style == JoinMiter) {
ZnPoint miter_i, miter_o;
for (i = c2->num_points-1, points = c2->points; i >= 3; i--, points++) {
- GetMiterPoints(points, points+1, points+2, lw, &miter_i, &miter_o);
- AddPointToBBox(&item->item_bounding_box, miter_i.x, miter_i.y);
- AddPointToBBox(&item->item_bounding_box, miter_o.x, miter_o.y);
+ 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);
}
}
/*
@@ -986,7 +988,7 @@ ComputeCoordinates(Item item,
bbox.orig.y = points->y - h;
bbox.corner.x = points->x + w;
bbox.corner.y = points->y + h;
- AddBBoxToBBox(&item->item_bounding_box, &bbox);
+ ZnAddBBoxToBBox(&item->item_bounding_box, &bbox);
}
}
/*
@@ -995,14 +997,14 @@ ComputeCoordinates(Item item,
num_points = c2->num_points;
points = c2->points;
if (ISSET(cv->flags, FIRST_END_OK)) {
- GetLineEnd(&points[0], &points[1], lw, cv->cap_style,
- cv->first_end, end_points);
- AddPointsToBBox(&item->item_bounding_box, end_points, 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)) {
- GetLineEnd(&points[num_points-1], &points[num_points-2],
- lw, cv->cap_style, cv->last_end, end_points);
- AddPointsToBBox(&item->item_bounding_box, end_points, 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);
}
}
@@ -1016,13 +1018,14 @@ ComputeCoordinates(Item item,
item->item_bounding_box.corner.y += 1;
}
-#ifdef GLX
+#ifdef GL
if (!ZnGradientFlat(cv->fill_color)) {
if (!cv->grad_geo) {
cv->grad_geo = ZnMalloc(6*sizeof(ZnPoint));
}
if (cv->fill_color->type == ZN_AXIAL_GRADIENT) {
- ZnComputeAxialGradient(wi, &cv->shape, cv->fill_color->g.angle, cv->grad_geo);
+ ZnComputeAxialGradient(wi, &cv->shape, (ZnReal) cv->fill_color->g.angle,
+ cv->grad_geo);
}
else if (cv->fill_color->type == ZN_RADIAL_GRADIENT) {
ZnComputeRadialGradient(wi, &cv->shape, False, &cv->fill_color->g.p, cv->grad_geo);
@@ -1052,16 +1055,16 @@ ComputeCoordinates(Item item,
**********************************************************************************
*/
static int
-ToArea(Item item,
+ToArea(ZnItem item,
ZnToArea ta)
{
CurveItem cv = (CurveItem) item;
ZnBBox bbox, *area = ta->area;
ZnPoint *points;
ZnPoint triangle[3];
- ZnPoint end_points[LINE_END_POINTS];
- int i, j, num_points, stop, result=-1, result2;
- int width, height;
+ 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) {
@@ -1094,10 +1097,10 @@ ToArea(Item item,
}
if (!first_done) {
first_done = True;
- result = PolygonInBBox(triangle, 3, area, NULL);
+ result = ZnPolygonInBBox(triangle, 3, area, NULL);
}
else {
- result2 = PolygonInBBox(triangle, 3, area, NULL);
+ result2 = ZnPolygonInBBox(triangle, 3, area, NULL);
if (result2 != result) {
return 0;
}
@@ -1114,8 +1117,8 @@ ToArea(Item item,
if (!first_done) {
first_done = True;
if (ISCLEAR(cv->flags, RELIEF_OK)) {
- result = PolylineInBBox(points, num_points,
- cv->line_width, cv->cap_style, cv->join_style, area);
+ 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);
@@ -1126,8 +1129,8 @@ ToArea(Item item,
}
else {
if (ISCLEAR(cv->flags, RELIEF_OK)) {
- result2 = PolylineInBBox(points, num_points,
- cv->line_width, cv->cap_style, cv->join_style, area);
+ 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);
@@ -1144,16 +1147,16 @@ ToArea(Item item,
points = cv->outlines.contours[0].points;
num_points = cv->outlines.contours[0].num_points;
if (ISSET(cv->flags, FIRST_END_OK)) {
- GetLineEnd(&points[0], &points[1], cv->line_width, cv->cap_style,
- cv->first_end, end_points);
- if (PolygonInBBox(end_points, LINE_END_POINTS, area, NULL) != result) {
+ ZnGetLineEnd(&points[0], &points[1], cv->line_width, cv->cap_style,
+ cv->first_end, end_points);
+ if (ZnPolygonInBBox(end_points, ZN_LINE_END_POINTS, area, NULL) != result) {
return 0;
}
}
if (ISSET(cv->flags, LAST_END_OK)) {
- GetLineEnd(&points[num_points-1], &points[num_points-2], cv->line_width,
- cv->cap_style, cv->last_end, end_points);
- if (PolygonInBBox(end_points, LINE_END_POINTS, area, NULL) != result) {
+ ZnGetLineEnd(&points[num_points-1], &points[num_points-2], cv->line_width,
+ cv->cap_style, cv->last_end, end_points);
+ if (ZnPolygonInBBox(end_points, ZN_LINE_END_POINTS, area, NULL) != result) {
return 0;
}
}
@@ -1181,7 +1184,7 @@ ToArea(Item item,
bbox.orig.y = points->y - (height+1)/2;
bbox.corner.x = bbox.orig.x + width;
bbox.corner.y = bbox.orig.y + height;
- if (BBoxInBBox(&bbox, area) != result) {
+ if (ZnBBoxInBBox(&bbox, area) != result) {
return 0;
}
}
@@ -1200,12 +1203,12 @@ ToArea(Item item,
**********************************************************************************
*/
static void
-Draw(Item item)
+Draw(ZnItem item)
{
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
CurveItem cv = (CurveItem) item;
XGCValues values;
- int i, j, num_points=0, num2;
+ unsigned int i, j, num_points=0, num2;
unsigned int gc_mask;
ZnPoint *points=NULL;
XPoint *xpoints=NULL;
@@ -1225,16 +1228,16 @@ Draw(Item item)
gc_mask = GCFillStyle;
if (cv->tile != ZnUnspecifiedImage) { /* Fill tiled */
values.fill_style = FillTiled;
- values.tile = ZnImagePixmap(cv->tile, NULL);
- values.ts_x_origin = REAL_TO_INT(item->item_bounding_box.orig.x);
- values.ts_y_origin = REAL_TO_INT(item->item_bounding_box.orig.y);
+ values.tile = ZnImagePixmap(cv->tile);
+ 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 if (cv->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */
values.fill_style = FillStippled;
- values.stipple = ZnImagePixmap(cv->fill_pattern, NULL);
- values.ts_x_origin = REAL_TO_INT(item->item_bounding_box.orig.x);
- values.ts_y_origin = REAL_TO_INT(item->item_bounding_box.orig.y);
+ values.stipple = ZnImagePixmap(cv->fill_pattern);
+ 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 */
@@ -1249,13 +1252,13 @@ Draw(Item item)
points = cv->tristrip.strips[i].points;
if (cv->tristrip.strips[i].fan) {
XPoint xpoints[3];
- xpoints[0].x = REAL_TO_INT(points[0].x);
- xpoints[0].y = REAL_TO_INT(points[0].y);
- xpoints[1].x = REAL_TO_INT(points[1].x);
- xpoints[1].y = REAL_TO_INT(points[1].y);
+ 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 = REAL_TO_INT(points[j].x);
- xpoints[2].y = REAL_TO_INT(points[j].y);
+ 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];
@@ -1265,8 +1268,8 @@ Draw(Item item)
ZnListAssertSize(wi->work_xpts, num_points);
xpoints = ZnListArray(wi->work_xpts);
for (j = 0; j < num_points; j++) {
- xpoints[j].x = REAL_TO_INT(points[j].x);
- xpoints[j].y = REAL_TO_INT(points[j].y);
+ 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,
@@ -1280,8 +1283,8 @@ Draw(Item item)
* Draw the lines between points
*/
if (cv->line_width) {
- ZnPoint end_points[LINE_END_POINTS];
- XPoint xp[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.
@@ -1300,8 +1303,8 @@ Draw(Item item)
}
else {
ZnSetLineStyle(wi, cv->line_style);
- values.foreground = ZnPixel(ZnGetGradientColor(cv->line_color, 0, NULL));
- values.line_width = (cv->line_width == 1) ? 0 : cv->line_width;
+ values.foreground = ZnPixel(ZnGetGradientColor(cv->line_color, 0.0, NULL));
+ values.line_width = (cv->line_width == 1) ? 0 : (int) cv->line_width;
values.join_style = cv->join_style;
values.cap_style = cv->cap_style;
if (cv->line_pattern == ZnUnspecifiedImage) {
@@ -1311,7 +1314,7 @@ Draw(Item item)
}
else {
values.fill_style = FillStippled;
- values.stipple = ZnImagePixmap(cv->line_pattern, NULL);
+ values.stipple = ZnImagePixmap(cv->line_pattern);
XChangeGC(wi->dpy, wi->gc,
GCFillStyle|GCStipple|GCLineWidth|GCJoinStyle|GCCapStyle|GCForeground,
&values);
@@ -1322,33 +1325,33 @@ Draw(Item item)
ZnListAssertSize(wi->work_xpts, num_points);
xpoints = ZnListArray(wi->work_xpts);
for (i = 0; i < num2; i++) {
- xpoints[i].x = REAL_TO_INT(points[i].x);
- xpoints[i].y = REAL_TO_INT(points[i].y);
+ xpoints[i].x = ZnNearestInt(points[i].x);
+ xpoints[i].y = ZnNearestInt(points[i].y);
}
if (ISSET(cv->flags, CLOSED_BIT)) {
xpoints[num2] = xpoints[0];
}
XDrawLines(wi->dpy, wi->draw_buffer, wi->gc,
- xpoints, num_points, CoordModeOrigin);
+ xpoints, (int) num_points, CoordModeOrigin);
}
if (ISSET(cv->flags, FIRST_END_OK)) {
- GetLineEnd(&points[0], &points[1], cv->line_width, cv->cap_style,
- cv->first_end, end_points);
- for (i = 0; i < LINE_END_POINTS; i++) {
- xp[i].x = end_points[i].x;
- xp[i].y = end_points[i].y;
+ 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, LINE_END_POINTS,
+ XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xp, ZN_LINE_END_POINTS,
Nonconvex, CoordModeOrigin);
}
if (ISSET(cv->flags, LAST_END_OK)) {
- GetLineEnd(&points[num_points-1], &points[num_points-2], cv->line_width,
- cv->cap_style, cv->last_end, end_points);
- for (i = 0; i < LINE_END_POINTS; i++) {
- xp[i].x = end_points[i].x;
- xp[i].y = end_points[i].y;
+ 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, LINE_END_POINTS,
+ XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xp, ZN_LINE_END_POINTS,
Nonconvex, CoordModeOrigin);
}
}
@@ -1359,15 +1362,15 @@ Draw(Item item)
* if last point join first point suppress markers at end points.
*/
if (ISSET(cv->flags, MARKER_OK)) {
- int h_width, h_height, width, height;
- ZnPoint ptmp;
+ unsigned int h_width, h_height, width, height;
+ int tmp_x, tmp_y;
ZnSizeOfImage(cv->marker, &width, &height);
h_width = (width+1)/2;
h_height = (height+1)/2;
values.fill_style = FillStippled;
- values.stipple = ZnImagePixmap(cv->marker, NULL);
- values.foreground = ZnPixel(ZnGetGradientColor(cv->marker_color, 0, NULL));
+ values.stipple = ZnImagePixmap(cv->marker);
+ values.foreground = ZnPixel(ZnGetGradientColor(cv->marker_color, 0.0, NULL));
XChangeGC(wi->dpy, wi->gc, GCFillStyle|GCStipple|GCForeground, &values);
for (j = 0; j < cv->outlines.num_contours; j++) {
num_points = cv->outlines.contours[j].num_points;
@@ -1375,8 +1378,8 @@ Draw(Item item)
ZnListAssertSize(wi->work_xpts, num_points);
xpoints = (XPoint *) ZnListArray(wi->work_xpts);
for (i = 0; i < num_points; i++) {
- xpoints[i].x = REAL_TO_INT(points[i].x);
- xpoints[i].y = REAL_TO_INT(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--;
@@ -1386,14 +1389,14 @@ Draw(Item item)
num_points--;
}
for (; num_points > 0; num_points--, points++) {
- ptmp.x = points->x - h_width;
- ptmp.y = points->y - h_height;
- values.ts_x_origin = ptmp.x;
- values.ts_y_origin = ptmp.y;
+ 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, ptmp.x, ptmp.y,
- width, height);
+ XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc,
+ tmp_x, tmp_y, width, height);
}
}
}
@@ -1407,12 +1410,12 @@ Draw(Item item)
*
**********************************************************************************
*/
-#ifdef GLX
+#ifdef GL
static void
CurveRenderCB(void *closure)
{
CurveItem cv = (CurveItem) closure;
- int i, j, num_points;
+ unsigned int i, j, num_points;
ZnPoint *points;
for (i = 0; i < cv->tristrip.num_strips; i++) {
@@ -1425,22 +1428,23 @@ CurveRenderCB(void *closure)
glBegin(GL_TRIANGLE_STRIP);
}
for (j = 0; j < num_points; j++, points++) {
- glVertex2f(points->x, points->y);
+ glVertex2d(points->x, points->y);
}
glEnd();
}
}
#endif
+
+#ifdef GL
static void
-Render(Item item)
+Render(ZnItem item)
{
-#ifdef GLX
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
CurveItem cv = (CurveItem) item;
- int j, num_points;
+ unsigned int j, num_points;
ZnPoint *points;
XColor *color;
- int alpha;
+ unsigned short alpha;
if ((cv->outlines.num_contours == 0) ||
(ISCLEAR(cv->flags, FILLED_OK) &&
@@ -1473,7 +1477,7 @@ Render(Item item)
* Setup polygon stippling.
*/
glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple(ZnImagePattern(cv->fill_pattern, NULL));
+ glPolygonStipple(ZnImageMask(cv->fill_pattern, NULL));
}
color = ZnGetGradientColor(cv->fill_color, 0.0, &alpha);
alpha = ZnComposeAlpha(alpha, wi->alpha);
@@ -1490,7 +1494,7 @@ Render(Item item)
/*
* Drawing with relief disables: ends, line style and line pattern.
*/
- ZnGetGradientColor(cv->line_color, 0, &alpha);
+ ZnGetGradientColor(cv->line_color, 0.0, &alpha);
alpha = ZnComposeAlpha(alpha, wi->alpha);
if (ISSET(cv->flags, RELIEF_OK)) {
for (j = 0; j < cv->outlines.num_contours; j++) {
@@ -1524,12 +1528,13 @@ Render(Item item)
* if last point join first point suppress markers at end points.
*/
if (ISSET(cv->flags, MARKER_OK)) {
- int h_width, h_height;
- ZnPoint ptmp;
+ int i_width, i_height;
+ ZnReal r_width, r_height;
+ ZnPoint ptmp;
- ZnSizeOfImage(cv->marker, &h_width, & h_height);
- h_width = (h_width+1.0)/2.0;
- h_height = (h_height+1.0)/2.0;
+ 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;
@@ -1541,8 +1546,8 @@ Render(Item item)
num_points--;
}
for (; num_points > 0; num_points--, points++) {
- ptmp.x = points->x - h_width;
- ptmp.y = points->y - h_height;
+ ptmp.x = points->x - r_width;
+ ptmp.y = points->y - r_height;
ZnRenderIcon(wi, cv->marker, cv->marker_color, &ptmp, True);
}
}
@@ -1553,8 +1558,13 @@ Render(Item item)
glCallList(item->gl_list);
#endif
-#endif
}
+#else
+static void
+Render(ZnItem item __unused)
+{
+}
+#endif
/*
@@ -1565,10 +1575,10 @@ Render(Item item)
**********************************************************************************
*/
static ZnBool
-IsSensitive(Item item,
- int item_part)
+IsSensitive(ZnItem item,
+ int item_part __unused)
{
- return (ISSET(item->flags, SENSITIVE_BIT) &&
+ return (ISSET(item->flags, ZN_SENSITIVE_BIT) &&
item->parent->class->IsSensitive(item->parent, ZN_NO_PART));
}
@@ -1581,17 +1591,16 @@ IsSensitive(Item item,
**********************************************************************************
*/
static double
-Pick(Item item,
+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[LINE_END_POINTS];
- int num_points;
+ ZnPoint end_points[ZN_LINE_END_POINTS];
+ unsigned int num_points, i;
int width, height;
- int i;
if (cv->outlines.num_contours == 0) {
return dist;
@@ -1606,15 +1615,15 @@ Pick(Item item,
*/
for (i = 0; i < cv->outlines.num_contours; i++) {
if (cv->outlines.contours[i].cw) {
- new_hole_dist = PolygonToPointDist(cv->outlines.contours[i].points,
- cv->outlines.contours[i].num_points, p);
+ new_hole_dist = ZnPolygonToPointDist(cv->outlines.contours[i].points,
+ cv->outlines.contours[i].num_points, p);
if (new_hole_dist < hole_dist) {
hole_dist = new_hole_dist;
}
}
else {
- new_dist = PolygonToPointDist(cv->outlines.contours[i].points,
- cv->outlines.contours[i].num_points, p);
+ new_dist = ZnPolygonToPointDist(cv->outlines.contours[i].points,
+ cv->outlines.contours[i].num_points, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1643,8 +1652,8 @@ Pick(Item item,
points = cv->outlines.contours[i].points;
num_points = cv->outlines.contours[i].num_points;
if (ISCLEAR(cv->flags, RELIEF_OK)) {
- new_dist = PolylineToPointDist(points, num_points,
- cv->line_width, cv->cap_style, cv->join_style, p);
+ new_dist = ZnPolylineToPointDist(points, num_points,
+ cv->line_width, cv->cap_style, cv->join_style, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1675,9 +1684,9 @@ Pick(Item item,
* Check line ends.
*/
if (ISSET(cv->flags, FIRST_END_OK)) {
- GetLineEnd(&points[0], &points[1], cv->line_width, cv->cap_style,
- cv->first_end, end_points);
- new_dist = PolygonToPointDist(end_points, LINE_END_POINTS, p);
+ ZnGetLineEnd(&points[0], &points[1], cv->line_width, cv->cap_style,
+ cv->first_end, end_points);
+ new_dist = ZnPolygonToPointDist(end_points, ZN_LINE_END_POINTS, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1687,9 +1696,9 @@ Pick(Item item,
}
}
if (ISSET(cv->flags, LAST_END_OK)) {
- GetLineEnd(&points[num_points-1], &points[num_points-2], cv->line_width,
- cv->cap_style, cv->last_end, end_points);
- new_dist = PolygonToPointDist(end_points, LINE_END_POINTS, p);
+ ZnGetLineEnd(&points[num_points-1], &points[num_points-2], cv->line_width,
+ 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;
}
@@ -1721,7 +1730,7 @@ Pick(Item item,
bbox.orig.y = points->y - (height+1)/2;
bbox.corner.x = bbox.orig.x + width;
bbox.corner.y = bbox.orig.y + height;
- new_dist = RectangleToPointDist(&bbox, p);
+ new_dist = ZnRectangleToPointDist(&bbox, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1746,8 +1755,8 @@ Pick(Item item,
**********************************************************************************
*/
static void
-PostScript(Item item,
- PostScriptInfo ps_info)
+PostScript(ZnItem item __unused,
+ ZnPostScriptInfo ps_info __unused)
{
}
@@ -1757,12 +1766,12 @@ PostScript(Item item,
*
* GetClipVertices --
* Get the clipping shape.
- * Never ever call TRI_FREE on the tristrip returned by GetClipVertices.
+ * Never ever call ZnTriFree on the tristrip returned by GetClipVertices.
*
**********************************************************************************
*/
static ZnBool
-GetClipVertices(Item item,
+GetClipVertices(ZnItem item,
ZnTriStrip *tristrip)
{
CurveItem cv = (CurveItem) item;
@@ -1770,10 +1779,10 @@ GetClipVertices(Item item,
tristrip->num_strips = 0;
if (cv->tristrip.num_strips == 1) {
- TRI_STRIP1(tristrip,
- cv->tristrip.strips[0].points,
- cv->tristrip.strips[0].num_points,
- cv->tristrip.strips[0].fan);
+ ZnTriStrip1(tristrip,
+ 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;
@@ -1789,20 +1798,20 @@ GetClipVertices(Item item,
*
* GetContours --
* Get the external contour(s).
- * Never ever call POLY_FREE on the poly returned by GetContours.
+ * Never ever call ZnPolyFree on the poly returned by GetContours.
*
**********************************************************************************
*/
static ZnBool
-GetContours(Item item,
+GetContours(ZnItem item,
ZnPoly *poly)
{
CurveItem cv = (CurveItem) item;
if (cv->outlines.num_contours == 1) {
- POLY_CONTOUR1(poly, cv->outlines.contours[0].points,
- cv->outlines.contours[0].num_points,
- cv->outlines.contours[0].cw);
+ ZnPolyContour1(poly, cv->outlines.contours[0].points,
+ 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;
@@ -1822,16 +1831,17 @@ GetContours(Item item,
**********************************************************************************
*/
static int
-Coords(Item item,
- int contour,
- int index,
- int cmd,
- ZnPoint **pts,
- char **controls,
- int *num_pts)
+Coords(ZnItem item,
+ int contour,
+ int index,
+ int cmd,
+ ZnPoint **pts,
+ char **controls,
+ unsigned int *num_pts)
{
CurveItem cv = (CurveItem) item;
- int i, num_controls;
+ unsigned int j, num_controls;
+ int i;
ZnContour *c=NULL;
/*printf("contour %d, num_pts %d, index %d, cmd %d\n",
@@ -1840,10 +1850,10 @@ Coords(Item item,
if (contour < 0) {
contour += cv->shape.num_contours;
}
- if ((contour < 0) || (contour >= cv->shape.num_contours)) {
+ if ((contour < 0) || ((unsigned int) contour >= cv->shape.num_contours)) {
Tcl_AppendResult(item->wi->interp,
" curve contour index out of range", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (cv->shape.num_contours != 0) {
c = &cv->shape.contours[contour];
@@ -1851,8 +1861,8 @@ Coords(Item item,
/* REPLACE */
- if ((cmd == COORDS_REPLACE) || (cmd == COORDS_REPLACE_ALL)) {
- if (cmd == COORDS_REPLACE_ALL) {
+ if ((cmd == ZN_COORDS_REPLACE) || (cmd == ZN_COORDS_REPLACE_ALL)) {
+ if (cmd == ZN_COORDS_REPLACE_ALL) {
/*
* Replacing all the coordinates of a contour by no coordinates
* is also legal, resulting in the contour being removed.
@@ -1874,15 +1884,15 @@ Coords(Item item,
if (*num_pts == 0) {
Tcl_AppendResult(item->wi->interp,
" coords replace command need at least 1 point on curves", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (index < 0) {
index += c->num_points;
}
- if ((index < 0) || (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 ZN_ERROR;
+ return TCL_ERROR;
}
/*printf("--->%g@%g\n", (*pts)[0].x, (*pts)[0].y);*/
c->points[index] = (*pts)[0];
@@ -1905,37 +1915,37 @@ Coords(Item item,
if (!index) {
control_first:
Tcl_AppendResult(item->wi->interp, " the first point must not be a control", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
- else if (index == c->num_points-1) {
+ 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 ZN_ERROR;
+ return TCL_ERROR;
}
}
else {
for (i = index-1; c->controls[i] && (i >= 0); i--, num_controls++);
}
- for (i = index+1; c->controls[i] && (i < c->num_points); 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 ZN_ERROR;
+ return TCL_ERROR;
}
}
c->controls[index] = (*controls)[0];
}
}
}
- ITEM.Invalidate(item, ZN_COORDS_FLAG);
+ ZnITEM.Invalidate(item, ZN_COORDS_FLAG);
}
/* READ */
- else if ((cmd == COORDS_READ) || (cmd == COORDS_READ_ALL)) {
- if (cmd == COORDS_READ_ALL) {
+ else if ((cmd == ZN_COORDS_READ) || (cmd == ZN_COORDS_READ_ALL)) {
+ if (cmd == ZN_COORDS_READ_ALL) {
*num_pts = c->num_points;
*pts = c->points;
if (c->controls) {
@@ -1946,7 +1956,7 @@ Coords(Item item,
if (index < 0) {
index += c->num_points;
}
- if ((index < 0) || (index >= c->num_points)) {
+ if ((index < 0) || ((unsigned int) index >= c->num_points)) {
goto range_err;
}
*num_pts = 1;
@@ -1959,17 +1969,17 @@ Coords(Item item,
/* ADD */
- else if ((cmd == COORDS_ADD) || (cmd == COORDS_ADD_LAST)) {
+ else if ((cmd == ZN_COORDS_ADD) || (cmd == ZN_COORDS_ADD_LAST)) {
if (*num_pts == 0) {
- return ZN_OK;
+ return TCL_OK;
}
- if (cmd == COORDS_ADD_LAST) {
+ if (cmd == ZN_COORDS_ADD_LAST) {
index = c->num_points;
}
if (index < 0) {
index += c->num_points;
}
- if ((index < 0) || (index > c->num_points)) {
+ if ((index < 0) || ((unsigned int) index > c->num_points)) {
goto range_err;
}
if (*controls) {
@@ -1981,8 +1991,10 @@ Coords(Item item,
if ((index == 0) && (*controls)[0]) {
goto control_first;
}
- else if ((index == c->num_points-1) && (*controls)[*num_pts-1] &&
- ISCLEAR(cv->flags, CLOSED_BIT) && (cv->shape.num_contours == 1)) {
+ 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;
}
@@ -1993,8 +2005,8 @@ Coords(Item item,
}
}
/*printf("******* num controls: %d\n", num_controls);*/
- for (i = 0; i < *num_pts; i++) {
- if (!(*controls)[i]) {
+ for (j = 0; j < *num_pts; j++) {
+ if (!(*controls)[j]) {
num_controls = 0;
}
else {
@@ -2006,7 +2018,7 @@ Coords(Item item,
}
/*printf("******* num controls(2): %d\n", num_controls);*/
if (c->controls) {
- for (i = index; c->controls[i] && (i < c->num_points); i++, 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) {
@@ -2032,23 +2044,23 @@ Coords(Item item,
c->controls[i+*num_pts] = c->controls[i];
}
}
- for (i = 0; i < *num_pts; i++, index++) {
- c->points[index] = (*pts)[i];
+ for (j = 0; j < *num_pts; j++, index++) {
+ c->points[index] = (*pts)[j];
if (c->controls) {
- c->controls[index] = (*controls)?(*controls)[i]:0;
+ c->controls[index] = (*controls)?(*controls)[j]:0;
}
}
c->num_points += *num_pts;
- ITEM.Invalidate(item, ZN_COORDS_FLAG);
+ ZnITEM.Invalidate(item, ZN_COORDS_FLAG);
}
/* REMOVE */
- else if (cmd == COORDS_REMOVE) {
+ else if (cmd == ZN_COORDS_REMOVE) {
if (index < 0) {
index += c->num_points;
}
- if ((index < 0) || (index >= c->num_points)) {
+ if ((index < 0) || ((unsigned int) index >= c->num_points)) {
goto range_err;
}
@@ -2064,11 +2076,11 @@ Coords(Item item,
}
c->num_points--;
- if ((c->num_points != 0) && (index != c->num_points)) {
- for (i = index; i < c->num_points; i++) {
- c->points[i] = c->points[i+1];
+ 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[i] = c->controls[i+1];
+ c->controls[j] = c->controls[j+1];
}
}
}
@@ -2076,10 +2088,10 @@ Coords(Item item,
if (c->controls) {
c->controls = ZnRealloc(c->controls, (c->num_points)*sizeof(char));
}
- ITEM.Invalidate(item, ZN_COORDS_FLAG);
+ ZnITEM.Invalidate(item, ZN_COORDS_FLAG);
}
- return ZN_OK;
+ return TCL_OK;
}
@@ -2092,26 +2104,27 @@ Coords(Item item,
**********************************************************************************
*/
static int
-Contour(Item item,
+Contour(ZnItem item,
int cmd,
int index,
ZnPoly *poly)
{
CurveItem cv = (CurveItem) item;
- int i, num_contours;
+ unsigned int j, num_contours;
+ int i;
switch (cmd) {
case ZN_CONTOUR_ADD:
if (index < 0) {
index += cv->shape.num_contours;
}
- if (index > cv->shape.num_contours) {
+ if ((unsigned int) index > cv->shape.num_contours) {
index = cv->shape.num_contours;
}
if (index < 0) {
contour_err:
Tcl_AppendResult(item->wi->interp, " contour index out of range", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
num_contours = cv->shape.num_contours + poly->num_contours;
if (cv->shape.contours == &cv->shape.contour1) {
@@ -2132,31 +2145,31 @@ Contour(Item item,
for (i = cv->shape.num_contours-1; i >= index; i--) {
cv->shape.contours[i+poly->num_contours] = cv->shape.contours[i];
}
- for (i = 0; i < poly->num_contours; i++, index++) {
- cv->shape.contours[index].num_points = poly->contours[i].num_points;
- cv->shape.contours[index].cw = poly->contours[i].cw;
- cv->shape.contours[index].points = ZnMalloc(poly->contours[i].num_points * sizeof(ZnPoint));
- memcpy(cv->shape.contours[index].points, poly->contours[i].points,
- poly->contours[i].num_points * sizeof(ZnPoint));
+ for (j = 0; j < poly->num_contours; j++, index++) {
+ cv->shape.contours[index].num_points = poly->contours[j].num_points;
+ cv->shape.contours[index].cw = poly->contours[j].cw;
+ cv->shape.contours[index].points = ZnMalloc(poly->contours[j].num_points * sizeof(ZnPoint));
+ memcpy(cv->shape.contours[index].points, poly->contours[j].points,
+ poly->contours[j].num_points * sizeof(ZnPoint));
cv->shape.contours[index].controls = NULL;
- if (poly->contours[i].controls) {
+ 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 = ZnMalloc(poly->contours[i].num_points * sizeof(char));
- memcpy(cv->shape.contours[index].controls, poly->contours[i].controls,
- poly->contours[i].num_points * sizeof(char));
+ cv->shape.contours[index].controls = ZnMalloc(poly->contours[j].num_points * sizeof(char));
+ memcpy(cv->shape.contours[index].controls, poly->contours[j].controls,
+ poly->contours[j].num_points * sizeof(char));
}
}
cv->shape.num_contours = num_contours;
- ITEM.Invalidate(item, ZN_COORDS_FLAG);
+ ZnITEM.Invalidate(item, ZN_COORDS_FLAG);
break;
case ZN_CONTOUR_REMOVE:
if (index < 0) {
index += cv->shape.num_contours;
}
- if (index >= cv->shape.num_contours) {
+ if ((unsigned int) index >= cv->shape.num_contours) {
index = cv->shape.num_contours - 1;
}
if (index < 0) {
@@ -2164,18 +2177,18 @@ Contour(Item item,
}
cv->shape.num_contours--;
if (cv->shape.num_contours == 0) {
- POLY_FREE(&cv->shape);
+ ZnPolyFree(&cv->shape);
}
else {
ZnFree(cv->shape.contours[index].points);
if (cv->shape.contours[index].controls) {
ZnFree(cv->shape.contours[index].controls);
}
- for (i = index; i < cv->shape.num_contours; i++) {
- cv->shape.contours[i] = cv->shape.contours[i+1];
+ for (j = index; j < cv->shape.num_contours; j++) {
+ cv->shape.contours[j] = cv->shape.contours[j+1];
}
}
- ITEM.Invalidate(item, ZN_COORDS_FLAG);
+ ZnITEM.Invalidate(item, ZN_COORDS_FLAG);
break;
}
@@ -2194,14 +2207,14 @@ Contour(Item item,
**********************************************************************************
*/
static void
-PickVertex(Item item,
+PickVertex(ZnItem item,
ZnPoint *p,
int *contour,
int *vertex,
int *o_vertex)
{
CurveItem cv = (CurveItem) item;
- int i, j, k, num_points;
+ unsigned int i, j, k, num_points;
ZnPoint *points, po;
ZnReal dist=1.0e40, new_dist, dist2;
ZnTransfo t, inv;
@@ -2215,7 +2228,7 @@ PickVertex(Item item,
/*
* Get the point in the item coordinate space.
*/
- ITEM.GetItemTransform(item, &t);
+ ZnITEM.GetItemTransform(item, &t);
ZnTransfoInvert(&t, &inv);
ZnTransformPoint(&inv, p, &po);
@@ -2237,11 +2250,11 @@ PickVertex(Item item,
* If the closest vertex is in the current contour update
* the opposite vertex.
*/
- if (i == *contour) {
+ if (i == (unsigned int) *contour) {
j = (*vertex+1) % num_points;
- new_dist = LineToPointDist(&points[*vertex], &points[j], &po);
- k = ((unsigned)(*vertex-1)) % num_points;
- dist2 = LineToPointDist(&points[*vertex], &points[k], &po);
+ new_dist = ZnLineToPointDist(&points[*vertex], &points[j], &po);
+ k = ((unsigned int)(*vertex-1)) % num_points;
+ dist2 = ZnLineToPointDist(&points[*vertex], &points[k], &po);
if (dist2 < new_dist) {
*o_vertex = k;
}
@@ -2261,16 +2274,16 @@ PickVertex(Item item,
**********************************************************************************
*/
static void
-GetAnchor(Item item,
- ZnAnchor anchor,
+GetAnchor(ZnItem item,
+ Tk_Anchor anchor,
ZnPoint *p)
{
ZnBBox *bbox = &item->item_bounding_box;
- Origin2Anchor(&bbox->orig,
- bbox->corner.x - bbox->orig.x,
- bbox->corner.y - bbox->orig.y,
- anchor, p);
+ ZnOrigin2Anchor(&bbox->orig,
+ bbox->corner.x - bbox->orig.x,
+ bbox->corner.y - bbox->orig.y,
+ anchor, p);
}
@@ -2281,7 +2294,7 @@ GetAnchor(Item item,
*
**********************************************************************************
*/
-static ItemClassStruct CURVE_ITEM_CLASS = {
+static ZnItemClassStruct CURVE_ITEM_CLASS = {
sizeof(CurveItemStruct),
0, /* num_parts */
False, /* has_anchors */