fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Groups / Light / OSGPointLightBase.cpp
blob0484c205edac306bac1b3bb7036c50c55be5e39a
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 PointLight!
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 "OSGPointLightBase.h"
67 #include "OSGPointLight.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::PointLight
78 PointLight is a located lightsource. The position of the light source
79 (in the beacon's coordinate system) is defined by the \c position
80 attribute. The influence of the light diminishes with distance, controlled
81 by the \c constantAttenuation, \c linearAttenuation and \c
82 quadraticAttenuation attributes.
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var Pnt3f PointLightBase::_sfPosition
94 /***************************************************************************\
95 * FieldType/FieldTrait Instantiation *
96 \***************************************************************************/
98 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
99 PointerType FieldTraits<PointLight *, nsOSG>::_type(
100 "PointLightPtr",
101 "LightPtr",
102 PointLight::getClassType(),
103 nsOSG);
104 #endif
106 OSG_FIELDTRAITS_GETTYPE_NS(PointLight *, nsOSG)
108 /***************************************************************************\
109 * Field Description *
110 \***************************************************************************/
112 void PointLightBase::classDescInserter(TypeObject &oType)
114 FieldDescriptionBase *pDesc = NULL;
117 pDesc = new SFPnt3f::Description(
118 SFPnt3f::getClassType(),
119 "position",
121 PositionFieldId, PositionFieldMask,
122 false,
123 (Field::SFDefaultFlags | Field::FStdAccess),
124 static_cast<FieldEditMethodSig>(&PointLight::editHandlePosition),
125 static_cast<FieldGetMethodSig >(&PointLight::getHandlePosition));
127 oType.addInitialDesc(pDesc);
131 PointLightBase::TypeObject PointLightBase::_type(
132 PointLightBase::getClassname(),
133 Inherited::getClassname(),
134 "NULL",
135 nsOSG, //Namespace
136 reinterpret_cast<PrototypeCreateF>(&PointLightBase::createEmptyLocal),
137 reinterpret_cast<InitContainerF>(&PointLight::initMethod),
138 reinterpret_cast<ExitContainerF>(&PointLight::exitMethod),
139 reinterpret_cast<InitalInsertDescFunc>(
140 reinterpret_cast<void *>(&PointLight::classDescInserter)),
141 false,
143 "<?xml version=\"1.0\" ?>\n"
144 "\n"
145 "<FieldContainer\n"
146 " name=\"PointLight\"\n"
147 " parent=\"Light\"\n"
148 " library=\"Group\"\n"
149 " structure=\"concrete\"\n"
150 " pointerfieldtypes=\"none\"\n"
151 " systemcomponent=\"true\"\n"
152 " parentsystemcomponent=\"true\"\n"
153 " isNodeCore=\"true\"\n"
154 " docGroupBase=\"GrpGroupLight\"\n"
155 " >\n"
156 " PointLight is a located lightsource. The position of the light source\n"
157 " (in the beacon's coordinate system) is defined by the \\c position\n"
158 " attribute. The influence of the light diminishes with distance, controlled\n"
159 " by the \\c constantAttenuation, \\c linearAttenuation and \\c\n"
160 " quadraticAttenuation attributes.\n"
161 " <Field\n"
162 "\t name=\"position\"\n"
163 "\t type=\"Pnt3f\"\n"
164 "\t cardinality=\"single\"\n"
165 "\t visibility=\"external\"\n"
166 " defaultValue=\"0.f,0.f,0.f\"\n"
167 "\t >\n"
168 " </Field>\n"
169 "</FieldContainer>\n",
170 "PointLight is a located lightsource. The position of the light source\n"
171 "(in the beacon's coordinate system) is defined by the \\c position\n"
172 "attribute. The influence of the light diminishes with distance, controlled\n"
173 "by the \\c constantAttenuation, \\c linearAttenuation and \\c\n"
174 "quadraticAttenuation attributes.\n"
177 /*------------------------------ get -----------------------------------*/
179 FieldContainerType &PointLightBase::getType(void)
181 return _type;
184 const FieldContainerType &PointLightBase::getType(void) const
186 return _type;
189 UInt32 PointLightBase::getContainerSize(void) const
191 return sizeof(PointLight);
194 /*------------------------- decorator get ------------------------------*/
197 SFPnt3f *PointLightBase::editSFPosition(void)
199 editSField(PositionFieldMask);
201 return &_sfPosition;
204 const SFPnt3f *PointLightBase::getSFPosition(void) const
206 return &_sfPosition;
214 /*------------------------------ access -----------------------------------*/
216 SizeT PointLightBase::getBinSize(ConstFieldMaskArg whichField)
218 SizeT returnValue = Inherited::getBinSize(whichField);
220 if(FieldBits::NoField != (PositionFieldMask & whichField))
222 returnValue += _sfPosition.getBinSize();
225 return returnValue;
228 void PointLightBase::copyToBin(BinaryDataHandler &pMem,
229 ConstFieldMaskArg whichField)
231 Inherited::copyToBin(pMem, whichField);
233 if(FieldBits::NoField != (PositionFieldMask & whichField))
235 _sfPosition.copyToBin(pMem);
239 void PointLightBase::copyFromBin(BinaryDataHandler &pMem,
240 ConstFieldMaskArg whichField)
242 Inherited::copyFromBin(pMem, whichField);
244 if(FieldBits::NoField != (PositionFieldMask & whichField))
246 editSField(PositionFieldMask);
247 _sfPosition.copyFromBin(pMem);
251 //! create a new instance of the class
252 PointLightTransitPtr PointLightBase::createLocal(BitVector bFlags)
254 PointLightTransitPtr fc;
256 if(getClassType().getPrototype() != NULL)
258 FieldContainerTransitPtr tmpPtr =
259 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
261 fc = dynamic_pointer_cast<PointLight>(tmpPtr);
264 return fc;
267 //! create a new instance of the class, copy the container flags
268 PointLightTransitPtr PointLightBase::createDependent(BitVector bFlags)
270 PointLightTransitPtr fc;
272 if(getClassType().getPrototype() != NULL)
274 FieldContainerTransitPtr tmpPtr =
275 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
277 fc = dynamic_pointer_cast<PointLight>(tmpPtr);
280 return fc;
283 //! create a new instance of the class
284 PointLightTransitPtr PointLightBase::create(void)
286 PointLightTransitPtr fc;
288 if(getClassType().getPrototype() != NULL)
290 FieldContainerTransitPtr tmpPtr =
291 getClassType().getPrototype()-> shallowCopy();
293 fc = dynamic_pointer_cast<PointLight>(tmpPtr);
296 return fc;
299 PointLight *PointLightBase::createEmptyLocal(BitVector bFlags)
301 PointLight *returnValue;
303 newPtr<PointLight>(returnValue, bFlags);
305 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
307 return returnValue;
310 //! create an empty new instance of the class, do not copy the prototype
311 PointLight *PointLightBase::createEmpty(void)
313 PointLight *returnValue;
315 newPtr<PointLight>(returnValue, Thread::getCurrentLocalFlags());
317 returnValue->_pFieldFlags->_bNamespaceMask &=
318 ~Thread::getCurrentLocalFlags();
320 return returnValue;
324 FieldContainerTransitPtr PointLightBase::shallowCopyLocal(
325 BitVector bFlags) const
327 PointLight *tmpPtr;
329 newPtr(tmpPtr, dynamic_cast<const PointLight *>(this), bFlags);
331 FieldContainerTransitPtr returnValue(tmpPtr);
333 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
335 return returnValue;
338 FieldContainerTransitPtr PointLightBase::shallowCopyDependent(
339 BitVector bFlags) const
341 PointLight *tmpPtr;
343 newPtr(tmpPtr, dynamic_cast<const PointLight *>(this), ~bFlags);
345 FieldContainerTransitPtr returnValue(tmpPtr);
347 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
349 return returnValue;
352 FieldContainerTransitPtr PointLightBase::shallowCopy(void) const
354 PointLight *tmpPtr;
356 newPtr(tmpPtr,
357 dynamic_cast<const PointLight *>(this),
358 Thread::getCurrentLocalFlags());
360 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
362 FieldContainerTransitPtr returnValue(tmpPtr);
364 return returnValue;
370 /*------------------------- constructors ----------------------------------*/
372 PointLightBase::PointLightBase(void) :
373 Inherited(),
374 _sfPosition (Pnt3f(0.f,0.f,0.f))
378 PointLightBase::PointLightBase(const PointLightBase &source) :
379 Inherited(source),
380 _sfPosition (source._sfPosition )
385 /*-------------------------- destructors ----------------------------------*/
387 PointLightBase::~PointLightBase(void)
392 GetFieldHandlePtr PointLightBase::getHandlePosition (void) const
394 SFPnt3f::GetHandlePtr returnValue(
395 new SFPnt3f::GetHandle(
396 &_sfPosition,
397 this->getType().getFieldDesc(PositionFieldId),
398 const_cast<PointLightBase *>(this)));
400 return returnValue;
403 EditFieldHandlePtr PointLightBase::editHandlePosition (void)
405 SFPnt3f::EditHandlePtr returnValue(
406 new SFPnt3f::EditHandle(
407 &_sfPosition,
408 this->getType().getFieldDesc(PositionFieldId),
409 this));
412 editSField(PositionFieldMask);
414 return returnValue;
418 #ifdef OSG_MT_CPTR_ASPECT
419 void PointLightBase::execSyncV( FieldContainer &oFrom,
420 ConstFieldMaskArg whichField,
421 AspectOffsetStore &oOffsets,
422 ConstFieldMaskArg syncMode,
423 const UInt32 uiSyncInfo)
425 PointLight *pThis = static_cast<PointLight *>(this);
427 pThis->execSync(static_cast<PointLight *>(&oFrom),
428 whichField,
429 oOffsets,
430 syncMode,
431 uiSyncInfo);
433 #endif
436 #ifdef OSG_MT_CPTR_ASPECT
437 FieldContainer *PointLightBase::createAspectCopy(
438 const FieldContainer *pRefAspect) const
440 PointLight *returnValue;
442 newAspectCopy(returnValue,
443 dynamic_cast<const PointLight *>(pRefAspect),
444 dynamic_cast<const PointLight *>(this));
446 return returnValue;
448 #endif
450 void PointLightBase::resolveLinks(void)
452 Inherited::resolveLinks();
458 OSG_END_NAMESPACE