1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_sine.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_sine.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_Sine::ValueNode_Sine(const ValueBase &value):
53 LinkableValueNode(value.get_type())
55 switch(value.get_type())
57 case ValueBase::TYPE_REAL:
58 set_link("angle",ValueNode_Const::create(Angle::deg(90)));
59 set_link("amp",ValueNode_Const::create(value.get(Real())));
62 throw Exception::BadType(ValueBase::type_name(value.get_type()));
69 ValueNode_Sine::create_new()const
71 return new ValueNode_Sine(get_type());
75 ValueNode_Sine::create(const ValueBase &x)
77 return new ValueNode_Sine(x);
80 ValueNode_Sine::~ValueNode_Sine()
86 ValueNode_Sine::operator()(Time t)const
90 (*angle_)(t).get(Angle())
91 ).get() * (*amp_)(t).get(Real())
97 ValueNode_Sine::get_name()const
103 ValueNode_Sine::get_local_name()const
109 ValueNode_Sine::check_type(ValueBase::Type type)
111 return type==ValueBase::TYPE_REAL;
115 ValueNode_Sine::set_link_vfunc(int i,ValueNode::Handle x)
117 assert(i==0 || i==1);
121 signal_child_changed()(i);signal_value_changed()();
127 signal_child_changed()(i);signal_value_changed()();
133 ValueNode::LooseHandle
134 ValueNode_Sine::get_link_vfunc(int i)const
136 assert(i==0 || i==1);
146 ValueNode_Sine::link_count()const
152 ValueNode_Sine::link_name(int i)const
154 assert(i==0 || i==1);
163 ValueNode_Sine::link_local_name(int i)const
165 assert(i==0 || i==1);
169 return _("Amplitude");
174 ValueNode_Sine::get_link_index_from_name(const String &name)const
181 throw Exception::BadLinkName(name);