- Main Page
- Related Pages
- Namespaces
- Classes
- Files

# waypoint.h

Go to the documentation of this file.

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