00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __DOP_Parent_h__
00019 #define __DOP_Parent_h__
00020
00021 #include "DOP_API.h"
00022 #include <UT/UT_PtrArray.h>
00023 #include <SIM/SIM_Utils.h>
00024 #include "DOP_FullPathData.h"
00025 #include "DOP_Node.h"
00026
00027 class DOP_Parent;
00028
00029 typedef enum {
00030 DOP_PARENT_CREATED,
00031 DOP_PARENT_DELETED,
00032 DOP_PARENT_REORDERED
00033 } DOP_ParentEventType;
00034
00035 typedef UT_PtrArray<DOP_Parent *> DOP_ParentList;
00036
00037 class DOP_API DOP_Parent
00038 {
00039 public:
00040 DOP_Parent();
00041 virtual ~DOP_Parent();
00042
00043 const DOP_Engine &getEngine() const;
00044 void setNeedsToResimulateLastTimestep();
00045 void setNeedsToFilterData();
00046
00047
00048
00049
00050 void setDOPTime(const SIM_Time &t);
00051
00052
00053 const SIM_Time getDOPTime(const SIM_Time &t) const;
00054
00055
00056 const SIM_Time getGlobalTime(const SIM_Time &t) const;
00057 void resimulate();
00058
00059
00060
00061 bool getNeedsResimulation() const;
00062
00063
00064 const SIM_Time &getOffsetTime() const;
00065 void setOffsetTime(const SIM_Time &t);
00066 fpreal getTimeScale() const;
00067 void setTimeScale(fpreal scale);
00068 bool getAutoResimulation() const;
00069 void setAutoResimulation(bool autoreset);
00070 bool getInterpolateData(const SIM_Time &t) const;
00071 void setInterpolateData(bool interpolate);
00072 bool getIsSimulating() const;
00073 virtual bool getIsTimeless() const { return false; }
00074
00075
00076
00077
00078
00079 void findAllObjectsFromString(const char *objspec,
00080 SIM_ConstObjectArray &objects,
00081 const SIM_Time &t) const;
00082
00083
00084
00085
00086 const SIM_Object *findObjectFromString(const char *objspec,
00087 int whichmatch, int *nummatch,
00088 const SIM_Time &t) const;
00089
00090
00091
00092
00093 void findAllRelationshipsFromString(
00094 const char *relspec,
00095 SIM_ConstDataArray &relationships,
00096 const SIM_Time &t) const;
00097
00098
00099
00100
00101 const SIM_Relationship *findRelationshipFromString(
00102 const char *relspec,
00103 int whichmatch, int *nummatch,
00104 const SIM_Time &t) const;
00105
00106
00107
00108 DOP_Node::DOP_CookData &getDopNodeCookData();
00109
00110
00111
00112
00113
00114
00115 void sendResimulateNotification(
00116 bool callnotify,
00117 bool changingguideparm);
00118
00119
00120 static const DOP_ParentList &getAllDopParents();
00121
00122
00123
00124 static void setMostRecentDopParent(DOP_Parent *dopparent);
00125
00126 protected:
00127 const SIM_Time &getLastSetTime() const;
00128 void resimulateLastTimestep();
00129 DOP_Engine &getEngineProtected();
00130
00131
00132 void setNeedsToFilterData(const SIM_Time &t);
00133
00134 void filterDataIfRequired() const;
00135
00136
00137 void filterData(const SIM_Time &t);
00138
00139 virtual const DOP_Engine &getEngineSubclass() const = 0;
00140 virtual void resimulateLastTimestepSubclass();
00141 virtual void setDOPTimeSubclass(const SIM_Time &t);
00142 virtual DOP_Engine &getEngineProtectedSubclass() = 0;
00143 virtual void filterDataSubclass(const SIM_Time &t) = 0;
00144
00145 void notifySimulationChangeSinksOfChange();
00146 void notifySimulationChangeSinksOfDelete();
00147
00148 private:
00149 UT_PtrArray<DOP_SimulationChangeSink *> mySimulationChangeSinks;
00150 DOP_Node::DOP_CookData myDopNodeCookData;
00151 SIM_Time myLastSetTime;
00152 SIM_Time myOffsetTime;
00153 SIM_Time myNeedsToFilterDataTime;
00154 fpreal myTimeScale;
00155 bool myNeedsToFilterData;
00156 bool mySimulating;
00157 bool myNeedsToResimulateFrame;
00158 bool myNeedsToResimulateCompletely;
00159 bool myAutoResimulation;
00160 bool myInterpolateData;
00161 bool mySendingResimulateNotification;
00162
00163 static DOP_ParentList theDopParents;
00164
00165 friend class DOP_SimulationChangeSink;
00166 };
00167
00168 class DOP_API DOP_SimulationChangeSink
00169 {
00170 public:
00171 DOP_SimulationChangeSink()
00172 { }
00173 virtual ~DOP_SimulationChangeSink()
00174 { removeAllSimulationChangeSinks(); }
00175
00176 virtual void simulationChanged(DOP_Parent *dopparent) = 0;
00177 virtual void simulationDeleted(DOP_Parent *dopparent)
00178 { removeSimulationChangeSink(dopparent); }
00179
00180 protected:
00181 void addSimulationChangeSink(DOP_Parent *dopparent)
00182 {
00183 if( !dopparent ) return;
00184 dopparent->mySimulationChangeSinks.append(this, 1);
00185 myDopParents.append(dopparent, 1);
00186 }
00187 void removeSimulationChangeSink(DOP_Parent *dopparent)
00188 {
00189 if( !dopparent ) return;
00190 dopparent->mySimulationChangeSinks.remove(this);
00191 myDopParents.remove(dopparent);
00192 }
00193 void removeAllSimulationChangeSinks()
00194 {
00195 for( int i = myDopParents.entries(); i --> 0; )
00196 removeSimulationChangeSink(myDopParents(i));
00197 }
00198
00199 private:
00200 UT_PtrArray<DOP_Parent *> myDopParents;
00201 };
00202
00203 #endif