fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Window / Base / OSGMatrixCameraBase.cpp
blobf357f0896ffea75f556aa5eb1ddc042a74b4b044
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 MatrixCamera!
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 "OSGMatrixCameraBase.h"
67 #include "OSGMatrixCamera.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::MatrixCamera
78 The Matrix Camera class, see \ref PageSystemWindowCameraMatrix for
79 a description.
81 The used matrices are stored in the _sfModelviewMatrix and
82 _sfProjectionMatrix Fields.
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var Matrix MatrixCameraBase::_sfProjectionMatrix
93 /*! \var Matrix MatrixCameraBase::_sfModelviewMatrix
97 /*! \var bool MatrixCameraBase::_sfUseBeacon
98 Use beacon if set to get the modelview matrix
102 /***************************************************************************\
103 * FieldType/FieldTrait Instantiation *
104 \***************************************************************************/
106 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
107 PointerType FieldTraits<MatrixCamera *, nsOSG>::_type(
108 "MatrixCameraPtr",
109 "CameraPtr",
110 MatrixCamera::getClassType(),
111 nsOSG);
112 #endif
114 OSG_FIELDTRAITS_GETTYPE_NS(MatrixCamera *, nsOSG)
116 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
117 MatrixCamera *,
118 nsOSG)
120 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
121 MatrixCamera *,
122 nsOSG)
124 /***************************************************************************\
125 * Field Description *
126 \***************************************************************************/
128 void MatrixCameraBase::classDescInserter(TypeObject &oType)
130 FieldDescriptionBase *pDesc = NULL;
133 pDesc = new SFMatrix::Description(
134 SFMatrix::getClassType(),
135 "ProjectionMatrix",
137 ProjectionMatrixFieldId, ProjectionMatrixFieldMask,
138 false,
139 (Field::SFDefaultFlags | Field::FStdAccess),
140 static_cast<FieldEditMethodSig>(&MatrixCamera::editHandleProjectionMatrix),
141 static_cast<FieldGetMethodSig >(&MatrixCamera::getHandleProjectionMatrix));
143 oType.addInitialDesc(pDesc);
145 pDesc = new SFMatrix::Description(
146 SFMatrix::getClassType(),
147 "ModelviewMatrix",
149 ModelviewMatrixFieldId, ModelviewMatrixFieldMask,
150 false,
151 (Field::SFDefaultFlags | Field::FStdAccess),
152 static_cast<FieldEditMethodSig>(&MatrixCamera::editHandleModelviewMatrix),
153 static_cast<FieldGetMethodSig >(&MatrixCamera::getHandleModelviewMatrix));
155 oType.addInitialDesc(pDesc);
157 pDesc = new SFBool::Description(
158 SFBool::getClassType(),
159 "useBeacon",
160 "Use beacon if set to get the modelview matrix\n",
161 UseBeaconFieldId, UseBeaconFieldMask,
162 false,
163 (Field::SFDefaultFlags | Field::FStdAccess),
164 static_cast<FieldEditMethodSig>(&MatrixCamera::editHandleUseBeacon),
165 static_cast<FieldGetMethodSig >(&MatrixCamera::getHandleUseBeacon));
167 oType.addInitialDesc(pDesc);
171 MatrixCameraBase::TypeObject MatrixCameraBase::_type(
172 MatrixCameraBase::getClassname(),
173 Inherited::getClassname(),
174 "NULL",
175 nsOSG, //Namespace
176 reinterpret_cast<PrototypeCreateF>(&MatrixCameraBase::createEmptyLocal),
177 reinterpret_cast<InitContainerF>(&MatrixCamera::initMethod),
178 reinterpret_cast<ExitContainerF>(&MatrixCamera::exitMethod),
179 reinterpret_cast<InitalInsertDescFunc>(
180 reinterpret_cast<void *>(&MatrixCamera::classDescInserter)),
181 false,
183 "<?xml version=\"1.0\"?>\n"
184 "\n"
185 "<FieldContainer\n"
186 " name=\"MatrixCamera\"\n"
187 " parent=\"Camera\"\n"
188 " library=\"System\"\n"
189 " pointerfieldtypes=\"both\"\n"
190 " structure=\"concrete\"\n"
191 " systemcomponent=\"true\"\n"
192 " parentsystemcomponent=\"true\"\n"
193 " docGroupBase=\"GrpSystemWindow\"\n"
194 " >\n"
195 "\n"
196 " The Matrix Camera class, see \\ref PageSystemWindowCameraMatrix for\n"
197 " a description.\n"
198 "\n"
199 " The used matrices are stored in the _sfModelviewMatrix and\n"
200 " _sfProjectionMatrix Fields.\n"
201 " <Field\n"
202 "\t name=\"ProjectionMatrix\"\n"
203 "\t type=\"Matrix\"\n"
204 "\t cardinality=\"single\"\n"
205 "\t visibility=\"external\"\n"
206 "\t access=\"public\"\n"
207 "\t >\n"
208 " </Field>\n"
209 " <Field\n"
210 "\t name=\"ModelviewMatrix\"\n"
211 "\t type=\"Matrix\"\n"
212 "\t cardinality=\"single\"\n"
213 "\t visibility=\"external\"\n"
214 "\t access=\"public\"\n"
215 "\t >\n"
216 " </Field>\n"
217 " <Field\n"
218 " name=\"useBeacon\"\n"
219 " type=\"bool\"\n"
220 " cardinality=\"single\"\n"
221 " visibility=\"external\"\n"
222 " access=\"public\"\n"
223 " >\n"
224 " Use beacon if set to get the modelview matrix\n"
225 " </Field>\n"
226 "</FieldContainer>\n",
227 "The Matrix Camera class, see \\ref PageSystemWindowCameraMatrix for\n"
228 "a description.\n"
229 "\n"
230 "The used matrices are stored in the _sfModelviewMatrix and\n"
231 "_sfProjectionMatrix Fields.\n"
234 /*------------------------------ get -----------------------------------*/
236 FieldContainerType &MatrixCameraBase::getType(void)
238 return _type;
241 const FieldContainerType &MatrixCameraBase::getType(void) const
243 return _type;
246 UInt32 MatrixCameraBase::getContainerSize(void) const
248 return sizeof(MatrixCamera);
251 /*------------------------- decorator get ------------------------------*/
254 SFMatrix *MatrixCameraBase::editSFProjectionMatrix(void)
256 editSField(ProjectionMatrixFieldMask);
258 return &_sfProjectionMatrix;
261 const SFMatrix *MatrixCameraBase::getSFProjectionMatrix(void) const
263 return &_sfProjectionMatrix;
267 SFMatrix *MatrixCameraBase::editSFModelviewMatrix(void)
269 editSField(ModelviewMatrixFieldMask);
271 return &_sfModelviewMatrix;
274 const SFMatrix *MatrixCameraBase::getSFModelviewMatrix(void) const
276 return &_sfModelviewMatrix;
280 SFBool *MatrixCameraBase::editSFUseBeacon(void)
282 editSField(UseBeaconFieldMask);
284 return &_sfUseBeacon;
287 const SFBool *MatrixCameraBase::getSFUseBeacon(void) const
289 return &_sfUseBeacon;
297 /*------------------------------ access -----------------------------------*/
299 SizeT MatrixCameraBase::getBinSize(ConstFieldMaskArg whichField)
301 SizeT returnValue = Inherited::getBinSize(whichField);
303 if(FieldBits::NoField != (ProjectionMatrixFieldMask & whichField))
305 returnValue += _sfProjectionMatrix.getBinSize();
307 if(FieldBits::NoField != (ModelviewMatrixFieldMask & whichField))
309 returnValue += _sfModelviewMatrix.getBinSize();
311 if(FieldBits::NoField != (UseBeaconFieldMask & whichField))
313 returnValue += _sfUseBeacon.getBinSize();
316 return returnValue;
319 void MatrixCameraBase::copyToBin(BinaryDataHandler &pMem,
320 ConstFieldMaskArg whichField)
322 Inherited::copyToBin(pMem, whichField);
324 if(FieldBits::NoField != (ProjectionMatrixFieldMask & whichField))
326 _sfProjectionMatrix.copyToBin(pMem);
328 if(FieldBits::NoField != (ModelviewMatrixFieldMask & whichField))
330 _sfModelviewMatrix.copyToBin(pMem);
332 if(FieldBits::NoField != (UseBeaconFieldMask & whichField))
334 _sfUseBeacon.copyToBin(pMem);
338 void MatrixCameraBase::copyFromBin(BinaryDataHandler &pMem,
339 ConstFieldMaskArg whichField)
341 Inherited::copyFromBin(pMem, whichField);
343 if(FieldBits::NoField != (ProjectionMatrixFieldMask & whichField))
345 editSField(ProjectionMatrixFieldMask);
346 _sfProjectionMatrix.copyFromBin(pMem);
348 if(FieldBits::NoField != (ModelviewMatrixFieldMask & whichField))
350 editSField(ModelviewMatrixFieldMask);
351 _sfModelviewMatrix.copyFromBin(pMem);
353 if(FieldBits::NoField != (UseBeaconFieldMask & whichField))
355 editSField(UseBeaconFieldMask);
356 _sfUseBeacon.copyFromBin(pMem);
360 //! create a new instance of the class
361 MatrixCameraTransitPtr MatrixCameraBase::createLocal(BitVector bFlags)
363 MatrixCameraTransitPtr fc;
365 if(getClassType().getPrototype() != NULL)
367 FieldContainerTransitPtr tmpPtr =
368 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
370 fc = dynamic_pointer_cast<MatrixCamera>(tmpPtr);
373 return fc;
376 //! create a new instance of the class, copy the container flags
377 MatrixCameraTransitPtr MatrixCameraBase::createDependent(BitVector bFlags)
379 MatrixCameraTransitPtr fc;
381 if(getClassType().getPrototype() != NULL)
383 FieldContainerTransitPtr tmpPtr =
384 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
386 fc = dynamic_pointer_cast<MatrixCamera>(tmpPtr);
389 return fc;
392 //! create a new instance of the class
393 MatrixCameraTransitPtr MatrixCameraBase::create(void)
395 MatrixCameraTransitPtr fc;
397 if(getClassType().getPrototype() != NULL)
399 FieldContainerTransitPtr tmpPtr =
400 getClassType().getPrototype()-> shallowCopy();
402 fc = dynamic_pointer_cast<MatrixCamera>(tmpPtr);
405 return fc;
408 MatrixCamera *MatrixCameraBase::createEmptyLocal(BitVector bFlags)
410 MatrixCamera *returnValue;
412 newPtr<MatrixCamera>(returnValue, bFlags);
414 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
416 return returnValue;
419 //! create an empty new instance of the class, do not copy the prototype
420 MatrixCamera *MatrixCameraBase::createEmpty(void)
422 MatrixCamera *returnValue;
424 newPtr<MatrixCamera>(returnValue, Thread::getCurrentLocalFlags());
426 returnValue->_pFieldFlags->_bNamespaceMask &=
427 ~Thread::getCurrentLocalFlags();
429 return returnValue;
433 FieldContainerTransitPtr MatrixCameraBase::shallowCopyLocal(
434 BitVector bFlags) const
436 MatrixCamera *tmpPtr;
438 newPtr(tmpPtr, dynamic_cast<const MatrixCamera *>(this), bFlags);
440 FieldContainerTransitPtr returnValue(tmpPtr);
442 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
444 return returnValue;
447 FieldContainerTransitPtr MatrixCameraBase::shallowCopyDependent(
448 BitVector bFlags) const
450 MatrixCamera *tmpPtr;
452 newPtr(tmpPtr, dynamic_cast<const MatrixCamera *>(this), ~bFlags);
454 FieldContainerTransitPtr returnValue(tmpPtr);
456 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
458 return returnValue;
461 FieldContainerTransitPtr MatrixCameraBase::shallowCopy(void) const
463 MatrixCamera *tmpPtr;
465 newPtr(tmpPtr,
466 dynamic_cast<const MatrixCamera *>(this),
467 Thread::getCurrentLocalFlags());
469 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
471 FieldContainerTransitPtr returnValue(tmpPtr);
473 return returnValue;
479 /*------------------------- constructors ----------------------------------*/
481 MatrixCameraBase::MatrixCameraBase(void) :
482 Inherited(),
483 _sfProjectionMatrix (),
484 _sfModelviewMatrix (),
485 _sfUseBeacon ()
489 MatrixCameraBase::MatrixCameraBase(const MatrixCameraBase &source) :
490 Inherited(source),
491 _sfProjectionMatrix (source._sfProjectionMatrix ),
492 _sfModelviewMatrix (source._sfModelviewMatrix ),
493 _sfUseBeacon (source._sfUseBeacon )
498 /*-------------------------- destructors ----------------------------------*/
500 MatrixCameraBase::~MatrixCameraBase(void)
505 GetFieldHandlePtr MatrixCameraBase::getHandleProjectionMatrix (void) const
507 SFMatrix::GetHandlePtr returnValue(
508 new SFMatrix::GetHandle(
509 &_sfProjectionMatrix,
510 this->getType().getFieldDesc(ProjectionMatrixFieldId),
511 const_cast<MatrixCameraBase *>(this)));
513 return returnValue;
516 EditFieldHandlePtr MatrixCameraBase::editHandleProjectionMatrix(void)
518 SFMatrix::EditHandlePtr returnValue(
519 new SFMatrix::EditHandle(
520 &_sfProjectionMatrix,
521 this->getType().getFieldDesc(ProjectionMatrixFieldId),
522 this));
525 editSField(ProjectionMatrixFieldMask);
527 return returnValue;
530 GetFieldHandlePtr MatrixCameraBase::getHandleModelviewMatrix (void) const
532 SFMatrix::GetHandlePtr returnValue(
533 new SFMatrix::GetHandle(
534 &_sfModelviewMatrix,
535 this->getType().getFieldDesc(ModelviewMatrixFieldId),
536 const_cast<MatrixCameraBase *>(this)));
538 return returnValue;
541 EditFieldHandlePtr MatrixCameraBase::editHandleModelviewMatrix(void)
543 SFMatrix::EditHandlePtr returnValue(
544 new SFMatrix::EditHandle(
545 &_sfModelviewMatrix,
546 this->getType().getFieldDesc(ModelviewMatrixFieldId),
547 this));
550 editSField(ModelviewMatrixFieldMask);
552 return returnValue;
555 GetFieldHandlePtr MatrixCameraBase::getHandleUseBeacon (void) const
557 SFBool::GetHandlePtr returnValue(
558 new SFBool::GetHandle(
559 &_sfUseBeacon,
560 this->getType().getFieldDesc(UseBeaconFieldId),
561 const_cast<MatrixCameraBase *>(this)));
563 return returnValue;
566 EditFieldHandlePtr MatrixCameraBase::editHandleUseBeacon (void)
568 SFBool::EditHandlePtr returnValue(
569 new SFBool::EditHandle(
570 &_sfUseBeacon,
571 this->getType().getFieldDesc(UseBeaconFieldId),
572 this));
575 editSField(UseBeaconFieldMask);
577 return returnValue;
581 #ifdef OSG_MT_CPTR_ASPECT
582 void MatrixCameraBase::execSyncV( FieldContainer &oFrom,
583 ConstFieldMaskArg whichField,
584 AspectOffsetStore &oOffsets,
585 ConstFieldMaskArg syncMode,
586 const UInt32 uiSyncInfo)
588 MatrixCamera *pThis = static_cast<MatrixCamera *>(this);
590 pThis->execSync(static_cast<MatrixCamera *>(&oFrom),
591 whichField,
592 oOffsets,
593 syncMode,
594 uiSyncInfo);
596 #endif
599 #ifdef OSG_MT_CPTR_ASPECT
600 FieldContainer *MatrixCameraBase::createAspectCopy(
601 const FieldContainer *pRefAspect) const
603 MatrixCamera *returnValue;
605 newAspectCopy(returnValue,
606 dynamic_cast<const MatrixCamera *>(pRefAspect),
607 dynamic_cast<const MatrixCamera *>(this));
609 return returnValue;
611 #endif
613 void MatrixCameraBase::resolveLinks(void)
615 Inherited::resolveLinks();
621 OSG_END_NAMESPACE