コード例 #1
0
ファイル: valuedescconnect.cpp プロジェクト: BakaMANIA/synfig
bool
Action::ValueDescConnect::is_candidate(const ParamList &x)
{
    if(candidate_check(get_param_vocab(),x))
    {
        // don't show the option of connecting to an existing Index parameter of the Duplicate layer
        if(x.count("dest"))
        {
            ValueDesc value_desc=x.find("dest")->second.get_value_desc();

            if (value_desc.parent_is_layer() &&
                    value_desc.get_layer()->get_name() == "duplicate" &&
                    value_desc.get_param_name() == "index")
                return false;
        }

        if(x.count("src"))
        {
            ValueDesc value_desc=x.find("dest")->second.get_value_desc();
            ValueNode::Handle value_node=x.find("src")->second.get_value_node();
            if(value_desc.get_value_type()==value_node->get_type())
                return true;
        }
        return true;
    }
    return false;
}
コード例 #2
0
bool
Action::candidate_check(const ParamVocab& param_vocab, const ParamList& param_list)
{
	ParamVocab::const_iterator iter;

	for(iter=param_vocab.begin();iter!=param_vocab.end();++iter)
	{
		int n(param_list.count(iter->get_name()));

//		if(n && !iter->get_mutual_exclusion().empty() && param_list.count(iter->get_mutual_exclusion()))
//			return false;

		if(!n && !iter->get_mutual_exclusion().empty() && param_list.count(iter->get_mutual_exclusion()))
			continue;

		if(iter->get_user_supplied() || iter->get_optional())
			continue;

		if(n==0)
			return false;
		if(n==1 && iter->get_requires_multiple())
			return false;
		if(n>1 && !iter->get_supports_multiple())
			return false;

		if(iter->get_type()!=param_list.find(iter->get_name())->second.get_type())
			return false;
	}
	return true;
}
コード例 #3
0
bool
Action::ValueDescConnect::is_candidate(const ParamList &x)
{
	if(candidate_check(get_param_vocab(),x))
	{
	    ValueDesc value_desc(x.find("dest")->second.get_value_desc());
	    ValueNode::Handle value_node(x.find("src")->second.get_value_node());

	    //! forbid recursive linking (fix #48)
	    if (value_desc.parent_is_value_node())
	    {
	        ValueNode* vn = dynamic_cast<ValueNode*>(value_node.get());
	        if (vn && vn->is_descendant(value_desc.get_parent_value_node()))
	            return false;
	    }


		// don't show the option of connecting to an existing Index parameter of the Duplicate layer
		if(x.count("dest"))
		{
			if (value_desc.parent_is_layer() &&
				value_desc.get_layer()->get_name() == "duplicate" &&
				value_desc.get_param_name() == "index")
				return false;
		}

		if(x.count("src"))
		{
			if(value_desc.get_value_type()==value_node->get_type())
				return true;
		}
		return true;
	}
	return false;
}
コード例 #4
0
ファイル: param.cpp プロジェクト: defc0n1/guh
/*! Writes the param of the given \a params to \a dbg. */
QDebug operator<<(QDebug dbg, const ParamList &params)
{
    dbg.nospace() << "ParamList (count:" << params.count() << ")" << endl;
    for (int i = 0; i < params.count(); i++ ) {
        dbg.nospace() << "     " << i << ": " << params.at(i) << endl;
    }

    return dbg.space();
}
コード例 #5
0
ファイル: waypointadd.cpp プロジェクト: breaklyn/synfig-osx
bool
Action::WaypointAdd::is_candidate(const ParamList &x)
{
	return (candidate_check(get_param_vocab(),x) &&
			// We need an animated valuenode.
			ValueNode_Animated::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()) &&
			// We need either a waypoint or a time.
			(x.count("waypoint") || x.count("time")));
}
コード例 #6
0
bool
Action::ActivepointSetSmart::is_candidate(const ParamList &x)
{
	if (!candidate_check(get_param_vocab(),x))
		return false;

	ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());

	return (value_desc.parent_is_value_node() &&
			// We need a dynamic list.
			ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()) &&
			// We need either an activepoint or a time.
			(x.count("activepoint") || x.count("time")));
}
コード例 #7
0
bool
Action::ActivepointSetOff::is_candidate(const ParamList &x)
{
    if (!candidate_check(get_param_vocab(),x))
        return false;

    ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());

    if (!(value_desc.parent_is_value_node() &&
            // We need a dynamic list.
            ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())))
        return false;

    Canvas::Handle canvas(x.find("canvas")->second.get_canvas());

    // We are only a candidate if this canvas is animated.
    return (canvas->rend_desc().get_time_start() != canvas->rend_desc().get_time_end() &&
            // We need either an activepoint or a time.
            (x.count("activepoint") || x.count("time")));
}
コード例 #8
0
bool
Action::LayerMakeBLine::is_candidate_for_make_bline(const ParamList &x, const char **possible_layer_names, size_t possible_layer_names_count)
{
	if(!candidate_check(get_param_vocab(),x))
		return false;

	if(x.count("layer") == 1)
	{
		const Param &param = x.find("layer")->second;
		if(param.get_type() == Param::TYPE_LAYER
		&& param.get_layer()
		&& param.get_layer()->dynamic_param_list().count("bline") == 1)
		{
			for(size_t i = 0; i < possible_layer_names_count; i++)
				if (param.get_layer()->get_name() == possible_layer_names[i])
					return true;
		}
	}

	return false;
}