make precision correct when calling conversion between LttTime and double
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 5 Aug 2004 00:14:17 +0000 (00:14 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 5 Aug 2004 00:14:17 +0000 (00:14 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@662 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c
ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c
ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h
ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c
ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h
ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c
ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h
ltt/branches/poly/lttv/modules/gui/detailedevents/events.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c

index fefe0a0be364a0411b31dfbce501624298efd054..276e40ae0d0f7d4606f0f1d3d27d684e70f6cc44 100644 (file)
@@ -39,6 +39,22 @@ static void control_flow_grab_focus(GtkWidget *widget, gpointer data){
 }
 
 
+static gboolean
+header_size_allocate(GtkWidget *widget,
+                        GtkAllocation *allocation,
+                        gpointer user_data)
+{
+  Drawing_t *drawing = (Drawing_t*)user_data;
+
+  gtk_widget_set_size_request(drawing->ruler, -1, allocation->height);
+  //gtk_widget_queue_resize(drawing->padding);
+  //gtk_widget_queue_resize(drawing->ruler);
+  gtk_container_check_resize(GTK_CONTAINER(drawing->ruler_hbox));
+  return 0;
+}
+
+
+
 /*****************************************************************************
  *                     Control Flow Viewer class implementation              *
  *****************************************************************************/
@@ -86,6 +102,12 @@ guicontrolflow(void)
                                 GTK_ADJUSTMENT(
                                    control_flow_data->v_adjust));
 
+  g_signal_connect (G_OBJECT(control_flow_data->process_list->button),
+        "size-allocate",
+        G_CALLBACK(header_size_allocate),
+        (gpointer)control_flow_data->drawing);
+
+  
   
   control_flow_data->h_paned = gtk_hpaned_new();
   control_flow_data->box = gtk_event_box_new();
@@ -155,7 +177,6 @@ guicontrolflow_destructor_full(ControlFlowData *control_flow_data)
 void
 guicontrolflow_destructor(ControlFlowData *control_flow_data)
 {
-  guint index;
   Tab *tab = control_flow_data->tab;
   
   g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
@@ -188,8 +209,8 @@ guicontrolflow_destructor(ControlFlowData *control_flow_data)
     lttvwindow_events_request_remove_all(control_flow_data->tab,
                                          control_flow_data);
 
-    lttvwindowtraces_background_notify_remove(control_flow_data);
   }
+  lttvwindowtraces_background_notify_remove(control_flow_data);
   g_control_flow_data_list = 
          g_slist_remove(g_control_flow_data_list,control_flow_data);
 
index 2c5ab83bf39c3e3dbb420f165a36a0ddf9f840ee..d9d4a03d48f7c4c490db7102a5256eec83c96776 100644 (file)
@@ -125,18 +125,32 @@ void drawing_data_request(Drawing_t *drawing,
   LttvHooks *event = lttv_hooks_new();
   LttvHooks *before_chunk_traceset = lttv_hooks_new();
   LttvHooks *after_chunk_traceset = lttv_hooks_new();
+  LttvHooks *before_request_hook = lttv_hooks_new();
+  LttvHooks *after_request_hook = lttv_hooks_new();
 
   lttv_hooks_add(before_chunk_traceset,
-                 before_data_request,
+                 before_chunk,
                  events_request,
                  LTTV_PRIO_DEFAULT);
 
   lttv_hooks_add(after_chunk_traceset,
-                 after_data_request,
+                 after_chunk,
                  events_request,
                  LTTV_PRIO_DEFAULT);
+
+  lttv_hooks_add(before_request_hook,
+                 before_request,
+                 events_request,
+                 LTTV_PRIO_DEFAULT);
+
+  lttv_hooks_add(after_request_hook,
+                 after_request,
+                 events_request,
+                 LTTV_PRIO_DEFAULT);
+
+
   lttv_hooks_add(event,
-                 draw_event_hook,
+                 draw_before_hook,
                  events_request,
                  LTTV_PRIO_STATE-5);
   lttv_hooks_add(event,
@@ -144,7 +158,6 @@ void drawing_data_request(Drawing_t *drawing,
                  events_request,
                  LTTV_PRIO_STATE+5);
 
-
   // Fill the events request
   events_request->owner = control_flow_data;
   events_request->viewer_data = control_flow_data;
@@ -163,8 +176,8 @@ void drawing_data_request(Drawing_t *drawing,
   events_request->after_chunk_tracefile = NULL;
   events_request->after_chunk_trace = NULL;
   events_request->after_chunk_traceset = after_chunk_traceset;
-  events_request->before_request = NULL;
-  events_request->after_request = NULL;
+  events_request->before_request = before_request_hook;
+  events_request->after_request = after_request_hook;
 
   g_debug("req : start : %u, %u", start.tv_sec, 
                                       start.tv_nsec);
@@ -176,21 +189,58 @@ void drawing_data_request(Drawing_t *drawing,
                                        control_flow_data);
   lttvwindow_events_request(tab, events_request);
 }
-   
+
+static void set_last_start(gpointer key, gpointer value, gpointer user_data)
+{
+  ProcessInfo *process_info = (ProcessInfo*)key;
+  HashedProcessData *hashed_process_data = (HashedProcessData*)value;
+  guint x = (guint)user_data;
 
+  hashed_process_data->x = x;
+
+  return;
+}
 
 void drawing_data_request_begin(EventsRequest *events_request, LttvTracesetState *tss)
 {
-  g_debug("Begin of data request chunk");
+  g_debug("Begin of data request");
   ControlFlowData *cfd = events_request->viewer_data;
   LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tss);
+  TimeWindow time_window = 
+    lttvwindow_get_time_window(cfd->tab);
+  LttTime end_time = ltt_time_add(time_window.start_time,
+                                    time_window.time_width);
+  guint width = cfd->drawing->width;
+  guint x=0;
+
+  cfd->drawing->last_start = events_request->start_time;
+
+  convert_time_to_pixels(
+          time_window.start_time,
+          end_time,
+          events_request->start_time,
+          width,
+          &x);
+
+  g_hash_table_foreach(cfd->process_list->process_hash, set_last_start,
+                            (gpointer)x);
+}
 
+void drawing_chunk_begin(EventsRequest *events_request, LttvTracesetState *tss)
+{
+  g_debug("Begin of chunk");
+  ControlFlowData *cfd = events_request->viewer_data;
+  LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tss);
   LttTime current_time = lttv_traceset_context_get_current_tfc(tsc)->timestamp;
 
   cfd->drawing->last_start = current_time;
 }
 
-void drawing_data_request_end(EventsRequest *events_request, LttvTracesetState *tss)
+
+void drawing_request_expose(EventsRequest *events_request,
+                            LttvTracesetState *tss,
+                            LttTime end_time)
 {
   gint x, x_end, width;
 
@@ -201,13 +251,11 @@ void drawing_data_request_end(EventsRequest *events_request, LttvTracesetState *
   TimeWindow time_window = 
         lttvwindow_get_time_window(cfd->tab);
 
-  g_debug("End of data request chunk");
+  g_debug("request expose");
   
   LttTime window_end = ltt_time_add(time_window.time_width,
                                     time_window.start_time);
 
-  LttTime current_time = lttv_traceset_context_get_current_tfc(tsc)->timestamp;
-  
   convert_time_to_pixels(
         time_window.start_time,
         window_end,
@@ -218,7 +266,7 @@ void drawing_data_request_end(EventsRequest *events_request, LttvTracesetState *
   convert_time_to_pixels(
         time_window.start_time,
         window_end,
-        current_time,
+        end_time,
         drawing->width,
         &x_end);
 
@@ -229,16 +277,16 @@ void drawing_data_request_end(EventsRequest *events_request, LttvTracesetState *
 
   /* ask for the buffer to be redrawn */
 
-  gtk_widget_queue_draw_area ( drawing->drawing_area,
-                               0, 0,
-                               drawing->width, drawing->height);
+  //gtk_widget_queue_draw_area ( drawing->drawing_area,
+  //                             0, 0,
+  //                             drawing->width, drawing->height);
 
   /* FIXME
    * will need more precise pixel_to_time and time_to_pixel conversion
    * functions to redraw only the needed area. */
-  //gtk_widget_queue_draw_area ( drawing->drawing_area,
-  //                             x, 0,
-  //                             width, drawing->height);
+  gtk_widget_queue_draw_area ( drawing->drawing_area,
+                               x, 0,
+                               width, drawing->height);
  
 }
 
@@ -449,13 +497,13 @@ button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user_data
 }
 
 static gboolean
-scrollbar_size_request(GtkWidget *widget,
-                       GtkRequisition *requisition,
-                       gpointer user_data)
+scrollbar_size_allocate(GtkWidget *widget,
+                        GtkAllocation *allocation,
+                        gpointer user_data)
 {
   Drawing_t *drawing = (Drawing_t*)user_data;
 
-  gtk_widget_set_size_request(drawing->padding, requisition->width, -1);
+  gtk_widget_set_size_request(drawing->padding, allocation->width, -1);
   //gtk_widget_queue_resize(drawing->padding);
   //gtk_widget_queue_resize(drawing->ruler);
   gtk_container_check_resize(GTK_CONTAINER(drawing->ruler_hbox));
@@ -476,7 +524,7 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
   drawing->ruler_hbox = gtk_hbox_new(FALSE, 1);
   drawing->ruler = gtk_drawing_area_new ();
   gtk_widget_add_events(drawing->ruler, GDK_BUTTON_PRESS_MASK);
-  gtk_widget_set_size_request(drawing->ruler, -1, 27);
+  //gtk_widget_set_size_request(drawing->ruler, -1, 27);
   
   drawing->padding = gtk_drawing_area_new ();
   gtk_widget_add_events(drawing->padding, GDK_BUTTON_PRESS_MASK);
@@ -589,8 +637,8 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
 
 
   g_signal_connect (G_OBJECT(drawing->scrollbar),
-        "size-request",
-        G_CALLBACK(scrollbar_size_request),
+        "size-allocate",
+        G_CALLBACK(scrollbar_size_allocate),
         (gpointer)drawing);
 
 
@@ -678,16 +726,17 @@ void convert_time_to_pixels(
     guint *x)
 {
   LttTime window_time_interval;
-  float interval_float, time_float;
+  double interval_double, time_double;
   
   window_time_interval = ltt_time_sub(window_time_end,window_time_begin);
   
   time = ltt_time_sub(time, window_time_begin);
   
-  interval_float = ltt_time_to_double(window_time_interval);
-  time_float = ltt_time_to_double(time);
+  /* LttTime to double conversions here should really be under 4000 hours.. */
+  interval_double = ltt_time_to_double(window_time_interval);
+  time_double = ltt_time_to_double(time);
 
-  *x = (guint)(time_float/interval_float * width);
+  *x = (guint)(time_double/interval_double * width);
   
 }
 
@@ -702,7 +751,28 @@ void drawing_draw_line( Drawing_t *drawing,
       x1, y1, x2, y2);
 }
 
+void drawing_clear(Drawing_t *drawing)
+{ 
+  if (drawing->pixmap)
+    gdk_pixmap_unref(drawing->pixmap);
 
+  drawing->height = 1;
+  /* Allocate a new pixmap with new height */
+  drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
+                                   drawing->width + SAFETY,
+                                   drawing->height,
+                                     -1);
+
+  gtk_widget_set_size_request(drawing->drawing_area,
+                             -1,
+                             drawing->height);
+  gtk_widget_queue_resize_no_redraw(drawing->drawing_area);
+  
+  /* ask for the buffer to be redrawn */
+  gtk_widget_queue_draw_area ( drawing->drawing_area,
+                               0, 0,
+                               drawing->width, drawing->height);
+}
 
 
 /* Insert a square corresponding to a new process in the list */
@@ -766,7 +836,6 @@ void drawing_insert_square(Drawing_t *drawing,
   gtk_widget_queue_draw_area ( drawing->drawing_area,
                                0, y,
                                drawing->width, drawing->height-y);
-
 }
 
 
@@ -775,41 +844,47 @@ void drawing_remove_square(Drawing_t *drawing,
         guint y,
         guint height)
 {
-  //GdkRectangle update_rect;
-  
-  /* Allocate a new pixmap with new height */
-  GdkPixmap *pixmap = gdk_pixmap_new(
-      drawing->drawing_area->window,
-      drawing->width + SAFETY,
-      drawing->height - height,
-      -1);
-  
-  /* Copy the high region */
-  gdk_draw_drawable (pixmap,
-    drawing->drawing_area->style->black_gc,
-    drawing->pixmap,
-    0, 0,
-    0, 0,
-    drawing->width + SAFETY, y);
-
+  GdkPixmap *pixmap;
 
+  if(drawing->height == height) {
+    pixmap = gdk_pixmap_new(
+        drawing->drawing_area->window,
+        drawing->width + SAFETY,
+        1,
+        -1);
+    drawing->height=1;
+  } else {
+    /* Allocate a new pixmap with new height */
+     pixmap = gdk_pixmap_new(
+        drawing->drawing_area->window,
+        drawing->width + SAFETY,
+        drawing->height - height,
+        -1);
+   
+    /* Copy the high region */
+    gdk_draw_drawable (pixmap,
+      drawing->drawing_area->style->black_gc,
+      drawing->pixmap,
+      0, 0,
+      0, 0,
+      drawing->width + SAFETY, y);
 
-  /* Copy up the bottom of the region */
-  gdk_draw_drawable (pixmap,
-    drawing->drawing_area->style->black_gc,
-    drawing->pixmap,
-    0, y + height,
-    0, y,
-    drawing->width, drawing->height - y - height);
+    /* Copy up the bottom of the region */
+    gdk_draw_drawable (pixmap,
+      drawing->drawing_area->style->black_gc,
+      drawing->pixmap,
+      0, y + height,
+      0, y,
+      drawing->width, drawing->height - y - height);
 
+    drawing->height-=height;
+  }
 
   if (drawing->pixmap)
     gdk_pixmap_unref(drawing->pixmap);
 
   drawing->pixmap = pixmap;
   
-  drawing->height-=height;
-  
   gtk_widget_set_size_request(drawing->drawing_area,
                              -1,
                              drawing->height);
@@ -817,7 +892,7 @@ void drawing_remove_square(Drawing_t *drawing,
   /* ask for the buffer to be redrawn */
   gtk_widget_queue_draw_area ( drawing->drawing_area,
                                0, y,
-                               drawing->width, drawing->height-y);
+                               drawing->width, MAX(drawing->height-y, 1));
 }
 
 void drawing_update_ruler(Drawing_t *drawing, TimeWindow *time_window)
index 37dfc8385c1befb0bff148a803c80718db14e59d..1139d48b6127ba716b3141a100757617a958e621 100644 (file)
@@ -99,6 +99,9 @@ void drawing_draw_line( Drawing_t *drawing,
 //    guint xdest, guint ydest,
 //    guint width, guint height);
 
+/* Clear the drawing : make it 1xwidth. */
+void drawing_clear(Drawing_t *drawing);
+
 /* Insert a square corresponding to a new process in the list */
 void drawing_insert_square(Drawing_t *drawing,
         guint y,
@@ -109,7 +112,6 @@ void drawing_remove_square(Drawing_t *drawing,
         guint y,
         guint height);
 
-
 void convert_pixels_to_time(
     gint width,
     guint x,
@@ -126,6 +128,12 @@ void convert_time_to_pixels(
 
 void drawing_update_ruler(Drawing_t *drawing, TimeWindow *time_window);
 
-void drawing_data_request_end(EventsRequest *events_request, LttvTracesetState *tss);
+void drawing_request_expose(EventsRequest *events_request,
+                            LttvTracesetState *tss,
+                            LttTime end_time);
+
+void drawing_data_request_begin(EventsRequest *events_request,
+                                LttvTracesetState *tss);
+void drawing_chunk_begin(EventsRequest *events_request, LttvTracesetState *tss);
 
 #endif // _DRAWING_H
index 98b13d278cdecfeaac0e1099a472162afa43a254..cb1121acd7fb77a91d0e2ddbd43a119c3c655711 100644 (file)
  *****************************************************************************/
 
 
+/* Event hooks are the drawing hooks called during traceset read. They draw the
+ * icons, text, lines and background color corresponding to the events read.
+ *
+ * Two hooks are used for drawing : draw_before and draw_after hooks. The
+ * draw_before is called before the state update that occurs with an event and
+ * the draw_after hook is called after this state update.
+ *
+ * The draw_before hooks fulfill the task of drawing the visible objects that
+ * corresponds to the data accumulated by the draw_after hook.
+ *
+ * The draw_after hook accumulates the data that need to be shown on the screen
+ * (items) into a queue. Then, the next draw_before hook will draw what that
+ * queue contains. That's the Right Way (TM) of drawing items on the screen,
+ * because we need to draw the background first (and then add icons, text, ...
+ * over it), but we only know the length of a background region once the state
+ * corresponding to it is over, which happens to be at the next draw_before
+ * hook.
+ *
+ * We also have a hook called at the end of a chunk to draw the information left
+ * undrawn in each process queue. We use the current time as end of
+ * line/background.
+ */
+
+
 //#define PANGO_ENABLE_BACKEND
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
 #define MAX_PATH_LEN 256
 
 
+#if 0
+typedef struct _ProcessAddClosure {
+  ControlFlowData *cfd;
+  guint trace_num;
+} ProcessAddClosure;
+
+static void process_add(gpointer key,
+                        gpointer value,
+                        gpointer user_data)
+{
+  LttvProcessState *process = (LttvProcessState*)value;
+  ProcessAddClosure *closure = (ProcessAddClosure*)user_data;
+  ControlFlowData *control_flow_data = closure->cfd;
+  guint trace_num = closure->trace_num;
+
+  /* Add process to process list (if not present) */
+  guint pid;
+  LttTime birth;
+  guint y = 0, height = 0, pl_height = 0;
+
+  ProcessList *process_list =
+    guicontrolflow_get_process_list(control_flow_data);
+
+  pid = process->pid;
+  birth = process->creation_time;
+  const gchar *name = g_quark_to_string(process->name);
+  HashedProcessData *hashed_process_data = NULL;
+
+  if(processlist_get_process_pixels(process_list,
+          pid,
+          &birth,
+          trace_num,
+          &y,
+          &height,
+          &hashed_process_data) == 1)
+  {
+    /* Process not present */
+    processlist_add(process_list,
+        pid,
+        &birth,
+        trace_num,
+        name,
+        &pl_height,
+        &hashed_process_data);
+    processlist_get_process_pixels(process_list,
+            pid,
+            &birth,
+            trace_num,
+            &y,
+            &height,
+            &hashed_process_data);
+    drawing_insert_square( control_flow_data->drawing, y, height);
+  }
+}
+#endif //0
+
+
 /* Action to do when background computation completed.
  *
  * Eventually, will have to check that every requested traces are finished
- * before doing the redraw.
+ * before doing the redraw. It will save unnecessary processor usage.
  */
 
 gint background_ready(void *hook_data, void *call_data)
 {
   ControlFlowData *control_flow_data = (ControlFlowData *)hook_data;
   LttvTrace *trace = (LttvTrace*)call_data;
+  LttvTracesetContext *tsc =
+        lttvwindow_get_traceset_context(control_flow_data->tab);
 
   g_debug("control flow viewer : background computation data ready.");
 
+  drawing_clear(control_flow_data->drawing);
+  processlist_clear(control_flow_data->process_list);
+#if 0
+  {
+    gint num_traces = lttv_traceset_number(tsc->ts);
+    gint i;
+    LttvTraceState *ts;
+    ProcessAddClosure closure;
+    closure.cfd = control_flow_data;
+
+    for(i=0;i<num_traces;i++) {
+      ts = (LttvTraceState*)tsc->traces[i];
+      
+      closure.trace_num = i;
+      
+      /* add all the processes to the list */
+      lttv_state_for_each_process(ts, (GHFunc)process_add, &closure);
+    }
+  }
+#endif //0
   redraw_notify(control_flow_data, NULL);
 
   return 0;
@@ -174,32 +277,10 @@ int event_selected_hook(void *hook_data, void *call_data)
 
   g_debug("DEBUG : event selected by main window : %u", *event_number);
   
-//  control_flow_data->currently_Selected_Event = *event_number;
-//  control_flow_data->Selected_Event = TRUE ;
-  
-//  tree_v_set_cursor(control_flow_data);
-
 }
 
-/* Hook called before drawing. Gets the initial context at the beginning of the
- * drawing interval and copy it to the context in event_request.
- */
-int draw_before_hook(void *hook_data, void *call_data)
-{
-  EventsRequest *events_request = (EventsRequest*)hook_data;
-  //EventsContext Events_Context = (EventsContext*)call_data;
-  
-  //event_request->Events_Context = Events_Context;
-
-  return 0;
-}
-
-/*
- * The draw event hook is called by the reading API to have a
- * particular event drawn on the screen.
- * @param hook_data ControlFlowData structure of the viewer. 
- * @param call_data Event context.
- *
+/* draw_before_hook
+ * 
  * This function basically draw lines and icons. Two types of lines are drawn :
  * one small (3 pixels?) representing the state of the process and the second
  * type is thicker (10 pixels?) representing on which CPU a process is running
@@ -214,8 +295,120 @@ int draw_before_hook(void *hook_data, void *call_data)
  * The choice of lines'color is defined by the context of the last event for this
  * process.
  */
-int draw_event_hook(void *hook_data, void *call_data)
+
+
+int draw_before_hook(void *hook_data, void *call_data)
 {
+  EventsRequest *events_request = (EventsRequest*)hook_data;
+  ControlFlowData *control_flow_data = events_request->viewer_data;
+
+  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
+
+  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
+  LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
+
+  LttEvent *e;
+  e = tfc->e;
+
+  LttTime evtime = ltt_event_time(e);
+  TimeWindow time_window = 
+    lttvwindow_get_time_window(control_flow_data->tab);
+
+  LttTime end_time = ltt_time_add(time_window.start_time,
+                                    time_window.time_width);
+
+  if(ltt_time_compare(evtime, time_window.start_time) == -1
+        || ltt_time_compare(evtime, end_time) == 1)
+            return;
+
+  guint width = control_flow_data->drawing->width;
+
+  if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) {
+
+    /* we are in a schedchange, before the state update. We must draw the
+     * items corresponding to the state before it changes : now is the right
+     * time to do it.
+     */
+
+    guint pid_out;
+    {
+      guint pid_in;
+      LttField *f = ltt_event_field(e);
+      LttField *element;
+      element = ltt_field_member(f,0);
+      pid_out = ltt_event_get_long_unsigned(e,element);
+      element = ltt_field_member(f,1);
+      pid_in = ltt_event_get_long_unsigned(e,element);
+      g_debug("out : %u  in : %u", pid_out, pid_in);
+    }
+
+    /* First, check if the current process is in the state computation process
+     * list. If it is there, that means we must add it right now and draw items
+     * from the beginning of the read for it. If it is not present, it's a new
+     * process and it was not present : it will be added after the state update.
+     */
+    LttvProcessState *process;
+    process = lttv_state_find_process(tfs, pid_out);
+    
+    if(process != NULL) {
+      /* Well, the process_out existed : we must get it in the process hash
+       * or add it, and draw its items.
+       */
+       /* Add process to process list (if not present) */
+      guint y_out = 0, height = 0, pl_height = 0;
+      HashedProcessData *hashed_process_data = NULL;
+      ProcessList *process_list = 
+                      guicontrolflow_get_process_list(control_flow_data);
+      LttTime birth = process->creation_time;
+      const gchar *name = g_quark_to_string(process->name);
+      
+      if(processlist_get_process_pixels(process_list,
+              pid_out,
+              &birth,
+              tfc->t_context->index,
+              &y_out,
+              &height,
+              &hashed_process_data) == 1)
+      {
+        /* Process not present */
+        processlist_add(process_list,
+            pid_out,
+            &birth,
+            tfc->t_context->index,
+            name,
+            &pl_height,
+            &hashed_process_data);
+        processlist_get_process_pixels(process_list,
+                pid_out,
+                &birth,
+                tfc->t_context->index,
+                &y_out,
+                &height,
+                &hashed_process_data);
+        drawing_insert_square( control_flow_data->drawing, y_out, height);
+      }
+    
+      /* Now, the process is in the state hash and our own process hash.
+       * We definitely can draw the items related to the ending state.
+       */
+      
+      /* Check if the x position is unset. In can have been left unset by
+       * a draw closure from a after chunk hook. This should never happen,
+       * because it must be set by before chunk hook to the damage_begin
+       * value.
+       */
+      g_assert(hashed_process_data->x != -1);
+      
+   
+    }
+  }
+
+  
+  return 0;
+
+
+
+#if 0
   EventsRequest *events_request = (EventsRequest*)hook_data;
   ControlFlowData *control_flow_data = 
                       (ControlFlowData*)events_request->viewer_data;
@@ -802,6 +995,9 @@ int draw_event_hook(void *hook_data, void *call_data)
   }
 
   return 0;
+#endif //0
+
+
 
   /* Text dump */
 #ifdef DONTSHOW
@@ -825,7 +1021,16 @@ int draw_event_hook(void *hook_data, void *call_data)
 
 }
 
-
+/* draw_after_hook
+ * 
+ * The draw after hook is called by the reading API to have a
+ * particular event drawn on the screen.
+ * @param hook_data ControlFlowData structure of the viewer. 
+ * @param call_data Event context.
+ *
+ * This function adds items to be drawn in a queue for each process.
+ * 
+ */
 int draw_after_hook(void *hook_data, void *call_data)
 {
   EventsRequest *events_request = (EventsRequest*)hook_data;
@@ -836,6 +1041,104 @@ int draw_after_hook(void *hook_data, void *call_data)
   LttvTracefileState *tfs = (LttvTracefileState *)call_data;
   LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
 
+  LttEvent *e;
+  e = tfc->e;
+
+  LttTime evtime = ltt_event_time(e);
+  TimeWindow time_window = 
+    lttvwindow_get_time_window(control_flow_data->tab);
+
+  LttTime end_time = ltt_time_add(time_window.start_time,
+                                    time_window.time_width);
+
+  if(ltt_time_compare(evtime, time_window.start_time) == -1
+        || ltt_time_compare(evtime, end_time) == 1)
+            return;
+
+  guint width = control_flow_data->drawing->width;
+
+  if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) {
+
+    g_debug("schedchange!");
+    
+    {
+      /* Add process to process list (if not present) */
+      LttvProcessState *process_out, *process_in;
+      LttTime birth;
+      guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
+      HashedProcessData *hashed_process_data_in = NULL;
+
+      ProcessList *process_list =
+        guicontrolflow_get_process_list(control_flow_data);
+      
+      guint pid_in;
+      {
+        guint pid_out;
+        LttField *f = ltt_event_field(e);
+        LttField *element;
+        element = ltt_field_member(f,0);
+        pid_out = ltt_event_get_long_unsigned(e,element);
+        element = ltt_field_member(f,1);
+        pid_in = ltt_event_get_long_unsigned(e,element);
+        g_debug("out : %u  in : %u", pid_out, pid_in);
+      }
+
+
+      /* Find process pid_in in the list... */
+      process_in = lttv_state_find_process(tfs, pid_in);
+      /* It should exist, because we are after the state update. */
+      g_assert(process_in != NULL);
+
+      birth = process_in->creation_time;
+      const gchar *name = g_quark_to_string(process_in->name);
+
+      if(processlist_get_process_pixels(process_list,
+              pid_in,
+              &birth,
+              tfc->t_context->index,
+              &y_in,
+              &height,
+              &hashed_process_data_in) == 1)
+      {
+        /* Process not present */
+        processlist_add(process_list,
+            pid_in,
+            &birth,
+            tfc->t_context->index,
+            name,
+            &pl_height,
+            &hashed_process_data_in);
+        processlist_get_process_pixels(process_list,
+                pid_in,
+                &birth,
+                tfc->t_context->index,
+                &y_in,
+                &height,
+                &hashed_process_data_in);
+        drawing_insert_square( control_flow_data->drawing, y_in, height);
+      }
+
+      convert_time_to_pixels(
+          time_window.start_time,
+          end_time,
+          evtime,
+          width,
+          &hashed_process_data_in->x);
+    }
+  }
+  return 0;
+
+
+
+#if 0
+  EventsRequest *events_request = (EventsRequest*)hook_data;
+  ControlFlowData *control_flow_data = events_request->viewer_data;
+
+  LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
+
+  LttvTracefileState *tfs = (LttvTracefileState *)call_data;
+  LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
+
   
   LttEvent *e;
   e = tfc->e;
@@ -1277,6 +1580,7 @@ int draw_after_hook(void *hook_data, void *call_data)
   }
 
   return 0;
+#endif //0
 }
 
 
@@ -1510,15 +1814,8 @@ gint traceset_notify(void *hook_data, void *call_data)
   drawing->damage_begin = 0;
   drawing->damage_end = drawing->width;
 
-
-  // Clear the image
-  gdk_draw_rectangle (drawing->pixmap,
-        widget->style->black_gc,
-        TRUE,
-        0, 0,
-        drawing->width+SAFETY,
-        drawing->height);
-
+  drawing_clear(control_flow_data->drawing);
+  processlist_clear(control_flow_data->process_list);
 
   if(drawing->damage_begin < drawing->damage_end)
   {
@@ -1601,22 +1898,6 @@ gint continue_notify(void *hook_data, void *call_data)
 }
 
 
-gint after_process_traceset_hook(void *hook_data, void *call_data)
-{
-  //ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
-  EventsRequest *events_request = (EventsRequest *)hook_data;
-
-  ControlFlowData *control_flow_data = 
-                   (ControlFlowData*)events_request->viewer_data;
-
-
-  drawing_data_request_end(events_request,
-                           (LttvTracesetState*)call_data);
-  return 0; 
-}
-
-
 gint update_current_time_hook(void *hook_data, void *call_data)
 {
   ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
@@ -1695,11 +1976,17 @@ gint update_current_time_hook(void *hook_data, void *call_data)
 typedef struct _ClosureData {
   EventsRequest *events_request;
   LttvTracesetState *tss;
+  LttTime end_time;
 } ClosureData;
   
 
 void draw_closure(gpointer key, gpointer value, gpointer user_data)
 {
+
+  return;
+  
+
+#if 0
   ProcessInfo *process_info = (ProcessInfo*)key;
   HashedProcessData *hashed_process_data = (HashedProcessData*)value;
   ClosureData *closure_data = (ClosureData*)user_data;
@@ -1915,9 +2202,20 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
   hashed_process_data->draw_context->previous->modify_under->y = -1;
   hashed_process_data->draw_context->previous->status = LTTV_STATE_UNNAMED;
 
+#endif //0
 }
 
-int  before_data_request(void *hook_data, void *call_data)
+int before_chunk(void *hook_data, void *call_data)
+{
+  EventsRequest *events_request = (EventsRequest*)hook_data;
+  LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
+
+  drawing_chunk_begin(events_request, tss);
+
+  return 0;
+}
+
+int before_request(void *hook_data, void *call_data)
 {
   EventsRequest *events_request = (EventsRequest*)hook_data;
   LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
@@ -1929,29 +2227,72 @@ int  before_data_request(void *hook_data, void *call_data)
 
 
 /*
+ * after request is necessary in addition of after chunk in order to draw 
+ * lines until the end of the screen. after chunk just draws lines until
+ * the last event.
+ * 
  * for each process
  *    draw closing line
- *    new default prev and current
- * then finally remove reading hooks.
+ *    expose
  */
-int  after_data_request(void *hook_data, void *call_data)
+int after_request(void *hook_data, void *call_data)
 {
   EventsRequest *events_request = (EventsRequest*)hook_data;
   ControlFlowData *control_flow_data = events_request->viewer_data;
   LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
+  LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(call_data);
   
   ProcessList *process_list =
     guicontrolflow_get_process_list(control_flow_data);
+  LttTime end_time = events_request->end_time;
+
+  ClosureData closure_data;
+  closure_data.events_request = (EventsRequest*)hook_data;
+  closure_data.tss = tss;
+  closure_data.end_time = end_time;
+
+  /* Draw last items */
+  g_hash_table_foreach(process_list->process_hash, draw_closure,
+                        (void*)&closure_data);
+
+  /* Request expose */
+  drawing_request_expose(events_request, tss, end_time);
+  return 0;
+}
+
+/*
+ * for each process
+ *    draw closing line
+ *    expose
+ */
+int after_chunk(void *hook_data, void *call_data)
+{
+  EventsRequest *events_request = (EventsRequest*)hook_data;
+  ControlFlowData *control_flow_data = events_request->viewer_data;
+  LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
+  LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(call_data);
+  LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc);
+  LttTime end_time;
+  
+  ProcessList *process_list =
+    guicontrolflow_get_process_list(control_flow_data);
+
+  if(tfc != NULL)
+    end_time = tfc->timestamp;
+  else /* end of traceset */
+    end_time = tsc->time_span.end_time;
 
   ClosureData closure_data;
   closure_data.events_request = (EventsRequest*)hook_data;
   closure_data.tss = tss;
+  closure_data.end_time = end_time;
 
+  /* Draw last items */
   g_hash_table_foreach(process_list->process_hash, draw_closure,
                         (void*)&closure_data);
 
   /* Request expose */
-  drawing_data_request_end(events_request, tss);
+  drawing_request_expose(events_request, tss, end_time);
 
   return 0;
 }
index 1f528be7ca13299265c7afe5514599edf2aabec5..d5d610a0eb74b35c4e2eef5b5959ff590e418f71 100644 (file)
@@ -61,16 +61,11 @@ GtkWidget *h_guicontrolflow(Tab *tab, LttvTracesetSelector * s, char * key);
 
 int event_selected_hook(void *hook_data, void *call_data);
 
-/* Hook called before drawing. Gets the initial context at the beginning of the
- * drawing interval and copy it to the context in event_request.
- */
-int draw_before_hook(void *hook_data, void *call_data);
-
 /*
  * The draw event hook is called by the reading API to have a
  * particular event drawn on the screen.
  * @param hook_data ControlFlowData structure of the viewer. 
- * @param call_data Event context.
+ * @param call_data Event context with state.
  *
  * This function basically draw lines and icons. Two types of lines are drawn :
  * one small (3 pixels?) representing the state of the process and the second
@@ -86,14 +81,17 @@ int draw_before_hook(void *hook_data, void *call_data);
  * The choice of lines'color is defined by the context of the last event for this
  * process.
  */
-int draw_event_hook(void *hook_data, void *call_data);
+int draw_before_hook(void *hook_data, void *call_data);
 
 int draw_after_hook(void *hook_data, void *call_data);
 
 void draw_closure(gpointer key, gpointer value, gpointer user_data);
 
-int  before_data_request(void *hook_data, void *call_data);
-int  after_data_request(void *hook_data, void *call_data);
+int  before_chunk(void *hook_data, void *call_data);
+int  after_chunk(void *hook_data, void *call_data);
+int  before_request(void *hook_data, void *call_data);
+int  after_request(void *hook_data, void *call_data);
+
 
 
 gint update_time_window_hook(void *hook_data, void *call_data);
@@ -102,8 +100,4 @@ gint traceset_notify(void *hook_data, void *call_data);
 gint redraw_notify(void *hook_data, void *call_data);
 gint continue_notify(void *hook_data, void *call_data);
 
-gint after_process_traceset_hook(void *hook_data, void *call_data);
-
-
-
 #endif // _EVENT_HOOKS_H
index 6c450afe6b72cb41c9ed60e0c4ef151d0c32d36a..bc12c7d27c65965c0f43cbccd7b93057094adb0f 100644 (file)
@@ -274,7 +274,9 @@ ProcessList *processlist_construct(void)
   gtk_tree_view_column_set_fixed_width (column, 45);
   gtk_tree_view_append_column (
     GTK_TREE_VIEW (process_list->process_list_widget), column);
-
+  
+  process_list->button = column->button;
+  
   column = gtk_tree_view_column_new_with_attributes ( "PID",
                 renderer,
                 "text",
@@ -321,16 +323,69 @@ ProcessList *processlist_construct(void)
 
   return process_list;
 }
+
 void processlist_destroy(ProcessList *process_list)
 {
-  g_info("processlist_destroy %p", process_list);
+  g_debug("processlist_destroy %p", process_list);
   g_hash_table_destroy(process_list->process_hash);
   process_list->process_hash = NULL;
 
   g_free(process_list);
-  g_info("processlist_destroy end");
+  g_debug("processlist_destroy end");
 }
 
+static gboolean remove_hash_item(ProcessInfo *process_info,
+                                 HashedProcessData *hashed_process_data,
+                                 ProcessList *process_list)
+{
+  GtkTreePath *tree_path;
+  GtkTreeIter iter;
+
+  tree_path = gtk_tree_row_reference_get_path(
+                  hashed_process_data->row_ref);
+
+  gtk_tree_model_get_iter (
+      GTK_TREE_MODEL(process_list->list_store),
+      &iter, tree_path);
+
+  gtk_tree_path_free(tree_path);
+
+  gtk_list_store_remove (process_list->list_store, &iter);
+
+#if 0
+    g_free(hashed_process_data->draw_context->previous->modify_under);
+    g_free(hashed_process_data->draw_context->previous->modify_middle);
+    g_free(hashed_process_data->draw_context->previous->modify_over);
+    g_free(hashed_process_data->draw_context->previous->under);
+    g_free(hashed_process_data->draw_context->previous->middle);
+    g_free(hashed_process_data->draw_context->previous->over);
+    g_free(hashed_process_data->draw_context->previous);
+    g_free(hashed_process_data->draw_context->current->modify_under);
+    g_free(hashed_process_data->draw_context->current->modify_middle);
+    g_free(hashed_process_data->draw_context->current->modify_over);
+    g_free(hashed_process_data->draw_context->current->under);
+    g_free(hashed_process_data->draw_context->current->middle);
+    g_free(hashed_process_data->draw_context->current->over);
+    g_free(hashed_process_data->draw_context->current);
+    g_free(hashed_process_data->draw_context);
+    g_free(hashed_process_data);
+#endif //0
+
+
+  return TRUE; /* remove the element from the hash table */
+}
+
+void processlist_clear(ProcessList *process_list)
+{
+  g_info("processlist_clear %p", process_list);
+
+  g_hash_table_foreach_remove(process_list->process_hash,
+                              (GHRFunc)remove_hash_item,
+                              (gpointer)process_list);
+  process_list->number_of_process = 0;
+}
+
+
 GtkWidget *processlist_get_widget(ProcessList *process_list)
 {
   return process_list->process_list_widget;
@@ -378,7 +433,16 @@ int processlist_add(  ProcessList *process_list,
   Process_Info->pid = pid;
   Process_Info->birth = *birth;
   Process_Info->trace_num = trace_num;
+
+  /* When we create it from before state update, we are sure that the
+   * last event occured before the beginning of the global area.
+   *
+   * If it is created after state update, this value (0) will be
+   * overriden by the new state before anything is drawn.
+   */
+  hashed_process_data->x = 0;
   
+#if 0
   hashed_process_data->draw_context = g_new(DrawContext, 1);
   hashed_process_data->draw_context->drawable = NULL;
   hashed_process_data->draw_context->gc = NULL;
@@ -423,7 +487,8 @@ int processlist_add(  ProcessList *process_list,
   hashed_process_data->draw_context->previous->modify_under->x = -1;
   hashed_process_data->draw_context->previous->modify_under->y = -1;
   hashed_process_data->draw_context->previous->status = LTTV_STATE_UNNAMED;
-  
+#endif //0
+
   /* Add a new row to the model */
   gtk_list_store_append ( process_list->list_store, &iter);
   //g_critical ( "iter before : %s", gtk_tree_path_to_string (
@@ -492,7 +557,7 @@ int processlist_remove( ProcessList *process_list,
     gtk_tree_path_free(tree_path);
 
     gtk_list_store_remove (process_list->list_store, &iter);
-    
+#if 0
     g_free(hashed_process_data->draw_context->previous->modify_under);
     g_free(hashed_process_data->draw_context->previous->modify_middle);
     g_free(hashed_process_data->draw_context->previous->modify_over);
@@ -509,7 +574,7 @@ int processlist_remove( ProcessList *process_list,
     g_free(hashed_process_data->draw_context->current);
     g_free(hashed_process_data->draw_context);
     g_free(hashed_process_data);
-
+#endif //0
     g_hash_table_remove(process_list->process_hash,
         &Process_Info);
     
index 112337892991a020d326c6580d8bd3c7b9a76f82..efb747f72e10b8c75d047ab96be9ad2259313436 100644 (file)
@@ -52,7 +52,11 @@ typedef struct _ProcessInfo {
 typedef struct _HashedProcessData {
   
   GtkTreeRowReference *row_ref;
-  DrawContext *draw_context;
+ // DrawContext *draw_context;
+  /* Information on current drawing */
+  guint x; /* last x position saved by after state update */
+
+  // FIXME : add info on last event ?
 
 } HashedProcessData;
   
@@ -60,6 +64,7 @@ struct _ProcessList {
   
   GtkWidget *process_list_widget;
   GtkListStore *list_store;
+  GtkWidget *button; /* one button of the tree view */
 
   /* A hash table by PID to speed up process position find in the list */
   GHashTable *process_hash;
@@ -74,6 +79,8 @@ ProcessList *processlist_construct(void);
 void processlist_destroy(ProcessList *process_list);
 GtkWidget *processlist_get_widget(ProcessList *process_list);
 
+void processlist_clear(ProcessList *process_list);
+
 // out : success (0) and height
 int processlist_add(ProcessList *process_list, guint pid, LttTime *birth,
     guint trace_num, const gchar *name, guint *height,
index 5e27c17a3315cb397f9af2180b6a63cfdf901768..ee6e6c52d9739f0697e1ecfd56afb7dfdfc4e79a 100644 (file)
@@ -231,7 +231,7 @@ h_gui_events(Tab * tab, LttvTracesetSelector * s, char* key)
 EventViewerData *
 gui_events(Tab *tab, LttvTracesetSelector * s,char* key )
 {
-  LttTime start;
+  LttTime end;
   GtkTreeViewColumn *column;
   GtkCellRenderer *renderer;
   EventViewerData* event_viewer_data = g_new(EventViewerData,1) ;
@@ -423,10 +423,10 @@ gui_events(Tab *tab, LttvTracesetSelector * s,char* key )
   LttvTracesetContext * tsc =
         lttvwindow_get_traceset_context(event_viewer_data->tab);
   TimeInterval time_span = tsc->time_span;
-  start = ltt_time_sub(time_span.end_time, time_span.start_time);
+  end = ltt_time_sub(time_span.end_time, time_span.start_time);
 
   event_viewer_data->vadjust_c->upper =
-              ltt_time_to_double(start) * NANOSECONDS_PER_SECOND;
+              ltt_time_to_double(end) * NANOSECONDS_PER_SECOND;
 
   event_viewer_data->append = TRUE;
 
@@ -1524,13 +1524,13 @@ gboolean traceset_changed(void * hook_data, void * call_data)
         lttvwindow_get_traceset_context(event_viewer_data->tab);
   TimeInterval time_span = tsc->time_span;
   
-  LttTime start;
+  LttTime end;
   remove_all_items_from_queue(event_viewer_data->event_fields_queue);
   gtk_list_store_clear(event_viewer_data->store_m);
   event_viewer_data->append = TRUE;
 
-  start = ltt_time_sub(time_span.end_time, time_span.start_time);
-  event_viewer_data->vadjust_c->upper = ltt_time_to_double(start) * NANOSECONDS_PER_SECOND;
+  end = ltt_time_sub(time_span.end_time, time_span.start_time);
+  event_viewer_data->vadjust_c->upper = ltt_time_to_double(end) * NANOSECONDS_PER_SECOND;
   //  event_viewer_data->vadjust_c->value = 0;
 
   return FALSE;
index 128b420229c0f345ef741168f7d4c28b15f215ab..41b0a0fc48b3de5e6b98af9ebfa720d5833d075a 100644 (file)
@@ -259,10 +259,10 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset)
       
   g_object_set(G_OBJECT(adjustment),
                "lower",
-               ltt_time_to_double(time_span.start_time) 
-                 * NANOSECONDS_PER_SECOND, /* lower */
+                 0, /* lower */
                "upper",
-               ltt_time_to_double(time_span.end_time) 
+               ltt_time_to_double(
+                   ltt_time_sub(time_span.end_time, time_span.start_time)) 
                  * NANOSECONDS_PER_SECOND, /* upper */
                "step_increment",
                ltt_time_to_double(tab->time_window.time_width)
@@ -279,8 +279,9 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset)
 
   g_object_set(G_OBJECT(adjustment),
                "value",
-               ltt_time_to_double(tab->time_window.start_time) 
-                 * NANOSECONDS_PER_SECOND, /* value */
+               ltt_time_to_double(
+                ltt_time_sub(tab->time_window.start_time, time_span.start_time))
+                   * NANOSECONDS_PER_SECOND, /* value */
                NULL);
   gtk_adjustment_value_changed(adjustment);
   
@@ -2023,10 +2024,10 @@ void zoom(GtkWidget * widget, double size)
                  //ltt_time_to_double(new_time_window.start_time) 
                  //  * NANOSECONDS_PER_SECOND, /* value */
                  "lower",
-                 ltt_time_to_double(time_span.start_time) 
-                   * NANOSECONDS_PER_SECOND, /* lower */
+                   0, /* lower */
                  "upper",
-                 ltt_time_to_double(time_span.end_time) 
+                 ltt_time_to_double(
+                   ltt_time_sub(time_span.end_time, time_span.start_time))
                    * NANOSECONDS_PER_SECOND, /* upper */
                  "step_increment",
                  ltt_time_to_double(new_time_window.time_width)
@@ -2044,7 +2045,8 @@ void zoom(GtkWidget * widget, double size)
     //gtk_adjustment_value_changed(adjustment);
     g_object_set(G_OBJECT(adjustment),
                  "value",
-                 ltt_time_to_double(new_time_window.start_time) 
+                 ltt_time_to_double(
+                   ltt_time_sub(new_time_window.start_time, time_span.start_time))
                    * NANOSECONDS_PER_SECOND, /* value */
                  NULL);
     gtk_adjustment_value_changed(adjustment);
@@ -3089,17 +3091,16 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
 {
   Tab *tab = (Tab *)user_data;
   TimeWindow time_window;
-  TimeInterval *time_span;
   LttTime time;
   GtkAdjustment *adjust = gtk_range_get_adjustment(GTK_RANGE(scrollbar));
   gdouble value = gtk_adjustment_get_value(adjust);
   gdouble upper, lower, ratio, page_size;
   LttvTracesetContext * tsc = 
     LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
+  TimeInterval time_span = tsc->time_span;
 
   //time_window = tab->time_window;
 
-  time_span = &tsc->time_span ;
   lower = adjust->lower;
   upper = adjust->upper;
   ratio = (value - lower) / (upper - lower);
@@ -3108,7 +3109,8 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
   //time = ltt_time_sub(time_span->end_time, time_span->start_time);
   //time = ltt_time_mul(time, (float)ratio);
   //time = ltt_time_add(time_span->start_time, time);
-  time = ltt_time_from_double(value/NANOSECONDS_PER_SECOND);
+  time = ltt_time_add(ltt_time_from_double(value/NANOSECONDS_PER_SECOND),
+                      time_span.start_time);
 
   time_window.start_time = time;
   
@@ -3116,7 +3118,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
 
   time_window.time_width = 
     ltt_time_from_double(page_size/NANOSECONDS_PER_SECOND);
-  //time = ltt_time_sub(time_span->end_time, time);
+  //time = ltt_time_sub(time_span.end_time, time);
   //if(ltt_time_compare(time,time_window.time_width) < 0){
   //  time_window.time_width = time;
   //}
index 4b09a5d9e9bc134132132315ffcc5bc891452d10..8b1f2b21df24005932b8089d7f0bb2d1e1be1064 100644 (file)
@@ -691,10 +691,10 @@ void lttvwindow_report_time_window(Tab *tab,
       
   g_object_set(G_OBJECT(adjustment),
                "lower",
-               ltt_time_to_double(time_span.start_time) 
-                 * NANOSECONDS_PER_SECOND, /* lower */
+               0, /* lower */
                "upper",
-               ltt_time_to_double(time_span.end_time) 
+               ltt_time_to_double(
+                 ltt_time_sub(time_span.end_time, time_span.start_time)) 
                  * NANOSECONDS_PER_SECOND, /* upper */
                "step_increment",
                ltt_time_to_double(time_window->time_width)
@@ -717,8 +717,10 @@ void lttvwindow_report_time_window(Tab *tab,
   /* Note : the set value will call set_time_window if scrollbar value changed
    */
   gtk_adjustment_set_value(adjustment,
-                                   ltt_time_to_double(time_window->start_time)
-                                   * NANOSECONDS_PER_SECOND);
+                           ltt_time_to_double(
+                             ltt_time_sub(time_window->start_time,
+                                          time_span.start_time))
+                           * NANOSECONDS_PER_SECOND);
 }
 
 
This page took 0.047042 seconds and 4 git commands to generate.