changed: gcc8 base update
[opensg.git] / Source / System / Window / Base / OSGPerspectiveCameraBase.cpp
blob92b4c485d1c2b850d9d465596175af392326e1c0
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 PerspectiveCamera!
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"
66 #include "OSGPerspectiveCameraBase.h"
67 #include "OSGPerspectiveCamera.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::PerspectiveCamera
78 The Perspective Camera class, see \ref PageSystemWindowCameraPerspective for
79 a description.
81 The only new parameter is the _sfFov.
84 /***************************************************************************\
85 * Field Documentation *
86 \***************************************************************************/
88 /*! \var Real32 PerspectiveCameraBase::_sfFov
89 The vertical field of view, in radians.
92 /*! \var UInt32 PerspectiveCameraBase::_sfFovMode
93 Defines whether the field of view is measured vertically, horizontally or
94 in the smaller direction. See OSG::PerspectiveCamera::FovMode enum for
95 the actual values,
98 /*! \var Real32 PerspectiveCameraBase::_sfAspect
99 The aspect ratio (i.e. width / height) of a pixel.
103 /***************************************************************************\
104 * FieldType/FieldTrait Instantiation *
105 \***************************************************************************/
107 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
108 PointerType FieldTraits<PerspectiveCamera *, nsOSG>::_type(
109 "PerspectiveCameraPtr",
110 "CameraPtr",
111 PerspectiveCamera::getClassType(),
112 nsOSG);
113 #endif
115 OSG_FIELDTRAITS_GETTYPE_NS(PerspectiveCamera *, nsOSG)
117 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
118 PerspectiveCamera *,
119 nsOSG)
121 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
122 PerspectiveCamera *,
123 nsOSG)
125 /***************************************************************************\
126 * Field Description *
127 \***************************************************************************/
129 void PerspectiveCameraBase::classDescInserter(TypeObject &oType)
131 FieldDescriptionBase *pDesc = NULL;
134 pDesc = new SFReal32::Description(
135 SFReal32::getClassType(),
136 "fov",
137 "The vertical field of view, in radians.\n",
138 FovFieldId, FovFieldMask,
139 false,
140 (Field::SFDefaultFlags | Field::FStdAccess),
141 static_cast<FieldEditMethodSig>(&PerspectiveCamera::editHandleFov),
142 static_cast<FieldGetMethodSig >(&PerspectiveCamera::getHandleFov));
144 oType.addInitialDesc(pDesc);
146 pDesc = new SFUInt32::Description(
147 SFUInt32::getClassType(),
148 "fovMode",
149 "Defines whether the field of view is measured vertically, horizontally or\n"
150 "in the smaller direction. See OSG::PerspectiveCamera::FovMode enum for\n"
151 "the actual values, \n",
152 FovModeFieldId, FovModeFieldMask,
153 false,
154 (Field::SFDefaultFlags | Field::FStdAccess),
155 static_cast<FieldEditMethodSig>(&PerspectiveCamera::editHandleFovMode),
156 static_cast<FieldGetMethodSig >(&PerspectiveCamera::getHandleFovMode));
158 oType.addInitialDesc(pDesc);
160 pDesc = new SFReal32::Description(
161 SFReal32::getClassType(),
162 "aspect",
163 "The aspect ratio (i.e. width / height) of a pixel.\n",
164 AspectFieldId, AspectFieldMask,
165 false,
166 (Field::SFDefaultFlags | Field::FStdAccess),
167 static_cast<FieldEditMethodSig>(&PerspectiveCamera::editHandleAspect),
168 static_cast<FieldGetMethodSig >(&PerspectiveCamera::getHandleAspect));
170 oType.addInitialDesc(pDesc);
174 PerspectiveCameraBase::TypeObject PerspectiveCameraBase::_type(
175 PerspectiveCameraBase::getClassname(),
176 Inherited::getClassname(),
177 "NULL",
178 nsOSG, //Namespace
179 reinterpret_cast<PrototypeCreateF>(&PerspectiveCameraBase::createEmptyLocal),
180 reinterpret_cast<InitContainerF>(&PerspectiveCamera::initMethod),
181 reinterpret_cast<ExitContainerF>(&PerspectiveCamera::exitMethod),
182 reinterpret_cast<InitalInsertDescFunc>(
183 reinterpret_cast<void *>(&PerspectiveCamera::classDescInserter)),
184 false,
186 "<?xml version=\"1.0\" ?>\n"
187 "\n"
188 "<FieldContainer\n"
189 " name=\"PerspectiveCamera\"\n"
190 " parent=\"Camera\"\n"
191 " library=\"System\"\n"
192 " structure=\"concrete\"\n"
193 " pointerfieldtypes=\"both\"\n"
194 " systemcomponent=\"true\"\n"
195 " parentsystemcomponent=\"true\"\n"
196 " docGroupBase=\"GrpSystemWindow\"\n"
197 " >\n"
198 "\n"
199 "The Perspective Camera class, see \\ref PageSystemWindowCameraPerspective for \n"
200 "a description.\n"
201 "\n"
202 "The only new parameter is the _sfFov.\n"
203 " <Field\n"
204 " name=\"fov\"\n"
205 " type=\"Real32\"\n"
206 " cardinality=\"single\"\n"
207 " visibility=\"external\"\n"
208 " >\n"
209 " The vertical field of view, in radians.\n"
210 " </Field>\n"
211 " <Field\n"
212 " name=\"fovMode\"\n"
213 " type=\"UInt32\"\n"
214 " cardinality=\"single\"\n"
215 " visibility=\"external\"\n"
216 " defaultValue=\"0\"\n"
217 " access=\"public\"\n"
218 " >\n"
219 " Defines whether the field of view is measured vertically, horizontally or\n"
220 " in the smaller direction. See OSG::PerspectiveCamera::FovMode enum for\n"
221 " the actual values, \n"
222 " </Field>\n"
223 " <Field\n"
224 " name=\"aspect\"\n"
225 " type=\"Real32\"\n"
226 " cardinality=\"single\"\n"
227 " visibility=\"external\"\n"
228 " defaultValue=\"1\"\n"
229 " >\n"
230 " The aspect ratio (i.e. width / height) of a pixel.\n"
231 " </Field>\n"
232 "</FieldContainer>\n",
233 "The Perspective Camera class, see \\ref PageSystemWindowCameraPerspective for \n"
234 "a description.\n"
235 "\n"
236 "The only new parameter is the _sfFov.\n"
239 /*------------------------------ get -----------------------------------*/
241 FieldContainerType &PerspectiveCameraBase::getType(void)
243 return _type;
246 const FieldContainerType &PerspectiveCameraBase::getType(void) const
248 return _type;
251 UInt32 PerspectiveCameraBase::getContainerSize(void) const
253 return sizeof(PerspectiveCamera);
256 /*------------------------- decorator get ------------------------------*/
259 SFReal32 *PerspectiveCameraBase::editSFFov(void)
261 editSField(FovFieldMask);
263 return &_sfFov;
266 const SFReal32 *PerspectiveCameraBase::getSFFov(void) const
268 return &_sfFov;
272 SFUInt32 *PerspectiveCameraBase::editSFFovMode(void)
274 editSField(FovModeFieldMask);
276 return &_sfFovMode;
279 const SFUInt32 *PerspectiveCameraBase::getSFFovMode(void) const
281 return &_sfFovMode;
285 SFReal32 *PerspectiveCameraBase::editSFAspect(void)
287 editSField(AspectFieldMask);
289 return &_sfAspect;
292 const SFReal32 *PerspectiveCameraBase::getSFAspect(void) const
294 return &_sfAspect;
302 /*------------------------------ access -----------------------------------*/
304 SizeT PerspectiveCameraBase::getBinSize(ConstFieldMaskArg whichField)
306 SizeT returnValue = Inherited::getBinSize(whichField);
308 if(FieldBits::NoField != (FovFieldMask & whichField))
310 returnValue += _sfFov.getBinSize();
312 if(FieldBits::NoField != (FovModeFieldMask & whichField))
314 returnValue += _sfFovMode.getBinSize();
316 if(FieldBits::NoField != (AspectFieldMask & whichField))
318 returnValue += _sfAspect.getBinSize();
321 return returnValue;
324 void PerspectiveCameraBase::copyToBin(BinaryDataHandler &pMem,
325 ConstFieldMaskArg whichField)
327 Inherited::copyToBin(pMem, whichField);
329 if(FieldBits::NoField != (FovFieldMask & whichField))
331 _sfFov.copyToBin(pMem);
333 if(FieldBits::NoField != (FovModeFieldMask & whichField))
335 _sfFovMode.copyToBin(pMem);
337 if(FieldBits::NoField != (AspectFieldMask & whichField))
339 _sfAspect.copyToBin(pMem);
343 void PerspectiveCameraBase::copyFromBin(BinaryDataHandler &pMem,
344 ConstFieldMaskArg whichField)
346 Inherited::copyFromBin(pMem, whichField);
348 if(FieldBits::NoField != (FovFieldMask & whichField))
350 editSField(FovFieldMask);
351 _sfFov.copyFromBin(pMem);
353 if(FieldBits::NoField != (FovModeFieldMask & whichField))
355 editSField(FovModeFieldMask);
356 _sfFovMode.copyFromBin(pMem);
358 if(FieldBits::NoField != (AspectFieldMask & whichField))
360 editSField(AspectFieldMask);
361 _sfAspect.copyFromBin(pMem);
365 //! create a new instance of the class
366 PerspectiveCameraTransitPtr PerspectiveCameraBase::createLocal(BitVector bFlags)
368 PerspectiveCameraTransitPtr fc;
370 if(getClassType().getPrototype() != NULL)
372 FieldContainerTransitPtr tmpPtr =
373 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
375 fc = dynamic_pointer_cast<PerspectiveCamera>(tmpPtr);
378 return fc;
381 //! create a new instance of the class, copy the container flags
382 PerspectiveCameraTransitPtr PerspectiveCameraBase::createDependent(BitVector bFlags)
384 PerspectiveCameraTransitPtr fc;
386 if(getClassType().getPrototype() != NULL)
388 FieldContainerTransitPtr tmpPtr =
389 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
391 fc = dynamic_pointer_cast<PerspectiveCamera>(tmpPtr);
394 return fc;
397 //! create a new instance of the class
398 PerspectiveCameraTransitPtr PerspectiveCameraBase::create(void)
400 PerspectiveCameraTransitPtr fc;
402 if(getClassType().getPrototype() != NULL)
404 FieldContainerTransitPtr tmpPtr =
405 getClassType().getPrototype()-> shallowCopy();
407 fc = dynamic_pointer_cast<PerspectiveCamera>(tmpPtr);
410 return fc;
413 PerspectiveCamera *PerspectiveCameraBase::createEmptyLocal(BitVector bFlags)
415 PerspectiveCamera *returnValue;
417 newPtr<PerspectiveCamera>(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 PerspectiveCamera *PerspectiveCameraBase::createEmpty(void)
427 PerspectiveCamera *returnValue;
429 newPtr<PerspectiveCamera>(returnValue, Thread::getCurrentLocalFlags());
431 returnValue->_pFieldFlags->_bNamespaceMask &=
432 ~Thread::getCurrentLocalFlags();
434 return returnValue;
438 FieldContainerTransitPtr PerspectiveCameraBase::shallowCopyLocal(
439 BitVector bFlags) const
441 PerspectiveCamera *tmpPtr;
443 newPtr(tmpPtr, dynamic_cast<const PerspectiveCamera *>(this), bFlags);
445 FieldContainerTransitPtr returnValue(tmpPtr);
447 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
449 return returnValue;
452 FieldContainerTransitPtr PerspectiveCameraBase::shallowCopyDependent(
453 BitVector bFlags) const
455 PerspectiveCamera *tmpPtr;
457 newPtr(tmpPtr, dynamic_cast<const PerspectiveCamera *>(this), ~bFlags);
459 FieldContainerTransitPtr returnValue(tmpPtr);
461 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
463 return returnValue;
466 FieldContainerTransitPtr PerspectiveCameraBase::shallowCopy(void) const
468 PerspectiveCamera *tmpPtr;
470 newPtr(tmpPtr,
471 dynamic_cast<const PerspectiveCamera *>(this),
472 Thread::getCurrentLocalFlags());
474 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
476 FieldContainerTransitPtr returnValue(tmpPtr);
478 return returnValue;
484 /*------------------------- constructors ----------------------------------*/
486 PerspectiveCameraBase::PerspectiveCameraBase(void) :
487 Inherited(),
488 _sfFov (),
489 _sfFovMode (UInt32(0)),
490 _sfAspect (Real32(1))
494 PerspectiveCameraBase::PerspectiveCameraBase(const PerspectiveCameraBase &source) :
495 Inherited(source),
496 _sfFov (source._sfFov ),
497 _sfFovMode (source._sfFovMode ),
498 _sfAspect (source._sfAspect )
503 /*-------------------------- destructors ----------------------------------*/
505 PerspectiveCameraBase::~PerspectiveCameraBase(void)
510 GetFieldHandlePtr PerspectiveCameraBase::getHandleFov (void) const
512 SFReal32::GetHandlePtr returnValue(
513 new SFReal32::GetHandle(
514 &_sfFov,
515 this->getType().getFieldDesc(FovFieldId),
516 const_cast<PerspectiveCameraBase *>(this)));
518 return returnValue;
521 EditFieldHandlePtr PerspectiveCameraBase::editHandleFov (void)
523 SFReal32::EditHandlePtr returnValue(
524 new SFReal32::EditHandle(
525 &_sfFov,
526 this->getType().getFieldDesc(FovFieldId),
527 this));
530 editSField(FovFieldMask);
532 return returnValue;
535 GetFieldHandlePtr PerspectiveCameraBase::getHandleFovMode (void) const
537 SFUInt32::GetHandlePtr returnValue(
538 new SFUInt32::GetHandle(
539 &_sfFovMode,
540 this->getType().getFieldDesc(FovModeFieldId),
541 const_cast<PerspectiveCameraBase *>(this)));
543 return returnValue;
546 EditFieldHandlePtr PerspectiveCameraBase::editHandleFovMode (void)
548 SFUInt32::EditHandlePtr returnValue(
549 new SFUInt32::EditHandle(
550 &_sfFovMode,
551 this->getType().getFieldDesc(FovModeFieldId),
552 this));
555 editSField(FovModeFieldMask);
557 return returnValue;
560 GetFieldHandlePtr PerspectiveCameraBase::getHandleAspect (void) const
562 SFReal32::GetHandlePtr returnValue(
563 new SFReal32::GetHandle(
564 &_sfAspect,
565 this->getType().getFieldDesc(AspectFieldId),
566 const_cast<PerspectiveCameraBase *>(this)));
568 return returnValue;
571 EditFieldHandlePtr PerspectiveCameraBase::editHandleAspect (void)
573 SFReal32::EditHandlePtr returnValue(
574 new SFReal32::EditHandle(
575 &_sfAspect,
576 this->getType().getFieldDesc(AspectFieldId),
577 this));
580 editSField(AspectFieldMask);
582 return returnValue;
586 #ifdef OSG_MT_CPTR_ASPECT
587 void PerspectiveCameraBase::execSyncV( FieldContainer &oFrom,
588 ConstFieldMaskArg whichField,
589 AspectOffsetStore &oOffsets,
590 ConstFieldMaskArg syncMode,
591 const UInt32 uiSyncInfo)
593 PerspectiveCamera *pThis = static_cast<PerspectiveCamera *>(this);
595 pThis->execSync(static_cast<PerspectiveCamera *>(&oFrom),
596 whichField,
597 oOffsets,
598 syncMode,
599 uiSyncInfo);
601 #endif
604 #ifdef OSG_MT_CPTR_ASPECT
605 FieldContainer *PerspectiveCameraBase::createAspectCopy(
606 const FieldContainer *pRefAspect) const
608 PerspectiveCamera *returnValue;
610 newAspectCopy(returnValue,
611 dynamic_cast<const PerspectiveCamera *>(pRefAspect),
612 dynamic_cast<const PerspectiveCamera *>(this));
614 return returnValue;
616 #endif
618 void PerspectiveCameraBase::resolveLinks(void)
620 Inherited::resolveLinks();
626 OSG_END_NAMESPACE