1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_vectorx.cpp
3 ** \brief Implementation of the "Vector X" 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_vectorx.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_VectorX::ValueNode_VectorX(const ValueBase &value):
54 LinkableValueNode(value.get_type())
56 Vocab ret(get_children_vocab());
57 set_children_vocab(ret);
58 switch(value.get_type())
60 case ValueBase::TYPE_REAL:
61 set_link("vector",ValueNode_Const::create(Vector(value.get(Real()), 0)));
64 throw Exception::BadType(ValueBase::type_local_name(value.get_type()));
69 ValueNode_VectorX::create_new()const
71 return new ValueNode_VectorX(get_type());
75 ValueNode_VectorX::create(const ValueBase &x)
77 return new ValueNode_VectorX(x);
80 ValueNode_VectorX::~ValueNode_VectorX()
86 ValueNode_VectorX::operator()(Time t)const
88 if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS"))
89 printf("%s:%d operator()\n", __FILE__, __LINE__);
91 return (*vector_)(t).get(Vector())[0];
96 ValueNode_VectorX::set_link_vfunc(int i,ValueNode::Handle value)
98 assert(i>=0 && i<link_count());
102 case 0: CHECK_TYPE_AND_SET_VALUE(vector_, ValueBase::TYPE_VECTOR);
107 ValueNode::LooseHandle
108 ValueNode_VectorX::get_link_vfunc(int i)const
110 assert(i>=0 && i<link_count());
118 ValueNode_VectorX::get_name()const
124 ValueNode_VectorX::get_local_name()const
126 return _("Vector X");
130 ValueNode_VectorX::check_type(ValueBase::Type type)
132 return type==ValueBase::TYPE_REAL;
135 LinkableValueNode::Vocab
136 ValueNode_VectorX::get_children_vocab_vfunc()const
138 if(children_vocab.size())
139 return children_vocab;
141 LinkableValueNode::Vocab ret;
143 ret.push_back(ParamDesc(ValueBase(),"vector")
144 .set_local_name(_("Vector"))
145 .set_description(_("The vector where the X coordinate is extracted from"))