void View::update(float delta) { //std::cout << "View:update: " << x1 << " " << y1 << " " << x2 << " " << y2 //<< " " << state.x_offset << " " << state.y_offset << std::endl; if (view_updater) view_updater->update(delta, state); scene_context->reset_modelview(); scene_context->translate(get_x_offset(), get_y_offset()); //drawing_context.translate(state.x_offset, state.y_offset); }
ss_model::ss_model(MODULE *module) { if (oclass==NULL) { // register to receive notice for first top down. bottom up, and second top down synchronizations oclass = gld_class::create(module,"ss_model",sizeof(ss_model),PC_BOTTOMUP|PC_AUTOLOCK); if (oclass==NULL) throw "unable to register class ss_model"; else oclass->trl = TRL_PRINCIPLE; defaults = this; if (gl_publish_variable(oclass, PT_enumeration,"form",get_form_offset(),PT_DESCRIPTION,"desired canonical controller type", PT_KEYWORD,"CCF",CF_CCF, PT_KEYWORD,"OCF",CF_OCF, PT_double,"timestep",get_timestep_offset(),PT_UNITS,"s",PT_DESCRIPTION,"discrete timestep", PT_char1024, "Y", get_Y_offset(),PT_DESCRIPTION,"transfer function numerator coefficients", PT_char1024, "U", get_U_offset(),PT_DESCRIPTION,"transfer function denominator coefficients", PT_char1024, "x", get_x_offset(),PT_DESCRIPTION,"state variable values", PT_char1024, "u", get_u_offset(),PT_DESCRIPTION,"ss_model variable names", PT_char1024, "y", get_y_offset(),PT_DESCRIPTION,"output variable names", PT_char1024, "H", get_H_offset(),PT_DESCRIPTION,"transfer function", PT_char1024, "A", get_y_offset(),PT_DESCRIPTION,"canonical A matrix", PT_char1024, "B", get_y_offset(),PT_DESCRIPTION,"canonical B matrix", PT_char1024, "C", get_y_offset(),PT_DESCRIPTION,"canonical C matrix", PT_char1024, "D", get_y_offset(),PT_DESCRIPTION,"canonical D matrix", NULL)<1){ char msg[256]; sprintf(msg, "unable to publish properties in %s",__FILE__); throw msg; } memset(this,0,sizeof(ss_model)); } }
FloatVector2d View::world_to_screen (const FloatVector2d& pos) { return FloatVector2d (pos.x + get_x_offset (), pos.y + get_y_offset ()); }
FloatVector2d View::screen_to_world (const FloatVector2d& pos) { return FloatVector2d (pos.x - get_x_offset (), pos.y - get_y_offset ()); }
static void ppg_line_visualizer_draw (PpgVisualizer *visualizer) { PpgLineVisualizerPrivate *priv; PpgModelIter iter; Line *line; PpgColorIter color; cairo_t *cr; GValue value = { 0 }; gfloat height; gfloat width; gdouble x; gdouble y; gdouble begin; gdouble end; gdouble lower; gdouble upper; gdouble val = 0; gint i; g_return_if_fail(PPG_IS_LINE_VISUALIZER(visualizer)); priv = PPG_LINE_VISUALIZER(visualizer)->priv; clutter_cairo_texture_clear(CLUTTER_CAIRO_TEXTURE(priv->actor)); cr = clutter_cairo_texture_create(CLUTTER_CAIRO_TEXTURE(priv->actor)); g_object_get(visualizer, "begin", &begin, "end", &end, NULL); g_object_get(priv->actor, "width", &width, "height", &height, NULL); /* FIXME: */ lower = 0; upper = 200; ppg_color_iter_init(&color); cairo_set_line_width(cr, 1.0); for (i = 0; i < priv->lines->len; i++) { line = &g_array_index(priv->lines, Line, i); cairo_move_to(cr, 0, height); gdk_cairo_set_source_color(cr, &color.color); if (!ppg_model_get_iter_first(line->model, &iter)) { goto next; } do { ppg_model_get_value(line->model, &iter, line->key, &value); if (G_VALUE_HOLDS(&value, G_TYPE_DOUBLE)) { val = g_value_get_double(&value); } else if (G_VALUE_HOLDS(&value, G_TYPE_INT)) { val = g_value_get_int(&value); } else if (G_VALUE_HOLDS(&value, G_TYPE_UINT)) { val = g_value_get_uint(&value); } else { g_critical("HOLDS %s", g_type_name(value.g_type)); g_assert_not_reached(); } x = get_x_offset(begin, end, width, iter.time); y = get_y_offset(lower, upper, height, val); cairo_line_to(cr, x, y); g_value_unset(&value); } while (ppg_model_iter_next(line->model, &iter)); cairo_stroke(cr); next: ppg_color_iter_next(&color); } cairo_destroy(cr); }