X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fwaypoint.cpp;fp=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fwaypoint.cpp;h=2fa82a2fda08508173d91b5da94c29e26502fa67;hb=e3acc0b267b14fda5db3c7bbb2f218b993ef84b3;hp=0000000000000000000000000000000000000000;hpb=ced68168d8518aac837f20e73bcd1e84a6bd6178;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/waypoint.cpp b/synfig-core/trunk/src/synfig/waypoint.cpp new file mode 100644 index 0000000..2fa82a2 --- /dev/null +++ b/synfig-core/trunk/src/synfig/waypoint.cpp @@ -0,0 +1,154 @@ +/* === S I N F G =========================================================== */ +/*! \file waypoint.cpp +** \brief Template File +** +** $Id: waypoint.cpp,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $ +** +** \legal +** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** +** This software and associated documentation +** are CONFIDENTIAL and PROPRIETARY property of +** the above-mentioned copyright holder. +** +** You may not copy, print, publish, or in any +** other way distribute this software without +** a prior written agreement with +** the copyright holder. +** \endlegal +*/ +/* ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#ifdef USING_PCH +# include "pch.h" +#else +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "waypoint.h" +#include "valuenode_const.h" + +#endif + +/* === U S I N G =========================================================== */ + +using namespace std; +using namespace etl; +using namespace sinfg; + +/* === M A C R O S ========================================================= */ + +/* === G L O B A L S ======================================================= */ + +/* === P R O C E D U R E S ================================================= */ + +/* === M E T H O D S ======================================================= */ + +Waypoint::Waypoint(ValueBase value, Time time): + priority_(0), + before(INTERPOLATION_TCB), + after(INTERPOLATION_TCB), + value_node(ValueNode_Const::create(value)), + time(time), + tension(0.0), + continuity(0.0), + bias(0), + time_tension(0.0f) +{ + if(value.get_type()==ValueBase::TYPE_ANGLE) + after=before=INTERPOLATION_LINEAR; +} + +Waypoint::Waypoint(ValueNode::Handle value_node, Time time): + priority_(0), + before(INTERPOLATION_TCB), + after(INTERPOLATION_TCB), + value_node(value_node), + time(time), + tension(0.0), + continuity(0), + bias(0), + time_tension(0.0f) +{ + if(value_node->get_type()==ValueBase::TYPE_ANGLE) + after=before=INTERPOLATION_LINEAR; +} + +Waypoint::Waypoint(): + priority_(0), + before(INTERPOLATION_TCB), + after(INTERPOLATION_TCB), + tension(0), + continuity(0), + bias(0), + time_tension(0.0f) +{ +} + +void +Waypoint::set_value(const ValueBase &x) +{ + if(!value_node && x.get_type()==ValueBase::TYPE_ANGLE) + after=before=INTERPOLATION_LINEAR; + + value_node=ValueNode_Const::create(x); +} + +void +Waypoint::set_value_node(const ValueNode::Handle &x) +{ + if(!value_node && x->get_type()==ValueBase::TYPE_ANGLE) + after=before=INTERPOLATION_LINEAR; + + value_node=x; +} + +bool +Waypoint::is_static()const +{ + return static_cast(ValueNode_Const::Handle::cast_dynamic(value_node)) && value_node && !value_node->is_exported(); +} + +void +Waypoint::set_time(const Time &x) +{ + time=x; +} + +void +Waypoint::apply_model(const Model &x) +{ + if(x.priority_flag) set_priority(x.get_priority()); + if(x.before_flag) set_before(x.get_before()); + if(x.after_flag) set_after(x.get_after()); + if(x.tension_flag) set_tension(x.get_tension()); + if(x.continuity_flag) set_continuity(x.get_continuity()); + if(x.bias_flag) set_bias(x.get_bias()); + if(x.temporal_tension_flag) set_temporal_tension(x.get_temporal_tension()); +} + +Waypoint +Waypoint::clone(const GUID& deriv_guid)const +{ + Waypoint ret(*this); + ret.make_unique(); + if(!ret.value_node->is_exported()) + ret.value_node=value_node->clone(deriv_guid); + ret.parent_=0; + return ret; +} + +ValueBase +Waypoint::get_value()const { return (*value_node)(0); } + +ValueBase +Waypoint::get_value(const Time &t)const { return (*value_node)(t); } + +sinfg::GUID +Waypoint::get_guid()const +{ + return GUID::hasher(get_uid()); +}