00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef _SO_SUB_INTERPOLATOR_
00052 #define _SO_SUB_INTERPOLATOR_
00053
00054 #include <Inventor/VRMLnodes/SoVRMLInterpolator.h>
00055 #include <Inventor/VRMLnodes/SoVRMLInterpOutputData.h>
00056 #include <Inventor/errors/SoDebugError.h>
00057 #include <Inventor/fields/SoFieldData.h>
00058
00059
00060
00061 #if defined(OIV_IGNORE_VRML_DEPRECATED)
00062 #include <SoDeprecationRules.h>
00063 #pragma push_macro("SoDEPRECATED_CLASS")
00064 #pragma push_macro("SoDEPRECATED_TYPEDEF")
00065 #undef SoDEPRECATED_CLASS
00066 #undef SoDEPRECATED_TYPEDEF
00067 #define SoDEPRECATED_CLASS(x,y)
00068 #define SoDEPRECATED_TYPEDEF(x,y)
00069 #endif
00070
00072
00073
00074
00075 #if defined(_DEBUG)
00076 #define SO__INTERPOLATOR_CHECK_INIT(className) \
00077 if (classTypeId.isBad()) { \
00078 SoDebugError::post("SO_INTERPOLATOR_CONSTRUCTOR", \
00079 "Can't construct an interpolator of type " \
00080 SO__QUOTE(className) \
00081 " until initClass() has been called"); \
00082 className::initClass(); \
00083 } \
00084 SoTypedObject::checkDatabase(SO__QUOTE(className), this, className::getClassTypeId(), classTypeId); \
00085
00086 #define SO__INTERPOLATOR_CHECK_CONSTRUCT(where) \
00087 { \
00088 if (inputData == NULL) { \
00089 SoDebugError::post(where, \
00090 "Instance not properly constructed.\n" \
00091 "Did you forget to put " \
00092 "SO_INTERPOLATOR_CONSTRUCTOR()" \
00093 " in the constructor?"); \
00094 inputData = new SoFieldData(parentInputData ? \
00095 *parentInputData : NULL); \
00096 outputData = new SoVRMLInterpOutputData(parentOutputData ? \
00097 *parentOutputData : NULL); \
00098 } \
00099 }
00100 #else
00101 #define SO__INTERPOLATOR_CHECK_INIT(className) { }
00102 #define SO__INTERPOLATOR_CHECK_CONSTRUCT(where) { }
00103
00104 #endif
00106 //
00107
00108
00109
00111
00112
00113
00114
00115
00116 #define SO_INTERPOLATOR_ABSTRACT_HEADER(className) \
00117 public: \
00118 static SoType getClassTypeId() ; \
00119 virtual SoType getTypeId() const; \
00120 public: \
00121 virtual const SoFieldData * getFieldData() const; \
00122 virtual const SoVRMLInterpOutputData * getOutputData() const; \
00123 private: \
00124 virtual SbBool getIsBuiltIn() const ; \
00125 private: \
00126 static const SoFieldData ** getInputDataPtr() ; \
00127 static const SoVRMLInterpOutputData ** getOutputDataPtr(); \
00128 private: \
00129 static SoType classTypeId; \
00130 static SbBool isBuiltIn; \
00131 static SbBool firstInstance; \
00132 static SoFieldData *inputData; \
00133 static SoVRMLInterpOutputData *outputData; \
00134 static const SoFieldData **parentInputData; \
00135 static const SoVRMLInterpOutputData **parentOutputData
00136
00137 #define SO_INTERPOLATOR_HEADER(className) \
00138 \
00139 SO_INTERPOLATOR_ABSTRACT_HEADER(className); \
00140 \
00141 private: \
00142 static void *createInstance(SoType* dynamicType = NULL)
00143
00145
00146
00147
00148
00149 #define SO__INTERPOLATOR_ABSTRACT_VARS(className) \
00150 SoType className::classTypeId; \
00151 SbBool className::isBuiltIn = FALSE; \
00152 const SoFieldData **className::parentInputData = NULL; \
00153 const SoVRMLInterpOutputData **className::parentOutputData = NULL; \
00154 SoFieldData * className::inputData = NULL; \
00155 SoVRMLInterpOutputData * className::outputData = NULL; \
00156 SbBool className::firstInstance=TRUE
00157
00158 #define SO__INTERPOLATOR_VARS(className) \
00159 SO__INTERPOLATOR_ABSTRACT_VARS(className)
00160
00162
00163
00164
00165
00166 #define SO__INTERPOLATOR_ABSTRACT_METHODS(className) \
00167 SoType \
00168 className::getClassTypeId() { return classTypeId; } \
00169 \
00170 SbBool \
00171 className::getIsBuiltIn() const \
00172 { \
00173 return isBuiltIn; \
00174 } \
00175 \
00176 SoType \
00177 className::getTypeId() const \
00178 { \
00179 return classTypeId; \
00180 } \
00181 \
00182 const SoFieldData * \
00183 className::getFieldData() const \
00184 { \
00185 return inputData; \
00186 } \
00187 \
00188 const SoVRMLInterpOutputData * \
00189 className::getOutputData() const \
00190 { \
00191 return outputData; \
00192 } \
00193 const SoFieldData ** \
00194 className::getInputDataPtr() \
00195 { return (const SoFieldData **)&inputData; } \
00196 const SoVRMLInterpOutputData ** \
00197 className::getOutputDataPtr() \
00198 { return (const SoVRMLInterpOutputData **)&outputData; }
00199
00200
00201 #define SO__INTERPOLATOR_METHODS(className) \
00202 \
00203 SO__INTERPOLATOR_ABSTRACT_METHODS(className) \
00204 \
00205 void * \
00206 className::createInstance(SoType*) \
00207 { \
00208 return (void *)(new className); \
00209 }
00210
00212
00213
00214
00215
00216 #define SO_INTERPOLATOR_SOURCE(className) \
00217 SO__INTERPOLATOR_VARS(className); \
00218 SO__INTERPOLATOR_METHODS(className)
00219
00220 #define SO_INTERPOLATOR_ABSTRACT_SOURCE(className) \
00221 SO__INTERPOLATOR_ABSTRACT_VARS(className); \
00222 SO__INTERPOLATOR_ABSTRACT_METHODS(className)
00223
00225
00226
00227
00228 #if defined(_DEBUG)
00229 #define SO_INTERPOLATOR_INIT_CLASS_CHECK_PARENT(className, parentClass) \
00230 if (parentClass::getClassTypeId().isBad()) { \
00231 SoDebugError::post( SO__QUOTE(className)"::initClass", \
00232 SO__QUOTE(className)" initialized before parent class " \
00233 SO__QUOTE(parentClass)"\n"); \
00234 parentClass::initClass(); \
00235 }
00236 #else
00237 #define SO_INTERPOLATOR_INIT_CLASS_CHECK_PARENT(className, parentClass) \
00238 if (parentClass::getClassTypeId().isBad()) \
00239 parentClass::initClass()
00240
00241 #endif
00242 #define SO__INTERPOLATOR_INIT_CLASS_INTERNAL(className, classPrintName, parentClass) \
00243 SO_INTERPOLATOR_INIT_CLASS_CHECK_PARENT(className, parentClass); \
00244 classTypeId = SoType::createType(parentClass::getClassTypeId(), \
00245 classPrintName, \
00246 &className::createInstance, \
00247 (short)SoNode::getNextActionMethodIndex()); \
00248 parentInputData = parentClass::getInputDataPtr(); \
00249 parentOutputData = parentClass::getOutputDataPtr()
00250
00251 #define SO__INTERPOLATOR_INIT_CLASS(className, classPrintName, parentClass) \
00252 SO__INTERPOLATOR_INIT_CLASS_INTERNAL(className, classPrintName, parentClass)
00253
00254 #define SO__INTERPOLATOR_INIT_ABSTRACT_CLASS_INTERNAL(className,classPrintName,parentClass) \
00255 SO_INTERPOLATOR_INIT_CLASS_CHECK_PARENT(className, parentClass); \
00256 classTypeId = SoType::createType(parentClass::getClassTypeId(), \
00257 classPrintName); \
00258 parentInputData = parentClass::getInputDataPtr(); \
00259 parentOutputData = parentClass::getOutputDataPtr()
00260
00261 #define SO__INTERPOLATOR_INIT_ABSTRACT_CLASS(className,classPrintName,parent) \
00262 SO__INTERPOLATOR_INIT_ABSTRACT_CLASS_INTERNAL(className,classPrintName,parent);
00263
00265
00266
00267
00268
00269
00270
00271 #define SO_INTERPOLATOR_INIT_CLASS_INTERNAL(className,parentClass,parentPrintClass) \
00272 SO_INTERPOLATOR_INIT_CLASS_CHECK_PARENT(className, parentClass); \
00273 classTypeId = SoType::createType(SoType::fromName(parentPrintClass), \
00274 SO__QUOTE(className), \
00275 &className::createInstance); \
00276 parentInputData = parentClass::getInputDataPtr(); \
00277 parentOutputData = parentClass::getOutputDataPtr()
00278
00279 #define SO_INTERPOLATOR_INIT_CLASS(className,parentClass,parentPrintClass) \
00280 SO_INTERPOLATOR_INIT_CLASS_INTERNAL(className,parentClass,parentPrintClass);
00281
00282 #define SO_INTERPOLATOR_INIT_ABSTRACT_CLASS_INTERNAL(className,parentClass,parentPrintClass) \
00283 SO_INTERPOLATOR_INIT_CLASS_CHECK_PARENT(className, parentClass); \
00284 classTypeId = SoType::createType(SoType::fromName(parentPrintClass), SO__QUOTE(className)); \
00285 parentInputData = parentClass::getInputDataPtr(); \
00286 parentOutputData = parentClass::getOutputDataPtr()
00287
00288 #define SO_INTERPOLATOR_INIT_ABSTRACT_CLASS(className, parentClass, parentPrintClass) \
00289 SO_INTERPOLATOR_INIT_ABSTRACT_CLASS_INTERNAL(className,parentClass,parentPrintClass);
00290
00291 #define SO_INTERPOLATOR_EXIT_CLASS(className) \
00292 SoType::removeType(classTypeId.getName()); \
00293 classTypeId = SoType::badType(); \
00294 if (inputData) { \
00295 delete inputData; \
00296 inputData = NULL; \
00297 } \
00298 if (outputData) { \
00299 delete outputData; \
00300 outputData = NULL; \
00301 } \
00302 parentInputData = NULL; \
00303 parentOutputData = NULL; \
00304 firstInstance = TRUE
00305
00307
00308
00309
00310
00311 #define SO_INTERPOLATOR_CONSTRUCTOR(className) \
00312 { \
00313 SO__INTERPOLATOR_CHECK_INIT(className); \
00314 if (inputData == NULL) { \
00315 inputData = new SoFieldData(parentInputData ? \
00316 *parentInputData : NULL); \
00317 outputData = new SoVRMLInterpOutputData(parentOutputData ? \
00318 *parentOutputData : NULL); \
00319 } \
00320 else { \
00321 firstInstance = FALSE; \
00322 } \
00323 isBuiltIn = FALSE; \
00324 }
00325
00327
00328
00329
00330
00331
00332 #define SO_INTERPOLATOR_IS_FIRST_INSTANCE() (firstInstance == TRUE)
00333
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351 #define SO_INTERPOLATOR_ADD_INPUT(inputName, defValue) \
00352 { \
00353 SO__INTERPOLATOR_CHECK_CONSTRUCT(__FILE__); \
00354 if (firstInstance) \
00355 inputData->addField(this, SO__QUOTE(inputName), \
00356 &this->inputName); \
00357 this->inputName.setValue defValue; \
00358 this->inputName.setContainer(this); \
00359 }
00360
00361 #define SO_INTERPOLATOR_ADD_EXPOSEDINPUT(inputName, defValue) \
00362 { \
00363 SO__INTERPOLATOR_CHECK_CONSTRUCT(__FILE__); \
00364 if (firstInstance) \
00365 inputData->addField(this, SO__QUOTE(inputName), &this->inputName); \
00366 this->inputName.setValue defValue; \
00367 this->inputName.setContainer(this); \
00368 this->inputName.setFieldType(SoField::EXPOSED_FIELD); \
00369 }
00370
00371 #define SO_INTERPOLATOR_ADD_EVENTIN(inputName) \
00372 { \
00373 SO__INTERPOLATOR_CHECK_CONSTRUCT(__FILE__); \
00374 if (firstInstance) \
00375 inputData->addField(this, SO__QUOTE(inputName), &this->inputName); \
00376 this->inputName.setContainer(this); \
00377 this->inputName.setFieldType(SoField::EVENTIN_FIELD); \
00378 }
00379
00380 #define SO_INTERPOLATOR_ADD_HIDDEN_FIELD(inputName, defValue) \
00381 { \
00382 SO__INTERPOLATOR_CHECK_CONSTRUCT(__FILE__); \
00383 if (firstInstance) \
00384 inputData->addField(this, SO__QUOTE(inputName), &this->inputName); \
00385 this->inputName.setValue defValue; \
00386 this->inputName.setContainer(this); \
00387 this->inputName.setFieldType(SoField::INTERNAL_FIELD); \
00388 }
00389
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407 #define SO_INTERPOLATOR_ADD_OUTPUT(outputName, type) \
00408 { \
00409 SO__INTERPOLATOR_CHECK_CONSTRUCT(__FILE__); \
00410 if (firstInstance) { \
00411 outputData->addOutput(this, SO__QUOTE(outputName), \
00412 &this->outputName, \
00413 type::getClassTypeId()); \
00414 } \
00415 this->outputName.setContainer(this); \
00416 }
00417
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440 #define SO_INTERPOLATOR_DEFINE_ENUM_VALUE(enumType,enumValue) \
00441 { \
00442 SO__INTERPOLATOR_CHECK_CONSTRUCT(__FILE__); \
00443 if (firstInstance) \
00444 inputData->addEnumValue(SO__QUOTE(enumType), \
00445 SO__QUOTE(enumValue), enumValue); \
00446 }
00447
00449
00450
00451
00452
00453
00454 #define SO_INTERPOLATOR_OUTPUT(outputName,type,code) \
00455 { \
00456 if (outputName.isEnabled()) { \
00457 for (int _eng_out_i = 0; \
00458 _eng_out_i < outputName.getNumConnections(); \
00459 _eng_out_i++) { \
00460 type *_eng_out_temp = (type *) outputName[_eng_out_i]; \
00461 if (!_eng_out_temp->isReadOnly()) { \
00462 _eng_out_temp->code; \
00463 } \
00464 } \
00465 } \
00466 }
00467
00468
00469
00470
00471 #if defined(OIV_IGNORE_VRML_DEPRECATED)
00472 #pragma pop_macro("SoDEPRECATED_TYPEDEF")
00473 #pragma pop_macro("SoDEPRECATED_CLASS")
00474 #endif
00475
00476 #endif
00477