1 /* === S Y N F I G ========================================================= */
2 /*! \file waypointsimpleadd.cpp
3 ** \brief Simple add waypoint File
5 ** $Id: waypointsimpleadd.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 "waypointsimpleadd.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::WaypointSimpleAdd);
45 ACTION_SET_NAME(Action::WaypointSimpleAdd,"waypoint_simpleadd");
46 ACTION_SET_LOCAL_NAME(Action::WaypointSimpleAdd,"Simply Add Waypoint");
47 ACTION_SET_TASK(Action::WaypointSimpleAdd,"add");
48 ACTION_SET_CATEGORY(Action::WaypointSimpleAdd,Action::CATEGORY_WAYPOINT);
49 ACTION_SET_PRIORITY(Action::WaypointSimpleAdd,0);
50 ACTION_SET_VERSION(Action::WaypointSimpleAdd,"0.0");
51 ACTION_SET_CVS_ID(Action::WaypointSimpleAdd,"$Id: waypointsimpleadd.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::WaypointSimpleAdd::WaypointSimpleAdd()
62 waypoint.set_time(Time::begin()-1);
66 Action::WaypointSimpleAdd::get_param_vocab()
68 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
70 ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
71 .set_local_name(_("Destination ValueNode (Animated)"))
74 ret.push_back(ParamDesc("waypoint",Param::TYPE_WAYPOINT)
75 .set_local_name(_("Waypoint"))
76 .set_desc(_("Waypoint to be added"))
83 Action::WaypointSimpleAdd::is_canidate(const ParamList &x)
85 return canidate_check(get_param_vocab(),x);
89 Action::WaypointSimpleAdd::set_param(const synfig::String& name, const Action::Param ¶m)
91 if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
93 value_node=ValueNode_Animated::Handle::cast_dynamic(param.get_value_node());
95 return static_cast<bool>(value_node);
97 if(name=="waypoint" && param.get_type()==Param::TYPE_WAYPOINT)
99 waypoint = param.get_waypoint();
104 return Action::CanvasSpecific::set_param(name,param);
108 Action::WaypointSimpleAdd::is_ready()const
110 if(!value_node && waypoint.get_time() != (Time::begin()-1))
112 return Action::CanvasSpecific::is_ready();
116 Action::WaypointSimpleAdd::perform()
118 //remove any pretenders that lie at our destination
119 ValueNode_Animated::findresult iter = value_node->find_time(waypoint.get_time());
121 time_overwrite = false;
124 overwritten_wp = *iter.first;
125 time_overwrite = true;
128 //add the value node in since it's safe
129 value_node->add(waypoint);
131 // Signal that a valuenode has been changed
132 value_node->changed();
136 Action::WaypointSimpleAdd::undo()
138 //remove our old version...
139 ValueNode_Animated::findresult iter = value_node->find_uid(waypoint);
143 throw Error(_("The waypoint to remove no longer exists"));
146 //remove the offending value
147 value_node->erase(*iter.first); //could also just use waypoint
151 value_node->add(overwritten_wp);
154 // Signal that a valuenode has been changed
155 value_node->changed();