1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_linear.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_linear.h"
33 #include "valuenode_const.h"
38 /* === U S I N G =========================================================== */
42 using namespace synfig;
44 /* === M A C R O S ========================================================= */
46 /* === G L O B A L S ======================================================= */
48 /* === P R O C E D U R E S ================================================= */
50 /* === M E T H O D S ======================================================= */
52 ValueNode_Linear::ValueNode_Linear(const ValueBase::Type &x):
57 case ValueBase::TYPE_REAL:
58 set_link("slope",ValueNode_Const::create(Real(1)));
59 set_link("offset",ValueNode_Const::create(Real(0)));
61 case ValueBase::TYPE_TIME:
62 set_link("slope",ValueNode_Const::create(Time(1)));
63 set_link("offset",ValueNode_Const::create(Time(0)));
65 case ValueBase::TYPE_VECTOR:
66 set_link("slope",ValueNode_Const::create(Vector(1.0,1.0)));
67 set_link("offset",ValueNode_Const::create(Vector(0.0,0.0)));
69 case ValueBase::TYPE_ANGLE:
70 set_link("slope",ValueNode_Const::create(Angle::deg(90)));
71 set_link("offset",ValueNode_Const::create(Angle::deg(0)));
74 throw Exception::BadType(ValueBase::type_name(x));
81 ValueNode_Linear::create(const ValueBase &x)
83 return new ValueNode_Linear(x.get_type());
86 ValueNode_Linear::~ValueNode_Linear()
92 ValueNode_Linear::operator()(Time t)const
96 case ValueBase::TYPE_TIME:
97 return (*m_)(t).get(Time())*t+(*b_)(t).get(Time());
98 case ValueBase::TYPE_REAL:
99 return (*m_)(t).get(Real())*t+(*b_)(t).get(Real());
100 case ValueBase::TYPE_VECTOR:
101 return (*m_)(t).get(Vector())*t+(*b_)(t).get(Vector());
102 case ValueBase::TYPE_ANGLE:
103 return (*m_)(t).get(Angle())*t+(*b_)(t).get(Angle());
113 ValueNode_Linear::get_name()const
119 ValueNode_Linear::get_local_name()const
125 ValueNode_Linear::check_type(ValueBase::Type type)
127 return type==ValueBase::TYPE_REAL
128 || type==ValueBase::TYPE_VECTOR
129 || type==ValueBase::TYPE_TIME
130 || type==ValueBase::TYPE_ANGLE;
134 ValueNode_Linear::set_link_vfunc(int i,ValueNode::Handle x)
136 assert(i==0 || i==1);
140 signal_child_changed()(i);signal_value_changed()();
146 signal_child_changed()(i);signal_value_changed()();
152 ValueNode::LooseHandle
153 ValueNode_Linear::get_link_vfunc(int i)const
155 assert(i==0 || i==1);
165 ValueNode_Linear::link_count()const
171 ValueNode_Linear::link_name(int i)const
173 assert(i==0 || i==1);
182 ValueNode_Linear::link_local_name(int i)const
184 assert(i==0 || i==1);
188 case ValueBase::TYPE_REAL:
189 case ValueBase::TYPE_TIME:
190 case ValueBase::TYPE_ANGLE:
201 ValueNode_Linear::get_link_index_from_name(const String &name)const
208 throw Exception::BadLinkName(name);
212 ValueNode_Linear::create_new()const
214 return new ValueNode_Linear(get_type());