コード例 #1
0
bool
ValueNode_RadialComposite::set_link_vfunc(int i,ValueNode::Handle x)
{
	assert(i>=0 && i<link_count());

	if(PlaceholderValueNode::Handle::cast_dynamic(x))
	{
		components[i]=x;
		return true;
	}

	Type &type(get_type());
	if (type == type_vector)
	{
		if(i==0 && x->get_type()!=type_real)
			return false;
		if(i==1 && x->get_type()!=type_angle)
			return false;
		components[i]=x;
		return true;
	}
	else
	if (type == type_color)
	{
		if((i==0 || i==1 || i==3) && x->get_type()!=type_real)
			return false;
		if((i==2) && x->get_type()!=type_angle)
			return false;
		components[i]=x;
		return true;
	}

	return false;
}
コード例 #2
0
ValueNode_BLineRevTangent::ValueNode_BLineRevTangent(const ValueNode::Handle &x):
	LinkableValueNode(x->get_type())
{
	Vocab ret(get_children_vocab());
	set_children_vocab(ret);
	if(x->get_type()!=ValueBase::TYPE_BLINEPOINT)
		throw Exception::BadType(ValueBase::type_local_name(x->get_type()));

	set_link("reference",x);
	set_link("reverse",ValueNode_Const::create(bool(false)));
}
コード例 #3
0
ValueNode_Animated::Handle
ValueNode_Animated::create(ValueNode::Handle value_node, const Time& time)
{
	ValueNode_Animated::Handle ret(create(value_node->get_type()));
	ret->new_waypoint(time,value_node);
	return ret;
}
コード例 #4
0
ValueNode_Greyed::ValueNode_Greyed(const ValueNode::Handle &x):
	ValueNode_Reference(x->get_type())
{
	Vocab ret(get_children_vocab());
	set_children_vocab(ret);
	set_link("link",x);
}
コード例 #5
0
ValueNode_Switch::ValueNode_Switch(const ValueNode::Handle &x):
	LinkableValueNode(x->get_type())
{
	Vocab ret(get_children_vocab());
	set_children_vocab(ret);
	set_link("link_off",x);
	set_link("link_on",x);
	set_link("switch",ValueNode_Const::create(bool(false)));
}
コード例 #6
0
ファイル: canvastreestore.cpp プロジェクト: aaronaskew/synfig
ValueNode::Handle
CanvasTreeStore::expandable_bone_parent(ValueNode::Handle node)
{
	if ((!getenv("SYNFIG_DISABLE_EXPANDABLE_BONE_PARENTS")) &&
		node->get_type() == ValueBase::TYPE_VALUENODE_BONE &&
		(node->get_name() == "constant" || node->get_name() == "animated"))
		if (ValueNode::Handle bone_node = (*node)(canvas_interface()->get_time()).get(ValueNode_Bone::Handle()))
			return bone_node;
	return node;
}
コード例 #7
0
ValueNode_TimeLoop::ValueNode_TimeLoop(const ValueNode::Handle &x):
	LinkableValueNode(x->get_type())
{
	Vocab ret(get_children_vocab());
	set_children_vocab(ret);
	set_link("link", x);
	set_link("link_time",  ValueNode_Const::create(Time(0)));
	set_link("local_time", ValueNode_Const::create(Time(0)));
	set_link("duration",   ValueNode_Const::create(Time(1)));
}
コード例 #8
0
bool
ValueNode_DynamicList::set_link_vfunc(int i,ValueNode::Handle x)
{
	assert(i>=0);

	if((unsigned)i>=list.size())
		return false;
	if(x->get_type()!=*container_type)
		return false;
	list[i].value_node=x;
	return true;
}
コード例 #9
0
bool
ValueNode_StaticList::set_link_vfunc(int i,ValueNode::Handle x) // line 628
{
	assert(i>=0);

	if((unsigned)i>=list.size())
		return false;
	if(x->get_type()!=*container_type)
		return false;
	list[i]=x;
	return true;
}
コード例 #10
0
ValueNode_BoneInfluence::ValueNode_BoneInfluence(const ValueNode::Handle &x, Canvas::LooseHandle canvas):
	LinkableValueNode(x->get_type()),
	checked_inverse_(),
	has_inverse_()
{
	Type &type(x->get_type());
	if (type == type_vector || type == type_bline_point)
	{
		ValueNode_StaticList::Handle bone_weight_list(ValueNode_StaticList::create(type_bone_weight_pair, canvas));
		bone_weight_list->add(ValueNode_BoneWeightPair::create(BoneWeightPair(Bone(), 1), canvas));
		set_link("bone_weight_list",	bone_weight_list);
		set_link("link",				x);

		if (getenv("SYNFIG_DEBUG_SET_PARENT_CANVAS"))
			printf("%s:%d set parent canvas for bone influence to %lx\n", __FILE__, __LINE__, uintptr_t(canvas.get()));
		set_parent_canvas(canvas);
	}
	else
	{
		throw Exception::BadType(type.description.local_name);
	}
}
コード例 #11
0
ValueNode_BoneInfluence::ValueNode_BoneInfluence(const ValueNode::Handle &x, Canvas::LooseHandle canvas):
	LinkableValueNode(x->get_type())
{
	switch(x->get_type())
	{
	case ValueBase::TYPE_VECTOR:
	case ValueBase::TYPE_BLINEPOINT:
	//case ValueBase::TYPE_BLINE:
	{
		ValueNode_StaticList::Handle bone_weight_list(ValueNode_StaticList::create(ValueBase::TYPE_BONE_WEIGHT_PAIR, canvas));
		bone_weight_list->add(ValueNode_BoneWeightPair::create(BoneWeightPair(Bone(), 1), canvas));
		set_link("bone_weight_list",	bone_weight_list);
		set_link("link",				x);

		if (getenv("SYNFIG_DEBUG_SET_PARENT_CANVAS"))
			printf("%s:%d set parent canvas for bone influence to %lx\n", __FILE__, __LINE__, uintptr_t(canvas.get()));
		set_parent_canvas(canvas);

		break;
	}
	default:
		throw Exception::BadType(ValueBase::type_local_name(x->get_type()));
	}
}
コード例 #12
0
ファイル: valuenode_bone.cpp プロジェクト: jottoprimo/synfig
ValueNode_Bone::BoneSet
ValueNode_Bone::get_bones_referenced_by(ValueNode::Handle value_node, bool recursive)
{
	// printf("%s:%d rec = %d\n", __FILE__, __LINE__,recursive);
	BoneSet ret;
	if (!value_node)
	{
		printf("%s:%d failed?\n", __FILE__, __LINE__);
		assert(0);
		return ret;
	}

	// if it's a ValueNode_Const
	if (ValueNode_Const::Handle value_node_const = ValueNode_Const::Handle::cast_dynamic(value_node))
	{
		ValueBase value_node(value_node_const->get_value());
		if (value_node.get_type() == type_bone_valuenode)
			if (ValueNode_Bone::Handle bone = value_node.get(ValueNode_Bone::Handle()))
			{
				// do we want to check for bone references in other bone fields or just 'parent'?
				if (recursive)
				{
					// printf("%s:%d rec\n", __FILE__, __LINE__);
					ret = get_bones_referenced_by(bone, recursive);
					// ret = get_bones_referenced_by(bone->get_link("parent"), recursive);
				}
				if (!bone->is_root())
					ret.insert(bone);
			}
		return ret;
	}

	// if it's a ValueNode_Animated
	if (ValueNode_Animated::Handle value_node_animated = ValueNode_Animated::Handle::cast_dynamic(value_node))
	{
		// ValueNode_Animated::Handle ret = ValueNode_Animated::create(type_bone_object);
		ValueNode_Animated::WaypointList list(value_node_animated->waypoint_list());
		for (ValueNode_Animated::WaypointList::iterator iter = list.begin(); iter != list.end(); iter++)
		{
//			printf("%s:%d getting bones from waypoint\n", __FILE__, __LINE__);
			BoneSet ret2(get_bones_referenced_by(iter->get_value_node(), recursive));
			ret.insert(ret2.begin(), ret2.end());
//			printf("added %d bones from waypoint to get %d\n", int(ret2.size()), int(ret.size()));
		}
//		printf("returning %d bones\n", int(ret.size()));
		return ret;
	}

	// if it's a LinkableValueNode
	if (LinkableValueNode::Handle linkable_value_node = LinkableValueNode::Handle::cast_dynamic(value_node))
	{
		for (int i = 0; i < linkable_value_node->link_count(); i++)
		{
			BoneSet ret2(get_bones_referenced_by(linkable_value_node->get_link(i), recursive));
			ret.insert(ret2.begin(), ret2.end());
		}
		return ret;
	}

	if (PlaceholderValueNode::Handle linkable_value_node = PlaceholderValueNode::Handle::cast_dynamic(value_node))
	{
		// todo: while loading we might be setting up an ancestry loop by ignoring the placeholder valuenode here
		// can we check for loops in badly formatted .sifz files somehow?
		if (getenv("SYNFIG_DEBUG_PLACEHOLDER_VALUENODE"))
			printf("%s:%d found a placeholder - skipping loop check\n", __FILE__, __LINE__);
		return ret;
	}

	error("%s:%d BUG: bad type in valuenode '%s'", __FILE__, __LINE__, value_node->get_string().c_str());
	assert(0);
	return ret;
}
コード例 #13
0
ファイル: valuenode_composite.cpp プロジェクト: synfig/synfig
bool
ValueNode_Composite::set_link_vfunc(int i,ValueNode::Handle x)
{
    assert(i>=0 && i<link_count());

    if(PlaceholderValueNode::Handle::cast_dynamic(x))
    {
        components[i]=x;
        return true;
    }

    Type &type(get_type());
    if (type == type_vector)
    {
        if(x->get_type()==ValueBase(Real()).get_type() || PlaceholderValueNode::Handle::cast_dynamic(x))
        {
            components[i]=x;
            return true;
        }
    }
    else if (type == type_color)
    {
        if(x->get_type()==ValueBase(Real()).get_type() || PlaceholderValueNode::Handle::cast_dynamic(x))
        {
            components[i]=x;
            return true;
        }
    }
    else if (type == type_segment)
    {
        if(x->get_type()==ValueBase(Point()).get_type() || PlaceholderValueNode::Handle::cast_dynamic(x))
        {
            components[i]=x;
            return true;
        }
    }
    else if (type == type_bline_point)
    {
        if((i==0 || i==4 || i==5) && x->get_type()==ValueBase(Point()).get_type())
        {
            components[i]=x;
            return true;
        }
        if((i==1 || i==2) && x->get_type()==ValueBase(Real()).get_type())
        {
            components[i]=x;
            return true;
        }
        if((i==3 || i==6 || i==7) && x->get_type()==ValueBase(bool()).get_type())
        {
            components[i]=x;
            return true;
        }
    }
    else if (type == type_dash_item
             || type == type_width_point)
    {
        if((i==0 || i==1) && x->get_type()==ValueBase(Real()).get_type())
        {
            components[i]=x;
            return true;
        }
        if((i==2 || i==3) && x->get_type()==ValueBase(int()).get_type())
        {
            components[i]=x;
            return true;
        }
        if((i==4 || i==5) && x->get_type()==ValueBase(Real()).get_type())
        {
            if(ValueNode_Const::Handle::cast_dynamic(x))
            {
                if(i==4 && components[5])
                {
                    if(i==4 && (*x)(0).get(Real()) < (*components[5])(0).get(Real()))
                    {
                        components[i]=x;
                        return true;
                    }
                    else
                        return false;
                }
                if(i==5 && components[4])
                {
                    if((i==5 && (*x)(0).get(Real()) > (*components[4])(0).get(Real())))
                    {
                        components[i]=x;
                        return true;
                    }
                    else
                        return false;
                }
                components[i]=x;
                return true;
            }
            return false;
        }
    }
    else if (type == type_transformation)
    {
        if( PlaceholderValueNode::Handle::cast_dynamic(x)
                || (i == 0 && x->get_type()==ValueBase(Vector()).get_type())
                || (i == 1 && x->get_type()==ValueBase(Angle()).get_type())
                || (i == 2 && x->get_type()==ValueBase(Angle()).get_type())
                || (i == 3 && x->get_type()==ValueBase(Vector()).get_type())
          ) {
            components[i]=x;
            return true;
        }
    }
    else if (dynamic_cast<types_namespace::TypeWeightedValueBase*>(&type) != NULL)
    {
        types_namespace::TypeWeightedValueBase *tp =
            dynamic_cast<types_namespace::TypeWeightedValueBase*>(&type);
        if( PlaceholderValueNode::Handle::cast_dynamic(x)
                || (i == 0 && x->get_type()==ValueBase(Real()).get_type())
                || (i == 1 && x->get_type()==tp->get_contained_type())
          ) {
            components[i]=x;
            return true;
        }
    }
    else if (dynamic_cast<types_namespace::TypePairBase*>(&type) != NULL)
    {
        types_namespace::TypePairBase *tp =
            dynamic_cast<types_namespace::TypePairBase*>(&type);
        if( PlaceholderValueNode::Handle::cast_dynamic(x)
                || (i == 0 && x->get_type()==tp->get_first_type())
                || (i == 1 && x->get_type()==tp->get_second_type())
          ) {
            components[i]=x;
            return true;
        }
    }

    return false;
}