From: compudj Date: Wed, 15 Oct 2003 02:27:55 +0000 (+0000) Subject: Draw_Item .h and .c design complete. Now, needs to be implemented. X-Git-Tag: v0.12.20~3184 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b782dd11ec8e363e135b32a563687a8e4f70bedb;p=lttv.git Draw_Item .h and .c design complete. Now, needs to be implemented. git-svn-id: http://ltt.polymtl.ca/svn@305 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c index fd6f0cf0..4ccd30e8 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c @@ -5,6 +5,21 @@ * 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.) @@ -22,7 +37,7 @@ * GQuark.) The habitual place for xpm icons is in * ${prefix}/share/LinuxTraceToolkit.) + position (over or under line) * - line (color, width, style) - * - point (color, size) + * - Arc (can be seen as points) (color, size) * - background color (color) * * Each item has an array of hooks (hook list). Each hook represents an @@ -46,6 +61,11 @@ * 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. + * * Author : Mathieu Desnoyers, October 2003 */ @@ -54,3 +74,167 @@ #include #include +#include +#include + +/* 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. + */ +struct _DrawContext { + GdkDrawable *drawable; + GdkGC *gc; + + DrawInfo *Current; + DrawInfo *Previous; +}; + +struct _DrawInfo { + ItemInfo *over; + ItemInfo *middle; + ItemInfo *under; +}; + +/* 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 _ItemInfo { + gint x, y; + LttvTraceState *ts; + LttvTracefileState *tfs; +}; + + +/* + * 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. + */ + +typedef enum _DrawableItems { + ITEM_TEXT, ITEM_ICON, ITEM_LINE, ITEM_POINT, ITEM_BACKGROUND +} DrawableItems; + +static gchar * Items_Priorities = { + 50, /* ITEM_TEXT */ + 40, /* ITEM_ICON */ + 20, /* ITEM_LINE */ + 30, /* ITEM_POINT */ + 10 /* ITEM_BACKGROUND */ +}; + +typedef enum _RelPos { + OVER, MIDDLE, UNDER +} RelPos; + +/* + * 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; +}; + + + + + +/* Drawing hook functions */ +gboolean DrawText( void *hook_data, void *call_data) +{ + PropertiesText *Properties = (PropertiesText*)hook_data; + DrawContext *Draw_Context = (DrawContext*)call_data; +} + +gboolean DrawIcon( void *hook_data, void *call_data) +{ + PropertiesIcon *Properties = (PropertiesIcon*)hook_data; + DrawContext *Draw_Context = (DrawContext*)call_data; + +} + +gboolean DrawLine( void *hook_data, void *call_data) +{ + PropertiesLine *Properties = (PropertiesLine*)hook_data; + DrawContext *Draw_Context = (DrawContext*)call_data; + +} + +gboolean DrawArc( void *hook_data, void *call_data) +{ + PropertiesArc *Properties = (PropertiesArc*)hook_data; + DrawContext *Draw_Context = (DrawContext*)call_data; + +} + +gboolean DrawBG( void *hook_data, void *call_data) +{ + PropertiesBG *Properties = (PropertiesBG*)hook_data; + DrawContext *Draw_Context = (DrawContext*)call_data; + +} + + diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h new file mode 100644 index 00000000..51e1a0d5 --- /dev/null +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h @@ -0,0 +1,135 @@ +#ifndef _DRAW_ITEM_H +#define _DRAW_ITEM_H + +typedef struct _DrawContext DrawContext; +typedef struct _DrawInfo DrawInfo; +typedef struct _ItemInfo ItemInfo; + +typedef struct _DrawOperation DrawOperation; + + +typedef struct _PropertiesText PropertiesText; +typedef struct _PropertiesIcon PropertiesIcon; +typedef struct _PropertiesLine PropertiesLine; +typedef struct _PropertiesArc PropertiesArc; +typedef struct _PropertiesBG PropertiesBG; + + +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 AddOperation has to do a quick sort by priority to keep the operations + * in the right order. + */ +void AddOperation( LttvIAttribute *attributes, + gchar *pathname, + DrawOperation *Operation); + +/* + * The DelOperation seeks the array present at pathname (if any) and + * removes the DrawOperation if present. It returns 0 on success, -1 + * if it fails. + */ +gint DelOperation( LttvIAttribute *attributes, + gchar *pathname, + DrawOperation *Operation); + +/* + * The CleanOperations removes all operations present at a pathname. + * returns 0 on success, -1 if it fails. + */ +gint DelOperations( LttvIAttribute *attributes, + gchar *pathname ); + + +/* + * The ListOperation gives a pointer to the operation array associated + * with the pathname. It will be NULL if no operation is present. + */ +void ListOperations( LttvIAttribute *attributes, + gchar *pathname, + GArray **Operation); + + + +/* + * ExecOperation executes the operations if present in the attributes, or + * do nothing if not present. + */ +void ExecOperations( 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 DrawText( void *hook_data, void *call_data); +gboolean DrawIcon( void *hook_data, void *call_data); +gboolean DrawLine( void *hook_data, void *call_data); +gboolean DrawArc( void *hook_data, void *call_data); +gboolean DrawBG( void *hook_data, void *call_data); + + +#endif // _DRAW_ITEM_H