From a56a1ba44968b834968a8ab0f39d4f64eb6b5e5c Mon Sep 17 00:00:00 2001 From: compudj Date: Sat, 17 Jan 2004 03:49:03 +0000 Subject: [PATCH] retabulation 2 spaces git-svn-id: http://ltt.polymtl.ca/svn@389 04897980-b3bd-0310-b5e0-8ef037075253 --- .../lttv/modules/guiControlFlow/CFV-private.h | 54 +- .../poly/lttv/modules/guiControlFlow/CFV.c | 292 +-- .../lttv/modules/guiControlFlow/Draw_Item.c | 436 ++-- .../lttv/modules/guiControlFlow/Draw_Item.h | 160 +- .../lttv/modules/guiControlFlow/Drawing.c | 906 +++---- .../lttv/modules/guiControlFlow/Drawing.h | 70 +- .../lttv/modules/guiControlFlow/Event_Hooks.c | 2112 ++++++++--------- .../lttv/modules/guiControlFlow/Event_Hooks.h | 14 +- .../modules/guiControlFlow/Process_List.c | 856 +++---- .../modules/guiControlFlow/Process_List.h | 56 +- .../poly/lttv/modules/guiControlFlow/module.c | 58 +- 11 files changed, 2507 insertions(+), 2507 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV-private.h b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV-private.h index 1a745026..108259af 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV-private.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV-private.h @@ -5,33 +5,33 @@ struct _ControlFlowData { - GtkWidget *Scrolled_Window_VC; - MainWindow *Parent_Window; - - ProcessList *Process_List; - Drawing_t *Drawing; - - //GtkWidget *HBox_V; - //GtkWidget *Inside_HBox_V; - GtkWidget *HPaned; - - GtkAdjustment *VAdjust_C ; - - /* Trace information */ - //TraceSet *Trace_Set; - //TraceStatistics *Trace_Statistics; - - /* Shown events information */ - guint First_Event, Last_Event; - TimeWindow Time_Window; - LttTime Current_Time; - - - /* TEST DATA, TO BE READ FROM THE TRACE */ - gint Number_Of_Events ; - guint Currently_Selected_Event ; - gboolean Selected_Event ; - guint Number_Of_Process; + GtkWidget *Scrolled_Window_VC; + MainWindow *Parent_Window; + + ProcessList *Process_List; + Drawing_t *Drawing; + + //GtkWidget *HBox_V; + //GtkWidget *Inside_HBox_V; + GtkWidget *HPaned; + + GtkAdjustment *VAdjust_C ; + + /* Trace information */ + //TraceSet *Trace_Set; + //TraceStatistics *Trace_Statistics; + + /* Shown events information */ + guint First_Event, Last_Event; + TimeWindow Time_Window; + LttTime Current_Time; + + + /* TEST DATA, TO BE READ FROM THE TRACE */ + gint Number_Of_Events ; + guint Currently_Selected_Event ; + gboolean Selected_Event ; + guint Number_Of_Process; } ; diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c index d15b2c52..13a2bac9 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c @@ -29,119 +29,119 @@ extern GSList *gControl_Flow_Data_List; ControlFlowData * guicontrolflow(void) { - GtkWidget *Process_List_Widget, *Drawing_Widget;//, *button; - - ControlFlowData* Control_Flow_Data = g_new(ControlFlowData,1) ; - - /* Create the Drawing */ - Control_Flow_Data->Drawing = drawing_construct(Control_Flow_Data); - - Drawing_Widget = - drawing_get_widget(Control_Flow_Data->Drawing); - - /* TEST DATA, TO BE READ FROM THE TRACE */ - Control_Flow_Data->Number_Of_Events = 1000 ; - Control_Flow_Data->Currently_Selected_Event = FALSE ; - Control_Flow_Data->Selected_Event = 0; - Control_Flow_Data->Number_Of_Process = 10; - - /* FIXME register Event_Selected_Hook */ - - - - /* Create the Process list */ - Control_Flow_Data->Process_List = processlist_construct(); - - Process_List_Widget = - processlist_get_widget(Control_Flow_Data->Process_List); - - //Control_Flow_Data->Inside_HBox_V = gtk_hbox_new(0, 0); - Control_Flow_Data->HPaned = gtk_hpaned_new(); - - //gtk_box_pack_start( - // GTK_BOX(Control_Flow_Data->Inside_HBox_V), - // Process_List_Widget, FALSE, TRUE, 0); // FALSE TRUE - //gtk_box_pack_start( - // GTK_BOX(Control_Flow_Data->Inside_HBox_V), - // Drawing_Widget, TRUE, TRUE, 0); - - //button = gtk_button_new(); - //gtk_button_set_relief(button, GTK_RELIEF_NONE); - //gtk_container_set_border_width(GTK_CONTAINER(button),0); - //gtk_container_add(GTK_CONTAINER(button), Drawing_Widget); - gtk_paned_pack1(GTK_PANED(Control_Flow_Data->HPaned), Process_List_Widget, FALSE, TRUE); - gtk_paned_pack2(GTK_PANED(Control_Flow_Data->HPaned), Drawing_Widget, TRUE, TRUE); - - Control_Flow_Data->VAdjust_C = - GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */ - 0.0, /* Lower */ - 0.0, /* Upper */ - 0.0, /* Step inc. */ - 0.0, /* Page inc. */ - 0.0)); /* page size */ - - Control_Flow_Data->Scrolled_Window_VC = - gtk_scrolled_window_new (NULL, - Control_Flow_Data->VAdjust_C); - - gtk_scrolled_window_set_policy( - GTK_SCROLLED_WINDOW(Control_Flow_Data->Scrolled_Window_VC) , - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - - gtk_scrolled_window_add_with_viewport( - GTK_SCROLLED_WINDOW(Control_Flow_Data->Scrolled_Window_VC), - //Control_Flow_Data->Inside_HBox_V); - Control_Flow_Data->HPaned); - - //g_signal_connect (G_OBJECT (Control_Flow_Data->Drawing_Area_V), - // "expose_event", - // G_CALLBACK (expose_event_cb), - // Control_Flow_Data); - - - - //g_signal_connect (G_OBJECT (Control_Flow_Data->VAdjust_C), - // "value-changed", - // G_CALLBACK (v_scroll_cb), - // Control_Flow_Data); - - - /* Set the size of the drawing area */ - //Drawing_Resize(Drawing, h, w); - - /* Get trace statistics */ - //Control_Flow_Data->Trace_Statistics = get_trace_statistics(Trace); - - - gtk_widget_show(Drawing_Widget); - //gtk_widget_show(button); - gtk_widget_show(Process_List_Widget); - //gtk_widget_show(Control_Flow_Data->Inside_HBox_V); - gtk_widget_show(Control_Flow_Data->HPaned); - gtk_widget_show(Control_Flow_Data->Scrolled_Window_VC); - - g_object_set_data_full( - G_OBJECT(Control_Flow_Data->Scrolled_Window_VC), - "Control_Flow_Data", - Control_Flow_Data, - (GDestroyNotify)guicontrolflow_destructor); - - g_object_set_data( - G_OBJECT(Drawing_Widget), - "Control_Flow_Data", - Control_Flow_Data); - - gControl_Flow_Data_List = g_slist_append( - gControl_Flow_Data_List, - Control_Flow_Data); - - //WARNING : The widget must be - //inserted in the main window before the Drawing area - //can be configured (and this must happend bedore sending - //data) - - return Control_Flow_Data; + GtkWidget *Process_List_Widget, *Drawing_Widget;//, *button; + + ControlFlowData* Control_Flow_Data = g_new(ControlFlowData,1) ; + + /* Create the Drawing */ + Control_Flow_Data->Drawing = drawing_construct(Control_Flow_Data); + + Drawing_Widget = + drawing_get_widget(Control_Flow_Data->Drawing); + + /* TEST DATA, TO BE READ FROM THE TRACE */ + Control_Flow_Data->Number_Of_Events = 1000 ; + Control_Flow_Data->Currently_Selected_Event = FALSE ; + Control_Flow_Data->Selected_Event = 0; + Control_Flow_Data->Number_Of_Process = 10; + + /* FIXME register Event_Selected_Hook */ + + + + /* Create the Process list */ + Control_Flow_Data->Process_List = processlist_construct(); + + Process_List_Widget = + processlist_get_widget(Control_Flow_Data->Process_List); + + //Control_Flow_Data->Inside_HBox_V = gtk_hbox_new(0, 0); + Control_Flow_Data->HPaned = gtk_hpaned_new(); + + //gtk_box_pack_start( + // GTK_BOX(Control_Flow_Data->Inside_HBox_V), + // Process_List_Widget, FALSE, TRUE, 0); // FALSE TRUE + //gtk_box_pack_start( + // GTK_BOX(Control_Flow_Data->Inside_HBox_V), + // Drawing_Widget, TRUE, TRUE, 0); + + //button = gtk_button_new(); + //gtk_button_set_relief(button, GTK_RELIEF_NONE); + //gtk_container_set_border_width(GTK_CONTAINER(button),0); + //gtk_container_add(GTK_CONTAINER(button), Drawing_Widget); + gtk_paned_pack1(GTK_PANED(Control_Flow_Data->HPaned), Process_List_Widget, FALSE, TRUE); + gtk_paned_pack2(GTK_PANED(Control_Flow_Data->HPaned), Drawing_Widget, TRUE, TRUE); + + Control_Flow_Data->VAdjust_C = + GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */ + 0.0, /* Lower */ + 0.0, /* Upper */ + 0.0, /* Step inc. */ + 0.0, /* Page inc. */ + 0.0)); /* page size */ + + Control_Flow_Data->Scrolled_Window_VC = + gtk_scrolled_window_new (NULL, + Control_Flow_Data->VAdjust_C); + + gtk_scrolled_window_set_policy( + GTK_SCROLLED_WINDOW(Control_Flow_Data->Scrolled_Window_VC) , + GTK_POLICY_NEVER, + GTK_POLICY_AUTOMATIC); + + gtk_scrolled_window_add_with_viewport( + GTK_SCROLLED_WINDOW(Control_Flow_Data->Scrolled_Window_VC), + //Control_Flow_Data->Inside_HBox_V); + Control_Flow_Data->HPaned); + + //g_signal_connect (G_OBJECT (Control_Flow_Data->Drawing_Area_V), + // "expose_event", + // G_CALLBACK (expose_event_cb), + // Control_Flow_Data); + + + + //g_signal_connect (G_OBJECT (Control_Flow_Data->VAdjust_C), + // "value-changed", + // G_CALLBACK (v_scroll_cb), + // Control_Flow_Data); + + + /* Set the size of the drawing area */ + //Drawing_Resize(Drawing, h, w); + + /* Get trace statistics */ + //Control_Flow_Data->Trace_Statistics = get_trace_statistics(Trace); + + + gtk_widget_show(Drawing_Widget); + //gtk_widget_show(button); + gtk_widget_show(Process_List_Widget); + //gtk_widget_show(Control_Flow_Data->Inside_HBox_V); + gtk_widget_show(Control_Flow_Data->HPaned); + gtk_widget_show(Control_Flow_Data->Scrolled_Window_VC); + + g_object_set_data_full( + G_OBJECT(Control_Flow_Data->Scrolled_Window_VC), + "Control_Flow_Data", + Control_Flow_Data, + (GDestroyNotify)guicontrolflow_destructor); + + g_object_set_data( + G_OBJECT(Drawing_Widget), + "Control_Flow_Data", + Control_Flow_Data); + + gControl_Flow_Data_List = g_slist_append( + gControl_Flow_Data_List, + Control_Flow_Data); + + //WARNING : The widget must be + //inserted in the main window before the Drawing area + //can be configured (and this must happend bedore sending + //data) + + return Control_Flow_Data; } @@ -149,60 +149,60 @@ guicontrolflow(void) void 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_VC)) - gtk_widget_destroy(Control_Flow_Data->Scrolled_Window_VC); - //Control_Flow_Data->Parent_Window = NULL; - //FIXME guicontrolflow_destructor(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_VC)) + gtk_widget_destroy(Control_Flow_Data->Scrolled_Window_VC); + //Control_Flow_Data->Parent_Window = NULL; + //FIXME guicontrolflow_destructor(Control_Flow_Data); } /* When this destructor is called, the widgets are already disconnected */ void guicontrolflow_destructor(ControlFlowData *Control_Flow_Data) { - guint index; - - 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->Parent_Window); - if(GTK_IS_WIDGET(Control_Flow_Data->Scrolled_Window_VC)) - g_info("widget still exists"); - - /* Process List is removed with it's widget */ - //ProcessList_destroy(Control_Flow_Data->Process_List); - if(Control_Flow_Data->Parent_Window != NULL) - { - unreg_update_time_window(update_time_window_hook, - Control_Flow_Data, - Control_Flow_Data->Parent_Window); - - unreg_update_current_time(update_current_time_hook, - Control_Flow_Data, - Control_Flow_Data->Parent_Window); - } - g_info("CFV.c : guicontrolflow_destructor, %p", Control_Flow_Data); - g_slist_remove(gControl_Flow_Data_List,Control_Flow_Data); - g_free(Control_Flow_Data); + guint index; + + 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->Parent_Window); + if(GTK_IS_WIDGET(Control_Flow_Data->Scrolled_Window_VC)) + g_info("widget still exists"); + + /* Process List is removed with it's widget */ + //ProcessList_destroy(Control_Flow_Data->Process_List); + if(Control_Flow_Data->Parent_Window != NULL) + { + unreg_update_time_window(update_time_window_hook, + Control_Flow_Data, + Control_Flow_Data->Parent_Window); + + unreg_update_current_time(update_current_time_hook, + Control_Flow_Data, + Control_Flow_Data->Parent_Window); + } + g_info("CFV.c : guicontrolflow_destructor, %p", Control_Flow_Data); + g_slist_remove(gControl_Flow_Data_List,Control_Flow_Data); + g_free(Control_Flow_Data); } GtkWidget *guicontrolflow_get_widget(ControlFlowData *Control_Flow_Data) { - return Control_Flow_Data->Scrolled_Window_VC ; + return Control_Flow_Data->Scrolled_Window_VC ; } ProcessList *guicontrolflow_get_process_list - (ControlFlowData *Control_Flow_Data) + (ControlFlowData *Control_Flow_Data) { - return Control_Flow_Data->Process_List ; + return Control_Flow_Data->Process_List ; } TimeWindow *guicontrolflow_get_time_window(ControlFlowData *Control_Flow_Data) { - return &Control_Flow_Data->Time_Window; + return &Control_Flow_Data->Time_Window; } LttTime *guicontrolflow_get_current_time(ControlFlowData *Control_Flow_Data) { - return &Control_Flow_Data->Current_Time; + return &Control_Flow_Data->Current_Time; } diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c index c73aee01..35be232b 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c @@ -93,55 +93,55 @@ /* Drawing hook functions */ gboolean draw_text( void *hook_data, void *call_data) { - PropertiesText *Properties = (PropertiesText*)hook_data; - DrawContext *Draw_Context = (DrawContext*)call_data; - - PangoContext *context; - PangoLayout *layout; - PangoAttribute *attribute; - PangoFontDescription *FontDesc;// = pango_font_description_new(); - gint Font_Size; - PangoRectangle ink_rect; - - layout = Draw_Context->pango_layout; - - context = pango_layout_get_context(layout); - FontDesc = pango_context_get_font_description(context); - - pango_font_description_set_size(FontDesc, Properties->size*PANGO_SCALE); - pango_layout_context_changed(layout); - - pango_layout_set_text(layout, Properties->Text, -1); - pango_layout_get_pixel_extents(layout, &ink_rect, NULL); - switch(Properties->position) { - case OVER: - gdk_draw_layout_with_colors(Draw_Context->drawable, - Draw_Context->gc, - Draw_Context->Current->modify_over->x, - Draw_Context->Current->modify_over->y, - layout, Properties->foreground, Properties->background); - Draw_Context->Current->modify_over->x += ink_rect.width; - - break; - case MIDDLE: - gdk_draw_layout_with_colors(Draw_Context->drawable, - Draw_Context->gc, - Draw_Context->Current->modify_middle->x, - Draw_Context->Current->modify_middle->y, - layout, Properties->foreground, Properties->background); - Draw_Context->Current->modify_middle->x += ink_rect.width; - break; - case UNDER: - gdk_draw_layout_with_colors(Draw_Context->drawable, - Draw_Context->gc, - Draw_Context->Current->modify_under->x, - Draw_Context->Current->modify_under->y, - layout, Properties->foreground, Properties->background); - Draw_Context->Current->modify_under->x += ink_rect.width; - break; - } - - return 0; + PropertiesText *Properties = (PropertiesText*)hook_data; + DrawContext *Draw_Context = (DrawContext*)call_data; + + PangoContext *context; + PangoLayout *layout; + PangoAttribute *attribute; + PangoFontDescription *FontDesc;// = pango_font_description_new(); + gint Font_Size; + PangoRectangle ink_rect; + + layout = Draw_Context->pango_layout; + + context = pango_layout_get_context(layout); + FontDesc = pango_context_get_font_description(context); + + pango_font_description_set_size(FontDesc, Properties->size*PANGO_SCALE); + pango_layout_context_changed(layout); + + pango_layout_set_text(layout, Properties->Text, -1); + pango_layout_get_pixel_extents(layout, &ink_rect, NULL); + switch(Properties->position) { + case OVER: + gdk_draw_layout_with_colors(Draw_Context->drawable, + Draw_Context->gc, + Draw_Context->Current->modify_over->x, + Draw_Context->Current->modify_over->y, + layout, Properties->foreground, Properties->background); + Draw_Context->Current->modify_over->x += ink_rect.width; + + break; + case MIDDLE: + gdk_draw_layout_with_colors(Draw_Context->drawable, + Draw_Context->gc, + Draw_Context->Current->modify_middle->x, + Draw_Context->Current->modify_middle->y, + layout, Properties->foreground, Properties->background); + Draw_Context->Current->modify_middle->x += ink_rect.width; + break; + case UNDER: + gdk_draw_layout_with_colors(Draw_Context->drawable, + Draw_Context->gc, + Draw_Context->Current->modify_under->x, + Draw_Context->Current->modify_under->y, + layout, Properties->foreground, Properties->background); + Draw_Context->Current->modify_under->x += ink_rect.width; + break; + } + + return 0; } @@ -150,196 +150,196 @@ gboolean draw_text( void *hook_data, void *call_data) */ gboolean draw_icon( void *hook_data, void *call_data) { - PropertiesIcon *Properties = (PropertiesIcon*)hook_data; - DrawContext *Draw_Context = (DrawContext*)call_data; + PropertiesIcon *Properties = (PropertiesIcon*)hook_data; + DrawContext *Draw_Context = (DrawContext*)call_data; LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); - LttvAttributeValue value; - gchar icon_name[MAX_PATH_LEN] = "icons/"; - IconStruct *icon_info; + LttvAttributeValue value; + gchar icon_name[MAX_PATH_LEN] = "icons/"; + IconStruct *icon_info; - strcat(icon_name, Properties->icon_name); - + strcat(icon_name, Properties->icon_name); + g_assert(lttv_iattribute_find_by_path(attributes, icon_name, LTTV_POINTER, &value)); - if(*(value.v_pointer) == NULL) - { - *(value.v_pointer) = icon_info = g_new(IconStruct,1); - - icon_info->pixmap = gdk_pixmap_create_from_xpm(Draw_Context->drawable, - &icon_info->mask, NULL, Properties->icon_name); - } - else - { - icon_info = *(value.v_pointer); - } - - gdk_gc_set_clip_mask(Draw_Context->gc, icon_info->mask); - - switch(Properties->position) { - case OVER: - gdk_gc_set_clip_origin( - Draw_Context->gc, - Draw_Context->Current->modify_over->x, - Draw_Context->Current->modify_over->y); - gdk_draw_drawable(Draw_Context->drawable, - Draw_Context->gc, - icon_info->pixmap, - 0, 0, - Draw_Context->Current->modify_over->x, - Draw_Context->Current->modify_over->y, - Properties->width, Properties->height); - - Draw_Context->Current->modify_over->x += Properties->width; - - break; - case MIDDLE: - gdk_gc_set_clip_origin( - Draw_Context->gc, - Draw_Context->Current->modify_middle->x, - Draw_Context->Current->modify_middle->y); - gdk_draw_drawable(Draw_Context->drawable, - Draw_Context->gc, - icon_info->pixmap, - 0, 0, - Draw_Context->Current->modify_middle->x, - Draw_Context->Current->modify_middle->y, - Properties->width, Properties->height); - - Draw_Context->Current->modify_middle->x += Properties->width; - break; - case UNDER: - gdk_gc_set_clip_origin( - Draw_Context->gc, - Draw_Context->Current->modify_under->x, - Draw_Context->Current->modify_under->y); - gdk_draw_drawable(Draw_Context->drawable, - Draw_Context->gc, - icon_info->pixmap, - 0, 0, - Draw_Context->Current->modify_under->x, - Draw_Context->Current->modify_under->y, - Properties->width, Properties->height); - - Draw_Context->Current->modify_under->x += Properties->width; - break; - } - - gdk_gc_set_clip_origin(Draw_Context->gc, 0, 0); - gdk_gc_set_clip_mask(Draw_Context->gc, NULL); - - return 0; + if(*(value.v_pointer) == NULL) + { + *(value.v_pointer) = icon_info = g_new(IconStruct,1); + + icon_info->pixmap = gdk_pixmap_create_from_xpm(Draw_Context->drawable, + &icon_info->mask, NULL, Properties->icon_name); + } + else + { + icon_info = *(value.v_pointer); + } + + gdk_gc_set_clip_mask(Draw_Context->gc, icon_info->mask); + + switch(Properties->position) { + case OVER: + gdk_gc_set_clip_origin( + Draw_Context->gc, + Draw_Context->Current->modify_over->x, + Draw_Context->Current->modify_over->y); + gdk_draw_drawable(Draw_Context->drawable, + Draw_Context->gc, + icon_info->pixmap, + 0, 0, + Draw_Context->Current->modify_over->x, + Draw_Context->Current->modify_over->y, + Properties->width, Properties->height); + + Draw_Context->Current->modify_over->x += Properties->width; + + break; + case MIDDLE: + gdk_gc_set_clip_origin( + Draw_Context->gc, + Draw_Context->Current->modify_middle->x, + Draw_Context->Current->modify_middle->y); + gdk_draw_drawable(Draw_Context->drawable, + Draw_Context->gc, + icon_info->pixmap, + 0, 0, + Draw_Context->Current->modify_middle->x, + Draw_Context->Current->modify_middle->y, + Properties->width, Properties->height); + + Draw_Context->Current->modify_middle->x += Properties->width; + break; + case UNDER: + gdk_gc_set_clip_origin( + Draw_Context->gc, + Draw_Context->Current->modify_under->x, + Draw_Context->Current->modify_under->y); + gdk_draw_drawable(Draw_Context->drawable, + Draw_Context->gc, + icon_info->pixmap, + 0, 0, + Draw_Context->Current->modify_under->x, + Draw_Context->Current->modify_under->y, + Properties->width, Properties->height); + + Draw_Context->Current->modify_under->x += Properties->width; + break; + } + + gdk_gc_set_clip_origin(Draw_Context->gc, 0, 0); + gdk_gc_set_clip_mask(Draw_Context->gc, NULL); + + return 0; } gboolean draw_line( void *hook_data, void *call_data) { - PropertiesLine *Properties = (PropertiesLine*)hook_data; - DrawContext *Draw_Context = (DrawContext*)call_data; - //GdkGC *gc = gdk_gc_new(Draw_Context->drawable); - - //gdk_gc_set_foreground(Draw_Context->gc, Properties->color); - gdk_gc_set_rgb_fg_color(Draw_Context->gc, Properties->color); - //gdk_gc_set_foreground(gc, Properties->color); - gdk_gc_set_line_attributes( Draw_Context->gc, - Properties->line_width, - Properties->style, - GDK_CAP_BUTT, - GDK_JOIN_MITER); - - switch(Properties->position) { - case OVER: - drawing_draw_line( - NULL, Draw_Context->drawable, - Draw_Context->Previous->over->x, - Draw_Context->Previous->over->y, - Draw_Context->Current->over->x, - Draw_Context->Current->over->y, - Draw_Context->gc); - break; - case MIDDLE: - drawing_draw_line( - NULL, Draw_Context->drawable, - Draw_Context->Previous->middle->x, - Draw_Context->Previous->middle->y, - Draw_Context->Current->middle->x, - Draw_Context->Current->middle->y, - Draw_Context->gc); - break; - case UNDER: - drawing_draw_line( - NULL, Draw_Context->drawable, - Draw_Context->Previous->under->x, - Draw_Context->Previous->under->y, - Draw_Context->Current->under->x, - Draw_Context->Current->under->y, - Draw_Context->gc); - - break; - } - - //gdk_gc_unref(gc); - - return 0; + PropertiesLine *Properties = (PropertiesLine*)hook_data; + DrawContext *Draw_Context = (DrawContext*)call_data; + //GdkGC *gc = gdk_gc_new(Draw_Context->drawable); + + //gdk_gc_set_foreground(Draw_Context->gc, Properties->color); + gdk_gc_set_rgb_fg_color(Draw_Context->gc, Properties->color); + //gdk_gc_set_foreground(gc, Properties->color); + gdk_gc_set_line_attributes( Draw_Context->gc, + Properties->line_width, + Properties->style, + GDK_CAP_BUTT, + GDK_JOIN_MITER); + + switch(Properties->position) { + case OVER: + drawing_draw_line( + NULL, Draw_Context->drawable, + Draw_Context->Previous->over->x, + Draw_Context->Previous->over->y, + Draw_Context->Current->over->x, + Draw_Context->Current->over->y, + Draw_Context->gc); + break; + case MIDDLE: + drawing_draw_line( + NULL, Draw_Context->drawable, + Draw_Context->Previous->middle->x, + Draw_Context->Previous->middle->y, + Draw_Context->Current->middle->x, + Draw_Context->Current->middle->y, + Draw_Context->gc); + break; + case UNDER: + drawing_draw_line( + NULL, Draw_Context->drawable, + Draw_Context->Previous->under->x, + Draw_Context->Previous->under->y, + Draw_Context->Current->under->x, + Draw_Context->Current->under->y, + Draw_Context->gc); + + break; + } + + //gdk_gc_unref(gc); + + return 0; } gboolean draw_arc( void *hook_data, void *call_data) { - PropertiesArc *Properties = (PropertiesArc*)hook_data; - DrawContext *Draw_Context = (DrawContext*)call_data; - - //gdk_gc_set_foreground(Draw_Context->gc, Properties->color); - gdk_gc_set_rgb_fg_color(Draw_Context->gc, Properties->color); - - switch(Properties->position) { - case OVER: - gdk_draw_arc(Draw_Context->drawable, Draw_Context->gc, - Properties->filled, - Draw_Context->Current->modify_over->x, - Draw_Context->Current->modify_over->y, - Properties->size, Properties->size, 0, 360*64); - Draw_Context->Current->modify_over->x += Properties->size; - break; - case MIDDLE: - gdk_draw_arc(Draw_Context->drawable, Draw_Context->gc, - Properties->filled, - Draw_Context->Current->modify_middle->x, - Draw_Context->Current->modify_middle->y, - Properties->size, Properties->size, 0, 360*64); - Draw_Context->Current->modify_middle->x += Properties->size; - - break; - case UNDER: - gdk_draw_arc(Draw_Context->drawable, Draw_Context->gc, - Properties->filled, - Draw_Context->Current->modify_under->x, - Draw_Context->Current->modify_under->y, - Properties->size, Properties->size, 0, 360*64); - Draw_Context->Current->modify_under->x += Properties->size; - - break; - } - - - return 0; + PropertiesArc *Properties = (PropertiesArc*)hook_data; + DrawContext *Draw_Context = (DrawContext*)call_data; + + //gdk_gc_set_foreground(Draw_Context->gc, Properties->color); + gdk_gc_set_rgb_fg_color(Draw_Context->gc, Properties->color); + + switch(Properties->position) { + case OVER: + gdk_draw_arc(Draw_Context->drawable, Draw_Context->gc, + Properties->filled, + Draw_Context->Current->modify_over->x, + Draw_Context->Current->modify_over->y, + Properties->size, Properties->size, 0, 360*64); + Draw_Context->Current->modify_over->x += Properties->size; + break; + case MIDDLE: + gdk_draw_arc(Draw_Context->drawable, Draw_Context->gc, + Properties->filled, + Draw_Context->Current->modify_middle->x, + Draw_Context->Current->modify_middle->y, + Properties->size, Properties->size, 0, 360*64); + Draw_Context->Current->modify_middle->x += Properties->size; + + break; + case UNDER: + gdk_draw_arc(Draw_Context->drawable, Draw_Context->gc, + Properties->filled, + Draw_Context->Current->modify_under->x, + Draw_Context->Current->modify_under->y, + Properties->size, Properties->size, 0, 360*64); + Draw_Context->Current->modify_under->x += Properties->size; + + break; + } + + + return 0; } gboolean draw_bg( void *hook_data, void *call_data) { - PropertiesBG *Properties = (PropertiesBG*)hook_data; - DrawContext *Draw_Context = (DrawContext*)call_data; + PropertiesBG *Properties = (PropertiesBG*)hook_data; + DrawContext *Draw_Context = (DrawContext*)call_data; - //gdk_gc_set_foreground(Draw_Context->gc, Properties->color); - gdk_gc_set_rgb_fg_color(Draw_Context->gc, Properties->color); + //gdk_gc_set_foreground(Draw_Context->gc, Properties->color); + gdk_gc_set_rgb_fg_color(Draw_Context->gc, Properties->color); - gdk_draw_rectangle(Draw_Context->drawable, Draw_Context->gc, - TRUE, - Draw_Context->Previous->over->x, - Draw_Context->Previous->over->y, - Draw_Context->Current->over->x - Draw_Context->Previous->over->x, - Draw_Context->Previous->under->y); + gdk_draw_rectangle(Draw_Context->drawable, Draw_Context->gc, + TRUE, + Draw_Context->Previous->over->x, + Draw_Context->Previous->over->y, + Draw_Context->Current->over->x - Draw_Context->Previous->over->x, + Draw_Context->Previous->under->y); - return 0; + return 0; } diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h index ff332f49..0a36ddfc 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h @@ -20,12 +20,12 @@ typedef struct _PropertiesBG PropertiesBG; typedef enum _DrawableItems DrawableItems; enum _DrawableItems { - ITEM_TEXT, ITEM_ICON, ITEM_LINE, ITEM_POINT, ITEM_BACKGROUND + ITEM_TEXT, ITEM_ICON, ITEM_LINE, ITEM_POINT, ITEM_BACKGROUND }; typedef enum _RelPos { - OVER, MIDDLE, UNDER + OVER, MIDDLE, UNDER } RelPos; @@ -44,12 +44,12 @@ typedef enum _RelPos { struct _DrawContext { - GdkDrawable *drawable; - GdkGC *gc; - PangoLayout *pango_layout; + GdkDrawable *drawable; + GdkGC *gc; + PangoLayout *pango_layout; - DrawInfo *Current; - DrawInfo *Previous; + DrawInfo *Current; + DrawInfo *Previous; }; /* LttvExecutionState is accessible through the LttvTracefileState. Is has @@ -70,26 +70,26 @@ struct _DrawContext { * to get facility name and event name. */ struct _DrawInfo { - ItemInfo *over; - ItemInfo *middle; - ItemInfo *under; - - ItemInfo *modify_over; - ItemInfo *modify_middle; - ItemInfo *modify_under; - LttvProcessStatus status; + ItemInfo *over; + ItemInfo *middle; + ItemInfo *under; + + ItemInfo *modify_over; + ItemInfo *modify_middle; + ItemInfo *modify_under; + LttvProcessStatus status; }; struct _ItemInfo { - gint x, y; + gint x, y; }; /* * Structure used to keep information about icons. */ struct _IconStruct { - GdkPixmap *pixmap; - GdkBitmap *mask; + GdkPixmap *pixmap; + GdkBitmap *mask; }; @@ -98,8 +98,8 @@ struct _IconStruct { * During drawing, only the Hook is needed. */ struct _DrawOperation { - DrawableItems Item; - LttvHooks *Hook; + DrawableItems Item; + LttvHooks *Hook; }; /* @@ -113,11 +113,11 @@ struct _DrawOperation { */ static int Items_Priorities[] = { - 50, /* ITEM_TEXT */ - 40, /* ITEM_ICON */ - 20, /* ITEM_LINE */ - 30, /* ITEM_POINT */ - 10 /* ITEM_BACKGROUND */ + 50, /* ITEM_TEXT */ + 40, /* ITEM_ICON */ + 20, /* ITEM_LINE */ + 30, /* ITEM_POINT */ + 10 /* ITEM_BACKGROUND */ }; /* @@ -128,47 +128,47 @@ static int Items_Priorities[] = { */ struct _PropertiesText { - GdkColor *foreground; - GdkColor *background; - gint size; - gchar *Text; - RelPos position; + GdkColor *foreground; + GdkColor *background; + gint size; + gchar *Text; + RelPos position; }; struct _PropertiesIcon { - gchar *icon_name; - gint width; - gint height; - RelPos position; + gchar *icon_name; + gint width; + gint height; + RelPos position; }; struct _PropertiesLine { - GdkColor *color; - gint line_width; - GdkLineStyle style; - RelPos position; + GdkColor *color; + gint line_width; + GdkLineStyle style; + RelPos position; }; struct _PropertiesArc { - GdkColor *color; - gint size; /* We force circle by width = height */ - gboolean filled; - RelPos position; + GdkColor *color; + gint size; /* We force circle by width = height */ + gboolean filled; + RelPos position; }; struct _PropertiesBG { - GdkColor *color; + GdkColor *color; }; -void draw_item( GdkDrawable *drawable, - gint x, - gint y, - LttvTraceState *ts, - LttvTracefileState *tfs, - LttvIAttribute *attributes); +void draw_item( GdkDrawable *drawable, + gint x, + gint y, + LttvTraceState *ts, + LttvTracefileState *tfs, + LttvIAttribute *attributes); /* * The tree of attributes used to store drawing operations goes like this : @@ -194,34 +194,34 @@ void draw_item( GdkDrawable *drawable, * The add_operation has to do a quick sort by priority to keep the operations * in the right order. */ -void add_operation( LttvIAttribute *attributes, - gchar *pathname, - DrawOperation *Operation); +void add_operation( LttvIAttribute *attributes, + gchar *pathname, + DrawOperation *Operation); /* * The del_operation seeks the array present at pathname (if any) and * removes the DrawOperation if present. It returns 0 on success, -1 * if it fails. */ -gint del_operation( LttvIAttribute *attributes, - gchar *pathname, - DrawOperation *Operation); +gint del_operation( LttvIAttribute *attributes, + gchar *pathname, + DrawOperation *Operation); /* * The clean_operations removes all operations present at a pathname. * returns 0 on success, -1 if it fails. */ -gint clean_operations( LttvIAttribute *attributes, - gchar *pathname ); +gint clean_operations( LttvIAttribute *attributes, + gchar *pathname ); /* * The list_operations gives a pointer to the operation array associated * with the pathname. It will be NULL if no operation is present. */ -void list_operations( LttvIAttribute *attributes, - gchar *pathname, - GArray **Operation); +void list_operations( LttvIAttribute *attributes, + gchar *pathname, + GArray **Operation); @@ -229,8 +229,8 @@ void list_operations( LttvIAttribute *attributes, * exec_operation executes the operations if present in the attributes, or * do nothing if not present. */ -void exec_operations( LttvIAttribute *attributes, - gchar *pathname); +void exec_operations( LttvIAttribute *attributes, + gchar *pathname); /* @@ -238,32 +238,32 @@ void exec_operations( LttvIAttribute *attributes, */ PropertiesText *properties_text_create( - GdkColor *foreground, - GdkColor *background, - gint size, - gchar *Text, - RelPos position); + GdkColor *foreground, + GdkColor *background, + gint size, + gchar *Text, + RelPos position); PropertiesIcon *properties_icon_create( - gchar *icon_name, - gint width, - gint height, - RelPos position); + gchar *icon_name, + gint width, + gint height, + RelPos position); PropertiesLine *properties_line_create( - GdkColor *color, - gint line_width, - GdkLineStyle style, - RelPos position); + GdkColor *color, + gint line_width, + GdkLineStyle style, + RelPos position); PropertiesArc *properties_arc_create( - GdkColor *color, - gint size, - gboolean filled, - RelPos position); + GdkColor *color, + gint size, + gboolean filled, + RelPos position); PropertiesBG *properties_bg_create( - GdkColor *color); + GdkColor *color); diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c index 0d666cee..9242cbe1 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c @@ -21,22 +21,22 @@ //FIXME Colors will need to be dynamic. Graphic context part not done so far. typedef enum { - RED, - GREEN, - BLUE, - WHITE, - BLACK + RED, + GREEN, + BLUE, + WHITE, + BLACK } ControlFlowColors; /* Vector of unallocated colors */ static GdkColor CF_Colors [] = { - { 0, 0xffff, 0x0000, 0x0000 }, // RED - { 0, 0x0000, 0xffff, 0x0000 }, // GREEN - { 0, 0x0000, 0x0000, 0xffff }, // BLUE - { 0, 0xffff, 0xffff, 0xffff }, // WHITE - { 0, 0x0000, 0x0000, 0x0000 } // BLACK + { 0, 0xffff, 0x0000, 0x0000 }, // RED + { 0, 0x0000, 0xffff, 0x0000 }, // GREEN + { 0, 0x0000, 0x0000, 0xffff }, // BLUE + { 0, 0xffff, 0xffff, 0xffff }, // WHITE + { 0, 0x0000, 0x0000, 0x0000 } // BLACK }; @@ -46,97 +46,97 @@ static GdkColor CF_Colors [] = * erase drawing already present (SAFETY). */ void drawing_data_request(Drawing_t *Drawing, - GdkPixmap **Pixmap, - gint x, gint y, - gint width, - gint height) + GdkPixmap **Pixmap, + gint x, gint y, + gint width, + gint height) { if(width < 0) return ; if(height < 0) return ; - ControlFlowData *control_flow_data = - (ControlFlowData*)g_object_get_data( - G_OBJECT( - Drawing->Drawing_Area_V), - "Control_Flow_Data"); - - LttTime start, end; - LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, - control_flow_data->Time_Window.start_time); - - g_critical("req : window_end : %u, %u", window_end.tv_sec, - window_end.tv_nsec); - - g_critical("req : time width : %u, %u", control_flow_data->Time_Window.time_width.tv_sec, - control_flow_data->Time_Window.time_width.tv_nsec); - - g_critical("x is : %i, x+width is : %i", x, x+width); - - convert_pixels_to_time(Drawing->Drawing_Area_V->allocation.width, x, - &control_flow_data->Time_Window.start_time, - &window_end, - &start); - - convert_pixels_to_time(Drawing->Drawing_Area_V->allocation.width, x + width, - &control_flow_data->Time_Window.start_time, - &window_end, - &end); - - LttvTracesetContext * tsc = - get_traceset_context(control_flow_data->Parent_Window); - + ControlFlowData *control_flow_data = + (ControlFlowData*)g_object_get_data( + G_OBJECT( + Drawing->Drawing_Area_V), + "Control_Flow_Data"); + + LttTime start, end; + LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, + control_flow_data->Time_Window.start_time); + + g_critical("req : window_end : %u, %u", window_end.tv_sec, + window_end.tv_nsec); + + g_critical("req : time width : %u, %u", control_flow_data->Time_Window.time_width.tv_sec, + control_flow_data->Time_Window.time_width.tv_nsec); + + g_critical("x is : %i, x+width is : %i", x, x+width); + + convert_pixels_to_time(Drawing->Drawing_Area_V->allocation.width, x, + &control_flow_data->Time_Window.start_time, + &window_end, + &start); + + convert_pixels_to_time(Drawing->Drawing_Area_V->allocation.width, x + width, + &control_flow_data->Time_Window.start_time, + &window_end, + &end); + + LttvTracesetContext * tsc = + get_traceset_context(control_flow_data->Parent_Window); + //send_test_process( - //guicontrolflow_get_process_list(Drawing->Control_Flow_Data), - //Drawing); + //guicontrolflow_get_process_list(Drawing->Control_Flow_Data), + //Drawing); //send_test_drawing( - //guicontrolflow_get_process_list(Drawing->Control_Flow_Data), - //Drawing, *Pixmap, x, y, width, height); - - // Let's call processTrace() !! - EventRequest event_request; // Variable freed at the end of the function. - event_request.Control_Flow_Data = control_flow_data; - event_request.time_begin = start; - event_request.time_end = end; - event_request.x_begin = x; - event_request.x_end = x+width; - - g_critical("req : start : %u, %u", event_request.time_begin.tv_sec, - event_request.time_begin.tv_nsec); - - g_critical("req : end : %u, %u", event_request.time_end.tv_sec, - event_request.time_end.tv_nsec); - - LttvHooks *event = lttv_hooks_new(); - LttvHooks *after_event = lttv_hooks_new(); - LttvHooks *after_traceset = lttv_hooks_new(); - lttv_hooks_add(after_traceset, after_data_request, &event_request); - lttv_hooks_add(event, draw_event_hook, &event_request); - //Modified by xiangxiu: state update hooks are added by the main window - //state_add_event_hooks_api(control_flow_data->Parent_Window); - lttv_hooks_add(after_event, draw_after_hook, &event_request); - - lttv_process_traceset_seek_time(tsc, 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, after_traceset, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, - NULL, after_traceset, NULL, event, after_event); - lttv_process_traceset(tsc, end, G_MAXULONG); - //after_data_request((void*)&event_request,(void*)tsc); - lttv_traceset_context_remove_hooks(tsc, - //NULL, after_traceset, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, - NULL, after_traceset, NULL, event, after_event); - //Modified by xiangxiu: state update hooks are removed by the main window - //state_remove_event_hooks_api(control_flow_data->Parent_Window); - - lttv_hooks_destroy(after_traceset); - lttv_hooks_destroy(event); - lttv_hooks_destroy(after_event); - - + //guicontrolflow_get_process_list(Drawing->Control_Flow_Data), + //Drawing, *Pixmap, x, y, width, height); + + // Let's call processTrace() !! + EventRequest event_request; // Variable freed at the end of the function. + event_request.Control_Flow_Data = control_flow_data; + event_request.time_begin = start; + event_request.time_end = end; + event_request.x_begin = x; + event_request.x_end = x+width; + + g_critical("req : start : %u, %u", event_request.time_begin.tv_sec, + event_request.time_begin.tv_nsec); + + g_critical("req : end : %u, %u", event_request.time_end.tv_sec, + event_request.time_end.tv_nsec); + + LttvHooks *event = lttv_hooks_new(); + LttvHooks *after_event = lttv_hooks_new(); + LttvHooks *after_traceset = lttv_hooks_new(); + lttv_hooks_add(after_traceset, after_data_request, &event_request); + lttv_hooks_add(event, draw_event_hook, &event_request); + //Modified by xiangxiu: state update hooks are added by the main window + //state_add_event_hooks_api(control_flow_data->Parent_Window); + lttv_hooks_add(after_event, draw_after_hook, &event_request); + + lttv_process_traceset_seek_time(tsc, 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, after_traceset, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, after_traceset, NULL, event, after_event); + lttv_process_traceset(tsc, end, G_MAXULONG); + //after_data_request((void*)&event_request,(void*)tsc); + lttv_traceset_context_remove_hooks(tsc, + //NULL, after_traceset, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, after_traceset, NULL, event, after_event); + //Modified by xiangxiu: state update hooks are removed by the main window + //state_remove_event_hooks_api(control_flow_data->Parent_Window); + + lttv_hooks_destroy(after_traceset); + lttv_hooks_destroy(event); + lttv_hooks_destroy(after_event); + + } - + /* Callbacks */ @@ -146,68 +146,68 @@ void drawing_data_request(Drawing_t *Drawing, */ static gboolean configure_event( GtkWidget *widget, GdkEventConfigure *event, - gpointer user_data) + gpointer user_data) { Drawing_t *Drawing = (Drawing_t*)user_data; - /* First, get the new time interval of the main window */ - /* we assume (see documentation) that the main window - * has updated the time interval before this configure gets - * executed. - */ - get_time_window(Drawing->Control_Flow_Data->Parent_Window, - &Drawing->Control_Flow_Data->Time_Window); - + /* First, get the new time interval of the main window */ + /* we assume (see documentation) that the main window + * has updated the time interval before this configure gets + * executed. + */ + get_time_window(Drawing->Control_Flow_Data->Parent_Window, + &Drawing->Control_Flow_Data->Time_Window); + /* New Pixmap, size of the configure event */ //GdkPixmap *Pixmap = gdk_pixmap_new(widget->window, - // widget->allocation.width + SAFETY, - // widget->allocation.height + SAFETY, - // -1); - + // widget->allocation.width + SAFETY, + // widget->allocation.height + SAFETY, + // -1); + g_critical("drawing configure event"); - g_critical("New draw size : %i by %i",widget->allocation.width, widget->allocation.height); - - - if (Drawing->Pixmap) + g_critical("New draw size : %i by %i",widget->allocation.width, widget->allocation.height); + + + if (Drawing->Pixmap) gdk_pixmap_unref(Drawing->Pixmap); - + /* If no old Pixmap present */ //if(Drawing->Pixmap == NULL) { - Drawing->Pixmap = gdk_pixmap_new( - widget->window, - widget->allocation.width + SAFETY, - widget->allocation.height + SAFETY, - //ProcessList_get_height - // (GuiControlFlow_get_Process_List(Drawing->Control_Flow_Data)), - -1); - Drawing->width = widget->allocation.width; - Drawing->height = widget->allocation.height; - - - // Clear the image - gdk_draw_rectangle (Drawing->Pixmap, - widget->style->white_gc, - TRUE, - 0, 0, - widget->allocation.width+SAFETY, - widget->allocation.height+SAFETY); - - //g_info("init data request"); - - - /* Initial data request */ - // Do not need to ask for data of 1 pixel : not synchronized with - // main window time at this moment. - drawing_data_request(Drawing, &Drawing->Pixmap, 0, 0, - widget->allocation.width, - widget->allocation.height); - - Drawing->width = widget->allocation.width; - Drawing->height = widget->allocation.height; - - return TRUE; + Drawing->Pixmap = gdk_pixmap_new( + widget->window, + widget->allocation.width + SAFETY, + widget->allocation.height + SAFETY, + //ProcessList_get_height + // (GuiControlFlow_get_Process_List(Drawing->Control_Flow_Data)), + -1); + Drawing->width = widget->allocation.width; + Drawing->height = widget->allocation.height; + + + // Clear the image + gdk_draw_rectangle (Drawing->Pixmap, + widget->style->white_gc, + TRUE, + 0, 0, + widget->allocation.width+SAFETY, + widget->allocation.height+SAFETY); + + //g_info("init data request"); + + + /* Initial data request */ + // Do not need to ask for data of 1 pixel : not synchronized with + // main window time at this moment. + drawing_data_request(Drawing, &Drawing->Pixmap, 0, 0, + widget->allocation.width, + widget->allocation.height); + + Drawing->width = widget->allocation.width; + Drawing->height = widget->allocation.height; + + return TRUE; @@ -215,55 +215,55 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event, #ifdef NOTUSE // /* Draw empty background */ // gdk_draw_rectangle (Pixmap, -// widget->style->black_gc, -// TRUE, -// 0, 0, -// widget->allocation.width, -// widget->allocation.height); - - /* Copy old data to new pixmap */ - gdk_draw_drawable (Pixmap, - widget->style->white_gc, - Drawing->Pixmap, - 0, 0, - 0, 0, - -1, -1); - +// widget->style->black_gc, +// TRUE, +// 0, 0, +// widget->allocation.width, +// widget->allocation.height); + + /* Copy old data to new pixmap */ + gdk_draw_drawable (Pixmap, + widget->style->white_gc, + Drawing->Pixmap, + 0, 0, + 0, 0, + -1, -1); + if (Drawing->Pixmap) gdk_pixmap_unref(Drawing->Pixmap); Drawing->Pixmap = Pixmap; - - // Clear the bottom part of the image (SAFETY) + + // Clear the bottom part of the image (SAFETY) gdk_draw_rectangle (Pixmap, - widget->style->white_gc, - TRUE, - 0, Drawing->height+SAFETY, - Drawing->width+SAFETY, // do not overlap - (widget->allocation.height) - Drawing->height); + widget->style->white_gc, + TRUE, + 0, Drawing->height+SAFETY, + Drawing->width+SAFETY, // do not overlap + (widget->allocation.height) - Drawing->height); - // Clear the right part of the image (SAFETY) + // Clear the right part of the image (SAFETY) gdk_draw_rectangle (Pixmap, - widget->style->white_gc, - TRUE, - Drawing->width+SAFETY, 0, - (widget->allocation.width) - Drawing->width, // do not overlap - Drawing->height+SAFETY); - - /* Clear the backgound for data request, but not SAFETY */ - gdk_draw_rectangle (Pixmap, - Drawing->Drawing_Area_V->style->white_gc, - TRUE, - Drawing->width + SAFETY, 0, - widget->allocation.width - Drawing->width, // do not overlap - widget->allocation.height+SAFETY); + widget->style->white_gc, + TRUE, + Drawing->width+SAFETY, 0, + (widget->allocation.width) - Drawing->width, // do not overlap + Drawing->height+SAFETY); + + /* Clear the backgound for data request, but not SAFETY */ + gdk_draw_rectangle (Pixmap, + Drawing->Drawing_Area_V->style->white_gc, + TRUE, + Drawing->width + SAFETY, 0, + widget->allocation.width - Drawing->width, // do not overlap + widget->allocation.height+SAFETY); /* Request data for missing space */ - g_info("missing data request"); + g_info("missing data request"); drawing_data_request(Drawing, &Pixmap, Drawing->width, 0, - widget->allocation.width - Drawing->width, - widget->allocation.height); - + widget->allocation.width - Drawing->width, + widget->allocation.height); + Drawing->width = widget->allocation.width; Drawing->height = widget->allocation.height; @@ -277,45 +277,45 @@ static gboolean expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) { Drawing_t *Drawing = (Drawing_t*)user_data; - ControlFlowData *control_flow_data = - (ControlFlowData*)g_object_get_data( - G_OBJECT(widget), - "Control_Flow_Data"); + ControlFlowData *control_flow_data = + (ControlFlowData*)g_object_get_data( + G_OBJECT(widget), + "Control_Flow_Data"); g_critical("drawing expose event"); - - guint x=0; - LttTime* Current_Time = - guicontrolflow_get_current_time(control_flow_data); - - LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, - control_flow_data->Time_Window.start_time); - - convert_time_to_pixels( - control_flow_data->Time_Window.start_time, - window_end, - *Current_Time, - widget->allocation.width, - &x); - + + guint x=0; + LttTime* Current_Time = + guicontrolflow_get_current_time(control_flow_data); + + LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, + control_flow_data->Time_Window.start_time); + + convert_time_to_pixels( + control_flow_data->Time_Window.start_time, + window_end, + *Current_Time, + widget->allocation.width, + &x); + gdk_draw_pixmap(widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - Drawing->Pixmap, - event->area.x, event->area.y, - event->area.x, event->area.y, - event->area.width, event->area.height); - - if(x >= event->area.x && x <= event->area.x+event->area.width) - { - GdkGC *gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); - gdk_gc_copy(gc, widget->style->black_gc); - - drawing_draw_line(NULL, widget->window, - x, event->area.y, - x, event->area.y+event->area.height, - gc); - gdk_gc_unref(gc); - } + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + Drawing->Pixmap, + event->area.x, event->area.y, + event->area.x, event->area.y, + event->area.width, event->area.height); + + if(x >= event->area.x && x <= event->area.x+event->area.width) + { + GdkGC *gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); + gdk_gc_copy(gc, widget->style->black_gc); + + drawing_draw_line(NULL, widget->window, + x, event->area.y, + x, event->area.y+event->area.height, + gc); + gdk_gc_unref(gc); + } return FALSE; } @@ -323,35 +323,35 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) static gboolean button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user_data ) { - ControlFlowData *control_flow_data = - (ControlFlowData*)g_object_get_data( - G_OBJECT(widget), - "Control_Flow_Data"); - Drawing_t *Drawing = control_flow_data->Drawing; + ControlFlowData *control_flow_data = + (ControlFlowData*)g_object_get_data( + G_OBJECT(widget), + "Control_Flow_Data"); + Drawing_t *Drawing = control_flow_data->Drawing; - g_critical("click"); - if(event->button == 1) - { - LttTime time; + g_critical("click"); + if(event->button == 1) + { + LttTime time; - LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, - control_flow_data->Time_Window.start_time); + LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, + control_flow_data->Time_Window.start_time); - /* left mouse button click */ - g_critical("x click is : %f", event->x); + /* left mouse button click */ + g_critical("x click is : %f", event->x); - convert_pixels_to_time(widget->allocation.width, (guint)event->x, - &control_flow_data->Time_Window.start_time, - &window_end, - &time); + convert_pixels_to_time(widget->allocation.width, (guint)event->x, + &control_flow_data->Time_Window.start_time, + &window_end, + &time); - set_current_time(control_flow_data->Parent_Window, &time); + set_current_time(control_flow_data->Parent_Window, &time); - } - - return FALSE; + } + + return FALSE; } @@ -359,78 +359,78 @@ button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user_data Drawing_t *drawing_construct(ControlFlowData *Control_Flow_Data) { - Drawing_t *Drawing = g_new(Drawing_t, 1); - - Drawing->Drawing_Area_V = gtk_drawing_area_new (); - Drawing->Control_Flow_Data = Control_Flow_Data; - - Drawing->pango_layout = - gtk_widget_create_pango_layout(Drawing->Drawing_Area_V, NULL); - - //gtk_widget_set_size_request(Drawing->Drawing_Area_V->window, 50, 50); - g_object_set_data_full( - G_OBJECT(Drawing->Drawing_Area_V), - "Link_Drawing_Data", - Drawing, - (GDestroyNotify)drawing_destroy); - - //gtk_widget_modify_bg( Drawing->Drawing_Area_V, - // GTK_STATE_NORMAL, - // &CF_Colors[BLACK]); - - //gdk_window_get_geometry(Drawing->Drawing_Area_V->window, - // NULL, NULL, - // &(Drawing->width), - // &(Drawing->height), - // -1); - - //Drawing->Pixmap = gdk_pixmap_new( - // Drawing->Drawing_Area_V->window, - // Drawing->width, - // Drawing->height, - // Drawing->depth); - - Drawing->Pixmap = NULL; - -// Drawing->Pixmap = gdk_pixmap_new(Drawing->Drawing_Area_V->window, -// Drawing->Drawing_Area_V->allocation.width, -// Drawing->Drawing_Area_V->allocation.height, -// -1); - - gtk_widget_add_events(Drawing->Drawing_Area_V, GDK_BUTTON_PRESS_MASK); - - g_signal_connect (G_OBJECT(Drawing->Drawing_Area_V), - "configure_event", - G_CALLBACK (configure_event), - (gpointer)Drawing); - - g_signal_connect (G_OBJECT(Drawing->Drawing_Area_V), - "expose_event", - G_CALLBACK (expose_event), - (gpointer)Drawing); - - g_signal_connect (G_OBJECT(Drawing->Drawing_Area_V), - "button-press-event", - G_CALLBACK (button_press_event), - (gpointer)Drawing); - - - return Drawing; + Drawing_t *Drawing = g_new(Drawing_t, 1); + + Drawing->Drawing_Area_V = gtk_drawing_area_new (); + Drawing->Control_Flow_Data = Control_Flow_Data; + + Drawing->pango_layout = + gtk_widget_create_pango_layout(Drawing->Drawing_Area_V, NULL); + + //gtk_widget_set_size_request(Drawing->Drawing_Area_V->window, 50, 50); + g_object_set_data_full( + G_OBJECT(Drawing->Drawing_Area_V), + "Link_Drawing_Data", + Drawing, + (GDestroyNotify)drawing_destroy); + + //gtk_widget_modify_bg( Drawing->Drawing_Area_V, + // GTK_STATE_NORMAL, + // &CF_Colors[BLACK]); + + //gdk_window_get_geometry(Drawing->Drawing_Area_V->window, + // NULL, NULL, + // &(Drawing->width), + // &(Drawing->height), + // -1); + + //Drawing->Pixmap = gdk_pixmap_new( + // Drawing->Drawing_Area_V->window, + // Drawing->width, + // Drawing->height, + // Drawing->depth); + + Drawing->Pixmap = NULL; + +// Drawing->Pixmap = gdk_pixmap_new(Drawing->Drawing_Area_V->window, +// Drawing->Drawing_Area_V->allocation.width, +// Drawing->Drawing_Area_V->allocation.height, +// -1); + + gtk_widget_add_events(Drawing->Drawing_Area_V, GDK_BUTTON_PRESS_MASK); + + g_signal_connect (G_OBJECT(Drawing->Drawing_Area_V), + "configure_event", + G_CALLBACK (configure_event), + (gpointer)Drawing); + + g_signal_connect (G_OBJECT(Drawing->Drawing_Area_V), + "expose_event", + G_CALLBACK (expose_event), + (gpointer)Drawing); + + g_signal_connect (G_OBJECT(Drawing->Drawing_Area_V), + "button-press-event", + G_CALLBACK (button_press_event), + (gpointer)Drawing); + + + return Drawing; } void drawing_destroy(Drawing_t *Drawing) { - // Do not unref here, Drawing_t destroyed by it's widget. - //g_object_unref( G_OBJECT(Drawing->Drawing_Area_V)); - - g_free(Drawing->pango_layout); - g_free(Drawing); + // Do not unref here, Drawing_t destroyed by it's widget. + //g_object_unref( G_OBJECT(Drawing->Drawing_Area_V)); + + g_free(Drawing->pango_layout); + g_free(Drawing); } GtkWidget *drawing_get_widget(Drawing_t *Drawing) { - return Drawing->Drawing_Area_V; + return Drawing->Drawing_Area_V; } /* convert_pixels_to_time @@ -438,77 +438,77 @@ GtkWidget *drawing_get_widget(Drawing_t *Drawing) * Convert from window pixel and time interval to an absolute time. */ void convert_pixels_to_time( - gint width, - guint x, - LttTime *window_time_begin, - LttTime *window_time_end, - LttTime *time) + gint width, + guint x, + LttTime *window_time_begin, + LttTime *window_time_end, + LttTime *time) { - LttTime window_time_interval; - - window_time_interval = ltt_time_sub(*window_time_end, + LttTime window_time_interval; + + window_time_interval = ltt_time_sub(*window_time_end, *window_time_begin); - *time = ltt_time_mul(window_time_interval, (x/(float)width)); - *time = ltt_time_add(*window_time_begin, *time); + *time = ltt_time_mul(window_time_interval, (x/(float)width)); + *time = ltt_time_add(*window_time_begin, *time); } void convert_time_to_pixels( - LttTime window_time_begin, - LttTime window_time_end, - LttTime time, - int width, - guint *x) + LttTime window_time_begin, + LttTime window_time_end, + LttTime time, + int width, + guint *x) { - LttTime window_time_interval; - float interval_float, time_float; - - 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); - - *x = (guint)(time_float/interval_float * width); - + LttTime window_time_interval; + float interval_float, time_float; + + 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); + + *x = (guint)(time_float/interval_float * width); + } -void drawing_refresh ( Drawing_t *Drawing, - guint x, guint y, - guint width, guint height) +void drawing_refresh ( Drawing_t *Drawing, + guint x, guint y, + guint width, guint height) { - g_info("Drawing.c : drawing_refresh %u, %u, %u, %u", x, y, width, height); - GdkRectangle update_rect; - - gdk_draw_drawable( - Drawing->Drawing_Area_V->window, - Drawing->Drawing_Area_V-> - style->fg_gc[GTK_WIDGET_STATE (Drawing->Drawing_Area_V)], - GDK_DRAWABLE(Drawing->Pixmap), - x, y, - x, y, - width, height); - - update_rect.x = 0 ; - update_rect.y = 0 ; - update_rect.width = Drawing->width; - update_rect.height = Drawing->height ; - gtk_widget_draw( Drawing->Drawing_Area_V, &update_rect); + g_info("Drawing.c : drawing_refresh %u, %u, %u, %u", x, y, width, height); + GdkRectangle update_rect; + + gdk_draw_drawable( + Drawing->Drawing_Area_V->window, + Drawing->Drawing_Area_V-> + style->fg_gc[GTK_WIDGET_STATE (Drawing->Drawing_Area_V)], + GDK_DRAWABLE(Drawing->Pixmap), + x, y, + x, y, + width, height); + + update_rect.x = 0 ; + update_rect.y = 0 ; + update_rect.width = Drawing->width; + update_rect.height = Drawing->height ; + gtk_widget_draw( Drawing->Drawing_Area_V, &update_rect); } -void drawing_draw_line( Drawing_t *Drawing, - GdkPixmap *Pixmap, - guint x1, guint y1, - guint x2, guint y2, - GdkGC *GC) +void drawing_draw_line( Drawing_t *Drawing, + GdkPixmap *Pixmap, + guint x1, guint y1, + guint x2, guint y2, + GdkGC *GC) { - gdk_draw_line (Pixmap, - GC, - x1, y1, x2, y2); + gdk_draw_line (Pixmap, + GC, + x1, y1, x2, y2); } @@ -516,125 +516,125 @@ void drawing_draw_line( Drawing_t *Drawing, void drawing_resize(Drawing_t *Drawing, guint h, guint w) { - Drawing->height = h ; - Drawing->width = w ; - - gtk_widget_set_size_request ( Drawing->Drawing_Area_V, - Drawing->width, - Drawing->height); - - + Drawing->height = h ; + Drawing->width = w ; + + gtk_widget_set_size_request ( Drawing->Drawing_Area_V, + Drawing->width, + Drawing->height); + + } /* Insert a square corresponding to a new process in the list */ /* Applies to whole Drawing->width */ void drawing_insert_square(Drawing_t *Drawing, - guint y, - guint height) + guint y, + guint height) { - //GdkRectangle update_rect; - - /* Allocate a new pixmap with new height */ - GdkPixmap *Pixmap = gdk_pixmap_new(Drawing->Drawing_Area_V->window, - Drawing->width + SAFETY, - Drawing->height + height + SAFETY, - -1); - - /* Copy the high region */ - gdk_draw_drawable (Pixmap, - Drawing->Drawing_Area_V->style->black_gc, - Drawing->Pixmap, - 0, 0, - 0, 0, - Drawing->width + SAFETY, y); + //GdkRectangle update_rect; + /* Allocate a new pixmap with new height */ + GdkPixmap *Pixmap = gdk_pixmap_new(Drawing->Drawing_Area_V->window, + Drawing->width + SAFETY, + Drawing->height + height + SAFETY, + -1); + + /* Copy the high region */ + gdk_draw_drawable (Pixmap, + Drawing->Drawing_Area_V->style->black_gc, + Drawing->Pixmap, + 0, 0, + 0, 0, + Drawing->width + SAFETY, y); - /* add an empty square */ - gdk_draw_rectangle (Pixmap, - Drawing->Drawing_Area_V->style->white_gc, - TRUE, - 0, y, - Drawing->width + SAFETY, // do not overlap - height); + /* add an empty square */ + gdk_draw_rectangle (Pixmap, + Drawing->Drawing_Area_V->style->white_gc, + TRUE, + 0, y, + Drawing->width + SAFETY, // do not overlap + height); - /* copy the bottom of the region */ - gdk_draw_drawable (Pixmap, - Drawing->Drawing_Area_V->style->black_gc, - Drawing->Pixmap, - 0, y, - 0, y + height, - Drawing->width+SAFETY, Drawing->height - y + SAFETY); + /* copy the bottom of the region */ + gdk_draw_drawable (Pixmap, + Drawing->Drawing_Area_V->style->black_gc, + Drawing->Pixmap, + 0, y, + 0, y + height, + Drawing->width+SAFETY, Drawing->height - y + SAFETY); - if (Drawing->Pixmap) - gdk_pixmap_unref(Drawing->Pixmap); - Drawing->Pixmap = Pixmap; - - Drawing->height+=height; + if (Drawing->Pixmap) + gdk_pixmap_unref(Drawing->Pixmap); - /* Rectangle to update, from new Drawing dimensions */ - //update_rect.x = 0 ; - //update_rect.y = y ; - //update_rect.width = Drawing->width; - //update_rect.height = Drawing->height - y ; - //gtk_widget_draw( Drawing->Drawing_Area_V, &update_rect); + Drawing->Pixmap = Pixmap; + + Drawing->height+=height; + + /* Rectangle to update, from new Drawing dimensions */ + //update_rect.x = 0 ; + //update_rect.y = y ; + //update_rect.width = Drawing->width; + //update_rect.height = Drawing->height - y ; + //gtk_widget_draw( Drawing->Drawing_Area_V, &update_rect); } /* Remove a square corresponding to a removed process in the list */ void drawing_remove_square(Drawing_t *Drawing, - guint y, - guint height) + guint y, + guint height) { - //GdkRectangle update_rect; - - /* Allocate a new pixmap with new height */ - GdkPixmap *Pixmap = gdk_pixmap_new( - Drawing->Drawing_Area_V->window, - Drawing->width + SAFETY, - Drawing->height - height + SAFETY, - -1); - - /* Copy the high region */ - gdk_draw_drawable (Pixmap, - Drawing->Drawing_Area_V->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_V->style->black_gc, - Drawing->Pixmap, - 0, y + height, - 0, y, - Drawing->width, Drawing->height - y - height + SAFETY); - - - if (Drawing->Pixmap) - gdk_pixmap_unref(Drawing->Pixmap); - - Drawing->Pixmap = Pixmap; - - Drawing->height-=height; - - /* Rectangle to update, from new Drawing dimensions */ - //update_rect.x = 0 ; - //update_rect.y = y ; - //update_rect.width = Drawing->width; - //update_rect.height = Drawing->height - y ; - //gtk_widget_draw( Drawing->Drawing_Area_V, &update_rect); + //GdkRectangle update_rect; + + /* Allocate a new pixmap with new height */ + GdkPixmap *Pixmap = gdk_pixmap_new( + Drawing->Drawing_Area_V->window, + Drawing->width + SAFETY, + Drawing->height - height + SAFETY, + -1); + + /* Copy the high region */ + gdk_draw_drawable (Pixmap, + Drawing->Drawing_Area_V->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_V->style->black_gc, + Drawing->Pixmap, + 0, y + height, + 0, y, + Drawing->width, Drawing->height - y - height + SAFETY); + + + if (Drawing->Pixmap) + gdk_pixmap_unref(Drawing->Pixmap); + + Drawing->Pixmap = Pixmap; + + Drawing->height-=height; + + /* Rectangle to update, from new Drawing dimensions */ + //update_rect.x = 0 ; + //update_rect.y = y ; + //update_rect.width = Drawing->width; + //update_rect.height = Drawing->height - y ; + //gtk_widget_draw( Drawing->Drawing_Area_V, &update_rect); } diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h index d2aa0a6a..01e906be 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h @@ -9,7 +9,7 @@ #include "Draw_Item.h" -#define SAFETY 50 // safety pixels at right and bottom of pixmap buffer +#define SAFETY 50 // safety pixels at right and bottom of pixmap buffer /* This part of the viewer does : * Draw horizontal lines, getting graphic context as arg. @@ -36,61 +36,61 @@ typedef struct _Drawing_t Drawing_t; struct _Drawing_t { - GtkWidget *Drawing_Area_V; - GdkPixmap *Pixmap; - ControlFlowData *Control_Flow_Data; - - PangoLayout *pango_layout; - - gint height, width, depth; - + GtkWidget *Drawing_Area_V; + GdkPixmap *Pixmap; + ControlFlowData *Control_Flow_Data; + + PangoLayout *pango_layout; + + gint height, width, depth; + }; Drawing_t *drawing_construct(ControlFlowData *Control_Flow_Data); void drawing_destroy(Drawing_t *Drawing); GtkWidget *drawing_get_widget(Drawing_t *Drawing); - -//void Drawing_Refresh ( Drawing_t *Drawing, -// guint x, guint y, -// guint width, guint height); + +//void Drawing_Refresh ( Drawing_t *Drawing, +// guint x, guint y, +// guint width, guint height); -void drawing_draw_line( Drawing_t *Drawing, - GdkPixmap *Pixmap, - guint x1, guint y1, - guint x2, guint y2, - GdkGC *GC); +void drawing_draw_line( Drawing_t *Drawing, + GdkPixmap *Pixmap, + guint x1, guint y1, + guint x2, guint y2, + GdkGC *GC); //void Drawing_copy( Drawing_t *Drawing, -// guint xsrc, guint ysrc, -// guint xdest, guint ydest, -// guint width, guint height); +// guint xsrc, guint ysrc, +// guint xdest, guint ydest, +// guint width, guint height); /* Insert a square corresponding to a new process in the list */ void drawing_insert_square(Drawing_t *Drawing, - guint y, - guint height); + guint y, + guint height); /* Remove a square corresponding to a removed process in the list */ void drawing_remove_square(Drawing_t *Drawing, - guint y, - guint height); + guint y, + guint height); //void Drawing_Resize(Drawing_t *Drawing, guint h, guint w); void convert_pixels_to_time( - gint width, - guint x, - LttTime *window_time_begin, - LttTime *window_time_end, - LttTime *time); + gint width, + guint x, + LttTime *window_time_begin, + LttTime *window_time_end, + LttTime *time); void convert_time_to_pixels( - LttTime window_time_begin, - LttTime window_time_end, - LttTime time, - gint width, - guint *x); + LttTime window_time_begin, + LttTime window_time_end, + LttTime time, + gint width, + guint *x); #endif // _DRAWING_H diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c index 1a6378b5..ee289196 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c @@ -46,48 +46,48 @@ GtkWidget * h_guicontrolflow(MainWindow *pmParentWindow, LttvTracesetSelector * s, char * key) { - g_info("h_guicontrolflow, %p, %p, %s", pmParentWindow, s, key); - ControlFlowData *Control_Flow_Data = guicontrolflow() ; - - Control_Flow_Data->Parent_Window = pmParentWindow; - TimeWindow *time_window = guicontrolflow_get_time_window(Control_Flow_Data); - time_window->start_time.tv_sec = 0; - time_window->start_time.tv_nsec = 0; - time_window->time_width.tv_sec = 0; - time_window->time_width.tv_nsec = 0; - - LttTime *current_time = guicontrolflow_get_current_time(Control_Flow_Data); - current_time->tv_sec = 0; - current_time->tv_nsec = 0; - - //g_critical("time width1 : %u",time_window->time_width); - - get_time_window(pmParentWindow, - time_window); - get_current_time(pmParentWindow, - current_time); - - //g_critical("time width2 : %u",time_window->time_width); - // Unreg done in the GuiControlFlow_Destructor - reg_update_time_window(update_time_window_hook, Control_Flow_Data, - pmParentWindow); - reg_update_current_time(update_current_time_hook, Control_Flow_Data, - pmParentWindow); - return guicontrolflow_get_widget(Control_Flow_Data) ; - + g_info("h_guicontrolflow, %p, %p, %s", pmParentWindow, s, key); + ControlFlowData *Control_Flow_Data = guicontrolflow() ; + + Control_Flow_Data->Parent_Window = pmParentWindow; + TimeWindow *time_window = guicontrolflow_get_time_window(Control_Flow_Data); + time_window->start_time.tv_sec = 0; + time_window->start_time.tv_nsec = 0; + time_window->time_width.tv_sec = 0; + time_window->time_width.tv_nsec = 0; + + LttTime *current_time = guicontrolflow_get_current_time(Control_Flow_Data); + current_time->tv_sec = 0; + current_time->tv_nsec = 0; + + //g_critical("time width1 : %u",time_window->time_width); + + get_time_window(pmParentWindow, + time_window); + get_current_time(pmParentWindow, + current_time); + + //g_critical("time width2 : %u",time_window->time_width); + // Unreg done in the GuiControlFlow_Destructor + reg_update_time_window(update_time_window_hook, Control_Flow_Data, + pmParentWindow); + reg_update_current_time(update_current_time_hook, Control_Flow_Data, + pmParentWindow); + return guicontrolflow_get_widget(Control_Flow_Data) ; + } int event_selected_hook(void *hook_data, void *call_data) { - ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data; - guint *Event_Number = (guint*) call_data; + ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data; + guint *Event_Number = (guint*) call_data; - g_critical("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); + g_critical("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); } @@ -96,12 +96,12 @@ 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; - //EventsContext Events_Context = (EventsContext*)call_data; - - //Event_Request->Events_Context = Events_Context; + EventRequest *Event_Request = (EventRequest*)hook_data; + //EventsContext Events_Context = (EventsContext*)call_data; + + //Event_Request->Events_Context = Events_Context; - return 0; + return 0; } /* @@ -126,362 +126,362 @@ 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; + EventRequest *Event_Request = (EventRequest*)hook_data; + ControlFlowData *control_flow_data = Event_Request->Control_Flow_Data; - LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; + LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; LttvTracefileState *tfs = (LttvTracefileState *)call_data; - + LttEvent *e; e = tfc->e; - if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) - { - g_critical("schedchange!"); - - /* Add process to process list (if not present) and get drawing "y" from - * process position */ - guint pid_out, pid_in; - LttvProcessState *process_out, *process_in; - LttTime birth; - guint y_in = 0, y_out = 0, height = 0, pl_height = 0; - - ProcessList *process_list = - guicontrolflow_get_process_list(Event_Request->Control_Flow_Data); - - - 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_critical("out : %u in : %u", pid_out, pid_in); - - - /* Find process pid_out in the list... */ - process_out = lttv_state_find_process(tfs, pid_out); - g_critical("out : %s",g_quark_to_string(process_out->state->s)); - - birth = process_out->creation_time; - gchar *name = strdup(g_quark_to_string(process_out->name)); - HashedProcessData *Hashed_Process_Data_out = NULL; - - if(processlist_get_process_pixels(process_list, - pid_out, - &birth, - &y_out, - &height, - &Hashed_Process_Data_out) == 1) - { - /* Process not present */ - processlist_add(process_list, - pid_out, - &birth, - name, - &pl_height, - &Hashed_Process_Data_out); - processlist_get_process_pixels(process_list, - pid_out, - &birth, - &y_out, - &height, - &Hashed_Process_Data_out); - drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y_out, height); - } - - g_free(name); - - /* Find process pid_in in the list... */ - process_in = lttv_state_find_process(tfs, pid_in); - g_critical("in : %s",g_quark_to_string(process_in->state->s)); - - birth = process_in->creation_time; - name = strdup(g_quark_to_string(process_in->name)); - HashedProcessData *Hashed_Process_Data_in = NULL; - - if(processlist_get_process_pixels(process_list, - pid_in, - &birth, - &y_in, - &height, - &Hashed_Process_Data_in) == 1) - { - /* Process not present */ - processlist_add(process_list, - pid_in, - &birth, - name, - &pl_height, - &Hashed_Process_Data_in); - processlist_get_process_pixels(process_list, - pid_in, - &birth, - &y_in, - &height, - &Hashed_Process_Data_in); - - drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y_in, height); - } - g_free(name); - - - /* Find pixels corresponding to time of the event. 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_V->allocation.width; - - LttTime time = ltt_event_time(e); - - LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, - control_flow_data->Time_Window.start_time); - - - convert_time_to_pixels( - control_flow_data->Time_Window.start_time, - window_end, - time, - width, - &x); - - assert(x <= width); - - /* draw what represents the event for outgoing process. */ - - DrawContext *draw_context_out = Hashed_Process_Data_out->draw_context; - draw_context_out->Current->modify_over->x = x; - draw_context_out->Current->modify_over->y = y_out; - draw_context_out->drawable = control_flow_data->Drawing->Pixmap; - draw_context_out->pango_layout = control_flow_data->Drawing->pango_layout; - GtkWidget *widget = control_flow_data->Drawing->Drawing_Area_V; - //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; - draw_context_out->gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); - gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); - //draw_context_out->gc = widget->style->black_gc; - - //draw_arc((void*)&prop_arc, (void*)draw_context_out); - //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); - - GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; - GdkColor colorbg_out = { 0, 0xffff, 0xffff, 0xffff }; - PropertiesText prop_text_out; - prop_text_out.foreground = &colorfg_out; - prop_text_out.background = &colorbg_out; - prop_text_out.size = 10; - prop_text_out.position = OVER; - - /* Print status of the process : U, WF, WC, E, W, R */ - if(process_out->state->s == LTTV_STATE_UNNAMED) - prop_text_out.Text = "U"; - else if(process_out->state->s == LTTV_STATE_WAIT_FORK) - prop_text_out.Text = "WF"; - else if(process_out->state->s == LTTV_STATE_WAIT_CPU) - prop_text_out.Text = "WC"; - else if(process_out->state->s == LTTV_STATE_EXIT) - prop_text_out.Text = "E"; - else if(process_out->state->s == LTTV_STATE_WAIT) - prop_text_out.Text = "W"; - else if(process_out->state->s == LTTV_STATE_RUN) - prop_text_out.Text = "R"; - else - prop_text_out.Text = "U"; - - draw_text((void*)&prop_text_out, (void*)draw_context_out); - gdk_gc_unref(draw_context_out->gc); - - /* Draw the line of the out process */ - if(draw_context_out->Previous->middle->x == -1) - { - draw_context_out->Previous->middle->x = Event_Request->x_begin; - g_critical("out middle x_beg : %u",Event_Request->x_begin); - } - - draw_context_out->Current->middle->x = x; - draw_context_out->Current->middle->y = y_out + height/2; - draw_context_out->Previous->middle->y = y_out + height/2; - draw_context_out->drawable = control_flow_data->Drawing->Pixmap; - draw_context_out->pango_layout = control_flow_data->Drawing->pango_layout; - //draw_context_out->gc = widget->style->black_gc; - draw_context_out->gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); - gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); - - PropertiesLine prop_line_out; - prop_line_out.color = g_new(GdkColor,1); - prop_line_out.line_width = 4; - prop_line_out.style = GDK_LINE_SOLID; - prop_line_out.position = MIDDLE; - - /* color of line : status of the process */ - if(process_out->state->s == LTTV_STATE_UNNAMED) - { - prop_line_out.color->red = 0x0000; - prop_line_out.color->green = 0x0000; - prop_line_out.color->blue = 0x0000; - } - else if(process_out->state->s == LTTV_STATE_WAIT_FORK) - { - prop_line_out.color->red = 0x0fff; - prop_line_out.color->green = 0x0000; - prop_line_out.color->blue = 0x0fff; - } - else if(process_out->state->s == LTTV_STATE_WAIT_CPU) - { - prop_line_out.color->red = 0x0fff; - prop_line_out.color->green = 0x0fff; - prop_line_out.color->blue = 0x0000; - } - else if(process_out->state->s == LTTV_STATE_EXIT) - { - prop_line_out.color->red = 0xffff; - prop_line_out.color->green = 0x0000; - prop_line_out.color->blue = 0xffff; - } - else if(process_out->state->s == LTTV_STATE_WAIT) - { - prop_line_out.color->red = 0xffff; - prop_line_out.color->green = 0x0000; - prop_line_out.color->blue = 0x0000; - } - else if(process_out->state->s == LTTV_STATE_RUN) - { - prop_line_out.color->red = 0x0000; - prop_line_out.color->green = 0xffff; - prop_line_out.color->blue = 0x0000; - } - else - { - prop_line_out.color->red = 0x0000; - prop_line_out.color->green = 0x0000; - prop_line_out.color->blue = 0x0000; - } - - draw_line((void*)&prop_line_out, (void*)draw_context_out); - g_free(prop_line_out.color); - gdk_gc_unref(draw_context_out->gc); - /* Note : finishing line will have to be added when trace read over. */ - - /* Finally, update the drawing context of the pid_in. */ - - DrawContext *draw_context_in = Hashed_Process_Data_in->draw_context; - draw_context_in->Current->modify_over->x = x; - draw_context_in->Current->modify_over->y = y_in; - draw_context_in->drawable = control_flow_data->Drawing->Pixmap; - draw_context_in->pango_layout = control_flow_data->Drawing->pango_layout; - widget = control_flow_data->Drawing->Drawing_Area_V; - //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; - //draw_context_in->gc = widget->style->black_gc; - draw_context_in->gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); - gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); - - //draw_arc((void*)&prop_arc, (void*)draw_context_in); - //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); - - GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; - GdkColor colorbg_in = { 0, 0xffff, 0xffff, 0xffff }; - PropertiesText prop_text_in; - prop_text_in.foreground = &colorfg_in; - prop_text_in.background = &colorbg_in; - prop_text_in.size = 10; - prop_text_in.position = OVER; - - /* Print status of the process : U, WF, WC, E, W, R */ - if(process_in->state->s == LTTV_STATE_UNNAMED) - prop_text_in.Text = "U"; - else if(process_in->state->s == LTTV_STATE_WAIT_FORK) - prop_text_in.Text = "WF"; - else if(process_in->state->s == LTTV_STATE_WAIT_CPU) - prop_text_in.Text = "WC"; - else if(process_in->state->s == LTTV_STATE_EXIT) - prop_text_in.Text = "E"; - else if(process_in->state->s == LTTV_STATE_WAIT) - prop_text_in.Text = "W"; - else if(process_in->state->s == LTTV_STATE_RUN) - prop_text_in.Text = "R"; - else - prop_text_in.Text = "U"; - - draw_text((void*)&prop_text_in, (void*)draw_context_in); - gdk_gc_unref(draw_context_in->gc); - - /* Draw the line of the in process */ - if(draw_context_in->Previous->middle->x == -1) - { - draw_context_in->Previous->middle->x = Event_Request->x_begin; - g_critical("in middle x_beg : %u",Event_Request->x_begin); - } - - draw_context_in->Current->middle->x = x; - draw_context_in->Previous->middle->y = y_in + height/2; - draw_context_in->Current->middle->y = y_in + height/2; - draw_context_in->drawable = control_flow_data->Drawing->Pixmap; - draw_context_in->pango_layout = control_flow_data->Drawing->pango_layout; - //draw_context_in->gc = widget->style->black_gc; - draw_context_in->gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); - gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); - - PropertiesLine prop_line_in; - prop_line_in.color = g_new(GdkColor,1); - prop_line_in.line_width = 4; - prop_line_in.style = GDK_LINE_SOLID; - prop_line_in.position = MIDDLE; - - /* color of line : status of the process */ - if(process_in->state->s == LTTV_STATE_UNNAMED) - { - prop_line_in.color->red = 0x0000; - prop_line_in.color->green = 0x0000; - prop_line_in.color->blue = 0x0000; - } - else if(process_in->state->s == LTTV_STATE_WAIT_FORK) - { - prop_line_in.color->red = 0x0fff; - prop_line_in.color->green = 0x0000; - prop_line_in.color->blue = 0x0fff; - } - else if(process_in->state->s == LTTV_STATE_WAIT_CPU) - { - prop_line_in.color->red = 0x0fff; - prop_line_in.color->green = 0x0fff; - prop_line_in.color->blue = 0x0000; - } - else if(process_in->state->s == LTTV_STATE_EXIT) - { - prop_line_in.color->red = 0xffff; - prop_line_in.color->green = 0x0000; - prop_line_in.color->blue = 0xffff; - } - else if(process_in->state->s == LTTV_STATE_WAIT) - { - prop_line_in.color->red = 0xffff; - prop_line_in.color->green = 0x0000; - prop_line_in.color->blue = 0x0000; - } - else if(process_in->state->s == LTTV_STATE_RUN) - { - prop_line_in.color->red = 0x0000; - prop_line_in.color->green = 0xffff; - prop_line_in.color->blue = 0x0000; - } - else - { - prop_line_in.color->red = 0x0000; - prop_line_in.color->green = 0x0000; - prop_line_in.color->blue = 0x0000; - } - - draw_line((void*)&prop_line_in, (void*)draw_context_in); - g_free(prop_line_in.color); - gdk_gc_unref(draw_context_in->gc); - } - - return 0; - - /* Temp dump */ + if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) + { + g_critical("schedchange!"); + + /* Add process to process list (if not present) and get drawing "y" from + * process position */ + guint pid_out, pid_in; + LttvProcessState *process_out, *process_in; + LttTime birth; + guint y_in = 0, y_out = 0, height = 0, pl_height = 0; + + ProcessList *process_list = + guicontrolflow_get_process_list(Event_Request->Control_Flow_Data); + + + 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_critical("out : %u in : %u", pid_out, pid_in); + + + /* Find process pid_out in the list... */ + process_out = lttv_state_find_process(tfs, pid_out); + g_critical("out : %s",g_quark_to_string(process_out->state->s)); + + birth = process_out->creation_time; + gchar *name = strdup(g_quark_to_string(process_out->name)); + HashedProcessData *Hashed_Process_Data_out = NULL; + + if(processlist_get_process_pixels(process_list, + pid_out, + &birth, + &y_out, + &height, + &Hashed_Process_Data_out) == 1) + { + /* Process not present */ + processlist_add(process_list, + pid_out, + &birth, + name, + &pl_height, + &Hashed_Process_Data_out); + processlist_get_process_pixels(process_list, + pid_out, + &birth, + &y_out, + &height, + &Hashed_Process_Data_out); + drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y_out, height); + } + + g_free(name); + + /* Find process pid_in in the list... */ + process_in = lttv_state_find_process(tfs, pid_in); + g_critical("in : %s",g_quark_to_string(process_in->state->s)); + + birth = process_in->creation_time; + name = strdup(g_quark_to_string(process_in->name)); + HashedProcessData *Hashed_Process_Data_in = NULL; + + if(processlist_get_process_pixels(process_list, + pid_in, + &birth, + &y_in, + &height, + &Hashed_Process_Data_in) == 1) + { + /* Process not present */ + processlist_add(process_list, + pid_in, + &birth, + name, + &pl_height, + &Hashed_Process_Data_in); + processlist_get_process_pixels(process_list, + pid_in, + &birth, + &y_in, + &height, + &Hashed_Process_Data_in); + + drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y_in, height); + } + g_free(name); + + + /* Find pixels corresponding to time of the event. 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_V->allocation.width; + + LttTime time = ltt_event_time(e); + + LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, + control_flow_data->Time_Window.start_time); + + + convert_time_to_pixels( + control_flow_data->Time_Window.start_time, + window_end, + time, + width, + &x); + + assert(x <= width); + + /* draw what represents the event for outgoing process. */ + + DrawContext *draw_context_out = Hashed_Process_Data_out->draw_context; + draw_context_out->Current->modify_over->x = x; + draw_context_out->Current->modify_over->y = y_out; + draw_context_out->drawable = control_flow_data->Drawing->Pixmap; + draw_context_out->pango_layout = control_flow_data->Drawing->pango_layout; + GtkWidget *widget = control_flow_data->Drawing->Drawing_Area_V; + //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; + draw_context_out->gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); + gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); + //draw_context_out->gc = widget->style->black_gc; + + //draw_arc((void*)&prop_arc, (void*)draw_context_out); + //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); + + GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; + GdkColor colorbg_out = { 0, 0xffff, 0xffff, 0xffff }; + PropertiesText prop_text_out; + prop_text_out.foreground = &colorfg_out; + prop_text_out.background = &colorbg_out; + prop_text_out.size = 10; + prop_text_out.position = OVER; + + /* Print status of the process : U, WF, WC, E, W, R */ + if(process_out->state->s == LTTV_STATE_UNNAMED) + prop_text_out.Text = "U"; + else if(process_out->state->s == LTTV_STATE_WAIT_FORK) + prop_text_out.Text = "WF"; + else if(process_out->state->s == LTTV_STATE_WAIT_CPU) + prop_text_out.Text = "WC"; + else if(process_out->state->s == LTTV_STATE_EXIT) + prop_text_out.Text = "E"; + else if(process_out->state->s == LTTV_STATE_WAIT) + prop_text_out.Text = "W"; + else if(process_out->state->s == LTTV_STATE_RUN) + prop_text_out.Text = "R"; + else + prop_text_out.Text = "U"; + + draw_text((void*)&prop_text_out, (void*)draw_context_out); + gdk_gc_unref(draw_context_out->gc); + + /* Draw the line of the out process */ + if(draw_context_out->Previous->middle->x == -1) + { + draw_context_out->Previous->middle->x = Event_Request->x_begin; + g_critical("out middle x_beg : %u",Event_Request->x_begin); + } + + draw_context_out->Current->middle->x = x; + draw_context_out->Current->middle->y = y_out + height/2; + draw_context_out->Previous->middle->y = y_out + height/2; + draw_context_out->drawable = control_flow_data->Drawing->Pixmap; + draw_context_out->pango_layout = control_flow_data->Drawing->pango_layout; + //draw_context_out->gc = widget->style->black_gc; + draw_context_out->gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); + gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); + + PropertiesLine prop_line_out; + prop_line_out.color = g_new(GdkColor,1); + prop_line_out.line_width = 4; + prop_line_out.style = GDK_LINE_SOLID; + prop_line_out.position = MIDDLE; + + /* color of line : status of the process */ + if(process_out->state->s == LTTV_STATE_UNNAMED) + { + prop_line_out.color->red = 0x0000; + prop_line_out.color->green = 0x0000; + prop_line_out.color->blue = 0x0000; + } + else if(process_out->state->s == LTTV_STATE_WAIT_FORK) + { + prop_line_out.color->red = 0x0fff; + prop_line_out.color->green = 0x0000; + prop_line_out.color->blue = 0x0fff; + } + else if(process_out->state->s == LTTV_STATE_WAIT_CPU) + { + prop_line_out.color->red = 0x0fff; + prop_line_out.color->green = 0x0fff; + prop_line_out.color->blue = 0x0000; + } + else if(process_out->state->s == LTTV_STATE_EXIT) + { + prop_line_out.color->red = 0xffff; + prop_line_out.color->green = 0x0000; + prop_line_out.color->blue = 0xffff; + } + else if(process_out->state->s == LTTV_STATE_WAIT) + { + prop_line_out.color->red = 0xffff; + prop_line_out.color->green = 0x0000; + prop_line_out.color->blue = 0x0000; + } + else if(process_out->state->s == LTTV_STATE_RUN) + { + prop_line_out.color->red = 0x0000; + prop_line_out.color->green = 0xffff; + prop_line_out.color->blue = 0x0000; + } + else + { + prop_line_out.color->red = 0x0000; + prop_line_out.color->green = 0x0000; + prop_line_out.color->blue = 0x0000; + } + + draw_line((void*)&prop_line_out, (void*)draw_context_out); + g_free(prop_line_out.color); + gdk_gc_unref(draw_context_out->gc); + /* Note : finishing line will have to be added when trace read over. */ + + /* Finally, update the drawing context of the pid_in. */ + + DrawContext *draw_context_in = Hashed_Process_Data_in->draw_context; + draw_context_in->Current->modify_over->x = x; + draw_context_in->Current->modify_over->y = y_in; + draw_context_in->drawable = control_flow_data->Drawing->Pixmap; + draw_context_in->pango_layout = control_flow_data->Drawing->pango_layout; + widget = control_flow_data->Drawing->Drawing_Area_V; + //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; + //draw_context_in->gc = widget->style->black_gc; + draw_context_in->gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); + gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); + + //draw_arc((void*)&prop_arc, (void*)draw_context_in); + //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); + + GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; + GdkColor colorbg_in = { 0, 0xffff, 0xffff, 0xffff }; + PropertiesText prop_text_in; + prop_text_in.foreground = &colorfg_in; + prop_text_in.background = &colorbg_in; + prop_text_in.size = 10; + prop_text_in.position = OVER; + + /* Print status of the process : U, WF, WC, E, W, R */ + if(process_in->state->s == LTTV_STATE_UNNAMED) + prop_text_in.Text = "U"; + else if(process_in->state->s == LTTV_STATE_WAIT_FORK) + prop_text_in.Text = "WF"; + else if(process_in->state->s == LTTV_STATE_WAIT_CPU) + prop_text_in.Text = "WC"; + else if(process_in->state->s == LTTV_STATE_EXIT) + prop_text_in.Text = "E"; + else if(process_in->state->s == LTTV_STATE_WAIT) + prop_text_in.Text = "W"; + else if(process_in->state->s == LTTV_STATE_RUN) + prop_text_in.Text = "R"; + else + prop_text_in.Text = "U"; + + draw_text((void*)&prop_text_in, (void*)draw_context_in); + gdk_gc_unref(draw_context_in->gc); + + /* Draw the line of the in process */ + if(draw_context_in->Previous->middle->x == -1) + { + draw_context_in->Previous->middle->x = Event_Request->x_begin; + g_critical("in middle x_beg : %u",Event_Request->x_begin); + } + + draw_context_in->Current->middle->x = x; + draw_context_in->Previous->middle->y = y_in + height/2; + draw_context_in->Current->middle->y = y_in + height/2; + draw_context_in->drawable = control_flow_data->Drawing->Pixmap; + draw_context_in->pango_layout = control_flow_data->Drawing->pango_layout; + //draw_context_in->gc = widget->style->black_gc; + draw_context_in->gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); + gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); + + PropertiesLine prop_line_in; + prop_line_in.color = g_new(GdkColor,1); + prop_line_in.line_width = 4; + prop_line_in.style = GDK_LINE_SOLID; + prop_line_in.position = MIDDLE; + + /* color of line : status of the process */ + if(process_in->state->s == LTTV_STATE_UNNAMED) + { + prop_line_in.color->red = 0x0000; + prop_line_in.color->green = 0x0000; + prop_line_in.color->blue = 0x0000; + } + else if(process_in->state->s == LTTV_STATE_WAIT_FORK) + { + prop_line_in.color->red = 0x0fff; + prop_line_in.color->green = 0x0000; + prop_line_in.color->blue = 0x0fff; + } + else if(process_in->state->s == LTTV_STATE_WAIT_CPU) + { + prop_line_in.color->red = 0x0fff; + prop_line_in.color->green = 0x0fff; + prop_line_in.color->blue = 0x0000; + } + else if(process_in->state->s == LTTV_STATE_EXIT) + { + prop_line_in.color->red = 0xffff; + prop_line_in.color->green = 0x0000; + prop_line_in.color->blue = 0xffff; + } + else if(process_in->state->s == LTTV_STATE_WAIT) + { + prop_line_in.color->red = 0xffff; + prop_line_in.color->green = 0x0000; + prop_line_in.color->blue = 0x0000; + } + else if(process_in->state->s == LTTV_STATE_RUN) + { + prop_line_in.color->red = 0x0000; + prop_line_in.color->green = 0xffff; + prop_line_in.color->blue = 0x0000; + } + else + { + prop_line_in.color->red = 0x0000; + prop_line_in.color->green = 0x0000; + prop_line_in.color->blue = 0x0000; + } + + draw_line((void*)&prop_line_in, (void*)draw_context_in); + g_free(prop_line_in.color); + gdk_gc_unref(draw_context_in->gc); + } + + return 0; + + /* Temp dump */ #ifdef DONTSHOW - GString *string = g_string_new("");; - gboolean field_names = TRUE, state = TRUE; + GString *string = g_string_new("");; + gboolean field_names = TRUE, state = TRUE; lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); g_string_append_printf(string,"\n"); @@ -493,9 +493,9 @@ int draw_event_hook(void *hook_data, void *call_data) g_info("%s",string->str); - g_string_free(string, TRUE); - - /* End of text dump */ + g_string_free(string, TRUE); + + /* End of text dump */ #endif //DONTSHOW } @@ -503,281 +503,281 @@ 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; + EventRequest *Event_Request = (EventRequest*)hook_data; + ControlFlowData *control_flow_data = Event_Request->Control_Flow_Data; - LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; + LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; LttvTracefileState *tfs = (LttvTracefileState *)call_data; - + LttEvent *e; e = tfc->e; - if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) - { - g_critical("schedchange!"); - - /* Add process to process list (if not present) and get drawing "y" from - * process position */ - guint pid_out, pid_in; - LttvProcessState *process_out, *process_in; - LttTime birth; - guint y_in = 0, y_out = 0, height = 0, pl_height = 0; - - ProcessList *process_list = - guicontrolflow_get_process_list(Event_Request->Control_Flow_Data); - - - 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_critical("out : %u in : %u", pid_out, pid_in); - - - /* Find process pid_out in the list... */ - process_out = lttv_state_find_process(tfs, pid_out); - g_critical("out : %s",g_quark_to_string(process_out->state->s)); - - birth = process_out->creation_time; - gchar *name = strdup(g_quark_to_string(process_out->name)); - HashedProcessData *Hashed_Process_Data_out = NULL; - - if(processlist_get_process_pixels(process_list, - pid_out, - &birth, - &y_out, - &height, - &Hashed_Process_Data_out) == 1) - { - /* Process not present */ - processlist_add(process_list, - pid_out, - &birth, - name, - &pl_height, - &Hashed_Process_Data_out); - processlist_get_process_pixels(process_list, - pid_out, - &birth, - &y_out, - &height, - &Hashed_Process_Data_out); - drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y_out, height); - } - - g_free(name); - - /* Find process pid_in in the list... */ - process_in = lttv_state_find_process(tfs, pid_in); - g_critical("in : %s",g_quark_to_string(process_in->state->s)); - - birth = process_in->creation_time; - name = strdup(g_quark_to_string(process_in->name)); - HashedProcessData *Hashed_Process_Data_in = NULL; - - if(processlist_get_process_pixels(process_list, - pid_in, - &birth, - &y_in, - &height, - &Hashed_Process_Data_in) == 1) - { - /* Process not present */ - processlist_add(process_list, - pid_in, - &birth, - name, - &pl_height, - &Hashed_Process_Data_in); - processlist_get_process_pixels(process_list, - pid_in, - &birth, - &y_in, - &height, - &Hashed_Process_Data_in); - - drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y_in, height); - } - g_free(name); - - - /* Find pixels corresponding to time of the event. 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_V->allocation.width; - - //LttTime time = ltt_event_time(e); - - //LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, - // control_flow_data->Time_Window.start_time); - - - //convert_time_to_pixels( - // control_flow_data->Time_Window.start_time, - // window_end, - // time, - // width, - // &x); - - //assert(x <= width); - - /* draw what represents the event for outgoing process. */ - - DrawContext *draw_context_out = Hashed_Process_Data_out->draw_context; - //draw_context_out->Current->modify_over->x = x; - draw_context_out->Current->modify_over->y = y_out; - draw_context_out->drawable = control_flow_data->Drawing->Pixmap; - draw_context_out->pango_layout = control_flow_data->Drawing->pango_layout; - GtkWidget *widget = control_flow_data->Drawing->Drawing_Area_V; - //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; - draw_context_out->gc = widget->style->black_gc; - - //draw_arc((void*)&prop_arc, (void*)draw_context_out); - //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); - - GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; - GdkColor colorbg_out = { 0, 0xffff, 0xffff, 0xffff }; - PropertiesText prop_text_out; - prop_text_out.foreground = &colorfg_out; - prop_text_out.background = &colorbg_out; - prop_text_out.size = 10; - prop_text_out.position = OVER; - - /* Print status of the process : U, WF, WC, E, W, R */ - if(process_out->state->s == LTTV_STATE_UNNAMED) - prop_text_out.Text = "U"; - else if(process_out->state->s == LTTV_STATE_WAIT_FORK) - prop_text_out.Text = "WF"; - else if(process_out->state->s == LTTV_STATE_WAIT_CPU) - prop_text_out.Text = "WC"; - else if(process_out->state->s == LTTV_STATE_EXIT) - prop_text_out.Text = "E"; - else if(process_out->state->s == LTTV_STATE_WAIT) - prop_text_out.Text = "W"; - else if(process_out->state->s == LTTV_STATE_RUN) - prop_text_out.Text = "R"; - else - prop_text_out.Text = "U"; - - draw_text((void*)&prop_text_out, (void*)draw_context_out); - - draw_context_out->Current->middle->y = y_out+height/2; - draw_context_out->Current->status = process_out->state->s; - - /* for pid_out : remove Previous, Prev = Current, new Current (default) */ - g_free(draw_context_out->Previous->modify_under); - g_free(draw_context_out->Previous->modify_middle); - g_free(draw_context_out->Previous->modify_over); - g_free(draw_context_out->Previous->under); - g_free(draw_context_out->Previous->middle); - g_free(draw_context_out->Previous->over); - g_free(draw_context_out->Previous); - - draw_context_out->Previous = draw_context_out->Current; - - draw_context_out->Current = g_new(DrawInfo,1); - draw_context_out->Current->over = g_new(ItemInfo,1); - draw_context_out->Current->over->x = -1; - draw_context_out->Current->over->y = -1; - draw_context_out->Current->middle = g_new(ItemInfo,1); - draw_context_out->Current->middle->x = -1; - draw_context_out->Current->middle->y = -1; - draw_context_out->Current->under = g_new(ItemInfo,1); - draw_context_out->Current->under->x = -1; - draw_context_out->Current->under->y = -1; - draw_context_out->Current->modify_over = g_new(ItemInfo,1); - draw_context_out->Current->modify_over->x = -1; - draw_context_out->Current->modify_over->y = -1; - draw_context_out->Current->modify_middle = g_new(ItemInfo,1); - draw_context_out->Current->modify_middle->x = -1; - draw_context_out->Current->modify_middle->y = -1; - draw_context_out->Current->modify_under = g_new(ItemInfo,1); - draw_context_out->Current->modify_under->x = -1; - draw_context_out->Current->modify_under->y = -1; - draw_context_out->Current->status = LTTV_STATE_UNNAMED; - - /* Finally, update the drawing context of the pid_in. */ - - DrawContext *draw_context_in = Hashed_Process_Data_in->draw_context; - //draw_context_in->Current->modify_over->x = x; - draw_context_in->Current->modify_over->y = y_in; - draw_context_in->drawable = control_flow_data->Drawing->Pixmap; - draw_context_in->pango_layout = control_flow_data->Drawing->pango_layout; - widget = control_flow_data->Drawing->Drawing_Area_V; - //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; - draw_context_in->gc = widget->style->black_gc; - - //draw_arc((void*)&prop_arc, (void*)draw_context_in); - //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); - - GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; - GdkColor colorbg_in = { 0, 0xffff, 0xffff, 0xffff }; - PropertiesText prop_text_in; - prop_text_in.foreground = &colorfg_in; - prop_text_in.background = &colorbg_in; - prop_text_in.size = 10; - prop_text_in.position = OVER; - - /* Print status of the process : U, WF, WC, E, W, R */ - if(process_in->state->s == LTTV_STATE_UNNAMED) - prop_text_in.Text = "U"; - else if(process_in->state->s == LTTV_STATE_WAIT_FORK) - prop_text_in.Text = "WF"; - else if(process_in->state->s == LTTV_STATE_WAIT_CPU) - prop_text_in.Text = "WC"; - else if(process_in->state->s == LTTV_STATE_EXIT) - prop_text_in.Text = "E"; - else if(process_in->state->s == LTTV_STATE_WAIT) - prop_text_in.Text = "W"; - else if(process_in->state->s == LTTV_STATE_RUN) - prop_text_in.Text = "R"; - else - prop_text_in.Text = "U"; - - draw_text((void*)&prop_text_in, (void*)draw_context_in); - - draw_context_in->Current->middle->y = y_in+height/2; - draw_context_in->Current->status = process_in->state->s; - - /* for pid_in : remove Previous, Prev = Current, new Current (default) */ - g_free(draw_context_in->Previous->modify_under); - g_free(draw_context_in->Previous->modify_middle); - g_free(draw_context_in->Previous->modify_over); - g_free(draw_context_in->Previous->under); - g_free(draw_context_in->Previous->middle); - g_free(draw_context_in->Previous->over); - g_free(draw_context_in->Previous); - - draw_context_in->Previous = draw_context_in->Current; - - draw_context_in->Current = g_new(DrawInfo,1); - draw_context_in->Current->over = g_new(ItemInfo,1); - draw_context_in->Current->over->x = -1; - draw_context_in->Current->over->y = -1; - draw_context_in->Current->middle = g_new(ItemInfo,1); - draw_context_in->Current->middle->x = -1; - draw_context_in->Current->middle->y = -1; - draw_context_in->Current->under = g_new(ItemInfo,1); - draw_context_in->Current->under->x = -1; - draw_context_in->Current->under->y = -1; - draw_context_in->Current->modify_over = g_new(ItemInfo,1); - draw_context_in->Current->modify_over->x = -1; - draw_context_in->Current->modify_over->y = -1; - draw_context_in->Current->modify_middle = g_new(ItemInfo,1); - draw_context_in->Current->modify_middle->x = -1; - draw_context_in->Current->modify_middle->y = -1; - draw_context_in->Current->modify_under = g_new(ItemInfo,1); - draw_context_in->Current->modify_under->x = -1; - draw_context_in->Current->modify_under->y = -1; - draw_context_in->Current->status = LTTV_STATE_UNNAMED; - - } - - return 0; + if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) + { + g_critical("schedchange!"); + + /* Add process to process list (if not present) and get drawing "y" from + * process position */ + guint pid_out, pid_in; + LttvProcessState *process_out, *process_in; + LttTime birth; + guint y_in = 0, y_out = 0, height = 0, pl_height = 0; + + ProcessList *process_list = + guicontrolflow_get_process_list(Event_Request->Control_Flow_Data); + + + 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_critical("out : %u in : %u", pid_out, pid_in); + + + /* Find process pid_out in the list... */ + process_out = lttv_state_find_process(tfs, pid_out); + g_critical("out : %s",g_quark_to_string(process_out->state->s)); + + birth = process_out->creation_time; + gchar *name = strdup(g_quark_to_string(process_out->name)); + HashedProcessData *Hashed_Process_Data_out = NULL; + + if(processlist_get_process_pixels(process_list, + pid_out, + &birth, + &y_out, + &height, + &Hashed_Process_Data_out) == 1) + { + /* Process not present */ + processlist_add(process_list, + pid_out, + &birth, + name, + &pl_height, + &Hashed_Process_Data_out); + processlist_get_process_pixels(process_list, + pid_out, + &birth, + &y_out, + &height, + &Hashed_Process_Data_out); + drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y_out, height); + } + + g_free(name); + + /* Find process pid_in in the list... */ + process_in = lttv_state_find_process(tfs, pid_in); + g_critical("in : %s",g_quark_to_string(process_in->state->s)); + + birth = process_in->creation_time; + name = strdup(g_quark_to_string(process_in->name)); + HashedProcessData *Hashed_Process_Data_in = NULL; + + if(processlist_get_process_pixels(process_list, + pid_in, + &birth, + &y_in, + &height, + &Hashed_Process_Data_in) == 1) + { + /* Process not present */ + processlist_add(process_list, + pid_in, + &birth, + name, + &pl_height, + &Hashed_Process_Data_in); + processlist_get_process_pixels(process_list, + pid_in, + &birth, + &y_in, + &height, + &Hashed_Process_Data_in); + + drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y_in, height); + } + g_free(name); + + + /* Find pixels corresponding to time of the event. 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_V->allocation.width; + + //LttTime time = ltt_event_time(e); + + //LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, + // control_flow_data->Time_Window.start_time); + + + //convert_time_to_pixels( + // control_flow_data->Time_Window.start_time, + // window_end, + // time, + // width, + // &x); + + //assert(x <= width); + + /* draw what represents the event for outgoing process. */ + + DrawContext *draw_context_out = Hashed_Process_Data_out->draw_context; + //draw_context_out->Current->modify_over->x = x; + draw_context_out->Current->modify_over->y = y_out; + draw_context_out->drawable = control_flow_data->Drawing->Pixmap; + draw_context_out->pango_layout = control_flow_data->Drawing->pango_layout; + GtkWidget *widget = control_flow_data->Drawing->Drawing_Area_V; + //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; + draw_context_out->gc = widget->style->black_gc; + + //draw_arc((void*)&prop_arc, (void*)draw_context_out); + //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); + + GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; + GdkColor colorbg_out = { 0, 0xffff, 0xffff, 0xffff }; + PropertiesText prop_text_out; + prop_text_out.foreground = &colorfg_out; + prop_text_out.background = &colorbg_out; + prop_text_out.size = 10; + prop_text_out.position = OVER; + + /* Print status of the process : U, WF, WC, E, W, R */ + if(process_out->state->s == LTTV_STATE_UNNAMED) + prop_text_out.Text = "U"; + else if(process_out->state->s == LTTV_STATE_WAIT_FORK) + prop_text_out.Text = "WF"; + else if(process_out->state->s == LTTV_STATE_WAIT_CPU) + prop_text_out.Text = "WC"; + else if(process_out->state->s == LTTV_STATE_EXIT) + prop_text_out.Text = "E"; + else if(process_out->state->s == LTTV_STATE_WAIT) + prop_text_out.Text = "W"; + else if(process_out->state->s == LTTV_STATE_RUN) + prop_text_out.Text = "R"; + else + prop_text_out.Text = "U"; + + draw_text((void*)&prop_text_out, (void*)draw_context_out); + + draw_context_out->Current->middle->y = y_out+height/2; + draw_context_out->Current->status = process_out->state->s; + + /* for pid_out : remove Previous, Prev = Current, new Current (default) */ + g_free(draw_context_out->Previous->modify_under); + g_free(draw_context_out->Previous->modify_middle); + g_free(draw_context_out->Previous->modify_over); + g_free(draw_context_out->Previous->under); + g_free(draw_context_out->Previous->middle); + g_free(draw_context_out->Previous->over); + g_free(draw_context_out->Previous); + + draw_context_out->Previous = draw_context_out->Current; + + draw_context_out->Current = g_new(DrawInfo,1); + draw_context_out->Current->over = g_new(ItemInfo,1); + draw_context_out->Current->over->x = -1; + draw_context_out->Current->over->y = -1; + draw_context_out->Current->middle = g_new(ItemInfo,1); + draw_context_out->Current->middle->x = -1; + draw_context_out->Current->middle->y = -1; + draw_context_out->Current->under = g_new(ItemInfo,1); + draw_context_out->Current->under->x = -1; + draw_context_out->Current->under->y = -1; + draw_context_out->Current->modify_over = g_new(ItemInfo,1); + draw_context_out->Current->modify_over->x = -1; + draw_context_out->Current->modify_over->y = -1; + draw_context_out->Current->modify_middle = g_new(ItemInfo,1); + draw_context_out->Current->modify_middle->x = -1; + draw_context_out->Current->modify_middle->y = -1; + draw_context_out->Current->modify_under = g_new(ItemInfo,1); + draw_context_out->Current->modify_under->x = -1; + draw_context_out->Current->modify_under->y = -1; + draw_context_out->Current->status = LTTV_STATE_UNNAMED; + + /* Finally, update the drawing context of the pid_in. */ + + DrawContext *draw_context_in = Hashed_Process_Data_in->draw_context; + //draw_context_in->Current->modify_over->x = x; + draw_context_in->Current->modify_over->y = y_in; + draw_context_in->drawable = control_flow_data->Drawing->Pixmap; + draw_context_in->pango_layout = control_flow_data->Drawing->pango_layout; + widget = control_flow_data->Drawing->Drawing_Area_V; + //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; + draw_context_in->gc = widget->style->black_gc; + + //draw_arc((void*)&prop_arc, (void*)draw_context_in); + //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); + + GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; + GdkColor colorbg_in = { 0, 0xffff, 0xffff, 0xffff }; + PropertiesText prop_text_in; + prop_text_in.foreground = &colorfg_in; + prop_text_in.background = &colorbg_in; + prop_text_in.size = 10; + prop_text_in.position = OVER; + + /* Print status of the process : U, WF, WC, E, W, R */ + if(process_in->state->s == LTTV_STATE_UNNAMED) + prop_text_in.Text = "U"; + else if(process_in->state->s == LTTV_STATE_WAIT_FORK) + prop_text_in.Text = "WF"; + else if(process_in->state->s == LTTV_STATE_WAIT_CPU) + prop_text_in.Text = "WC"; + else if(process_in->state->s == LTTV_STATE_EXIT) + prop_text_in.Text = "E"; + else if(process_in->state->s == LTTV_STATE_WAIT) + prop_text_in.Text = "W"; + else if(process_in->state->s == LTTV_STATE_RUN) + prop_text_in.Text = "R"; + else + prop_text_in.Text = "U"; + + draw_text((void*)&prop_text_in, (void*)draw_context_in); + + draw_context_in->Current->middle->y = y_in+height/2; + draw_context_in->Current->status = process_in->state->s; + + /* for pid_in : remove Previous, Prev = Current, new Current (default) */ + g_free(draw_context_in->Previous->modify_under); + g_free(draw_context_in->Previous->modify_middle); + g_free(draw_context_in->Previous->modify_over); + g_free(draw_context_in->Previous->under); + g_free(draw_context_in->Previous->middle); + g_free(draw_context_in->Previous->over); + g_free(draw_context_in->Previous); + + draw_context_in->Previous = draw_context_in->Current; + + draw_context_in->Current = g_new(DrawInfo,1); + draw_context_in->Current->over = g_new(ItemInfo,1); + draw_context_in->Current->over->x = -1; + draw_context_in->Current->over->y = -1; + draw_context_in->Current->middle = g_new(ItemInfo,1); + draw_context_in->Current->middle->x = -1; + draw_context_in->Current->middle->y = -1; + draw_context_in->Current->under = g_new(ItemInfo,1); + draw_context_in->Current->under->x = -1; + draw_context_in->Current->under->y = -1; + draw_context_in->Current->modify_over = g_new(ItemInfo,1); + draw_context_in->Current->modify_over->x = -1; + draw_context_in->Current->modify_over->y = -1; + draw_context_in->Current->modify_middle = g_new(ItemInfo,1); + draw_context_in->Current->modify_middle->x = -1; + draw_context_in->Current->modify_middle->y = -1; + draw_context_in->Current->modify_under = g_new(ItemInfo,1); + draw_context_in->Current->modify_under->x = -1; + draw_context_in->Current->modify_under->y = -1; + draw_context_in->Current->status = LTTV_STATE_UNNAMED; + + } + + return 0; } @@ -785,421 +785,421 @@ int draw_after_hook(void *hook_data, void *call_data) gint update_time_window_hook(void *hook_data, void *call_data) { - ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; - TimeWindow *Old_Time_Window = - guicontrolflow_get_time_window(control_flow_data); - TimeWindow *New_Time_Window = ((TimeWindow*)call_data); - - /* Two cases : zoom in/out or scrolling */ - - /* In order to make sure we can reuse the old drawing, the scale must - * be the same and the new time interval being partly located in the - * currently shown time interval. (reuse is only for scrolling) - */ - - g_info("Old time window HOOK : %u, %u to %u, %u", - Old_Time_Window->start_time.tv_sec, - Old_Time_Window->start_time.tv_nsec, - Old_Time_Window->time_width.tv_sec, - Old_Time_Window->time_width.tv_nsec); - - g_info("New time window HOOK : %u, %u to %u, %u", - New_Time_Window->start_time.tv_sec, - New_Time_Window->start_time.tv_nsec, - New_Time_Window->time_width.tv_sec, - New_Time_Window->time_width.tv_nsec); - - if( New_Time_Window->time_width.tv_sec == Old_Time_Window->time_width.tv_sec - && New_Time_Window->time_width.tv_nsec == Old_Time_Window->time_width.tv_nsec) - { - /* Same scale (scrolling) */ - g_info("scrolling"); - LttTime *ns = &New_Time_Window->start_time; - LttTime *os = &Old_Time_Window->start_time; - LttTime old_end = ltt_time_add(Old_Time_Window->start_time, - Old_Time_Window->time_width); - LttTime new_end = ltt_time_add(New_Time_Window->start_time, - New_Time_Window->time_width); - //if(nsDrawing->Drawing_Area_V->allocation.width; - convert_time_to_pixels( - *os, - old_end, - *ns, - width, - &x); - - /* Copy old data to new location */ - gdk_draw_drawable (control_flow_data->Drawing->Pixmap, - control_flow_data->Drawing->Drawing_Area_V->style->white_gc, - control_flow_data->Drawing->Pixmap, - x, 0, - 0, 0, - -1, -1); - - convert_time_to_pixels( - *ns, - new_end, - old_end, - width, - &x); - - *Old_Time_Window = *New_Time_Window; - /* Clear the data request background, but not SAFETY */ - gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, - control_flow_data->Drawing->Drawing_Area_V->style->white_gc, - TRUE, - x+SAFETY, 0, - control_flow_data->Drawing->width - x, // do not overlap - control_flow_data->Drawing->height+SAFETY); - /* Get new data for the rest. */ - drawing_data_request(control_flow_data->Drawing, - &control_flow_data->Drawing->Pixmap, - x, 0, - control_flow_data->Drawing->width - x, - control_flow_data->Drawing->height); - - drawing_refresh(control_flow_data->Drawing, - 0, 0, - control_flow_data->Drawing->width, - control_flow_data->Drawing->height); - - - } else { - //if(nsDrawing->Drawing_Area_V->allocation.width; - convert_time_to_pixels( - *ns, - new_end, - *os, - width, - &x); - - /* Copy old data to new location */ - gdk_draw_drawable (control_flow_data->Drawing->Pixmap, - control_flow_data->Drawing->Drawing_Area_V->style->white_gc, - control_flow_data->Drawing->Pixmap, - 0, 0, - x, 0, - -1, -1); - - *Old_Time_Window = *New_Time_Window; - - /* Clean the data request background */ - gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, - control_flow_data->Drawing->Drawing_Area_V->style->white_gc, - TRUE, - 0, 0, - x, // do not overlap - control_flow_data->Drawing->height+SAFETY); - /* Get new data for the rest. */ - drawing_data_request(control_flow_data->Drawing, - &control_flow_data->Drawing->Pixmap, - 0, 0, - x, - control_flow_data->Drawing->height); - - drawing_refresh(control_flow_data->Drawing, - 0, 0, - control_flow_data->Drawing->width, - control_flow_data->Drawing->height); - - } else { - g_info("scrolling far"); - /* Cannot reuse any part of the screen : far jump */ - *Old_Time_Window = *New_Time_Window; - - - gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, - control_flow_data->Drawing->Drawing_Area_V->style->white_gc, - TRUE, - 0, 0, - control_flow_data->Drawing->width+SAFETY, // do not overlap - control_flow_data->Drawing->height+SAFETY); - - drawing_data_request(control_flow_data->Drawing, - &control_flow_data->Drawing->Pixmap, - 0, 0, - control_flow_data->Drawing->width, - control_flow_data->Drawing->height); - - drawing_refresh(control_flow_data->Drawing, - 0, 0, - control_flow_data->Drawing->width, - control_flow_data->Drawing->height); - } - } - } else { - /* Different scale (zoom) */ - g_info("zoom"); - - *Old_Time_Window = *New_Time_Window; - - gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, - control_flow_data->Drawing->Drawing_Area_V->style->white_gc, - TRUE, - 0, 0, - control_flow_data->Drawing->width+SAFETY, // do not overlap - control_flow_data->Drawing->height+SAFETY); - - - drawing_data_request(control_flow_data->Drawing, - &control_flow_data->Drawing->Pixmap, - 0, 0, - control_flow_data->Drawing->width, - control_flow_data->Drawing->height); - - drawing_refresh(control_flow_data->Drawing, - 0, 0, - control_flow_data->Drawing->width, - control_flow_data->Drawing->height); - } - - return 0; + ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; + TimeWindow *Old_Time_Window = + guicontrolflow_get_time_window(control_flow_data); + TimeWindow *New_Time_Window = ((TimeWindow*)call_data); + + /* Two cases : zoom in/out or scrolling */ + + /* In order to make sure we can reuse the old drawing, the scale must + * be the same and the new time interval being partly located in the + * currently shown time interval. (reuse is only for scrolling) + */ + + g_info("Old time window HOOK : %u, %u to %u, %u", + Old_Time_Window->start_time.tv_sec, + Old_Time_Window->start_time.tv_nsec, + Old_Time_Window->time_width.tv_sec, + Old_Time_Window->time_width.tv_nsec); + + g_info("New time window HOOK : %u, %u to %u, %u", + New_Time_Window->start_time.tv_sec, + New_Time_Window->start_time.tv_nsec, + New_Time_Window->time_width.tv_sec, + New_Time_Window->time_width.tv_nsec); + + if( New_Time_Window->time_width.tv_sec == Old_Time_Window->time_width.tv_sec + && New_Time_Window->time_width.tv_nsec == Old_Time_Window->time_width.tv_nsec) + { + /* Same scale (scrolling) */ + g_info("scrolling"); + LttTime *ns = &New_Time_Window->start_time; + LttTime *os = &Old_Time_Window->start_time; + LttTime old_end = ltt_time_add(Old_Time_Window->start_time, + Old_Time_Window->time_width); + LttTime new_end = ltt_time_add(New_Time_Window->start_time, + New_Time_Window->time_width); + //if(nsDrawing->Drawing_Area_V->allocation.width; + convert_time_to_pixels( + *os, + old_end, + *ns, + width, + &x); + + /* Copy old data to new location */ + gdk_draw_drawable (control_flow_data->Drawing->Pixmap, + control_flow_data->Drawing->Drawing_Area_V->style->white_gc, + control_flow_data->Drawing->Pixmap, + x, 0, + 0, 0, + -1, -1); + + convert_time_to_pixels( + *ns, + new_end, + old_end, + width, + &x); + + *Old_Time_Window = *New_Time_Window; + /* Clear the data request background, but not SAFETY */ + gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, + control_flow_data->Drawing->Drawing_Area_V->style->white_gc, + TRUE, + x+SAFETY, 0, + control_flow_data->Drawing->width - x, // do not overlap + control_flow_data->Drawing->height+SAFETY); + /* Get new data for the rest. */ + drawing_data_request(control_flow_data->Drawing, + &control_flow_data->Drawing->Pixmap, + x, 0, + control_flow_data->Drawing->width - x, + control_flow_data->Drawing->height); + + drawing_refresh(control_flow_data->Drawing, + 0, 0, + control_flow_data->Drawing->width, + control_flow_data->Drawing->height); + + + } else { + //if(nsDrawing->Drawing_Area_V->allocation.width; + convert_time_to_pixels( + *ns, + new_end, + *os, + width, + &x); + + /* Copy old data to new location */ + gdk_draw_drawable (control_flow_data->Drawing->Pixmap, + control_flow_data->Drawing->Drawing_Area_V->style->white_gc, + control_flow_data->Drawing->Pixmap, + 0, 0, + x, 0, + -1, -1); + + *Old_Time_Window = *New_Time_Window; + + /* Clean the data request background */ + gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, + control_flow_data->Drawing->Drawing_Area_V->style->white_gc, + TRUE, + 0, 0, + x, // do not overlap + control_flow_data->Drawing->height+SAFETY); + /* Get new data for the rest. */ + drawing_data_request(control_flow_data->Drawing, + &control_flow_data->Drawing->Pixmap, + 0, 0, + x, + control_flow_data->Drawing->height); + + drawing_refresh(control_flow_data->Drawing, + 0, 0, + control_flow_data->Drawing->width, + control_flow_data->Drawing->height); + + } else { + g_info("scrolling far"); + /* Cannot reuse any part of the screen : far jump */ + *Old_Time_Window = *New_Time_Window; + + + gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, + control_flow_data->Drawing->Drawing_Area_V->style->white_gc, + TRUE, + 0, 0, + control_flow_data->Drawing->width+SAFETY, // do not overlap + control_flow_data->Drawing->height+SAFETY); + + drawing_data_request(control_flow_data->Drawing, + &control_flow_data->Drawing->Pixmap, + 0, 0, + control_flow_data->Drawing->width, + control_flow_data->Drawing->height); + + drawing_refresh(control_flow_data->Drawing, + 0, 0, + control_flow_data->Drawing->width, + control_flow_data->Drawing->height); + } + } + } else { + /* Different scale (zoom) */ + g_info("zoom"); + + *Old_Time_Window = *New_Time_Window; + + gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, + control_flow_data->Drawing->Drawing_Area_V->style->white_gc, + TRUE, + 0, 0, + control_flow_data->Drawing->width+SAFETY, // do not overlap + control_flow_data->Drawing->height+SAFETY); + + + drawing_data_request(control_flow_data->Drawing, + &control_flow_data->Drawing->Pixmap, + 0, 0, + control_flow_data->Drawing->width, + control_flow_data->Drawing->height); + + drawing_refresh(control_flow_data->Drawing, + 0, 0, + control_flow_data->Drawing->width, + control_flow_data->Drawing->height); + } + + return 0; } gint update_current_time_hook(void *hook_data, void *call_data) { - ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; - - LttTime* current_time = - guicontrolflow_get_current_time(control_flow_data); - *current_time = *((LttTime*)call_data); - - TimeWindow time_window; - - LttTime time_begin = control_flow_data->Time_Window.start_time; - LttTime width = control_flow_data->Time_Window.time_width; - LttTime half_width = ltt_time_div(width,2.0); - LttTime time_end = ltt_time_add(time_begin, width); - - LttvTracesetContext * tsc = - get_traceset_context(control_flow_data->Parent_Window); - - LttTime trace_start = tsc->Time_Span->startTime; - LttTime trace_end = tsc->Time_Span->endTime; - - g_info("New Current time HOOK : %u, %u", current_time->tv_sec, - current_time->tv_nsec); - - - - /* If current time is inside time interval, just move the highlight - * bar */ - - /* Else, we have to change the time interval. We have to tell it - * to the main window. */ - /* The time interval change will take care of placing the current - * time at the center of the visible area, or nearest possible if we are - * at one end of the trace. */ - - - if(ltt_time_compare(*current_time, time_begin) == -1) - { - if(ltt_time_compare(*current_time, - ltt_time_add(trace_start,half_width)) == -1) - time_begin = trace_start; - else - time_begin = ltt_time_sub(*current_time,half_width); - - time_window.start_time = time_begin; - time_window.time_width = width; - - set_time_window(control_flow_data->Parent_Window, &time_window); - } - else if(ltt_time_compare(*current_time, time_end) == 1) - { - if(ltt_time_compare(*current_time, ltt_time_sub(trace_end, half_width)) == 1) - time_begin = ltt_time_sub(trace_end,width); - else - time_begin = ltt_time_sub(*current_time,half_width); - - time_window.start_time = time_begin; - time_window.time_width = width; - - set_time_window(control_flow_data->Parent_Window, &time_window); - - } - gtk_widget_queue_draw(control_flow_data->Drawing->Drawing_Area_V); - - return 0; + ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; + + LttTime* current_time = + guicontrolflow_get_current_time(control_flow_data); + *current_time = *((LttTime*)call_data); + + TimeWindow time_window; + + LttTime time_begin = control_flow_data->Time_Window.start_time; + LttTime width = control_flow_data->Time_Window.time_width; + LttTime half_width = ltt_time_div(width,2.0); + LttTime time_end = ltt_time_add(time_begin, width); + + LttvTracesetContext * tsc = + get_traceset_context(control_flow_data->Parent_Window); + + LttTime trace_start = tsc->Time_Span->startTime; + LttTime trace_end = tsc->Time_Span->endTime; + + g_info("New Current time HOOK : %u, %u", current_time->tv_sec, + current_time->tv_nsec); + + + + /* If current time is inside time interval, just move the highlight + * bar */ + + /* Else, we have to change the time interval. We have to tell it + * to the main window. */ + /* The time interval change will take care of placing the current + * time at the center of the visible area, or nearest possible if we are + * at one end of the trace. */ + + + if(ltt_time_compare(*current_time, time_begin) == -1) + { + if(ltt_time_compare(*current_time, + ltt_time_add(trace_start,half_width)) == -1) + time_begin = trace_start; + else + time_begin = ltt_time_sub(*current_time,half_width); + + time_window.start_time = time_begin; + time_window.time_width = width; + + set_time_window(control_flow_data->Parent_Window, &time_window); + } + else if(ltt_time_compare(*current_time, time_end) == 1) + { + if(ltt_time_compare(*current_time, ltt_time_sub(trace_end, half_width)) == 1) + time_begin = ltt_time_sub(trace_end,width); + else + time_begin = ltt_time_sub(*current_time,half_width); + + time_window.start_time = time_begin; + time_window.time_width = width; + + set_time_window(control_flow_data->Parent_Window, &time_window); + + } + gtk_widget_queue_draw(control_flow_data->Drawing->Drawing_Area_V); + + return 0; } typedef struct _ClosureData { - EventRequest *event_request; - LttvTraceState *ts; + EventRequest *event_request; + LttvTraceState *ts; } ClosureData; - + void draw_closure(gpointer key, gpointer value, gpointer user_data) { - ProcessInfo *process_info = (ProcessInfo*)key; - HashedProcessData *hashed_process_data = (HashedProcessData*)value; - ClosureData *closure_data = (ClosureData*)user_data; - - ControlFlowData *control_flow_data = - closure_data->event_request->Control_Flow_Data; - - GtkWidget *widget = control_flow_data->Drawing->Drawing_Area_V; - - /* Get y position of process */ - gint y=0, height=0; - - processlist_get_pixels_from_data( control_flow_data->Process_List, - process_info, - hashed_process_data, - &y, - &height); - /* Get last state of process */ - LttvTraceContext *tc = - (LttvTraceContext *)closure_data->ts; + ProcessInfo *process_info = (ProcessInfo*)key; + HashedProcessData *hashed_process_data = (HashedProcessData*)value; + ClosureData *closure_data = (ClosureData*)user_data; + + ControlFlowData *control_flow_data = + closure_data->event_request->Control_Flow_Data; + + GtkWidget *widget = control_flow_data->Drawing->Drawing_Area_V; + + /* Get y position of process */ + gint y=0, height=0; + + processlist_get_pixels_from_data( control_flow_data->Process_List, + process_info, + hashed_process_data, + &y, + &height); + /* Get last state of process */ + LttvTraceContext *tc = + (LttvTraceContext *)closure_data->ts; LttvTraceState *ts = closure_data->ts; - LttvProcessState *process; - - process = lttv_state_find_process((LttvTracefileState*)ts, process_info->pid); - - /* Draw the closing line */ - 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; - g_critical("out middle x_beg : %u",closure_data->event_request->x_begin); - } - - draw_context->Current->middle->x = closure_data->event_request->x_end; - draw_context->Current->middle->y = y + height/2; - draw_context->Previous->middle->y = y + height/2; - draw_context->drawable = control_flow_data->Drawing->Pixmap; - draw_context->pango_layout = control_flow_data->Drawing->pango_layout; - //draw_context->gc = widget->style->black_gc; - draw_context->gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); - gdk_gc_copy(draw_context->gc, widget->style->black_gc); - - PropertiesLine prop_line; - prop_line.color = g_new(GdkColor,1); - prop_line.line_width = 6; - prop_line.style = GDK_LINE_SOLID; - prop_line.position = MIDDLE; - - /* color of line : status of the process */ - if(process->state->s == LTTV_STATE_UNNAMED) - { - prop_line.color->red = 0x0000; - prop_line.color->green = 0x0000; - prop_line.color->blue = 0x0000; - } - else if(process->state->s == LTTV_STATE_WAIT_FORK) - { - prop_line.color->red = 0x0fff; - prop_line.color->green = 0x0000; - prop_line.color->blue = 0x0fff; - } - else if(process->state->s == LTTV_STATE_WAIT_CPU) - { - prop_line.color->red = 0x0fff; - prop_line.color->green = 0x0fff; - prop_line.color->blue = 0x0000; - } - else if(process->state->s == LTTV_STATE_EXIT) - { - prop_line.color->red = 0xffff; - prop_line.color->green = 0x0000; - prop_line.color->blue = 0xffff; - } - else if(process->state->s == LTTV_STATE_WAIT) - { - prop_line.color->red = 0xffff; - prop_line.color->green = 0x0000; - prop_line.color->blue = 0x0000; - } - else if(process->state->s == LTTV_STATE_RUN) - { - prop_line.color->red = 0x0000; - prop_line.color->green = 0xffff; - prop_line.color->blue = 0x0000; - } - else - { - prop_line.color->red = 0x0000; - prop_line.color->green = 0x0000; - prop_line.color->blue = 0x0000; - } - - draw_line((void*)&prop_line, (void*)draw_context); - g_free(prop_line.color); - gdk_gc_unref(draw_context->gc); - - /* Reset draw_context of the process for next request */ - - hashed_process_data->draw_context->drawable = NULL; - hashed_process_data->draw_context->gc = NULL; - hashed_process_data->draw_context->pango_layout = NULL; - hashed_process_data->draw_context->Current->over->x = -1; - hashed_process_data->draw_context->Current->over->y = -1; - hashed_process_data->draw_context->Current->middle->x = -1; - hashed_process_data->draw_context->Current->middle->y = -1; - hashed_process_data->draw_context->Current->under->x = -1; - hashed_process_data->draw_context->Current->under->y = -1; - hashed_process_data->draw_context->Current->modify_over->x = -1; - hashed_process_data->draw_context->Current->modify_over->y = -1; - hashed_process_data->draw_context->Current->modify_middle->x = -1; - hashed_process_data->draw_context->Current->modify_middle->y = -1; - hashed_process_data->draw_context->Current->modify_under->x = -1; - hashed_process_data->draw_context->Current->modify_under->y = -1; - hashed_process_data->draw_context->Current->status = LTTV_STATE_UNNAMED; - hashed_process_data->draw_context->Previous->over->x = -1; - hashed_process_data->draw_context->Previous->over->y = -1; - hashed_process_data->draw_context->Previous->middle->x = -1; - hashed_process_data->draw_context->Previous->middle->y = -1; - hashed_process_data->draw_context->Previous->under->x = -1; - hashed_process_data->draw_context->Previous->under->y = -1; - hashed_process_data->draw_context->Previous->modify_over->x = -1; - hashed_process_data->draw_context->Previous->modify_over->y = -1; - hashed_process_data->draw_context->Previous->modify_middle->x = -1; - hashed_process_data->draw_context->Previous->modify_middle->y = -1; - 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; - + LttvProcessState *process; + + process = lttv_state_find_process((LttvTracefileState*)ts, process_info->pid); + + /* Draw the closing line */ + 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; + g_critical("out middle x_beg : %u",closure_data->event_request->x_begin); + } + + draw_context->Current->middle->x = closure_data->event_request->x_end; + draw_context->Current->middle->y = y + height/2; + draw_context->Previous->middle->y = y + height/2; + draw_context->drawable = control_flow_data->Drawing->Pixmap; + draw_context->pango_layout = control_flow_data->Drawing->pango_layout; + //draw_context->gc = widget->style->black_gc; + draw_context->gc = gdk_gc_new(control_flow_data->Drawing->Pixmap); + gdk_gc_copy(draw_context->gc, widget->style->black_gc); + + PropertiesLine prop_line; + prop_line.color = g_new(GdkColor,1); + prop_line.line_width = 6; + prop_line.style = GDK_LINE_SOLID; + prop_line.position = MIDDLE; + + /* color of line : status of the process */ + if(process->state->s == LTTV_STATE_UNNAMED) + { + prop_line.color->red = 0x0000; + prop_line.color->green = 0x0000; + prop_line.color->blue = 0x0000; + } + else if(process->state->s == LTTV_STATE_WAIT_FORK) + { + prop_line.color->red = 0x0fff; + prop_line.color->green = 0x0000; + prop_line.color->blue = 0x0fff; + } + else if(process->state->s == LTTV_STATE_WAIT_CPU) + { + prop_line.color->red = 0x0fff; + prop_line.color->green = 0x0fff; + prop_line.color->blue = 0x0000; + } + else if(process->state->s == LTTV_STATE_EXIT) + { + prop_line.color->red = 0xffff; + prop_line.color->green = 0x0000; + prop_line.color->blue = 0xffff; + } + else if(process->state->s == LTTV_STATE_WAIT) + { + prop_line.color->red = 0xffff; + prop_line.color->green = 0x0000; + prop_line.color->blue = 0x0000; + } + else if(process->state->s == LTTV_STATE_RUN) + { + prop_line.color->red = 0x0000; + prop_line.color->green = 0xffff; + prop_line.color->blue = 0x0000; + } + else + { + prop_line.color->red = 0x0000; + prop_line.color->green = 0x0000; + prop_line.color->blue = 0x0000; + } + + draw_line((void*)&prop_line, (void*)draw_context); + g_free(prop_line.color); + gdk_gc_unref(draw_context->gc); + + /* Reset draw_context of the process for next request */ + + hashed_process_data->draw_context->drawable = NULL; + hashed_process_data->draw_context->gc = NULL; + hashed_process_data->draw_context->pango_layout = NULL; + hashed_process_data->draw_context->Current->over->x = -1; + hashed_process_data->draw_context->Current->over->y = -1; + hashed_process_data->draw_context->Current->middle->x = -1; + hashed_process_data->draw_context->Current->middle->y = -1; + hashed_process_data->draw_context->Current->under->x = -1; + hashed_process_data->draw_context->Current->under->y = -1; + hashed_process_data->draw_context->Current->modify_over->x = -1; + hashed_process_data->draw_context->Current->modify_over->y = -1; + hashed_process_data->draw_context->Current->modify_middle->x = -1; + hashed_process_data->draw_context->Current->modify_middle->y = -1; + hashed_process_data->draw_context->Current->modify_under->x = -1; + hashed_process_data->draw_context->Current->modify_under->y = -1; + hashed_process_data->draw_context->Current->status = LTTV_STATE_UNNAMED; + hashed_process_data->draw_context->Previous->over->x = -1; + hashed_process_data->draw_context->Previous->over->y = -1; + hashed_process_data->draw_context->Previous->middle->x = -1; + hashed_process_data->draw_context->Previous->middle->y = -1; + hashed_process_data->draw_context->Previous->under->x = -1; + hashed_process_data->draw_context->Previous->under->y = -1; + hashed_process_data->draw_context->Previous->modify_over->x = -1; + hashed_process_data->draw_context->Previous->modify_over->y = -1; + hashed_process_data->draw_context->Previous->modify_middle->x = -1; + hashed_process_data->draw_context->Previous->modify_middle->y = -1; + 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; + } /* * for each process - * draw closing line - * new default prev and current + * draw closing line + * new default prev and current */ 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; - - ProcessList *process_list = - guicontrolflow_get_process_list(Event_Request->Control_Flow_Data); - - ClosureData closure_data; - closure_data.event_request = (EventRequest*)hook_data; - closure_data.ts = (LttvTraceState*)call_data; - - g_hash_table_foreach(process_list->Process_Hash, draw_closure, - (void*)&closure_data); - + EventRequest *Event_Request = (EventRequest*)hook_data; + ControlFlowData *control_flow_data = Event_Request->Control_Flow_Data; + + ProcessList *process_list = + guicontrolflow_get_process_list(Event_Request->Control_Flow_Data); + + ClosureData closure_data; + closure_data.event_request = (EventRequest*)hook_data; + closure_data.ts = (LttvTraceState*)call_data; + + g_hash_table_foreach(process_list->Process_Hash, draw_closure, + (void*)&closure_data); + } diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.h index 6add225d..c3f29089 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.h @@ -22,13 +22,13 @@ */ 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 + 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 ; diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c index 370a0349..fcf36282 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c @@ -11,146 +11,146 @@ /* Enumeration of the columns */ enum { - PROCESS_COLUMN, - PID_COLUMN, - BIRTH_S_COLUMN, - BIRTH_NS_COLUMN, - N_COLUMNS + PROCESS_COLUMN, + PID_COLUMN, + BIRTH_S_COLUMN, + BIRTH_NS_COLUMN, + N_COLUMNS }; -gint process_sort_func ( GtkTreeModel *model, - GtkTreeIter *it_a, - GtkTreeIter *it_b, - gpointer user_data) +gint process_sort_func ( GtkTreeModel *model, + GtkTreeIter *it_a, + GtkTreeIter *it_b, + gpointer user_data) { - GValue a, b; - - memset(&a, 0, sizeof(GValue)); - memset(&b, 0, sizeof(GValue)); - - /* Order by PID */ - gtk_tree_model_get_value( model, - it_a, - PID_COLUMN, - &a); - - gtk_tree_model_get_value( model, - it_b, - PID_COLUMN, - &b); - - if(G_VALUE_TYPE(&a) == G_TYPE_UINT - && G_VALUE_TYPE(&b) == G_TYPE_UINT ) - { - if(g_value_get_uint(&a) > g_value_get_uint(&b)) - { - g_value_unset(&a); - g_value_unset(&b); - return 1; - } - if(g_value_get_uint(&a) < g_value_get_uint(&b)) - { - g_value_unset(&a); - g_value_unset(&b); - return 0; - } - } - - g_value_unset(&a); - g_value_unset(&b); - - - /* Order by birth second */ - gtk_tree_model_get_value( model, - it_a, - BIRTH_S_COLUMN, - &a); - - gtk_tree_model_get_value( model, - it_b, - BIRTH_S_COLUMN, - &b); - - - if(G_VALUE_TYPE(&a) == G_TYPE_ULONG - && G_VALUE_TYPE(&b) == G_TYPE_ULONG ) - { - if(g_value_get_ulong(&a) > g_value_get_ulong(&b)) - { - g_value_unset(&a); - g_value_unset(&b); - return 1; - } - if(g_value_get_ulong(&a) < g_value_get_ulong(&b)) - { - g_value_unset(&a); - g_value_unset(&b); - return 0; - } - - } - - g_value_unset(&a); - g_value_unset(&b); - - /* Order by birth nanosecond */ - gtk_tree_model_get_value( model, - it_a, - BIRTH_NS_COLUMN, - &a); - - gtk_tree_model_get_value( model, - it_b, - BIRTH_NS_COLUMN, - &b); - - - if(G_VALUE_TYPE(&a) == G_TYPE_ULONG - && G_VALUE_TYPE(&b) == G_TYPE_ULONG ) - { - if(g_value_get_ulong(&a) > g_value_get_ulong(&b)) - { - g_value_unset(&a); - g_value_unset(&b); - return 1; - } - // Final condition - //if(g_value_get_ulong(&a) < g_value_get_ulong(&b)) - //{ - // g_value_unset(&a); - // g_value_unset(&b); - // return 0; - //} - - } - - g_value_unset(&a); - g_value_unset(&b); - - return 0; + GValue a, b; + + memset(&a, 0, sizeof(GValue)); + memset(&b, 0, sizeof(GValue)); + + /* Order by PID */ + gtk_tree_model_get_value( model, + it_a, + PID_COLUMN, + &a); + + gtk_tree_model_get_value( model, + it_b, + PID_COLUMN, + &b); + + if(G_VALUE_TYPE(&a) == G_TYPE_UINT + && G_VALUE_TYPE(&b) == G_TYPE_UINT ) + { + if(g_value_get_uint(&a) > g_value_get_uint(&b)) + { + g_value_unset(&a); + g_value_unset(&b); + return 1; + } + if(g_value_get_uint(&a) < g_value_get_uint(&b)) + { + g_value_unset(&a); + g_value_unset(&b); + return 0; + } + } + + g_value_unset(&a); + g_value_unset(&b); + + + /* Order by birth second */ + gtk_tree_model_get_value( model, + it_a, + BIRTH_S_COLUMN, + &a); + + gtk_tree_model_get_value( model, + it_b, + BIRTH_S_COLUMN, + &b); + + + if(G_VALUE_TYPE(&a) == G_TYPE_ULONG + && G_VALUE_TYPE(&b) == G_TYPE_ULONG ) + { + if(g_value_get_ulong(&a) > g_value_get_ulong(&b)) + { + g_value_unset(&a); + g_value_unset(&b); + return 1; + } + if(g_value_get_ulong(&a) < g_value_get_ulong(&b)) + { + g_value_unset(&a); + g_value_unset(&b); + return 0; + } + + } + + g_value_unset(&a); + g_value_unset(&b); + + /* Order by birth nanosecond */ + gtk_tree_model_get_value( model, + it_a, + BIRTH_NS_COLUMN, + &a); + + gtk_tree_model_get_value( model, + it_b, + BIRTH_NS_COLUMN, + &b); + + + if(G_VALUE_TYPE(&a) == G_TYPE_ULONG + && G_VALUE_TYPE(&b) == G_TYPE_ULONG ) + { + if(g_value_get_ulong(&a) > g_value_get_ulong(&b)) + { + g_value_unset(&a); + g_value_unset(&b); + return 1; + } + // Final condition + //if(g_value_get_ulong(&a) < g_value_get_ulong(&b)) + //{ + // g_value_unset(&a); + // g_value_unset(&b); + // return 0; + //} + + } + + g_value_unset(&a); + g_value_unset(&b); + + return 0; } guint hash_fct(gconstpointer key) { - return ((ProcessInfo*)key)->pid; + return ((ProcessInfo*)key)->pid; } gboolean equ_fct(gconstpointer a, gconstpointer b) { - if(((ProcessInfo*)a)->pid != ((ProcessInfo*)b)->pid) - return 0; -// g_critical("compare %u and %u",((ProcessInfo*)a)->pid,((ProcessInfo*)b)->pid); - if(((ProcessInfo*)a)->birth.tv_sec != ((ProcessInfo*)b)->birth.tv_sec) - return 0; -// g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_sec,((ProcessInfo*)b)->birth.tv_sec); - - if(((ProcessInfo*)a)->birth.tv_nsec != ((ProcessInfo*)b)->birth.tv_nsec) - return 0; -// g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_nsec,((ProcessInfo*)b)->birth.tv_nsec); - - return 1; + if(((ProcessInfo*)a)->pid != ((ProcessInfo*)b)->pid) + return 0; +// g_critical("compare %u and %u",((ProcessInfo*)a)->pid,((ProcessInfo*)b)->pid); + if(((ProcessInfo*)a)->birth.tv_sec != ((ProcessInfo*)b)->birth.tv_sec) + return 0; +// g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_sec,((ProcessInfo*)b)->birth.tv_sec); + + if(((ProcessInfo*)a)->birth.tv_nsec != ((ProcessInfo*)b)->birth.tv_nsec) + return 0; +// g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_nsec,((ProcessInfo*)b)->birth.tv_nsec); + + return 1; } void destroy_hash_key(gpointer key); @@ -162,351 +162,351 @@ void destroy_hash_data(gpointer data); ProcessList *processlist_construct(void) { - GtkTreeViewColumn *column; - GtkCellRenderer *renderer; - - ProcessList* Process_List = g_new(ProcessList,1); - - Process_List->Number_Of_Process = 0; - - /* Create the Process list */ - Process_List->Store_M = gtk_list_store_new ( N_COLUMNS, - G_TYPE_STRING, - G_TYPE_UINT, - G_TYPE_ULONG, - G_TYPE_ULONG); - - - Process_List->Process_List_VC = - gtk_tree_view_new_with_model - (GTK_TREE_MODEL (Process_List->Store_M)); - - g_object_unref (G_OBJECT (Process_List->Store_M)); - - gtk_tree_sortable_set_sort_func( - GTK_TREE_SORTABLE(Process_List->Store_M), - PID_COLUMN, - process_sort_func, - NULL, - NULL); - - gtk_tree_sortable_set_sort_column_id( - GTK_TREE_SORTABLE(Process_List->Store_M), - PID_COLUMN, - GTK_SORT_ASCENDING); - - Process_List->Process_Hash = g_hash_table_new_full( - hash_fct, equ_fct, - destroy_hash_key, destroy_hash_data - ); - - - gtk_tree_view_set_headers_visible( - GTK_TREE_VIEW(Process_List->Process_List_VC), FALSE); - - /* Create a column, associating the "text" attribute of the - * cell_renderer to the first column of the model */ - /* Columns alignment : 0.0 : Left 0.5 : Center 1.0 : Right */ - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes ( "Process", - renderer, - "text", - PROCESS_COLUMN, - NULL); - gtk_tree_view_column_set_alignment (column, 0.0); - gtk_tree_view_column_set_fixed_width (column, 45); - gtk_tree_view_append_column ( - GTK_TREE_VIEW (Process_List->Process_List_VC), column); - - column = gtk_tree_view_column_new_with_attributes ( "PID", - renderer, - "text", - PID_COLUMN, - NULL); - gtk_tree_view_append_column ( - GTK_TREE_VIEW (Process_List->Process_List_VC), column); - - - column = gtk_tree_view_column_new_with_attributes ( "Birth sec", - renderer, - "text", - BIRTH_S_COLUMN, - NULL); - gtk_tree_view_append_column ( - GTK_TREE_VIEW (Process_List->Process_List_VC), column); - - //gtk_tree_view_column_set_visible(column, 0); - // - column = gtk_tree_view_column_new_with_attributes ( "Birth nsec", - renderer, - "text", - BIRTH_NS_COLUMN, - NULL); - gtk_tree_view_append_column ( - GTK_TREE_VIEW (Process_List->Process_List_VC), column); - - //gtk_tree_view_column_set_visible(column, 0); - - g_object_set_data_full( - G_OBJECT(Process_List->Process_List_VC), - "Process_List_Data", - Process_List, - (GDestroyNotify)processlist_destroy); - - Process_List->Test_Process_Sent = 0; - - return Process_List; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + + ProcessList* Process_List = g_new(ProcessList,1); + + Process_List->Number_Of_Process = 0; + + /* Create the Process list */ + Process_List->Store_M = gtk_list_store_new ( N_COLUMNS, + G_TYPE_STRING, + G_TYPE_UINT, + G_TYPE_ULONG, + G_TYPE_ULONG); + + + Process_List->Process_List_VC = + gtk_tree_view_new_with_model + (GTK_TREE_MODEL (Process_List->Store_M)); + + g_object_unref (G_OBJECT (Process_List->Store_M)); + + gtk_tree_sortable_set_sort_func( + GTK_TREE_SORTABLE(Process_List->Store_M), + PID_COLUMN, + process_sort_func, + NULL, + NULL); + + gtk_tree_sortable_set_sort_column_id( + GTK_TREE_SORTABLE(Process_List->Store_M), + PID_COLUMN, + GTK_SORT_ASCENDING); + + Process_List->Process_Hash = g_hash_table_new_full( + hash_fct, equ_fct, + destroy_hash_key, destroy_hash_data + ); + + + gtk_tree_view_set_headers_visible( + GTK_TREE_VIEW(Process_List->Process_List_VC), FALSE); + + /* Create a column, associating the "text" attribute of the + * cell_renderer to the first column of the model */ + /* Columns alignment : 0.0 : Left 0.5 : Center 1.0 : Right */ + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ( "Process", + renderer, + "text", + PROCESS_COLUMN, + NULL); + gtk_tree_view_column_set_alignment (column, 0.0); + gtk_tree_view_column_set_fixed_width (column, 45); + gtk_tree_view_append_column ( + GTK_TREE_VIEW (Process_List->Process_List_VC), column); + + column = gtk_tree_view_column_new_with_attributes ( "PID", + renderer, + "text", + PID_COLUMN, + NULL); + gtk_tree_view_append_column ( + GTK_TREE_VIEW (Process_List->Process_List_VC), column); + + + column = gtk_tree_view_column_new_with_attributes ( "Birth sec", + renderer, + "text", + BIRTH_S_COLUMN, + NULL); + gtk_tree_view_append_column ( + GTK_TREE_VIEW (Process_List->Process_List_VC), column); + + //gtk_tree_view_column_set_visible(column, 0); + // + column = gtk_tree_view_column_new_with_attributes ( "Birth nsec", + renderer, + "text", + BIRTH_NS_COLUMN, + NULL); + gtk_tree_view_append_column ( + GTK_TREE_VIEW (Process_List->Process_List_VC), column); + + //gtk_tree_view_column_set_visible(column, 0); + + g_object_set_data_full( + G_OBJECT(Process_List->Process_List_VC), + "Process_List_Data", + Process_List, + (GDestroyNotify)processlist_destroy); + + Process_List->Test_Process_Sent = 0; + + return Process_List; } void processlist_destroy(ProcessList *Process_List) { - g_hash_table_destroy(Process_List->Process_Hash); - Process_List->Process_Hash = NULL; + g_hash_table_destroy(Process_List->Process_Hash); + Process_List->Process_Hash = NULL; - g_free(Process_List); + g_free(Process_List); } GtkWidget *processlist_get_widget(ProcessList *Process_List) { - return Process_List->Process_List_VC; + return Process_List->Process_List_VC; } gint get_cell_height(GtkTreeView *TreeView) { - gint height; - GtkTreeViewColumn *Column = gtk_tree_view_get_column(TreeView, 0); - //GList *Render_List = gtk_tree_view_column_get_cell_renderers(Column); - //GtkCellRenderer *Renderer = g_list_first(Render_List)->data; - - //g_list_free(Render_List); - gtk_tree_view_column_cell_get_size(Column, NULL, NULL, NULL, NULL, &height); - //g_critical("cell 0 height : %u",height); - - return height; + gint height; + GtkTreeViewColumn *Column = gtk_tree_view_get_column(TreeView, 0); + //GList *Render_List = gtk_tree_view_column_get_cell_renderers(Column); + //GtkCellRenderer *Renderer = g_list_first(Render_List)->data; + + //g_list_free(Render_List); + gtk_tree_view_column_cell_get_size(Column, NULL, NULL, NULL, NULL, &height); + //g_critical("cell 0 height : %u",height); + + return height; } void destroy_hash_key(gpointer key) { - g_free(key); + g_free(key); } void destroy_hash_data(gpointer data) { - g_free(data); + g_free(data); } -int processlist_add( ProcessList *Process_List, - guint pid, - LttTime *birth, - gchar *name, - guint *height, - HashedProcessData **pmHashed_Process_Data) +int processlist_add( ProcessList *Process_List, + guint pid, + LttTime *birth, + gchar *name, + guint *height, + HashedProcessData **pmHashed_Process_Data) { - GtkTreeIter iter ; - ProcessInfo *Process_Info = g_new(ProcessInfo, 1); - HashedProcessData *Hashed_Process_Data = g_new(HashedProcessData, 1); - *pmHashed_Process_Data = Hashed_Process_Data; - - Process_Info->pid = pid; - Process_Info->birth = *birth; - - Hashed_Process_Data->draw_context = g_new(DrawContext, 1); - Hashed_Process_Data->draw_context->drawable = NULL; - Hashed_Process_Data->draw_context->gc = NULL; - Hashed_Process_Data->draw_context->pango_layout = NULL; - Hashed_Process_Data->draw_context->Current = g_new(DrawInfo,1); - Hashed_Process_Data->draw_context->Current->over = g_new(ItemInfo,1); - Hashed_Process_Data->draw_context->Current->over->x = -1; - Hashed_Process_Data->draw_context->Current->over->y = -1; - Hashed_Process_Data->draw_context->Current->middle = g_new(ItemInfo,1); - Hashed_Process_Data->draw_context->Current->middle->x = -1; - Hashed_Process_Data->draw_context->Current->middle->y = -1; - Hashed_Process_Data->draw_context->Current->under = g_new(ItemInfo,1); - Hashed_Process_Data->draw_context->Current->under->x = -1; - Hashed_Process_Data->draw_context->Current->under->y = -1; - Hashed_Process_Data->draw_context->Current->modify_over = g_new(ItemInfo,1); - Hashed_Process_Data->draw_context->Current->modify_over->x = -1; - Hashed_Process_Data->draw_context->Current->modify_over->y = -1; - Hashed_Process_Data->draw_context->Current->modify_middle = g_new(ItemInfo,1); - Hashed_Process_Data->draw_context->Current->modify_middle->x = -1; - Hashed_Process_Data->draw_context->Current->modify_middle->y = -1; - Hashed_Process_Data->draw_context->Current->modify_under = g_new(ItemInfo,1); - Hashed_Process_Data->draw_context->Current->modify_under->x = -1; - Hashed_Process_Data->draw_context->Current->modify_under->y = -1; - Hashed_Process_Data->draw_context->Current->status = LTTV_STATE_UNNAMED; - Hashed_Process_Data->draw_context->Previous = g_new(DrawInfo,1); - Hashed_Process_Data->draw_context->Previous->over = g_new(ItemInfo,1); - Hashed_Process_Data->draw_context->Previous->over->x = -1; - Hashed_Process_Data->draw_context->Previous->over->y = -1; - Hashed_Process_Data->draw_context->Previous->middle = g_new(ItemInfo,1); - Hashed_Process_Data->draw_context->Previous->middle->x = -1; - Hashed_Process_Data->draw_context->Previous->middle->y = -1; - Hashed_Process_Data->draw_context->Previous->under = g_new(ItemInfo,1); - Hashed_Process_Data->draw_context->Previous->under->x = -1; - Hashed_Process_Data->draw_context->Previous->under->y = -1; - Hashed_Process_Data->draw_context->Previous->modify_over = g_new(ItemInfo,1); - Hashed_Process_Data->draw_context->Previous->modify_over->x = -1; - Hashed_Process_Data->draw_context->Previous->modify_over->y = -1; - Hashed_Process_Data->draw_context->Previous->modify_middle = g_new(ItemInfo,1); - Hashed_Process_Data->draw_context->Previous->modify_middle->x = -1; - Hashed_Process_Data->draw_context->Previous->modify_middle->y = -1; - Hashed_Process_Data->draw_context->Previous->modify_under = g_new(ItemInfo,1); - 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; - - /* Add a new row to the model */ - gtk_list_store_append ( Process_List->Store_M, &iter); - //g_critical ( "iter before : %s", gtk_tree_path_to_string ( - // gtk_tree_model_get_path ( - // GTK_TREE_MODEL(Process_List->Store_M), - // &iter))); - gtk_list_store_set ( Process_List->Store_M, &iter, - PROCESS_COLUMN, name, - PID_COLUMN, pid, - BIRTH_S_COLUMN, birth->tv_sec, - BIRTH_NS_COLUMN, birth->tv_nsec, - -1); - Hashed_Process_Data->RowRef = gtk_tree_row_reference_new ( - GTK_TREE_MODEL(Process_List->Store_M), - gtk_tree_model_get_path( - GTK_TREE_MODEL(Process_List->Store_M), - &iter)); - g_hash_table_insert( Process_List->Process_Hash, - (gpointer)Process_Info, - (gpointer)Hashed_Process_Data); - - //g_critical ( "iter after : %s", gtk_tree_path_to_string ( - // gtk_tree_model_get_path ( - // GTK_TREE_MODEL(Process_List->Store_M), - // &iter))); - Process_List->Number_Of_Process++; - - *height = get_cell_height(GTK_TREE_VIEW(Process_List->Process_List_VC)) - * Process_List->Number_Of_Process ; - - - return 0; - + GtkTreeIter iter ; + ProcessInfo *Process_Info = g_new(ProcessInfo, 1); + HashedProcessData *Hashed_Process_Data = g_new(HashedProcessData, 1); + *pmHashed_Process_Data = Hashed_Process_Data; + + Process_Info->pid = pid; + Process_Info->birth = *birth; + + Hashed_Process_Data->draw_context = g_new(DrawContext, 1); + Hashed_Process_Data->draw_context->drawable = NULL; + Hashed_Process_Data->draw_context->gc = NULL; + Hashed_Process_Data->draw_context->pango_layout = NULL; + Hashed_Process_Data->draw_context->Current = g_new(DrawInfo,1); + Hashed_Process_Data->draw_context->Current->over = g_new(ItemInfo,1); + Hashed_Process_Data->draw_context->Current->over->x = -1; + Hashed_Process_Data->draw_context->Current->over->y = -1; + Hashed_Process_Data->draw_context->Current->middle = g_new(ItemInfo,1); + Hashed_Process_Data->draw_context->Current->middle->x = -1; + Hashed_Process_Data->draw_context->Current->middle->y = -1; + Hashed_Process_Data->draw_context->Current->under = g_new(ItemInfo,1); + Hashed_Process_Data->draw_context->Current->under->x = -1; + Hashed_Process_Data->draw_context->Current->under->y = -1; + Hashed_Process_Data->draw_context->Current->modify_over = g_new(ItemInfo,1); + Hashed_Process_Data->draw_context->Current->modify_over->x = -1; + Hashed_Process_Data->draw_context->Current->modify_over->y = -1; + Hashed_Process_Data->draw_context->Current->modify_middle = g_new(ItemInfo,1); + Hashed_Process_Data->draw_context->Current->modify_middle->x = -1; + Hashed_Process_Data->draw_context->Current->modify_middle->y = -1; + Hashed_Process_Data->draw_context->Current->modify_under = g_new(ItemInfo,1); + Hashed_Process_Data->draw_context->Current->modify_under->x = -1; + Hashed_Process_Data->draw_context->Current->modify_under->y = -1; + Hashed_Process_Data->draw_context->Current->status = LTTV_STATE_UNNAMED; + Hashed_Process_Data->draw_context->Previous = g_new(DrawInfo,1); + Hashed_Process_Data->draw_context->Previous->over = g_new(ItemInfo,1); + Hashed_Process_Data->draw_context->Previous->over->x = -1; + Hashed_Process_Data->draw_context->Previous->over->y = -1; + Hashed_Process_Data->draw_context->Previous->middle = g_new(ItemInfo,1); + Hashed_Process_Data->draw_context->Previous->middle->x = -1; + Hashed_Process_Data->draw_context->Previous->middle->y = -1; + Hashed_Process_Data->draw_context->Previous->under = g_new(ItemInfo,1); + Hashed_Process_Data->draw_context->Previous->under->x = -1; + Hashed_Process_Data->draw_context->Previous->under->y = -1; + Hashed_Process_Data->draw_context->Previous->modify_over = g_new(ItemInfo,1); + Hashed_Process_Data->draw_context->Previous->modify_over->x = -1; + Hashed_Process_Data->draw_context->Previous->modify_over->y = -1; + Hashed_Process_Data->draw_context->Previous->modify_middle = g_new(ItemInfo,1); + Hashed_Process_Data->draw_context->Previous->modify_middle->x = -1; + Hashed_Process_Data->draw_context->Previous->modify_middle->y = -1; + Hashed_Process_Data->draw_context->Previous->modify_under = g_new(ItemInfo,1); + 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; + + /* Add a new row to the model */ + gtk_list_store_append ( Process_List->Store_M, &iter); + //g_critical ( "iter before : %s", gtk_tree_path_to_string ( + // gtk_tree_model_get_path ( + // GTK_TREE_MODEL(Process_List->Store_M), + // &iter))); + gtk_list_store_set ( Process_List->Store_M, &iter, + PROCESS_COLUMN, name, + PID_COLUMN, pid, + BIRTH_S_COLUMN, birth->tv_sec, + BIRTH_NS_COLUMN, birth->tv_nsec, + -1); + Hashed_Process_Data->RowRef = gtk_tree_row_reference_new ( + GTK_TREE_MODEL(Process_List->Store_M), + gtk_tree_model_get_path( + GTK_TREE_MODEL(Process_List->Store_M), + &iter)); + g_hash_table_insert( Process_List->Process_Hash, + (gpointer)Process_Info, + (gpointer)Hashed_Process_Data); + + //g_critical ( "iter after : %s", gtk_tree_path_to_string ( + // gtk_tree_model_get_path ( + // GTK_TREE_MODEL(Process_List->Store_M), + // &iter))); + Process_List->Number_Of_Process++; + + *height = get_cell_height(GTK_TREE_VIEW(Process_List->Process_List_VC)) + * Process_List->Number_Of_Process ; + + + return 0; + } -int processlist_remove( ProcessList *Process_List, - guint pid, - LttTime *birth) +int processlist_remove( ProcessList *Process_List, + guint pid, + LttTime *birth) { - ProcessInfo Process_Info; - gint *path_indices; - HashedProcessData *Hashed_Process_Data; - GtkTreeIter iter; - - Process_Info.pid = pid; - Process_Info.birth = *birth; - - - if(Hashed_Process_Data = - (HashedProcessData*)g_hash_table_lookup( - Process_List->Process_Hash, - &Process_Info)) - { - gtk_tree_model_get_iter ( - GTK_TREE_MODEL(Process_List->Store_M), - &iter, - gtk_tree_row_reference_get_path( - (GtkTreeRowReference*)Hashed_Process_Data->RowRef) - ); - - gtk_list_store_remove (Process_List->Store_M, &iter); - - 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); - - g_hash_table_remove(Process_List->Process_Hash, - &Process_Info); - - Process_List->Number_Of_Process--; - - return 0; - } else { - return 1; - } + ProcessInfo Process_Info; + gint *path_indices; + HashedProcessData *Hashed_Process_Data; + GtkTreeIter iter; + + Process_Info.pid = pid; + Process_Info.birth = *birth; + + + if(Hashed_Process_Data = + (HashedProcessData*)g_hash_table_lookup( + Process_List->Process_Hash, + &Process_Info)) + { + gtk_tree_model_get_iter ( + GTK_TREE_MODEL(Process_List->Store_M), + &iter, + gtk_tree_row_reference_get_path( + (GtkTreeRowReference*)Hashed_Process_Data->RowRef) + ); + + gtk_list_store_remove (Process_List->Store_M, &iter); + + 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); + + g_hash_table_remove(Process_List->Process_Hash, + &Process_Info); + + Process_List->Number_Of_Process--; + + return 0; + } else { + return 1; + } } guint processlist_get_height(ProcessList *Process_List) { - return get_cell_height(GTK_TREE_VIEW(Process_List->Process_List_VC)) - * Process_List->Number_Of_Process ; + return get_cell_height(GTK_TREE_VIEW(Process_List->Process_List_VC)) + * Process_List->Number_Of_Process ; } -gint processlist_get_process_pixels( ProcessList *Process_List, - guint pid, LttTime *birth, - guint *y, - guint *height, - HashedProcessData **pmHashed_Process_Data) +gint processlist_get_process_pixels( ProcessList *Process_List, + guint pid, LttTime *birth, + guint *y, + guint *height, + HashedProcessData **pmHashed_Process_Data) { - ProcessInfo Process_Info; - gint *path_indices; - GtkTreePath *tree_path; - HashedProcessData *Hashed_Process_Data = NULL; - - Process_Info.pid = pid; - Process_Info.birth = *birth; - - if(Hashed_Process_Data = - (HashedProcessData*)g_hash_table_lookup( - Process_List->Process_Hash, - &Process_Info)) - { - tree_path = gtk_tree_row_reference_get_path( - Hashed_Process_Data->RowRef); - path_indices = gtk_tree_path_get_indices (tree_path); - - *height = get_cell_height( - GTK_TREE_VIEW(Process_List->Process_List_VC)); - *y = *height * path_indices[0]; - *pmHashed_Process_Data = Hashed_Process_Data; - return 0; - } else { - *pmHashed_Process_Data = Hashed_Process_Data; - return 1; - } + ProcessInfo Process_Info; + gint *path_indices; + GtkTreePath *tree_path; + HashedProcessData *Hashed_Process_Data = NULL; + + Process_Info.pid = pid; + Process_Info.birth = *birth; + + if(Hashed_Process_Data = + (HashedProcessData*)g_hash_table_lookup( + Process_List->Process_Hash, + &Process_Info)) + { + tree_path = gtk_tree_row_reference_get_path( + Hashed_Process_Data->RowRef); + path_indices = gtk_tree_path_get_indices (tree_path); + + *height = get_cell_height( + GTK_TREE_VIEW(Process_List->Process_List_VC)); + *y = *height * path_indices[0]; + *pmHashed_Process_Data = Hashed_Process_Data; + return 0; + } else { + *pmHashed_Process_Data = Hashed_Process_Data; + return 1; + } } -gint processlist_get_pixels_from_data( ProcessList *Process_List, - ProcessInfo *process_info, - HashedProcessData *Hashed_Process_Data, - guint *y, - guint *height) +gint processlist_get_pixels_from_data( ProcessList *Process_List, + ProcessInfo *process_info, + HashedProcessData *Hashed_Process_Data, + guint *y, + guint *height) { - gint *path_indices; - GtkTreePath *tree_path; + gint *path_indices; + GtkTreePath *tree_path; - tree_path = gtk_tree_row_reference_get_path( - Hashed_Process_Data->RowRef); - path_indices = gtk_tree_path_get_indices (tree_path); + tree_path = gtk_tree_row_reference_get_path( + Hashed_Process_Data->RowRef); + path_indices = gtk_tree_path_get_indices (tree_path); - *height = get_cell_height( - GTK_TREE_VIEW(Process_List->Process_List_VC)); - *y = *height * path_indices[0]; + *height = get_cell_height( + GTK_TREE_VIEW(Process_List->Process_List_VC)); + *y = *height * path_indices[0]; - return 0; + return 0; } diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.h index 9b2d7b1f..625c9bcb 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.h @@ -13,37 +13,37 @@ * contains the data for the process list * tells the height of the process list widget * provides methods to add/remove process from the list - * note : the sync with drawing is left to the caller. + * note : the sync with drawing is left to the caller. * provides helper function to convert a process unique identifier to - * pixels (in height). + * pixels (in height). * * //FIXME : connect the scrolled window adjustment with the list. */ typedef struct _ProcessInfo { - - guint pid; - LttTime birth; + + guint pid; + LttTime birth; } ProcessInfo; typedef struct _HashedProcessData { - - GtkTreeRowReference *RowRef; - DrawContext *draw_context; + + GtkTreeRowReference *RowRef; + DrawContext *draw_context; } HashedProcessData; - + struct _ProcessList { - - GtkWidget *Process_List_VC; - GtkListStore *Store_M; + + GtkWidget *Process_List_VC; + GtkListStore *Store_M; - /* A hash table by PID to speed up process position find in the list */ - GHashTable *Process_Hash; - - guint Number_Of_Process; - gboolean Test_Process_Sent; + /* A hash table by PID to speed up process position find in the list */ + GHashTable *Process_Hash; + + guint Number_Of_Process; + gboolean Test_Process_Sent; }; @@ -56,8 +56,8 @@ GtkWidget *processlist_get_widget(ProcessList *Process_List); // out : success (0) and height int processlist_add(ProcessList *Process_List, guint pid, LttTime *birth, - gchar *name, - guint *height, HashedProcessData **Hashed_Process_Data); + gchar *name, + guint *height, HashedProcessData **Hashed_Process_Data); // out : success (0) and height int processlist_remove(ProcessList *Process_List, guint pid, LttTime *birth); @@ -65,14 +65,14 @@ guint processlist_get_height(ProcessList *Process_List); // Returns 0 on success gint processlist_get_process_pixels(ProcessList *Process_List, - guint pid, LttTime *birth, - guint *y, guint *height, - HashedProcessData **Hashed_Process_Data); - -gint processlist_get_pixels_from_data( ProcessList *Process_List, - ProcessInfo *process_info, - HashedProcessData *Hashed_Process_Data, - guint *y, - guint *height); + guint pid, LttTime *birth, + guint *y, guint *height, + HashedProcessData **Hashed_Process_Data); + +gint processlist_get_pixels_from_data( ProcessList *Process_List, + ProcessInfo *process_info, + HashedProcessData *Hashed_Process_Data, + guint *y, + guint *height); #endif // _PROCESS_LIST_H diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/module.c b/ltt/branches/poly/lttv/modules/guiControlFlow/module.c index dde25f28..7e5ab92e 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/module.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/module.c @@ -50,29 +50,29 @@ GSList *gControl_Flow_Data_List = NULL ; */ G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { - Main_Win_Module = lttv_module_require(self, "mainwin", argc, argv); - - if(Main_Win_Module == NULL) - { - g_critical("Can't load Control Flow Viewer : missing mainwin\n"); - return; - } - - g_info("GUI ControlFlow Viewer init()"); - - /* Register the toolbar insert button */ - toolbar_item_reg(hGuiControlFlowInsert_xpm, "Insert Control Flow Viewer", - h_guicontrolflow); - - /* Register the menu item insert entry */ - menu_item_reg("/", "Insert Control Flow Viewer", h_guicontrolflow); - + Main_Win_Module = lttv_module_require(self, "mainwin", argc, argv); + + if(Main_Win_Module == NULL) + { + g_critical("Can't load Control Flow Viewer : missing mainwin\n"); + return; + } + + g_info("GUI ControlFlow Viewer init()"); + + /* Register the toolbar insert button */ + toolbar_item_reg(hGuiControlFlowInsert_xpm, "Insert Control Flow Viewer", + h_guicontrolflow); + + /* Register the menu item insert entry */ + menu_item_reg("/", "Insert Control Flow Viewer", h_guicontrolflow); + } void destroy_walk(gpointer data, gpointer user_data) { - g_info("Walk destroy GUI Control Flow Viewer"); - guicontrolflow_destructor_full((ControlFlowData*)data); + g_info("Walk destroy GUI Control Flow Viewer"); + guicontrolflow_destructor_full((ControlFlowData*)data); } @@ -84,17 +84,17 @@ void destroy_walk(gpointer data, gpointer user_data) * everything that has been registered in the gtkTraceSet API. */ G_MODULE_EXPORT void destroy() { - g_info("GUI Control Flow Viewer destroy()"); - int i; + g_info("GUI Control Flow Viewer destroy()"); + int i; - g_slist_foreach(gControl_Flow_Data_List, destroy_walk, NULL ); - - g_slist_free(gControl_Flow_Data_List); + g_slist_foreach(gControl_Flow_Data_List, destroy_walk, NULL ); + + g_slist_free(gControl_Flow_Data_List); - /* Unregister the toolbar insert button */ - toolbar_item_unreg(h_guicontrolflow); + /* Unregister the toolbar insert button */ + toolbar_item_unreg(h_guicontrolflow); - /* Unregister the menu item insert entry */ - menu_item_unreg(h_guicontrolflow); - + /* Unregister the menu item insert entry */ + menu_item_unreg(h_guicontrolflow); + } -- 2.34.1