changed: gcc8 base update
[opensg.git] / Source / Contrib / ComplexSceneManager / OSGCSMViewportBase.cpp
blob932ee7c4c9eee9de904f6a6451b11f004ccd73db
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>(
343 reinterpret_cast<void *>(&CSMViewport::classDescInserter)),
344 false,
346 "<?xml version=\"1.0\"?>\n"
347 "\n"
348 "<FieldContainer\n"
349 " name=\"CSMViewport\"\n"
350 " parent=\"AttachmentContainer\"\n"
351 " library=\"ContribCSM\"\n"
352 " pointerfieldtypes=\"both\"\n"
353 " structure=\"concrete\"\n"
354 " systemcomponent=\"true\"\n"
355 " parentsystemcomponent=\"true\"\n"
356 " decoratable=\"false\"\n"
357 " useLocalIncludes=\"false\"\n"
358 " isNodeCore=\"false\"\n"
359 " isBundle=\"true\"\n"
360 " >\n"
361 " <Field\n"
362 " name=\"root\"\n"
363 " type=\"Node\"\n"
364 " cardinality=\"single\"\n"
365 " visibility=\"external\"\n"
366 " defaultValue=\"NULL\"\n"
367 " access=\"public\"\n"
368 " category=\"pointer\"\n"
369 " >\n"
370 " </Field>\n"
371 " <Field\n"
372 " name=\"camera\"\n"
373 " type=\"Camera\"\n"
374 " cardinality=\"single\"\n"
375 " visibility=\"external\"\n"
376 " defaultValue=\"NULL\"\n"
377 " access=\"public\"\n"
378 " category=\"pointer\"\n"
379 " >\n"
380 " </Field>\n"
381 " <Field\n"
382 " name=\"background\"\n"
383 " type=\"Background\"\n"
384 " cardinality=\"single\"\n"
385 " visibility=\"external\"\n"
386 " access=\"public\"\n"
387 " category=\"pointer\"\n"
388 " >\n"
389 " </Field>\n"
390 " <Field\n"
391 " name=\"foregrounds\"\n"
392 " type=\"Foreground\"\n"
393 " cardinality=\"multi\"\n"
394 " visibility=\"external\"\n"
395 " access=\"public\"\n"
396 " category=\"pointer\"\n"
397 " >\n"
398 " </Field>\n"
399 " <Field\n"
400 " name=\"leftBottom\"\n"
401 " type=\"Vec2f\"\n"
402 " cardinality=\"single\"\n"
403 " visibility=\"external\"\n"
404 " access=\"public\"\n"
405 " defaultValue=\"0.f, 0.f\"\n"
406 " >\n"
407 " </Field>\n"
408 " <Field\n"
409 " name=\"rightTop\"\n"
410 " type=\"Vec2f\"\n"
411 " cardinality=\"single\"\n"
412 " visibility=\"external\"\n"
413 " access=\"public\"\n"
414 " defaultValue=\"1.f, 1.f\"\n"
415 " >\n"
416 " </Field>\n"
417 " <Field\n"
418 " name=\"travMask\"\n"
419 " type=\"UInt32\"\n"
420 " cardinality=\"single\"\n"
421 " visibility=\"external\"\n"
422 " access=\"public\"\n"
423 " defaultValue=\"TypeTraits&lt;UInt32&gt;::BitsSet &amp; ~TraversalMasks::FindNamedComponentTraversal\"\n"
424 " >\n"
425 " </Field>\n"
426 " <Field\n"
427 " name=\"renderOptions\"\n"
428 " type=\"RenderOptionsPtr\"\n"
429 " cardinality=\"single\"\n"
430 " visibility=\"external\"\n"
431 " access=\"public\"\n"
432 " defaultValue=\"NULL\"\n"
433 " >\n"
434 " </Field>\n"
435 " <Field\n"
436 " name=\"stereoMode\"\n"
437 " type=\"std::string\"\n"
438 " cardinality=\"single\"\n"
439 " visibility=\"external\"\n"
440 " access=\"public\"\n"
441 " defaultValue='\"none\"'\n"
442 " >\n"
443 " </Field>\n"
444 " <Field\n"
445 " name=\"passive\"\n"
446 " type=\"bool\"\n"
447 " cardinality=\"single\"\n"
448 " visibility=\"external\"\n"
449 " access=\"public\"\n"
450 " defaultValue=\"false\"\n"
451 " >\n"
452 " </Field>\n"
453 " <Field\n"
454 " name=\"serverId\"\n"
455 " type=\"Int32\"\n"
456 " cardinality=\"single\"\n"
457 " visibility=\"external\"\n"
458 " access=\"public\"\n"
459 " defaultValue=\"-1\"\n"
460 " >\n"
461 " If not -1 used by the cluster multi window to compute the corresponding\n"
462 " viewport\n"
463 " </Field>\n"
464 "\n"
465 " <Field\n"
466 " name=\"mouseDataVC\"\n"
467 " type=\"MouseData\"\n"
468 " cardinality=\"single\"\n"
469 " visibility=\"internal\"\n"
470 " access=\"public\"\n"
471 " >\n"
472 " MTouchData in local viewport coordinates\n"
473 " </Field>\n"
474 " <Field\n"
475 " name=\"MTouchDataVC\"\n"
476 " type=\"MTouchData\"\n"
477 " cardinality=\"single\"\n"
478 " visibility=\"internal\"\n"
479 " access=\"public\"\n"
480 " >\n"
481 " MTouchData in local viewport coordinates\n"
482 " </Field>\n"
483 "\n"
484 "</FieldContainer>\n",
488 /*------------------------------ get -----------------------------------*/
490 FieldContainerType &CSMViewportBase::getType(void)
492 return _type;
495 const FieldContainerType &CSMViewportBase::getType(void) const
497 return _type;
500 UInt32 CSMViewportBase::getContainerSize(void) const
502 return sizeof(CSMViewport);
505 /*------------------------- decorator get ------------------------------*/
508 //! Get the CSMViewport::_sfRoot field.
509 const SFUnrecNodePtr *CSMViewportBase::getSFRoot(void) const
511 return &_sfRoot;
514 SFUnrecNodePtr *CSMViewportBase::editSFRoot (void)
516 editSField(RootFieldMask);
518 return &_sfRoot;
521 //! Get the value of the CSMViewport::_sfRoot field.
522 Node * CSMViewportBase::getRoot(void) const
524 return _sfRoot.getValue();
527 //! Set the value of the CSMViewport::_sfRoot field.
528 void CSMViewportBase::setRoot(Node * const value)
530 editSField(RootFieldMask);
532 _sfRoot.setValue(value);
536 //! Get the CSMViewport::_sfCamera field.
537 const SFUnrecCameraPtr *CSMViewportBase::getSFCamera(void) const
539 return &_sfCamera;
542 SFUnrecCameraPtr *CSMViewportBase::editSFCamera (void)
544 editSField(CameraFieldMask);
546 return &_sfCamera;
549 //! Get the value of the CSMViewport::_sfCamera field.
550 Camera * CSMViewportBase::getCamera(void) const
552 return _sfCamera.getValue();
555 //! Set the value of the CSMViewport::_sfCamera field.
556 void CSMViewportBase::setCamera(Camera * const value)
558 editSField(CameraFieldMask);
560 _sfCamera.setValue(value);
564 //! Get the CSMViewport::_sfBackground field.
565 const SFUnrecBackgroundPtr *CSMViewportBase::getSFBackground(void) const
567 return &_sfBackground;
570 SFUnrecBackgroundPtr *CSMViewportBase::editSFBackground (void)
572 editSField(BackgroundFieldMask);
574 return &_sfBackground;
577 //! Get the value of the CSMViewport::_sfBackground field.
578 Background * CSMViewportBase::getBackground(void) const
580 return _sfBackground.getValue();
583 //! Set the value of the CSMViewport::_sfBackground field.
584 void CSMViewportBase::setBackground(Background * const value)
586 editSField(BackgroundFieldMask);
588 _sfBackground.setValue(value);
592 //! Get the CSMViewport::_mfForegrounds field.
593 const MFUnrecForegroundPtr *CSMViewportBase::getMFForegrounds(void) const
595 return &_mfForegrounds;
598 MFUnrecForegroundPtr *CSMViewportBase::editMFForegrounds (void)
600 editMField(ForegroundsFieldMask, _mfForegrounds);
602 return &_mfForegrounds;
604 Foreground * CSMViewportBase::getForegrounds(const UInt32 index) const
606 return _mfForegrounds[index];
609 SFVec2f *CSMViewportBase::editSFLeftBottom(void)
611 editSField(LeftBottomFieldMask);
613 return &_sfLeftBottom;
616 const SFVec2f *CSMViewportBase::getSFLeftBottom(void) const
618 return &_sfLeftBottom;
622 SFVec2f *CSMViewportBase::editSFRightTop(void)
624 editSField(RightTopFieldMask);
626 return &_sfRightTop;
629 const SFVec2f *CSMViewportBase::getSFRightTop(void) const
631 return &_sfRightTop;
635 SFUInt32 *CSMViewportBase::editSFTravMask(void)
637 editSField(TravMaskFieldMask);
639 return &_sfTravMask;
642 const SFUInt32 *CSMViewportBase::getSFTravMask(void) const
644 return &_sfTravMask;
648 //! Get the CSMViewport::_sfRenderOptions field.
649 const SFUnrecRenderOptionsPtr *CSMViewportBase::getSFRenderOptions(void) const
651 return &_sfRenderOptions;
654 SFUnrecRenderOptionsPtr *CSMViewportBase::editSFRenderOptions (void)
656 editSField(RenderOptionsFieldMask);
658 return &_sfRenderOptions;
661 //! Get the value of the CSMViewport::_sfRenderOptions field.
662 RenderOptions * CSMViewportBase::getRenderOptions(void) const
664 return _sfRenderOptions.getValue();
667 //! Set the value of the CSMViewport::_sfRenderOptions field.
668 void CSMViewportBase::setRenderOptions(RenderOptions * const value)
670 editSField(RenderOptionsFieldMask);
672 _sfRenderOptions.setValue(value);
676 SFString *CSMViewportBase::editSFStereoMode(void)
678 editSField(StereoModeFieldMask);
680 return &_sfStereoMode;
683 const SFString *CSMViewportBase::getSFStereoMode(void) const
685 return &_sfStereoMode;
689 SFBool *CSMViewportBase::editSFPassive(void)
691 editSField(PassiveFieldMask);
693 return &_sfPassive;
696 const SFBool *CSMViewportBase::getSFPassive(void) const
698 return &_sfPassive;
702 SFInt32 *CSMViewportBase::editSFServerId(void)
704 editSField(ServerIdFieldMask);
706 return &_sfServerId;
709 const SFInt32 *CSMViewportBase::getSFServerId(void) const
711 return &_sfServerId;
715 SFMouseData *CSMViewportBase::editSFMouseDataVC(void)
717 editSField(MouseDataVCFieldMask);
719 return &_sfMouseDataVC;
722 const SFMouseData *CSMViewportBase::getSFMouseDataVC(void) const
724 return &_sfMouseDataVC;
728 SFMTouchData *CSMViewportBase::editSFMTouchDataVC(void)
730 editSField(MTouchDataVCFieldMask);
732 return &_sfMTouchDataVC;
735 const SFMTouchData *CSMViewportBase::getSFMTouchDataVC(void) const
737 return &_sfMTouchDataVC;
743 void CSMViewportBase::pushToForegrounds(Foreground * const value)
745 editMField(ForegroundsFieldMask, _mfForegrounds);
747 _mfForegrounds.push_back(value);
750 void CSMViewportBase::assignForegrounds(const MFUnrecForegroundPtr &value)
752 MFUnrecForegroundPtr::const_iterator elemIt =
753 value.begin();
754 MFUnrecForegroundPtr::const_iterator elemEnd =
755 value.end ();
757 static_cast<CSMViewport *>(this)->clearForegrounds();
759 while(elemIt != elemEnd)
761 this->pushToForegrounds(*elemIt);
763 ++elemIt;
767 void CSMViewportBase::removeFromForegrounds(UInt32 uiIndex)
769 if(uiIndex < _mfForegrounds.size())
771 editMField(ForegroundsFieldMask, _mfForegrounds);
773 _mfForegrounds.erase(uiIndex);
777 void CSMViewportBase::removeObjFromForegrounds(Foreground * const value)
779 Int32 iElemIdx = _mfForegrounds.findIndex(value);
781 if(iElemIdx != -1)
783 editMField(ForegroundsFieldMask, _mfForegrounds);
785 _mfForegrounds.erase(iElemIdx);
788 void CSMViewportBase::clearForegrounds(void)
790 editMField(ForegroundsFieldMask, _mfForegrounds);
793 _mfForegrounds.clear();
798 /*------------------------------ access -----------------------------------*/
800 SizeT CSMViewportBase::getBinSize(ConstFieldMaskArg whichField)
802 SizeT returnValue = Inherited::getBinSize(whichField);
804 if(FieldBits::NoField != (RootFieldMask & whichField))
806 returnValue += _sfRoot.getBinSize();
808 if(FieldBits::NoField != (CameraFieldMask & whichField))
810 returnValue += _sfCamera.getBinSize();
812 if(FieldBits::NoField != (BackgroundFieldMask & whichField))
814 returnValue += _sfBackground.getBinSize();
816 if(FieldBits::NoField != (ForegroundsFieldMask & whichField))
818 returnValue += _mfForegrounds.getBinSize();
820 if(FieldBits::NoField != (LeftBottomFieldMask & whichField))
822 returnValue += _sfLeftBottom.getBinSize();
824 if(FieldBits::NoField != (RightTopFieldMask & whichField))
826 returnValue += _sfRightTop.getBinSize();
828 if(FieldBits::NoField != (TravMaskFieldMask & whichField))
830 returnValue += _sfTravMask.getBinSize();
832 if(FieldBits::NoField != (RenderOptionsFieldMask & whichField))
834 returnValue += _sfRenderOptions.getBinSize();
836 if(FieldBits::NoField != (StereoModeFieldMask & whichField))
838 returnValue += _sfStereoMode.getBinSize();
840 if(FieldBits::NoField != (PassiveFieldMask & whichField))
842 returnValue += _sfPassive.getBinSize();
844 if(FieldBits::NoField != (ServerIdFieldMask & whichField))
846 returnValue += _sfServerId.getBinSize();
848 if(FieldBits::NoField != (MouseDataVCFieldMask & whichField))
850 returnValue += _sfMouseDataVC.getBinSize();
852 if(FieldBits::NoField != (MTouchDataVCFieldMask & whichField))
854 returnValue += _sfMTouchDataVC.getBinSize();
857 return returnValue;
860 void CSMViewportBase::copyToBin(BinaryDataHandler &pMem,
861 ConstFieldMaskArg whichField)
863 Inherited::copyToBin(pMem, whichField);
865 if(FieldBits::NoField != (RootFieldMask & whichField))
867 _sfRoot.copyToBin(pMem);
869 if(FieldBits::NoField != (CameraFieldMask & whichField))
871 _sfCamera.copyToBin(pMem);
873 if(FieldBits::NoField != (BackgroundFieldMask & whichField))
875 _sfBackground.copyToBin(pMem);
877 if(FieldBits::NoField != (ForegroundsFieldMask & whichField))
879 _mfForegrounds.copyToBin(pMem);
881 if(FieldBits::NoField != (LeftBottomFieldMask & whichField))
883 _sfLeftBottom.copyToBin(pMem);
885 if(FieldBits::NoField != (RightTopFieldMask & whichField))
887 _sfRightTop.copyToBin(pMem);
889 if(FieldBits::NoField != (TravMaskFieldMask & whichField))
891 _sfTravMask.copyToBin(pMem);
893 if(FieldBits::NoField != (RenderOptionsFieldMask & whichField))
895 _sfRenderOptions.copyToBin(pMem);
897 if(FieldBits::NoField != (StereoModeFieldMask & whichField))
899 _sfStereoMode.copyToBin(pMem);
901 if(FieldBits::NoField != (PassiveFieldMask & whichField))
903 _sfPassive.copyToBin(pMem);
905 if(FieldBits::NoField != (ServerIdFieldMask & whichField))
907 _sfServerId.copyToBin(pMem);
909 if(FieldBits::NoField != (MouseDataVCFieldMask & whichField))
911 _sfMouseDataVC.copyToBin(pMem);
913 if(FieldBits::NoField != (MTouchDataVCFieldMask & whichField))
915 _sfMTouchDataVC.copyToBin(pMem);
919 void CSMViewportBase::copyFromBin(BinaryDataHandler &pMem,
920 ConstFieldMaskArg whichField)
922 Inherited::copyFromBin(pMem, whichField);
924 if(FieldBits::NoField != (RootFieldMask & whichField))
926 editSField(RootFieldMask);
927 _sfRoot.copyFromBin(pMem);
929 if(FieldBits::NoField != (CameraFieldMask & whichField))
931 editSField(CameraFieldMask);
932 _sfCamera.copyFromBin(pMem);
934 if(FieldBits::NoField != (BackgroundFieldMask & whichField))
936 editSField(BackgroundFieldMask);
937 _sfBackground.copyFromBin(pMem);
939 if(FieldBits::NoField != (ForegroundsFieldMask & whichField))
941 editMField(ForegroundsFieldMask, _mfForegrounds);
942 _mfForegrounds.copyFromBin(pMem);
944 if(FieldBits::NoField != (LeftBottomFieldMask & whichField))
946 editSField(LeftBottomFieldMask);
947 _sfLeftBottom.copyFromBin(pMem);
949 if(FieldBits::NoField != (RightTopFieldMask & whichField))
951 editSField(RightTopFieldMask);
952 _sfRightTop.copyFromBin(pMem);
954 if(FieldBits::NoField != (TravMaskFieldMask & whichField))
956 editSField(TravMaskFieldMask);
957 _sfTravMask.copyFromBin(pMem);
959 if(FieldBits::NoField != (RenderOptionsFieldMask & whichField))
961 editSField(RenderOptionsFieldMask);
962 _sfRenderOptions.copyFromBin(pMem);
964 if(FieldBits::NoField != (StereoModeFieldMask & whichField))
966 editSField(StereoModeFieldMask);
967 _sfStereoMode.copyFromBin(pMem);
969 if(FieldBits::NoField != (PassiveFieldMask & whichField))
971 editSField(PassiveFieldMask);
972 _sfPassive.copyFromBin(pMem);
974 if(FieldBits::NoField != (ServerIdFieldMask & whichField))
976 editSField(ServerIdFieldMask);
977 _sfServerId.copyFromBin(pMem);
979 if(FieldBits::NoField != (MouseDataVCFieldMask & whichField))
981 editSField(MouseDataVCFieldMask);
982 _sfMouseDataVC.copyFromBin(pMem);
984 if(FieldBits::NoField != (MTouchDataVCFieldMask & whichField))
986 editSField(MTouchDataVCFieldMask);
987 _sfMTouchDataVC.copyFromBin(pMem);
991 //! create a new instance of the class
992 CSMViewportTransitPtr CSMViewportBase::createLocal(BitVector bFlags)
994 CSMViewportTransitPtr fc;
996 if(getClassType().getPrototype() != NULL)
998 FieldContainerTransitPtr tmpPtr =
999 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
1001 fc = dynamic_pointer_cast<CSMViewport>(tmpPtr);
1004 return fc;
1007 //! create a new instance of the class, copy the container flags
1008 CSMViewportTransitPtr CSMViewportBase::createDependent(BitVector bFlags)
1010 CSMViewportTransitPtr fc;
1012 if(getClassType().getPrototype() != NULL)
1014 FieldContainerTransitPtr tmpPtr =
1015 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
1017 fc = dynamic_pointer_cast<CSMViewport>(tmpPtr);
1020 return fc;
1023 //! create a new instance of the class
1024 CSMViewportTransitPtr CSMViewportBase::create(void)
1026 return createLocal();
1029 CSMViewport *CSMViewportBase::createEmptyLocal(BitVector bFlags)
1031 CSMViewport *returnValue;
1033 newPtr<CSMViewport>(returnValue, bFlags);
1035 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
1037 return returnValue;
1040 //! create an empty new instance of the class, do not copy the prototype
1041 CSMViewport *CSMViewportBase::createEmpty(void)
1043 return createEmptyLocal();
1047 FieldContainerTransitPtr CSMViewportBase::shallowCopyLocal(
1048 BitVector bFlags) const
1050 CSMViewport *tmpPtr;
1052 newPtr(tmpPtr, dynamic_cast<const CSMViewport *>(this), bFlags);
1054 FieldContainerTransitPtr returnValue(tmpPtr);
1056 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
1058 return returnValue;
1061 FieldContainerTransitPtr CSMViewportBase::shallowCopyDependent(
1062 BitVector bFlags) const
1064 CSMViewport *tmpPtr;
1066 newPtr(tmpPtr, dynamic_cast<const CSMViewport *>(this), ~bFlags);
1068 FieldContainerTransitPtr returnValue(tmpPtr);
1070 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
1072 return returnValue;
1075 FieldContainerTransitPtr CSMViewportBase::shallowCopy(void) const
1077 return shallowCopyLocal();
1083 /*------------------------- constructors ----------------------------------*/
1085 CSMViewportBase::CSMViewportBase(void) :
1086 Inherited(),
1087 _sfRoot (NULL),
1088 _sfCamera (NULL),
1089 _sfBackground (NULL),
1090 _mfForegrounds (),
1091 _sfLeftBottom (Vec2f(0.f, 0.f)),
1092 _sfRightTop (Vec2f(1.f, 1.f)),
1093 _sfTravMask (UInt32(TypeTraits<UInt32>::BitsSet & ~TraversalMasks::FindNamedComponentTraversal)),
1094 _sfRenderOptions (NULL),
1095 _sfStereoMode (std::string("none")),
1096 _sfPassive (bool(false)),
1097 _sfServerId (Int32(-1)),
1098 _sfMouseDataVC (),
1099 _sfMTouchDataVC ()
1103 CSMViewportBase::CSMViewportBase(const CSMViewportBase &source) :
1104 Inherited(source),
1105 _sfRoot (NULL),
1106 _sfCamera (NULL),
1107 _sfBackground (NULL),
1108 _mfForegrounds (),
1109 _sfLeftBottom (source._sfLeftBottom ),
1110 _sfRightTop (source._sfRightTop ),
1111 _sfTravMask (source._sfTravMask ),
1112 _sfRenderOptions (NULL),
1113 _sfStereoMode (source._sfStereoMode ),
1114 _sfPassive (source._sfPassive ),
1115 _sfServerId (source._sfServerId ),
1116 _sfMouseDataVC (source._sfMouseDataVC ),
1117 _sfMTouchDataVC (source._sfMTouchDataVC )
1122 /*-------------------------- destructors ----------------------------------*/
1124 CSMViewportBase::~CSMViewportBase(void)
1128 void CSMViewportBase::onCreate(const CSMViewport *source)
1130 Inherited::onCreate(source);
1132 if(source != NULL)
1134 CSMViewport *pThis = static_cast<CSMViewport *>(this);
1136 pThis->setRoot(source->getRoot());
1138 pThis->setCamera(source->getCamera());
1140 pThis->setBackground(source->getBackground());
1142 MFUnrecForegroundPtr::const_iterator ForegroundsIt =
1143 source->_mfForegrounds.begin();
1144 MFUnrecForegroundPtr::const_iterator ForegroundsEnd =
1145 source->_mfForegrounds.end ();
1147 while(ForegroundsIt != ForegroundsEnd)
1149 pThis->pushToForegrounds(*ForegroundsIt);
1151 ++ForegroundsIt;
1154 pThis->setRenderOptions(source->getRenderOptions());
1158 GetFieldHandlePtr CSMViewportBase::getHandleRoot (void) const
1160 SFUnrecNodePtr::GetHandlePtr returnValue(
1161 new SFUnrecNodePtr::GetHandle(
1162 &_sfRoot,
1163 this->getType().getFieldDesc(RootFieldId),
1164 const_cast<CSMViewportBase *>(this)));
1166 return returnValue;
1169 EditFieldHandlePtr CSMViewportBase::editHandleRoot (void)
1171 SFUnrecNodePtr::EditHandlePtr returnValue(
1172 new SFUnrecNodePtr::EditHandle(
1173 &_sfRoot,
1174 this->getType().getFieldDesc(RootFieldId),
1175 this));
1177 returnValue->setSetMethod(
1178 boost::bind(&CSMViewport::setRoot,
1179 static_cast<CSMViewport *>(this), _1));
1181 editSField(RootFieldMask);
1183 return returnValue;
1186 GetFieldHandlePtr CSMViewportBase::getHandleCamera (void) const
1188 SFUnrecCameraPtr::GetHandlePtr returnValue(
1189 new SFUnrecCameraPtr::GetHandle(
1190 &_sfCamera,
1191 this->getType().getFieldDesc(CameraFieldId),
1192 const_cast<CSMViewportBase *>(this)));
1194 return returnValue;
1197 EditFieldHandlePtr CSMViewportBase::editHandleCamera (void)
1199 SFUnrecCameraPtr::EditHandlePtr returnValue(
1200 new SFUnrecCameraPtr::EditHandle(
1201 &_sfCamera,
1202 this->getType().getFieldDesc(CameraFieldId),
1203 this));
1205 returnValue->setSetMethod(
1206 boost::bind(&CSMViewport::setCamera,
1207 static_cast<CSMViewport *>(this), _1));
1209 editSField(CameraFieldMask);
1211 return returnValue;
1214 GetFieldHandlePtr CSMViewportBase::getHandleBackground (void) const
1216 SFUnrecBackgroundPtr::GetHandlePtr returnValue(
1217 new SFUnrecBackgroundPtr::GetHandle(
1218 &_sfBackground,
1219 this->getType().getFieldDesc(BackgroundFieldId),
1220 const_cast<CSMViewportBase *>(this)));
1222 return returnValue;
1225 EditFieldHandlePtr CSMViewportBase::editHandleBackground (void)
1227 SFUnrecBackgroundPtr::EditHandlePtr returnValue(
1228 new SFUnrecBackgroundPtr::EditHandle(
1229 &_sfBackground,
1230 this->getType().getFieldDesc(BackgroundFieldId),
1231 this));
1233 returnValue->setSetMethod(
1234 boost::bind(&CSMViewport::setBackground,
1235 static_cast<CSMViewport *>(this), _1));
1237 editSField(BackgroundFieldMask);
1239 return returnValue;
1242 GetFieldHandlePtr CSMViewportBase::getHandleForegrounds (void) const
1244 MFUnrecForegroundPtr::GetHandlePtr returnValue(
1245 new MFUnrecForegroundPtr::GetHandle(
1246 &_mfForegrounds,
1247 this->getType().getFieldDesc(ForegroundsFieldId),
1248 const_cast<CSMViewportBase *>(this)));
1250 return returnValue;
1253 EditFieldHandlePtr CSMViewportBase::editHandleForegrounds (void)
1255 MFUnrecForegroundPtr::EditHandlePtr returnValue(
1256 new MFUnrecForegroundPtr::EditHandle(
1257 &_mfForegrounds,
1258 this->getType().getFieldDesc(ForegroundsFieldId),
1259 this));
1261 returnValue->setAddMethod(
1262 boost::bind(&CSMViewport::pushToForegrounds,
1263 static_cast<CSMViewport *>(this), _1));
1264 returnValue->setRemoveMethod(
1265 boost::bind(&CSMViewport::removeFromForegrounds,
1266 static_cast<CSMViewport *>(this), _1));
1267 returnValue->setRemoveObjMethod(
1268 boost::bind(&CSMViewport::removeObjFromForegrounds,
1269 static_cast<CSMViewport *>(this), _1));
1270 returnValue->setClearMethod(
1271 boost::bind(&CSMViewport::clearForegrounds,
1272 static_cast<CSMViewport *>(this)));
1274 editMField(ForegroundsFieldMask, _mfForegrounds);
1276 return returnValue;
1279 GetFieldHandlePtr CSMViewportBase::getHandleLeftBottom (void) const
1281 SFVec2f::GetHandlePtr returnValue(
1282 new SFVec2f::GetHandle(
1283 &_sfLeftBottom,
1284 this->getType().getFieldDesc(LeftBottomFieldId),
1285 const_cast<CSMViewportBase *>(this)));
1287 return returnValue;
1290 EditFieldHandlePtr CSMViewportBase::editHandleLeftBottom (void)
1292 SFVec2f::EditHandlePtr returnValue(
1293 new SFVec2f::EditHandle(
1294 &_sfLeftBottom,
1295 this->getType().getFieldDesc(LeftBottomFieldId),
1296 this));
1299 editSField(LeftBottomFieldMask);
1301 return returnValue;
1304 GetFieldHandlePtr CSMViewportBase::getHandleRightTop (void) const
1306 SFVec2f::GetHandlePtr returnValue(
1307 new SFVec2f::GetHandle(
1308 &_sfRightTop,
1309 this->getType().getFieldDesc(RightTopFieldId),
1310 const_cast<CSMViewportBase *>(this)));
1312 return returnValue;
1315 EditFieldHandlePtr CSMViewportBase::editHandleRightTop (void)
1317 SFVec2f::EditHandlePtr returnValue(
1318 new SFVec2f::EditHandle(
1319 &_sfRightTop,
1320 this->getType().getFieldDesc(RightTopFieldId),
1321 this));
1324 editSField(RightTopFieldMask);
1326 return returnValue;
1329 GetFieldHandlePtr CSMViewportBase::getHandleTravMask (void) const
1331 SFUInt32::GetHandlePtr returnValue(
1332 new SFUInt32::GetHandle(
1333 &_sfTravMask,
1334 this->getType().getFieldDesc(TravMaskFieldId),
1335 const_cast<CSMViewportBase *>(this)));
1337 return returnValue;
1340 EditFieldHandlePtr CSMViewportBase::editHandleTravMask (void)
1342 SFUInt32::EditHandlePtr returnValue(
1343 new SFUInt32::EditHandle(
1344 &_sfTravMask,
1345 this->getType().getFieldDesc(TravMaskFieldId),
1346 this));
1349 editSField(TravMaskFieldMask);
1351 return returnValue;
1354 GetFieldHandlePtr CSMViewportBase::getHandleRenderOptions (void) const
1356 SFUnrecRenderOptionsPtr::GetHandlePtr returnValue(
1357 new SFUnrecRenderOptionsPtr::GetHandle(
1358 &_sfRenderOptions,
1359 this->getType().getFieldDesc(RenderOptionsFieldId),
1360 const_cast<CSMViewportBase *>(this)));
1362 return returnValue;
1365 EditFieldHandlePtr CSMViewportBase::editHandleRenderOptions (void)
1367 SFUnrecRenderOptionsPtr::EditHandlePtr returnValue(
1368 new SFUnrecRenderOptionsPtr::EditHandle(
1369 &_sfRenderOptions,
1370 this->getType().getFieldDesc(RenderOptionsFieldId),
1371 this));
1373 returnValue->setSetMethod(
1374 boost::bind(&CSMViewport::setRenderOptions,
1375 static_cast<CSMViewport *>(this), _1));
1377 editSField(RenderOptionsFieldMask);
1379 return returnValue;
1382 GetFieldHandlePtr CSMViewportBase::getHandleStereoMode (void) const
1384 SFString::GetHandlePtr returnValue(
1385 new SFString::GetHandle(
1386 &_sfStereoMode,
1387 this->getType().getFieldDesc(StereoModeFieldId),
1388 const_cast<CSMViewportBase *>(this)));
1390 return returnValue;
1393 EditFieldHandlePtr CSMViewportBase::editHandleStereoMode (void)
1395 SFString::EditHandlePtr returnValue(
1396 new SFString::EditHandle(
1397 &_sfStereoMode,
1398 this->getType().getFieldDesc(StereoModeFieldId),
1399 this));
1402 editSField(StereoModeFieldMask);
1404 return returnValue;
1407 GetFieldHandlePtr CSMViewportBase::getHandlePassive (void) const
1409 SFBool::GetHandlePtr returnValue(
1410 new SFBool::GetHandle(
1411 &_sfPassive,
1412 this->getType().getFieldDesc(PassiveFieldId),
1413 const_cast<CSMViewportBase *>(this)));
1415 return returnValue;
1418 EditFieldHandlePtr CSMViewportBase::editHandlePassive (void)
1420 SFBool::EditHandlePtr returnValue(
1421 new SFBool::EditHandle(
1422 &_sfPassive,
1423 this->getType().getFieldDesc(PassiveFieldId),
1424 this));
1427 editSField(PassiveFieldMask);
1429 return returnValue;
1432 GetFieldHandlePtr CSMViewportBase::getHandleServerId (void) const
1434 SFInt32::GetHandlePtr returnValue(
1435 new SFInt32::GetHandle(
1436 &_sfServerId,
1437 this->getType().getFieldDesc(ServerIdFieldId),
1438 const_cast<CSMViewportBase *>(this)));
1440 return returnValue;
1443 EditFieldHandlePtr CSMViewportBase::editHandleServerId (void)
1445 SFInt32::EditHandlePtr returnValue(
1446 new SFInt32::EditHandle(
1447 &_sfServerId,
1448 this->getType().getFieldDesc(ServerIdFieldId),
1449 this));
1452 editSField(ServerIdFieldMask);
1454 return returnValue;
1457 GetFieldHandlePtr CSMViewportBase::getHandleMouseDataVC (void) const
1459 SFMouseData::GetHandlePtr returnValue(
1460 new SFMouseData::GetHandle(
1461 &_sfMouseDataVC,
1462 this->getType().getFieldDesc(MouseDataVCFieldId),
1463 const_cast<CSMViewportBase *>(this)));
1465 return returnValue;
1468 EditFieldHandlePtr CSMViewportBase::editHandleMouseDataVC (void)
1470 SFMouseData::EditHandlePtr returnValue(
1471 new SFMouseData::EditHandle(
1472 &_sfMouseDataVC,
1473 this->getType().getFieldDesc(MouseDataVCFieldId),
1474 this));
1477 editSField(MouseDataVCFieldMask);
1479 return returnValue;
1482 GetFieldHandlePtr CSMViewportBase::getHandleMTouchDataVC (void) const
1484 SFMTouchData::GetHandlePtr returnValue(
1485 new SFMTouchData::GetHandle(
1486 &_sfMTouchDataVC,
1487 this->getType().getFieldDesc(MTouchDataVCFieldId),
1488 const_cast<CSMViewportBase *>(this)));
1490 return returnValue;
1493 EditFieldHandlePtr CSMViewportBase::editHandleMTouchDataVC (void)
1495 SFMTouchData::EditHandlePtr returnValue(
1496 new SFMTouchData::EditHandle(
1497 &_sfMTouchDataVC,
1498 this->getType().getFieldDesc(MTouchDataVCFieldId),
1499 this));
1502 editSField(MTouchDataVCFieldMask);
1504 return returnValue;
1508 #ifdef OSG_MT_CPTR_ASPECT
1509 void CSMViewportBase::execSyncV( FieldContainer &oFrom,
1510 ConstFieldMaskArg whichField,
1511 AspectOffsetStore &oOffsets,
1512 ConstFieldMaskArg syncMode,
1513 const UInt32 uiSyncInfo)
1515 CSMViewport *pThis = static_cast<CSMViewport *>(this);
1517 pThis->execSync(static_cast<CSMViewport *>(&oFrom),
1518 whichField,
1519 oOffsets,
1520 syncMode,
1521 uiSyncInfo);
1523 #endif
1526 #ifdef OSG_MT_CPTR_ASPECT
1527 FieldContainer *CSMViewportBase::createAspectCopy(
1528 const FieldContainer *pRefAspect) const
1530 CSMViewport *returnValue;
1532 newAspectCopy(returnValue,
1533 dynamic_cast<const CSMViewport *>(pRefAspect),
1534 dynamic_cast<const CSMViewport *>(this));
1536 return returnValue;
1538 #endif
1540 void CSMViewportBase::resolveLinks(void)
1542 Inherited::resolveLinks();
1544 static_cast<CSMViewport *>(this)->setRoot(NULL);
1546 static_cast<CSMViewport *>(this)->setCamera(NULL);
1548 static_cast<CSMViewport *>(this)->setBackground(NULL);
1550 static_cast<CSMViewport *>(this)->clearForegrounds();
1552 static_cast<CSMViewport *>(this)->setRenderOptions(NULL);
1558 OSG_END_NAMESPACE