7 #include <lttv/processTrace.h>
10 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
11 #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
14 /*****************************************************************************
16 *****************************************************************************/
18 //FIXME Colors will need to be dynamic. Graphic context part not done so far.
29 /* Vector of unallocated colors */
30 static GdkColor CF_Colors
[] =
32 { 0, 0xffff, 0x0000, 0x0000 }, // RED
33 { 0, 0x0000, 0xffff, 0x0000 }, // GREEN
34 { 0, 0x0000, 0x0000, 0xffff }, // BLUE
35 { 0, 0xffff, 0xffff, 0xffff }, // WHITE
36 { 0, 0x0000, 0x0000, 0x0000 } // BLACK
40 /* Function responsible for updating the exposed area.
41 * It must call processTrace() to ask for this update.
43 void drawing_data_request(Drawing_t
*Drawing
,
50 // start from pixel to time(x)
51 // end from pixel to time (x + width)
53 // LttvTracesetContext * tsc = get_traceset_context(event_viewer_data->mw);
55 if(width
< 0) return ;
56 if(height
< 0) return ;
58 gdk_draw_rectangle (*Pixmap
,
59 Drawing
->Drawing_Area_V
->style
->white_gc
,
62 width
, // do not overlap
66 guicontrolflow_get_process_list(Drawing
->Control_Flow_Data
),
69 guicontrolflow_get_process_list(Drawing
->Control_Flow_Data
),
70 Drawing
, *Pixmap
, x
, y
, width
, height
);
72 // Let's call processTrace() !!
75 //lttv_process_traceset_seek_time(tsc, start);
76 //lttv_traceset_context_add_hooks(
77 //lttv_process_traceset
78 //lttv_traceset_context_remove_hooks
84 /* Create a new backing pixmap of the appropriate size */
86 configure_event( GtkWidget
*widget
, GdkEventConfigure
*event
,
89 Drawing_t
*Drawing
= (Drawing_t
*)user_data
;
91 /* New Pixmap, size of the configure event */
92 GdkPixmap
*Pixmap
= gdk_pixmap_new(widget
->window
,
93 widget
->allocation
.width
,
94 widget
->allocation
.height
,
97 g_critical("drawing configure event");
99 /* If no old Pixmap present */
100 if(Drawing
->Pixmap
== NULL
)
102 Drawing
->Pixmap
= gdk_pixmap_new(
104 widget
->allocation
.width
,
105 widget
->allocation
.height
,
106 //ProcessList_get_height
107 // (GuiControlFlow_get_Process_List(Drawing->Control_Flow_Data)),
109 Drawing
->width
= widget
->allocation
.width
;
110 Drawing
->height
= widget
->allocation
.height
;
111 g_critical("init data");
112 /* Initial data request */
113 drawing_data_request(Drawing
, &Drawing
->Pixmap
, 0, 0,
114 widget
->allocation
.width
,
115 widget
->allocation
.height
);
118 // /* Draw empty background */
119 // gdk_draw_rectangle (Pixmap,
120 // widget->style->black_gc,
123 // widget->allocation.width,
124 // widget->allocation.height);
126 /* Copy old data to new pixmap */
127 gdk_draw_drawable (Pixmap
,
128 widget
->style
->white_gc
,
134 /* Request data for missing space */
135 g_critical("missing data");
136 drawing_data_request(Drawing
, &Pixmap
, Drawing
->width
, 0,
137 widget
->allocation
.width
- Drawing
->width
,
138 widget
->allocation
.height
);
139 drawing_data_request(Drawing
, &Pixmap
, 0, Drawing
->height
,
141 widget
->allocation
.height
- Drawing
->height
);
143 // gdk_draw_rectangle (Pixmap,
144 // widget->style->white_gc,
146 // Drawing->width, 0,
147 // widget->allocation.width -
149 // widget->allocation.height);
151 // gdk_draw_rectangle (Pixmap,
152 // widget->style->white_gc,
154 // 0, Drawing->height,
155 // Drawing->width, // do not overlap
156 // widget->allocation.height -
162 gdk_pixmap_unref(Drawing
->Pixmap
);
164 Drawing
->Pixmap
= Pixmap
;
165 Drawing
->width
= widget
->allocation
.width
;
166 Drawing
->height
= widget
->allocation
.height
;
172 /* Redraw the screen from the backing pixmap */
174 expose_event( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
)
176 Drawing_t
*Drawing
= (Drawing_t
*)user_data
;
177 g_critical("drawing expose event");
179 gdk_draw_pixmap(widget
->window
,
180 widget
->style
->fg_gc
[GTK_WIDGET_STATE (widget
)],
182 event
->area
.x
, event
->area
.y
,
183 event
->area
.x
, event
->area
.y
,
184 event
->area
.width
, event
->area
.height
);
189 Drawing_t
*drawing_construct(ControlFlowData
*Control_Flow_Data
)
191 Drawing_t
*Drawing
= g_new(Drawing_t
, 1);
193 Drawing
->Drawing_Area_V
= gtk_drawing_area_new ();
194 Drawing
->Control_Flow_Data
= Control_Flow_Data
;
196 //gtk_widget_set_size_request(Drawing->Drawing_Area_V->window, 50, 50);
197 g_object_set_data_full(
198 G_OBJECT(Drawing
->Drawing_Area_V
),
201 (GDestroyNotify
)drawing_destroy
);
203 //gtk_widget_modify_bg( Drawing->Drawing_Area_V,
205 // &CF_Colors[BLACK]);
207 //gdk_window_get_geometry(Drawing->Drawing_Area_V->window,
209 // &(Drawing->width),
210 // &(Drawing->height),
213 //Drawing->Pixmap = gdk_pixmap_new(
214 // Drawing->Drawing_Area_V->window,
219 Drawing
->Pixmap
= NULL
;
221 // Drawing->Pixmap = gdk_pixmap_new(Drawing->Drawing_Area_V->window,
222 // Drawing->Drawing_Area_V->allocation.width,
223 // Drawing->Drawing_Area_V->allocation.height,
226 g_signal_connect (G_OBJECT(Drawing
->Drawing_Area_V
),
228 G_CALLBACK (configure_event
),
231 g_signal_connect (G_OBJECT(Drawing
->Drawing_Area_V
),
233 G_CALLBACK (expose_event
),
239 void drawing_destroy(Drawing_t
*Drawing
)
242 // Do not unref here, Drawing_t destroyed by it's widget.
243 //g_object_unref( G_OBJECT(Drawing->Drawing_Area_V));
248 GtkWidget
*drawing_get_widget(Drawing_t
*Drawing
)
250 return Drawing
->Drawing_Area_V
;
253 /* get_time_from_pixels
255 * Get the time interval from window time and pixels, and pixels requested.
257 void convert_pixels_to_time(
260 LttTime
*window_time_begin
,
261 LttTime
*window_time_end
,
264 LttTime window_time_interval
;
266 window_time_interval
= ltt_time_sub(*window_time_end
,
268 *time
= ltt_time_mul(window_time_interval
, (x
/(float)Drawing
->width
));
269 *time
= ltt_time_add(*window_time_begin
, *time
);
274 void convert_time_to_pixels(
275 LttTime window_time_begin
,
276 LttTime window_time_end
,
281 LttTime window_time_interval
;
282 float interval_float
, time_float
;
284 window_time_interval
= ltt_time_sub(window_time_end
,window_time_begin
);
286 time
= ltt_time_sub(time
, window_time_begin
);
288 interval_float
= ltt_time_to_double(window_time_interval
);
289 time_float
= ltt_time_to_double(time
);
291 *x
= (guint
)(time_float
/interval_float
* Drawing
->width
);
295 void drawing_refresh ( Drawing_t
*Drawing
,
297 guint width
, guint height
)
299 g_info("Drawing.c : drawing_refresh %u, %u, %u, %u", x
, y
, width
, height
);
300 GdkRectangle update_rect
;
303 Drawing
->Drawing_Area_V
->window
,
304 Drawing
->Drawing_Area_V
->
305 style
->fg_gc
[GTK_WIDGET_STATE (Drawing
->Drawing_Area_V
)],
306 GDK_DRAWABLE(Drawing
->Pixmap
),
313 update_rect
.width
= Drawing
->width
;
314 update_rect
.height
= Drawing
->height
;
315 gtk_widget_draw( Drawing
->Drawing_Area_V
, &update_rect
);
320 void drawing_draw_line( Drawing_t
*Drawing
,
326 gdk_draw_line (Pixmap
,
334 void drawing_resize(Drawing_t
*Drawing
, guint h
, guint w
)
336 Drawing
->height
= h
;
339 gtk_widget_set_size_request ( Drawing
->Drawing_Area_V
,
347 /* Insert a square corresponding to a new process in the list */
348 /* Applies to whole Drawing->width */
349 void drawing_insert_square(Drawing_t
*Drawing
,
353 GdkRectangle update_rect
;
355 /* Allocate a new pixmap with new height */
356 GdkPixmap
*Pixmap
= gdk_pixmap_new(Drawing
->Drawing_Area_V
->window
,
358 Drawing
->height
+ height
,
361 /* Copy the high region */
362 gdk_draw_drawable (Pixmap
,
363 Drawing
->Drawing_Area_V
->style
->black_gc
,
372 /* add an empty square */
373 gdk_draw_rectangle (Pixmap
,
374 Drawing
->Drawing_Area_V
->style
->black_gc
,
377 Drawing
->width
, // do not overlap
382 /* copy the bottom of the region */
383 gdk_draw_drawable (Pixmap
,
384 Drawing
->Drawing_Area_V
->style
->black_gc
,
388 Drawing
->width
, Drawing
->height
- y
);
394 gdk_pixmap_unref(Drawing
->Pixmap
);
396 Drawing
->Pixmap
= Pixmap
;
398 Drawing
->height
+=height
;
400 /* Rectangle to update, from new Drawing dimensions */
403 update_rect
.width
= Drawing
->width
;
404 update_rect
.height
= Drawing
->height
- y
;
405 gtk_widget_draw( Drawing
->Drawing_Area_V
, &update_rect
);
409 /* Remove a square corresponding to a removed process in the list */
410 void drawing_remove_square(Drawing_t
*Drawing
,
414 GdkRectangle update_rect
;
416 /* Allocate a new pixmap with new height */
417 GdkPixmap
*Pixmap
= gdk_pixmap_new(
418 Drawing
->Drawing_Area_V
->window
,
420 Drawing
->height
- height
,
423 /* Copy the high region */
424 gdk_draw_drawable (Pixmap
,
425 Drawing
->Drawing_Area_V
->style
->black_gc
,
433 /* Copy up the bottom of the region */
434 gdk_draw_drawable (Pixmap
,
435 Drawing
->Drawing_Area_V
->style
->black_gc
,
439 Drawing
->width
, Drawing
->height
- y
- height
);
443 gdk_pixmap_unref(Drawing
->Pixmap
);
445 Drawing
->Pixmap
= Pixmap
;
447 Drawing
->height
-=height
;
449 /* Rectangle to update, from new Drawing dimensions */
452 update_rect
.width
= Drawing
->width
;
453 update_rect
.height
= Drawing
->height
- y
;
454 gtk_widget_draw( Drawing
->Drawing_Area_V
, &update_rect
);