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 **
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"
65 #include "OSGNode.h" // Beacon Class
67 #include "OSGCameraBase.h"
68 #include "OSGCamera.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
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
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(
110 "AttachmentContainerPtr",
111 Camera::getClassType(),
115 OSG_FIELDTRAITS_GETTYPE_NS(Camera
*, nsOSG
)
117 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
121 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
125 /***************************************************************************\
126 * Field Description *
127 \***************************************************************************/
129 void CameraBase::classDescInserter(TypeObject
&oType
)
131 FieldDescriptionBase
*pDesc
= NULL
;
134 pDesc
= new SFWeakNodePtr::Description(
135 SFWeakNodePtr::getClassType(),
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
,
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(),
151 "The near distance of the camera.\n",
152 NearFieldId
, NearFieldMask
,
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(),
163 "The far distance of the camera.\n",
164 FarFieldId
, FarFieldMask
,
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(),
180 reinterpret_cast<InitContainerF
>(&Camera::initMethod
),
181 reinterpret_cast<ExitContainerF
>(&Camera::exitMethod
),
182 reinterpret_cast<InitalInsertDescFunc
>(
183 reinterpret_cast<void *>(&Camera::classDescInserter
)),
186 "<?xml version=\"1.0\" ?>\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"
201 " The Camera base class, see \\ref PageSystemWindowCamera for a description.\n"
203 " The only common fields are _sfNear and _sfFar.\n"
206 "\t name=\"beacon\"\n"
208 " category=\"weakpointer\"\n"
209 "\t cardinality=\"single\"\n"
210 "\t visibility=\"external\"\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"
218 "\t type=\"Real32\"\n"
219 "\t cardinality=\"single\"\n"
220 "\t visibility=\"external\"\n"
222 "\tThe near distance of the camera.\n"
226 "\t type=\"Real32\"\n"
227 "\t cardinality=\"single\"\n"
228 "\t visibility=\"external\"\n"
230 "\tThe far distance of the camera.\n"
232 "</FieldContainer>\n",
233 "The Camera base class, see \\ref PageSystemWindowCamera for a description.\n"
235 "The only common fields are _sfNear and _sfFar.\n"
238 /*------------------------------ get -----------------------------------*/
240 FieldContainerType
&CameraBase::getType(void)
245 const FieldContainerType
&CameraBase::getType(void) const
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
264 SFWeakNodePtr
*CameraBase::editSFBeacon (void)
266 editSField(BeaconFieldMask
);
273 SFReal32
*CameraBase::editSFNear(void)
275 editSField(NearFieldMask
);
280 const SFReal32
*CameraBase::getSFNear(void) const
286 SFReal32
*CameraBase::editSFFar(void)
288 editSField(FarFieldMask
);
293 const SFReal32
*CameraBase::getSFFar(void) const
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();
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) :
379 CameraBase::CameraBase(const CameraBase
&source
) :
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
);
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(
411 this->getType().getFieldDesc(BeaconFieldId
),
412 const_cast<CameraBase
*>(this)));
417 EditFieldHandlePtr
CameraBase::editHandleBeacon (void)
419 SFWeakNodePtr::EditHandlePtr
returnValue(
420 new SFWeakNodePtr::EditHandle(
422 this->getType().getFieldDesc(BeaconFieldId
),
425 returnValue
->setSetMethod(
426 boost::bind(&Camera::setBeacon
,
427 static_cast<Camera
*>(this), _1
));
429 editSField(BeaconFieldMask
);
434 GetFieldHandlePtr
CameraBase::getHandleNear (void) const
436 SFReal32::GetHandlePtr
returnValue(
437 new SFReal32::GetHandle(
439 this->getType().getFieldDesc(NearFieldId
),
440 const_cast<CameraBase
*>(this)));
445 EditFieldHandlePtr
CameraBase::editHandleNear (void)
447 SFReal32::EditHandlePtr
returnValue(
448 new SFReal32::EditHandle(
450 this->getType().getFieldDesc(NearFieldId
),
454 editSField(NearFieldMask
);
459 GetFieldHandlePtr
CameraBase::getHandleFar (void) const
461 SFReal32::GetHandlePtr
returnValue(
462 new SFReal32::GetHandle(
464 this->getType().getFieldDesc(FarFieldId
),
465 const_cast<CameraBase
*>(this)));
470 EditFieldHandlePtr
CameraBase::editHandleFar (void)
472 SFReal32::EditHandlePtr
returnValue(
473 new SFReal32::EditHandle(
475 this->getType().getFieldDesc(FarFieldId
),
479 editSField(FarFieldMask
);
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
),
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
);