changed: gcc8 base update
[opensg.git] / Source / Contrib / ComplexSceneManager / OSGCSMPerspectiveCameraBase.cpp
blobac7781d948831999d12b0802aba6f12e252ace47
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>(
177 reinterpret_cast<void *>(&CSMPerspectiveCamera::classDescInserter)),
178 false,
180 "<?xml version=\"1.0\"?>\n"
181 "\n"
182 "<FieldContainer\n"
183 " name=\"CSMPerspectiveCamera\"\n"
184 " parent=\"PerspectiveCamera\"\n"
185 " library=\"ContribCSM\"\n"
186 " pointerfieldtypes=\"both\"\n"
187 " structure=\"concrete\"\n"
188 " systemcomponent=\"true\"\n"
189 " parentsystemcomponent=\"true\"\n"
190 " decoratable=\"false\"\n"
191 " useLocalIncludes=\"false\"\n"
192 " isNodeCore=\"false\"\n"
193 " isBundle=\"false\"\n"
194 ">\n"
195 "\t<Field\n"
196 "\t\tname=\"eyeSeparation\"\n"
197 "\t\ttype=\"Real32\"\n"
198 "\t\tcardinality=\"single\"\n"
199 "\t\tvisibility=\"external\"\n"
200 "\t\taccess=\"public\"\n"
201 " defaultValue=\"0.5f\"\n"
202 "\t>\n"
203 "\t</Field>\n"
204 "\t<Field\n"
205 "\t\tname=\"zeroParallax\"\n"
206 "\t\ttype=\"Real32\"\n"
207 "\t\tcardinality=\"single\"\n"
208 "\t\tvisibility=\"external\"\n"
209 "\t\taccess=\"public\"\n"
210 " defaultValue=\"10.0f\"\n"
211 "\t>\n"
212 "\t</Field>\n"
213 " <Field\n"
214 " name=\"headBeacon\"\n"
215 " type=\"Node\"\n"
216 " category=\"weakpointer\"\n"
217 " cardinality=\"single\"\n"
218 " visibility=\"external\"\n"
219 " >\n"
220 "\t</Field>\n"
221 "</FieldContainer>\n",
225 /*------------------------------ get -----------------------------------*/
227 FieldContainerType &CSMPerspectiveCameraBase::getType(void)
229 return _type;
232 const FieldContainerType &CSMPerspectiveCameraBase::getType(void) const
234 return _type;
237 UInt32 CSMPerspectiveCameraBase::getContainerSize(void) const
239 return sizeof(CSMPerspectiveCamera);
242 /*------------------------- decorator get ------------------------------*/
245 SFReal32 *CSMPerspectiveCameraBase::editSFEyeSeparation(void)
247 editSField(EyeSeparationFieldMask);
249 return &_sfEyeSeparation;
252 const SFReal32 *CSMPerspectiveCameraBase::getSFEyeSeparation(void) const
254 return &_sfEyeSeparation;
258 SFReal32 *CSMPerspectiveCameraBase::editSFZeroParallax(void)
260 editSField(ZeroParallaxFieldMask);
262 return &_sfZeroParallax;
265 const SFReal32 *CSMPerspectiveCameraBase::getSFZeroParallax(void) const
267 return &_sfZeroParallax;
271 //! Get the CSMPerspectiveCamera::_sfHeadBeacon field.
272 const SFWeakNodePtr *CSMPerspectiveCameraBase::getSFHeadBeacon(void) const
274 return &_sfHeadBeacon;
277 SFWeakNodePtr *CSMPerspectiveCameraBase::editSFHeadBeacon (void)
279 editSField(HeadBeaconFieldMask);
281 return &_sfHeadBeacon;
284 //! Get the value of the CSMPerspectiveCamera::_sfHeadBeacon field.
285 Node * CSMPerspectiveCameraBase::getHeadBeacon(void) const
287 return _sfHeadBeacon.getValue();
290 //! Set the value of the CSMPerspectiveCamera::_sfHeadBeacon field.
291 void CSMPerspectiveCameraBase::setHeadBeacon(Node * const value)
293 editSField(HeadBeaconFieldMask);
295 _sfHeadBeacon.setValue(value);
303 /*------------------------------ access -----------------------------------*/
305 SizeT CSMPerspectiveCameraBase::getBinSize(ConstFieldMaskArg whichField)
307 SizeT returnValue = Inherited::getBinSize(whichField);
309 if(FieldBits::NoField != (EyeSeparationFieldMask & whichField))
311 returnValue += _sfEyeSeparation.getBinSize();
313 if(FieldBits::NoField != (ZeroParallaxFieldMask & whichField))
315 returnValue += _sfZeroParallax.getBinSize();
317 if(FieldBits::NoField != (HeadBeaconFieldMask & whichField))
319 returnValue += _sfHeadBeacon.getBinSize();
322 return returnValue;
325 void CSMPerspectiveCameraBase::copyToBin(BinaryDataHandler &pMem,
326 ConstFieldMaskArg whichField)
328 Inherited::copyToBin(pMem, whichField);
330 if(FieldBits::NoField != (EyeSeparationFieldMask & whichField))
332 _sfEyeSeparation.copyToBin(pMem);
334 if(FieldBits::NoField != (ZeroParallaxFieldMask & whichField))
336 _sfZeroParallax.copyToBin(pMem);
338 if(FieldBits::NoField != (HeadBeaconFieldMask & whichField))
340 _sfHeadBeacon.copyToBin(pMem);
344 void CSMPerspectiveCameraBase::copyFromBin(BinaryDataHandler &pMem,
345 ConstFieldMaskArg whichField)
347 Inherited::copyFromBin(pMem, whichField);
349 if(FieldBits::NoField != (EyeSeparationFieldMask & whichField))
351 editSField(EyeSeparationFieldMask);
352 _sfEyeSeparation.copyFromBin(pMem);
354 if(FieldBits::NoField != (ZeroParallaxFieldMask & whichField))
356 editSField(ZeroParallaxFieldMask);
357 _sfZeroParallax.copyFromBin(pMem);
359 if(FieldBits::NoField != (HeadBeaconFieldMask & whichField))
361 editSField(HeadBeaconFieldMask);
362 _sfHeadBeacon.copyFromBin(pMem);
366 //! create a new instance of the class
367 CSMPerspectiveCameraTransitPtr CSMPerspectiveCameraBase::createLocal(BitVector bFlags)
369 CSMPerspectiveCameraTransitPtr fc;
371 if(getClassType().getPrototype() != NULL)
373 FieldContainerTransitPtr tmpPtr =
374 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
376 fc = dynamic_pointer_cast<CSMPerspectiveCamera>(tmpPtr);
379 return fc;
382 //! create a new instance of the class, copy the container flags
383 CSMPerspectiveCameraTransitPtr CSMPerspectiveCameraBase::createDependent(BitVector bFlags)
385 CSMPerspectiveCameraTransitPtr fc;
387 if(getClassType().getPrototype() != NULL)
389 FieldContainerTransitPtr tmpPtr =
390 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
392 fc = dynamic_pointer_cast<CSMPerspectiveCamera>(tmpPtr);
395 return fc;
398 //! create a new instance of the class
399 CSMPerspectiveCameraTransitPtr CSMPerspectiveCameraBase::create(void)
401 CSMPerspectiveCameraTransitPtr fc;
403 if(getClassType().getPrototype() != NULL)
405 FieldContainerTransitPtr tmpPtr =
406 getClassType().getPrototype()-> shallowCopy();
408 fc = dynamic_pointer_cast<CSMPerspectiveCamera>(tmpPtr);
411 return fc;
414 CSMPerspectiveCamera *CSMPerspectiveCameraBase::createEmptyLocal(BitVector bFlags)
416 CSMPerspectiveCamera *returnValue;
418 newPtr<CSMPerspectiveCamera>(returnValue, bFlags);
420 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
422 return returnValue;
425 //! create an empty new instance of the class, do not copy the prototype
426 CSMPerspectiveCamera *CSMPerspectiveCameraBase::createEmpty(void)
428 CSMPerspectiveCamera *returnValue;
430 newPtr<CSMPerspectiveCamera>(returnValue, Thread::getCurrentLocalFlags());
432 returnValue->_pFieldFlags->_bNamespaceMask &=
433 ~Thread::getCurrentLocalFlags();
435 return returnValue;
439 FieldContainerTransitPtr CSMPerspectiveCameraBase::shallowCopyLocal(
440 BitVector bFlags) const
442 CSMPerspectiveCamera *tmpPtr;
444 newPtr(tmpPtr, dynamic_cast<const CSMPerspectiveCamera *>(this), bFlags);
446 FieldContainerTransitPtr returnValue(tmpPtr);
448 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
450 return returnValue;
453 FieldContainerTransitPtr CSMPerspectiveCameraBase::shallowCopyDependent(
454 BitVector bFlags) const
456 CSMPerspectiveCamera *tmpPtr;
458 newPtr(tmpPtr, dynamic_cast<const CSMPerspectiveCamera *>(this), ~bFlags);
460 FieldContainerTransitPtr returnValue(tmpPtr);
462 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
464 return returnValue;
467 FieldContainerTransitPtr CSMPerspectiveCameraBase::shallowCopy(void) const
469 CSMPerspectiveCamera *tmpPtr;
471 newPtr(tmpPtr,
472 dynamic_cast<const CSMPerspectiveCamera *>(this),
473 Thread::getCurrentLocalFlags());
475 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
477 FieldContainerTransitPtr returnValue(tmpPtr);
479 return returnValue;
485 /*------------------------- constructors ----------------------------------*/
487 CSMPerspectiveCameraBase::CSMPerspectiveCameraBase(void) :
488 Inherited(),
489 _sfEyeSeparation (Real32(0.5f)),
490 _sfZeroParallax (Real32(10.0f)),
491 _sfHeadBeacon (NULL)
495 CSMPerspectiveCameraBase::CSMPerspectiveCameraBase(const CSMPerspectiveCameraBase &source) :
496 Inherited(source),
497 _sfEyeSeparation (source._sfEyeSeparation ),
498 _sfZeroParallax (source._sfZeroParallax ),
499 _sfHeadBeacon (NULL)
504 /*-------------------------- destructors ----------------------------------*/
506 CSMPerspectiveCameraBase::~CSMPerspectiveCameraBase(void)
510 void CSMPerspectiveCameraBase::onCreate(const CSMPerspectiveCamera *source)
512 Inherited::onCreate(source);
514 if(source != NULL)
516 CSMPerspectiveCamera *pThis = static_cast<CSMPerspectiveCamera *>(this);
518 pThis->setHeadBeacon(source->getHeadBeacon());
522 GetFieldHandlePtr CSMPerspectiveCameraBase::getHandleEyeSeparation (void) const
524 SFReal32::GetHandlePtr returnValue(
525 new SFReal32::GetHandle(
526 &_sfEyeSeparation,
527 this->getType().getFieldDesc(EyeSeparationFieldId),
528 const_cast<CSMPerspectiveCameraBase *>(this)));
530 return returnValue;
533 EditFieldHandlePtr CSMPerspectiveCameraBase::editHandleEyeSeparation (void)
535 SFReal32::EditHandlePtr returnValue(
536 new SFReal32::EditHandle(
537 &_sfEyeSeparation,
538 this->getType().getFieldDesc(EyeSeparationFieldId),
539 this));
542 editSField(EyeSeparationFieldMask);
544 return returnValue;
547 GetFieldHandlePtr CSMPerspectiveCameraBase::getHandleZeroParallax (void) const
549 SFReal32::GetHandlePtr returnValue(
550 new SFReal32::GetHandle(
551 &_sfZeroParallax,
552 this->getType().getFieldDesc(ZeroParallaxFieldId),
553 const_cast<CSMPerspectiveCameraBase *>(this)));
555 return returnValue;
558 EditFieldHandlePtr CSMPerspectiveCameraBase::editHandleZeroParallax (void)
560 SFReal32::EditHandlePtr returnValue(
561 new SFReal32::EditHandle(
562 &_sfZeroParallax,
563 this->getType().getFieldDesc(ZeroParallaxFieldId),
564 this));
567 editSField(ZeroParallaxFieldMask);
569 return returnValue;
572 GetFieldHandlePtr CSMPerspectiveCameraBase::getHandleHeadBeacon (void) const
574 SFWeakNodePtr::GetHandlePtr returnValue(
575 new SFWeakNodePtr::GetHandle(
576 &_sfHeadBeacon,
577 this->getType().getFieldDesc(HeadBeaconFieldId),
578 const_cast<CSMPerspectiveCameraBase *>(this)));
580 return returnValue;
583 EditFieldHandlePtr CSMPerspectiveCameraBase::editHandleHeadBeacon (void)
585 SFWeakNodePtr::EditHandlePtr returnValue(
586 new SFWeakNodePtr::EditHandle(
587 &_sfHeadBeacon,
588 this->getType().getFieldDesc(HeadBeaconFieldId),
589 this));
591 returnValue->setSetMethod(
592 boost::bind(&CSMPerspectiveCamera::setHeadBeacon,
593 static_cast<CSMPerspectiveCamera *>(this), _1));
595 editSField(HeadBeaconFieldMask);
597 return returnValue;
601 #ifdef OSG_MT_CPTR_ASPECT
602 void CSMPerspectiveCameraBase::execSyncV( FieldContainer &oFrom,
603 ConstFieldMaskArg whichField,
604 AspectOffsetStore &oOffsets,
605 ConstFieldMaskArg syncMode,
606 const UInt32 uiSyncInfo)
608 CSMPerspectiveCamera *pThis = static_cast<CSMPerspectiveCamera *>(this);
610 pThis->execSync(static_cast<CSMPerspectiveCamera *>(&oFrom),
611 whichField,
612 oOffsets,
613 syncMode,
614 uiSyncInfo);
616 #endif
619 #ifdef OSG_MT_CPTR_ASPECT
620 FieldContainer *CSMPerspectiveCameraBase::createAspectCopy(
621 const FieldContainer *pRefAspect) const
623 CSMPerspectiveCamera *returnValue;
625 newAspectCopy(returnValue,
626 dynamic_cast<const CSMPerspectiveCamera *>(pRefAspect),
627 dynamic_cast<const CSMPerspectiveCamera *>(this));
629 return returnValue;
631 #endif
633 void CSMPerspectiveCameraBase::resolveLinks(void)
635 Inherited::resolveLinks();
637 static_cast<CSMPerspectiveCamera *>(this)->setHeadBeacon(NULL);
643 OSG_END_NAMESPACE