fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Groups / Misc / OSGScreenLODBase.cpp
blobccf31b9cca3b117aef0d05acc69d61200687aae3
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 ScreenLOD!
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 "OSGScreenLODBase.h"
67 #include "OSGScreenLOD.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::ScreenLOD
78 A ScreenLOD node enables smart LOD selection based on screen size. It must
79 be used in combination with the RenderTraversal Action.
81 See Ref:ScreenLOD
84 /***************************************************************************\
85 * Field Documentation *
86 \***************************************************************************/
88 /*! \var Real32 ScreenLODBase::_mfCoverageOverride
89 A list of percentages to override the default LOD behavior. These
90 percentages are used to determine which lod to use based on screen size
91 percentage. If the percentage covered by the node bounding volume is less
92 then entry 0, we use child 0. If is is greater then entry 0 less then
93 entry 1, then we use child 1 and so on. Ex: [0.05, 0.01, 0.001]
97 /***************************************************************************\
98 * FieldType/FieldTrait Instantiation *
99 \***************************************************************************/
101 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
102 PointerType FieldTraits<ScreenLOD *, nsOSG>::_type(
103 "ScreenLODPtr",
104 "GroupPtr",
105 ScreenLOD::getClassType(),
106 nsOSG);
107 #endif
109 OSG_FIELDTRAITS_GETTYPE_NS(ScreenLOD *, nsOSG)
111 /***************************************************************************\
112 * Field Description *
113 \***************************************************************************/
115 void ScreenLODBase::classDescInserter(TypeObject &oType)
117 FieldDescriptionBase *pDesc = NULL;
120 pDesc = new MFReal32::Description(
121 MFReal32::getClassType(),
122 "coverageOverride",
123 "A list of percentages to override the default LOD behavior. These\n"
124 "percentages are used to determine which lod to use based on screen size\n"
125 "percentage. If the percentage covered by the node bounding volume is less\n"
126 "then entry 0, we use child 0. If is is greater then entry 0 less then\n"
127 "entry 1, then we use child 1 and so on. Ex: [0.05, 0.01, 0.001]\n",
128 CoverageOverrideFieldId, CoverageOverrideFieldMask,
129 false,
130 (Field::MFDefaultFlags | Field::FStdAccess),
131 static_cast<FieldEditMethodSig>(&ScreenLOD::editHandleCoverageOverride),
132 static_cast<FieldGetMethodSig >(&ScreenLOD::getHandleCoverageOverride));
134 oType.addInitialDesc(pDesc);
138 ScreenLODBase::TypeObject ScreenLODBase::_type(
139 ScreenLODBase::getClassname(),
140 Inherited::getClassname(),
141 "NULL",
142 nsOSG, //Namespace
143 reinterpret_cast<PrototypeCreateF>(&ScreenLODBase::createEmptyLocal),
144 reinterpret_cast<InitContainerF>(&ScreenLOD::initMethod),
145 reinterpret_cast<ExitContainerF>(&ScreenLOD::exitMethod),
146 reinterpret_cast<InitalInsertDescFunc>(
147 reinterpret_cast<void *>(&ScreenLOD::classDescInserter)),
148 false,
150 "<?xml version=\"1.0\"?>\n"
151 "\n"
152 "<FieldContainer\n"
153 " name=\"ScreenLOD\"\n"
154 " parent=\"Group\"\n"
155 " library=\"Group\"\n"
156 " pointerfieldtypes=\"none\"\n"
157 " structure=\"concrete\"\n"
158 " systemcomponent=\"true\"\n"
159 " parentsystemcomponent=\"true\"\n"
160 " isNodeCore=\"true\"\n"
161 " docGroupBase=\"GrpGroupMisc\"\n"
162 " >\n"
163 " A ScreenLOD node enables smart LOD selection based on screen size. It must\n"
164 " be used in combination with the RenderTraversal Action.\n"
165 "\n"
166 " See Ref:ScreenLOD\n"
167 " <Field\n"
168 "\t name=\"coverageOverride\"\n"
169 "\t type=\"Real32\"\n"
170 "\t cardinality=\"multi\"\n"
171 "\t visibility=\"external\"\n"
172 "\t access=\"public\"\n"
173 "\t >\n"
174 "\tA list of percentages to override the default LOD behavior. These\n"
175 "\tpercentages are used to determine which lod to use based on screen size\n"
176 "\tpercentage. If the percentage covered by the node bounding volume is less\n"
177 "\tthen entry 0, we use child 0. If is is greater then entry 0 less then\n"
178 "\tentry 1, then we use child 1 and so on. Ex: [0.05, 0.01, 0.001]\n"
179 " </Field>\n"
180 "</FieldContainer>\n",
181 "A ScreenLOD node enables smart LOD selection based on screen size. It must\n"
182 "be used in combination with the RenderTraversal Action.\n"
183 "\n"
184 "See Ref:ScreenLOD\n"
187 /*------------------------------ get -----------------------------------*/
189 FieldContainerType &ScreenLODBase::getType(void)
191 return _type;
194 const FieldContainerType &ScreenLODBase::getType(void) const
196 return _type;
199 UInt32 ScreenLODBase::getContainerSize(void) const
201 return sizeof(ScreenLOD);
204 /*------------------------- decorator get ------------------------------*/
207 MFReal32 *ScreenLODBase::editMFCoverageOverride(void)
209 editMField(CoverageOverrideFieldMask, _mfCoverageOverride);
211 return &_mfCoverageOverride;
214 const MFReal32 *ScreenLODBase::getMFCoverageOverride(void) const
216 return &_mfCoverageOverride;
224 /*------------------------------ access -----------------------------------*/
226 SizeT ScreenLODBase::getBinSize(ConstFieldMaskArg whichField)
228 SizeT returnValue = Inherited::getBinSize(whichField);
230 if(FieldBits::NoField != (CoverageOverrideFieldMask & whichField))
232 returnValue += _mfCoverageOverride.getBinSize();
235 return returnValue;
238 void ScreenLODBase::copyToBin(BinaryDataHandler &pMem,
239 ConstFieldMaskArg whichField)
241 Inherited::copyToBin(pMem, whichField);
243 if(FieldBits::NoField != (CoverageOverrideFieldMask & whichField))
245 _mfCoverageOverride.copyToBin(pMem);
249 void ScreenLODBase::copyFromBin(BinaryDataHandler &pMem,
250 ConstFieldMaskArg whichField)
252 Inherited::copyFromBin(pMem, whichField);
254 if(FieldBits::NoField != (CoverageOverrideFieldMask & whichField))
256 editMField(CoverageOverrideFieldMask, _mfCoverageOverride);
257 _mfCoverageOverride.copyFromBin(pMem);
261 //! create a new instance of the class
262 ScreenLODTransitPtr ScreenLODBase::createLocal(BitVector bFlags)
264 ScreenLODTransitPtr fc;
266 if(getClassType().getPrototype() != NULL)
268 FieldContainerTransitPtr tmpPtr =
269 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
271 fc = dynamic_pointer_cast<ScreenLOD>(tmpPtr);
274 return fc;
277 //! create a new instance of the class, copy the container flags
278 ScreenLODTransitPtr ScreenLODBase::createDependent(BitVector bFlags)
280 ScreenLODTransitPtr fc;
282 if(getClassType().getPrototype() != NULL)
284 FieldContainerTransitPtr tmpPtr =
285 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
287 fc = dynamic_pointer_cast<ScreenLOD>(tmpPtr);
290 return fc;
293 //! create a new instance of the class
294 ScreenLODTransitPtr ScreenLODBase::create(void)
296 ScreenLODTransitPtr fc;
298 if(getClassType().getPrototype() != NULL)
300 FieldContainerTransitPtr tmpPtr =
301 getClassType().getPrototype()-> shallowCopy();
303 fc = dynamic_pointer_cast<ScreenLOD>(tmpPtr);
306 return fc;
309 ScreenLOD *ScreenLODBase::createEmptyLocal(BitVector bFlags)
311 ScreenLOD *returnValue;
313 newPtr<ScreenLOD>(returnValue, bFlags);
315 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
317 return returnValue;
320 //! create an empty new instance of the class, do not copy the prototype
321 ScreenLOD *ScreenLODBase::createEmpty(void)
323 ScreenLOD *returnValue;
325 newPtr<ScreenLOD>(returnValue, Thread::getCurrentLocalFlags());
327 returnValue->_pFieldFlags->_bNamespaceMask &=
328 ~Thread::getCurrentLocalFlags();
330 return returnValue;
334 FieldContainerTransitPtr ScreenLODBase::shallowCopyLocal(
335 BitVector bFlags) const
337 ScreenLOD *tmpPtr;
339 newPtr(tmpPtr, dynamic_cast<const ScreenLOD *>(this), bFlags);
341 FieldContainerTransitPtr returnValue(tmpPtr);
343 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
345 return returnValue;
348 FieldContainerTransitPtr ScreenLODBase::shallowCopyDependent(
349 BitVector bFlags) const
351 ScreenLOD *tmpPtr;
353 newPtr(tmpPtr, dynamic_cast<const ScreenLOD *>(this), ~bFlags);
355 FieldContainerTransitPtr returnValue(tmpPtr);
357 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
359 return returnValue;
362 FieldContainerTransitPtr ScreenLODBase::shallowCopy(void) const
364 ScreenLOD *tmpPtr;
366 newPtr(tmpPtr,
367 dynamic_cast<const ScreenLOD *>(this),
368 Thread::getCurrentLocalFlags());
370 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
372 FieldContainerTransitPtr returnValue(tmpPtr);
374 return returnValue;
380 /*------------------------- constructors ----------------------------------*/
382 ScreenLODBase::ScreenLODBase(void) :
383 Inherited(),
384 _mfCoverageOverride ()
388 ScreenLODBase::ScreenLODBase(const ScreenLODBase &source) :
389 Inherited(source),
390 _mfCoverageOverride (source._mfCoverageOverride )
395 /*-------------------------- destructors ----------------------------------*/
397 ScreenLODBase::~ScreenLODBase(void)
402 GetFieldHandlePtr ScreenLODBase::getHandleCoverageOverride (void) const
404 MFReal32::GetHandlePtr returnValue(
405 new MFReal32::GetHandle(
406 &_mfCoverageOverride,
407 this->getType().getFieldDesc(CoverageOverrideFieldId),
408 const_cast<ScreenLODBase *>(this)));
410 return returnValue;
413 EditFieldHandlePtr ScreenLODBase::editHandleCoverageOverride(void)
415 MFReal32::EditHandlePtr returnValue(
416 new MFReal32::EditHandle(
417 &_mfCoverageOverride,
418 this->getType().getFieldDesc(CoverageOverrideFieldId),
419 this));
422 editMField(CoverageOverrideFieldMask, _mfCoverageOverride);
424 return returnValue;
428 #ifdef OSG_MT_CPTR_ASPECT
429 void ScreenLODBase::execSyncV( FieldContainer &oFrom,
430 ConstFieldMaskArg whichField,
431 AspectOffsetStore &oOffsets,
432 ConstFieldMaskArg syncMode,
433 const UInt32 uiSyncInfo)
435 ScreenLOD *pThis = static_cast<ScreenLOD *>(this);
437 pThis->execSync(static_cast<ScreenLOD *>(&oFrom),
438 whichField,
439 oOffsets,
440 syncMode,
441 uiSyncInfo);
443 #endif
446 #ifdef OSG_MT_CPTR_ASPECT
447 FieldContainer *ScreenLODBase::createAspectCopy(
448 const FieldContainer *pRefAspect) const
450 ScreenLOD *returnValue;
452 newAspectCopy(returnValue,
453 dynamic_cast<const ScreenLOD *>(pRefAspect),
454 dynamic_cast<const ScreenLOD *>(this));
456 return returnValue;
458 #endif
460 void ScreenLODBase::resolveLinks(void)
462 Inherited::resolveLinks();
464 #ifdef OSG_MT_CPTR_ASPECT
465 AspectOffsetStore oOffsets;
467 _pAspectStore->fillOffsetArray(oOffsets, this);
468 #endif
470 #ifdef OSG_MT_CPTR_ASPECT
471 _mfCoverageOverride.terminateShare(Thread::getCurrentAspect(),
472 oOffsets);
473 #endif
477 OSG_END_NAMESPACE