aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlecoanet2002-03-15 14:29:02 +0000
committerlecoanet2002-03-15 14:29:02 +0000
commit2668aa298a2d2088ce8698b32131414cf635efaa (patch)
tree449ba8a879a293bd704943fb3b7d46bf712d4cef
parentc69d91d204f227f02ddc92cc9c4cf135a526f2c7 (diff)
downloadtkzinc-2668aa298a2d2088ce8698b32131414cf635efaa.zip
tkzinc-2668aa298a2d2088ce8698b32131414cf635efaa.tar.gz
tkzinc-2668aa298a2d2088ce8698b32131414cf635efaa.tar.bz2
tkzinc-2668aa298a2d2088ce8698b32131414cf635efaa.tar.xz
Ajustement des ressources couleurs pour tenir compte de la
g�n�ralisation des gradients. Traitement centralis� des images. Les reliefs ont leur propre alpha. Ajout de l'attribut booleen -smoothrelief qui permet de choisir la progression longitudinale du relief : soit progressive, soit par facettes. Adaptation pour les nouvelles constantes de relief. Dessin des marqueurs sur les sommets en GL.
-rw-r--r--generic/Curve.c131
1 files changed, 70 insertions, 61 deletions
diff --git a/generic/Curve.c b/generic/Curve.c
index abec56e..9ea09de 100644
--- a/generic/Curve.c
+++ b/generic/Curve.c
@@ -52,6 +52,7 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
#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 CLOSED_BIT 1<<2 /* If the outline should be closed automatically */
+#define SMOOTH_RELIEF_BIT 1<<3 /* If the relief should be continuous (arc) or discrete (angle) */
#define REDUCED_BIT 1<<5 /* Tell if the contours are in the most reduced
* form. */
#define FIRST_END_OK 1<<6
@@ -143,6 +144,9 @@ static ZnAttrConfig cv_attrs[] = {
ZN_COORDS_FLAG, False },
{ ZN_CONFIG_BOOL, "-sensitive", NULL,
Tk_Offset(CurveItemStruct, header.flags), SENSITIVE_BIT,
+ ZN_DRAW_FLAG, False },
+ { ZN_CONFIG_BOOL, "-smoothrelief", NULL,
+ Tk_Offset(CurveItemStruct, flags), SMOOTH_RELIEF_BIT,
ZN_REPICK_FLAG, False },
{ ZN_CONFIG_TAGS, "-tags", NULL,
Tk_Offset(CurveItemStruct, header.tags), 0, 0, False },
@@ -210,6 +214,7 @@ Init(Item item,
SET(item->flags, COMPOSE_ROTATION_BIT);
SET(item->flags, COMPOSE_SCALE_BIT);
CLEAR(cv->flags, CLOSED_BIT);
+ CLEAR(cv->flags, SMOOTH_RELIEF_BIT);
SET(cv->flags, REDUCED_BIT);
item->priority = DEFAULT_CURVE_PRIORITY;
@@ -266,9 +271,9 @@ Init(Item item,
*/
SET(cv->flags, MARKED_BIT);
cv->marker = ZnUnspecifiedPattern;
- cv->fill_color = ZnGetGradientByValue(wi->fore_gradient);
- cv->line_color = ZnGetGradientByValue(wi->fore_gradient);
- cv->marker_color = ZnGetGradientByValue(wi->fore_gradient);
+ cv->fill_color = ZnGetGradientByValue(wi->fore_color);
+ cv->line_color = ZnGetGradientByValue(wi->fore_color);
+ cv->marker_color = ZnGetGradientByValue(wi->fore_color);
return ZN_OK;
}
@@ -327,7 +332,7 @@ Clone(Item item)
if (cv->last_end) {
LineEndDuplicate(cv->last_end);
}
- if (strlen(cv->tile_name) != 0) {
+ if (cv->tile != ZnUnspecifiedImage) {
text = ZnMalloc((strlen(cv->tile_name) + 1) * sizeof(char));
strcpy(text, cv->tile_name);
cv->tile_name = text;
@@ -458,6 +463,8 @@ Configure(Item item,
WidgetInfo *wi = item->wi;
CurveItem cv = (CurveItem) item;
int status = ZN_OK;
+ XColor *color;
+ int alpha;
status = ITEM_P.ConfigureAttributes((char *) item, -1, argc, argv, flags);
@@ -467,34 +474,18 @@ Configure(Item item,
cv->gradient = NULL;
}
if ((cv->relief != RELIEF_FLAT) && !cv->gradient) {
+ color = ZnGetGradientColor(cv->line_color, 51.0, &alpha);
cv->gradient = ZnGetReliefGradient(wi->interp, wi->win,
- ZnNameOfColor(ZnGetGradientColor(cv->fill_color,
- 50.0, NULL)));
+ ZnNameOfColor(color), alpha);
if (cv->gradient == NULL) {
status = ZN_ERROR;
}
}
if (ISSET(*flags, ZN_TILE_FLAG)) {
- Tk_Image tile;
-
- if (strcmp(cv->tile_name, "") != 0) {
- tile = Tk_GetImage(wi->interp, wi->win, cv->tile_name,
- CvTileChange, (ClientData) cv);
- if (tile == NULL) {
- /*
- * The name will not be in sync with the image in
- * this case.
- */
- status = ZN_ERROR;
- }
- }
- else {
- tile = ZnUnspecifiedImage;
- }
- if (cv->tile != ZnUnspecifiedImage) {
- Tk_FreeImage(cv->tile);
+ if (ValidateImage(wi, item, cv->tile_name, CvTileChange,
+ &cv->tile, "curve -tile") == ZN_ERROR) {
+ status = ZN_ERROR;
}
- cv->tile = tile;
}
return status;
@@ -981,7 +972,6 @@ Draw(Item item)
unsigned int gc_mask;
ZnPoint *points=NULL;
XPoint *xpoints=NULL;
- ReliefStyle relief;
if ((cv->dev_shape.num_contours == 0) ||
(ISCLEAR(cv->flags, FILLED_OK) &&
@@ -1056,12 +1046,13 @@ Draw(Item item)
if (cv->line_width) {
ZnPoint end_points[LINE_END_POINTS];
XPoint xp[LINE_END_POINTS];
-
+ ReliefStyle relief;
+ int lw, relief_dir;
+
/*
* Drawing with relief disables: ends, line style and line pattern.
*/
if (ISSET(cv->flags, RELIEF_OK)) {
- relief = cv->relief;
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;
@@ -1070,24 +1061,20 @@ Draw(Item item)
num_points, points[0].x, points[0].y,
points[num_points-1].x, points[num_points-1].y,cv->shape.holes[j],
cv->dev_shape.cw[j], cv->dev_shape.cw[j]^cv->shape.holes[j]);*/
+ lw = cv->line_width;
+ relief = cv->relief;
+ relief_dir = relief & RELIEF_MASK;
if (cv->dev_shape.cw[j]^cv->shape.holes[j]) {
- switch (relief) {
- case RELIEF_BEVEL_OUT:
- relief = RELIEF_BEVEL_IN;
- break;
- case RELIEF_BEVEL_IN:
- relief = RELIEF_BEVEL_OUT;
- break;
- case RELIEF_RIDGE:
- relief = RELIEF_GROOVE;
- break;
- case RELIEF_GROOVE:
- relief = RELIEF_RIDGE;
- break;
+ lw = -lw;
+ if (relief_dir == RELIEF_SUNKEN) {
+ relief_dir = RELIEF_RAISED;
+ }
+ else {
+ relief_dir = RELIEF_SUNKEN;
}
+ relief = (relief & ~RELIEF_MASK) | relief_dir;
}
- DrawPolygonRelief(wi, relief, cv->gradient, points, num_points,
- (cv->dev_shape.cw[j]^cv->shape.holes[j])?-cv->line_width:cv->line_width);
+ DrawPolygonRelief(wi, relief, cv->gradient, points, num_points, lw);
}
}
else {
@@ -1236,7 +1223,6 @@ Render(Item item)
ZnPoint *points;
XColor *color;
int alpha;
- ReliefStyle relief;
if ((cv->dev_shape.num_contours == 0) ||
(ISCLEAR(cv->flags, FILLED_OK) &&
@@ -1285,7 +1271,10 @@ Render(Item item)
ZnGetGradientColor(cv->line_color, 0, &alpha);
alpha = ZnComposeAlpha(alpha, wi->alpha);
if (ISSET(cv->flags, RELIEF_OK)) {
- relief = cv->relief;
+ ReliefStyle relief;
+ ZnDim line_width;
+ int relief_dir;
+
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;
@@ -1294,25 +1283,22 @@ Render(Item item)
num_points, points[0].x, points[0].y,
points[num_points-1].x, points[num_points-1].y,cv->shape.holes[j],
cv->dev_shape.cw[j], cv->dev_shape.cw[j]^cv->shape.holes[j]);*/
+ relief = cv->relief;
+ line_width = cv->line_width;
+ relief_dir = relief & RELIEF_MASK;
if (cv->dev_shape.cw[j]^cv->shape.holes[j]) {
- switch (relief) {
- case RELIEF_BEVEL_OUT:
- relief = RELIEF_BEVEL_IN;
- break;
- case RELIEF_BEVEL_IN:
- relief = RELIEF_BEVEL_OUT;
- break;
- case RELIEF_RIDGE:
- relief = RELIEF_GROOVE;
- break;
- case RELIEF_GROOVE:
- relief = RELIEF_RIDGE;
- break;
+ line_width = -line_width;
+ if (relief_dir == RELIEF_SUNKEN) {
+ relief_dir = RELIEF_RAISED;
}
+ else {
+ relief_dir = RELIEF_SUNKEN;
+ }
+ relief = (relief & ~RELIEF_MASK) | relief_dir;
}
- RenderPolygonRelief(wi, relief, cv->gradient, alpha,
- False, points, num_points,
- (cv->dev_shape.cw[j]^cv->shape.holes[j])?-cv->line_width:cv->line_width);
+ RenderPolygonRelief(wi, relief, cv->gradient,
+ ISSET(cv->flags, SMOOTH_RELIEF_BIT),
+ points, num_points, line_width);
}
}
else {
@@ -1336,6 +1322,29 @@ Render(Item item)
* if last point join first point suppress markers at end points.
*/
if (ISSET(cv->flags, MARKER_OK)) {
+ int width, h_width, height, h_height;
+ ZnPoint ptmp;
+
+ Tk_SizeOfBitmap(wi->dpy, cv->marker, &width, &height);
+ h_width = (width+1.0)/2.0;
+ h_height = (height+1.0)/2.0;
+ 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, FIRST_END_OK)) {
+ num_points--;
+ points++;
+ }
+ if (ISSET(cv->flags, LAST_END_OK)) {
+ num_points--;
+ }
+ for (; num_points > 0; num_points--, points++) {
+ ptmp.x = points->x - h_width;
+ ptmp.y = points->y - h_height;
+ RenderImage(wi, (ImageBits *) GetBitmapTexture(wi->dpy, cv->marker),
+ cv->marker_color, &ptmp, True);
+ }
+ }
}
#endif
}