1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_segcalcvertex.cpp
3 ** \brief Template File
5 ** $Id: valuenode_segcalcvertex.cpp,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $
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 segment_=ValueNode_Composite::create(ValueBase::TYPE_SEGMENT);
63 amount_=ValueNode_Const::create(Real(0.5));
67 ValueNode_SegCalcVertex*
68 ValueNode_SegCalcVertex::create(const ValueBase &x)
70 return new ValueNode_SegCalcVertex(x.get_type());
73 ValueNode_SegCalcVertex::~ValueNode_SegCalcVertex()
79 ValueNode_SegCalcVertex::operator()(Time t)const
81 Segment segment((*segment_)(t).get(Segment()));
83 etl::hermite<Vector> curve(segment.p1,segment.p2,segment.t1,segment.t2);
85 return curve((*amount_)(t).get(Real()));
90 ValueNode_SegCalcVertex::get_name()const
92 return "segcalcvertex";
96 ValueNode_SegCalcVertex::get_local_name()const
98 return _("SegCalcVertex");
102 ValueNode_SegCalcVertex::check_type(ValueBase::Type type)
104 return type==ValueBase::TYPE_VECTOR;
108 ValueNode_SegCalcVertex::set_link_vfunc(int i,ValueNode::Handle x)
110 assert(i==0 || i==1);
114 signal_child_changed()(i);signal_value_changed()();
120 signal_child_changed()(i);signal_value_changed()();
126 ValueNode::LooseHandle
127 ValueNode_SegCalcVertex::get_link_vfunc(int i)const
129 assert(i==0 || i==1);
139 ValueNode_SegCalcVertex::link_count()const
145 ValueNode_SegCalcVertex::link_name(int i)const
147 assert(i==0 || i==1);
156 ValueNode_SegCalcVertex::link_local_name(int i)const
158 assert(i==0 || i==1);
167 ValueNode_SegCalcVertex::get_link_index_from_name(const String &name)const
174 throw Exception::BadLinkName(name);
178 ValueNode_SegCalcVertex::create_new()const
180 return new ValueNode_SegCalcVertex(ValueBase::TYPE_VECTOR);