1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_exp.cpp
3 ** \brief Implementation of the "Exponential" valuenode conversion.
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_exp.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_Exp::ValueNode_Exp(const ValueBase &value):
53 LinkableValueNode(value.get_type())
55 switch(value.get_type())
57 case ValueBase::TYPE_REAL:
58 set_link("exp",ValueNode_Const::create(Real(1)));
59 set_link("scale",ValueNode_Const::create(value.get(Real())));
62 throw Exception::BadType(ValueBase::type_local_name(value.get_type()));
69 ValueNode_Exp::create_new()const
71 return new ValueNode_Exp(get_type());
75 ValueNode_Exp::create(const ValueBase &x)
77 return new ValueNode_Exp(x);
80 ValueNode_Exp::~ValueNode_Exp()
86 ValueNode_Exp::operator()(Time t)const
88 return (exp((*exp_)(t).get(Real())) *
89 (*scale_)(t).get(Real()));
93 ValueNode_Exp::get_name()const
99 ValueNode_Exp::get_local_name()const
101 return _("Exponential");
105 ValueNode_Exp::set_link_vfunc(int i,ValueNode::Handle value)
107 assert(i>=0 && i<link_count());
111 case 0: CHECK_TYPE_AND_SET_VALUE(exp_, ValueBase::TYPE_REAL);
112 case 1: CHECK_TYPE_AND_SET_VALUE(scale_, ValueBase::TYPE_REAL);
117 ValueNode::LooseHandle
118 ValueNode_Exp::get_link_vfunc(int i)const
120 assert(i>=0 && i<link_count());
131 ValueNode_Exp::link_count()const
137 ValueNode_Exp::link_name(int i)const
139 assert(i>=0 && i<link_count());
149 ValueNode_Exp::link_local_name(int i)const
151 assert(i>=0 && i<link_count());
154 return _("Exponent");
161 ValueNode_Exp::get_link_index_from_name(const String &name)const
168 throw Exception::BadLinkName(name);
172 ValueNode_Exp::check_type(ValueBase::Type type)
174 return type==ValueBase::TYPE_REAL;