1 /* === S Y N F I G ========================================================= */
2 /*! \file activepointsimpleadd.cpp
3 ** \brief Simple add activepoint File
5 ** $Id: activepointsimpleadd.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
8 ** Copyright (c) 2004 Adrian Bentley
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "activepointsimpleadd.h"
32 #include <synfigapp/canvasinterface.h>
38 using namespace synfig;
39 using namespace synfigapp;
40 using namespace Action;
42 /* === M A C R O S ========================================================= */
44 ACTION_INIT(Action::ActivepointSimpleAdd);
45 ACTION_SET_NAME(Action::ActivepointSimpleAdd,"waypoint_simpleadd");
46 ACTION_SET_LOCAL_NAME(Action::ActivepointSimpleAdd,"Simply Add Waypoint");
47 ACTION_SET_TASK(Action::ActivepointSimpleAdd,"add");
48 ACTION_SET_CATEGORY(Action::ActivepointSimpleAdd,Action::CATEGORY_WAYPOINT);
49 ACTION_SET_PRIORITY(Action::ActivepointSimpleAdd,0);
50 ACTION_SET_VERSION(Action::ActivepointSimpleAdd,"0.0");
51 ACTION_SET_CVS_ID(Action::ActivepointSimpleAdd,"$Id: activepointsimpleadd.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
53 /* === G L O B A L S ======================================================= */
55 /* === P R O C E D U R E S ================================================= */
57 /* === M E T H O D S ======================================================= */
59 Action::ActivepointSimpleAdd::ActivepointSimpleAdd()
62 activepoint.set_time(Time::begin()-1);
66 Action::ActivepointSimpleAdd::get_param_vocab()
68 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
70 ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
71 .set_local_name(_("Destination ValueNode (Animated)"))
74 ret.push_back(ParamDesc("activepoint",Param::TYPE_ACTIVEPOINT)
75 .set_local_name(_("Activepoint"))
76 .set_desc(_("Activepoint to be added"))
83 Action::ActivepointSimpleAdd::is_canidate(const ParamList &x)
85 if(canidate_check(get_param_vocab(),x))
87 ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
88 if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()))
93 return canidate_check(get_param_vocab(),x);
97 Action::ActivepointSimpleAdd::set_param(const synfig::String& name, const Action::Param ¶m)
99 if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
101 ValueDesc value_desc(param.get_value_desc());
103 if(!value_desc.parent_is_value_node())
106 value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
111 index=value_desc.get_index();
115 if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT)
117 activepoint = param.get_activepoint();
122 return Action::CanvasSpecific::set_param(name,param);
126 Action::ActivepointSimpleAdd::is_ready()const
128 if(!value_node && activepoint.get_time() != (Time::begin()-1))
130 return Action::CanvasSpecific::is_ready();
134 Action::ActivepointSimpleAdd::perform()
136 //remove any pretenders that lie at our destination
137 ValueNode_DynamicList::ListEntry::findresult iter = value_node->list[index]
138 .find_time(activepoint.get_time());
140 time_overwrite = false;
143 overwritten_ap = *iter.first;
144 time_overwrite = true;
145 value_node->list[index].erase(overwritten_ap);
148 //add the value node in since it's safe
149 value_node->list[index].add(activepoint);
152 value_node->list[index].timing_info.sort();
154 // Signal that a valuenode has been changed
155 value_node->changed();
159 Action::ActivepointSimpleAdd::undo()
161 //remove our old version...
162 ValueNode_DynamicList::ListEntry::findresult iter = value_node->list[index].find_uid(activepoint);
166 throw Error(_("The activepoint to remove no longer exists"));
169 //remove the offending value
170 value_node->list[index].erase(*iter.first); //could also just use waypoint
174 value_node->list[index].add(overwritten_ap);
178 value_node->list[index].timing_info.sort();
180 // Signal that a valuenode has been changed
181 value_node->changed();