1 /* === S I N F G =========================================================== */
2 /*! \file valuenode_linear.cpp
3 ** \brief Template File
5 ** $Id: valuenode_linear.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_linear.h"
32 #include "valuenode_const.h"
37 /* === U S I N G =========================================================== */
41 using namespace sinfg;
43 /* === M A C R O S ========================================================= */
45 /* === G L O B A L S ======================================================= */
47 /* === P R O C E D U R E S ================================================= */
49 /* === M E T H O D S ======================================================= */
51 ValueNode_Linear::ValueNode_Linear(const ValueBase::Type &x):
56 case ValueBase::TYPE_REAL:
57 set_link("slope",ValueNode_Const::create(Real(1)));
58 set_link("offset",ValueNode_Const::create(Real(0)));
60 case ValueBase::TYPE_TIME:
61 set_link("slope",ValueNode_Const::create(Time(1)));
62 set_link("offset",ValueNode_Const::create(Time(0)));
64 case ValueBase::TYPE_VECTOR:
65 set_link("slope",ValueNode_Const::create(Vector(1.0,1.0)));
66 set_link("offset",ValueNode_Const::create(Vector(0.0,0.0)));
68 case ValueBase::TYPE_ANGLE:
69 set_link("slope",ValueNode_Const::create(Angle::deg(90)));
70 set_link("offset",ValueNode_Const::create(Angle::deg(0)));
73 throw Exception::BadType(ValueBase::type_name(x));
80 ValueNode_Linear::create(const ValueBase &x)
82 return new ValueNode_Linear(x.get_type());
85 ValueNode_Linear::~ValueNode_Linear()
91 ValueNode_Linear::operator()(Time t)const
95 case ValueBase::TYPE_TIME:
96 return (*m_)(t).get(Time())*t+(*b_)(t).get(Time());
97 case ValueBase::TYPE_REAL:
98 return (*m_)(t).get(Real())*t+(*b_)(t).get(Real());
99 case ValueBase::TYPE_VECTOR:
100 return (*m_)(t).get(Vector())*t+(*b_)(t).get(Vector());
101 case ValueBase::TYPE_ANGLE:
102 return (*m_)(t).get(Angle())*t+(*b_)(t).get(Angle());
112 ValueNode_Linear::get_name()const
118 ValueNode_Linear::get_local_name()const
124 ValueNode_Linear::check_type(ValueBase::Type type)
126 return type==ValueBase::TYPE_REAL
127 || type==ValueBase::TYPE_VECTOR
128 || type==ValueBase::TYPE_TIME
129 || type==ValueBase::TYPE_ANGLE;
133 ValueNode_Linear::set_link_vfunc(int i,ValueNode::Handle x)
135 assert(i==0 || i==1);
139 signal_child_changed()(i);signal_value_changed()();
145 signal_child_changed()(i);signal_value_changed()();
151 ValueNode::LooseHandle
152 ValueNode_Linear::get_link_vfunc(int i)const
154 assert(i==0 || i==1);
164 ValueNode_Linear::link_count()const
170 ValueNode_Linear::link_name(int i)const
172 assert(i==0 || i==1);
181 ValueNode_Linear::link_local_name(int i)const
183 assert(i==0 || i==1);
187 case ValueBase::TYPE_REAL:
188 case ValueBase::TYPE_TIME:
189 case ValueBase::TYPE_ANGLE:
200 ValueNode_Linear::get_link_index_from_name(const String &name)const
207 throw Exception::BadLinkName(name);
211 ValueNode_Linear::create_new()const
213 return new ValueNode_Linear(get_type());