waypoint.h

Go to the documentation of this file.
00001 /* === S Y N F I G ========================================================= */
00021 /* ========================================================================= */
00022 
00023 /* === S T A R T =========================================================== */
00024 
00025 #ifndef __SYNFIG_WAYPOINT_H
00026 #define __SYNFIG_WAYPOINT_H
00027 
00028 /* === H E A D E R S ======================================================= */
00029 
00030 #include "time.h"
00031 #include "real.h"
00032 #include "value.h"
00033 //#include "valuenode.h"
00034 #include "uniqueid.h"
00035 #include <vector>
00036 #include "guid.h"
00037 #include "interpolation.h"
00038 
00039 /* === M A C R O S ========================================================= */
00040 
00041 /* === T Y P E D E F S ===================================================== */
00042 
00043 /* === C L A S S E S & S T R U C T S ======================================= */
00044 
00045 namespace synfig {
00046 
00047 class ValueNode;
00048 class GUID;
00049 
00050 
00054 class Waypoint : public UniqueID
00055 {
00056     /*
00057  -- ** -- T Y P E S -----------------------------------------------------------
00058     */
00059 
00060 public:
00061 
00062     typedef synfig::Interpolation Interpolation;
00063 
00064     class Model
00065     {
00066         friend class Waypoint;
00067 
00068         int priority;
00069         Interpolation before;
00070         Interpolation after;
00071         Real tension;
00072         Real continuity;
00073         Real bias;
00074         Real temporal_tension;
00075 
00076         bool priority_flag,before_flag,after_flag,tension_flag,continuity_flag,bias_flag,temporal_tension_flag;
00077 
00078     public:
00079         Model():
00080             priority_flag(false),
00081             before_flag(false),
00082             after_flag(false),
00083             tension_flag(false),
00084             continuity_flag(false),
00085             bias_flag(false),
00086             temporal_tension_flag(false) { }
00087 
00088         Interpolation get_before()const { return before; }
00089         void set_before(Interpolation x) { before=x; before_flag=true;}
00090 
00091         Interpolation get_after()const { return after; }
00092         void set_after(Interpolation x) { after=x; after_flag=true;}
00093 
00094         const Real &get_tension()const { return tension; }
00095         void set_tension(const Real &x) { tension=x; tension_flag=true;}
00096 
00097         const Real &get_continuity()const { return continuity; }
00098         void set_continuity(const Real &x) { continuity=x; continuity_flag=true;}
00099 
00100         const Real &get_bias()const { return bias; }
00101         void set_bias(const Real &x) { bias=x; bias_flag=true;}
00102 
00103         const Real &get_temporal_tension()const { return temporal_tension; }
00104         void set_temporal_tension(const Real &x) { temporal_tension=x; temporal_tension_flag=true;}
00105 
00106         int get_priority()const { return priority; }
00107         void set_priority(int x) { priority=x; priority_flag=true;}
00108 
00109         #define FLAG_MACRO(x) bool get_##x##_flag()const { return x##_flag; } void set_##x##_flag(bool y) { x##_flag=y; }
00110         FLAG_MACRO(priority)
00111         FLAG_MACRO(before)
00112         FLAG_MACRO(after)
00113         FLAG_MACRO(tension)
00114         FLAG_MACRO(continuity)
00115         FLAG_MACRO(bias)
00116         FLAG_MACRO(temporal_tension)
00117         #undef FLAG_MACRO
00118 
00119         void reset()
00120         {
00121             priority_flag=false;
00122             before_flag=false;
00123             after_flag=false;
00124             tension_flag=false;
00125             continuity_flag=false;
00126             bias_flag=false;
00127             temporal_tension_flag=false;
00128         }
00129 
00130         bool is_trivial()const
00131         {
00132             return !(
00133                 priority_flag||
00134                 before_flag||
00135                 after_flag||
00136                 tension_flag||
00137                 continuity_flag||
00138                 bias_flag||
00139                 temporal_tension_flag
00140             );
00141         }
00142     };
00143 
00144     /*
00145  -- ** -- D A T A -------------------------------------------------------------
00146     */
00147 
00148 private:
00149 
00150     int priority_;
00151     etl::loose_handle<ValueNode> parent_;
00152 
00153     Interpolation before, after;
00154 
00155     etl::rhandle<ValueNode> value_node;
00156 
00157     Time time;
00158 
00159     // The following are for the INTERPOLATION_TCB type
00160     Real tension;
00161     Real continuity;
00162     Real bias;
00163 
00164     // The following are for the INTERPOLATION_MANUAL type
00165     ValueBase cpoint_before,cpoint_after;
00166 
00167 
00168     float time_tension;
00169 
00170     /*
00171  -- ** -- C O N S T R U C T O R S ---------------------------------------------
00172     */
00173 
00174 public:
00175 
00176     Waypoint(ValueBase value, Time time);
00177     Waypoint(etl::handle<ValueNode> value_node, Time time);
00178 
00179     Waypoint();
00180 
00181     /*
00182  -- ** -- M E M B E R   F U N C T I O N S -------------------------------------
00183     */
00184 
00185 public:
00186 
00187     void apply_model(const Model &x);
00188 
00189     Interpolation get_before()const { return before; }
00190     void set_before(Interpolation x) { before=x; }
00191 
00192     Interpolation get_after()const { return after; }
00193     void set_after(Interpolation x) { after=x; }
00194 
00195     ValueBase get_value()const;
00196     ValueBase get_value(const Time &t)const;
00197     void set_value(const ValueBase &x);
00198 
00199     const etl::rhandle<ValueNode> &get_value_node()const { return value_node; }
00200     void set_value_node(const etl::handle<ValueNode> &x);
00201 
00202     const Real &get_tension()const { return tension; }
00203     void set_tension(const Real &x) { tension=x; }
00204 
00205     const Real &get_continuity()const { return continuity; }
00206     void set_continuity(const Real &x) { continuity=x; }
00207 
00208     const Real &get_bias()const { return bias; }
00209     void set_bias(const Real &x) { bias=x; }
00210 
00211     const Time &get_time()const { return time; }
00212     void set_time(const Time &x);
00213 
00214     int get_priority()const { return priority_; }
00215     void set_priority(int x) { priority_=x; }
00216 
00217     const etl::loose_handle<ValueNode> &get_parent_value_node()const { return parent_; }
00218     void set_parent_value_node(const etl::loose_handle<ValueNode> &x) { parent_=x; }
00219 
00220     bool is_static()const;
00221 
00222     float get_time_tension()const { return time_tension; }
00223     void set_time_tension(const float& x) { time_tension=x; }
00224     float get_temporal_tension()const { return time_tension; }
00225     void set_temporal_tension(const float& x) { time_tension=x; }
00226 
00227     bool operator<(const Waypoint &rhs)const
00228     { return time<rhs.time; }
00229 
00230     bool operator<(const Time &rhs)const
00231     { return time.is_less_than(rhs); }
00232     bool operator>(const Time &rhs)const
00233     { return time.is_more_than(rhs); }
00234 
00235     bool operator==(const Time &rhs)const
00236     { return time.is_equal(rhs); }
00237     bool operator!=(const Time &rhs)const
00238     { return !time.is_equal(rhs); }
00239 
00240     bool operator==(const UniqueID &rhs)const
00241     { return get_uid()==rhs.get_uid(); }
00242     bool operator!=(const UniqueID &rhs)const
00243     { return get_uid()!=rhs.get_uid(); }
00244 
00245     Waypoint clone(const GUID& deriv_guid=GUID())const;
00246 
00247     GUID get_guid()const;
00248 }; // END of class Waypoint
00249 
00250 typedef std::vector< Waypoint > WaypointList;
00251 
00252 }; // END of namespace synfig
00253 
00254 /* === E N D =============================================================== */
00255 
00256 #endif

Generated on Wed Aug 15 05:00:23 2007 for synfig by  doxygen 1.5.3