changed: gcc8 base update
[opensg.git] / Source / System / Window / Base / OSGViewareaBase.cpp
blob4c811b88faef5cff6832fccb5f99e047d3ba829f
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 Viewarea!
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"
64 #include "OSGNode.h" // TravMask default header
66 #include "OSGRenderOptions.h" // RenderOptions Class
68 #include "OSGViewareaBase.h"
69 #include "OSGViewarea.h"
71 #include <boost/bind.hpp>
73 OSG_BEGIN_NAMESPACE
75 /***************************************************************************\
76 * Description *
77 \***************************************************************************/
79 /*! \class OSG::Viewarea
80 A Viewport is a part of the Window it is attached to used for rendering. See
81 \ref PageSystemWindowViewports for a description.
83 The size of the viewport is defined by the _sfLeft, _sfRight, _sfBottom and
84 _sfTop Fields. The Window this Viewport is attached is stored in _sfWindow.
85 _sfBackground defines the background clearing method, the
86 _sfRoot and _sfCamera Fields the scene being rendered and the camera used to
87 view it. The optional _mfForegrounds define which information are added or
88 actions are executed after the Viewport has been rendered.
90 \ext
92 To create a new Viewport the draw and render methods should be overridden.
94 \endext
96 \dev
98 When adding fields to the Viewport, make sure to add the code to copy them to
99 all the different ClusterWindows!
101 \enddev
104 /***************************************************************************\
105 * Field Documentation *
106 \***************************************************************************/
108 /*! \var Real32 ViewareaBase::_sfLeft
109 The left edge of the viewport. Values between 0 and 1 are relative to the
110 size of the Window, values >1 are absolute pixel coordinates.
111 All other values are illegal.
114 /*! \var Real32 ViewareaBase::_sfRight
115 The right edge of the viewport. Values between 0 and 1 are relative to the
116 size of the Window, values >1 are absolute pixel coordinates.
117 All other values are illegal.
120 /*! \var Real32 ViewareaBase::_sfBottom
121 The bottom edge of the viewport. Values between 0 and 1 are relative to
122 the size of the Window, values >1 are absolute pixel coordinates.
123 All other values are illegal.
126 /*! \var Real32 ViewareaBase::_sfTop
127 The top edge of the viewport. Values between 0 and 1 are relative to the
128 size of the Window, values >1 are absolute pixel coordinates.
129 All other values are illegal.
132 /*! \var UInt32 ViewareaBase::_sfTravMask
133 The foreground additions to the rendered image.
136 /*! \var bool ViewareaBase::_sfEnabled
137 Enabled is used to turn drawing on and off of a viewport.
140 /*! \var Real32 ViewareaBase::_sfDrawTime
141 Drawtime of the last frame using this viewport.
144 /*! \var Int32 ViewareaBase::_sfDrawableId
145 DrawableId to select viewport dependent elements (e.g. Distortion filter).
148 /*! \var RenderOptions * ViewareaBase::_sfRenderOptions
153 /***************************************************************************\
154 * FieldType/FieldTrait Instantiation *
155 \***************************************************************************/
157 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
158 PointerType FieldTraits<Viewarea *, nsOSG>::_type(
159 "ViewareaPtr",
160 "AttachmentContainerPtr",
161 Viewarea::getClassType(),
162 nsOSG);
163 #endif
165 OSG_FIELDTRAITS_GETTYPE_NS(Viewarea *, nsOSG)
167 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
168 Viewarea *,
169 nsOSG)
171 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
172 Viewarea *,
173 nsOSG)
175 DataType &FieldTraits< Viewarea *, nsOSG + 1 >::getType(void)
177 return FieldTraits<Viewarea *, nsOSG>::getType();
181 OSG_EXPORT_PTR_MFIELD(ChildPointerMField,
182 Viewarea *,
183 UnrecordedRefCountPolicy,
184 nsOSG + 1)
187 /***************************************************************************\
188 * Field Description *
189 \***************************************************************************/
191 void ViewareaBase::classDescInserter(TypeObject &oType)
193 FieldDescriptionBase *pDesc = NULL;
196 pDesc = new SFReal32::Description(
197 SFReal32::getClassType(),
198 "left",
199 "The left edge of the viewport. Values between 0 and 1 are relative to the \n"
200 "size of the Window, values >1 are absolute pixel coordinates.\n"
201 "All other values are illegal.\n",
202 LeftFieldId, LeftFieldMask,
203 false,
204 (Field::SFDefaultFlags | Field::FStdAccess),
205 static_cast<FieldEditMethodSig>(&Viewarea::editHandleLeft),
206 static_cast<FieldGetMethodSig >(&Viewarea::getHandleLeft));
208 oType.addInitialDesc(pDesc);
210 pDesc = new SFReal32::Description(
211 SFReal32::getClassType(),
212 "right",
213 "The right edge of the viewport. Values between 0 and 1 are relative to the \n"
214 "size of the Window, values >1 are absolute pixel coordinates.\n"
215 "All other values are illegal.\n",
216 RightFieldId, RightFieldMask,
217 false,
218 (Field::SFDefaultFlags | Field::FStdAccess),
219 static_cast<FieldEditMethodSig>(&Viewarea::editHandleRight),
220 static_cast<FieldGetMethodSig >(&Viewarea::getHandleRight));
222 oType.addInitialDesc(pDesc);
224 pDesc = new SFReal32::Description(
225 SFReal32::getClassType(),
226 "bottom",
227 "The bottom edge of the viewport. Values between 0 and 1 are relative to \n"
228 "the size of the Window, values >1 are absolute pixel coordinates.\n"
229 "All other values are illegal.\n",
230 BottomFieldId, BottomFieldMask,
231 false,
232 (Field::SFDefaultFlags | Field::FStdAccess),
233 static_cast<FieldEditMethodSig>(&Viewarea::editHandleBottom),
234 static_cast<FieldGetMethodSig >(&Viewarea::getHandleBottom));
236 oType.addInitialDesc(pDesc);
238 pDesc = new SFReal32::Description(
239 SFReal32::getClassType(),
240 "top",
241 "The top edge of the viewport. Values between 0 and 1 are relative to the \n"
242 "size of the Window, values >1 are absolute pixel coordinates.\n"
243 "All other values are illegal.\n",
244 TopFieldId, TopFieldMask,
245 false,
246 (Field::SFDefaultFlags | Field::FStdAccess),
247 static_cast<FieldEditMethodSig>(&Viewarea::editHandleTop),
248 static_cast<FieldGetMethodSig >(&Viewarea::getHandleTop));
250 oType.addInitialDesc(pDesc);
252 pDesc = new SFUInt32::Description(
253 SFUInt32::getClassType(),
254 "travMask",
255 "The foreground additions to the rendered image.\n",
256 TravMaskFieldId, TravMaskFieldMask,
257 false,
258 (Field::SFDefaultFlags | Field::FStdAccess),
259 static_cast<FieldEditMethodSig>(&Viewarea::editHandleTravMask),
260 static_cast<FieldGetMethodSig >(&Viewarea::getHandleTravMask));
262 oType.addInitialDesc(pDesc);
264 pDesc = new SFBool::Description(
265 SFBool::getClassType(),
266 "enabled",
267 "Enabled is used to turn drawing on and off of a viewport.\n",
268 EnabledFieldId, EnabledFieldMask,
269 false,
270 (Field::SFDefaultFlags | Field::FStdAccess),
271 static_cast<FieldEditMethodSig>(&Viewarea::editHandleEnabled),
272 static_cast<FieldGetMethodSig >(&Viewarea::getHandleEnabled));
274 oType.addInitialDesc(pDesc);
276 pDesc = new SFReal32::Description(
277 SFReal32::getClassType(),
278 "drawTime",
279 "Drawtime of the last frame using this viewport.\n",
280 DrawTimeFieldId, DrawTimeFieldMask,
281 true,
282 (Field::SFDefaultFlags | Field::FStdAccess),
283 static_cast<FieldEditMethodSig>(&Viewarea::editHandleDrawTime),
284 static_cast<FieldGetMethodSig >(&Viewarea::getHandleDrawTime));
286 oType.addInitialDesc(pDesc);
288 pDesc = new SFInt32::Description(
289 SFInt32::getClassType(),
290 "drawableId",
291 "DrawableId to select viewport dependent elements (e.g. Distortion filter).\n",
292 DrawableIdFieldId, DrawableIdFieldMask,
293 true,
294 (Field::SFDefaultFlags | Field::FStdAccess),
295 static_cast<FieldEditMethodSig>(&Viewarea::editHandleDrawableId),
296 static_cast<FieldGetMethodSig >(&Viewarea::getHandleDrawableId));
298 oType.addInitialDesc(pDesc);
300 pDesc = new SFUnrecRenderOptionsPtr::Description(
301 SFUnrecRenderOptionsPtr::getClassType(),
302 "renderOptions",
304 RenderOptionsFieldId, RenderOptionsFieldMask,
305 false,
306 (Field::SFDefaultFlags | Field::FStdAccess),
307 static_cast<FieldEditMethodSig>(&Viewarea::editHandleRenderOptions),
308 static_cast<FieldGetMethodSig >(&Viewarea::getHandleRenderOptions));
310 oType.addInitialDesc(pDesc);
314 ViewareaBase::TypeObject ViewareaBase::_type(
315 ViewareaBase::getClassname(),
316 Inherited::getClassname(),
317 "NULL",
318 nsOSG, //Namespace
319 reinterpret_cast<PrototypeCreateF>(&ViewareaBase::createEmptyLocal),
320 reinterpret_cast<InitContainerF>(&Viewarea::initMethod),
321 reinterpret_cast<ExitContainerF>(&Viewarea::exitMethod),
322 reinterpret_cast<InitalInsertDescFunc>(
323 reinterpret_cast<void *>(&Viewarea::classDescInserter)),
324 false,
326 "<?xml version=\"1.0\"?>\n"
327 "\n"
328 "<FieldContainer\n"
329 " name=\"Viewarea\"\n"
330 " parent=\"AttachmentContainer\"\n"
331 " library=\"System\"\n"
332 " pointerfieldtypes=\"both\"\n"
333 " structure=\"concrete\"\n"
334 " systemcomponent=\"true\"\n"
335 " parentsystemcomponent=\"true\"\n"
336 " childFields=\"multi\"\n"
337 " docGroupBase=\"GrpSystemWindow\"\n"
338 " >\n"
339 "\n"
340 " A Viewport is a part of the Window it is attached to used for rendering. See\n"
341 " \\ref PageSystemWindowViewports for a description.\n"
342 " \n"
343 " The size of the viewport is defined by the _sfLeft, _sfRight, _sfBottom and\n"
344 " _sfTop Fields. The Window this Viewport is attached is stored in _sfWindow.\n"
345 " _sfBackground defines the background clearing method, the\n"
346 " _sfRoot and _sfCamera Fields the scene being rendered and the camera used to\n"
347 " view it. The optional _mfForegrounds define which information are added or\n"
348 " actions are executed after the Viewport has been rendered.\n"
349 " \n"
350 " \\ext\n"
351 " \n"
352 " To create a new Viewport the draw and render methods should be overridden. \n"
353 " \n"
354 " \\endext\n"
355 "\n"
356 " \\dev\n"
357 " \n"
358 " When adding fields to the Viewport, make sure to add the code to copy them to\n"
359 " all the different ClusterWindows!\n"
360 " \n"
361 " \\enddev\n"
362 " <Field\n"
363 " name=\"left\"\n"
364 " type=\"Real32\"\n"
365 " cardinality=\"single\"\n"
366 " visibility=\"external\"\n"
367 " access=\"public\"\n"
368 " defaultValue=\"0.f\"\n"
369 " >\n"
370 " The left edge of the viewport. Values between 0 and 1 are relative to the \n"
371 " size of the Window, values &gt; 1 are absolute pixel coordinates.\n"
372 " All other values are illegal.\n"
373 " </Field>\n"
374 " <Field\n"
375 " name=\"right\"\n"
376 " type=\"Real32\"\n"
377 " cardinality=\"single\"\n"
378 " visibility=\"external\"\n"
379 " access=\"public\"\n"
380 " defaultValue=\"1.f\"\n"
381 " >\n"
382 " The right edge of the viewport. Values between 0 and 1 are relative to the \n"
383 " size of the Window, values &gt; 1 are absolute pixel coordinates.\n"
384 " All other values are illegal.\n"
385 " </Field>\n"
386 " <Field\n"
387 " name=\"bottom\"\n"
388 " type=\"Real32\"\n"
389 " cardinality=\"single\"\n"
390 " visibility=\"external\"\n"
391 " access=\"public\"\n"
392 " defaultValue=\"0.f\"\n"
393 " >\n"
394 " The bottom edge of the viewport. Values between 0 and 1 are relative to \n"
395 " the size of the Window, values &gt; 1 are absolute pixel coordinates.\n"
396 " All other values are illegal.\n"
397 " </Field>\n"
398 " <Field\n"
399 " name=\"top\"\n"
400 " type=\"Real32\"\n"
401 " cardinality=\"single\"\n"
402 " visibility=\"external\"\n"
403 " access=\"public\"\n"
404 " defaultValue=\"1.f\"\n"
405 " >\n"
406 " The top edge of the viewport. Values between 0 and 1 are relative to the \n"
407 " size of the Window, values &gt; 1 are absolute pixel coordinates.\n"
408 " All other values are illegal.\n"
409 " </Field>\n"
410 " <Field\n"
411 " name=\"travMask\"\n"
412 " type=\"UInt32\"\n"
413 " cardinality=\"single\"\n"
414 " visibility=\"external\"\n"
415 " access=\"public\"\n"
416 " defaultHeader=\"OSGNode.h\"\n"
417 " defaultValue=\"TypeTraits&lt;UInt32&gt;::getMax() &amp; ~TraversalMasks::FindNamedComponentTraversal\"\n"
418 " >\n"
419 " The foreground additions to the rendered image.\n"
420 " </Field>\n"
421 " <Field\n"
422 " name=\"enabled\"\n"
423 " type=\"bool\"\n"
424 " cardinality=\"single\"\n"
425 " visibility=\"external\"\n"
426 " access=\"public\"\n"
427 " defaultValue=\"true\"\n"
428 " >\n"
429 " Enabled is used to turn drawing on and off of a viewport.\n"
430 " </Field>\n"
431 " <Field\n"
432 " name=\"drawTime\"\n"
433 " type=\"Real32\"\n"
434 " cardinality=\"single\"\n"
435 " visibility=\"internal\"\n"
436 " defaultValue=\"0.0f\"\n"
437 " access=\"public\"\n"
438 " >\n"
439 " Drawtime of the last frame using this viewport.\n"
440 " </Field>\n"
441 " <Field\n"
442 " name=\"drawableId\"\n"
443 " type=\"Int32\"\n"
444 " cardinality=\"single\"\n"
445 " visibility=\"internal\"\n"
446 " access=\"public\"\n"
447 " defaultValue=\"-1\"\n"
448 " >\n"
449 " DrawableId to select viewport dependent elements (e.g. Distortion filter).\n"
450 " </Field>\n"
451 " <Field\n"
452 " name=\"renderOptions\"\n"
453 " type=\"RenderOptionsPtr\"\n"
454 " cardinality=\"single\"\n"
455 " visibility=\"external\"\n"
456 " access=\"public\"\n"
457 " defaultValue=\"NULL\"\n"
458 " >\n"
459 " </Field>\n"
460 "</FieldContainer>\n",
461 "A Viewport is a part of the Window it is attached to used for rendering. See\n"
462 "\\ref PageSystemWindowViewports for a description.\n"
463 "\n"
464 "The size of the viewport is defined by the _sfLeft, _sfRight, _sfBottom and\n"
465 "_sfTop Fields. The Window this Viewport is attached is stored in _sfWindow.\n"
466 "_sfBackground defines the background clearing method, the\n"
467 "_sfRoot and _sfCamera Fields the scene being rendered and the camera used to\n"
468 "view it. The optional _mfForegrounds define which information are added or\n"
469 "actions are executed after the Viewport has been rendered.\n"
470 "\n"
471 "\\ext\n"
472 "\n"
473 "To create a new Viewport the draw and render methods should be overridden. \n"
474 "\n"
475 "\\endext\n"
476 "\n"
477 "\\dev\n"
478 "\n"
479 "When adding fields to the Viewport, make sure to add the code to copy them to\n"
480 "all the different ClusterWindows!\n"
481 "\n"
482 "\\enddev\n"
485 /*------------------------------ get -----------------------------------*/
487 FieldContainerType &ViewareaBase::getType(void)
489 return _type;
492 const FieldContainerType &ViewareaBase::getType(void) const
494 return _type;
497 UInt32 ViewareaBase::getContainerSize(void) const
499 return sizeof(Viewarea);
502 /*------------------------- decorator get ------------------------------*/
505 SFReal32 *ViewareaBase::editSFLeft(void)
507 editSField(LeftFieldMask);
509 return &_sfLeft;
512 const SFReal32 *ViewareaBase::getSFLeft(void) const
514 return &_sfLeft;
518 SFReal32 *ViewareaBase::editSFRight(void)
520 editSField(RightFieldMask);
522 return &_sfRight;
525 const SFReal32 *ViewareaBase::getSFRight(void) const
527 return &_sfRight;
531 SFReal32 *ViewareaBase::editSFBottom(void)
533 editSField(BottomFieldMask);
535 return &_sfBottom;
538 const SFReal32 *ViewareaBase::getSFBottom(void) const
540 return &_sfBottom;
544 SFReal32 *ViewareaBase::editSFTop(void)
546 editSField(TopFieldMask);
548 return &_sfTop;
551 const SFReal32 *ViewareaBase::getSFTop(void) const
553 return &_sfTop;
557 SFUInt32 *ViewareaBase::editSFTravMask(void)
559 editSField(TravMaskFieldMask);
561 return &_sfTravMask;
564 const SFUInt32 *ViewareaBase::getSFTravMask(void) const
566 return &_sfTravMask;
570 SFBool *ViewareaBase::editSFEnabled(void)
572 editSField(EnabledFieldMask);
574 return &_sfEnabled;
577 const SFBool *ViewareaBase::getSFEnabled(void) const
579 return &_sfEnabled;
583 SFReal32 *ViewareaBase::editSFDrawTime(void)
585 editSField(DrawTimeFieldMask);
587 return &_sfDrawTime;
590 const SFReal32 *ViewareaBase::getSFDrawTime(void) const
592 return &_sfDrawTime;
596 SFInt32 *ViewareaBase::editSFDrawableId(void)
598 editSField(DrawableIdFieldMask);
600 return &_sfDrawableId;
603 const SFInt32 *ViewareaBase::getSFDrawableId(void) const
605 return &_sfDrawableId;
609 //! Get the Viewarea::_sfRenderOptions field.
610 const SFUnrecRenderOptionsPtr *ViewareaBase::getSFRenderOptions(void) const
612 return &_sfRenderOptions;
615 SFUnrecRenderOptionsPtr *ViewareaBase::editSFRenderOptions (void)
617 editSField(RenderOptionsFieldMask);
619 return &_sfRenderOptions;
622 //! Get the value of the Viewarea::_sfRenderOptions field.
623 RenderOptions * ViewareaBase::getRenderOptions(void) const
625 return _sfRenderOptions.getValue();
628 //! Set the value of the Viewarea::_sfRenderOptions field.
629 void ViewareaBase::setRenderOptions(RenderOptions * const value)
631 editSField(RenderOptionsFieldMask);
633 _sfRenderOptions.setValue(value);
641 /*------------------------------ access -----------------------------------*/
643 SizeT ViewareaBase::getBinSize(ConstFieldMaskArg whichField)
645 SizeT returnValue = Inherited::getBinSize(whichField);
647 if(FieldBits::NoField != (LeftFieldMask & whichField))
649 returnValue += _sfLeft.getBinSize();
651 if(FieldBits::NoField != (RightFieldMask & whichField))
653 returnValue += _sfRight.getBinSize();
655 if(FieldBits::NoField != (BottomFieldMask & whichField))
657 returnValue += _sfBottom.getBinSize();
659 if(FieldBits::NoField != (TopFieldMask & whichField))
661 returnValue += _sfTop.getBinSize();
663 if(FieldBits::NoField != (TravMaskFieldMask & whichField))
665 returnValue += _sfTravMask.getBinSize();
667 if(FieldBits::NoField != (EnabledFieldMask & whichField))
669 returnValue += _sfEnabled.getBinSize();
671 if(FieldBits::NoField != (DrawTimeFieldMask & whichField))
673 returnValue += _sfDrawTime.getBinSize();
675 if(FieldBits::NoField != (DrawableIdFieldMask & whichField))
677 returnValue += _sfDrawableId.getBinSize();
679 if(FieldBits::NoField != (RenderOptionsFieldMask & whichField))
681 returnValue += _sfRenderOptions.getBinSize();
684 return returnValue;
687 void ViewareaBase::copyToBin(BinaryDataHandler &pMem,
688 ConstFieldMaskArg whichField)
690 Inherited::copyToBin(pMem, whichField);
692 if(FieldBits::NoField != (LeftFieldMask & whichField))
694 _sfLeft.copyToBin(pMem);
696 if(FieldBits::NoField != (RightFieldMask & whichField))
698 _sfRight.copyToBin(pMem);
700 if(FieldBits::NoField != (BottomFieldMask & whichField))
702 _sfBottom.copyToBin(pMem);
704 if(FieldBits::NoField != (TopFieldMask & whichField))
706 _sfTop.copyToBin(pMem);
708 if(FieldBits::NoField != (TravMaskFieldMask & whichField))
710 _sfTravMask.copyToBin(pMem);
712 if(FieldBits::NoField != (EnabledFieldMask & whichField))
714 _sfEnabled.copyToBin(pMem);
716 if(FieldBits::NoField != (DrawTimeFieldMask & whichField))
718 _sfDrawTime.copyToBin(pMem);
720 if(FieldBits::NoField != (DrawableIdFieldMask & whichField))
722 _sfDrawableId.copyToBin(pMem);
724 if(FieldBits::NoField != (RenderOptionsFieldMask & whichField))
726 _sfRenderOptions.copyToBin(pMem);
730 void ViewareaBase::copyFromBin(BinaryDataHandler &pMem,
731 ConstFieldMaskArg whichField)
733 Inherited::copyFromBin(pMem, whichField);
735 if(FieldBits::NoField != (LeftFieldMask & whichField))
737 editSField(LeftFieldMask);
738 _sfLeft.copyFromBin(pMem);
740 if(FieldBits::NoField != (RightFieldMask & whichField))
742 editSField(RightFieldMask);
743 _sfRight.copyFromBin(pMem);
745 if(FieldBits::NoField != (BottomFieldMask & whichField))
747 editSField(BottomFieldMask);
748 _sfBottom.copyFromBin(pMem);
750 if(FieldBits::NoField != (TopFieldMask & whichField))
752 editSField(TopFieldMask);
753 _sfTop.copyFromBin(pMem);
755 if(FieldBits::NoField != (TravMaskFieldMask & whichField))
757 editSField(TravMaskFieldMask);
758 _sfTravMask.copyFromBin(pMem);
760 if(FieldBits::NoField != (EnabledFieldMask & whichField))
762 editSField(EnabledFieldMask);
763 _sfEnabled.copyFromBin(pMem);
765 if(FieldBits::NoField != (DrawTimeFieldMask & whichField))
767 editSField(DrawTimeFieldMask);
768 _sfDrawTime.copyFromBin(pMem);
770 if(FieldBits::NoField != (DrawableIdFieldMask & whichField))
772 editSField(DrawableIdFieldMask);
773 _sfDrawableId.copyFromBin(pMem);
775 if(FieldBits::NoField != (RenderOptionsFieldMask & whichField))
777 editSField(RenderOptionsFieldMask);
778 _sfRenderOptions.copyFromBin(pMem);
782 //! create a new instance of the class
783 ViewareaTransitPtr ViewareaBase::createLocal(BitVector bFlags)
785 ViewareaTransitPtr fc;
787 if(getClassType().getPrototype() != NULL)
789 FieldContainerTransitPtr tmpPtr =
790 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
792 fc = dynamic_pointer_cast<Viewarea>(tmpPtr);
795 return fc;
798 //! create a new instance of the class, copy the container flags
799 ViewareaTransitPtr ViewareaBase::createDependent(BitVector bFlags)
801 ViewareaTransitPtr fc;
803 if(getClassType().getPrototype() != NULL)
805 FieldContainerTransitPtr tmpPtr =
806 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
808 fc = dynamic_pointer_cast<Viewarea>(tmpPtr);
811 return fc;
814 //! create a new instance of the class
815 ViewareaTransitPtr ViewareaBase::create(void)
817 ViewareaTransitPtr fc;
819 if(getClassType().getPrototype() != NULL)
821 FieldContainerTransitPtr tmpPtr =
822 getClassType().getPrototype()-> shallowCopy();
824 fc = dynamic_pointer_cast<Viewarea>(tmpPtr);
827 return fc;
830 Viewarea *ViewareaBase::createEmptyLocal(BitVector bFlags)
832 Viewarea *returnValue;
834 newPtr<Viewarea>(returnValue, bFlags);
836 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
838 return returnValue;
841 //! create an empty new instance of the class, do not copy the prototype
842 Viewarea *ViewareaBase::createEmpty(void)
844 Viewarea *returnValue;
846 newPtr<Viewarea>(returnValue, Thread::getCurrentLocalFlags());
848 returnValue->_pFieldFlags->_bNamespaceMask &=
849 ~Thread::getCurrentLocalFlags();
851 return returnValue;
855 FieldContainerTransitPtr ViewareaBase::shallowCopyLocal(
856 BitVector bFlags) const
858 Viewarea *tmpPtr;
860 newPtr(tmpPtr, dynamic_cast<const Viewarea *>(this), bFlags);
862 FieldContainerTransitPtr returnValue(tmpPtr);
864 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
866 return returnValue;
869 FieldContainerTransitPtr ViewareaBase::shallowCopyDependent(
870 BitVector bFlags) const
872 Viewarea *tmpPtr;
874 newPtr(tmpPtr, dynamic_cast<const Viewarea *>(this), ~bFlags);
876 FieldContainerTransitPtr returnValue(tmpPtr);
878 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
880 return returnValue;
883 FieldContainerTransitPtr ViewareaBase::shallowCopy(void) const
885 Viewarea *tmpPtr;
887 newPtr(tmpPtr,
888 dynamic_cast<const Viewarea *>(this),
889 Thread::getCurrentLocalFlags());
891 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
893 FieldContainerTransitPtr returnValue(tmpPtr);
895 return returnValue;
901 /*------------------------- constructors ----------------------------------*/
903 ViewareaBase::ViewareaBase(void) :
904 Inherited(),
905 _sfLeft (Real32(0.f)),
906 _sfRight (Real32(1.f)),
907 _sfBottom (Real32(0.f)),
908 _sfTop (Real32(1.f)),
909 _sfTravMask (UInt32(TypeTraits<UInt32>::getMax() & ~TraversalMasks::FindNamedComponentTraversal)),
910 _sfEnabled (bool(true)),
911 _sfDrawTime (Real32(0.0f)),
912 _sfDrawableId (Int32(-1)),
913 _sfRenderOptions (NULL)
917 ViewareaBase::ViewareaBase(const ViewareaBase &source) :
918 Inherited(source),
919 _sfLeft (source._sfLeft ),
920 _sfRight (source._sfRight ),
921 _sfBottom (source._sfBottom ),
922 _sfTop (source._sfTop ),
923 _sfTravMask (source._sfTravMask ),
924 _sfEnabled (source._sfEnabled ),
925 _sfDrawTime (source._sfDrawTime ),
926 _sfDrawableId (source._sfDrawableId ),
927 _sfRenderOptions (NULL)
932 /*-------------------------- destructors ----------------------------------*/
934 ViewareaBase::~ViewareaBase(void)
938 void ViewareaBase::onCreate(const Viewarea *source)
940 Inherited::onCreate(source);
942 if(source != NULL)
944 Viewarea *pThis = static_cast<Viewarea *>(this);
946 pThis->setRenderOptions(source->getRenderOptions());
950 GetFieldHandlePtr ViewareaBase::getHandleLeft (void) const
952 SFReal32::GetHandlePtr returnValue(
953 new SFReal32::GetHandle(
954 &_sfLeft,
955 this->getType().getFieldDesc(LeftFieldId),
956 const_cast<ViewareaBase *>(this)));
958 return returnValue;
961 EditFieldHandlePtr ViewareaBase::editHandleLeft (void)
963 SFReal32::EditHandlePtr returnValue(
964 new SFReal32::EditHandle(
965 &_sfLeft,
966 this->getType().getFieldDesc(LeftFieldId),
967 this));
970 editSField(LeftFieldMask);
972 return returnValue;
975 GetFieldHandlePtr ViewareaBase::getHandleRight (void) const
977 SFReal32::GetHandlePtr returnValue(
978 new SFReal32::GetHandle(
979 &_sfRight,
980 this->getType().getFieldDesc(RightFieldId),
981 const_cast<ViewareaBase *>(this)));
983 return returnValue;
986 EditFieldHandlePtr ViewareaBase::editHandleRight (void)
988 SFReal32::EditHandlePtr returnValue(
989 new SFReal32::EditHandle(
990 &_sfRight,
991 this->getType().getFieldDesc(RightFieldId),
992 this));
995 editSField(RightFieldMask);
997 return returnValue;
1000 GetFieldHandlePtr ViewareaBase::getHandleBottom (void) const
1002 SFReal32::GetHandlePtr returnValue(
1003 new SFReal32::GetHandle(
1004 &_sfBottom,
1005 this->getType().getFieldDesc(BottomFieldId),
1006 const_cast<ViewareaBase *>(this)));
1008 return returnValue;
1011 EditFieldHandlePtr ViewareaBase::editHandleBottom (void)
1013 SFReal32::EditHandlePtr returnValue(
1014 new SFReal32::EditHandle(
1015 &_sfBottom,
1016 this->getType().getFieldDesc(BottomFieldId),
1017 this));
1020 editSField(BottomFieldMask);
1022 return returnValue;
1025 GetFieldHandlePtr ViewareaBase::getHandleTop (void) const
1027 SFReal32::GetHandlePtr returnValue(
1028 new SFReal32::GetHandle(
1029 &_sfTop,
1030 this->getType().getFieldDesc(TopFieldId),
1031 const_cast<ViewareaBase *>(this)));
1033 return returnValue;
1036 EditFieldHandlePtr ViewareaBase::editHandleTop (void)
1038 SFReal32::EditHandlePtr returnValue(
1039 new SFReal32::EditHandle(
1040 &_sfTop,
1041 this->getType().getFieldDesc(TopFieldId),
1042 this));
1045 editSField(TopFieldMask);
1047 return returnValue;
1050 GetFieldHandlePtr ViewareaBase::getHandleTravMask (void) const
1052 SFUInt32::GetHandlePtr returnValue(
1053 new SFUInt32::GetHandle(
1054 &_sfTravMask,
1055 this->getType().getFieldDesc(TravMaskFieldId),
1056 const_cast<ViewareaBase *>(this)));
1058 return returnValue;
1061 EditFieldHandlePtr ViewareaBase::editHandleTravMask (void)
1063 SFUInt32::EditHandlePtr returnValue(
1064 new SFUInt32::EditHandle(
1065 &_sfTravMask,
1066 this->getType().getFieldDesc(TravMaskFieldId),
1067 this));
1070 editSField(TravMaskFieldMask);
1072 return returnValue;
1075 GetFieldHandlePtr ViewareaBase::getHandleEnabled (void) const
1077 SFBool::GetHandlePtr returnValue(
1078 new SFBool::GetHandle(
1079 &_sfEnabled,
1080 this->getType().getFieldDesc(EnabledFieldId),
1081 const_cast<ViewareaBase *>(this)));
1083 return returnValue;
1086 EditFieldHandlePtr ViewareaBase::editHandleEnabled (void)
1088 SFBool::EditHandlePtr returnValue(
1089 new SFBool::EditHandle(
1090 &_sfEnabled,
1091 this->getType().getFieldDesc(EnabledFieldId),
1092 this));
1095 editSField(EnabledFieldMask);
1097 return returnValue;
1100 GetFieldHandlePtr ViewareaBase::getHandleDrawTime (void) const
1102 SFReal32::GetHandlePtr returnValue(
1103 new SFReal32::GetHandle(
1104 &_sfDrawTime,
1105 this->getType().getFieldDesc(DrawTimeFieldId),
1106 const_cast<ViewareaBase *>(this)));
1108 return returnValue;
1111 EditFieldHandlePtr ViewareaBase::editHandleDrawTime (void)
1113 SFReal32::EditHandlePtr returnValue(
1114 new SFReal32::EditHandle(
1115 &_sfDrawTime,
1116 this->getType().getFieldDesc(DrawTimeFieldId),
1117 this));
1120 editSField(DrawTimeFieldMask);
1122 return returnValue;
1125 GetFieldHandlePtr ViewareaBase::getHandleDrawableId (void) const
1127 SFInt32::GetHandlePtr returnValue(
1128 new SFInt32::GetHandle(
1129 &_sfDrawableId,
1130 this->getType().getFieldDesc(DrawableIdFieldId),
1131 const_cast<ViewareaBase *>(this)));
1133 return returnValue;
1136 EditFieldHandlePtr ViewareaBase::editHandleDrawableId (void)
1138 SFInt32::EditHandlePtr returnValue(
1139 new SFInt32::EditHandle(
1140 &_sfDrawableId,
1141 this->getType().getFieldDesc(DrawableIdFieldId),
1142 this));
1145 editSField(DrawableIdFieldMask);
1147 return returnValue;
1150 GetFieldHandlePtr ViewareaBase::getHandleRenderOptions (void) const
1152 SFUnrecRenderOptionsPtr::GetHandlePtr returnValue(
1153 new SFUnrecRenderOptionsPtr::GetHandle(
1154 &_sfRenderOptions,
1155 this->getType().getFieldDesc(RenderOptionsFieldId),
1156 const_cast<ViewareaBase *>(this)));
1158 return returnValue;
1161 EditFieldHandlePtr ViewareaBase::editHandleRenderOptions (void)
1163 SFUnrecRenderOptionsPtr::EditHandlePtr returnValue(
1164 new SFUnrecRenderOptionsPtr::EditHandle(
1165 &_sfRenderOptions,
1166 this->getType().getFieldDesc(RenderOptionsFieldId),
1167 this));
1169 returnValue->setSetMethod(
1170 boost::bind(&Viewarea::setRenderOptions,
1171 static_cast<Viewarea *>(this), _1));
1173 editSField(RenderOptionsFieldMask);
1175 return returnValue;
1179 #ifdef OSG_MT_CPTR_ASPECT
1180 void ViewareaBase::execSyncV( FieldContainer &oFrom,
1181 ConstFieldMaskArg whichField,
1182 AspectOffsetStore &oOffsets,
1183 ConstFieldMaskArg syncMode,
1184 const UInt32 uiSyncInfo)
1186 Viewarea *pThis = static_cast<Viewarea *>(this);
1188 pThis->execSync(static_cast<Viewarea *>(&oFrom),
1189 whichField,
1190 oOffsets,
1191 syncMode,
1192 uiSyncInfo);
1194 #endif
1197 #ifdef OSG_MT_CPTR_ASPECT
1198 FieldContainer *ViewareaBase::createAspectCopy(
1199 const FieldContainer *pRefAspect) const
1201 Viewarea *returnValue;
1203 newAspectCopy(returnValue,
1204 dynamic_cast<const Viewarea *>(pRefAspect),
1205 dynamic_cast<const Viewarea *>(this));
1207 return returnValue;
1209 #endif
1211 void ViewareaBase::resolveLinks(void)
1213 Inherited::resolveLinks();
1215 static_cast<Viewarea *>(this)->setRenderOptions(NULL);
1221 OSG_END_NAMESPACE