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 **
48 ** class GradientBackground!
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 "OSGGradientBackgroundBase.h"
67 #include "OSGGradientBackground.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
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(),
118 OSG_FIELDTRAITS_GETTYPE_NS(GradientBackground
*, nsOSG
)
121 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
122 GradientBackground
*,
125 /***************************************************************************\
126 * Field Description *
127 \***************************************************************************/
129 void GradientBackgroundBase::classDescInserter(TypeObject
&oType
)
131 FieldDescriptionBase
*pDesc
= NULL
;
134 pDesc
= new MFColor3f::Description(
135 MFColor3f::getClassType(),
137 "The colors of the gradient.\n",
138 ColorFieldId
, ColorFieldMask
,
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(),
149 "The positions of the gradient.\n",
150 PositionFieldId
, PositionFieldMask
,
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(),
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
,
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(),
174 "Gradient style. Allowed values are VERTICAL and HORIZONTAL.\n",
175 StyleFieldId
, StyleFieldMask
,
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(),
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
)),
197 "<?xml version=\"1.0\"?>\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"
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"
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"
221 "\tThe colors of the gradient.\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"
230 "\tThe positions of the gradient.\n"
233 " name=\"normPosition\"\n"
235 " cardinality=\"single\"\n"
236 " visibility=\"external\"\n"
237 " defaultValue=\"true\"\n"
238 " access=\"protected\"\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"
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"
251 "\tGradient style. Allowed values are VERTICAL and HORIZONTAL.\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)
267 const FieldContainerType
&GradientBackgroundBase::getType(void) const
272 UInt32
GradientBackgroundBase::getContainerSize(void) const
274 return sizeof(GradientBackground
);
277 /*------------------------- decorator get ------------------------------*/
280 MFColor3f
*GradientBackgroundBase::editMFColor(void)
282 editMField(ColorFieldMask
, _mfColor
);
287 const MFColor3f
*GradientBackgroundBase::getMFColor(void) const
293 MFReal32
*GradientBackgroundBase::editMFPosition(void)
295 editMField(PositionFieldMask
, _mfPosition
);
300 const MFReal32
*GradientBackgroundBase::getMFPosition(void) const
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
);
326 const SFUInt32
*GradientBackgroundBase::getSFStyle(void) const
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();
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
);
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
);
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
);
460 GradientBackground
*GradientBackgroundBase::createEmptyLocal(BitVector bFlags
)
462 GradientBackground
*returnValue
;
464 newPtr
<GradientBackground
>(returnValue
, bFlags
);
466 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
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();
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
;
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
;
513 FieldContainerTransitPtr
GradientBackgroundBase::shallowCopy(void) const
515 GradientBackground
*tmpPtr
;
518 dynamic_cast<const GradientBackground
*>(this),
519 Thread::getCurrentLocalFlags());
521 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
523 FieldContainerTransitPtr
returnValue(tmpPtr
);
531 /*------------------------- constructors ----------------------------------*/
533 GradientBackgroundBase::GradientBackgroundBase(void) :
537 _sfNormPosition (bool(true)),
538 _sfStyle (UInt32(GradientBackground::VERTICAL
))
542 GradientBackgroundBase::GradientBackgroundBase(const GradientBackgroundBase
&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(
564 this->getType().getFieldDesc(ColorFieldId
),
565 const_cast<GradientBackgroundBase
*>(this)));
570 EditFieldHandlePtr
GradientBackgroundBase::editHandleColor (void)
572 MFColor3f::EditHandlePtr
returnValue(
573 new MFColor3f::EditHandle(
575 this->getType().getFieldDesc(ColorFieldId
),
579 editMField(ColorFieldMask
, _mfColor
);
584 GetFieldHandlePtr
GradientBackgroundBase::getHandlePosition (void) const
586 MFReal32::GetHandlePtr
returnValue(
587 new MFReal32::GetHandle(
589 this->getType().getFieldDesc(PositionFieldId
),
590 const_cast<GradientBackgroundBase
*>(this)));
595 EditFieldHandlePtr
GradientBackgroundBase::editHandlePosition (void)
597 MFReal32::EditHandlePtr
returnValue(
598 new MFReal32::EditHandle(
600 this->getType().getFieldDesc(PositionFieldId
),
604 editMField(PositionFieldMask
, _mfPosition
);
609 GetFieldHandlePtr
GradientBackgroundBase::getHandleNormPosition (void) const
611 SFBool::GetHandlePtr
returnValue(
612 new SFBool::GetHandle(
614 this->getType().getFieldDesc(NormPositionFieldId
),
615 const_cast<GradientBackgroundBase
*>(this)));
620 EditFieldHandlePtr
GradientBackgroundBase::editHandleNormPosition (void)
622 SFBool::EditHandlePtr
returnValue(
623 new SFBool::EditHandle(
625 this->getType().getFieldDesc(NormPositionFieldId
),
629 editSField(NormPositionFieldMask
);
634 GetFieldHandlePtr
GradientBackgroundBase::getHandleStyle (void) const
636 SFUInt32::GetHandlePtr
returnValue(
637 new SFUInt32::GetHandle(
639 this->getType().getFieldDesc(StyleFieldId
),
640 const_cast<GradientBackgroundBase
*>(this)));
645 EditFieldHandlePtr
GradientBackgroundBase::editHandleStyle (void)
647 SFUInt32::EditHandlePtr
returnValue(
648 new SFUInt32::EditHandle(
650 this->getType().getFieldDesc(StyleFieldId
),
654 editSField(StyleFieldMask
);
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
),
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));
692 void GradientBackgroundBase::resolveLinks(void)
694 Inherited::resolveLinks();
696 #ifdef OSG_MT_CPTR_ASPECT
697 AspectOffsetStore oOffsets
;
699 _pAspectStore
->fillOffsetArray(oOffsets
, this);
702 #ifdef OSG_MT_CPTR_ASPECT
703 _mfColor
.terminateShare(Thread::getCurrentAspect(),
706 #ifdef OSG_MT_CPTR_ASPECT
707 _mfPosition
.terminateShare(Thread::getCurrentAspect(),