changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Groups / Base / OSGMaterialGroupBase.cpp
blob327562c0a9b83e946dcb3f026a4cd8744b24cb9e
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
41 ** **
42 ** This file is automatically generated. **
43 ** **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
46 ** **
47 ** Do not change this file, changes should be done in the derived **
48 ** class MaterialGroup!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #ifdef WIN32
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
59 #endif
61 #include "OSGConfig.h"
65 #include "OSGMaterial.h" // Material Class
67 #include "OSGMaterialGroupBase.h"
68 #include "OSGMaterialGroup.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
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(
100 "MaterialGroupPtr",
101 "GroupPtr",
102 MaterialGroup::getClassType(),
103 nsOSG);
104 #endif
106 OSG_FIELDTRAITS_GETTYPE_NS(MaterialGroup *, nsOSG)
108 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
109 MaterialGroup *,
110 nsOSG)
112 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
113 MaterialGroup *,
114 nsOSG)
116 /***************************************************************************\
117 * Field Description *
118 \***************************************************************************/
120 void MaterialGroupBase::classDescInserter(TypeObject &oType)
122 FieldDescriptionBase *pDesc = NULL;
125 pDesc = new SFUnrecMaterialPtr::Description(
126 SFUnrecMaterialPtr::getClassType(),
127 "material",
129 MaterialFieldId, MaterialFieldMask,
130 false,
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(),
142 "NULL",
143 nsOSG, //Namespace
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)),
149 false,
151 "<?xml version=\"1.0\"?>\n"
152 "\n"
153 "<FieldContainer\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"
163 " >\n"
164 "\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"
169 "\n"
170 " <Field\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"
176 "\t >\n"
177 " </Field>\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)
189 return _type;
192 const FieldContainerType &MaterialGroupBase::getType(void) const
194 return _type;
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
208 return &_sfMaterial;
211 SFUnrecMaterialPtr *MaterialGroupBase::editSFMaterial (void)
213 editSField(MaterialFieldMask);
215 return &_sfMaterial;
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();
248 return returnValue;
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);
287 return fc;
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);
303 return fc;
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);
319 return fc;
322 MaterialGroup *MaterialGroupBase::createEmptyLocal(BitVector bFlags)
324 MaterialGroup *returnValue;
326 newPtr<MaterialGroup>(returnValue, bFlags);
328 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
330 return returnValue;
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();
343 return returnValue;
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;
358 return returnValue;
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;
372 return returnValue;
375 FieldContainerTransitPtr MaterialGroupBase::shallowCopy(void) const
377 MaterialGroup *tmpPtr;
379 newPtr(tmpPtr,
380 dynamic_cast<const MaterialGroup *>(this),
381 Thread::getCurrentLocalFlags());
383 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
385 FieldContainerTransitPtr returnValue(tmpPtr);
387 return returnValue;
393 /*------------------------- constructors ----------------------------------*/
395 MaterialGroupBase::MaterialGroupBase(void) :
396 Inherited(),
397 _sfMaterial (NULL)
401 MaterialGroupBase::MaterialGroupBase(const MaterialGroupBase &source) :
402 Inherited(source),
403 _sfMaterial (NULL)
408 /*-------------------------- destructors ----------------------------------*/
410 MaterialGroupBase::~MaterialGroupBase(void)
414 void MaterialGroupBase::onCreate(const MaterialGroup *source)
416 Inherited::onCreate(source);
418 if(source != NULL)
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(
430 &_sfMaterial,
431 this->getType().getFieldDesc(MaterialFieldId),
432 const_cast<MaterialGroupBase *>(this)));
434 return returnValue;
437 EditFieldHandlePtr MaterialGroupBase::editHandleMaterial (void)
439 SFUnrecMaterialPtr::EditHandlePtr returnValue(
440 new SFUnrecMaterialPtr::EditHandle(
441 &_sfMaterial,
442 this->getType().getFieldDesc(MaterialFieldId),
443 this));
445 returnValue->setSetMethod(
446 boost::bind(&MaterialGroup::setMaterial,
447 static_cast<MaterialGroup *>(this), _1));
449 editSField(MaterialFieldMask);
451 return returnValue;
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),
465 whichField,
466 oOffsets,
467 syncMode,
468 uiSyncInfo);
470 #endif
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));
483 return returnValue;
485 #endif
487 void MaterialGroupBase::resolveLinks(void)
489 Inherited::resolveLinks();
491 static_cast<MaterialGroup *>(this)->setMaterial(NULL);
497 OSG_END_NAMESPACE