const synfig::Time get_time_offset_from_vdesc(const synfigapp::ValueDesc &v) { #ifdef ADJUST_WAYPOINTS_FOR_TIME_OFFSET if(getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") || v.get_value_type() != synfig::type_canvas) return synfig::Time::zero(); synfig::Canvas::Handle canvasparam = v.get_value().get(Canvas::Handle()); if(!canvasparam) return synfig::Time::zero(); if (!v.parent_is_layer()) return synfig::Time::zero(); synfig::Layer::Handle layer = v.get_layer(); if (etl::handle<Layer_PasteCanvas>::cast_dynamic(layer)) return synfig::Time::zero(); return layer->get_param("time_offset").get(Time()); #else // ADJUST_WAYPOINTS_FOR_TIME_OFFSET return synfig::Time::zero(); #endif }
synfig::Real get_value(int chan, synfig::Real time, synfig::Real tolerance) { std::map<synfig::Real,synfig::Real>::iterator iter; // First check to see if we have a value // that is "close enough" to the time // we are looking for iter=channels[chan].values.lower_bound(time); if(iter!=channels[chan].values.end() && iter->first-time<=tolerance) return -iter->second; // Since that didn't work, we now need // to go ahead and figure out what the // actual value is at that time. ValueBase value(value_desc.get_value(time)); Type &type(value.get_type()); if (type == type_real) channels[0].values[time]=value.get(Real()); else if (type == type_time) channels[0].values[time]=value.get(Time()); else if (type == type_integer) channels[0].values[time]=value.get(int()); else if (type == type_bool) channels[0].values[time]=value.get(bool()); else if (type == type_angle) channels[0].values[time]=Angle::rad(value.get(Angle())).get(); else if (type == type_color) { channels[0].values[time]=value.get(Color()).get_r(); channels[1].values[time]=value.get(Color()).get_g(); channels[2].values[time]=value.get(Color()).get_b(); channels[3].values[time]=value.get(Color()).get_a(); } else if (type == type_vector) { channels[0].values[time]=value.get(Vector())[0]; channels[1].values[time]=value.get(Vector())[1]; } else if (type == type_bline_point) { channels[0].values[time]=value.get(BLinePoint()).get_vertex()[0]; channels[1].values[time]=value.get(BLinePoint()).get_vertex()[1]; channels[2].values[time]=value.get(BLinePoint()).get_width(); channels[3].values[time]=value.get(BLinePoint()).get_origin(); channels[4].values[time]=value.get(BLinePoint()).get_split_tangent_both(); channels[5].values[time]=value.get(BLinePoint()).get_tangent1()[0]; channels[6].values[time]=value.get(BLinePoint()).get_tangent1()[1]; channels[7].values[time]=value.get(BLinePoint()).get_tangent2()[0]; channels[8].values[time]=value.get(BLinePoint()).get_tangent2()[1]; channels[9].values[time]=value.get(BLinePoint()).get_split_tangent_radius(); channels[10].values[time]=value.get(BLinePoint()).get_split_tangent_angle(); } else if (type == type_width_point) { channels[0].values[time]=value.get(WidthPoint()).get_position(); channels[1].values[time]=value.get(WidthPoint()).get_width(); } else { return 0; } return -channels[chan].values[time]; }