1 /* === S I N F G =========================================================== */
2 /*! \file valuenode_radialcomposite.cpp
3 ** \brief Template File
5 ** $Id: valuenode_radialcomposite.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 ======================================================= */
31 #include "valuenode_radialcomposite.h"
32 #include "valuenode_const.h"
38 /* === U S I N G =========================================================== */
42 using namespace sinfg;
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 sinfg::ValueNode_RadialComposite::ValueNode_RadialComposite(const ValueBase &value):
53 LinkableValueNode(value.get_type())
57 case ValueBase::TYPE_VECTOR:
59 Vector vect(value.get(Vector()));
60 set_link("r",ValueNode_Const::create(vect.mag()));
61 set_link("t",ValueNode_Const::create(Angle(Angle::tan(vect[1],vect[0]))));
64 case ValueBase::TYPE_COLOR:
65 set_link("y",ValueNode_Const::create(value.get(Color()).get_y()));
66 set_link("s",ValueNode_Const::create(value.get(Color()).get_s()));
67 set_link("h",ValueNode_Const::create(value.get(Color()).get_hue()));
68 set_link("a",ValueNode_Const::create(value.get(Color()).get_a()));
72 throw Exception::BadType(ValueBase::type_name(get_type()));
76 ValueNode_RadialComposite::~ValueNode_RadialComposite()
81 ValueNode_RadialComposite*
82 ValueNode_RadialComposite::create(const ValueBase &value)
84 return new ValueNode_RadialComposite(value);
88 ValueNode_RadialComposite::create_new()const
90 return new ValueNode_RadialComposite(ValueBase(get_type()));
94 sinfg::ValueNode_RadialComposite::operator()(Time t)const
98 case ValueBase::TYPE_VECTOR:
102 assert(components[0] && components[1]);
103 mag=(*components[0])(t).get(mag);
104 angle=(*components[1])(t).get(angle);
105 return Vector(Angle::cos(angle).get()*mag,Angle::sin(angle).get()*mag);
107 case ValueBase::TYPE_COLOR:
109 assert(components[0] && components[1] && components[2] && components[3]);
111 (*components[0])(t).get(Real()),
112 (*components[1])(t).get(Real()),
113 (*components[2])(t).get(Angle()),
114 (*components[3])(t).get(Real())
118 sinfg::error(string("ValueNode_RadialComposite::operator():")+_("Bad type for radialcomposite"));
119 assert(components[0]);
120 return (*components[0])(t);
125 ValueNode_RadialComposite::link_count()const
129 case ValueBase::TYPE_VECTOR:
131 case ValueBase::TYPE_COLOR:
134 sinfg::warning(string("ValueNode_RadialComposite::component_count():")+_("Bad type for radialcomposite"));
140 ValueNode_RadialComposite::set_link_vfunc(int i,ValueNode::Handle x)
145 if(PlaceholderValueNode::Handle::cast_dynamic(x))
153 case ValueBase::TYPE_VECTOR:
155 if(i==0 && x->get_type()!=ValueBase::TYPE_REAL)
157 if(i==1 && x->get_type()!=ValueBase::TYPE_ANGLE)
163 case ValueBase::TYPE_COLOR:
165 if((i==0 || i==1 || i==3) && x->get_type()!=ValueBase::TYPE_REAL)
167 if((i==2) && x->get_type()!=ValueBase::TYPE_ANGLE)
180 ValueNode::LooseHandle
181 ValueNode_RadialComposite::get_link_vfunc(int i)const
184 return components[i];
188 ValueNode_RadialComposite::link_local_name(int i)const
193 case ValueBase::TYPE_VECTOR:
200 case ValueBase::TYPE_COLOR:
204 return _("Saturation");
214 return etl::strprintf(_("C%d"),i+1);
219 ValueNode_RadialComposite::link_name(int i)const
222 return strprintf("c%d",i);
226 ValueNode_RadialComposite::get_link_index_from_name(const String &name)const
229 throw Exception::BadLinkName(name);
236 case ValueBase::TYPE_COLOR:
245 case ValueBase::TYPE_VECTOR:
254 throw Exception::BadLinkName(name);
258 ValueNode_RadialComposite::get_name()const
260 return "radial_composite";
264 ValueNode_RadialComposite::get_local_name()const
266 return _("RadialComposite");
270 ValueNode_RadialComposite::check_type(ValueBase::Type type)
273 type==ValueBase::TYPE_VECTOR ||
274 type==ValueBase::TYPE_COLOR;