1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
66 #include "OSGBackgroundBase.h"
67 #include "OSGBackground.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
75 \***************************************************************************/
77 /*! \class OSG::Background
78 Background is the base class for all background/buffer clearing. See \ref
79 PageSystemWindowBackground for a description.
83 To create a new Background the method that has be overridden is
84 clear(DrawActionBase * action, Viewport * port);. It can directly call OpenGL
85 commands, but should restore the state after it's done.
90 /***************************************************************************\
91 * Field Documentation *
92 \***************************************************************************/
94 /*! \var Int32 BackgroundBase::_sfClearStencilBit
95 Usually 0 is used to clear all stencil bitplanes
96 (clear is deactivated if smaller zero).
99 /*! \var Real32 BackgroundBase::_sfDepth
100 Depth value for clear, defaults to 1.
103 /*! \var bool BackgroundBase::_sfClearDepth
104 Whether to clear the depth buffer or not
107 /*! \var bool BackgroundBase::_sfClearColor
108 Whether to clear the color buffer or not
112 /***************************************************************************\
113 * FieldType/FieldTrait Instantiation *
114 \***************************************************************************/
116 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
117 PointerType FieldTraits
<Background
*, nsOSG
>::_type(
119 "AttachmentContainerPtr",
120 Background::getClassType(),
124 OSG_FIELDTRAITS_GETTYPE_NS(Background
*, nsOSG
)
126 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
130 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
134 /***************************************************************************\
135 * Field Description *
136 \***************************************************************************/
138 void BackgroundBase::classDescInserter(TypeObject
&oType
)
140 FieldDescriptionBase
*pDesc
= NULL
;
143 pDesc
= new SFInt32::Description(
144 SFInt32::getClassType(),
146 "Usually 0 is used to clear all stencil bitplanes \n"
147 "(clear is deactivated if smaller zero).\n",
148 ClearStencilBitFieldId
, ClearStencilBitFieldMask
,
150 (Field::SFDefaultFlags
| Field::FStdAccess
),
151 static_cast<FieldEditMethodSig
>(&Background::editHandleClearStencilBit
),
152 static_cast<FieldGetMethodSig
>(&Background::getHandleClearStencilBit
));
154 oType
.addInitialDesc(pDesc
);
156 pDesc
= new SFReal32::Description(
157 SFReal32::getClassType(),
159 "Depth value for clear, defaults to 1.\n",
160 DepthFieldId
, DepthFieldMask
,
162 (Field::SFDefaultFlags
| Field::FStdAccess
),
163 static_cast<FieldEditMethodSig
>(&Background::editHandleDepth
),
164 static_cast<FieldGetMethodSig
>(&Background::getHandleDepth
));
166 oType
.addInitialDesc(pDesc
);
168 pDesc
= new SFBool::Description(
169 SFBool::getClassType(),
171 "Whether to clear the depth buffer or not\n",
172 ClearDepthFieldId
, ClearDepthFieldMask
,
174 (Field::SFDefaultFlags
| Field::FStdAccess
),
175 static_cast<FieldEditMethodSig
>(&Background::editHandleClearDepth
),
176 static_cast<FieldGetMethodSig
>(&Background::getHandleClearDepth
));
178 oType
.addInitialDesc(pDesc
);
180 pDesc
= new SFBool::Description(
181 SFBool::getClassType(),
183 "Whether to clear the color buffer or not\n",
184 ClearColorFieldId
, ClearColorFieldMask
,
186 (Field::SFDefaultFlags
| Field::FStdAccess
),
187 static_cast<FieldEditMethodSig
>(&Background::editHandleClearColor
),
188 static_cast<FieldGetMethodSig
>(&Background::getHandleClearColor
));
190 oType
.addInitialDesc(pDesc
);
194 BackgroundBase::TypeObject
BackgroundBase::_type(
195 BackgroundBase::getClassname(),
196 Inherited::getClassname(),
200 reinterpret_cast<InitContainerF
>(&Background::initMethod
),
201 reinterpret_cast<ExitContainerF
>(&Background::exitMethod
),
202 reinterpret_cast<InitalInsertDescFunc
>(
203 reinterpret_cast<void *>(&Background::classDescInserter
)),
206 "<?xml version=\"1.0\" ?>\n"
209 " name=\"Background\"\n"
210 " parent=\"AttachmentContainer\"\n"
211 " library=\"System\"\n"
212 " structure=\"abstract\"\n"
213 " pointerfieldtypes=\"both\"\n"
214 " systemcomponent=\"true\"\n"
215 " parentsystemcomponent=\"true\"\n"
216 " docGroupBase=\"GrpSystemWindow\"\n"
219 " Background is the base class for all background/buffer clearing. See \\ref\n"
220 " PageSystemWindowBackground for a description.\n"
224 " To create a new Background the method that has be overridden is\n"
225 " clear(DrawActionBase * action, Viewport * port);. It can directly call OpenGL\n"
226 " commands, but should restore the state after it's done.\n"
231 " \t name=\"clearStencilBit\"\n"
232 " \t type=\"Int32\"\n"
233 " \t cardinality=\"single\"\n"
234 " \t visibility=\"external\"\n"
235 " \t defaultValue=\"-1\"\n"
236 " \t access=\"public\"\n"
238 " \tUsually 0 is used to clear all stencil bitplanes \n"
239 " (clear is deactivated if smaller zero).\n"
242 " \t name=\"depth\"\n"
243 " \t type=\"Real32\"\n"
244 " \t cardinality=\"single\"\n"
245 " \t visibility=\"external\"\n"
246 " \t defaultValue=\"1.f\"\n"
247 " \t access=\"public\"\n"
249 " \tDepth value for clear, defaults to 1.\n"
252 " name=\"clearDepth\"\n"
254 " cardinality=\"single\"\n"
255 " visibility=\"external\"\n"
256 " defaultValue=\"true\"\n"
257 " access=\"public\"\n"
259 " Whether to clear the depth buffer or not\n"
262 " name=\"clearColor\"\n"
264 " cardinality=\"single\"\n"
265 " visibility=\"external\"\n"
266 " defaultValue=\"true\"\n"
267 " access=\"public\"\n"
269 " Whether to clear the color buffer or not\n"
271 "</FieldContainer>\n",
272 "Background is the base class for all background/buffer clearing. See \\ref\n"
273 "PageSystemWindowBackground for a description.\n"
277 "To create a new Background the method that has be overridden is\n"
278 "clear(DrawActionBase * action, Viewport * port);. It can directly call OpenGL\n"
279 "commands, but should restore the state after it's done.\n"
284 /*------------------------------ get -----------------------------------*/
286 FieldContainerType
&BackgroundBase::getType(void)
291 const FieldContainerType
&BackgroundBase::getType(void) const
296 UInt32
BackgroundBase::getContainerSize(void) const
298 return sizeof(Background
);
301 /*------------------------- decorator get ------------------------------*/
304 SFInt32
*BackgroundBase::editSFClearStencilBit(void)
306 editSField(ClearStencilBitFieldMask
);
308 return &_sfClearStencilBit
;
311 const SFInt32
*BackgroundBase::getSFClearStencilBit(void) const
313 return &_sfClearStencilBit
;
317 SFReal32
*BackgroundBase::editSFDepth(void)
319 editSField(DepthFieldMask
);
324 const SFReal32
*BackgroundBase::getSFDepth(void) const
330 SFBool
*BackgroundBase::editSFClearDepth(void)
332 editSField(ClearDepthFieldMask
);
334 return &_sfClearDepth
;
337 const SFBool
*BackgroundBase::getSFClearDepth(void) const
339 return &_sfClearDepth
;
343 SFBool
*BackgroundBase::editSFClearColor(void)
345 editSField(ClearColorFieldMask
);
347 return &_sfClearColor
;
350 const SFBool
*BackgroundBase::getSFClearColor(void) const
352 return &_sfClearColor
;
360 /*------------------------------ access -----------------------------------*/
362 SizeT
BackgroundBase::getBinSize(ConstFieldMaskArg whichField
)
364 SizeT returnValue
= Inherited::getBinSize(whichField
);
366 if(FieldBits::NoField
!= (ClearStencilBitFieldMask
& whichField
))
368 returnValue
+= _sfClearStencilBit
.getBinSize();
370 if(FieldBits::NoField
!= (DepthFieldMask
& whichField
))
372 returnValue
+= _sfDepth
.getBinSize();
374 if(FieldBits::NoField
!= (ClearDepthFieldMask
& whichField
))
376 returnValue
+= _sfClearDepth
.getBinSize();
378 if(FieldBits::NoField
!= (ClearColorFieldMask
& whichField
))
380 returnValue
+= _sfClearColor
.getBinSize();
386 void BackgroundBase::copyToBin(BinaryDataHandler
&pMem
,
387 ConstFieldMaskArg whichField
)
389 Inherited::copyToBin(pMem
, whichField
);
391 if(FieldBits::NoField
!= (ClearStencilBitFieldMask
& whichField
))
393 _sfClearStencilBit
.copyToBin(pMem
);
395 if(FieldBits::NoField
!= (DepthFieldMask
& whichField
))
397 _sfDepth
.copyToBin(pMem
);
399 if(FieldBits::NoField
!= (ClearDepthFieldMask
& whichField
))
401 _sfClearDepth
.copyToBin(pMem
);
403 if(FieldBits::NoField
!= (ClearColorFieldMask
& whichField
))
405 _sfClearColor
.copyToBin(pMem
);
409 void BackgroundBase::copyFromBin(BinaryDataHandler
&pMem
,
410 ConstFieldMaskArg whichField
)
412 Inherited::copyFromBin(pMem
, whichField
);
414 if(FieldBits::NoField
!= (ClearStencilBitFieldMask
& whichField
))
416 editSField(ClearStencilBitFieldMask
);
417 _sfClearStencilBit
.copyFromBin(pMem
);
419 if(FieldBits::NoField
!= (DepthFieldMask
& whichField
))
421 editSField(DepthFieldMask
);
422 _sfDepth
.copyFromBin(pMem
);
424 if(FieldBits::NoField
!= (ClearDepthFieldMask
& whichField
))
426 editSField(ClearDepthFieldMask
);
427 _sfClearDepth
.copyFromBin(pMem
);
429 if(FieldBits::NoField
!= (ClearColorFieldMask
& whichField
))
431 editSField(ClearColorFieldMask
);
432 _sfClearColor
.copyFromBin(pMem
);
439 /*------------------------- constructors ----------------------------------*/
441 BackgroundBase::BackgroundBase(void) :
443 _sfClearStencilBit (Int32(-1)),
444 _sfDepth (Real32(1.f
)),
445 _sfClearDepth (bool(true)),
446 _sfClearColor (bool(true))
450 BackgroundBase::BackgroundBase(const BackgroundBase
&source
) :
452 _sfClearStencilBit (source
._sfClearStencilBit
),
453 _sfDepth (source
._sfDepth
),
454 _sfClearDepth (source
._sfClearDepth
),
455 _sfClearColor (source
._sfClearColor
)
460 /*-------------------------- destructors ----------------------------------*/
462 BackgroundBase::~BackgroundBase(void)
467 GetFieldHandlePtr
BackgroundBase::getHandleClearStencilBit (void) const
469 SFInt32::GetHandlePtr
returnValue(
470 new SFInt32::GetHandle(
472 this->getType().getFieldDesc(ClearStencilBitFieldId
),
473 const_cast<BackgroundBase
*>(this)));
478 EditFieldHandlePtr
BackgroundBase::editHandleClearStencilBit(void)
480 SFInt32::EditHandlePtr
returnValue(
481 new SFInt32::EditHandle(
483 this->getType().getFieldDesc(ClearStencilBitFieldId
),
487 editSField(ClearStencilBitFieldMask
);
492 GetFieldHandlePtr
BackgroundBase::getHandleDepth (void) const
494 SFReal32::GetHandlePtr
returnValue(
495 new SFReal32::GetHandle(
497 this->getType().getFieldDesc(DepthFieldId
),
498 const_cast<BackgroundBase
*>(this)));
503 EditFieldHandlePtr
BackgroundBase::editHandleDepth (void)
505 SFReal32::EditHandlePtr
returnValue(
506 new SFReal32::EditHandle(
508 this->getType().getFieldDesc(DepthFieldId
),
512 editSField(DepthFieldMask
);
517 GetFieldHandlePtr
BackgroundBase::getHandleClearDepth (void) const
519 SFBool::GetHandlePtr
returnValue(
520 new SFBool::GetHandle(
522 this->getType().getFieldDesc(ClearDepthFieldId
),
523 const_cast<BackgroundBase
*>(this)));
528 EditFieldHandlePtr
BackgroundBase::editHandleClearDepth (void)
530 SFBool::EditHandlePtr
returnValue(
531 new SFBool::EditHandle(
533 this->getType().getFieldDesc(ClearDepthFieldId
),
537 editSField(ClearDepthFieldMask
);
542 GetFieldHandlePtr
BackgroundBase::getHandleClearColor (void) const
544 SFBool::GetHandlePtr
returnValue(
545 new SFBool::GetHandle(
547 this->getType().getFieldDesc(ClearColorFieldId
),
548 const_cast<BackgroundBase
*>(this)));
553 EditFieldHandlePtr
BackgroundBase::editHandleClearColor (void)
555 SFBool::EditHandlePtr
returnValue(
556 new SFBool::EditHandle(
558 this->getType().getFieldDesc(ClearColorFieldId
),
562 editSField(ClearColorFieldMask
);
568 #ifdef OSG_MT_CPTR_ASPECT
569 void BackgroundBase::execSyncV( FieldContainer
&oFrom
,
570 ConstFieldMaskArg whichField
,
571 AspectOffsetStore
&oOffsets
,
572 ConstFieldMaskArg syncMode
,
573 const UInt32 uiSyncInfo
)
575 Background
*pThis
= static_cast<Background
*>(this);
577 pThis
->execSync(static_cast<Background
*>(&oFrom
),
587 void BackgroundBase::resolveLinks(void)
589 Inherited::resolveLinks();