changed: gcc8 base update
[opensg.git] / Source / System / Window / Foreground / OSGPolygonForegroundBase.cpp
blob9fc414b80644a9956c3a301ed20ef37b597e8761
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 PolygonForeground!
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 "OSGPrimeMaterial.h" // Material Class
67 #include "OSGPolygonForegroundBase.h"
68 #include "OSGPolygonForeground.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::PolygonForeground
79 A foreground that renders a single polygon used the specified material,
80 see \ref PageSystemPolygonForeground for a
81 description.
83 The polygon material is defined by _sfMaterial, the positions by _mfPositions,
84 the texture coordinates by _mfTexCoords (there must be as many texture
85 coordinates as positions). The interpretation of the positions is
86 controlled by _sfNormalizedX and _sfNormalizedY.
89 /***************************************************************************\
90 * Field Documentation *
91 \***************************************************************************/
93 /*! \var PrimeMaterial * PolygonForegroundBase::_sfMaterial
94 The material used to display.
97 /*! \var Pnt2f PolygonForegroundBase::_mfPositions
98 The vertices of the geometry to display.
101 /*! \var Vec3f PolygonForegroundBase::_mfTexCoords
102 The texture coordinates of the geometry to display.
105 /*! \var bool PolygonForegroundBase::_sfNormalizedX
106 Define whether the x coordinates are normalized (0-1) or pixel-based.
109 /*! \var bool PolygonForegroundBase::_sfNormalizedY
110 Define whether the y coordinates are normalized (0-1) or pixel-based.
113 /*! \var UInt16 PolygonForegroundBase::_sfAspectHeight
114 Useful for keeping aspect ratio when rendering things like images.
117 /*! \var UInt16 PolygonForegroundBase::_sfAspectWidth
118 Useful for keeping aspect ratio when rendering things like images.
121 /*! \var Real32 PolygonForegroundBase::_sfScale
122 Scale factor for zooming.
125 /*! \var bool PolygonForegroundBase::_sfTile
126 If true the image tiles in multi window settings.
130 /***************************************************************************\
131 * FieldType/FieldTrait Instantiation *
132 \***************************************************************************/
134 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
135 PointerType FieldTraits<PolygonForeground *, nsOSG>::_type(
136 "PolygonForegroundPtr",
137 "ForegroundPtr",
138 PolygonForeground::getClassType(),
139 nsOSG);
140 #endif
142 OSG_FIELDTRAITS_GETTYPE_NS(PolygonForeground *, nsOSG)
144 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
145 PolygonForeground *,
146 nsOSG)
148 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
149 PolygonForeground *,
150 nsOSG)
152 /***************************************************************************\
153 * Field Description *
154 \***************************************************************************/
156 void PolygonForegroundBase::classDescInserter(TypeObject &oType)
158 FieldDescriptionBase *pDesc = NULL;
161 pDesc = new SFUnrecPrimeMaterialPtr::Description(
162 SFUnrecPrimeMaterialPtr::getClassType(),
163 "material",
164 "The material used to display.\n",
165 MaterialFieldId, MaterialFieldMask,
166 false,
167 (Field::SFDefaultFlags | Field::FStdAccess),
168 static_cast<FieldEditMethodSig>(&PolygonForeground::editHandleMaterial),
169 static_cast<FieldGetMethodSig >(&PolygonForeground::getHandleMaterial));
171 oType.addInitialDesc(pDesc);
173 pDesc = new MFPnt2f::Description(
174 MFPnt2f::getClassType(),
175 "positions",
176 "The vertices of the geometry to display.\n",
177 PositionsFieldId, PositionsFieldMask,
178 false,
179 (Field::MFDefaultFlags | Field::FStdAccess),
180 static_cast<FieldEditMethodSig>(&PolygonForeground::editHandlePositions),
181 static_cast<FieldGetMethodSig >(&PolygonForeground::getHandlePositions));
183 oType.addInitialDesc(pDesc);
185 pDesc = new MFVec3f::Description(
186 MFVec3f::getClassType(),
187 "texCoords",
188 "The texture coordinates of the geometry to display.\n",
189 TexCoordsFieldId, TexCoordsFieldMask,
190 false,
191 (Field::MFDefaultFlags | Field::FStdAccess),
192 static_cast<FieldEditMethodSig>(&PolygonForeground::editHandleTexCoords),
193 static_cast<FieldGetMethodSig >(&PolygonForeground::getHandleTexCoords));
195 oType.addInitialDesc(pDesc);
197 pDesc = new SFBool::Description(
198 SFBool::getClassType(),
199 "normalizedX",
200 "Define whether the x coordinates are normalized (0-1) or pixel-based.\n",
201 NormalizedXFieldId, NormalizedXFieldMask,
202 false,
203 (Field::SFDefaultFlags | Field::FStdAccess),
204 static_cast<FieldEditMethodSig>(&PolygonForeground::editHandleNormalizedX),
205 static_cast<FieldGetMethodSig >(&PolygonForeground::getHandleNormalizedX));
207 oType.addInitialDesc(pDesc);
209 pDesc = new SFBool::Description(
210 SFBool::getClassType(),
211 "normalizedY",
212 "Define whether the y coordinates are normalized (0-1) or pixel-based.\n",
213 NormalizedYFieldId, NormalizedYFieldMask,
214 false,
215 (Field::SFDefaultFlags | Field::FStdAccess),
216 static_cast<FieldEditMethodSig>(&PolygonForeground::editHandleNormalizedY),
217 static_cast<FieldGetMethodSig >(&PolygonForeground::getHandleNormalizedY));
219 oType.addInitialDesc(pDesc);
221 pDesc = new SFUInt16::Description(
222 SFUInt16::getClassType(),
223 "aspectHeight",
224 "Useful for keeping aspect ratio when rendering things like images.\n",
225 AspectHeightFieldId, AspectHeightFieldMask,
226 false,
227 (Field::SFDefaultFlags | Field::FStdAccess),
228 static_cast<FieldEditMethodSig>(&PolygonForeground::editHandleAspectHeight),
229 static_cast<FieldGetMethodSig >(&PolygonForeground::getHandleAspectHeight));
231 oType.addInitialDesc(pDesc);
233 pDesc = new SFUInt16::Description(
234 SFUInt16::getClassType(),
235 "aspectWidth",
236 "Useful for keeping aspect ratio when rendering things like images.\n",
237 AspectWidthFieldId, AspectWidthFieldMask,
238 false,
239 (Field::SFDefaultFlags | Field::FStdAccess),
240 static_cast<FieldEditMethodSig>(&PolygonForeground::editHandleAspectWidth),
241 static_cast<FieldGetMethodSig >(&PolygonForeground::getHandleAspectWidth));
243 oType.addInitialDesc(pDesc);
245 pDesc = new SFReal32::Description(
246 SFReal32::getClassType(),
247 "scale",
248 "Scale factor for zooming.\n",
249 ScaleFieldId, ScaleFieldMask,
250 false,
251 (Field::SFDefaultFlags | Field::FStdAccess),
252 static_cast<FieldEditMethodSig>(&PolygonForeground::editHandleScale),
253 static_cast<FieldGetMethodSig >(&PolygonForeground::getHandleScale));
255 oType.addInitialDesc(pDesc);
257 pDesc = new SFBool::Description(
258 SFBool::getClassType(),
259 "tile",
260 "If true the image tiles in multi window settings.\n",
261 TileFieldId, TileFieldMask,
262 false,
263 (Field::SFDefaultFlags | Field::FStdAccess),
264 static_cast<FieldEditMethodSig>(&PolygonForeground::editHandleTile),
265 static_cast<FieldGetMethodSig >(&PolygonForeground::getHandleTile));
267 oType.addInitialDesc(pDesc);
271 PolygonForegroundBase::TypeObject PolygonForegroundBase::_type(
272 PolygonForegroundBase::getClassname(),
273 Inherited::getClassname(),
274 "NULL",
275 nsOSG, //Namespace
276 reinterpret_cast<PrototypeCreateF>(&PolygonForegroundBase::createEmptyLocal),
277 reinterpret_cast<InitContainerF>(&PolygonForeground::initMethod),
278 reinterpret_cast<ExitContainerF>(&PolygonForeground::exitMethod),
279 reinterpret_cast<InitalInsertDescFunc>(
280 reinterpret_cast<void *>(&PolygonForeground::classDescInserter)),
281 false,
283 "<?xml version=\"1.0\"?>\n"
284 "\n"
285 "<FieldContainer\n"
286 " name=\"PolygonForeground\"\n"
287 " parent=\"Foreground\"\n"
288 " library=\"Window\"\n"
289 " pointerfieldtypes=\"both\"\n"
290 " structure=\"concrete\"\n"
291 " systemcomponent=\"true\"\n"
292 " parentsystemcomponent=\"true\"\n"
293 " decoratable=\"false\"\n"
294 " useLocalIncludes=\"false\"\n"
295 " docGroupBase=\"GrpWindowForeground\"\n"
296 " >\n"
297 " A foreground that renders a single polygon used the specified material, \n"
298 " see \\ref PageSystemPolygonForeground for a\n"
299 " description.\n"
300 "\n"
301 " The polygon material is defined by _sfMaterial, the positions by _mfPositions,\n"
302 " the texture coordinates by _mfTexCoords (there must be as many texture\n"
303 " coordinates as positions). The interpretation of the positions is\n"
304 " controlled by _sfNormalizedX and _sfNormalizedY.\n"
305 " <Field\n"
306 "\t name=\"material\"\n"
307 "\t type=\"PrimeMaterialPtr\"\n"
308 "\t cardinality=\"single\"\n"
309 "\t visibility=\"external\"\n"
310 "\t access=\"public\"\n"
311 "\t >\n"
312 "\tThe material used to display.\n"
313 " </Field>\n"
314 " <Field\n"
315 "\t name=\"positions\"\n"
316 "\t type=\"Pnt2f\"\n"
317 "\t cardinality=\"multi\"\n"
318 "\t visibility=\"external\"\n"
319 "\t access=\"public\"\n"
320 "\t >\n"
321 "\tThe vertices of the geometry to display.\n"
322 " </Field>\n"
323 " <Field\n"
324 "\t name=\"texCoords\"\n"
325 "\t type=\"Vec3f\"\n"
326 "\t cardinality=\"multi\"\n"
327 "\t visibility=\"external\"\n"
328 "\t access=\"public\"\n"
329 "\t >\n"
330 "\tThe texture coordinates of the geometry to display.\n"
331 " </Field>\n"
332 " <Field\n"
333 "\t name=\"normalizedX\"\n"
334 "\t type=\"bool\"\n"
335 "\t cardinality=\"single\"\n"
336 "\t visibility=\"external\"\n"
337 "\t defaultValue=\"true\"\n"
338 "\t access=\"public\"\n"
339 "\t >\n"
340 "\tDefine whether the x coordinates are normalized (0-1) or pixel-based.\n"
341 " </Field>\n"
342 " <Field\n"
343 "\t name=\"normalizedY\"\n"
344 "\t type=\"bool\"\n"
345 "\t cardinality=\"single\"\n"
346 "\t visibility=\"external\"\n"
347 "\t defaultValue=\"true\"\n"
348 "\t access=\"public\"\n"
349 "\t >\n"
350 "\tDefine whether the y coordinates are normalized (0-1) or pixel-based.\n"
351 " </Field>\n"
352 " <Field\n"
353 "\t name=\"aspectHeight\"\n"
354 "\t type=\"UInt16\"\n"
355 "\t cardinality=\"single\"\n"
356 "\t visibility=\"external\"\n"
357 "\t defaultValue=\"0\"\n"
358 "\t access=\"public\"\n"
359 "\t >\n"
360 "\tUseful for keeping aspect ratio when rendering things like images.\n"
361 " </Field>\n"
362 " <Field\n"
363 "\t name=\"aspectWidth\"\n"
364 "\t type=\"UInt16\"\n"
365 "\t cardinality=\"single\"\n"
366 "\t visibility=\"external\"\n"
367 "\t defaultValue=\"0\"\n"
368 "\t access=\"public\"\n"
369 "\t >\n"
370 "\tUseful for keeping aspect ratio when rendering things like images.\n"
371 " </Field>\n"
372 " <Field\n"
373 "\t name=\"scale\"\n"
374 "\t type=\"Real32\"\n"
375 "\t cardinality=\"single\"\n"
376 "\t visibility=\"external\"\n"
377 "\t defaultValue=\"1.0\"\n"
378 "\t access=\"public\"\n"
379 "\t >\n"
380 "\tScale factor for zooming.\n"
381 " </Field>\n"
382 " <Field\n"
383 "\t name=\"tile\"\n"
384 "\t type=\"bool\"\n"
385 "\t cardinality=\"single\"\n"
386 "\t visibility=\"external\"\n"
387 "\t defaultValue=\"true\"\n"
388 "\t access=\"public\"\n"
389 "\t >\n"
390 "\tIf true the image tiles in multi window settings.\n"
391 " </Field>\n"
392 "</FieldContainer>\n",
393 "A foreground that renders a single polygon used the specified material, \n"
394 "see \\ref PageSystemPolygonForeground for a\n"
395 "description.\n"
396 "\n"
397 "The polygon material is defined by _sfMaterial, the positions by _mfPositions,\n"
398 "the texture coordinates by _mfTexCoords (there must be as many texture\n"
399 "coordinates as positions). The interpretation of the positions is\n"
400 "controlled by _sfNormalizedX and _sfNormalizedY.\n"
403 /*------------------------------ get -----------------------------------*/
405 FieldContainerType &PolygonForegroundBase::getType(void)
407 return _type;
410 const FieldContainerType &PolygonForegroundBase::getType(void) const
412 return _type;
415 UInt32 PolygonForegroundBase::getContainerSize(void) const
417 return sizeof(PolygonForeground);
420 /*------------------------- decorator get ------------------------------*/
423 //! Get the PolygonForeground::_sfMaterial field.
424 const SFUnrecPrimeMaterialPtr *PolygonForegroundBase::getSFMaterial(void) const
426 return &_sfMaterial;
429 SFUnrecPrimeMaterialPtr *PolygonForegroundBase::editSFMaterial (void)
431 editSField(MaterialFieldMask);
433 return &_sfMaterial;
436 //! Get the value of the PolygonForeground::_sfMaterial field.
437 PrimeMaterial * PolygonForegroundBase::getMaterial(void) const
439 return _sfMaterial.getValue();
442 //! Set the value of the PolygonForeground::_sfMaterial field.
443 void PolygonForegroundBase::setMaterial(PrimeMaterial * const value)
445 editSField(MaterialFieldMask);
447 _sfMaterial.setValue(value);
451 MFPnt2f *PolygonForegroundBase::editMFPositions(void)
453 editMField(PositionsFieldMask, _mfPositions);
455 return &_mfPositions;
458 const MFPnt2f *PolygonForegroundBase::getMFPositions(void) const
460 return &_mfPositions;
464 MFVec3f *PolygonForegroundBase::editMFTexCoords(void)
466 editMField(TexCoordsFieldMask, _mfTexCoords);
468 return &_mfTexCoords;
471 const MFVec3f *PolygonForegroundBase::getMFTexCoords(void) const
473 return &_mfTexCoords;
477 SFBool *PolygonForegroundBase::editSFNormalizedX(void)
479 editSField(NormalizedXFieldMask);
481 return &_sfNormalizedX;
484 const SFBool *PolygonForegroundBase::getSFNormalizedX(void) const
486 return &_sfNormalizedX;
490 SFBool *PolygonForegroundBase::editSFNormalizedY(void)
492 editSField(NormalizedYFieldMask);
494 return &_sfNormalizedY;
497 const SFBool *PolygonForegroundBase::getSFNormalizedY(void) const
499 return &_sfNormalizedY;
503 SFUInt16 *PolygonForegroundBase::editSFAspectHeight(void)
505 editSField(AspectHeightFieldMask);
507 return &_sfAspectHeight;
510 const SFUInt16 *PolygonForegroundBase::getSFAspectHeight(void) const
512 return &_sfAspectHeight;
516 SFUInt16 *PolygonForegroundBase::editSFAspectWidth(void)
518 editSField(AspectWidthFieldMask);
520 return &_sfAspectWidth;
523 const SFUInt16 *PolygonForegroundBase::getSFAspectWidth(void) const
525 return &_sfAspectWidth;
529 SFReal32 *PolygonForegroundBase::editSFScale(void)
531 editSField(ScaleFieldMask);
533 return &_sfScale;
536 const SFReal32 *PolygonForegroundBase::getSFScale(void) const
538 return &_sfScale;
542 SFBool *PolygonForegroundBase::editSFTile(void)
544 editSField(TileFieldMask);
546 return &_sfTile;
549 const SFBool *PolygonForegroundBase::getSFTile(void) const
551 return &_sfTile;
559 /*------------------------------ access -----------------------------------*/
561 SizeT PolygonForegroundBase::getBinSize(ConstFieldMaskArg whichField)
563 SizeT returnValue = Inherited::getBinSize(whichField);
565 if(FieldBits::NoField != (MaterialFieldMask & whichField))
567 returnValue += _sfMaterial.getBinSize();
569 if(FieldBits::NoField != (PositionsFieldMask & whichField))
571 returnValue += _mfPositions.getBinSize();
573 if(FieldBits::NoField != (TexCoordsFieldMask & whichField))
575 returnValue += _mfTexCoords.getBinSize();
577 if(FieldBits::NoField != (NormalizedXFieldMask & whichField))
579 returnValue += _sfNormalizedX.getBinSize();
581 if(FieldBits::NoField != (NormalizedYFieldMask & whichField))
583 returnValue += _sfNormalizedY.getBinSize();
585 if(FieldBits::NoField != (AspectHeightFieldMask & whichField))
587 returnValue += _sfAspectHeight.getBinSize();
589 if(FieldBits::NoField != (AspectWidthFieldMask & whichField))
591 returnValue += _sfAspectWidth.getBinSize();
593 if(FieldBits::NoField != (ScaleFieldMask & whichField))
595 returnValue += _sfScale.getBinSize();
597 if(FieldBits::NoField != (TileFieldMask & whichField))
599 returnValue += _sfTile.getBinSize();
602 return returnValue;
605 void PolygonForegroundBase::copyToBin(BinaryDataHandler &pMem,
606 ConstFieldMaskArg whichField)
608 Inherited::copyToBin(pMem, whichField);
610 if(FieldBits::NoField != (MaterialFieldMask & whichField))
612 _sfMaterial.copyToBin(pMem);
614 if(FieldBits::NoField != (PositionsFieldMask & whichField))
616 _mfPositions.copyToBin(pMem);
618 if(FieldBits::NoField != (TexCoordsFieldMask & whichField))
620 _mfTexCoords.copyToBin(pMem);
622 if(FieldBits::NoField != (NormalizedXFieldMask & whichField))
624 _sfNormalizedX.copyToBin(pMem);
626 if(FieldBits::NoField != (NormalizedYFieldMask & whichField))
628 _sfNormalizedY.copyToBin(pMem);
630 if(FieldBits::NoField != (AspectHeightFieldMask & whichField))
632 _sfAspectHeight.copyToBin(pMem);
634 if(FieldBits::NoField != (AspectWidthFieldMask & whichField))
636 _sfAspectWidth.copyToBin(pMem);
638 if(FieldBits::NoField != (ScaleFieldMask & whichField))
640 _sfScale.copyToBin(pMem);
642 if(FieldBits::NoField != (TileFieldMask & whichField))
644 _sfTile.copyToBin(pMem);
648 void PolygonForegroundBase::copyFromBin(BinaryDataHandler &pMem,
649 ConstFieldMaskArg whichField)
651 Inherited::copyFromBin(pMem, whichField);
653 if(FieldBits::NoField != (MaterialFieldMask & whichField))
655 editSField(MaterialFieldMask);
656 _sfMaterial.copyFromBin(pMem);
658 if(FieldBits::NoField != (PositionsFieldMask & whichField))
660 editMField(PositionsFieldMask, _mfPositions);
661 _mfPositions.copyFromBin(pMem);
663 if(FieldBits::NoField != (TexCoordsFieldMask & whichField))
665 editMField(TexCoordsFieldMask, _mfTexCoords);
666 _mfTexCoords.copyFromBin(pMem);
668 if(FieldBits::NoField != (NormalizedXFieldMask & whichField))
670 editSField(NormalizedXFieldMask);
671 _sfNormalizedX.copyFromBin(pMem);
673 if(FieldBits::NoField != (NormalizedYFieldMask & whichField))
675 editSField(NormalizedYFieldMask);
676 _sfNormalizedY.copyFromBin(pMem);
678 if(FieldBits::NoField != (AspectHeightFieldMask & whichField))
680 editSField(AspectHeightFieldMask);
681 _sfAspectHeight.copyFromBin(pMem);
683 if(FieldBits::NoField != (AspectWidthFieldMask & whichField))
685 editSField(AspectWidthFieldMask);
686 _sfAspectWidth.copyFromBin(pMem);
688 if(FieldBits::NoField != (ScaleFieldMask & whichField))
690 editSField(ScaleFieldMask);
691 _sfScale.copyFromBin(pMem);
693 if(FieldBits::NoField != (TileFieldMask & whichField))
695 editSField(TileFieldMask);
696 _sfTile.copyFromBin(pMem);
700 //! create a new instance of the class
701 PolygonForegroundTransitPtr PolygonForegroundBase::createLocal(BitVector bFlags)
703 PolygonForegroundTransitPtr fc;
705 if(getClassType().getPrototype() != NULL)
707 FieldContainerTransitPtr tmpPtr =
708 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
710 fc = dynamic_pointer_cast<PolygonForeground>(tmpPtr);
713 return fc;
716 //! create a new instance of the class, copy the container flags
717 PolygonForegroundTransitPtr PolygonForegroundBase::createDependent(BitVector bFlags)
719 PolygonForegroundTransitPtr fc;
721 if(getClassType().getPrototype() != NULL)
723 FieldContainerTransitPtr tmpPtr =
724 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
726 fc = dynamic_pointer_cast<PolygonForeground>(tmpPtr);
729 return fc;
732 //! create a new instance of the class
733 PolygonForegroundTransitPtr PolygonForegroundBase::create(void)
735 PolygonForegroundTransitPtr fc;
737 if(getClassType().getPrototype() != NULL)
739 FieldContainerTransitPtr tmpPtr =
740 getClassType().getPrototype()-> shallowCopy();
742 fc = dynamic_pointer_cast<PolygonForeground>(tmpPtr);
745 return fc;
748 PolygonForeground *PolygonForegroundBase::createEmptyLocal(BitVector bFlags)
750 PolygonForeground *returnValue;
752 newPtr<PolygonForeground>(returnValue, bFlags);
754 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
756 return returnValue;
759 //! create an empty new instance of the class, do not copy the prototype
760 PolygonForeground *PolygonForegroundBase::createEmpty(void)
762 PolygonForeground *returnValue;
764 newPtr<PolygonForeground>(returnValue, Thread::getCurrentLocalFlags());
766 returnValue->_pFieldFlags->_bNamespaceMask &=
767 ~Thread::getCurrentLocalFlags();
769 return returnValue;
773 FieldContainerTransitPtr PolygonForegroundBase::shallowCopyLocal(
774 BitVector bFlags) const
776 PolygonForeground *tmpPtr;
778 newPtr(tmpPtr, dynamic_cast<const PolygonForeground *>(this), bFlags);
780 FieldContainerTransitPtr returnValue(tmpPtr);
782 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
784 return returnValue;
787 FieldContainerTransitPtr PolygonForegroundBase::shallowCopyDependent(
788 BitVector bFlags) const
790 PolygonForeground *tmpPtr;
792 newPtr(tmpPtr, dynamic_cast<const PolygonForeground *>(this), ~bFlags);
794 FieldContainerTransitPtr returnValue(tmpPtr);
796 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
798 return returnValue;
801 FieldContainerTransitPtr PolygonForegroundBase::shallowCopy(void) const
803 PolygonForeground *tmpPtr;
805 newPtr(tmpPtr,
806 dynamic_cast<const PolygonForeground *>(this),
807 Thread::getCurrentLocalFlags());
809 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
811 FieldContainerTransitPtr returnValue(tmpPtr);
813 return returnValue;
819 /*------------------------- constructors ----------------------------------*/
821 PolygonForegroundBase::PolygonForegroundBase(void) :
822 Inherited(),
823 _sfMaterial (NULL),
824 _mfPositions (),
825 _mfTexCoords (),
826 _sfNormalizedX (bool(true)),
827 _sfNormalizedY (bool(true)),
828 _sfAspectHeight (UInt16(0)),
829 _sfAspectWidth (UInt16(0)),
830 _sfScale (Real32(1.0)),
831 _sfTile (bool(true))
835 PolygonForegroundBase::PolygonForegroundBase(const PolygonForegroundBase &source) :
836 Inherited(source),
837 _sfMaterial (NULL),
838 _mfPositions (source._mfPositions ),
839 _mfTexCoords (source._mfTexCoords ),
840 _sfNormalizedX (source._sfNormalizedX ),
841 _sfNormalizedY (source._sfNormalizedY ),
842 _sfAspectHeight (source._sfAspectHeight ),
843 _sfAspectWidth (source._sfAspectWidth ),
844 _sfScale (source._sfScale ),
845 _sfTile (source._sfTile )
850 /*-------------------------- destructors ----------------------------------*/
852 PolygonForegroundBase::~PolygonForegroundBase(void)
856 void PolygonForegroundBase::onCreate(const PolygonForeground *source)
858 Inherited::onCreate(source);
860 if(source != NULL)
862 PolygonForeground *pThis = static_cast<PolygonForeground *>(this);
864 pThis->setMaterial(source->getMaterial());
868 GetFieldHandlePtr PolygonForegroundBase::getHandleMaterial (void) const
870 SFUnrecPrimeMaterialPtr::GetHandlePtr returnValue(
871 new SFUnrecPrimeMaterialPtr::GetHandle(
872 &_sfMaterial,
873 this->getType().getFieldDesc(MaterialFieldId),
874 const_cast<PolygonForegroundBase *>(this)));
876 return returnValue;
879 EditFieldHandlePtr PolygonForegroundBase::editHandleMaterial (void)
881 SFUnrecPrimeMaterialPtr::EditHandlePtr returnValue(
882 new SFUnrecPrimeMaterialPtr::EditHandle(
883 &_sfMaterial,
884 this->getType().getFieldDesc(MaterialFieldId),
885 this));
887 returnValue->setSetMethod(
888 boost::bind(&PolygonForeground::setMaterial,
889 static_cast<PolygonForeground *>(this), _1));
891 editSField(MaterialFieldMask);
893 return returnValue;
896 GetFieldHandlePtr PolygonForegroundBase::getHandlePositions (void) const
898 MFPnt2f::GetHandlePtr returnValue(
899 new MFPnt2f::GetHandle(
900 &_mfPositions,
901 this->getType().getFieldDesc(PositionsFieldId),
902 const_cast<PolygonForegroundBase *>(this)));
904 return returnValue;
907 EditFieldHandlePtr PolygonForegroundBase::editHandlePositions (void)
909 MFPnt2f::EditHandlePtr returnValue(
910 new MFPnt2f::EditHandle(
911 &_mfPositions,
912 this->getType().getFieldDesc(PositionsFieldId),
913 this));
916 editMField(PositionsFieldMask, _mfPositions);
918 return returnValue;
921 GetFieldHandlePtr PolygonForegroundBase::getHandleTexCoords (void) const
923 MFVec3f::GetHandlePtr returnValue(
924 new MFVec3f::GetHandle(
925 &_mfTexCoords,
926 this->getType().getFieldDesc(TexCoordsFieldId),
927 const_cast<PolygonForegroundBase *>(this)));
929 return returnValue;
932 EditFieldHandlePtr PolygonForegroundBase::editHandleTexCoords (void)
934 MFVec3f::EditHandlePtr returnValue(
935 new MFVec3f::EditHandle(
936 &_mfTexCoords,
937 this->getType().getFieldDesc(TexCoordsFieldId),
938 this));
941 editMField(TexCoordsFieldMask, _mfTexCoords);
943 return returnValue;
946 GetFieldHandlePtr PolygonForegroundBase::getHandleNormalizedX (void) const
948 SFBool::GetHandlePtr returnValue(
949 new SFBool::GetHandle(
950 &_sfNormalizedX,
951 this->getType().getFieldDesc(NormalizedXFieldId),
952 const_cast<PolygonForegroundBase *>(this)));
954 return returnValue;
957 EditFieldHandlePtr PolygonForegroundBase::editHandleNormalizedX (void)
959 SFBool::EditHandlePtr returnValue(
960 new SFBool::EditHandle(
961 &_sfNormalizedX,
962 this->getType().getFieldDesc(NormalizedXFieldId),
963 this));
966 editSField(NormalizedXFieldMask);
968 return returnValue;
971 GetFieldHandlePtr PolygonForegroundBase::getHandleNormalizedY (void) const
973 SFBool::GetHandlePtr returnValue(
974 new SFBool::GetHandle(
975 &_sfNormalizedY,
976 this->getType().getFieldDesc(NormalizedYFieldId),
977 const_cast<PolygonForegroundBase *>(this)));
979 return returnValue;
982 EditFieldHandlePtr PolygonForegroundBase::editHandleNormalizedY (void)
984 SFBool::EditHandlePtr returnValue(
985 new SFBool::EditHandle(
986 &_sfNormalizedY,
987 this->getType().getFieldDesc(NormalizedYFieldId),
988 this));
991 editSField(NormalizedYFieldMask);
993 return returnValue;
996 GetFieldHandlePtr PolygonForegroundBase::getHandleAspectHeight (void) const
998 SFUInt16::GetHandlePtr returnValue(
999 new SFUInt16::GetHandle(
1000 &_sfAspectHeight,
1001 this->getType().getFieldDesc(AspectHeightFieldId),
1002 const_cast<PolygonForegroundBase *>(this)));
1004 return returnValue;
1007 EditFieldHandlePtr PolygonForegroundBase::editHandleAspectHeight (void)
1009 SFUInt16::EditHandlePtr returnValue(
1010 new SFUInt16::EditHandle(
1011 &_sfAspectHeight,
1012 this->getType().getFieldDesc(AspectHeightFieldId),
1013 this));
1016 editSField(AspectHeightFieldMask);
1018 return returnValue;
1021 GetFieldHandlePtr PolygonForegroundBase::getHandleAspectWidth (void) const
1023 SFUInt16::GetHandlePtr returnValue(
1024 new SFUInt16::GetHandle(
1025 &_sfAspectWidth,
1026 this->getType().getFieldDesc(AspectWidthFieldId),
1027 const_cast<PolygonForegroundBase *>(this)));
1029 return returnValue;
1032 EditFieldHandlePtr PolygonForegroundBase::editHandleAspectWidth (void)
1034 SFUInt16::EditHandlePtr returnValue(
1035 new SFUInt16::EditHandle(
1036 &_sfAspectWidth,
1037 this->getType().getFieldDesc(AspectWidthFieldId),
1038 this));
1041 editSField(AspectWidthFieldMask);
1043 return returnValue;
1046 GetFieldHandlePtr PolygonForegroundBase::getHandleScale (void) const
1048 SFReal32::GetHandlePtr returnValue(
1049 new SFReal32::GetHandle(
1050 &_sfScale,
1051 this->getType().getFieldDesc(ScaleFieldId),
1052 const_cast<PolygonForegroundBase *>(this)));
1054 return returnValue;
1057 EditFieldHandlePtr PolygonForegroundBase::editHandleScale (void)
1059 SFReal32::EditHandlePtr returnValue(
1060 new SFReal32::EditHandle(
1061 &_sfScale,
1062 this->getType().getFieldDesc(ScaleFieldId),
1063 this));
1066 editSField(ScaleFieldMask);
1068 return returnValue;
1071 GetFieldHandlePtr PolygonForegroundBase::getHandleTile (void) const
1073 SFBool::GetHandlePtr returnValue(
1074 new SFBool::GetHandle(
1075 &_sfTile,
1076 this->getType().getFieldDesc(TileFieldId),
1077 const_cast<PolygonForegroundBase *>(this)));
1079 return returnValue;
1082 EditFieldHandlePtr PolygonForegroundBase::editHandleTile (void)
1084 SFBool::EditHandlePtr returnValue(
1085 new SFBool::EditHandle(
1086 &_sfTile,
1087 this->getType().getFieldDesc(TileFieldId),
1088 this));
1091 editSField(TileFieldMask);
1093 return returnValue;
1097 #ifdef OSG_MT_CPTR_ASPECT
1098 void PolygonForegroundBase::execSyncV( FieldContainer &oFrom,
1099 ConstFieldMaskArg whichField,
1100 AspectOffsetStore &oOffsets,
1101 ConstFieldMaskArg syncMode,
1102 const UInt32 uiSyncInfo)
1104 PolygonForeground *pThis = static_cast<PolygonForeground *>(this);
1106 pThis->execSync(static_cast<PolygonForeground *>(&oFrom),
1107 whichField,
1108 oOffsets,
1109 syncMode,
1110 uiSyncInfo);
1112 #endif
1115 #ifdef OSG_MT_CPTR_ASPECT
1116 FieldContainer *PolygonForegroundBase::createAspectCopy(
1117 const FieldContainer *pRefAspect) const
1119 PolygonForeground *returnValue;
1121 newAspectCopy(returnValue,
1122 dynamic_cast<const PolygonForeground *>(pRefAspect),
1123 dynamic_cast<const PolygonForeground *>(this));
1125 return returnValue;
1127 #endif
1129 void PolygonForegroundBase::resolveLinks(void)
1131 Inherited::resolveLinks();
1133 static_cast<PolygonForeground *>(this)->setMaterial(NULL);
1135 #ifdef OSG_MT_CPTR_ASPECT
1136 AspectOffsetStore oOffsets;
1138 _pAspectStore->fillOffsetArray(oOffsets, this);
1139 #endif
1141 #ifdef OSG_MT_CPTR_ASPECT
1142 _mfPositions.terminateShare(Thread::getCurrentAspect(),
1143 oOffsets);
1144 #endif
1145 #ifdef OSG_MT_CPTR_ASPECT
1146 _mfTexCoords.terminateShare(Thread::getCurrentAspect(),
1147 oOffsets);
1148 #endif
1152 OSG_END_NAMESPACE