From 202f6c8f25f240e60e41792e631f9be93cce9166 Mon Sep 17 00:00:00 2001 From: yangxx Date: Tue, 18 Nov 2003 20:47:34 +0000 Subject: [PATCH] main window call process_traceset for each viewer git-svn-id: http://ltt.polymtl.ca/svn@337 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/include/lttv/common.h | 3 + ltt/branches/poly/include/lttv/gtkTraceSet.h | 35 +++++++ .../poly/lttv/modules/gui/API/gtkTraceSet.c | 65 +++++++++++++ .../lttv/modules/gui/mainWin/src/callbacks.c | 41 ++++++++- ltt/branches/poly/lttv/modules/guiEvents.c | 92 +++++++++++++------ 5 files changed, 205 insertions(+), 31 deletions(-) diff --git a/ltt/branches/poly/include/lttv/common.h b/ltt/branches/poly/include/lttv/common.h index 81bf7c63..b4ef29c8 100644 --- a/ltt/branches/poly/include/lttv/common.h +++ b/ltt/branches/poly/include/lttv/common.h @@ -6,6 +6,9 @@ #include #include +#define MAX_NUMBER_EVENT "MAX_NUMBER_EVENT" +#define TRACESET_TIME_SPAN "TRACESET_TIME_SPAN" + typedef struct _MainWindow MainWindow; typedef struct _Tab Tab; diff --git a/ltt/branches/poly/include/lttv/gtkTraceSet.h b/ltt/branches/poly/include/lttv/gtkTraceSet.h index f1df3436..2d7ed4dc 100644 --- a/ltt/branches/poly/include/lttv/gtkTraceSet.h +++ b/ltt/branches/poly/include/lttv/gtkTraceSet.h @@ -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 diff --git a/ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c b/ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c index 8aeca549..b079fb5a 100644 --- a/ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c +++ b/ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c @@ -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 diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c index fd708324..5fa2a787 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c @@ -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); } diff --git a/ltt/branches/poly/lttv/modules/guiEvents.c b/ltt/branches/poly/lttv/modules/guiEvents.c index a53f7262..ee167de9 100644 --- a/ltt/branches/poly/lttv/modules/guiEvents.c +++ b/ltt/branches/poly/lttv/modules/guiEvents.c @@ -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; -- 2.34.1