fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Groups / Misc / OSGBillboardBase.cpp
blob9f802220635c7ef8ba8be4c51a54202720923e97
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 Billboard!
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 "OSGBillboardBase.h"
67 #include "OSGBillboard.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::Billboard
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var Vec3f BillboardBase::_sfAxisOfRotation
89 /*! \var bool BillboardBase::_sfFocusOnCamera
93 /*! \var bool BillboardBase::_sfAlignToScreen
97 /*! \var Real32 BillboardBase::_sfMinAngle
101 /*! \var Real32 BillboardBase::_sfMaxAngle
106 /***************************************************************************\
107 * FieldType/FieldTrait Instantiation *
108 \***************************************************************************/
110 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
111 PointerType FieldTraits<Billboard *, nsOSG>::_type(
112 "BillboardPtr",
113 "GroupPtr",
114 Billboard::getClassType(),
115 nsOSG);
116 #endif
118 OSG_FIELDTRAITS_GETTYPE_NS(Billboard *, nsOSG)
120 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
121 Billboard *,
122 nsOSG)
124 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
125 Billboard *,
126 nsOSG)
128 /***************************************************************************\
129 * Field Description *
130 \***************************************************************************/
132 void BillboardBase::classDescInserter(TypeObject &oType)
134 FieldDescriptionBase *pDesc = NULL;
137 pDesc = new SFVec3f::Description(
138 SFVec3f::getClassType(),
139 "axisOfRotation",
141 AxisOfRotationFieldId, AxisOfRotationFieldMask,
142 false,
143 (Field::SFDefaultFlags | Field::FStdAccess),
144 static_cast<FieldEditMethodSig>(&Billboard::editHandleAxisOfRotation),
145 static_cast<FieldGetMethodSig >(&Billboard::getHandleAxisOfRotation));
147 oType.addInitialDesc(pDesc);
149 pDesc = new SFBool::Description(
150 SFBool::getClassType(),
151 "focusOnCamera",
153 FocusOnCameraFieldId, FocusOnCameraFieldMask,
154 false,
155 (Field::SFDefaultFlags | Field::FStdAccess),
156 static_cast<FieldEditMethodSig>(&Billboard::editHandleFocusOnCamera),
157 static_cast<FieldGetMethodSig >(&Billboard::getHandleFocusOnCamera));
159 oType.addInitialDesc(pDesc);
161 pDesc = new SFBool::Description(
162 SFBool::getClassType(),
163 "alignToScreen",
165 AlignToScreenFieldId, AlignToScreenFieldMask,
166 false,
167 (Field::SFDefaultFlags | Field::FStdAccess),
168 static_cast<FieldEditMethodSig>(&Billboard::editHandleAlignToScreen),
169 static_cast<FieldGetMethodSig >(&Billboard::getHandleAlignToScreen));
171 oType.addInitialDesc(pDesc);
173 pDesc = new SFReal32::Description(
174 SFReal32::getClassType(),
175 "minAngle",
177 MinAngleFieldId, MinAngleFieldMask,
178 false,
179 (Field::SFDefaultFlags | Field::FStdAccess),
180 static_cast<FieldEditMethodSig>(&Billboard::editHandleMinAngle),
181 static_cast<FieldGetMethodSig >(&Billboard::getHandleMinAngle));
183 oType.addInitialDesc(pDesc);
185 pDesc = new SFReal32::Description(
186 SFReal32::getClassType(),
187 "maxAngle",
189 MaxAngleFieldId, MaxAngleFieldMask,
190 false,
191 (Field::SFDefaultFlags | Field::FStdAccess),
192 static_cast<FieldEditMethodSig>(&Billboard::editHandleMaxAngle),
193 static_cast<FieldGetMethodSig >(&Billboard::getHandleMaxAngle));
195 oType.addInitialDesc(pDesc);
199 BillboardBase::TypeObject BillboardBase::_type(
200 BillboardBase::getClassname(),
201 Inherited::getClassname(),
202 "NULL",
203 nsOSG, //Namespace
204 reinterpret_cast<PrototypeCreateF>(&BillboardBase::createEmptyLocal),
205 reinterpret_cast<InitContainerF>(&Billboard::initMethod),
206 reinterpret_cast<ExitContainerF>(&Billboard::exitMethod),
207 reinterpret_cast<InitalInsertDescFunc>(
208 reinterpret_cast<void *>(&Billboard::classDescInserter)),
209 false,
211 "<?xml version=\"1.0\"?>\n"
212 "\n"
213 "<FieldContainer\n"
214 " name=\"Billboard\"\n"
215 " parent=\"Group\"\n"
216 " library=\"Group\"\n"
217 " pointerfieldtypes=\"both\"\n"
218 " structure=\"concrete\"\n"
219 " systemcomponent=\"true\"\n"
220 " parentsystemcomponent=\"true\"\n"
221 " isNodeCore=\"true\"\n"
222 " docGroupBase=\"GrpGroupMisc\"\n"
223 " >\n"
224 " <Field\n"
225 "\t name=\"axisOfRotation\"\n"
226 "\t type=\"Vec3f\"\n"
227 "\t cardinality=\"single\"\n"
228 "\t visibility=\"external\"\n"
229 "\t defaultValue=\"0.f, 1.f, 0.f\"\n"
230 "\t access=\"public\"\n"
231 "\t >\n"
232 " </Field>\n"
233 " <Field\n"
234 "\t name=\"focusOnCamera\"\n"
235 "\t type=\"bool\"\n"
236 "\t cardinality=\"single\"\n"
237 "\t visibility=\"external\"\n"
238 "\t defaultValue=\"true\"\n"
239 "\t access=\"public\"\n"
240 "\t >\n"
241 " </Field>\n"
242 " <Field\n"
243 "\t name=\"alignToScreen\"\n"
244 "\t type=\"bool\"\n"
245 "\t cardinality=\"single\"\n"
246 "\t visibility=\"external\"\n"
247 "\t defaultValue=\"false\"\n"
248 "\t access=\"public\"\n"
249 "\t >\n"
250 " </Field>\n"
251 " <Field\n"
252 "\t name=\"minAngle\"\n"
253 "\t type=\"Real32\"\n"
254 "\t cardinality=\"single\"\n"
255 "\t visibility=\"external\"\n"
256 "\t defaultValue=\"0.0f\"\n"
257 "\t access=\"public\"\n"
258 "\t >\n"
259 " </Field>\n"
260 " <Field\n"
261 "\t name=\"maxAngle\"\n"
262 "\t type=\"Real32\"\n"
263 "\t cardinality=\"single\"\n"
264 "\t visibility=\"external\"\n"
265 "\t defaultValue=\"-1.0f\"\n"
266 "\t access=\"public\"\n"
267 "\t >\n"
268 " </Field>\n"
269 "</FieldContainer>\n",
273 /*------------------------------ get -----------------------------------*/
275 FieldContainerType &BillboardBase::getType(void)
277 return _type;
280 const FieldContainerType &BillboardBase::getType(void) const
282 return _type;
285 UInt32 BillboardBase::getContainerSize(void) const
287 return sizeof(Billboard);
290 /*------------------------- decorator get ------------------------------*/
293 SFVec3f *BillboardBase::editSFAxisOfRotation(void)
295 editSField(AxisOfRotationFieldMask);
297 return &_sfAxisOfRotation;
300 const SFVec3f *BillboardBase::getSFAxisOfRotation(void) const
302 return &_sfAxisOfRotation;
306 SFBool *BillboardBase::editSFFocusOnCamera(void)
308 editSField(FocusOnCameraFieldMask);
310 return &_sfFocusOnCamera;
313 const SFBool *BillboardBase::getSFFocusOnCamera(void) const
315 return &_sfFocusOnCamera;
319 SFBool *BillboardBase::editSFAlignToScreen(void)
321 editSField(AlignToScreenFieldMask);
323 return &_sfAlignToScreen;
326 const SFBool *BillboardBase::getSFAlignToScreen(void) const
328 return &_sfAlignToScreen;
332 SFReal32 *BillboardBase::editSFMinAngle(void)
334 editSField(MinAngleFieldMask);
336 return &_sfMinAngle;
339 const SFReal32 *BillboardBase::getSFMinAngle(void) const
341 return &_sfMinAngle;
345 SFReal32 *BillboardBase::editSFMaxAngle(void)
347 editSField(MaxAngleFieldMask);
349 return &_sfMaxAngle;
352 const SFReal32 *BillboardBase::getSFMaxAngle(void) const
354 return &_sfMaxAngle;
362 /*------------------------------ access -----------------------------------*/
364 SizeT BillboardBase::getBinSize(ConstFieldMaskArg whichField)
366 SizeT returnValue = Inherited::getBinSize(whichField);
368 if(FieldBits::NoField != (AxisOfRotationFieldMask & whichField))
370 returnValue += _sfAxisOfRotation.getBinSize();
372 if(FieldBits::NoField != (FocusOnCameraFieldMask & whichField))
374 returnValue += _sfFocusOnCamera.getBinSize();
376 if(FieldBits::NoField != (AlignToScreenFieldMask & whichField))
378 returnValue += _sfAlignToScreen.getBinSize();
380 if(FieldBits::NoField != (MinAngleFieldMask & whichField))
382 returnValue += _sfMinAngle.getBinSize();
384 if(FieldBits::NoField != (MaxAngleFieldMask & whichField))
386 returnValue += _sfMaxAngle.getBinSize();
389 return returnValue;
392 void BillboardBase::copyToBin(BinaryDataHandler &pMem,
393 ConstFieldMaskArg whichField)
395 Inherited::copyToBin(pMem, whichField);
397 if(FieldBits::NoField != (AxisOfRotationFieldMask & whichField))
399 _sfAxisOfRotation.copyToBin(pMem);
401 if(FieldBits::NoField != (FocusOnCameraFieldMask & whichField))
403 _sfFocusOnCamera.copyToBin(pMem);
405 if(FieldBits::NoField != (AlignToScreenFieldMask & whichField))
407 _sfAlignToScreen.copyToBin(pMem);
409 if(FieldBits::NoField != (MinAngleFieldMask & whichField))
411 _sfMinAngle.copyToBin(pMem);
413 if(FieldBits::NoField != (MaxAngleFieldMask & whichField))
415 _sfMaxAngle.copyToBin(pMem);
419 void BillboardBase::copyFromBin(BinaryDataHandler &pMem,
420 ConstFieldMaskArg whichField)
422 Inherited::copyFromBin(pMem, whichField);
424 if(FieldBits::NoField != (AxisOfRotationFieldMask & whichField))
426 editSField(AxisOfRotationFieldMask);
427 _sfAxisOfRotation.copyFromBin(pMem);
429 if(FieldBits::NoField != (FocusOnCameraFieldMask & whichField))
431 editSField(FocusOnCameraFieldMask);
432 _sfFocusOnCamera.copyFromBin(pMem);
434 if(FieldBits::NoField != (AlignToScreenFieldMask & whichField))
436 editSField(AlignToScreenFieldMask);
437 _sfAlignToScreen.copyFromBin(pMem);
439 if(FieldBits::NoField != (MinAngleFieldMask & whichField))
441 editSField(MinAngleFieldMask);
442 _sfMinAngle.copyFromBin(pMem);
444 if(FieldBits::NoField != (MaxAngleFieldMask & whichField))
446 editSField(MaxAngleFieldMask);
447 _sfMaxAngle.copyFromBin(pMem);
451 //! create a new instance of the class
452 BillboardTransitPtr BillboardBase::createLocal(BitVector bFlags)
454 BillboardTransitPtr fc;
456 if(getClassType().getPrototype() != NULL)
458 FieldContainerTransitPtr tmpPtr =
459 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
461 fc = dynamic_pointer_cast<Billboard>(tmpPtr);
464 return fc;
467 //! create a new instance of the class, copy the container flags
468 BillboardTransitPtr BillboardBase::createDependent(BitVector bFlags)
470 BillboardTransitPtr fc;
472 if(getClassType().getPrototype() != NULL)
474 FieldContainerTransitPtr tmpPtr =
475 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
477 fc = dynamic_pointer_cast<Billboard>(tmpPtr);
480 return fc;
483 //! create a new instance of the class
484 BillboardTransitPtr BillboardBase::create(void)
486 BillboardTransitPtr fc;
488 if(getClassType().getPrototype() != NULL)
490 FieldContainerTransitPtr tmpPtr =
491 getClassType().getPrototype()-> shallowCopy();
493 fc = dynamic_pointer_cast<Billboard>(tmpPtr);
496 return fc;
499 Billboard *BillboardBase::createEmptyLocal(BitVector bFlags)
501 Billboard *returnValue;
503 newPtr<Billboard>(returnValue, bFlags);
505 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
507 return returnValue;
510 //! create an empty new instance of the class, do not copy the prototype
511 Billboard *BillboardBase::createEmpty(void)
513 Billboard *returnValue;
515 newPtr<Billboard>(returnValue, Thread::getCurrentLocalFlags());
517 returnValue->_pFieldFlags->_bNamespaceMask &=
518 ~Thread::getCurrentLocalFlags();
520 return returnValue;
524 FieldContainerTransitPtr BillboardBase::shallowCopyLocal(
525 BitVector bFlags) const
527 Billboard *tmpPtr;
529 newPtr(tmpPtr, dynamic_cast<const Billboard *>(this), bFlags);
531 FieldContainerTransitPtr returnValue(tmpPtr);
533 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
535 return returnValue;
538 FieldContainerTransitPtr BillboardBase::shallowCopyDependent(
539 BitVector bFlags) const
541 Billboard *tmpPtr;
543 newPtr(tmpPtr, dynamic_cast<const Billboard *>(this), ~bFlags);
545 FieldContainerTransitPtr returnValue(tmpPtr);
547 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
549 return returnValue;
552 FieldContainerTransitPtr BillboardBase::shallowCopy(void) const
554 Billboard *tmpPtr;
556 newPtr(tmpPtr,
557 dynamic_cast<const Billboard *>(this),
558 Thread::getCurrentLocalFlags());
560 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
562 FieldContainerTransitPtr returnValue(tmpPtr);
564 return returnValue;
570 /*------------------------- constructors ----------------------------------*/
572 BillboardBase::BillboardBase(void) :
573 Inherited(),
574 _sfAxisOfRotation (Vec3f(0.f, 1.f, 0.f)),
575 _sfFocusOnCamera (bool(true)),
576 _sfAlignToScreen (bool(false)),
577 _sfMinAngle (Real32(0.0f)),
578 _sfMaxAngle (Real32(-1.0f))
582 BillboardBase::BillboardBase(const BillboardBase &source) :
583 Inherited(source),
584 _sfAxisOfRotation (source._sfAxisOfRotation ),
585 _sfFocusOnCamera (source._sfFocusOnCamera ),
586 _sfAlignToScreen (source._sfAlignToScreen ),
587 _sfMinAngle (source._sfMinAngle ),
588 _sfMaxAngle (source._sfMaxAngle )
593 /*-------------------------- destructors ----------------------------------*/
595 BillboardBase::~BillboardBase(void)
600 GetFieldHandlePtr BillboardBase::getHandleAxisOfRotation (void) const
602 SFVec3f::GetHandlePtr returnValue(
603 new SFVec3f::GetHandle(
604 &_sfAxisOfRotation,
605 this->getType().getFieldDesc(AxisOfRotationFieldId),
606 const_cast<BillboardBase *>(this)));
608 return returnValue;
611 EditFieldHandlePtr BillboardBase::editHandleAxisOfRotation (void)
613 SFVec3f::EditHandlePtr returnValue(
614 new SFVec3f::EditHandle(
615 &_sfAxisOfRotation,
616 this->getType().getFieldDesc(AxisOfRotationFieldId),
617 this));
620 editSField(AxisOfRotationFieldMask);
622 return returnValue;
625 GetFieldHandlePtr BillboardBase::getHandleFocusOnCamera (void) const
627 SFBool::GetHandlePtr returnValue(
628 new SFBool::GetHandle(
629 &_sfFocusOnCamera,
630 this->getType().getFieldDesc(FocusOnCameraFieldId),
631 const_cast<BillboardBase *>(this)));
633 return returnValue;
636 EditFieldHandlePtr BillboardBase::editHandleFocusOnCamera (void)
638 SFBool::EditHandlePtr returnValue(
639 new SFBool::EditHandle(
640 &_sfFocusOnCamera,
641 this->getType().getFieldDesc(FocusOnCameraFieldId),
642 this));
645 editSField(FocusOnCameraFieldMask);
647 return returnValue;
650 GetFieldHandlePtr BillboardBase::getHandleAlignToScreen (void) const
652 SFBool::GetHandlePtr returnValue(
653 new SFBool::GetHandle(
654 &_sfAlignToScreen,
655 this->getType().getFieldDesc(AlignToScreenFieldId),
656 const_cast<BillboardBase *>(this)));
658 return returnValue;
661 EditFieldHandlePtr BillboardBase::editHandleAlignToScreen (void)
663 SFBool::EditHandlePtr returnValue(
664 new SFBool::EditHandle(
665 &_sfAlignToScreen,
666 this->getType().getFieldDesc(AlignToScreenFieldId),
667 this));
670 editSField(AlignToScreenFieldMask);
672 return returnValue;
675 GetFieldHandlePtr BillboardBase::getHandleMinAngle (void) const
677 SFReal32::GetHandlePtr returnValue(
678 new SFReal32::GetHandle(
679 &_sfMinAngle,
680 this->getType().getFieldDesc(MinAngleFieldId),
681 const_cast<BillboardBase *>(this)));
683 return returnValue;
686 EditFieldHandlePtr BillboardBase::editHandleMinAngle (void)
688 SFReal32::EditHandlePtr returnValue(
689 new SFReal32::EditHandle(
690 &_sfMinAngle,
691 this->getType().getFieldDesc(MinAngleFieldId),
692 this));
695 editSField(MinAngleFieldMask);
697 return returnValue;
700 GetFieldHandlePtr BillboardBase::getHandleMaxAngle (void) const
702 SFReal32::GetHandlePtr returnValue(
703 new SFReal32::GetHandle(
704 &_sfMaxAngle,
705 this->getType().getFieldDesc(MaxAngleFieldId),
706 const_cast<BillboardBase *>(this)));
708 return returnValue;
711 EditFieldHandlePtr BillboardBase::editHandleMaxAngle (void)
713 SFReal32::EditHandlePtr returnValue(
714 new SFReal32::EditHandle(
715 &_sfMaxAngle,
716 this->getType().getFieldDesc(MaxAngleFieldId),
717 this));
720 editSField(MaxAngleFieldMask);
722 return returnValue;
726 #ifdef OSG_MT_CPTR_ASPECT
727 void BillboardBase::execSyncV( FieldContainer &oFrom,
728 ConstFieldMaskArg whichField,
729 AspectOffsetStore &oOffsets,
730 ConstFieldMaskArg syncMode,
731 const UInt32 uiSyncInfo)
733 Billboard *pThis = static_cast<Billboard *>(this);
735 pThis->execSync(static_cast<Billboard *>(&oFrom),
736 whichField,
737 oOffsets,
738 syncMode,
739 uiSyncInfo);
741 #endif
744 #ifdef OSG_MT_CPTR_ASPECT
745 FieldContainer *BillboardBase::createAspectCopy(
746 const FieldContainer *pRefAspect) const
748 Billboard *returnValue;
750 newAspectCopy(returnValue,
751 dynamic_cast<const Billboard *>(pRefAspect),
752 dynamic_cast<const Billboard *>(this));
754 return returnValue;
756 #endif
758 void BillboardBase::resolveLinks(void)
760 Inherited::resolveLinks();
766 OSG_END_NAMESPACE