1 /* === S Y N F I G ========================================================= */
2 /*! \file waypointsimpleadd.cpp
3 ** \brief Simple add waypoint File
8 ** Copyright (c) 2004 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 "waypointsimpleadd.h"
33 #include <synfigapp/canvasinterface.h>
35 #include <synfigapp/general.h>
41 using namespace synfig;
42 using namespace synfigapp;
43 using namespace Action;
45 /* === M A C R O S ========================================================= */
47 ACTION_INIT(Action::WaypointSimpleAdd);
48 ACTION_SET_NAME(Action::WaypointSimpleAdd,"waypoint_simpleadd");
49 ACTION_SET_LOCAL_NAME(Action::WaypointSimpleAdd,N_("Simply Add Waypoint"));
50 ACTION_SET_TASK(Action::WaypointSimpleAdd,"add");
51 ACTION_SET_CATEGORY(Action::WaypointSimpleAdd,Action::CATEGORY_WAYPOINT);
52 ACTION_SET_PRIORITY(Action::WaypointSimpleAdd,0);
53 ACTION_SET_VERSION(Action::WaypointSimpleAdd,"0.0");
54 ACTION_SET_CVS_ID(Action::WaypointSimpleAdd,"$Id$");
56 /* === G L O B A L S ======================================================= */
58 /* === P R O C E D U R E S ================================================= */
60 /* === M E T H O D S ======================================================= */
62 Action::WaypointSimpleAdd::WaypointSimpleAdd()
65 waypoint.set_time(Time::begin()-1);
69 Action::WaypointSimpleAdd::get_param_vocab()
71 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
73 ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
74 .set_local_name(_("Destination ValueNode (Animated)"))
77 ret.push_back(ParamDesc("waypoint",Param::TYPE_WAYPOINT)
78 .set_local_name(_("Waypoint"))
79 .set_desc(_("Waypoint to be added"))
86 Action::WaypointSimpleAdd::is_candidate(const ParamList &x)
88 return candidate_check(get_param_vocab(),x);
92 Action::WaypointSimpleAdd::set_param(const synfig::String& name, const Action::Param ¶m)
94 if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
96 value_node=ValueNode_Animated::Handle::cast_dynamic(param.get_value_node());
98 return static_cast<bool>(value_node);
100 if(name=="waypoint" && param.get_type()==Param::TYPE_WAYPOINT)
102 waypoint = param.get_waypoint();
107 return Action::CanvasSpecific::set_param(name,param);
111 Action::WaypointSimpleAdd::is_ready()const
113 if(!value_node && waypoint.get_time() != (Time::begin()-1))
115 return Action::CanvasSpecific::is_ready();
119 Action::WaypointSimpleAdd::perform()
121 //remove any pretenders that lie at our destination
122 ValueNode_Animated::findresult iter = value_node->find_time(waypoint.get_time());
124 time_overwrite = false;
127 overwritten_wp = *iter.first;
128 time_overwrite = true;
131 //add the value node in since it's safe
132 value_node->add(waypoint);
134 // Signal that a valuenode has been changed
135 value_node->changed();
139 Action::WaypointSimpleAdd::undo()
141 //remove our old version...
142 ValueNode_Animated::findresult iter = value_node->find_uid(waypoint);
146 throw Error(_("The waypoint to remove no longer exists"));
149 //remove the offending value
150 value_node->erase(*iter.first); //could also just use waypoint
154 value_node->add(overwritten_wp);
157 // Signal that a valuenode has been changed
158 value_node->changed();