/*! \file waypointadd.cpp
** \brief Template File
**
-** $Id: waypointadd.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
+** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2008 Chris Moore
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
#include <synfigapp/canvasinterface.h>
#include <synfigapp/main.h>
+#include <synfigapp/general.h>
+
#endif
using namespace std;
ACTION_INIT(Action::WaypointAdd);
ACTION_SET_NAME(Action::WaypointAdd,"waypoint_add");
-ACTION_SET_LOCAL_NAME(Action::WaypointAdd,"Add Waypoint");
+ACTION_SET_LOCAL_NAME(Action::WaypointAdd,N_("Add Waypoint"));
ACTION_SET_TASK(Action::WaypointAdd,"add");
ACTION_SET_CATEGORY(Action::WaypointAdd,Action::CATEGORY_WAYPOINT);
ACTION_SET_PRIORITY(Action::WaypointAdd,0);
ACTION_SET_VERSION(Action::WaypointAdd,"0.0");
-ACTION_SET_CVS_ID(Action::WaypointAdd,"$Id: waypointadd.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
+ACTION_SET_CVS_ID(Action::WaypointAdd,"$Id$");
/* === G L O B A L S ======================================================= */
Action::WaypointAdd::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("Destination ValueNode (Animated)"))
);
bool
Action::WaypointAdd::is_candidate(const ParamList &x)
{
- if(candidate_check(get_param_vocab(),x))
- {
- if(!ValueNode_Animated::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()))
- return false;
-
- // We need either a waypoint or a time.
- if(x.count("waypoint") || x.count("time"))
- return true;
- }
- return false;
+ return (candidate_check(get_param_vocab(),x) &&
+ // We need an animated valuenode.
+ ValueNode_Animated::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()) &&
+ // We need either a waypoint or a time.
+ (x.count("waypoint") || x.count("time")));
}
bool
value_node=ValueNode_Animated::Handle::cast_dynamic(param.get_value_node());
if(time_set)
calc_waypoint();
-
+
return static_cast<bool>(value_node);
}
if(name=="waypoint" && param.get_type()==Param::TYPE_WAYPOINT && !time_set)
{
waypoint=param.get_waypoint();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME && waypoint.get_time()==Time::begin()-1)
if(value_node)
calc_waypoint();
-
+
return true;
}
return Action::CanvasSpecific::is_ready();
}
-// This function is called if a time is specified, but not
+// This function is called if a time is specified, but not
// a waypoint. In this case, we need to calculate the value
// of the waypoint
void
Action::WaypointAdd::calc_waypoint()
-{
+{
Time time=waypoint.get_time();
Waypoint original(waypoint);
- waypoint=value_node->new_waypoint_at_time(time);
+ waypoint=value_node->new_waypoint_at_time(time);
waypoint.mimic(original);
waypoint.set_before(synfigapp::Main::get_interpolation());
waypoint.set_after(synfigapp::Main::get_interpolation());
/*
ValueNode_Animated::WaypointList &waypoint_list(value_node->waypoint_list());
ValueNode_Animated::WaypointList::iterator iter;
-
+
if(waypoint_list.empty())
{
waypoint.set_value((*value_node)(time));
}
ValueNode_Animated::WaypointList::iterator closest=waypoint_list.begin();
-
+
for(iter=waypoint_list.begin();iter!=waypoint_list.end();++iter)
{
const Real dist(abs(iter->get_time()-time));
void
Action::WaypointAdd::perform()
-{
+{
try { value_node->find(waypoint.get_time()); throw Error(_("A Waypoint already exists at this point in time (%s)"),waypoint.get_time().get_string().c_str());}
- catch(synfig::Exception::NotFound) { }
+ catch(synfig::Exception::NotFound) { }
try { if(value_node->find(waypoint)!=value_node->waypoint_list().end()) throw Error(_("This waypoint is already in the ValueNode"));}
- catch(synfig::Exception::NotFound) { }
-
+ catch(synfig::Exception::NotFound) { }
+
value_node->add(waypoint);
-
+
value_node->changed();
/*_if(get_canvas_interface())
{
Action::WaypointAdd::undo()
{
value_node->erase(waypoint);
-
+
value_node->changed();
/*_if(get_canvas_interface())
{