1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_gradientrotate.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 ======================================================= */
33 #include "valuenode_gradientrotate.h"
34 #include "valuenode_const.h"
40 /* === U S I N G =========================================================== */
44 using namespace synfig;
46 /* === M A C R O S ========================================================= */
48 /* === G L O B A L S ======================================================= */
50 /* === P R O C E D U R E S ================================================= */
52 /* === M E T H O D S ======================================================= */
54 synfig::ValueNode_GradientRotate::ValueNode_GradientRotate(const Gradient& x):
55 LinkableValueNode(synfig::ValueBase::TYPE_GRADIENT)
57 set_link("gradient",ValueNode_Const::create(x));
58 set_link("offset",ValueNode_Const::create(Real(0)));
63 ValueNode_GradientRotate::create_new()const
65 return new ValueNode_GradientRotate(Gradient());
68 ValueNode_GradientRotate*
69 ValueNode_GradientRotate::create(const ValueBase& x)
71 ValueBase::Type id(x.get_type());
72 if(id!=ValueBase::TYPE_GRADIENT)
75 throw runtime_error("synfig::ValueNode_GradientRotate:Bad type "+ValueBase::type_name(id));
78 ValueNode_GradientRotate* value_node=new ValueNode_GradientRotate(x.get(Gradient()));
80 assert(value_node->get_type()==id);
85 synfig::ValueNode_GradientRotate::~ValueNode_GradientRotate()
91 synfig::ValueNode_GradientRotate::set_gradient(ValueNode::Handle a)
93 if(a->get_type()!=ValueBase::TYPE_GRADIENT&& !PlaceholderValueNode::Handle::cast_dynamic(a))
102 synfig::ValueNode_GradientRotate::set_offset(ValueNode::Handle b)
104 if(b->get_type()!=ValueBase::TYPE_REAL&& !PlaceholderValueNode::Handle::cast_dynamic(b))
111 synfig::ValueNode_GradientRotate::operator()(Time t)const
114 gradient=(*ref_gradient)(t).get(gradient);
115 Real offset((*ref_offset)(t).get(Real()));
116 Gradient::iterator iter;
117 for(iter=gradient.begin();iter!=gradient.end();++iter)
124 ValueNode_GradientRotate::set_link_vfunc(int i,ValueNode::Handle x)
130 if(set_gradient(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
131 else { return false; }
133 if(set_offset(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
134 else { return false; }
140 ValueNode::LooseHandle
141 ValueNode_GradientRotate::get_link_vfunc(int i)const
155 ValueNode_GradientRotate::link_count()const
161 ValueNode_GradientRotate::link_local_name(int i)const
167 return _("Gradient");
176 ValueNode_GradientRotate::link_name(int i)const
185 default: return String();
190 ValueNode_GradientRotate::get_link_index_from_name(const String &name)const
196 throw Exception::BadLinkName(name);
200 ValueNode_GradientRotate::get_name()const
202 return "gradient_rotate";
206 ValueNode_GradientRotate::get_local_name()const
208 return _("Gradient Rotate");
212 ValueNode_GradientRotate::check_type(ValueBase::Type type)
214 return type==ValueBase::TYPE_GRADIENT;