Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-core / trunk / src / synfig / valuenode_scale.cpp
index 0afab20..b272d7d 100644 (file)
@@ -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)