changed: gcc8 base update
[opensg.git] / Source / System / Window / Background / OSGGradientBackgroundBase.cpp
blob19ad01700ce28ad4a3c8d9a28d7ef9b989c4dc1b
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 GradientBackground!
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 "OSGGradientBackgroundBase.h"
67 #include "OSGGradientBackground.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::GradientBackground
78 A background showing a color gradient. The colors and positions correspond to
79 each other, so both have to have the same number of elements.
80 The style field (_sfStyle) selects the kind of gradient being
81 drawn (HORIZONTAL, VERTICAL).
84 /***************************************************************************\
85 * Field Documentation *
86 \***************************************************************************/
88 /*! \var Color3f GradientBackgroundBase::_mfColor
89 The colors of the gradient.
92 /*! \var Real32 GradientBackgroundBase::_mfPosition
93 The positions of the gradient.
96 /*! \var bool GradientBackgroundBase::_sfNormPosition
97 If true the values of the position field must be normed coordinates in the
98 range [0,1], otherwise they must be pixel coordinates.
101 /*! \var UInt32 GradientBackgroundBase::_sfStyle
102 Gradient style. Allowed values are VERTICAL and HORIZONTAL.
106 /***************************************************************************\
107 * FieldType/FieldTrait Instantiation *
108 \***************************************************************************/
110 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
111 PointerType FieldTraits<GradientBackground *, nsOSG>::_type(
112 "GradientBackgroundPtr",
113 "TileableBackgroundPtr",
114 GradientBackground::getClassType(),
115 nsOSG);
116 #endif
118 OSG_FIELDTRAITS_GETTYPE_NS(GradientBackground *, nsOSG)
121 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
122 GradientBackground *,
123 nsOSG)
125 /***************************************************************************\
126 * Field Description *
127 \***************************************************************************/
129 void GradientBackgroundBase::classDescInserter(TypeObject &oType)
131 FieldDescriptionBase *pDesc = NULL;
134 pDesc = new MFColor3f::Description(
135 MFColor3f::getClassType(),
136 "color",
137 "The colors of the gradient.\n",
138 ColorFieldId, ColorFieldMask,
139 false,
140 (Field::MFDefaultFlags | Field::FStdAccess),
141 static_cast<FieldEditMethodSig>(&GradientBackground::editHandleColor),
142 static_cast<FieldGetMethodSig >(&GradientBackground::getHandleColor));
144 oType.addInitialDesc(pDesc);
146 pDesc = new MFReal32::Description(
147 MFReal32::getClassType(),
148 "position",
149 "The positions of the gradient.\n",
150 PositionFieldId, PositionFieldMask,
151 false,
152 (Field::MFDefaultFlags | Field::FStdAccess),
153 static_cast<FieldEditMethodSig>(&GradientBackground::editHandlePosition),
154 static_cast<FieldGetMethodSig >(&GradientBackground::getHandlePosition));
156 oType.addInitialDesc(pDesc);
158 pDesc = new SFBool::Description(
159 SFBool::getClassType(),
160 "normPosition",
161 "If true the values of the position field must be normed coordinates in the\n"
162 "range [0,1], otherwise they must be pixel coordinates.\n",
163 NormPositionFieldId, NormPositionFieldMask,
164 false,
165 (Field::SFDefaultFlags | Field::FStdAccess),
166 static_cast<FieldEditMethodSig>(&GradientBackground::editHandleNormPosition),
167 static_cast<FieldGetMethodSig >(&GradientBackground::getHandleNormPosition));
169 oType.addInitialDesc(pDesc);
171 pDesc = new SFUInt32::Description(
172 SFUInt32::getClassType(),
173 "style",
174 "Gradient style. Allowed values are VERTICAL and HORIZONTAL.\n",
175 StyleFieldId, StyleFieldMask,
176 false,
177 (Field::SFDefaultFlags | Field::FStdAccess),
178 static_cast<FieldEditMethodSig>(&GradientBackground::editHandleStyle),
179 static_cast<FieldGetMethodSig >(&GradientBackground::getHandleStyle));
181 oType.addInitialDesc(pDesc);
185 GradientBackgroundBase::TypeObject GradientBackgroundBase::_type(
186 GradientBackgroundBase::getClassname(),
187 Inherited::getClassname(),
188 "NULL",
189 nsOSG, //Namespace
190 reinterpret_cast<PrototypeCreateF>(&GradientBackgroundBase::createEmptyLocal),
191 reinterpret_cast<InitContainerF>(&GradientBackground::initMethod),
192 reinterpret_cast<ExitContainerF>(&GradientBackground::exitMethod),
193 reinterpret_cast<InitalInsertDescFunc>(
194 reinterpret_cast<void *>(&GradientBackground::classDescInserter)),
195 false,
197 "<?xml version=\"1.0\"?>\n"
198 "\n"
199 "<FieldContainer\n"
200 " name=\"GradientBackground\"\n"
201 " parent=\"TileableBackground\"\n"
202 " library=\"Window\"\n"
203 " pointerfieldtypes=\"multi\"\n"
204 " structure=\"concrete\"\n"
205 " systemcomponent=\"true\"\n"
206 " parentsystemcomponent=\"true\"\n"
207 " decoratable=\"false\"\n"
208 " docGroupBase=\"GrpWindowBackground\"\n"
209 " >\n"
210 " A background showing a color gradient. The colors and positions correspond to\n"
211 " each other, so both have to have the same number of elements.\n"
212 " The style field (_sfStyle) selects the kind of gradient being\n"
213 " drawn (HORIZONTAL, VERTICAL).\n"
214 " <Field\n"
215 "\t name=\"color\"\n"
216 "\t type=\"Color3f\"\n"
217 "\t cardinality=\"multi\"\n"
218 "\t visibility=\"external\"\n"
219 "\t access=\"protected\"\n"
220 "\t >\n"
221 "\tThe colors of the gradient.\n"
222 " </Field>\n"
223 " <Field\n"
224 "\t name=\"position\"\n"
225 "\t type=\"Real32\"\n"
226 "\t cardinality=\"multi\"\n"
227 "\t visibility=\"external\"\n"
228 "\t access=\"protected\"\n"
229 "\t >\n"
230 "\tThe positions of the gradient.\n"
231 " </Field>\n"
232 " <Field\n"
233 " name=\"normPosition\"\n"
234 " type=\"bool\"\n"
235 " cardinality=\"single\"\n"
236 " visibility=\"external\"\n"
237 " defaultValue=\"true\"\n"
238 " access=\"protected\"\n"
239 " >\n"
240 " If true the values of the position field must be normed coordinates in the\n"
241 " range [0,1], otherwise they must be pixel coordinates.\n"
242 " </Field>\n"
243 " <Field\n"
244 "\t name=\"style\"\n"
245 "\t type=\"UInt32\"\n"
246 "\t cardinality=\"single\"\n"
247 "\t visibility=\"external\"\n"
248 " defaultValue=\"GradientBackground::VERTICAL\"\n"
249 "\t access=\"public\"\n"
250 "\t >\n"
251 "\tGradient style. Allowed values are VERTICAL and HORIZONTAL.\n"
252 " </Field>\n"
253 "</FieldContainer>\n",
254 "A background showing a color gradient. The colors and positions correspond to\n"
255 "each other, so both have to have the same number of elements.\n"
256 "The style field (_sfStyle) selects the kind of gradient being\n"
257 "drawn (HORIZONTAL, VERTICAL).\n"
260 /*------------------------------ get -----------------------------------*/
262 FieldContainerType &GradientBackgroundBase::getType(void)
264 return _type;
267 const FieldContainerType &GradientBackgroundBase::getType(void) const
269 return _type;
272 UInt32 GradientBackgroundBase::getContainerSize(void) const
274 return sizeof(GradientBackground);
277 /*------------------------- decorator get ------------------------------*/
280 MFColor3f *GradientBackgroundBase::editMFColor(void)
282 editMField(ColorFieldMask, _mfColor);
284 return &_mfColor;
287 const MFColor3f *GradientBackgroundBase::getMFColor(void) const
289 return &_mfColor;
293 MFReal32 *GradientBackgroundBase::editMFPosition(void)
295 editMField(PositionFieldMask, _mfPosition);
297 return &_mfPosition;
300 const MFReal32 *GradientBackgroundBase::getMFPosition(void) const
302 return &_mfPosition;
306 SFBool *GradientBackgroundBase::editSFNormPosition(void)
308 editSField(NormPositionFieldMask);
310 return &_sfNormPosition;
313 const SFBool *GradientBackgroundBase::getSFNormPosition(void) const
315 return &_sfNormPosition;
319 SFUInt32 *GradientBackgroundBase::editSFStyle(void)
321 editSField(StyleFieldMask);
323 return &_sfStyle;
326 const SFUInt32 *GradientBackgroundBase::getSFStyle(void) const
328 return &_sfStyle;
336 /*------------------------------ access -----------------------------------*/
338 SizeT GradientBackgroundBase::getBinSize(ConstFieldMaskArg whichField)
340 SizeT returnValue = Inherited::getBinSize(whichField);
342 if(FieldBits::NoField != (ColorFieldMask & whichField))
344 returnValue += _mfColor.getBinSize();
346 if(FieldBits::NoField != (PositionFieldMask & whichField))
348 returnValue += _mfPosition.getBinSize();
350 if(FieldBits::NoField != (NormPositionFieldMask & whichField))
352 returnValue += _sfNormPosition.getBinSize();
354 if(FieldBits::NoField != (StyleFieldMask & whichField))
356 returnValue += _sfStyle.getBinSize();
359 return returnValue;
362 void GradientBackgroundBase::copyToBin(BinaryDataHandler &pMem,
363 ConstFieldMaskArg whichField)
365 Inherited::copyToBin(pMem, whichField);
367 if(FieldBits::NoField != (ColorFieldMask & whichField))
369 _mfColor.copyToBin(pMem);
371 if(FieldBits::NoField != (PositionFieldMask & whichField))
373 _mfPosition.copyToBin(pMem);
375 if(FieldBits::NoField != (NormPositionFieldMask & whichField))
377 _sfNormPosition.copyToBin(pMem);
379 if(FieldBits::NoField != (StyleFieldMask & whichField))
381 _sfStyle.copyToBin(pMem);
385 void GradientBackgroundBase::copyFromBin(BinaryDataHandler &pMem,
386 ConstFieldMaskArg whichField)
388 Inherited::copyFromBin(pMem, whichField);
390 if(FieldBits::NoField != (ColorFieldMask & whichField))
392 editMField(ColorFieldMask, _mfColor);
393 _mfColor.copyFromBin(pMem);
395 if(FieldBits::NoField != (PositionFieldMask & whichField))
397 editMField(PositionFieldMask, _mfPosition);
398 _mfPosition.copyFromBin(pMem);
400 if(FieldBits::NoField != (NormPositionFieldMask & whichField))
402 editSField(NormPositionFieldMask);
403 _sfNormPosition.copyFromBin(pMem);
405 if(FieldBits::NoField != (StyleFieldMask & whichField))
407 editSField(StyleFieldMask);
408 _sfStyle.copyFromBin(pMem);
412 //! create a new instance of the class
413 GradientBackgroundTransitPtr GradientBackgroundBase::createLocal(BitVector bFlags)
415 GradientBackgroundTransitPtr fc;
417 if(getClassType().getPrototype() != NULL)
419 FieldContainerTransitPtr tmpPtr =
420 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
422 fc = dynamic_pointer_cast<GradientBackground>(tmpPtr);
425 return fc;
428 //! create a new instance of the class, copy the container flags
429 GradientBackgroundTransitPtr GradientBackgroundBase::createDependent(BitVector bFlags)
431 GradientBackgroundTransitPtr fc;
433 if(getClassType().getPrototype() != NULL)
435 FieldContainerTransitPtr tmpPtr =
436 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
438 fc = dynamic_pointer_cast<GradientBackground>(tmpPtr);
441 return fc;
444 //! create a new instance of the class
445 GradientBackgroundTransitPtr GradientBackgroundBase::create(void)
447 GradientBackgroundTransitPtr fc;
449 if(getClassType().getPrototype() != NULL)
451 FieldContainerTransitPtr tmpPtr =
452 getClassType().getPrototype()-> shallowCopy();
454 fc = dynamic_pointer_cast<GradientBackground>(tmpPtr);
457 return fc;
460 GradientBackground *GradientBackgroundBase::createEmptyLocal(BitVector bFlags)
462 GradientBackground *returnValue;
464 newPtr<GradientBackground>(returnValue, bFlags);
466 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
468 return returnValue;
471 //! create an empty new instance of the class, do not copy the prototype
472 GradientBackground *GradientBackgroundBase::createEmpty(void)
474 GradientBackground *returnValue;
476 newPtr<GradientBackground>(returnValue, Thread::getCurrentLocalFlags());
478 returnValue->_pFieldFlags->_bNamespaceMask &=
479 ~Thread::getCurrentLocalFlags();
481 return returnValue;
485 FieldContainerTransitPtr GradientBackgroundBase::shallowCopyLocal(
486 BitVector bFlags) const
488 GradientBackground *tmpPtr;
490 newPtr(tmpPtr, dynamic_cast<const GradientBackground *>(this), bFlags);
492 FieldContainerTransitPtr returnValue(tmpPtr);
494 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
496 return returnValue;
499 FieldContainerTransitPtr GradientBackgroundBase::shallowCopyDependent(
500 BitVector bFlags) const
502 GradientBackground *tmpPtr;
504 newPtr(tmpPtr, dynamic_cast<const GradientBackground *>(this), ~bFlags);
506 FieldContainerTransitPtr returnValue(tmpPtr);
508 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
510 return returnValue;
513 FieldContainerTransitPtr GradientBackgroundBase::shallowCopy(void) const
515 GradientBackground *tmpPtr;
517 newPtr(tmpPtr,
518 dynamic_cast<const GradientBackground *>(this),
519 Thread::getCurrentLocalFlags());
521 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
523 FieldContainerTransitPtr returnValue(tmpPtr);
525 return returnValue;
531 /*------------------------- constructors ----------------------------------*/
533 GradientBackgroundBase::GradientBackgroundBase(void) :
534 Inherited(),
535 _mfColor (),
536 _mfPosition (),
537 _sfNormPosition (bool(true)),
538 _sfStyle (UInt32(GradientBackground::VERTICAL))
542 GradientBackgroundBase::GradientBackgroundBase(const GradientBackgroundBase &source) :
543 Inherited(source),
544 _mfColor (source._mfColor ),
545 _mfPosition (source._mfPosition ),
546 _sfNormPosition (source._sfNormPosition ),
547 _sfStyle (source._sfStyle )
552 /*-------------------------- destructors ----------------------------------*/
554 GradientBackgroundBase::~GradientBackgroundBase(void)
559 GetFieldHandlePtr GradientBackgroundBase::getHandleColor (void) const
561 MFColor3f::GetHandlePtr returnValue(
562 new MFColor3f::GetHandle(
563 &_mfColor,
564 this->getType().getFieldDesc(ColorFieldId),
565 const_cast<GradientBackgroundBase *>(this)));
567 return returnValue;
570 EditFieldHandlePtr GradientBackgroundBase::editHandleColor (void)
572 MFColor3f::EditHandlePtr returnValue(
573 new MFColor3f::EditHandle(
574 &_mfColor,
575 this->getType().getFieldDesc(ColorFieldId),
576 this));
579 editMField(ColorFieldMask, _mfColor);
581 return returnValue;
584 GetFieldHandlePtr GradientBackgroundBase::getHandlePosition (void) const
586 MFReal32::GetHandlePtr returnValue(
587 new MFReal32::GetHandle(
588 &_mfPosition,
589 this->getType().getFieldDesc(PositionFieldId),
590 const_cast<GradientBackgroundBase *>(this)));
592 return returnValue;
595 EditFieldHandlePtr GradientBackgroundBase::editHandlePosition (void)
597 MFReal32::EditHandlePtr returnValue(
598 new MFReal32::EditHandle(
599 &_mfPosition,
600 this->getType().getFieldDesc(PositionFieldId),
601 this));
604 editMField(PositionFieldMask, _mfPosition);
606 return returnValue;
609 GetFieldHandlePtr GradientBackgroundBase::getHandleNormPosition (void) const
611 SFBool::GetHandlePtr returnValue(
612 new SFBool::GetHandle(
613 &_sfNormPosition,
614 this->getType().getFieldDesc(NormPositionFieldId),
615 const_cast<GradientBackgroundBase *>(this)));
617 return returnValue;
620 EditFieldHandlePtr GradientBackgroundBase::editHandleNormPosition (void)
622 SFBool::EditHandlePtr returnValue(
623 new SFBool::EditHandle(
624 &_sfNormPosition,
625 this->getType().getFieldDesc(NormPositionFieldId),
626 this));
629 editSField(NormPositionFieldMask);
631 return returnValue;
634 GetFieldHandlePtr GradientBackgroundBase::getHandleStyle (void) const
636 SFUInt32::GetHandlePtr returnValue(
637 new SFUInt32::GetHandle(
638 &_sfStyle,
639 this->getType().getFieldDesc(StyleFieldId),
640 const_cast<GradientBackgroundBase *>(this)));
642 return returnValue;
645 EditFieldHandlePtr GradientBackgroundBase::editHandleStyle (void)
647 SFUInt32::EditHandlePtr returnValue(
648 new SFUInt32::EditHandle(
649 &_sfStyle,
650 this->getType().getFieldDesc(StyleFieldId),
651 this));
654 editSField(StyleFieldMask);
656 return returnValue;
660 #ifdef OSG_MT_CPTR_ASPECT
661 void GradientBackgroundBase::execSyncV( FieldContainer &oFrom,
662 ConstFieldMaskArg whichField,
663 AspectOffsetStore &oOffsets,
664 ConstFieldMaskArg syncMode,
665 const UInt32 uiSyncInfo)
667 GradientBackground *pThis = static_cast<GradientBackground *>(this);
669 pThis->execSync(static_cast<GradientBackground *>(&oFrom),
670 whichField,
671 oOffsets,
672 syncMode,
673 uiSyncInfo);
675 #endif
678 #ifdef OSG_MT_CPTR_ASPECT
679 FieldContainer *GradientBackgroundBase::createAspectCopy(
680 const FieldContainer *pRefAspect) const
682 GradientBackground *returnValue;
684 newAspectCopy(returnValue,
685 dynamic_cast<const GradientBackground *>(pRefAspect),
686 dynamic_cast<const GradientBackground *>(this));
688 return returnValue;
690 #endif
692 void GradientBackgroundBase::resolveLinks(void)
694 Inherited::resolveLinks();
696 #ifdef OSG_MT_CPTR_ASPECT
697 AspectOffsetStore oOffsets;
699 _pAspectStore->fillOffsetArray(oOffsets, this);
700 #endif
702 #ifdef OSG_MT_CPTR_ASPECT
703 _mfColor.terminateShare(Thread::getCurrentAspect(),
704 oOffsets);
705 #endif
706 #ifdef OSG_MT_CPTR_ASPECT
707 _mfPosition.terminateShare(Thread::getCurrentAspect(),
708 oOffsets);
709 #endif
713 OSG_END_NAMESPACE