1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
48 ** class ClipPlaneChunk!
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
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>
75 /***************************************************************************\
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(
114 ClipPlaneChunk::getClassType(),
118 OSG_FIELDTRAITS_GETTYPE_NS(ClipPlaneChunk
*, nsOSG
)
120 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
124 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
128 /***************************************************************************\
129 * Field Description *
130 \***************************************************************************/
132 void ClipPlaneChunkBase::classDescInserter(TypeObject
&oType
)
134 FieldDescriptionBase
*pDesc
= NULL
;
137 pDesc
= new SFVec4f::Description(
138 SFVec4f::getClassType(),
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
,
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(),
153 "Defines activation state of the clip plane.\n",
154 EnableFieldId
, EnableFieldMask
,
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(),
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
,
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(),
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
)),
189 "<?xml version=\"1.0\"?>\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"
202 " See \\ref PageSystemClipPlaneChunk for a description.\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"
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"
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 "= 0.\n"
219 "\t name=\"enable\"\n"
221 "\t cardinality=\"single\"\n"
222 "\t visibility=\"external\"\n"
223 "\t defaultValue=\"GL_TRUE\"\n"
224 "\t defaultHeader=\""OSGGL.h"\"\n"
225 "\t access=\"public\"\n"
227 "\tDefines activation state of the clip plane.\n"
230 "\t name=\"beacon\"\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"
238 " The object that defines the clip planes's coordinate system. The clip\n"
239 " plane is positioned relative to this system.\n"
241 "</FieldContainer>\n",
242 "See \\ref PageSystemClipPlaneChunk for a description.\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)
256 const FieldContainerType
&ClipPlaneChunkBase::getType(void) const
261 UInt32
ClipPlaneChunkBase::getContainerSize(void) const
263 return sizeof(ClipPlaneChunk
);
266 /*------------------------- decorator get ------------------------------*/
269 SFVec4f
*ClipPlaneChunkBase::editSFEquation(void)
271 editSField(EquationFieldMask
);
276 const SFVec4f
*ClipPlaneChunkBase::getSFEquation(void) const
282 SFBool
*ClipPlaneChunkBase::editSFEnable(void)
284 editSField(EnableFieldMask
);
289 const SFBool
*ClipPlaneChunkBase::getSFEnable(void) const
295 //! Get the ClipPlaneChunk::_sfBeacon field.
296 const SFWeakNodePtr
*ClipPlaneChunkBase::getSFBeacon(void) const
301 SFWeakNodePtr
*ClipPlaneChunkBase::editSFBeacon (void)
303 editSField(BeaconFieldMask
);
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();
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
);
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
);
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
);
438 ClipPlaneChunk
*ClipPlaneChunkBase::createEmptyLocal(BitVector bFlags
)
440 ClipPlaneChunk
*returnValue
;
442 newPtr
<ClipPlaneChunk
>(returnValue
, bFlags
);
444 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
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();
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
;
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
;
491 FieldContainerTransitPtr
ClipPlaneChunkBase::shallowCopy(void) const
493 ClipPlaneChunk
*tmpPtr
;
496 dynamic_cast<const ClipPlaneChunk
*>(this),
497 Thread::getCurrentLocalFlags());
499 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
501 FieldContainerTransitPtr
returnValue(tmpPtr
);
509 /*------------------------- constructors ----------------------------------*/
511 ClipPlaneChunkBase::ClipPlaneChunkBase(void) :
513 _sfEquation (Vec4f(0, 0, 1, 0)),
514 _sfEnable (bool(GL_TRUE
)),
519 ClipPlaneChunkBase::ClipPlaneChunkBase(const ClipPlaneChunkBase
&source
) :
521 _sfEquation (source
._sfEquation
),
522 _sfEnable (source
._sfEnable
),
528 /*-------------------------- destructors ----------------------------------*/
530 ClipPlaneChunkBase::~ClipPlaneChunkBase(void)
534 void ClipPlaneChunkBase::onCreate(const ClipPlaneChunk
*source
)
536 Inherited::onCreate(source
);
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(
551 this->getType().getFieldDesc(EquationFieldId
),
552 const_cast<ClipPlaneChunkBase
*>(this)));
557 EditFieldHandlePtr
ClipPlaneChunkBase::editHandleEquation (void)
559 SFVec4f::EditHandlePtr
returnValue(
560 new SFVec4f::EditHandle(
562 this->getType().getFieldDesc(EquationFieldId
),
566 editSField(EquationFieldMask
);
571 GetFieldHandlePtr
ClipPlaneChunkBase::getHandleEnable (void) const
573 SFBool::GetHandlePtr
returnValue(
574 new SFBool::GetHandle(
576 this->getType().getFieldDesc(EnableFieldId
),
577 const_cast<ClipPlaneChunkBase
*>(this)));
582 EditFieldHandlePtr
ClipPlaneChunkBase::editHandleEnable (void)
584 SFBool::EditHandlePtr
returnValue(
585 new SFBool::EditHandle(
587 this->getType().getFieldDesc(EnableFieldId
),
591 editSField(EnableFieldMask
);
596 GetFieldHandlePtr
ClipPlaneChunkBase::getHandleBeacon (void) const
598 SFWeakNodePtr::GetHandlePtr
returnValue(
599 new SFWeakNodePtr::GetHandle(
601 this->getType().getFieldDesc(BeaconFieldId
),
602 const_cast<ClipPlaneChunkBase
*>(this)));
607 EditFieldHandlePtr
ClipPlaneChunkBase::editHandleBeacon (void)
609 SFWeakNodePtr::EditHandlePtr
returnValue(
610 new SFWeakNodePtr::EditHandle(
612 this->getType().getFieldDesc(BeaconFieldId
),
615 returnValue
->setSetMethod(
616 boost::bind(&ClipPlaneChunk::setBeacon
,
617 static_cast<ClipPlaneChunk
*>(this), _1
));
619 editSField(BeaconFieldMask
);
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
),
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));
657 void ClipPlaneChunkBase::resolveLinks(void)
659 Inherited::resolveLinks();
661 static_cast<ClipPlaneChunk
*>(this)->setBeacon(NULL
);