fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Window / Foreground / OSGTextureGrabForegroundBase.cpp
blob9c7b9c66dab627aa0ebee187b340174ff02c1d19
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 TextureGrabForeground!
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 "OSGTextureObjChunk.h" // Texture Class
67 #include "OSGTextureGrabForegroundBase.h"
68 #include "OSGTextureGrabForeground.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::TextureGrabForeground
79 The GrabForeground is used for grabbing a rendered viewport into a Texture.
80 See \ref PageSystemWindowForegroundGrabTexture for a description.
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var TextureObjChunk * TextureGrabForegroundBase::_sfTexture
88 The texture to grab into.
91 /*! \var bool TextureGrabForegroundBase::_sfAutoResize
92 Automatically resize the texture when the viewport size changes.
95 /*! \var GLenum TextureGrabForegroundBase::_sfBindTarget
96 Enum to use for glBindTexture, if GL_NONE chosen from texture
97 dimensionality.
100 /*! \var GLenum TextureGrabForegroundBase::_sfCopyTarget
101 Enum to use for glCopyTexture, if GL_NONE chosen from texture
102 dimensionality.
103 Mainly useful to grab into the different parts of a CubeTexture.
107 /***************************************************************************\
108 * FieldType/FieldTrait Instantiation *
109 \***************************************************************************/
111 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
112 PointerType FieldTraits<TextureGrabForeground *, nsOSG>::_type(
113 "TextureGrabForegroundPtr",
114 "ForegroundPtr",
115 TextureGrabForeground::getClassType(),
116 nsOSG);
117 #endif
119 OSG_FIELDTRAITS_GETTYPE_NS(TextureGrabForeground *, nsOSG)
121 /***************************************************************************\
122 * Field Description *
123 \***************************************************************************/
125 void TextureGrabForegroundBase::classDescInserter(TypeObject &oType)
127 FieldDescriptionBase *pDesc = NULL;
130 pDesc = new SFUnrecTextureObjChunkPtr::Description(
131 SFUnrecTextureObjChunkPtr::getClassType(),
132 "texture",
133 "The texture to grab into.\n",
134 TextureFieldId, TextureFieldMask,
135 false,
136 (Field::SFDefaultFlags | Field::FStdAccess),
137 static_cast<FieldEditMethodSig>(&TextureGrabForeground::editHandleTexture),
138 static_cast<FieldGetMethodSig >(&TextureGrabForeground::getHandleTexture));
140 oType.addInitialDesc(pDesc);
142 pDesc = new SFBool::Description(
143 SFBool::getClassType(),
144 "autoResize",
145 "Automatically resize the texture when the viewport size changes.\n",
146 AutoResizeFieldId, AutoResizeFieldMask,
147 false,
148 (Field::SFDefaultFlags | Field::FStdAccess),
149 static_cast<FieldEditMethodSig>(&TextureGrabForeground::editHandleAutoResize),
150 static_cast<FieldGetMethodSig >(&TextureGrabForeground::getHandleAutoResize));
152 oType.addInitialDesc(pDesc);
154 pDesc = new SFGLenum::Description(
155 SFGLenum::getClassType(),
156 "bindTarget",
157 "Enum to use for glBindTexture, if GL_NONE chosen from texture\n"
158 "dimensionality. \n",
159 BindTargetFieldId, BindTargetFieldMask,
160 false,
161 (Field::SFDefaultFlags | Field::FStdAccess),
162 static_cast<FieldEditMethodSig>(&TextureGrabForeground::editHandleBindTarget),
163 static_cast<FieldGetMethodSig >(&TextureGrabForeground::getHandleBindTarget));
165 oType.addInitialDesc(pDesc);
167 pDesc = new SFGLenum::Description(
168 SFGLenum::getClassType(),
169 "copyTarget",
170 "Enum to use for glCopyTexture, if GL_NONE chosen from texture\n"
171 "dimensionality. \n"
172 "Mainly useful to grab into the different parts of a CubeTexture.\n",
173 CopyTargetFieldId, CopyTargetFieldMask,
174 false,
175 (Field::SFDefaultFlags | Field::FStdAccess),
176 static_cast<FieldEditMethodSig>(&TextureGrabForeground::editHandleCopyTarget),
177 static_cast<FieldGetMethodSig >(&TextureGrabForeground::getHandleCopyTarget));
179 oType.addInitialDesc(pDesc);
183 TextureGrabForegroundBase::TypeObject TextureGrabForegroundBase::_type(
184 TextureGrabForegroundBase::getClassname(),
185 Inherited::getClassname(),
186 "NULL",
187 nsOSG, //Namespace
188 reinterpret_cast<PrototypeCreateF>(&TextureGrabForegroundBase::createEmptyLocal),
189 reinterpret_cast<InitContainerF>(&TextureGrabForeground::initMethod),
190 reinterpret_cast<ExitContainerF>(&TextureGrabForeground::exitMethod),
191 reinterpret_cast<InitalInsertDescFunc>(
192 reinterpret_cast<void *>(&TextureGrabForeground::classDescInserter)),
193 false,
195 "<?xml version=\"1.0\"?>\n"
196 "\n"
197 "<FieldContainer\n"
198 " name=\"TextureGrabForeground\"\n"
199 " parent=\"Foreground\"\n"
200 " library=\"Window\"\n"
201 " pointerfieldtypes=\"none\"\n"
202 " structure=\"concrete\"\n"
203 " systemcomponent=\"true\"\n"
204 " parentsystemcomponent=\"true\"\n"
205 " decoratable=\"false\"\n"
206 " docGroupBase=\"GrpWindowForeground\"\n"
207 " >\n"
208 " The GrabForeground is used for grabbing a rendered viewport into a Texture.\n"
209 " See \\ref PageSystemWindowForegroundGrabTexture for a description.\n"
210 " <Field\n"
211 "\t name=\"texture\"\n"
212 "\t type=\"TextureObjChunkPtr\"\n"
213 "\t cardinality=\"single\"\n"
214 "\t visibility=\"external\"\n"
215 "\t access=\"public\"\n"
216 "\t >\n"
217 "\tThe texture to grab into.\n"
218 " </Field>\n"
219 " <Field\n"
220 "\t name=\"autoResize\"\n"
221 "\t type=\"bool\"\n"
222 "\t cardinality=\"single\"\n"
223 "\t visibility=\"external\"\n"
224 "\t defaultValue=\"true\"\n"
225 "\t access=\"public\"\n"
226 "\t >\n"
227 " Automatically resize the texture when the viewport size changes.\n"
228 " </Field>\n"
229 " <Field\n"
230 "\t name=\"bindTarget\"\n"
231 "\t type=\"GLenum\"\n"
232 "\t cardinality=\"single\"\n"
233 "\t visibility=\"external\"\n"
234 "\t defaultValue=\"GL_NONE\"\n"
235 "\t access=\"public\"\n"
236 "\t >\n"
237 " Enum to use for glBindTexture, if GL_NONE chosen from texture\n"
238 "\tdimensionality. \n"
239 " </Field>\n"
240 " <Field\n"
241 "\t name=\"copyTarget\"\n"
242 "\t type=\"GLenum\"\n"
243 "\t cardinality=\"single\"\n"
244 "\t visibility=\"external\"\n"
245 "\t defaultValue=\"GL_NONE\"\n"
246 "\t access=\"public\"\n"
247 "\t >\n"
248 " Enum to use for glCopyTexture, if GL_NONE chosen from texture\n"
249 "\tdimensionality. \n"
250 " Mainly useful to grab into the different parts of a CubeTexture.\n"
251 " </Field>\n"
252 "</FieldContainer>\n",
253 "The GrabForeground is used for grabbing a rendered viewport into a Texture.\n"
254 "See \\ref PageSystemWindowForegroundGrabTexture for a description.\n"
257 /*------------------------------ get -----------------------------------*/
259 FieldContainerType &TextureGrabForegroundBase::getType(void)
261 return _type;
264 const FieldContainerType &TextureGrabForegroundBase::getType(void) const
266 return _type;
269 UInt32 TextureGrabForegroundBase::getContainerSize(void) const
271 return sizeof(TextureGrabForeground);
274 /*------------------------- decorator get ------------------------------*/
277 //! Get the TextureGrabForeground::_sfTexture field.
278 const SFUnrecTextureObjChunkPtr *TextureGrabForegroundBase::getSFTexture(void) const
280 return &_sfTexture;
283 SFUnrecTextureObjChunkPtr *TextureGrabForegroundBase::editSFTexture (void)
285 editSField(TextureFieldMask);
287 return &_sfTexture;
290 //! Get the value of the TextureGrabForeground::_sfTexture field.
291 TextureObjChunk * TextureGrabForegroundBase::getTexture(void) const
293 return _sfTexture.getValue();
296 //! Set the value of the TextureGrabForeground::_sfTexture field.
297 void TextureGrabForegroundBase::setTexture(TextureObjChunk * const value)
299 editSField(TextureFieldMask);
301 _sfTexture.setValue(value);
305 SFBool *TextureGrabForegroundBase::editSFAutoResize(void)
307 editSField(AutoResizeFieldMask);
309 return &_sfAutoResize;
312 const SFBool *TextureGrabForegroundBase::getSFAutoResize(void) const
314 return &_sfAutoResize;
318 SFGLenum *TextureGrabForegroundBase::editSFBindTarget(void)
320 editSField(BindTargetFieldMask);
322 return &_sfBindTarget;
325 const SFGLenum *TextureGrabForegroundBase::getSFBindTarget(void) const
327 return &_sfBindTarget;
331 SFGLenum *TextureGrabForegroundBase::editSFCopyTarget(void)
333 editSField(CopyTargetFieldMask);
335 return &_sfCopyTarget;
338 const SFGLenum *TextureGrabForegroundBase::getSFCopyTarget(void) const
340 return &_sfCopyTarget;
348 /*------------------------------ access -----------------------------------*/
350 SizeT TextureGrabForegroundBase::getBinSize(ConstFieldMaskArg whichField)
352 SizeT returnValue = Inherited::getBinSize(whichField);
354 if(FieldBits::NoField != (TextureFieldMask & whichField))
356 returnValue += _sfTexture.getBinSize();
358 if(FieldBits::NoField != (AutoResizeFieldMask & whichField))
360 returnValue += _sfAutoResize.getBinSize();
362 if(FieldBits::NoField != (BindTargetFieldMask & whichField))
364 returnValue += _sfBindTarget.getBinSize();
366 if(FieldBits::NoField != (CopyTargetFieldMask & whichField))
368 returnValue += _sfCopyTarget.getBinSize();
371 return returnValue;
374 void TextureGrabForegroundBase::copyToBin(BinaryDataHandler &pMem,
375 ConstFieldMaskArg whichField)
377 Inherited::copyToBin(pMem, whichField);
379 if(FieldBits::NoField != (TextureFieldMask & whichField))
381 _sfTexture.copyToBin(pMem);
383 if(FieldBits::NoField != (AutoResizeFieldMask & whichField))
385 _sfAutoResize.copyToBin(pMem);
387 if(FieldBits::NoField != (BindTargetFieldMask & whichField))
389 _sfBindTarget.copyToBin(pMem);
391 if(FieldBits::NoField != (CopyTargetFieldMask & whichField))
393 _sfCopyTarget.copyToBin(pMem);
397 void TextureGrabForegroundBase::copyFromBin(BinaryDataHandler &pMem,
398 ConstFieldMaskArg whichField)
400 Inherited::copyFromBin(pMem, whichField);
402 if(FieldBits::NoField != (TextureFieldMask & whichField))
404 editSField(TextureFieldMask);
405 _sfTexture.copyFromBin(pMem);
407 if(FieldBits::NoField != (AutoResizeFieldMask & whichField))
409 editSField(AutoResizeFieldMask);
410 _sfAutoResize.copyFromBin(pMem);
412 if(FieldBits::NoField != (BindTargetFieldMask & whichField))
414 editSField(BindTargetFieldMask);
415 _sfBindTarget.copyFromBin(pMem);
417 if(FieldBits::NoField != (CopyTargetFieldMask & whichField))
419 editSField(CopyTargetFieldMask);
420 _sfCopyTarget.copyFromBin(pMem);
424 //! create a new instance of the class
425 TextureGrabForegroundTransitPtr TextureGrabForegroundBase::createLocal(BitVector bFlags)
427 TextureGrabForegroundTransitPtr fc;
429 if(getClassType().getPrototype() != NULL)
431 FieldContainerTransitPtr tmpPtr =
432 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
434 fc = dynamic_pointer_cast<TextureGrabForeground>(tmpPtr);
437 return fc;
440 //! create a new instance of the class, copy the container flags
441 TextureGrabForegroundTransitPtr TextureGrabForegroundBase::createDependent(BitVector bFlags)
443 TextureGrabForegroundTransitPtr fc;
445 if(getClassType().getPrototype() != NULL)
447 FieldContainerTransitPtr tmpPtr =
448 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
450 fc = dynamic_pointer_cast<TextureGrabForeground>(tmpPtr);
453 return fc;
456 //! create a new instance of the class
457 TextureGrabForegroundTransitPtr TextureGrabForegroundBase::create(void)
459 TextureGrabForegroundTransitPtr fc;
461 if(getClassType().getPrototype() != NULL)
463 FieldContainerTransitPtr tmpPtr =
464 getClassType().getPrototype()-> shallowCopy();
466 fc = dynamic_pointer_cast<TextureGrabForeground>(tmpPtr);
469 return fc;
472 TextureGrabForeground *TextureGrabForegroundBase::createEmptyLocal(BitVector bFlags)
474 TextureGrabForeground *returnValue;
476 newPtr<TextureGrabForeground>(returnValue, bFlags);
478 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
480 return returnValue;
483 //! create an empty new instance of the class, do not copy the prototype
484 TextureGrabForeground *TextureGrabForegroundBase::createEmpty(void)
486 TextureGrabForeground *returnValue;
488 newPtr<TextureGrabForeground>(returnValue, Thread::getCurrentLocalFlags());
490 returnValue->_pFieldFlags->_bNamespaceMask &=
491 ~Thread::getCurrentLocalFlags();
493 return returnValue;
497 FieldContainerTransitPtr TextureGrabForegroundBase::shallowCopyLocal(
498 BitVector bFlags) const
500 TextureGrabForeground *tmpPtr;
502 newPtr(tmpPtr, dynamic_cast<const TextureGrabForeground *>(this), bFlags);
504 FieldContainerTransitPtr returnValue(tmpPtr);
506 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
508 return returnValue;
511 FieldContainerTransitPtr TextureGrabForegroundBase::shallowCopyDependent(
512 BitVector bFlags) const
514 TextureGrabForeground *tmpPtr;
516 newPtr(tmpPtr, dynamic_cast<const TextureGrabForeground *>(this), ~bFlags);
518 FieldContainerTransitPtr returnValue(tmpPtr);
520 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
522 return returnValue;
525 FieldContainerTransitPtr TextureGrabForegroundBase::shallowCopy(void) const
527 TextureGrabForeground *tmpPtr;
529 newPtr(tmpPtr,
530 dynamic_cast<const TextureGrabForeground *>(this),
531 Thread::getCurrentLocalFlags());
533 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
535 FieldContainerTransitPtr returnValue(tmpPtr);
537 return returnValue;
543 /*------------------------- constructors ----------------------------------*/
545 TextureGrabForegroundBase::TextureGrabForegroundBase(void) :
546 Inherited(),
547 _sfTexture (NULL),
548 _sfAutoResize (bool(true)),
549 _sfBindTarget (GLenum(GL_NONE)),
550 _sfCopyTarget (GLenum(GL_NONE))
554 TextureGrabForegroundBase::TextureGrabForegroundBase(const TextureGrabForegroundBase &source) :
555 Inherited(source),
556 _sfTexture (NULL),
557 _sfAutoResize (source._sfAutoResize ),
558 _sfBindTarget (source._sfBindTarget ),
559 _sfCopyTarget (source._sfCopyTarget )
564 /*-------------------------- destructors ----------------------------------*/
566 TextureGrabForegroundBase::~TextureGrabForegroundBase(void)
570 void TextureGrabForegroundBase::onCreate(const TextureGrabForeground *source)
572 Inherited::onCreate(source);
574 if(source != NULL)
576 TextureGrabForeground *pThis = static_cast<TextureGrabForeground *>(this);
578 pThis->setTexture(source->getTexture());
582 GetFieldHandlePtr TextureGrabForegroundBase::getHandleTexture (void) const
584 SFUnrecTextureObjChunkPtr::GetHandlePtr returnValue(
585 new SFUnrecTextureObjChunkPtr::GetHandle(
586 &_sfTexture,
587 this->getType().getFieldDesc(TextureFieldId),
588 const_cast<TextureGrabForegroundBase *>(this)));
590 return returnValue;
593 EditFieldHandlePtr TextureGrabForegroundBase::editHandleTexture (void)
595 SFUnrecTextureObjChunkPtr::EditHandlePtr returnValue(
596 new SFUnrecTextureObjChunkPtr::EditHandle(
597 &_sfTexture,
598 this->getType().getFieldDesc(TextureFieldId),
599 this));
601 returnValue->setSetMethod(
602 boost::bind(&TextureGrabForeground::setTexture,
603 static_cast<TextureGrabForeground *>(this), _1));
605 editSField(TextureFieldMask);
607 return returnValue;
610 GetFieldHandlePtr TextureGrabForegroundBase::getHandleAutoResize (void) const
612 SFBool::GetHandlePtr returnValue(
613 new SFBool::GetHandle(
614 &_sfAutoResize,
615 this->getType().getFieldDesc(AutoResizeFieldId),
616 const_cast<TextureGrabForegroundBase *>(this)));
618 return returnValue;
621 EditFieldHandlePtr TextureGrabForegroundBase::editHandleAutoResize (void)
623 SFBool::EditHandlePtr returnValue(
624 new SFBool::EditHandle(
625 &_sfAutoResize,
626 this->getType().getFieldDesc(AutoResizeFieldId),
627 this));
630 editSField(AutoResizeFieldMask);
632 return returnValue;
635 GetFieldHandlePtr TextureGrabForegroundBase::getHandleBindTarget (void) const
637 SFGLenum::GetHandlePtr returnValue(
638 new SFGLenum::GetHandle(
639 &_sfBindTarget,
640 this->getType().getFieldDesc(BindTargetFieldId),
641 const_cast<TextureGrabForegroundBase *>(this)));
643 return returnValue;
646 EditFieldHandlePtr TextureGrabForegroundBase::editHandleBindTarget (void)
648 SFGLenum::EditHandlePtr returnValue(
649 new SFGLenum::EditHandle(
650 &_sfBindTarget,
651 this->getType().getFieldDesc(BindTargetFieldId),
652 this));
655 editSField(BindTargetFieldMask);
657 return returnValue;
660 GetFieldHandlePtr TextureGrabForegroundBase::getHandleCopyTarget (void) const
662 SFGLenum::GetHandlePtr returnValue(
663 new SFGLenum::GetHandle(
664 &_sfCopyTarget,
665 this->getType().getFieldDesc(CopyTargetFieldId),
666 const_cast<TextureGrabForegroundBase *>(this)));
668 return returnValue;
671 EditFieldHandlePtr TextureGrabForegroundBase::editHandleCopyTarget (void)
673 SFGLenum::EditHandlePtr returnValue(
674 new SFGLenum::EditHandle(
675 &_sfCopyTarget,
676 this->getType().getFieldDesc(CopyTargetFieldId),
677 this));
680 editSField(CopyTargetFieldMask);
682 return returnValue;
686 #ifdef OSG_MT_CPTR_ASPECT
687 void TextureGrabForegroundBase::execSyncV( FieldContainer &oFrom,
688 ConstFieldMaskArg whichField,
689 AspectOffsetStore &oOffsets,
690 ConstFieldMaskArg syncMode,
691 const UInt32 uiSyncInfo)
693 TextureGrabForeground *pThis = static_cast<TextureGrabForeground *>(this);
695 pThis->execSync(static_cast<TextureGrabForeground *>(&oFrom),
696 whichField,
697 oOffsets,
698 syncMode,
699 uiSyncInfo);
701 #endif
704 #ifdef OSG_MT_CPTR_ASPECT
705 FieldContainer *TextureGrabForegroundBase::createAspectCopy(
706 const FieldContainer *pRefAspect) const
708 TextureGrabForeground *returnValue;
710 newAspectCopy(returnValue,
711 dynamic_cast<const TextureGrabForeground *>(pRefAspect),
712 dynamic_cast<const TextureGrabForeground *>(this));
714 return returnValue;
716 #endif
718 void TextureGrabForegroundBase::resolveLinks(void)
720 Inherited::resolveLinks();
722 static_cast<TextureGrabForeground *>(this)->setTexture(NULL);
728 OSG_END_NAMESPACE