X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fsynfigapp%2Ftimegather.h;h=a878d141e426651a5c8235d14f518b685e652f3a;hb=334e15ce6c4d9b1f30a168a55e7ef4d31320d568;hp=f944a71eb6e97f3791d8391aeb1dbe856b905b88;hpb=02252941b29de64037116f4d37991a38d9ff0d94;p=synfig.git diff --git a/synfig-studio/trunk/src/synfigapp/timegather.h b/synfig-studio/trunk/src/synfigapp/timegather.h index f944a71..a878d14 100644 --- a/synfig-studio/trunk/src/synfigapp/timegather.h +++ b/synfig-studio/trunk/src/synfigapp/timegather.h @@ -2,19 +2,21 @@ /*! \file timegather.h ** \brief Time Gather Header ** -** $Id: timegather.h,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $ +** $Id$ ** ** \legal ** Copyright (c) 2004 Adrian Bentley +** Copyright (c) 2007 Chris Moore ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -36,16 +38,19 @@ /* === C L A S S E S & S T R U C T S ======================================= */ +namespace synfig { + class Time; +} + namespace synfigapp { class ValueDesc; -class synfig::Time; struct ValueBaseTimeInfo { synfig::ValueNode_Animated::Handle val; mutable std::set waypoints; - + bool operator<(const ValueBaseTimeInfo &rhs) const { return val < rhs.val; @@ -59,72 +64,68 @@ struct ActiveTimeInfo bool operator()(const synfig::Activepoint &lhs, const synfig::Activepoint &rhs) const { return lhs.time < rhs.time; - } + } }; - + synfigapp::ValueDesc val; - + typedef std::set set; - + mutable set activepoints; - + bool operator<(const ActiveTimeInfo &rhs) const { - return val.get_parent_value_node() == rhs.val.get_parent_value_node() ? - val.get_index() < rhs.val.get_index() : + return val.get_parent_value_node() == rhs.val.get_parent_value_node() ? + val.get_index() < rhs.val.get_index() : val.get_parent_value_node() < rhs.val.get_parent_value_node(); } }; struct timepoints_ref { - typedef std::set waytracker; + typedef std::set waytracker; typedef std::set acttracker; - + waytracker waypointbiglist; - acttracker actpointbiglist; - - void insert(synfig::ValueNode_Animated::Handle v, synfig::Waypoint w); + acttracker actpointbiglist; + + void insert(synfig::ValueNode_Animated::Handle v, synfig::Waypoint w); void insert(synfigapp::ValueDesc v, synfig::Activepoint a); }; //assumes they're sorted... (incremental advance) //checks the intersection of the two sets... might be something better in the stl template < typename I1, typename I2 > -bool check_intersect(I1 b1, I1 end1, I2 b2, I2 end2) +bool check_intersect(I1 b1, I1 end1, I2 b2, I2 end2, synfig::Time time_offset = 0) { - if(b1 == end1 || b2 == end2) + if(b1 == end1 || b2 == end2) return false; - + for(; b1 != end1 && b2 != end2;) { - if(*b1 < *b2) ++b1; - else if(*b2 < *b1) ++b2; + if(*b1 < *b2 + time_offset) ++b1; + else if(*b2 + time_offset < *b1) ++b2; else { - assert(*b1 == *b2); + assert(*b1 == *b2 + time_offset); return true; } } return false; } -//pointer kind of a hack, gets the accurate times from a value desc -// (deals with dynamic list member correctly... i.e. gathers activepoints) -const synfig::Node::time_set *get_times_from_vdesc(const synfigapp::ValueDesc &v); - -//get's the closest time inside the set -bool get_closest_time(const synfig::Node::time_set &tset, const synfig::Time &t, +//gets the closest time inside the set +bool get_closest_time(const synfig::Node::time_set &tset, const synfig::Time &t, const synfig::Time &range, synfig::Time &out); //recursion functions based on time restrictions (can be expanded later)... //builds a list of relevant waypoints and activepoints inside the timepoints_ref structure void recurse_valuedesc(synfigapp::ValueDesc valdesc, const std::set &tlist, - timepoints_ref &vals); -void recurse_layer(synfig::Layer::Handle layer, const std::set &tlist, - timepoints_ref &vals); -void recurse_canvas(synfig::Canvas::Handle canvas, const std::set &tlist, - timepoints_ref &vals); + timepoints_ref &vals, synfig::Time time = 0); +void recurse_layer(synfig::Layer::Handle layer, const std::set &tlist, + timepoints_ref &vals, synfig::Time time = 0); +void recurse_canvas(synfig::Canvas::Handle canvas, const std::set &tlist, + timepoints_ref &vals, synfig::Time time = 0);