aboutsummaryrefslogtreecommitdiff
path: root/generic/Curve.c
diff options
context:
space:
mode:
authorlecoanet2002-01-23 14:21:09 +0000
committerlecoanet2002-01-23 14:21:09 +0000
commit5ab9ee6b0f799e844d5285373bac3cd7a019beec (patch)
tree52f9b39bcce392b9456a7c7610c898e0f291ee45 /generic/Curve.c
parentcd7b949f50063bf9e9357ffad9c65ce8d0f8f850 (diff)
downloadtkzinc-5ab9ee6b0f799e844d5285373bac3cd7a019beec.zip
tkzinc-5ab9ee6b0f799e844d5285373bac3cd7a019beec.tar.gz
tkzinc-5ab9ee6b0f799e844d5285373bac3cd7a019beec.tar.bz2
tkzinc-5ab9ee6b0f799e844d5285373bac3cd7a019beec.tar.xz
Traitement des contours par RenderPolyline.
Suppression de la d�pendance gle.
Diffstat (limited to 'generic/Curve.c')
-rw-r--r--generic/Curve.c126
1 files changed, 20 insertions, 106 deletions
diff --git a/generic/Curve.c b/generic/Curve.c
index e0444bd..1363231 100644
--- a/generic/Curve.c
+++ b/generic/Curve.c
@@ -37,9 +37,6 @@
#ifdef GPC
#include "gpc/gpc.h"
#endif
-#ifdef GLX
-#include <GL/tube.h>
-#endif
#include <ctype.h>
#include <malloc.h>
@@ -369,7 +366,7 @@ Destroy(Item item)
{
WidgetInfo *wi = item->wi;
CurveItem cv = (CurveItem) item;
-
+
POLY_FREE(&cv->shape);
if (cv->grad_geo) {
ZnFree(cv->grad_geo);
@@ -441,7 +438,6 @@ SetRenderFlags(CurveItem cv)
ISCLEAR(cv->flags, FILLED_BIT) && cv->line_width &&
ISCLEAR(cv->flags, RELIEF_OK) &&
ISCLEAR(cv->flags, CLOSED_BIT));
-
ASSIGN(cv->flags, LAST_END_OK,
(cv->last_end != NULL) &&
(cv->shape.num_contours == 1) && (cv->shape.contours[0].num_points > 1) &&
@@ -815,7 +811,7 @@ ComputeCoordinates(Item item,
&cv->fill_color->g.p, cv->grad_geo);
}
else if (cv->fill_color->type == ZN_PATH_GRADIENT) {
- ZnTransformPoint(wi->current_transfo, &cv->fill_color->g.p, &cv->grad_geo[0]);
+ ZnTransformPoint(wi->current_transfo, &cv->fill_color->g.p, &cv->grad_geo[0]);
}
}
else {
@@ -1242,7 +1238,7 @@ Render(Item item)
#ifdef GLX
WidgetInfo *wi = item->wi;
CurveItem cv = (CurveItem) item;
- int i, j, num_points;
+ int j, num_points;
ZnPoint *points;
XColor *color;
int alpha;
@@ -1261,11 +1257,13 @@ Render(Item item)
if (ISSET(cv->flags, FILLED_OK)) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (!ZnGradientFlat(cv->fill_color)) {
- RenderGradient(wi, cv->fill_color, CurveRenderCB, cv, cv->grad_geo, &cv->dev_shape);
+ RenderGradient(wi, cv->fill_color, CurveRenderCB, cv, cv->grad_geo,
+ &cv->dev_shape);
}
else if (cv->tile != ZnUnspecifiedImage) { /* Fill tiled */
RenderTile(wi, GetImageTexture(wi->win, cv->tile_name, cv->tile),
- cv->fill_color, CurveRenderCB, cv, (ZnPoint *) &item->item_bounding_box);
+ cv->fill_color, CurveRenderCB, cv,
+ (ZnPoint *) &item->item_bounding_box);
}
else {
if (cv->fill_pattern != ZnUnspecifiedPattern) { /* Fill stippled */
@@ -1323,99 +1321,17 @@ Render(Item item)
}
}
else {
- color = cv->line_color;
- glColor4us(color->red, color->green, color->blue, alpha);
- if ((cv->line_width <= wi->max_line_width) &&
- (cv->line_width <= wi->max_point_width)) {
- glLineWidth(cv->line_width);
- SetLineStyle(wi, cv->line_style);
- for (j = 0; j < cv->dev_shape.num_contours; j++) {
- num_points = cv->dev_shape.contours[j].num_points;
- points = cv->dev_shape.contours[j].points;
- if (ISSET(cv->flags, CLOSED_BIT)) {
- glBegin(GL_LINE_LOOP);
- }
- else {
- glBegin(GL_LINE_STRIP);
- }
- for (i = 0; i < num_points; i++) {
- glVertex2f(points[i].x, points[i].y);
- }
- glEnd();
- }
- if (cv->line_width > 1) {
- glPointSize(cv->line_width);
- for (j = 0; j < cv->dev_shape.num_contours; j++) {
- num_points = cv->dev_shape.contours[j].num_points;
- points = cv->dev_shape.contours[j].points;
- glBegin(GL_POINTS);
- for (i = 0; i < num_points; i++) {
- glVertex2f(points[i].x, points[i].y);
- }
- glEnd();
- }
- }
- }
- else {
- double lw_2 = (double) cv->line_width / 2.0;
- double section[2][2] = { { 0.0, -lw_2 }, { 0.0, lw_2 } };
- double up[3] = { 1.0, 0.0, 0.0 };
- double (*gl_pts)[3];
- int style, num;
-
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- for (j = 0; j < cv->dev_shape.num_contours; j++) {
- num_points = cv->dev_shape.contours[j].num_points;
- points = cv->dev_shape.contours[j].points;
- ZnListAssertSize(wi->work_doubles, (num_points+3)*3);
- gl_pts = (void *) ZnListArray(wi->work_doubles);
- if (ISSET(cv->flags, CLOSED_BIT)) {
- gl_pts[0][0] = points[num_points-1].x;
- gl_pts[0][1] = points[num_points-1].y;
- gl_pts[0][2] = 0;
- gl_pts[num_points+1][0] = points[0].x;
- gl_pts[num_points+1][1] = points[0].y;
- gl_pts[num_points+1][2] = 0;
- gl_pts[num_points+2][0] = points[1].x;
- gl_pts[num_points+2][1] = points[1].y;
- gl_pts[num_points+2][2] = 0;
- }
- else {
- gl_pts[0][0] = points[0].x;
- gl_pts[1][1] = points[0].y;
- gl_pts[2][2] = 0;
- gl_pts[num_points+1][0] = points[num_points-1].x;
- gl_pts[num_points+1][1] = points[num_points-1].y;
- gl_pts[num_points+1][2] = 0;
- }
- for (i = 0; i < num_points; i++) {
- gl_pts[i+1][0] = points[i].x;
- gl_pts[i+1][1] = points[i].y;
- gl_pts[i+1][2] = 0;
- }
- switch (cv->join_style) {
- case JoinRound:
- style = TUBE_JN_ROUND;
- break;
- case JoinMiter:
- style = TUBE_JN_ANGLE;
- break;
- case JoinBevel:
- style = TUBE_JN_CUT;
- break;
- }
- if (cv->cap_style == CapRound) {
- style |= TUBE_JN_CAP;
- }
- style |= TUBE_CONTOUR_CLOSED;
-
- num = num_points+2;
- if (ISSET(cv->flags, CLOSED_BIT)) {
- num++;
- }
- gleSetJoinStyle(style);
- gleExtrusion(2, section, NULL, up, num, gl_pts, NULL);
- }
+ ZnLineEnd first = ISSET(cv->flags, FIRST_END_OK) ? cv->first_end : NULL;
+ ZnLineEnd last = ISSET(cv->flags, LAST_END_OK) ? cv->last_end : NULL;
+ ZnBool closed = ISSET(cv->flags, CLOSED_BIT);
+
+ for (j = 0; j < cv->dev_shape.num_contours; j++) {
+ RenderPolyline(wi,
+ cv->dev_shape.contours[j].points,
+ cv->dev_shape.contours[j].num_points,
+ cv->line_width, closed,
+ cv->line_style, cv->cap_style, cv->join_style,
+ first, last, cv->line_color, alpha);
}
}
}
@@ -1918,11 +1834,9 @@ Contour(Item item,
POLY_INIT(&rpoly);
gpc_polygon_clip(cmd, (gpc_polygon *) &cv->shape, (gpc_polygon *) poly,
(gpc_polygon *) &rpoly);
+
POLY_SET(&cv->shape, &rpoly);
- /*printf("cmd %d, num contours %d, num vertices %d\n",
- cmd,
- cv->shape.num_contours,
- cv->shape.contours[0].num_points);*/
+
ITEM.Invalidate(item, ZN_COORDS_FLAG);
}
#endif