1 /* === S Y N F I G ========================================================= */
2 /*! \file activepointremove.cpp
3 ** \brief Template File
5 ** $Id: activepointremove.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 "activepointremove.h"
33 #include <synfigapp/canvasinterface.h>
39 using namespace synfig;
40 using namespace synfigapp;
41 using namespace Action;
43 /* === M A C R O S ========================================================= */
45 ACTION_INIT(Action::ActivepointRemove);
46 ACTION_SET_NAME(Action::ActivepointRemove,"activepoint_remove");
47 ACTION_SET_LOCAL_NAME(Action::ActivepointRemove,"Remove Activepoint");
48 ACTION_SET_TASK(Action::ActivepointRemove,"remove");
49 ACTION_SET_CATEGORY(Action::ActivepointRemove,Action::CATEGORY_ACTIVEPOINT);
50 ACTION_SET_PRIORITY(Action::ActivepointRemove,0);
51 ACTION_SET_VERSION(Action::ActivepointRemove,"0.0");
52 ACTION_SET_CVS_ID(Action::ActivepointRemove,"$Id: activepointremove.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
54 /* === G L O B A L S ======================================================= */
56 /* === P R O C E D U R E S ================================================= */
58 /* === M E T H O D S ======================================================= */
60 Action::ActivepointRemove::ActivepointRemove()
62 activepoint.set_time(Time::begin()-1);
67 Action::ActivepointRemove::get_param_vocab()
69 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
71 ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
72 .set_local_name(_("ValueDesc"))
75 ret.push_back(ParamDesc("activepoint",Param::TYPE_ACTIVEPOINT)
76 .set_local_name(_("Activepoint"))
77 .set_desc(_("Activepoint to be changed"))
84 Action::ActivepointRemove::is_canidate(const ParamList &x)
86 if(canidate_check(get_param_vocab(),x))
88 ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
89 if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()))
98 Action::ActivepointRemove::set_param(const synfig::String& name, const Action::Param ¶m)
100 if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
102 ValueDesc value_desc(param.get_value_desc());
104 if(!value_desc.parent_is_value_node())
107 value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
112 index=value_desc.get_index();
116 if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT)
118 activepoint=param.get_activepoint();
123 return Action::CanvasSpecific::set_param(name,param);
127 Action::ActivepointRemove::is_ready()const
129 if(!value_node || activepoint.get_time()==(Time::begin()-1))
131 return Action::CanvasSpecific::is_ready();
135 Action::ActivepointRemove::perform()
137 ValueNode_DynamicList::ListEntry::ActivepointList::iterator iter;
139 try { iter=value_node->list[index].find(activepoint); }
140 catch(synfig::Exception::NotFound)
142 throw Error(_("Unable to find activepoint"));
145 value_node->list[index].erase(activepoint);
146 value_node->changed();
149 // Signal that a layer has been inserted
150 if(get_canvas_interface())
152 get_canvas_interface()->signal_value_node_changed()(value_node);
154 else synfig::warning("CanvasInterface not set on action");
159 Action::ActivepointRemove::undo()
161 try { value_node->list[index].find(activepoint.get_time()); throw Error(_("A Activepoint already exists at this point in time"));}
162 catch(synfig::Exception::NotFound) { }
164 try { if(value_node->list[index].find(activepoint)!=value_node->list[index].timing_info.end()) throw Error(_("This activepoint is already in the ValueNode"));}
165 catch(synfig::Exception::NotFound) { }
167 value_node->list[index].add(activepoint);
168 value_node->changed();
170 // Signal that a layer has been inserted
171 if(get_canvas_interface())
173 get_canvas_interface()->signal_value_node_changed()(value_node);
175 else synfig::warning("CanvasInterface not set on action");