Made all the assert() lines which check the valuenode sub-parameter index range the...
[synfig.git] / synfig-core / trunk / src / synfig / valuenode_duplicate.cpp
index 4c6ce2a..7a9cc3c 100644 (file)
@@ -55,18 +55,19 @@ ValueNode_Duplicate::ValueNode_Duplicate(const ValueBase::Type &x):
 {
 }
 
-ValueNode_Duplicate::ValueNode_Duplicate(const ValueNode::Handle &x):
-       LinkableValueNode(x->get_type())
+ValueNode_Duplicate::ValueNode_Duplicate(const ValueBase &x):
+       LinkableValueNode(x.get_type())
 {
-       set_link("from", ValueNode_Const::create(int(0)));
-       set_link("to",   ValueNode_Const::create(int(3)));
-       set_link("step", ValueNode_Const::create(int(1)));
+       set_link("from", ValueNode_Const::create(Real(1.0)));
+       set_link("to",   ValueNode_Const::create(x.get(Real())));
+       set_link("step", ValueNode_Const::create(Real(1.0)));
+       index = 1.0;
 }
 
 ValueNode_Duplicate*
 ValueNode_Duplicate::create(const ValueBase &x)
 {
-       return new ValueNode_Duplicate(ValueNode_Const::create(x));
+       return new ValueNode_Duplicate(x);
 }
 
 LinkableValueNode*
@@ -83,7 +84,8 @@ ValueNode_Duplicate::~ValueNode_Duplicate()
 bool
 ValueNode_Duplicate::set_link_vfunc(int i,ValueNode::Handle x)
 {
-       assert(i >= 0 && i < link_count());
+       assert(i>=0 && i<link_count());
+
        switch(i)
        {
        case 0:  from_ = x; break;
@@ -100,7 +102,8 @@ ValueNode_Duplicate::set_link_vfunc(int i,ValueNode::Handle x)
 ValueNode::LooseHandle
 ValueNode_Duplicate::get_link_vfunc(int i)const
 {
-       assert(i >= 0 && i < link_count());
+       assert(i>=0 && i<link_count());
+
        if(i==0) return from_;
        if(i==1) return to_;
        if(i==2) return step_;
@@ -117,7 +120,8 @@ ValueNode_Duplicate::link_count()const
 String
 ValueNode_Duplicate::link_local_name(int i)const
 {
-       assert(i >= 0 && i < link_count());
+       assert(i>=0 && i<link_count());
+
        if(i==0) return _("From");
        if(i==1) return _("To");
        if(i==2) return _("Step");
@@ -127,7 +131,8 @@ ValueNode_Duplicate::link_local_name(int i)const
 String
 ValueNode_Duplicate::link_name(int i)const
 {
-       assert(i >= 0 && i < link_count());
+       assert(i>=0 && i<link_count());
+
        if(i==0) return "from";
        if(i==1) return "to";
        if(i==2) return "step";
@@ -147,16 +152,16 @@ ValueNode_Duplicate::get_link_index_from_name(const String &name)const
 void
 ValueNode_Duplicate::reset_index(Time t)const
 {
-       int from = (*from_)(t).get(int());
+       Real from = (*from_)(t).get(Real());
        index = from;
 }
 
 bool
 ValueNode_Duplicate::step(Time t)const
 {
-       int from = (*from_)(t).get(int());
-       int to   = (*to_  )(t).get(int());
-       int step = (*step_)(t).get(int());
+       Real from = (*from_)(t).get(Real());
+       Real to   = (*to_  )(t).get(Real());
+       Real step = (*step_)(t).get(Real());
 
        if (step == 0) return false;
 
@@ -177,9 +182,9 @@ ValueNode_Duplicate::step(Time t)const
 int
 ValueNode_Duplicate::count_steps(Time t)const
 {
-       int from = (*from_)(t).get(int());
-       int to   = (*to_  )(t).get(int());
-       int step = (*step_)(t).get(int());
+       Real from = (*from_)(t).get(Real());
+       Real to   = (*to_  )(t).get(Real());
+       Real step = (*step_)(t).get(Real());
 
        if (step == 0) return 1;
 
@@ -207,5 +212,6 @@ ValueNode_Duplicate::get_local_name()const
 bool
 ValueNode_Duplicate::check_type(ValueBase::Type type)
 {
-       return type==ValueBase::TYPE_INTEGER;
+       // never offer this as a choice.  it's used automatically by the 'Duplicate' layer.
+       return false;
 }