Use translated versions of the type names everywhere other than in the .sif(z) files.
[synfig.git] / synfig-core / trunk / src / synfig / valuenode_exp.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file valuenode_exp.cpp
3 **      \brief Implementation of the "Exponential" valuenode conversion.
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
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.
14 **
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.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "valuenode_exp.h"
33 #include "valuenode_const.h"
34 #include "general.h"
35
36 #endif
37
38 /* === U S I N G =========================================================== */
39
40 using namespace std;
41 using namespace etl;
42 using namespace synfig;
43
44 /* === M A C R O S ========================================================= */
45
46 /* === G L O B A L S ======================================================= */
47
48 /* === P R O C E D U R E S ================================================= */
49
50 /* === M E T H O D S ======================================================= */
51
52 ValueNode_Exp::ValueNode_Exp(const ValueBase &value):
53         LinkableValueNode(value.get_type())
54 {
55         switch(value.get_type())
56         {
57         case ValueBase::TYPE_REAL:
58                 set_link("exp",ValueNode_Const::create(Real(1)));
59                 set_link("scale",ValueNode_Const::create(value.get(Real())));
60                 break;
61         default:
62                 throw Exception::BadType(ValueBase::type_local_name(value.get_type()));
63         }
64
65         DCAST_HACK_ENABLE();
66 }
67
68 LinkableValueNode*
69 ValueNode_Exp::create_new()const
70 {
71         return new ValueNode_Exp(get_type());
72 }
73
74 ValueNode_Exp*
75 ValueNode_Exp::create(const ValueBase &x)
76 {
77         return new ValueNode_Exp(x);
78 }
79
80 ValueNode_Exp::~ValueNode_Exp()
81 {
82         unlink_all();
83 }
84
85 ValueBase
86 ValueNode_Exp::operator()(Time t)const
87 {
88         return (exp((*exp_)(t).get(Real())) *
89                         (*scale_)(t).get(Real()));
90 }
91
92 String
93 ValueNode_Exp::get_name()const
94 {
95         return "exp";
96 }
97
98 String
99 ValueNode_Exp::get_local_name()const
100 {
101         return _("Exponential");
102 }
103
104 bool
105 ValueNode_Exp::set_link_vfunc(int i,ValueNode::Handle x)
106 {
107         assert(i>=0 && i<link_count());
108
109         if(i==0)
110         {
111                 exp_=x;
112                 signal_child_changed()(i);signal_value_changed()();
113                 return true;
114         }
115         if(i==1)
116         {
117                 scale_=x;
118                 signal_child_changed()(i);signal_value_changed()();
119                 return true;
120         }
121         return false;
122 }
123
124 ValueNode::LooseHandle
125 ValueNode_Exp::get_link_vfunc(int i)const
126 {
127         assert(i>=0 && i<link_count());
128
129         if(i==0)
130                 return exp_;
131         if(i==1)
132                 return scale_;
133
134         return 0;
135 }
136
137 int
138 ValueNode_Exp::link_count()const
139 {
140         return 2;
141 }
142
143 String
144 ValueNode_Exp::link_name(int i)const
145 {
146         assert(i>=0 && i<link_count());
147
148         if(i==0)
149                 return "exp";
150         if(i==1)
151                 return "scale";
152         return String();
153 }
154
155 String
156 ValueNode_Exp::link_local_name(int i)const
157 {
158         assert(i>=0 && i<link_count());
159
160         if(i==0)
161                 return _("Exponent");
162         if(i==1)
163                 return _("Scale");
164         return String();
165 }
166
167 int
168 ValueNode_Exp::get_link_index_from_name(const String &name)const
169 {
170         if(name=="exp")
171                 return 0;
172         if(name=="scale")
173                 return 1;
174
175         throw Exception::BadLinkName(name);
176 }
177
178 bool
179 ValueNode_Exp::check_type(ValueBase::Type type)
180 {
181         return type==ValueBase::TYPE_REAL;
182 }