aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/Track.c152
1 files changed, 73 insertions, 79 deletions
diff --git a/generic/Track.c b/generic/Track.c
index 14c3de2..2b0fa88 100644
--- a/generic/Track.c
+++ b/generic/Track.c
@@ -93,7 +93,7 @@ typedef struct _TrackItemStruct {
/* Public data */
unsigned short flags;
- Pixmap symbol; /* item symbol */
+ ZnImage symbol; /* item symbol */
ZnGradient *symbol_color;
int label_angle; /* Label angle from track. */
ZnDim label_distance; /* Label distance from track. */
@@ -112,7 +112,7 @@ typedef struct _TrackItemStruct {
ZnDim marker_size; /* world size of error circle */
ZnGradient *marker_color; /* error circle color */
LineStyle marker_style; /* error circle style */
- Pixmap marker_fill_pattern; /* error circle fill pattern */
+ ZnImage marker_fill_pattern; /* error circle fill pattern */
ZnGradient *connection_color; /* connection color */
LineStyle connection_style;
ZnDim connection_width;
@@ -136,6 +136,9 @@ typedef struct _TrackItemStruct {
static ZnAttrConfig track_attrs[] = {
{ ZN_CONFIG_BOOL, "-circlehistory", NULL,
Tk_Offset(TrackItemStruct, flags), CIRCLE_HISTORY_BIT, ZN_DRAW_FLAG, False },
+ { ZN_CONFIG_BOOL, "-composealpha", NULL,
+ Tk_Offset(TrackItemStruct, header.flags), COMPOSE_ALPHA_BIT,
+ ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-composerotation", NULL,
Tk_Offset(TrackItemStruct, header.flags), COMPOSE_ROTATION_BIT,
ZN_COORDS_FLAG, False },
@@ -204,7 +207,7 @@ static ZnAttrConfig track_attrs[] = {
Tk_Offset(TrackItemStruct, leader_width), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_GRADIENT, "-markercolor", NULL,
Tk_Offset(TrackItemStruct, marker_color), 0, ZN_DRAW_FLAG, False },
- { ZN_CONFIG_PATTERN, "-markerfillpattern", NULL,
+ { ZN_CONFIG_BITMAP, "-markerfillpattern", NULL,
Tk_Offset(TrackItemStruct, marker_fill_pattern), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_DIM, "-markersize", NULL,
Tk_Offset(TrackItemStruct, marker_size), 0, ZN_COORDS_FLAG, False },
@@ -234,14 +237,14 @@ static ZnAttrConfig track_attrs[] = {
Tk_Offset(TrackItemStruct, flags), SV_TICKS_BIT, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_DIM, "-speedvectorwidth", NULL,
Tk_Offset(TrackItemStruct, speed_vector_width), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_PATTERN, "-symbol", NULL,
+ { ZN_CONFIG_BITMAP, "-symbol", NULL,
Tk_Offset(TrackItemStruct, symbol), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_GRADIENT, "-symbolcolor", NULL,
Tk_Offset(TrackItemStruct, symbol_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-symbolsensitive", NULL,
Tk_Offset(TrackItemStruct, header.part_sensitive), PART_NUMBER_TO_BIT(CURRENT_POSITION),
ZN_REPICK_FLAG, False },
- { ZN_CONFIG_TAGS, "-tags", NULL,
+ { ZN_CONFIG_TAG_LIST, "-tags", NULL,
Tk_Offset(TrackItemStruct, header.tags), 0, 0, False },
{ ZN_CONFIG_BOOL, "-visible", NULL,
Tk_Offset(TrackItemStruct, header.flags), VISIBLE_BIT,
@@ -253,6 +256,9 @@ static ZnAttrConfig track_attrs[] = {
};
static ZnAttrConfig wp_attrs[] = {
+ { ZN_CONFIG_BOOL, "-composealpha", NULL,
+ Tk_Offset(TrackItemStruct, header.flags), COMPOSE_ALPHA_BIT,
+ ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-composerotation", NULL,
Tk_Offset(TrackItemStruct, header.flags), COMPOSE_ROTATION_BIT,
ZN_COORDS_FLAG, False },
@@ -309,7 +315,7 @@ static ZnAttrConfig wp_attrs[] = {
Tk_Offset(TrackItemStruct, leader_width), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_GRADIENT, "-markercolor", NULL,
Tk_Offset(TrackItemStruct, marker_color), 0, ZN_DRAW_FLAG, False },
- { ZN_CONFIG_PATTERN, "-markerfillpattern", NULL,
+ { ZN_CONFIG_BITMAP, "-markerfillpattern", NULL,
Tk_Offset(TrackItemStruct, marker_fill_pattern), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_DIM, "-markersize", NULL,
Tk_Offset(TrackItemStruct, marker_size), 0, ZN_COORDS_FLAG, False },
@@ -324,14 +330,14 @@ static ZnAttrConfig wp_attrs[] = {
ZN_DRAW_FLAG|ZN_REPICK_FLAG, False },
{ ZN_CONFIG_BOOL, "-sensitive", NULL,
Tk_Offset(TrackItemStruct, header.flags), SENSITIVE_BIT, ZN_REPICK_FLAG, False },
- { ZN_CONFIG_PATTERN, "-symbol", NULL,
+ { ZN_CONFIG_BITMAP, "-symbol", NULL,
Tk_Offset(TrackItemStruct, symbol), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_GRADIENT, "-symbolcolor", NULL,
Tk_Offset(TrackItemStruct, symbol_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-symbolsensitive", NULL,
Tk_Offset(TrackItemStruct, header.part_sensitive), PART_NUMBER_TO_BIT(CURRENT_POSITION),
ZN_REPICK_FLAG, False },
- { ZN_CONFIG_TAGS, "-tags", NULL,
+ { ZN_CONFIG_TAG_LIST, "-tags", NULL,
Tk_Offset(TrackItemStruct, header.tags), 0, 0, False },
{ ZN_CONFIG_BOOL, "-visible", NULL,
Tk_Offset(TrackItemStruct, header.flags), VISIBLE_BIT,
@@ -362,6 +368,7 @@ Init(Item item,
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->part_sensitive, PART_NUMBER_TO_BIT(CURRENT_POSITION));
@@ -369,7 +376,7 @@ Init(Item item,
SET(item->part_sensitive, PART_NUMBER_TO_BIT(CONNECTION));
SET(item->part_sensitive, PART_NUMBER_TO_BIT(SPEED_VECTOR));
track->symbol_color = ZnGetGradientByValue(wi->fore_color);
- track->symbol = Tk_GetBitmap(wi->interp, wi->win, Tk_GetUid("AtcSymbol15"));
+ track->symbol = ZnGetBitmap(wi, Tk_GetUid("AtcSymbol15"));
track->label_anchor = ZnAnchorCenter;
track->label_angle = DEFAULT_LABEL_ANGLE;
track->label_distance = DEFAULT_LABEL_DISTANCE;
@@ -389,7 +396,7 @@ Init(Item item,
track->connection_width = DEFAULT_LINE_WIDTH;
track->marker_color = ZnGetGradientByValue(wi->fore_color);
track->marker_style = LINE_SIMPLE;
- track->marker_fill_pattern = ZnUnspecifiedPattern;
+ track->marker_fill_pattern = ZnUnspecifiedImage;
track->speed_vector_color = ZnGetGradientByValue(wi->fore_color);
track->history_color = ZnGetGradientByValue(wi->fore_color);
CLEAR(track->flags, MARKER_FILLED_BIT);
@@ -461,7 +468,6 @@ static void
Clone(Item item)
{
TrackItem track = (TrackItem) item;
- WidgetInfo *wi = item->wi;
if (track->history) {
track->history = ZnListDuplicate(track->history);
@@ -482,6 +488,7 @@ Clone(Item item)
}
FIELD.CloneFields(&track->field_set);
+ track->field_set.item = item;
/*
* We get all shared resources, colors bitmaps.
@@ -492,13 +499,11 @@ Clone(Item item)
track->marker_color = ZnGetGradientByValue(track->marker_color);
track->speed_vector_color = ZnGetGradientByValue(track->speed_vector_color);
track->history_color = ZnGetGradientByValue(track->history_color);
- if (track->symbol != ZnUnspecifiedPattern) {
- track->symbol = Tk_GetBitmap(wi->interp, wi->win,
- Tk_NameOfBitmap(wi->dpy, track->symbol));
+ if (track->symbol != ZnUnspecifiedImage) {
+ track->symbol = ZnGetImageByValue(track->symbol);
}
- if (track->marker_fill_pattern != ZnUnspecifiedPattern) {
- track->marker_fill_pattern = Tk_GetBitmap(wi->interp, wi->win,
- Tk_NameOfBitmap(wi->dpy, track->marker_fill_pattern));
+ if (track->marker_fill_pattern != ZnUnspecifiedImage) {
+ track->marker_fill_pattern = ZnGetImageByValue(track->marker_fill_pattern);
}
}
@@ -514,7 +519,6 @@ static void
Destroy(Item item)
{
TrackItem track = (TrackItem) item;
- WidgetInfo *wi = item->wi;
if (track->leader_points) {
ZnListFree(track->leader_points);
@@ -539,11 +543,13 @@ Destroy(Item item)
ZnFreeGradient(track->marker_color);
ZnFreeGradient(track->speed_vector_color);
ZnFreeGradient(track->history_color);
- if (track->symbol != ZnUnspecifiedPattern) {
- Tk_FreeBitmap(wi->dpy, track->symbol);
+ if (track->symbol != ZnUnspecifiedImage) {
+ ZnFreeImage(track->symbol);
+ track->symbol = ZnUnspecifiedImage;
}
- if (track->marker_fill_pattern != ZnUnspecifiedPattern) {
- Tk_FreeBitmap(wi->dpy, track->marker_fill_pattern);
+ if (track->marker_fill_pattern != ZnUnspecifiedImage) {
+ ZnFreeImage(track->marker_fill_pattern);
+ track->marker_fill_pattern = ZnUnspecifiedImage;
}
FIELD.FreeFields(&track->field_set);
@@ -602,6 +608,10 @@ Configure(Item item,
return ZN_ERROR;
}
+ if (track->label_angle < 0) {
+ track->label_angle = 360 + track->label_angle;
+ }
+
/*
* Trunc the visible history to the managed size.
*/
@@ -717,8 +727,8 @@ ComputeCoordinates(Item item,
track->dev.x = REAL_TO_INT(track->dev.x);
track->dev.y = REAL_TO_INT(track->dev.y);
/*printf("track pos %g %g --> %g %g\n", track->pos.x, track->pos.y, track->dev.x, track->dev.y);*/
- if (track->symbol != ZnUnspecifiedPattern) {
- Tk_SizeOfBitmap(wi->dpy, track->symbol, &w, &h);
+ if (track->symbol != ZnUnspecifiedImage) {
+ ZnSizeOfImage(track->symbol, &w, &h);
/*printf("taille symbole %d %d\n", w, h);*/
w2 = (w+1)/2;
h2 = (h+1)/2;
@@ -807,7 +817,7 @@ ComputeCoordinates(Item item,
}
/* Compute the new label bounding box. */
- if (field_set->label_format) {
+ if (field_set->label_format && field_set->num_fields) {
ZnDim bb_width, bb_height, dist;
ZnPoint leader_end;
@@ -914,8 +924,8 @@ ComputeCoordinates(Item item,
if (!track->leader_points) {
track->leader_points = ZnListNew(LINE_SHAPE_POINTS, sizeof(ZnPoint));
}
- GetLineShape(&track->dev, &leader_end, track->leader_width,
- track->leader_shape, &bbox, track->leader_points);
+ ZnGetLineShape(&track->dev, &leader_end, track->leader_width,
+ track->leader_shape, &bbox, track->leader_points);
AddBBoxToBBox(&item->item_bounding_box, &bbox);
points = (ZnPoint *) ZnListArray(track->leader_points);
num_points = ZnListSize(track->leader_points);
@@ -958,25 +968,21 @@ ComputeCoordinates(Item item,
*/
static int
ToArea(Item item,
- ZnBBox *area,
- Tk_Uid tag_uid,
- int enclosed,
- ZnBool report)
+ ZnToArea ta)
{
- WidgetInfo *wi = item->wi;
TrackItem track = (TrackItem) item;
int inside;
int width, height;
ZnDim lwidth, lheight;
- ZnBBox bbox;
+ ZnBBox bbox, *area = ta->area;
ZnPoint pts[2];
/*
* Try the current position.
*/
ResetBBox(&bbox);
- if (track->symbol != ZnUnspecifiedPattern) {
- Tk_SizeOfBitmap(wi->dpy, track->symbol, &width, &height);
+ if (track->symbol != ZnUnspecifiedImage) {
+ ZnSizeOfImage(track->symbol, &width, &height);
bbox.orig.x = track->dev.x-(width+1)/2;
bbox.orig.y = track->dev.y-(height+1)/2;
bbox.corner.x = bbox.orig.x + width;
@@ -1075,7 +1081,6 @@ Draw(Item item)
WidgetInfo *wi = item->wi;
TrackItem track = (TrackItem) item;
Item c_item;
- char tmp_str[] = ".";
XGCValues values;
History hist;
int h_side_size, side_size, width=0, height=0;
@@ -1083,11 +1088,11 @@ Draw(Item item)
/* Draw the marker */
if (track->marker_size_dev != 0) {
- SetLineStyle(wi, track->marker_style);
+ ZnSetLineStyle(wi, track->marker_style);
values.foreground = ZnPixel(ZnGetGradientColor(track->marker_color, 0, NULL));
values.line_width = 0;
if (ISSET(track->flags, MARKER_FILLED_BIT)) {
- if (track->marker_fill_pattern == ZnUnspecifiedPattern) {
+ if (track->marker_fill_pattern == ZnUnspecifiedImage) {
/* Fill solid */
values.fill_style = FillSolid;
XChangeGC(wi->dpy, wi->gc, GCFillStyle | GCLineWidth | GCForeground, &values);
@@ -1095,7 +1100,7 @@ Draw(Item item)
else {
/* Fill stippled */
values.fill_style = FillStippled;
- values.stipple = track->marker_fill_pattern;
+ values.stipple = ZnImagePixmap(track->marker_fill_pattern, NULL);
XChangeGC(wi->dpy, wi->gc,
GCFillStyle | GCStipple | GCLineWidth | GCForeground, &values);
}
@@ -1125,9 +1130,9 @@ Draw(Item item)
pts[0] = track->dev;
pts[1] = ((TrackItem) item->connected_item)->dev;
- DrawLineShape(wi, pts, 2, track->connection_style,
- ZnGetGradientColor(track->connection_color, 0, NULL),
- track->connection_width, LINE_STRAIGHT);
+ ZnDrawLineShape(wi, pts, 2, track->connection_style,
+ ZnGetGradientColor(track->connection_color, 0, NULL),
+ track->connection_width, LINE_STRAIGHT);
}
/*
@@ -1155,9 +1160,9 @@ Draw(Item item)
points = (ZnPoint *) ZnListArray(track->leader_points);
num_points = ZnListSize(track->leader_points);
- DrawLineShape(wi, points, num_points, track->leader_style,
- ZnGetGradientColor(track->leader_color, 0, NULL),
- track->leader_width, track->leader_shape);
+ ZnDrawLineShape(wi, points, num_points, track->leader_style,
+ ZnGetGradientColor(track->leader_color, 0, NULL),
+ track->leader_width, track->leader_shape);
if (track->leader_first_end != NULL) {
GetLineEnd(&points[0], &points[1], track->leader_width,
CapRound, track->leader_first_end, end_points);
@@ -1180,9 +1185,8 @@ Draw(Item item)
}
}
- tmp_str[0] = track->symbol;
- if (track->symbol != ZnUnspecifiedPattern) {
- Tk_SizeOfBitmap(wi->dpy, track->symbol, &width, &height);
+ if (track->symbol != ZnUnspecifiedImage) {
+ ZnSizeOfImage(track->symbol, &width, &height);
}
/*
@@ -1247,12 +1251,12 @@ Draw(Item item)
/*
* Draw the current position using a pattern for Tk.
*/
- if (track->symbol != ZnUnspecifiedPattern) {
+ if (track->symbol != ZnUnspecifiedImage) {
int x = track->dev.x - (width+1)/2;
int y = track->dev.y - (height+1)/2;
values.foreground = ZnPixel(ZnGetGradientColor(track->symbol_color, 0, NULL));
values.fill_style = FillStippled;
- values.stipple = track->symbol;
+ values.stipple = ZnImagePixmap(track->symbol, NULL);
values.ts_x_origin = x;
values.ts_y_origin = y;
XChangeGC(wi->dpy, wi->gc,
@@ -1282,7 +1286,6 @@ Render(Item item)
WidgetInfo *wi = item->wi;
TrackItem track = (TrackItem) item;
TrackItem c_item;
- char tmp_str[] = ".";
History hist;
int h_side_size, side_size, width=0, height=0;
int i, j, nb_hist, num_acc_pos, alpha;
@@ -1293,7 +1296,7 @@ Render(Item item)
/* Draw the marker */
if (track->marker_size_dev != 0) {
- points = GetCirclePoints(3, ZN_CIRCLE_MEDIUM, 0, 360, &num_points, NULL);
+ points = GetCirclePoints(3, ZN_CIRCLE_MEDIUM, 0, 2*M_PI, &num_points, NULL);
x0 = track->dev.x;
y0 = track->dev.y;
size = track->marker_size_dev;
@@ -1302,12 +1305,12 @@ Render(Item item)
glColor4us(color->red, color->green, color->blue, alpha);
if (ISSET(track->flags, MARKER_FILLED_BIT)) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- if (track->marker_fill_pattern != ZnUnspecifiedPattern) { /* Fill stippled */
+ if (track->marker_fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */
/*
* Setup polygon stippling.
*/
glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple(GetBitmapMask(wi->dpy, track->marker_fill_pattern)->pixels);
+ glPolygonStipple(ZnImagePattern(track->marker_fill_pattern, NULL));
}
glBegin(GL_TRIANGLE_FAN);
for (i = 0; i < num_points; i++) {
@@ -1318,7 +1321,7 @@ Render(Item item)
}
else {
glLineWidth(1);
- SetLineStyle(wi, track->marker_style);
+ ZnSetLineStyle(wi, track->marker_style);
glBegin(GL_LINE_LOOP);
for (i = 0; i < num_points; i++) {
glVertex2f(x0 + points[i].x*size, y0 + points[i].y*size);
@@ -1413,23 +1416,22 @@ Render(Item item)
if (track->field_set.label_format && (track->leader_width > 0)) {
points = ZnListArray(track->leader_points);
num_points = ZnListSize(track->leader_points);
- RenderPolyline(wi,
- points, num_points, track->leader_width,
- track->leader_style, CapRound, JoinRound,
- track->leader_first_end, track->leader_last_end,
- track->leader_color);
+ ZnRenderPolyline(wi,
+ points, num_points, track->leader_width,
+ track->leader_style, CapRound, JoinRound,
+ track->leader_first_end, track->leader_last_end,
+ track->leader_color);
}
- tmp_str[0] = track->symbol;
- if (track->symbol != ZnUnspecifiedPattern) {
- Tk_SizeOfBitmap(wi->dpy, track->symbol, &width, &height);
+ if (track->symbol != ZnUnspecifiedImage) {
+ ZnSizeOfImage(track->symbol, &width, &height);
}
/*
* Draw the history, current pos excepted.
*/
if ((item->class == ZnTrack) && track->history) {
- points = GetCirclePoints(3, ZN_CIRCLE_COARSE, 0, 360, &num_points, NULL);
+ points = GetCirclePoints(3, ZN_CIRCLE_COARSE, 0, 2*M_PI, &num_points, NULL);
color = ZnGetGradientColor(track->history_color, 0, &alpha);
alpha = ZnComposeAlpha(alpha, wi->alpha);
glColor4us(color->red, color->green, color->blue, alpha);
@@ -1513,13 +1515,12 @@ Render(Item item)
/*
* Draw the current position using a pattern.
*/
- if (track->symbol != ZnUnspecifiedPattern) {
+ if (track->symbol != ZnUnspecifiedImage) {
ZnPoint p;
p.x = track->dev.x - (width+1)/2;
p.y = track->dev.y - (height+1)/2;
- RenderImage(wi, (ImageBits *) GetBitmapTexture(wi->dpy, track->symbol),
- track->symbol_color, &p, True);
+ ZnRenderImage(wi, track->symbol, track->symbol_color, &p, True);
}
/*
@@ -1567,18 +1568,13 @@ IsSensitive(Item item,
*/
static double
Pick(Item item,
- ZnPoint *p,
- Item start_item,
- int aperture,
- Item *a_item,
- int *part)
+ ZnPick ps)
{
- WidgetInfo *wi= item->wi;
TrackItem track = (TrackItem) item;
Item c_item;
ZnBBox bbox;
double dist=0, new_dist;
- ZnPoint *points;
+ ZnPoint *points, *p = ps->point;
int num_points, i;
int width=0, height=0;
double width_2;
@@ -1597,8 +1593,8 @@ Pick(Item item,
* Try the current position symbol.
*/
ResetBBox(&bbox);
- if (track->symbol != ZnUnspecifiedPattern) {
- Tk_SizeOfBitmap(wi->dpy, track->symbol, &width, &height);
+ if (track->symbol != ZnUnspecifiedImage) {
+ ZnSizeOfImage(track->symbol, &width, &height);
bbox.orig.x = track->dev.x-(width+1)/2;
bbox.orig.y = track->dev.y-(height+1)/2;
bbox.corner.x = bbox.orig.x + width;
@@ -1699,7 +1695,7 @@ Pick(Item item,
/* printf("track %d reporting part %d, distance %lf\n",
item->id, best_part, dist); */
- *part = best_part;
+ ps->a_part = best_part;
return dist;
}
@@ -2232,7 +2228,6 @@ Selection(Item item,
*/
static ItemClassStruct TRACK_ITEM_CLASS = {
sizeof(TrackItemStruct),
- True, /* has_fields */
4, /* num_parts */
True, /* has_anchors */
"track",
@@ -2266,7 +2261,6 @@ static ItemClassStruct TRACK_ITEM_CLASS = {
static ItemClassStruct WAY_POINT_ITEM_CLASS = {
sizeof(TrackItemStruct),
- True, /* has_fields */
3, /* num_parts */
True, /* has_anchors */
"waypoint",