fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Window / Camera / OSGOrthographicCameraBase.cpp
blobc4360f1f52b53c04ef6c751fc5c15c5792688acc
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 OrthographicCamera!
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 "OSGOrthographicCameraBase.h"
67 #include "OSGOrthographicCamera.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::OrthographicCamera
78 A perspective camera with a symmetric frustum.
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var Real32 OrthographicCameraBase::_sfVerticalSize
86 The vertical size of the camera box, in world units. Ignored when less
87 then or equal to zero.
90 /*! \var Real32 OrthographicCameraBase::_sfHorizontalSize
91 The horizontal size of the camera box, in world units. Ignored when less
92 then or equal to zero.
95 /*! \var Real32 OrthographicCameraBase::_sfAspect
96 The aspect ratio (i.e. width / height) of a pixel.
100 /***************************************************************************\
101 * FieldType/FieldTrait Instantiation *
102 \***************************************************************************/
104 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
105 PointerType FieldTraits<OrthographicCamera *, nsOSG>::_type(
106 "OrthographicCameraPtr",
107 "CameraPtr",
108 OrthographicCamera::getClassType(),
109 nsOSG);
110 #endif
112 OSG_FIELDTRAITS_GETTYPE_NS(OrthographicCamera *, nsOSG)
114 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
115 OrthographicCamera *,
116 nsOSG)
118 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
119 OrthographicCamera *,
120 nsOSG)
122 /***************************************************************************\
123 * Field Description *
124 \***************************************************************************/
126 void OrthographicCameraBase::classDescInserter(TypeObject &oType)
128 FieldDescriptionBase *pDesc = NULL;
131 pDesc = new SFReal32::Description(
132 SFReal32::getClassType(),
133 "verticalSize",
134 "The vertical size of the camera box, in world units. Ignored when less\n"
135 "then or equal to zero. \n",
136 VerticalSizeFieldId, VerticalSizeFieldMask,
137 false,
138 (Field::SFDefaultFlags | Field::FStdAccess),
139 static_cast<FieldEditMethodSig>(&OrthographicCamera::editHandleVerticalSize),
140 static_cast<FieldGetMethodSig >(&OrthographicCamera::getHandleVerticalSize));
142 oType.addInitialDesc(pDesc);
144 pDesc = new SFReal32::Description(
145 SFReal32::getClassType(),
146 "horizontalSize",
147 "The horizontal size of the camera box, in world units. Ignored when less\n"
148 "then or equal to zero. \n",
149 HorizontalSizeFieldId, HorizontalSizeFieldMask,
150 false,
151 (Field::SFDefaultFlags | Field::FStdAccess),
152 static_cast<FieldEditMethodSig>(&OrthographicCamera::editHandleHorizontalSize),
153 static_cast<FieldGetMethodSig >(&OrthographicCamera::getHandleHorizontalSize));
155 oType.addInitialDesc(pDesc);
157 pDesc = new SFReal32::Description(
158 SFReal32::getClassType(),
159 "aspect",
160 "The aspect ratio (i.e. width / height) of a pixel.\n",
161 AspectFieldId, AspectFieldMask,
162 false,
163 (Field::SFDefaultFlags | Field::FStdAccess),
164 static_cast<FieldEditMethodSig>(&OrthographicCamera::editHandleAspect),
165 static_cast<FieldGetMethodSig >(&OrthographicCamera::getHandleAspect));
167 oType.addInitialDesc(pDesc);
171 OrthographicCameraBase::TypeObject OrthographicCameraBase::_type(
172 OrthographicCameraBase::getClassname(),
173 Inherited::getClassname(),
174 "NULL",
175 nsOSG, //Namespace
176 reinterpret_cast<PrototypeCreateF>(&OrthographicCameraBase::createEmptyLocal),
177 reinterpret_cast<InitContainerF>(&OrthographicCamera::initMethod),
178 reinterpret_cast<ExitContainerF>(&OrthographicCamera::exitMethod),
179 reinterpret_cast<InitalInsertDescFunc>(
180 reinterpret_cast<void *>(&OrthographicCamera::classDescInserter)),
181 false,
183 "<?xml version=\"1.0\" ?>\n"
184 "\n"
185 "<FieldContainer\n"
186 " name=\"OrthographicCamera\"\n"
187 " parent=\"Camera\"\n"
188 " library=\"Window\"\n"
189 " structure=\"concrete\"\n"
190 " pointerfieldtypes=\"both\"\n"
191 " systemcomponent=\"true\"\n"
192 " parentsystemcomponent=\"true\"\n"
193 " docGroupBase=\"GrpWindowCamera\"\n"
194 " >\n"
195 " A perspective camera with a symmetric frustum.\n"
196 " <Field\n"
197 "\t name=\"verticalSize\"\n"
198 "\t type=\"Real32\"\n"
199 "\t cardinality=\"single\"\n"
200 "\t visibility=\"external\"\n"
201 "\t >\n"
202 "\tThe vertical size of the camera box, in world units. Ignored when less\n"
203 "\tthen or equal to zero. \n"
204 " </Field>\n"
205 " <Field\n"
206 "\t name=\"horizontalSize\"\n"
207 "\t type=\"Real32\"\n"
208 "\t cardinality=\"single\"\n"
209 "\t visibility=\"external\"\n"
210 " defaultValue=\"-1\"\n"
211 "\t >\n"
212 "\tThe horizontal size of the camera box, in world units. Ignored when less\n"
213 "\tthen or equal to zero. \n"
214 " </Field>\n"
215 " <Field\n"
216 "\t name=\"aspect\"\n"
217 "\t type=\"Real32\"\n"
218 "\t cardinality=\"single\"\n"
219 "\t visibility=\"external\"\n"
220 " defaultValue=\"1\"\n"
221 "\t >\n"
222 "\tThe aspect ratio (i.e. width / height) of a pixel.\n"
223 " </Field>\n"
224 "</FieldContainer>\n",
225 "A perspective camera with a symmetric frustum.\n"
228 /*------------------------------ get -----------------------------------*/
230 FieldContainerType &OrthographicCameraBase::getType(void)
232 return _type;
235 const FieldContainerType &OrthographicCameraBase::getType(void) const
237 return _type;
240 UInt32 OrthographicCameraBase::getContainerSize(void) const
242 return sizeof(OrthographicCamera);
245 /*------------------------- decorator get ------------------------------*/
248 SFReal32 *OrthographicCameraBase::editSFVerticalSize(void)
250 editSField(VerticalSizeFieldMask);
252 return &_sfVerticalSize;
255 const SFReal32 *OrthographicCameraBase::getSFVerticalSize(void) const
257 return &_sfVerticalSize;
261 SFReal32 *OrthographicCameraBase::editSFHorizontalSize(void)
263 editSField(HorizontalSizeFieldMask);
265 return &_sfHorizontalSize;
268 const SFReal32 *OrthographicCameraBase::getSFHorizontalSize(void) const
270 return &_sfHorizontalSize;
274 SFReal32 *OrthographicCameraBase::editSFAspect(void)
276 editSField(AspectFieldMask);
278 return &_sfAspect;
281 const SFReal32 *OrthographicCameraBase::getSFAspect(void) const
283 return &_sfAspect;
291 /*------------------------------ access -----------------------------------*/
293 SizeT OrthographicCameraBase::getBinSize(ConstFieldMaskArg whichField)
295 SizeT returnValue = Inherited::getBinSize(whichField);
297 if(FieldBits::NoField != (VerticalSizeFieldMask & whichField))
299 returnValue += _sfVerticalSize.getBinSize();
301 if(FieldBits::NoField != (HorizontalSizeFieldMask & whichField))
303 returnValue += _sfHorizontalSize.getBinSize();
305 if(FieldBits::NoField != (AspectFieldMask & whichField))
307 returnValue += _sfAspect.getBinSize();
310 return returnValue;
313 void OrthographicCameraBase::copyToBin(BinaryDataHandler &pMem,
314 ConstFieldMaskArg whichField)
316 Inherited::copyToBin(pMem, whichField);
318 if(FieldBits::NoField != (VerticalSizeFieldMask & whichField))
320 _sfVerticalSize.copyToBin(pMem);
322 if(FieldBits::NoField != (HorizontalSizeFieldMask & whichField))
324 _sfHorizontalSize.copyToBin(pMem);
326 if(FieldBits::NoField != (AspectFieldMask & whichField))
328 _sfAspect.copyToBin(pMem);
332 void OrthographicCameraBase::copyFromBin(BinaryDataHandler &pMem,
333 ConstFieldMaskArg whichField)
335 Inherited::copyFromBin(pMem, whichField);
337 if(FieldBits::NoField != (VerticalSizeFieldMask & whichField))
339 editSField(VerticalSizeFieldMask);
340 _sfVerticalSize.copyFromBin(pMem);
342 if(FieldBits::NoField != (HorizontalSizeFieldMask & whichField))
344 editSField(HorizontalSizeFieldMask);
345 _sfHorizontalSize.copyFromBin(pMem);
347 if(FieldBits::NoField != (AspectFieldMask & whichField))
349 editSField(AspectFieldMask);
350 _sfAspect.copyFromBin(pMem);
354 //! create a new instance of the class
355 OrthographicCameraTransitPtr OrthographicCameraBase::createLocal(BitVector bFlags)
357 OrthographicCameraTransitPtr fc;
359 if(getClassType().getPrototype() != NULL)
361 FieldContainerTransitPtr tmpPtr =
362 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
364 fc = dynamic_pointer_cast<OrthographicCamera>(tmpPtr);
367 return fc;
370 //! create a new instance of the class, copy the container flags
371 OrthographicCameraTransitPtr OrthographicCameraBase::createDependent(BitVector bFlags)
373 OrthographicCameraTransitPtr fc;
375 if(getClassType().getPrototype() != NULL)
377 FieldContainerTransitPtr tmpPtr =
378 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
380 fc = dynamic_pointer_cast<OrthographicCamera>(tmpPtr);
383 return fc;
386 //! create a new instance of the class
387 OrthographicCameraTransitPtr OrthographicCameraBase::create(void)
389 OrthographicCameraTransitPtr fc;
391 if(getClassType().getPrototype() != NULL)
393 FieldContainerTransitPtr tmpPtr =
394 getClassType().getPrototype()-> shallowCopy();
396 fc = dynamic_pointer_cast<OrthographicCamera>(tmpPtr);
399 return fc;
402 OrthographicCamera *OrthographicCameraBase::createEmptyLocal(BitVector bFlags)
404 OrthographicCamera *returnValue;
406 newPtr<OrthographicCamera>(returnValue, bFlags);
408 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
410 return returnValue;
413 //! create an empty new instance of the class, do not copy the prototype
414 OrthographicCamera *OrthographicCameraBase::createEmpty(void)
416 OrthographicCamera *returnValue;
418 newPtr<OrthographicCamera>(returnValue, Thread::getCurrentLocalFlags());
420 returnValue->_pFieldFlags->_bNamespaceMask &=
421 ~Thread::getCurrentLocalFlags();
423 return returnValue;
427 FieldContainerTransitPtr OrthographicCameraBase::shallowCopyLocal(
428 BitVector bFlags) const
430 OrthographicCamera *tmpPtr;
432 newPtr(tmpPtr, dynamic_cast<const OrthographicCamera *>(this), bFlags);
434 FieldContainerTransitPtr returnValue(tmpPtr);
436 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
438 return returnValue;
441 FieldContainerTransitPtr OrthographicCameraBase::shallowCopyDependent(
442 BitVector bFlags) const
444 OrthographicCamera *tmpPtr;
446 newPtr(tmpPtr, dynamic_cast<const OrthographicCamera *>(this), ~bFlags);
448 FieldContainerTransitPtr returnValue(tmpPtr);
450 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
452 return returnValue;
455 FieldContainerTransitPtr OrthographicCameraBase::shallowCopy(void) const
457 OrthographicCamera *tmpPtr;
459 newPtr(tmpPtr,
460 dynamic_cast<const OrthographicCamera *>(this),
461 Thread::getCurrentLocalFlags());
463 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
465 FieldContainerTransitPtr returnValue(tmpPtr);
467 return returnValue;
473 /*------------------------- constructors ----------------------------------*/
475 OrthographicCameraBase::OrthographicCameraBase(void) :
476 Inherited(),
477 _sfVerticalSize (),
478 _sfHorizontalSize (Real32(-1)),
479 _sfAspect (Real32(1))
483 OrthographicCameraBase::OrthographicCameraBase(const OrthographicCameraBase &source) :
484 Inherited(source),
485 _sfVerticalSize (source._sfVerticalSize ),
486 _sfHorizontalSize (source._sfHorizontalSize ),
487 _sfAspect (source._sfAspect )
492 /*-------------------------- destructors ----------------------------------*/
494 OrthographicCameraBase::~OrthographicCameraBase(void)
499 GetFieldHandlePtr OrthographicCameraBase::getHandleVerticalSize (void) const
501 SFReal32::GetHandlePtr returnValue(
502 new SFReal32::GetHandle(
503 &_sfVerticalSize,
504 this->getType().getFieldDesc(VerticalSizeFieldId),
505 const_cast<OrthographicCameraBase *>(this)));
507 return returnValue;
510 EditFieldHandlePtr OrthographicCameraBase::editHandleVerticalSize (void)
512 SFReal32::EditHandlePtr returnValue(
513 new SFReal32::EditHandle(
514 &_sfVerticalSize,
515 this->getType().getFieldDesc(VerticalSizeFieldId),
516 this));
519 editSField(VerticalSizeFieldMask);
521 return returnValue;
524 GetFieldHandlePtr OrthographicCameraBase::getHandleHorizontalSize (void) const
526 SFReal32::GetHandlePtr returnValue(
527 new SFReal32::GetHandle(
528 &_sfHorizontalSize,
529 this->getType().getFieldDesc(HorizontalSizeFieldId),
530 const_cast<OrthographicCameraBase *>(this)));
532 return returnValue;
535 EditFieldHandlePtr OrthographicCameraBase::editHandleHorizontalSize (void)
537 SFReal32::EditHandlePtr returnValue(
538 new SFReal32::EditHandle(
539 &_sfHorizontalSize,
540 this->getType().getFieldDesc(HorizontalSizeFieldId),
541 this));
544 editSField(HorizontalSizeFieldMask);
546 return returnValue;
549 GetFieldHandlePtr OrthographicCameraBase::getHandleAspect (void) const
551 SFReal32::GetHandlePtr returnValue(
552 new SFReal32::GetHandle(
553 &_sfAspect,
554 this->getType().getFieldDesc(AspectFieldId),
555 const_cast<OrthographicCameraBase *>(this)));
557 return returnValue;
560 EditFieldHandlePtr OrthographicCameraBase::editHandleAspect (void)
562 SFReal32::EditHandlePtr returnValue(
563 new SFReal32::EditHandle(
564 &_sfAspect,
565 this->getType().getFieldDesc(AspectFieldId),
566 this));
569 editSField(AspectFieldMask);
571 return returnValue;
575 #ifdef OSG_MT_CPTR_ASPECT
576 void OrthographicCameraBase::execSyncV( FieldContainer &oFrom,
577 ConstFieldMaskArg whichField,
578 AspectOffsetStore &oOffsets,
579 ConstFieldMaskArg syncMode,
580 const UInt32 uiSyncInfo)
582 OrthographicCamera *pThis = static_cast<OrthographicCamera *>(this);
584 pThis->execSync(static_cast<OrthographicCamera *>(&oFrom),
585 whichField,
586 oOffsets,
587 syncMode,
588 uiSyncInfo);
590 #endif
593 #ifdef OSG_MT_CPTR_ASPECT
594 FieldContainer *OrthographicCameraBase::createAspectCopy(
595 const FieldContainer *pRefAspect) const
597 OrthographicCamera *returnValue;
599 newAspectCopy(returnValue,
600 dynamic_cast<const OrthographicCamera *>(pRefAspect),
601 dynamic_cast<const OrthographicCamera *>(this));
603 return returnValue;
605 #endif
607 void OrthographicCameraBase::resolveLinks(void)
609 Inherited::resolveLinks();
615 OSG_END_NAMESPACE