changed: gcc8 base update
[opensg.git] / Source / System / Window / Base / OSGBackgroundBase.cpp
blob0a349f0aab6a38affd1c3ac1e7a866cc157f7a90
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 Background!
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"
66 #include "OSGBackgroundBase.h"
67 #include "OSGBackground.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::Background
78 Background is the base class for all background/buffer clearing. See \ref
79 PageSystemWindowBackground for a description.
81 \ext
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.
87 \endext
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(
118 "BackgroundPtr",
119 "AttachmentContainerPtr",
120 Background::getClassType(),
121 nsOSG);
122 #endif
124 OSG_FIELDTRAITS_GETTYPE_NS(Background *, nsOSG)
126 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
127 Background *,
128 nsOSG)
130 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
131 Background *,
132 nsOSG)
134 /***************************************************************************\
135 * Field Description *
136 \***************************************************************************/
138 void BackgroundBase::classDescInserter(TypeObject &oType)
140 FieldDescriptionBase *pDesc = NULL;
143 pDesc = new SFInt32::Description(
144 SFInt32::getClassType(),
145 "clearStencilBit",
146 "Usually 0 is used to clear all stencil bitplanes \n"
147 "(clear is deactivated if smaller zero).\n",
148 ClearStencilBitFieldId, ClearStencilBitFieldMask,
149 false,
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(),
158 "depth",
159 "Depth value for clear, defaults to 1.\n",
160 DepthFieldId, DepthFieldMask,
161 false,
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(),
170 "clearDepth",
171 "Whether to clear the depth buffer or not\n",
172 ClearDepthFieldId, ClearDepthFieldMask,
173 false,
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(),
182 "clearColor",
183 "Whether to clear the color buffer or not\n",
184 ClearColorFieldId, ClearColorFieldMask,
185 false,
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(),
197 "NULL",
198 nsOSG, //Namespace
199 NULL,
200 reinterpret_cast<InitContainerF>(&Background::initMethod),
201 reinterpret_cast<ExitContainerF>(&Background::exitMethod),
202 reinterpret_cast<InitalInsertDescFunc>(
203 reinterpret_cast<void *>(&Background::classDescInserter)),
204 false,
206 "<?xml version=\"1.0\" ?>\n"
207 "\n"
208 "<FieldContainer\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"
217 " >\n"
218 "\n"
219 " Background is the base class for all background/buffer clearing. See \\ref\n"
220 " PageSystemWindowBackground for a description.\n"
221 "\n"
222 " \\ext\n"
223 "\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"
227 " \n"
228 " \\endext\n"
229 "\n"
230 " <Field\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"
237 " \t >\n"
238 " \tUsually 0 is used to clear all stencil bitplanes \n"
239 " (clear is deactivated if smaller zero).\n"
240 " </Field>\n"
241 " <Field\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"
248 " \t >\n"
249 " \tDepth value for clear, defaults to 1.\n"
250 " </Field>\n"
251 " <Field\n"
252 " name=\"clearDepth\"\n"
253 " type=\"bool\"\n"
254 " cardinality=\"single\"\n"
255 " visibility=\"external\"\n"
256 " defaultValue=\"true\"\n"
257 " access=\"public\"\n"
258 " >\n"
259 " Whether to clear the depth buffer or not\n"
260 " </Field>\n"
261 " <Field\n"
262 " name=\"clearColor\"\n"
263 " type=\"bool\"\n"
264 " cardinality=\"single\"\n"
265 " visibility=\"external\"\n"
266 " defaultValue=\"true\"\n"
267 " access=\"public\"\n"
268 " >\n"
269 " Whether to clear the color buffer or not\n"
270 " </Field>\n"
271 "</FieldContainer>\n",
272 "Background is the base class for all background/buffer clearing. See \\ref\n"
273 "PageSystemWindowBackground for a description.\n"
274 "\n"
275 "\\ext\n"
276 "\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"
280 "\n"
281 "\\endext\n"
284 /*------------------------------ get -----------------------------------*/
286 FieldContainerType &BackgroundBase::getType(void)
288 return _type;
291 const FieldContainerType &BackgroundBase::getType(void) const
293 return _type;
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);
321 return &_sfDepth;
324 const SFReal32 *BackgroundBase::getSFDepth(void) const
326 return &_sfDepth;
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();
383 return returnValue;
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) :
442 Inherited(),
443 _sfClearStencilBit (Int32(-1)),
444 _sfDepth (Real32(1.f)),
445 _sfClearDepth (bool(true)),
446 _sfClearColor (bool(true))
450 BackgroundBase::BackgroundBase(const BackgroundBase &source) :
451 Inherited(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(
471 &_sfClearStencilBit,
472 this->getType().getFieldDesc(ClearStencilBitFieldId),
473 const_cast<BackgroundBase *>(this)));
475 return returnValue;
478 EditFieldHandlePtr BackgroundBase::editHandleClearStencilBit(void)
480 SFInt32::EditHandlePtr returnValue(
481 new SFInt32::EditHandle(
482 &_sfClearStencilBit,
483 this->getType().getFieldDesc(ClearStencilBitFieldId),
484 this));
487 editSField(ClearStencilBitFieldMask);
489 return returnValue;
492 GetFieldHandlePtr BackgroundBase::getHandleDepth (void) const
494 SFReal32::GetHandlePtr returnValue(
495 new SFReal32::GetHandle(
496 &_sfDepth,
497 this->getType().getFieldDesc(DepthFieldId),
498 const_cast<BackgroundBase *>(this)));
500 return returnValue;
503 EditFieldHandlePtr BackgroundBase::editHandleDepth (void)
505 SFReal32::EditHandlePtr returnValue(
506 new SFReal32::EditHandle(
507 &_sfDepth,
508 this->getType().getFieldDesc(DepthFieldId),
509 this));
512 editSField(DepthFieldMask);
514 return returnValue;
517 GetFieldHandlePtr BackgroundBase::getHandleClearDepth (void) const
519 SFBool::GetHandlePtr returnValue(
520 new SFBool::GetHandle(
521 &_sfClearDepth,
522 this->getType().getFieldDesc(ClearDepthFieldId),
523 const_cast<BackgroundBase *>(this)));
525 return returnValue;
528 EditFieldHandlePtr BackgroundBase::editHandleClearDepth (void)
530 SFBool::EditHandlePtr returnValue(
531 new SFBool::EditHandle(
532 &_sfClearDepth,
533 this->getType().getFieldDesc(ClearDepthFieldId),
534 this));
537 editSField(ClearDepthFieldMask);
539 return returnValue;
542 GetFieldHandlePtr BackgroundBase::getHandleClearColor (void) const
544 SFBool::GetHandlePtr returnValue(
545 new SFBool::GetHandle(
546 &_sfClearColor,
547 this->getType().getFieldDesc(ClearColorFieldId),
548 const_cast<BackgroundBase *>(this)));
550 return returnValue;
553 EditFieldHandlePtr BackgroundBase::editHandleClearColor (void)
555 SFBool::EditHandlePtr returnValue(
556 new SFBool::EditHandle(
557 &_sfClearColor,
558 this->getType().getFieldDesc(ClearColorFieldId),
559 this));
562 editSField(ClearColorFieldMask);
564 return returnValue;
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),
578 whichField,
579 oOffsets,
580 syncMode,
581 uiSyncInfo);
583 #endif
587 void BackgroundBase::resolveLinks(void)
589 Inherited::resolveLinks();
595 OSG_END_NAMESPACE