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 VisitSubTree!
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"
65 #include "OSGNode.h" // SubTreeRoot Class
67 #include "OSGVisitSubTreeBase.h"
68 #include "OSGVisitSubTree.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::VisitSubTree
79 VisitSubTree provides a way to point the renderer to another section of the
80 scene graph for rendering. This is useful for multi-pass algorithms using
81 OSG::Stage because it provides a way to render the same graph multiple times
82 without duplicating the nodes.
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var Node * VisitSubTreeBase::_sfSubTreeRoot
90 Reference to the sub-graph to draw in place of this node.
91 Whatever node is pointed to will be drawn here as if it was duplicated
95 /*! \var UInt32 VisitSubTreeBase::_sfSubTreeTravMask
96 This travmask will be used to update the action mask on traversal (and)
99 /*! \var UInt32 VisitSubTreeBase::_sfTravMaskMode
100 This defines how the travmask will be used to update the action mask on
105 /***************************************************************************\
106 * FieldType/FieldTrait Instantiation *
107 \***************************************************************************/
109 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
110 PointerType FieldTraits
<VisitSubTree
*, nsOSG
>::_type(
113 VisitSubTree::getClassType(),
117 OSG_FIELDTRAITS_GETTYPE_NS(VisitSubTree
*, nsOSG
)
119 /***************************************************************************\
120 * Field Description *
121 \***************************************************************************/
123 void VisitSubTreeBase::classDescInserter(TypeObject
&oType
)
125 FieldDescriptionBase
*pDesc
= NULL
;
128 pDesc
= new SFWeakNodePtr::Description(
129 SFWeakNodePtr::getClassType(),
131 "Reference to the sub-graph to draw in place of this node.\n"
132 "Whatever node is pointed to will be drawn here as if it was duplicated\n"
133 "at this location.\n",
134 SubTreeRootFieldId
, SubTreeRootFieldMask
,
136 (Field::SFDefaultFlags
| Field::FCustomAccess
),
137 static_cast<FieldEditMethodSig
>(&VisitSubTree::editHandleSubTreeRoot
),
138 static_cast<FieldGetMethodSig
>(&VisitSubTree::getHandleSubTreeRoot
));
140 oType
.addInitialDesc(pDesc
);
142 pDesc
= new SFUInt32::Description(
143 SFUInt32::getClassType(),
145 "This travmask will be used to update the action mask on traversal (and)\n",
146 SubTreeTravMaskFieldId
, SubTreeTravMaskFieldMask
,
148 (Field::SFDefaultFlags
| Field::FStdAccess
),
149 static_cast<FieldEditMethodSig
>(&VisitSubTree::editHandleSubTreeTravMask
),
150 static_cast<FieldGetMethodSig
>(&VisitSubTree::getHandleSubTreeTravMask
));
152 oType
.addInitialDesc(pDesc
);
154 pDesc
= new SFUInt32::Description(
155 SFUInt32::getClassType(),
157 "This defines how the travmask will be used to update the action mask on \n"
159 TravMaskModeFieldId
, TravMaskModeFieldMask
,
161 (Field::SFDefaultFlags
| Field::FStdAccess
),
162 static_cast<FieldEditMethodSig
>(&VisitSubTree::editHandleTravMaskMode
),
163 static_cast<FieldGetMethodSig
>(&VisitSubTree::getHandleTravMaskMode
));
165 oType
.addInitialDesc(pDesc
);
169 VisitSubTreeBase::TypeObject
VisitSubTreeBase::_type(
170 VisitSubTreeBase::getClassname(),
171 Inherited::getClassname(),
174 reinterpret_cast<PrototypeCreateF
>(&VisitSubTreeBase::createEmptyLocal
),
175 reinterpret_cast<InitContainerF
>(&VisitSubTree::initMethod
),
176 reinterpret_cast<ExitContainerF
>(&VisitSubTree::exitMethod
),
177 reinterpret_cast<InitalInsertDescFunc
>(
178 reinterpret_cast<void *>(&VisitSubTree::classDescInserter
)),
181 "<?xml version=\"1.0\"?>\n"
184 " name=\"VisitSubTree\"\n"
185 " parent=\"Group\"\n"
186 " library=\"Group\"\n"
187 " pointerfieldtypes=\"none\"\n"
188 " structure=\"concrete\"\n"
189 " systemcomponent=\"true\"\n"
190 " parentsystemcomponent=\"true\"\n"
191 " decoratable=\"false\"\n"
192 " useLocalIncludes=\"false\"\n"
193 " isNodeCore=\"true\"\n"
194 " docGroupBase=\"GrpGroupMisc\"\n"
196 " VisitSubTree provides a way to point the renderer to another section of the\n"
197 " scene graph for rendering. This is useful for multi-pass algorithms using\n"
198 " OSG::Stage because it provides a way to render the same graph multiple times\n"
199 " without duplicating the nodes.\n"
201 " name=\"subTreeRoot\"\n"
203 " category=\"weakpointer\"\n"
204 " cardinality=\"single\"\n"
205 " visibility=\"external\"\n"
206 " defaultValue=\"NULL\"\n"
207 " access=\"protected\"\n"
208 " ptrFieldAccess = \"custom\"\n"
210 " Reference to the sub-graph to draw in place of this node.\n"
211 " Whatever node is pointed to will be drawn here as if it was duplicated\n"
212 " at this location.\n"
215 " name=\"subTreeTravMask\"\n"
217 " cardinality=\"single\"\n"
218 " visibility=\"external\"\n"
219 " defaultValue=\"TypeTraits<UInt32>::getMax()\"\n"
220 " access=\"public\"\n"
222 " This travmask will be used to update the action mask on traversal (and)\n"
225 " name=\"travMaskMode\"\n"
227 " cardinality=\"single\"\n"
228 " visibility=\"external\"\n"
229 " defaultValue=\"VisitSubTree::AndTravMask\"\n"
230 " access=\"public\"\n"
232 " This defines how the travmask will be used to update the action mask on \n"
235 "</FieldContainer>\n",
236 "VisitSubTree provides a way to point the renderer to another section of the\n"
237 "scene graph for rendering. This is useful for multi-pass algorithms using\n"
238 "OSG::Stage because it provides a way to render the same graph multiple times\n"
239 "without duplicating the nodes.\n"
242 /*------------------------------ get -----------------------------------*/
244 FieldContainerType
&VisitSubTreeBase::getType(void)
249 const FieldContainerType
&VisitSubTreeBase::getType(void) const
254 UInt32
VisitSubTreeBase::getContainerSize(void) const
256 return sizeof(VisitSubTree
);
259 /*------------------------- decorator get ------------------------------*/
262 //! Get the VisitSubTree::_sfSubTreeRoot field.
263 const SFWeakNodePtr
*VisitSubTreeBase::getSFSubTreeRoot(void) const
265 return &_sfSubTreeRoot
;
268 //! Get the value of the VisitSubTree::_sfSubTreeRoot field.
269 Node
* VisitSubTreeBase::getSubTreeRoot(void) const
271 return _sfSubTreeRoot
.getValue();
276 SFUInt32
*VisitSubTreeBase::editSFSubTreeTravMask(void)
278 editSField(SubTreeTravMaskFieldMask
);
280 return &_sfSubTreeTravMask
;
283 const SFUInt32
*VisitSubTreeBase::getSFSubTreeTravMask(void) const
285 return &_sfSubTreeTravMask
;
289 SFUInt32
*VisitSubTreeBase::editSFTravMaskMode(void)
291 editSField(TravMaskModeFieldMask
);
293 return &_sfTravMaskMode
;
296 const SFUInt32
*VisitSubTreeBase::getSFTravMaskMode(void) const
298 return &_sfTravMaskMode
;
306 /*------------------------------ access -----------------------------------*/
308 SizeT
VisitSubTreeBase::getBinSize(ConstFieldMaskArg whichField
)
310 SizeT returnValue
= Inherited::getBinSize(whichField
);
312 if(FieldBits::NoField
!= (SubTreeRootFieldMask
& whichField
))
314 returnValue
+= _sfSubTreeRoot
.getBinSize();
316 if(FieldBits::NoField
!= (SubTreeTravMaskFieldMask
& whichField
))
318 returnValue
+= _sfSubTreeTravMask
.getBinSize();
320 if(FieldBits::NoField
!= (TravMaskModeFieldMask
& whichField
))
322 returnValue
+= _sfTravMaskMode
.getBinSize();
328 void VisitSubTreeBase::copyToBin(BinaryDataHandler
&pMem
,
329 ConstFieldMaskArg whichField
)
331 Inherited::copyToBin(pMem
, whichField
);
333 if(FieldBits::NoField
!= (SubTreeRootFieldMask
& whichField
))
335 _sfSubTreeRoot
.copyToBin(pMem
);
337 if(FieldBits::NoField
!= (SubTreeTravMaskFieldMask
& whichField
))
339 _sfSubTreeTravMask
.copyToBin(pMem
);
341 if(FieldBits::NoField
!= (TravMaskModeFieldMask
& whichField
))
343 _sfTravMaskMode
.copyToBin(pMem
);
347 void VisitSubTreeBase::copyFromBin(BinaryDataHandler
&pMem
,
348 ConstFieldMaskArg whichField
)
350 Inherited::copyFromBin(pMem
, whichField
);
352 if(FieldBits::NoField
!= (SubTreeRootFieldMask
& whichField
))
354 editSField(SubTreeRootFieldMask
);
355 _sfSubTreeRoot
.copyFromBin(pMem
);
357 if(FieldBits::NoField
!= (SubTreeTravMaskFieldMask
& whichField
))
359 editSField(SubTreeTravMaskFieldMask
);
360 _sfSubTreeTravMask
.copyFromBin(pMem
);
362 if(FieldBits::NoField
!= (TravMaskModeFieldMask
& whichField
))
364 editSField(TravMaskModeFieldMask
);
365 _sfTravMaskMode
.copyFromBin(pMem
);
369 //! create a new instance of the class
370 VisitSubTreeTransitPtr
VisitSubTreeBase::createLocal(BitVector bFlags
)
372 VisitSubTreeTransitPtr fc
;
374 if(getClassType().getPrototype() != NULL
)
376 FieldContainerTransitPtr tmpPtr
=
377 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
379 fc
= dynamic_pointer_cast
<VisitSubTree
>(tmpPtr
);
385 //! create a new instance of the class, copy the container flags
386 VisitSubTreeTransitPtr
VisitSubTreeBase::createDependent(BitVector bFlags
)
388 VisitSubTreeTransitPtr fc
;
390 if(getClassType().getPrototype() != NULL
)
392 FieldContainerTransitPtr tmpPtr
=
393 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
395 fc
= dynamic_pointer_cast
<VisitSubTree
>(tmpPtr
);
401 //! create a new instance of the class
402 VisitSubTreeTransitPtr
VisitSubTreeBase::create(void)
404 VisitSubTreeTransitPtr fc
;
406 if(getClassType().getPrototype() != NULL
)
408 FieldContainerTransitPtr tmpPtr
=
409 getClassType().getPrototype()-> shallowCopy();
411 fc
= dynamic_pointer_cast
<VisitSubTree
>(tmpPtr
);
417 VisitSubTree
*VisitSubTreeBase::createEmptyLocal(BitVector bFlags
)
419 VisitSubTree
*returnValue
;
421 newPtr
<VisitSubTree
>(returnValue
, bFlags
);
423 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
428 //! create an empty new instance of the class, do not copy the prototype
429 VisitSubTree
*VisitSubTreeBase::createEmpty(void)
431 VisitSubTree
*returnValue
;
433 newPtr
<VisitSubTree
>(returnValue
, Thread::getCurrentLocalFlags());
435 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
436 ~Thread::getCurrentLocalFlags();
442 FieldContainerTransitPtr
VisitSubTreeBase::shallowCopyLocal(
443 BitVector bFlags
) const
445 VisitSubTree
*tmpPtr
;
447 newPtr(tmpPtr
, dynamic_cast<const VisitSubTree
*>(this), bFlags
);
449 FieldContainerTransitPtr
returnValue(tmpPtr
);
451 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
456 FieldContainerTransitPtr
VisitSubTreeBase::shallowCopyDependent(
457 BitVector bFlags
) const
459 VisitSubTree
*tmpPtr
;
461 newPtr(tmpPtr
, dynamic_cast<const VisitSubTree
*>(this), ~bFlags
);
463 FieldContainerTransitPtr
returnValue(tmpPtr
);
465 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
470 FieldContainerTransitPtr
VisitSubTreeBase::shallowCopy(void) const
472 VisitSubTree
*tmpPtr
;
475 dynamic_cast<const VisitSubTree
*>(this),
476 Thread::getCurrentLocalFlags());
478 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
480 FieldContainerTransitPtr
returnValue(tmpPtr
);
488 /*------------------------- constructors ----------------------------------*/
490 VisitSubTreeBase::VisitSubTreeBase(void) :
492 _sfSubTreeRoot (NULL
),
493 _sfSubTreeTravMask (UInt32(TypeTraits
<UInt32
>::getMax())),
494 _sfTravMaskMode (UInt32(VisitSubTree::AndTravMask
))
498 VisitSubTreeBase::VisitSubTreeBase(const VisitSubTreeBase
&source
) :
500 _sfSubTreeRoot (NULL
),
501 _sfSubTreeTravMask (source
._sfSubTreeTravMask
),
502 _sfTravMaskMode (source
._sfTravMaskMode
)
507 /*-------------------------- destructors ----------------------------------*/
509 VisitSubTreeBase::~VisitSubTreeBase(void)
513 void VisitSubTreeBase::onCreate(const VisitSubTree
*source
)
515 Inherited::onCreate(source
);
519 VisitSubTree
*pThis
= static_cast<VisitSubTree
*>(this);
521 pThis
->setSubTreeRoot(source
->getSubTreeRoot());
525 GetFieldHandlePtr
VisitSubTreeBase::getHandleSubTreeRoot (void) const
527 SFWeakNodePtr::GetHandlePtr
returnValue(
528 new SFWeakNodePtr::GetHandle(
530 this->getType().getFieldDesc(SubTreeRootFieldId
),
531 const_cast<VisitSubTreeBase
*>(this)));
536 EditFieldHandlePtr
VisitSubTreeBase::editHandleSubTreeRoot (void)
538 SFWeakNodePtr::EditHandlePtr
returnValue(
539 new SFWeakNodePtr::EditHandle(
541 this->getType().getFieldDesc(SubTreeRootFieldId
),
544 returnValue
->setSetMethod(
545 boost::bind(&VisitSubTree::setSubTreeRoot
,
546 static_cast<VisitSubTree
*>(this), _1
));
548 editSField(SubTreeRootFieldMask
);
553 GetFieldHandlePtr
VisitSubTreeBase::getHandleSubTreeTravMask (void) const
555 SFUInt32::GetHandlePtr
returnValue(
556 new SFUInt32::GetHandle(
558 this->getType().getFieldDesc(SubTreeTravMaskFieldId
),
559 const_cast<VisitSubTreeBase
*>(this)));
564 EditFieldHandlePtr
VisitSubTreeBase::editHandleSubTreeTravMask(void)
566 SFUInt32::EditHandlePtr
returnValue(
567 new SFUInt32::EditHandle(
569 this->getType().getFieldDesc(SubTreeTravMaskFieldId
),
573 editSField(SubTreeTravMaskFieldMask
);
578 GetFieldHandlePtr
VisitSubTreeBase::getHandleTravMaskMode (void) const
580 SFUInt32::GetHandlePtr
returnValue(
581 new SFUInt32::GetHandle(
583 this->getType().getFieldDesc(TravMaskModeFieldId
),
584 const_cast<VisitSubTreeBase
*>(this)));
589 EditFieldHandlePtr
VisitSubTreeBase::editHandleTravMaskMode (void)
591 SFUInt32::EditHandlePtr
returnValue(
592 new SFUInt32::EditHandle(
594 this->getType().getFieldDesc(TravMaskModeFieldId
),
598 editSField(TravMaskModeFieldMask
);
604 #ifdef OSG_MT_CPTR_ASPECT
605 void VisitSubTreeBase::execSyncV( FieldContainer
&oFrom
,
606 ConstFieldMaskArg whichField
,
607 AspectOffsetStore
&oOffsets
,
608 ConstFieldMaskArg syncMode
,
609 const UInt32 uiSyncInfo
)
611 VisitSubTree
*pThis
= static_cast<VisitSubTree
*>(this);
613 pThis
->execSync(static_cast<VisitSubTree
*>(&oFrom
),
622 #ifdef OSG_MT_CPTR_ASPECT
623 FieldContainer
*VisitSubTreeBase::createAspectCopy(
624 const FieldContainer
*pRefAspect
) const
626 VisitSubTree
*returnValue
;
628 newAspectCopy(returnValue
,
629 dynamic_cast<const VisitSubTree
*>(pRefAspect
),
630 dynamic_cast<const VisitSubTree
*>(this));
636 void VisitSubTreeBase::resolveLinks(void)
638 Inherited::resolveLinks();
640 static_cast<VisitSubTree
*>(this)->setSubTreeRoot(NULL
);