void Duck::set_sub_trans_point(const synfig::Point &x, const synfig::Time &time) { set_sub_trans_point(x); if(get_type() == Duck::TYPE_VERTEX || get_type() == Duck::TYPE_POSITION || get_type() == Duck::TYPE_WIDTHPOINT_POSITION) { ValueNode_BLineCalcVertex::Handle bline_vertex; ValueNode_Composite::Handle composite; if ((bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(get_value_desc().get_value_node())) || ((composite = ValueNode_Composite::Handle::cast_dynamic(get_value_desc().get_value_node())) && composite->get_type() == ValueBase::TYPE_BLINEPOINT && (bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point"))))) { synfig::Point closest_point = get_point(); synfig::Real radius = 0.0; ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link("bline")); synfig::find_closest_point( (*bline)(time), get_point(), radius, bline->get_loop(), &closest_point); set_point(closest_point); } ValueNode_Composite::Handle wpoint_composite; ValueNode_WPList::Handle wplist; wpoint_composite=ValueNode_Composite::Handle::cast_dynamic(get_value_desc().get_value_node()); if(wpoint_composite && wpoint_composite->get_type() == ValueBase::TYPE_WIDTHPOINT) if(get_value_desc().parent_is_value_node()) { wplist=ValueNode_WPList::Handle::cast_dynamic(get_value_desc().get_parent_value_node()); if(wplist) { ValueNode_BLine::Handle bline(ValueNode_BLine::Handle::cast_dynamic(wplist->get_bline())); synfig::Point closest_point = get_point(); synfig::Real radius = 0.0; synfig::find_closest_point( (*bline)(time), get_point(), radius, bline->get_loop(), &closest_point); set_point(closest_point); } } } }
bool Action::BLinePointTangentSplitAngle::set_param(const synfig::String& name, const Action::Param ¶m) { if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE) { value_node=value_node.cast_dynamic(param.get_value_node()); if(value_node && value_node->get_type()==ValueBase::TYPE_BLINEPOINT) return true; ValueNode_RadialComposite::Handle radial_value_node; radial_value_node=ValueNode_RadialComposite::Handle::cast_dynamic(param.get_value_node()); if(radial_value_node && radial_value_node->get_type()==ValueBase::TYPE_VECTOR) // value_node is radial composite and vector (user rigth click on a tangent) { ValueNode_Composite::Handle blinepoint; std::set<Node*>::iterator iter; // now check if the parent of value_node is a blinepoint type for(iter=radial_value_node->parent_set.begin(); iter!=radial_value_node->parent_set.end(); ++iter) { blinepoint=ValueNode_Composite::Handle::cast_dynamic(*iter); if(blinepoint && blinepoint->get_type()==ValueBase::TYPE_BLINEPOINT) { value_node=blinepoint; return true; } } return false; } return false; } if(name=="time" && param.get_type()==Param::TYPE_TIME) { time=param.get_time(); return true; } return Action::CanvasSpecific::set_param(name,param); }
void Duck::set_sub_trans_point(const synfig::Point &x, const synfig::Time &time) { if (get_type() == Duck::TYPE_TANGENT || get_type() == Duck::TYPE_ANGLE) { Angle old_angle = get_point().angle(); set_point((x-get_sub_trans_origin())/get_scalar()); Angle change = get_point().angle() - old_angle; while (change < Angle::deg(-180)) change += Angle::deg(360); while (change > Angle::deg(180)) change -= Angle::deg(360); //int old_halves = round_to_int(Angle::deg(rotations).get()/180); rotations += change; //int new_halves = round_to_int(Angle::deg(rotations).get()/180); /*if (old_halves != new_halves && (new_halves > 1 || new_halves < -1 || old_halves > 1 || old_halves < -1)) synfig::info("rotation: %.2f turns", new_halves/2.0)*/; } else if(get_type() == Duck::TYPE_VERTEX || get_type() == Duck::TYPE_POSITION || get_type() == Duck::TYPE_WIDTHPOINT_POSITION) { set_point((x-get_sub_trans_origin())/get_scalar()); ValueNode_BLineCalcVertex::Handle bline_vertex; ValueNode_Composite::Handle composite; if ((bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(get_value_desc().get_value_node())) || ((composite = ValueNode_Composite::Handle::cast_dynamic(get_value_desc().get_value_node())) && composite->get_type() == ValueBase::TYPE_BLINEPOINT && (bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point"))))) { synfig::Point closest_point = get_point(); synfig::Real radius = 0.0; ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link("bline")); synfig::find_closest_point( (*bline)(time), get_point(), radius, bline->get_loop(), &closest_point); set_point(closest_point); } ValueNode_Composite::Handle wpoint_composite; ValueNode_WPList::Handle wplist; wpoint_composite=ValueNode_Composite::Handle::cast_dynamic(get_value_desc().get_value_node()); if(wpoint_composite && wpoint_composite->get_type() == ValueBase::TYPE_WIDTHPOINT) if(get_value_desc().parent_is_value_node()) { wplist=ValueNode_WPList::Handle::cast_dynamic(get_value_desc().get_parent_value_node()); if(wplist) { ValueNode_BLine::Handle bline(ValueNode_BLine::Handle::cast_dynamic(wplist->get_bline())); synfig::Point closest_point = get_point(); synfig::Real radius = 0.0; synfig::find_closest_point( (*bline)(time), get_point(), radius, bline->get_loop(), &closest_point); set_point(closest_point); } } } else set_point((x-get_sub_trans_origin())/get_scalar()); }