00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __DOP_Node__
00021 #define __DOP_Node__
00022
00023 #include "DOP_API.h"
00024 #include <SIM/SIM_Utils.h>
00025 #include <OP/OP_PreDefRules.h>
00026 #include <OP/OP_Network.h>
00027 #include "DOP_Error.h"
00028
00029 #define DOP_MAX_NUMINPUTS 10
00030 #define DOP_MAX_NUMOUTPUTS 4
00031
00032 class OP_OperatorTable;
00033 class SIM_Data;
00034 class SIM_Object;
00035 class SIM_ObjectArray;
00036 class SIM_RootData;
00037 class SIM_Options;
00038 class SIM_Relationship;
00039 class DOP_InOutInfo;
00040 class DOP_Output;
00041 class DOP_Engine;
00042
00043
00044 extern "C" {
00045 DLLEXPORT extern void newDopOperator(OP_OperatorTable *table);
00046 };
00047
00048
00049
00050
00051
00052 enum {
00053 DOP_VAR_SIMTIME,
00054 DOP_VAR_SIMFRAME,
00055 DOP_VAR_SIMFRAME1,
00056 DOP_VAR_SIMFRAME2,
00057 DOP_VAR_SIMFRAME3,
00058 DOP_VAR_SIMFRAME4,
00059 DOP_VAR_SIMFRAME5,
00060 DOP_VAR_SIMFRAME6,
00061 DOP_VAR_SIMFRAME7,
00062 DOP_VAR_SIMFRAME8,
00063 DOP_VAR_SIMFRAME9,
00064 DOP_VAR_SFPS,
00065 DOP_VAR_TIMESTEP,
00066 DOP_VAR_SIMNOBJ,
00067 DOP_VAR_OBJ,
00068 DOP_VAR_NOBJ,
00069 DOP_VAR_OBJID,
00070 DOP_VAR_OBJCT,
00071 DOP_VAR_OBJCF,
00072 DOP_VAR_DOPNET,
00073 DOP_VAR_OBJNAME,
00074 DOP_VAR_ALLOBJNAMES,
00075 DOP_VAR_ALLOBJIDS,
00076 DOP_VAR_RELNAME,
00077 DOP_VAR_RELOBJNAMES,
00078 DOP_VAR_RELOBJIDS,
00079 DOP_VAR_RELAFFOBJNAMES,
00080 DOP_VAR_RELAFFOBJIDS,
00081 DOP_NUM_DOP_VARS
00082 };
00083
00084
00085 class DOP_API DOP_Node : public OP_Network
00086 {
00087 public:
00088
00089 DOP_Node(OP_Network *dad, const char *name,
00090 OP_Operator *entry);
00091
00092 virtual ~DOP_Node();
00093
00094
00095
00096 static OP_VariablePair theVariablePair;
00097 static CH_LocalVariable theVariables[];
00098
00099
00100
00101 static void buildActivationRules(void *data,
00102 PRM_Name* menu,
00103 int maxSize,
00104 const PRM_SpareData*,
00105 PRM_Parm *);
00106
00107
00108 static int setActivationCallback(void *data,
00109 int index,
00110 float t,
00111 const PRM_Template *);
00112
00113
00114
00115
00116 void applyDataFromInput(fpreal time, int inputidx,
00117 int inputidxforsuffix,
00118 SIM_RootData &rootdata,
00119 const char *parentdataname,
00120 DOP_Engine &engine,
00121 UT_StringArray *datanames,
00122 bool changeuniquenamesuffix);
00123
00124
00125
00126
00127 void getRequiredOutputs(fpreal time, int foroutputidx,
00128 UT_RefArray<DOP_Output> &outputs,
00129 const DOP_Engine &engine);
00130
00131
00132 void partitionObjects(fpreal time,
00133 const SIM_ObjectArray &objects,
00134 const UT_PtrArray<SIM_ObjectArray *> &p,
00135 const DOP_Engine &engine);
00136
00137
00138 void processObjects(fpreal time, int foroutputidx,
00139 const SIM_ObjectArray &objects,
00140 DOP_Engine &engine);
00141
00142
00143
00144 void applyOutputData(fpreal time, int outputidx,
00145 SIM_RootData &rootdata,
00146 const char *parentdataname,
00147 DOP_Engine &engine,
00148 UT_StringArray *datanames);
00149
00150
00151
00152 void preNetworkProcessing(DOP_Engine &engine);
00153
00154
00155
00156 void postNetworkProcessing(DOP_Engine &engine);
00157
00158
00159 void getInputInfo(int inputidx, DOP_InOutInfo &info);
00160
00161
00162 void getOutputInfo(int outputidx, DOP_InOutInfo &info);
00163
00164
00165 void addError(int code, const char *msg = 0)
00166 { UTaddError("DOP", code, msg);}
00167
00168 void addMessage(DOP_ErrorCode code, const char *msg = 0)
00169 { UTaddMessage("DOP", code, msg);}
00170
00171 void addWarning(DOP_ErrorCode code, const char *msg = 0)
00172 { UTaddWarning("DOP", code, msg);}
00173
00174 void addFatal(DOP_ErrorCode code, const char *msg = 0)
00175 { UTaddFatal("DOP", code, msg);}
00176
00177
00178 virtual const char *getChildType() const;
00179
00180 virtual const char *getOpType() const;
00181
00182
00183 virtual OP_OpTypeId getChildTypeID() const;
00184
00185 virtual OP_OpTypeId getOpTypeID() const;
00186
00187
00188
00189
00190 virtual OP_Node *getRenderNodePtr();
00191
00192
00193 virtual const char *inputLabel(unsigned idx) const;
00194
00195
00196
00197
00198 virtual void opChanged(OP_EventType reason, void *data=0);
00199
00200
00201
00202 virtual void referencedParmChanged(int pi);
00203
00204
00205 virtual float getVariableValue(int index, int thread);
00206
00207 virtual void getVariableString(int index, UT_String &value,
00208 int thread);
00209
00210
00211 static void buildOperatorTable(OP_OperatorTable &table);
00212
00213 static void initializeExpressions();
00214
00215 static void installCommands();
00216
00217
00218 virtual fpreal getW() const;
00219
00220 virtual fpreal getH() const;
00221
00222
00223 virtual int getDandROpsEqual();
00224 virtual int updateDandROpsEqual(int check_inputs = 1);
00225
00226
00227
00228 virtual void clearInterrupted();
00229
00230
00231 virtual void getNodeSpecificInfoText(OP_Context &context,
00232 int verbose,
00233 UT_WorkBuffer &text);
00234
00235
00236
00237 virtual DOP_Parent *castToDOPParent();
00238
00239
00240 virtual const DOP_Parent *castToDOPParent() const;
00241
00242
00243
00244
00245 virtual OP_ERROR setInput(unsigned idx, OP_Node *op,
00246 unsigned outputIdx = 0);
00247 virtual OP_ERROR setInputReference(unsigned idx, const char *label,
00248 int keeppos, unsigned outputIdx = 0);
00249
00250 virtual bool hasDifferentMultiInputs() const;
00251
00252
00253
00254
00255 void setCurrentObject(int objectindex,
00256 int objectcount,
00257 const SIM_Object *object);
00258
00259
00260
00261 void setCurrentRel(const SIM_Relationship *rel);
00262
00263
00264 void copyCurrentObjectAndRelInto(DOP_Node *dest) const;
00265
00266 void clearCurrentObjectAndRel();
00267
00268 protected:
00269
00270 virtual OP_ERROR cookMe(OP_Context &);
00271
00272 virtual OP_ERROR bypassMe(OP_Context &, int &);
00273
00274 virtual const char *getFileExtension(int binary) const;
00275
00276 virtual void childFlagChange(OP_Node *);
00277
00278 OP_ERROR checkInputValidity();
00279
00280
00281
00282 virtual bool cookedDataUsesAllParameters() const
00283 { return true; }
00284
00285
00286 virtual OP_DATA_TYPE getCookedDataType() const;
00287
00288 virtual void deleteCookedData();
00289
00290 virtual int saveCookedData(const char *, OP_Context &);
00291
00292 virtual int saveCookedData(ostream &, OP_Context &, int);
00293
00294
00295
00296
00297
00298
00299
00300 virtual int propagateModification(OP_Node *by_whom,
00301 OP_EventType reason,
00302 int parm_index,
00303 OP_PropagateData &prop_data);
00304
00305
00306
00307
00308
00309
00310 bool isActive(float time);
00311
00312
00313 virtual void getRequiredOutputsSubclass(fpreal time,
00314 int foroutputidx,
00315 UT_RefArray<DOP_Output> &outputs,
00316 const DOP_Engine &engine);
00317
00318 virtual void partitionObjectsSubclass(fpreal time,
00319 const SIM_ObjectArray &objects,
00320 const UT_PtrArray<SIM_ObjectArray *> &p,
00321 const DOP_Engine &engine);
00322
00323 virtual void processObjectsSubclass(fpreal time,
00324 int foroutputidx,
00325 const SIM_ObjectArray &objects,
00326 DOP_Engine &engine);
00327
00328
00329 virtual void applyOutputDataSubclass(fpreal time, int outputidx,
00330 SIM_RootData &rootdata,
00331 const char *parentdataname,
00332 DOP_Engine &engine,
00333 UT_StringArray *datanames);
00334
00335
00336 virtual void preNetworkProcessingSubclass(DOP_Engine &engine);
00337
00338
00339 virtual void postNetworkProcessingSubclass(DOP_Engine &engine);
00340
00341 virtual void getInputInfoSubclass(int inputidx,
00342 DOP_InOutInfo &info);
00343
00344 virtual void getOutputInfoSubclass(int outputidx,
00345 DOP_InOutInfo &info);
00346
00347
00348
00349 void makeFullDataName(const char *root,
00350 UT_String &name) const;
00351
00352
00353 void appendUniqueDataNameSuffix(UT_String &dataname,
00354 bool usenodepath) const;
00355
00356 private:
00357 class DOP_CookData
00358 {
00359 public:
00360 UT_String myApplyingDataToInput;
00361 };
00362
00363 DOP_CookData &getCookData() const;
00364 void handleNodeChange(OP_EventType reason, void *data);
00365
00366 const SIM_ObjectArray *myCurrentObjects;
00367 int myCurrentObjectIndex;
00368 int myCurrentObjectCount;
00369 const SIM_Object *myCurrentObject;
00370 const SIM_Relationship *myCurrentRel;
00371 bool myIsBusy;
00372 bool myIsGettingInputInfo;
00373 bool myIsGettingOutputInfo;
00374 static UT_String theApplyingDataToInput;
00375 static OP_PreDefRules theActivationRules;
00376
00377 friend class DOP_Parent;
00378 };
00379
00380 #endif