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
9 ** Copyright (c) 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include "valuenode_exp.h"
34 #include "valuenode_const.h"
39 /* === U S I N G =========================================================== */
43 using namespace synfig;
45 /* === M A C R O S ========================================================= */
47 /* === G L O B A L S ======================================================= */
49 /* === P R O C E D U R E S ================================================= */
51 /* === M E T H O D S ======================================================= */
53 ValueNode_Exp::ValueNode_Exp(const ValueBase &value):
54 LinkableValueNode(value.get_type())
56 switch(value.get_type())
58 case ValueBase::TYPE_REAL:
59 set_link("exp",ValueNode_Const::create(Real(0)));
60 set_link("scale",ValueNode_Const::create(value.get(Real())));
63 throw Exception::BadType(ValueBase::type_local_name(value.get_type()));
70 ValueNode_Exp::create_new()const
72 return new ValueNode_Exp(get_type());
76 ValueNode_Exp::create(const ValueBase &x)
78 return new ValueNode_Exp(x);
81 ValueNode_Exp::~ValueNode_Exp()
87 ValueNode_Exp::operator()(Time t)const
89 if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS"))
90 printf("%s:%d operator()\n", __FILE__, __LINE__);
92 return (exp((*exp_)(t).get(Real())) *
93 (*scale_)(t).get(Real()));
97 ValueNode_Exp::get_name()const
103 ValueNode_Exp::get_local_name()const
105 return _("Exponential");
109 ValueNode_Exp::set_link_vfunc(int i,ValueNode::Handle value)
111 assert(i>=0 && i<link_count());
115 case 0: CHECK_TYPE_AND_SET_VALUE(exp_, ValueBase::TYPE_REAL);
116 case 1: CHECK_TYPE_AND_SET_VALUE(scale_, ValueBase::TYPE_REAL);
121 ValueNode::LooseHandle
122 ValueNode_Exp::get_link_vfunc(int i)const
124 assert(i>=0 && i<link_count());
135 ValueNode_Exp::link_count()const
141 ValueNode_Exp::link_name(int i)const
143 assert(i>=0 && i<link_count());
153 ValueNode_Exp::link_local_name(int i)const
155 assert(i>=0 && i<link_count());
158 return _("Exponent");
165 ValueNode_Exp::get_link_index_from_name(const String &name)const
172 throw Exception::BadLinkName(name);
176 ValueNode_Exp::check_type(ValueBase::Type type)
178 return type==ValueBase::TYPE_REAL;