1 /* === S Y N F I G ========================================================= */
3 ** \brief Template Header
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., 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 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_WAYPOINT_H
26 #define __SYNFIG_WAYPOINT_H
28 /* === H E A D E R S ======================================================= */
33 //#include "valuenode.h"
37 #include "interpolation.h"
39 /* === M A C R O S ========================================================= */
41 /* === T Y P E D E F S ===================================================== */
43 /* === C L A S S E S & S T R U C T S ======================================= */
54 class Waypoint : public UniqueID
57 -- ** -- T Y P E S -----------------------------------------------------------
62 typedef synfig::Interpolation Interpolation;
66 friend class Waypoint;
74 Real temporal_tension;
76 bool priority_flag,before_flag,after_flag,tension_flag,continuity_flag,bias_flag,temporal_tension_flag;
80 // we don't need to initialise these 5, but the compiler thinks they're used uninitialised if we don't
81 // and this constructor isn't called often, so it's ok
82 priority(0), tension(0), continuity(0), bias(0), temporal_tension(0),
88 continuity_flag(false),
90 temporal_tension_flag(false) { }
92 Interpolation get_before()const { return before; }
93 void set_before(Interpolation x) { before=x; before_flag=true;}
95 Interpolation get_after()const { return after; }
96 void set_after(Interpolation x) { after=x; after_flag=true;}
98 const Real &get_tension()const { return tension; }
99 void set_tension(const Real &x) { tension=x; tension_flag=true;}
101 const Real &get_continuity()const { return continuity; }
102 void set_continuity(const Real &x) { continuity=x; continuity_flag=true;}
104 const Real &get_bias()const { return bias; }
105 void set_bias(const Real &x) { bias=x; bias_flag=true;}
107 const Real &get_temporal_tension()const { return temporal_tension; }
108 void set_temporal_tension(const Real &x) { temporal_tension=x; temporal_tension_flag=true;}
110 int get_priority()const { return priority; }
111 void set_priority(int x) { priority=x; priority_flag=true;}
113 #define FLAG_MACRO(x) bool get_##x##_flag()const { return x##_flag; } void set_##x##_flag(bool y) { x##_flag=y; }
118 FLAG_MACRO(continuity)
120 FLAG_MACRO(temporal_tension)
129 continuity_flag=false;
131 temporal_tension_flag=false;
134 bool is_trivial()const
143 temporal_tension_flag
149 -- ** -- D A T A -------------------------------------------------------------
155 etl::loose_handle<ValueNode> parent_;
157 Interpolation before, after;
159 etl::rhandle<ValueNode> value_node;
163 // The following are for the INTERPOLATION_TCB type
168 // The following are for the INTERPOLATION_MANUAL type
169 ValueBase cpoint_before,cpoint_after;
175 -- ** -- C O N S T R U C T O R S ---------------------------------------------
180 Waypoint(ValueBase value, Time time);
181 Waypoint(etl::handle<ValueNode> value_node, Time time);
186 -- ** -- M E M B E R F U N C T I O N S -------------------------------------
191 void apply_model(const Model &x);
193 Interpolation get_before()const { return before; }
194 void set_before(Interpolation x) { before=x; }
196 Interpolation get_after()const { return after; }
197 void set_after(Interpolation x) { after=x; }
199 ValueBase get_value()const;
200 ValueBase get_value(const Time &t)const;
201 void set_value(const ValueBase &x);
203 const etl::rhandle<ValueNode> &get_value_node()const { return value_node; }
204 void set_value_node(const etl::handle<ValueNode> &x);
206 const Real &get_tension()const { return tension; }
207 void set_tension(const Real &x) { tension=x; }
209 const Real &get_continuity()const { return continuity; }
210 void set_continuity(const Real &x) { continuity=x; }
212 const Real &get_bias()const { return bias; }
213 void set_bias(const Real &x) { bias=x; }
215 const Time &get_time()const { return time; }
216 void set_time(const Time &x);
218 int get_priority()const { return priority_; }
219 void set_priority(int x) { priority_=x; }
221 const etl::loose_handle<ValueNode> &get_parent_value_node()const { return parent_; }
222 void set_parent_value_node(const etl::loose_handle<ValueNode> &x) { parent_=x; }
224 bool is_static()const;
226 float get_time_tension()const { return time_tension; }
227 void set_time_tension(const float& x) { time_tension=x; }
228 float get_temporal_tension()const { return time_tension; }
229 void set_temporal_tension(const float& x) { time_tension=x; }
231 bool operator<(const Waypoint &rhs)const
232 { return time<rhs.time; }
234 bool operator<(const Time &rhs)const
235 { return time.is_less_than(rhs); }
236 bool operator>(const Time &rhs)const
237 { return time.is_more_than(rhs); }
239 bool operator==(const Time &rhs)const
240 { return time.is_equal(rhs); }
241 bool operator!=(const Time &rhs)const
242 { return !time.is_equal(rhs); }
244 bool operator==(const UniqueID &rhs)const
245 { return get_uid()==rhs.get_uid(); }
246 bool operator!=(const UniqueID &rhs)const
247 { return get_uid()!=rhs.get_uid(); }
249 Waypoint clone(const GUID& deriv_guid=GUID())const;
251 GUID get_guid()const;
252 }; // END of class Waypoint
254 typedef std::vector< Waypoint > WaypointList;
256 }; // END of namespace synfig
258 /* === E N D =============================================================== */