diff options
author | lecoanet | 2005-10-19 10:54:07 +0000 |
---|---|---|
committer | lecoanet | 2005-10-19 10:54:07 +0000 |
commit | e3dba13cb46272306b626406e2ca5493e6683dc0 (patch) | |
tree | 0fe7a39ec99bef11b4a8db7bfb0f7cadce6845da /generic | |
parent | 644f9796c22aadecb29599fcf215a8e9a9ea1027 (diff) | |
download | tkzinc-e3dba13cb46272306b626406e2ca5493e6683dc0.zip tkzinc-e3dba13cb46272306b626406e2ca5493e6683dc0.tar.gz tkzinc-e3dba13cb46272306b626406e2ca5493e6683dc0.tar.bz2 tkzinc-e3dba13cb46272306b626406e2ca5493e6683dc0.tar.xz |
Integrated a patch from D Pavet. This patch keep the angular position
of the leader in sync when changing the leader position with -labeldx
and -labeldy.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/Track.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/generic/Track.c b/generic/Track.c index 232089e..0b25256 100644 --- a/generic/Track.c +++ b/generic/Track.c @@ -95,7 +95,7 @@ typedef struct _TrackItemStruct { unsigned short flags; ZnImage symbol; /* item symbol */ ZnGradient *symbol_color; - int label_angle; /* Label angle from track. */ + int label_angle; /* Label angle from track (degree). */ ZnDim label_distance; /* Label distance from track. */ ZnDim label_dx; /* Label dx/dy from track. */ ZnDim label_dy; @@ -823,7 +823,7 @@ ComputeCoordinates(ZnItem item, /* Compute the new label bounding box. */ if (field_set->label_format && field_set->num_fields) { ZnDim bb_width, bb_height; - ZnReal rho, dist; + ZnReal rho, theta, dist; ZnPoint leader_end; int it; @@ -832,6 +832,9 @@ ComputeCoordinates(ZnItem item, * Compute the label position. */ if (ISSET(track->flags, POLAR_BIT)) { + /* + * Update label_dx, label_dy from label_distance, label_angle + */ rho = track->label_distance; /* * Compute heading after applying the transform. @@ -841,6 +844,10 @@ ComputeCoordinates(ZnItem item, ZnProjectionToAngle(track->speed_vector.x, track->speed_vector.y), track->label_angle);*/ rotation = ZnProjectionToAngle(track->speed_vector.x, track->speed_vector.y)-rotation; + /* + * Adjust the distance to match the requested label_distance + * whatever the label_angle. + */ it = 0; while (1) { ZnPointPolarToCartesian(rotation, rho, (ZnReal) track->label_angle, @@ -862,6 +869,15 @@ ComputeCoordinates(ZnItem item, } } else { + /* + * Update label_angle following the change in label_dx, label_dy. + * label_distance is not updated. + */ + ZnTransfoDecompose(wi->current_transfo, NULL, NULL, &rotation, NULL); + rotation = ZnProjectionToAngle(track->speed_vector.x, track->speed_vector.y) - rotation; + ZnPointCartesianToPolar(rotation, &dist, &theta, track->label_dx, track->label_dy); + track->label_angle = (int) theta; + field_set->label_pos.x = track->dev.x + track->label_dx; field_set->label_pos.y = track->dev.y - track->label_dy; ZnAnchor2Origin(&field_set->label_pos, bb_width, bb_height, |