fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / OpenGL / OSGClipPlaneChunkBase.cpp
blobe44d87f6d3d65dad70fd62776369908cd7138a95
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 ClipPlaneChunk!
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"
64 #include "OSGGL.h" // Enable default header
66 #include "OSGNode.h" // Beacon Class
68 #include "OSGClipPlaneChunkBase.h"
69 #include "OSGClipPlaneChunk.h"
71 #include <boost/bind.hpp>
73 OSG_BEGIN_NAMESPACE
75 /***************************************************************************\
76 * Description *
77 \***************************************************************************/
79 /*! \class OSG::ClipPlaneChunk
80 See \ref PageSystemClipPlaneChunk for a description.
82 This chunk wraps glCLipPlane() (OSG::ClipPlaneChunk::_sfEquation) and
83 glEnable(GL_CLIP_PLANEi) (OSG::ClipPlaneChunk::_sfEnable). The coordinate
84 system the plane is in is defined by OSG::ClipPlaneChunk::_sfBeacon.
87 /***************************************************************************\
88 * Field Documentation *
89 \***************************************************************************/
91 /*! \var Vec4f ClipPlaneChunkBase::_sfEquation
92 Defines the equation of the clip plane. Standard format, if (a,b,c,d) is
93 the plane a point (x,y,z) is visible if a*x+b*y+c*z+d "= 0.
96 /*! \var bool ClipPlaneChunkBase::_sfEnable
97 Defines activation state of the clip plane.
100 /*! \var Node * ClipPlaneChunkBase::_sfBeacon
101 The object that defines the clip planes's coordinate system. The clip
102 plane is positioned relative to this system.
106 /***************************************************************************\
107 * FieldType/FieldTrait Instantiation *
108 \***************************************************************************/
110 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
111 PointerType FieldTraits<ClipPlaneChunk *, nsOSG>::_type(
112 "ClipPlaneChunkPtr",
113 "StateChunkPtr",
114 ClipPlaneChunk::getClassType(),
115 nsOSG);
116 #endif
118 OSG_FIELDTRAITS_GETTYPE_NS(ClipPlaneChunk *, nsOSG)
120 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
121 ClipPlaneChunk *,
122 nsOSG)
124 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
125 ClipPlaneChunk *,
126 nsOSG)
128 /***************************************************************************\
129 * Field Description *
130 \***************************************************************************/
132 void ClipPlaneChunkBase::classDescInserter(TypeObject &oType)
134 FieldDescriptionBase *pDesc = NULL;
137 pDesc = new SFVec4f::Description(
138 SFVec4f::getClassType(),
139 "equation",
140 "Defines the equation of the clip plane. Standard format, if (a,b,c,d) is\n"
141 "the plane a point (x,y,z) is visible if a*x+b*y+c*z+d \"= 0.\n",
142 EquationFieldId, EquationFieldMask,
143 false,
144 (Field::SFDefaultFlags | Field::FStdAccess),
145 static_cast<FieldEditMethodSig>(&ClipPlaneChunk::editHandleEquation),
146 static_cast<FieldGetMethodSig >(&ClipPlaneChunk::getHandleEquation));
148 oType.addInitialDesc(pDesc);
150 pDesc = new SFBool::Description(
151 SFBool::getClassType(),
152 "enable",
153 "Defines activation state of the clip plane.\n",
154 EnableFieldId, EnableFieldMask,
155 false,
156 (Field::SFDefaultFlags | Field::FStdAccess),
157 static_cast<FieldEditMethodSig>(&ClipPlaneChunk::editHandleEnable),
158 static_cast<FieldGetMethodSig >(&ClipPlaneChunk::getHandleEnable));
160 oType.addInitialDesc(pDesc);
162 pDesc = new SFWeakNodePtr::Description(
163 SFWeakNodePtr::getClassType(),
164 "beacon",
165 "The object that defines the clip planes's coordinate system. The clip\n"
166 "plane is positioned relative to this system.\n",
167 BeaconFieldId, BeaconFieldMask,
168 false,
169 (Field::SFDefaultFlags | Field::FStdAccess),
170 static_cast<FieldEditMethodSig>(&ClipPlaneChunk::editHandleBeacon),
171 static_cast<FieldGetMethodSig >(&ClipPlaneChunk::getHandleBeacon));
173 oType.addInitialDesc(pDesc);
177 ClipPlaneChunkBase::TypeObject ClipPlaneChunkBase::_type(
178 ClipPlaneChunkBase::getClassname(),
179 Inherited::getClassname(),
180 "NULL",
181 nsOSG, //Namespace
182 reinterpret_cast<PrototypeCreateF>(&ClipPlaneChunkBase::createEmptyLocal),
183 reinterpret_cast<InitContainerF>(&ClipPlaneChunk::initMethod),
184 reinterpret_cast<ExitContainerF>(&ClipPlaneChunk::exitMethod),
185 reinterpret_cast<InitalInsertDescFunc>(
186 reinterpret_cast<void *>(&ClipPlaneChunk::classDescInserter)),
187 false,
189 "<?xml version=\"1.0\"?>\n"
190 "\n"
191 "<FieldContainer\n"
192 " name=\"ClipPlaneChunk\"\n"
193 " parent=\"StateChunk\"\n"
194 " library=\"State\"\n"
195 " pointerfieldtypes=\"both\"\n"
196 " structure=\"concrete\"\n"
197 " systemcomponent=\"true\"\n"
198 " parentsystemcomponent=\"true\"\n"
199 " decoratable=\"false\"\n"
200 " docGroupBase=\"GrpStateOpenGL\"\n"
201 " >\n"
202 " See \\ref PageSystemClipPlaneChunk for a description.\n"
203 "\n"
204 " This chunk wraps glCLipPlane() (OSG::ClipPlaneChunk::_sfEquation) and\n"
205 " glEnable(GL_CLIP_PLANEi) (OSG::ClipPlaneChunk::_sfEnable). The coordinate\n"
206 " system the plane is in is defined by OSG::ClipPlaneChunk::_sfBeacon.\n"
207 " <Field\n"
208 "\t name=\"equation\"\n"
209 "\t type=\"Vec4f\"\n"
210 "\t cardinality=\"single\"\n"
211 "\t visibility=\"external\"\n"
212 "\t defaultValue=\"0, 0, 1, 0\"\n"
213 "\t access=\"public\"\n"
214 "\t >\n"
215 "\tDefines the equation of the clip plane. Standard format, if (a,b,c,d) is\n"
216 " the plane a point (x,y,z) is visible if a*x+b*y+c*z+d &quot;= 0.\n"
217 " </Field>\n"
218 " <Field\n"
219 "\t name=\"enable\"\n"
220 "\t type=\"bool\"\n"
221 "\t cardinality=\"single\"\n"
222 "\t visibility=\"external\"\n"
223 "\t defaultValue=\"GL_TRUE\"\n"
224 "\t defaultHeader=\"&quot;OSGGL.h&quot;\"\n"
225 "\t access=\"public\"\n"
226 "\t >\n"
227 "\tDefines activation state of the clip plane.\n"
228 " </Field>\n"
229 " <Field\n"
230 "\t name=\"beacon\"\n"
231 "\t type=\"Node\"\n"
232 " category=\"weakpointer\"\n"
233 "\t cardinality=\"single\"\n"
234 "\t visibility=\"external\"\n"
235 "\t defaultValue=\"NULL\"\n"
236 "\t access=\"public\"\n"
237 "\t >\n"
238 " The object that defines the clip planes's coordinate system. The clip\n"
239 " plane is positioned relative to this system.\n"
240 " </Field>\n"
241 "</FieldContainer>\n",
242 "See \\ref PageSystemClipPlaneChunk for a description.\n"
243 "\n"
244 "This chunk wraps glCLipPlane() (OSG::ClipPlaneChunk::_sfEquation) and\n"
245 "glEnable(GL_CLIP_PLANEi) (OSG::ClipPlaneChunk::_sfEnable). The coordinate\n"
246 "system the plane is in is defined by OSG::ClipPlaneChunk::_sfBeacon.\n"
249 /*------------------------------ get -----------------------------------*/
251 FieldContainerType &ClipPlaneChunkBase::getType(void)
253 return _type;
256 const FieldContainerType &ClipPlaneChunkBase::getType(void) const
258 return _type;
261 UInt32 ClipPlaneChunkBase::getContainerSize(void) const
263 return sizeof(ClipPlaneChunk);
266 /*------------------------- decorator get ------------------------------*/
269 SFVec4f *ClipPlaneChunkBase::editSFEquation(void)
271 editSField(EquationFieldMask);
273 return &_sfEquation;
276 const SFVec4f *ClipPlaneChunkBase::getSFEquation(void) const
278 return &_sfEquation;
282 SFBool *ClipPlaneChunkBase::editSFEnable(void)
284 editSField(EnableFieldMask);
286 return &_sfEnable;
289 const SFBool *ClipPlaneChunkBase::getSFEnable(void) const
291 return &_sfEnable;
295 //! Get the ClipPlaneChunk::_sfBeacon field.
296 const SFWeakNodePtr *ClipPlaneChunkBase::getSFBeacon(void) const
298 return &_sfBeacon;
301 SFWeakNodePtr *ClipPlaneChunkBase::editSFBeacon (void)
303 editSField(BeaconFieldMask);
305 return &_sfBeacon;
308 //! Get the value of the ClipPlaneChunk::_sfBeacon field.
309 Node * ClipPlaneChunkBase::getBeacon(void) const
311 return _sfBeacon.getValue();
314 //! Set the value of the ClipPlaneChunk::_sfBeacon field.
315 void ClipPlaneChunkBase::setBeacon(Node * const value)
317 editSField(BeaconFieldMask);
319 _sfBeacon.setValue(value);
327 /*------------------------------ access -----------------------------------*/
329 SizeT ClipPlaneChunkBase::getBinSize(ConstFieldMaskArg whichField)
331 SizeT returnValue = Inherited::getBinSize(whichField);
333 if(FieldBits::NoField != (EquationFieldMask & whichField))
335 returnValue += _sfEquation.getBinSize();
337 if(FieldBits::NoField != (EnableFieldMask & whichField))
339 returnValue += _sfEnable.getBinSize();
341 if(FieldBits::NoField != (BeaconFieldMask & whichField))
343 returnValue += _sfBeacon.getBinSize();
346 return returnValue;
349 void ClipPlaneChunkBase::copyToBin(BinaryDataHandler &pMem,
350 ConstFieldMaskArg whichField)
352 Inherited::copyToBin(pMem, whichField);
354 if(FieldBits::NoField != (EquationFieldMask & whichField))
356 _sfEquation.copyToBin(pMem);
358 if(FieldBits::NoField != (EnableFieldMask & whichField))
360 _sfEnable.copyToBin(pMem);
362 if(FieldBits::NoField != (BeaconFieldMask & whichField))
364 _sfBeacon.copyToBin(pMem);
368 void ClipPlaneChunkBase::copyFromBin(BinaryDataHandler &pMem,
369 ConstFieldMaskArg whichField)
371 Inherited::copyFromBin(pMem, whichField);
373 if(FieldBits::NoField != (EquationFieldMask & whichField))
375 editSField(EquationFieldMask);
376 _sfEquation.copyFromBin(pMem);
378 if(FieldBits::NoField != (EnableFieldMask & whichField))
380 editSField(EnableFieldMask);
381 _sfEnable.copyFromBin(pMem);
383 if(FieldBits::NoField != (BeaconFieldMask & whichField))
385 editSField(BeaconFieldMask);
386 _sfBeacon.copyFromBin(pMem);
390 //! create a new instance of the class
391 ClipPlaneChunkTransitPtr ClipPlaneChunkBase::createLocal(BitVector bFlags)
393 ClipPlaneChunkTransitPtr fc;
395 if(getClassType().getPrototype() != NULL)
397 FieldContainerTransitPtr tmpPtr =
398 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
400 fc = dynamic_pointer_cast<ClipPlaneChunk>(tmpPtr);
403 return fc;
406 //! create a new instance of the class, copy the container flags
407 ClipPlaneChunkTransitPtr ClipPlaneChunkBase::createDependent(BitVector bFlags)
409 ClipPlaneChunkTransitPtr fc;
411 if(getClassType().getPrototype() != NULL)
413 FieldContainerTransitPtr tmpPtr =
414 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
416 fc = dynamic_pointer_cast<ClipPlaneChunk>(tmpPtr);
419 return fc;
422 //! create a new instance of the class
423 ClipPlaneChunkTransitPtr ClipPlaneChunkBase::create(void)
425 ClipPlaneChunkTransitPtr fc;
427 if(getClassType().getPrototype() != NULL)
429 FieldContainerTransitPtr tmpPtr =
430 getClassType().getPrototype()-> shallowCopy();
432 fc = dynamic_pointer_cast<ClipPlaneChunk>(tmpPtr);
435 return fc;
438 ClipPlaneChunk *ClipPlaneChunkBase::createEmptyLocal(BitVector bFlags)
440 ClipPlaneChunk *returnValue;
442 newPtr<ClipPlaneChunk>(returnValue, bFlags);
444 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
446 return returnValue;
449 //! create an empty new instance of the class, do not copy the prototype
450 ClipPlaneChunk *ClipPlaneChunkBase::createEmpty(void)
452 ClipPlaneChunk *returnValue;
454 newPtr<ClipPlaneChunk>(returnValue, Thread::getCurrentLocalFlags());
456 returnValue->_pFieldFlags->_bNamespaceMask &=
457 ~Thread::getCurrentLocalFlags();
459 return returnValue;
463 FieldContainerTransitPtr ClipPlaneChunkBase::shallowCopyLocal(
464 BitVector bFlags) const
466 ClipPlaneChunk *tmpPtr;
468 newPtr(tmpPtr, dynamic_cast<const ClipPlaneChunk *>(this), bFlags);
470 FieldContainerTransitPtr returnValue(tmpPtr);
472 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
474 return returnValue;
477 FieldContainerTransitPtr ClipPlaneChunkBase::shallowCopyDependent(
478 BitVector bFlags) const
480 ClipPlaneChunk *tmpPtr;
482 newPtr(tmpPtr, dynamic_cast<const ClipPlaneChunk *>(this), ~bFlags);
484 FieldContainerTransitPtr returnValue(tmpPtr);
486 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
488 return returnValue;
491 FieldContainerTransitPtr ClipPlaneChunkBase::shallowCopy(void) const
493 ClipPlaneChunk *tmpPtr;
495 newPtr(tmpPtr,
496 dynamic_cast<const ClipPlaneChunk *>(this),
497 Thread::getCurrentLocalFlags());
499 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
501 FieldContainerTransitPtr returnValue(tmpPtr);
503 return returnValue;
509 /*------------------------- constructors ----------------------------------*/
511 ClipPlaneChunkBase::ClipPlaneChunkBase(void) :
512 Inherited(),
513 _sfEquation (Vec4f(0, 0, 1, 0)),
514 _sfEnable (bool(GL_TRUE)),
515 _sfBeacon (NULL)
519 ClipPlaneChunkBase::ClipPlaneChunkBase(const ClipPlaneChunkBase &source) :
520 Inherited(source),
521 _sfEquation (source._sfEquation ),
522 _sfEnable (source._sfEnable ),
523 _sfBeacon (NULL)
528 /*-------------------------- destructors ----------------------------------*/
530 ClipPlaneChunkBase::~ClipPlaneChunkBase(void)
534 void ClipPlaneChunkBase::onCreate(const ClipPlaneChunk *source)
536 Inherited::onCreate(source);
538 if(source != NULL)
540 ClipPlaneChunk *pThis = static_cast<ClipPlaneChunk *>(this);
542 pThis->setBeacon(source->getBeacon());
546 GetFieldHandlePtr ClipPlaneChunkBase::getHandleEquation (void) const
548 SFVec4f::GetHandlePtr returnValue(
549 new SFVec4f::GetHandle(
550 &_sfEquation,
551 this->getType().getFieldDesc(EquationFieldId),
552 const_cast<ClipPlaneChunkBase *>(this)));
554 return returnValue;
557 EditFieldHandlePtr ClipPlaneChunkBase::editHandleEquation (void)
559 SFVec4f::EditHandlePtr returnValue(
560 new SFVec4f::EditHandle(
561 &_sfEquation,
562 this->getType().getFieldDesc(EquationFieldId),
563 this));
566 editSField(EquationFieldMask);
568 return returnValue;
571 GetFieldHandlePtr ClipPlaneChunkBase::getHandleEnable (void) const
573 SFBool::GetHandlePtr returnValue(
574 new SFBool::GetHandle(
575 &_sfEnable,
576 this->getType().getFieldDesc(EnableFieldId),
577 const_cast<ClipPlaneChunkBase *>(this)));
579 return returnValue;
582 EditFieldHandlePtr ClipPlaneChunkBase::editHandleEnable (void)
584 SFBool::EditHandlePtr returnValue(
585 new SFBool::EditHandle(
586 &_sfEnable,
587 this->getType().getFieldDesc(EnableFieldId),
588 this));
591 editSField(EnableFieldMask);
593 return returnValue;
596 GetFieldHandlePtr ClipPlaneChunkBase::getHandleBeacon (void) const
598 SFWeakNodePtr::GetHandlePtr returnValue(
599 new SFWeakNodePtr::GetHandle(
600 &_sfBeacon,
601 this->getType().getFieldDesc(BeaconFieldId),
602 const_cast<ClipPlaneChunkBase *>(this)));
604 return returnValue;
607 EditFieldHandlePtr ClipPlaneChunkBase::editHandleBeacon (void)
609 SFWeakNodePtr::EditHandlePtr returnValue(
610 new SFWeakNodePtr::EditHandle(
611 &_sfBeacon,
612 this->getType().getFieldDesc(BeaconFieldId),
613 this));
615 returnValue->setSetMethod(
616 boost::bind(&ClipPlaneChunk::setBeacon,
617 static_cast<ClipPlaneChunk *>(this), _1));
619 editSField(BeaconFieldMask);
621 return returnValue;
625 #ifdef OSG_MT_CPTR_ASPECT
626 void ClipPlaneChunkBase::execSyncV( FieldContainer &oFrom,
627 ConstFieldMaskArg whichField,
628 AspectOffsetStore &oOffsets,
629 ConstFieldMaskArg syncMode,
630 const UInt32 uiSyncInfo)
632 ClipPlaneChunk *pThis = static_cast<ClipPlaneChunk *>(this);
634 pThis->execSync(static_cast<ClipPlaneChunk *>(&oFrom),
635 whichField,
636 oOffsets,
637 syncMode,
638 uiSyncInfo);
640 #endif
643 #ifdef OSG_MT_CPTR_ASPECT
644 FieldContainer *ClipPlaneChunkBase::createAspectCopy(
645 const FieldContainer *pRefAspect) const
647 ClipPlaneChunk *returnValue;
649 newAspectCopy(returnValue,
650 dynamic_cast<const ClipPlaneChunk *>(pRefAspect),
651 dynamic_cast<const ClipPlaneChunk *>(this));
653 return returnValue;
655 #endif
657 void ClipPlaneChunkBase::resolveLinks(void)
659 Inherited::resolveLinks();
661 static_cast<ClipPlaneChunk *>(this)->setBeacon(NULL);
667 OSG_END_NAMESPACE