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 ChunkOverrideGroup!
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 "OSGChunkBlock.h" // FallbackChunkBlock Class
67 #include "OSGChunkOverrideGroupBase.h"
68 #include "OSGChunkOverrideGroup.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::ChunkOverrideGroup
79 ChunkOverrideGroup is a simple group node that allows for material chunks
80 to be set that will override all chunks stored in materials in the entire
81 subtree. Currently the last chunk override wins (note the difference to
82 the material group). This might change in future.
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var ChunkBlock * ChunkOverrideGroupBase::_sfFallbackChunkBlock
93 /*! \var bool ChunkOverrideGroupBase::_sfSubOverride
94 If true, the ChunkOverrideGroup group does not add new override chunks,
95 but subtract the chunks from the list of already defined override chunks.
96 Basically, that allows to negate overrides at a deeper level in the scene graph.
100 /***************************************************************************\
101 * FieldType/FieldTrait Instantiation *
102 \***************************************************************************/
104 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
105 PointerType FieldTraits
<ChunkOverrideGroup
*, nsOSG
>::_type(
106 "ChunkOverrideGroupPtr",
108 ChunkOverrideGroup::getClassType(),
112 OSG_FIELDTRAITS_GETTYPE_NS(ChunkOverrideGroup
*, nsOSG
)
114 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
115 ChunkOverrideGroup
*,
118 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
119 ChunkOverrideGroup
*,
122 /***************************************************************************\
123 * Field Description *
124 \***************************************************************************/
126 void ChunkOverrideGroupBase::classDescInserter(TypeObject
&oType
)
128 FieldDescriptionBase
*pDesc
= NULL
;
131 pDesc
= new SFUnrecChunkBlockPtr::Description(
132 SFUnrecChunkBlockPtr::getClassType(),
133 "fallbackChunkBlock",
135 FallbackChunkBlockFieldId
, FallbackChunkBlockFieldMask
,
137 (Field::SFDefaultFlags
| Field::FStdAccess
),
138 static_cast<FieldEditMethodSig
>(&ChunkOverrideGroup::editHandleFallbackChunkBlock
),
139 static_cast<FieldGetMethodSig
>(&ChunkOverrideGroup::getHandleFallbackChunkBlock
));
141 oType
.addInitialDesc(pDesc
);
143 pDesc
= new SFBool::Description(
144 SFBool::getClassType(),
146 "If true, the ChunkOverrideGroup group does not add new override chunks, \n"
147 "but subtract the chunks from the list of already defined override chunks.\n"
148 "Basically, that allows to negate overrides at a deeper level in the scene graph.\n",
149 SubOverrideFieldId
, SubOverrideFieldMask
,
151 (Field::SFDefaultFlags
| Field::FStdAccess
),
152 static_cast<FieldEditMethodSig
>(&ChunkOverrideGroup::editHandleSubOverride
),
153 static_cast<FieldGetMethodSig
>(&ChunkOverrideGroup::getHandleSubOverride
));
155 oType
.addInitialDesc(pDesc
);
159 ChunkOverrideGroupBase::TypeObject
ChunkOverrideGroupBase::_type(
160 ChunkOverrideGroupBase::getClassname(),
161 Inherited::getClassname(),
164 reinterpret_cast<PrototypeCreateF
>(&ChunkOverrideGroupBase::createEmptyLocal
),
165 reinterpret_cast<InitContainerF
>(&ChunkOverrideGroup::initMethod
),
166 reinterpret_cast<ExitContainerF
>(&ChunkOverrideGroup::exitMethod
),
167 reinterpret_cast<InitalInsertDescFunc
>(
168 reinterpret_cast<void *>(&ChunkOverrideGroup::classDescInserter
)),
171 "<?xml version=\"1.0\"?>\n"
174 " name=\"ChunkOverrideGroup\"\n"
175 " parent=\"Group\"\n"
176 " library=\"System\"\n"
177 " pointerfieldtypes=\"both\"\n"
178 " structure=\"concrete\"\n"
179 " systemcomponent=\"true\"\n"
180 " parentsystemcomponent=\"true\"\n"
181 " isNodeCore=\"true\"\n"
182 " docGroupBase=\"GrpSystemNodeCoreGroups\"\n"
185 " ChunkOverrideGroup is a simple group node that allows for material chunks\n"
186 " to be set that will override all chunks stored in materials in the entire \n"
187 " subtree. Currently the last chunk override wins (note the difference to\n"
188 " the material group). This might change in future.\n"
191 "\t name=\"fallbackChunkBlock\"\n"
192 "\t type=\"ChunkBlockPtr\"\n"
193 "\t cardinality=\"single\"\n"
194 "\t visibility=\"external\"\n"
195 "\t access=\"public\"\n"
200 " name=\"subOverride\"\n"
202 " cardinality=\"single\"\n"
203 " visibility=\"external\"\n"
204 " defaultValue=\"false\"\n"
205 " access=\"public\"\n"
207 " If true, the ChunkOverrideGroup group does not add new override chunks, \n"
208 " but subtract the chunks from the list of already defined override chunks.\n"
209 " Basically, that allows to negate overrides at a deeper level in the scene graph.\n"
212 "</FieldContainer>\n"
214 "ChunkOverrideGroup is a simple group node that allows for material chunks\n"
215 "to be set that will override all chunks stored in materials in the entire \n"
216 "subtree. Currently the last chunk override wins (note the difference to\n"
217 "the material group). This might change in future.\n"
220 /*------------------------------ get -----------------------------------*/
222 FieldContainerType
&ChunkOverrideGroupBase::getType(void)
227 const FieldContainerType
&ChunkOverrideGroupBase::getType(void) const
232 UInt32
ChunkOverrideGroupBase::getContainerSize(void) const
234 return sizeof(ChunkOverrideGroup
);
237 /*------------------------- decorator get ------------------------------*/
240 //! Get the ChunkOverrideGroup::_sfFallbackChunkBlock field.
241 const SFUnrecChunkBlockPtr
*ChunkOverrideGroupBase::getSFFallbackChunkBlock(void) const
243 return &_sfFallbackChunkBlock
;
246 SFUnrecChunkBlockPtr
*ChunkOverrideGroupBase::editSFFallbackChunkBlock(void)
248 editSField(FallbackChunkBlockFieldMask
);
250 return &_sfFallbackChunkBlock
;
253 //! Get the value of the ChunkOverrideGroup::_sfFallbackChunkBlock field.
254 ChunkBlock
* ChunkOverrideGroupBase::getFallbackChunkBlock(void) const
256 return _sfFallbackChunkBlock
.getValue();
259 //! Set the value of the ChunkOverrideGroup::_sfFallbackChunkBlock field.
260 void ChunkOverrideGroupBase::setFallbackChunkBlock(ChunkBlock
* const value
)
262 editSField(FallbackChunkBlockFieldMask
);
264 _sfFallbackChunkBlock
.setValue(value
);
268 SFBool
*ChunkOverrideGroupBase::editSFSubOverride(void)
270 editSField(SubOverrideFieldMask
);
272 return &_sfSubOverride
;
275 const SFBool
*ChunkOverrideGroupBase::getSFSubOverride(void) const
277 return &_sfSubOverride
;
285 /*------------------------------ access -----------------------------------*/
287 SizeT
ChunkOverrideGroupBase::getBinSize(ConstFieldMaskArg whichField
)
289 SizeT returnValue
= Inherited::getBinSize(whichField
);
291 if(FieldBits::NoField
!= (FallbackChunkBlockFieldMask
& whichField
))
293 returnValue
+= _sfFallbackChunkBlock
.getBinSize();
295 if(FieldBits::NoField
!= (SubOverrideFieldMask
& whichField
))
297 returnValue
+= _sfSubOverride
.getBinSize();
303 void ChunkOverrideGroupBase::copyToBin(BinaryDataHandler
&pMem
,
304 ConstFieldMaskArg whichField
)
306 Inherited::copyToBin(pMem
, whichField
);
308 if(FieldBits::NoField
!= (FallbackChunkBlockFieldMask
& whichField
))
310 _sfFallbackChunkBlock
.copyToBin(pMem
);
312 if(FieldBits::NoField
!= (SubOverrideFieldMask
& whichField
))
314 _sfSubOverride
.copyToBin(pMem
);
318 void ChunkOverrideGroupBase::copyFromBin(BinaryDataHandler
&pMem
,
319 ConstFieldMaskArg whichField
)
321 Inherited::copyFromBin(pMem
, whichField
);
323 if(FieldBits::NoField
!= (FallbackChunkBlockFieldMask
& whichField
))
325 editSField(FallbackChunkBlockFieldMask
);
326 _sfFallbackChunkBlock
.copyFromBin(pMem
);
328 if(FieldBits::NoField
!= (SubOverrideFieldMask
& whichField
))
330 editSField(SubOverrideFieldMask
);
331 _sfSubOverride
.copyFromBin(pMem
);
335 //! create a new instance of the class
336 ChunkOverrideGroupTransitPtr
ChunkOverrideGroupBase::createLocal(BitVector bFlags
)
338 ChunkOverrideGroupTransitPtr fc
;
340 if(getClassType().getPrototype() != NULL
)
342 FieldContainerTransitPtr tmpPtr
=
343 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
345 fc
= dynamic_pointer_cast
<ChunkOverrideGroup
>(tmpPtr
);
351 //! create a new instance of the class, copy the container flags
352 ChunkOverrideGroupTransitPtr
ChunkOverrideGroupBase::createDependent(BitVector bFlags
)
354 ChunkOverrideGroupTransitPtr fc
;
356 if(getClassType().getPrototype() != NULL
)
358 FieldContainerTransitPtr tmpPtr
=
359 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
361 fc
= dynamic_pointer_cast
<ChunkOverrideGroup
>(tmpPtr
);
367 //! create a new instance of the class
368 ChunkOverrideGroupTransitPtr
ChunkOverrideGroupBase::create(void)
370 ChunkOverrideGroupTransitPtr fc
;
372 if(getClassType().getPrototype() != NULL
)
374 FieldContainerTransitPtr tmpPtr
=
375 getClassType().getPrototype()-> shallowCopy();
377 fc
= dynamic_pointer_cast
<ChunkOverrideGroup
>(tmpPtr
);
383 ChunkOverrideGroup
*ChunkOverrideGroupBase::createEmptyLocal(BitVector bFlags
)
385 ChunkOverrideGroup
*returnValue
;
387 newPtr
<ChunkOverrideGroup
>(returnValue
, bFlags
);
389 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
394 //! create an empty new instance of the class, do not copy the prototype
395 ChunkOverrideGroup
*ChunkOverrideGroupBase::createEmpty(void)
397 ChunkOverrideGroup
*returnValue
;
399 newPtr
<ChunkOverrideGroup
>(returnValue
, Thread::getCurrentLocalFlags());
401 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
402 ~Thread::getCurrentLocalFlags();
408 FieldContainerTransitPtr
ChunkOverrideGroupBase::shallowCopyLocal(
409 BitVector bFlags
) const
411 ChunkOverrideGroup
*tmpPtr
;
413 newPtr(tmpPtr
, dynamic_cast<const ChunkOverrideGroup
*>(this), bFlags
);
415 FieldContainerTransitPtr
returnValue(tmpPtr
);
417 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
422 FieldContainerTransitPtr
ChunkOverrideGroupBase::shallowCopyDependent(
423 BitVector bFlags
) const
425 ChunkOverrideGroup
*tmpPtr
;
427 newPtr(tmpPtr
, dynamic_cast<const ChunkOverrideGroup
*>(this), ~bFlags
);
429 FieldContainerTransitPtr
returnValue(tmpPtr
);
431 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
436 FieldContainerTransitPtr
ChunkOverrideGroupBase::shallowCopy(void) const
438 ChunkOverrideGroup
*tmpPtr
;
441 dynamic_cast<const ChunkOverrideGroup
*>(this),
442 Thread::getCurrentLocalFlags());
444 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
446 FieldContainerTransitPtr
returnValue(tmpPtr
);
454 /*------------------------- constructors ----------------------------------*/
456 ChunkOverrideGroupBase::ChunkOverrideGroupBase(void) :
458 _sfFallbackChunkBlock (NULL
),
459 _sfSubOverride (bool(false))
463 ChunkOverrideGroupBase::ChunkOverrideGroupBase(const ChunkOverrideGroupBase
&source
) :
465 _sfFallbackChunkBlock (NULL
),
466 _sfSubOverride (source
._sfSubOverride
)
471 /*-------------------------- destructors ----------------------------------*/
473 ChunkOverrideGroupBase::~ChunkOverrideGroupBase(void)
477 void ChunkOverrideGroupBase::onCreate(const ChunkOverrideGroup
*source
)
479 Inherited::onCreate(source
);
483 ChunkOverrideGroup
*pThis
= static_cast<ChunkOverrideGroup
*>(this);
485 pThis
->setFallbackChunkBlock(source
->getFallbackChunkBlock());
489 GetFieldHandlePtr
ChunkOverrideGroupBase::getHandleFallbackChunkBlock (void) const
491 SFUnrecChunkBlockPtr::GetHandlePtr
returnValue(
492 new SFUnrecChunkBlockPtr::GetHandle(
493 &_sfFallbackChunkBlock
,
494 this->getType().getFieldDesc(FallbackChunkBlockFieldId
),
495 const_cast<ChunkOverrideGroupBase
*>(this)));
500 EditFieldHandlePtr
ChunkOverrideGroupBase::editHandleFallbackChunkBlock(void)
502 SFUnrecChunkBlockPtr::EditHandlePtr
returnValue(
503 new SFUnrecChunkBlockPtr::EditHandle(
504 &_sfFallbackChunkBlock
,
505 this->getType().getFieldDesc(FallbackChunkBlockFieldId
),
508 returnValue
->setSetMethod(
509 boost::bind(&ChunkOverrideGroup::setFallbackChunkBlock
,
510 static_cast<ChunkOverrideGroup
*>(this), _1
));
512 editSField(FallbackChunkBlockFieldMask
);
517 GetFieldHandlePtr
ChunkOverrideGroupBase::getHandleSubOverride (void) const
519 SFBool::GetHandlePtr
returnValue(
520 new SFBool::GetHandle(
522 this->getType().getFieldDesc(SubOverrideFieldId
),
523 const_cast<ChunkOverrideGroupBase
*>(this)));
528 EditFieldHandlePtr
ChunkOverrideGroupBase::editHandleSubOverride (void)
530 SFBool::EditHandlePtr
returnValue(
531 new SFBool::EditHandle(
533 this->getType().getFieldDesc(SubOverrideFieldId
),
537 editSField(SubOverrideFieldMask
);
543 #ifdef OSG_MT_CPTR_ASPECT
544 void ChunkOverrideGroupBase::execSyncV( FieldContainer
&oFrom
,
545 ConstFieldMaskArg whichField
,
546 AspectOffsetStore
&oOffsets
,
547 ConstFieldMaskArg syncMode
,
548 const UInt32 uiSyncInfo
)
550 ChunkOverrideGroup
*pThis
= static_cast<ChunkOverrideGroup
*>(this);
552 pThis
->execSync(static_cast<ChunkOverrideGroup
*>(&oFrom
),
561 #ifdef OSG_MT_CPTR_ASPECT
562 FieldContainer
*ChunkOverrideGroupBase::createAspectCopy(
563 const FieldContainer
*pRefAspect
) const
565 ChunkOverrideGroup
*returnValue
;
567 newAspectCopy(returnValue
,
568 dynamic_cast<const ChunkOverrideGroup
*>(pRefAspect
),
569 dynamic_cast<const ChunkOverrideGroup
*>(this));
575 void ChunkOverrideGroupBase::resolveLinks(void)
577 Inherited::resolveLinks();
579 static_cast<ChunkOverrideGroup
*>(this)->setFallbackChunkBlock(NULL
);