changed: gcc8 base update
[opensg.git] / Source / System / Window / Base / OSGCameraBase.cpp
blob6c59dc6c9a2e54278ed9b19d54ba1f20a54f538f
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 Camera!
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" // Beacon Class
67 #include "OSGCameraBase.h"
68 #include "OSGCamera.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::Camera
79 The Camera base class, see \ref PageSystemWindowCamera for a description.
81 The only common fields are _sfNear and _sfFar.
84 /***************************************************************************\
85 * Field Documentation *
86 \***************************************************************************/
88 /*! \var Node * CameraBase::_sfBeacon
89 The object that define's the camera's coordinate system. The camera is
90 positioned at the origin of the system and looks down the negative z-axis
91 (OpenGL-style).
94 /*! \var Real32 CameraBase::_sfNear
95 The near distance of the camera.
98 /*! \var Real32 CameraBase::_sfFar
99 The far distance of the camera.
103 /***************************************************************************\
104 * FieldType/FieldTrait Instantiation *
105 \***************************************************************************/
107 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
108 PointerType FieldTraits<Camera *, nsOSG>::_type(
109 "CameraPtr",
110 "AttachmentContainerPtr",
111 Camera::getClassType(),
112 nsOSG);
113 #endif
115 OSG_FIELDTRAITS_GETTYPE_NS(Camera *, nsOSG)
117 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
118 Camera *,
119 nsOSG)
121 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
122 Camera *,
123 nsOSG)
125 /***************************************************************************\
126 * Field Description *
127 \***************************************************************************/
129 void CameraBase::classDescInserter(TypeObject &oType)
131 FieldDescriptionBase *pDesc = NULL;
134 pDesc = new SFWeakNodePtr::Description(
135 SFWeakNodePtr::getClassType(),
136 "beacon",
137 "The object that define's the camera's coordinate system. The camera is\n"
138 "positioned at the origin of the system and looks down the negative z-axis\n"
139 "(OpenGL-style). \n",
140 BeaconFieldId, BeaconFieldMask,
141 false,
142 (Field::SFDefaultFlags | Field::FStdAccess),
143 static_cast<FieldEditMethodSig>(&Camera::editHandleBeacon),
144 static_cast<FieldGetMethodSig >(&Camera::getHandleBeacon));
146 oType.addInitialDesc(pDesc);
148 pDesc = new SFReal32::Description(
149 SFReal32::getClassType(),
150 "near",
151 "The near distance of the camera.\n",
152 NearFieldId, NearFieldMask,
153 false,
154 (Field::SFDefaultFlags | Field::FStdAccess),
155 static_cast<FieldEditMethodSig>(&Camera::editHandleNear),
156 static_cast<FieldGetMethodSig >(&Camera::getHandleNear));
158 oType.addInitialDesc(pDesc);
160 pDesc = new SFReal32::Description(
161 SFReal32::getClassType(),
162 "far",
163 "The far distance of the camera.\n",
164 FarFieldId, FarFieldMask,
165 false,
166 (Field::SFDefaultFlags | Field::FStdAccess),
167 static_cast<FieldEditMethodSig>(&Camera::editHandleFar),
168 static_cast<FieldGetMethodSig >(&Camera::getHandleFar));
170 oType.addInitialDesc(pDesc);
174 CameraBase::TypeObject CameraBase::_type(
175 CameraBase::getClassname(),
176 Inherited::getClassname(),
177 "NULL",
178 nsOSG, //Namespace
179 NULL,
180 reinterpret_cast<InitContainerF>(&Camera::initMethod),
181 reinterpret_cast<ExitContainerF>(&Camera::exitMethod),
182 reinterpret_cast<InitalInsertDescFunc>(
183 reinterpret_cast<void *>(&Camera::classDescInserter)),
184 false,
186 "<?xml version=\"1.0\" ?>\n"
187 "\n"
188 "<FieldContainer\n"
189 " name=\"Camera\"\n"
190 " parent=\"AttachmentContainer\"\n"
191 " library=\"System\"\n"
192 " structure=\"abstract\"\n"
193 " pointerfieldtypes=\"both\"\n"
194 " systemcomponent=\"true\"\n"
195 " parentsystemcomponent=\"true\"\n"
196 " decoratable=\"true\"\n"
197 " decorateeFieldFlags=\"SFDefaultFlags | Field::FStdAccess\"\n"
198 " docGroupBase=\"GrpSystemWindow\"\n"
199 " >\n"
200 "\n"
201 " The Camera base class, see \\ref PageSystemWindowCamera for a description.\n"
202 "\n"
203 " The only common fields are _sfNear and _sfFar.\n"
204 "\n"
205 " <Field\n"
206 "\t name=\"beacon\"\n"
207 "\t type=\"Node\"\n"
208 " category=\"weakpointer\"\n"
209 "\t cardinality=\"single\"\n"
210 "\t visibility=\"external\"\n"
211 "\t >\n"
212 "\tThe object that define's the camera's coordinate system. The camera is\n"
213 "\t positioned at the origin of the system and looks down the negative z-axis\n"
214 "\t (OpenGL-style). \n"
215 " </Field>\n"
216 " <Field\n"
217 "\t name=\"near\"\n"
218 "\t type=\"Real32\"\n"
219 "\t cardinality=\"single\"\n"
220 "\t visibility=\"external\"\n"
221 "\t >\n"
222 "\tThe near distance of the camera.\n"
223 " </Field>\n"
224 " <Field\n"
225 "\t name=\"far\"\n"
226 "\t type=\"Real32\"\n"
227 "\t cardinality=\"single\"\n"
228 "\t visibility=\"external\"\n"
229 "\t >\n"
230 "\tThe far distance of the camera.\n"
231 " </Field>\n"
232 "</FieldContainer>\n",
233 "The Camera base class, see \\ref PageSystemWindowCamera for a description.\n"
234 "\n"
235 "The only common fields are _sfNear and _sfFar.\n"
238 /*------------------------------ get -----------------------------------*/
240 FieldContainerType &CameraBase::getType(void)
242 return _type;
245 const FieldContainerType &CameraBase::getType(void) const
247 return _type;
250 UInt32 CameraBase::getContainerSize(void) const
252 return sizeof(Camera);
255 /*------------------------- decorator get ------------------------------*/
258 //! Get the Camera::_sfBeacon field.
259 const SFWeakNodePtr *CameraBase::getSFBeacon(void) const
261 return &_sfBeacon;
264 SFWeakNodePtr *CameraBase::editSFBeacon (void)
266 editSField(BeaconFieldMask);
268 return &_sfBeacon;
273 SFReal32 *CameraBase::editSFNear(void)
275 editSField(NearFieldMask);
277 return &_sfNear;
280 const SFReal32 *CameraBase::getSFNear(void) const
282 return &_sfNear;
286 SFReal32 *CameraBase::editSFFar(void)
288 editSField(FarFieldMask);
290 return &_sfFar;
293 const SFReal32 *CameraBase::getSFFar(void) const
295 return &_sfFar;
303 /*------------------------------ access -----------------------------------*/
305 SizeT CameraBase::getBinSize(ConstFieldMaskArg whichField)
307 SizeT returnValue = Inherited::getBinSize(whichField);
309 if(FieldBits::NoField != (BeaconFieldMask & whichField))
311 returnValue += _sfBeacon.getBinSize();
313 if(FieldBits::NoField != (NearFieldMask & whichField))
315 returnValue += _sfNear.getBinSize();
317 if(FieldBits::NoField != (FarFieldMask & whichField))
319 returnValue += _sfFar.getBinSize();
322 return returnValue;
325 void CameraBase::copyToBin(BinaryDataHandler &pMem,
326 ConstFieldMaskArg whichField)
328 Inherited::copyToBin(pMem, whichField);
330 if(FieldBits::NoField != (BeaconFieldMask & whichField))
332 _sfBeacon.copyToBin(pMem);
334 if(FieldBits::NoField != (NearFieldMask & whichField))
336 _sfNear.copyToBin(pMem);
338 if(FieldBits::NoField != (FarFieldMask & whichField))
340 _sfFar.copyToBin(pMem);
344 void CameraBase::copyFromBin(BinaryDataHandler &pMem,
345 ConstFieldMaskArg whichField)
347 Inherited::copyFromBin(pMem, whichField);
349 if(FieldBits::NoField != (BeaconFieldMask & whichField))
351 editSField(BeaconFieldMask);
352 _sfBeacon.copyFromBin(pMem);
354 if(FieldBits::NoField != (NearFieldMask & whichField))
356 editSField(NearFieldMask);
357 _sfNear.copyFromBin(pMem);
359 if(FieldBits::NoField != (FarFieldMask & whichField))
361 editSField(FarFieldMask);
362 _sfFar.copyFromBin(pMem);
369 /*------------------------- constructors ----------------------------------*/
371 CameraBase::CameraBase(void) :
372 Inherited(),
373 _sfBeacon (NULL),
374 _sfNear (),
375 _sfFar ()
379 CameraBase::CameraBase(const CameraBase &source) :
380 Inherited(source),
381 _sfBeacon (NULL),
382 _sfNear (source._sfNear ),
383 _sfFar (source._sfFar )
388 /*-------------------------- destructors ----------------------------------*/
390 CameraBase::~CameraBase(void)
394 void CameraBase::onCreate(const Camera *source)
396 Inherited::onCreate(source);
398 if(source != NULL)
400 Camera *pThis = static_cast<Camera *>(this);
402 pThis->setBeacon(source->getBeacon());
406 GetFieldHandlePtr CameraBase::getHandleBeacon (void) const
408 SFWeakNodePtr::GetHandlePtr returnValue(
409 new SFWeakNodePtr::GetHandle(
410 &_sfBeacon,
411 this->getType().getFieldDesc(BeaconFieldId),
412 const_cast<CameraBase *>(this)));
414 return returnValue;
417 EditFieldHandlePtr CameraBase::editHandleBeacon (void)
419 SFWeakNodePtr::EditHandlePtr returnValue(
420 new SFWeakNodePtr::EditHandle(
421 &_sfBeacon,
422 this->getType().getFieldDesc(BeaconFieldId),
423 this));
425 returnValue->setSetMethod(
426 boost::bind(&Camera::setBeacon,
427 static_cast<Camera *>(this), _1));
429 editSField(BeaconFieldMask);
431 return returnValue;
434 GetFieldHandlePtr CameraBase::getHandleNear (void) const
436 SFReal32::GetHandlePtr returnValue(
437 new SFReal32::GetHandle(
438 &_sfNear,
439 this->getType().getFieldDesc(NearFieldId),
440 const_cast<CameraBase *>(this)));
442 return returnValue;
445 EditFieldHandlePtr CameraBase::editHandleNear (void)
447 SFReal32::EditHandlePtr returnValue(
448 new SFReal32::EditHandle(
449 &_sfNear,
450 this->getType().getFieldDesc(NearFieldId),
451 this));
454 editSField(NearFieldMask);
456 return returnValue;
459 GetFieldHandlePtr CameraBase::getHandleFar (void) const
461 SFReal32::GetHandlePtr returnValue(
462 new SFReal32::GetHandle(
463 &_sfFar,
464 this->getType().getFieldDesc(FarFieldId),
465 const_cast<CameraBase *>(this)));
467 return returnValue;
470 EditFieldHandlePtr CameraBase::editHandleFar (void)
472 SFReal32::EditHandlePtr returnValue(
473 new SFReal32::EditHandle(
474 &_sfFar,
475 this->getType().getFieldDesc(FarFieldId),
476 this));
479 editSField(FarFieldMask);
481 return returnValue;
485 #ifdef OSG_MT_CPTR_ASPECT
486 void CameraBase::execSyncV( FieldContainer &oFrom,
487 ConstFieldMaskArg whichField,
488 AspectOffsetStore &oOffsets,
489 ConstFieldMaskArg syncMode,
490 const UInt32 uiSyncInfo)
492 Camera *pThis = static_cast<Camera *>(this);
494 pThis->execSync(static_cast<Camera *>(&oFrom),
495 whichField,
496 oOffsets,
497 syncMode,
498 uiSyncInfo);
500 #endif
504 void CameraBase::resolveLinks(void)
506 Inherited::resolveLinks();
508 static_cast<Camera *>(this)->setBeacon(NULL);
513 /*------------------------------ get -----------------------------------*/
516 //! Get the value of the Camera::_sfBeacon field.
517 Node * CameraBase::getBeacon(void) const
519 return _sfBeacon.getValue();
522 //! Set the value of the Camera::_sfBeacon field.
523 void CameraBase::setBeacon(Node * const value)
525 editSField(BeaconFieldMask);
527 _sfBeacon.setValue(value);
529 //! Get the value of the Camera::_sfNear field.
531 Real32 &CameraBase::editNear(void)
533 editSField(NearFieldMask);
535 return _sfNear.getValue();
538 //! Get the value of the Camera::_sfNear field.
539 Real32 CameraBase::getNear(void) const
541 return _sfNear.getValue();
545 //! Set the value of the Camera::_sfNear field.
546 void CameraBase::setNear(const Real32 value)
548 editSField(NearFieldMask);
550 _sfNear.setValue(value);
552 //! Get the value of the Camera::_sfFar field.
554 Real32 &CameraBase::editFar(void)
556 editSField(FarFieldMask);
558 return _sfFar.getValue();
561 //! Get the value of the Camera::_sfFar field.
562 Real32 CameraBase::getFar(void) const
564 return _sfFar.getValue();
568 //! Set the value of the Camera::_sfFar field.
569 void CameraBase::setFar(const Real32 value)
571 editSField(FarFieldMask);
573 _sfFar.setValue(value);
577 OSG_END_NAMESPACE