1 /* === S Y N F I G ========================================================= */
3 ** \brief Waypoint class header.
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2008 Chris Moore
10 ** Copyright (c) 2008 Paul Wise
12 ** This package is free software; you can redistribute it and/or
13 ** modify it under the terms of the GNU General Public License as
14 ** published by the Free Software Foundation; either version 2 of
15 ** the License, or (at your option) any later version.
17 ** This package is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ** General Public License for more details.
23 /* ========================================================================= */
25 /* === S T A R T =========================================================== */
27 #ifndef __SYNFIG_WAYPOINT_H
28 #define __SYNFIG_WAYPOINT_H
30 /* === H E A D E R S ======================================================= */
38 #include "interpolation.h"
40 /* === M A C R O S ========================================================= */
42 /* === T Y P E D E F S ===================================================== */
44 /* === C L A S S E S & S T R U C T S ======================================= */
53 ** \brief Waypoint is used to handle variations along the time of the ValueNodes
55 * The Waypoint is a child of a ValueNode (or any of inherited) and it describes the
56 * Interpolation type (before and after), the ValueNode (usually waypoints are constant
57 * but in fact they can be animated) and the time where the waypoint is.
58 * \see Waypoint::get_value(), Waypoint::get_value(const Time &t)
60 class Waypoint : public UniqueID
63 -- ** -- T Y P E S -----------------------------------------------------------
68 typedef synfig::Interpolation Interpolation;
70 /*! \class Waypoint::Model
71 * \brief Waypoint::Model is a Waypoint model. It is used to store and
72 * retrieve the values of the waypoint that is going to be modified. Once
73 * the model is completely modifed then it can be applied to the waypoint
74 * itself by using the \apply_model() member
78 friend class Waypoint;
86 Real temporal_tension;
88 bool priority_flag,before_flag,after_flag,tension_flag,continuity_flag,bias_flag,temporal_tension_flag;
92 // we don't need to initialise these 5, but the compiler thinks they're used uninitialised if we don't
93 // and this constructor isn't called often, so it's ok
94 priority(0), before(INTERPOLATION_NIL), after(INTERPOLATION_NIL), tension(0), continuity(0), bias(0), temporal_tension(0),
100 continuity_flag(false),
102 temporal_tension_flag(false) { }
104 //! Gets before Interpolation
105 Interpolation get_before()const { return before; }
106 //! Sets before Interpolation
107 void set_before(Interpolation x) { before=x; before_flag=true;}
108 //! Gets after Interpolation
109 Interpolation get_after()const { return after; }
110 //! Sets after Interpolation
111 void set_after(Interpolation x) { after=x; after_flag=true;}
113 const Real &get_tension()const { return tension; }
115 void set_tension(const Real &x) { tension=x; tension_flag=true;}
117 const Real &get_continuity()const { return continuity; }
119 void set_continuity(const Real &x) { continuity=x; continuity_flag=true;}
121 const Real &get_bias()const { return bias; }
123 void set_bias(const Real &x) { bias=x; bias_flag=true;}
124 //! Gets temporal tension
125 const Real &get_temporal_tension()const { return temporal_tension; }
126 //! Sets temporal tension
127 void set_temporal_tension(const Real &x) { temporal_tension=x; temporal_tension_flag=true;}
129 int get_priority()const { return priority; }
131 void set_priority(int x) { priority=x; priority_flag=true;}
133 //! Get & Set members for the flags
134 #define FLAG_MACRO(x) bool get_##x##_flag()const { return x##_flag; } void set_##x##_flag(bool y) { x##_flag=y; }
139 FLAG_MACRO(continuity)
141 FLAG_MACRO(temporal_tension)
144 //! Converts the Model in trivial: None of its values will be applied
151 continuity_flag=false;
153 temporal_tension_flag=false;
156 //! Checks if none of the Model information is relevant for the Waypoint
157 //! If all the flags are off, the Model doesn't apply wnything to the
158 //! waypoint. \see apply_model(const Model &x)
159 bool is_trivial()const
168 temporal_tension_flag
175 SIDE_UNSPECIFIED, SIDE_LEFT, SIDE_RIGHT,
177 SIDE_END=2 //!< \internal
181 -- ** -- D A T A -------------------------------------------------------------
188 //! Usually Animated Value Nodes are parents of waypoints
189 //! \see class ValueNode_Animated
190 etl::loose_handle<ValueNode> parent_;
191 //! The two Interpolations before and after
192 Interpolation before, after;
193 //! The value node that is hold by the waypoint
194 etl::rhandle<ValueNode> value_node;
195 //! The time of the waypoint
198 //! The following are for the INTERPOLATION_TCB type
203 //! The following are for the INTERPOLATION_MANUAL type
204 //! Seems to be not used
205 ValueBase cpoint_before,cpoint_after;
207 //! Shouldn't be Real?
211 -- ** -- C O N S T R U C T O R S ---------------------------------------------
216 //! Constructor for constant Waypoint
217 Waypoint(ValueBase value, Time time);
218 //! Constructor for animated Waypoint
219 //! Is is called anytime?
220 Waypoint(etl::handle<ValueNode> value_node, Time time);
222 //! Default constructor. Leaves unset the Value Node
226 -- ** -- M E M B E R F U N C T I O N S -------------------------------------
231 //! Applies the content of the Model to the Waypoint. It doesn't alter
232 //! the Value Node hold or the time.
233 void apply_model(const Model &x);
235 //! Gets the before Interpolation
236 Interpolation get_before()const { return before; }
237 //! Sets the before Interpolation
238 void set_before(Interpolation x) { before=x; }
239 //! Gets the after Interpolation
240 Interpolation get_after()const { return after; }
241 //! Sets the after Interpolation
242 void set_after(Interpolation x) { after=x; }
243 //! Gets the value hold by the Waypoint
244 ValueBase get_value()const;
245 //!Gets the value hold by the Waypoint at time \t when it is animated
246 ValueBase get_value(const Time &t)const;
247 //!Sets the value of the Waypoint.
248 //!Maybe it would be posible to define set_value(const ValueBase &x, Time &t) ?
249 void set_value(const ValueBase &x);
250 //! Returns the handle to the value node
251 const etl::rhandle<ValueNode> &get_value_node()const { return value_node; }
252 //! Sets the value node by handle
253 void set_value_node(const etl::handle<ValueNode> &x);
256 const Real &get_tension()const { return tension; }
258 void set_tension(const Real &x) { tension=x; }
260 const Real &get_continuity()const { return continuity; }
262 void set_continuity(const Real &x) { continuity=x; }
264 const Real &get_bias()const { return bias; }
266 void set_bias(const Real &x) { bias=x; }
268 //! Gets the time of the waypoint
269 const Time &get_time()const { return time; }
270 //! Sets the time of the waypoint
271 void set_time(const Time &x);
273 int get_priority()const { return priority_; }
274 void set_priority(int x) { priority_=x; }
276 //! Gets parent Value Node
277 const etl::loose_handle<ValueNode> &get_parent_value_node()const { return parent_; }
278 //! Sets parent Value Node
279 void set_parent_value_node(const etl::loose_handle<ValueNode> &x) { parent_=x; }
281 //! \true if the Value Node is constant, not null and not exported
282 bool is_static()const;
284 //!! Gets temporal tension
285 float get_temporal_tension()const { return time_tension; }
286 //!! Sets temporal tension
287 void set_temporal_tension(const float& x) { time_tension=x; }
289 //! True if the current waypoint's time is earlier than the compared waypoint's time
290 bool operator<(const Waypoint &rhs)const
291 { return time<rhs.time; }
292 //! True if the current waypoint's time is earlier than the given time
293 bool operator<(const Time &rhs)const
294 { return time.is_less_than(rhs); }
295 //! True if the current waypoint's time is later than the given time
296 bool operator>(const Time &rhs)const
297 { return time.is_more_than(rhs); }
298 //! True if the waypoint's time is the same than the given time
299 bool operator==(const Time &rhs)const
300 { return time.is_equal(rhs); }
301 //! True if the waypoint's time is different than the given time
302 bool operator!=(const Time &rhs)const
303 { return !time.is_equal(rhs); }
305 //! True if the Waypoint's Unique Id is the same than the argument's Unique ID
306 bool operator==(const UniqueID &rhs)const
307 { return get_uid()==rhs.get_uid(); }
308 //! True if the Waypoint's Unique Id is different than the argument's Unique ID
309 bool operator!=(const UniqueID &rhs)const
310 { return get_uid()!=rhs.get_uid(); }
312 //! Clones the Value Node if it is not exported and returns a Waypoint
314 Waypoint clone(const GUID& deriv_guid=GUID())const;
316 //! Returns a hack GUID using the UniqueID's value
317 GUID get_guid()const;
318 }; // END of class Waypoint
320 typedef std::vector< Waypoint > WaypointList;
322 }; // END of namespace synfig
324 /* === E N D =============================================================== */