change function names
[lttv.git] / ltt / branches / poly / lttv / modules / guiControlFlow / Event_Hooks.c
CommitLineData
f0d936c0 1/*****************************************************************************
2 * Hooks to be called by the main window *
3 *****************************************************************************/
4
f0d936c0 5
cf6cb7e0 6//#define PANGO_ENABLE_BACKEND
558aa013 7#include <gtk/gtk.h>
8#include <gdk/gdk.h>
5f16133f 9#include <glib.h>
10
cf6cb7e0 11//#include <pango/pango.h>
12
558aa013 13#include <lttv/hook.h>
14#include <lttv/common.h>
f0d936c0 15
1ab818de 16#include "Event_Hooks.h"
f0d936c0 17#include "CFV.h"
5f16133f 18#include "Process_List.h"
1ab3d149 19#include "Drawing.h"
f7afe191 20#include "CFV-private.h"
5f16133f 21
f7afe191 22
23/* NOTE : no drawing data should be sent there, as the drawing widget
96cfe486 24 * has not been initialized */
f7afe191 25void send_test_drawing(ProcessList *Process_List,
26 Drawing_t *Drawing,
27 GdkPixmap *Pixmap,
28 gint x, gint y, // y not used here?
29 gint width,
30 gint height) // height won't be used here ?
31{
32 int i;
33 ProcessInfo Process_Info = {10000, 12000, 55600};
34 //ProcessInfo Process_Info = {156, 14000, 55500};
35 GtkTreeRowReference *got_RowRef;
cf6cb7e0 36 PangoContext *context;
37 PangoLayout *layout;
38 PangoFontDescription *FontDesc;// = pango_font_description_new();
39 gint Font_Size;
40
41 /* Sent text data */
42 layout = gtk_widget_create_pango_layout(Drawing->Drawing_Area_V,
43 NULL);
44 context = pango_layout_get_context(layout);
45 FontDesc = pango_context_get_font_description(context);
46 Font_Size = pango_font_description_get_size(FontDesc);
47 pango_font_description_set_size(FontDesc, Font_Size-3*PANGO_SCALE);
48
f7afe191 49
cf6cb7e0 50
51
f7afe191 52 LttTime birth;
53 birth.tv_sec = 12000;
54 birth.tv_nsec = 55500;
55 g_critical("we have : x : %u, y : %u, width : %u, height : %u", x, y, width, height);
4c69e0cc 56 processlist_get_process_pixels(Process_List,
f7afe191 57 1,
58 &birth,
59 &y,
60 &height);
61
62 g_critical("we draw : x : %u, y : %u, width : %u, height : %u", x, y, width, height);
4c69e0cc 63 drawing_draw_line(
f7afe191 64 Drawing, Pixmap, x,
65 y+(height/2), x + width, y+(height/2),
66 Drawing->Drawing_Area_V->style->black_gc);
67
cf6cb7e0 68 pango_layout_set_text(layout, "Test", -1);
69 gdk_draw_layout(Pixmap, Drawing->Drawing_Area_V->style->black_gc,
70 0, y+height, layout);
71
f7afe191 72 birth.tv_sec = 14000;
73 birth.tv_nsec = 55500;
74
4c69e0cc 75 processlist_get_process_pixels(Process_List,
f7afe191 76 156,
77 &birth,
78 &y,
79 &height);
80
81
4c69e0cc 82 drawing_draw_line(
f7afe191 83 Drawing, Pixmap, x,
84 y+(height/2), x + width, y+(height/2),
85 Drawing->Drawing_Area_V->style->black_gc);
86
87 g_critical("y : %u, height : %u", y, height);
88
89 birth.tv_sec = 12000;
90 birth.tv_nsec = 55700;
91
4c69e0cc 92 processlist_get_process_pixels(Process_List,
f7afe191 93 10,
94 &birth,
95 &y,
96 &height);
97
98
4c69e0cc 99 drawing_draw_line(
f7afe191 100 Drawing, Pixmap, x,
101 y+(height/2), x + width, y+(height/2),
102 Drawing->Drawing_Area_V->style->black_gc);
103
104 g_critical("y : %u, height : %u", y, height);
105
106 for(i=0; i<10; i++)
107 {
108 birth.tv_sec = i*12000;
109 birth.tv_nsec = i*55700;
110
4c69e0cc 111 processlist_get_process_pixels(Process_List,
f7afe191 112 i,
113 &birth,
114 &y,
115 &height);
116
117
4c69e0cc 118 drawing_draw_line(
f7afe191 119 Drawing, Pixmap, x,
120 y+(height/2), x + width, y+(height/2),
121 Drawing->Drawing_Area_V->style->black_gc);
122
123 g_critical("y : %u, height : %u", y, height);
124
125 }
126
127 birth.tv_sec = 12000;
128 birth.tv_nsec = 55600;
129
4c69e0cc 130 processlist_get_process_pixels(Process_List,
f7afe191 131 10,
132 &birth,
133 &y,
134 &height);
135
136
4c69e0cc 137 drawing_draw_line(
f7afe191 138 Drawing, Pixmap, x,
139 y+(height/2), x + width, y+(height/2),
140 Drawing->Drawing_Area_V->style->black_gc);
141
142 g_critical("y : %u, height : %u", y, height);
cf6cb7e0 143
144
145 pango_font_description_set_size(FontDesc, Font_Size);
146 g_free(layout);
147 //g_free(context);
f7afe191 148}
149
150void send_test_process(ProcessList *Process_List, Drawing_t *Drawing)
5f16133f 151{
f7afe191 152 guint height, y;
5f16133f 153 int i;
154 ProcessInfo Process_Info = {10000, 12000, 55600};
155 //ProcessInfo Process_Info = {156, 14000, 55500};
156 GtkTreeRowReference *got_RowRef;
157
158 LttTime birth;
f7afe191 159
160 if(Process_List->Test_Process_Sent) return;
161
5f16133f 162 birth.tv_sec = 12000;
163 birth.tv_nsec = 55500;
164
4c69e0cc 165 processlist_add(Process_List,
5f16133f 166 1,
167 &birth,
f7afe191 168 &y);
4c69e0cc 169 processlist_get_process_pixels(Process_List,
f7afe191 170 1,
171 &birth,
172 &y,
173 &height);
4c69e0cc 174 drawing_insert_square( Drawing, y, height);
1ab3d149 175
f7afe191 176 //g_critical("y : %u, height : %u", y, height);
5f16133f 177
178 birth.tv_sec = 14000;
179 birth.tv_nsec = 55500;
180
4c69e0cc 181 processlist_add(Process_List,
5f16133f 182 156,
183 &birth,
f7afe191 184 &y);
4c69e0cc 185 processlist_get_process_pixels(Process_List,
f7afe191 186 156,
187 &birth,
188 &y,
189 &height);
4c69e0cc 190 drawing_insert_square( Drawing, y, height);
f7afe191 191
192 //g_critical("y : %u, height : %u", y, height);
193
5f16133f 194 birth.tv_sec = 12000;
195 birth.tv_nsec = 55700;
196
4c69e0cc 197 processlist_add(Process_List,
5f16133f 198 10,
199 &birth,
200 &height);
4c69e0cc 201 processlist_get_process_pixels(Process_List,
f7afe191 202 10,
203 &birth,
204 &y,
205 &height);
4c69e0cc 206 drawing_insert_square( Drawing, y, height);
f7afe191 207
208 //g_critical("y : %u, height : %u", y, height);
209
4c69e0cc 210 //drawing_insert_square( Drawing, height, 5);
5f16133f 211
212 for(i=0; i<10; i++)
213 {
214 birth.tv_sec = i*12000;
215 birth.tv_nsec = i*55700;
216
4c69e0cc 217 processlist_add(Process_List,
5f16133f 218 i,
219 &birth,
220 &height);
4c69e0cc 221 processlist_get_process_pixels(Process_List,
f7afe191 222 i,
223 &birth,
224 &y,
225 &height);
4c69e0cc 226 drawing_insert_square( Drawing, y, height);
f7afe191 227
228 // g_critical("y : %u, height : %u", y, height);
229
5f16133f 230 }
f7afe191 231 //g_critical("height : %u", height);
5f16133f 232
233 birth.tv_sec = 12000;
234 birth.tv_nsec = 55600;
235
4c69e0cc 236 processlist_add(Process_List,
5f16133f 237 10,
238 &birth,
f7afe191 239 &y);
4c69e0cc 240 processlist_get_process_pixels(Process_List,
f7afe191 241 10,
242 &birth,
243 &y,
244 &height);
4c69e0cc 245 drawing_insert_square( Drawing, y, height);
f7afe191 246
247 //g_critical("y : %u, height : %u", y, height);
248
4c69e0cc 249 processlist_add(Process_List,
5f16133f 250 10000,
251 &birth,
252 &height);
4c69e0cc 253 processlist_get_process_pixels(Process_List,
f7afe191 254 10000,
255 &birth,
256 &y,
257 &height);
4c69e0cc 258 drawing_insert_square( Drawing, y, height);
f7afe191 259
260 //g_critical("y : %u, height : %u", y, height);
261
4c69e0cc 262 //drawing_insert_square( Drawing, height, 5);
f7afe191 263 //g_critical("height : %u", height);
5f16133f 264
265
4c69e0cc 266 processlist_get_process_pixels(Process_List,
1ab3d149 267 10000,
268 &birth,
f7afe191 269 &y, &height);
4c69e0cc 270 processlist_remove( Process_List,
5f16133f 271 10000,
272 &birth);
1ab3d149 273
4c69e0cc 274 drawing_remove_square( Drawing, y, height);
5f16133f 275
276 if(got_RowRef =
277 (GtkTreeRowReference*)g_hash_table_lookup(
278 Process_List->Process_Hash,
279 &Process_Info))
280 {
281 g_critical("key found");
282 g_critical("position in the list : %s",
283 gtk_tree_path_to_string (
284 gtk_tree_row_reference_get_path(
285 (GtkTreeRowReference*)got_RowRef)
286 ));
287
288 }
289
f7afe191 290 Process_List->Test_Process_Sent = TRUE;
291
5f16133f 292}
293
294
f0d936c0 295
296/**
297 * Event Viewer's constructor hook
298 *
299 * This constructor is given as a parameter to the menuitem and toolbar button
300 * registration. It creates the list.
301 * @param pmParentWindow A pointer to the parent window.
302 * @return The widget created.
303 */
304GtkWidget *
4c69e0cc 305h_guicontrolflow(MainWindow *pmParentWindow, LttvTracesetSelector * s, char * key)
f0d936c0 306{
1ab818de 307 g_critical("hGuiControlFlow");
4c69e0cc 308 ControlFlowData *Control_Flow_Data = guicontrolflow() ;
f0d936c0 309
41a76985 310 get_time_window(pmParentWindow,
f7afe191 311 GuiControlFlow_get_Time_Window(Control_Flow_Data));
41a76985 312 get_current_time(pmParentWindow,
f7afe191 313 GuiControlFlow_get_Current_Time(Control_Flow_Data));
314
315 // Unreg done in the GuiControlFlow_Destructor
41a76985 316 reg_update_time_window(Update_Time_Window_Hook, Control_Flow_Data,
f7afe191 317 pmParentWindow);
41a76985 318 reg_update_current_time(Update_Current_Time_Hook, Control_Flow_Data,
f7afe191 319 pmParentWindow);
558aa013 320 return GuiControlFlow_get_Widget(Control_Flow_Data) ;
f0d936c0 321
322}
323
324int Event_Selected_Hook(void *hook_data, void *call_data)
325{
326 ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data;
327 guint *Event_Number = (guint*) call_data;
328
329 g_critical("DEBUG : event selected by main window : %u", *Event_Number);
330
331// Control_Flow_Data->Currently_Selected_Event = *Event_Number;
332// Control_Flow_Data->Selected_Event = TRUE ;
333
4c69e0cc 334// tree_v_set_cursor(Control_Flow_Data);
f0d936c0 335
336}
337
558aa013 338#ifdef DEBUG
f0d936c0 339/* Hook called before drawing. Gets the initial context at the beginning of the
340 * drawing interval and copy it to the context in Event_Request.
341 */
4c69e0cc 342int draw_before_hook(void *hook_data, void *call_data)
f0d936c0 343{
344 EventRequest *Event_Request = (EventRequest*)hook_data;
345 EventsContext Events_Context = (EventsContext*)call_data;
346
347 Event_Request->Events_Context = Events_Context;
348
349 return 0;
350}
351
352/*
353 * The draw event hook is called by the reading API to have a
354 * particular event drawn on the screen.
355 * @param hook_data ControlFlowData structure of the viewer.
356 * @param call_data Event context.
357 *
358 * This function basically draw lines and icons. Two types of lines are drawn :
359 * one small (3 pixels?) representing the state of the process and the second
360 * type is thicker (10 pixels?) representing on which CPU a process is running
361 * (and this only in running state).
362 *
363 * Extremums of the lines :
364 * x_min : time of the last event context for this process kept in memory.
365 * x_max : time of the current event.
366 * y : middle of the process in the process list. The process is found in the
367 * list, therefore is it's position in pixels.
368 *
369 * The choice of lines'color is defined by the context of the last event for this
370 * process.
371 */
4c69e0cc 372int draw_event_hook(void *hook_data, void *call_data)
f0d936c0 373{
374 EventRequest *Event_Request = (EventRequest*)hook_data;
375
376 return 0;
377}
378
379
4c69e0cc 380int draw_after_hook(void *hook_data, void *call_data)
f0d936c0 381{
382 EventRequest *Event_Request = (EventRequest*)hook_data;
383
384 g_free(Event_Request);
385 return 0;
386}
558aa013 387#endif
f7afe191 388
389
390
391
4c69e0cc 392void update_time_window_hook(void *hook_data, void *call_data)
f7afe191 393{
394 ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data;
395 TimeWindow* Time_Window =
396 GuiControlFlow_get_Time_Window(Control_Flow_Data);
397 TimeWindow *New_Time_Window = ((TimeWindow*)call_data);
398
399 // As the time interval change will mostly be used for
400 // zoom in and out, it's not useful to keep old drawing
401 // sections, as scale will be changed.
402
403
404 *Time_Window = *New_Time_Window;
405 g_critical("New time window HOOK : %u, %u to %u, %u",
bca3b81f 406 Time_Window->start_time.tv_sec,
407 Time_Window->start_time.tv_nsec,
408 Time_Window->time_width.tv_sec,
409 Time_Window->time_width.tv_nsec);
f7afe191 410
4c69e0cc 411 drawing_data_request(Control_Flow_Data->Drawing,
f7afe191 412 &Control_Flow_Data->Drawing->Pixmap,
413 0, 0,
414 Control_Flow_Data->Drawing->width,
415 Control_Flow_Data->Drawing->height);
416
4c69e0cc 417 drawing_refresh(Control_Flow_Data->Drawing,
f7afe191 418 0, 0,
419 Control_Flow_Data->Drawing->width,
420 Control_Flow_Data->Drawing->height);
421
422}
423
4c69e0cc 424void update_current_time_hook(void *hook_data, void *call_data)
f7afe191 425{
426 ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data;
427 LttTime* Current_Time =
4c69e0cc 428 guicontrolflow_get_current_time(Control_Flow_Data);
f7afe191 429 *Current_Time = *((LttTime*)call_data);
430 g_critical("New Current time HOOK : %u, %u", Current_Time->tv_sec,
431 Current_Time->tv_nsec);
432
433 /* If current time is inside time interval, just move the highlight
434 * bar */
435
436 /* Else, we have to change the time interval. We have to tell it
437 * to the main window. */
438 /* The time interval change will take care of placing the current
439 * time at the center of the visible area */
440
441}
442
This page took 0.043123 seconds and 4 git commands to generate.