changed: gcc8 base update
[opensg.git] / Source / System / State / Base / OSGDepthChunkBase.cpp
blob0a445feda4f995f3da6c0e111156a78a98a48d6e
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 DepthChunk!
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"
64 #include "OSGGL.h" // Func default header
67 #include "OSGDepthChunkBase.h"
68 #include "OSGDepthChunk.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::DepthChunk
79 The depth chunk contains the parameters that are specific for depth control.
81 The parameters of the following functions are wrapped here: glDepthFunc
82 (OSG::DepthChunk::_sfFunc), glDepthRange (OSG::DepthChunk::_sfNear,
83 OSG::DepthChunk::_sfFar), glEnable(GL_DEPTH_TEST)
84 (OSG::DepthChunk::_sfEnable).
87 /***************************************************************************\
88 * Field Documentation *
89 \***************************************************************************/
91 /*! \var bool DepthChunkBase::_sfEnable
92 Whether the depth test should be enabled or not.
95 /*! \var GLenum DepthChunkBase::_sfFunc
96 The depth function to use. If GL_NONE, it's not changed. The default is GL_LEQUAL.
99 /*! \var Real32 DepthChunkBase::_sfNear
100 The near value for glDepthRange. Ignored if less than 0, defaults to -1.
103 /*! \var Real32 DepthChunkBase::_sfFar
104 The far value for glDepthRange. Ignored if less than 0, defaults to -1.
107 /*! \var bool DepthChunkBase::_sfReadOnly
108 Whether the depth buffer is enabled for writing or not.
112 /***************************************************************************\
113 * FieldType/FieldTrait Instantiation *
114 \***************************************************************************/
116 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
117 PointerType FieldTraits<DepthChunk *, nsOSG>::_type(
118 "DepthChunkPtr",
119 "StateChunkPtr",
120 DepthChunk::getClassType(),
121 nsOSG);
122 #endif
124 OSG_FIELDTRAITS_GETTYPE_NS(DepthChunk *, nsOSG)
126 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
127 DepthChunk *,
128 nsOSG)
130 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
131 DepthChunk *,
132 nsOSG)
134 /***************************************************************************\
135 * Field Description *
136 \***************************************************************************/
138 void DepthChunkBase::classDescInserter(TypeObject &oType)
140 FieldDescriptionBase *pDesc = NULL;
143 pDesc = new SFBool::Description(
144 SFBool::getClassType(),
145 "enable",
146 "Whether the depth test should be enabled or not.\n",
147 EnableFieldId, EnableFieldMask,
148 false,
149 (Field::SFDefaultFlags | Field::FStdAccess),
150 static_cast<FieldEditMethodSig>(&DepthChunk::editHandleEnable),
151 static_cast<FieldGetMethodSig >(&DepthChunk::getHandleEnable));
153 oType.addInitialDesc(pDesc);
155 pDesc = new SFGLenum::Description(
156 SFGLenum::getClassType(),
157 "func",
158 "The depth function to use. If GL_NONE, it's not changed. The default is GL_LEQUAL.\n",
159 FuncFieldId, FuncFieldMask,
160 false,
161 (Field::SFDefaultFlags | Field::FStdAccess),
162 static_cast<FieldEditMethodSig>(&DepthChunk::editHandleFunc),
163 static_cast<FieldGetMethodSig >(&DepthChunk::getHandleFunc));
165 oType.addInitialDesc(pDesc);
167 pDesc = new SFReal32::Description(
168 SFReal32::getClassType(),
169 "near",
170 "The near value for glDepthRange. Ignored if less than 0, defaults to -1.\n",
171 NearFieldId, NearFieldMask,
172 false,
173 (Field::SFDefaultFlags | Field::FStdAccess),
174 static_cast<FieldEditMethodSig>(&DepthChunk::editHandleNear),
175 static_cast<FieldGetMethodSig >(&DepthChunk::getHandleNear));
177 oType.addInitialDesc(pDesc);
179 pDesc = new SFReal32::Description(
180 SFReal32::getClassType(),
181 "far",
182 "The far value for glDepthRange. Ignored if less than 0, defaults to -1.\n",
183 FarFieldId, FarFieldMask,
184 false,
185 (Field::SFDefaultFlags | Field::FStdAccess),
186 static_cast<FieldEditMethodSig>(&DepthChunk::editHandleFar),
187 static_cast<FieldGetMethodSig >(&DepthChunk::getHandleFar));
189 oType.addInitialDesc(pDesc);
191 pDesc = new SFBool::Description(
192 SFBool::getClassType(),
193 "readOnly",
194 "Whether the depth buffer is enabled for writing or not.\n",
195 ReadOnlyFieldId, ReadOnlyFieldMask,
196 false,
197 (Field::SFDefaultFlags | Field::FStdAccess),
198 static_cast<FieldEditMethodSig>(&DepthChunk::editHandleReadOnly),
199 static_cast<FieldGetMethodSig >(&DepthChunk::getHandleReadOnly));
201 oType.addInitialDesc(pDesc);
205 DepthChunkBase::TypeObject DepthChunkBase::_type(
206 DepthChunkBase::getClassname(),
207 Inherited::getClassname(),
208 "NULL",
209 nsOSG, //Namespace
210 reinterpret_cast<PrototypeCreateF>(&DepthChunkBase::createEmptyLocal),
211 reinterpret_cast<InitContainerF>(&DepthChunk::initMethod),
212 reinterpret_cast<ExitContainerF>(&DepthChunk::exitMethod),
213 reinterpret_cast<InitalInsertDescFunc>(
214 reinterpret_cast<void *>(&DepthChunk::classDescInserter)),
215 false,
217 "<?xml version=\"1.0\"?>\n"
218 "\n"
219 "<FieldContainer\n"
220 " name=\"DepthChunk\"\n"
221 " parent=\"StateChunk\"\n"
222 " library=\"System\"\n"
223 " pointerfieldtypes=\"both\"\n"
224 " structure=\"concrete\"\n"
225 " systemcomponent=\"true\"\n"
226 " parentsystemcomponent=\"true\"\n"
227 " decoratable=\"false\"\n"
228 " useLocalIncludes=\"false\"\n"
229 " docGroupBase=\"GrpSystemState\"\n"
230 ">\n"
231 "The depth chunk contains the parameters that are specific for depth control.\n"
232 "\n"
233 "The parameters of the following functions are wrapped here: glDepthFunc\n"
234 "(OSG::DepthChunk::_sfFunc), glDepthRange (OSG::DepthChunk::_sfNear,\n"
235 "OSG::DepthChunk::_sfFar), glEnable(GL_DEPTH_TEST)\n"
236 "(OSG::DepthChunk::_sfEnable).\n"
237 "\t<Field\n"
238 "\t\tname=\"enable\"\n"
239 "\t\ttype=\"bool\"\n"
240 "\t\tcardinality=\"single\"\n"
241 "\t\tvisibility=\"external\"\n"
242 "\t\tdefaultValue=\"true\"\n"
243 "\t\taccess=\"public\"\n"
244 "\t>\n"
245 "\tWhether the depth test should be enabled or not.\n"
246 "\t</Field>\n"
247 "\t<Field\n"
248 "\t\tname=\"func\"\n"
249 "\t\ttype=\"GLenum\"\n"
250 "\t\tcardinality=\"single\"\n"
251 "\t\tvisibility=\"external\"\n"
252 "\t\tdefaultValue=\"GL_LEQUAL\"\n"
253 "\t\tdefaultHeader=\"&quot;OSGGL.h&quot;\"\n"
254 "\t\taccess=\"public\"\n"
255 "\t>\n"
256 "\tThe depth function to use. If GL_NONE, it's not changed. The default is GL_LEQUAL.\n"
257 "\t</Field>\n"
258 "\t<Field\n"
259 "\t\tname=\"near\"\n"
260 "\t\ttype=\"Real32\"\n"
261 "\t\tcardinality=\"single\"\n"
262 "\t\tvisibility=\"external\"\n"
263 "\t\tdefaultValue=\"-1.f\"\n"
264 "\t\taccess=\"public\"\n"
265 "\t>\n"
266 "\tThe near value for glDepthRange. Ignored if less than 0, defaults to -1.\n"
267 "\t</Field>\n"
268 "\t<Field\n"
269 "\t\tname=\"far\"\n"
270 "\t\ttype=\"Real32\"\n"
271 "\t\tcardinality=\"single\"\n"
272 "\t\tvisibility=\"external\"\n"
273 "\t\tdefaultValue=\"-1.f\"\n"
274 "\t\taccess=\"public\"\n"
275 "\t>\n"
276 "\tThe far value for glDepthRange. Ignored if less than 0, defaults to -1.\n"
277 "\t</Field>\n"
278 "\t<Field\n"
279 "\t\tname=\"readOnly\"\n"
280 "\t\ttype=\"bool\"\n"
281 "\t\tcardinality=\"single\"\n"
282 "\t\tvisibility=\"external\"\n"
283 "\t\tdefaultValue=\"false\"\n"
284 "\t\taccess=\"public\"\n"
285 "\t>\n"
286 "\tWhether the depth buffer is enabled for writing or not.\n"
287 "\t</Field>\n"
288 "</FieldContainer>\n",
289 "The depth chunk contains the parameters that are specific for depth control.\n"
290 "\n"
291 "The parameters of the following functions are wrapped here: glDepthFunc\n"
292 "(OSG::DepthChunk::_sfFunc), glDepthRange (OSG::DepthChunk::_sfNear,\n"
293 "OSG::DepthChunk::_sfFar), glEnable(GL_DEPTH_TEST)\n"
294 "(OSG::DepthChunk::_sfEnable).\n"
297 /*------------------------------ get -----------------------------------*/
299 FieldContainerType &DepthChunkBase::getType(void)
301 return _type;
304 const FieldContainerType &DepthChunkBase::getType(void) const
306 return _type;
309 UInt32 DepthChunkBase::getContainerSize(void) const
311 return sizeof(DepthChunk);
314 /*------------------------- decorator get ------------------------------*/
317 SFBool *DepthChunkBase::editSFEnable(void)
319 editSField(EnableFieldMask);
321 return &_sfEnable;
324 const SFBool *DepthChunkBase::getSFEnable(void) const
326 return &_sfEnable;
330 SFGLenum *DepthChunkBase::editSFFunc(void)
332 editSField(FuncFieldMask);
334 return &_sfFunc;
337 const SFGLenum *DepthChunkBase::getSFFunc(void) const
339 return &_sfFunc;
343 SFReal32 *DepthChunkBase::editSFNear(void)
345 editSField(NearFieldMask);
347 return &_sfNear;
350 const SFReal32 *DepthChunkBase::getSFNear(void) const
352 return &_sfNear;
356 SFReal32 *DepthChunkBase::editSFFar(void)
358 editSField(FarFieldMask);
360 return &_sfFar;
363 const SFReal32 *DepthChunkBase::getSFFar(void) const
365 return &_sfFar;
369 SFBool *DepthChunkBase::editSFReadOnly(void)
371 editSField(ReadOnlyFieldMask);
373 return &_sfReadOnly;
376 const SFBool *DepthChunkBase::getSFReadOnly(void) const
378 return &_sfReadOnly;
386 /*------------------------------ access -----------------------------------*/
388 SizeT DepthChunkBase::getBinSize(ConstFieldMaskArg whichField)
390 SizeT returnValue = Inherited::getBinSize(whichField);
392 if(FieldBits::NoField != (EnableFieldMask & whichField))
394 returnValue += _sfEnable.getBinSize();
396 if(FieldBits::NoField != (FuncFieldMask & whichField))
398 returnValue += _sfFunc.getBinSize();
400 if(FieldBits::NoField != (NearFieldMask & whichField))
402 returnValue += _sfNear.getBinSize();
404 if(FieldBits::NoField != (FarFieldMask & whichField))
406 returnValue += _sfFar.getBinSize();
408 if(FieldBits::NoField != (ReadOnlyFieldMask & whichField))
410 returnValue += _sfReadOnly.getBinSize();
413 return returnValue;
416 void DepthChunkBase::copyToBin(BinaryDataHandler &pMem,
417 ConstFieldMaskArg whichField)
419 Inherited::copyToBin(pMem, whichField);
421 if(FieldBits::NoField != (EnableFieldMask & whichField))
423 _sfEnable.copyToBin(pMem);
425 if(FieldBits::NoField != (FuncFieldMask & whichField))
427 _sfFunc.copyToBin(pMem);
429 if(FieldBits::NoField != (NearFieldMask & whichField))
431 _sfNear.copyToBin(pMem);
433 if(FieldBits::NoField != (FarFieldMask & whichField))
435 _sfFar.copyToBin(pMem);
437 if(FieldBits::NoField != (ReadOnlyFieldMask & whichField))
439 _sfReadOnly.copyToBin(pMem);
443 void DepthChunkBase::copyFromBin(BinaryDataHandler &pMem,
444 ConstFieldMaskArg whichField)
446 Inherited::copyFromBin(pMem, whichField);
448 if(FieldBits::NoField != (EnableFieldMask & whichField))
450 editSField(EnableFieldMask);
451 _sfEnable.copyFromBin(pMem);
453 if(FieldBits::NoField != (FuncFieldMask & whichField))
455 editSField(FuncFieldMask);
456 _sfFunc.copyFromBin(pMem);
458 if(FieldBits::NoField != (NearFieldMask & whichField))
460 editSField(NearFieldMask);
461 _sfNear.copyFromBin(pMem);
463 if(FieldBits::NoField != (FarFieldMask & whichField))
465 editSField(FarFieldMask);
466 _sfFar.copyFromBin(pMem);
468 if(FieldBits::NoField != (ReadOnlyFieldMask & whichField))
470 editSField(ReadOnlyFieldMask);
471 _sfReadOnly.copyFromBin(pMem);
475 //! create a new instance of the class
476 DepthChunkTransitPtr DepthChunkBase::createLocal(BitVector bFlags)
478 DepthChunkTransitPtr fc;
480 if(getClassType().getPrototype() != NULL)
482 FieldContainerTransitPtr tmpPtr =
483 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
485 fc = dynamic_pointer_cast<DepthChunk>(tmpPtr);
488 return fc;
491 //! create a new instance of the class, copy the container flags
492 DepthChunkTransitPtr DepthChunkBase::createDependent(BitVector bFlags)
494 DepthChunkTransitPtr fc;
496 if(getClassType().getPrototype() != NULL)
498 FieldContainerTransitPtr tmpPtr =
499 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
501 fc = dynamic_pointer_cast<DepthChunk>(tmpPtr);
504 return fc;
507 //! create a new instance of the class
508 DepthChunkTransitPtr DepthChunkBase::create(void)
510 DepthChunkTransitPtr fc;
512 if(getClassType().getPrototype() != NULL)
514 FieldContainerTransitPtr tmpPtr =
515 getClassType().getPrototype()-> shallowCopy();
517 fc = dynamic_pointer_cast<DepthChunk>(tmpPtr);
520 return fc;
523 DepthChunk *DepthChunkBase::createEmptyLocal(BitVector bFlags)
525 DepthChunk *returnValue;
527 newPtr<DepthChunk>(returnValue, bFlags);
529 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
531 return returnValue;
534 //! create an empty new instance of the class, do not copy the prototype
535 DepthChunk *DepthChunkBase::createEmpty(void)
537 DepthChunk *returnValue;
539 newPtr<DepthChunk>(returnValue, Thread::getCurrentLocalFlags());
541 returnValue->_pFieldFlags->_bNamespaceMask &=
542 ~Thread::getCurrentLocalFlags();
544 return returnValue;
548 FieldContainerTransitPtr DepthChunkBase::shallowCopyLocal(
549 BitVector bFlags) const
551 DepthChunk *tmpPtr;
553 newPtr(tmpPtr, dynamic_cast<const DepthChunk *>(this), bFlags);
555 FieldContainerTransitPtr returnValue(tmpPtr);
557 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
559 return returnValue;
562 FieldContainerTransitPtr DepthChunkBase::shallowCopyDependent(
563 BitVector bFlags) const
565 DepthChunk *tmpPtr;
567 newPtr(tmpPtr, dynamic_cast<const DepthChunk *>(this), ~bFlags);
569 FieldContainerTransitPtr returnValue(tmpPtr);
571 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
573 return returnValue;
576 FieldContainerTransitPtr DepthChunkBase::shallowCopy(void) const
578 DepthChunk *tmpPtr;
580 newPtr(tmpPtr,
581 dynamic_cast<const DepthChunk *>(this),
582 Thread::getCurrentLocalFlags());
584 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
586 FieldContainerTransitPtr returnValue(tmpPtr);
588 return returnValue;
594 /*------------------------- constructors ----------------------------------*/
596 DepthChunkBase::DepthChunkBase(void) :
597 Inherited(),
598 _sfEnable (bool(true)),
599 _sfFunc (GLenum(GL_LEQUAL)),
600 _sfNear (Real32(-1.f)),
601 _sfFar (Real32(-1.f)),
602 _sfReadOnly (bool(false))
606 DepthChunkBase::DepthChunkBase(const DepthChunkBase &source) :
607 Inherited(source),
608 _sfEnable (source._sfEnable ),
609 _sfFunc (source._sfFunc ),
610 _sfNear (source._sfNear ),
611 _sfFar (source._sfFar ),
612 _sfReadOnly (source._sfReadOnly )
617 /*-------------------------- destructors ----------------------------------*/
619 DepthChunkBase::~DepthChunkBase(void)
624 GetFieldHandlePtr DepthChunkBase::getHandleEnable (void) const
626 SFBool::GetHandlePtr returnValue(
627 new SFBool::GetHandle(
628 &_sfEnable,
629 this->getType().getFieldDesc(EnableFieldId),
630 const_cast<DepthChunkBase *>(this)));
632 return returnValue;
635 EditFieldHandlePtr DepthChunkBase::editHandleEnable (void)
637 SFBool::EditHandlePtr returnValue(
638 new SFBool::EditHandle(
639 &_sfEnable,
640 this->getType().getFieldDesc(EnableFieldId),
641 this));
644 editSField(EnableFieldMask);
646 return returnValue;
649 GetFieldHandlePtr DepthChunkBase::getHandleFunc (void) const
651 SFGLenum::GetHandlePtr returnValue(
652 new SFGLenum::GetHandle(
653 &_sfFunc,
654 this->getType().getFieldDesc(FuncFieldId),
655 const_cast<DepthChunkBase *>(this)));
657 return returnValue;
660 EditFieldHandlePtr DepthChunkBase::editHandleFunc (void)
662 SFGLenum::EditHandlePtr returnValue(
663 new SFGLenum::EditHandle(
664 &_sfFunc,
665 this->getType().getFieldDesc(FuncFieldId),
666 this));
669 editSField(FuncFieldMask);
671 return returnValue;
674 GetFieldHandlePtr DepthChunkBase::getHandleNear (void) const
676 SFReal32::GetHandlePtr returnValue(
677 new SFReal32::GetHandle(
678 &_sfNear,
679 this->getType().getFieldDesc(NearFieldId),
680 const_cast<DepthChunkBase *>(this)));
682 return returnValue;
685 EditFieldHandlePtr DepthChunkBase::editHandleNear (void)
687 SFReal32::EditHandlePtr returnValue(
688 new SFReal32::EditHandle(
689 &_sfNear,
690 this->getType().getFieldDesc(NearFieldId),
691 this));
694 editSField(NearFieldMask);
696 return returnValue;
699 GetFieldHandlePtr DepthChunkBase::getHandleFar (void) const
701 SFReal32::GetHandlePtr returnValue(
702 new SFReal32::GetHandle(
703 &_sfFar,
704 this->getType().getFieldDesc(FarFieldId),
705 const_cast<DepthChunkBase *>(this)));
707 return returnValue;
710 EditFieldHandlePtr DepthChunkBase::editHandleFar (void)
712 SFReal32::EditHandlePtr returnValue(
713 new SFReal32::EditHandle(
714 &_sfFar,
715 this->getType().getFieldDesc(FarFieldId),
716 this));
719 editSField(FarFieldMask);
721 return returnValue;
724 GetFieldHandlePtr DepthChunkBase::getHandleReadOnly (void) const
726 SFBool::GetHandlePtr returnValue(
727 new SFBool::GetHandle(
728 &_sfReadOnly,
729 this->getType().getFieldDesc(ReadOnlyFieldId),
730 const_cast<DepthChunkBase *>(this)));
732 return returnValue;
735 EditFieldHandlePtr DepthChunkBase::editHandleReadOnly (void)
737 SFBool::EditHandlePtr returnValue(
738 new SFBool::EditHandle(
739 &_sfReadOnly,
740 this->getType().getFieldDesc(ReadOnlyFieldId),
741 this));
744 editSField(ReadOnlyFieldMask);
746 return returnValue;
750 #ifdef OSG_MT_CPTR_ASPECT
751 void DepthChunkBase::execSyncV( FieldContainer &oFrom,
752 ConstFieldMaskArg whichField,
753 AspectOffsetStore &oOffsets,
754 ConstFieldMaskArg syncMode,
755 const UInt32 uiSyncInfo)
757 DepthChunk *pThis = static_cast<DepthChunk *>(this);
759 pThis->execSync(static_cast<DepthChunk *>(&oFrom),
760 whichField,
761 oOffsets,
762 syncMode,
763 uiSyncInfo);
765 #endif
768 #ifdef OSG_MT_CPTR_ASPECT
769 FieldContainer *DepthChunkBase::createAspectCopy(
770 const FieldContainer *pRefAspect) const
772 DepthChunk *returnValue;
774 newAspectCopy(returnValue,
775 dynamic_cast<const DepthChunk *>(pRefAspect),
776 dynamic_cast<const DepthChunk *>(this));
778 return returnValue;
780 #endif
782 void DepthChunkBase::resolveLinks(void)
784 Inherited::resolveLinks();
790 OSG_END_NAMESPACE