From a18124ff571a52da3166455842735142ad067a89 Mon Sep 17 00:00:00 2001 From: compudj Date: Fri, 13 Aug 2004 21:30:15 +0000 Subject: [PATCH] ifdef for EXTRA_CHECK, and precalculate time_width_double git-svn-id: http://ltt.polymtl.ca/svn@733 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/time.h | 2 +- .../lttv/modules/gui/controlflow/drawing.c | 49 ++++-------- .../lttv/modules/gui/controlflow/drawing.h | 8 +- .../lttv/modules/gui/controlflow/eventhooks.c | 76 ++++++++----------- .../gui/lttvwindow/lttvwindow/callbacks.c | 26 ++++++- .../gui/lttvwindow/lttvwindow/mainwindow.h | 1 + 6 files changed, 72 insertions(+), 90 deletions(-) diff --git a/ltt/branches/poly/ltt/time.h b/ltt/branches/poly/ltt/time.h index 642328e9..db85c69c 100644 --- a/ltt/branches/poly/ltt/time.h +++ b/ltt/branches/poly/ltt/time.h @@ -90,7 +90,7 @@ static inline double ltt_time_to_double(LttTime t1) if(t1.tv_sec > MAX_TV_SEC_TO_DOUBLE) g_warning("Precision loss in conversion LttTime to double"); #endif //EXTRA_CHECK - return ((double)t1.tv_sec * NANOSECONDS_PER_SECOND) + (double)t1.tv_nsec; + return ((double)t1.tv_sec * (double)NANOSECONDS_PER_SECOND) + (double)t1.tv_nsec; } diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c index 3a15130c..ee42d907 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c @@ -138,15 +138,11 @@ void drawing_data_request(Drawing_t *drawing, g_debug("x is : %i, x+width is : %i", x, x+width); convert_pixels_to_time(drawing->width, x, - time_window.start_time, - time_window.time_width, - window_end, + time_window, &start); convert_pixels_to_time(drawing->width, x+width, - time_window.start_time, - time_window.time_width, - window_end, + time_window, &time_end); lttvwindow_events_request_remove_all(tab, @@ -406,9 +402,7 @@ void drawing_data_request_begin(EventsRequest *events_request, LttvTracesetState cfd->drawing->last_start = events_request->start_time; convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - end_time, + time_window, events_request->start_time, width, &x); @@ -448,18 +442,14 @@ void drawing_request_expose(EventsRequest *events_request, #if 0 convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - window_end, + time_window, cfd->drawing->last_start, drawing->width, &x); #endif //0 convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - window_end, + time_window, end_time, drawing->width, &x_end); @@ -614,9 +604,7 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) { /* Draw the dotted lines */ convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - window_end, + time_window, current_time, drawing->width, &cursor_x); @@ -704,9 +692,7 @@ button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user_data g_debug("x click is : %f", event->x); convert_pixels_to_time(drawing->width, (guint)event->x, - time_window.start_time, - time_window.time_width, - window_end, + time_window, &time); lttvwindow_report_current_time(control_flow_data->tab, time); @@ -933,44 +919,39 @@ GtkWidget *drawing_get_widget(Drawing_t *drawing) __inline void convert_pixels_to_time( gint width, guint x, - LttTime window_time_begin, - LttTime window_time_interval, - LttTime window_time_end, + TimeWindow time_window, LttTime *time) { double time_d; - time_d = ltt_time_to_double(window_time_interval); + time_d = time_window.time_width_double; time_d = time_d / (double)width * (double)x; *time = ltt_time_from_double(time_d); - *time = ltt_time_add(window_time_begin, *time); + *time = ltt_time_add(time_window.start_time, *time); } __inline void convert_time_to_pixels( - LttTime window_time_begin, - LttTime window_time_interval, - LttTime window_time_end, + TimeWindow time_window, LttTime time, int width, guint *x) { - double time_d, interval_d; + double time_d; #ifdef EXTRA_CHECK g_assert(ltt_time_compare(window_time_begin, time) <= 0 && ltt_time_compare(window_time_end, time) >= 0); #endif //EXTRA_CHECK - time = ltt_time_sub(time, window_time_begin); + time = ltt_time_sub(time, time_window.start_time); time_d = ltt_time_to_double(time); - interval_d = ltt_time_to_double(window_time_interval); - if(interval_d == 0.0) { + if(time_window.time_width_double == 0.0) { g_assert(time_d == 0.0); *x = 0; } else { - *x = (guint)(time_d / interval_d * (double)width); + *x = (guint)(time_d / time_window.time_width_double * (double)width); } } diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h index d07ed4e7..69840a1a 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h @@ -137,15 +137,11 @@ void drawing_remove_square(Drawing_t *drawing, __inline void convert_pixels_to_time( gint width, guint x, - LttTime window_time_begin, - LttTime window_time_interval, - LttTime window_time_end, + TimeWindow time_window, LttTime *time); __inline void convert_time_to_pixels( - LttTime window_time_begin, - LttTime window_time_interval, - LttTime window_time_end, + TimeWindow time_window, LttTime time, gint width, guint *x); diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c index f4b77bce..02674d6a 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c @@ -395,10 +395,11 @@ int before_schedchange_hook(void *hook_data, void *call_data) lttvwindow_get_time_window(control_flow_data->tab); LttTime end_time = time_window.end_time; - +#ifdef EXTRA_CHECK if(ltt_time_compare(evtime, time_window.start_time) == -1 || ltt_time_compare(evtime, end_time) == 1) return; +#endif //EXTRA_CHECK guint width = drawing->width; /* we are in a schedchange, before the state update. We must draw the @@ -483,9 +484,7 @@ int before_schedchange_hook(void *hook_data, void *call_data) { guint x; convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - end_time, + time_window, evtime, width, &x); @@ -608,9 +607,7 @@ int before_schedchange_hook(void *hook_data, void *call_data) guint x; convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - end_time, + time_window, evtime, width, &x); @@ -799,14 +796,10 @@ int before_schedchange_hook(void *hook_data, void *call_data) LttTime time = ltt_event_time(e); - LttTime window_end = ltt_time_add(time_window.time_width, - time_window.start_time); - + LttTime window_end = time_window.end_time; convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - window_end, + time_window, time, width, &x); @@ -1312,9 +1305,11 @@ int after_schedchange_hook(void *hook_data, void *call_data) LttTime end_time = time_window.end_time; +#ifdef EXTRA_CHECK if(ltt_time_compare(evtime, time_window.start_time) == -1 || ltt_time_compare(evtime, end_time) == 1) return; +#endif //EXTRA_CHECK guint width = control_flow_data->drawing->width; @@ -1381,9 +1376,7 @@ int after_schedchange_hook(void *hook_data, void *call_data) guint new_x; convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - end_time, + time_window, evtime, width, &new_x); @@ -1530,14 +1523,11 @@ int after_schedchange_hook(void *hook_data, void *call_data) //LttTime time = ltt_event_time(e); - //LttTime window_end = ltt_time_add(time_window->time_width, - // time_window->start_time); + //LttTime window_end = time_window->end_time; //convert_time_to_pixels( - // time_window->start_time, - // time_window.time_width, - // window_end, + // *time_window, // time, // width, // &x); @@ -1925,9 +1915,11 @@ int before_execmode_hook(void *hook_data, void *call_data) LttTime end_time = time_window.end_time; +#ifdef EXTRA_CHECK if(ltt_time_compare(evtime, time_window.start_time) == -1 || ltt_time_compare(evtime, end_time) == 1) return; +#endif //EXTRA_CHECK guint width = drawing->width; @@ -1996,9 +1988,7 @@ int before_execmode_hook(void *hook_data, void *call_data) guint x; convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - end_time, + time_window, evtime, width, &x); @@ -2085,9 +2075,11 @@ int after_execmode_hook(void *hook_data, void *call_data) LttTime end_time = time_window.end_time; +#ifdef EXTRA_CHECK if(ltt_time_compare(evtime, time_window.start_time) == -1 || ltt_time_compare(evtime, end_time) == 1) return; +#endif //EXTRA_CHECK guint width = control_flow_data->drawing->width; @@ -2143,9 +2135,7 @@ int after_execmode_hook(void *hook_data, void *call_data) guint new_x; convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - end_time, + time_window, evtime, width, &new_x); @@ -2191,9 +2181,11 @@ int before_process_hook(void *hook_data, void *call_data) LttTime end_time = time_window.end_time; +#ifdef EXTRA_CHECK if(ltt_time_compare(evtime, time_window.start_time) == -1 || ltt_time_compare(evtime, end_time) == 1) return; +#endif //EXTRA_CHECK guint width = control_flow_data->drawing->width; @@ -2266,9 +2258,7 @@ int before_process_hook(void *hook_data, void *call_data) guint x; convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - end_time, + time_window, evtime, width, &x); @@ -2363,9 +2353,11 @@ int after_process_hook(void *hook_data, void *call_data) LttTime end_time = time_window.end_time; +#ifdef EXTRA_CHECK if(ltt_time_compare(evtime, time_window.start_time) == -1 || ltt_time_compare(evtime, end_time) == 1) return; +#endif //EXTRA_CHECK guint width = control_flow_data->drawing->width; @@ -2432,9 +2424,7 @@ int after_process_hook(void *hook_data, void *call_data) guint new_x; convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - end_time, + time_window, evtime, width, &new_x); @@ -2505,9 +2495,7 @@ int after_process_hook(void *hook_data, void *call_data) guint new_x; convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - end_time, + time_window, evtime, width, &new_x); @@ -2583,9 +2571,7 @@ gint update_time_window_hook(void *hook_data, void *call_data) guint x = 0; guint width = control_flow_data->drawing->width; convert_time_to_pixels( - *os, - *ow, - old_end, + *old_time_window, *ns, width, &x); @@ -2637,9 +2623,7 @@ gint update_time_window_hook(void *hook_data, void *call_data) guint x = 0; guint width = control_flow_data->drawing->width; convert_time_to_pixels( - *ns, - *nw, - new_end, + *new_time_window, *os, width, &x); @@ -2895,6 +2879,7 @@ gint update_current_time_hook(void *hook_data, void *call_data) new_time_window.start_time = time_begin; new_time_window.time_width = width; + new_time_window.time_width_double = ltt_time_to_double(width); new_time_window.end_time = ltt_time_add(time_begin, width); lttvwindow_report_time_window(control_flow_data->tab, new_time_window); @@ -2910,6 +2895,7 @@ gint update_current_time_hook(void *hook_data, void *call_data) new_time_window.start_time = time_begin; new_time_window.time_width = width; + new_time_window.time_width_double = ltt_time_to_double(width); new_time_window.end_time = ltt_time_add(time_begin, width); lttvwindow_report_time_window(control_flow_data->tab, new_time_window); @@ -2950,9 +2936,11 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data) LttTime end_time = time_window.end_time; +#ifdef EXTRA_CHECK if(ltt_time_compare(evtime, time_window.start_time) == -1 || ltt_time_compare(evtime, end_time) == 1) return; +#endif //EXTRA_CHECK guint width = drawing->width; @@ -3012,9 +3000,7 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data) guint x; convert_time_to_pixels( - time_window.start_time, - time_window.time_width, - end_time, + time_window, evtime, width, &x); diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index e4c497d4..be473dea 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -485,6 +485,7 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset) tmp_time.tv_sec = time_span.end_time.tv_sec; tmp_time.tv_nsec = 0; new_time_window.time_width = tmp_time ; + new_time_window.time_width_double = ltt_time_to_double(tmp_time); new_time_window.end_time = ltt_time_add(new_time_window.start_time, new_time_window.time_width) ; } @@ -2284,14 +2285,18 @@ void zoom(GtkWidget * widget, double size) if(size == 0){ new_time_window.start_time = time_span.start_time; new_time_window.time_width = time_delta; + new_time_window.time_width_double = ltt_time_to_double(time_delta); new_time_window.end_time = ltt_time_add(new_time_window.start_time, new_time_window.time_width) ; }else{ new_time_window.time_width = ltt_time_div(new_time_window.time_width, size); + new_time_window.time_width_double = + ltt_time_to_double(new_time_window.time_width); if(ltt_time_compare(new_time_window.time_width,time_delta) > 0) { /* Case where zoom out is bigger than trace length */ new_time_window.start_time = time_span.start_time; new_time_window.time_width = time_delta; + new_time_window.time_width_double = ltt_time_to_double(time_delta); new_time_window.end_time = ltt_time_add(new_time_window.start_time, new_time_window.time_width) ; } @@ -2299,7 +2304,8 @@ void zoom(GtkWidget * widget, double size) { /* Center the image on the current time */ new_time_window.start_time = - ltt_time_sub(current_time, ltt_time_div(new_time_window.time_width, 2.0)); + ltt_time_sub(current_time, + ltt_time_from_double(new_time_window.time_width_double/2.0)); new_time_window.end_time = ltt_time_add(new_time_window.start_time, new_time_window.time_width) ; /* If on borders, don't fall off */ @@ -3466,13 +3472,13 @@ void time_change_manager (Tab *tab, "upper", ltt_time_to_double(upper), /* upper */ "step_increment", - ltt_time_to_double(new_time_window.time_width) + new_time_window.time_width_double / SCROLL_STEP_PER_PAGE, /* step increment */ "page_increment", - ltt_time_to_double(new_time_window.time_width), + new_time_window.time_width_double, /* page increment */ "page_size", - ltt_time_to_double(new_time_window.time_width), /* page size */ + new_time_window.time_width_double, /* page size */ NULL); gtk_adjustment_changed(adjustment); @@ -3609,6 +3615,9 @@ on_MEntry1_value_changed (GtkSpinButton *spinbutton, /* Fix the time width to fit start time and end time */ new_time_window.time_width = ltt_time_sub(end_time, new_time_window.start_time); + new_time_window.time_width_double = + ltt_time_to_double(new_time_window.time_width); + new_time_window.end_time = end_time; time_change_manager(tab, new_time_window); @@ -3642,6 +3651,8 @@ on_MEntry2_value_changed (GtkSpinButton *spinbutton, /* Fix the time width to fit start time and end time */ new_time_window.time_width = ltt_time_sub(end_time, new_time_window.start_time); + new_time_window.time_width_double = + ltt_time_to_double(new_time_window.time_width); new_time_window.end_time = end_time; @@ -3694,6 +3705,8 @@ on_MEntry3_value_changed (GtkSpinButton *spinbutton, /* Fix the time width to fit start time and end time */ new_time_window.time_width = ltt_time_sub(end_time, new_time_window.start_time); + new_time_window.time_width_double = + ltt_time_to_double(new_time_window.time_width); new_time_window.end_time = end_time; @@ -3729,6 +3742,8 @@ on_MEntry4_value_changed (GtkSpinButton *spinbutton, /* Fix the time width to fit start time and end time */ new_time_window.time_width = ltt_time_sub(end_time, new_time_window.start_time); + new_time_window.time_width_double = + ltt_time_to_double(new_time_window.time_width); new_time_window.end_time = end_time; time_change_manager(tab, new_time_window); @@ -3855,6 +3870,9 @@ void scroll_value_changed_cb(GtkWidget *scrollbar, new_time_window.time_width = ltt_time_from_double(page_size); + new_time_window.time_width_double = + page_size; + new_time_window.end_time = ltt_time_add(new_time_window.start_time, new_time_window.time_width); diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/mainwindow.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/mainwindow.h index 5dcc85ff..9874d0d9 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/mainwindow.h +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/mainwindow.h @@ -30,6 +30,7 @@ typedef struct _TracesetInfo TracesetInfo; struct _TimeWindow { LttTime start_time; LttTime time_width; + double time_width_double; LttTime end_time; }; -- 2.34.1