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

# timegather.h

Go to the documentation of this file.

    00001 /* === S Y N F I G ========================================================= */
    00022 /* ========================================================================= */
    00023
    00024 /* === S T A R T =========================================================== */
    00025
    00026 #ifndef __SYNFIG_TIMEGATHER_H
    00027 #define __SYNFIG_TIMEGATHER_H
    00028
    00029 /* === H E A D E R S ======================================================= */
    00030 #include <synfig/valuenode_animated.h>
    00031 #include <synfig/valuenode_dynamiclist.h>
    00032 #include <synfig/time.h>
    00033 #include "value_desc.h"
    00034
    00035 /* === M A C R O S ========================================================= */
    00036
    00037 /* === T Y P E D E F S ===================================================== */
    00038
    00039 /* === C L A S S E S & S T R U C T S ======================================= */
    00040
    00041 namespace synfig {
    00042     class Time;
    00043 }
    00044
    00045 namespace synfigapp {
    00046
    00047 class ValueDesc;
    00048
    00049 struct ValueBaseTimeInfo
    00050 {
    00051     synfig::ValueNode_Animated::Handle  val;
    00052     mutable std::set<synfig::Waypoint>  waypoints;
    00053
    00054     bool operator<(const ValueBaseTimeInfo &rhs) const
    00055     {
    00056         return val < rhs.val;
    00057     }
    00058 };
    00059
    00060 struct ActiveTimeInfo
    00061 {
    00062     struct actcmp
    00063     {
    00064         bool operator()(const synfig::Activepoint &lhs, const synfig::Activepoint &rhs) const
    00065         {
    00066             return lhs.time < rhs.time;
    00067         }
    00068     };
    00069
    00070     synfigapp::ValueDesc                        val;
    00071
    00072     typedef std::set<synfig::Activepoint,actcmp>    set;
    00073
    00074     mutable set activepoints;
    00075
    00076     bool operator<(const ActiveTimeInfo &rhs) const
    00077     {
    00078         return val.get_parent_value_node() == rhs.val.get_parent_value_node() ?
    00079                         val.get_index() < rhs.val.get_index() :
    00080                         val.get_parent_value_node() < rhs.val.get_parent_value_node();
    00081     }
    00082 };
    00083
    00084 struct timepoints_ref
    00085 {
    00086     typedef std::set<ValueBaseTimeInfo>     waytracker;
    00087     typedef std::set<ActiveTimeInfo>    acttracker;
    00088
    00089     waytracker      waypointbiglist;
    00090     acttracker      actpointbiglist;
    00091
    00092     void insert(synfig::ValueNode_Animated::Handle v, synfig::Waypoint w);
    00093     void insert(synfigapp::ValueDesc v, synfig::Activepoint a);
    00094 };
    00095
    00096 //assumes they're sorted... (incremental advance)
    00097 //checks the intersection of the two sets... might be something better in the stl
    00098 template < typename I1, typename I2 >
    00099 bool check_intersect(I1 b1, I1 end1, I2 b2, I2 end2, synfig::Time time_offset = 0)
    00100 {
    00101     if(b1 == end1 || b2 == end2)
    00102         return false;
    00103
    00104     for(; b1 != end1 && b2 != end2;)
    00105     {
    00106         if(*b1 < *b2 + time_offset) ++b1;
    00107         else if(*b2 + time_offset < *b1) ++b2;
    00108         else
    00109         {
    00110             assert(*b1 == *b2 + time_offset);
    00111             return true;
    00112         }
    00113     }
    00114     return false;
    00115 }
    00116
    00117 //gets the closest time inside the set
    00118 bool get_closest_time(const synfig::Node::time_set &tset, const synfig::Time &t,
    00119                         const synfig::Time &range, synfig::Time &out);
    00120
    00121 //recursion functions based on time restrictions (can be expanded later)...
    00122 //builds a list of relevant waypoints and activepoints inside the timepoints_ref structure
    00123 void recurse_valuedesc(synfigapp::ValueDesc valdesc, const std::set<synfig::Time> &tlist,
    00124                                 timepoints_ref &vals, synfig::Time time = 0);
    00125 void recurse_layer(synfig::Layer::Handle layer, const std::set<synfig::Time> &tlist,
    00126                                 timepoints_ref &vals, synfig::Time time = 0);
    00127 void recurse_canvas(synfig::Canvas::Handle canvas, const std::set<synfig::Time> &tlist,
    00128                                 timepoints_ref &vals, synfig::Time time = 0);
    00129
    00130
    00131
    00132 }; // END of namespace studio
    00133
    00134 /* === E N D =============================================================== */
    00135
    00136 #endif