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 MaterialGroup!
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 "OSGMaterial.h" // Material Class
67 #include "OSGMaterialGroupBase.h"
68 #include "OSGMaterialGroup.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::MaterialGroup
79 MaterialGroup is a standard group node that allows for a material to be set
80 that will override all materials in the entire subtree. This can be useful
81 if you want to disable materials in a subtree or if a large group of geometry
82 nodes should have the same material applied.
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var Material * MaterialGroupBase::_sfMaterial
94 /***************************************************************************\
95 * FieldType/FieldTrait Instantiation *
96 \***************************************************************************/
98 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
99 PointerType FieldTraits
<MaterialGroup
*, nsOSG
>::_type(
102 MaterialGroup::getClassType(),
106 OSG_FIELDTRAITS_GETTYPE_NS(MaterialGroup
*, nsOSG
)
108 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
112 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
116 /***************************************************************************\
117 * Field Description *
118 \***************************************************************************/
120 void MaterialGroupBase::classDescInserter(TypeObject
&oType
)
122 FieldDescriptionBase
*pDesc
= NULL
;
125 pDesc
= new SFUnrecMaterialPtr::Description(
126 SFUnrecMaterialPtr::getClassType(),
129 MaterialFieldId
, MaterialFieldMask
,
131 (Field::SFDefaultFlags
| Field::FStdAccess
),
132 static_cast<FieldEditMethodSig
>(&MaterialGroup::editHandleMaterial
),
133 static_cast<FieldGetMethodSig
>(&MaterialGroup::getHandleMaterial
));
135 oType
.addInitialDesc(pDesc
);
139 MaterialGroupBase::TypeObject
MaterialGroupBase::_type(
140 MaterialGroupBase::getClassname(),
141 Inherited::getClassname(),
144 reinterpret_cast<PrototypeCreateF
>(&MaterialGroupBase::createEmptyLocal
),
145 reinterpret_cast<InitContainerF
>(&MaterialGroup::initMethod
),
146 reinterpret_cast<ExitContainerF
>(&MaterialGroup::exitMethod
),
147 reinterpret_cast<InitalInsertDescFunc
>(
148 reinterpret_cast<void *>(&MaterialGroup::classDescInserter
)),
151 "<?xml version=\"1.0\"?>\n"
154 " name=\"MaterialGroup\"\n"
155 " parent=\"Group\"\n"
156 " library=\"System\"\n"
157 " pointerfieldtypes=\"both\"\n"
158 " structure=\"concrete\"\n"
159 " systemcomponent=\"true\"\n"
160 " parentsystemcomponent=\"true\"\n"
161 " isNodeCore=\"true\"\n"
162 " docGroupBase=\"GrpSystemNodeCoreGroups\"\n"
165 " MaterialGroup is a standard group node that allows for a material to be set\n"
166 " that will override all materials in the entire subtree. This can be useful\n"
167 " if you want to disable materials in a subtree or if a large group of geometry\n"
168 " nodes should have the same material applied.\n"
171 "\t name=\"material\"\n"
172 "\t type=\"MaterialPtr\"\n"
173 "\t cardinality=\"single\"\n"
174 "\t visibility=\"external\"\n"
175 "\t access=\"public\"\n"
178 "</FieldContainer>\n",
179 "MaterialGroup is a standard group node that allows for a material to be set\n"
180 "that will override all materials in the entire subtree. This can be useful\n"
181 "if you want to disable materials in a subtree or if a large group of geometry\n"
182 "nodes should have the same material applied.\n"
185 /*------------------------------ get -----------------------------------*/
187 FieldContainerType
&MaterialGroupBase::getType(void)
192 const FieldContainerType
&MaterialGroupBase::getType(void) const
197 UInt32
MaterialGroupBase::getContainerSize(void) const
199 return sizeof(MaterialGroup
);
202 /*------------------------- decorator get ------------------------------*/
205 //! Get the MaterialGroup::_sfMaterial field.
206 const SFUnrecMaterialPtr
*MaterialGroupBase::getSFMaterial(void) const
211 SFUnrecMaterialPtr
*MaterialGroupBase::editSFMaterial (void)
213 editSField(MaterialFieldMask
);
218 //! Get the value of the MaterialGroup::_sfMaterial field.
219 Material
* MaterialGroupBase::getMaterial(void) const
221 return _sfMaterial
.getValue();
224 //! Set the value of the MaterialGroup::_sfMaterial field.
225 void MaterialGroupBase::setMaterial(Material
* const value
)
227 editSField(MaterialFieldMask
);
229 _sfMaterial
.setValue(value
);
237 /*------------------------------ access -----------------------------------*/
239 SizeT
MaterialGroupBase::getBinSize(ConstFieldMaskArg whichField
)
241 SizeT returnValue
= Inherited::getBinSize(whichField
);
243 if(FieldBits::NoField
!= (MaterialFieldMask
& whichField
))
245 returnValue
+= _sfMaterial
.getBinSize();
251 void MaterialGroupBase::copyToBin(BinaryDataHandler
&pMem
,
252 ConstFieldMaskArg whichField
)
254 Inherited::copyToBin(pMem
, whichField
);
256 if(FieldBits::NoField
!= (MaterialFieldMask
& whichField
))
258 _sfMaterial
.copyToBin(pMem
);
262 void MaterialGroupBase::copyFromBin(BinaryDataHandler
&pMem
,
263 ConstFieldMaskArg whichField
)
265 Inherited::copyFromBin(pMem
, whichField
);
267 if(FieldBits::NoField
!= (MaterialFieldMask
& whichField
))
269 editSField(MaterialFieldMask
);
270 _sfMaterial
.copyFromBin(pMem
);
274 //! create a new instance of the class
275 MaterialGroupTransitPtr
MaterialGroupBase::createLocal(BitVector bFlags
)
277 MaterialGroupTransitPtr fc
;
279 if(getClassType().getPrototype() != NULL
)
281 FieldContainerTransitPtr tmpPtr
=
282 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
284 fc
= dynamic_pointer_cast
<MaterialGroup
>(tmpPtr
);
290 //! create a new instance of the class, copy the container flags
291 MaterialGroupTransitPtr
MaterialGroupBase::createDependent(BitVector bFlags
)
293 MaterialGroupTransitPtr fc
;
295 if(getClassType().getPrototype() != NULL
)
297 FieldContainerTransitPtr tmpPtr
=
298 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
300 fc
= dynamic_pointer_cast
<MaterialGroup
>(tmpPtr
);
306 //! create a new instance of the class
307 MaterialGroupTransitPtr
MaterialGroupBase::create(void)
309 MaterialGroupTransitPtr fc
;
311 if(getClassType().getPrototype() != NULL
)
313 FieldContainerTransitPtr tmpPtr
=
314 getClassType().getPrototype()-> shallowCopy();
316 fc
= dynamic_pointer_cast
<MaterialGroup
>(tmpPtr
);
322 MaterialGroup
*MaterialGroupBase::createEmptyLocal(BitVector bFlags
)
324 MaterialGroup
*returnValue
;
326 newPtr
<MaterialGroup
>(returnValue
, bFlags
);
328 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
333 //! create an empty new instance of the class, do not copy the prototype
334 MaterialGroup
*MaterialGroupBase::createEmpty(void)
336 MaterialGroup
*returnValue
;
338 newPtr
<MaterialGroup
>(returnValue
, Thread::getCurrentLocalFlags());
340 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
341 ~Thread::getCurrentLocalFlags();
347 FieldContainerTransitPtr
MaterialGroupBase::shallowCopyLocal(
348 BitVector bFlags
) const
350 MaterialGroup
*tmpPtr
;
352 newPtr(tmpPtr
, dynamic_cast<const MaterialGroup
*>(this), bFlags
);
354 FieldContainerTransitPtr
returnValue(tmpPtr
);
356 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
361 FieldContainerTransitPtr
MaterialGroupBase::shallowCopyDependent(
362 BitVector bFlags
) const
364 MaterialGroup
*tmpPtr
;
366 newPtr(tmpPtr
, dynamic_cast<const MaterialGroup
*>(this), ~bFlags
);
368 FieldContainerTransitPtr
returnValue(tmpPtr
);
370 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
375 FieldContainerTransitPtr
MaterialGroupBase::shallowCopy(void) const
377 MaterialGroup
*tmpPtr
;
380 dynamic_cast<const MaterialGroup
*>(this),
381 Thread::getCurrentLocalFlags());
383 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
385 FieldContainerTransitPtr
returnValue(tmpPtr
);
393 /*------------------------- constructors ----------------------------------*/
395 MaterialGroupBase::MaterialGroupBase(void) :
401 MaterialGroupBase::MaterialGroupBase(const MaterialGroupBase
&source
) :
408 /*-------------------------- destructors ----------------------------------*/
410 MaterialGroupBase::~MaterialGroupBase(void)
414 void MaterialGroupBase::onCreate(const MaterialGroup
*source
)
416 Inherited::onCreate(source
);
420 MaterialGroup
*pThis
= static_cast<MaterialGroup
*>(this);
422 pThis
->setMaterial(source
->getMaterial());
426 GetFieldHandlePtr
MaterialGroupBase::getHandleMaterial (void) const
428 SFUnrecMaterialPtr::GetHandlePtr
returnValue(
429 new SFUnrecMaterialPtr::GetHandle(
431 this->getType().getFieldDesc(MaterialFieldId
),
432 const_cast<MaterialGroupBase
*>(this)));
437 EditFieldHandlePtr
MaterialGroupBase::editHandleMaterial (void)
439 SFUnrecMaterialPtr::EditHandlePtr
returnValue(
440 new SFUnrecMaterialPtr::EditHandle(
442 this->getType().getFieldDesc(MaterialFieldId
),
445 returnValue
->setSetMethod(
446 boost::bind(&MaterialGroup::setMaterial
,
447 static_cast<MaterialGroup
*>(this), _1
));
449 editSField(MaterialFieldMask
);
455 #ifdef OSG_MT_CPTR_ASPECT
456 void MaterialGroupBase::execSyncV( FieldContainer
&oFrom
,
457 ConstFieldMaskArg whichField
,
458 AspectOffsetStore
&oOffsets
,
459 ConstFieldMaskArg syncMode
,
460 const UInt32 uiSyncInfo
)
462 MaterialGroup
*pThis
= static_cast<MaterialGroup
*>(this);
464 pThis
->execSync(static_cast<MaterialGroup
*>(&oFrom
),
473 #ifdef OSG_MT_CPTR_ASPECT
474 FieldContainer
*MaterialGroupBase::createAspectCopy(
475 const FieldContainer
*pRefAspect
) const
477 MaterialGroup
*returnValue
;
479 newAspectCopy(returnValue
,
480 dynamic_cast<const MaterialGroup
*>(pRefAspect
),
481 dynamic_cast<const MaterialGroup
*>(this));
487 void MaterialGroupBase::resolveLinks(void)
489 Inherited::resolveLinks();
491 static_cast<MaterialGroup
*>(this)->setMaterial(NULL
);