# HG changeset patch # User Gustavo J. A. M. Carneiro # Date 1191428967 -3600 # Node ID 73844d079af99a601a8e3189bd8f91b37626d53f # Parent 306c81333d64e15643d091e75b8fc3ef792b68e1 Draw the velocity vector diff -r 306c81333d64 -r 73844d079af9 utils/mobility-visualizer-model.cc --- a/utils/mobility-visualizer-model.cc Wed Oct 03 16:38:17 2007 +0100 +++ b/utils/mobility-visualizer-model.cc Wed Oct 03 17:29:27 2007 +0100 @@ -71,7 +71,7 @@ DefaultValue::Bind ("RandomWalk2dMode", "Time"); DefaultValue::Bind ("RandomWalk2dTime", "5s"); DefaultValue::Bind ("RandomWalk2dSpeed", "Constant:20.0"); - DefaultValue::Bind ("RandomDirection2dSpeed", "Constant:20.0"); + DefaultValue::Bind ("RandomDirection2dSpeed", "Uniform:10.0:20.0"); DefaultValue::Bind ("RandomWalk2dBounds", "0:400:0:300"); DefaultValue::Bind ("RandomDirection2dArea", "0:400:0:300"); DefaultValue::Bind ("RandomWaypointSpeed", "Uniform:10:30"); diff -r 306c81333d64 -r 73844d079af9 utils/mobility-visualizer-view.cc --- a/utils/mobility-visualizer-view.cc Wed Oct 03 16:38:17 2007 +0100 +++ b/utils/mobility-visualizer-view.cc Wed Oct 03 17:29:27 2007 +0100 @@ -20,6 +20,7 @@ struct Node { GooCanvasItem *m_item; + GooCanvasItem *m_vector; void create () { GooCanvasItem *root = goo_canvas_get_root_item (GOO_CANVAS (g_canvas)); @@ -28,10 +29,31 @@ "stroke_color", "black", "fill_color", "red", NULL); + + m_vector = goo_canvas_polyline_new (root, FALSE, 0, + "line_width", 0.3, + "stroke_color", "black", + "end-arrow", TRUE, + "arrow-length", 10.0, + "arrow-width", 10.0, + NULL); + } + + void update (double x, double y, double vx, double vy) { g_object_set (m_item, "center_x", x, "center_y", y, NULL); + + GooCanvasPoints *points = goo_canvas_points_new (2); + + points->coords[0] = x; + points->coords[1] = y; + points->coords[2] = x + vx; + points->coords[3] = y + vy; + + g_object_set (m_vector, "points", points, NULL); + goo_canvas_points_unref (points); } }; @@ -46,6 +68,8 @@ GAsyncQueue *queue; +#define TIME_SCALE 1 + double get_current_time () { GTimeVal currTime; @@ -54,7 +78,7 @@ relativeTime.tv_sec = currTime.tv_sec - initialTime.tv_sec + LOOKAHEAD_SECONDS; relativeTime.tv_usec = currTime.tv_usec; g_time_val_add (&relativeTime, -initialTime.tv_usec); - return relativeTime.tv_sec + 1.0e-6*relativeTime.tv_usec; + return (relativeTime.tv_sec + 1.0e-6*relativeTime.tv_usec)*TIME_SCALE; } // called from the simulation thread