aboutsummaryrefslogtreecommitdiff
path: root/generic/Track.c
diff options
context:
space:
mode:
authorlecoanet2000-12-22 17:37:48 +0000
committerlecoanet2000-12-22 17:37:48 +0000
commitb190ac7bb7abcaad09c0d4d02ded66dcf374c8d0 (patch)
tree2e6261652abe1f303528a83b337f47ad8df814c4 /generic/Track.c
parente031229a89b4067020d7a762f11f001bac6115e7 (diff)
downloadtkzinc-b190ac7bb7abcaad09c0d4d02ded66dcf374c8d0.zip
tkzinc-b190ac7bb7abcaad09c0d4d02ded66dcf374c8d0.tar.gz
tkzinc-b190ac7bb7abcaad09c0d4d02ded66dcf374c8d0.tar.bz2
tkzinc-b190ac7bb7abcaad09c0d4d02ded66dcf374c8d0.tar.xz
Le vecteur vitesse est cod� en flottant et il est possible de modifier
sa largeur. Correction de bugs tr�s g�nants dans l'appel de l'antirec. Correction de la spec associ�e avec l'option -lastasfirst : maintenant la derniere pos prend la couleur du symbole de tete lorsque le nombre de pos pass�es est atteint.
Diffstat (limited to 'generic/Track.c')
-rw-r--r--generic/Track.c136
1 files changed, 76 insertions, 60 deletions
diff --git a/generic/Track.c b/generic/Track.c
index f61c661..d85f71c 100644
--- a/generic/Track.c
+++ b/generic/Track.c
@@ -103,6 +103,7 @@ typedef struct _TrackItemStruct {
int visible_history_size; /* Number of visible positions */
ZnPoint pos; /* item world coordinates */
ZnPoint speed_vector; /* s. v. slope in world coord */
+ int speed_vector_width;
ZnColor history_color;
/* Private data */
@@ -206,6 +207,8 @@ static ZnAttrConfig track_attrs[] = {
{ ZN_CONFIG_BOOL, "-speedvectorsensitive", NULL,
Tk_Offset(TrackItemStruct, header.part_sensitive), PART_NUMBER_TO_BIT(SPEED_VECTOR),
ZN_REPICK_FLAG, False },
+ { ZN_CONFIG_DIM, "-speedvectorwidth", NULL,
+ Tk_Offset(TrackItemStruct, speed_vector_width), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_PATTERN, "-symbol", NULL,
Tk_Offset(TrackItemStruct, symbol), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_COLOR, "-symbolcolor", NULL,
@@ -372,6 +375,7 @@ Init(Item item,
track->marker_size = DEFAULT_MARKER_SIZE;
track->speed_vector.x = 0;
track->speed_vector.y = 0;
+ track->speed_vector_width = DEFAULT_LINE_WIDTH;
}
else {
item->priority = DEFAULT_WAY_POINT_PRIORITY;
@@ -559,7 +563,10 @@ Configure(Item item,
WidgetInfo *wi = item->wi;
Item old_connected;
ZnPoint old_pos;
-
+#ifdef OM
+ GroupItem group = (GroupItem) item->parent;
+#endif
+
old_pos = track->pos;
old_connected = item->connected_item;
@@ -577,9 +584,15 @@ Configure(Item item,
*/
if (ISSET(*flags, ZN_POLAR_FLAG)) {
SET(track->flags, POLAR_BIT);
+#ifdef OM
+ group->call_om = True;
+#endif
}
else if (ISSET(*flags, ZN_CARTESIAN_FLAG)) {
CLEAR(track->flags, POLAR_BIT);
+#ifdef OM
+ group->call_om = True;
+#endif
}
if (ISSET(*flags, ZN_ITEM_FLAG)) {
@@ -602,7 +615,7 @@ Configure(Item item,
if (ISSET(*flags, ZN_VIS_FLAG)) {
/* Record the change to trigger the overlap manager latter */
if ((item->class == ZnTrack) && ISSET(item->flags, VISIBLE_BIT)) {
- ((GroupItem) item->parent)->call_om = True;
+ group->call_om = True;
}
}
#endif
@@ -611,6 +624,9 @@ Configure(Item item,
if (ISSET(*flags, ZN_MOVED_FLAG)) {
if (item->class == ZnTrack) {
AddToHistory(track, old_pos);
+#ifdef OM
+ group->call_om = True;
+#endif
}
}
@@ -764,44 +780,42 @@ ComputeCoordinates(Item item,
/*
* Compute the label position.
*/
- if (ISCLEAR(track->flags, FROZEN_LABEL_BIT)) {
- if (ISSET(track->flags, POLAR_BIT)) {
- /*
- * Adjust the min dist spec given in label_distance by
- * the size of the label.
- */
- if ((track->label_anchor == ZnAnchorN) ||
- (track->label_anchor == ZnAnchorCenter) ||
- (track->label_anchor == ZnAnchorS)) {
- dist = sqrt(bb_width*bb_width/4+bb_height*bb_height/4);
- }
- else {
- dist = sqrt(bb_width*bb_width+bb_height*bb_height);
- }
- dist += track->label_distance;
- /*
- * Compute heading after applying the transform.
- */
- ZnTransfoDecompose(wi->current_transfo, NULL, NULL, &rotation, NULL);
- /*printf("rotation=%g, heading=%g, angle=%d\n", rotation,
- ProjectionToAngle(track->speed_vector.x, track->speed_vector.y),
- track->label_angle);*/
- rotation = ProjectionToAngle(track->speed_vector.x, track->speed_vector.y)-rotation;
- PointPolarToCartesian(rotation, dist, track->label_angle,
- &track->label_dx, &track->label_dy);
+ if (ISSET(track->flags, POLAR_BIT)) {
+ /*
+ * Adjust the min dist spec given in label_distance by
+ * the size of the label.
+ */
+ if ((track->label_anchor == ZnAnchorN) ||
+ (track->label_anchor == ZnAnchorCenter) ||
+ (track->label_anchor == ZnAnchorS)) {
+ dist = sqrt(bb_width*bb_width/4+bb_height*bb_height/4);
}
- field_set->label_pos.x = track->dev.x + track->label_dx;
- field_set->label_pos.y = track->dev.y - track->label_dy;
- Anchor2Origin(&field_set->label_pos, bb_width, bb_height,
- track->label_anchor, &field_set->label_pos);
+ else {
+ dist = sqrt(bb_width*bb_width+bb_height*bb_height);
+ }
+ dist += track->label_distance;
+ /*
+ * Compute heading after applying the transform.
+ */
+ ZnTransfoDecompose(wi->current_transfo, NULL, NULL, &rotation, NULL);
+ /*printf("rotation=%g, heading=%g, angle=%d\n", rotation,
+ ProjectionToAngle(track->speed_vector.x, track->speed_vector.y),
+ track->label_angle);*/
+ rotation = ProjectionToAngle(track->speed_vector.x, track->speed_vector.y)-rotation;
+ PointPolarToCartesian(rotation, dist, track->label_angle,
+ &track->label_dx, &track->label_dy);
}
-
+ field_set->label_pos.x = track->dev.x + track->label_dx;
+ field_set->label_pos.y = track->dev.y - track->label_dy;
+ Anchor2Origin(&field_set->label_pos, bb_width, bb_height,
+ track->label_anchor, &field_set->label_pos);
+
AddPointToBBox(&item->item_bounding_box, field_set->label_pos.x,
field_set->label_pos.y);
AddPointToBBox(&item->item_bounding_box,
field_set->label_pos.x + (ZnPos) bb_width,
field_set->label_pos.y + (ZnPos) bb_height);
-
+
/*
* Process the leader.
*/
@@ -817,13 +831,13 @@ ComputeCoordinates(Item item,
right_x = track->leader_anchors->right_x;
left_y = track->leader_anchors->left_y;
right_y = track->leader_anchors->right_y;
- }
- else {
- left_x = right_x = left_y = right_y = 50;
- }
- if (track->label_angle >= 270 || track->label_angle < 90) {
- if (track->leader_anchors && (left_y < 0)) {
- ITEM_P.GetFieldBBox(field_set, left_x, &bbox);
+ }
+ else {
+ left_x = right_x = left_y = right_y = 50;
+ }
+ if (track->label_angle >= 270 || track->label_angle < 90) {
+ if (track->leader_anchors && (left_y < 0)) {
+ ITEM_P.GetFieldBBox(field_set, left_x, &bbox);
leader_end.x = bbox.orig.x;
leader_end.y = bbox.corner.y;
}
@@ -884,13 +898,6 @@ ComputeCoordinates(Item item,
(old_pos.y != track->dev.y)) {
/* Update connected items */
SET(item->flags, UPDATE_DEPENDENT_BIT);
-
-#ifdef OM
- /* Record the move to trigger the overlap manager latter */
- if (item->class == ZnTrack) {
- ((GroupItem) item->parent)->call_om = True;
- }
-#endif
}
}
@@ -917,6 +924,7 @@ ToArea(Item item,
int width, height;
ZnDim lwidth, lheight;
ZnBBox bbox;
+ ZnPoint pts[2];
/*
* Try the current position.
@@ -982,8 +990,11 @@ ToArea(Item item,
/*
* Try the speed vector.
*/
- if (item->class == ZnTrack) {
- if (LineInBBox(&track->dev, &track->speed_vector_dev, area) != inside) {
+ if ((item->class == ZnTrack) && (track->speed_vector_width > 0)) {
+ pts[0] = track->dev;
+ pts[1] = track->speed_vector_dev;
+ width = track->speed_vector_width > 1 ? track->speed_vector_width : 0;
+ if (PolylineInBBox(pts, 2, width, CapRound, JoinRound, area) != inside) {
/*printf("track speed vector\n");*/
return 0;
}
@@ -993,8 +1004,6 @@ ToArea(Item item,
* Try the connection.
*/
if ((item->connected_item != ZN_NO_ITEM) && (track->connection_width > 0)) {
- ZnPoint pts[2];
-
pts[0] = track->dev;
pts[1] = ((TrackItem) item->connected_item)->dev;
width = track->connection_width > 1 ? track->connection_width : 0;
@@ -1078,9 +1087,9 @@ Draw(Item item)
/*
* Draw the speed vector.
*/
- if (item->class == ZnTrack) {
+ if ((item->class == ZnTrack) && (track->speed_vector_width > 0)) {
values.foreground = ZnPixel(track->speed_vector_color);
- values.line_width = 0;
+ values.line_width = track->speed_vector_width > 1 ? track->speed_vector_width : 0;
values.line_style = LineSolid;
values.fill_style = FillSolid;
XChangeGC(wi->dpy, wi->gc,
@@ -1146,7 +1155,8 @@ Draw(Item item)
hist = ZnListArray(track->history);
side_size = MAX(width, height);
for (i = 0, nb_hist = 0; i < num_acc_pos; i++) {
- if (ISSET(track->flags, LAST_AS_FIRST_BIT) && (i == num_acc_pos-1)) {
+ if (ISSET(track->flags, LAST_AS_FIRST_BIT) &&
+ (i == track->visible_history_size-1)) {
values.foreground = ZnPixel(track->symbol_color);
XChangeGC(wi->dpy, wi->gc, GCForeground, &values);
}
@@ -1278,7 +1288,8 @@ Pick(Item item,
int width=0, height=0;
double width_2;
int best_part;
-
+ ZnPoint pts[2];
+
/*
* Try one of the fields.
*/
@@ -1358,8 +1369,11 @@ Pick(Item item,
/*
* Try the speed vector.
*/
- if (item->class == ZnTrack) {
- new_dist = LineToPointDist(&track->dev, &track->speed_vector_dev, p);
+ if ((item->class == ZnTrack) && (track->speed_vector_width > 0)) {
+ pts[0] = track->dev;
+ pts[1] = track->speed_vector_dev;
+ new_dist = PolylineToPointDist(pts, 2, track->speed_vector_width,
+ CapRound, JoinRound, p);
if (new_dist < dist) {
best_part = SPEED_VECTOR;
dist = new_dist;
@@ -1374,8 +1388,6 @@ Pick(Item item,
*/
c_item = item->connected_item;
if ((c_item != ZN_NO_ITEM) && (track->connection_width > 0)) {
- ZnPoint pts[2];
-
pts[0] = track->dev;
pts[1] = ((TrackItem) item->connected_item)->dev;
new_dist = PolylineToPointDist(pts, 2, track->connection_width,
@@ -1411,6 +1423,7 @@ PostScript(Item item,
}
+#ifdef OM
/*
**********************************************************************************
*
@@ -1526,10 +1539,12 @@ SetLabelAngleFromOm(void *ptr, /* No longer in use. */
theta %= 360;
- if ((theta >= 0) && (track->label_angle != theta)) {
+ if (ISCLEAR(track->flags, FROZEN_LABEL_BIT) &&
+ (theta >= 0) && (track->label_angle != theta)) {
track->label_angle = theta;
SET(track->flags, POLAR_BIT);
ITEM.Invalidate((Item) item, ZN_COORDS_FLAG);
+ ((GroupItem) ((Item) item)->parent)->call_om = True;
}
}
@@ -1580,6 +1595,7 @@ QueryLabelPosition(void *ptr, /* No longer in use. */
*x = *y = *w = *h = 0;
}
}
+#endif
/*