Simplified version for reverse manipulation Scale convert types ducks
authorCarlos Lopez <carlos@pcnuevo.(none)>
Mon, 6 Jul 2009 14:02:03 +0000 (16:02 +0200)
committerCarlos Lopez <carlos@pcnuevo.(none)>
Mon, 13 Jul 2009 18:17:02 +0000 (20:17 +0200)
synfig-core/trunk/src/synfig/valuenode_scale.cpp
synfig-core/trunk/src/synfig/valuenode_scale.h
synfig-studio/trunk/src/gtkmm/canvasview.cpp
synfig-studio/trunk/src/synfigapp/instance.cpp

index a0bba53..25b3822 100644 (file)
@@ -141,6 +141,21 @@ synfig::ValueNode_Scale::operator()(Time t)const
        return ValueBase();
 }
 
+synfig::ValueBase
+synfig::ValueNode_Scale::operator()(Time t, const synfig::Point &target_value)const
+{
+       Real scalar_value((*scalar)(t).get(Real()));
+       if(scalar_value==0)
+               return (*value_node)(t).get(value_node->get_type());
+       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;
+}
+
 
 bool
 ValueNode_Scale::set_link_vfunc(int i,ValueNode::Handle value)
index bb1ccd0..a11f6e0 100644 (file)
@@ -64,6 +64,9 @@ public:
 
        virtual ValueBase operator()(Time t)const;
 
+       //! Returns the modified Link to match the target value at time t
+       virtual ValueBase operator()(Time t, const synfig::Point &target_value) const;
+
        virtual String get_name()const;
 
        virtual String get_local_name()const;
index 4a555a8..50789a9 100644 (file)
@@ -2887,6 +2887,12 @@ CanvasView::on_duck_changed(const synfig::Point &value,const synfigapp::ValueDes
                }
        }
 
+       if (ValueNode_Scale::Handle scale_value_node = ValueNode_Scale::Handle::cast_dynamic(value_desc.get_value_node()))
+       {
+               int link_index(scale_value_node->get_link_index_from_name("link"));
+               return canvas_interface()->change_value(synfigapp::ValueDesc(scale_value_node,link_index), scale_value_node(t, value));
+       }
+
        switch(value_desc.get_value_type())
        {
        case ValueBase::TYPE_REAL:
index 020d337..c3c542b 100644 (file)
@@ -42,6 +42,7 @@
 #include <synfig/valuenode_blinecalctangent.h>
 #include <synfig/valuenode_blinecalcvertex.h>
 #include <synfig/valuenode_blinecalcwidth.h>
+#include <synfig/valuenode_scale.h>
 #include <map>
 
 #include "general.h"
@@ -74,6 +75,7 @@ synfigapp::is_editable(synfig::ValueNode::Handle value_node)
                || ValueNode_BLineCalcVertex::Handle::cast_dynamic(value_node)
                || ValueNode_BLineCalcTangent::Handle::cast_dynamic(value_node)
                || ValueNode_BLineCalcWidth::Handle::cast_dynamic(value_node)
+               || ValueNode_Scale::Handle::cast_dynamic(value_node)
        )
                return true;
        return false;