From 55042dac77ebd58211be612641accdad13e22e56 Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 29 Jan 2004 19:04:27 +0000 Subject: [PATCH] remove old files git-svn-id: http://ltt.polymtl.ca/svn@442 04897980-b3bd-0310-b5e0-8ef037075253 --- .../modules/gui/controlflow/CFV-private.h | 28 - .../poly/lttv/modules/gui/controlflow/CFV.c | 173 --- .../poly/lttv/modules/gui/controlflow/CFV.h | 23 - .../lttv/modules/gui/controlflow/Draw_Item.c | 345 ----- .../lttv/modules/gui/controlflow/Draw_Item.h | 283 ---- .../lttv/modules/gui/controlflow/Drawing.c | 640 --------- .../lttv/modules/gui/controlflow/Drawing.h | 96 -- .../modules/gui/controlflow/Event_Hooks.c | 1205 ----------------- .../modules/gui/controlflow/Event_Hooks.h | 84 -- .../modules/gui/controlflow/Process_List.c | 510 ------- .../modules/gui/controlflow/Process_List.h | 75 - 11 files changed, 3462 deletions(-) delete mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/CFV-private.h delete mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/CFV.c delete mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/CFV.h delete mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/Draw_Item.c delete mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/Draw_Item.h delete mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/Drawing.c delete mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/Drawing.h delete mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/Event_Hooks.c delete mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/Event_Hooks.h delete mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/Process_List.c delete mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/Process_List.h diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/CFV-private.h b/ltt/branches/poly/lttv/modules/gui/controlflow/CFV-private.h deleted file mode 100644 index 2903a281..00000000 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/CFV-private.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _CFV_PRIVATE_H -#define _CFV_PRIVATE_H - - - -struct _ControlFlowData { - - GtkWidget *scrolled_window; - MainWindow *mw; - - ProcessList *process_list; - Drawing_t *drawing; - - GtkWidget *h_paned; - - GtkAdjustment *v_adjust ; - - /* Shown events information */ - TimeWindow time_window; - LttTime current_time; - - //guint currently_Selected_Event ; - guint number_of_process; - -} ; - - -#endif //_CFV_PRIVATE_H diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/CFV.c b/ltt/branches/poly/lttv/modules/gui/controlflow/CFV.c deleted file mode 100644 index ac371adc..00000000 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/CFV.c +++ /dev/null @@ -1,173 +0,0 @@ - -#include -#include -#include - -#include "CFV.h" -#include "Drawing.h" -#include "Process_List.h" -#include "Event_Hooks.h" -#include "CFV-private.h" - - -#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) -#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) - -extern GSList *g_control_flow_data_list; - -/***************************************************************************** - * Control Flow Viewer class implementation * - *****************************************************************************/ -/** - * Control Flow Viewer's constructor - * - * This constructor is given as a parameter to the menuitem and toolbar button - * registration. It creates the drawing widget. - * @param ParentWindow A pointer to the parent window. - * @return The widget created. - */ -ControlFlowData * -guicontrolflow(void) -{ - GtkWidget *process_list_widget, *drawing_widget; - - 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); - - control_flow_data->number_of_process = 0; - - /* 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->h_paned = gtk_hpaned_new(); - - gtk_paned_pack1(GTK_PANED(control_flow_data->h_paned), process_list_widget, FALSE, TRUE); - gtk_paned_pack2(GTK_PANED(control_flow_data->h_paned), drawing_widget, TRUE, TRUE); - - control_flow_data->v_adjust = - 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 = - gtk_scrolled_window_new (NULL, - control_flow_data->v_adjust); - - gtk_scrolled_window_set_policy( - GTK_SCROLLED_WINDOW(control_flow_data->scrolled_window) , - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - - gtk_scrolled_window_add_with_viewport( - GTK_SCROLLED_WINDOW(control_flow_data->scrolled_window), - control_flow_data->h_paned); - - /* 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(process_list_widget); - gtk_widget_show(control_flow_data->h_paned); - gtk_widget_show(control_flow_data->scrolled_window); - - g_object_set_data_full( - G_OBJECT(control_flow_data->scrolled_window), - "control_flow_data", - control_flow_data, - (GDestroyNotify)guicontrolflow_destructor); - - g_object_set_data( - G_OBJECT(drawing_widget), - "control_flow_data", - control_flow_data); - - g_control_flow_data_list = g_slist_append( - g_control_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; - -} - -/* Destroys widget also */ -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)) - gtk_widget_destroy(control_flow_data->scrolled_window); - //control_flow_data->mw = 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->mw); - if(GTK_IS_WIDGET(control_flow_data->scrolled_window)) - g_info("widget still exists"); - - /* Process List is removed with it's widget */ - //ProcessList_destroy(control_flow_data->process_list); - if(control_flow_data->mw != NULL) - { - unreg_update_time_window(update_time_window_hook, - control_flow_data, - control_flow_data->mw); - - unreg_update_current_time(update_current_time_hook, - control_flow_data, - control_flow_data->mw); - } - g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data); - g_slist_remove(g_control_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 ; -} - -ProcessList *guicontrolflow_get_process_list - (ControlFlowData *control_flow_data) -{ - return control_flow_data->process_list ; -} - -TimeWindow *guicontrolflow_get_time_window(ControlFlowData *control_flow_data) -{ - return &control_flow_data->time_window; -} -LttTime *guicontrolflow_get_current_time(ControlFlowData *control_flow_data) -{ - return &control_flow_data->current_time; -} - - diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/CFV.h b/ltt/branches/poly/lttv/modules/gui/controlflow/CFV.h deleted file mode 100644 index 208cbf7e..00000000 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/CFV.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _CFV_H -#define _CFV_H - -#include -#include -#include -#include "Process_List.h" - -typedef struct _ControlFlowData ControlFlowData; - -/* Control Flow Data constructor */ -ControlFlowData *guicontrolflow(void); -void -guicontrolflow_destructor_full(ControlFlowData *control_flow_data); -void -guicontrolflow_destructor(ControlFlowData *control_flow_data); -GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data); -ProcessList *guicontrolflow_get_process_list(ControlFlowData *control_flow_data); -TimeWindow *guicontrolflow_get_time_window(ControlFlowData *control_flow_data); -LttTime *guicontrolflow_get_current_time(ControlFlowData *control_flow_data); - - -#endif // _CFV_H diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/Draw_Item.c b/ltt/branches/poly/lttv/modules/gui/controlflow/Draw_Item.c deleted file mode 100644 index 7c929c82..00000000 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/Draw_Item.c +++ /dev/null @@ -1,345 +0,0 @@ -/****************************************************************************** - * Draw_Item.c - * - * This file contains methods responsible for drawing a generic type of data - * in a drawable. Doing this generically will permit user defined drawing - * behavior in a later time. - * - * This file provides an API which is meant to be reusable for all viewers that - * need to show information in line, icon, text, background or point form in - * a drawable area having time for x axis. The y axis, in the control flow - * viewer case, is corresponding to the different processes, but it can be - * reused integrally for cpu, and eventually locks, buffers, network - * interfaces... What will differ between the viewers is the precise - * information which interests us. We may think that the most useful - * information for control flow are some specific events, like schedule - * change, and processes'states. It may differ for a cpu viewer : the - * interesting information could be more the execution mode of each cpu. - * This API in meant to make viewer's writers life easier : it will become - * a simple choice of icons and line types for the precise information - * the viewer has to provide (agremented with keeping supplementary records - * and modifying slightly the DrawContext to suit the needs.) - * - * We keep each data type in attributes, keys to specific information - * being formed from the GQuark corresponding to the information received. - * (facilities / facility_name / events / eventname.) - * (cpus/cpu_name, process_states/ps_name, - * execution_modes/em_name, execution_submodes/es_name). - * The goal is then to provide a generic way to print information on the - * screen for all this different information. - * - * Information can be printed as - * - * - text (text + color + size + position (over or under line) - * - icon (icon filename, corresponding to a loaded icon, accessible through - * a GQuark. Icons are loaded statically at the guiControlFlow level during - * module initialization and can be added on the fly if not present in the - * GQuark.) The habitual place for xpm icons is in - * ${prefix}/share/LinuxTraceToolkit.) + position (over or under line) - * - line (color, width, style) - * - Arc (big points) (color, size) - * - background color (color) - * - * An item is a leaf of the attributes tree. It is, in that case, including - * all kind of events categories we can have. It then associates each category - * with one or more actions (drawing something) or nothing. - * - * Each item has an array of hooks (hook list). Each hook represents an - * operation to perform. We seek the array each time we want to - * draw an item. We execute each operation in order. An operation type - * is associated with each hook to permit user listing and modification - * of these operations. The operation type is also used to find the - * corresponding priority for the sorting. Operation type and priorities - * are enum and a static int table. - * - * The array has to be sorted by priority each time we add a task in it. - * A priority is associated with each operation type. It permits - * to perform background color selection before line or text drawing. We also - * draw lines before text, so the text appears over the lines. - * - * Executing all the arrays of operations for a specific event (which - * implies information for state, event, cpu, execution mode and submode) - * has to be done in a same DrawContext. The goal there is to keep the offset - * of the text and icons over and under the middle line, so a specific - * event could be printed as ( R Si 0 for running, scheduled in, cpu 0 ), - * text being easy to replace with icons. The DrawContext is passed as - * call_data for the operation hooks. - * - * We use the lttv global attributes to keep track of the loaded icons. - * If we need an icon, we look for it in the icons / icon name pathname. - * If found, we use the pointer to it. If not, we load the pixmap in - * memory and set the pointer to the GdkPixmap in the attributes. The - * structure pointed to contains the pixmap and the mask bitmap. - * - * Author : Mathieu Desnoyers, October 2003 - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Draw_Item.h" - - -#define MAX_PATH_LEN 256 - -/* 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; -} - - -/* To speed up the process, search in already loaded icons list first. Only - * load it if not present. - */ -gboolean draw_icon( void *hook_data, void *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; - - 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; -} - -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; -} - -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; -} - -gboolean draw_bg( void *hook_data, void *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_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; -} - - diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/Draw_Item.h b/ltt/branches/poly/lttv/modules/gui/controlflow/Draw_Item.h deleted file mode 100644 index 9f342052..00000000 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/Draw_Item.h +++ /dev/null @@ -1,283 +0,0 @@ -#ifndef _DRAW_ITEM_H -#define _DRAW_ITEM_H - -#include - -typedef struct _DrawContext DrawContext; -typedef struct _DrawInfo DrawInfo; -typedef struct _ItemInfo ItemInfo; - -typedef struct _IconStruct IconStruct; - -typedef struct _DrawOperation DrawOperation; - - -typedef struct _PropertiesText PropertiesText; -typedef struct _PropertiesIcon PropertiesIcon; -typedef struct _PropertiesLine PropertiesLine; -typedef struct _PropertiesArc PropertiesArc; -typedef struct _PropertiesBG PropertiesBG; - -typedef enum _DrawableItems DrawableItems; -enum _DrawableItems { - ITEM_TEXT, ITEM_ICON, ITEM_LINE, ITEM_POINT, ITEM_BACKGROUND -}; - - -typedef enum _RelPos { - OVER, MIDDLE, UNDER -} RelPos; - - -/* The DrawContext keeps information about the current drawing position and - * the previous one, so we can use both to draw lines. - * - * over : position for drawing over the middle line. - * middle : middle line position. - * under : position for drawing under the middle line. - * - * the modify_* are used to take into account that we should go forward - * when we draw a text, an arc or an icon, while it's unneeded when we - * draw a line or background. - * - */ - - -struct _DrawContext { - GdkDrawable *drawable; - GdkGC *gc; - PangoLayout *pango_layout; - - DrawInfo *current; - DrawInfo *previous; -}; - -/* LttvExecutionState is accessible through the LttvTracefileState. Is has - * a pointer to the LttvProcessState which points to the top of stack - * execution state : LttvExecutionState *state. - * - * LttvExecutionState contains (useful here): - * LttvExecutionMode t, - * LttvExecutionSubmode n, - * LttvProcessStatus s - * - * - * LttvTraceState will be used in the case we need the string of the - * different processes, eventtype_names, syscall_names, trap_names, irq_names. - * - * LttvTracefileState also gives the cpu_name and, as it herits from - * LttvTracefileContext, it gives the LttEvent structure, which is needed - * 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; -}; - -struct _ItemInfo { - gint x, y; -}; - -/* - * Structure used to keep information about icons. - */ -struct _IconStruct { - GdkPixmap *pixmap; - GdkBitmap *mask; -}; - - -/* - * The Item element is only used so the DrawOperation is modifiable by users. - * During drawing, only the Hook is needed. - */ -struct _DrawOperation { - DrawableItems item; - LttvHooks *hook; -}; - -/* - * We define here each items that can be drawn, together with their - * associated priority. Many item types can have the same priority, - * it's only used for quicksorting the operations when we add a new one - * to the array of operations to perform. Lower priorities are executed - * first. So, for example, we may want to give background color a value - * of 10 while a line would have 20, so the background color, which - * is in fact a rectangle, does not hide the line. - */ - -static int Items_Priorities[] = { - 50, /* ITEM_TEXT */ - 40, /* ITEM_ICON */ - 20, /* ITEM_LINE */ - 30, /* ITEM_POINT */ - 10 /* ITEM_BACKGROUND */ -}; - -/* - * Here are the different structures describing each item type that can be - * drawn. They contain the information necessary to draw the item : not the - * position (this is provided by the DrawContext), but the text, icon name, - * line width, color; all the properties of the specific items. - */ - -struct _PropertiesText { - GdkColor *foreground; - GdkColor *background; - gint size; - gchar *text; - RelPos position; -}; - - -struct _PropertiesIcon { - gchar *icon_name; - gint width; - gint height; - RelPos position; -}; - -struct _PropertiesLine { - 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; -}; - -struct _PropertiesBG { - GdkColor *color; -}; - - - -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 : - * - * event_types/ - * "facility-event_type" - * cpus/ - * "cpu name" - * mode_types/ - * "execution mode"/ - * submodes/ - * "submode" - * process_states/ - * "state name" - * - * So if, for example, we want to add a hook to get called each time we - * receive an event that is in state LTTV_STATE_SYSCALL, we put the - * pointer to the GArray of DrawOperation in - * process_states/ "name associated with LTTV_STATE_SYSCALL" - */ - -/* - * 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); - -/* - * 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); - -/* - * 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 ); - - -/* - * 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); - - - -/* - * exec_operation executes the operations if present in the attributes, or - * do nothing if not present. - */ -void exec_operations( LttvIAttribute *attributes, - gchar *pathname); - - -/* - * Functions to create Properties structures. - */ - -PropertiesText *properties_text_create( - GdkColor *foreground, - GdkColor *background, - gint size, - gchar *text, - RelPos position); - -PropertiesIcon *properties_icon_create( - gchar *icon_name, - gint width, - gint height, - RelPos position); - -PropertiesLine *properties_line_create( - GdkColor *color, - gint line_width, - GdkLineStyle style, - RelPos position); - -PropertiesArc *properties_arc_create( - GdkColor *color, - gint size, - gboolean filled, - RelPos position); - -PropertiesBG *properties_bg_create( - GdkColor *color); - - - - -/* - * Here follow the prototypes of the hook functions used to draw the - * different items. - */ - -gboolean draw_text( void *hook_data, void *call_data); -gboolean draw_icon( void *hook_data, void *call_data); -gboolean draw_line( void *hook_data, void *call_data); -gboolean draw_arc( void *hook_data, void *call_data); -gboolean draw_bg( void *hook_data, void *call_data); - - -#endif // _DRAW_ITEM_H diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/Drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/Drawing.c deleted file mode 100644 index 85d2efcb..00000000 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/Drawing.c +++ /dev/null @@ -1,640 +0,0 @@ - -#include -#include - -#include -#include -#include - -#include "Drawing.h" -#include "CFV.h" -#include "CFV-private.h" -#include "Event_Hooks.h" - -#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) -#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) - -/***************************************************************************** - * drawing functions * - *****************************************************************************/ - -//FIXME Colors will need to be dynamic. Graphic context part not done so far. -typedef enum -{ - 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 -}; - - -/* Function responsible for updating the exposed area. - * It must call processTrace() to ask for this update. - * Note : this function cannot clear the background, because it may - * erase drawing already present (SAFETY). - */ -void drawing_data_request(Drawing_t *drawing, - 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), - "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->allocation.width, x, - &control_flow_data->time_window.start_time, - &window_end, - &start); - - convert_pixels_to_time(drawing->drawing_area->allocation.width, x + width, - &control_flow_data->time_window.start_time, - &window_end, - &end); - - LttvTracesetContext * tsc = - get_traceset_context(control_flow_data->mw); - - //send_test_process( - //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->mw); - 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->mw); - - lttv_hooks_destroy(after_traceset); - lttv_hooks_destroy(event); - lttv_hooks_destroy(after_event); - - -} - -/* Callbacks */ - - -/* Create a new backing pixmap of the appropriate size */ -/* As the scaling will always change, it's of no use to copy old - * pixmap. - */ -static gboolean -configure_event( GtkWidget *widget, GdkEventConfigure *event, - 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->mw, - &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); - - g_critical("drawing configure event"); - 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; - - - - } -#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); - - if (drawing->pixmap) - gdk_pixmap_unref(drawing->pixmap); - - drawing->pixmap = pixmap; - - // 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); - - // 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->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"); - drawing_data_request(drawing, &pixmap, drawing->width, 0, - widget->allocation.width - drawing->width, - widget->allocation.height); - - drawing->width = widget->allocation.width; - drawing->height = widget->allocation.height; - - return TRUE; -#endif //NOTUSE -} - - -/* Redraw the screen from the backing pixmap */ -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"); - - 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); - - 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); - } - return FALSE; -} - -/* mouse click */ -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; - - - 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); - - - /* 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); - - set_current_time(control_flow_data->mw, &time); - - } - - return FALSE; -} - - - - -Drawing_t *drawing_construct(ControlFlowData *control_flow_data) -{ - Drawing_t *drawing = g_new(Drawing_t, 1); - - drawing->drawing_area = gtk_drawing_area_new (); - drawing->control_flow_data = control_flow_data; - - drawing->pango_layout = - gtk_widget_create_pango_layout(drawing->drawing_area, NULL); - - //gtk_widget_set_size_request(drawing->drawing_area->window, 50, 50); - g_object_set_data_full( - G_OBJECT(drawing->drawing_area), - "Link_drawing_Data", - drawing, - (GDestroyNotify)drawing_destroy); - - //gtk_widget_modify_bg( drawing->drawing_area, - // GTK_STATE_NORMAL, - // &CF_Colors[BLACK]); - - //gdk_window_get_geometry(drawing->drawing_area->window, - // NULL, NULL, - // &(drawing->width), - // &(drawing->height), - // -1); - - //drawing->pixmap = gdk_pixmap_new( - // drawing->drawing_area->window, - // drawing->width, - // drawing->height, - // drawing->depth); - - drawing->pixmap = NULL; - -// drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window, -// drawing->drawing_area->allocation.width, -// drawing->drawing_area->allocation.height, -// -1); - - gtk_widget_add_events(drawing->drawing_area, GDK_BUTTON_PRESS_MASK); - - g_signal_connect (G_OBJECT(drawing->drawing_area), - "configure_event", - G_CALLBACK (configure_event), - (gpointer)drawing); - - g_signal_connect (G_OBJECT(drawing->drawing_area), - "expose_event", - G_CALLBACK (expose_event), - (gpointer)drawing); - - g_signal_connect (G_OBJECT(drawing->drawing_area), - "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)); - - g_free(drawing->pango_layout); - g_free(drawing); -} - -GtkWidget *drawing_get_widget(Drawing_t *drawing) -{ - return drawing->drawing_area; -} - -/* convert_pixels_to_time - * - * 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) -{ - 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); -} - - - -void convert_time_to_pixels( - 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); - -} - -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->window, - drawing->drawing_area-> - style->fg_gc[GTK_WIDGET_STATE (drawing->drawing_area)], - 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, &update_rect); - -} - - -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); -} - - - - -void drawing_resize(Drawing_t *drawing, guint h, guint w) -{ - drawing->height = h ; - drawing->width = w ; - - gtk_widget_set_size_request ( drawing->drawing_area, - 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) -{ - //GdkRectangle update_rect; - - /* Allocate a new pixmap with new height */ - GdkPixmap *pixmap = gdk_pixmap_new(drawing->drawing_area->window, - drawing->width + SAFETY, - drawing->height + height + SAFETY, - -1); - - /* Copy the high region */ - gdk_draw_drawable (pixmap, - drawing->drawing_area->style->black_gc, - drawing->pixmap, - 0, 0, - 0, 0, - drawing->width + SAFETY, y); - - - - - /* add an empty square */ - gdk_draw_rectangle (pixmap, - drawing->drawing_area->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->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; - - /* 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, &update_rect); -} - - -/* Remove a square corresponding to a removed process in the list */ -void drawing_remove_square(Drawing_t *drawing, - guint y, - guint height) -{ - //GdkRectangle update_rect; - - /* Allocate a new pixmap with new height */ - GdkPixmap *pixmap = gdk_pixmap_new( - drawing->drawing_area->window, - drawing->width + SAFETY, - drawing->height - height + SAFETY, - -1); - - /* Copy the high region */ - gdk_draw_drawable (pixmap, - drawing->drawing_area->style->black_gc, - drawing->pixmap, - 0, 0, - 0, 0, - drawing->width + SAFETY, y); - - - - /* Copy up the bottom of the region */ - gdk_draw_drawable (pixmap, - drawing->drawing_area->style->black_gc, - drawing->pixmap, - 0, y + height, - 0, y, - drawing->width, drawing->height - y - height + 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, &update_rect); -} - - diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/Drawing.h b/ltt/branches/poly/lttv/modules/gui/controlflow/Drawing.h deleted file mode 100644 index d4b6afd6..00000000 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/Drawing.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef _DRAWING_H -#define _DRAWING_H - -#include -#include -#include -#include -#include "CFV.h" -#include "Draw_Item.h" - - -#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. - * Copy region of the screen into another. - * Modify the boundaries to reflect a scale change. (resize) - * Refresh the physical screen with the pixmap - * A helper function is provided here to convert from time to process - * identifier to pixels and the contrary (will be useful for mouse selection). - * Insert an empty square in the drawing, moving the bottom part. - * - * Note: The last point is exactly why it would not be so easy to add the - * vertical line functionnality as in the original version of LTT. In order - * to do so, we should keep all processes in the list for the duration of - * all the trace instead of dynamically adding and removing them when we - * scroll. Another possibility is to redraw all the visible area when a new - * process is added to the list. The second solution seems more appropriate - * to me. - * - * - * The pixmap used has the width of the physical window, but the height - * of the shown processes. - */ - -typedef struct _Drawing_t Drawing_t; - -struct _Drawing_t { - GtkWidget *drawing_area; - 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_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); - -/* Insert a square corresponding to a new process in the list */ -void drawing_insert_square(Drawing_t *drawing, - 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); - - -//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); - -void convert_time_to_pixels( - 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/gui/controlflow/Event_Hooks.c b/ltt/branches/poly/lttv/modules/gui/controlflow/Event_Hooks.c deleted file mode 100644 index 2905f6bd..00000000 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/Event_Hooks.c +++ /dev/null @@ -1,1205 +0,0 @@ -/***************************************************************************** - * Hooks to be called by the main window * - *****************************************************************************/ - - -#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) -#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) - -//#define PANGO_ENABLE_BACKEND -#include -#include -#include -#include -#include - -//#include - -#include -#include -#include - -#include -#include -#include -#include - - -#include "Event_Hooks.h" -#include "CFV.h" -#include "Process_List.h" -#include "Drawing.h" -#include "CFV-private.h" - - -#define MAX_PATH_LEN 256 - - -/** - * Event Viewer's constructor hook - * - * This constructor is given as a parameter to the menuitem and toolbar button - * registration. It creates the list. - * @param mw A pointer to the parent window. - * @return The widget created. - */ -GtkWidget * -h_guicontrolflow(MainWindow *mw, LttvTracesetSelector * s, char * key) -{ - g_info("h_guicontrolflow, %p, %p, %s", mw, s, key); - ControlFlowData *control_flow_data = guicontrolflow() ; - - control_flow_data->mw = mw; - 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(mw, - time_window); - get_current_time(mw, - 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, - mw); - reg_update_current_time(update_current_time_hook, control_flow_data, - mw); - 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; - - 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); - -} - -/* Hook called before drawing. Gets the initial context at the beginning of the - * drawing interval and copy it to the context in event_request. - */ -int draw_before_hook(void *hook_data, void *call_data) -{ - EventRequest *event_request = (EventRequest*)hook_data; - //EventsContext Events_Context = (EventsContext*)call_data; - - //event_request->Events_Context = Events_Context; - - return 0; -} - -/* - * The draw event hook is called by the reading API to have a - * particular event drawn on the screen. - * @param hook_data ControlFlowData structure of the viewer. - * @param call_data Event context. - * - * This function basically draw lines and icons. Two types of lines are drawn : - * one small (3 pixels?) representing the state of the process and the second - * type is thicker (10 pixels?) representing on which CPU a process is running - * (and this only in running state). - * - * Extremums of the lines : - * x_min : time of the last event context for this process kept in memory. - * x_max : time of the current event. - * y : middle of the process in the process list. The process is found in the - * list, therefore is it's position in pixels. - * - * The choice of lines'color is defined by the context of the last event for this - * process. - */ -int draw_event_hook(void *hook_data, void *call_data) -{ - EventRequest *event_request = (EventRequest*)hook_data; - ControlFlowData *control_flow_data = event_request->control_flow_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->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; - //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; - //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; - - lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); - g_string_append_printf(string,"\n"); - - if(state) { - g_string_append_printf(string, " %s", - g_quark_to_string(tfs->process->state->s)); - } - - g_info("%s",string->str); - - g_string_free(string, TRUE); - - /* End of text dump */ -#endif //DONTSHOW - -} - - -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; - - 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->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; - //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; - //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; -} - - - - -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->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->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->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->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->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->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->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->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->mw); - - 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->mw, &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->mw, &time_window); - - } - gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); - - return 0; -} - -typedef struct _ClosureData { - 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; - - /* 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; - - -} - -/* - * for each process - * 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); - -} - diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/Event_Hooks.h b/ltt/branches/poly/lttv/modules/gui/controlflow/Event_Hooks.h deleted file mode 100644 index 66170d3c..00000000 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/Event_Hooks.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Event_hooks.c defines the hooks that are given to processTrace as parameter. - * These hooks call the drawing API to draw the information on the screen, - * using information from Context, but mostly state (running, waiting...). - */ - - -#ifndef _EVENT_HOOKS_H -#define _EVENT_HOOKS_H - -#include -#include -#include -#include "Process_List.h" -#include "Drawing.h" -#include "CFV.h" - - -/* Structure used to store and use information relative to one events refresh - * request. Typically filled in by the expose event callback, then passed to the - * library call, then used by the drawing hooks. Then, once all the events are - * sent, it is freed by the hook called after the reading. - */ -typedef struct _EventRequest -{ - ControlFlowData *control_flow_data; - LttTime time_begin, time_end; - gint x_begin, x_end; - /* Fill the Events_Context during the initial expose, before calling for - * events. - */ - //GArray Events_Context; //FIXME -} EventRequest ; - - - - - -void send_test_data(ProcessList *process_list, Drawing_t *drawing); - -GtkWidget *h_guicontrolflow(MainWindow *mw, LttvTracesetSelector * s, char * key); - -int event_selected_hook(void *hook_data, void *call_data); - -/* Hook called before drawing. Gets the initial context at the beginning of the - * drawing interval and copy it to the context in event_request. - */ -int draw_before_hook(void *hook_data, void *call_data); - -/* - * The draw event hook is called by the reading API to have a - * particular event drawn on the screen. - * @param hook_data ControlFlowData structure of the viewer. - * @param call_data Event context. - * - * This function basically draw lines and icons. Two types of lines are drawn : - * one small (3 pixels?) representing the state of the process and the second - * type is thicker (10 pixels?) representing on which CPU a process is running - * (and this only in running state). - * - * Extremums of the lines : - * x_min : time of the last event context for this process kept in memory. - * x_max : time of the current event. - * y : middle of the process in the process list. The process is found in the - * list, therefore is it's position in pixels. - * - * The choice of lines'color is defined by the context of the last event for this - * process. - */ -int draw_event_hook(void *hook_data, void *call_data); - -int draw_after_hook(void *hook_data, void *call_data); - -void draw_closure(gpointer key, gpointer value, gpointer user_data); - -int after_data_request(void *hook_data, void *call_data); - - -gint update_time_window_hook(void *hook_data, void *call_data); -gint update_current_time_hook(void *hook_data, void *call_data); - - - - -#endif // _EVENT_HOOKS_H diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/Process_List.c b/ltt/branches/poly/lttv/modules/gui/controlflow/Process_List.c deleted file mode 100644 index c695fb15..00000000 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/Process_List.c +++ /dev/null @@ -1,510 +0,0 @@ - -#include -#include -#include "Process_List.h" -#include "Draw_Item.h" - -/***************************************************************************** - * Methods to synchronize process list * - *****************************************************************************/ - -/* Enumeration of the columns */ -enum -{ - 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) -{ - 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; -} - -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; -} - -void destroy_hash_key(gpointer key); - -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->list_store = gtk_list_store_new ( N_COLUMNS, - G_TYPE_STRING, - G_TYPE_UINT, - G_TYPE_ULONG, - G_TYPE_ULONG); - - - process_list->process_list_widget = - gtk_tree_view_new_with_model - (GTK_TREE_MODEL (process_list->list_store)); - - g_object_unref (G_OBJECT (process_list->list_store)); - - gtk_tree_sortable_set_sort_func( - GTK_TREE_SORTABLE(process_list->list_store), - PID_COLUMN, - process_sort_func, - NULL, - NULL); - - gtk_tree_sortable_set_sort_column_id( - GTK_TREE_SORTABLE(process_list->list_store), - 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_widget), 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_widget), 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_widget), 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_widget), 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_widget), column); - - //gtk_tree_view_column_set_visible(column, 0); - - g_object_set_data_full( - G_OBJECT(process_list->process_list_widget), - "process_list_Data", - process_list, - (GDestroyNotify)processlist_destroy); - - return process_list; -} -void processlist_destroy(ProcessList *process_list) -{ - g_hash_table_destroy(process_list->process_hash); - process_list->process_hash = NULL; - - g_free(process_list); -} - -GtkWidget *processlist_get_widget(ProcessList *process_list) -{ - return process_list->process_list_widget; -} - - - -gint get_cell_height(GtkTreeView *tree_view) -{ - gint height; - GtkTreeViewColumn *Column = gtk_tree_view_get_column(tree_view, 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); -} - -void destroy_hash_data(gpointer data) -{ - g_free(data); -} - -int processlist_add( ProcessList *process_list, - guint pid, - LttTime *birth, - gchar *name, - guint *height, - HashedProcessData **pm_hashed_process_data) -{ - GtkTreeIter iter ; - ProcessInfo *Process_Info = g_new(ProcessInfo, 1); - HashedProcessData *hashed_process_data = g_new(HashedProcessData, 1); - *pm_hashed_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->list_store, &iter); - //g_critical ( "iter before : %s", gtk_tree_path_to_string ( - // gtk_tree_model_get_path ( - // GTK_TREE_MODEL(process_list->list_store), - // &iter))); - gtk_list_store_set ( process_list->list_store, &iter, - PROCESS_COLUMN, name, - PID_COLUMN, pid, - BIRTH_S_COLUMN, birth->tv_sec, - BIRTH_NS_COLUMN, birth->tv_nsec, - -1); - hashed_process_data->row_ref = gtk_tree_row_reference_new ( - GTK_TREE_MODEL(process_list->list_store), - gtk_tree_model_get_path( - GTK_TREE_MODEL(process_list->list_store), - &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->list_store), - // &iter))); - process_list->number_of_process++; - - *height = get_cell_height(GTK_TREE_VIEW(process_list->process_list_widget)) - * process_list->number_of_process ; - - - return 0; - -} - -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->list_store), - &iter, - gtk_tree_row_reference_get_path( - (GtkTreeRowReference*)hashed_process_data->row_ref) - ); - - gtk_list_store_remove (process_list->list_store, &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_widget)) - * process_list->number_of_process ; -} - - -gint processlist_get_process_pixels( ProcessList *process_list, - guint pid, LttTime *birth, - guint *y, - guint *height, - HashedProcessData **pm_hashed_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->row_ref); - path_indices = gtk_tree_path_get_indices (tree_path); - - *height = get_cell_height( - GTK_TREE_VIEW(process_list->process_list_widget)); - *y = *height * path_indices[0]; - *pm_hashed_process_data = hashed_process_data; - return 0; - } else { - *pm_hashed_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 *path_indices; - GtkTreePath *tree_path; - - tree_path = gtk_tree_row_reference_get_path( - hashed_process_data->row_ref); - path_indices = gtk_tree_path_get_indices (tree_path); - - *height = get_cell_height( - GTK_TREE_VIEW(process_list->process_list_widget)); - *y = *height * path_indices[0]; - - return 0; - -} diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/Process_List.h b/ltt/branches/poly/lttv/modules/gui/controlflow/Process_List.h deleted file mode 100644 index d3272160..00000000 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/Process_List.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef _PROCESS_LIST_H -#define _PROCESS_LIST_H - -#include -#include -#include -#include "Draw_Item.h" - -/* The process list - * - * Tasks : - * Create a process list - * 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. - * provides helper function to convert a process unique identifier to - * pixels (in height). - * - * //FIXME : connect the scrolled window adjustment with the list. - */ - -typedef struct _ProcessInfo { - - guint pid; - LttTime birth; - -} ProcessInfo; - -typedef struct _HashedProcessData { - - GtkTreeRowReference *row_ref; - DrawContext *draw_context; - -} HashedProcessData; - -struct _ProcessList { - - GtkWidget *process_list_widget; - GtkListStore *list_store; - - /* A hash table by PID to speed up process position find in the list */ - GHashTable *process_hash; - - guint number_of_process; -}; - - -typedef struct _ProcessList ProcessList; - -ProcessList *processlist_construct(void); -void processlist_destroy(ProcessList *process_list); -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); -// out : success (0) and height -int processlist_remove(ProcessList *process_list, guint pid, LttTime *birth); - -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); - -#endif // _PROCESS_LIST_H -- 2.34.1