void
synfig::BLinePoint::reverse()
{
- if(split_tangent_)
- {
- std::swap(tangent_[0],tangent_[1]);
- tangent_[0]=-tangent_[0];
- tangent_[1]=-tangent_[1];
- }
- else
- {
- tangent_[0]=-tangent_[0];
- tangent_[1]=-tangent_[1];
- }
+ std::swap(tangent_[0],tangent_[1]);
+ tangent_[0]=-tangent_[0];
+ tangent_[1]=-tangent_[1];
+}
+
+void
+synfig::BLinePoint::normalize(int i)
+{
+ //i is the number of the tangent to modify
+ //other tangent is (1-i)
+ split_tangent_=(!link_radius_ && !link_theta_);
+ if (link_radius_ && link_theta_)
+ tangent_[i]=tangent_[1-i];
+ else if (link_radius_)
+ tangent_[i]=tangent_[i].norm()*tangent_[1-i].mag();
+ else if (link_theta_)
+ tangent_[i]=tangent_[1-i].norm()*tangent_[i].mag();
+
}
float width_;
float origin_;
bool split_tangent_;
+ bool link_radius_;
+ bool link_theta_;
public:
vertex_(Point(0,0)),
width_(0.01),
origin_(0.0),
- split_tangent_(false)
+ split_tangent_(false),
+ link_radius_(true),
+ link_theta_(true)
{ tangent_[0] = Point(0,0); tangent_[1] = Point(0,0); }
const Point& get_vertex()const { return vertex_; }
const Vector& get_tangent1()const { return tangent_[0]; }
- const Vector& get_tangent2()const { return split_tangent_?tangent_[1]:tangent_[0]; }
+ const Vector& get_tangent2()const { return tangent_[1]; }
void set_tangent(const Vector& x) { tangent_[0]=tangent_[1]=x; }
- void set_tangent1(const Vector& x) { tangent_[0]=x; }
- void set_tangent2(const Vector& x) { tangent_[1]=x; }
+ void set_tangent1(const Vector& x) { tangent_[0]=x; normalize(1);}
+ void set_tangent2(const Vector& x) { tangent_[1]=x; normalize(0);}
const float& get_width()const { return width_; }
const bool& get_split_tangent_flag()const { return split_tangent_; }
- void set_split_tangent_flag(bool x=true) { split_tangent_=x; }
+ void set_split_tangent_flag(bool x=true) { link_radius_=link_theta_=!x; normalize();}
+
+ const bool& get_link_radius_flag()const { return link_radius_; }
+ void set_link_radius_flag(bool x=true) { link_radius_=x; normalize();}
+
+ const bool& get_link_theta_flag()const { return link_theta_; }
+ void set_link_theta_flag(bool x=true) { link_theta_=x; normalize();}
+
+ //normalize tangents, i.e. make sure their values correspond to the linkage
+ void normalize(int i=0);
void reverse();
if (version == "0.1" || version == "0.2" || version == "0.3")
{
handle<LinkableValueNode> scale_value_node=LinkableValueNode::create("scale",type);
- scale_value_node->set_link(scale_value_node->get_link_index_from_name("link"), value_node);
- scale_value_node->set_link(scale_value_node->get_link_index_from_name("scalar"), ValueNode_Const::create(Real(0.5)));
+ scale_value_node->set_link("link", value_node);
+ scale_value_node->set_link("scalar", ValueNode_Const::create(Real(0.5)));
value_node = scale_value_node;
}
}
case ValueBase::TYPE_BLINEPOINT:
{
BLinePoint bline_point(value);
- set_link(0,ValueNode_Const::create(bline_point.get_vertex()));
- set_link(1,ValueNode_Const::create(bline_point.get_width()));
- set_link(2,ValueNode_Const::create(bline_point.get_origin()));
- set_link(3,ValueNode_Const::create(bline_point.get_split_tangent_flag()));
- set_link(4,ValueNode_RadialComposite::create(bline_point.get_tangent1()));
- set_link(5,ValueNode_RadialComposite::create(bline_point.get_tangent2()));
+ set_link("point",ValueNode_Const::create(bline_point.get_vertex()));
+ set_link("width",ValueNode_Const::create(bline_point.get_width()));
+ set_link("origin",ValueNode_Const::create(bline_point.get_origin()));
+ set_link("split",ValueNode_Const::create(bline_point.get_split_tangent_flag()));
+ set_link("t1",ValueNode_RadialComposite::create(bline_point.get_tangent1()));
+ set_link("t2",ValueNode_RadialComposite::create(bline_point.get_tangent2()));
break;
}
default:
if (ValueNode_BLineCalcVertex::Handle bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(value_desc.get_value_node()))
{
- ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link(bline_vertex->get_link_index_from_name("bline")));
+ ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link("bline"));
Real radius = 0.0;
if (((*(bline_vertex->get_link("loop")))(get_time()).get(bool()))){
Real amount_old((*(bline_vertex->get_link("amount")))(get_time()).get(Real()));
param_list2=canvas_interface->generate_param_list(
synfigapp::ValueDesc(
ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node())
- ,0
+ ,ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node())
+ ->get_link_index_from_name("point")
)
);
param_list2.add("origin",location);
if(extend_start_join_different)
LinkableValueNode::Handle::cast_dynamic(source.value_node)->
- set_link(0,finish_duck_value_desc.get_value_node());
+ set_link("point",finish_duck_value_desc.get_value_node());
else if(extend_start_join_same)
LinkableValueNode::Handle::cast_dynamic(source.value_node)->
- set_link(0,synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(start_duck_value_node_bline->
+ set_link("point",synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(start_duck_value_node_bline->
list[target_offset+finish_duck_index].value_node),0).get_value_node());
return result;
}
if(extend_finish_join_different)
LinkableValueNode::Handle::cast_dynamic(source.value_node)->
- set_link(0,start_duck_value_desc.get_value_node());
+ set_link("point",start_duck_value_desc.get_value_node());
else if(extend_finish_join_same)
LinkableValueNode::Handle::cast_dynamic(source.value_node)->
- set_link(0,synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(finish_duck_value_node_bline->
+ set_link("point",synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(finish_duck_value_node_bline->
list[target_offset+start_duck_index].value_node),0).get_value_node());
return result;
}
if (join_start_no_extend)
LinkableValueNode::Handle::cast_dynamic(value_node->list.front().value_node)->
- set_link(0,start_duck_value_desc.get_value_node());
+ set_link("point",start_duck_value_desc.get_value_node());
if (join_finish_no_extend)
LinkableValueNode::Handle::cast_dynamic(value_node->list.back().value_node)->
- set_link(0,finish_duck_value_desc.get_value_node());
+ set_link("point",finish_duck_value_desc.get_value_node());
if(get_auto_export_flag())
if (!get_canvas_interface()->add_value_node(value_node,get_id()))
continue;
}
// \todo if next isn't split, don't we want to copy its 'Tangent 1' instead?
- value_node->set_link(5,value_node_next->get_link(5)); // Tangent 2
- value_node->set_link(3,ValueNode_Const::create(true)); // Split Tangents
+ value_node->set_link("t2",value_node_next->get_link("t2"));
+ value_node->set_link("split",ValueNode_Const::create(true));
// get_canvas_interface()->auto_export(value_node);
printf("exporting\n");
value_desc_list.push_back(
synfigapp::ValueDesc(
ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node())
- ,0
+ ,ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node())
+ ->get_link_index_from_name("point")
)
);
}
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
- action->set_param("value_desc",ValueDesc(value_node,3));
+ action->set_param("value_desc",ValueDesc(value_node,value_node->get_link_index_from_name("split")));
action->set_param("time",time);
action->set_param("new_value",synfig::ValueBase(false));
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
- action->set_param("value_desc",ValueDesc(value_node,3));
+ action->set_param("value_desc",ValueDesc(value_node,value_node->get_link_index_from_name("split")));
action->set_param("time",time);
action->set_param("new_value",synfig::ValueBase(true));
// tangent.
if( value_desc.parent_is_value_node() &&
value_desc.get_parent_value_node()->get_type()==ValueBase::TYPE_BLINEPOINT &&
- (value_desc.get_index()==4 || value_desc.get_index()==5) &&
+ (value_desc.get_name()=="t1" || value_desc.get_name()=="t2") &&
+ //(value_desc.get_index()==4 || value_desc.get_index()==5) &&
(*value_desc.get_parent_value_node())(time).get(BLinePoint()).get_split_tangent_flag()==false)
{
{
Vector t2((*parent_value_node->get_link("t2"))(time));
}
- if (value_desc.get_index()==4) {
+ //if (value_desc.get_index()==4) {
+ if (value_desc.get_name()=="t1") {
ValueNode_Composite::Handle parent_value_node;
parent_value_node=parent_value_node.cast_dynamic(value_desc.get_parent_value_node());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("new_value",value);
- action->set_param("value_desc",ValueDesc(parent_value_node,5));
+ action->set_param("value_desc",ValueDesc(parent_value_node, parent_value_node->get_link_index_from_name("t2")));
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
case ValueBase::TYPE_VECTOR:
{
Angle old_angle = (*(ValueNode_RadialComposite::Handle::cast_dynamic(
- value_desc.get_value_node())->get_link_vfunc(1)))(time).get(Angle());
+ value_desc.get_value_node())->get_link("theta")))(time).get(Angle());
Vector vect(value.get(Vector()));
components[0]=vect.mag();
Angle change = Angle(Angle::tan(vect[1],vect[0])) - old_angle;
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
- action->set_param("new_value",(*parent_value_node->get_link(4))(time));
- action->set_param("value_desc",ValueDesc(parent_value_node,5));
+ action->set_param("new_value",(*parent_value_node->get_link("t1"))(time));
+ action->set_param("value_desc",ValueDesc(parent_value_node,parent_value_node->get_link_index_from_name("t2")));
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("new_value",average);
- action->set_param("value_desc",ValueDesc(parent_value_node,4));
+ action->set_param("value_desc",ValueDesc(parent_value_node,parent_value_node->get_link_index_from_name("t1")));
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("new_value",average);
- action->set_param("value_desc",ValueDesc(parent_value_node,5));
+ action->set_param("value_desc",ValueDesc(parent_value_node,parent_value_node->get_link_index_from_name("t2")));
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
synfig::ValueNode::Handle get_parent_value_node()const { assert(parent_is_value_node()); return parent_value_node; }
int get_index()const { assert(parent_is_linkable_value_node()); return index; }
+ synfig::String get_name()const { assert(parent_is_linkable_value_node()); return (synfig::LinkableValueNode::Handle::cast_reinterpret(parent_value_node))->link_name(index); }
synfig::Time get_waypoint_time()const { assert(parent_is_waypoint()); return waypoint_time; }
const synfig::String& get_value_node_id()const { assert(parent_is_canvas()); return name; }