changed: gcc8 base update
[opensg.git] / Source / System / Window / Foreground / OSGImageForegroundBase.cpp
blobdc78b981c6503903eee9a1313e371e4d2d8fb513
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 ImageForeground!
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"
65 #include "OSGImage.h" // Images Class
67 #include "OSGImageForegroundBase.h"
68 #include "OSGImageForeground.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
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",
110 "ForegroundPtr",
111 ImageForeground::getClassType(),
112 nsOSG);
113 #endif
115 OSG_FIELDTRAITS_GETTYPE_NS(ImageForeground *, nsOSG)
117 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
118 ImageForeground *,
119 nsOSG)
121 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
122 ImageForeground *,
123 nsOSG)
125 /***************************************************************************\
126 * Field Description *
127 \***************************************************************************/
129 void ImageForegroundBase::classDescInserter(TypeObject &oType)
131 FieldDescriptionBase *pDesc = NULL;
134 pDesc = new MFUnrecImagePtr::Description(
135 MFUnrecImagePtr::getClassType(),
136 "images",
137 "The images to display.\n",
138 ImagesFieldId, ImagesFieldMask,
139 false,
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(),
148 "positions",
149 "The positions of the images.\n",
150 PositionsFieldId, PositionsFieldMask,
151 false,
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(),
160 "scales",
161 "The positions of the images.\n",
162 ScalesFieldId, ScalesFieldMask,
163 false,
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(),
175 "NULL",
176 nsOSG, //Namespace
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)),
182 false,
184 "<?xml version=\"1.0\"?>\n"
185 "\n"
186 "<FieldContainer\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"
195 " >\n"
196 " The ImageForeground is used to draw images on top of the viewport. See \\ref\n"
197 " PageSystemWindowForegroundImage for a description.\n"
198 "\n"
199 " The images are stored in the _mfImages Field, the corresponding positions in\n"
200 " the _mfPositions Field.\n"
201 " <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"
207 "\t >\n"
208 "\tThe images to display.\n"
209 " </Field>\n"
210 " <Field\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"
216 "\t >\n"
217 "\tThe positions of the images.\n"
218 " </Field>\n"
219 " <Field\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"
225 "\t >\n"
226 "\tThe positions of the images.\n"
227 " </Field>\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"
231 "\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)
240 return _type;
243 const FieldContainerType &ImageForegroundBase::getType(void) const
245 return _type;
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
259 return &_mfImages;
262 MFUnrecImagePtr *ImageForegroundBase::editMFImages (void)
264 editMField(ImagesFieldMask, _mfImages);
266 return &_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);
290 return &_mfScales;
293 const MFPnt2f *ImageForegroundBase::getMFScales(void) const
295 return &_mfScales;
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 =
311 value.begin();
312 MFUnrecImagePtr ::const_iterator elemEnd =
313 value.end ();
315 static_cast<ImageForeground *>(this)->clearImages();
317 while(elemIt != elemEnd)
319 this->pushToImages(*elemIt);
321 ++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);
339 if(iElemIdx != -1)
341 editMField(ImagesFieldMask, _mfImages);
343 _mfImages.erase(iElemIdx);
346 void ImageForegroundBase::clearImages(void)
348 editMField(ImagesFieldMask, _mfImages);
351 _mfImages.clear();
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();
375 return returnValue;
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);
432 return fc;
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);
448 return fc;
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);
464 return fc;
467 ImageForeground *ImageForegroundBase::createEmptyLocal(BitVector bFlags)
469 ImageForeground *returnValue;
471 newPtr<ImageForeground>(returnValue, bFlags);
473 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
475 return returnValue;
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();
488 return returnValue;
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;
503 return returnValue;
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;
517 return returnValue;
520 FieldContainerTransitPtr ImageForegroundBase::shallowCopy(void) const
522 ImageForeground *tmpPtr;
524 newPtr(tmpPtr,
525 dynamic_cast<const ImageForeground *>(this),
526 Thread::getCurrentLocalFlags());
528 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
530 FieldContainerTransitPtr returnValue(tmpPtr);
532 return returnValue;
538 /*------------------------- constructors ----------------------------------*/
540 ImageForegroundBase::ImageForegroundBase(void) :
541 Inherited(),
542 _mfImages (),
543 _mfPositions (),
544 _mfScales ()
548 ImageForegroundBase::ImageForegroundBase(const ImageForegroundBase &source) :
549 Inherited(source),
550 _mfImages (),
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);
567 if(source != NULL)
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);
580 ++ImagesIt;
585 GetFieldHandlePtr ImageForegroundBase::getHandleImages (void) const
587 MFUnrecImagePtr::GetHandlePtr returnValue(
588 new MFUnrecImagePtr::GetHandle(
589 &_mfImages,
590 this->getType().getFieldDesc(ImagesFieldId),
591 const_cast<ImageForegroundBase *>(this)));
593 return returnValue;
596 EditFieldHandlePtr ImageForegroundBase::editHandleImages (void)
598 MFUnrecImagePtr::EditHandlePtr returnValue(
599 new MFUnrecImagePtr::EditHandle(
600 &_mfImages,
601 this->getType().getFieldDesc(ImagesFieldId),
602 this));
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);
619 return returnValue;
622 GetFieldHandlePtr ImageForegroundBase::getHandlePositions (void) const
624 MFPnt2f::GetHandlePtr returnValue(
625 new MFPnt2f::GetHandle(
626 &_mfPositions,
627 this->getType().getFieldDesc(PositionsFieldId),
628 const_cast<ImageForegroundBase *>(this)));
630 return returnValue;
633 EditFieldHandlePtr ImageForegroundBase::editHandlePositions (void)
635 MFPnt2f::EditHandlePtr returnValue(
636 new MFPnt2f::EditHandle(
637 &_mfPositions,
638 this->getType().getFieldDesc(PositionsFieldId),
639 this));
642 editMField(PositionsFieldMask, _mfPositions);
644 return returnValue;
647 GetFieldHandlePtr ImageForegroundBase::getHandleScales (void) const
649 MFPnt2f::GetHandlePtr returnValue(
650 new MFPnt2f::GetHandle(
651 &_mfScales,
652 this->getType().getFieldDesc(ScalesFieldId),
653 const_cast<ImageForegroundBase *>(this)));
655 return returnValue;
658 EditFieldHandlePtr ImageForegroundBase::editHandleScales (void)
660 MFPnt2f::EditHandlePtr returnValue(
661 new MFPnt2f::EditHandle(
662 &_mfScales,
663 this->getType().getFieldDesc(ScalesFieldId),
664 this));
667 editMField(ScalesFieldMask, _mfScales);
669 return returnValue;
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),
683 whichField,
684 oOffsets,
685 syncMode,
686 uiSyncInfo);
688 #endif
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));
701 return returnValue;
703 #endif
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);
715 #endif
717 #ifdef OSG_MT_CPTR_ASPECT
718 _mfPositions.terminateShare(Thread::getCurrentAspect(),
719 oOffsets);
720 #endif
721 #ifdef OSG_MT_CPTR_ASPECT
722 _mfScales.terminateShare(Thread::getCurrentAspect(),
723 oOffsets);
724 #endif
728 OSG_END_NAMESPACE