main window call process_traceset for each viewer
authoryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 18 Nov 2003 20:47:34 +0000 (20:47 +0000)
committeryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 18 Nov 2003 20:47:34 +0000 (20:47 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@337 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/include/lttv/common.h
ltt/branches/poly/include/lttv/gtkTraceSet.h
ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c
ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c
ltt/branches/poly/lttv/modules/guiEvents.c

index 81bf7c63a22d1289e43601212739234ad5bb20cc..b4ef29c81b2c99568285e7b1d3e8bbfdf941100a 100644 (file)
@@ -6,6 +6,9 @@
 #include <gtk/gtk.h>
 #include <lttv/lttvfilter.h>
 
+#define MAX_NUMBER_EVENT     "MAX_NUMBER_EVENT"
+#define TRACESET_TIME_SPAN   "TRACESET_TIME_SPAN"
+
 typedef struct _MainWindow MainWindow;
 typedef struct _Tab Tab;
 
index f1df34367030be6f26bb4f7d13942d869f43ce7d..2d7ed4dcf6c2ad225ecb1550546852c27633f330 100644 (file)
@@ -241,6 +241,41 @@ void unreg_update_current_time(LttvHook hook, gpointer hook_data,
                            MainWindow * main_win);
 
 
+/**
+ * Function to register a hook function for a viewer to show 
+ *the content of the viewer.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_show_viewer(LttvHook hook, gpointer hook_data, 
+                    MainWindow *main_win);
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * show the content of the viewer..
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_show_viewer(LttvHook hook, gpointer hook_data,
+                      MainWindow * main_win);
+
+
+/**
+ * Function to show each viewer in the current tab.
+ * It will be called by main window after it called process_traceset 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void show_viewer(MainWindow *main_win);
+
+
 /**
  * Function to set the focused pane (viewer).
  * It will be called by a viewer's signal handle associated with 
index 8aeca549af2ef66ebc3175a741eb1e97c989b2b7..b079fb5a39e998c800b0724c0f7624196b862476 100644 (file)
@@ -488,6 +488,71 @@ void unreg_update_current_time(LttvHook hook, gpointer hook_data,
 }
 
 
+/**
+ * Function to register a hook function for a viewer to show 
+ *the content of the viewer.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_show_viewer(LttvHook hook, gpointer hook_data, 
+                    MainWindow *main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+                      "hooks/showviewer", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL){    
+    tmp = lttv_hooks_new();
+    *(value.v_pointer) = tmp;
+  }
+  lttv_hooks_add(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * show the content of the viewer..
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_show_viewer(LttvHook hook, gpointer hook_data,
+                      MainWindow * main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+                      "hooks/showviewer", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_remove_data(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to show each viewer in the current tab.
+ * It will be called by main window after it called process_traceset 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void show_viewer(MainWindow *main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+                      "hooks/showviewer", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_call(tmp, NULL);
+}
+
+
 /**
  * Function to set the focused pane (viewer).
  * It will be called by a viewer's signal handle associated with 
index fd708324a87f15debb672047204f99ea0d19a94c..5fa2a787dff3d6f87cd1d53a51d6b154daf206bb 100644 (file)
@@ -49,6 +49,9 @@ void add_trace_into_traceset_selector(GtkMultiVPaned * paned, LttTrace * trace);
 
 LttvTracesetSelector * construct_traceset_selector(LttvTraceset * traceset);
 
+void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window, unsigned nb_events);
+
+
 enum {
   CHECKBOX_COLUMN,
   NAME_COLUMN,
@@ -127,6 +130,9 @@ void insert_viewer(GtkWidget* widget, view_constructor constructor)
   MainWindow * mw_data;  
   GtkWidget * viewer;
   LttvTracesetSelector  * s;
+  unsigned * size;
+  TimeInterval * time_interval;
+  TimeWindow  time_window;
 
   mw_data = get_window_data_struct(widget);
   if(!mw_data->current_tab) return;
@@ -139,6 +145,19 @@ void insert_viewer(GtkWidget* widget, view_constructor constructor)
     gtk_multi_vpaned_widget_add(multi_vpaned, viewer); 
     // Added by MD
     //    g_object_unref(G_OBJECT(viewer));
+
+    size = (unsigned*)g_object_get_data(G_OBJECT(viewer), MAX_NUMBER_EVENT);
+    if(size == NULL) *size = G_MAXULONG;
+
+    time_window = mw_data->current_tab->time_window;
+    time_interval = (TimeInterval*)g_object_get_data(G_OBJECT(viewer), TRACESET_TIME_SPAN);
+    if(time_interval){
+      time_window.start_time = time_interval->startTime;
+      time_window.time_width = ltt_time_sub(time_interval->endTime,time_interval->startTime);
+    }
+
+    redraw_viewer(mw_data,&time_window, *size);
+    set_current_time(mw_data,&(mw_data->current_tab->current_time));
   }
 }
 
@@ -266,6 +285,19 @@ void open_traceset(GtkWidget * widget, gpointer user_data)
 
 }
 
+void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window, unsigned nb_events)
+{
+  //update time window of each viewer, let viewer insert hooks needed by process_traceset
+  set_time_window(mw_data, time_window);
+
+  process_traceset_api(mw_data, time_window->start_time, 
+                      ltt_time_add(time_window->start_time,time_window->time_width),
+                      nb_events);
+
+  //call hooks to show each viewer and let them remove hooks
+  show_viewer(mw_data);  
+}
+
 void add_trace_into_traceset_selector(GtkMultiVPaned * paned, LttTrace * t)
 {
   int j, nb_tracefile, nb_control, nb_per_cpu;
@@ -334,7 +366,8 @@ void add_trace(GtkWidget * widget, gpointer user_data)
       gtk_widget_destroy((GtkWidget*)file_selector);
       
       //update current tab
-      //      set_current_time(mw_data, &(mw_data->current_tab->current_time));
+      redraw_viewer(mw_data, &(mw_data->current_tab->time_window), G_MAXULONG);
+      set_current_time(mw_data,&(mw_data->current_tab->current_time));
       break;
     case GTK_RESPONSE_REJECT:
     case GTK_RESPONSE_CANCEL:
@@ -425,7 +458,8 @@ void remove_trace(GtkWidget * widget, gpointer user_data)
                            LTTV_TRACESET_CONTEXT(mw_data->current_tab->
                                      traceset_info->traceset_context),traceset);      
          //update current tab
-         //      set_current_time(mw_data, &(mw_data->current_tab->current_time));
+         redraw_viewer(mw_data, &(mw_data->current_tab->time_window), G_MAXULONG);
+         set_current_time(mw_data,&(mw_data->current_tab->current_time));
        }
        break;
       }
@@ -476,7 +510,8 @@ void zoom(GtkWidget * widget, double size)
     }
     time_window.start_time = time_s;    
   }
-  set_time_window(mw_data, &time_window);
+  redraw_viewer(mw_data, &time_window, G_MAXULONG);
+  set_current_time(mw_data,&(mw_data->current_tab->current_time));
   gtk_multi_vpaned_set_adjust(mw_data->current_tab->multi_vpaned, FALSE);
 }
 
index a53f7262fa4cd260d651633e1aa037759af1f6e1..ee167de98c0945a4895d9d9f1adf63a9332602d6 100644 (file)
@@ -57,6 +57,7 @@ static GSList *g_event_viewer_data_list = NULL ;
 /** hook functions for update time interval, current time ... */
 gboolean update_time_window(void * hook_data, void * call_data);
 gboolean update_current_time(void * hook_data, void * call_data);
+gboolean show_event_detail(void * hook_data, void * call_data);
 void remove_item_from_queue(GQueue * q, gboolean fromHead);
 void remove_all_items_from_queue(GQueue * q);
 
@@ -95,11 +96,11 @@ typedef struct _EventViewerData {
   unsigned     current_event_index;
   double       previous_value;            //value of the slide
   TimeInterval time_span;
- // LttTime      trace_start;
- // LttTime      trace_end;
   unsigned     start_event_index;        //the first event shown in the window
   unsigned     end_event_index;          //the last event shown in the window
-
+  unsigned     size;                     //maxi number of events loaded when instance the viewer
+  gboolean     shown;                    //indicate if event detail is shown or not
   //scroll window containing Tree View
   GtkWidget * scroll_win;
 
@@ -156,6 +157,8 @@ static void get_test_data(double time, guint list_height,
 
 void add_test_data(EventViewerData *event_viewer_data);
 
+static void update_raw_data_array(EventViewerData* event_viewer_data, unsigned size);
+
 static void get_events(EventViewerData* event_viewer_data, LttTime start, 
                       LttTime end, unsigned max_num_events, unsigned * real_num_events);
 static gboolean parse_event(void *hook_data, void *call_data);
@@ -259,7 +262,6 @@ gui_events(MainWindow *parent_window, LttvTracesetSelector * s,char* key )
   GtkCellRenderer *renderer;
   EventViewerData* event_viewer_data = g_new(EventViewerData,1) ;
   RawTraceData * data;
-  unsigned size;
 
   event_viewer_data->mw = parent_window;
   get_time_window(event_viewer_data->mw, &event_viewer_data->time_window);
@@ -273,6 +275,7 @@ gui_events(MainWindow *parent_window, LttvTracesetSelector * s,char* key )
 
   reg_update_time_window(update_time_window,event_viewer_data, event_viewer_data->mw);
   reg_update_current_time(update_current_time,event_viewer_data, event_viewer_data->mw);
+  reg_show_viewer(show_event_detail,event_viewer_data, event_viewer_data->mw);
 
   event_viewer_data->scroll_win = gtk_scrolled_window_new (NULL, NULL);
   gtk_widget_show ( event_viewer_data->scroll_win);
@@ -437,24 +440,23 @@ gui_events(MainWindow *parent_window, LttvTracesetSelector * s,char* key )
 
   event_viewer_data->append = TRUE;
 
-  start.tv_sec = 0;
-  start.tv_nsec = 0;
-  end.tv_sec = G_MAXULONG;
-  end.tv_nsec = G_MAXULONG;
-
-  get_events(event_viewer_data, start,end, RESERVE_SMALL_SIZE, &size);
-
   event_viewer_data->start_event_index = 0;
   event_viewer_data->end_event_index   = event_viewer_data->num_visible_events - 1;  
 
-  // Test data 
-  get_test_data(event_viewer_data->vadjust_c->value,
-               event_viewer_data->num_visible_events, 
-               event_viewer_data);
-
   /* Set the Selected Event */
   //  tree_v_set_cursor(event_viewer_data);
 
+  event_viewer_data->shown = FALSE;
+  event_viewer_data->size  = RESERVE_SMALL_SIZE;
+  g_object_set_data(
+                   G_OBJECT(event_viewer_data->hbox_v),
+                   MAX_NUMBER_EVENT,
+                   &event_viewer_data->size);
+  
+  g_object_set_data(
+                   G_OBJECT(event_viewer_data->hbox_v),
+                   TRACESET_TIME_SPAN,
+                   &event_viewer_data->time_span);
 
   g_object_set_data(
                    G_OBJECT(event_viewer_data->hbox_v),
@@ -769,6 +771,26 @@ void tree_v_size_request_cb (GtkWidget *widget, GtkRequisition *requisition, gpo
        
 }
 
+gboolean show_event_detail(void * hook_data, void * call_data)
+{
+  EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
+
+  if(event_viewer_data->shown == FALSE){
+    event_viewer_data->shown = TRUE;
+    update_raw_data_array(event_viewer_data, 
+                         event_viewer_data->raw_trace_data_queue_tmp->length);
+
+    get_test_data(event_viewer_data->vadjust_c->value,
+                 event_viewer_data->num_visible_events, 
+                 event_viewer_data);
+    //remove hooks from context
+    context_remove_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL,
+                            NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL);
+  }
+
+  return FALSE;
+}
+
 void get_test_data(double time_value, guint list_height, 
                   EventViewerData *event_viewer_data)
 {
@@ -1111,6 +1133,7 @@ gui_events_free(EventViewerData *event_viewer_data)
 
     unreg_update_time_window(update_time_window,event_viewer_data, event_viewer_data->mw);
     unreg_update_current_time(update_current_time,event_viewer_data, event_viewer_data->mw);
+    unreg_show_viewer(show_event_detail,event_viewer_data, event_viewer_data->mw);
 
     g_event_viewer_data_list = g_slist_remove(g_event_viewer_data_list, event_viewer_data);
     g_free(event_viewer_data);
@@ -1173,7 +1196,14 @@ int event_selected_hook(void *hook_data, void *call_data)
 gboolean update_time_window(void * hook_data, void * call_data)
 {
   EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
-  event_viewer_data->time_window = *(TimeWindow*)call_data;
+
+  if(event_viewer_data->shown == FALSE){
+    event_viewer_data->time_window = *(TimeWindow*)call_data;
+
+    //add hooks for process_traceset
+    context_add_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL,
+                         NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL);  
+  }
 
   return FALSE;
 }
@@ -1214,19 +1244,9 @@ void tree_v_grab_focus(GtkWidget *widget, gpointer data){
   set_focused_pane(mw, gtk_widget_get_parent(event_viewer_data->hbox_v));
 }
 
-void get_events(EventViewerData* event_viewer_data, LttTime start, 
-               LttTime end,unsigned max_num_events, unsigned * real_num_events)
+void update_raw_data_array(EventViewerData* event_viewer_data, unsigned size)
 {
-  int size;
   RawTraceData * data;
-  context_add_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL,
-                       NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL);
-  process_traceset_api(event_viewer_data->mw, start, end, max_num_events);
-  context_remove_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL,
-                          NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL);
-
-  size = event_viewer_data->raw_trace_data_queue_tmp->length;
-  *real_num_events = size;
   if(size > 0){
     int pid, tmpPid, i;
     GList * list, *tmpList;
@@ -1285,6 +1305,22 @@ void get_events(EventViewerData* event_viewer_data, LttTime start,
   }
 }
 
+void get_events(EventViewerData* event_viewer_data, LttTime start, 
+               LttTime end,unsigned max_num_events, unsigned * real_num_events)
+{
+  int size;
+  context_add_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL,
+                       NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL);
+  process_traceset_api(event_viewer_data->mw, start, end, max_num_events);
+  context_remove_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL,
+                          NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL);
+
+  size = event_viewer_data->raw_trace_data_queue_tmp->length;
+  *real_num_events = size;
+  
+  update_raw_data_array(event_viewer_data,size);
+}
+
 static void get_event_detail(LttEvent *e, LttField *f, GString * s)
 {
   LttType *type;
This page took 0.029092 seconds and 4 git commands to generate.