f0d936c0 |
1 | /***************************************************************************** |
2 | * Hooks to be called by the main window * |
3 | *****************************************************************************/ |
4 | |
f0d936c0 |
5 | |
189a5d08 |
6 | #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) |
7 | #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) |
8 | |
cf6cb7e0 |
9 | //#define PANGO_ENABLE_BACKEND |
558aa013 |
10 | #include <gtk/gtk.h> |
11 | #include <gdk/gdk.h> |
5f16133f |
12 | #include <glib.h> |
80a52ff8 |
13 | #include <assert.h> |
5f16133f |
14 | |
cf6cb7e0 |
15 | //#include <pango/pango.h> |
16 | |
80a52ff8 |
17 | #include <ltt/event.h> |
18 | |
558aa013 |
19 | #include <lttv/hook.h> |
20 | #include <lttv/common.h> |
80a52ff8 |
21 | #include <lttv/state.h> |
22 | |
f0d936c0 |
23 | |
1ab818de |
24 | #include "Event_Hooks.h" |
f0d936c0 |
25 | #include "CFV.h" |
5f16133f |
26 | #include "Process_List.h" |
1ab3d149 |
27 | #include "Drawing.h" |
f7afe191 |
28 | #include "CFV-private.h" |
5f16133f |
29 | |
80a52ff8 |
30 | |
1a31868c |
31 | #define MAX_PATH_LEN 256 |
32 | |
33 | //FIXME : remove this include when tests finished. |
1a31868c |
34 | #include <string.h> |
35 | |
1a31868c |
36 | void test_draw_item(Drawing_t *Drawing, |
37 | GdkPixmap *Pixmap) |
38 | { |
39 | PropertiesIcon properties_icon; |
40 | DrawContext draw_context; |
41 | |
42 | DrawInfo current, previous; |
43 | ItemInfo over, middle, under, modify_over, modify_middle, modify_under; |
44 | |
80a52ff8 |
45 | int i=0,j=0; |
1a31868c |
46 | |
80a52ff8 |
47 | //for(i=0; i<1024;i=i+15) |
1a31868c |
48 | { |
80a52ff8 |
49 | // for(j=0;j<768;j=j+15) |
1a31868c |
50 | { |
51 | over.x = i; |
52 | over.y = j; |
1a31868c |
53 | |
54 | current.modify_over = &over; |
55 | |
56 | draw_context.drawable = Pixmap; |
57 | draw_context.gc = Drawing->Drawing_Area_V->style->black_gc; |
58 | |
59 | draw_context.Current = ¤t; |
60 | draw_context.Previous = NULL; |
61 | |
62 | properties_icon.icon_name = g_new(char, MAX_PATH_LEN); |
63 | strncpy(properties_icon.icon_name, |
64 | "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/mini-display.xpm", |
65 | MAX_PATH_LEN); |
66 | properties_icon.width = -1; |
67 | properties_icon.height = -1; |
68 | properties_icon.position = OVER; |
1a31868c |
69 | draw_icon(&properties_icon, &draw_context); |
8d088fb2 |
70 | g_free(properties_icon.icon_name); |
1a31868c |
71 | } |
72 | } |
73 | |
74 | } |
f7afe191 |
75 | |
80a52ff8 |
76 | #ifdef NOTUSE |
189a5d08 |
77 | /* NOTE : no drawing data should be sent there, since the drawing widget |
96cfe486 |
78 | * has not been initialized */ |
f7afe191 |
79 | void send_test_drawing(ProcessList *Process_List, |
80 | Drawing_t *Drawing, |
81 | GdkPixmap *Pixmap, |
82 | gint x, gint y, // y not used here? |
8d088fb2 |
83 | gint width, |
f7afe191 |
84 | gint height) // height won't be used here ? |
85 | { |
1a31868c |
86 | int i,j; |
f7afe191 |
87 | ProcessInfo Process_Info = {10000, 12000, 55600}; |
88 | //ProcessInfo Process_Info = {156, 14000, 55500}; |
89 | GtkTreeRowReference *got_RowRef; |
cf6cb7e0 |
90 | PangoContext *context; |
91 | PangoLayout *layout; |
92 | PangoFontDescription *FontDesc;// = pango_font_description_new(); |
93 | gint Font_Size; |
94 | |
189a5d08 |
95 | //icon |
8d088fb2 |
96 | //GdkBitmap *mask = g_new(GdkBitmap, 1); |
97 | //GdkPixmap *icon_pixmap = g_new(GdkPixmap, 1); |
98 | GdkGC * gc; |
6d5ed1c3 |
99 | // rectangle |
100 | GdkColor color = { 0, 0xffff, 0x0000, 0x0000 }; |
101 | |
80ff382d |
102 | gc = gdk_gc_new(Pixmap); |
cf6cb7e0 |
103 | /* Sent text data */ |
80ff382d |
104 | layout = gtk_widget_create_pango_layout(Drawing->Drawing_Area_V, |
105 | NULL); |
106 | context = pango_layout_get_context(layout); |
107 | FontDesc = pango_context_get_font_description(context); |
108 | Font_Size = pango_font_description_get_size(FontDesc); |
109 | pango_font_description_set_size(FontDesc, Font_Size-3*PANGO_SCALE); |
cf6cb7e0 |
110 | |
f7afe191 |
111 | |
cf6cb7e0 |
112 | |
113 | |
f7afe191 |
114 | LttTime birth; |
115 | birth.tv_sec = 12000; |
116 | birth.tv_nsec = 55500; |
189a5d08 |
117 | g_info("we have : x : %u, y : %u, width : %u, height : %u", x, y, width, height); |
4c69e0cc |
118 | processlist_get_process_pixels(Process_List, |
f7afe191 |
119 | 1, |
120 | &birth, |
121 | &y, |
122 | &height); |
123 | |
189a5d08 |
124 | g_info("we draw : x : %u, y : %u, width : %u, height : %u", x, y, width, height); |
4c69e0cc |
125 | drawing_draw_line( |
f7afe191 |
126 | Drawing, Pixmap, x, |
127 | y+(height/2), x + width, y+(height/2), |
128 | Drawing->Drawing_Area_V->style->black_gc); |
129 | |
80ff382d |
130 | pango_layout_set_text(layout, "Test", -1); |
131 | gdk_draw_layout(Pixmap, Drawing->Drawing_Area_V->style->black_gc, |
132 | 0, y+height, layout); |
cf6cb7e0 |
133 | |
f7afe191 |
134 | birth.tv_sec = 14000; |
135 | birth.tv_nsec = 55500; |
136 | |
4c69e0cc |
137 | processlist_get_process_pixels(Process_List, |
f7afe191 |
138 | 156, |
139 | &birth, |
140 | &y, |
141 | &height); |
142 | |
143 | |
4c69e0cc |
144 | drawing_draw_line( |
f7afe191 |
145 | Drawing, Pixmap, x, |
146 | y+(height/2), x + width, y+(height/2), |
147 | Drawing->Drawing_Area_V->style->black_gc); |
148 | |
189a5d08 |
149 | g_info("y : %u, height : %u", y, height); |
f7afe191 |
150 | |
6d5ed1c3 |
151 | |
152 | |
f7afe191 |
153 | birth.tv_sec = 12000; |
154 | birth.tv_nsec = 55700; |
155 | |
4c69e0cc |
156 | processlist_get_process_pixels(Process_List, |
f7afe191 |
157 | 10, |
158 | &birth, |
159 | &y, |
160 | &height); |
6d5ed1c3 |
161 | |
162 | /* Draw rectangle (background color) */ |
80ff382d |
163 | gdk_gc_copy(gc, Drawing->Drawing_Area_V->style->black_gc); |
164 | gdk_gc_set_rgb_fg_color(gc, &color); |
165 | gdk_draw_rectangle(Pixmap, gc, |
166 | TRUE, |
167 | x, y, width, height); |
f7afe191 |
168 | |
4c69e0cc |
169 | drawing_draw_line( |
f7afe191 |
170 | Drawing, Pixmap, x, |
171 | y+(height/2), x + width, y+(height/2), |
172 | Drawing->Drawing_Area_V->style->black_gc); |
173 | |
6d5ed1c3 |
174 | |
175 | /* Draw arc */ |
176 | gdk_draw_arc(Pixmap, Drawing->Drawing_Area_V->style->black_gc, |
2f9f7ee0 |
177 | TRUE, 100, y, height/2, height/2, 0, 360*64); |
6d5ed1c3 |
178 | |
189a5d08 |
179 | g_info("y : %u, height : %u", y, height); |
f7afe191 |
180 | |
181 | for(i=0; i<10; i++) |
182 | { |
183 | birth.tv_sec = i*12000; |
184 | birth.tv_nsec = i*55700; |
185 | |
4c69e0cc |
186 | processlist_get_process_pixels(Process_List, |
f7afe191 |
187 | i, |
188 | &birth, |
189 | &y, |
190 | &height); |
191 | |
192 | |
4c69e0cc |
193 | drawing_draw_line( |
f7afe191 |
194 | Drawing, Pixmap, x, |
195 | y+(height/2), x + width, y+(height/2), |
196 | Drawing->Drawing_Area_V->style->black_gc); |
197 | |
198 | g_critical("y : %u, height : %u", y, height); |
199 | |
200 | } |
201 | |
202 | birth.tv_sec = 12000; |
203 | birth.tv_nsec = 55600; |
204 | |
4c69e0cc |
205 | processlist_get_process_pixels(Process_List, |
f7afe191 |
206 | 10, |
207 | &birth, |
208 | &y, |
209 | &height); |
210 | |
211 | |
4c69e0cc |
212 | drawing_draw_line( |
f7afe191 |
213 | Drawing, Pixmap, x, |
214 | y+(height/2), x + width, y+(height/2), |
215 | Drawing->Drawing_Area_V->style->black_gc); |
216 | |
189a5d08 |
217 | g_info("y : %u, height : %u", y, height); |
1a31868c |
218 | |
219 | |
220 | /* IMPORTANT : This action uses the cpu heavily! */ |
221 | //icon_pixmap = gdk_pixmap_create_from_xpm(Pixmap, &mask, NULL, |
222 | // "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/move_message.xpm"); |
223 | // "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/mini-display.xpm"); |
224 | |
225 | // gdk_gc_set_clip_mask(Drawing->Drawing_Area_V->style->black_gc, mask); |
226 | |
227 | // for(i=x;i<x+width;i=i+15) |
228 | // { |
229 | // for(j=0;j<height*20;j=j+15) |
230 | // { |
231 | |
232 | /* Draw icon */ |
233 | //gdk_gc_copy(gc, Drawing->Drawing_Area_V->style->black_gc); |
234 | // gdk_gc_set_clip_origin(Drawing->Drawing_Area_V->style->black_gc, i, j); |
235 | // gdk_draw_drawable(Pixmap, |
236 | // Drawing->Drawing_Area_V->style->black_gc, |
237 | // icon_pixmap, |
238 | // 0, 0, i, j, -1, -1); |
239 | |
240 | // } |
241 | // } |
8d088fb2 |
242 | |
1a31868c |
243 | test_draw_item(Drawing,Pixmap); |
244 | |
245 | //gdk_gc_set_clip_origin(Drawing->Drawing_Area_V->style->black_gc, 0, 0); |
246 | //gdk_gc_set_clip_mask(Drawing->Drawing_Area_V->style->black_gc, NULL); |
247 | |
248 | //g_free(icon_pixmap); |
249 | //g_free(mask); |
250 | |
251 | |
252 | |
253 | |
cf6cb7e0 |
254 | |
255 | |
80ff382d |
256 | pango_font_description_set_size(FontDesc, Font_Size); |
257 | g_object_unref(layout); |
258 | g_free(gc); |
f7afe191 |
259 | } |
260 | |
261 | void send_test_process(ProcessList *Process_List, Drawing_t *Drawing) |
5f16133f |
262 | { |
f7afe191 |
263 | guint height, y; |
5f16133f |
264 | int i; |
265 | ProcessInfo Process_Info = {10000, 12000, 55600}; |
266 | //ProcessInfo Process_Info = {156, 14000, 55500}; |
267 | GtkTreeRowReference *got_RowRef; |
268 | |
269 | LttTime birth; |
f7afe191 |
270 | |
271 | if(Process_List->Test_Process_Sent) return; |
272 | |
5f16133f |
273 | birth.tv_sec = 12000; |
274 | birth.tv_nsec = 55500; |
275 | |
4c69e0cc |
276 | processlist_add(Process_List, |
5f16133f |
277 | 1, |
278 | &birth, |
f7afe191 |
279 | &y); |
4c69e0cc |
280 | processlist_get_process_pixels(Process_List, |
f7afe191 |
281 | 1, |
282 | &birth, |
283 | &y, |
284 | &height); |
4c69e0cc |
285 | drawing_insert_square( Drawing, y, height); |
1ab3d149 |
286 | |
f7afe191 |
287 | //g_critical("y : %u, height : %u", y, height); |
5f16133f |
288 | |
289 | birth.tv_sec = 14000; |
290 | birth.tv_nsec = 55500; |
291 | |
4c69e0cc |
292 | processlist_add(Process_List, |
5f16133f |
293 | 156, |
294 | &birth, |
f7afe191 |
295 | &y); |
4c69e0cc |
296 | processlist_get_process_pixels(Process_List, |
f7afe191 |
297 | 156, |
298 | &birth, |
299 | &y, |
300 | &height); |
4c69e0cc |
301 | drawing_insert_square( Drawing, y, height); |
f7afe191 |
302 | |
303 | //g_critical("y : %u, height : %u", y, height); |
304 | |
5f16133f |
305 | birth.tv_sec = 12000; |
306 | birth.tv_nsec = 55700; |
307 | |
4c69e0cc |
308 | processlist_add(Process_List, |
5f16133f |
309 | 10, |
310 | &birth, |
311 | &height); |
4c69e0cc |
312 | processlist_get_process_pixels(Process_List, |
f7afe191 |
313 | 10, |
314 | &birth, |
315 | &y, |
316 | &height); |
4c69e0cc |
317 | drawing_insert_square( Drawing, y, height); |
f7afe191 |
318 | |
319 | //g_critical("y : %u, height : %u", y, height); |
320 | |
4c69e0cc |
321 | //drawing_insert_square( Drawing, height, 5); |
5f16133f |
322 | |
323 | for(i=0; i<10; i++) |
324 | { |
325 | birth.tv_sec = i*12000; |
326 | birth.tv_nsec = i*55700; |
327 | |
4c69e0cc |
328 | processlist_add(Process_List, |
5f16133f |
329 | i, |
330 | &birth, |
331 | &height); |
4c69e0cc |
332 | processlist_get_process_pixels(Process_List, |
f7afe191 |
333 | i, |
334 | &birth, |
335 | &y, |
336 | &height); |
4c69e0cc |
337 | drawing_insert_square( Drawing, y, height); |
f7afe191 |
338 | |
339 | // g_critical("y : %u, height : %u", y, height); |
340 | |
5f16133f |
341 | } |
f7afe191 |
342 | //g_critical("height : %u", height); |
5f16133f |
343 | |
344 | birth.tv_sec = 12000; |
345 | birth.tv_nsec = 55600; |
346 | |
4c69e0cc |
347 | processlist_add(Process_List, |
5f16133f |
348 | 10, |
349 | &birth, |
f7afe191 |
350 | &y); |
4c69e0cc |
351 | processlist_get_process_pixels(Process_List, |
f7afe191 |
352 | 10, |
353 | &birth, |
354 | &y, |
355 | &height); |
4c69e0cc |
356 | drawing_insert_square( Drawing, y, height); |
f7afe191 |
357 | |
358 | //g_critical("y : %u, height : %u", y, height); |
359 | |
4c69e0cc |
360 | processlist_add(Process_List, |
5f16133f |
361 | 10000, |
362 | &birth, |
363 | &height); |
4c69e0cc |
364 | processlist_get_process_pixels(Process_List, |
f7afe191 |
365 | 10000, |
366 | &birth, |
367 | &y, |
368 | &height); |
4c69e0cc |
369 | drawing_insert_square( Drawing, y, height); |
f7afe191 |
370 | |
371 | //g_critical("y : %u, height : %u", y, height); |
372 | |
4c69e0cc |
373 | //drawing_insert_square( Drawing, height, 5); |
f7afe191 |
374 | //g_critical("height : %u", height); |
5f16133f |
375 | |
376 | |
4c69e0cc |
377 | processlist_get_process_pixels(Process_List, |
1ab3d149 |
378 | 10000, |
379 | &birth, |
f7afe191 |
380 | &y, &height); |
4c69e0cc |
381 | processlist_remove( Process_List, |
5f16133f |
382 | 10000, |
383 | &birth); |
1ab3d149 |
384 | |
4c69e0cc |
385 | drawing_remove_square( Drawing, y, height); |
5f16133f |
386 | |
387 | if(got_RowRef = |
388 | (GtkTreeRowReference*)g_hash_table_lookup( |
389 | Process_List->Process_Hash, |
390 | &Process_Info)) |
391 | { |
392 | g_critical("key found"); |
393 | g_critical("position in the list : %s", |
394 | gtk_tree_path_to_string ( |
395 | gtk_tree_row_reference_get_path( |
396 | (GtkTreeRowReference*)got_RowRef) |
397 | )); |
398 | |
399 | } |
400 | |
f7afe191 |
401 | Process_List->Test_Process_Sent = TRUE; |
402 | |
5f16133f |
403 | } |
80a52ff8 |
404 | #endif//NOTUSE |
5f16133f |
405 | |
f0d936c0 |
406 | |
407 | /** |
408 | * Event Viewer's constructor hook |
409 | * |
410 | * This constructor is given as a parameter to the menuitem and toolbar button |
411 | * registration. It creates the list. |
412 | * @param pmParentWindow A pointer to the parent window. |
413 | * @return The widget created. |
414 | */ |
415 | GtkWidget * |
4c69e0cc |
416 | h_guicontrolflow(MainWindow *pmParentWindow, LttvTracesetSelector * s, char * key) |
f0d936c0 |
417 | { |
189a5d08 |
418 | g_info("h_guicontrolflow, %p, %p, %s", pmParentWindow, s, key); |
4c69e0cc |
419 | ControlFlowData *Control_Flow_Data = guicontrolflow() ; |
189a5d08 |
420 | |
421 | Control_Flow_Data->Parent_Window = pmParentWindow; |
f66eba62 |
422 | TimeWindow *time_window = guicontrolflow_get_time_window(Control_Flow_Data); |
423 | time_window->start_time.tv_sec = 0; |
424 | time_window->start_time.tv_nsec = 0; |
425 | time_window->time_width.tv_sec = 0; |
426 | time_window->time_width.tv_nsec = 0; |
f0d936c0 |
427 | |
f66eba62 |
428 | LttTime *current_time = guicontrolflow_get_current_time(Control_Flow_Data); |
429 | current_time->tv_sec = 0; |
430 | current_time->tv_nsec = 0; |
431 | |
432 | //g_critical("time width1 : %u",time_window->time_width); |
433 | |
41a76985 |
434 | get_time_window(pmParentWindow, |
f66eba62 |
435 | time_window); |
41a76985 |
436 | get_current_time(pmParentWindow, |
f66eba62 |
437 | current_time); |
f7afe191 |
438 | |
f66eba62 |
439 | //g_critical("time width2 : %u",time_window->time_width); |
f7afe191 |
440 | // Unreg done in the GuiControlFlow_Destructor |
3cff8cc1 |
441 | reg_update_time_window(update_time_window_hook, Control_Flow_Data, |
f7afe191 |
442 | pmParentWindow); |
3cff8cc1 |
443 | reg_update_current_time(update_current_time_hook, Control_Flow_Data, |
f7afe191 |
444 | pmParentWindow); |
3cff8cc1 |
445 | return guicontrolflow_get_widget(Control_Flow_Data) ; |
f0d936c0 |
446 | |
447 | } |
448 | |
3cff8cc1 |
449 | int event_selected_hook(void *hook_data, void *call_data) |
f0d936c0 |
450 | { |
451 | ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data; |
452 | guint *Event_Number = (guint*) call_data; |
453 | |
454 | g_critical("DEBUG : event selected by main window : %u", *Event_Number); |
455 | |
456 | // Control_Flow_Data->Currently_Selected_Event = *Event_Number; |
457 | // Control_Flow_Data->Selected_Event = TRUE ; |
458 | |
4c69e0cc |
459 | // tree_v_set_cursor(Control_Flow_Data); |
f0d936c0 |
460 | |
461 | } |
462 | |
f0d936c0 |
463 | /* Hook called before drawing. Gets the initial context at the beginning of the |
464 | * drawing interval and copy it to the context in Event_Request. |
465 | */ |
4c69e0cc |
466 | int draw_before_hook(void *hook_data, void *call_data) |
f0d936c0 |
467 | { |
468 | EventRequest *Event_Request = (EventRequest*)hook_data; |
f66eba62 |
469 | //EventsContext Events_Context = (EventsContext*)call_data; |
f0d936c0 |
470 | |
f66eba62 |
471 | //Event_Request->Events_Context = Events_Context; |
f0d936c0 |
472 | |
473 | return 0; |
474 | } |
475 | |
476 | /* |
477 | * The draw event hook is called by the reading API to have a |
478 | * particular event drawn on the screen. |
479 | * @param hook_data ControlFlowData structure of the viewer. |
480 | * @param call_data Event context. |
481 | * |
482 | * This function basically draw lines and icons. Two types of lines are drawn : |
483 | * one small (3 pixels?) representing the state of the process and the second |
484 | * type is thicker (10 pixels?) representing on which CPU a process is running |
485 | * (and this only in running state). |
486 | * |
487 | * Extremums of the lines : |
488 | * x_min : time of the last event context for this process kept in memory. |
489 | * x_max : time of the current event. |
490 | * y : middle of the process in the process list. The process is found in the |
491 | * list, therefore is it's position in pixels. |
492 | * |
493 | * The choice of lines'color is defined by the context of the last event for this |
494 | * process. |
495 | */ |
4c69e0cc |
496 | int draw_event_hook(void *hook_data, void *call_data) |
f0d936c0 |
497 | { |
498 | EventRequest *Event_Request = (EventRequest*)hook_data; |
80a52ff8 |
499 | ControlFlowData *control_flow_data = Event_Request->Control_Flow_Data; |
e9a9c513 |
500 | //static int i=0; |
501 | |
502 | //i++; |
503 | //g_critical("%i", i); |
80a52ff8 |
504 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
e9a9c513 |
505 | |
506 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
507 | |
508 | LttEvent *e; |
e9a9c513 |
509 | e = tfc->e; |
510 | |
80a52ff8 |
511 | /* Temp dump */ |
512 | #ifdef DONTSHOW |
513 | GString *string = g_string_new("");; |
514 | gboolean field_names = TRUE, state = TRUE; |
515 | |
e9a9c513 |
516 | lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); |
517 | g_string_append_printf(string,"\n"); |
518 | |
519 | if(state) { |
520 | g_string_append_printf(string, " %s", |
521 | g_quark_to_string(tfs->process->state->s)); |
522 | } |
523 | |
524 | g_info("%s",string->str); |
525 | |
526 | g_string_free(string, TRUE); |
527 | |
528 | /* End of text dump */ |
80a52ff8 |
529 | #endif //DONTSHOW |
e9a9c513 |
530 | /* Add process to process list (if not present) and get drawing "y" from |
531 | * process position */ |
532 | guint pid = tfs->process->pid; |
533 | LttTime birth = tfs->process->creation_time; |
80a52ff8 |
534 | guint y = 0, height = 0, pl_height = 0; |
535 | HashedProcessData *Hashed_Process_Data = NULL; |
536 | |
e9a9c513 |
537 | ProcessList *process_list = |
538 | guicontrolflow_get_process_list(Event_Request->Control_Flow_Data); |
539 | |
540 | if(processlist_get_process_pixels(process_list, |
541 | pid, |
542 | &birth, |
543 | &y, |
80a52ff8 |
544 | &height, |
545 | &Hashed_Process_Data) == 1) |
e9a9c513 |
546 | { |
547 | /* Process not present */ |
548 | processlist_add(process_list, |
549 | pid, |
550 | &birth, |
80a52ff8 |
551 | &pl_height, |
552 | &Hashed_Process_Data); |
e9a9c513 |
553 | drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y, height); |
554 | } |
80a52ff8 |
555 | |
e9a9c513 |
556 | /* Find pixels corresponding to time of the event. If the time does |
557 | * not fit in the window, show a warning, not supposed to happend. */ |
80a52ff8 |
558 | guint x = 0; |
559 | guint width = control_flow_data->Drawing->Drawing_Area_V->allocation.width; |
e9a9c513 |
560 | |
80a52ff8 |
561 | LttTime time = ltt_event_time(e); |
562 | |
563 | LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, |
564 | control_flow_data->Time_Window.start_time); |
565 | |
566 | |
567 | convert_time_to_pixels( |
568 | control_flow_data->Time_Window.start_time, |
569 | window_end, |
570 | time, |
571 | width, |
572 | &x); |
e9a9c513 |
573 | |
80a52ff8 |
574 | assert(x <= width); |
f66eba62 |
575 | |
80a52ff8 |
576 | /* Finally, draw what represents the event. */ |
577 | |
578 | GdkColor color = { 0, 0xffff, 0x0000, 0x0000 }; |
579 | PropertiesArc prop_arc; |
580 | prop_arc.color = &color; |
581 | prop_arc.size = 10; |
582 | prop_arc.filled = TRUE; |
583 | prop_arc.position = OVER; |
584 | DrawContext *draw_context = Hashed_Process_Data->draw_context; |
585 | draw_context->Current->modify_over->x = x; |
80a52ff8 |
586 | draw_context->Current->modify_over->y = y; |
80a52ff8 |
587 | draw_context->drawable = control_flow_data->Drawing->Pixmap; |
588 | GtkWidget *widget = control_flow_data->Drawing->Drawing_Area_V; |
589 | //draw_context->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
590 | draw_context->gc = widget->style->black_gc; |
591 | |
592 | draw_arc((void*)&prop_arc, (void*)draw_context); |
593 | //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); |
f0d936c0 |
594 | return 0; |
595 | } |
596 | |
597 | |
4c69e0cc |
598 | int draw_after_hook(void *hook_data, void *call_data) |
f0d936c0 |
599 | { |
600 | EventRequest *Event_Request = (EventRequest*)hook_data; |
601 | |
602 | g_free(Event_Request); |
603 | return 0; |
604 | } |
f7afe191 |
605 | |
606 | |
607 | |
608 | |
4c69e0cc |
609 | void update_time_window_hook(void *hook_data, void *call_data) |
f7afe191 |
610 | { |
611 | ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data; |
612 | TimeWindow* Time_Window = |
3cff8cc1 |
613 | guicontrolflow_get_time_window(Control_Flow_Data); |
f7afe191 |
614 | TimeWindow *New_Time_Window = ((TimeWindow*)call_data); |
615 | |
616 | // As the time interval change will mostly be used for |
617 | // zoom in and out, it's not useful to keep old drawing |
618 | // sections, as scale will be changed. |
619 | |
620 | |
621 | *Time_Window = *New_Time_Window; |
189a5d08 |
622 | g_info("New time window HOOK : %u, %u to %u, %u", |
bca3b81f |
623 | Time_Window->start_time.tv_sec, |
624 | Time_Window->start_time.tv_nsec, |
625 | Time_Window->time_width.tv_sec, |
626 | Time_Window->time_width.tv_nsec); |
f7afe191 |
627 | |
6d5ed1c3 |
628 | drawing_data_request(Control_Flow_Data->Drawing, |
f7afe191 |
629 | &Control_Flow_Data->Drawing->Pixmap, |
630 | 0, 0, |
631 | Control_Flow_Data->Drawing->width, |
632 | Control_Flow_Data->Drawing->height); |
633 | |
4c69e0cc |
634 | drawing_refresh(Control_Flow_Data->Drawing, |
f7afe191 |
635 | 0, 0, |
636 | Control_Flow_Data->Drawing->width, |
637 | Control_Flow_Data->Drawing->height); |
638 | |
639 | } |
640 | |
4c69e0cc |
641 | void update_current_time_hook(void *hook_data, void *call_data) |
f7afe191 |
642 | { |
643 | ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data; |
644 | LttTime* Current_Time = |
4c69e0cc |
645 | guicontrolflow_get_current_time(Control_Flow_Data); |
f7afe191 |
646 | *Current_Time = *((LttTime*)call_data); |
189a5d08 |
647 | g_info("New Current time HOOK : %u, %u", Current_Time->tv_sec, |
f7afe191 |
648 | Current_Time->tv_nsec); |
649 | |
650 | /* If current time is inside time interval, just move the highlight |
651 | * bar */ |
652 | |
653 | /* Else, we have to change the time interval. We have to tell it |
654 | * to the main window. */ |
655 | /* The time interval change will take care of placing the current |
656 | * time at the center of the visible area */ |
657 | |
658 | } |
659 | |