changed: gcc8 base update
[opensg.git] / Source / System / State / OpenGL / OSGFogChunkBase.cpp
bloba8c2197b7c6d81c24261d0cb0ecb879a362f96d0
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 FogChunk!
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" // Mode default header
67 #include "OSGFogChunkBase.h"
68 #include "OSGFogChunk.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::FogChunk
79 This chunk wraps glFog() (OSG::FogChunk::_sfMode, OSG::FogChunk::_sfFogColor,
80 OSG::FogChunk::_sfStart, OSG::FogChunk::_sfEnd, OSG::FogChunk::_sfDensity).
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var GLenum FogChunkBase::_sfMode
88 The fog type to use (GL_LINEAR, GL_EXP, GL_EXP2, default: GL_EXP).
91 /*! \var Color4f FogChunkBase::_sfColor
92 The color of the fog (default: 0, 0, 0, 0).
95 /*! \var Real32 FogChunkBase::_sfStart
96 The near value for the fog, used in GL_LINEAR mode (default: 0.f)
99 /*! \var Real32 FogChunkBase::_sfEnd
100 The far value for the fog, used in GL_LINEAR mode (default: 1.f)
103 /*! \var Real32 FogChunkBase::_sfDensity
104 The denisty of the fog, used in GL_EXP, GL_EXP2 mode (default: 1.f)
108 /***************************************************************************\
109 * FieldType/FieldTrait Instantiation *
110 \***************************************************************************/
112 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
113 PointerType FieldTraits<FogChunk *, nsOSG>::_type(
114 "FogChunkPtr",
115 "StateChunkPtr",
116 FogChunk::getClassType(),
117 nsOSG);
118 #endif
120 OSG_FIELDTRAITS_GETTYPE_NS(FogChunk *, nsOSG)
122 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
123 FogChunk *,
124 nsOSG)
126 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
127 FogChunk *,
128 nsOSG)
130 /***************************************************************************\
131 * Field Description *
132 \***************************************************************************/
134 void FogChunkBase::classDescInserter(TypeObject &oType)
136 FieldDescriptionBase *pDesc = NULL;
139 pDesc = new SFGLenum::Description(
140 SFGLenum::getClassType(),
141 "mode",
142 "The fog type to use (GL_LINEAR, GL_EXP, GL_EXP2, default: GL_EXP).\n",
143 ModeFieldId, ModeFieldMask,
144 false,
145 (Field::SFDefaultFlags | Field::FStdAccess),
146 static_cast<FieldEditMethodSig>(&FogChunk::editHandleMode),
147 static_cast<FieldGetMethodSig >(&FogChunk::getHandleMode));
149 oType.addInitialDesc(pDesc);
151 pDesc = new SFColor4f::Description(
152 SFColor4f::getClassType(),
153 "color",
154 "The color of the fog (default: 0, 0, 0, 0).\n",
155 ColorFieldId, ColorFieldMask,
156 false,
157 (Field::SFDefaultFlags | Field::FStdAccess),
158 static_cast<FieldEditMethodSig>(&FogChunk::editHandleColor),
159 static_cast<FieldGetMethodSig >(&FogChunk::getHandleColor));
161 oType.addInitialDesc(pDesc);
163 pDesc = new SFReal32::Description(
164 SFReal32::getClassType(),
165 "start",
166 "The near value for the fog, used in GL_LINEAR mode (default: 0.f)\n",
167 StartFieldId, StartFieldMask,
168 false,
169 (Field::SFDefaultFlags | Field::FStdAccess),
170 static_cast<FieldEditMethodSig>(&FogChunk::editHandleStart),
171 static_cast<FieldGetMethodSig >(&FogChunk::getHandleStart));
173 oType.addInitialDesc(pDesc);
175 pDesc = new SFReal32::Description(
176 SFReal32::getClassType(),
177 "end",
178 "The far value for the fog, used in GL_LINEAR mode (default: 1.f)\n",
179 EndFieldId, EndFieldMask,
180 false,
181 (Field::SFDefaultFlags | Field::FStdAccess),
182 static_cast<FieldEditMethodSig>(&FogChunk::editHandleEnd),
183 static_cast<FieldGetMethodSig >(&FogChunk::getHandleEnd));
185 oType.addInitialDesc(pDesc);
187 pDesc = new SFReal32::Description(
188 SFReal32::getClassType(),
189 "density",
190 "The denisty of the fog, used in GL_EXP, GL_EXP2 mode (default: 1.f)\n",
191 DensityFieldId, DensityFieldMask,
192 false,
193 (Field::SFDefaultFlags | Field::FStdAccess),
194 static_cast<FieldEditMethodSig>(&FogChunk::editHandleDensity),
195 static_cast<FieldGetMethodSig >(&FogChunk::getHandleDensity));
197 oType.addInitialDesc(pDesc);
201 FogChunkBase::TypeObject FogChunkBase::_type(
202 FogChunkBase::getClassname(),
203 Inherited::getClassname(),
204 "NULL",
205 nsOSG, //Namespace
206 reinterpret_cast<PrototypeCreateF>(&FogChunkBase::createEmptyLocal),
207 reinterpret_cast<InitContainerF>(&FogChunk::initMethod),
208 reinterpret_cast<ExitContainerF>(&FogChunk::exitMethod),
209 reinterpret_cast<InitalInsertDescFunc>(
210 reinterpret_cast<void *>(&FogChunk::classDescInserter)),
211 false,
213 "<?xml version=\"1.0\"?>\n"
214 "\n"
215 "<FieldContainer\n"
216 " name=\"FogChunk\"\n"
217 " parent=\"StateChunk\"\n"
218 " library=\"State\"\n"
219 " pointerfieldtypes=\"both\"\n"
220 " structure=\"concrete\"\n"
221 " systemcomponent=\"true\"\n"
222 " parentsystemcomponent=\"true\"\n"
223 " decoratable=\"false\"\n"
224 " docGroupBase=\"GrpStateOpenGL\"\n"
225 " >\n"
226 " This chunk wraps glFog() (OSG::FogChunk::_sfMode, OSG::FogChunk::_sfFogColor,\n"
227 " OSG::FogChunk::_sfStart, OSG::FogChunk::_sfEnd, OSG::FogChunk::_sfDensity).\n"
228 "\n"
229 " <Field\n"
230 " name=\"mode\"\n"
231 " type=\"GLenum\"\n"
232 " category=\"data\"\n"
233 " cardinality=\"single\"\n"
234 " defaultValue=\"GL_EXP\"\n"
235 " defaultHeader=\"&quot;OSGGL.h&quot;\"\n"
236 " visibility=\"external\"\n"
237 " access=\"public\"\n"
238 " >\n"
239 " The fog type to use (GL_LINEAR, GL_EXP, GL_EXP2, default: GL_EXP).\n"
240 " </Field>\n"
241 "\n"
242 " <Field\n"
243 " name=\"color\"\n"
244 " type=\"Color4f\"\n"
245 " category=\"data\"\n"
246 " cardinality=\"single\"\n"
247 " defaultValue=\"0.f, 0.f, 0.f, 0.f\"\n"
248 " visibility=\"external\"\n"
249 " access=\"public\"\n"
250 " >\n"
251 " The color of the fog (default: 0, 0, 0, 0).\n"
252 " </Field>\n"
253 "\n"
254 " <Field\n"
255 " name=\"start\"\n"
256 " type=\"Real32\"\n"
257 " category=\"data\"\n"
258 " cardinality=\"single\"\n"
259 " defaultValue=\"0.f\"\n"
260 " visibility=\"external\"\n"
261 " access=\"public\"\n"
262 " >\n"
263 " The near value for the fog, used in GL_LINEAR mode (default: 0.f)\n"
264 " </Field>\n"
265 "\n"
266 " <Field\n"
267 " name=\"end\"\n"
268 " type=\"Real32\"\n"
269 " category=\"data\"\n"
270 " cardinality=\"single\"\n"
271 " defaultValue=\"1.f\"\n"
272 " visibility=\"external\"\n"
273 " access=\"public\"\n"
274 " >\n"
275 " The far value for the fog, used in GL_LINEAR mode (default: 1.f)\n"
276 " </Field>\n"
277 "\n"
278 " <Field\n"
279 " name=\"density\"\n"
280 " type=\"Real32\"\n"
281 " category=\"data\"\n"
282 " cardinality=\"single\"\n"
283 " defaultValue=\"1.f\"\n"
284 " visibility=\"external\"\n"
285 " access=\"public\"\n"
286 " >\n"
287 " The denisty of the fog, used in GL_EXP, GL_EXP2 mode (default: 1.f)\n"
288 " </Field>\n"
289 "</FieldContainer>\n",
290 "This chunk wraps glFog() (OSG::FogChunk::_sfMode, OSG::FogChunk::_sfFogColor,\n"
291 "OSG::FogChunk::_sfStart, OSG::FogChunk::_sfEnd, OSG::FogChunk::_sfDensity).\n"
294 /*------------------------------ get -----------------------------------*/
296 FieldContainerType &FogChunkBase::getType(void)
298 return _type;
301 const FieldContainerType &FogChunkBase::getType(void) const
303 return _type;
306 UInt32 FogChunkBase::getContainerSize(void) const
308 return sizeof(FogChunk);
311 /*------------------------- decorator get ------------------------------*/
314 SFGLenum *FogChunkBase::editSFMode(void)
316 editSField(ModeFieldMask);
318 return &_sfMode;
321 const SFGLenum *FogChunkBase::getSFMode(void) const
323 return &_sfMode;
327 SFColor4f *FogChunkBase::editSFColor(void)
329 editSField(ColorFieldMask);
331 return &_sfColor;
334 const SFColor4f *FogChunkBase::getSFColor(void) const
336 return &_sfColor;
340 SFReal32 *FogChunkBase::editSFStart(void)
342 editSField(StartFieldMask);
344 return &_sfStart;
347 const SFReal32 *FogChunkBase::getSFStart(void) const
349 return &_sfStart;
353 SFReal32 *FogChunkBase::editSFEnd(void)
355 editSField(EndFieldMask);
357 return &_sfEnd;
360 const SFReal32 *FogChunkBase::getSFEnd(void) const
362 return &_sfEnd;
366 SFReal32 *FogChunkBase::editSFDensity(void)
368 editSField(DensityFieldMask);
370 return &_sfDensity;
373 const SFReal32 *FogChunkBase::getSFDensity(void) const
375 return &_sfDensity;
383 /*------------------------------ access -----------------------------------*/
385 SizeT FogChunkBase::getBinSize(ConstFieldMaskArg whichField)
387 SizeT returnValue = Inherited::getBinSize(whichField);
389 if(FieldBits::NoField != (ModeFieldMask & whichField))
391 returnValue += _sfMode.getBinSize();
393 if(FieldBits::NoField != (ColorFieldMask & whichField))
395 returnValue += _sfColor.getBinSize();
397 if(FieldBits::NoField != (StartFieldMask & whichField))
399 returnValue += _sfStart.getBinSize();
401 if(FieldBits::NoField != (EndFieldMask & whichField))
403 returnValue += _sfEnd.getBinSize();
405 if(FieldBits::NoField != (DensityFieldMask & whichField))
407 returnValue += _sfDensity.getBinSize();
410 return returnValue;
413 void FogChunkBase::copyToBin(BinaryDataHandler &pMem,
414 ConstFieldMaskArg whichField)
416 Inherited::copyToBin(pMem, whichField);
418 if(FieldBits::NoField != (ModeFieldMask & whichField))
420 _sfMode.copyToBin(pMem);
422 if(FieldBits::NoField != (ColorFieldMask & whichField))
424 _sfColor.copyToBin(pMem);
426 if(FieldBits::NoField != (StartFieldMask & whichField))
428 _sfStart.copyToBin(pMem);
430 if(FieldBits::NoField != (EndFieldMask & whichField))
432 _sfEnd.copyToBin(pMem);
434 if(FieldBits::NoField != (DensityFieldMask & whichField))
436 _sfDensity.copyToBin(pMem);
440 void FogChunkBase::copyFromBin(BinaryDataHandler &pMem,
441 ConstFieldMaskArg whichField)
443 Inherited::copyFromBin(pMem, whichField);
445 if(FieldBits::NoField != (ModeFieldMask & whichField))
447 editSField(ModeFieldMask);
448 _sfMode.copyFromBin(pMem);
450 if(FieldBits::NoField != (ColorFieldMask & whichField))
452 editSField(ColorFieldMask);
453 _sfColor.copyFromBin(pMem);
455 if(FieldBits::NoField != (StartFieldMask & whichField))
457 editSField(StartFieldMask);
458 _sfStart.copyFromBin(pMem);
460 if(FieldBits::NoField != (EndFieldMask & whichField))
462 editSField(EndFieldMask);
463 _sfEnd.copyFromBin(pMem);
465 if(FieldBits::NoField != (DensityFieldMask & whichField))
467 editSField(DensityFieldMask);
468 _sfDensity.copyFromBin(pMem);
472 //! create a new instance of the class
473 FogChunkTransitPtr FogChunkBase::createLocal(BitVector bFlags)
475 FogChunkTransitPtr fc;
477 if(getClassType().getPrototype() != NULL)
479 FieldContainerTransitPtr tmpPtr =
480 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
482 fc = dynamic_pointer_cast<FogChunk>(tmpPtr);
485 return fc;
488 //! create a new instance of the class, copy the container flags
489 FogChunkTransitPtr FogChunkBase::createDependent(BitVector bFlags)
491 FogChunkTransitPtr fc;
493 if(getClassType().getPrototype() != NULL)
495 FieldContainerTransitPtr tmpPtr =
496 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
498 fc = dynamic_pointer_cast<FogChunk>(tmpPtr);
501 return fc;
504 //! create a new instance of the class
505 FogChunkTransitPtr FogChunkBase::create(void)
507 FogChunkTransitPtr fc;
509 if(getClassType().getPrototype() != NULL)
511 FieldContainerTransitPtr tmpPtr =
512 getClassType().getPrototype()-> shallowCopy();
514 fc = dynamic_pointer_cast<FogChunk>(tmpPtr);
517 return fc;
520 FogChunk *FogChunkBase::createEmptyLocal(BitVector bFlags)
522 FogChunk *returnValue;
524 newPtr<FogChunk>(returnValue, bFlags);
526 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
528 return returnValue;
531 //! create an empty new instance of the class, do not copy the prototype
532 FogChunk *FogChunkBase::createEmpty(void)
534 FogChunk *returnValue;
536 newPtr<FogChunk>(returnValue, Thread::getCurrentLocalFlags());
538 returnValue->_pFieldFlags->_bNamespaceMask &=
539 ~Thread::getCurrentLocalFlags();
541 return returnValue;
545 FieldContainerTransitPtr FogChunkBase::shallowCopyLocal(
546 BitVector bFlags) const
548 FogChunk *tmpPtr;
550 newPtr(tmpPtr, dynamic_cast<const FogChunk *>(this), bFlags);
552 FieldContainerTransitPtr returnValue(tmpPtr);
554 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
556 return returnValue;
559 FieldContainerTransitPtr FogChunkBase::shallowCopyDependent(
560 BitVector bFlags) const
562 FogChunk *tmpPtr;
564 newPtr(tmpPtr, dynamic_cast<const FogChunk *>(this), ~bFlags);
566 FieldContainerTransitPtr returnValue(tmpPtr);
568 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
570 return returnValue;
573 FieldContainerTransitPtr FogChunkBase::shallowCopy(void) const
575 FogChunk *tmpPtr;
577 newPtr(tmpPtr,
578 dynamic_cast<const FogChunk *>(this),
579 Thread::getCurrentLocalFlags());
581 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
583 FieldContainerTransitPtr returnValue(tmpPtr);
585 return returnValue;
591 /*------------------------- constructors ----------------------------------*/
593 FogChunkBase::FogChunkBase(void) :
594 Inherited(),
595 _sfMode (GLenum(GL_EXP)),
596 _sfColor (Color4f(0.f, 0.f, 0.f, 0.f)),
597 _sfStart (Real32(0.f)),
598 _sfEnd (Real32(1.f)),
599 _sfDensity (Real32(1.f))
603 FogChunkBase::FogChunkBase(const FogChunkBase &source) :
604 Inherited(source),
605 _sfMode (source._sfMode ),
606 _sfColor (source._sfColor ),
607 _sfStart (source._sfStart ),
608 _sfEnd (source._sfEnd ),
609 _sfDensity (source._sfDensity )
614 /*-------------------------- destructors ----------------------------------*/
616 FogChunkBase::~FogChunkBase(void)
621 GetFieldHandlePtr FogChunkBase::getHandleMode (void) const
623 SFGLenum::GetHandlePtr returnValue(
624 new SFGLenum::GetHandle(
625 &_sfMode,
626 this->getType().getFieldDesc(ModeFieldId),
627 const_cast<FogChunkBase *>(this)));
629 return returnValue;
632 EditFieldHandlePtr FogChunkBase::editHandleMode (void)
634 SFGLenum::EditHandlePtr returnValue(
635 new SFGLenum::EditHandle(
636 &_sfMode,
637 this->getType().getFieldDesc(ModeFieldId),
638 this));
641 editSField(ModeFieldMask);
643 return returnValue;
646 GetFieldHandlePtr FogChunkBase::getHandleColor (void) const
648 SFColor4f::GetHandlePtr returnValue(
649 new SFColor4f::GetHandle(
650 &_sfColor,
651 this->getType().getFieldDesc(ColorFieldId),
652 const_cast<FogChunkBase *>(this)));
654 return returnValue;
657 EditFieldHandlePtr FogChunkBase::editHandleColor (void)
659 SFColor4f::EditHandlePtr returnValue(
660 new SFColor4f::EditHandle(
661 &_sfColor,
662 this->getType().getFieldDesc(ColorFieldId),
663 this));
666 editSField(ColorFieldMask);
668 return returnValue;
671 GetFieldHandlePtr FogChunkBase::getHandleStart (void) const
673 SFReal32::GetHandlePtr returnValue(
674 new SFReal32::GetHandle(
675 &_sfStart,
676 this->getType().getFieldDesc(StartFieldId),
677 const_cast<FogChunkBase *>(this)));
679 return returnValue;
682 EditFieldHandlePtr FogChunkBase::editHandleStart (void)
684 SFReal32::EditHandlePtr returnValue(
685 new SFReal32::EditHandle(
686 &_sfStart,
687 this->getType().getFieldDesc(StartFieldId),
688 this));
691 editSField(StartFieldMask);
693 return returnValue;
696 GetFieldHandlePtr FogChunkBase::getHandleEnd (void) const
698 SFReal32::GetHandlePtr returnValue(
699 new SFReal32::GetHandle(
700 &_sfEnd,
701 this->getType().getFieldDesc(EndFieldId),
702 const_cast<FogChunkBase *>(this)));
704 return returnValue;
707 EditFieldHandlePtr FogChunkBase::editHandleEnd (void)
709 SFReal32::EditHandlePtr returnValue(
710 new SFReal32::EditHandle(
711 &_sfEnd,
712 this->getType().getFieldDesc(EndFieldId),
713 this));
716 editSField(EndFieldMask);
718 return returnValue;
721 GetFieldHandlePtr FogChunkBase::getHandleDensity (void) const
723 SFReal32::GetHandlePtr returnValue(
724 new SFReal32::GetHandle(
725 &_sfDensity,
726 this->getType().getFieldDesc(DensityFieldId),
727 const_cast<FogChunkBase *>(this)));
729 return returnValue;
732 EditFieldHandlePtr FogChunkBase::editHandleDensity (void)
734 SFReal32::EditHandlePtr returnValue(
735 new SFReal32::EditHandle(
736 &_sfDensity,
737 this->getType().getFieldDesc(DensityFieldId),
738 this));
741 editSField(DensityFieldMask);
743 return returnValue;
747 #ifdef OSG_MT_CPTR_ASPECT
748 void FogChunkBase::execSyncV( FieldContainer &oFrom,
749 ConstFieldMaskArg whichField,
750 AspectOffsetStore &oOffsets,
751 ConstFieldMaskArg syncMode,
752 const UInt32 uiSyncInfo)
754 FogChunk *pThis = static_cast<FogChunk *>(this);
756 pThis->execSync(static_cast<FogChunk *>(&oFrom),
757 whichField,
758 oOffsets,
759 syncMode,
760 uiSyncInfo);
762 #endif
765 #ifdef OSG_MT_CPTR_ASPECT
766 FieldContainer *FogChunkBase::createAspectCopy(
767 const FieldContainer *pRefAspect) const
769 FogChunk *returnValue;
771 newAspectCopy(returnValue,
772 dynamic_cast<const FogChunk *>(pRefAspect),
773 dynamic_cast<const FogChunk *>(this));
775 return returnValue;
777 #endif
779 void FogChunkBase::resolveLinks(void)
781 Inherited::resolveLinks();
787 OSG_END_NAMESPACE