1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_vectorlength.cpp
3 ** \brief Implementation of the "Vector Length" valuenode conversion.
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007, 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include "valuenode_vectorlength.h"
34 #include "valuenode_const.h"
39 /* === U S I N G =========================================================== */
43 using namespace synfig;
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 ValueNode_VectorLength::ValueNode_VectorLength(const ValueBase &value):
54 LinkableValueNode(value.get_type())
56 switch(value.get_type())
58 case ValueBase::TYPE_REAL:
59 set_link("vector",ValueNode_Const::create(Vector(value.get(Real()), 0)));
62 throw Exception::BadType(ValueBase::type_local_name(value.get_type()));
69 ValueNode_VectorLength::create_new()const
71 return new ValueNode_VectorLength(get_type());
74 ValueNode_VectorLength*
75 ValueNode_VectorLength::create(const ValueBase &x)
77 return new ValueNode_VectorLength(x);
80 ValueNode_VectorLength::~ValueNode_VectorLength()
86 ValueNode_VectorLength::operator()(Time t)const
88 return (*vector_)(t).get(Vector()).mag();
93 ValueNode_VectorLength::set_link_vfunc(int i,ValueNode::Handle value)
95 assert(i>=0 && i<link_count());
99 case 0: CHECK_TYPE_AND_SET_VALUE(vector_, ValueBase::TYPE_VECTOR);
104 ValueNode::LooseHandle
105 ValueNode_VectorLength::get_link_vfunc(int i)const
107 assert(i>=0 && i<link_count());
115 ValueNode_VectorLength::link_count()const
121 ValueNode_VectorLength::link_local_name(int i)const
123 assert(i>=0 && i<link_count());
131 ValueNode_VectorLength::link_name(int i)const
133 assert(i>=0 && i<link_count());
141 ValueNode_VectorLength::get_link_index_from_name(const String &name)const
146 throw Exception::BadLinkName(name);
150 ValueNode_VectorLength::get_name()const
152 return "vectorlength";
156 ValueNode_VectorLength::get_local_name()const
158 return _("Vector Length");
162 ValueNode_VectorLength::check_type(ValueBase::Type type)
164 return type==ValueBase::TYPE_REAL;