1 /* === S Y N F I G ========================================================= */
2 /*! \file blinepointtangentmerge.cpp
3 ** \brief Template File
5 ** $Id: blinepointtangentmerge.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "blinepointtangentmerge.h"
33 #include "valuedescset.h"
35 #include "activepointset.h"
36 #include "activepointadd.h"
38 #include "valuedescconnect.h"
39 #include <synfigapp/canvasinterface.h>
45 using namespace synfig;
46 using namespace synfigapp;
47 using namespace Action;
49 /* === M A C R O S ========================================================= */
51 ACTION_INIT(Action::BLinePointTangentMerge);
52 ACTION_SET_NAME(Action::BLinePointTangentMerge,"bline_point_tangent_merge");
53 ACTION_SET_LOCAL_NAME(Action::BLinePointTangentMerge,_("Merge Tangents"));
54 ACTION_SET_TASK(Action::BLinePointTangentMerge,"merge");
55 ACTION_SET_CATEGORY(Action::BLinePointTangentMerge,Action::CATEGORY_VALUENODE);
56 ACTION_SET_PRIORITY(Action::BLinePointTangentMerge,0);
57 ACTION_SET_VERSION(Action::BLinePointTangentMerge,"0.0");
58 ACTION_SET_CVS_ID(Action::BLinePointTangentMerge,"$Id: blinepointtangentmerge.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
60 /* === G L O B A L S ======================================================= */
62 /* === P R O C E D U R E S ================================================= */
64 /* === M E T H O D S ======================================================= */
66 Action::BLinePointTangentMerge::BLinePointTangentMerge()
68 time=(Time::begin()-1);
73 Action::BLinePointTangentMerge::get_param_vocab()
75 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
77 ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
78 .set_local_name(_("ValueNode of BLinePoint"))
81 ret.push_back(ParamDesc("time",Param::TYPE_TIME)
82 .set_local_name(_("Time"))
89 Action::BLinePointTangentMerge::is_canidate(const ParamList &x)
91 if(canidate_check(get_param_vocab(),x))
93 ValueNode_Composite::Handle value_node;
94 value_node=ValueNode_Composite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node());
95 if(!value_node || value_node->get_type()!=ValueBase::TYPE_BLINEPOINT)
97 synfig::Time time(x.find("time")->second.get_time());
98 if((*value_node->get_link("split"))(time).get(bool())==false)
106 Action::BLinePointTangentMerge::set_param(const synfig::String& name, const Action::Param ¶m)
108 if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
110 value_node=value_node.cast_dynamic(param.get_value_node());
112 return (bool)(value_node);
114 if(name=="time" && param.get_type()==Param::TYPE_TIME)
116 time=param.get_time();
121 return Action::CanvasSpecific::set_param(name,param);
125 Action::BLinePointTangentMerge::is_ready()const
128 synfig::error("Missing or bad value_node");
130 if(time==(Time::begin()-1))
131 synfig::error("Missing time");
133 if(!value_node || time==(Time::begin()-1))
135 return Action::CanvasSpecific::is_ready();
139 Action::BLinePointTangentMerge::prepare()
143 Action::Handle action;
146 action=Action::create("value_desc_set");
148 throw Error(_("Couldn't find action \"value_desc_set\""));
150 action->set_param("canvas",get_canvas());
151 action->set_param("canvas_interface",get_canvas_interface());
152 action->set_param("value_desc",ValueDesc(value_node,3));
153 action->set_param("time",time);
154 action->set_param("new_value",synfig::ValueBase(false));
156 assert(action->is_ready());
157 if(!action->is_ready())
158 throw Error(Error::TYPE_NOTREADY);
163 action=Action::create("value_desc_set");
165 throw Error(_("Couldn't find action \"value_desc_set\""));
167 action->set_param("canvas",get_canvas());
168 action->set_param("canvas_interface",get_canvas_interface());
169 action->set_param("value_desc",ValueDesc(value_node,5));
170 action->set_param("time",time);
171 action->set_param("new_value",(*value_node->get_link("t1"))(time));
173 assert(action->is_ready());
174 if(!action->is_ready())
175 throw Error(Error::TYPE_NOTREADY);