continue, redraw, stop, ok
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 2 Jul 2004 20:48:03 +0000 (20:48 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 2 Jul 2004 20:48:03 +0000 (20:48 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@622 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/gui/controlflow/cfv-private.h
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/module.c
ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c

index ad11453ea262d5d785829c593177b662f4730ad4..19361699027d082722421a79d01ed81692ecc671 100644 (file)
@@ -39,12 +39,6 @@ struct _ControlFlowData {
   //guint currently_Selected_Event  ;
   guint number_of_process;
 
-  /* hooks for trace read */
-  LttvHooks *event;
-  LttvHooks *after_event;
-  LttvHooks *after_traceset;
-  EventRequest *event_request;
-
 } ;
 
 
index ee0b37fda9b6d158ec204435c2c4aeb4f0944f61..64254f24f87361324e941e5bfdfbf6f220328364 100644 (file)
@@ -31,8 +31,8 @@ extern GSList *g_control_flow_data_list;
 
 static void control_flow_grab_focus(GtkWidget *widget, gpointer data){
   ControlFlowData * control_flow_data = (ControlFlowData *)data;
-  MainWindow * mw = control_flow_data->mw;
-  lttvwindow_report_focus(mw, control_flow_data->scrolled_window);
+  Tab * tab = control_flow_data->tab;
+  lttvwindow_report_focus(tab, guicontrolflow_get_widget(control_flow_data));
 }
 
 
@@ -104,13 +104,6 @@ guicontrolflow(void)
   /* Get trace statistics */
   //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
 
-  /* Create reading hooks */
-  control_flow_data->event = lttv_hooks_new();
-  control_flow_data->after_event = lttv_hooks_new();
-  control_flow_data->after_traceset = lttv_hooks_new();
-  control_flow_data->event_request = g_new(EventRequest, 1);
-
-  
   gtk_widget_show(drawing_widget);
   gtk_widget_show(process_list_widget);
   gtk_widget_show(control_flow_data->h_paned);
@@ -151,8 +144,8 @@ guicontrolflow_destructor_full(ControlFlowData *control_flow_data)
 {
   g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data);
   /* May already have been done by GTK window closing */
-  if(GTK_IS_WIDGET(control_flow_data->scrolled_window))
-    gtk_widget_destroy(control_flow_data->scrolled_window);
+  if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data)))
+    gtk_widget_destroy(guicontrolflow_get_widget(control_flow_data));
   //control_flow_data->mw = NULL;
   //FIXME guicontrolflow_destructor(control_flow_data);
 }
@@ -162,33 +155,40 @@ 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);
-  g_info("%p, %p, %p", update_time_window_hook, control_flow_data, control_flow_data->mw);
-  if(GTK_IS_WIDGET(control_flow_data->scrolled_window))
+  g_info("%p, %p, %p", update_time_window_hook, control_flow_data, tab);
+  if(GTK_IS_WIDGET(guicontrolflow_get_widget(control_flow_data)))
     g_info("widget still exists");
   
   /* Process List is removed with it's widget */
   //ProcessList_destroy(control_flow_data->process_list);
-  if(control_flow_data->mw != NULL)
+  if(tab != NULL)
   {
       /* Delete reading hooks */
-    lttv_hooks_destroy(control_flow_data->event);
-    lttv_hooks_destroy(control_flow_data->after_event);
-    lttv_hooks_destroy(control_flow_data->after_traceset);
-    g_free(control_flow_data->event_request);
-
-    lttvwindow_unregister_time_window_notify(control_flow_data->mw,
+    lttvwindow_unregister_time_window_notify(tab,
         update_time_window_hook,
         control_flow_data);
   
-    lttvwindow_unregister_current_time_notify(control_flow_data->mw,
+    lttvwindow_unregister_current_time_notify(tab,
         update_current_time_hook,
         control_flow_data);
+
+    lttvwindow_unregister_redraw_notify(tab, redraw_notify, control_flow_data);
+    lttvwindow_unregister_continue_notify(tab,
+                                          continue_notify,
+                                          control_flow_data);
+    
+    lttvwindow_events_request_remove_all(control_flow_data->tab,
+                                         control_flow_data);
   }
-  g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
-  g_slist_remove(g_control_flow_data_list,control_flow_data);
+  g_control_flow_data_list = 
+         g_slist_remove(g_control_flow_data_list,control_flow_data);
+
+  g_info("CFV.c : guicontrolflow_destructor end, %p", control_flow_data);
   g_free(control_flow_data);
 }
 
 GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data)
index 2379435663901512f9ce3a9692db0611c332915f..375ed57007780e053deb0716bed976c93a1d69bb 100644 (file)
@@ -67,7 +67,7 @@ static GdkColor CF_Colors [] =
 
 
 /* Function responsible for updating the exposed area.
- * It must call processTrace() to ask for this update.
+ * It must do an events request to the lttvwindow API to ask for this update.
  * Note : this function cannot clear the background, because it may
  * erase drawing already present (SAFETY).
  */
@@ -80,21 +80,23 @@ void drawing_data_request(Drawing_t *drawing,
   if(width < 0) return ;
   if(height < 0) return ;
 
-  const TimeWindow *time_window = lttvwindow_get_time_window(drawing->control_flow_data->mw);
+  TimeWindow time_window =
+              lttvwindow_get_time_window(drawing->control_flow_data->tab);
 
   ControlFlowData *control_flow_data = drawing->control_flow_data;
+  Tab *tab = control_flow_data->tab;
   //    (ControlFlowData*)g_object_get_data(
   //               G_OBJECT(drawing->drawing_area), "control_flow_data");
 
   LttTime start, time_end;
-  LttTime window_end = ltt_time_add(time_window->time_width,
-                                    time_window->start_time);
+  LttTime window_end = ltt_time_add(time_window.time_width,
+                                    time_window.start_time);
 
-  g_debug("req : window start_time : %u, %u", time_window->start_time.tv_sec, 
-                                       time_window->start_time.tv_nsec);
+  g_debug("req : window start_time : %u, %u", time_window.start_time.tv_sec, 
+                                       time_window.start_time.tv_nsec);
 
-  g_debug("req : window time width : %u, %u", time_window->time_width.tv_sec, 
-                                       time_window->time_width.tv_nsec);
+  g_debug("req : window time width : %u, %u", time_window.time_width.tv_sec, 
+                                       time_window.time_width.tv_nsec);
   
   g_debug("req : window_end : %u, %u", window_end.tv_sec, 
                                        window_end.tv_nsec);
@@ -102,109 +104,127 @@ void drawing_data_request(Drawing_t *drawing,
   g_debug("x is : %i, x+width is : %i", x, x+width);
 
   convert_pixels_to_time(drawing->drawing_area->allocation.width, x,
-        time_window->start_time,
+        time_window.start_time,
         window_end,
         &start);
 
   convert_pixels_to_time(drawing->drawing_area->allocation.width, x+width,
-        time_window->start_time,
+        time_window.start_time,
         window_end,
         &time_end);
   
-  LttvTracesetContext * tsc =
-        lttvwindow_get_traceset_context(control_flow_data->mw);
-  LttvTracesetState * tss =
-        (LttvTracesetState*)tsc;
-  
-  // Let's call processTrace() !!
-  
-  EventRequest *event_request = control_flow_data->event_request;
-  event_request->control_flow_data = control_flow_data;
-  event_request->time_begin = start;
-  event_request->time_end = time_end;
-
-  event_request->x_begin = x;
-  event_request->x_end = x+width;
-
-  g_debug("req : start : %u, %u", event_request->time_begin.tv_sec, 
-                                      event_request->time_begin.tv_nsec);
-
-  g_debug("req : end : %u, %u", event_request->time_end.tv_sec, 
-                                      event_request->time_end.tv_nsec);
-  
-  lttv_hooks_add(control_flow_data->after_traceset, after_data_request, event_request);
-  lttv_hooks_add(control_flow_data->event, draw_event_hook, event_request);
-  lttv_hooks_add(control_flow_data->after_event, draw_after_hook, event_request);
-
-  //lttv_process_traceset_seek_time(tsc, start);
-  //lttv_state_traceset_seek_time_closest(tss, start);
-  // FIXME : would like to place the after_traceset hook after the traceset,
-  // but the traceset context state is not valid anymore.
-  lttv_traceset_context_add_hooks(tsc,
-      NULL, control_flow_data->after_traceset, NULL, NULL, NULL, NULL,
-      //NULL, NULL, NULL, NULL, NULL, NULL,
-      NULL, NULL, NULL, control_flow_data->event, control_flow_data->after_event);
-  TimeWindow time_request;
-  time_request.start_time = start;
-  time_request.time_width = ltt_time_sub(time_end, start);
-  
-  lttvwindow_time_interval_request(drawing->control_flow_data->mw, 
-                                   time_request, G_MAXUINT,
-                                   after_process_traceset_hook,
-                                   control_flow_data);
-      
-  //lttv_process_traceset(tsc, end, G_MAXULONG);
+  EventsRequest *events_request = g_new(EventsRequest, 1);
+  // Create the hooks
+  LttvHooks *event = lttv_hooks_new();
+  LttvHooks *before_chunk_traceset = lttv_hooks_new();
+  LttvHooks *after_chunk_traceset = lttv_hooks_new();
+
+  lttv_hooks_add(before_chunk_traceset,
+                 before_data_request,
+                 events_request,
+                 LTTV_PRIO_DEFAULT);
+
+  lttv_hooks_add(after_chunk_traceset,
+                 after_data_request,
+                 events_request,
+                 LTTV_PRIO_DEFAULT);
+  lttv_hooks_add(event,
+                 draw_event_hook,
+                 events_request,
+                 LTTV_PRIO_STATE-5);
+  lttv_hooks_add(event,
+                 draw_after_hook,
+                 events_request,
+                 LTTV_PRIO_STATE+5);
+
+
+  // Fill the events request
+  events_request->owner = control_flow_data;
+  events_request->viewer_data = control_flow_data;
+  events_request->servicing = FALSE;
+  events_request->start_time = start;
+  events_request->start_position = NULL;
+  events_request->stop_flag = FALSE;
+  events_request->end_time = time_end;
+  events_request->num_events = G_MAXUINT;
+  events_request->end_position = NULL;
+  events_request->before_chunk_traceset = before_chunk_traceset;
+  events_request->before_chunk_trace = NULL;
+  events_request->before_chunk_tracefile = NULL;
+  events_request->event = event;
+  events_request->event_by_id = NULL;
+  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;
+
+  g_debug("req : start : %u, %u", start.tv_sec, 
+                                      start.tv_nsec);
+
+  g_debug("req : end : %u, %u", time_end.tv_sec, 
+                                     time_end.tv_nsec);
+
+  lttvwindow_events_request_remove_all(tab,
+                                       control_flow_data);
+  lttvwindow_events_request(tab, events_request);
 }
    
 
 
-
-void drawing_data_request_end(Drawing_t *drawing,
-                              TimeWindow req_time_window)
+void drawing_data_request_begin(EventsRequest *events_request, LttvTracesetState *tss)
 {
-  gint x, x_end, width;
-  
-  LttvTracesetContext * tsc =
-        lttvwindow_get_traceset_context(drawing->control_flow_data->mw);
+  g_debug("Begin of data request chunk");
+  ControlFlowData *cfd = events_request->viewer_data;
+  LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tss);
 
-  const TimeWindow *time_window = lttvwindow_get_time_window(drawing->control_flow_data->mw);
+  LttTime current_time = lttv_traceset_context_get_current_tfc(tsc)->timestamp;
 
-  //FIXME ? removing hooks during processtrace can BREAK things!
-  lttv_traceset_context_remove_hooks(tsc,
-      NULL, drawing->control_flow_data->after_traceset, NULL, NULL, NULL, NULL,
-      NULL, NULL, NULL,
-      drawing->control_flow_data->event,
-      drawing->control_flow_data->after_event);
+  cfd->drawing->last_start = current_time;
+}
 
-  g_debug("End of data request");
+void drawing_data_request_end(EventsRequest *events_request, LttvTracesetState *tss)
+{
+  gint x, x_end, width;
+
+  ControlFlowData *cfd = events_request->viewer_data;
+  LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tss);
+  Drawing_t *drawing = cfd->drawing;
   
-  LttTime window_end = ltt_time_add(time_window->time_width,
-                                    time_window->start_time);
+  TimeWindow time_window = 
+        lttvwindow_get_time_window(cfd->tab);
 
-  LttTime req_window_end = ltt_time_add(req_time_window.time_width,
-                                        req_time_window.start_time);
+  g_debug("End of data request chunk");
+  
+  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,
+        time_window.start_time,
         window_end,
-        req_time_window.start_time,
+        cfd->drawing->last_start,
         drawing->width,
         &x);
 
   convert_time_to_pixels(
-        time_window->start_time,
+        time_window.start_time,
         window_end,
-        req_window_end,
+        current_time,
         drawing->width,
         &x_end);
 
   width = x_end - x;
 
+  drawing->damage_begin = x+width;
+  drawing->damage_end = drawing->width;
+
   /* ask for the buffer to be redrawn */
   gtk_widget_queue_draw_area ( drawing->drawing_area,
                                x, 0,
                                width, drawing->height);
-
 }
 
 
@@ -237,7 +257,8 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event,
   //      -1);
   
   g_debug("drawing configure event");
-  g_debug("New draw size : %i by %i",widget->allocation.width, widget->allocation.height);
+  g_debug("New draw size : %i by %i",widget->allocation.width,
+                                    widget->allocation.height);
   
     
   if (drawing->pixmap)
@@ -279,12 +300,20 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event,
     drawing->width = widget->allocation.width;
     drawing->height = widget->allocation.height;
   
-    drawing->data_injected = FALSE;
-
+    drawing->damage_begin = 0;
+    drawing->damage_end = widget->allocation.width;
+
+    if(drawing->damage_begin < drawing->damage_end)
+    {
+      drawing_data_request(drawing,
+                           &drawing->pixmap,
+                           drawing->damage_begin,
+                           0,
+                           drawing->damage_end,
+                           widget->allocation.height);
+    }
+   
     return TRUE;
-
-
-
   }
 }
 
@@ -295,38 +324,29 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
 {
   Drawing_t *drawing = (Drawing_t*)user_data;
 
-  const TimeWindow *time_window = lttvwindow_get_time_window(drawing->control_flow_data->mw);
-  const LttTime* current_time = 
-      lttvwindow_get_current_time(drawing->control_flow_data->mw);
-
   ControlFlowData *control_flow_data =
       (ControlFlowData*)g_object_get_data(
                 G_OBJECT(widget),
                 "control_flow_data");
 
+  TimeWindow time_window = 
+      lttvwindow_get_time_window(control_flow_data->tab);
+  LttTime current_time = 
+      lttvwindow_get_current_time(control_flow_data->tab);
+
   guint cursor_x=0;
 
-  LttTime window_end = ltt_time_add(time_window->time_width,
-                                    time_window->start_time);
+  LttTime window_end = ltt_time_add(time_window.time_width,
+                                    time_window.start_time);
 
   convert_time_to_pixels(
-        time_window->start_time,
+        time_window.start_time,
         window_end,
-        *current_time,
+        current_time,
         widget->allocation.width,
         &cursor_x);
 
-
-
-
-  if(!drawing->data_injected)
-  {
-    drawing_data_request(drawing, &drawing->pixmap, 0, 0,
-        widget->allocation.width,
-        widget->allocation.height);
-    drawing->data_injected = TRUE;
-  }
-  
   /* update the screen from the pixmap buffer */
   gdk_draw_pixmap(widget->window,
       widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
@@ -338,27 +358,26 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
 
   /* Draw the dotted lines */
 
-  gint8 dash_list[] = { 1, 2 };
-  GdkGC *gc = gdk_gc_new(control_flow_data->drawing->pixmap);
-  gdk_gc_copy(gc, widget->style->white_gc);
-  gdk_gc_set_line_attributes(gc,
-                             1,
-                             GDK_LINE_ON_OFF_DASH,
-                             GDK_CAP_BUTT,
-                             GDK_JOIN_MITER);
-  gdk_gc_set_dashes(gc,
-                    0,
-                    dash_list,
-                    2);
-  drawing_draw_line(NULL, widget->window,
-                cursor_x, 0,
-                cursor_x, drawing->height,
-                gc);
-  gdk_gc_unref(gc);
-
-  
-
+  if(drawing->dotted_gc == NULL) {
 
+    drawing->dotted_gc = gdk_gc_new(drawing->drawing_area->window);
+    gdk_gc_copy(drawing->dotted_gc, widget->style->white_gc);
+    gint8 dash_list[] = { 1, 2 };
+    gdk_gc_set_line_attributes(drawing->dotted_gc,
+                               1,
+                               GDK_LINE_ON_OFF_DASH,
+                               GDK_CAP_BUTT,
+                               GDK_JOIN_MITER);
+    gdk_gc_set_dashes(drawing->dotted_gc,
+                      0,
+                      dash_list,
+                      2);
+    drawing_draw_line(NULL, widget->window,
+                  cursor_x, 0,
+                  cursor_x, drawing->height,
+                  drawing->dotted_gc);
+  }
   return FALSE;
 }
 
@@ -383,31 +402,33 @@ button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user_data
                 G_OBJECT(widget),
                 "control_flow_data");
   Drawing_t *drawing = control_flow_data->drawing;
-  const TimeWindow *time_window = lttvwindow_get_time_window(drawing->control_flow_data->mw);
+  TimeWindow time_window =
+               lttvwindow_get_time_window(control_flow_data->tab);
 
   g_debug("click");
   if(event->button == 1)
   {
     LttTime time;
 
-    LttTime window_end = ltt_time_add(time_window->time_width,
-                                      time_window->start_time);
+    LttTime window_end = ltt_time_add(time_window.time_width,
+                                      time_window.start_time);
 
 
     /* left mouse button click */
     g_debug("x click is : %f", event->x);
 
     convert_pixels_to_time(widget->allocation.width, (guint)event->x,
-        time_window->start_time,
+        time_window.start_time,
         window_end,
         &time);
 
-    lttvwindow_report_current_time(control_flow_data->mw, &time);
+    lttvwindow_report_current_time(control_flow_data->tab, &time);
 
   }
 
-  lttvwindow_report_focus(control_flow_data->mw, gtk_widget_get_parent(control_flow_data->scrolled_window));
-  
+  lttvwindow_report_focus(control_flow_data->tab,
+           gtk_widget_get_parent(guicontrolflow_get_widget(control_flow_data)));
+
   return FALSE;
 }
 
@@ -433,12 +454,15 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
   
   drawing->pango_layout =
     gtk_widget_create_pango_layout(drawing->drawing_area, NULL);
-  
+
+  drawing->dotted_gc = NULL;
+
   drawing->height = 0;
   drawing->width = 0;
   drawing->depth = 0;
   
-  drawing->data_injected = FALSE;
+  drawing->damage_begin = 0;
+  drawing->damage_end = 0;
   
   //gtk_widget_set_size_request(drawing->drawing_area->window, 50, 50);
   g_object_set_data_full(
@@ -520,12 +544,14 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
 
 void drawing_destroy(Drawing_t *drawing)
 {
-
+  g_info("drawing_destroy %p", drawing);
   // Do not unref here, Drawing_t destroyed by it's widget.
   //g_object_unref( G_OBJECT(drawing->drawing_area));
     
   g_free(drawing->pango_layout);
+  if(!drawing->dotted_gc) gdk_gc_unref(drawing->dotted_gc);
   g_free(drawing);
+  g_info("drawing_destroy end");
 }
 
 GtkWidget *drawing_get_drawing_area(Drawing_t *drawing)
@@ -740,7 +766,7 @@ static gboolean
 expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
 {
   Drawing_t *drawing = (Drawing_t*)user_data;
-  const TimeWindow *time_window = lttvwindow_get_time_window(drawing->control_flow_data->mw);
+  TimeWindow time_window = lttvwindow_get_time_window(drawing->control_flow_data->tab);
   gchar text[255];
   
   PangoContext *context;
@@ -754,13 +780,13 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
   GdkColor background = { 0, 0xffff, 0xffff, 0xffff };
 
   LttTime window_end = 
-    ltt_time_add(time_window->time_width,
-                 time_window->start_time);
+    ltt_time_add(time_window.time_width,
+                 time_window.start_time);
   LttTime half_width =
-    ltt_time_div(time_window->time_width,2.0);
+    ltt_time_div(time_window.time_width,2.0);
   LttTime window_middle =
     ltt_time_add(half_width,
-                 time_window->start_time);
+                 time_window.start_time);
   g_debug("ruler expose event");
  
   gdk_draw_rectangle (drawing->ruler->window,
@@ -784,8 +810,8 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
 
 
   snprintf(text, 255, "%lus\n%luns",
-    time_window->start_time.tv_sec,
-    time_window->start_time.tv_nsec);
+    time_window.start_time.tv_sec,
+    time_window.start_time.tv_nsec);
 
   layout = gtk_widget_create_pango_layout(drawing->drawing_area, NULL);
 
index 29ac461c989812f892f78e6795326711cde665d2..8ee55f18dfb1caa5e1301824da19ffd8afb0519d 100644 (file)
@@ -24,6 +24,9 @@
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
 #include <ltt/ltt.h>
+#include <lttv/tracecontext.h>
+#include <lttv/state.h>
+#include <lttvwindow/lttvwindow.h>
 #include "cfv.h"
 #include "drawitem.h"
 
@@ -64,8 +67,11 @@ struct _Drawing_t {
   PangoLayout *pango_layout;
 
   gint      height, width, depth;
-  gboolean  data_injected;
   
+  /* X coordinate of damaged region */
+  gint      damage_begin, damage_end;
+  LttTime   last_start;
+  GdkGC     *dotted_gc;
 };
 
 Drawing_t *drawing_construct(ControlFlowData *control_flow_data);
@@ -114,8 +120,7 @@ void convert_time_to_pixels(
 
 void drawing_update_ruler(Drawing_t *drawing, TimeWindow *time_window);
 
-void drawing_data_request_end(Drawing_t *drawing,
-                              TimeWindow req_time_window);
+void drawing_data_request_end(EventsRequest *events_request, LttvTracesetState *tss);
 
 
 #endif // _DRAWING_H
index 146cb6113cbc1d8b4bfffe3b0855e7be546bfd64..75609d09544dd8599ed0701c8dbf2fb83d591ac4 100644 (file)
  *
  * This constructor is given as a parameter to the menuitem and toolbar button
  * registration. It creates the list.
- * @param mw A pointer to the parent window.
+ * @param tab A pointer to the parent tab.
  * @return The widget created.
  */
 GtkWidget *
-h_guicontrolflow(MainWindow *mw, LttvTracesetSelector * s, char * key)
+h_guicontrolflow(Tab *tab, LttvTracesetSelector * s, char * key)
 {
-  g_info("h_guicontrolflow, %p, %p, %s", mw, s, key);
+  g_info("h_guicontrolflow, %p, %p, %s", tab, s, key);
   ControlFlowData *control_flow_data = guicontrolflow() ;
   
-  control_flow_data->mw = mw;
+  control_flow_data->tab = tab;
   
   //g_debug("time width2 : %u",time_window->time_width);
   // Unreg done in the GuiControlFlow_Destructor
-  lttvwindow_register_time_window_notify(mw,
+  lttvwindow_register_time_window_notify(tab,
                                          update_time_window_hook,
                                          control_flow_data);
-  lttvwindow_register_current_time_notify(mw,
+  lttvwindow_register_current_time_notify(tab,
                                           update_current_time_hook,
                                           control_flow_data);
+  lttvwindow_register_redraw_notify(tab,
+                                    redraw_notify,
+                                    control_flow_data);
+  lttvwindow_register_continue_notify(tab,
+                                      continue_notify,
+                                      control_flow_data);
+
+
   return guicontrolflow_get_widget(control_flow_data) ;
   
 }
@@ -99,7 +107,7 @@ int event_selected_hook(void *hook_data, void *call_data)
  */
 int draw_before_hook(void *hook_data, void *call_data)
 {
-  EventRequest *event_request = (EventRequest*)hook_data;
+  EventsRequest *events_request = (EventsRequest*)hook_data;
   //EventsContext Events_Context = (EventsContext*)call_data;
   
   //event_request->Events_Context = Events_Context;
@@ -129,9 +137,10 @@ int draw_before_hook(void *hook_data, void *call_data)
  */
 int draw_event_hook(void *hook_data, void *call_data)
 {
-  EventRequest *event_request = (EventRequest*)hook_data;
-  ControlFlowData *control_flow_data = event_request->control_flow_data;
-  MainWindow *mw = control_flow_data->mw;
+  EventsRequest *events_request = (EventsRequest*)hook_data;
+  ControlFlowData *control_flow_data = 
+                      (ControlFlowData*)events_request->viewer_data;
+  Tab *tab = control_flow_data->tab;
 
   LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
 
@@ -142,13 +151,13 @@ int draw_event_hook(void *hook_data, void *call_data)
   e = tfc->e;
 
   LttTime evtime = ltt_event_time(e);
-  const TimeWindow *time_window = 
-    lttvwindow_get_time_window(mw);
+  TimeWindow time_window = 
+    lttvwindow_get_time_window(tab);
 
-  LttTime end_time = ltt_time_add(time_window->start_time,
-                                    time_window->time_width);
+  LttTime end_time = ltt_time_add(time_window.start_time,
+                                    time_window.time_width);
   //if(time < time_beg || time > time_end) return;
-  if(ltt_time_compare(evtime, time_window->start_time) == -1
+  if(ltt_time_compare(evtime, time_window.start_time) == -1
         || ltt_time_compare(evtime, end_time) == 1)
             return;
 
@@ -164,7 +173,7 @@ int draw_event_hook(void *hook_data, void *call_data)
     guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
 
     ProcessList *process_list =
-      guicontrolflow_get_process_list(event_request->control_flow_data);
+      guicontrolflow_get_process_list(control_flow_data);
 
 
     LttField *f = ltt_event_field(e);
@@ -208,7 +217,7 @@ int draw_event_hook(void *hook_data, void *call_data)
             &y_out,
             &height,
             &hashed_process_data_out);
-    drawing_insert_square( event_request->control_flow_data->drawing, y_out, height);
+    drawing_insert_square( control_flow_data->drawing, y_out, height);
     }
 
     g_free(name);
@@ -246,7 +255,7 @@ int draw_event_hook(void *hook_data, void *call_data)
             &height,
             &hashed_process_data_in);
 
-      drawing_insert_square( event_request->control_flow_data->drawing, y_in, height);
+      drawing_insert_square( control_flow_data->drawing, y_in, height);
     }
     g_free(name);
 
@@ -258,12 +267,12 @@ int draw_event_hook(void *hook_data, void *call_data)
 
     LttTime time = ltt_event_time(e);
 
-    LttTime window_end = ltt_time_add(time_window->time_width,
-                          time_window->start_time);
+    LttTime window_end = ltt_time_add(time_window.time_width,
+                          time_window.start_time);
 
     
     convert_time_to_pixels(
-        time_window->start_time,
+        time_window.start_time,
         window_end,
         time,
         width,
@@ -291,11 +300,14 @@ int draw_event_hook(void *hook_data, void *call_data)
     /* Draw the line/background of the out process */
     if(draw_context_out->previous->middle->x == -1)
     {
-      draw_context_out->previous->over->x = event_request->x_begin;
-      draw_context_out->previous->middle->x = event_request->x_begin;
-      draw_context_out->previous->under->x = event_request->x_begin;
-
-      g_debug("out middle x_beg : %u",event_request->x_begin);
+      draw_context_out->previous->over->x =
+                            control_flow_data->drawing->damage_begin;
+      draw_context_out->previous->middle->x = 
+                            control_flow_data->drawing->damage_begin;
+      draw_context_out->previous->under->x =
+                            control_flow_data->drawing->damage_begin;
+
+      g_debug("out middle x_beg : %u",control_flow_data->drawing->damage_begin);
     }
   
     draw_context_out->current->middle->x = x;
@@ -507,10 +519,15 @@ int draw_event_hook(void *hook_data, void *call_data)
     /* Draw the line/bg of the in process */
     if(draw_context_in->previous->middle->x == -1)
     {
-      draw_context_in->previous->middle->x = event_request->x_begin;
-      draw_context_in->previous->over->x = event_request->x_begin;
-      draw_context_in->previous->under->x = event_request->x_begin;
-      g_debug("in middle x_beg : %u",event_request->x_begin);
+      draw_context_in->previous->over->x =
+                            control_flow_data->drawing->damage_begin;
+      draw_context_in->previous->middle->x = 
+                            control_flow_data->drawing->damage_begin;
+      draw_context_in->previous->under->x =
+                            control_flow_data->drawing->damage_begin;
+
+      g_debug("in middle x_beg : %u",control_flow_data->drawing->damage_begin);
+
     }
   
     draw_context_in->current->middle->x = x;
@@ -729,8 +746,8 @@ int draw_event_hook(void *hook_data, void *call_data)
 
 int draw_after_hook(void *hook_data, void *call_data)
 {
-  EventRequest *event_request = (EventRequest*)hook_data;
-  ControlFlowData *control_flow_data = event_request->control_flow_data;
+  EventsRequest *events_request = (EventsRequest*)hook_data;
+  ControlFlowData *control_flow_data = events_request->viewer_data;
 
   LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
 
@@ -742,13 +759,13 @@ int draw_after_hook(void *hook_data, void *call_data)
   e = tfc->e;
 
   LttTime evtime = ltt_event_time(e);
-  const TimeWindow *time_window = 
-    lttvwindow_get_time_window(control_flow_data->mw);
+  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);
+  LttTime end_time = ltt_time_add(time_window.start_time,
+                                    time_window.time_width);
   //if(time < time_beg || time > time_end) return;
-  if(ltt_time_compare(evtime, time_window->start_time) == -1
+  if(ltt_time_compare(evtime, time_window.start_time) == -1
         || ltt_time_compare(evtime, end_time) == 1)
             return;
 
@@ -765,7 +782,7 @@ int draw_after_hook(void *hook_data, void *call_data)
     guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
 
     ProcessList *process_list =
-      guicontrolflow_get_process_list(event_request->control_flow_data);
+      guicontrolflow_get_process_list(control_flow_data);
 
 
     LttField *f = ltt_event_field(e);
@@ -809,7 +826,7 @@ int draw_after_hook(void *hook_data, void *call_data)
             &y_out,
             &height,
             &hashed_process_data_out);
-    drawing_insert_square( event_request->control_flow_data->drawing, y_out, height);
+    drawing_insert_square( control_flow_data->drawing, y_out, height);
     }
 
     g_free(name);
@@ -847,7 +864,7 @@ int draw_after_hook(void *hook_data, void *call_data)
             &height,
             &hashed_process_data_in);
 
-      drawing_insert_square( event_request->control_flow_data->drawing, y_in, height);
+      drawing_insert_square( control_flow_data->drawing, y_in, height);
     }
     g_free(name);
 
@@ -1383,13 +1400,78 @@ gint update_time_window_hook(void *hook_data, void *call_data)
   return 0;
 }
 
-gint after_process_traceset_hook(void *hook_data, void *call_data)
+gint redraw_notify(void *hook_data, void *call_data)
+{
+  ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
+  Drawing_t *drawing = control_flow_data->drawing;
+  GtkWidget *widget = drawing->drawing_area;
+
+  drawing->damage_begin = 0;
+  drawing->damage_end = widget->allocation.width;
+
+
+  // Clear the image
+  gdk_draw_rectangle (drawing->pixmap,
+        widget->style->black_gc,
+        TRUE,
+        0, 0,
+        widget->allocation.width+SAFETY,
+        widget->allocation.height+SAFETY);
+
+
+  if(drawing->damage_begin < drawing->damage_end)
+  {
+    drawing_data_request(drawing,
+                         &drawing->pixmap,
+                         drawing->damage_begin,
+                         0,
+                         drawing->damage_end-drawing->damage_begin,
+                         widget->allocation.height);
+  }
+
+  gtk_widget_queue_draw_area(drawing->drawing_area,
+                             0,0,
+                             drawing->width,
+                             drawing->height);
+  return FALSE;
+
+}
+
+
+gint continue_notify(void *hook_data, void *call_data)
 {
   ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
-  TimeRequest *time_request = (TimeRequest *)call_data;
+  Drawing_t *drawing = control_flow_data->drawing;
+  GtkWidget *widget = drawing->drawing_area;
 
-  drawing_data_request_end(control_flow_data->drawing,
-                           time_request->time_window);
+  g_assert(widget->allocation.width == drawing->damage_end);
+
+  if(drawing->damage_begin < drawing->damage_end)
+  {
+    drawing_data_request(drawing,
+                         &drawing->pixmap,
+                         drawing->damage_begin,
+                         0,
+                         drawing->damage_end-drawing->damage_begin,
+                         widget->allocation.height);
+  }
+
+  return FALSE;
+}
+
+
+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; 
 }
  
@@ -1402,19 +1484,19 @@ gint update_current_time_hook(void *hook_data, void *call_data)
 
   LttTime current_time = *((LttTime*)call_data);
   
-  const TimeWindow *time_window =
-            lttvwindow_get_time_window(control_flow_data->mw);
+  TimeWindow time_window =
+            lttvwindow_get_time_window(control_flow_data->tab);
   
-  LttTime time_begin = time_window->start_time;
-  LttTime width = time_window->time_width;
+  LttTime time_begin = time_window.start_time;
+  LttTime width = time_window.time_width;
   LttTime half_width = ltt_time_div(width,2.0);
   LttTime time_end = ltt_time_add(time_begin, width);
 
   LttvTracesetContext * tsc =
-        lttvwindow_get_traceset_context(control_flow_data->mw);
+        lttvwindow_get_traceset_context(control_flow_data->tab);
   
-  LttTime trace_start = tsc->Time_Span->startTime;
-  LttTime trace_end = tsc->Time_Span->endTime;
+  LttTime trace_start = tsc->time_span.start_time;
+  LttTime trace_end = tsc->time_span.end_time;
   
   g_info("New current time HOOK : %u, %u", current_time.tv_sec,
               current_time.tv_nsec);
@@ -1444,7 +1526,7 @@ gint update_current_time_hook(void *hook_data, void *call_data)
     new_time_window.start_time = time_begin;
     new_time_window.time_width = width;
 
-    lttvwindow_report_time_window(control_flow_data->mw, &new_time_window);
+    lttvwindow_report_time_window(control_flow_data->tab, &new_time_window);
   }
   else if(ltt_time_compare(current_time, time_end) == 1)
   {
@@ -1458,7 +1540,7 @@ gint update_current_time_hook(void *hook_data, void *call_data)
     new_time_window.start_time = time_begin;
     new_time_window.time_width = width;
 
-    lttvwindow_report_time_window(control_flow_data->mw, &new_time_window);
+    lttvwindow_report_time_window(control_flow_data->tab, &new_time_window);
     
   }
   //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
@@ -1471,7 +1553,7 @@ gint update_current_time_hook(void *hook_data, void *call_data)
 }
 
 typedef struct _ClosureData {
-  EventRequest *event_request;
+  EventsRequest *events_request;
   LttvTracesetState *tss;
 } ClosureData;
   
@@ -1483,7 +1565,7 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
   ClosureData *closure_data = (ClosureData*)user_data;
     
   ControlFlowData *control_flow_data =
-    closure_data->event_request->control_flow_data;
+    closure_data->events_request->viewer_data;
   
   GtkWidget *widget = control_flow_data->drawing->drawing_area;
 
@@ -1498,7 +1580,7 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
   /* Get last state of process */
   LttvTraceContext *tc =
     ((LttvTracesetContext*)closure_data->tss)->traces[process_info->trace_num];
-  //LttvTracefileContext *tfc = (LttvTracefileContext *)closure_data->ts;
+  LttvTracesetContext *tsc = (LttvTracesetContext *)closure_data->tss;
 
   LttvTraceState *ts = (LttvTraceState*)tc;
   LttvProcessState *process;
@@ -1511,15 +1593,39 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
   DrawContext *draw_context = hashed_process_data->draw_context;
   if(draw_context->previous->middle->x == -1)
   {
-    draw_context->previous->middle->x = closure_data->event_request->x_begin;
-    draw_context->previous->over->x = closure_data->event_request->x_begin;
-    draw_context->previous->under->x = closure_data->event_request->x_begin;
-    g_debug("out middle x_beg : %u",closure_data->event_request->x_begin);
+    draw_context->previous->over->x =
+                          control_flow_data->drawing->damage_begin;
+    draw_context->previous->middle->x = 
+                          control_flow_data->drawing->damage_begin;
+    draw_context->previous->under->x =
+                          control_flow_data->drawing->damage_begin;
+
+    g_debug("out middle x_beg : %u",control_flow_data->drawing->damage_begin);
   }
 
-  draw_context->current->middle->x = closure_data->event_request->x_end;
-  draw_context->current->over->x = closure_data->event_request->x_end;
-  draw_context->current->under->x = closure_data->event_request->x_end;
+  /* Find pixels corresponding to current time . If the time does
+   * not fit in the window, show a warning, not supposed to happend. */
+  guint x = 0;
+  guint width = control_flow_data->drawing->drawing_area->allocation.width;
+
+  TimeWindow time_window =
+            lttvwindow_get_time_window(control_flow_data->tab);
+
+  LttTime time = lttv_traceset_context_get_current_tfc(tsc)->timestamp;
+
+  LttTime window_end = ltt_time_add(time_window.time_width,
+                        time_window.start_time);
+  
+  convert_time_to_pixels(
+      time_window.start_time,
+      window_end,
+      time,
+      width,
+      &x);
+
+  draw_context->current->middle->x = x;
+  draw_context->current->over->x = x;
+  draw_context->current->under->x = x;
   draw_context->current->middle->y = y + height/2;
   draw_context->current->over->y = y ;
   draw_context->current->under->y = y + height;
@@ -1667,10 +1773,20 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
   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;
-  
 
 }
 
+int  before_data_request(void *hook_data, void *call_data)
+{
+  EventsRequest *events_request = (EventsRequest*)hook_data;
+  LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
+
+  drawing_data_request_begin(events_request, tss);
+
+  return 0;
+}
+
+
 /*
  * for each process
  *    draw closing line
@@ -1679,22 +1795,23 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
  */
 int  after_data_request(void *hook_data, void *call_data)
 {
-  EventRequest *event_request = (EventRequest*)hook_data;
-  ControlFlowData *control_flow_data = event_request->control_flow_data;
+  EventsRequest *events_request = (EventsRequest*)hook_data;
+  ControlFlowData *control_flow_data = events_request->viewer_data;
+  LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
   
   ProcessList *process_list =
-    guicontrolflow_get_process_list(event_request->control_flow_data);
+    guicontrolflow_get_process_list(control_flow_data);
 
   ClosureData closure_data;
-  closure_data.event_request = (EventRequest*)hook_data;
-  closure_data.tss = (LttvTracesetState*)call_data;
+  closure_data.events_request = (EventsRequest*)hook_data;
+  closure_data.tss = tss;
 
   g_hash_table_foreach(process_list->process_hash, draw_closure,
                         (void*)&closure_data);
 
-  /* Remove reading hooks */
-  // Cannot do this here, will break processtrace!
-  //drawing_data_request_end(control_flow_data->drawing);
-  
+  /* Request expose */
+  drawing_data_request_end(events_request, tss);
+
+  return 0;
 }
 
index 324bd759be5be25df2bcd873d4661639ef10ee59..75cde72b5fbd20c2bd2f90ca1beef07ff0a388c7 100644 (file)
  * library call, then used by the drawing hooks. Then, once all the events are
  * sent, it is freed by the hook called after the reading.
  */
-typedef struct _EventRequest
-{
-  ControlFlowData *control_flow_data;
-  LttTime time_begin, time_end;
-  gint  x_begin, x_end;
+//typedef struct _EventRequest
+//{
+//  ControlFlowData *control_flow_data;
+//  LttTime time_begin, time_end;
+//  gint  x_begin, x_end;
   /* Fill the Events_Context during the initial expose, before calling for
    * events.
    */
   //GArray Events_Context; //FIXME
-} EventRequest ;
+//} EventRequest ;
 
 
 
@@ -57,7 +57,7 @@ typedef struct _EventRequest
 
 void send_test_data(ProcessList *process_list, Drawing_t *drawing);
 
-GtkWidget *h_guicontrolflow(MainWindow *mw, LttvTracesetSelector * s, char * key);
+GtkWidget *h_guicontrolflow(Tab *tab, LttvTracesetSelector * s, char * key);
 
 int event_selected_hook(void *hook_data, void *call_data);
 
@@ -92,12 +92,17 @@ 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);
 
 
 gint update_time_window_hook(void *hook_data, void *call_data);
 gint update_current_time_hook(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 258356e65f3f067a4778df32f1c04f57d64c1d24..db6d256f957cc29e97f7ce7ff125db636f822173 100644 (file)
@@ -69,13 +69,12 @@ static void init() {
 
   g_info("GUI ControlFlow Viewer init()");
 
-  /* Register the toolbar insert button */
-  lttvwindow_register_toolbar(hGuiControlFlowInsert_xpm,
-      "Insert Control Flow Viewer", h_guicontrolflow);
-
-  /* Register the menu item insert entry */
-  lttvwindow_register_menu("/", "Insert Control Flow Viewer", h_guicontrolflow);
-  
+  /* Register the toolbar insert button and menu entry*/
+  lttvwindow_register_constructor("/",
+                                  "Insert Control Flow Viewer",
+                                  hGuiControlFlowInsert_xpm,
+                                  "Insert Control Flow Viewer",
+                                  h_guicontrolflow);
 }
 
 void destroy_walk(gpointer data, gpointer user_data)
@@ -100,12 +99,8 @@ static void destroy() {
   
   g_slist_free(g_control_flow_data_list);
 
-  /* Unregister the toolbar insert button */
-  lttvwindow_unregister_toolbar(h_guicontrolflow);
-
-  /* Unregister the menu item insert entry */
-  lttvwindow_unregister_menu(h_guicontrolflow);
-  
+  /* Unregister the toolbar insert button and menu entry */
+  lttvwindow_unregister_constructor(h_guicontrolflow);
 }
 
 
index 4145f745ddbdaeeccee2447f69b1b2b096e30452..7b5885b18c05ec1845d6fa2164632cc6fa3b68b9 100644 (file)
 #include "processlist.h"
 #include "drawitem.h"
 
+#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
+#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
+
+
 /*****************************************************************************
  *                       Methods to synchronize process list                 *
  *****************************************************************************/
@@ -320,10 +324,12 @@ ProcessList *processlist_construct(void)
 }
 void processlist_destroy(ProcessList *process_list)
 {
+  g_info("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");
 }
 
 GtkWidget *processlist_get_widget(ProcessList *process_list)
This page took 0.052361 seconds and 4 git commands to generate.