aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlecoanet2004-02-13 13:24:52 +0000
committerlecoanet2004-02-13 13:24:52 +0000
commitc9dbc80c2f41e9b56b446fd51576d8b9ebab5c80 (patch)
tree7181e33283a65a8575e2ecb06dc45a6cdabd48a3
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
-rw-r--r--generic/Track.c54
-rw-r--r--generic/WidgetInfo.h3
-rw-r--r--generic/tkZinc.c10
3 files changed, 31 insertions, 36 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);
diff --git a/generic/WidgetInfo.h b/generic/WidgetInfo.h
index bbf296a..47c209d 100644
--- a/generic/WidgetInfo.h
+++ b/generic/WidgetInfo.h
@@ -151,8 +151,7 @@ typedef struct _ZnWInfo {
/* Tracks global resources */
unsigned int track_managed_history_size; /* Size of history for tracks */
- ZnBool track_manage_history; /* Tell if the tracks manage their */
- /* histories. */
+ unsigned int track_visible_history_size; /* Size of displayed history */
ZnReal speed_vector_length; /* How long (in time) are speedvectors*/
int om_group_id; /* Tell which group contains tracks to be */
#ifdef OM
diff --git a/generic/tkZinc.c b/generic/tkZinc.c
index 4fdac88..0a5818c 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -238,8 +238,8 @@ static Tk_ConfigSpec config_specs[] = {
NULL, Tk_Offset(ZnWInfo, take_focus), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-tile", "tile", "Tile",
"", Tk_Offset(ZnWInfo, tile), 0, &imageOption},
- {TK_CONFIG_BOOLEAN, "-trackmanagehistory", "trackManageHistory", "TrackManageHistory",
- "1", Tk_Offset(ZnWInfo, track_manage_history), 0, NULL},
+ {TK_CONFIG_INT, "-trackvisiblehistorysize", "trackVisibleHistorySize", "TrackVisibleHistorySize",
+ "6", Tk_Offset(ZnWInfo, track_visible_history_size), 0, NULL},
{TK_CONFIG_INT, "-trackmanagedhistorysize", "trackManagedHistorySize",
"TrackManagedHistorySize", "6", Tk_Offset(ZnWInfo, track_managed_history_size), 0, NULL},
{TK_CONFIG_CUSTOM, "-tracksymbol", "trackSymbol", "TrackSymbol",
@@ -309,7 +309,7 @@ static Tk_ConfigSpec config_specs[] = {
#define SPEED_VECTOR_LENGTH_SPEC 24
#define TAKE_FOCUS_SPEC 25
#define TILE_SPEC 26
-#define MANAGE_HISTORY_SPEC 27
+#define VISIBLE_HISTORY_SIZE_SPEC 27
#define MANAGED_HISTORY_SIZE_SPEC 28
#define TRACK_SYMBOL_SPEC 29
#define WIDTH_SPEC 30
@@ -751,7 +751,7 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
wi->cursor = None;
wi->hot_item = ZN_NO_ITEM;
wi->hot_prev = ZN_NO_ITEM;
- wi->track_manage_history = False;
+ wi->track_visible_history_size = 0;
wi->track_managed_history_size = 0;
wi->speed_vector_length = 0;
wi->tile = ZnUnspecifiedImage;
@@ -5940,7 +5940,7 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
ZnDamageAll(wi);
}
if (CONFIG_PROBE(SPEED_VECTOR_LENGTH_SPEC) ||
- CONFIG_PROBE(MANAGE_HISTORY_SPEC) ||
+ CONFIG_PROBE(VISIBLE_HISTORY_SIZE_SPEC) ||
CONFIG_PROBE(MANAGED_HISTORY_SIZE_SPEC)) {
ZnITEM.InvalidateItems(wi->top_group, ZnTrack);
}