From a43d67bae425508678e5ae2ffe5dd1e84286b915 Mon Sep 17 00:00:00 2001 From: compudj Date: Fri, 14 May 2004 22:10:30 +0000 Subject: [PATCH] merge modifications for multiple viewer read at the same time, better expose handling. We now use a g_idle to make the main window do the process_traceset once for all viewers the need redraw. The detailed event list and statistics are broken now, functionnality of the control flow view is not completed, but it interacts well with the main window. git-svn-id: http://ltt.polymtl.ca/svn@524 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/attribute.c | 2 +- ltt/branches/poly/lttv/lttv/main.c | 6 +- ltt/branches/poly/lttv/lttv/tracecontext.c | 12 +- ltt/branches/poly/lttv/lttv/tracecontext.h | 1 + ltt/branches/poly/lttv/lttv/traceset.c | 16 + ltt/branches/poly/lttv/lttv/traceset.h | 4 + .../modules/gui/controlflow/cfv-private.h | 7 + .../poly/lttv/modules/gui/controlflow/cfv.c | 16 +- .../lttv/modules/gui/controlflow/drawing.c | 317 ++++++------- .../lttv/modules/gui/controlflow/drawing.h | 11 +- .../lttv/modules/gui/controlflow/eventhooks.c | 119 +++-- .../lttv/modules/gui/controlflow/eventhooks.h | 3 +- .../lttv/modules/gui/detailedevents/events.c | 10 +- .../gui/lttvwindow/lttvwindow/callbacks.c | 430 +++++++++++++----- .../gui/lttvwindow/lttvwindow/callbacks.h | 15 + .../lttvwindow/lttvwindow/gtkmultivpaned.c | 41 +- .../lttvwindow/lttvwindow/gtkmultivpaned.h | 2 +- .../gui/lttvwindow/lttvwindow/interface.c | 1 + .../gui/lttvwindow/lttvwindow/mainwindow.h | 11 + .../gui/lttvwindow/lttvwindow/viewer.c | 99 ++-- .../gui/lttvwindow/lttvwindow/viewer.h | 18 +- .../lttv/modules/gui/statistics/statistics.c | 4 +- 22 files changed, 738 insertions(+), 407 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/attribute.c b/ltt/branches/poly/lttv/lttv/attribute.c index a3f8ab9a..53867930 100644 --- a/ltt/branches/poly/lttv/lttv/attribute.c +++ b/ltt/branches/poly/lttv/lttv/attribute.c @@ -199,7 +199,7 @@ lttv_attribute_find_subdir(LttvAttribute *self, LttvAttributeName name) Attribute a; LttvAttribute *new; - + i = (unsigned)g_hash_table_lookup(self->names, GUINT_TO_POINTER(name)); if(i != 0) { a = g_array_index(self->attributes, Attribute, i - 1); diff --git a/ltt/branches/poly/lttv/lttv/main.c b/ltt/branches/poly/lttv/lttv/main.c index a27519e8..c1b23242 100644 --- a/ltt/branches/poly/lttv/lttv/main.c +++ b/ltt/branches/poly/lttv/lttv/main.c @@ -108,9 +108,9 @@ int main(int argc, char **argv) { /* Initialize glib and by default ignore info and debug messages */ g_type_init(); - //g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS); - g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL); - g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL); + g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS); + //g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL); + //g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL); /* Have an attributes subtree to store hooks to be registered by modules. */ diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.c b/ltt/branches/poly/lttv/lttv/tracecontext.c index 30f2da07..7e757ba7 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.c +++ b/ltt/branches/poly/lttv/lttv/tracecontext.c @@ -173,6 +173,7 @@ init(LttvTracesetContext *self, LttvTraceset *ts) /*CHECK why dynamically allocate the time span... and the casing is wroNg*/ self->Time_Span = g_new(TimeInterval,1); lttv_traceset_context_compute_time_span(self, self->Time_Span); + self->e = NULL; } @@ -656,7 +657,11 @@ guint lttv_process_traceset_middle(LttvTracesetContext *self, LttTime end, while(TRUE) { tfc = NULL; g_tree_foreach(pqueue, get_first, &tfc); - if(tfc == NULL) return count; + if(tfc == NULL) + { + self->e = event; + return count; + } /* Have we reached the maximum number of events specified? However, continue for all the events with the same time stamp (CHECK?). Then, @@ -664,7 +669,10 @@ guint lttv_process_traceset_middle(LttvTracesetContext *self, LttTime end, if(count >= nb_events && ltt_time_compare(tfc->timestamp, previous_timestamp) != 0) - return count; + { + self->e = event; + return count; + } previous_timestamp = tfc->timestamp; diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.h b/ltt/branches/poly/lttv/lttv/tracecontext.h index 6afff0ff..654e3126 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.h +++ b/ltt/branches/poly/lttv/lttv/tracecontext.h @@ -92,6 +92,7 @@ struct _LttvTracesetContext { LttvAttribute *ts_a; TimeInterval *Time_Span; GTree *pqueue; + LttEvent *e; /* Last event read by lttv_process_traceset_middle */ }; struct _LttvTracesetContextClass { diff --git a/ltt/branches/poly/lttv/lttv/traceset.c b/ltt/branches/poly/lttv/lttv/traceset.c index aa536488..568e6721 100644 --- a/ltt/branches/poly/lttv/lttv/traceset.c +++ b/ltt/branches/poly/lttv/lttv/traceset.c @@ -187,3 +187,19 @@ guint lttv_trace_get_ref_number(LttvTrace * t) { return t->ref_count; } + +guint lttv_trace_ref(LttvTrace * t) +{ + t->ref_count++; + + return t->ref_count; +} + +guint lttv_trace_unref(LttvTrace * t) +{ + if(t->ref_count > 0) + t->ref_count--; + + return t->ref_count; +} + diff --git a/ltt/branches/poly/lttv/lttv/traceset.h b/ltt/branches/poly/lttv/lttv/traceset.h index 9d29d7a3..7ef85be5 100644 --- a/ltt/branches/poly/lttv/lttv/traceset.h +++ b/ltt/branches/poly/lttv/lttv/traceset.h @@ -65,5 +65,9 @@ LttTrace *lttv_trace(LttvTrace *t); guint lttv_trace_get_ref_number(LttvTrace * t); +guint lttv_trace_ref(LttvTrace * t); + +guint lttv_trace_unref(LttvTrace * t); + #endif // TRACESET_H diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv-private.h b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv-private.h index de324869..67d8413c 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv-private.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv-private.h @@ -19,6 +19,7 @@ #ifndef _CFV_PRIVATE_H #define _CFV_PRIVATE_H + struct _ControlFlowData { GtkWidget *scrolled_window; @@ -38,6 +39,12 @@ struct _ControlFlowData { //guint currently_Selected_Event ; guint number_of_process; + /* hooks for trace read */ + LttvHooks *event; + LttvHooks *after_event; + LttvHooks *after_traceset; + EventRequest *event_request; + } ; diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c index f51f974d..9ab60ef0 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c @@ -104,7 +104,13 @@ guicontrolflow(void) /* Get trace statistics */ //control_flow_data->Trace_Statistics = get_trace_statistics(Trace); + /* Create reading hooks */ + control_flow_data->event = lttv_hooks_new(); + control_flow_data->after_event = lttv_hooks_new(); + control_flow_data->after_traceset = lttv_hooks_new(); + control_flow_data->event_request = g_new(EventRequest, 1); + gtk_widget_show(drawing_widget); gtk_widget_show(process_list_widget); gtk_widget_show(control_flow_data->h_paned); @@ -133,8 +139,8 @@ guicontrolflow(void) g_signal_connect (G_OBJECT (process_list_widget), "grab-focus", G_CALLBACK (control_flow_grab_focus), control_flow_data); - - + + return control_flow_data; } @@ -166,6 +172,12 @@ guicontrolflow_destructor(ControlFlowData *control_flow_data) //ProcessList_destroy(control_flow_data->process_list); if(control_flow_data->mw != NULL) { + /* Delete reading hooks */ + lttv_hooks_destroy(control_flow_data->event); + lttv_hooks_destroy(control_flow_data->after_event); + lttv_hooks_destroy(control_flow_data->after_traceset); + g_free(control_flow_data->event_request); + lttvwindow_unregister_time_window_notify(control_flow_data->mw, update_time_window_hook, control_flow_data); diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c index acaf0a42..71131819 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c @@ -26,9 +26,9 @@ #include #include "drawing.h" +#include "eventhooks.h" #include "cfv.h" #include "cfv-private.h" -#include "eventhooks.h" #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) @@ -82,20 +82,23 @@ void drawing_data_request(Drawing_t *drawing, const TimeWindow *time_window = lttvwindow_get_time_window(drawing->control_flow_data->mw); - ControlFlowData *control_flow_data = - (ControlFlowData*)g_object_get_data( - G_OBJECT(drawing->drawing_area), "control_flow_data"); + ControlFlowData *control_flow_data = drawing->control_flow_data; + // (ControlFlowData*)g_object_get_data( + // G_OBJECT(drawing->drawing_area), "control_flow_data"); - LttTime start, end; + LttTime start, time_end; LttTime window_end = ltt_time_add(time_window->time_width, time_window->start_time); - g_debug("req : window_end : %u, %u", window_end.tv_sec, - window_end.tv_nsec); + g_debug("req : window start_time : %u, %u", time_window->start_time.tv_sec, + time_window->start_time.tv_nsec); - g_debug("req : time width : %u, %u", time_window->time_width.tv_sec, + g_debug("req : window time width : %u, %u", time_window->time_width.tv_sec, time_window->time_width.tv_nsec); + g_debug("req : window_end : %u, %u", window_end.tv_sec, + window_end.tv_nsec); + g_debug("x is : %i, x+width is : %i", x, x+width); convert_pixels_to_time(drawing->drawing_area->allocation.width, x, @@ -103,10 +106,10 @@ void drawing_data_request(Drawing_t *drawing, window_end, &start); - convert_pixels_to_time(drawing->drawing_area->allocation.width, x + width, + convert_pixels_to_time(drawing->drawing_area->allocation.width, x+width, time_window->start_time, window_end, - &end); + &time_end); LttvTracesetContext * tsc = lttvwindow_get_traceset_context(control_flow_data->mw); @@ -114,52 +117,97 @@ void drawing_data_request(Drawing_t *drawing, (LttvTracesetState*)tsc; // Let's call processTrace() !! - EventRequest event_request; // Variable freed at the end of the function. - event_request.control_flow_data = control_flow_data; - event_request.time_begin = start; - event_request.time_end = end; - event_request.x_begin = x; - event_request.x_end = x+width; - - g_debug("req : start : %u, %u", event_request.time_begin.tv_sec, - event_request.time_begin.tv_nsec); - - g_debug("req : end : %u, %u", event_request.time_end.tv_sec, - event_request.time_end.tv_nsec); - - LttvHooks *event = lttv_hooks_new(); - LttvHooks *after_event = lttv_hooks_new(); - LttvHooks *after_traceset = lttv_hooks_new(); - lttv_hooks_add(after_traceset, after_data_request, &event_request); - lttv_hooks_add(event, draw_event_hook, &event_request); - //Modified by xiangxiu: state update hooks are added by the main window - //lttv_state_add_event_hooks(tsc); - lttv_hooks_add(after_event, draw_after_hook, &event_request); + + EventRequest *event_request = control_flow_data->event_request; + event_request->control_flow_data = control_flow_data; + event_request->time_begin = start; + event_request->time_end = time_end; + + event_request->x_begin = x; + event_request->x_end = x+width; + + g_debug("req : start : %u, %u", event_request->time_begin.tv_sec, + event_request->time_begin.tv_nsec); + + g_debug("req : end : %u, %u", event_request->time_end.tv_sec, + event_request->time_end.tv_nsec); + + lttv_hooks_add(control_flow_data->after_traceset, after_data_request, event_request); + lttv_hooks_add(control_flow_data->event, draw_event_hook, event_request); + lttv_hooks_add(control_flow_data->after_event, draw_after_hook, event_request); //lttv_process_traceset_seek_time(tsc, start); - lttv_state_traceset_seek_time_closest(tss, start); + //lttv_state_traceset_seek_time_closest(tss, start); // FIXME : would like to place the after_traceset hook after the traceset, // but the traceset context state is not valid anymore. lttv_traceset_context_add_hooks(tsc, - NULL, after_traceset, NULL, NULL, NULL, NULL, + NULL, control_flow_data->after_traceset, NULL, NULL, NULL, NULL, //NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, event, after_event); - lttv_process_traceset(tsc, end, G_MAXULONG); - //after_data_request((void*)&event_request,(void*)tsc); - lttv_traceset_context_remove_hooks(tsc, - NULL, after_traceset, NULL, NULL, NULL, NULL, - // NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, event, after_event); - //Modified by xiangxiu: state update hooks are removed by the main window - //lttv_state_remove_event_hooks(tsc); + NULL, NULL, NULL, control_flow_data->event, control_flow_data->after_event); + TimeWindow time_request; + time_request.start_time = start; + time_request.time_width = ltt_time_sub(time_end, start); + + lttvwindow_time_interval_request(drawing->control_flow_data->mw, + time_request, G_MAXUINT, + after_process_traceset_hook, + control_flow_data); + + //lttv_process_traceset(tsc, end, G_MAXULONG); +} + + + + +void drawing_data_request_end(Drawing_t *drawing, + TimeWindow req_time_window) +{ + gint x, x_end, width; + + LttvTracesetContext * tsc = + lttvwindow_get_traceset_context(drawing->control_flow_data->mw); + + const TimeWindow *time_window = lttvwindow_get_time_window(drawing->control_flow_data->mw); - lttv_hooks_destroy(after_traceset); - lttv_hooks_destroy(event); - lttv_hooks_destroy(after_event); + //FIXME ? removing hooks during processtrace can BREAK things! + lttv_traceset_context_remove_hooks(tsc, + NULL, drawing->control_flow_data->after_traceset, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, + drawing->control_flow_data->event, + drawing->control_flow_data->after_event); + g_debug("End of data request"); + LttTime window_end = ltt_time_add(time_window->time_width, + time_window->start_time); + + LttTime req_window_end = ltt_time_add(req_time_window.time_width, + req_time_window.start_time); + + convert_time_to_pixels( + time_window->start_time, + window_end, + req_time_window.start_time, + drawing->width, + &x); + + convert_time_to_pixels( + time_window->start_time, + window_end, + req_window_end, + drawing->width, + &x_end); + + width = x_end - x; + + /* ask for the buffer to be redrawn */ + gtk_widget_queue_draw_area ( drawing->drawing_area, + x, 0, + width, drawing->height); + } - + + /* Callbacks */ @@ -221,77 +269,23 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event, /* Initial data request */ + /* no, do initial data request in the expose event */ // Do not need to ask for data of 1 pixel : not synchronized with // main window time at this moment. - drawing_data_request(drawing, &drawing->pixmap, 0, 0, - widget->allocation.width, - widget->allocation.height); + //drawing_data_request(drawing, &drawing->pixmap, 0, 0, + // widget->allocation.width, + // widget->allocation.height); drawing->width = widget->allocation.width; drawing->height = widget->allocation.height; + + drawing->data_injected = FALSE; return TRUE; } -#ifdef NOTUSE -// /* Draw empty background */ -// gdk_draw_rectangle (pixmap, -// widget->style->black_gc, -// TRUE, -// 0, 0, -// widget->allocation.width, -// widget->allocation.height); - - /* Copy old data to new pixmap */ - gdk_draw_drawable (pixmap, - widget->style->black_gc, - drawing->pixmap, - 0, 0, - 0, 0, - -1, -1); - - if (drawing->pixmap) - gdk_pixmap_unref(drawing->pixmap); - - drawing->pixmap = pixmap; - - // Clear the bottom part of the image (SAFETY) - gdk_draw_rectangle (pixmap, - widget->style->black_gc, - TRUE, - 0, drawing->height+SAFETY, - drawing->width+SAFETY, // do not overlap - (widget->allocation.height) - drawing->height); - - // Clear the right part of the image (SAFETY) - gdk_draw_rectangle (pixmap, - widget->style->black_gc, - TRUE, - drawing->width+SAFETY, 0, - (widget->allocation.width) - drawing->width, // do not overlap - drawing->height+SAFETY); - - /* Clear the backgound for data request, but not SAFETY */ - gdk_draw_rectangle (pixmap, - drawing->drawing_area->style->black_gc, - TRUE, - drawing->width + SAFETY, 0, - widget->allocation.width - drawing->width, // do not overlap - widget->allocation.height+SAFETY); - - /* Request data for missing space */ - g_info("missing data request"); - drawing_data_request(drawing, &pixmap, drawing->width, 0, - widget->allocation.width - drawing->width, - widget->allocation.height); - - drawing->width = widget->allocation.width; - drawing->height = widget->allocation.height; - - return TRUE; -#endif //NOTUSE } @@ -300,6 +294,7 @@ static gboolean expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) { Drawing_t *drawing = (Drawing_t*)user_data; + const TimeWindow *time_window = lttvwindow_get_time_window(drawing->control_flow_data->mw); const LttTime* current_time = lttvwindow_get_current_time(drawing->control_flow_data->mw); @@ -309,9 +304,7 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) G_OBJECT(widget), "control_flow_data"); - g_debug("drawing expose event"); - - guint x=0; + guint cursor_x=0; LttTime window_end = ltt_time_add(time_window->time_width, time_window->start_time); @@ -321,8 +314,20 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) window_end, *current_time, widget->allocation.width, - &x); + &cursor_x); + + + + + if(!drawing->data_injected) + { + drawing_data_request(drawing, &drawing->pixmap, 0, 0, + widget->allocation.width, + widget->allocation.height); + drawing->data_injected = TRUE; + } + /* update the screen from the pixmap buffer */ gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], drawing->pixmap, @@ -330,29 +335,45 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) event->area.x, event->area.y, event->area.width, event->area.height); - if(x >= event->area.x && x <= event->area.x+event->area.width) - { - gint8 dash_list[] = { 1, 2 }; - GdkGC *gc = gdk_gc_new(control_flow_data->drawing->pixmap); - gdk_gc_copy(gc, widget->style->white_gc); - gdk_gc_set_line_attributes(gc, - 1, - GDK_LINE_ON_OFF_DASH, - GDK_CAP_BUTT, - GDK_JOIN_MITER); - gdk_gc_set_dashes(gc, - 0, - dash_list, - 2); - drawing_draw_line(NULL, widget->window, - x, event->area.y, - x, event->area.y+event->area.height, - gc); - gdk_gc_unref(gc); - } + + /* Draw the dotted lines */ + + gint8 dash_list[] = { 1, 2 }; + GdkGC *gc = gdk_gc_new(control_flow_data->drawing->pixmap); + gdk_gc_copy(gc, widget->style->white_gc); + gdk_gc_set_line_attributes(gc, + 1, + GDK_LINE_ON_OFF_DASH, + GDK_CAP_BUTT, + GDK_JOIN_MITER); + gdk_gc_set_dashes(gc, + 0, + dash_list, + 2); + drawing_draw_line(NULL, widget->window, + cursor_x, 0, + cursor_x, drawing->height, + gc); + gdk_gc_unref(gc); + + + + + return FALSE; +} + +static gboolean +after_expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) +{ + //g_assert(0); + g_critical("AFTER EXPOSE"); + return FALSE; + + } + /* mouse click */ static gboolean button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user_data ) @@ -413,6 +434,12 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) drawing->pango_layout = gtk_widget_create_pango_layout(drawing->drawing_area, NULL); + drawing->height = 0; + drawing->width = 0; + drawing->depth = 0; + + drawing->data_injected = FALSE; + //gtk_widget_set_size_request(drawing->drawing_area->window, 50, 50); g_object_set_data_full( G_OBJECT(drawing->drawing_area), @@ -474,6 +501,11 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) G_CALLBACK (expose_event), (gpointer)drawing); + g_signal_connect_after (G_OBJECT(drawing->drawing_area), + "expose_event", + G_CALLBACK (after_expose_event), + (gpointer)drawing); + g_signal_connect (G_OBJECT(drawing->drawing_area), "button-press-event", G_CALLBACK (button_press_event), @@ -548,31 +580,6 @@ void convert_time_to_pixels( } -void drawing_refresh ( Drawing_t *drawing, - guint x, guint y, - guint width, guint height) -{ - g_info("Drawing.c : drawing_refresh %u, %u, %u, %u", x, y, width, height); - GdkRectangle update_rect; - - gdk_draw_drawable( - drawing->drawing_area->window, - drawing->drawing_area-> - style->fg_gc[GTK_WIDGET_STATE (drawing->drawing_area)], - GDK_DRAWABLE(drawing->pixmap), - x, y, - x, y, - width, height); - - update_rect.x = 0 ; - update_rect.y = 0 ; - update_rect.width = drawing->width; - update_rect.height = drawing->height ; - gtk_widget_draw( drawing->drawing_area, &update_rect); - -} - - void drawing_draw_line( Drawing_t *drawing, GdkPixmap *pixmap, guint x1, guint y1, diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h index e37e56df..29ac461c 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h @@ -63,7 +63,8 @@ struct _Drawing_t { PangoLayout *pango_layout; - gint height, width, depth; + gint height, width, depth; + gboolean data_injected; }; @@ -73,10 +74,6 @@ void drawing_destroy(Drawing_t *drawing); GtkWidget *drawing_get_widget(Drawing_t *drawing); GtkWidget *drawing_get_drawing_area(Drawing_t *drawing); -//void drawing_Refresh ( Drawing_t *drawing, -// guint x, guint y, -// guint width, guint height); - void drawing_draw_line( Drawing_t *drawing, GdkPixmap *pixmap, guint x1, guint y1, @@ -117,4 +114,8 @@ void convert_time_to_pixels( void drawing_update_ruler(Drawing_t *drawing, TimeWindow *time_window); +void drawing_data_request_end(Drawing_t *drawing, + TimeWindow req_time_window); + + #endif // _DRAWING_H diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c index 1fb3f1ec..17498ae5 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c @@ -132,6 +132,7 @@ int draw_event_hook(void *hook_data, void *call_data) { EventRequest *event_request = (EventRequest*)hook_data; ControlFlowData *control_flow_data = event_request->control_flow_data; + MainWindow *mw = control_flow_data->mw; LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; @@ -143,7 +144,7 @@ int draw_event_hook(void *hook_data, void *call_data) LttTime evtime = ltt_event_time(e); const TimeWindow *time_window = - lttvwindow_get_time_window(control_flow_data->mw); + lttvwindow_get_time_window(mw); LttTime end_time = ltt_time_add(time_window->start_time, time_window->time_width); @@ -1186,6 +1187,8 @@ int draw_after_hook(void *hook_data, void *call_data) gint update_time_window_hook(void *hook_data, void *call_data) { ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; + Drawing_t *drawing = control_flow_data->drawing; + const TimeWindowNotifyData *time_window_nofify_data = ((const TimeWindowNotifyData *)call_data); @@ -1254,14 +1257,6 @@ gint update_time_window_hook(void *hook_data, void *call_data) 0, 0, -1, -1); - convert_time_to_pixels( - *ns, - new_end, - old_end, - width, - &x); - - *old_time_window = *new_time_window; /* Clear the data request background, but not SAFETY */ gdk_draw_rectangle (control_flow_data->drawing->pixmap, control_flow_data->drawing->drawing_area->style->black_gc, @@ -1269,6 +1264,12 @@ gint update_time_window_hook(void *hook_data, void *call_data) x+SAFETY, 0, control_flow_data->drawing->width - x, // do not overlap control_flow_data->drawing->height+SAFETY); + + gtk_widget_queue_draw_area (drawing->drawing_area, + 0,0, + control_flow_data->drawing->width - x, + control_flow_data->drawing->height); + /* Get new data for the rest. */ drawing_data_request(control_flow_data->drawing, &control_flow_data->drawing->pixmap, @@ -1276,12 +1277,6 @@ gint update_time_window_hook(void *hook_data, void *call_data) control_flow_data->drawing->width - x, control_flow_data->drawing->height); - drawing_refresh(control_flow_data->drawing, - 0, 0, - control_flow_data->drawing->width, - control_flow_data->drawing->height); - - } else { //if(nsdrawing->pixmap, @@ -1317,6 +1312,12 @@ gint update_time_window_hook(void *hook_data, void *call_data) 0, 0, x, // do not overlap control_flow_data->drawing->height+SAFETY); + + gtk_widget_queue_draw_area (drawing->drawing_area, + x,0, + control_flow_data->drawing->width - x, + control_flow_data->drawing->height); + /* Get new data for the rest. */ drawing_data_request(control_flow_data->drawing, &control_flow_data->drawing->pixmap, @@ -1324,42 +1325,40 @@ gint update_time_window_hook(void *hook_data, void *call_data) x, control_flow_data->drawing->height); - drawing_refresh(control_flow_data->drawing, - 0, 0, - control_flow_data->drawing->width, - control_flow_data->drawing->height); - } else { - g_info("scrolling far"); - /* Cannot reuse any part of the screen : far jump */ - //*old_time_window = *new_time_window; - - - gdk_draw_rectangle (control_flow_data->drawing->pixmap, - control_flow_data->drawing->drawing_area->style->black_gc, - TRUE, - 0, 0, - control_flow_data->drawing->width+SAFETY, // do not overlap - control_flow_data->drawing->height+SAFETY); - - drawing_data_request(control_flow_data->drawing, - &control_flow_data->drawing->pixmap, - 0, 0, - control_flow_data->drawing->width, - control_flow_data->drawing->height); - - drawing_refresh(control_flow_data->drawing, + if(ltt_time_compare(*ns,*os) == 0) + { + g_info("not scrolling"); + } else { + g_info("scrolling far"); + /* Cannot reuse any part of the screen : far jump */ + + + gdk_draw_rectangle (control_flow_data->drawing->pixmap, + control_flow_data->drawing->drawing_area->style->black_gc, + TRUE, 0, 0, - control_flow_data->drawing->width, - control_flow_data->drawing->height); + control_flow_data->drawing->width+SAFETY, // do not overlap + control_flow_data->drawing->height+SAFETY); + + gtk_widget_queue_draw_area (drawing->drawing_area, + 0,0, + control_flow_data->drawing->width, + control_flow_data->drawing->height); + + drawing_data_request(control_flow_data->drawing, + &control_flow_data->drawing->pixmap, + 0, 0, + control_flow_data->drawing->width, + control_flow_data->drawing->height); + + } } } } else { /* Different scale (zoom) */ g_info("zoom"); - //*old_time_window = *new_time_window; - gdk_draw_rectangle (control_flow_data->drawing->pixmap, control_flow_data->drawing->drawing_area->style->black_gc, TRUE, @@ -1367,6 +1366,10 @@ gint update_time_window_hook(void *hook_data, void *call_data) control_flow_data->drawing->width+SAFETY, // do not overlap control_flow_data->drawing->height+SAFETY); + gtk_widget_queue_draw_area (drawing->drawing_area, + 0,0, + control_flow_data->drawing->width, + control_flow_data->drawing->height); drawing_data_request(control_flow_data->drawing, &control_flow_data->drawing->pixmap, @@ -1374,10 +1377,6 @@ gint update_time_window_hook(void *hook_data, void *call_data) control_flow_data->drawing->width, control_flow_data->drawing->height); - drawing_refresh(control_flow_data->drawing, - 0, 0, - control_flow_data->drawing->width, - control_flow_data->drawing->height); } @@ -1385,9 +1384,22 @@ gint update_time_window_hook(void *hook_data, void *call_data) return 0; } +gint after_process_traceset_hook(void *hook_data, void *call_data) +{ + ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; + TimeRequest *time_request = (TimeRequest *)call_data; + + drawing_data_request_end(control_flow_data->drawing, + time_request->time_window); + return 0; +} + + + gint update_current_time_hook(void *hook_data, void *call_data) { ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; + Drawing_t *drawing = control_flow_data->drawing; LttTime current_time = *((LttTime*)call_data); @@ -1450,7 +1462,11 @@ gint update_current_time_hook(void *hook_data, void *call_data) lttvwindow_report_time_window(control_flow_data->mw, &new_time_window); } - gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); + //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); + gtk_widget_queue_draw_area(drawing->drawing_area, + 0,0, + drawing->width, + drawing->height); return 0; } @@ -1660,6 +1676,7 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data) * for each process * draw closing line * new default prev and current + * then finally remove reading hooks. */ int after_data_request(void *hook_data, void *call_data) { @@ -1675,6 +1692,10 @@ int after_data_request(void *hook_data, void *call_data) g_hash_table_foreach(process_list->process_hash, draw_closure, (void*)&closure_data); + + /* Remove reading hooks */ + // Cannot do this here, will break processtrace! + //drawing_data_request_end(control_flow_data->drawing); } diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h index 05e7e7c0..324bd759 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.h @@ -99,6 +99,5 @@ gint update_time_window_hook(void *hook_data, void *call_data); gint update_current_time_hook(void *hook_data, void *call_data); - - +gint after_process_traceset_hook(void *hook_data, void *call_data); #endif // _EVENT_HOOKS_H diff --git a/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c b/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c index 6799b226..d28c67ff 100644 --- a/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c +++ b/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c @@ -244,7 +244,7 @@ gui_events(MainWindow *parent_window, LttvTracesetSelector * s,char* key ) update_time_window, event_viewer_data); lttvwindow_register_current_time_notify(event_viewer_data->mw, update_current_time,event_viewer_data); - lttvwindow_register_show(event_viewer_data->mw, + lttvwindow_register_show_notify(event_viewer_data->mw, show_event_detail,event_viewer_data); lttvwindow_register_traceset_notify(event_viewer_data->mw, traceset_changed,event_viewer_data); @@ -881,7 +881,11 @@ void get_test_data(double time_value, guint list_height, if(!first)break; raw_data = (RawTraceData*)g_list_nth_data(first,0); end = raw_data->time; - end.tv_nsec--; + if(end.tv_nsec != 0) + end.tv_nsec--; + else + end.tv_sec--; // even if tv_sec == 0, wrapping should give a real big + // value, so will read all the trace. ltt_event_position_get(raw_data->ep, &block_num, &event_num, &tf); if(size !=0){ if(event_num > minNum){ @@ -1166,7 +1170,7 @@ gui_events_free(EventViewerData *event_viewer_data) update_time_window, event_viewer_data); lttvwindow_unregister_current_time_notify(event_viewer_data->mw, update_current_time, event_viewer_data); - lttvwindow_unregister_show(event_viewer_data->mw, + lttvwindow_unregister_show_notify(event_viewer_data->mw, show_event_detail, event_viewer_data); lttvwindow_unregister_traceset_notify(event_viewer_data->mw, traceset_changed, event_viewer_data); 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 c4568cf4..1a4e4c65 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -25,17 +25,20 @@ #include "callbacks.h" #include "interface.h" #include "support.h" +#include +#include +#include +#include #include +#include +#include +#include #include #include #include #include -#include #include -#include #include -#include -#include #define PATH_LENGTH 256 #define DEFAULT_TIME_WIDTH_S 1 @@ -48,7 +51,7 @@ extern GSList * g_main_window_list; static int g_win_count = 0; -// MD : keep old directory +/** MD : keep old directory. */ static char remember_plugins_dir[PATH_LENGTH] = ""; static char remember_trace_dir[PATH_LENGTH] = ""; @@ -73,7 +76,7 @@ void add_trace_into_traceset_selector(GtkMultiVPaned * paned, LttTrace * trace); LttvTracesetSelector * construct_traceset_selector(LttvTraceset * traceset); -void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window); +void call_pending_read_hooks(MainWindow * mw_data); unsigned get_max_event_number(MainWindow * mw_data); enum { @@ -166,7 +169,6 @@ void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor) GtkWidget * viewer; LttvTracesetSelector * s; TimeInterval * time_interval; - TimeWindow time_window, t; mw_data = get_window_data_struct(widget); if(!mw_data->current_tab) return; @@ -177,22 +179,17 @@ void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor) if(viewer) { gtk_multi_vpaned_widget_add(multi_vpaned, viewer); - // Added by MD - // g_object_unref(G_OBJECT(viewer)); - - time_window = mw_data->current_tab->time_window; - time_interval = (TimeInterval*)g_object_get_data(G_OBJECT(viewer), TRACESET_TIME_SPAN); - if(time_interval){ - t = time_window; - time_window.start_time = time_interval->startTime; - time_window.time_width = ltt_time_sub(time_interval->endTime,time_interval->startTime); - } - - redraw_viewer(mw_data,&time_window); - lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time)); - if(time_interval){ - lttvwindow_report_time_window(mw_data,&t); - } + // We unref here, because it is now referenced by the multi_vpaned! + g_object_unref(G_OBJECT(viewer)); + + // The viewer will show itself when it receives a show notify + // So we call the show notify hooks here. It will + // typically add hooks for reading, we call process trace, and the + // end of reading hook will call gtk_widget_show and unregister the + // hooks. + // Note that show notify gets the time_requested through the call_data. + //show_viewer(mw_data); + // in expose now call_pending_read_hooks(mw_data); } } @@ -319,6 +316,7 @@ void delete_viewer(GtkWidget * widget, gpointer user_data) /* open_traceset will open a traceset saved in a file * Right now, it is not finished yet, (not working) + * FIXME */ void open_traceset(GtkWidget * widget, gpointer user_data) @@ -377,18 +375,37 @@ unsigned get_max_event_number(MainWindow * mw_data) } -/* redraw_viewer parses the traceset first by calling +/* call_pending_read_hooks parses the traceset first by calling * process_traceset, then display all viewers of * the current tab + * It will then remove all entries from the time_requests array. */ -void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window) +gint compare_time_request(TimeRequest *a, TimeRequest *b) +{ + return ltt_time_compare(a->time_window.start_time, b->time_window.start_time); +} + +void call_pending_read_hooks(MainWindow * mw_data) { unsigned max_nb_events; GdkWindow * win; GdkCursor * new; GtkWidget* widget; - LttvTracesetContext *tsc = + int i; + LttvTracesetContext *tsc; + + /* Current tab check : if no current tab is present, no hooks to call. */ + /* It makes the expose works.. */ + if(mw_data->current_tab == NULL) + return; + + if(mw_data->current_tab->time_requests->len == 0) + return; + + LttvHooks *tmp_hooks = lttv_hooks_new(); + + tsc = LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info-> traceset_context); @@ -400,20 +417,60 @@ void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window) gdk_cursor_unref(new); gdk_window_stick(win); gdk_window_unstick(win); - + + + g_array_sort(mw_data->current_tab->time_requests, + (GCompareFunc)compare_time_request); + + //update time window of each viewer, let viewer insert hooks needed by process_traceset - lttvwindow_report_time_window(mw_data, time_window); + //lttvwindow_report_time_window(mw_data, time_window); - max_nb_events = get_max_event_number(mw_data); - - lttv_process_traceset_seek_time(tsc, time_window->start_time); - lttv_process_traceset(tsc, - ltt_time_add(time_window->start_time,time_window->time_width), - max_nb_events); + //max_nb_events = get_max_event_number(mw_data); //call hooks to show each viewer and let them remove hooks - show_viewer(mw_data); + //show_viewer(mw_data); + // FIXME + // call process trace for each time interval + // Will have to be combined! + g_critical("SIZE time req len : %d", mw_data->current_tab->time_requests->len); + + //g_assert(mw_data->current_tab->time_requests->len <= 1); //FIXME + /* Go through each time request. As they are already sorted by start_time, + * we check with the current event time if processing is needed. */ + for(i=0; i < mw_data->current_tab->time_requests->len; i++) + { + g_critical("RUN i %d", i); + TimeRequest *time_request = + &g_array_index(mw_data->current_tab->time_requests, TimeRequest, i); + LttTime end_time = ltt_time_add( time_request->time_window.start_time, + time_request->time_window.time_width); + + if(i == 0 || !(ltt_time_compare(time_request->time_window.start_time, ltt_event_time(tsc->e))<0) ) + { + /* do it if first request or start_time >= last event's time */ + lttv_process_traceset_seek_time(tsc, time_request->time_window.start_time); + lttv_process_traceset(tsc, end_time, time_request->num_events); + } + + /* Call the end of process_traceset hook */ + lttv_hooks_add(tmp_hooks, + time_request->after_hook, + time_request->after_hook_data); + lttv_hooks_call(tmp_hooks, time_request); + lttv_hooks_remove(tmp_hooks, time_request->after_hook); + } + + /* Free the time requests */ + g_array_free(mw_data->current_tab->time_requests, TRUE); + mw_data->current_tab->time_requests = + g_array_new(FALSE, FALSE, sizeof(TimeRequest)); + + mw_data->current_tab->time_request_pending = FALSE; + + lttv_hooks_destroy(tmp_hooks); + //set the cursor back to normal gdk_window_set_cursor(win, NULL); } @@ -485,9 +542,9 @@ void add_trace(GtkWidget * widget, gpointer user_data) LttTrace *trace; LttvTrace * trace_v; LttvTraceset * traceset; - LttvTracesetStats* tmp_context; const char * dir; gint id; + gint i; MainWindow * mw_data = get_window_data_struct(widget); GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select a trace"); gtk_dir_selection_hide_fileop_buttons(file_selector); @@ -500,20 +557,34 @@ void add_trace(GtkWidget * widget, gpointer user_data) case GTK_RESPONSE_OK: dir = gtk_dir_selection_get_dir (file_selector); strncpy(remember_trace_dir, dir, PATH_LENGTH); - if(!dir || strlen(dir) ==0){ - gtk_widget_destroy((GtkWidget*)file_selector); - break; + if(!dir || strlen(dir) == 0){ + gtk_widget_destroy((GtkWidget*)file_selector); + break; } trace = ltt_trace_open(dir); if(trace == NULL) g_critical("cannot open trace %s", dir); trace_v = lttv_trace_new(trace); traceset = mw_data->current_tab->traceset_info->traceset; - // Keep the context until the new one is created. - tmp_context = mw_data->current_tab->traceset_info->traceset_context; - mw_data->current_tab->traceset_info->traceset_context = NULL; + //Keep a reference to the traces so they are not freed. + for(i=0; icurrent_tab->traceset_info->traceset_context); + + lttv_context_fini(LTTV_TRACESET_CONTEXT( + mw_data->current_tab->traceset_info->traceset_context)); + g_object_unref(mw_data->current_tab->traceset_info->traceset_context); + lttv_traceset_add(traceset, trace_v); + + /* Create new context */ mw_data->current_tab->traceset_info->traceset_context = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); lttv_context_init( @@ -523,37 +594,45 @@ void add_trace(GtkWidget * widget, gpointer user_data) //add state update hooks lttv_state_add_event_hooks( (LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context); - if(tmp_context != NULL) + //Remove local reference to the traces. + for(i=0; icurrent_tab->multi_vpaned, trace); gtk_widget_destroy((GtkWidget*)file_selector); //update current tab - update_traceset(mw_data); + //update_traceset(mw_data); //get_traceset_time_span(mw_data,LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span); - if(lttv_traceset_number(mw_data->current_tab->traceset_info->traceset) == 1 || - ltt_time_compare(mw_data->current_tab->current_time, - LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span->startTime)<0){ - mw_data->current_tab->current_time = - LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span->startTime; - mw_data->current_tab->time_window.start_time = mw_data->current_tab->current_time; - mw_data->current_tab->time_window.time_width.tv_sec = DEFAULT_TIME_WIDTH_S; - mw_data->current_tab->time_window.time_width.tv_nsec = 0; + if( + lttv_traceset_number(mw_data->current_tab->traceset_info->traceset) == 1 + || ltt_time_compare(mw_data->current_tab->current_time, + LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info-> + traceset_context)->Time_Span->startTime)<0) + { + /* Set initial time if this is the first trace in the traceset */ + mw_data->current_tab->current_time = + LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info-> + traceset_context)->Time_Span->startTime; + mw_data->current_tab->time_window.start_time = + mw_data->current_tab->current_time; + mw_data->current_tab->time_window.time_width.tv_sec = + DEFAULT_TIME_WIDTH_S; + mw_data->current_tab->time_window.time_width.tv_nsec = 0; } - redraw_viewer(mw_data, &(mw_data->current_tab->time_window)); - lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time)); + /* Call the updatetraceset hooks */ + + SetTraceset(mw_data, (gpointer)traceset); + // in expose now call_pending_read_hooks(mw_data); + + //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time)); break; case GTK_RESPONSE_REJECT: case GTK_RESPONSE_CANCEL: @@ -602,8 +681,7 @@ void remove_trace(GtkWidget * widget, gpointer user_data) LttTrace *trace; LttvTrace * trace_v; LttvTraceset * traceset; - LttvTracesetStats* tmp_context; - gint i, nb_trace; + gint i, j, nb_trace; char ** name, *remove_trace_name; MainWindow * mw_data = get_window_data_struct(widget); LttvTracesetSelector * s; @@ -655,37 +733,51 @@ void remove_trace(GtkWidget * widget, gpointer user_data) trace_v = lttv_traceset_get(traceset, i); if(lttv_trace_get_ref_number(trace_v) <= 1) ltt_trace_close(lttv_trace(trace_v)); - - // Keep the context until the new one is created. - tmp_context = mw_data->current_tab->traceset_info->traceset_context; - mw_data->current_tab->traceset_info->traceset_context = NULL; + + //Keep a reference to the traces so they are not freed. + for(j=0; jcurrent_tab->traceset_info->traceset_context); + lttv_context_fini(LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)); + g_object_unref(mw_data->current_tab->traceset_info->traceset_context); + lttv_traceset_remove(traceset, i); + lttv_trace_unref(trace_v); // Remove local reference if(!lttv_trace_get_ref_number(trace_v)) lttv_trace_destroy(trace_v); + mw_data->current_tab->traceset_info->traceset_context = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); - lttv_context_init( + lttv_context_init( LTTV_TRACESET_CONTEXT(mw_data->current_tab-> traceset_info->traceset_context),traceset); //add state update hooks - lttv_state_add_event_hooks( + lttv_state_add_event_hooks( (LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context); - if(tmp_context != NULL){ - //remove state update hooks - lttv_state_remove_event_hooks( - (LttvTracesetState*)tmp_context); - lttv_context_fini(LTTV_TRACESET_CONTEXT(tmp_context)); - g_object_unref(tmp_context); - } + //Remove local reference to the traces. + for(j=0; j 1){ - redraw_viewer(mw_data, &(mw_data->current_tab->time_window)); - lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time)); + + SetTraceset(mw_data, (gpointer)traceset); + // in expose now call_pending_read_hooks(mw_data); + + //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time)); }else{ if(mw_data->current_tab){ while(mw_data->current_tab->multi_vpaned->num_children){ @@ -704,7 +796,7 @@ void remove_trace(GtkWidget * widget, gpointer user_data) /* save will save the traceset to a file - * Not implemented yet + * Not implemented yet FIXME */ void save(GtkWidget * widget, gpointer user_data) @@ -726,44 +818,77 @@ void save_as(GtkWidget * widget, gpointer user_data) void zoom(GtkWidget * widget, double size) { TimeInterval *time_span; - TimeWindow time_window; - LttTime current_time, time_delta, time_s, time_e, time_t; + TimeWindow new_time_window; + LttTime current_time, time_delta, time_s, time_e, time_tmp; MainWindow * mw_data = get_window_data_struct(widget); if(size == 1) return; time_span = LTTV_TRACESET_CONTEXT(mw_data->current_tab-> traceset_info->traceset_context)->Time_Span; - time_window = mw_data->current_tab->time_window; + new_time_window = mw_data->current_tab->time_window; current_time = mw_data->current_tab->current_time; time_delta = ltt_time_sub(time_span->endTime,time_span->startTime); if(size == 0){ - time_window.start_time = time_span->startTime; - time_window.time_width = time_delta; + new_time_window.start_time = time_span->startTime; + new_time_window.time_width = time_delta; }else{ - time_window.time_width = ltt_time_div(time_window.time_width, size); - if(ltt_time_compare(time_window.time_width,time_delta) > 0) - time_window.time_width = time_delta; - - time_t = ltt_time_div(time_window.time_width, 2); - if(ltt_time_compare(current_time, time_t) < 0){ - time_s = time_span->startTime; - } else { - time_s = ltt_time_sub(current_time,time_t); + new_time_window.time_width = ltt_time_div(new_time_window.time_width, size); + 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->startTime; + new_time_window.time_width = time_delta; } - time_e = ltt_time_add(current_time,time_t); - if(ltt_time_compare(time_span->startTime, time_s) > 0){ - time_s = time_span->startTime; - }else if(ltt_time_compare(time_span->endTime, time_e) < 0){ - time_e = time_span->endTime; - time_s = ltt_time_sub(time_e,time_window.time_width); + else + { + /* Center the image on the current time */ + g_critical("update is HERE"); + new_time_window.start_time = + ltt_time_sub(current_time, ltt_time_div(new_time_window.time_width, 2.0)); + /* If on borders, don't fall off */ + if(ltt_time_compare(new_time_window.start_time, time_span->startTime) <0) + { + new_time_window.start_time = time_span->startTime; + } + else + { + if(ltt_time_compare( + ltt_time_add(new_time_window.start_time, new_time_window.time_width), + time_span->endTime) > 0) + { + new_time_window.start_time = + ltt_time_sub(time_span->endTime, new_time_window.time_width); + } + } + } - time_window.start_time = time_s; + + + + //time_tmp = ltt_time_div(new_time_window.time_width, 2); + //if(ltt_time_compare(current_time, time_tmp) < 0){ + // time_s = time_span->startTime; + //} else { + // time_s = ltt_time_sub(current_time,time_tmp); + //} + //time_e = ltt_time_add(current_time,time_tmp); + //if(ltt_time_compare(time_span->startTime, time_s) > 0){ + // time_s = time_span->startTime; + //}else if(ltt_time_compare(time_span->endTime, time_e) < 0){ + // time_e = time_span->endTime; + // time_s = ltt_time_sub(time_e,new_time_window.time_width); + //} + //new_time_window.start_time = time_s; } - redraw_viewer(mw_data, &time_window); - lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time)); - gtk_multi_vpaned_set_adjust(mw_data->current_tab->multi_vpaned, FALSE); + + //lttvwindow_report_time_window(mw_data, &new_time_window); + //call_pending_read_hooks(mw_data); + + //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time)); + set_time_window(mw_data, &new_time_window); + // in expose now call_pending_read_hooks(mw_data); + gtk_multi_vpaned_set_adjust(mw_data->current_tab->multi_vpaned, &new_time_window, FALSE); } void zoom_in(GtkWidget * widget, gpointer user_data) @@ -824,7 +949,7 @@ void create_new_tab(GtkWidget* widget, gpointer user_data){ strcpy(label,"Page"); if(get_label(mw_data, label,"Get the name of the tab","Please input tab's name")) - create_tab (mw_data, mw_data, notebook, label); + create_tab (NULL, mw_data, notebook, label); } void @@ -1039,9 +1164,10 @@ on_trace_filter_activate (GtkMenuItem *menuitem, return; } if(get_filter_selection(s, "Configure trace and tracefile filter", "Select traces and tracefiles")){ - update_traceset(mw_data); - redraw_viewer(mw_data, &(mw_data->current_tab->time_window)); - lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time)); + //FIXME report filter change + //update_traceset(mw_data); + //call_pending_read_hooks(mw_data); + //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time)); } } @@ -1380,7 +1506,6 @@ on_MWindow_configure (GtkWidget *widget, return FALSE; } - /* Set current tab */ @@ -1833,12 +1958,10 @@ void construct_main_window(MainWindow * parent) new_window = create_MWindow(); gtk_widget_show (new_window); - new_m_window->attributes = attributes; - new_m_window->mwindow = new_window; new_m_window->tab = NULL; new_m_window->current_tab = NULL; - new_m_window->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL)); + new_m_window->attributes = attributes; new_m_window->hash_menu_item = g_hash_table_new_full (g_str_hash, g_str_equal, main_window_destroy_hash_key, @@ -1850,7 +1973,6 @@ void construct_main_window(MainWindow * parent) insert_menu_toolbar_item(new_m_window, NULL); g_object_set_data(G_OBJECT(new_window), "mainWindow", (gpointer)new_m_window); - //create a default tab notebook = (GtkNotebook *)lookup_widget(new_m_window->mwindow, "MNotebook"); if(notebook == NULL){ @@ -1859,7 +1981,7 @@ void construct_main_window(MainWindow * parent) } //for now there is no name field in LttvTraceset structure //Use "Traceset" as the label for the default tab - create_tab(parent, new_m_window, notebook,"Traceset"); + create_tab(parent, new_m_window, notebook, "Traceset"); g_object_set_data_full( G_OBJECT(new_m_window->mwindow), @@ -1915,7 +2037,8 @@ void tab_destructor(Tab * tab_instance) // lttv_trace_destroy(trace); } } - lttv_traceset_destroy(tab_instance->traceset_info->traceset); + lttv_traceset_destroy(tab_instance->traceset_info->traceset); + g_array_free(tab_instance->time_requests, TRUE); g_free(tab_instance->traceset_info); g_free(tab_instance); } @@ -1931,7 +2054,7 @@ void * create_tab(MainWindow * parent, MainWindow* current_window, Tab * tmp_tab; MainWindow * mw_data = current_window; LttTime tmp_time; - + //create a new tab data structure tmp_tab = mw_data->tab; while(tmp_tab && tmp_tab->next) tmp_tab = tmp_tab->next; @@ -1947,22 +2070,32 @@ void * create_tab(MainWindow * parent, MainWindow* current_window, //construct and initialize the traceset_info tmp_tab->traceset_info = g_new(TracesetInfo,1); if(parent){ - tmp_tab->traceset_info->traceset = - lttv_traceset_copy(parent->current_tab->traceset_info->traceset); - }else{ + if(parent->current_tab){ + tmp_tab->traceset_info->traceset = + lttv_traceset_new(); + //FIXME lttv_traceset_copy(parent->current_tab->traceset_info->traceset); + }else{ + tmp_tab->traceset_info->traceset = lttv_traceset_new(); + } + + }else{ /* Initial window */ if(mw_data->current_tab){ tmp_tab->traceset_info->traceset = - lttv_traceset_copy(mw_data->current_tab->traceset_info->traceset); + lttv_traceset_new(); + //FIXME lttv_traceset_copy(mw_data->current_tab->traceset_info->traceset); }else{ tmp_tab->traceset_info->traceset = lttv_traceset_new(); /* Add the command line trace */ - if(g_init_trace != NULL) + if(g_init_trace != NULL){ lttv_traceset_add(tmp_tab->traceset_info->traceset, g_init_trace); + } } } + //FIXME copy not implemented in lower level tmp_tab->traceset_info->traceset_context = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); + g_assert(tmp_tab->traceset_info->traceset_context != NULL); lttv_context_init( LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context), tmp_tab->traceset_info->traceset); @@ -1970,7 +2103,6 @@ void * create_tab(MainWindow * parent, MainWindow* current_window, lttv_state_add_event_hooks( (LttvTracesetState*)tmp_tab->traceset_info->traceset_context); - //determine the current_time and time_window of the tab if(mw_data->current_tab){ // Will have to read directly at the main window level, as we want @@ -1996,8 +2128,10 @@ void * create_tab(MainWindow * parent, MainWindow* current_window, tmp_tab->current_time.tv_nsec = LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->startTime.tv_nsec; } + /* Become the current tab */ + mw_data->current_tab = tmp_tab; + tmp_tab->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL)); - // mw_data->current_tab = tmp_tab; tmp_tab->multi_vpaned = (GtkMultiVPaned*)gtk_multi_vpaned_new(); tmp_tab->multi_vpaned->mw = mw_data; gtk_widget_show((GtkWidget*)tmp_tab->multi_vpaned); @@ -2007,6 +2141,9 @@ void * create_tab(MainWindow * parent, MainWindow* current_window, tmp_tab->label = gtk_label_new (label); gtk_widget_show (tmp_tab->label); + tmp_tab->time_requests = g_array_new(FALSE, FALSE, sizeof(TimeRequest)); + tmp_tab->time_request_pending = FALSE; + g_object_set_data_full( G_OBJECT(tmp_tab->multi_vpaned), "Tab_Info", @@ -2017,8 +2154,9 @@ void * create_tab(MainWindow * parent, MainWindow* current_window, gtk_notebook_append_page(notebook, (GtkWidget*)tmp_tab->multi_vpaned, tmp_tab->label); list = gtk_container_get_children(GTK_CONTAINER(notebook)); gtk_notebook_set_current_page(notebook,g_list_length(list)-1); - if(g_list_length(list)>1) - gtk_notebook_set_show_tabs(notebook, TRUE); + // always show : not if(g_list_length(list)>1) + gtk_notebook_set_show_tabs(notebook, TRUE); + } @@ -2110,3 +2248,45 @@ void main_window_remove_toolbar_item(lttvwindow_viewer_constructor constructor) } } } + +/** + * Function to show each viewer in the current tab. + * It will be called by main window, call show on each registered viewer, + * will call process traceset and then it will + * @param main_win the main window the viewer belongs to. + */ +//FIXME Only one time request maximum for now! +void show_viewer(MainWindow *main_win) +{ + LttvAttributeValue value; + LttvHooks * tmp; + int i; + LttvTracesetContext * tsc = + (LttvTracesetContext*)main_win->current_tab-> + traceset_info->traceset_context; + + g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, + "hooks/showviewer", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL) + { + g_warning("The viewer(s) did not add any show hook"); + return; + } + + + // Call the show, where viewers add hooks to context and fill the + // time and number of events requested it the time_requests GArray. + lttv_hooks_call(tmp, NULL); + + +} + + +gboolean execute_time_requests(MainWindow * mw) +{ + call_pending_read_hooks(mw); + + return FALSE; // automatically removed from the list of event sources +} + diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h index 96cc541b..6d382cb9 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h @@ -27,6 +27,8 @@ void insert_menu_toolbar_item(MainWindow * mw, gpointer user_data); void construct_main_window(MainWindow * parent); void main_window_free(MainWindow * mw); void main_window_destructor(MainWindow * mw); +void show_viewer(MainWindow *main_win); + /* callback functions*/ @@ -229,6 +231,17 @@ on_MWindow_configure (GtkWidget *widget, GdkEventConfigure *event, gpointer user_data); +gboolean +on_MWindow_expose (GtkWidget *widget, + GdkEventExpose *event, + gpointer user_data); +gboolean +on_MWindow_after (GtkWidget *widget, + GdkEvent *event, + gpointer user_data); + + + void on_insert_viewer_test_activate (GtkMenuItem *menuitem, gpointer user_data); @@ -241,3 +254,5 @@ on_MNotebook_switch_page (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data); + +gboolean execute_time_requests(MainWindow * mw); diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.c index f0dc2cfe..cfcae7c1 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.c @@ -32,7 +32,7 @@ static void gtk_multi_vpaned_size_request (GtkWidget *widget, static void gtk_multi_vpaned_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -void gtk_multi_vpaned_scroll_value_changed (GtkRange *range, gpointer multi_vpaned); +void gtk_multi_vpaned_scroll_value_changed (GtkAdjustment *adjust, gpointer multi_vpaned); gboolean gtk_multi_vpaned_destroy(GtkObject *object, gpointer user_data) @@ -168,12 +168,11 @@ void gtk_multi_vpaned_set_focus (GtkWidget * widget, gpointer user_data) } } -void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, gboolean first_time) +void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, const TimeWindow *time_window, gboolean first_time) { - TimeWindow time_window = multi_vpaned->mw->current_tab->time_window; + //TimeWindow time_window = multi_vpaned->mw->current_tab->time_window; TimeInterval *time_span; - double tmp, start; - double range = 0; + double len, start; if(first_time){ @@ -193,16 +192,17 @@ void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, gboolean first_t return; } - start = ltt_time_to_double(time_window.start_time) * NANOSECONDS_PER_SECOND; - tmp = multi_vpaned->hadjust->upper - multi_vpaned->hadjust->lower; + start = ltt_time_to_double(time_window->start_time) * NANOSECONDS_PER_SECOND; + len = multi_vpaned->hadjust->upper - multi_vpaned->hadjust->lower; multi_vpaned->hadjust->page_increment = ltt_time_to_double( - time_window.time_width) * NANOSECONDS_PER_SECOND; + time_window->time_width) * NANOSECONDS_PER_SECOND; - if(multi_vpaned->hadjust->page_increment >= tmp - range) - multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower; - if(start + multi_vpaned->hadjust->page_increment >= multi_vpaned->hadjust->upper - range) - multi_vpaned->hadjust->value = start; + //if(multi_vpaned->hadjust->page_increment >= len ) + // multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower; + //if(start + multi_vpaned->hadjust->page_increment >= multi_vpaned->hadjust->upper ) + // multi_vpaned->hadjust->value = start; + multi_vpaned->hadjust->value = start; /* page_size to the whole visible area will take care that the * scroll value + the shown area will never be more than what is @@ -211,6 +211,7 @@ void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, gboolean first_t multi_vpaned->hadjust->step_increment = multi_vpaned->hadjust->page_increment / 10; gtk_adjustment_changed (multi_vpaned->hadjust); + } void gtk_multi_vpaned_widget_add(GtkMultiVPaned * multi_vpaned, GtkWidget * widget1) @@ -230,14 +231,17 @@ void gtk_multi_vpaned_widget_add(GtkMultiVPaned * multi_vpaned, GtkWidget * widg gtk_widget_show(multi_vpaned->hscrollbar); multi_vpaned->hadjust = gtk_range_get_adjustment(GTK_RANGE(multi_vpaned->hscrollbar)); - gtk_multi_vpaned_set_adjust(multi_vpaned, TRUE); + gtk_multi_vpaned_set_adjust(multi_vpaned, &multi_vpaned->mw->current_tab->time_window, TRUE); gtk_range_set_update_policy (GTK_RANGE(multi_vpaned->hscrollbar), GTK_UPDATE_CONTINUOUS); //changed by Mathieu Desnoyers, was : // GTK_UPDATE_DISCONTINUOUS); - g_signal_connect(G_OBJECT(multi_vpaned->hscrollbar), "value-changed", + g_signal_connect(G_OBJECT(multi_vpaned->hadjust), "value-changed", G_CALLBACK(gtk_multi_vpaned_scroll_value_changed), multi_vpaned); + g_signal_connect(G_OBJECT(multi_vpaned->hadjust), "changed", + G_CALLBACK(gtk_multi_vpaned_scroll_value_changed), multi_vpaned); + multi_vpaned->vbox = gtk_vbox_new(FALSE,0); gtk_widget_show(multi_vpaned->vbox); @@ -401,16 +405,16 @@ void gtk_multi_vpaned_widget_move_down(GtkMultiVPaned * multi_vpaned) void gtk_multi_vpaned_set_scroll_value(GtkMultiVPaned * multi_vpaned, double value) { gtk_adjustment_set_value(multi_vpaned->hadjust, value); - g_signal_stop_emission_by_name(G_OBJECT(multi_vpaned->hscrollbar), "value-changed"); + //g_signal_stop_emission_by_name(G_OBJECT(multi_vpaned->hscrollbar), "value-changed"); } -void gtk_multi_vpaned_scroll_value_changed(GtkRange *range, gpointer multi_vpaned_arg) +void gtk_multi_vpaned_scroll_value_changed(GtkAdjustment *adjust, gpointer multi_vpaned_arg) { TimeWindow time_window; TimeInterval *time_span; LttTime time; GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned*)multi_vpaned_arg; - gdouble value = gtk_range_get_value(range); + gdouble value = gtk_adjustment_get_value(adjust); gdouble upper, lower, ratio; time_window = multi_vpaned->mw->current_tab->time_window; @@ -431,7 +435,8 @@ void gtk_multi_vpaned_scroll_value_changed(GtkRange *range, gpointer multi_vpane if(ltt_time_compare(time,time_window.time_width) < 0){ time_window.time_width = time; } - lttvwindow_report_time_window(multi_vpaned->mw, &time_window); + set_time_window(multi_vpaned->mw, &time_window); + // done in expose now call_pending_read_hooks(multi_vpaned->mw); } diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.h index 316ec4d1..413abe3a 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.h +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.h @@ -76,7 +76,7 @@ void gtk_multi_vpaned_widget_add(GtkMultiVPaned * multi_vpaned, GtkWidget * widg void gtk_multi_vpaned_widget_delete(GtkMultiVPaned * multi_vpaned); void gtk_multi_vpaned_widget_move_up(GtkMultiVPaned * multi_vpaned); void gtk_multi_vpaned_widget_move_down(GtkMultiVPaned * multi_vpaned); -void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, gboolean first_time); +void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, const TimeWindow * time_window, gboolean first_time); void gtk_multi_vpaned_set_data(GtkMultiVPaned * multi_vpaned, char * key, gpointer value); gpointer gtk_multi_vpaned_get_data(GtkMultiVPaned * multi_vpaned, char * key); GtkWidget * gtk_multi_vpaned_get_widget(GtkMultiVPaned * multi_vpaned); diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/interface.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/interface.c index ee08b8e9..46a82b17 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/interface.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/interface.c @@ -597,6 +597,7 @@ create_MWindow (void) g_signal_connect ((gpointer) MWindow, "configure-event", G_CALLBACK (on_MWindow_configure), NULL); + // g_signal_connect ((gpointer) EmptyTraceset, "activate", // G_CALLBACK (on_empty_traceset_activate), // NULL); 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 f0c0e6a1..e9e5e536 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/mainwindow.h +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/mainwindow.h @@ -87,8 +87,19 @@ struct _Tab{ /* Traceset related information */ TracesetInfo * traceset_info; + + /* A list of time requested for the next process trace */ + GArray *time_requests; + gboolean time_request_pending; }; +typedef struct _TimeRequest { + TimeWindow time_window; + guint num_events; + LttvHook after_hook; + gpointer after_hook_data; +} TimeRequest; + /** * Remove menu and toolbar item when a module unloaded */ diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/viewer.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/viewer.c index 78a96fa8..a168ed5b 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/viewer.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/viewer.c @@ -28,16 +28,17 @@ * */ -#include #include #include +#include +#include +#include +#include #include #include -#include #include #include -#include -#include +#include // for execute_time_requests /** @@ -65,9 +66,10 @@ int SetTraceset(MainWindow * main_win, gpointer traceset) tmp = (LttvHooks*)*(value.v_pointer); if(tmp == NULL) return 1; + lttv_hooks_call(tmp,traceset); - + return 0; } @@ -115,27 +117,32 @@ void update_traceset(MainWindow * main_win) lttv_hooks_call(tmp, NULL); } +void set_time_window_adjustment(MainWindow * main_win, const TimeWindow* new_time_window) +{ + gtk_multi_vpaned_set_adjust(main_win->current_tab->multi_vpaned, new_time_window, FALSE); +} -/** - * Function to show each viewer in the current tab. - * It will be called by main window after it called process_traceset - * @param main_win the main window the viewer belongs to. - */ - -void show_viewer(MainWindow *main_win) +void set_time_window(MainWindow * main_win, const TimeWindow *time_window) { LttvAttributeValue value; LttvHooks * tmp; + + TimeWindowNotifyData time_window_notify_data; + TimeWindow old_time_window = main_win->current_tab->time_window; + time_window_notify_data.old_time_window = &old_time_window; + main_win->current_tab->time_window = *time_window; + time_window_notify_data.new_time_window = + &(main_win->current_tab->time_window); + g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, - "hooks/showviewer", LTTV_POINTER, &value)); + "hooks/updatetimewindow", LTTV_POINTER, &value)); tmp = (LttvHooks*)*(value.v_pointer); if(tmp == NULL) return; - lttv_hooks_call(tmp, NULL); -} - + lttv_hooks_call(tmp, &time_window_notify_data); +} /** * API parts @@ -372,7 +379,6 @@ void lttvwindow_unregister_filter_notify(LttvHook hook, gpointer hook_data, lttv_hooks_remove_data(tmp, hook, hook_data); } - /** * Function to register a hook function for a viewer to set/update its * current time. @@ -426,7 +432,7 @@ void lttvwindow_unregister_current_time_notify(MainWindow * main_win, * @param main_win the main window the viewer belongs to. */ -void lttvwindow_register_show(MainWindow *main_win, +void lttvwindow_register_show_notify(MainWindow *main_win, LttvHook hook, gpointer hook_data) { LttvAttributeValue value; @@ -450,7 +456,7 @@ void lttvwindow_register_show(MainWindow *main_win, * @param main_win the main window the viewer belongs to. */ -void lttvwindow_unregister_show(MainWindow * main_win, +void lttvwindow_unregister_show_notify(MainWindow * main_win, LttvHook hook, gpointer hook_data) { LttvAttributeValue value; @@ -531,26 +537,11 @@ void lttvwindow_report_status(MainWindow *main_win, char *info) void lttvwindow_report_time_window(MainWindow *main_win, TimeWindow *time_window) { - LttvAttributeValue value; - LttvHooks * tmp; - - TimeWindowNotifyData time_window_notify_data; - TimeWindow old_time_window = main_win->current_tab->time_window; - time_window_notify_data.old_time_window = &old_time_window; - main_win->current_tab->time_window = *time_window; - time_window_notify_data.new_time_window = - &(main_win->current_tab->time_window); - - gtk_multi_vpaned_set_scroll_value(main_win->current_tab->multi_vpaned, - ltt_time_to_double(time_window->start_time) - * NANOSECONDS_PER_SECOND ); - g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, - "hooks/updatetimewindow", LTTV_POINTER, &value)); - tmp = (LttvHooks*)*(value.v_pointer); - if(tmp == NULL) return; - lttv_hooks_call(tmp, &time_window_notify_data); + set_time_window(main_win, time_window); + set_time_window_adjustment(main_win, time_window); } + /** * Function to set the current time/event of the current tab. * It will be called by a viewer's signal handle associated with @@ -605,6 +596,40 @@ void lttvwindow_report_focus(MainWindow *main_win, gpointer paned) } +/** + * Function to request data in a specific time interval to the main window. + * The main window will use this time interval and the others present + * to get the data from the process trace. + * @param main_win the main window the viewer belongs to. + * @param paned a pointer to a pane where the viewer is contained. + */ + +void lttvwindow_time_interval_request(MainWindow *main_win, + TimeWindow time_requested, guint num_events, + LttvHook after_process_traceset, + gpointer after_process_traceset_data) +{ + TimeRequest time_request; + + time_request.time_window = time_requested; + time_request.num_events = num_events; + time_request.after_hook = after_process_traceset; + time_request.after_hook_data = after_process_traceset_data; + + g_array_append_val(main_win->current_tab->time_requests, time_request); + + if(!main_win->current_tab->time_request_pending) + { + /* Redraw has +20 priority. We want a prio higher than that, so +19 */ + g_idle_add_full((G_PRIORITY_HIGH_IDLE + 19), + (GSourceFunc)execute_time_requests, + main_win, + NULL); + main_win->current_tab->time_request_pending = TRUE; + } +} + + /** * Function to get the current time interval of the current traceset. diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/viewer.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/viewer.h index 4495c6b8..ae4349c2 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/viewer.h +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/viewer.h @@ -268,7 +268,7 @@ void lttvwindow_unregister_current_time_notify(MainWindow * main_win, * @param main_win the main window the viewer belongs to. */ -void lttvwindow_register_show(MainWindow *main_win, +void lttvwindow_register_show_notify(MainWindow *main_win, LttvHook hook, gpointer hook_data); @@ -280,7 +280,7 @@ void lttvwindow_register_show(MainWindow *main_win, * @param main_win the main window the viewer belongs to. */ -void lttvwindow_unregister_show(MainWindow * main_win, +void lttvwindow_unregister_show_notify(MainWindow * main_win, LttvHook hook, gpointer hook_data); @@ -360,6 +360,20 @@ void lttvwindow_report_dividor(MainWindow *main_win, gint position); //FIXME : can we do this through normal GTK signals ? void lttvwindow_report_focus(MainWindow *main_win, gpointer paned); + +/** + * Function to request data in a specific time interval to the main window. + * The main window will use this time interval and the others present + * to get the data from the process trace. + * @param main_win the main window the viewer belongs to. + * @param paned a pointer to a pane where the viewer is contained. + */ + +void lttvwindow_time_interval_request(MainWindow *main_win, + TimeWindow time_requested, guint num_events, + LttvHook after_process_traceset, + gpointer after_process_traceset_data); + /** * Function to get the life span of the traceset * @param main_win the main window the viewer belongs to. diff --git a/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c b/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c index 341ea771..d8d32465 100644 --- a/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c +++ b/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c @@ -121,7 +121,7 @@ gui_statistic_free(StatisticViewerData *statistic_viewer_data) if(statistic_viewer_data){ lttvwindow_unregister_time_window_notify(statistic_viewer_data->mw, statistic_update_time_window,statistic_viewer_data); - lttvwindow_unregister_show(statistic_viewer_data->mw, + lttvwindow_unregister_show_notify(statistic_viewer_data->mw, statistic_show_viewer,statistic_viewer_data); lttvwindow_unregister_traceset_notify(statistic_viewer_data->mw, statistic_traceset_changed,statistic_viewer_data); @@ -203,7 +203,7 @@ gui_statistic(MainWindow *parent_window, LttvTracesetSelector * s, char* key) lttvwindow_register_time_window_notify(statistic_viewer_data->mw, statistic_update_time_window,statistic_viewer_data); - lttvwindow_register_show(statistic_viewer_data->mw, + lttvwindow_register_show_notify(statistic_viewer_data->mw, statistic_show_viewer,statistic_viewer_data); lttvwindow_register_traceset_notify(statistic_viewer_data->mw, statistic_traceset_changed,statistic_viewer_data); -- 2.34.1