1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_segcalcvertex.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "valuenode_segcalcvertex.h"
33 #include "valuenode_const.h"
34 #include "valuenode_composite.h"
36 #include "exception.h"
37 #include <ETL/hermite>
42 /* === U S I N G =========================================================== */
46 using namespace synfig;
48 /* === M A C R O S ========================================================= */
50 /* === G L O B A L S ======================================================= */
52 /* === P R O C E D U R E S ================================================= */
54 /* === M E T H O D S ======================================================= */
56 ValueNode_SegCalcVertex::ValueNode_SegCalcVertex(const ValueBase::Type &x):
59 if(x!=ValueBase::TYPE_VECTOR)
60 throw Exception::BadType(ValueBase::type_name(x));
62 set_link("segment",ValueNode_Const::create(ValueBase::TYPE_SEGMENT));
63 set_link("amount",ValueNode_Const::create(Real(0.5)));
66 ValueNode_SegCalcVertex*
67 ValueNode_SegCalcVertex::create(const ValueBase &x)
69 return new ValueNode_SegCalcVertex(x.get_type());
72 ValueNode_SegCalcVertex::~ValueNode_SegCalcVertex()
78 ValueNode_SegCalcVertex::operator()(Time t)const
80 Segment segment((*segment_)(t).get(Segment()));
82 etl::hermite<Vector> curve(segment.p1,segment.p2,segment.t1,segment.t2);
84 return curve((*amount_)(t).get(Real()));
89 ValueNode_SegCalcVertex::get_name()const
91 return "segcalcvertex";
95 ValueNode_SegCalcVertex::get_local_name()const
97 return _("Segment Vertex");
101 ValueNode_SegCalcVertex::check_type(ValueBase::Type type)
103 return type==ValueBase::TYPE_VECTOR;
107 ValueNode_SegCalcVertex::set_link_vfunc(int i,ValueNode::Handle x)
109 assert(i==0 || i==1);
113 signal_child_changed()(i);signal_value_changed()();
119 signal_child_changed()(i);signal_value_changed()();
125 ValueNode::LooseHandle
126 ValueNode_SegCalcVertex::get_link_vfunc(int i)const
128 assert(i==0 || i==1);
138 ValueNode_SegCalcVertex::link_count()const
144 ValueNode_SegCalcVertex::link_name(int i)const
146 assert(i==0 || i==1);
155 ValueNode_SegCalcVertex::link_local_name(int i)const
157 assert(i==0 || i==1);
166 ValueNode_SegCalcVertex::get_link_index_from_name(const String &name)const
173 throw Exception::BadLinkName(name);
177 ValueNode_SegCalcVertex::create_new()const
179 return new ValueNode_SegCalcVertex(ValueBase::TYPE_VECTOR);