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 ImageForeground!
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"
65 #include "OSGImage.h" // Images Class
67 #include "OSGImageForegroundBase.h"
68 #include "OSGImageForeground.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::ImageForeground
79 The ImageForeground is used to draw images on top of the viewport. See \ref
80 PageSystemWindowForegroundImage for a description.
82 The images are stored in the _mfImages Field, the corresponding positions in
83 the _mfPositions Field.
86 /***************************************************************************\
87 * Field Documentation *
88 \***************************************************************************/
90 /*! \var Image * ImageForegroundBase::_mfImages
91 The images to display.
94 /*! \var Pnt2f ImageForegroundBase::_mfPositions
95 The positions of the images.
98 /*! \var Pnt2f ImageForegroundBase::_mfScales
99 The positions of the images.
103 /***************************************************************************\
104 * FieldType/FieldTrait Instantiation *
105 \***************************************************************************/
107 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
108 PointerType FieldTraits
<ImageForeground
*, nsOSG
>::_type(
109 "ImageForegroundPtr",
111 ImageForeground::getClassType(),
115 OSG_FIELDTRAITS_GETTYPE_NS(ImageForeground
*, nsOSG
)
117 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
121 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
125 /***************************************************************************\
126 * Field Description *
127 \***************************************************************************/
129 void ImageForegroundBase::classDescInserter(TypeObject
&oType
)
131 FieldDescriptionBase
*pDesc
= NULL
;
134 pDesc
= new MFUnrecImagePtr::Description(
135 MFUnrecImagePtr::getClassType(),
137 "The images to display.\n",
138 ImagesFieldId
, ImagesFieldMask
,
140 (Field::MFDefaultFlags
| Field::FStdAccess
),
141 static_cast<FieldEditMethodSig
>(&ImageForeground::editHandleImages
),
142 static_cast<FieldGetMethodSig
>(&ImageForeground::getHandleImages
));
144 oType
.addInitialDesc(pDesc
);
146 pDesc
= new MFPnt2f::Description(
147 MFPnt2f::getClassType(),
149 "The positions of the images.\n",
150 PositionsFieldId
, PositionsFieldMask
,
152 (Field::MFDefaultFlags
| Field::FStdAccess
),
153 static_cast<FieldEditMethodSig
>(&ImageForeground::editHandlePositions
),
154 static_cast<FieldGetMethodSig
>(&ImageForeground::getHandlePositions
));
156 oType
.addInitialDesc(pDesc
);
158 pDesc
= new MFPnt2f::Description(
159 MFPnt2f::getClassType(),
161 "The positions of the images.\n",
162 ScalesFieldId
, ScalesFieldMask
,
164 (Field::MFDefaultFlags
| Field::FStdAccess
),
165 static_cast<FieldEditMethodSig
>(&ImageForeground::editHandleScales
),
166 static_cast<FieldGetMethodSig
>(&ImageForeground::getHandleScales
));
168 oType
.addInitialDesc(pDesc
);
172 ImageForegroundBase::TypeObject
ImageForegroundBase::_type(
173 ImageForegroundBase::getClassname(),
174 Inherited::getClassname(),
177 reinterpret_cast<PrototypeCreateF
>(&ImageForegroundBase::createEmptyLocal
),
178 reinterpret_cast<InitContainerF
>(&ImageForeground::initMethod
),
179 reinterpret_cast<ExitContainerF
>(&ImageForeground::exitMethod
),
180 reinterpret_cast<InitalInsertDescFunc
>(
181 reinterpret_cast<void *>(&ImageForeground::classDescInserter
)),
184 "<?xml version=\"1.0\"?>\n"
187 " name=\"ImageForeground\"\n"
188 " parent=\"Foreground\"\n"
189 " library=\"Window\"\n"
190 " pointerfieldtypes=\"both\"\n"
191 " structure=\"concrete\"\n"
192 " systemcomponent=\"true\"\n"
193 " parentsystemcomponent=\"true\"\n"
194 " docGroupBase=\"GrpWindowForeground\"\n"
196 " The ImageForeground is used to draw images on top of the viewport. See \\ref\n"
197 " PageSystemWindowForegroundImage for a description.\n"
199 " The images are stored in the _mfImages Field, the corresponding positions in\n"
200 " the _mfPositions Field.\n"
202 "\t name=\"images\"\n"
203 "\t type=\"ImagePtr\"\n"
204 "\t cardinality=\"multi\"\n"
205 "\t visibility=\"external\"\n"
206 "\t access=\"public\"\n"
208 "\tThe images to display.\n"
211 "\t name=\"positions\"\n"
212 "\t type=\"Pnt2f\"\n"
213 "\t cardinality=\"multi\"\n"
214 "\t visibility=\"external\"\n"
215 "\t access=\"public\"\n"
217 "\tThe positions of the images.\n"
220 "\t name=\"scales\"\n"
221 "\t type=\"Pnt2f\"\n"
222 "\t cardinality=\"multi\"\n"
223 "\t visibility=\"external\"\n"
224 "\t access=\"public\"\n"
226 "\tThe positions of the images.\n"
228 "</FieldContainer>\n",
229 "The ImageForeground is used to draw images on top of the viewport. See \\ref\n"
230 "PageSystemWindowForegroundImage for a description.\n"
232 "The images are stored in the _mfImages Field, the corresponding positions in\n"
233 "the _mfPositions Field.\n"
236 /*------------------------------ get -----------------------------------*/
238 FieldContainerType
&ImageForegroundBase::getType(void)
243 const FieldContainerType
&ImageForegroundBase::getType(void) const
248 UInt32
ImageForegroundBase::getContainerSize(void) const
250 return sizeof(ImageForeground
);
253 /*------------------------- decorator get ------------------------------*/
256 //! Get the ImageForeground::_mfImages field.
257 const MFUnrecImagePtr
*ImageForegroundBase::getMFImages(void) const
262 MFUnrecImagePtr
*ImageForegroundBase::editMFImages (void)
264 editMField(ImagesFieldMask
, _mfImages
);
268 Image
* ImageForegroundBase::getImages(const UInt32 index
) const
270 return _mfImages
[index
];
273 MFPnt2f
*ImageForegroundBase::editMFPositions(void)
275 editMField(PositionsFieldMask
, _mfPositions
);
277 return &_mfPositions
;
280 const MFPnt2f
*ImageForegroundBase::getMFPositions(void) const
282 return &_mfPositions
;
286 MFPnt2f
*ImageForegroundBase::editMFScales(void)
288 editMField(ScalesFieldMask
, _mfScales
);
293 const MFPnt2f
*ImageForegroundBase::getMFScales(void) const
301 void ImageForegroundBase::pushToImages(Image
* const value
)
303 editMField(ImagesFieldMask
, _mfImages
);
305 _mfImages
.push_back(value
);
308 void ImageForegroundBase::assignImages (const MFUnrecImagePtr
&value
)
310 MFUnrecImagePtr ::const_iterator elemIt
=
312 MFUnrecImagePtr ::const_iterator elemEnd
=
315 static_cast<ImageForeground
*>(this)->clearImages();
317 while(elemIt
!= elemEnd
)
319 this->pushToImages(*elemIt
);
325 void ImageForegroundBase::removeFromImages(UInt32 uiIndex
)
327 if(uiIndex
< _mfImages
.size())
329 editMField(ImagesFieldMask
, _mfImages
);
331 _mfImages
.erase(uiIndex
);
335 void ImageForegroundBase::removeObjFromImages(Image
* const value
)
337 Int32 iElemIdx
= _mfImages
.findIndex(value
);
341 editMField(ImagesFieldMask
, _mfImages
);
343 _mfImages
.erase(iElemIdx
);
346 void ImageForegroundBase::clearImages(void)
348 editMField(ImagesFieldMask
, _mfImages
);
356 /*------------------------------ access -----------------------------------*/
358 SizeT
ImageForegroundBase::getBinSize(ConstFieldMaskArg whichField
)
360 SizeT returnValue
= Inherited::getBinSize(whichField
);
362 if(FieldBits::NoField
!= (ImagesFieldMask
& whichField
))
364 returnValue
+= _mfImages
.getBinSize();
366 if(FieldBits::NoField
!= (PositionsFieldMask
& whichField
))
368 returnValue
+= _mfPositions
.getBinSize();
370 if(FieldBits::NoField
!= (ScalesFieldMask
& whichField
))
372 returnValue
+= _mfScales
.getBinSize();
378 void ImageForegroundBase::copyToBin(BinaryDataHandler
&pMem
,
379 ConstFieldMaskArg whichField
)
381 Inherited::copyToBin(pMem
, whichField
);
383 if(FieldBits::NoField
!= (ImagesFieldMask
& whichField
))
385 _mfImages
.copyToBin(pMem
);
387 if(FieldBits::NoField
!= (PositionsFieldMask
& whichField
))
389 _mfPositions
.copyToBin(pMem
);
391 if(FieldBits::NoField
!= (ScalesFieldMask
& whichField
))
393 _mfScales
.copyToBin(pMem
);
397 void ImageForegroundBase::copyFromBin(BinaryDataHandler
&pMem
,
398 ConstFieldMaskArg whichField
)
400 Inherited::copyFromBin(pMem
, whichField
);
402 if(FieldBits::NoField
!= (ImagesFieldMask
& whichField
))
404 editMField(ImagesFieldMask
, _mfImages
);
405 _mfImages
.copyFromBin(pMem
);
407 if(FieldBits::NoField
!= (PositionsFieldMask
& whichField
))
409 editMField(PositionsFieldMask
, _mfPositions
);
410 _mfPositions
.copyFromBin(pMem
);
412 if(FieldBits::NoField
!= (ScalesFieldMask
& whichField
))
414 editMField(ScalesFieldMask
, _mfScales
);
415 _mfScales
.copyFromBin(pMem
);
419 //! create a new instance of the class
420 ImageForegroundTransitPtr
ImageForegroundBase::createLocal(BitVector bFlags
)
422 ImageForegroundTransitPtr fc
;
424 if(getClassType().getPrototype() != NULL
)
426 FieldContainerTransitPtr tmpPtr
=
427 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
429 fc
= dynamic_pointer_cast
<ImageForeground
>(tmpPtr
);
435 //! create a new instance of the class, copy the container flags
436 ImageForegroundTransitPtr
ImageForegroundBase::createDependent(BitVector bFlags
)
438 ImageForegroundTransitPtr fc
;
440 if(getClassType().getPrototype() != NULL
)
442 FieldContainerTransitPtr tmpPtr
=
443 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
445 fc
= dynamic_pointer_cast
<ImageForeground
>(tmpPtr
);
451 //! create a new instance of the class
452 ImageForegroundTransitPtr
ImageForegroundBase::create(void)
454 ImageForegroundTransitPtr fc
;
456 if(getClassType().getPrototype() != NULL
)
458 FieldContainerTransitPtr tmpPtr
=
459 getClassType().getPrototype()-> shallowCopy();
461 fc
= dynamic_pointer_cast
<ImageForeground
>(tmpPtr
);
467 ImageForeground
*ImageForegroundBase::createEmptyLocal(BitVector bFlags
)
469 ImageForeground
*returnValue
;
471 newPtr
<ImageForeground
>(returnValue
, bFlags
);
473 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
478 //! create an empty new instance of the class, do not copy the prototype
479 ImageForeground
*ImageForegroundBase::createEmpty(void)
481 ImageForeground
*returnValue
;
483 newPtr
<ImageForeground
>(returnValue
, Thread::getCurrentLocalFlags());
485 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
486 ~Thread::getCurrentLocalFlags();
492 FieldContainerTransitPtr
ImageForegroundBase::shallowCopyLocal(
493 BitVector bFlags
) const
495 ImageForeground
*tmpPtr
;
497 newPtr(tmpPtr
, dynamic_cast<const ImageForeground
*>(this), bFlags
);
499 FieldContainerTransitPtr
returnValue(tmpPtr
);
501 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
506 FieldContainerTransitPtr
ImageForegroundBase::shallowCopyDependent(
507 BitVector bFlags
) const
509 ImageForeground
*tmpPtr
;
511 newPtr(tmpPtr
, dynamic_cast<const ImageForeground
*>(this), ~bFlags
);
513 FieldContainerTransitPtr
returnValue(tmpPtr
);
515 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
520 FieldContainerTransitPtr
ImageForegroundBase::shallowCopy(void) const
522 ImageForeground
*tmpPtr
;
525 dynamic_cast<const ImageForeground
*>(this),
526 Thread::getCurrentLocalFlags());
528 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
530 FieldContainerTransitPtr
returnValue(tmpPtr
);
538 /*------------------------- constructors ----------------------------------*/
540 ImageForegroundBase::ImageForegroundBase(void) :
548 ImageForegroundBase::ImageForegroundBase(const ImageForegroundBase
&source
) :
551 _mfPositions (source
._mfPositions
),
552 _mfScales (source
._mfScales
)
557 /*-------------------------- destructors ----------------------------------*/
559 ImageForegroundBase::~ImageForegroundBase(void)
563 void ImageForegroundBase::onCreate(const ImageForeground
*source
)
565 Inherited::onCreate(source
);
569 ImageForeground
*pThis
= static_cast<ImageForeground
*>(this);
571 MFUnrecImagePtr::const_iterator ImagesIt
=
572 source
->_mfImages
.begin();
573 MFUnrecImagePtr::const_iterator ImagesEnd
=
574 source
->_mfImages
.end ();
576 while(ImagesIt
!= ImagesEnd
)
578 pThis
->pushToImages(*ImagesIt
);
585 GetFieldHandlePtr
ImageForegroundBase::getHandleImages (void) const
587 MFUnrecImagePtr::GetHandlePtr
returnValue(
588 new MFUnrecImagePtr::GetHandle(
590 this->getType().getFieldDesc(ImagesFieldId
),
591 const_cast<ImageForegroundBase
*>(this)));
596 EditFieldHandlePtr
ImageForegroundBase::editHandleImages (void)
598 MFUnrecImagePtr::EditHandlePtr
returnValue(
599 new MFUnrecImagePtr::EditHandle(
601 this->getType().getFieldDesc(ImagesFieldId
),
604 returnValue
->setAddMethod(
605 boost::bind(&ImageForeground::pushToImages
,
606 static_cast<ImageForeground
*>(this), _1
));
607 returnValue
->setRemoveMethod(
608 boost::bind(&ImageForeground::removeFromImages
,
609 static_cast<ImageForeground
*>(this), _1
));
610 returnValue
->setRemoveObjMethod(
611 boost::bind(&ImageForeground::removeObjFromImages
,
612 static_cast<ImageForeground
*>(this), _1
));
613 returnValue
->setClearMethod(
614 boost::bind(&ImageForeground::clearImages
,
615 static_cast<ImageForeground
*>(this)));
617 editMField(ImagesFieldMask
, _mfImages
);
622 GetFieldHandlePtr
ImageForegroundBase::getHandlePositions (void) const
624 MFPnt2f::GetHandlePtr
returnValue(
625 new MFPnt2f::GetHandle(
627 this->getType().getFieldDesc(PositionsFieldId
),
628 const_cast<ImageForegroundBase
*>(this)));
633 EditFieldHandlePtr
ImageForegroundBase::editHandlePositions (void)
635 MFPnt2f::EditHandlePtr
returnValue(
636 new MFPnt2f::EditHandle(
638 this->getType().getFieldDesc(PositionsFieldId
),
642 editMField(PositionsFieldMask
, _mfPositions
);
647 GetFieldHandlePtr
ImageForegroundBase::getHandleScales (void) const
649 MFPnt2f::GetHandlePtr
returnValue(
650 new MFPnt2f::GetHandle(
652 this->getType().getFieldDesc(ScalesFieldId
),
653 const_cast<ImageForegroundBase
*>(this)));
658 EditFieldHandlePtr
ImageForegroundBase::editHandleScales (void)
660 MFPnt2f::EditHandlePtr
returnValue(
661 new MFPnt2f::EditHandle(
663 this->getType().getFieldDesc(ScalesFieldId
),
667 editMField(ScalesFieldMask
, _mfScales
);
673 #ifdef OSG_MT_CPTR_ASPECT
674 void ImageForegroundBase::execSyncV( FieldContainer
&oFrom
,
675 ConstFieldMaskArg whichField
,
676 AspectOffsetStore
&oOffsets
,
677 ConstFieldMaskArg syncMode
,
678 const UInt32 uiSyncInfo
)
680 ImageForeground
*pThis
= static_cast<ImageForeground
*>(this);
682 pThis
->execSync(static_cast<ImageForeground
*>(&oFrom
),
691 #ifdef OSG_MT_CPTR_ASPECT
692 FieldContainer
*ImageForegroundBase::createAspectCopy(
693 const FieldContainer
*pRefAspect
) const
695 ImageForeground
*returnValue
;
697 newAspectCopy(returnValue
,
698 dynamic_cast<const ImageForeground
*>(pRefAspect
),
699 dynamic_cast<const ImageForeground
*>(this));
705 void ImageForegroundBase::resolveLinks(void)
707 Inherited::resolveLinks();
709 static_cast<ImageForeground
*>(this)->clearImages();
711 #ifdef OSG_MT_CPTR_ASPECT
712 AspectOffsetStore oOffsets
;
714 _pAspectStore
->fillOffsetArray(oOffsets
, this);
717 #ifdef OSG_MT_CPTR_ASPECT
718 _mfPositions
.terminateShare(Thread::getCurrentAspect(),
721 #ifdef OSG_MT_CPTR_ASPECT
722 _mfScales
.terminateShare(Thread::getCurrentAspect(),