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> |
50439712 |
14 | #include <string.h> |
5f16133f |
15 | |
cf6cb7e0 |
16 | //#include <pango/pango.h> |
17 | |
80a52ff8 |
18 | #include <ltt/event.h> |
4ba42155 |
19 | #include <ltt/time.h> |
50439712 |
20 | #include <ltt/type.h> |
80a52ff8 |
21 | |
558aa013 |
22 | #include <lttv/hook.h> |
23 | #include <lttv/common.h> |
80a52ff8 |
24 | #include <lttv/state.h> |
25 | |
f0d936c0 |
26 | |
1ab818de |
27 | #include "Event_Hooks.h" |
f0d936c0 |
28 | #include "CFV.h" |
5f16133f |
29 | #include "Process_List.h" |
1ab3d149 |
30 | #include "Drawing.h" |
f7afe191 |
31 | #include "CFV-private.h" |
5f16133f |
32 | |
80a52ff8 |
33 | |
1a31868c |
34 | #define MAX_PATH_LEN 256 |
35 | |
f0d936c0 |
36 | |
37 | /** |
38 | * Event Viewer's constructor hook |
39 | * |
40 | * This constructor is given as a parameter to the menuitem and toolbar button |
41 | * registration. It creates the list. |
42 | * @param pmParentWindow A pointer to the parent window. |
43 | * @return The widget created. |
44 | */ |
45 | GtkWidget * |
4c69e0cc |
46 | h_guicontrolflow(MainWindow *pmParentWindow, LttvTracesetSelector * s, char * key) |
f0d936c0 |
47 | { |
189a5d08 |
48 | g_info("h_guicontrolflow, %p, %p, %s", pmParentWindow, s, key); |
4c69e0cc |
49 | ControlFlowData *Control_Flow_Data = guicontrolflow() ; |
189a5d08 |
50 | |
51 | Control_Flow_Data->Parent_Window = pmParentWindow; |
f66eba62 |
52 | TimeWindow *time_window = guicontrolflow_get_time_window(Control_Flow_Data); |
53 | time_window->start_time.tv_sec = 0; |
54 | time_window->start_time.tv_nsec = 0; |
55 | time_window->time_width.tv_sec = 0; |
56 | time_window->time_width.tv_nsec = 0; |
f0d936c0 |
57 | |
f66eba62 |
58 | LttTime *current_time = guicontrolflow_get_current_time(Control_Flow_Data); |
59 | current_time->tv_sec = 0; |
60 | current_time->tv_nsec = 0; |
61 | |
62 | //g_critical("time width1 : %u",time_window->time_width); |
63 | |
41a76985 |
64 | get_time_window(pmParentWindow, |
f66eba62 |
65 | time_window); |
41a76985 |
66 | get_current_time(pmParentWindow, |
f66eba62 |
67 | current_time); |
f7afe191 |
68 | |
f66eba62 |
69 | //g_critical("time width2 : %u",time_window->time_width); |
f7afe191 |
70 | // Unreg done in the GuiControlFlow_Destructor |
3cff8cc1 |
71 | reg_update_time_window(update_time_window_hook, Control_Flow_Data, |
f7afe191 |
72 | pmParentWindow); |
3cff8cc1 |
73 | reg_update_current_time(update_current_time_hook, Control_Flow_Data, |
f7afe191 |
74 | pmParentWindow); |
3cff8cc1 |
75 | return guicontrolflow_get_widget(Control_Flow_Data) ; |
f0d936c0 |
76 | |
77 | } |
78 | |
3cff8cc1 |
79 | int event_selected_hook(void *hook_data, void *call_data) |
f0d936c0 |
80 | { |
81 | ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data; |
82 | guint *Event_Number = (guint*) call_data; |
83 | |
84 | g_critical("DEBUG : event selected by main window : %u", *Event_Number); |
85 | |
86 | // Control_Flow_Data->Currently_Selected_Event = *Event_Number; |
87 | // Control_Flow_Data->Selected_Event = TRUE ; |
88 | |
4c69e0cc |
89 | // tree_v_set_cursor(Control_Flow_Data); |
f0d936c0 |
90 | |
91 | } |
92 | |
f0d936c0 |
93 | /* Hook called before drawing. Gets the initial context at the beginning of the |
94 | * drawing interval and copy it to the context in Event_Request. |
95 | */ |
4c69e0cc |
96 | int draw_before_hook(void *hook_data, void *call_data) |
f0d936c0 |
97 | { |
98 | EventRequest *Event_Request = (EventRequest*)hook_data; |
f66eba62 |
99 | //EventsContext Events_Context = (EventsContext*)call_data; |
f0d936c0 |
100 | |
f66eba62 |
101 | //Event_Request->Events_Context = Events_Context; |
f0d936c0 |
102 | |
103 | return 0; |
104 | } |
105 | |
106 | /* |
107 | * The draw event hook is called by the reading API to have a |
108 | * particular event drawn on the screen. |
109 | * @param hook_data ControlFlowData structure of the viewer. |
110 | * @param call_data Event context. |
111 | * |
112 | * This function basically draw lines and icons. Two types of lines are drawn : |
113 | * one small (3 pixels?) representing the state of the process and the second |
114 | * type is thicker (10 pixels?) representing on which CPU a process is running |
115 | * (and this only in running state). |
116 | * |
117 | * Extremums of the lines : |
118 | * x_min : time of the last event context for this process kept in memory. |
119 | * x_max : time of the current event. |
120 | * y : middle of the process in the process list. The process is found in the |
121 | * list, therefore is it's position in pixels. |
122 | * |
123 | * The choice of lines'color is defined by the context of the last event for this |
124 | * process. |
125 | */ |
4c69e0cc |
126 | int draw_event_hook(void *hook_data, void *call_data) |
f0d936c0 |
127 | { |
128 | EventRequest *Event_Request = (EventRequest*)hook_data; |
80a52ff8 |
129 | ControlFlowData *control_flow_data = Event_Request->Control_Flow_Data; |
e9a9c513 |
130 | //static int i=0; |
131 | |
132 | //i++; |
133 | //g_critical("%i", i); |
80a52ff8 |
134 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
e9a9c513 |
135 | |
136 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
137 | |
138 | LttEvent *e; |
e9a9c513 |
139 | e = tfc->e; |
140 | |
80a52ff8 |
141 | /* Temp dump */ |
142 | #ifdef DONTSHOW |
143 | GString *string = g_string_new("");; |
144 | gboolean field_names = TRUE, state = TRUE; |
145 | |
e9a9c513 |
146 | lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); |
147 | g_string_append_printf(string,"\n"); |
148 | |
149 | if(state) { |
150 | g_string_append_printf(string, " %s", |
151 | g_quark_to_string(tfs->process->state->s)); |
152 | } |
153 | |
154 | g_info("%s",string->str); |
155 | |
156 | g_string_free(string, TRUE); |
157 | |
158 | /* End of text dump */ |
80a52ff8 |
159 | #endif //DONTSHOW |
50439712 |
160 | |
e9a9c513 |
161 | /* Add process to process list (if not present) and get drawing "y" from |
162 | * process position */ |
163 | guint pid = tfs->process->pid; |
164 | LttTime birth = tfs->process->creation_time; |
50439712 |
165 | gchar *name = strdup(g_quark_to_string(tfs->process->name)); |
80a52ff8 |
166 | guint y = 0, height = 0, pl_height = 0; |
167 | HashedProcessData *Hashed_Process_Data = NULL; |
168 | |
e9a9c513 |
169 | ProcessList *process_list = |
170 | guicontrolflow_get_process_list(Event_Request->Control_Flow_Data); |
171 | |
172 | if(processlist_get_process_pixels(process_list, |
173 | pid, |
174 | &birth, |
175 | &y, |
80a52ff8 |
176 | &height, |
177 | &Hashed_Process_Data) == 1) |
e9a9c513 |
178 | { |
179 | /* Process not present */ |
180 | processlist_add(process_list, |
181 | pid, |
182 | &birth, |
432a7065 |
183 | name, |
80a52ff8 |
184 | &pl_height, |
185 | &Hashed_Process_Data); |
432a7065 |
186 | g_free(name); |
e9a9c513 |
187 | drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y, height); |
188 | } |
80a52ff8 |
189 | |
e9a9c513 |
190 | /* Find pixels corresponding to time of the event. If the time does |
191 | * not fit in the window, show a warning, not supposed to happend. */ |
80a52ff8 |
192 | guint x = 0; |
193 | guint width = control_flow_data->Drawing->Drawing_Area_V->allocation.width; |
e9a9c513 |
194 | |
80a52ff8 |
195 | LttTime time = ltt_event_time(e); |
196 | |
197 | LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, |
198 | control_flow_data->Time_Window.start_time); |
199 | |
200 | |
201 | convert_time_to_pixels( |
202 | control_flow_data->Time_Window.start_time, |
203 | window_end, |
204 | time, |
205 | width, |
206 | &x); |
e9a9c513 |
207 | |
80a52ff8 |
208 | assert(x <= width); |
f66eba62 |
209 | |
80a52ff8 |
210 | /* Finally, draw what represents the event. */ |
211 | |
212 | GdkColor color = { 0, 0xffff, 0x0000, 0x0000 }; |
213 | PropertiesArc prop_arc; |
214 | prop_arc.color = &color; |
215 | prop_arc.size = 10; |
216 | prop_arc.filled = TRUE; |
217 | prop_arc.position = OVER; |
34b04882 |
218 | |
80a52ff8 |
219 | DrawContext *draw_context = Hashed_Process_Data->draw_context; |
220 | draw_context->Current->modify_over->x = x; |
80a52ff8 |
221 | draw_context->Current->modify_over->y = y; |
80a52ff8 |
222 | draw_context->drawable = control_flow_data->Drawing->Pixmap; |
34b04882 |
223 | draw_context->pango_layout = control_flow_data->Drawing->pango_layout; |
80a52ff8 |
224 | GtkWidget *widget = control_flow_data->Drawing->Drawing_Area_V; |
225 | //draw_context->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
226 | draw_context->gc = widget->style->black_gc; |
227 | |
34b04882 |
228 | //draw_arc((void*)&prop_arc, (void*)draw_context); |
80a52ff8 |
229 | //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); |
34b04882 |
230 | |
50439712 |
231 | //GdkColor colorfg = { 0, 0xffff, 0x0000, 0x0000 }; |
232 | GdkColor colorfg; |
233 | colorfg.red = 0xffff; |
234 | colorfg.green = 0x0000; |
235 | colorfg.blue = 0x0000; |
236 | //GdkColor colorbg = { 0, 0xffff, 0x0000, 0xffff }; |
237 | GdkColor colorbg; |
238 | colorbg.red = 0x0000; |
239 | colorbg.green = 0x0000; |
240 | colorbg.blue = 0x0000; |
241 | |
34b04882 |
242 | PropertiesText prop_text; |
243 | prop_text.foreground = &colorfg; |
244 | prop_text.background = &colorbg; |
245 | prop_text.size = 10; |
246 | prop_text.position = OVER; |
247 | |
248 | /* Print status of the process : U, WF, WC, E, W, R */ |
249 | if(tfs->process->state->s == LTTV_STATE_UNNAMED) |
250 | prop_text.Text = "U"; |
251 | else if(tfs->process->state->s == LTTV_STATE_WAIT_FORK) |
252 | prop_text.Text = "WF"; |
253 | else if(tfs->process->state->s == LTTV_STATE_WAIT_CPU) |
254 | prop_text.Text = "WC"; |
255 | else if(tfs->process->state->s == LTTV_STATE_EXIT) |
256 | prop_text.Text = "E"; |
257 | else if(tfs->process->state->s == LTTV_STATE_WAIT) |
258 | prop_text.Text = "W"; |
259 | else if(tfs->process->state->s == LTTV_STATE_RUN) |
260 | prop_text.Text = "R"; |
261 | else |
262 | prop_text.Text = "U"; |
263 | |
264 | draw_text((void*)&prop_text, (void*)draw_context); |
265 | |
f0d936c0 |
266 | return 0; |
267 | } |
268 | |
269 | |
4c69e0cc |
270 | int draw_after_hook(void *hook_data, void *call_data) |
f0d936c0 |
271 | { |
272 | EventRequest *Event_Request = (EventRequest*)hook_data; |
50439712 |
273 | ControlFlowData *control_flow_data = Event_Request->Control_Flow_Data; |
274 | |
275 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
276 | |
277 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
278 | |
f0d936c0 |
279 | |
50439712 |
280 | LttEvent *e; |
281 | e = tfc->e; |
282 | |
283 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) |
284 | { |
285 | g_critical("schedchange!"); |
286 | |
287 | /* Add process to process list (if not present) and get drawing "y" from |
288 | * process position */ |
289 | guint pid_out, pid_in; |
290 | LttvProcessState *process_out, *process_in; |
291 | LttTime birth; |
292 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
293 | |
294 | ProcessList *process_list = |
295 | guicontrolflow_get_process_list(Event_Request->Control_Flow_Data); |
296 | |
297 | |
298 | LttField *f = ltt_event_field(e); |
299 | LttField *element; |
300 | element = ltt_field_member(f,0); |
301 | pid_out = ltt_event_get_long_unsigned(e,element); |
302 | element = ltt_field_member(f,1); |
303 | pid_in = ltt_event_get_long_unsigned(e,element); |
304 | g_critical("out : %u in : %u", pid_out, pid_in); |
305 | |
306 | |
307 | /* Find process pid_out in the list... */ |
308 | process_out = lttv_state_find_process(tfs, pid_out); |
309 | g_critical("out : %s",g_quark_to_string(process_out->state->s)); |
310 | |
311 | birth = process_out->creation_time; |
312 | gchar *name = strdup(g_quark_to_string(process_out->name)); |
313 | HashedProcessData *Hashed_Process_Data_out = NULL; |
314 | |
315 | if(processlist_get_process_pixels(process_list, |
316 | pid_out, |
317 | &birth, |
318 | &y_out, |
319 | &height, |
320 | &Hashed_Process_Data_out) == 1) |
321 | { |
322 | /* Process not present */ |
323 | processlist_add(process_list, |
324 | pid_out, |
325 | &birth, |
326 | name, |
327 | &pl_height, |
328 | &Hashed_Process_Data_out); |
329 | processlist_get_process_pixels(process_list, |
330 | pid_out, |
331 | &birth, |
332 | &y_out, |
333 | &height, |
334 | &Hashed_Process_Data_out); |
335 | drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y_out, height); |
336 | } |
337 | |
338 | g_free(name); |
339 | |
340 | /* Find process pid_in in the list... */ |
341 | process_in = lttv_state_find_process(tfs, pid_in); |
342 | g_critical("in : %s",g_quark_to_string(process_in->state->s)); |
343 | |
344 | birth = process_in->creation_time; |
345 | name = strdup(g_quark_to_string(process_in->name)); |
346 | HashedProcessData *Hashed_Process_Data_in = NULL; |
347 | |
348 | if(processlist_get_process_pixels(process_list, |
349 | pid_in, |
350 | &birth, |
351 | &y_in, |
352 | &height, |
353 | &Hashed_Process_Data_in) == 1) |
354 | { |
355 | /* Process not present */ |
356 | processlist_add(process_list, |
357 | pid_in, |
358 | &birth, |
359 | name, |
360 | &pl_height, |
361 | &Hashed_Process_Data_in); |
362 | processlist_get_process_pixels(process_list, |
363 | pid_in, |
364 | &birth, |
365 | &y_in, |
366 | &height, |
367 | &Hashed_Process_Data_in); |
368 | |
369 | drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y_in, height); |
370 | } |
371 | g_free(name); |
372 | |
373 | |
374 | /* Find pixels corresponding to time of the event. If the time does |
375 | * not fit in the window, show a warning, not supposed to happend. */ |
376 | guint x = 0; |
377 | guint width = control_flow_data->Drawing->Drawing_Area_V->allocation.width; |
378 | |
379 | LttTime time = ltt_event_time(e); |
380 | |
381 | LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, |
382 | control_flow_data->Time_Window.start_time); |
383 | |
384 | |
385 | convert_time_to_pixels( |
386 | control_flow_data->Time_Window.start_time, |
387 | window_end, |
388 | time, |
389 | width, |
390 | &x); |
391 | |
392 | assert(x <= width); |
393 | |
394 | /* draw what represents the event for outgoing process. */ |
395 | |
396 | DrawContext *draw_context_out = Hashed_Process_Data_out->draw_context; |
397 | draw_context_out->Current->modify_over->x = x; |
398 | draw_context_out->Current->modify_over->y = y_out; |
399 | draw_context_out->drawable = control_flow_data->Drawing->Pixmap; |
400 | draw_context_out->pango_layout = control_flow_data->Drawing->pango_layout; |
401 | GtkWidget *widget = control_flow_data->Drawing->Drawing_Area_V; |
402 | //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
403 | draw_context_out->gc = widget->style->black_gc; |
404 | |
405 | //draw_arc((void*)&prop_arc, (void*)draw_context_out); |
406 | //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); |
407 | |
408 | GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; |
409 | GdkColor colorbg_out = { 0, 0xffff, 0xffff, 0xffff }; |
410 | PropertiesText prop_text_out; |
411 | prop_text_out.foreground = &colorfg_out; |
412 | prop_text_out.background = &colorbg_out; |
413 | prop_text_out.size = 10; |
414 | prop_text_out.position = OVER; |
415 | |
416 | /* Print status of the process : U, WF, WC, E, W, R */ |
417 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
418 | prop_text_out.Text = "U"; |
419 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
420 | prop_text_out.Text = "WF"; |
421 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
422 | prop_text_out.Text = "WC"; |
423 | else if(process_out->state->s == LTTV_STATE_EXIT) |
424 | prop_text_out.Text = "E"; |
425 | else if(process_out->state->s == LTTV_STATE_WAIT) |
426 | prop_text_out.Text = "W"; |
427 | else if(process_out->state->s == LTTV_STATE_RUN) |
428 | prop_text_out.Text = "R"; |
429 | else |
430 | prop_text_out.Text = "U"; |
431 | |
432 | draw_text((void*)&prop_text_out, (void*)draw_context_out); |
433 | |
434 | /* Finally, update the drawing context of the pid_in. */ |
435 | |
436 | DrawContext *draw_context_in = Hashed_Process_Data_in->draw_context; |
437 | draw_context_in->Current->modify_over->x = x; |
438 | draw_context_in->Current->modify_over->y = y_in; |
439 | draw_context_in->drawable = control_flow_data->Drawing->Pixmap; |
440 | draw_context_in->pango_layout = control_flow_data->Drawing->pango_layout; |
441 | widget = control_flow_data->Drawing->Drawing_Area_V; |
442 | //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
443 | draw_context_in->gc = widget->style->black_gc; |
444 | |
445 | //draw_arc((void*)&prop_arc, (void*)draw_context_in); |
446 | //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); |
447 | |
448 | GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; |
449 | GdkColor colorbg_in = { 0, 0xffff, 0xffff, 0xffff }; |
450 | PropertiesText prop_text_in; |
451 | prop_text_in.foreground = &colorfg_in; |
452 | prop_text_in.background = &colorbg_in; |
453 | prop_text_in.size = 10; |
454 | prop_text_in.position = OVER; |
455 | |
456 | /* Print status of the process : U, WF, WC, E, W, R */ |
457 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
458 | prop_text_in.Text = "U"; |
459 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
460 | prop_text_in.Text = "WF"; |
461 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
462 | prop_text_in.Text = "WC"; |
463 | else if(process_in->state->s == LTTV_STATE_EXIT) |
464 | prop_text_in.Text = "E"; |
465 | else if(process_in->state->s == LTTV_STATE_WAIT) |
466 | prop_text_in.Text = "W"; |
467 | else if(process_in->state->s == LTTV_STATE_RUN) |
468 | prop_text_in.Text = "R"; |
469 | else |
470 | prop_text_in.Text = "U"; |
471 | |
472 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
473 | |
474 | } |
475 | |
f0d936c0 |
476 | return 0; |
477 | } |
f7afe191 |
478 | |
479 | |
480 | |
481 | |
4c69e0cc |
482 | void update_time_window_hook(void *hook_data, void *call_data) |
f7afe191 |
483 | { |
4ba42155 |
484 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
485 | TimeWindow *Old_Time_Window = |
486 | guicontrolflow_get_time_window(control_flow_data); |
f7afe191 |
487 | TimeWindow *New_Time_Window = ((TimeWindow*)call_data); |
bd24a9af |
488 | |
4ba42155 |
489 | /* Two cases : zoom in/out or scrolling */ |
bd24a9af |
490 | |
4ba42155 |
491 | /* In order to make sure we can reuse the old drawing, the scale must |
492 | * be the same and the new time interval being partly located in the |
493 | * currently shown time interval. (reuse is only for scrolling) |
494 | */ |
495 | |
496 | g_info("Old time window HOOK : %u, %u to %u, %u", |
497 | Old_Time_Window->start_time.tv_sec, |
498 | Old_Time_Window->start_time.tv_nsec, |
499 | Old_Time_Window->time_width.tv_sec, |
500 | Old_Time_Window->time_width.tv_nsec); |
f7afe191 |
501 | |
189a5d08 |
502 | g_info("New time window HOOK : %u, %u to %u, %u", |
4ba42155 |
503 | New_Time_Window->start_time.tv_sec, |
504 | New_Time_Window->start_time.tv_nsec, |
505 | New_Time_Window->time_width.tv_sec, |
506 | New_Time_Window->time_width.tv_nsec); |
507 | |
508 | if( New_Time_Window->time_width.tv_sec == Old_Time_Window->time_width.tv_sec |
509 | && New_Time_Window->time_width.tv_nsec == Old_Time_Window->time_width.tv_nsec) |
510 | { |
511 | /* Same scale (scrolling) */ |
512 | g_info("scrolling"); |
513 | LttTime *ns = &New_Time_Window->start_time; |
514 | LttTime *os = &Old_Time_Window->start_time; |
515 | LttTime old_end = ltt_time_add(Old_Time_Window->start_time, |
516 | Old_Time_Window->time_width); |
517 | LttTime new_end = ltt_time_add(New_Time_Window->start_time, |
518 | New_Time_Window->time_width); |
519 | //if(ns<os+w<ns+w) |
520 | //if(ns<os+w && os+w<ns+w) |
521 | //if(ns<old_end && os<ns) |
522 | if(ltt_time_compare(*ns, old_end) == -1 |
523 | && ltt_time_compare(*os, *ns) == -1) |
524 | { |
525 | g_info("scrolling near right"); |
526 | /* Scroll right, keep right part of the screen */ |
527 | guint x = 0; |
528 | guint width = control_flow_data->Drawing->Drawing_Area_V->allocation.width; |
529 | convert_time_to_pixels( |
530 | *os, |
531 | old_end, |
532 | *ns, |
533 | width, |
534 | &x); |
535 | |
536 | /* Copy old data to new location */ |
537 | gdk_draw_drawable (control_flow_data->Drawing->Pixmap, |
538 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
539 | control_flow_data->Drawing->Pixmap, |
540 | x, 0, |
541 | 0, 0, |
542 | -1, -1); |
432a7065 |
543 | |
544 | convert_time_to_pixels( |
545 | *ns, |
546 | new_end, |
547 | old_end, |
548 | width, |
549 | &x); |
4ba42155 |
550 | |
3a941e84 |
551 | *Old_Time_Window = *New_Time_Window; |
432a7065 |
552 | /* Clear the data request background, but not SAFETY */ |
553 | gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, |
554 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
555 | TRUE, |
556 | x+SAFETY, 0, |
557 | control_flow_data->Drawing->width - x, // do not overlap |
558 | control_flow_data->Drawing->height+SAFETY); |
4ba42155 |
559 | /* Get new data for the rest. */ |
560 | drawing_data_request(control_flow_data->Drawing, |
561 | &control_flow_data->Drawing->Pixmap, |
562 | x, 0, |
563 | control_flow_data->Drawing->width - x, |
564 | control_flow_data->Drawing->height); |
565 | |
566 | drawing_refresh(control_flow_data->Drawing, |
567 | 0, 0, |
568 | control_flow_data->Drawing->width, |
569 | control_flow_data->Drawing->height); |
570 | |
571 | |
572 | } else { |
573 | //if(ns<os<ns+w) |
574 | //if(ns<os && os<ns+w) |
575 | //if(ns<os && os<new_end) |
576 | if(ltt_time_compare(*ns,*os) == -1 |
577 | && ltt_time_compare(*os,new_end) == -1) |
578 | { |
579 | g_info("scrolling near left"); |
580 | /* Scroll left, keep left part of the screen */ |
581 | guint x = 0; |
582 | guint width = control_flow_data->Drawing->Drawing_Area_V->allocation.width; |
583 | convert_time_to_pixels( |
584 | *ns, |
585 | new_end, |
586 | *os, |
587 | width, |
588 | &x); |
589 | |
590 | /* Copy old data to new location */ |
591 | gdk_draw_drawable (control_flow_data->Drawing->Pixmap, |
592 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
593 | control_flow_data->Drawing->Pixmap, |
594 | 0, 0, |
595 | x, 0, |
596 | -1, -1); |
597 | |
3a941e84 |
598 | *Old_Time_Window = *New_Time_Window; |
432a7065 |
599 | |
600 | /* Clean the data request background */ |
601 | gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, |
602 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
603 | TRUE, |
604 | 0, 0, |
605 | x, // do not overlap |
606 | control_flow_data->Drawing->height+SAFETY); |
4ba42155 |
607 | /* Get new data for the rest. */ |
608 | drawing_data_request(control_flow_data->Drawing, |
609 | &control_flow_data->Drawing->Pixmap, |
610 | 0, 0, |
611 | x, |
612 | control_flow_data->Drawing->height); |
613 | |
614 | drawing_refresh(control_flow_data->Drawing, |
615 | 0, 0, |
616 | control_flow_data->Drawing->width, |
617 | control_flow_data->Drawing->height); |
618 | |
619 | } else { |
620 | g_info("scrolling far"); |
621 | /* Cannot reuse any part of the screen : far jump */ |
622 | *Old_Time_Window = *New_Time_Window; |
432a7065 |
623 | |
bd24a9af |
624 | |
432a7065 |
625 | gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, |
626 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
627 | TRUE, |
628 | 0, 0, |
629 | control_flow_data->Drawing->width+SAFETY, // do not overlap |
630 | control_flow_data->Drawing->height+SAFETY); |
4ba42155 |
631 | |
632 | drawing_data_request(control_flow_data->Drawing, |
633 | &control_flow_data->Drawing->Pixmap, |
634 | 0, 0, |
635 | control_flow_data->Drawing->width, |
636 | control_flow_data->Drawing->height); |
637 | |
638 | drawing_refresh(control_flow_data->Drawing, |
639 | 0, 0, |
640 | control_flow_data->Drawing->width, |
641 | control_flow_data->Drawing->height); |
642 | } |
643 | } |
644 | } else { |
645 | /* Different scale (zoom) */ |
646 | g_info("zoom"); |
f7afe191 |
647 | |
4ba42155 |
648 | *Old_Time_Window = *New_Time_Window; |
432a7065 |
649 | |
650 | gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, |
651 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
652 | TRUE, |
653 | 0, 0, |
654 | control_flow_data->Drawing->width+SAFETY, // do not overlap |
655 | control_flow_data->Drawing->height+SAFETY); |
656 | |
657 | |
4ba42155 |
658 | drawing_data_request(control_flow_data->Drawing, |
659 | &control_flow_data->Drawing->Pixmap, |
660 | 0, 0, |
661 | control_flow_data->Drawing->width, |
662 | control_flow_data->Drawing->height); |
663 | |
664 | drawing_refresh(control_flow_data->Drawing, |
665 | 0, 0, |
666 | control_flow_data->Drawing->width, |
667 | control_flow_data->Drawing->height); |
668 | } |
669 | |
670 | |
f7afe191 |
671 | } |
672 | |
4c69e0cc |
673 | void update_current_time_hook(void *hook_data, void *call_data) |
f7afe191 |
674 | { |
675 | ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data; |
676 | LttTime* Current_Time = |
4c69e0cc |
677 | guicontrolflow_get_current_time(Control_Flow_Data); |
f7afe191 |
678 | *Current_Time = *((LttTime*)call_data); |
189a5d08 |
679 | g_info("New Current time HOOK : %u, %u", Current_Time->tv_sec, |
f7afe191 |
680 | Current_Time->tv_nsec); |
681 | |
682 | /* If current time is inside time interval, just move the highlight |
683 | * bar */ |
684 | |
685 | /* Else, we have to change the time interval. We have to tell it |
686 | * to the main window. */ |
687 | /* The time interval change will take care of placing the current |
688 | * time at the center of the visible area */ |
689 | |
690 | } |
691 | |