1 /* === S Y N F I G ========================================================= */
2 /*! \file blinepointtangentmerge.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007, 2008 Chris Moore
10 ** Copyright (c) 2009 Nikita Kitaev
12 ** This package is free software; you can redistribute it and/or
13 ** modify it under the terms of the GNU General Public License as
14 ** published by the Free Software Foundation; either version 2 of
15 ** the License, or (at your option) any later version.
17 ** This package is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ** General Public License for more details.
23 /* ========================================================================= */
25 /* === H E A D E R S ======================================================= */
34 #include "blinepointtangentmerge.h"
35 #include "valuedescset.h"
37 #include "activepointset.h"
38 #include "activepointadd.h"
40 #include "valuedescconnect.h"
41 #include <synfigapp/canvasinterface.h>
43 #include <synfigapp/general.h>
49 using namespace synfig;
50 using namespace synfigapp;
51 using namespace Action;
53 /* === M A C R O S ========================================================= */
55 ACTION_INIT_NO_GET_LOCAL_NAME(Action::BLinePointTangentMerge);
56 ACTION_SET_NAME(Action::BLinePointTangentMerge,"BLinePointTangentMerge");
57 ACTION_SET_LOCAL_NAME(Action::BLinePointTangentMerge,N_("Merge Tangents"));
58 ACTION_SET_TASK(Action::BLinePointTangentMerge,"merge");
59 ACTION_SET_CATEGORY(Action::BLinePointTangentMerge,Action::CATEGORY_VALUENODE);
60 ACTION_SET_PRIORITY(Action::BLinePointTangentMerge,0);
61 ACTION_SET_VERSION(Action::BLinePointTangentMerge,"0.0");
62 ACTION_SET_CVS_ID(Action::BLinePointTangentMerge,"$Id$");
64 /* === G L O B A L S ======================================================= */
66 /* === P R O C E D U R E S ================================================= */
68 /* === M E T H O D S ======================================================= */
70 Action::BLinePointTangentMerge::BLinePointTangentMerge()
72 time=(Time::begin()-1);
77 Action::BLinePointTangentMerge::get_local_name()const
79 return strprintf(_("Merge Tangents of '%s'"), ((ValueNode::Handle)(value_node))->get_description().c_str());
83 Action::BLinePointTangentMerge::get_param_vocab()
85 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
87 ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
88 .set_local_name(_("ValueNode of BLinePoint"))
91 ret.push_back(ParamDesc("time",Param::TYPE_TIME)
92 .set_local_name(_("Time"))
99 Action::BLinePointTangentMerge::is_candidate(const ParamList &x)
101 if(candidate_check(get_param_vocab(),x))
103 ValueNode_Composite::Handle value_node;
104 value_node=ValueNode_Composite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node());
105 if(!value_node || value_node->get_type()!=ValueBase::TYPE_BLINEPOINT)
107 synfig::Time time(x.find("time")->second.get_time());
108 if((*value_node->get_link("split"))(time).get(bool())==false)
116 Action::BLinePointTangentMerge::set_param(const synfig::String& name, const Action::Param ¶m)
118 if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
120 value_node=value_node.cast_dynamic(param.get_value_node());
122 return (bool)(value_node);
124 if(name=="time" && param.get_type()==Param::TYPE_TIME)
126 time=param.get_time();
131 return Action::CanvasSpecific::set_param(name,param);
135 Action::BLinePointTangentMerge::is_ready()const
138 synfig::error("Missing or bad value_node");
140 if(time==(Time::begin()-1))
141 synfig::error("Missing time");
143 if(!value_node || time==(Time::begin()-1))
145 return Action::CanvasSpecific::is_ready();
149 Action::BLinePointTangentMerge::prepare()
153 Action::Handle action;
155 action=Action::create("ValueDescSet");
157 throw Error(_("Couldn't find action \"ValueDescSet\""));
159 action->set_param("canvas",get_canvas());
160 action->set_param("canvas_interface",get_canvas_interface());
161 action->set_param("value_desc",ValueDesc(value_node,value_node->get_link_index_from_name("split")));
162 action->set_param("time",time);
163 action->set_param("new_value",synfig::ValueBase(false));
165 assert(action->is_ready());
166 if(!action->is_ready())
167 throw Error(Error::TYPE_NOTREADY);