fixed: gcc8 compile issues
[opensg.git] / Source / Contrib / ComplexSceneManager / OSGCSMPerspectiveCameraBase.cpp
blobbf6cf4873b26d6fafd9e423e0d6ab5d6fc5955cb
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 CSMPerspectiveCamera!
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 "OSGNode.h" // HeadBeacon Class
67 #include "OSGCSMPerspectiveCameraBase.h"
68 #include "OSGCSMPerspectiveCamera.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::CSMPerspectiveCamera
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var Real32 CSMPerspectiveCameraBase::_sfEyeSeparation
90 /*! \var Real32 CSMPerspectiveCameraBase::_sfZeroParallax
94 /*! \var Node * CSMPerspectiveCameraBase::_sfHeadBeacon
99 /***************************************************************************\
100 * FieldType/FieldTrait Instantiation *
101 \***************************************************************************/
103 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
104 PointerType FieldTraits<CSMPerspectiveCamera *, nsOSG>::_type(
105 "CSMPerspectiveCameraPtr",
106 "PerspectiveCameraPtr",
107 CSMPerspectiveCamera::getClassType(),
108 nsOSG);
109 #endif
111 OSG_FIELDTRAITS_GETTYPE_NS(CSMPerspectiveCamera *, nsOSG)
113 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
114 CSMPerspectiveCamera *,
115 nsOSG)
117 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
118 CSMPerspectiveCamera *,
119 nsOSG)
121 /***************************************************************************\
122 * Field Description *
123 \***************************************************************************/
125 void CSMPerspectiveCameraBase::classDescInserter(TypeObject &oType)
127 FieldDescriptionBase *pDesc = NULL;
130 pDesc = new SFReal32::Description(
131 SFReal32::getClassType(),
132 "eyeSeparation",
134 EyeSeparationFieldId, EyeSeparationFieldMask,
135 false,
136 (Field::SFDefaultFlags | Field::FStdAccess),
137 static_cast<FieldEditMethodSig>(&CSMPerspectiveCamera::editHandleEyeSeparation),
138 static_cast<FieldGetMethodSig >(&CSMPerspectiveCamera::getHandleEyeSeparation));
140 oType.addInitialDesc(pDesc);
142 pDesc = new SFReal32::Description(
143 SFReal32::getClassType(),
144 "zeroParallax",
146 ZeroParallaxFieldId, ZeroParallaxFieldMask,
147 false,
148 (Field::SFDefaultFlags | Field::FStdAccess),
149 static_cast<FieldEditMethodSig>(&CSMPerspectiveCamera::editHandleZeroParallax),
150 static_cast<FieldGetMethodSig >(&CSMPerspectiveCamera::getHandleZeroParallax));
152 oType.addInitialDesc(pDesc);
154 pDesc = new SFWeakNodePtr::Description(
155 SFWeakNodePtr::getClassType(),
156 "headBeacon",
158 HeadBeaconFieldId, HeadBeaconFieldMask,
159 false,
160 (Field::SFDefaultFlags | Field::FStdAccess),
161 static_cast<FieldEditMethodSig>(&CSMPerspectiveCamera::editHandleHeadBeacon),
162 static_cast<FieldGetMethodSig >(&CSMPerspectiveCamera::getHandleHeadBeacon));
164 oType.addInitialDesc(pDesc);
168 CSMPerspectiveCameraBase::TypeObject CSMPerspectiveCameraBase::_type(
169 CSMPerspectiveCameraBase::getClassname(),
170 Inherited::getClassname(),
171 "NULL",
172 nsOSG, //Namespace
173 reinterpret_cast<PrototypeCreateF>(&CSMPerspectiveCameraBase::createEmptyLocal),
174 reinterpret_cast<InitContainerF>(&CSMPerspectiveCamera::initMethod),
175 reinterpret_cast<ExitContainerF>(&CSMPerspectiveCamera::exitMethod),
176 reinterpret_cast<InitalInsertDescFunc>(&CSMPerspectiveCamera::classDescInserter),
177 false,
179 "<?xml version=\"1.0\"?>\n"
180 "\n"
181 "<FieldContainer\n"
182 " name=\"CSMPerspectiveCamera\"\n"
183 " parent=\"PerspectiveCamera\"\n"
184 " library=\"ContribCSM\"\n"
185 " pointerfieldtypes=\"both\"\n"
186 " structure=\"concrete\"\n"
187 " systemcomponent=\"true\"\n"
188 " parentsystemcomponent=\"true\"\n"
189 " decoratable=\"false\"\n"
190 " useLocalIncludes=\"false\"\n"
191 " isNodeCore=\"false\"\n"
192 " isBundle=\"false\"\n"
193 ">\n"
194 "\t<Field\n"
195 "\t\tname=\"eyeSeparation\"\n"
196 "\t\ttype=\"Real32\"\n"
197 "\t\tcardinality=\"single\"\n"
198 "\t\tvisibility=\"external\"\n"
199 "\t\taccess=\"public\"\n"
200 " defaultValue=\"0.5f\"\n"
201 "\t>\n"
202 "\t</Field>\n"
203 "\t<Field\n"
204 "\t\tname=\"zeroParallax\"\n"
205 "\t\ttype=\"Real32\"\n"
206 "\t\tcardinality=\"single\"\n"
207 "\t\tvisibility=\"external\"\n"
208 "\t\taccess=\"public\"\n"
209 " defaultValue=\"10.0f\"\n"
210 "\t>\n"
211 "\t</Field>\n"
212 " <Field\n"
213 " name=\"headBeacon\"\n"
214 " type=\"Node\"\n"
215 " category=\"weakpointer\"\n"
216 " cardinality=\"single\"\n"
217 " visibility=\"external\"\n"
218 " >\n"
219 "\t</Field>\n"
220 "</FieldContainer>\n",
224 /*------------------------------ get -----------------------------------*/
226 FieldContainerType &CSMPerspectiveCameraBase::getType(void)
228 return _type;
231 const FieldContainerType &CSMPerspectiveCameraBase::getType(void) const
233 return _type;
236 UInt32 CSMPerspectiveCameraBase::getContainerSize(void) const
238 return sizeof(CSMPerspectiveCamera);
241 /*------------------------- decorator get ------------------------------*/
244 SFReal32 *CSMPerspectiveCameraBase::editSFEyeSeparation(void)
246 editSField(EyeSeparationFieldMask);
248 return &_sfEyeSeparation;
251 const SFReal32 *CSMPerspectiveCameraBase::getSFEyeSeparation(void) const
253 return &_sfEyeSeparation;
257 SFReal32 *CSMPerspectiveCameraBase::editSFZeroParallax(void)
259 editSField(ZeroParallaxFieldMask);
261 return &_sfZeroParallax;
264 const SFReal32 *CSMPerspectiveCameraBase::getSFZeroParallax(void) const
266 return &_sfZeroParallax;
270 //! Get the CSMPerspectiveCamera::_sfHeadBeacon field.
271 const SFWeakNodePtr *CSMPerspectiveCameraBase::getSFHeadBeacon(void) const
273 return &_sfHeadBeacon;
276 SFWeakNodePtr *CSMPerspectiveCameraBase::editSFHeadBeacon (void)
278 editSField(HeadBeaconFieldMask);
280 return &_sfHeadBeacon;
283 //! Get the value of the CSMPerspectiveCamera::_sfHeadBeacon field.
284 Node * CSMPerspectiveCameraBase::getHeadBeacon(void) const
286 return _sfHeadBeacon.getValue();
289 //! Set the value of the CSMPerspectiveCamera::_sfHeadBeacon field.
290 void CSMPerspectiveCameraBase::setHeadBeacon(Node * const value)
292 editSField(HeadBeaconFieldMask);
294 _sfHeadBeacon.setValue(value);
302 /*------------------------------ access -----------------------------------*/
304 SizeT CSMPerspectiveCameraBase::getBinSize(ConstFieldMaskArg whichField)
306 SizeT returnValue = Inherited::getBinSize(whichField);
308 if(FieldBits::NoField != (EyeSeparationFieldMask & whichField))
310 returnValue += _sfEyeSeparation.getBinSize();
312 if(FieldBits::NoField != (ZeroParallaxFieldMask & whichField))
314 returnValue += _sfZeroParallax.getBinSize();
316 if(FieldBits::NoField != (HeadBeaconFieldMask & whichField))
318 returnValue += _sfHeadBeacon.getBinSize();
321 return returnValue;
324 void CSMPerspectiveCameraBase::copyToBin(BinaryDataHandler &pMem,
325 ConstFieldMaskArg whichField)
327 Inherited::copyToBin(pMem, whichField);
329 if(FieldBits::NoField != (EyeSeparationFieldMask & whichField))
331 _sfEyeSeparation.copyToBin(pMem);
333 if(FieldBits::NoField != (ZeroParallaxFieldMask & whichField))
335 _sfZeroParallax.copyToBin(pMem);
337 if(FieldBits::NoField != (HeadBeaconFieldMask & whichField))
339 _sfHeadBeacon.copyToBin(pMem);
343 void CSMPerspectiveCameraBase::copyFromBin(BinaryDataHandler &pMem,
344 ConstFieldMaskArg whichField)
346 Inherited::copyFromBin(pMem, whichField);
348 if(FieldBits::NoField != (EyeSeparationFieldMask & whichField))
350 editSField(EyeSeparationFieldMask);
351 _sfEyeSeparation.copyFromBin(pMem);
353 if(FieldBits::NoField != (ZeroParallaxFieldMask & whichField))
355 editSField(ZeroParallaxFieldMask);
356 _sfZeroParallax.copyFromBin(pMem);
358 if(FieldBits::NoField != (HeadBeaconFieldMask & whichField))
360 editSField(HeadBeaconFieldMask);
361 _sfHeadBeacon.copyFromBin(pMem);
365 //! create a new instance of the class
366 CSMPerspectiveCameraTransitPtr CSMPerspectiveCameraBase::createLocal(BitVector bFlags)
368 CSMPerspectiveCameraTransitPtr fc;
370 if(getClassType().getPrototype() != NULL)
372 FieldContainerTransitPtr tmpPtr =
373 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
375 fc = dynamic_pointer_cast<CSMPerspectiveCamera>(tmpPtr);
378 return fc;
381 //! create a new instance of the class, copy the container flags
382 CSMPerspectiveCameraTransitPtr CSMPerspectiveCameraBase::createDependent(BitVector bFlags)
384 CSMPerspectiveCameraTransitPtr fc;
386 if(getClassType().getPrototype() != NULL)
388 FieldContainerTransitPtr tmpPtr =
389 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
391 fc = dynamic_pointer_cast<CSMPerspectiveCamera>(tmpPtr);
394 return fc;
397 //! create a new instance of the class
398 CSMPerspectiveCameraTransitPtr CSMPerspectiveCameraBase::create(void)
400 CSMPerspectiveCameraTransitPtr fc;
402 if(getClassType().getPrototype() != NULL)
404 FieldContainerTransitPtr tmpPtr =
405 getClassType().getPrototype()-> shallowCopy();
407 fc = dynamic_pointer_cast<CSMPerspectiveCamera>(tmpPtr);
410 return fc;
413 CSMPerspectiveCamera *CSMPerspectiveCameraBase::createEmptyLocal(BitVector bFlags)
415 CSMPerspectiveCamera *returnValue;
417 newPtr<CSMPerspectiveCamera>(returnValue, bFlags);
419 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
421 return returnValue;
424 //! create an empty new instance of the class, do not copy the prototype
425 CSMPerspectiveCamera *CSMPerspectiveCameraBase::createEmpty(void)
427 CSMPerspectiveCamera *returnValue;
429 newPtr<CSMPerspectiveCamera>(returnValue, Thread::getCurrentLocalFlags());
431 returnValue->_pFieldFlags->_bNamespaceMask &=
432 ~Thread::getCurrentLocalFlags();
434 return returnValue;
438 FieldContainerTransitPtr CSMPerspectiveCameraBase::shallowCopyLocal(
439 BitVector bFlags) const
441 CSMPerspectiveCamera *tmpPtr;
443 newPtr(tmpPtr, dynamic_cast<const CSMPerspectiveCamera *>(this), bFlags);
445 FieldContainerTransitPtr returnValue(tmpPtr);
447 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
449 return returnValue;
452 FieldContainerTransitPtr CSMPerspectiveCameraBase::shallowCopyDependent(
453 BitVector bFlags) const
455 CSMPerspectiveCamera *tmpPtr;
457 newPtr(tmpPtr, dynamic_cast<const CSMPerspectiveCamera *>(this), ~bFlags);
459 FieldContainerTransitPtr returnValue(tmpPtr);
461 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
463 return returnValue;
466 FieldContainerTransitPtr CSMPerspectiveCameraBase::shallowCopy(void) const
468 CSMPerspectiveCamera *tmpPtr;
470 newPtr(tmpPtr,
471 dynamic_cast<const CSMPerspectiveCamera *>(this),
472 Thread::getCurrentLocalFlags());
474 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
476 FieldContainerTransitPtr returnValue(tmpPtr);
478 return returnValue;
484 /*------------------------- constructors ----------------------------------*/
486 CSMPerspectiveCameraBase::CSMPerspectiveCameraBase(void) :
487 Inherited(),
488 _sfEyeSeparation (Real32(0.5f)),
489 _sfZeroParallax (Real32(10.0f)),
490 _sfHeadBeacon (NULL)
494 CSMPerspectiveCameraBase::CSMPerspectiveCameraBase(const CSMPerspectiveCameraBase &source) :
495 Inherited(source),
496 _sfEyeSeparation (source._sfEyeSeparation ),
497 _sfZeroParallax (source._sfZeroParallax ),
498 _sfHeadBeacon (NULL)
503 /*-------------------------- destructors ----------------------------------*/
505 CSMPerspectiveCameraBase::~CSMPerspectiveCameraBase(void)
509 void CSMPerspectiveCameraBase::onCreate(const CSMPerspectiveCamera *source)
511 Inherited::onCreate(source);
513 if(source != NULL)
515 CSMPerspectiveCamera *pThis = static_cast<CSMPerspectiveCamera *>(this);
517 pThis->setHeadBeacon(source->getHeadBeacon());
521 GetFieldHandlePtr CSMPerspectiveCameraBase::getHandleEyeSeparation (void) const
523 SFReal32::GetHandlePtr returnValue(
524 new SFReal32::GetHandle(
525 &_sfEyeSeparation,
526 this->getType().getFieldDesc(EyeSeparationFieldId),
527 const_cast<CSMPerspectiveCameraBase *>(this)));
529 return returnValue;
532 EditFieldHandlePtr CSMPerspectiveCameraBase::editHandleEyeSeparation (void)
534 SFReal32::EditHandlePtr returnValue(
535 new SFReal32::EditHandle(
536 &_sfEyeSeparation,
537 this->getType().getFieldDesc(EyeSeparationFieldId),
538 this));
541 editSField(EyeSeparationFieldMask);
543 return returnValue;
546 GetFieldHandlePtr CSMPerspectiveCameraBase::getHandleZeroParallax (void) const
548 SFReal32::GetHandlePtr returnValue(
549 new SFReal32::GetHandle(
550 &_sfZeroParallax,
551 this->getType().getFieldDesc(ZeroParallaxFieldId),
552 const_cast<CSMPerspectiveCameraBase *>(this)));
554 return returnValue;
557 EditFieldHandlePtr CSMPerspectiveCameraBase::editHandleZeroParallax (void)
559 SFReal32::EditHandlePtr returnValue(
560 new SFReal32::EditHandle(
561 &_sfZeroParallax,
562 this->getType().getFieldDesc(ZeroParallaxFieldId),
563 this));
566 editSField(ZeroParallaxFieldMask);
568 return returnValue;
571 GetFieldHandlePtr CSMPerspectiveCameraBase::getHandleHeadBeacon (void) const
573 SFWeakNodePtr::GetHandlePtr returnValue(
574 new SFWeakNodePtr::GetHandle(
575 &_sfHeadBeacon,
576 this->getType().getFieldDesc(HeadBeaconFieldId),
577 const_cast<CSMPerspectiveCameraBase *>(this)));
579 return returnValue;
582 EditFieldHandlePtr CSMPerspectiveCameraBase::editHandleHeadBeacon (void)
584 SFWeakNodePtr::EditHandlePtr returnValue(
585 new SFWeakNodePtr::EditHandle(
586 &_sfHeadBeacon,
587 this->getType().getFieldDesc(HeadBeaconFieldId),
588 this));
590 returnValue->setSetMethod(
591 boost::bind(&CSMPerspectiveCamera::setHeadBeacon,
592 static_cast<CSMPerspectiveCamera *>(this), _1));
594 editSField(HeadBeaconFieldMask);
596 return returnValue;
600 #ifdef OSG_MT_CPTR_ASPECT
601 void CSMPerspectiveCameraBase::execSyncV( FieldContainer &oFrom,
602 ConstFieldMaskArg whichField,
603 AspectOffsetStore &oOffsets,
604 ConstFieldMaskArg syncMode,
605 const UInt32 uiSyncInfo)
607 CSMPerspectiveCamera *pThis = static_cast<CSMPerspectiveCamera *>(this);
609 pThis->execSync(static_cast<CSMPerspectiveCamera *>(&oFrom),
610 whichField,
611 oOffsets,
612 syncMode,
613 uiSyncInfo);
615 #endif
618 #ifdef OSG_MT_CPTR_ASPECT
619 FieldContainer *CSMPerspectiveCameraBase::createAspectCopy(
620 const FieldContainer *pRefAspect) const
622 CSMPerspectiveCamera *returnValue;
624 newAspectCopy(returnValue,
625 dynamic_cast<const CSMPerspectiveCamera *>(pRefAspect),
626 dynamic_cast<const CSMPerspectiveCamera *>(this));
628 return returnValue;
630 #endif
632 void CSMPerspectiveCameraBase::resolveLinks(void)
634 Inherited::resolveLinks();
636 static_cast<CSMPerspectiveCamera *>(this)->setHeadBeacon(NULL);
642 OSG_END_NAMESPACE