changed: gcc8 base update
[opensg.git] / Source / System / State / OpenGL / OSGLightModelChunkBase.cpp
blob1f13759d06bf5d224f6af3eea6a15d84eb5c11a2
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 LightModelChunk!
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 "OSGGLEXT.h" // ColorControl default header
67 #include "OSGLightModelChunkBase.h"
68 #include "OSGLightModelChunk.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::LightModelChunk
79 The LightModelChunk wraps most of glLightModel. It does not wrap
80 GL_LIGHT_MODEL_TWO_SIDE, which is wrapped by TwoSidedLightingChunk.
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var Color4f LightModelChunkBase::_sfAmbient
88 GL_LIGHT_MODEL_AMBIENT is set to this color.
91 /*! \var GLenum LightModelChunkBase::_sfColorControl
92 GL_LIGHT_MODEL_COLOR_CONTROL is set to this value. Legal values are
93 directly taken from the glLightModel() manpage.
96 /*! \var bool LightModelChunkBase::_sfLocalViewer
97 GL_LIGHT_MODEL_LOCAL_VIEWER is activated by this bool.
101 /***************************************************************************\
102 * FieldType/FieldTrait Instantiation *
103 \***************************************************************************/
105 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
106 PointerType FieldTraits<LightModelChunk *, nsOSG>::_type(
107 "LightModelChunkPtr",
108 "StateChunkPtr",
109 LightModelChunk::getClassType(),
110 nsOSG);
111 #endif
113 OSG_FIELDTRAITS_GETTYPE_NS(LightModelChunk *, nsOSG)
115 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
116 LightModelChunk *,
117 nsOSG)
119 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
120 LightModelChunk *,
121 nsOSG)
123 /***************************************************************************\
124 * Field Description *
125 \***************************************************************************/
127 void LightModelChunkBase::classDescInserter(TypeObject &oType)
129 FieldDescriptionBase *pDesc = NULL;
132 pDesc = new SFColor4f::Description(
133 SFColor4f::getClassType(),
134 "ambient",
135 "GL_LIGHT_MODEL_AMBIENT is set to this color.\n",
136 AmbientFieldId, AmbientFieldMask,
137 false,
138 (Field::SFDefaultFlags | Field::FStdAccess),
139 static_cast<FieldEditMethodSig>(&LightModelChunk::editHandleAmbient),
140 static_cast<FieldGetMethodSig >(&LightModelChunk::getHandleAmbient));
142 oType.addInitialDesc(pDesc);
144 pDesc = new SFGLenum::Description(
145 SFGLenum::getClassType(),
146 "colorControl",
147 "GL_LIGHT_MODEL_COLOR_CONTROL is set to this value. Legal values are\n"
148 "directly taken from the glLightModel() manpage. \n",
149 ColorControlFieldId, ColorControlFieldMask,
150 false,
151 (Field::SFDefaultFlags | Field::FStdAccess),
152 static_cast<FieldEditMethodSig>(&LightModelChunk::editHandleColorControl),
153 static_cast<FieldGetMethodSig >(&LightModelChunk::getHandleColorControl));
155 oType.addInitialDesc(pDesc);
157 pDesc = new SFBool::Description(
158 SFBool::getClassType(),
159 "localViewer",
160 "GL_LIGHT_MODEL_LOCAL_VIEWER is activated by this bool.\n",
161 LocalViewerFieldId, LocalViewerFieldMask,
162 false,
163 (Field::SFDefaultFlags | Field::FStdAccess),
164 static_cast<FieldEditMethodSig>(&LightModelChunk::editHandleLocalViewer),
165 static_cast<FieldGetMethodSig >(&LightModelChunk::getHandleLocalViewer));
167 oType.addInitialDesc(pDesc);
171 LightModelChunkBase::TypeObject LightModelChunkBase::_type(
172 LightModelChunkBase::getClassname(),
173 Inherited::getClassname(),
174 "NULL",
175 nsOSG, //Namespace
176 reinterpret_cast<PrototypeCreateF>(&LightModelChunkBase::createEmptyLocal),
177 reinterpret_cast<InitContainerF>(&LightModelChunk::initMethod),
178 reinterpret_cast<ExitContainerF>(&LightModelChunk::exitMethod),
179 reinterpret_cast<InitalInsertDescFunc>(
180 reinterpret_cast<void *>(&LightModelChunk::classDescInserter)),
181 false,
183 "<?xml version=\"1.0\"?>\n"
184 "\n"
185 "<FieldContainer\n"
186 " name=\"LightModelChunk\"\n"
187 " parent=\"StateChunk\"\n"
188 " library=\"State\"\n"
189 " pointerfieldtypes=\"both\"\n"
190 " structure=\"concrete\"\n"
191 " systemcomponent=\"true\"\n"
192 " parentsystemcomponent=\"true\"\n"
193 " decoratable=\"false\"\n"
194 " useLocalIncludes=\"false\"\n"
195 " docGroupBase=\"GrpStateOpenGL\"\n"
196 " >\n"
197 " The LightModelChunk wraps most of glLightModel. It does not wrap\n"
198 " GL_LIGHT_MODEL_TWO_SIDE, which is wrapped by TwoSidedLightingChunk. \n"
199 " <Field\n"
200 "\t name=\"ambient\"\n"
201 "\t type=\"Color4f\"\n"
202 "\t cardinality=\"single\"\n"
203 "\t visibility=\"external\"\n"
204 "\t defaultValue=\"0.2f, 0.2f, 0.2f, 1.0f\"\n"
205 "\t access=\"public\"\n"
206 "\t >\n"
207 "\tGL_LIGHT_MODEL_AMBIENT is set to this color.\n"
208 " </Field>\n"
209 " <Field\n"
210 "\t name=\"colorControl\"\n"
211 "\t type=\"GLenum\"\n"
212 "\t cardinality=\"single\"\n"
213 "\t visibility=\"external\"\n"
214 "\t defaultValue=\"GL_SINGLE_COLOR\"\n"
215 "\t defaultHeader=\"&quot;OSGGLEXT.h&quot;\"\n"
216 "\t access=\"public\"\n"
217 "\t >\n"
218 "\tGL_LIGHT_MODEL_COLOR_CONTROL is set to this value. Legal values are\n"
219 "\tdirectly taken from the glLightModel() manpage. \n"
220 " </Field>\n"
221 " <Field\n"
222 "\t name=\"localViewer\"\n"
223 "\t type=\"bool\"\n"
224 "\t cardinality=\"single\"\n"
225 "\t visibility=\"external\"\n"
226 "\t defaultValue=\"false\"\n"
227 "\t access=\"public\"\n"
228 "\t >\n"
229 "\tGL_LIGHT_MODEL_LOCAL_VIEWER is activated by this bool.\n"
230 " </Field>\n"
231 "</FieldContainer>\n",
232 "The LightModelChunk wraps most of glLightModel. It does not wrap\n"
233 "GL_LIGHT_MODEL_TWO_SIDE, which is wrapped by TwoSidedLightingChunk. \n"
236 /*------------------------------ get -----------------------------------*/
238 FieldContainerType &LightModelChunkBase::getType(void)
240 return _type;
243 const FieldContainerType &LightModelChunkBase::getType(void) const
245 return _type;
248 UInt32 LightModelChunkBase::getContainerSize(void) const
250 return sizeof(LightModelChunk);
253 /*------------------------- decorator get ------------------------------*/
256 SFColor4f *LightModelChunkBase::editSFAmbient(void)
258 editSField(AmbientFieldMask);
260 return &_sfAmbient;
263 const SFColor4f *LightModelChunkBase::getSFAmbient(void) const
265 return &_sfAmbient;
269 SFGLenum *LightModelChunkBase::editSFColorControl(void)
271 editSField(ColorControlFieldMask);
273 return &_sfColorControl;
276 const SFGLenum *LightModelChunkBase::getSFColorControl(void) const
278 return &_sfColorControl;
282 SFBool *LightModelChunkBase::editSFLocalViewer(void)
284 editSField(LocalViewerFieldMask);
286 return &_sfLocalViewer;
289 const SFBool *LightModelChunkBase::getSFLocalViewer(void) const
291 return &_sfLocalViewer;
299 /*------------------------------ access -----------------------------------*/
301 SizeT LightModelChunkBase::getBinSize(ConstFieldMaskArg whichField)
303 SizeT returnValue = Inherited::getBinSize(whichField);
305 if(FieldBits::NoField != (AmbientFieldMask & whichField))
307 returnValue += _sfAmbient.getBinSize();
309 if(FieldBits::NoField != (ColorControlFieldMask & whichField))
311 returnValue += _sfColorControl.getBinSize();
313 if(FieldBits::NoField != (LocalViewerFieldMask & whichField))
315 returnValue += _sfLocalViewer.getBinSize();
318 return returnValue;
321 void LightModelChunkBase::copyToBin(BinaryDataHandler &pMem,
322 ConstFieldMaskArg whichField)
324 Inherited::copyToBin(pMem, whichField);
326 if(FieldBits::NoField != (AmbientFieldMask & whichField))
328 _sfAmbient.copyToBin(pMem);
330 if(FieldBits::NoField != (ColorControlFieldMask & whichField))
332 _sfColorControl.copyToBin(pMem);
334 if(FieldBits::NoField != (LocalViewerFieldMask & whichField))
336 _sfLocalViewer.copyToBin(pMem);
340 void LightModelChunkBase::copyFromBin(BinaryDataHandler &pMem,
341 ConstFieldMaskArg whichField)
343 Inherited::copyFromBin(pMem, whichField);
345 if(FieldBits::NoField != (AmbientFieldMask & whichField))
347 editSField(AmbientFieldMask);
348 _sfAmbient.copyFromBin(pMem);
350 if(FieldBits::NoField != (ColorControlFieldMask & whichField))
352 editSField(ColorControlFieldMask);
353 _sfColorControl.copyFromBin(pMem);
355 if(FieldBits::NoField != (LocalViewerFieldMask & whichField))
357 editSField(LocalViewerFieldMask);
358 _sfLocalViewer.copyFromBin(pMem);
362 //! create a new instance of the class
363 LightModelChunkTransitPtr LightModelChunkBase::createLocal(BitVector bFlags)
365 LightModelChunkTransitPtr fc;
367 if(getClassType().getPrototype() != NULL)
369 FieldContainerTransitPtr tmpPtr =
370 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
372 fc = dynamic_pointer_cast<LightModelChunk>(tmpPtr);
375 return fc;
378 //! create a new instance of the class, copy the container flags
379 LightModelChunkTransitPtr LightModelChunkBase::createDependent(BitVector bFlags)
381 LightModelChunkTransitPtr fc;
383 if(getClassType().getPrototype() != NULL)
385 FieldContainerTransitPtr tmpPtr =
386 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
388 fc = dynamic_pointer_cast<LightModelChunk>(tmpPtr);
391 return fc;
394 //! create a new instance of the class
395 LightModelChunkTransitPtr LightModelChunkBase::create(void)
397 LightModelChunkTransitPtr fc;
399 if(getClassType().getPrototype() != NULL)
401 FieldContainerTransitPtr tmpPtr =
402 getClassType().getPrototype()-> shallowCopy();
404 fc = dynamic_pointer_cast<LightModelChunk>(tmpPtr);
407 return fc;
410 LightModelChunk *LightModelChunkBase::createEmptyLocal(BitVector bFlags)
412 LightModelChunk *returnValue;
414 newPtr<LightModelChunk>(returnValue, bFlags);
416 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
418 return returnValue;
421 //! create an empty new instance of the class, do not copy the prototype
422 LightModelChunk *LightModelChunkBase::createEmpty(void)
424 LightModelChunk *returnValue;
426 newPtr<LightModelChunk>(returnValue, Thread::getCurrentLocalFlags());
428 returnValue->_pFieldFlags->_bNamespaceMask &=
429 ~Thread::getCurrentLocalFlags();
431 return returnValue;
435 FieldContainerTransitPtr LightModelChunkBase::shallowCopyLocal(
436 BitVector bFlags) const
438 LightModelChunk *tmpPtr;
440 newPtr(tmpPtr, dynamic_cast<const LightModelChunk *>(this), bFlags);
442 FieldContainerTransitPtr returnValue(tmpPtr);
444 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
446 return returnValue;
449 FieldContainerTransitPtr LightModelChunkBase::shallowCopyDependent(
450 BitVector bFlags) const
452 LightModelChunk *tmpPtr;
454 newPtr(tmpPtr, dynamic_cast<const LightModelChunk *>(this), ~bFlags);
456 FieldContainerTransitPtr returnValue(tmpPtr);
458 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
460 return returnValue;
463 FieldContainerTransitPtr LightModelChunkBase::shallowCopy(void) const
465 LightModelChunk *tmpPtr;
467 newPtr(tmpPtr,
468 dynamic_cast<const LightModelChunk *>(this),
469 Thread::getCurrentLocalFlags());
471 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
473 FieldContainerTransitPtr returnValue(tmpPtr);
475 return returnValue;
481 /*------------------------- constructors ----------------------------------*/
483 LightModelChunkBase::LightModelChunkBase(void) :
484 Inherited(),
485 _sfAmbient (Color4f(0.2f, 0.2f, 0.2f, 1.0f)),
486 _sfColorControl (GLenum(GL_SINGLE_COLOR)),
487 _sfLocalViewer (bool(false))
491 LightModelChunkBase::LightModelChunkBase(const LightModelChunkBase &source) :
492 Inherited(source),
493 _sfAmbient (source._sfAmbient ),
494 _sfColorControl (source._sfColorControl ),
495 _sfLocalViewer (source._sfLocalViewer )
500 /*-------------------------- destructors ----------------------------------*/
502 LightModelChunkBase::~LightModelChunkBase(void)
507 GetFieldHandlePtr LightModelChunkBase::getHandleAmbient (void) const
509 SFColor4f::GetHandlePtr returnValue(
510 new SFColor4f::GetHandle(
511 &_sfAmbient,
512 this->getType().getFieldDesc(AmbientFieldId),
513 const_cast<LightModelChunkBase *>(this)));
515 return returnValue;
518 EditFieldHandlePtr LightModelChunkBase::editHandleAmbient (void)
520 SFColor4f::EditHandlePtr returnValue(
521 new SFColor4f::EditHandle(
522 &_sfAmbient,
523 this->getType().getFieldDesc(AmbientFieldId),
524 this));
527 editSField(AmbientFieldMask);
529 return returnValue;
532 GetFieldHandlePtr LightModelChunkBase::getHandleColorControl (void) const
534 SFGLenum::GetHandlePtr returnValue(
535 new SFGLenum::GetHandle(
536 &_sfColorControl,
537 this->getType().getFieldDesc(ColorControlFieldId),
538 const_cast<LightModelChunkBase *>(this)));
540 return returnValue;
543 EditFieldHandlePtr LightModelChunkBase::editHandleColorControl (void)
545 SFGLenum::EditHandlePtr returnValue(
546 new SFGLenum::EditHandle(
547 &_sfColorControl,
548 this->getType().getFieldDesc(ColorControlFieldId),
549 this));
552 editSField(ColorControlFieldMask);
554 return returnValue;
557 GetFieldHandlePtr LightModelChunkBase::getHandleLocalViewer (void) const
559 SFBool::GetHandlePtr returnValue(
560 new SFBool::GetHandle(
561 &_sfLocalViewer,
562 this->getType().getFieldDesc(LocalViewerFieldId),
563 const_cast<LightModelChunkBase *>(this)));
565 return returnValue;
568 EditFieldHandlePtr LightModelChunkBase::editHandleLocalViewer (void)
570 SFBool::EditHandlePtr returnValue(
571 new SFBool::EditHandle(
572 &_sfLocalViewer,
573 this->getType().getFieldDesc(LocalViewerFieldId),
574 this));
577 editSField(LocalViewerFieldMask);
579 return returnValue;
583 #ifdef OSG_MT_CPTR_ASPECT
584 void LightModelChunkBase::execSyncV( FieldContainer &oFrom,
585 ConstFieldMaskArg whichField,
586 AspectOffsetStore &oOffsets,
587 ConstFieldMaskArg syncMode,
588 const UInt32 uiSyncInfo)
590 LightModelChunk *pThis = static_cast<LightModelChunk *>(this);
592 pThis->execSync(static_cast<LightModelChunk *>(&oFrom),
593 whichField,
594 oOffsets,
595 syncMode,
596 uiSyncInfo);
598 #endif
601 #ifdef OSG_MT_CPTR_ASPECT
602 FieldContainer *LightModelChunkBase::createAspectCopy(
603 const FieldContainer *pRefAspect) const
605 LightModelChunk *returnValue;
607 newAspectCopy(returnValue,
608 dynamic_cast<const LightModelChunk *>(pRefAspect),
609 dynamic_cast<const LightModelChunk *>(this));
611 return returnValue;
613 #endif
615 void LightModelChunkBase::resolveLinks(void)
617 Inherited::resolveLinks();
623 OSG_END_NAMESPACE