changed: gcc8 base update
[opensg.git] / Source / System / Window / Base / OSGViewportBase.cpp
blob1b293dd2515533d371b88fa8363b679250d62086
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 Viewport!
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"
65 #include "OSGFieldContainer.h" // Parent Class
66 #include "OSGCamera.h" // Camera Class
67 #include "OSGNode.h" // Root Class
68 #include "OSGBackground.h" // Background Class
69 #include "OSGForeground.h" // Foregrounds Class
71 #include "OSGViewportBase.h"
72 #include "OSGViewport.h"
74 #include <boost/bind.hpp>
76 OSG_BEGIN_NAMESPACE
78 /***************************************************************************\
79 * Description *
80 \***************************************************************************/
82 /*! \class OSG::Viewport
83 A Viewport is a part of the Window it is attached to used for rendering. See
84 \ref PageSystemWindowViewports for a description.
86 The size of the viewport is defined by the _sfLeft, _sfRight, _sfBottom and
87 _sfTop Fields. The Window this Viewport is attached is stored in _sfWindow.
88 _sfBackground defines the background clearing method, the
89 _sfRoot and _sfCamera Fields the scene being rendered and the camera used to
90 view it. The optional _mfForegrounds define which information are added or
91 actions are executed after the Viewport has been rendered.
93 \ext
95 To create a new Viewport the draw and render methods should be overridden.
97 \endext
99 \dev
101 When adding fields to the Viewport, make sure to add the code to copy them to
102 all the different ClusterWindows!
104 \enddev
107 /***************************************************************************\
108 * Field Documentation *
109 \***************************************************************************/
111 /*! \var FieldContainer * ViewportBase::_sfParent
112 The Window this viewport is contained in.
115 /*! \var Camera * ViewportBase::_sfCamera
116 The Camera used to render the viewport.
119 /*! \var Node * ViewportBase::_sfRoot
120 The root of the tree that is displayed in this viewport.
123 /*! \var Background * ViewportBase::_sfBackground
124 The background used to clear this viewport.
127 /*! \var Foreground * ViewportBase::_mfForegrounds
128 The foreground additions to the rendered image.
132 /***************************************************************************\
133 * FieldType/FieldTrait Instantiation *
134 \***************************************************************************/
136 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
137 PointerType FieldTraits<Viewport *, nsOSG>::_type(
138 "ViewportPtr",
139 "ViewareaPtr",
140 Viewport::getClassType(),
141 nsOSG);
142 #endif
144 OSG_FIELDTRAITS_GETTYPE_NS(Viewport *, nsOSG)
146 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
147 Viewport *,
148 nsOSG)
150 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
151 Viewport *,
152 nsOSG)
154 DataType &FieldTraits< Viewport *, nsOSG + 1 >::getType(void)
156 return FieldTraits<Viewport *, nsOSG>::getType();
160 OSG_EXPORT_PTR_MFIELD(ChildPointerMField,
161 Viewport *,
162 UnrecordedRefCountPolicy,
163 nsOSG + 1)
166 /***************************************************************************\
167 * Field Description *
168 \***************************************************************************/
170 void ViewportBase::classDescInserter(TypeObject &oType)
172 FieldDescriptionBase *pDesc = NULL;
175 pDesc = new SFParentFieldContainerPtr::Description(
176 SFParentFieldContainerPtr::getClassType(),
177 "parent",
178 "The Window this viewport is contained in.\n",
179 ParentFieldId, ParentFieldMask,
180 false,
181 (Field::SFDefaultFlags | Field::FStdAccess),
182 static_cast <FieldEditMethodSig>(&Viewport::invalidEditField),
183 static_cast <FieldGetMethodSig >(&Viewport::invalidGetField));
185 oType.addInitialDesc(pDesc);
187 pDesc = new SFUnrecCameraPtr::Description(
188 SFUnrecCameraPtr::getClassType(),
189 "camera",
190 "The Camera used to render the viewport.\n",
191 CameraFieldId, CameraFieldMask,
192 false,
193 (Field::SFDefaultFlags | Field::FStdAccess),
194 static_cast<FieldEditMethodSig>(&Viewport::editHandleCamera),
195 static_cast<FieldGetMethodSig >(&Viewport::getHandleCamera));
197 oType.addInitialDesc(pDesc);
199 pDesc = new SFUnrecNodePtr::Description(
200 SFUnrecNodePtr::getClassType(),
201 "root",
202 "The root of the tree that is displayed in this viewport.\n",
203 RootFieldId, RootFieldMask,
204 false,
205 (Field::SFDefaultFlags | Field::FStdAccess),
206 static_cast<FieldEditMethodSig>(&Viewport::editHandleRoot),
207 static_cast<FieldGetMethodSig >(&Viewport::getHandleRoot));
209 oType.addInitialDesc(pDesc);
211 pDesc = new SFUnrecBackgroundPtr::Description(
212 SFUnrecBackgroundPtr::getClassType(),
213 "background",
214 "The background used to clear this viewport.\n",
215 BackgroundFieldId, BackgroundFieldMask,
216 false,
217 (Field::SFDefaultFlags | Field::FStdAccess),
218 static_cast<FieldEditMethodSig>(&Viewport::editHandleBackground),
219 static_cast<FieldGetMethodSig >(&Viewport::getHandleBackground));
221 oType.addInitialDesc(pDesc);
223 pDesc = new MFUnrecForegroundPtr::Description(
224 MFUnrecForegroundPtr::getClassType(),
225 "foregrounds",
226 "The foreground additions to the rendered image.\n",
227 ForegroundsFieldId, ForegroundsFieldMask,
228 false,
229 (Field::MFDefaultFlags | Field::FStdAccess),
230 static_cast<FieldEditMethodSig>(&Viewport::editHandleForegrounds),
231 static_cast<FieldGetMethodSig >(&Viewport::getHandleForegrounds));
233 oType.addInitialDesc(pDesc);
237 ViewportBase::TypeObject ViewportBase::_type(
238 ViewportBase::getClassname(),
239 Inherited::getClassname(),
240 "NULL",
241 nsOSG, //Namespace
242 reinterpret_cast<PrototypeCreateF>(&ViewportBase::createEmptyLocal),
243 reinterpret_cast<InitContainerF>(&Viewport::initMethod),
244 reinterpret_cast<ExitContainerF>(&Viewport::exitMethod),
245 reinterpret_cast<InitalInsertDescFunc>(
246 reinterpret_cast<void *>(&Viewport::classDescInserter)),
247 false,
249 "<?xml version=\"1.0\"?>\n"
250 "\n"
251 "<FieldContainer\n"
252 " name=\"Viewport\"\n"
253 " parent=\"Viewarea\"\n"
254 " library=\"System\"\n"
255 " pointerfieldtypes=\"both\"\n"
256 " structure=\"concrete\"\n"
257 " systemcomponent=\"true\"\n"
258 " parentsystemcomponent=\"true\"\n"
259 " childFields=\"multi\"\n"
260 " docGroupBase=\"GrpSystemWindow\"\n"
261 " >\n"
262 "\n"
263 " A Viewport is a part of the Window it is attached to used for rendering. See\n"
264 " \\ref PageSystemWindowViewports for a description.\n"
265 "\n"
266 " The size of the viewport is defined by the _sfLeft, _sfRight, _sfBottom and\n"
267 " _sfTop Fields. The Window this Viewport is attached is stored in _sfWindow.\n"
268 " _sfBackground defines the background clearing method, the\n"
269 " _sfRoot and _sfCamera Fields the scene being rendered and the camera used to\n"
270 " view it. The optional _mfForegrounds define which information are added or\n"
271 " actions are executed after the Viewport has been rendered.\n"
272 " \n"
273 " \\ext\n"
274 "\n"
275 " To create a new Viewport the draw and render methods should be overridden. \n"
276 " \n"
277 " \\endext\n"
278 " \n"
279 " \\dev\n"
280 "\n"
281 " When adding fields to the Viewport, make sure to add the code to copy them to\n"
282 " all the different ClusterWindows!\n"
283 " \n"
284 " \\enddev\n"
285 "\n"
286 " <Field\n"
287 " name=\"parent\"\n"
288 " type=\"FieldContainer\"\n"
289 " cardinality=\"single\"\n"
290 " visibility=\"external\"\n"
291 " access=\"none\"\n"
292 " category=\"parentpointer\"\n"
293 " >\n"
294 " The Window this viewport is contained in.\n"
295 " </Field>\n"
296 " <Field\n"
297 " name=\"camera\"\n"
298 " type=\"CameraPtr\"\n"
299 " cardinality=\"single\"\n"
300 " visibility=\"external\"\n"
301 " access=\"public\"\n"
302 " >\n"
303 " The Camera used to render the viewport.\n"
304 " </Field>\n"
305 " <Field\n"
306 " name=\"root\"\n"
307 " type=\"NodePtr\"\n"
308 " cardinality=\"single\"\n"
309 " visibility=\"external\"\n"
310 " access=\"public\"\n"
311 " >\n"
312 " The root of the tree that is displayed in this viewport.\n"
313 " </Field>\n"
314 " <Field\n"
315 " name=\"background\"\n"
316 " type=\"BackgroundPtr\"\n"
317 " cardinality=\"single\"\n"
318 " visibility=\"external\"\n"
319 " access=\"public\"\n"
320 " >\n"
321 " The background used to clear this viewport.\n"
322 " </Field>\n"
323 " <Field\n"
324 " name=\"foregrounds\"\n"
325 " type=\"ForegroundPtr\"\n"
326 " cardinality=\"multi\"\n"
327 " visibility=\"external\"\n"
328 " access=\"public\"\n"
329 " pushToFieldAs=\"addForeground\"\n"
330 " >\n"
331 " The foreground additions to the rendered image.\n"
332 " </Field>\n"
333 "</FieldContainer>\n",
334 "A Viewport is a part of the Window it is attached to used for rendering. See\n"
335 "\\ref PageSystemWindowViewports for a description.\n"
336 "\n"
337 "The size of the viewport is defined by the _sfLeft, _sfRight, _sfBottom and\n"
338 "_sfTop Fields. The Window this Viewport is attached is stored in _sfWindow.\n"
339 "_sfBackground defines the background clearing method, the\n"
340 "_sfRoot and _sfCamera Fields the scene being rendered and the camera used to\n"
341 "view it. The optional _mfForegrounds define which information are added or\n"
342 "actions are executed after the Viewport has been rendered.\n"
343 "\n"
344 "\\ext\n"
345 "\n"
346 "To create a new Viewport the draw and render methods should be overridden. \n"
347 "\n"
348 "\\endext\n"
349 "\n"
350 "\\dev\n"
351 "\n"
352 "When adding fields to the Viewport, make sure to add the code to copy them to\n"
353 "all the different ClusterWindows!\n"
354 "\n"
355 "\\enddev\n"
358 /*------------------------------ get -----------------------------------*/
360 FieldContainerType &ViewportBase::getType(void)
362 return _type;
365 const FieldContainerType &ViewportBase::getType(void) const
367 return _type;
370 UInt32 ViewportBase::getContainerSize(void) const
372 return sizeof(Viewport);
375 /*------------------------- decorator get ------------------------------*/
379 //! Get the Viewport::_sfCamera field.
380 const SFUnrecCameraPtr *ViewportBase::getSFCamera(void) const
382 return &_sfCamera;
385 SFUnrecCameraPtr *ViewportBase::editSFCamera (void)
387 editSField(CameraFieldMask);
389 return &_sfCamera;
392 //! Get the value of the Viewport::_sfCamera field.
393 Camera * ViewportBase::getCamera(void) const
395 return _sfCamera.getValue();
398 //! Set the value of the Viewport::_sfCamera field.
399 void ViewportBase::setCamera(Camera * const value)
401 editSField(CameraFieldMask);
403 _sfCamera.setValue(value);
407 //! Get the Viewport::_sfRoot field.
408 const SFUnrecNodePtr *ViewportBase::getSFRoot(void) const
410 return &_sfRoot;
413 SFUnrecNodePtr *ViewportBase::editSFRoot (void)
415 editSField(RootFieldMask);
417 return &_sfRoot;
420 //! Get the value of the Viewport::_sfRoot field.
421 Node * ViewportBase::getRoot(void) const
423 return _sfRoot.getValue();
426 //! Set the value of the Viewport::_sfRoot field.
427 void ViewportBase::setRoot(Node * const value)
429 editSField(RootFieldMask);
431 _sfRoot.setValue(value);
435 //! Get the Viewport::_sfBackground field.
436 const SFUnrecBackgroundPtr *ViewportBase::getSFBackground(void) const
438 return &_sfBackground;
441 SFUnrecBackgroundPtr *ViewportBase::editSFBackground (void)
443 editSField(BackgroundFieldMask);
445 return &_sfBackground;
448 //! Get the value of the Viewport::_sfBackground field.
449 Background * ViewportBase::getBackground(void) const
451 return _sfBackground.getValue();
454 //! Set the value of the Viewport::_sfBackground field.
455 void ViewportBase::setBackground(Background * const value)
457 editSField(BackgroundFieldMask);
459 _sfBackground.setValue(value);
463 //! Get the Viewport::_mfForegrounds field.
464 const MFUnrecForegroundPtr *ViewportBase::getMFForegrounds(void) const
466 return &_mfForegrounds;
469 MFUnrecForegroundPtr *ViewportBase::editMFForegrounds (void)
471 editMField(ForegroundsFieldMask, _mfForegrounds);
473 return &_mfForegrounds;
475 Foreground * ViewportBase::getForegrounds(const UInt32 index) const
477 return _mfForegrounds[index];
482 void ViewportBase::addForeground(Foreground * const value)
484 editMField(ForegroundsFieldMask, _mfForegrounds);
486 _mfForegrounds.push_back(value);
489 void ViewportBase::assignForegrounds(const MFUnrecForegroundPtr &value)
491 MFUnrecForegroundPtr::const_iterator elemIt =
492 value.begin();
493 MFUnrecForegroundPtr::const_iterator elemEnd =
494 value.end ();
496 static_cast<Viewport *>(this)->clearForegrounds();
498 while(elemIt != elemEnd)
500 this->addForeground(*elemIt);
502 ++elemIt;
506 void ViewportBase::removeFromForegrounds(UInt32 uiIndex)
508 if(uiIndex < _mfForegrounds.size())
510 editMField(ForegroundsFieldMask, _mfForegrounds);
512 _mfForegrounds.erase(uiIndex);
516 void ViewportBase::removeObjFromForegrounds(Foreground * const value)
518 Int32 iElemIdx = _mfForegrounds.findIndex(value);
520 if(iElemIdx != -1)
522 editMField(ForegroundsFieldMask, _mfForegrounds);
524 _mfForegrounds.erase(iElemIdx);
527 void ViewportBase::clearForegrounds(void)
529 editMField(ForegroundsFieldMask, _mfForegrounds);
532 _mfForegrounds.clear();
537 /*------------------------------ access -----------------------------------*/
539 SizeT ViewportBase::getBinSize(ConstFieldMaskArg whichField)
541 SizeT returnValue = Inherited::getBinSize(whichField);
543 if(FieldBits::NoField != (ParentFieldMask & whichField))
545 returnValue += _sfParent.getBinSize();
547 if(FieldBits::NoField != (CameraFieldMask & whichField))
549 returnValue += _sfCamera.getBinSize();
551 if(FieldBits::NoField != (RootFieldMask & whichField))
553 returnValue += _sfRoot.getBinSize();
555 if(FieldBits::NoField != (BackgroundFieldMask & whichField))
557 returnValue += _sfBackground.getBinSize();
559 if(FieldBits::NoField != (ForegroundsFieldMask & whichField))
561 returnValue += _mfForegrounds.getBinSize();
564 return returnValue;
567 void ViewportBase::copyToBin(BinaryDataHandler &pMem,
568 ConstFieldMaskArg whichField)
570 Inherited::copyToBin(pMem, whichField);
572 if(FieldBits::NoField != (ParentFieldMask & whichField))
574 _sfParent.copyToBin(pMem);
576 if(FieldBits::NoField != (CameraFieldMask & whichField))
578 _sfCamera.copyToBin(pMem);
580 if(FieldBits::NoField != (RootFieldMask & whichField))
582 _sfRoot.copyToBin(pMem);
584 if(FieldBits::NoField != (BackgroundFieldMask & whichField))
586 _sfBackground.copyToBin(pMem);
588 if(FieldBits::NoField != (ForegroundsFieldMask & whichField))
590 _mfForegrounds.copyToBin(pMem);
594 void ViewportBase::copyFromBin(BinaryDataHandler &pMem,
595 ConstFieldMaskArg whichField)
597 Inherited::copyFromBin(pMem, whichField);
599 if(FieldBits::NoField != (ParentFieldMask & whichField))
601 editSField(ParentFieldMask);
602 _sfParent.copyFromBin(pMem);
604 if(FieldBits::NoField != (CameraFieldMask & whichField))
606 editSField(CameraFieldMask);
607 _sfCamera.copyFromBin(pMem);
609 if(FieldBits::NoField != (RootFieldMask & whichField))
611 editSField(RootFieldMask);
612 _sfRoot.copyFromBin(pMem);
614 if(FieldBits::NoField != (BackgroundFieldMask & whichField))
616 editSField(BackgroundFieldMask);
617 _sfBackground.copyFromBin(pMem);
619 if(FieldBits::NoField != (ForegroundsFieldMask & whichField))
621 editMField(ForegroundsFieldMask, _mfForegrounds);
622 _mfForegrounds.copyFromBin(pMem);
626 //! create a new instance of the class
627 ViewportTransitPtr ViewportBase::createLocal(BitVector bFlags)
629 ViewportTransitPtr fc;
631 if(getClassType().getPrototype() != NULL)
633 FieldContainerTransitPtr tmpPtr =
634 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
636 fc = dynamic_pointer_cast<Viewport>(tmpPtr);
639 return fc;
642 //! create a new instance of the class, copy the container flags
643 ViewportTransitPtr ViewportBase::createDependent(BitVector bFlags)
645 ViewportTransitPtr fc;
647 if(getClassType().getPrototype() != NULL)
649 FieldContainerTransitPtr tmpPtr =
650 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
652 fc = dynamic_pointer_cast<Viewport>(tmpPtr);
655 return fc;
658 //! create a new instance of the class
659 ViewportTransitPtr ViewportBase::create(void)
661 ViewportTransitPtr fc;
663 if(getClassType().getPrototype() != NULL)
665 FieldContainerTransitPtr tmpPtr =
666 getClassType().getPrototype()-> shallowCopy();
668 fc = dynamic_pointer_cast<Viewport>(tmpPtr);
671 return fc;
674 Viewport *ViewportBase::createEmptyLocal(BitVector bFlags)
676 Viewport *returnValue;
678 newPtr<Viewport>(returnValue, bFlags);
680 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
682 return returnValue;
685 //! create an empty new instance of the class, do not copy the prototype
686 Viewport *ViewportBase::createEmpty(void)
688 Viewport *returnValue;
690 newPtr<Viewport>(returnValue, Thread::getCurrentLocalFlags());
692 returnValue->_pFieldFlags->_bNamespaceMask &=
693 ~Thread::getCurrentLocalFlags();
695 return returnValue;
699 FieldContainerTransitPtr ViewportBase::shallowCopyLocal(
700 BitVector bFlags) const
702 Viewport *tmpPtr;
704 newPtr(tmpPtr, dynamic_cast<const Viewport *>(this), bFlags);
706 FieldContainerTransitPtr returnValue(tmpPtr);
708 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
710 return returnValue;
713 FieldContainerTransitPtr ViewportBase::shallowCopyDependent(
714 BitVector bFlags) const
716 Viewport *tmpPtr;
718 newPtr(tmpPtr, dynamic_cast<const Viewport *>(this), ~bFlags);
720 FieldContainerTransitPtr returnValue(tmpPtr);
722 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
724 return returnValue;
727 FieldContainerTransitPtr ViewportBase::shallowCopy(void) const
729 Viewport *tmpPtr;
731 newPtr(tmpPtr,
732 dynamic_cast<const Viewport *>(this),
733 Thread::getCurrentLocalFlags());
735 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
737 FieldContainerTransitPtr returnValue(tmpPtr);
739 return returnValue;
745 /*------------------------- constructors ----------------------------------*/
747 ViewportBase::ViewportBase(void) :
748 Inherited(),
749 _sfParent (NULL),
750 _sfCamera (NULL),
751 _sfRoot (NULL),
752 _sfBackground (NULL),
753 _mfForegrounds ()
757 ViewportBase::ViewportBase(const ViewportBase &source) :
758 Inherited(source),
759 _sfParent (NULL),
760 _sfCamera (NULL),
761 _sfRoot (NULL),
762 _sfBackground (NULL),
763 _mfForegrounds ()
768 /*-------------------------- destructors ----------------------------------*/
770 ViewportBase::~ViewportBase(void)
773 /*-------------------------------------------------------------------------*/
774 /* Parent linking */
776 bool ViewportBase::linkParent(
777 FieldContainer * const pParent,
778 UInt16 const childFieldId,
779 UInt16 const parentFieldId )
781 if(parentFieldId == ParentFieldId)
783 FieldContainer * pTypedParent =
784 dynamic_cast< FieldContainer * >(pParent);
786 if(pTypedParent != NULL)
788 FieldContainer *pOldParent =
789 _sfParent.getValue ();
791 UInt16 oldChildFieldId =
792 _sfParent.getParentFieldPos();
794 if(pOldParent != NULL)
796 pOldParent->unlinkChild(this, oldChildFieldId);
799 editSField(ParentFieldMask);
801 _sfParent.setValue(static_cast<FieldContainer *>(pParent), childFieldId);
803 return true;
806 return false;
809 return Inherited::linkParent(pParent, childFieldId, parentFieldId);
812 bool ViewportBase::unlinkParent(
813 FieldContainer * const pParent,
814 UInt16 const parentFieldId)
816 if(parentFieldId == ParentFieldId)
818 FieldContainer * pTypedParent =
819 dynamic_cast< FieldContainer * >(pParent);
821 if(pTypedParent != NULL)
823 if(_sfParent.getValue() == pTypedParent)
825 editSField(ParentFieldMask);
827 _sfParent.setValue(NULL, 0xFFFF);
829 return true;
832 SWARNING << "Child ([" << this
833 << "] id [" << this->getId()
834 << "] type [" << this->getType().getCName()
835 << "] parentFieldId [" << parentFieldId
836 << "]) - Parent ([" << pParent
837 << "] id [" << pParent->getId()
838 << "] type [" << pParent->getType().getCName()
839 << "]): link inconsistent!"
840 << std::endl;
842 return false;
845 return false;
848 return Inherited::unlinkParent(pParent, parentFieldId);
852 void ViewportBase::onCreate(const Viewport *source)
854 Inherited::onCreate(source);
856 if(source != NULL)
858 Viewport *pThis = static_cast<Viewport *>(this);
860 pThis->setCamera(source->getCamera());
862 pThis->setRoot(source->getRoot());
864 pThis->setBackground(source->getBackground());
866 MFUnrecForegroundPtr::const_iterator ForegroundsIt =
867 source->_mfForegrounds.begin();
868 MFUnrecForegroundPtr::const_iterator ForegroundsEnd =
869 source->_mfForegrounds.end ();
871 while(ForegroundsIt != ForegroundsEnd)
873 pThis->addForeground(*ForegroundsIt);
875 ++ForegroundsIt;
880 GetFieldHandlePtr ViewportBase::getHandleParent (void) const
882 SFParentFieldContainerPtr::GetHandlePtr returnValue;
884 return returnValue;
887 EditFieldHandlePtr ViewportBase::editHandleParent (void)
889 EditFieldHandlePtr returnValue;
891 return returnValue;
894 GetFieldHandlePtr ViewportBase::getHandleCamera (void) const
896 SFUnrecCameraPtr::GetHandlePtr returnValue(
897 new SFUnrecCameraPtr::GetHandle(
898 &_sfCamera,
899 this->getType().getFieldDesc(CameraFieldId),
900 const_cast<ViewportBase *>(this)));
902 return returnValue;
905 EditFieldHandlePtr ViewportBase::editHandleCamera (void)
907 SFUnrecCameraPtr::EditHandlePtr returnValue(
908 new SFUnrecCameraPtr::EditHandle(
909 &_sfCamera,
910 this->getType().getFieldDesc(CameraFieldId),
911 this));
913 returnValue->setSetMethod(
914 boost::bind(&Viewport::setCamera,
915 static_cast<Viewport *>(this), _1));
917 editSField(CameraFieldMask);
919 return returnValue;
922 GetFieldHandlePtr ViewportBase::getHandleRoot (void) const
924 SFUnrecNodePtr::GetHandlePtr returnValue(
925 new SFUnrecNodePtr::GetHandle(
926 &_sfRoot,
927 this->getType().getFieldDesc(RootFieldId),
928 const_cast<ViewportBase *>(this)));
930 return returnValue;
933 EditFieldHandlePtr ViewportBase::editHandleRoot (void)
935 SFUnrecNodePtr::EditHandlePtr returnValue(
936 new SFUnrecNodePtr::EditHandle(
937 &_sfRoot,
938 this->getType().getFieldDesc(RootFieldId),
939 this));
941 returnValue->setSetMethod(
942 boost::bind(&Viewport::setRoot,
943 static_cast<Viewport *>(this), _1));
945 editSField(RootFieldMask);
947 return returnValue;
950 GetFieldHandlePtr ViewportBase::getHandleBackground (void) const
952 SFUnrecBackgroundPtr::GetHandlePtr returnValue(
953 new SFUnrecBackgroundPtr::GetHandle(
954 &_sfBackground,
955 this->getType().getFieldDesc(BackgroundFieldId),
956 const_cast<ViewportBase *>(this)));
958 return returnValue;
961 EditFieldHandlePtr ViewportBase::editHandleBackground (void)
963 SFUnrecBackgroundPtr::EditHandlePtr returnValue(
964 new SFUnrecBackgroundPtr::EditHandle(
965 &_sfBackground,
966 this->getType().getFieldDesc(BackgroundFieldId),
967 this));
969 returnValue->setSetMethod(
970 boost::bind(&Viewport::setBackground,
971 static_cast<Viewport *>(this), _1));
973 editSField(BackgroundFieldMask);
975 return returnValue;
978 GetFieldHandlePtr ViewportBase::getHandleForegrounds (void) const
980 MFUnrecForegroundPtr::GetHandlePtr returnValue(
981 new MFUnrecForegroundPtr::GetHandle(
982 &_mfForegrounds,
983 this->getType().getFieldDesc(ForegroundsFieldId),
984 const_cast<ViewportBase *>(this)));
986 return returnValue;
989 EditFieldHandlePtr ViewportBase::editHandleForegrounds (void)
991 MFUnrecForegroundPtr::EditHandlePtr returnValue(
992 new MFUnrecForegroundPtr::EditHandle(
993 &_mfForegrounds,
994 this->getType().getFieldDesc(ForegroundsFieldId),
995 this));
997 returnValue->setAddMethod(
998 boost::bind(&Viewport::addForeground,
999 static_cast<Viewport *>(this), _1));
1000 returnValue->setRemoveMethod(
1001 boost::bind(&Viewport::removeFromForegrounds,
1002 static_cast<Viewport *>(this), _1));
1003 returnValue->setRemoveObjMethod(
1004 boost::bind(&Viewport::removeObjFromForegrounds,
1005 static_cast<Viewport *>(this), _1));
1006 returnValue->setClearMethod(
1007 boost::bind(&Viewport::clearForegrounds,
1008 static_cast<Viewport *>(this)));
1010 editMField(ForegroundsFieldMask, _mfForegrounds);
1012 return returnValue;
1016 #ifdef OSG_MT_CPTR_ASPECT
1017 void ViewportBase::execSyncV( FieldContainer &oFrom,
1018 ConstFieldMaskArg whichField,
1019 AspectOffsetStore &oOffsets,
1020 ConstFieldMaskArg syncMode,
1021 const UInt32 uiSyncInfo)
1023 Viewport *pThis = static_cast<Viewport *>(this);
1025 pThis->execSync(static_cast<Viewport *>(&oFrom),
1026 whichField,
1027 oOffsets,
1028 syncMode,
1029 uiSyncInfo);
1031 #endif
1034 #ifdef OSG_MT_CPTR_ASPECT
1035 FieldContainer *ViewportBase::createAspectCopy(
1036 const FieldContainer *pRefAspect) const
1038 Viewport *returnValue;
1040 newAspectCopy(returnValue,
1041 dynamic_cast<const Viewport *>(pRefAspect),
1042 dynamic_cast<const Viewport *>(this));
1044 return returnValue;
1046 #endif
1048 void ViewportBase::resolveLinks(void)
1050 Inherited::resolveLinks();
1052 static_cast<Viewport *>(this)->setCamera(NULL);
1054 static_cast<Viewport *>(this)->setRoot(NULL);
1056 static_cast<Viewport *>(this)->setBackground(NULL);
1058 static_cast<Viewport *>(this)->clearForegrounds();
1064 OSG_END_NAMESPACE