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 LightModelChunk!
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"
64 #include "OSGGLEXT.h" // ColorControl default header
67 #include "OSGLightModelChunkBase.h"
68 #include "OSGLightModelChunk.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
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",
109 LightModelChunk::getClassType(),
113 OSG_FIELDTRAITS_GETTYPE_NS(LightModelChunk
*, nsOSG
)
115 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
119 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
123 /***************************************************************************\
124 * Field Description *
125 \***************************************************************************/
127 void LightModelChunkBase::classDescInserter(TypeObject
&oType
)
129 FieldDescriptionBase
*pDesc
= NULL
;
132 pDesc
= new SFColor4f::Description(
133 SFColor4f::getClassType(),
135 "GL_LIGHT_MODEL_AMBIENT is set to this color.\n",
136 AmbientFieldId
, AmbientFieldMask
,
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(),
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
,
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(),
160 "GL_LIGHT_MODEL_LOCAL_VIEWER is activated by this bool.\n",
161 LocalViewerFieldId
, LocalViewerFieldMask
,
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(),
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
)),
183 "<?xml version=\"1.0\"?>\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"
197 " The LightModelChunk wraps most of glLightModel. It does not wrap\n"
198 " GL_LIGHT_MODEL_TWO_SIDE, which is wrapped by TwoSidedLightingChunk. \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"
207 "\tGL_LIGHT_MODEL_AMBIENT is set to this color.\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=\""OSGGLEXT.h"\"\n"
216 "\t access=\"public\"\n"
218 "\tGL_LIGHT_MODEL_COLOR_CONTROL is set to this value. Legal values are\n"
219 "\tdirectly taken from the glLightModel() manpage. \n"
222 "\t name=\"localViewer\"\n"
224 "\t cardinality=\"single\"\n"
225 "\t visibility=\"external\"\n"
226 "\t defaultValue=\"false\"\n"
227 "\t access=\"public\"\n"
229 "\tGL_LIGHT_MODEL_LOCAL_VIEWER is activated by this bool.\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)
243 const FieldContainerType
&LightModelChunkBase::getType(void) const
248 UInt32
LightModelChunkBase::getContainerSize(void) const
250 return sizeof(LightModelChunk
);
253 /*------------------------- decorator get ------------------------------*/
256 SFColor4f
*LightModelChunkBase::editSFAmbient(void)
258 editSField(AmbientFieldMask
);
263 const SFColor4f
*LightModelChunkBase::getSFAmbient(void) const
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();
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
);
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
);
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
);
410 LightModelChunk
*LightModelChunkBase::createEmptyLocal(BitVector bFlags
)
412 LightModelChunk
*returnValue
;
414 newPtr
<LightModelChunk
>(returnValue
, bFlags
);
416 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
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();
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
;
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
;
463 FieldContainerTransitPtr
LightModelChunkBase::shallowCopy(void) const
465 LightModelChunk
*tmpPtr
;
468 dynamic_cast<const LightModelChunk
*>(this),
469 Thread::getCurrentLocalFlags());
471 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
473 FieldContainerTransitPtr
returnValue(tmpPtr
);
481 /*------------------------- constructors ----------------------------------*/
483 LightModelChunkBase::LightModelChunkBase(void) :
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
) :
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(
512 this->getType().getFieldDesc(AmbientFieldId
),
513 const_cast<LightModelChunkBase
*>(this)));
518 EditFieldHandlePtr
LightModelChunkBase::editHandleAmbient (void)
520 SFColor4f::EditHandlePtr
returnValue(
521 new SFColor4f::EditHandle(
523 this->getType().getFieldDesc(AmbientFieldId
),
527 editSField(AmbientFieldMask
);
532 GetFieldHandlePtr
LightModelChunkBase::getHandleColorControl (void) const
534 SFGLenum::GetHandlePtr
returnValue(
535 new SFGLenum::GetHandle(
537 this->getType().getFieldDesc(ColorControlFieldId
),
538 const_cast<LightModelChunkBase
*>(this)));
543 EditFieldHandlePtr
LightModelChunkBase::editHandleColorControl (void)
545 SFGLenum::EditHandlePtr
returnValue(
546 new SFGLenum::EditHandle(
548 this->getType().getFieldDesc(ColorControlFieldId
),
552 editSField(ColorControlFieldMask
);
557 GetFieldHandlePtr
LightModelChunkBase::getHandleLocalViewer (void) const
559 SFBool::GetHandlePtr
returnValue(
560 new SFBool::GetHandle(
562 this->getType().getFieldDesc(LocalViewerFieldId
),
563 const_cast<LightModelChunkBase
*>(this)));
568 EditFieldHandlePtr
LightModelChunkBase::editHandleLocalViewer (void)
570 SFBool::EditHandlePtr
returnValue(
571 new SFBool::EditHandle(
573 this->getType().getFieldDesc(LocalViewerFieldId
),
577 editSField(LocalViewerFieldMask
);
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
),
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));
615 void LightModelChunkBase::resolveLinks(void)
617 Inherited::resolveLinks();