1 /* === S I N F G =========================================================== */
2 /*! \file valuenode_gradientrotate.cpp
3 ** \brief Template File
5 ** $Id: valuenode_gradientrotate.cpp,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
32 #include "valuenode_gradientrotate.h"
33 #include "valuenode_const.h"
39 /* === U S I N G =========================================================== */
43 using namespace sinfg;
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 sinfg::ValueNode_GradientRotate::ValueNode_GradientRotate():
54 LinkableValueNode(sinfg::ValueBase::TYPE_GRADIENT)
56 set_link("gradient",ValueNode_Const::create(Gradient()));
57 set_link("offset",ValueNode_Const::create(Real(0)));
62 ValueNode_GradientRotate::create_new()const
64 return new ValueNode_GradientRotate();
67 ValueNode_GradientRotate*
68 ValueNode_GradientRotate::create(const ValueBase& x)
70 ValueBase::Type id(x.get_type());
71 if(id!=ValueBase::TYPE_GRADIENT)
74 throw runtime_error("sinfg::ValueNode_GradientRotate:Bad type "+ValueBase::type_name(id));
77 ValueNode_GradientRotate* value_node=new ValueNode_GradientRotate();
78 value_node->set_gradient(ValueNode_Const::create(x.get(Gradient())));
80 assert(value_node->get_type()==id);
85 sinfg::ValueNode_GradientRotate::~ValueNode_GradientRotate()
91 sinfg::ValueNode_GradientRotate::set_gradient(ValueNode::Handle a)
93 if(a->get_type()!=ValueBase::TYPE_GRADIENT&& !PlaceholderValueNode::Handle::cast_dynamic(a))
102 sinfg::ValueNode_GradientRotate::set_offset(ValueNode::Handle b)
104 if(b->get_type()!=ValueBase::TYPE_REAL&& !PlaceholderValueNode::Handle::cast_dynamic(b))
111 sinfg::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");
175 ValueNode_GradientRotate::link_name(int i)const
189 ValueNode_GradientRotate::get_link_index_from_name(const String &name)const
195 throw Exception::BadLinkName(name);
199 ValueNode_GradientRotate::get_name()const
201 return "gradient_rotate";
205 ValueNode_GradientRotate::get_local_name()const
207 return _("Gradient Rotate");
211 ValueNode_GradientRotate::check_type(ValueBase::Type type)
213 return type==ValueBase::TYPE_GRADIENT;