changed: gcc8 base update
[opensg.git] / Source / System / State / OpenGL / OSGLineChunkBase.cpp
blobf7a53dc50f2cb44b97f20882d007aaa3c928d15d
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 LineChunk!
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"
64 #include "OSGGL.h" // Smooth default header
67 #include "OSGLineChunkBase.h"
68 #include "OSGLineChunk.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::LineChunk
79 See \ref PageSystemLineChunk for a description.
81 The line chunk contains the parameters that are specific to lines.
83 The parameters of the following functions are wrapped here: glLineWidth
84 (OSG::LineChunk::_sfWidth), glLineStipple (OSG::LineChunk::_sfStippleRepeat,
85 OSG::LineChunk::_sfStipplePattern), glEnable(GL_LINE_SMOOTH)
86 (OSG::LineChunk::_sfSmooth).
89 /***************************************************************************\
90 * Field Documentation *
91 \***************************************************************************/
93 /*! \var Real32 LineChunkBase::_sfWidth
94 The line's width, in pixels.
97 /*! \var Int32 LineChunkBase::_sfStippleRepeat
98 Repetition factor for stippling.
101 /*! \var UInt16 LineChunkBase::_sfStipplePattern
102 Defines the stipple pattern. 1 bits are drawn, 0 bits are ignored,
103 starting with the most significant bit.
106 /*! \var bool LineChunkBase::_sfSmooth
107 Defines if line antialiasing is used.
111 /***************************************************************************\
112 * FieldType/FieldTrait Instantiation *
113 \***************************************************************************/
115 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
116 PointerType FieldTraits<LineChunk *, nsOSG>::_type(
117 "LineChunkPtr",
118 "StateChunkPtr",
119 LineChunk::getClassType(),
120 nsOSG);
121 #endif
123 OSG_FIELDTRAITS_GETTYPE_NS(LineChunk *, nsOSG)
125 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
126 LineChunk *,
127 nsOSG)
129 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
130 LineChunk *,
131 nsOSG)
133 /***************************************************************************\
134 * Field Description *
135 \***************************************************************************/
137 void LineChunkBase::classDescInserter(TypeObject &oType)
139 FieldDescriptionBase *pDesc = NULL;
142 pDesc = new SFReal32::Description(
143 SFReal32::getClassType(),
144 "width",
145 "The line's width, in pixels.\n",
146 WidthFieldId, WidthFieldMask,
147 false,
148 (Field::SFDefaultFlags | Field::FStdAccess),
149 static_cast<FieldEditMethodSig>(&LineChunk::editHandleWidth),
150 static_cast<FieldGetMethodSig >(&LineChunk::getHandleWidth));
152 oType.addInitialDesc(pDesc);
154 pDesc = new SFInt32::Description(
155 SFInt32::getClassType(),
156 "stippleRepeat",
157 "Repetition factor for stippling.\n",
158 StippleRepeatFieldId, StippleRepeatFieldMask,
159 false,
160 (Field::SFDefaultFlags | Field::FStdAccess),
161 static_cast<FieldEditMethodSig>(&LineChunk::editHandleStippleRepeat),
162 static_cast<FieldGetMethodSig >(&LineChunk::getHandleStippleRepeat));
164 oType.addInitialDesc(pDesc);
166 pDesc = new SFUInt16::Description(
167 SFUInt16::getClassType(),
168 "stipplePattern",
169 "Defines the stipple pattern. 1 bits are drawn, 0 bits are ignored, \n"
170 "starting with the most significant bit.\n",
171 StipplePatternFieldId, StipplePatternFieldMask,
172 false,
173 (Field::SFDefaultFlags | Field::FStdAccess),
174 static_cast<FieldEditMethodSig>(&LineChunk::editHandleStipplePattern),
175 static_cast<FieldGetMethodSig >(&LineChunk::getHandleStipplePattern));
177 oType.addInitialDesc(pDesc);
179 pDesc = new SFBool::Description(
180 SFBool::getClassType(),
181 "smooth",
182 "Defines if line antialiasing is used.\n",
183 SmoothFieldId, SmoothFieldMask,
184 false,
185 (Field::SFDefaultFlags | Field::FStdAccess),
186 static_cast<FieldEditMethodSig>(&LineChunk::editHandleSmooth),
187 static_cast<FieldGetMethodSig >(&LineChunk::getHandleSmooth));
189 oType.addInitialDesc(pDesc);
193 LineChunkBase::TypeObject LineChunkBase::_type(
194 LineChunkBase::getClassname(),
195 Inherited::getClassname(),
196 "NULL",
197 nsOSG, //Namespace
198 reinterpret_cast<PrototypeCreateF>(&LineChunkBase::createEmptyLocal),
199 reinterpret_cast<InitContainerF>(&LineChunk::initMethod),
200 reinterpret_cast<ExitContainerF>(&LineChunk::exitMethod),
201 reinterpret_cast<InitalInsertDescFunc>(
202 reinterpret_cast<void *>(&LineChunk::classDescInserter)),
203 false,
205 "<?xml version=\"1.0\"?>\n"
206 "\n"
207 "<FieldContainer\n"
208 " name=\"LineChunk\"\n"
209 " parent=\"StateChunk\"\n"
210 " library=\"State\"\n"
211 " pointerfieldtypes=\"both\"\n"
212 " structure=\"concrete\"\n"
213 " systemcomponent=\"true\"\n"
214 " parentsystemcomponent=\"true\"\n"
215 " docGroupBase=\"GrpStateOpenGL\"\n"
216 " >\n"
217 " See \\ref PageSystemLineChunk for a description.\n"
218 "\n"
219 " The line chunk contains the parameters that are specific to lines.\n"
220 "\n"
221 " The parameters of the following functions are wrapped here: glLineWidth\n"
222 " (OSG::LineChunk::_sfWidth), glLineStipple (OSG::LineChunk::_sfStippleRepeat,\n"
223 " OSG::LineChunk::_sfStipplePattern), glEnable(GL_LINE_SMOOTH)\n"
224 " (OSG::LineChunk::_sfSmooth).\n"
225 " <Field\n"
226 "\t name=\"width\"\n"
227 "\t type=\"Real32\"\n"
228 "\t cardinality=\"single\"\n"
229 "\t visibility=\"external\"\n"
230 "\t defaultValue=\"1\"\n"
231 "\t access=\"public\"\n"
232 "\t >\n"
233 " The line's width, in pixels.\n"
234 " </Field>\n"
235 " <Field\n"
236 "\t name=\"stippleRepeat\"\n"
237 "\t type=\"Int32\"\n"
238 "\t cardinality=\"single\"\n"
239 "\t visibility=\"external\"\n"
240 "\t defaultValue=\"1\"\n"
241 "\t access=\"public\"\n"
242 "\t >\n"
243 " Repetition factor for stippling.\n"
244 " </Field>\n"
245 " <Field\n"
246 "\t name=\"stipplePattern\"\n"
247 "\t type=\"UInt16\"\n"
248 "\t cardinality=\"single\"\n"
249 "\t visibility=\"external\"\n"
250 "\t defaultValue=\"0xffff\"\n"
251 "\t access=\"public\"\n"
252 "\t >\n"
253 "\tDefines the stipple pattern. 1 bits are drawn, 0 bits are ignored, \n"
254 " starting with the most significant bit.\n"
255 " </Field>\n"
256 " <Field\n"
257 "\t name=\"smooth\"\n"
258 "\t type=\"bool\"\n"
259 "\t cardinality=\"single\"\n"
260 "\t visibility=\"external\"\n"
261 "\t defaultValue=\"GL_FALSE\"\n"
262 "\t defaultHeader=\"&quot;OSGGL.h&quot;\"\n"
263 "\t access=\"public\"\n"
264 "\t >\n"
265 "\tDefines if line antialiasing is used.\n"
266 " </Field>\n"
267 "</FieldContainer>\n",
268 "See \\ref PageSystemLineChunk for a description.\n"
269 "\n"
270 "The line chunk contains the parameters that are specific to lines.\n"
271 "\n"
272 "The parameters of the following functions are wrapped here: glLineWidth\n"
273 "(OSG::LineChunk::_sfWidth), glLineStipple (OSG::LineChunk::_sfStippleRepeat,\n"
274 "OSG::LineChunk::_sfStipplePattern), glEnable(GL_LINE_SMOOTH)\n"
275 "(OSG::LineChunk::_sfSmooth).\n"
278 /*------------------------------ get -----------------------------------*/
280 FieldContainerType &LineChunkBase::getType(void)
282 return _type;
285 const FieldContainerType &LineChunkBase::getType(void) const
287 return _type;
290 UInt32 LineChunkBase::getContainerSize(void) const
292 return sizeof(LineChunk);
295 /*------------------------- decorator get ------------------------------*/
298 SFReal32 *LineChunkBase::editSFWidth(void)
300 editSField(WidthFieldMask);
302 return &_sfWidth;
305 const SFReal32 *LineChunkBase::getSFWidth(void) const
307 return &_sfWidth;
311 SFInt32 *LineChunkBase::editSFStippleRepeat(void)
313 editSField(StippleRepeatFieldMask);
315 return &_sfStippleRepeat;
318 const SFInt32 *LineChunkBase::getSFStippleRepeat(void) const
320 return &_sfStippleRepeat;
324 SFUInt16 *LineChunkBase::editSFStipplePattern(void)
326 editSField(StipplePatternFieldMask);
328 return &_sfStipplePattern;
331 const SFUInt16 *LineChunkBase::getSFStipplePattern(void) const
333 return &_sfStipplePattern;
337 SFBool *LineChunkBase::editSFSmooth(void)
339 editSField(SmoothFieldMask);
341 return &_sfSmooth;
344 const SFBool *LineChunkBase::getSFSmooth(void) const
346 return &_sfSmooth;
354 /*------------------------------ access -----------------------------------*/
356 SizeT LineChunkBase::getBinSize(ConstFieldMaskArg whichField)
358 SizeT returnValue = Inherited::getBinSize(whichField);
360 if(FieldBits::NoField != (WidthFieldMask & whichField))
362 returnValue += _sfWidth.getBinSize();
364 if(FieldBits::NoField != (StippleRepeatFieldMask & whichField))
366 returnValue += _sfStippleRepeat.getBinSize();
368 if(FieldBits::NoField != (StipplePatternFieldMask & whichField))
370 returnValue += _sfStipplePattern.getBinSize();
372 if(FieldBits::NoField != (SmoothFieldMask & whichField))
374 returnValue += _sfSmooth.getBinSize();
377 return returnValue;
380 void LineChunkBase::copyToBin(BinaryDataHandler &pMem,
381 ConstFieldMaskArg whichField)
383 Inherited::copyToBin(pMem, whichField);
385 if(FieldBits::NoField != (WidthFieldMask & whichField))
387 _sfWidth.copyToBin(pMem);
389 if(FieldBits::NoField != (StippleRepeatFieldMask & whichField))
391 _sfStippleRepeat.copyToBin(pMem);
393 if(FieldBits::NoField != (StipplePatternFieldMask & whichField))
395 _sfStipplePattern.copyToBin(pMem);
397 if(FieldBits::NoField != (SmoothFieldMask & whichField))
399 _sfSmooth.copyToBin(pMem);
403 void LineChunkBase::copyFromBin(BinaryDataHandler &pMem,
404 ConstFieldMaskArg whichField)
406 Inherited::copyFromBin(pMem, whichField);
408 if(FieldBits::NoField != (WidthFieldMask & whichField))
410 editSField(WidthFieldMask);
411 _sfWidth.copyFromBin(pMem);
413 if(FieldBits::NoField != (StippleRepeatFieldMask & whichField))
415 editSField(StippleRepeatFieldMask);
416 _sfStippleRepeat.copyFromBin(pMem);
418 if(FieldBits::NoField != (StipplePatternFieldMask & whichField))
420 editSField(StipplePatternFieldMask);
421 _sfStipplePattern.copyFromBin(pMem);
423 if(FieldBits::NoField != (SmoothFieldMask & whichField))
425 editSField(SmoothFieldMask);
426 _sfSmooth.copyFromBin(pMem);
430 //! create a new instance of the class
431 LineChunkTransitPtr LineChunkBase::createLocal(BitVector bFlags)
433 LineChunkTransitPtr fc;
435 if(getClassType().getPrototype() != NULL)
437 FieldContainerTransitPtr tmpPtr =
438 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
440 fc = dynamic_pointer_cast<LineChunk>(tmpPtr);
443 return fc;
446 //! create a new instance of the class, copy the container flags
447 LineChunkTransitPtr LineChunkBase::createDependent(BitVector bFlags)
449 LineChunkTransitPtr fc;
451 if(getClassType().getPrototype() != NULL)
453 FieldContainerTransitPtr tmpPtr =
454 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
456 fc = dynamic_pointer_cast<LineChunk>(tmpPtr);
459 return fc;
462 //! create a new instance of the class
463 LineChunkTransitPtr LineChunkBase::create(void)
465 LineChunkTransitPtr fc;
467 if(getClassType().getPrototype() != NULL)
469 FieldContainerTransitPtr tmpPtr =
470 getClassType().getPrototype()-> shallowCopy();
472 fc = dynamic_pointer_cast<LineChunk>(tmpPtr);
475 return fc;
478 LineChunk *LineChunkBase::createEmptyLocal(BitVector bFlags)
480 LineChunk *returnValue;
482 newPtr<LineChunk>(returnValue, bFlags);
484 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
486 return returnValue;
489 //! create an empty new instance of the class, do not copy the prototype
490 LineChunk *LineChunkBase::createEmpty(void)
492 LineChunk *returnValue;
494 newPtr<LineChunk>(returnValue, Thread::getCurrentLocalFlags());
496 returnValue->_pFieldFlags->_bNamespaceMask &=
497 ~Thread::getCurrentLocalFlags();
499 return returnValue;
503 FieldContainerTransitPtr LineChunkBase::shallowCopyLocal(
504 BitVector bFlags) const
506 LineChunk *tmpPtr;
508 newPtr(tmpPtr, dynamic_cast<const LineChunk *>(this), bFlags);
510 FieldContainerTransitPtr returnValue(tmpPtr);
512 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
514 return returnValue;
517 FieldContainerTransitPtr LineChunkBase::shallowCopyDependent(
518 BitVector bFlags) const
520 LineChunk *tmpPtr;
522 newPtr(tmpPtr, dynamic_cast<const LineChunk *>(this), ~bFlags);
524 FieldContainerTransitPtr returnValue(tmpPtr);
526 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
528 return returnValue;
531 FieldContainerTransitPtr LineChunkBase::shallowCopy(void) const
533 LineChunk *tmpPtr;
535 newPtr(tmpPtr,
536 dynamic_cast<const LineChunk *>(this),
537 Thread::getCurrentLocalFlags());
539 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
541 FieldContainerTransitPtr returnValue(tmpPtr);
543 return returnValue;
549 /*------------------------- constructors ----------------------------------*/
551 LineChunkBase::LineChunkBase(void) :
552 Inherited(),
553 _sfWidth (Real32(1)),
554 _sfStippleRepeat (Int32(1)),
555 _sfStipplePattern (UInt16(0xffff)),
556 _sfSmooth (bool(GL_FALSE))
560 LineChunkBase::LineChunkBase(const LineChunkBase &source) :
561 Inherited(source),
562 _sfWidth (source._sfWidth ),
563 _sfStippleRepeat (source._sfStippleRepeat ),
564 _sfStipplePattern (source._sfStipplePattern ),
565 _sfSmooth (source._sfSmooth )
570 /*-------------------------- destructors ----------------------------------*/
572 LineChunkBase::~LineChunkBase(void)
577 GetFieldHandlePtr LineChunkBase::getHandleWidth (void) const
579 SFReal32::GetHandlePtr returnValue(
580 new SFReal32::GetHandle(
581 &_sfWidth,
582 this->getType().getFieldDesc(WidthFieldId),
583 const_cast<LineChunkBase *>(this)));
585 return returnValue;
588 EditFieldHandlePtr LineChunkBase::editHandleWidth (void)
590 SFReal32::EditHandlePtr returnValue(
591 new SFReal32::EditHandle(
592 &_sfWidth,
593 this->getType().getFieldDesc(WidthFieldId),
594 this));
597 editSField(WidthFieldMask);
599 return returnValue;
602 GetFieldHandlePtr LineChunkBase::getHandleStippleRepeat (void) const
604 SFInt32::GetHandlePtr returnValue(
605 new SFInt32::GetHandle(
606 &_sfStippleRepeat,
607 this->getType().getFieldDesc(StippleRepeatFieldId),
608 const_cast<LineChunkBase *>(this)));
610 return returnValue;
613 EditFieldHandlePtr LineChunkBase::editHandleStippleRepeat (void)
615 SFInt32::EditHandlePtr returnValue(
616 new SFInt32::EditHandle(
617 &_sfStippleRepeat,
618 this->getType().getFieldDesc(StippleRepeatFieldId),
619 this));
622 editSField(StippleRepeatFieldMask);
624 return returnValue;
627 GetFieldHandlePtr LineChunkBase::getHandleStipplePattern (void) const
629 SFUInt16::GetHandlePtr returnValue(
630 new SFUInt16::GetHandle(
631 &_sfStipplePattern,
632 this->getType().getFieldDesc(StipplePatternFieldId),
633 const_cast<LineChunkBase *>(this)));
635 return returnValue;
638 EditFieldHandlePtr LineChunkBase::editHandleStipplePattern (void)
640 SFUInt16::EditHandlePtr returnValue(
641 new SFUInt16::EditHandle(
642 &_sfStipplePattern,
643 this->getType().getFieldDesc(StipplePatternFieldId),
644 this));
647 editSField(StipplePatternFieldMask);
649 return returnValue;
652 GetFieldHandlePtr LineChunkBase::getHandleSmooth (void) const
654 SFBool::GetHandlePtr returnValue(
655 new SFBool::GetHandle(
656 &_sfSmooth,
657 this->getType().getFieldDesc(SmoothFieldId),
658 const_cast<LineChunkBase *>(this)));
660 return returnValue;
663 EditFieldHandlePtr LineChunkBase::editHandleSmooth (void)
665 SFBool::EditHandlePtr returnValue(
666 new SFBool::EditHandle(
667 &_sfSmooth,
668 this->getType().getFieldDesc(SmoothFieldId),
669 this));
672 editSField(SmoothFieldMask);
674 return returnValue;
678 #ifdef OSG_MT_CPTR_ASPECT
679 void LineChunkBase::execSyncV( FieldContainer &oFrom,
680 ConstFieldMaskArg whichField,
681 AspectOffsetStore &oOffsets,
682 ConstFieldMaskArg syncMode,
683 const UInt32 uiSyncInfo)
685 LineChunk *pThis = static_cast<LineChunk *>(this);
687 pThis->execSync(static_cast<LineChunk *>(&oFrom),
688 whichField,
689 oOffsets,
690 syncMode,
691 uiSyncInfo);
693 #endif
696 #ifdef OSG_MT_CPTR_ASPECT
697 FieldContainer *LineChunkBase::createAspectCopy(
698 const FieldContainer *pRefAspect) const
700 LineChunk *returnValue;
702 newAspectCopy(returnValue,
703 dynamic_cast<const LineChunk *>(pRefAspect),
704 dynamic_cast<const LineChunk *>(this));
706 return returnValue;
708 #endif
710 void LineChunkBase::resolveLinks(void)
712 Inherited::resolveLinks();
718 OSG_END_NAMESPACE