aboutsummaryrefslogtreecommitdiff
path: root/generic/Track.c
diff options
context:
space:
mode:
authorlecoanet2004-02-13 13:24:52 +0000
committerlecoanet2004-02-13 13:24:52 +0000
commitc9dbc80c2f41e9b56b446fd51576d8b9ebab5c80 (patch)
tree7181e33283a65a8575e2ecb06dc45a6cdabd48a3 /generic/Track.c
parented990e32b5b9bee2cc4344d47bf12f4fa05f9add (diff)
downloadtkzinc-c9dbc80c2f41e9b56b446fd51576d8b9ebab5c80.zip
tkzinc-c9dbc80c2f41e9b56b446fd51576d8b9ebab5c80.tar.gz
tkzinc-c9dbc80c2f41e9b56b446fd51576d8b9ebab5c80.tar.bz2
tkzinc-c9dbc80c2f41e9b56b446fd51576d8b9ebab5c80.tar.xz
Changed the behavior of options/attributes for managing and displaying track histories
Diffstat (limited to 'generic/Track.c')
-rw-r--r--generic/Track.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/generic/Track.c b/generic/Track.c
index 18d8c7e..1d68217 100644
--- a/generic/Track.c
+++ b/generic/Track.c
@@ -59,7 +59,6 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
#define DEFAULT_LINE_WIDTH 1
#define DEFAULT_LABEL_PREFERRED_ANGLE 0
#define DEFAULT_CONVERGENCE_STYLE 0
-#define DEFAULT_VISIBLE_HISTORY_SIZE 6
#define SPEED_VECTOR_PICKING_THRESHOLD 5 /* In pixels */
@@ -79,6 +78,7 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
#define POLAR_BIT 1 << 6
#define FROZEN_LABEL_BIT 1 << 7
#define LAST_AS_FIRST_BIT 1 << 8
+#define HISTORY_VISIBLE_BIT 1 << 9
#define CURRENT_POSITION -2
#define LEADER -3
@@ -128,7 +128,6 @@ typedef struct _TrackItemStruct {
ZnLineStyle connection_style;
ZnDim connection_width;
ZnGradient *speed_vector_color; /* s. v. color */
- unsigned int visible_history_size; /* Number of visible positions */
ZnPoint pos; /* item world coordinates */
ZnPoint speed_vector; /* s. v. slope in world coord */
ZnDim speed_vector_width;
@@ -260,8 +259,8 @@ static ZnAttrConfig track_attrs[] = {
{ ZN_CONFIG_BOOL, "-visible", NULL,
Tk_Offset(TrackItemStruct, header.flags), ZN_VISIBLE_BIT,
ZN_DRAW_FLAG|ZN_REPICK_FLAG|ZN_VIS_FLAG, False },
- { ZN_CONFIG_UINT, "-visiblehistorysize", NULL,
- Tk_Offset(TrackItemStruct, visible_history_size), 0, ZN_DRAW_FLAG, False },
+ { ZN_CONFIG_BOOL, "-historyvisible", NULL,
+ Tk_Offset(TrackItemStruct, flags), HISTORY_VISIBLE_BIT, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_END, NULL, NULL, 0, 0, 0, False }
};
@@ -421,7 +420,7 @@ Init(ZnItem item,
if (item->class == ZnTrack) {
item->priority = 1;
- track->visible_history_size = DEFAULT_VISIBLE_HISTORY_SIZE;
+ SET(track->flags, HISTORY_VISIBLE_BIT);
track->marker_size = DEFAULT_MARKER_SIZE;
track->speed_vector.x = 0;
track->speed_vector.y = 0;
@@ -429,7 +428,7 @@ Init(ZnItem item,
}
else {
item->priority = 1;
- track->visible_history_size = 0;
+ CLEAR(track->flags, HISTORY_VISIBLE_BIT);
track->marker_size = 0;
track->speed_vector.x = 0.0;
track->speed_vector.y = 10.0;
@@ -582,17 +581,14 @@ AddToHistory(TrackItem track,
{
ZnWInfo *wi = ((ZnItem) track)->wi;
- /*printf("Track moved, manage history: %d\n", wi->track_manage_history);*/
if (track->history) {
- if (wi->track_manage_history) {
- HistoryStruct hist;
-
- hist.world = old_pos;
- hist.dev = track->dev;
- hist.visible = True;
- ZnListAdd(track->history, &hist, ZnListHead);
- ZnListTruncate(track->history, wi->track_managed_history_size);
- }
+ HistoryStruct hist;
+
+ hist.world = old_pos;
+ hist.dev = track->dev;
+ hist.visible = True;
+ ZnListAdd(track->history, &hist, ZnListHead);
+ ZnListTruncate(track->history, wi->track_managed_history_size);
}
else {
/* We do not shift the first time we move as the preceding position
@@ -722,13 +718,6 @@ ComputeCoordinates(ZnItem item,
old_label_width = field_set->label_width;
old_label_height = field_set->label_height;
- /*
- * Suppress history if history management was turned off.
- */
- if ((item->class == ZnTrack) && !wi->track_manage_history) {
- ZnListEmpty(track->history);
- }
-
old_pos = track->dev;
ZnTransformPoint(wi->current_transfo, &track->pos, &track->dev);
@@ -754,11 +743,14 @@ ComputeCoordinates(ZnItem item,
information from the symbol font.
*/
if ((item->class == ZnTrack) && track->history) {
+ unsigned int visible_history_size;
/*
* Trunc the visible history to the managed size.
*/
- unsigned int visible_history_size = MIN(track->visible_history_size,
- wi->track_managed_history_size);
+ ZnListTruncate(track->history, wi->track_managed_history_size);
+ visible_history_size = (ISSET(track->flags, HISTORY_VISIBLE_BIT) ?
+ wi->track_visible_history_size : 0);
+
ZnResetBBox(&bbox);
num_acc_pos = ZnListSize(track->history);
hist = ZnListArray(track->history);
@@ -1212,8 +1204,10 @@ Draw(ZnItem item)
* Draw the history, current pos excepted.
*/
if ((item->class == ZnTrack) && track->history) {
- unsigned int visible_history_size = MIN(track->visible_history_size,
- wi->track_managed_history_size);
+ unsigned int visible_history_size;
+
+ visible_history_size = (ISSET(track->flags, HISTORY_VISIBLE_BIT) ?
+ wi->track_visible_history_size : 0);
values.foreground = ZnGetGradientPixel(track->history_color, 0.0);
values.fill_style = FillSolid;
@@ -1483,8 +1477,10 @@ Render(ZnItem item)
* Draw the history, current pos excepted.
*/
if ((item->class == ZnTrack) && track->history) {
- unsigned int visible_history_size = MIN(track->visible_history_size,
- wi->track_managed_history_size);
+ unsigned int visible_history_size;
+
+ visible_history_size = (ISSET(track->flags, HISTORY_VISIBLE_BIT) ?
+ wi->track_visible_history_size : 0);
points = ZnGetCirclePoints(3, ZN_CIRCLE_COARSE, 0.0, 2*M_PI, &num_points, NULL);
color = ZnGetGradientColor(track->history_color, 0.0, &alpha);