X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fvaluenode_scale.cpp;h=b272d7d6b994418dc91c6a8746830e1a7b30b3c6;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=0afab2097a62a71ab9af43b21a2d3d1c880ddc7d;hpb=6f8559ddcb82636029d07776700d51b0e0c35e92;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/valuenode_scale.cpp b/synfig-core/trunk/src/synfig/valuenode_scale.cpp index 0afab20..b272d7d 100644 --- a/synfig-core/trunk/src/synfig/valuenode_scale.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_scale.cpp @@ -6,7 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** Copyright (c) 2007 Chris Moore +** 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 @@ -112,6 +112,9 @@ synfig::ValueNode_Scale::~ValueNode_Scale() synfig::ValueBase synfig::ValueNode_Scale::operator()(Time t)const { + if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS")) + printf("%s:%d operator()\n", __FILE__, __LINE__); + if(!value_node || !scalar) throw runtime_error(strprintf("ValueNode_Scale: %s",_("One or both of my parameters aren't set!"))); else if(get_type()==ValueBase::TYPE_ANGLE) @@ -138,6 +141,50 @@ synfig::ValueNode_Scale::operator()(Time t)const return ValueBase(); } +synfig::ValueBase +synfig::ValueNode_Scale::get_inverse(Time t, const synfig::Vector &target_value) const +{ + Real scalar_value((*scalar)(t).get(Real())); + if(scalar_value==0) + throw runtime_error(strprintf("ValueNode_Scale: %s",_("Attempting to get the inverse of a non invertible Valuenode"))); + else + { + switch (get_type()) + { + case ValueBase::TYPE_REAL: + return target_value.mag() / scalar_value; + case ValueBase::TYPE_ANGLE: + return Angle::tan(target_value[1] / scalar_value ,target_value[0] / scalar_value); + default: + return target_value / scalar_value; + } + } + return ValueBase(); +} + +synfig::ValueBase +synfig::ValueNode_Scale::get_inverse(Time t, const synfig::Angle &target_value) const +{ + Real scalar_value((*scalar)(t).get(Real())); + if(scalar_value==0) + throw runtime_error(strprintf("ValueNode_Scale: %s",_("Attempting to get the inverse of a non invertible Valuenode"))); + else + { + switch (get_type()) + { + default: + return (*value_node)(t).get(Angle()) + target_value / scalar_value; + } + } + return ValueBase(); +} + +bool +synfig::ValueNode_Scale::is_invertible(Time t) const +{ + Real scalar_value((*scalar)(t).get(Real())); + return (!scalar_value==0); +} bool ValueNode_Scale::set_link_vfunc(int i,ValueNode::Handle value)