basic drawing widget, nothing drawn for now
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sun, 28 Sep 2003 21:38:38 +0000 (21:38 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sun, 28 Sep 2003 21:38:38 +0000 (21:38 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@273 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c
ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c
ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h
ltt/branches/poly/lttv/modules/guiControlFlow/Makefile.am

index 18f3b52e4e484a31907d0c2cda856f8bb728b813..d69617a4e2f325d0516875371f92908d25808b86 100644 (file)
@@ -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);
index 009109f806c19ae7efb88dab8872c068e68281ba..0210b7136160d3fbfaf297d81e80172b57d677b5 100644 (file)
@@ -1,5 +1,7 @@
 
 #include "Drawing.h"
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
 
 /*****************************************************************************
  *                              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);
        
        
 }
-
-
-
index 801ef2d196972db8f31bde6abe1c60e871d704af..8fb20c20cc599d4999f419afb63a627f57a9b023 100644 (file)
@@ -2,12 +2,14 @@
 #define _DRAWING_H
 
 #include <glib.h>
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
 #include <ltt/ltt.h>
 
 /* 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).
 
 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
index d24fb4921d2d63d86eec4cd17749928e0b5856e4..2cde21b90ff9fb4b6671fea535b910fb80f7c082 100644 (file)
@@ -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
This page took 0.028409 seconds and 4 git commands to generate.