From 76a67e8a7bd87a57452127275bb7208f52f7a17b Mon Sep 17 00:00:00 2001 From: compudj Date: Sun, 28 Sep 2003 21:38:38 +0000 Subject: [PATCH] basic drawing widget, nothing drawn for now git-svn-id: http://ltt.polymtl.ca/svn@273 04897980-b3bd-0310-b5e0-8ef037075253 --- .../poly/lttv/modules/guiControlFlow/CFV.c | 18 +++-- .../lttv/modules/guiControlFlow/Drawing.c | 73 ++++++++++++------- .../lttv/modules/guiControlFlow/Drawing.h | 21 ++++-- .../lttv/modules/guiControlFlow/Makefile.am | 3 +- 4 files changed, 74 insertions(+), 41 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c index 18f3b52e..d69617a4 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c @@ -17,7 +17,6 @@ extern GSList *gControl_Flow_Data_List; struct _ControlFlowData { - GtkWidget *Drawing_Area_V; GtkWidget *Scrolled_Window_VC; ProcessList *Process_List; @@ -57,12 +56,15 @@ struct _ControlFlowData { ControlFlowData * GuiControlFlow(void) { - GtkWidget *Process_List_Widget; + GtkWidget *Process_List_Widget, *Drawing_Widget; ControlFlowData* Control_Flow_Data = g_new(ControlFlowData,1) ; /* Create the Drawing */ - //Control_Flow_Data->Drawing = Drawing(); + Control_Flow_Data->Drawing = Drawing_construct(); + + Drawing_Widget = + Drawing_getWidget(Control_Flow_Data->Drawing); /* TEST DATA, TO BE READ FROM THE TRACE */ Control_Flow_Data->Number_Of_Events = 1000 ; @@ -84,10 +86,10 @@ GuiControlFlow(void) gtk_box_pack_start( GTK_BOX(Control_Flow_Data->Inside_HBox_V), - Process_List_Widget, TRUE, TRUE, 0); // FALSE TRUE - //gtk_box_pack_start( - // GTK_BOX(Control_Flow_Data->Inside_HBox_V), - // Control_Flow_Data->Drawing_Area_V, TRUE, TRUE, 0); + Process_List_Widget, FALSE, TRUE, 0); // FALSE TRUE + gtk_box_pack_start( + GTK_BOX(Control_Flow_Data->Inside_HBox_V), + Drawing_Widget, TRUE, TRUE, 0); Control_Flow_Data->VAdjust_C = @@ -132,7 +134,7 @@ GuiControlFlow(void) //Control_Flow_Data->Trace_Statistics = get_trace_statistics(Trace); - //gtk_widget_show(Control_Flow_Data->Drawing_Area_V); + gtk_widget_show(Drawing_Widget); gtk_widget_show(Process_List_Widget); gtk_widget_show(Control_Flow_Data->Inside_HBox_V); gtk_widget_show(Control_Flow_Data->Scrolled_Window_VC); diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c index 009109f8..0210b713 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c @@ -1,5 +1,7 @@ #include "Drawing.h" +#include +#include /***************************************************************************** * Drawing functions * @@ -26,43 +28,61 @@ static GdkColor CF_Colors [] = }; -typedef struct _Drawing_t { - GtkWidget *Drawing_Area_V +struct _Drawing_t { + GtkWidget *Drawing_Area_V; + GdkPixmap *Pixmap; - guint height, width; + gint height, width, depth; -} Drawing_t; +}; -Drawing_t *Drawing(void) +Drawing_t *Drawing_construct(void) { - Drawing_t Drawing = g_new(Drawing_t, 1); + Drawing_t *Drawing = g_new(Drawing_t, 1); Drawing->Drawing_Area_V = gtk_drawing_area_new (); g_object_set_data_full( G_OBJECT(Drawing->Drawing_Area_V), - "Drawing_Data", + "Link_Drawing_Data", Drawing, (GDestroyNotify)Drawing_destroy); - gtk_widget_modify_bg( Control_Flow_Data->Drawing_Area_V, + gtk_widget_modify_bg( Drawing->Drawing_Area_V, GTK_STATE_NORMAL, &CF_Colors[BLACK]); - + gdk_window_get_geometry(Drawing->Drawing_Area_V->window, + NULL, NULL, + &(Drawing->width), + &(Drawing->height), + &(Drawing->depth)); + + Drawing->Pixmap = gdk_pixmap_new( + Drawing->Drawing_Area_V->window, + Drawing->width, + Drawing->height, + Drawing->depth); + return Drawing; } void Drawing_destroy(Drawing_t *Drawing) { - g_object_unref( G_OBJECT(Drawing->Drawing_Area_V)); + // Do not unref here, Drawing_t destroyed by it's widget. + //g_object_unref( G_OBJECT(Drawing->Drawing_Area_V)); g_free(Drawing); } +GtkWidget *Drawing_getWidget(Drawing_t *Drawing) +{ + return Drawing->Drawing_Area_V; +} + /* get_time_from_pixels * * Get the time interval from window time and pixels, and pixels requested. This @@ -74,17 +94,16 @@ void convert_pixels_to_time( guint x, LttTime *window_time_begin, LttTime *window_time_end, - LttTime *time, - ); + LttTime *time) { LttTime window_time_interval; - TimeSub(window_time_interval, *window_time_end, window_time_begin); + TimeSub(window_time_interval, *window_time_end, *window_time_begin); TimeMul(*time, window_time_interval, (x/(float)Drawing->width)); - TimeAdd(*time, window_time_begin, *time); + TimeAdd(*time, *window_time_begin, *time); } @@ -95,34 +114,34 @@ void convert_time_to_pixels( LttTime window_time_end, LttTime time, Drawing_t *Drawing, - guint *x, - ) + guint *x) { LttTime window_time_interval; + float interval_float, time_float; TimeSub(window_time_interval, window_time_end, window_time_begin); - TimeSub(time, time, wimdow_time_begin); + TimeSub(time, time, window_time_begin); - *x = (guint)((time/(float)window_time_interval) * Drawing->width); + interval_float = (window_time_interval.tv_sec * NANSECOND_CONST) + + window_time_interval.tv_nsec; + time_float = (time.tv_sec * NANSECOND_CONST) + + time.tv_nsec; + + *x = (guint)(time_float/interval_float * Drawing->width); } -void Drawing_Resize(Drawing_t *Drawing, guint h, guint, w) +void Drawing_Resize(Drawing_t *Drawing, guint h, guint w) { - guint w; - Drawing->height = h ; - Drawing->weight = w ; + Drawing->width = w ; - gtk_widget_set_size_request ( Control_Flow_Data->Drawing_Area_V, - Drawing->weight, + gtk_widget_set_size_request ( Drawing->Drawing_Area_V, + Drawing->width, Drawing->height); } - - - diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h index 801ef2d1..8fb20c20 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h @@ -2,12 +2,14 @@ #define _DRAWING_H #include +#include +#include #include /* This part of the viewer does : - * Draw horizontal lines, getting line color and width as arguments. + * Draw horizontal lines, getting graphic context as arg. * Copy region of the screen into another. - * Modify the boundaries to reflect a scale change. + * Modify the boundaries to reflect a scale change. (resize) * * A helper function is provided here to convert from time and process * identifier to pixels and the contrary (will be useful for mouse selection). @@ -15,12 +17,22 @@ typedef struct _Drawing_t Drawing_t; -Drawing_t *Drawing(void); +Drawing_t *Drawing_construct(void); void Drawing_destroy(Drawing_t *Drawing); -void Drawing_Resize(Drawing_t *Drawing, guint h, guint w); +GtkWidget *Drawing_getWidget(Drawing_t *Drawing); + + +void Drawing_draw_line( guint x1, guint y1, guint x2, guint y2, + GdkGC *GC); + +void Drawing_copy(guint xsrc, guint ysrc, + guint xdest, guint ydest, + guint width, guint height); +void Drawing_Resize(Drawing_t *Drawing, guint h, guint w); + void convert_pixels_to_time( Drawing_t *Drawing, guint x, @@ -35,5 +47,4 @@ void convert_time_to_pixels( Drawing_t *Drawing, guint *x); - #endif // _DRAWING_H diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Makefile.am b/ltt/branches/poly/lttv/modules/guiControlFlow/Makefile.am index d24fb492..2cde21b9 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Makefile.am +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Makefile.am @@ -13,4 +13,5 @@ libdir = ${lttvplugindir} lib_LTLIBRARIES = libguiControlFlow.la libguiControlFlow_la_LDFLAGS = -module -libguiControlFlow_la_SOURCES = module.c Event_Hooks.c CFV.c Process_List.c +libguiControlFlow_la_SOURCES = module.c Event_Hooks.c CFV.c Process_List.c\ + Drawing.c -- 2.34.1