current time set_time_window if necessary
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 16 Jan 2004 01:54:08 +0000 (01:54 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 16 Jan 2004 01:54:08 +0000 (01:54 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@384 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c
ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.h

index 4ab54f84c7465de45f191f10129af2e80a78b2d5..1a6378b5985c9c664ea915a23ac37a90667f9cf4 100644 (file)
@@ -22,6 +22,7 @@
 #include <lttv/hook.h>
 #include <lttv/common.h>
 #include <lttv/state.h>
+#include <lttv/gtkTraceSet.h>
 
 
 #include "Event_Hooks.h"
@@ -782,7 +783,7 @@ int draw_after_hook(void *hook_data, void *call_data)
 
 
 
-void update_time_window_hook(void *hook_data, void *call_data)
+gint update_time_window_hook(void *hook_data, void *call_data)
 {
        ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
        TimeWindow *Old_Time_Window = 
@@ -970,19 +971,34 @@ void update_time_window_hook(void *hook_data, void *call_data)
                                control_flow_data->Drawing->height);
        }
 
-       
+       return 0;
 }
 
-void update_current_time_hook(void *hook_data, void *call_data)
+gint update_current_time_hook(void *hook_data, void *call_data)
 {
-       ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data;
-       LttTime* Current_Time = 
-               guicontrolflow_get_current_time(Control_Flow_Data);
-       *Current_Time = *((LttTime*)call_data);
-       g_info("New Current time HOOK : %u, %u", Current_Time->tv_sec,
-                                                       Current_Time->tv_nsec);
+       ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
+
+       LttTime* current_time = 
+               guicontrolflow_get_current_time(control_flow_data);
+       *current_time = *((LttTime*)call_data);
+       
+       TimeWindow time_window;
+       
+       LttTime time_begin = control_flow_data->Time_Window.start_time;
+       LttTime width = control_flow_data->Time_Window.time_width;
+       LttTime half_width = ltt_time_div(width,2.0);
+       LttTime time_end = ltt_time_add(time_begin, width);
+
+       LttvTracesetContext * tsc =
+                               get_traceset_context(control_flow_data->Parent_Window);
+       
+       LttTime trace_start = tsc->Time_Span->startTime;
+       LttTime trace_end = tsc->Time_Span->endTime;
+       
+       g_info("New Current time HOOK : %u, %u", current_time->tv_sec,
+                                                       current_time->tv_nsec);
+
 
-       gtk_widget_queue_draw(Control_Flow_Data->Drawing->Drawing_Area_V);
        
        /* If current time is inside time interval, just move the highlight
         * bar */
@@ -990,8 +1006,39 @@ void update_current_time_hook(void *hook_data, void *call_data)
        /* Else, we have to change the time interval. We have to tell it
         * to the main window. */
        /* The time interval change will take care of placing the current
-        * time at the center of the visible area */
+        * time at the center of the visible area, or nearest possible if we are
+        * at one end of the trace. */
+       
        
+       if(ltt_time_compare(*current_time, time_begin) == -1)
+       {
+               if(ltt_time_compare(*current_time,
+                                       ltt_time_add(trace_start,half_width)) == -1)
+                       time_begin = trace_start;
+               else
+                       time_begin = ltt_time_sub(*current_time,half_width);
+       
+               time_window.start_time = time_begin;
+               time_window.time_width = width;
+
+               set_time_window(control_flow_data->Parent_Window, &time_window);
+       }
+       else if(ltt_time_compare(*current_time, time_end) == 1)
+       {
+               if(ltt_time_compare(*current_time, ltt_time_sub(trace_end, half_width)) == 1)
+                       time_begin = ltt_time_sub(trace_end,width);
+               else
+                       time_begin = ltt_time_sub(*current_time,half_width);
+       
+               time_window.start_time = time_begin;
+               time_window.time_width = width;
+
+               set_time_window(control_flow_data->Parent_Window, &time_window);
+               
+       }
+       gtk_widget_queue_draw(control_flow_data->Drawing->Drawing_Area_V);
+       
+       return 0;
 }
 
 typedef struct _ClosureData {
index a1fbb45807a86ab8590642cda19714ec72218506..6add225dc4d8f7e39a6b749d20ff2a84192fff51 100644 (file)
@@ -75,8 +75,8 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data);
 int  after_data_request(void *hook_data, void *call_data);
 
 
-void update_time_window_hook(void *hook_data, void *call_data);
-void update_current_time_hook(void *hook_data, void *call_data);
+gint update_time_window_hook(void *hook_data, void *call_data);
+gint update_current_time_hook(void *hook_data, void *call_data);
 
 
 
This page took 0.026276 seconds and 4 git commands to generate.