1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
48 ** class MultiPassMaterial!
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
65 #include "OSGPrimeMaterial.h" // Materials Class
67 #include "OSGMultiPassMaterialBase.h"
68 #include "OSGMultiPassMaterial.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::MultiPassMaterial
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var PrimeMaterial * MultiPassMaterialBase::_mfMaterials
91 /***************************************************************************\
92 * FieldType/FieldTrait Instantiation *
93 \***************************************************************************/
95 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
96 PointerType FieldTraits
<MultiPassMaterial
*, nsOSG
>::_type(
97 "MultiPassMaterialPtr",
99 MultiPassMaterial::getClassType(),
103 OSG_FIELDTRAITS_GETTYPE_NS(MultiPassMaterial
*, nsOSG
)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
113 /***************************************************************************\
114 * Field Description *
115 \***************************************************************************/
117 void MultiPassMaterialBase::classDescInserter(TypeObject
&oType
)
119 FieldDescriptionBase
*pDesc
= NULL
;
122 pDesc
= new MFUnrecPrimeMaterialPtr::Description(
123 MFUnrecPrimeMaterialPtr::getClassType(),
126 MaterialsFieldId
, MaterialsFieldMask
,
128 (Field::MFDefaultFlags
| Field::FStdAccess
),
129 static_cast<FieldEditMethodSig
>(&MultiPassMaterial::editHandleMaterials
),
130 static_cast<FieldGetMethodSig
>(&MultiPassMaterial::getHandleMaterials
));
132 oType
.addInitialDesc(pDesc
);
136 MultiPassMaterialBase::TypeObject
MultiPassMaterialBase::_type(
137 MultiPassMaterialBase::getClassname(),
138 Inherited::getClassname(),
141 reinterpret_cast<PrototypeCreateF
>(&MultiPassMaterialBase::createEmptyLocal
),
142 reinterpret_cast<InitContainerF
>(&MultiPassMaterial::initMethod
),
143 reinterpret_cast<ExitContainerF
>(&MultiPassMaterial::exitMethod
),
144 reinterpret_cast<InitalInsertDescFunc
>(
145 reinterpret_cast<void *>(&MultiPassMaterial::classDescInserter
)),
148 "<?xml version=\"1.0\"?>\n"
151 " name=\"MultiPassMaterial\"\n"
152 " parent=\"PrimeMaterial\"\n"
153 " library=\"System\"\n"
154 " pointerfieldtypes=\"both\"\n"
155 " structure=\"concrete\"\n"
156 " systemcomponent=\"true\"\n"
157 " parentsystemcomponent=\"true\"\n"
158 " decoratable=\"false\"\n"
159 " useLocalIncludes=\"false\"\n"
160 " docGroupBase=\"GrpSystemMaterial\"\n"
163 "\t name=\"materials\"\n"
164 "\t type=\"PrimeMaterialPtr\"\n"
165 "\t cardinality=\"multi\"\n"
166 "\t visibility=\"external\"\n"
167 "\t access=\"public\"\n"
168 " pushToFieldAs=\"addMaterial\"\n"
169 " assignMFieldAs=\"assignMaterialsFrom\"\n"
170 " insertIntoMFieldAs=\"insertMaterial\"\n"
171 " replaceInMFieldIndexAs=\"replaceMaterial\"\n"
172 " replaceInMFieldObjectAs=\"replaceMaterialByObj\"\n"
173 " removeFromMFieldIndexAs=\"subMaterial\"\n"
174 " removeFromMFieldObjectAs=\"subMaterialByObj\"\n"
175 " clearFieldAs=\"clearMaterials\"\n"
178 "</FieldContainer>\n",
182 /*------------------------------ get -----------------------------------*/
184 FieldContainerType
&MultiPassMaterialBase::getType(void)
189 const FieldContainerType
&MultiPassMaterialBase::getType(void) const
194 UInt32
MultiPassMaterialBase::getContainerSize(void) const
196 return sizeof(MultiPassMaterial
);
199 /*------------------------- decorator get ------------------------------*/
202 //! Get the MultiPassMaterial::_mfMaterials field.
203 const MFUnrecPrimeMaterialPtr
*MultiPassMaterialBase::getMFMaterials(void) const
205 return &_mfMaterials
;
208 MFUnrecPrimeMaterialPtr
*MultiPassMaterialBase::editMFMaterials (void)
210 editMField(MaterialsFieldMask
, _mfMaterials
);
212 return &_mfMaterials
;
214 PrimeMaterial
* MultiPassMaterialBase::getMaterials(const UInt32 index
) const
216 return _mfMaterials
[index
];
221 void MultiPassMaterialBase::addMaterial(PrimeMaterial
* const value
)
223 editMField(MaterialsFieldMask
, _mfMaterials
);
225 _mfMaterials
.push_back(value
);
228 void MultiPassMaterialBase::assignMaterialsFrom(const MFUnrecPrimeMaterialPtr
&value
)
230 MFUnrecPrimeMaterialPtr::const_iterator elemIt
=
232 MFUnrecPrimeMaterialPtr::const_iterator elemEnd
=
235 static_cast<MultiPassMaterial
*>(this)->clearMaterials();
237 while(elemIt
!= elemEnd
)
239 this->addMaterial(*elemIt
);
245 void MultiPassMaterialBase::subMaterial(UInt32 uiIndex
)
247 if(uiIndex
< _mfMaterials
.size())
249 editMField(MaterialsFieldMask
, _mfMaterials
);
251 _mfMaterials
.erase(uiIndex
);
255 void MultiPassMaterialBase::subMaterialByObj(PrimeMaterial
* const value
)
257 Int32 iElemIdx
= _mfMaterials
.findIndex(value
);
261 editMField(MaterialsFieldMask
, _mfMaterials
);
263 _mfMaterials
.erase(iElemIdx
);
266 void MultiPassMaterialBase::clearMaterials(void)
268 editMField(MaterialsFieldMask
, _mfMaterials
);
271 _mfMaterials
.clear();
276 /*------------------------------ access -----------------------------------*/
278 SizeT
MultiPassMaterialBase::getBinSize(ConstFieldMaskArg whichField
)
280 SizeT returnValue
= Inherited::getBinSize(whichField
);
282 if(FieldBits::NoField
!= (MaterialsFieldMask
& whichField
))
284 returnValue
+= _mfMaterials
.getBinSize();
290 void MultiPassMaterialBase::copyToBin(BinaryDataHandler
&pMem
,
291 ConstFieldMaskArg whichField
)
293 Inherited::copyToBin(pMem
, whichField
);
295 if(FieldBits::NoField
!= (MaterialsFieldMask
& whichField
))
297 _mfMaterials
.copyToBin(pMem
);
301 void MultiPassMaterialBase::copyFromBin(BinaryDataHandler
&pMem
,
302 ConstFieldMaskArg whichField
)
304 Inherited::copyFromBin(pMem
, whichField
);
306 if(FieldBits::NoField
!= (MaterialsFieldMask
& whichField
))
308 editMField(MaterialsFieldMask
, _mfMaterials
);
309 _mfMaterials
.copyFromBin(pMem
);
313 //! create a new instance of the class
314 MultiPassMaterialTransitPtr
MultiPassMaterialBase::createLocal(BitVector bFlags
)
316 MultiPassMaterialTransitPtr fc
;
318 if(getClassType().getPrototype() != NULL
)
320 FieldContainerTransitPtr tmpPtr
=
321 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
323 fc
= dynamic_pointer_cast
<MultiPassMaterial
>(tmpPtr
);
329 //! create a new instance of the class, copy the container flags
330 MultiPassMaterialTransitPtr
MultiPassMaterialBase::createDependent(BitVector bFlags
)
332 MultiPassMaterialTransitPtr fc
;
334 if(getClassType().getPrototype() != NULL
)
336 FieldContainerTransitPtr tmpPtr
=
337 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
339 fc
= dynamic_pointer_cast
<MultiPassMaterial
>(tmpPtr
);
345 //! create a new instance of the class
346 MultiPassMaterialTransitPtr
MultiPassMaterialBase::create(void)
348 MultiPassMaterialTransitPtr fc
;
350 if(getClassType().getPrototype() != NULL
)
352 FieldContainerTransitPtr tmpPtr
=
353 getClassType().getPrototype()-> shallowCopy();
355 fc
= dynamic_pointer_cast
<MultiPassMaterial
>(tmpPtr
);
361 MultiPassMaterial
*MultiPassMaterialBase::createEmptyLocal(BitVector bFlags
)
363 MultiPassMaterial
*returnValue
;
365 newPtr
<MultiPassMaterial
>(returnValue
, bFlags
);
367 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
372 //! create an empty new instance of the class, do not copy the prototype
373 MultiPassMaterial
*MultiPassMaterialBase::createEmpty(void)
375 MultiPassMaterial
*returnValue
;
377 newPtr
<MultiPassMaterial
>(returnValue
, Thread::getCurrentLocalFlags());
379 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
380 ~Thread::getCurrentLocalFlags();
386 FieldContainerTransitPtr
MultiPassMaterialBase::shallowCopyLocal(
387 BitVector bFlags
) const
389 MultiPassMaterial
*tmpPtr
;
391 newPtr(tmpPtr
, dynamic_cast<const MultiPassMaterial
*>(this), bFlags
);
393 FieldContainerTransitPtr
returnValue(tmpPtr
);
395 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
400 FieldContainerTransitPtr
MultiPassMaterialBase::shallowCopyDependent(
401 BitVector bFlags
) const
403 MultiPassMaterial
*tmpPtr
;
405 newPtr(tmpPtr
, dynamic_cast<const MultiPassMaterial
*>(this), ~bFlags
);
407 FieldContainerTransitPtr
returnValue(tmpPtr
);
409 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
414 FieldContainerTransitPtr
MultiPassMaterialBase::shallowCopy(void) const
416 MultiPassMaterial
*tmpPtr
;
419 dynamic_cast<const MultiPassMaterial
*>(this),
420 Thread::getCurrentLocalFlags());
422 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
424 FieldContainerTransitPtr
returnValue(tmpPtr
);
432 /*------------------------- constructors ----------------------------------*/
434 MultiPassMaterialBase::MultiPassMaterialBase(void) :
440 MultiPassMaterialBase::MultiPassMaterialBase(const MultiPassMaterialBase
&source
) :
447 /*-------------------------- destructors ----------------------------------*/
449 MultiPassMaterialBase::~MultiPassMaterialBase(void)
453 void MultiPassMaterialBase::onCreate(const MultiPassMaterial
*source
)
455 Inherited::onCreate(source
);
459 MultiPassMaterial
*pThis
= static_cast<MultiPassMaterial
*>(this);
461 MFUnrecPrimeMaterialPtr::const_iterator MaterialsIt
=
462 source
->_mfMaterials
.begin();
463 MFUnrecPrimeMaterialPtr::const_iterator MaterialsEnd
=
464 source
->_mfMaterials
.end ();
466 while(MaterialsIt
!= MaterialsEnd
)
468 pThis
->addMaterial(*MaterialsIt
);
475 GetFieldHandlePtr
MultiPassMaterialBase::getHandleMaterials (void) const
477 MFUnrecPrimeMaterialPtr::GetHandlePtr
returnValue(
478 new MFUnrecPrimeMaterialPtr::GetHandle(
480 this->getType().getFieldDesc(MaterialsFieldId
),
481 const_cast<MultiPassMaterialBase
*>(this)));
486 EditFieldHandlePtr
MultiPassMaterialBase::editHandleMaterials (void)
488 MFUnrecPrimeMaterialPtr::EditHandlePtr
returnValue(
489 new MFUnrecPrimeMaterialPtr::EditHandle(
491 this->getType().getFieldDesc(MaterialsFieldId
),
494 returnValue
->setAddMethod(
495 boost::bind(&MultiPassMaterial::addMaterial
,
496 static_cast<MultiPassMaterial
*>(this), _1
));
497 returnValue
->setRemoveMethod(
498 boost::bind(&MultiPassMaterial::subMaterial
,
499 static_cast<MultiPassMaterial
*>(this), _1
));
500 returnValue
->setRemoveObjMethod(
501 boost::bind(&MultiPassMaterial::subMaterialByObj
,
502 static_cast<MultiPassMaterial
*>(this), _1
));
503 returnValue
->setClearMethod(
504 boost::bind(&MultiPassMaterial::clearMaterials
,
505 static_cast<MultiPassMaterial
*>(this)));
507 editMField(MaterialsFieldMask
, _mfMaterials
);
513 #ifdef OSG_MT_CPTR_ASPECT
514 void MultiPassMaterialBase::execSyncV( FieldContainer
&oFrom
,
515 ConstFieldMaskArg whichField
,
516 AspectOffsetStore
&oOffsets
,
517 ConstFieldMaskArg syncMode
,
518 const UInt32 uiSyncInfo
)
520 MultiPassMaterial
*pThis
= static_cast<MultiPassMaterial
*>(this);
522 pThis
->execSync(static_cast<MultiPassMaterial
*>(&oFrom
),
531 #ifdef OSG_MT_CPTR_ASPECT
532 FieldContainer
*MultiPassMaterialBase::createAspectCopy(
533 const FieldContainer
*pRefAspect
) const
535 MultiPassMaterial
*returnValue
;
537 newAspectCopy(returnValue
,
538 dynamic_cast<const MultiPassMaterial
*>(pRefAspect
),
539 dynamic_cast<const MultiPassMaterial
*>(this));
545 void MultiPassMaterialBase::resolveLinks(void)
547 Inherited::resolveLinks();
549 static_cast<MultiPassMaterial
*>(this)->clearMaterials();