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 TextureSelectChunk!
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 "OSGTextureBaseChunk.h" // Textures Class
67 #include "OSGTextureSelectChunkBase.h"
68 #include "OSGTextureSelectChunk.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::TextureSelectChunk
79 The TextureSelectChunk allows choosing from a field of textures. It can be
80 used to change between a set of textures more easily than adding/removing
81 chunks the the used material, and can be used in places where only chunks
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var UInt32 TextureSelectChunkBase::_sfChoice
93 /*! \var TextureBaseChunk * TextureSelectChunkBase::_mfTextures
94 Texture chunks to choose from
98 /***************************************************************************\
99 * FieldType/FieldTrait Instantiation *
100 \***************************************************************************/
102 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
103 PointerType FieldTraits
<TextureSelectChunk
*, nsOSG
>::_type(
104 "TextureSelectChunkPtr",
105 "TextureBaseChunkPtr",
106 TextureSelectChunk::getClassType(),
110 OSG_FIELDTRAITS_GETTYPE_NS(TextureSelectChunk
*, nsOSG
)
112 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
113 TextureSelectChunk
*,
116 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
117 TextureSelectChunk
*,
120 /***************************************************************************\
121 * Field Description *
122 \***************************************************************************/
124 void TextureSelectChunkBase::classDescInserter(TypeObject
&oType
)
126 FieldDescriptionBase
*pDesc
= NULL
;
129 pDesc
= new SFUInt32::Description(
130 SFUInt32::getClassType(),
132 "Texture selector\n",
133 ChoiceFieldId
, ChoiceFieldMask
,
135 (Field::SFDefaultFlags
| Field::FStdAccess
),
136 static_cast<FieldEditMethodSig
>(&TextureSelectChunk::editHandleChoice
),
137 static_cast<FieldGetMethodSig
>(&TextureSelectChunk::getHandleChoice
));
139 oType
.addInitialDesc(pDesc
);
141 pDesc
= new MFUnrecTextureBaseChunkPtr::Description(
142 MFUnrecTextureBaseChunkPtr::getClassType(),
144 "Texture chunks to choose from \n",
145 TexturesFieldId
, TexturesFieldMask
,
147 (Field::MFDefaultFlags
| Field::FStdAccess
),
148 static_cast<FieldEditMethodSig
>(&TextureSelectChunk::editHandleTextures
),
149 static_cast<FieldGetMethodSig
>(&TextureSelectChunk::getHandleTextures
));
151 oType
.addInitialDesc(pDesc
);
155 TextureSelectChunkBase::TypeObject
TextureSelectChunkBase::_type(
156 TextureSelectChunkBase::getClassname(),
157 Inherited::getClassname(),
160 reinterpret_cast<PrototypeCreateF
>(&TextureSelectChunkBase::createEmptyLocal
),
161 reinterpret_cast<InitContainerF
>(&TextureSelectChunk::initMethod
),
162 reinterpret_cast<ExitContainerF
>(&TextureSelectChunk::exitMethod
),
163 reinterpret_cast<InitalInsertDescFunc
>(
164 reinterpret_cast<void *>(&TextureSelectChunk::classDescInserter
)),
167 "<?xml version=\"1.0\"?>\n"
170 " name=\"TextureSelectChunk\"\n"
171 " parent=\"TextureBaseChunk\"\n"
172 " library=\"State\"\n"
173 " pointerfieldtypes=\"both\"\n"
174 " structure=\"concrete\"\n"
175 " systemcomponent=\"true\"\n"
176 " parentsystemcomponent=\"true\"\n"
177 " decoratable=\"false\"\n"
178 " docGroupBase=\"GrpStateAuxiliary\"\n"
180 " The TextureSelectChunk allows choosing from a field of textures. It can be \n"
181 " used to change between a set of textures more easily than adding/removing \n"
182 " chunks the the used material, and can be used in places where only chunks\n"
186 "\t name=\"choice\"\n"
187 "\t type=\"UInt32\"\n"
188 "\t cardinality=\"single\"\n"
189 "\t visibility=\"external\"\n"
190 "\t access=\"public\"\n"
191 "\t defaultValue=\"0\"\n"
193 "\tTexture selector\n"
196 "\t name=\"textures\"\n"
197 "\t type=\"TextureBaseChunkPtr\"\n"
198 "\t cardinality=\"multi\"\n"
199 "\t visibility=\"external\"\n"
200 "\t access=\"public\"\n"
202 "\tTexture chunks to choose from \n"
204 "</FieldContainer>\n",
205 "The TextureSelectChunk allows choosing from a field of textures. It can be \n"
206 "used to change between a set of textures more easily than adding/removing \n"
207 "chunks the the used material, and can be used in places where only chunks\n"
211 /*------------------------------ get -----------------------------------*/
213 FieldContainerType
&TextureSelectChunkBase::getType(void)
218 const FieldContainerType
&TextureSelectChunkBase::getType(void) const
223 UInt32
TextureSelectChunkBase::getContainerSize(void) const
225 return sizeof(TextureSelectChunk
);
228 /*------------------------- decorator get ------------------------------*/
231 SFUInt32
*TextureSelectChunkBase::editSFChoice(void)
233 editSField(ChoiceFieldMask
);
238 const SFUInt32
*TextureSelectChunkBase::getSFChoice(void) const
244 //! Get the TextureSelectChunk::_mfTextures field.
245 const MFUnrecTextureBaseChunkPtr
*TextureSelectChunkBase::getMFTextures(void) const
250 MFUnrecTextureBaseChunkPtr
*TextureSelectChunkBase::editMFTextures (void)
252 editMField(TexturesFieldMask
, _mfTextures
);
256 TextureBaseChunk
* TextureSelectChunkBase::getTextures(const UInt32 index
) const
258 return _mfTextures
[index
];
263 void TextureSelectChunkBase::pushToTextures(TextureBaseChunk
* const value
)
265 editMField(TexturesFieldMask
, _mfTextures
);
267 _mfTextures
.push_back(value
);
270 void TextureSelectChunkBase::assignTextures (const MFUnrecTextureBaseChunkPtr
&value
)
272 MFUnrecTextureBaseChunkPtr::const_iterator elemIt
=
274 MFUnrecTextureBaseChunkPtr::const_iterator elemEnd
=
277 static_cast<TextureSelectChunk
*>(this)->clearTextures();
279 while(elemIt
!= elemEnd
)
281 this->pushToTextures(*elemIt
);
287 void TextureSelectChunkBase::removeFromTextures(UInt32 uiIndex
)
289 if(uiIndex
< _mfTextures
.size())
291 editMField(TexturesFieldMask
, _mfTextures
);
293 _mfTextures
.erase(uiIndex
);
297 void TextureSelectChunkBase::removeObjFromTextures(TextureBaseChunk
* const value
)
299 Int32 iElemIdx
= _mfTextures
.findIndex(value
);
303 editMField(TexturesFieldMask
, _mfTextures
);
305 _mfTextures
.erase(iElemIdx
);
308 void TextureSelectChunkBase::clearTextures(void)
310 editMField(TexturesFieldMask
, _mfTextures
);
318 /*------------------------------ access -----------------------------------*/
320 SizeT
TextureSelectChunkBase::getBinSize(ConstFieldMaskArg whichField
)
322 SizeT returnValue
= Inherited::getBinSize(whichField
);
324 if(FieldBits::NoField
!= (ChoiceFieldMask
& whichField
))
326 returnValue
+= _sfChoice
.getBinSize();
328 if(FieldBits::NoField
!= (TexturesFieldMask
& whichField
))
330 returnValue
+= _mfTextures
.getBinSize();
336 void TextureSelectChunkBase::copyToBin(BinaryDataHandler
&pMem
,
337 ConstFieldMaskArg whichField
)
339 Inherited::copyToBin(pMem
, whichField
);
341 if(FieldBits::NoField
!= (ChoiceFieldMask
& whichField
))
343 _sfChoice
.copyToBin(pMem
);
345 if(FieldBits::NoField
!= (TexturesFieldMask
& whichField
))
347 _mfTextures
.copyToBin(pMem
);
351 void TextureSelectChunkBase::copyFromBin(BinaryDataHandler
&pMem
,
352 ConstFieldMaskArg whichField
)
354 Inherited::copyFromBin(pMem
, whichField
);
356 if(FieldBits::NoField
!= (ChoiceFieldMask
& whichField
))
358 editSField(ChoiceFieldMask
);
359 _sfChoice
.copyFromBin(pMem
);
361 if(FieldBits::NoField
!= (TexturesFieldMask
& whichField
))
363 editMField(TexturesFieldMask
, _mfTextures
);
364 _mfTextures
.copyFromBin(pMem
);
368 //! create a new instance of the class
369 TextureSelectChunkTransitPtr
TextureSelectChunkBase::createLocal(BitVector bFlags
)
371 TextureSelectChunkTransitPtr fc
;
373 if(getClassType().getPrototype() != NULL
)
375 FieldContainerTransitPtr tmpPtr
=
376 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
378 fc
= dynamic_pointer_cast
<TextureSelectChunk
>(tmpPtr
);
384 //! create a new instance of the class, copy the container flags
385 TextureSelectChunkTransitPtr
TextureSelectChunkBase::createDependent(BitVector bFlags
)
387 TextureSelectChunkTransitPtr fc
;
389 if(getClassType().getPrototype() != NULL
)
391 FieldContainerTransitPtr tmpPtr
=
392 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
394 fc
= dynamic_pointer_cast
<TextureSelectChunk
>(tmpPtr
);
400 //! create a new instance of the class
401 TextureSelectChunkTransitPtr
TextureSelectChunkBase::create(void)
403 TextureSelectChunkTransitPtr fc
;
405 if(getClassType().getPrototype() != NULL
)
407 FieldContainerTransitPtr tmpPtr
=
408 getClassType().getPrototype()-> shallowCopy();
410 fc
= dynamic_pointer_cast
<TextureSelectChunk
>(tmpPtr
);
416 TextureSelectChunk
*TextureSelectChunkBase::createEmptyLocal(BitVector bFlags
)
418 TextureSelectChunk
*returnValue
;
420 newPtr
<TextureSelectChunk
>(returnValue
, bFlags
);
422 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
427 //! create an empty new instance of the class, do not copy the prototype
428 TextureSelectChunk
*TextureSelectChunkBase::createEmpty(void)
430 TextureSelectChunk
*returnValue
;
432 newPtr
<TextureSelectChunk
>(returnValue
, Thread::getCurrentLocalFlags());
434 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
435 ~Thread::getCurrentLocalFlags();
441 FieldContainerTransitPtr
TextureSelectChunkBase::shallowCopyLocal(
442 BitVector bFlags
) const
444 TextureSelectChunk
*tmpPtr
;
446 newPtr(tmpPtr
, dynamic_cast<const TextureSelectChunk
*>(this), bFlags
);
448 FieldContainerTransitPtr
returnValue(tmpPtr
);
450 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
455 FieldContainerTransitPtr
TextureSelectChunkBase::shallowCopyDependent(
456 BitVector bFlags
) const
458 TextureSelectChunk
*tmpPtr
;
460 newPtr(tmpPtr
, dynamic_cast<const TextureSelectChunk
*>(this), ~bFlags
);
462 FieldContainerTransitPtr
returnValue(tmpPtr
);
464 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
469 FieldContainerTransitPtr
TextureSelectChunkBase::shallowCopy(void) const
471 TextureSelectChunk
*tmpPtr
;
474 dynamic_cast<const TextureSelectChunk
*>(this),
475 Thread::getCurrentLocalFlags());
477 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
479 FieldContainerTransitPtr
returnValue(tmpPtr
);
487 /*------------------------- constructors ----------------------------------*/
489 TextureSelectChunkBase::TextureSelectChunkBase(void) :
491 _sfChoice (UInt32(0)),
496 TextureSelectChunkBase::TextureSelectChunkBase(const TextureSelectChunkBase
&source
) :
498 _sfChoice (source
._sfChoice
),
504 /*-------------------------- destructors ----------------------------------*/
506 TextureSelectChunkBase::~TextureSelectChunkBase(void)
510 void TextureSelectChunkBase::onCreate(const TextureSelectChunk
*source
)
512 Inherited::onCreate(source
);
516 TextureSelectChunk
*pThis
= static_cast<TextureSelectChunk
*>(this);
518 MFUnrecTextureBaseChunkPtr::const_iterator TexturesIt
=
519 source
->_mfTextures
.begin();
520 MFUnrecTextureBaseChunkPtr::const_iterator TexturesEnd
=
521 source
->_mfTextures
.end ();
523 while(TexturesIt
!= TexturesEnd
)
525 pThis
->pushToTextures(*TexturesIt
);
532 GetFieldHandlePtr
TextureSelectChunkBase::getHandleChoice (void) const
534 SFUInt32::GetHandlePtr
returnValue(
535 new SFUInt32::GetHandle(
537 this->getType().getFieldDesc(ChoiceFieldId
),
538 const_cast<TextureSelectChunkBase
*>(this)));
543 EditFieldHandlePtr
TextureSelectChunkBase::editHandleChoice (void)
545 SFUInt32::EditHandlePtr
returnValue(
546 new SFUInt32::EditHandle(
548 this->getType().getFieldDesc(ChoiceFieldId
),
552 editSField(ChoiceFieldMask
);
557 GetFieldHandlePtr
TextureSelectChunkBase::getHandleTextures (void) const
559 MFUnrecTextureBaseChunkPtr::GetHandlePtr
returnValue(
560 new MFUnrecTextureBaseChunkPtr::GetHandle(
562 this->getType().getFieldDesc(TexturesFieldId
),
563 const_cast<TextureSelectChunkBase
*>(this)));
568 EditFieldHandlePtr
TextureSelectChunkBase::editHandleTextures (void)
570 MFUnrecTextureBaseChunkPtr::EditHandlePtr
returnValue(
571 new MFUnrecTextureBaseChunkPtr::EditHandle(
573 this->getType().getFieldDesc(TexturesFieldId
),
576 returnValue
->setAddMethod(
577 boost::bind(&TextureSelectChunk::pushToTextures
,
578 static_cast<TextureSelectChunk
*>(this), _1
));
579 returnValue
->setRemoveMethod(
580 boost::bind(&TextureSelectChunk::removeFromTextures
,
581 static_cast<TextureSelectChunk
*>(this), _1
));
582 returnValue
->setRemoveObjMethod(
583 boost::bind(&TextureSelectChunk::removeObjFromTextures
,
584 static_cast<TextureSelectChunk
*>(this), _1
));
585 returnValue
->setClearMethod(
586 boost::bind(&TextureSelectChunk::clearTextures
,
587 static_cast<TextureSelectChunk
*>(this)));
589 editMField(TexturesFieldMask
, _mfTextures
);
595 #ifdef OSG_MT_CPTR_ASPECT
596 void TextureSelectChunkBase::execSyncV( FieldContainer
&oFrom
,
597 ConstFieldMaskArg whichField
,
598 AspectOffsetStore
&oOffsets
,
599 ConstFieldMaskArg syncMode
,
600 const UInt32 uiSyncInfo
)
602 TextureSelectChunk
*pThis
= static_cast<TextureSelectChunk
*>(this);
604 pThis
->execSync(static_cast<TextureSelectChunk
*>(&oFrom
),
613 #ifdef OSG_MT_CPTR_ASPECT
614 FieldContainer
*TextureSelectChunkBase::createAspectCopy(
615 const FieldContainer
*pRefAspect
) const
617 TextureSelectChunk
*returnValue
;
619 newAspectCopy(returnValue
,
620 dynamic_cast<const TextureSelectChunk
*>(pRefAspect
),
621 dynamic_cast<const TextureSelectChunk
*>(this));
627 void TextureSelectChunkBase::resolveLinks(void)
629 Inherited::resolveLinks();
631 static_cast<TextureSelectChunk
*>(this)->clearTextures();