| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /********************************************************************** 00002 VRS - The Virtual Rendering System 00003 Copyright (C) 2001 Computer Graphics Systems Group at the 00004 Hasso-Plattner-Institute, Potsdam, Germany. 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 This library is distributed in the hope that it will be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 See the GNU Lesser General Public License for more details. 00013 You should have received a copy of the GNU Lesser+ General Public 00014 License along with this library; if not, write to the FreeSoftware 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA, 02111-1307, USA. 00016 **********************************************************************/ 00017 // $Id: timegroup.h 6014 2007-08-09 07:51:16Z Konstantin_Baumann $ 00018 // $Date: 2007-08-09 09:51:16 +0200 (Thu, 09 Aug 2007) $ 00019 // $Revision: 6014 $ 00020 // $State: Exp $ 00021 // $Author: Konstantin_Baumann $ 00022 // 00023 // $Log: timegroup.h,v $ 00024 // Revision 1.29 2005/05/12 12:50:41 lorenz 00025 // Fixed comparison in TimeMark 00026 // 00027 // Revision 1.28 2005/01/03 01:43:10 klimetschek 00028 // - modified win32 project layout, splitted vrs.vcproj into vrs_container, vrs_core, vrs_sg, vrs_image, vrs_opengl and vrs_io 00029 // - removed vrs.vcproj 00030 // minor things: 00031 // - added all glutexamples to vrs4glut.sln 00032 // - fixed some problems in glutexamples 00033 // - removed all project references from all VS projects (using solution wide project dependencies instead) 00034 // 00035 // Revision 1.27 2004/10/28 14:16:01 basch 00036 // Class comment changed (Doxygen style) 00037 // 00038 // Revision 1.26 2004/09/17 07:36:19 heinrich 00039 // bugfix: all behavior nodes that will become children of the time group 00040 // are willfully deactivated since behavior nodes are active by default. 00041 // They will be activated step by step during the evaluation of the time 00042 // group. 00043 // 00044 // Revision 1.25 2004/04/06 13:12:15 baumann 00045 // a time event can store the moment of the previous time event, too 00046 // 00047 // Revision 1.24 2004/03/12 16:28:41 baumann 00048 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00049 // 00050 // Revision 1.23 2004/01/19 11:44:00 baumann 00051 // serialization mechanism improved 00052 // 00053 // Revision 1.22 2003/11/07 14:19:26 kirsch 00054 // removed leading underscore from include guards 00055 // 00056 // Revision 1.21 2003/06/06 11:52:08 kirsch 00057 // include callback.h 00058 // 00059 // Revision 1.20 2003/02/24 10:05:57 baumann 00060 // changed return type of BehaviorNode::handle() and Manipulator::drag*() 00061 // from "int" to "BehaviorNode::InvalidationHint" 00062 // 00063 // Revision 1.19 2002/11/21 12:13:36 baumann 00064 // comments added 00065 // 00066 // Revision 1.18 2002/11/20 13:02:43 baumann 00067 // progress callback added 00068 // 00069 // Revision 1.17 2002/10/29 10:32:53 baumann 00070 // macros VRS_CLASSNAME_* and VRS_IMPL_TYPEINFO_* removed 00071 // 00072 // Revision 1.16 2002/07/02 15:23:48 baumann 00073 // non-persistent containers now have the prefix NonPersistent, e.g. NonPersistentArray<T> 00074 // persistent containers now have no prefix, e.g. Array<T> 00075 // 00076 // Revision 1.15 2002/06/24 14:14:47 baumann 00077 // code cleanup 00078 // 00079 // Revision 1.14 2002/05/15 16:05:11 baumann 00080 // unneeded method BehaviorNode::canHandle() removed (from all sub classes too) 00081 // 00082 // Revision 1.13 2002/03/04 12:04:17 kersting 00083 // directory structure changes 00084 // 00085 // Revision 1.12 2002/03/03 21:44:26 kosta 00086 // VRS_TYPEINFO-macro rewritten 00087 // 00088 // Revision 1.11 2002/03/03 16:37:59 kosta 00089 // changed VRS-typeinfo to C++-typeid 00090 // 00091 // Revision 1.10 2002/02/27 15:03:29 kersting 00092 // renamed Time to VRSTime 00093 // 00094 // Revision 1.9 2002/02/19 10:34:21 kosta 00095 // undone all changes since 2002-02-15 00096 // 00097 // Revision 1.6 2002/02/12 15:04:34 kosta 00098 // VRS container classes completely rewritten using STL 00099 // 00100 // Revision 1.5 2002/02/05 07:48:26 kosta 00101 // new persistency macros: 00102 // VRS_SERIALIZABLE(CLASS_NAME); 00103 // VRS_SERIALIZABLE_ABSTRACT_CLASS(CLASS_NAME); 00104 // VRS_SERIALIZABLE_NO_SO_CLASS(CLASS_NAME) 00105 // 00106 // Revision 1.4 2002/02/04 11:54:37 kosta 00107 // persistency rewritten (for better namespace support) 00108 // 00109 // Revision 1.3 2002/01/15 16:25:55 kosta 00110 // macros rewritten for a better namespace support 00111 // 00112 // Revision 1.2 2001/11/13 16:36:32 kirsch 00113 // changed line feed to unix style (removed control-M) 00114 // 00115 // Revision 1.1.1.1 2001/06/08 08:09:21 kirsch 00116 // imported alpha-version by olli 00117 // 00118 00119 00120 #ifndef VRS_TIMEGROUP_H 00121 #define VRS_TIMEGROUP_H 00122 00123 #include <vrs/callback.h> 00124 #include <vrs/sg/polybehavior.h> 00125 #include <vrs/sg/timeevent.h> 00126 #include <vrs/container/deque.h> 00127 #include <vrs/container/array.h> 00128 00129 namespace VRS { 00130 00132 class VRS_CORE_API TimeGroup : public PolyBehavior { 00133 00134 public: 00135 TimeGroup(); 00136 00137 void append(BehaviorNode* node); 00142 void prepend(BehaviorNode* node); 00147 void insert(int, BehaviorNode* node); 00153 void refreshMarks(BehaviorNode* b); 00154 00155 void remove(int i); 00156 void remove(BehaviorNode* node); 00157 void clear(); 00158 bool contains(BehaviorNode* node) const; 00159 00160 virtual int childNodes() const; 00161 virtual BehaviorNode* childNode(int i) const; 00162 00163 virtual TimeRequirement timeRequirement() const; 00164 00165 virtual void activate(int hint=BehaviorNode::NoHint); 00166 virtual void deactivate(int hint=BehaviorNode::NoHint); 00167 00168 void registerProgressCB(Callback2<const TimeGroup*, unsigned int>* cb); 00169 void unregisterProgressCB(Callback2<const TimeGroup*, unsigned int>* cb); 00174 virtual BehaviorNode::InvalidationHint handle(Event*); 00178 virtual void modified(); 00179 00180 struct TimeMark { 00181 VRSTime time_; 00182 int order_, child_; 00183 bool bound_; 00184 00185 bool operator==(const TimeMark& m) const { 00186 return ((time_ == m.time_) 00187 && (order_ == m.order_) 00188 && (child_ == m.child_) 00189 && (bound_ == m.bound_)); 00190 } 00191 bool operator<(const TimeMark& m) const { 00192 return ((time_ < m.time_) 00193 || (((time_ == m.time_) && (order_ < m.order_)) 00194 || ((time_ == m.time_) && (order_ == m.order_) && (child_ < m.child_)))); 00195 } 00196 }; 00197 00198 struct ChildInterval { 00199 VRSTime start_; 00200 VRSTime end_; 00201 00202 bool operator == (ChildInterval& i) { 00203 return (start_ == i.start_ && end_ == i.end_); 00204 } 00205 }; 00206 00207 VRS_TYPEINFO(TimeGroup, PolyBehavior); 00208 00209 protected: 00210 virtual void childConfiguration(bool inserted, BehaviorNode* node); 00211 00212 virtual TimeRequirement buildTimeRequirements() = 0; 00213 virtual void buildLifeTimes(TimeEvent* firstTimeEvent) = 0; 00214 00215 void registerChild (int child, VRSTime start, VRSTime end); 00216 00217 TimeEvent* timeEvent(const Moment&); 00218 00219 private: 00220 SO<TimeEvent> timeEvent_; 00221 00222 void callProgressCB(unsigned int childIndex) const; 00223 int findMark (VRSTime time, int order); 00224 int processToMark (int, bool shutDown); 00225 int callChildren (VRSTime); 00226 00227 SO<Deque<SO<BehaviorNode> > > children_; 00228 SO<NonPersistentArray<TimeMark> > marks_; 00229 SO<NonPersistentArray<ChildInterval> > intervals_; 00230 VRSTime lastTime_; 00231 int lastMark_; 00232 int direction_; 00233 00234 TimeRequirement totalTimeReq_; 00235 VRSTime startTime_; 00236 VRSTime endTime_; 00237 Clock* clock_; 00238 00239 bool buildTimeReq_; 00240 bool buildLifeTimes_; 00241 }; 00242 00243 } // namespace VRS 00244 00245 #endif // VRS_TIMEGROUP_H