synfig-studio  1.0.3
timegather.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
22 /* ========================================================================= */
23 
24 /* === S T A R T =========================================================== */
25 
26 #ifndef __SYNFIG_TIMEGATHER_H
27 #define __SYNFIG_TIMEGATHER_H
28 
29 /* === H E A D E R S ======================================================= */
30 #include <synfig/valuenodes/valuenode_animated.h>
31 #include <synfig/valuenodes/valuenode_dynamiclist.h>
32 #include <synfig/time.h>
33 #include "value_desc.h"
34 
35 /* === M A C R O S ========================================================= */
36 
37 /* === T Y P E D E F S ===================================================== */
38 
39 /* === C L A S S E S & S T R U C T S ======================================= */
40 
41 namespace synfig {
42  class Time;
43 }
44 
45 namespace synfigapp {
46 
47 class ValueDesc;
48 
50 {
52  synfig::Real time_dilation;
53  mutable std::set<synfig::Waypoint> waypoints;
54 
55  bool operator<(const ValueBaseTimeInfo &rhs) const
56  {
57  return val == rhs.val ? time_dilation < rhs.time_dilation : val < rhs.val;
58  }
59 };
60 
62 {
63  struct actcmp
64  {
65  bool operator()(const synfig::Activepoint &lhs, const synfig::Activepoint &rhs) const
66  {
67  return lhs.time < rhs.time;
68  }
69  };
70 
72 
73  synfig::Real time_dilation;
74 
75  typedef std::set<synfig::Activepoint,actcmp> set;
76 
77  mutable set activepoints;
78 
79  bool operator<(const ActiveTimeInfo &rhs) const
80  {
82  val.get_index() == rhs.val.get_index() ?
84  val.get_index() < rhs.val.get_index() :
86  }
87 };
88 
90 {
91  typedef std::set<ValueBaseTimeInfo> waytracker;
92  typedef std::set<ActiveTimeInfo> acttracker;
93 
96 
97  void insert(synfig::ValueNode_Animated::Handle v, synfig::Waypoint w, synfig::Real time_dilation = 1);
98  void insert(synfigapp::ValueDesc v, synfig::Activepoint a, synfig::Real time_dilation = 1);
99 };
100 
101 //assumes they're sorted... (incremental advance)
102 //checks the intersection of the two sets... might be something better in the stl
103 template < typename I1, typename I2 >
104 bool check_intersect(I1 b1, I1 end1, I2 b2, I2 end2, synfig::Time time_offset = 0, synfig::Real time_dilation = 1)
105 {
106  if(b1 == end1 || b2 == end2)
107  return false;
108 
109  for(; b1 != end1 && b2 != end2;)
110  {
111  if(*b1 < *b2 * time_dilation + time_offset) ++b1;
112  else if(*b2 * time_dilation + time_offset < *b1) ++b2;
113  else
114  {
115  assert(*b1 == *b2 * time_dilation + time_offset);
116  return true;
117  }
118  }
119  return false;
120 }
121 
122 //gets the closest time inside the set
123 bool get_closest_time(const synfig::Node::time_set &tset, const synfig::Time &t,
124  const synfig::Time &range, synfig::Time &out);
125 
126 //recursion functions based on time restrictions (can be expanded later)...
127 //builds a list of relevant waypoints and activepoints inside the timepoints_ref structure
128 void recurse_valuedesc(synfigapp::ValueDesc valdesc, const std::set<synfig::Time> &tlist,
129  timepoints_ref &vals, synfig::Time time = 0, synfig::Real time_dilation = 1);
130 void recurse_layer(synfig::Layer::Handle layer, const std::set<synfig::Time> &tlist,
131  timepoints_ref &vals, synfig::Time time = 0, synfig::Real time_dilation = 1);
132 void recurse_canvas(synfig::Canvas::Handle canvas, const std::set<synfig::Time> &tlist,
133  timepoints_ref &vals, synfig::Time time = 0, synfig::Real time_dilation = 1);
134 
135 
136 
137 }; // END of namespace studio
138 
139 /* === E N D =============================================================== */
140 
141 #endif