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