/*! \brief build_v_value() allocates a viewable_value structure and populates it with sane defaults and returns it to the caller \param object is the object to get soem of the data from \returns a pointer to a newly allocated and populated Viewable_Value structure */ G_MODULE_EXPORT Viewable_Value * build_v_value(gconstpointer *object) { Viewable_Value *v_value = NULL; GdkPixmap *pixmap = NULL; pixmap = lv_data->pixmap; v_value = g_malloc(sizeof(Viewable_Value)); /* Set limits of this variable. (it's ranges, used for scaling */ if (DATA_GET(global_data,"playback_mode")) { /* textual name of the variable we're viewing.. */ v_value->vname = g_strdup(DATA_GET(object,"lview_name")); /* data was already read from file and stored, copy pointer * over to v_value so it can be drawn... */ v_value->data_source = g_strdup("data_array"); } else { /* textual name of the variable we're viewing.. */ v_value->vname = g_strdup(DATA_GET(object,"dlog_gui_name")); /* Array to keep history for resize/redraw and export * to datalog we use the _sized_ version to give a big * enough size to prevent reallocating memory too often. * (more initial mem usage, but less calls to malloc... */ v_value->data_source = g_strdup("history"); } /* Store pointer to object, but DO NOT FREE THIS on v_value destruction * as its the SAME one used for all Viewable_Values */ v_value->object = object; /* IS it a floating point value? */ v_value->precision = (GINT)DATA_GET(object,"precision"); v_value->lower = (GINT)strtol(DATA_GET(object,"real_lower"),NULL,10); v_value->upper = (GINT)strtol(DATA_GET(object,"real_upper"),NULL,10); /* Sets last "y" value to -1, needed for initial draw to be correct */ v_value->last_y = -1; /* User adjustable scales... */ v_value->cur_low = v_value->lower; v_value->cur_high = v_value->upper; v_value->min = 0; v_value->max = 0; /* Allocate the colors (GC's) for the font and trace */ v_value->font_gc = initialize_gc(pixmap, FONT); v_value->trace_gc = initialize_gc(pixmap, TRACE); /* Allocate the structs to hold the text screen dimensions */ v_value->ink_rect = g_new0(PangoRectangle, 1); v_value->log_rect = g_new0(PangoRectangle, 1); v_value->force_update = TRUE; v_value->highlight = FALSE; return v_value; }
EXPORT gboolean logger_display_config_event(GtkWidget * widget, GdkEventConfigure *event , gpointer data) { gint w = 0; gint h = 0; if(widget->window) { w=widget->allocation.width; h=widget->allocation.height; if (ttm_data->layout) g_object_unref(ttm_data->layout); if (ttm_data->axis_gc) g_object_unref(ttm_data->axis_gc); if (ttm_data->trace_gc) g_object_unref(ttm_data->trace_gc); if (ttm_data->pixmap) g_object_unref(ttm_data->pixmap); ttm_data->pixmap=gdk_pixmap_new(widget->window, w,h, gtk_widget_get_visual(widget)->depth); gdk_draw_rectangle(ttm_data->pixmap, widget->style->white_gc, TRUE, 0,0, w,h); gdk_window_set_back_pixmap(widget->window,ttm_data->pixmap,0); ttm_data->axis_gc = initialize_gc(ttm_data->pixmap,TTM_AXIS); ttm_data->trace_gc = initialize_gc(ttm_data->pixmap,TTM_TRACE); ttm_data->layout = gtk_widget_create_pango_layout(ttm_data->darea,NULL); } /* Don't try to update if the page isn't bound YET */ if (ttm_data->page < 0) return TRUE; _crunch_trigtooth_data(ttm_data->page); if (ttm_data->peak > 0) update_trigtooth_display(ttm_data->page); return TRUE; }
void setup_memory (unsigned long heap_size, unsigned long stack_size, unsigned long constant_size) { ALLOCATE_REGISTERS (); /* Consistency check 1 */ if ((heap_size == 0) || (stack_size == 0) || (constant_size == 0)) { outf_fatal ("Configuration won't hold initial data.\n"); outf_flush_fatal (); exit (1); } /* Allocate */ ALLOCATE_HEAP_SPACE ((stack_size + heap_size + constant_size), memory_block_start, memory_block_end); /* Consistency check 2 */ if (memory_block_start == 0) { outf_fatal ("Not enough memory for this configuration.\n"); outf_flush_fatal (); exit (1); } /* Consistency check 3 */ if ((ADDRESS_TO_DATUM (memory_block_end)) > DATUM_MASK) { outf_fatal ("Requested allocation is too large.\n"); outf_fatal ("Try again with a smaller argument to '--heap'.\n"); outf_flush_fatal (); reset_memory (); exit (1); } saved_stack_size = stack_size; saved_constant_size = constant_size; saved_heap_size = heap_size; reset_allocator_parameters (0); initialize_gc (heap_size, (&heap_start), (&Free), allocate_tospace, abort_gc); }
/*! \brief draw_infotext() draws the static textual data for the trace on the left hand side of the logviewer */ G_MODULE_EXPORT void draw_infotext(void) { /* Draws the textual (static) info on the left side of the window..*/ gint name_x = 0; gint name_y = 0; gint text_border = 10; gint info_ctr = 0; gint h = 0; gint i = 0; gint width = 0; gint height = 0; gint max = 0; Viewable_Value *v_value = NULL; PangoLayout *layout; GdkPixmap *pixmap = lv_data->pixmap; GtkAllocation allocation; gtk_widget_get_allocation(lv_data->darea,&allocation); h = allocation.height; gdk_draw_rectangle(pixmap, gtk_widget_get_style(lv_data->darea)->black_gc, TRUE, 0,0, lv_data->info_width,h); if (!lv_data->font_desc) { lv_data->font_desc = pango_font_description_from_string("courier"); pango_font_description_set_size(lv_data->font_desc,(10)*PANGO_SCALE); } if (!lv_data->highlight_gc) lv_data->highlight_gc = initialize_gc(lv_data->pixmap,HIGHLIGHT); lv_data->spread = (GINT)((float)h/(float)lv_data->active_traces); name_x = text_border; layout = gtk_widget_create_pango_layout(lv_data->darea,NULL); for (i=0;i<lv_data->active_traces;i++) { v_value = (Viewable_Value *)g_list_nth_data(lv_data->tlist,i); info_ctr = (lv_data->spread * (i+1))- (lv_data->spread/2); pango_layout_set_markup(layout,v_value->vname,-1); pango_layout_set_font_description(layout,lv_data->font_desc); pango_layout_get_pixel_size(layout,&width,&height); name_y = info_ctr - height - 2; if (width > max) max = width; gdk_draw_layout(pixmap,v_value->trace_gc,name_x,name_y,layout); } lv_data->info_width = max + (text_border * 2.5); for (i=0;i<lv_data->active_traces;i++) { gdk_draw_rectangle(pixmap, gtk_widget_get_style(lv_data->darea)->white_gc, FALSE, 0,i*lv_data->spread, lv_data->info_width-1,lv_data->spread); } }