fixed: gcc8 compile issues
[opensg.git] / Source / Contrib / ComplexSceneManager / OSGCSMViewportBase.cpp
blob19f0ffe0937499423b7bd57ed3cd011850e62089
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 CSMViewport!
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 "OSGNode.h" // Root Class
66 #include "OSGCamera.h" // Camera Class
67 #include "OSGBackground.h" // Background Class
68 #include "OSGForeground.h" // Foregrounds Class
69 #include "OSGRenderOptions.h" // RenderOptions Class
71 #include "OSGCSMViewportBase.h"
72 #include "OSGCSMViewport.h"
74 #include <boost/bind.hpp>
76 OSG_BEGIN_NAMESPACE
78 /***************************************************************************\
79 * Description *
80 \***************************************************************************/
82 /*! \class OSG::CSMViewport
86 /***************************************************************************\
87 * Field Documentation *
88 \***************************************************************************/
90 /*! \var Node * CSMViewportBase::_sfRoot
94 /*! \var Camera * CSMViewportBase::_sfCamera
98 /*! \var Background * CSMViewportBase::_sfBackground
102 /*! \var Foreground * CSMViewportBase::_mfForegrounds
106 /*! \var Vec2f CSMViewportBase::_sfLeftBottom
110 /*! \var Vec2f CSMViewportBase::_sfRightTop
114 /*! \var UInt32 CSMViewportBase::_sfTravMask
118 /*! \var RenderOptions * CSMViewportBase::_sfRenderOptions
122 /*! \var std::string CSMViewportBase::_sfStereoMode
126 /*! \var bool CSMViewportBase::_sfPassive
130 /*! \var Int32 CSMViewportBase::_sfServerId
131 If not -1 used by the cluster multi window to compute the corresponding
132 viewport
135 /*! \var MouseData CSMViewportBase::_sfMouseDataVC
136 MTouchData in local viewport coordinates
139 /*! \var MTouchData CSMViewportBase::_sfMTouchDataVC
140 MTouchData in local viewport coordinates
144 /***************************************************************************\
145 * FieldType/FieldTrait Instantiation *
146 \***************************************************************************/
148 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
149 PointerType FieldTraits<CSMViewport *, nsOSG>::_type(
150 "CSMViewportPtr",
151 "AttachmentContainerPtr",
152 CSMViewport::getClassType(),
153 nsOSG);
154 #endif
156 OSG_FIELDTRAITS_GETTYPE_NS(CSMViewport *, nsOSG)
158 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
159 CSMViewport *,
160 nsOSG)
162 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
163 CSMViewport *,
164 nsOSG)
166 /***************************************************************************\
167 * Field Description *
168 \***************************************************************************/
170 void CSMViewportBase::classDescInserter(TypeObject &oType)
172 FieldDescriptionBase *pDesc = NULL;
175 pDesc = new SFUnrecNodePtr::Description(
176 SFUnrecNodePtr::getClassType(),
177 "root",
179 RootFieldId, RootFieldMask,
180 false,
181 (Field::SFDefaultFlags | Field::FStdAccess),
182 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleRoot),
183 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleRoot));
185 oType.addInitialDesc(pDesc);
187 pDesc = new SFUnrecCameraPtr::Description(
188 SFUnrecCameraPtr::getClassType(),
189 "camera",
191 CameraFieldId, CameraFieldMask,
192 false,
193 (Field::SFDefaultFlags | Field::FStdAccess),
194 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleCamera),
195 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleCamera));
197 oType.addInitialDesc(pDesc);
199 pDesc = new SFUnrecBackgroundPtr::Description(
200 SFUnrecBackgroundPtr::getClassType(),
201 "background",
203 BackgroundFieldId, BackgroundFieldMask,
204 false,
205 (Field::SFDefaultFlags | Field::FStdAccess),
206 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleBackground),
207 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleBackground));
209 oType.addInitialDesc(pDesc);
211 pDesc = new MFUnrecForegroundPtr::Description(
212 MFUnrecForegroundPtr::getClassType(),
213 "foregrounds",
215 ForegroundsFieldId, ForegroundsFieldMask,
216 false,
217 (Field::MFDefaultFlags | Field::FStdAccess),
218 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleForegrounds),
219 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleForegrounds));
221 oType.addInitialDesc(pDesc);
223 pDesc = new SFVec2f::Description(
224 SFVec2f::getClassType(),
225 "leftBottom",
227 LeftBottomFieldId, LeftBottomFieldMask,
228 false,
229 (Field::SFDefaultFlags | Field::FStdAccess),
230 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleLeftBottom),
231 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleLeftBottom));
233 oType.addInitialDesc(pDesc);
235 pDesc = new SFVec2f::Description(
236 SFVec2f::getClassType(),
237 "rightTop",
239 RightTopFieldId, RightTopFieldMask,
240 false,
241 (Field::SFDefaultFlags | Field::FStdAccess),
242 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleRightTop),
243 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleRightTop));
245 oType.addInitialDesc(pDesc);
247 pDesc = new SFUInt32::Description(
248 SFUInt32::getClassType(),
249 "travMask",
251 TravMaskFieldId, TravMaskFieldMask,
252 false,
253 (Field::SFDefaultFlags | Field::FStdAccess),
254 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleTravMask),
255 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleTravMask));
257 oType.addInitialDesc(pDesc);
259 pDesc = new SFUnrecRenderOptionsPtr::Description(
260 SFUnrecRenderOptionsPtr::getClassType(),
261 "renderOptions",
263 RenderOptionsFieldId, RenderOptionsFieldMask,
264 false,
265 (Field::SFDefaultFlags | Field::FStdAccess),
266 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleRenderOptions),
267 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleRenderOptions));
269 oType.addInitialDesc(pDesc);
271 pDesc = new SFString::Description(
272 SFString::getClassType(),
273 "stereoMode",
275 StereoModeFieldId, StereoModeFieldMask,
276 false,
277 (Field::SFDefaultFlags | Field::FStdAccess),
278 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleStereoMode),
279 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleStereoMode));
281 oType.addInitialDesc(pDesc);
283 pDesc = new SFBool::Description(
284 SFBool::getClassType(),
285 "passive",
287 PassiveFieldId, PassiveFieldMask,
288 false,
289 (Field::SFDefaultFlags | Field::FStdAccess),
290 static_cast<FieldEditMethodSig>(&CSMViewport::editHandlePassive),
291 static_cast<FieldGetMethodSig >(&CSMViewport::getHandlePassive));
293 oType.addInitialDesc(pDesc);
295 pDesc = new SFInt32::Description(
296 SFInt32::getClassType(),
297 "serverId",
298 "If not -1 used by the cluster multi window to compute the corresponding\n"
299 "viewport\n",
300 ServerIdFieldId, ServerIdFieldMask,
301 false,
302 (Field::SFDefaultFlags | Field::FStdAccess),
303 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleServerId),
304 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleServerId));
306 oType.addInitialDesc(pDesc);
308 pDesc = new SFMouseData::Description(
309 SFMouseData::getClassType(),
310 "mouseDataVC",
311 "MTouchData in local viewport coordinates\n",
312 MouseDataVCFieldId, MouseDataVCFieldMask,
313 true,
314 (Field::SFDefaultFlags | Field::FStdAccess),
315 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleMouseDataVC),
316 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleMouseDataVC));
318 oType.addInitialDesc(pDesc);
320 pDesc = new SFMTouchData::Description(
321 SFMTouchData::getClassType(),
322 "MTouchDataVC",
323 "MTouchData in local viewport coordinates\n",
324 MTouchDataVCFieldId, MTouchDataVCFieldMask,
325 true,
326 (Field::SFDefaultFlags | Field::FStdAccess),
327 static_cast<FieldEditMethodSig>(&CSMViewport::editHandleMTouchDataVC),
328 static_cast<FieldGetMethodSig >(&CSMViewport::getHandleMTouchDataVC));
330 oType.addInitialDesc(pDesc);
334 CSMViewportBase::TypeObject CSMViewportBase::_type(
335 CSMViewportBase::getClassname(),
336 Inherited::getClassname(),
337 "NULL",
338 nsOSG, //Namespace
339 reinterpret_cast<PrototypeCreateF>(&CSMViewportBase::createEmptyLocal),
340 reinterpret_cast<InitContainerF>(&CSMViewport::initMethod),
341 reinterpret_cast<ExitContainerF>(&CSMViewport::exitMethod),
342 reinterpret_cast<InitalInsertDescFunc>(&CSMViewport::classDescInserter),
343 false,
345 "<?xml version=\"1.0\"?>\n"
346 "\n"
347 "<FieldContainer\n"
348 " name=\"CSMViewport\"\n"
349 " parent=\"AttachmentContainer\"\n"
350 " library=\"ContribCSM\"\n"
351 " pointerfieldtypes=\"both\"\n"
352 " structure=\"concrete\"\n"
353 " systemcomponent=\"true\"\n"
354 " parentsystemcomponent=\"true\"\n"
355 " decoratable=\"false\"\n"
356 " useLocalIncludes=\"false\"\n"
357 " isNodeCore=\"false\"\n"
358 " isBundle=\"true\"\n"
359 " >\n"
360 " <Field\n"
361 " name=\"root\"\n"
362 " type=\"Node\"\n"
363 " cardinality=\"single\"\n"
364 " visibility=\"external\"\n"
365 " defaultValue=\"NULL\"\n"
366 " access=\"public\"\n"
367 " category=\"pointer\"\n"
368 " >\n"
369 " </Field>\n"
370 " <Field\n"
371 " name=\"camera\"\n"
372 " type=\"Camera\"\n"
373 " cardinality=\"single\"\n"
374 " visibility=\"external\"\n"
375 " defaultValue=\"NULL\"\n"
376 " access=\"public\"\n"
377 " category=\"pointer\"\n"
378 " >\n"
379 " </Field>\n"
380 " <Field\n"
381 " name=\"background\"\n"
382 " type=\"Background\"\n"
383 " cardinality=\"single\"\n"
384 " visibility=\"external\"\n"
385 " access=\"public\"\n"
386 " category=\"pointer\"\n"
387 " >\n"
388 " </Field>\n"
389 " <Field\n"
390 " name=\"foregrounds\"\n"
391 " type=\"Foreground\"\n"
392 " cardinality=\"multi\"\n"
393 " visibility=\"external\"\n"
394 " access=\"public\"\n"
395 " category=\"pointer\"\n"
396 " >\n"
397 " </Field>\n"
398 " <Field\n"
399 " name=\"leftBottom\"\n"
400 " type=\"Vec2f\"\n"
401 " cardinality=\"single\"\n"
402 " visibility=\"external\"\n"
403 " access=\"public\"\n"
404 " defaultValue=\"0.f, 0.f\"\n"
405 " >\n"
406 " </Field>\n"
407 " <Field\n"
408 " name=\"rightTop\"\n"
409 " type=\"Vec2f\"\n"
410 " cardinality=\"single\"\n"
411 " visibility=\"external\"\n"
412 " access=\"public\"\n"
413 " defaultValue=\"1.f, 1.f\"\n"
414 " >\n"
415 " </Field>\n"
416 " <Field\n"
417 " name=\"travMask\"\n"
418 " type=\"UInt32\"\n"
419 " cardinality=\"single\"\n"
420 " visibility=\"external\"\n"
421 " access=\"public\"\n"
422 " defaultValue=\"TypeTraits&lt;UInt32&gt;::BitsSet &amp; ~TraversalMasks::FindNamedComponentTraversal\"\n"
423 " >\n"
424 " </Field>\n"
425 " <Field\n"
426 " name=\"renderOptions\"\n"
427 " type=\"RenderOptionsPtr\"\n"
428 " cardinality=\"single\"\n"
429 " visibility=\"external\"\n"
430 " access=\"public\"\n"
431 " defaultValue=\"NULL\"\n"
432 " >\n"
433 " </Field>\n"
434 " <Field\n"
435 " name=\"stereoMode\"\n"
436 " type=\"std::string\"\n"
437 " cardinality=\"single\"\n"
438 " visibility=\"external\"\n"
439 " access=\"public\"\n"
440 " defaultValue='\"none\"'\n"
441 " >\n"
442 " </Field>\n"
443 " <Field\n"
444 " name=\"passive\"\n"
445 " type=\"bool\"\n"
446 " cardinality=\"single\"\n"
447 " visibility=\"external\"\n"
448 " access=\"public\"\n"
449 " defaultValue=\"false\"\n"
450 " >\n"
451 " </Field>\n"
452 " <Field\n"
453 " name=\"serverId\"\n"
454 " type=\"Int32\"\n"
455 " cardinality=\"single\"\n"
456 " visibility=\"external\"\n"
457 " access=\"public\"\n"
458 " defaultValue=\"-1\"\n"
459 " >\n"
460 " If not -1 used by the cluster multi window to compute the corresponding\n"
461 " viewport\n"
462 " </Field>\n"
463 "\n"
464 " <Field\n"
465 " name=\"mouseDataVC\"\n"
466 " type=\"MouseData\"\n"
467 " cardinality=\"single\"\n"
468 " visibility=\"internal\"\n"
469 " access=\"public\"\n"
470 " >\n"
471 " MTouchData in local viewport coordinates\n"
472 " </Field>\n"
473 " <Field\n"
474 " name=\"MTouchDataVC\"\n"
475 " type=\"MTouchData\"\n"
476 " cardinality=\"single\"\n"
477 " visibility=\"internal\"\n"
478 " access=\"public\"\n"
479 " >\n"
480 " MTouchData in local viewport coordinates\n"
481 " </Field>\n"
482 "\n"
483 "</FieldContainer>\n",
487 /*------------------------------ get -----------------------------------*/
489 FieldContainerType &CSMViewportBase::getType(void)
491 return _type;
494 const FieldContainerType &CSMViewportBase::getType(void) const
496 return _type;
499 UInt32 CSMViewportBase::getContainerSize(void) const
501 return sizeof(CSMViewport);
504 /*------------------------- decorator get ------------------------------*/
507 //! Get the CSMViewport::_sfRoot field.
508 const SFUnrecNodePtr *CSMViewportBase::getSFRoot(void) const
510 return &_sfRoot;
513 SFUnrecNodePtr *CSMViewportBase::editSFRoot (void)
515 editSField(RootFieldMask);
517 return &_sfRoot;
520 //! Get the value of the CSMViewport::_sfRoot field.
521 Node * CSMViewportBase::getRoot(void) const
523 return _sfRoot.getValue();
526 //! Set the value of the CSMViewport::_sfRoot field.
527 void CSMViewportBase::setRoot(Node * const value)
529 editSField(RootFieldMask);
531 _sfRoot.setValue(value);
535 //! Get the CSMViewport::_sfCamera field.
536 const SFUnrecCameraPtr *CSMViewportBase::getSFCamera(void) const
538 return &_sfCamera;
541 SFUnrecCameraPtr *CSMViewportBase::editSFCamera (void)
543 editSField(CameraFieldMask);
545 return &_sfCamera;
548 //! Get the value of the CSMViewport::_sfCamera field.
549 Camera * CSMViewportBase::getCamera(void) const
551 return _sfCamera.getValue();
554 //! Set the value of the CSMViewport::_sfCamera field.
555 void CSMViewportBase::setCamera(Camera * const value)
557 editSField(CameraFieldMask);
559 _sfCamera.setValue(value);
563 //! Get the CSMViewport::_sfBackground field.
564 const SFUnrecBackgroundPtr *CSMViewportBase::getSFBackground(void) const
566 return &_sfBackground;
569 SFUnrecBackgroundPtr *CSMViewportBase::editSFBackground (void)
571 editSField(BackgroundFieldMask);
573 return &_sfBackground;
576 //! Get the value of the CSMViewport::_sfBackground field.
577 Background * CSMViewportBase::getBackground(void) const
579 return _sfBackground.getValue();
582 //! Set the value of the CSMViewport::_sfBackground field.
583 void CSMViewportBase::setBackground(Background * const value)
585 editSField(BackgroundFieldMask);
587 _sfBackground.setValue(value);
591 //! Get the CSMViewport::_mfForegrounds field.
592 const MFUnrecForegroundPtr *CSMViewportBase::getMFForegrounds(void) const
594 return &_mfForegrounds;
597 MFUnrecForegroundPtr *CSMViewportBase::editMFForegrounds (void)
599 editMField(ForegroundsFieldMask, _mfForegrounds);
601 return &_mfForegrounds;
603 Foreground * CSMViewportBase::getForegrounds(const UInt32 index) const
605 return _mfForegrounds[index];
608 SFVec2f *CSMViewportBase::editSFLeftBottom(void)
610 editSField(LeftBottomFieldMask);
612 return &_sfLeftBottom;
615 const SFVec2f *CSMViewportBase::getSFLeftBottom(void) const
617 return &_sfLeftBottom;
621 SFVec2f *CSMViewportBase::editSFRightTop(void)
623 editSField(RightTopFieldMask);
625 return &_sfRightTop;
628 const SFVec2f *CSMViewportBase::getSFRightTop(void) const
630 return &_sfRightTop;
634 SFUInt32 *CSMViewportBase::editSFTravMask(void)
636 editSField(TravMaskFieldMask);
638 return &_sfTravMask;
641 const SFUInt32 *CSMViewportBase::getSFTravMask(void) const
643 return &_sfTravMask;
647 //! Get the CSMViewport::_sfRenderOptions field.
648 const SFUnrecRenderOptionsPtr *CSMViewportBase::getSFRenderOptions(void) const
650 return &_sfRenderOptions;
653 SFUnrecRenderOptionsPtr *CSMViewportBase::editSFRenderOptions (void)
655 editSField(RenderOptionsFieldMask);
657 return &_sfRenderOptions;
660 //! Get the value of the CSMViewport::_sfRenderOptions field.
661 RenderOptions * CSMViewportBase::getRenderOptions(void) const
663 return _sfRenderOptions.getValue();
666 //! Set the value of the CSMViewport::_sfRenderOptions field.
667 void CSMViewportBase::setRenderOptions(RenderOptions * const value)
669 editSField(RenderOptionsFieldMask);
671 _sfRenderOptions.setValue(value);
675 SFString *CSMViewportBase::editSFStereoMode(void)
677 editSField(StereoModeFieldMask);
679 return &_sfStereoMode;
682 const SFString *CSMViewportBase::getSFStereoMode(void) const
684 return &_sfStereoMode;
688 SFBool *CSMViewportBase::editSFPassive(void)
690 editSField(PassiveFieldMask);
692 return &_sfPassive;
695 const SFBool *CSMViewportBase::getSFPassive(void) const
697 return &_sfPassive;
701 SFInt32 *CSMViewportBase::editSFServerId(void)
703 editSField(ServerIdFieldMask);
705 return &_sfServerId;
708 const SFInt32 *CSMViewportBase::getSFServerId(void) const
710 return &_sfServerId;
714 SFMouseData *CSMViewportBase::editSFMouseDataVC(void)
716 editSField(MouseDataVCFieldMask);
718 return &_sfMouseDataVC;
721 const SFMouseData *CSMViewportBase::getSFMouseDataVC(void) const
723 return &_sfMouseDataVC;
727 SFMTouchData *CSMViewportBase::editSFMTouchDataVC(void)
729 editSField(MTouchDataVCFieldMask);
731 return &_sfMTouchDataVC;
734 const SFMTouchData *CSMViewportBase::getSFMTouchDataVC(void) const
736 return &_sfMTouchDataVC;
742 void CSMViewportBase::pushToForegrounds(Foreground * const value)
744 editMField(ForegroundsFieldMask, _mfForegrounds);
746 _mfForegrounds.push_back(value);
749 void CSMViewportBase::assignForegrounds(const MFUnrecForegroundPtr &value)
751 MFUnrecForegroundPtr::const_iterator elemIt =
752 value.begin();
753 MFUnrecForegroundPtr::const_iterator elemEnd =
754 value.end ();
756 static_cast<CSMViewport *>(this)->clearForegrounds();
758 while(elemIt != elemEnd)
760 this->pushToForegrounds(*elemIt);
762 ++elemIt;
766 void CSMViewportBase::removeFromForegrounds(UInt32 uiIndex)
768 if(uiIndex < _mfForegrounds.size())
770 editMField(ForegroundsFieldMask, _mfForegrounds);
772 _mfForegrounds.erase(uiIndex);
776 void CSMViewportBase::removeObjFromForegrounds(Foreground * const value)
778 Int32 iElemIdx = _mfForegrounds.findIndex(value);
780 if(iElemIdx != -1)
782 editMField(ForegroundsFieldMask, _mfForegrounds);
784 _mfForegrounds.erase(iElemIdx);
787 void CSMViewportBase::clearForegrounds(void)
789 editMField(ForegroundsFieldMask, _mfForegrounds);
792 _mfForegrounds.clear();
797 /*------------------------------ access -----------------------------------*/
799 SizeT CSMViewportBase::getBinSize(ConstFieldMaskArg whichField)
801 SizeT returnValue = Inherited::getBinSize(whichField);
803 if(FieldBits::NoField != (RootFieldMask & whichField))
805 returnValue += _sfRoot.getBinSize();
807 if(FieldBits::NoField != (CameraFieldMask & whichField))
809 returnValue += _sfCamera.getBinSize();
811 if(FieldBits::NoField != (BackgroundFieldMask & whichField))
813 returnValue += _sfBackground.getBinSize();
815 if(FieldBits::NoField != (ForegroundsFieldMask & whichField))
817 returnValue += _mfForegrounds.getBinSize();
819 if(FieldBits::NoField != (LeftBottomFieldMask & whichField))
821 returnValue += _sfLeftBottom.getBinSize();
823 if(FieldBits::NoField != (RightTopFieldMask & whichField))
825 returnValue += _sfRightTop.getBinSize();
827 if(FieldBits::NoField != (TravMaskFieldMask & whichField))
829 returnValue += _sfTravMask.getBinSize();
831 if(FieldBits::NoField != (RenderOptionsFieldMask & whichField))
833 returnValue += _sfRenderOptions.getBinSize();
835 if(FieldBits::NoField != (StereoModeFieldMask & whichField))
837 returnValue += _sfStereoMode.getBinSize();
839 if(FieldBits::NoField != (PassiveFieldMask & whichField))
841 returnValue += _sfPassive.getBinSize();
843 if(FieldBits::NoField != (ServerIdFieldMask & whichField))
845 returnValue += _sfServerId.getBinSize();
847 if(FieldBits::NoField != (MouseDataVCFieldMask & whichField))
849 returnValue += _sfMouseDataVC.getBinSize();
851 if(FieldBits::NoField != (MTouchDataVCFieldMask & whichField))
853 returnValue += _sfMTouchDataVC.getBinSize();
856 return returnValue;
859 void CSMViewportBase::copyToBin(BinaryDataHandler &pMem,
860 ConstFieldMaskArg whichField)
862 Inherited::copyToBin(pMem, whichField);
864 if(FieldBits::NoField != (RootFieldMask & whichField))
866 _sfRoot.copyToBin(pMem);
868 if(FieldBits::NoField != (CameraFieldMask & whichField))
870 _sfCamera.copyToBin(pMem);
872 if(FieldBits::NoField != (BackgroundFieldMask & whichField))
874 _sfBackground.copyToBin(pMem);
876 if(FieldBits::NoField != (ForegroundsFieldMask & whichField))
878 _mfForegrounds.copyToBin(pMem);
880 if(FieldBits::NoField != (LeftBottomFieldMask & whichField))
882 _sfLeftBottom.copyToBin(pMem);
884 if(FieldBits::NoField != (RightTopFieldMask & whichField))
886 _sfRightTop.copyToBin(pMem);
888 if(FieldBits::NoField != (TravMaskFieldMask & whichField))
890 _sfTravMask.copyToBin(pMem);
892 if(FieldBits::NoField != (RenderOptionsFieldMask & whichField))
894 _sfRenderOptions.copyToBin(pMem);
896 if(FieldBits::NoField != (StereoModeFieldMask & whichField))
898 _sfStereoMode.copyToBin(pMem);
900 if(FieldBits::NoField != (PassiveFieldMask & whichField))
902 _sfPassive.copyToBin(pMem);
904 if(FieldBits::NoField != (ServerIdFieldMask & whichField))
906 _sfServerId.copyToBin(pMem);
908 if(FieldBits::NoField != (MouseDataVCFieldMask & whichField))
910 _sfMouseDataVC.copyToBin(pMem);
912 if(FieldBits::NoField != (MTouchDataVCFieldMask & whichField))
914 _sfMTouchDataVC.copyToBin(pMem);
918 void CSMViewportBase::copyFromBin(BinaryDataHandler &pMem,
919 ConstFieldMaskArg whichField)
921 Inherited::copyFromBin(pMem, whichField);
923 if(FieldBits::NoField != (RootFieldMask & whichField))
925 editSField(RootFieldMask);
926 _sfRoot.copyFromBin(pMem);
928 if(FieldBits::NoField != (CameraFieldMask & whichField))
930 editSField(CameraFieldMask);
931 _sfCamera.copyFromBin(pMem);
933 if(FieldBits::NoField != (BackgroundFieldMask & whichField))
935 editSField(BackgroundFieldMask);
936 _sfBackground.copyFromBin(pMem);
938 if(FieldBits::NoField != (ForegroundsFieldMask & whichField))
940 editMField(ForegroundsFieldMask, _mfForegrounds);
941 _mfForegrounds.copyFromBin(pMem);
943 if(FieldBits::NoField != (LeftBottomFieldMask & whichField))
945 editSField(LeftBottomFieldMask);
946 _sfLeftBottom.copyFromBin(pMem);
948 if(FieldBits::NoField != (RightTopFieldMask & whichField))
950 editSField(RightTopFieldMask);
951 _sfRightTop.copyFromBin(pMem);
953 if(FieldBits::NoField != (TravMaskFieldMask & whichField))
955 editSField(TravMaskFieldMask);
956 _sfTravMask.copyFromBin(pMem);
958 if(FieldBits::NoField != (RenderOptionsFieldMask & whichField))
960 editSField(RenderOptionsFieldMask);
961 _sfRenderOptions.copyFromBin(pMem);
963 if(FieldBits::NoField != (StereoModeFieldMask & whichField))
965 editSField(StereoModeFieldMask);
966 _sfStereoMode.copyFromBin(pMem);
968 if(FieldBits::NoField != (PassiveFieldMask & whichField))
970 editSField(PassiveFieldMask);
971 _sfPassive.copyFromBin(pMem);
973 if(FieldBits::NoField != (ServerIdFieldMask & whichField))
975 editSField(ServerIdFieldMask);
976 _sfServerId.copyFromBin(pMem);
978 if(FieldBits::NoField != (MouseDataVCFieldMask & whichField))
980 editSField(MouseDataVCFieldMask);
981 _sfMouseDataVC.copyFromBin(pMem);
983 if(FieldBits::NoField != (MTouchDataVCFieldMask & whichField))
985 editSField(MTouchDataVCFieldMask);
986 _sfMTouchDataVC.copyFromBin(pMem);
990 //! create a new instance of the class
991 CSMViewportTransitPtr CSMViewportBase::createLocal(BitVector bFlags)
993 CSMViewportTransitPtr fc;
995 if(getClassType().getPrototype() != NULL)
997 FieldContainerTransitPtr tmpPtr =
998 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
1000 fc = dynamic_pointer_cast<CSMViewport>(tmpPtr);
1003 return fc;
1006 //! create a new instance of the class, copy the container flags
1007 CSMViewportTransitPtr CSMViewportBase::createDependent(BitVector bFlags)
1009 CSMViewportTransitPtr fc;
1011 if(getClassType().getPrototype() != NULL)
1013 FieldContainerTransitPtr tmpPtr =
1014 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
1016 fc = dynamic_pointer_cast<CSMViewport>(tmpPtr);
1019 return fc;
1022 //! create a new instance of the class
1023 CSMViewportTransitPtr CSMViewportBase::create(void)
1025 return createLocal();
1028 CSMViewport *CSMViewportBase::createEmptyLocal(BitVector bFlags)
1030 CSMViewport *returnValue;
1032 newPtr<CSMViewport>(returnValue, bFlags);
1034 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
1036 return returnValue;
1039 //! create an empty new instance of the class, do not copy the prototype
1040 CSMViewport *CSMViewportBase::createEmpty(void)
1042 return createEmptyLocal();
1046 FieldContainerTransitPtr CSMViewportBase::shallowCopyLocal(
1047 BitVector bFlags) const
1049 CSMViewport *tmpPtr;
1051 newPtr(tmpPtr, dynamic_cast<const CSMViewport *>(this), bFlags);
1053 FieldContainerTransitPtr returnValue(tmpPtr);
1055 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
1057 return returnValue;
1060 FieldContainerTransitPtr CSMViewportBase::shallowCopyDependent(
1061 BitVector bFlags) const
1063 CSMViewport *tmpPtr;
1065 newPtr(tmpPtr, dynamic_cast<const CSMViewport *>(this), ~bFlags);
1067 FieldContainerTransitPtr returnValue(tmpPtr);
1069 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
1071 return returnValue;
1074 FieldContainerTransitPtr CSMViewportBase::shallowCopy(void) const
1076 return shallowCopyLocal();
1082 /*------------------------- constructors ----------------------------------*/
1084 CSMViewportBase::CSMViewportBase(void) :
1085 Inherited(),
1086 _sfRoot (NULL),
1087 _sfCamera (NULL),
1088 _sfBackground (NULL),
1089 _mfForegrounds (),
1090 _sfLeftBottom (Vec2f(0.f, 0.f)),
1091 _sfRightTop (Vec2f(1.f, 1.f)),
1092 _sfTravMask (UInt32(TypeTraits<UInt32>::BitsSet & ~TraversalMasks::FindNamedComponentTraversal)),
1093 _sfRenderOptions (NULL),
1094 _sfStereoMode (std::string("none")),
1095 _sfPassive (bool(false)),
1096 _sfServerId (Int32(-1)),
1097 _sfMouseDataVC (),
1098 _sfMTouchDataVC ()
1102 CSMViewportBase::CSMViewportBase(const CSMViewportBase &source) :
1103 Inherited(source),
1104 _sfRoot (NULL),
1105 _sfCamera (NULL),
1106 _sfBackground (NULL),
1107 _mfForegrounds (),
1108 _sfLeftBottom (source._sfLeftBottom ),
1109 _sfRightTop (source._sfRightTop ),
1110 _sfTravMask (source._sfTravMask ),
1111 _sfRenderOptions (NULL),
1112 _sfStereoMode (source._sfStereoMode ),
1113 _sfPassive (source._sfPassive ),
1114 _sfServerId (source._sfServerId ),
1115 _sfMouseDataVC (source._sfMouseDataVC ),
1116 _sfMTouchDataVC (source._sfMTouchDataVC )
1121 /*-------------------------- destructors ----------------------------------*/
1123 CSMViewportBase::~CSMViewportBase(void)
1127 void CSMViewportBase::onCreate(const CSMViewport *source)
1129 Inherited::onCreate(source);
1131 if(source != NULL)
1133 CSMViewport *pThis = static_cast<CSMViewport *>(this);
1135 pThis->setRoot(source->getRoot());
1137 pThis->setCamera(source->getCamera());
1139 pThis->setBackground(source->getBackground());
1141 MFUnrecForegroundPtr::const_iterator ForegroundsIt =
1142 source->_mfForegrounds.begin();
1143 MFUnrecForegroundPtr::const_iterator ForegroundsEnd =
1144 source->_mfForegrounds.end ();
1146 while(ForegroundsIt != ForegroundsEnd)
1148 pThis->pushToForegrounds(*ForegroundsIt);
1150 ++ForegroundsIt;
1153 pThis->setRenderOptions(source->getRenderOptions());
1157 GetFieldHandlePtr CSMViewportBase::getHandleRoot (void) const
1159 SFUnrecNodePtr::GetHandlePtr returnValue(
1160 new SFUnrecNodePtr::GetHandle(
1161 &_sfRoot,
1162 this->getType().getFieldDesc(RootFieldId),
1163 const_cast<CSMViewportBase *>(this)));
1165 return returnValue;
1168 EditFieldHandlePtr CSMViewportBase::editHandleRoot (void)
1170 SFUnrecNodePtr::EditHandlePtr returnValue(
1171 new SFUnrecNodePtr::EditHandle(
1172 &_sfRoot,
1173 this->getType().getFieldDesc(RootFieldId),
1174 this));
1176 returnValue->setSetMethod(
1177 boost::bind(&CSMViewport::setRoot,
1178 static_cast<CSMViewport *>(this), _1));
1180 editSField(RootFieldMask);
1182 return returnValue;
1185 GetFieldHandlePtr CSMViewportBase::getHandleCamera (void) const
1187 SFUnrecCameraPtr::GetHandlePtr returnValue(
1188 new SFUnrecCameraPtr::GetHandle(
1189 &_sfCamera,
1190 this->getType().getFieldDesc(CameraFieldId),
1191 const_cast<CSMViewportBase *>(this)));
1193 return returnValue;
1196 EditFieldHandlePtr CSMViewportBase::editHandleCamera (void)
1198 SFUnrecCameraPtr::EditHandlePtr returnValue(
1199 new SFUnrecCameraPtr::EditHandle(
1200 &_sfCamera,
1201 this->getType().getFieldDesc(CameraFieldId),
1202 this));
1204 returnValue->setSetMethod(
1205 boost::bind(&CSMViewport::setCamera,
1206 static_cast<CSMViewport *>(this), _1));
1208 editSField(CameraFieldMask);
1210 return returnValue;
1213 GetFieldHandlePtr CSMViewportBase::getHandleBackground (void) const
1215 SFUnrecBackgroundPtr::GetHandlePtr returnValue(
1216 new SFUnrecBackgroundPtr::GetHandle(
1217 &_sfBackground,
1218 this->getType().getFieldDesc(BackgroundFieldId),
1219 const_cast<CSMViewportBase *>(this)));
1221 return returnValue;
1224 EditFieldHandlePtr CSMViewportBase::editHandleBackground (void)
1226 SFUnrecBackgroundPtr::EditHandlePtr returnValue(
1227 new SFUnrecBackgroundPtr::EditHandle(
1228 &_sfBackground,
1229 this->getType().getFieldDesc(BackgroundFieldId),
1230 this));
1232 returnValue->setSetMethod(
1233 boost::bind(&CSMViewport::setBackground,
1234 static_cast<CSMViewport *>(this), _1));
1236 editSField(BackgroundFieldMask);
1238 return returnValue;
1241 GetFieldHandlePtr CSMViewportBase::getHandleForegrounds (void) const
1243 MFUnrecForegroundPtr::GetHandlePtr returnValue(
1244 new MFUnrecForegroundPtr::GetHandle(
1245 &_mfForegrounds,
1246 this->getType().getFieldDesc(ForegroundsFieldId),
1247 const_cast<CSMViewportBase *>(this)));
1249 return returnValue;
1252 EditFieldHandlePtr CSMViewportBase::editHandleForegrounds (void)
1254 MFUnrecForegroundPtr::EditHandlePtr returnValue(
1255 new MFUnrecForegroundPtr::EditHandle(
1256 &_mfForegrounds,
1257 this->getType().getFieldDesc(ForegroundsFieldId),
1258 this));
1260 returnValue->setAddMethod(
1261 boost::bind(&CSMViewport::pushToForegrounds,
1262 static_cast<CSMViewport *>(this), _1));
1263 returnValue->setRemoveMethod(
1264 boost::bind(&CSMViewport::removeFromForegrounds,
1265 static_cast<CSMViewport *>(this), _1));
1266 returnValue->setRemoveObjMethod(
1267 boost::bind(&CSMViewport::removeObjFromForegrounds,
1268 static_cast<CSMViewport *>(this), _1));
1269 returnValue->setClearMethod(
1270 boost::bind(&CSMViewport::clearForegrounds,
1271 static_cast<CSMViewport *>(this)));
1273 editMField(ForegroundsFieldMask, _mfForegrounds);
1275 return returnValue;
1278 GetFieldHandlePtr CSMViewportBase::getHandleLeftBottom (void) const
1280 SFVec2f::GetHandlePtr returnValue(
1281 new SFVec2f::GetHandle(
1282 &_sfLeftBottom,
1283 this->getType().getFieldDesc(LeftBottomFieldId),
1284 const_cast<CSMViewportBase *>(this)));
1286 return returnValue;
1289 EditFieldHandlePtr CSMViewportBase::editHandleLeftBottom (void)
1291 SFVec2f::EditHandlePtr returnValue(
1292 new SFVec2f::EditHandle(
1293 &_sfLeftBottom,
1294 this->getType().getFieldDesc(LeftBottomFieldId),
1295 this));
1298 editSField(LeftBottomFieldMask);
1300 return returnValue;
1303 GetFieldHandlePtr CSMViewportBase::getHandleRightTop (void) const
1305 SFVec2f::GetHandlePtr returnValue(
1306 new SFVec2f::GetHandle(
1307 &_sfRightTop,
1308 this->getType().getFieldDesc(RightTopFieldId),
1309 const_cast<CSMViewportBase *>(this)));
1311 return returnValue;
1314 EditFieldHandlePtr CSMViewportBase::editHandleRightTop (void)
1316 SFVec2f::EditHandlePtr returnValue(
1317 new SFVec2f::EditHandle(
1318 &_sfRightTop,
1319 this->getType().getFieldDesc(RightTopFieldId),
1320 this));
1323 editSField(RightTopFieldMask);
1325 return returnValue;
1328 GetFieldHandlePtr CSMViewportBase::getHandleTravMask (void) const
1330 SFUInt32::GetHandlePtr returnValue(
1331 new SFUInt32::GetHandle(
1332 &_sfTravMask,
1333 this->getType().getFieldDesc(TravMaskFieldId),
1334 const_cast<CSMViewportBase *>(this)));
1336 return returnValue;
1339 EditFieldHandlePtr CSMViewportBase::editHandleTravMask (void)
1341 SFUInt32::EditHandlePtr returnValue(
1342 new SFUInt32::EditHandle(
1343 &_sfTravMask,
1344 this->getType().getFieldDesc(TravMaskFieldId),
1345 this));
1348 editSField(TravMaskFieldMask);
1350 return returnValue;
1353 GetFieldHandlePtr CSMViewportBase::getHandleRenderOptions (void) const
1355 SFUnrecRenderOptionsPtr::GetHandlePtr returnValue(
1356 new SFUnrecRenderOptionsPtr::GetHandle(
1357 &_sfRenderOptions,
1358 this->getType().getFieldDesc(RenderOptionsFieldId),
1359 const_cast<CSMViewportBase *>(this)));
1361 return returnValue;
1364 EditFieldHandlePtr CSMViewportBase::editHandleRenderOptions (void)
1366 SFUnrecRenderOptionsPtr::EditHandlePtr returnValue(
1367 new SFUnrecRenderOptionsPtr::EditHandle(
1368 &_sfRenderOptions,
1369 this->getType().getFieldDesc(RenderOptionsFieldId),
1370 this));
1372 returnValue->setSetMethod(
1373 boost::bind(&CSMViewport::setRenderOptions,
1374 static_cast<CSMViewport *>(this), _1));
1376 editSField(RenderOptionsFieldMask);
1378 return returnValue;
1381 GetFieldHandlePtr CSMViewportBase::getHandleStereoMode (void) const
1383 SFString::GetHandlePtr returnValue(
1384 new SFString::GetHandle(
1385 &_sfStereoMode,
1386 this->getType().getFieldDesc(StereoModeFieldId),
1387 const_cast<CSMViewportBase *>(this)));
1389 return returnValue;
1392 EditFieldHandlePtr CSMViewportBase::editHandleStereoMode (void)
1394 SFString::EditHandlePtr returnValue(
1395 new SFString::EditHandle(
1396 &_sfStereoMode,
1397 this->getType().getFieldDesc(StereoModeFieldId),
1398 this));
1401 editSField(StereoModeFieldMask);
1403 return returnValue;
1406 GetFieldHandlePtr CSMViewportBase::getHandlePassive (void) const
1408 SFBool::GetHandlePtr returnValue(
1409 new SFBool::GetHandle(
1410 &_sfPassive,
1411 this->getType().getFieldDesc(PassiveFieldId),
1412 const_cast<CSMViewportBase *>(this)));
1414 return returnValue;
1417 EditFieldHandlePtr CSMViewportBase::editHandlePassive (void)
1419 SFBool::EditHandlePtr returnValue(
1420 new SFBool::EditHandle(
1421 &_sfPassive,
1422 this->getType().getFieldDesc(PassiveFieldId),
1423 this));
1426 editSField(PassiveFieldMask);
1428 return returnValue;
1431 GetFieldHandlePtr CSMViewportBase::getHandleServerId (void) const
1433 SFInt32::GetHandlePtr returnValue(
1434 new SFInt32::GetHandle(
1435 &_sfServerId,
1436 this->getType().getFieldDesc(ServerIdFieldId),
1437 const_cast<CSMViewportBase *>(this)));
1439 return returnValue;
1442 EditFieldHandlePtr CSMViewportBase::editHandleServerId (void)
1444 SFInt32::EditHandlePtr returnValue(
1445 new SFInt32::EditHandle(
1446 &_sfServerId,
1447 this->getType().getFieldDesc(ServerIdFieldId),
1448 this));
1451 editSField(ServerIdFieldMask);
1453 return returnValue;
1456 GetFieldHandlePtr CSMViewportBase::getHandleMouseDataVC (void) const
1458 SFMouseData::GetHandlePtr returnValue(
1459 new SFMouseData::GetHandle(
1460 &_sfMouseDataVC,
1461 this->getType().getFieldDesc(MouseDataVCFieldId),
1462 const_cast<CSMViewportBase *>(this)));
1464 return returnValue;
1467 EditFieldHandlePtr CSMViewportBase::editHandleMouseDataVC (void)
1469 SFMouseData::EditHandlePtr returnValue(
1470 new SFMouseData::EditHandle(
1471 &_sfMouseDataVC,
1472 this->getType().getFieldDesc(MouseDataVCFieldId),
1473 this));
1476 editSField(MouseDataVCFieldMask);
1478 return returnValue;
1481 GetFieldHandlePtr CSMViewportBase::getHandleMTouchDataVC (void) const
1483 SFMTouchData::GetHandlePtr returnValue(
1484 new SFMTouchData::GetHandle(
1485 &_sfMTouchDataVC,
1486 this->getType().getFieldDesc(MTouchDataVCFieldId),
1487 const_cast<CSMViewportBase *>(this)));
1489 return returnValue;
1492 EditFieldHandlePtr CSMViewportBase::editHandleMTouchDataVC (void)
1494 SFMTouchData::EditHandlePtr returnValue(
1495 new SFMTouchData::EditHandle(
1496 &_sfMTouchDataVC,
1497 this->getType().getFieldDesc(MTouchDataVCFieldId),
1498 this));
1501 editSField(MTouchDataVCFieldMask);
1503 return returnValue;
1507 #ifdef OSG_MT_CPTR_ASPECT
1508 void CSMViewportBase::execSyncV( FieldContainer &oFrom,
1509 ConstFieldMaskArg whichField,
1510 AspectOffsetStore &oOffsets,
1511 ConstFieldMaskArg syncMode,
1512 const UInt32 uiSyncInfo)
1514 CSMViewport *pThis = static_cast<CSMViewport *>(this);
1516 pThis->execSync(static_cast<CSMViewport *>(&oFrom),
1517 whichField,
1518 oOffsets,
1519 syncMode,
1520 uiSyncInfo);
1522 #endif
1525 #ifdef OSG_MT_CPTR_ASPECT
1526 FieldContainer *CSMViewportBase::createAspectCopy(
1527 const FieldContainer *pRefAspect) const
1529 CSMViewport *returnValue;
1531 newAspectCopy(returnValue,
1532 dynamic_cast<const CSMViewport *>(pRefAspect),
1533 dynamic_cast<const CSMViewport *>(this));
1535 return returnValue;
1537 #endif
1539 void CSMViewportBase::resolveLinks(void)
1541 Inherited::resolveLinks();
1543 static_cast<CSMViewport *>(this)->setRoot(NULL);
1545 static_cast<CSMViewport *>(this)->setCamera(NULL);
1547 static_cast<CSMViewport *>(this)->setBackground(NULL);
1549 static_cast<CSMViewport *>(this)->clearForegrounds();
1551 static_cast<CSMViewport *>(this)->setRenderOptions(NULL);
1557 OSG_END_NAMESPACE