ValueNode_BoneWeightPair::ValueNode_BoneWeightPair(const ValueBase &value, Canvas::LooseHandle canvas):
	LinkableValueNode(value.get_type())
{
	switch(value.get_type())
	{
	case ValueBase::TYPE_BONE_WEIGHT_PAIR:
	{
		BoneWeightPair bone_weight_pair(value.get(BoneWeightPair()));
		ValueBase bone(bone_weight_pair.get_bone());
		ValueNode_Bone::Handle bone_value_node;
		bone_value_node = ValueNode_Bone::create(bone, canvas);
		set_link("bone",ValueNode_Const::create(bone_value_node, canvas));
		set_link("weight",ValueNode_Const::create(Real(bone_weight_pair.get_weight())));

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

		ValueNode_Bone::show_bone_map(canvas, __FILE__, __LINE__, "after making new boneweightpair");

		break;
	}
	default:
		throw Exception::BadType(ValueBase::type_local_name(value.get_type()));
	}
}
Exemplo n.º 2
0
void
ValueNode_Bone::show_bone_map(Canvas::LooseHandle canvas, const char *file, int line, String text, Time t)
{
	if (!getenv("SYNFIG_DEBUG_BONE_MAP")) return;

	BoneMap bone_map(canvas_map[canvas]);

	set<ValueNode_Bone::LooseHandle, compare_bones> bone_set;
	for (ValueNode_Bone::BoneMap::iterator iter = bone_map.begin(); iter != bone_map.end(); iter++)
		bone_set.insert(iter->second);

	printf("\n  %s:%d (canvas %lx) %s we now have %d bones (%d unreachable):\n", file, line, uintptr_t(canvas.get()), text.c_str(), int(bone_map.size()), int(bone_map.size() - bone_set.size()));

	for (set<ValueNode_Bone::LooseHandle>::iterator iter = bone_set.begin(); iter != bone_set.end(); iter++)
	{
		ValueNode_Bone::LooseHandle bone(*iter);
		GUID guid(bone->get_guid());
//		printf("%s:%d loop 1 get_node_parent_node\n", __FILE__, __LINE__);
		ValueNode_Bone::LooseHandle parent(GET_NODE_PARENT_NODE(bone,t));
		String id;
		if (bone->is_exported()) id = String(" ") + bone->get_id();
//		printf("%s : %s (%d)\n",           		GET_GUID_CSTR(guid), GET_NODE_BONE_CSTR(bone,t), bone->rcount());
		printf("    %-20s : parent %-20s (%d refs, %d rrefs)%s\n",
			   GET_NODE_DESC_CSTR(bone,t),
			   GET_NODE_DESC_CSTR(parent,t),
			   bone->count(), bone->rcount(),
			   id.c_str());
	}
	printf("\n");
}
Exemplo n.º 3
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);
	}
}
ValueNode_DynamicList::ValueNode_DynamicList(Type &container_type, Type &type, Canvas::LooseHandle canvas):
	LinkableValueNode(type),
	container_type(&container_type),
	loop_(false)
{
	if (getenv("SYNFIG_DEBUG_SET_PARENT_CANVAS"))
		printf("%s:%d set parent canvas for dynamic_list %lx to %lx\n", __FILE__, __LINE__, uintptr_t(this), uintptr_t(canvas.get()));
	set_parent_canvas(canvas);
}
Exemplo n.º 5
0
synfig::ValueNode_Composite::ValueNode_Composite(const ValueBase &value, Canvas::LooseHandle canvas):
    LinkableValueNode(value.get_type())
{
    Vocab ret(get_children_vocab());
    set_children_vocab(ret);
    Type &type(get_type());
    if (type == type_vector)
    {
        set_link("x",ValueNode_Const::create(value.get(Vector())[0]));
        set_link("y",ValueNode_Const::create(value.get(Vector())[1]));
    }
    else if (type == type_color)
    {
        set_link("r",ValueNode_Const::create(value.get(Color()).get_r()));
        set_link("g",ValueNode_Const::create(value.get(Color()).get_g()));
        set_link("b",ValueNode_Const::create(value.get(Color()).get_b()));
        set_link("a",ValueNode_Const::create(value.get(Color()).get_a()));
    }
    else if (type == type_segment)
    {
        set_link("p1",ValueNode_Const::create(value.get(Segment()).p1));
        set_link("t1",ValueNode_Const::create(value.get(Segment()).t1));
        set_link("p2",ValueNode_Const::create(value.get(Segment()).p2));
        set_link("t2",ValueNode_Const::create(value.get(Segment()).t2));
    }
    else if (type == type_bline_point)
    {
        BLinePoint bline_point(value.get(BLinePoint()));
        set_link("point",ValueNode_Const::create(bline_point.get_vertex()));
        set_link("width",ValueNode_Const::create(bline_point.get_width()));
        set_link("origin",ValueNode_Const::create(bline_point.get_origin()));
        set_link("split",ValueNode_Const::create(bline_point.get_split_tangent_both()));
        set_link("split_radius",ValueNode_Const::create(bline_point.get_split_tangent_radius()));
        set_link("split_angle",ValueNode_Const::create(bline_point.get_split_tangent_angle()));
        set_link("t1",ValueNode_RadialComposite::create(bline_point.get_tangent1()));
        set_link("t2",ValueNode_RadialComposite::create(bline_point.get_tangent2()));
    }
    else if (type == type_width_point)
    {
        WidthPoint wpoint(value.get(WidthPoint()));
        set_link("position",ValueNode_Const::create(wpoint.get_position()));
        set_link("width",ValueNode_Const::create(wpoint.get_width()));
        set_link("side_before",ValueNode_Const::create(wpoint.get_side_type_before()));
        set_link("side_after",ValueNode_Const::create(wpoint.get_side_type_after()));
        ValueNode_Const::Handle value_node;
        value_node=ValueNode_Const::Handle::cast_dynamic(ValueNode_Const::create(wpoint.get_lower_bound()));
        if(value_node)
        {
            value_node->set_static(true);
            set_link("lower_bound",value_node);
        }
        value_node=ValueNode_Const::Handle::cast_dynamic(ValueNode_Const::create(wpoint.get_upper_bound()));
        if(value_node)
        {
            value_node->set_static(true);
            set_link("upper_bound",value_node);
        }
    }
    else if (type == type_dash_item)
    {
        DashItem ditem(value.get(DashItem()));
        set_link("offset",ValueNode_Const::create(ditem.get_offset()));
        set_link("length",ValueNode_Const::create(ditem.get_length()));
        set_link("side_before",ValueNode_Const::create(ditem.get_side_type_before()));
        set_link("side_after",ValueNode_Const::create(ditem.get_side_type_after()));
    }
    else if (type == type_transformation)
    {
        Transformation transformation(value.get(Transformation()));
        set_link("offset",ValueNode_Const::create(transformation.offset));
        set_link("angle",ValueNode_Const::create(transformation.angle));
        set_link("skew_angle",ValueNode_Const::create(transformation.skew_angle));
        set_link("scale",ValueNode_Const::create(transformation.scale));
    }
    else if (dynamic_cast<types_namespace::TypeWeightedValueBase*>(&type) != NULL)
    {
        types_namespace::TypeWeightedValueBase *t =
            dynamic_cast<types_namespace::TypeWeightedValueBase*>(&type);
        set_link("weight",ValueNode_Const::create(t->extract_weight(value)));
        set_link("value",ValueNode_Const::create(t->extract_value(value)));
    }
    else if (dynamic_cast<types_namespace::TypePairBase*>(&type) != NULL)
    {
        types_namespace::TypePairBase *t =
            dynamic_cast<types_namespace::TypePairBase*>(&type);
        set_link("first",ValueNode_Const::create(t->extract_first(value)));
        set_link("second",ValueNode_Const::create(t->extract_second(value)));
    }
    else
    {
        assert(0);
        throw Exception::BadType(get_type().description.local_name);
    }

    if (getenv("SYNFIG_DEBUG_SET_PARENT_CANVAS"))
        printf("%s:%d set parent canvas for composite %lx to %lx\n", __FILE__, __LINE__, uintptr_t(this), uintptr_t(canvas.get()));
    set_parent_canvas(canvas);
}
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()));
	}
}
Exemplo n.º 7
0
ValueNode_StaticList::ValueNode_StaticList(Type &container_type, Canvas::LooseHandle canvas): // line 548
	LinkableValueNode(type_list),
	container_type(&container_type),
	loop_(false)
{
	if (getenv("SYNFIG_DEBUG_STATICLIST_CONSTRUCTORS"))
		printf("%s:%d ValueNode_StaticList::ValueNode_StaticList() construct %lx\n", __FILE__, __LINE__, uintptr_t(this));

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