/* === S Y N F I G ========================================================= */
/*! \file valuenode_blinecalctangent.cpp
-** \brief Template File
+** \brief Implementation of the "BLine Tangent" valuenode conversion.
**
** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007, 2008 Chris Moore
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
ValueNode_BLineCalcTangent::ValueNode_BLineCalcTangent(const ValueBase::Type &x):
LinkableValueNode(x)
{
- if(x!=ValueBase::TYPE_VECTOR)
- throw Exception::BadType(ValueBase::type_name(x));
+ if(x!=ValueBase::TYPE_ANGLE && x!=ValueBase::TYPE_REAL && x!=ValueBase::TYPE_VECTOR)
+ throw Exception::BadType(ValueBase::type_local_name(x));
ValueNode_BLine* value_node(new ValueNode_BLine());
set_link("bline",value_node);
LinkableValueNode*
ValueNode_BLineCalcTangent::create_new()const
{
- return new ValueNode_BLineCalcTangent(ValueBase::TYPE_VECTOR);
+ return new ValueNode_BLineCalcTangent(get_type());
}
ValueNode_BLineCalcTangent*
BLinePoint blinepoint0, blinepoint1;
if (!looped) size--;
- if (size < 1) return Vector();
+ if (size < 1)
+ switch (get_type())
+ {
+ case ValueBase::TYPE_ANGLE: return Angle();
+ case ValueBase::TYPE_REAL: return Real();
+ case ValueBase::TYPE_VECTOR: return Vector();
+ default: assert(0); return ValueBase();
+ }
if (loop)
{
amount = amount - int(amount);
blinepoint0.get_tangent2(), blinepoint1.get_tangent1());
etl::derivative< etl::hermite<Vector> > deriv(curve);
-#ifdef ETL_FIXED_DERIVATIVE
- return deriv(amount-from_vertex)*(0.5);
-#else
- return deriv(amount-from_vertex)*(-0.5);
-#endif
+ switch (get_type())
+ {
+ case ValueBase::TYPE_ANGLE: return deriv(amount-from_vertex).angle();
+ case ValueBase::TYPE_REAL: return deriv(amount-from_vertex).mag();
+ case ValueBase::TYPE_VECTOR: return deriv(amount-from_vertex);
+ default: assert(0); return ValueBase();
+ }
}
String
}
bool
-ValueNode_BLineCalcTangent::set_link_vfunc(int i,ValueNode::Handle x)
+ValueNode_BLineCalcTangent::set_link_vfunc(int i,ValueNode::Handle value)
{
assert(i>=0 && i<link_count());
+
switch(i)
{
- case 0:
- bline_=x;
- signal_child_changed()(i);signal_value_changed()();
- return true;
- case 1:
- loop_=x;
- signal_child_changed()(i);signal_value_changed()();
- return true;
- case 2:
- amount_=x;
- signal_child_changed()(i);signal_value_changed()();
- return true;
+ case 0: CHECK_TYPE_AND_SET_VALUE(bline_, ValueBase::TYPE_LIST);
+ case 1: CHECK_TYPE_AND_SET_VALUE(loop_, ValueBase::TYPE_BOOL);
+ case 2: CHECK_TYPE_AND_SET_VALUE(amount_, ValueBase::TYPE_REAL);
}
return false;
}
ValueNode_BLineCalcTangent::get_link_vfunc(int i)const
{
assert(i>=0 && i<link_count());
+
switch(i)
{
case 0: return bline_;
ValueNode_BLineCalcTangent::link_name(int i)const
{
assert(i>=0 && i<link_count());
+
switch(i)
{
case 0: return "bline";
ValueNode_BLineCalcTangent::link_local_name(int i)const
{
assert(i>=0 && i<link_count());
+
switch(i)
{
case 0: return _("BLine");
bool
ValueNode_BLineCalcTangent::check_type(ValueBase::Type type)
{
- return type==ValueBase::TYPE_VECTOR;
+ return (type==ValueBase::TYPE_ANGLE ||
+ type==ValueBase::TYPE_REAL ||
+ type==ValueBase::TYPE_VECTOR);
}