changed: gcc8 base update
[opensg.git] / Source / Contrib / Manipulators / OSGPlaneMoveManipulatorBase.cpp
blobe302b9d52c29d92086dc5ce5cc17f5af91615323
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 PlaneMoveManipulator!
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"
66 #include "OSGPlaneMoveManipulatorBase.h"
67 #include "OSGPlaneMoveManipulator.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::PlaneMoveManipulator
78 The PlaneMoveHandle is used for moving objects in a plane and rotating them around one axis.
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var UInt16 PlaneMoveManipulatorBase::_sfAxis
86 Rotation axis to rotate around (0:X, 1:Y, 2:Z). Translation plane is defined by the other two axes. *** Not implemented yet ***
89 /*! \var Vec3f PlaneMoveManipulatorBase::_sfBaseTranslation
90 Translation value at the beginning of manipulation.
93 /*! \var Quaternion PlaneMoveManipulatorBase::_sfBaseRotation
94 Rotation value at the beginning of manipulation.
97 /*! \var Pnt3f PlaneMoveManipulatorBase::_sfClickPoint
98 Point clicked on to start manipulation.
102 /***************************************************************************\
103 * FieldType/FieldTrait Instantiation *
104 \***************************************************************************/
106 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
107 PointerType FieldTraits<PlaneMoveManipulator *, nsOSG>::_type(
108 "PlaneMoveManipulatorPtr",
109 "ManipulatorPtr",
110 PlaneMoveManipulator::getClassType(),
111 nsOSG);
112 #endif
114 OSG_FIELDTRAITS_GETTYPE_NS(PlaneMoveManipulator *, nsOSG)
116 /***************************************************************************\
117 * Field Description *
118 \***************************************************************************/
120 void PlaneMoveManipulatorBase::classDescInserter(TypeObject &oType)
122 FieldDescriptionBase *pDesc = NULL;
125 pDesc = new SFUInt16::Description(
126 SFUInt16::getClassType(),
127 "axis",
128 "Rotation axis to rotate around (0:X, 1:Y, 2:Z). Translation plane is defined by the other two axes. *** Not implemented yet ***\n",
129 AxisFieldId, AxisFieldMask,
130 false,
131 (Field::SFDefaultFlags | Field::FStdAccess),
132 static_cast<FieldEditMethodSig>(&PlaneMoveManipulator::editHandleAxis),
133 static_cast<FieldGetMethodSig >(&PlaneMoveManipulator::getHandleAxis));
135 oType.addInitialDesc(pDesc);
137 pDesc = new SFVec3f::Description(
138 SFVec3f::getClassType(),
139 "baseTranslation",
140 "Translation value at the beginning of manipulation.\n",
141 BaseTranslationFieldId, BaseTranslationFieldMask,
142 false,
143 (Field::SFDefaultFlags | Field::FStdAccess),
144 static_cast<FieldEditMethodSig>(&PlaneMoveManipulator::editHandleBaseTranslation),
145 static_cast<FieldGetMethodSig >(&PlaneMoveManipulator::getHandleBaseTranslation));
147 oType.addInitialDesc(pDesc);
149 pDesc = new SFQuaternion::Description(
150 SFQuaternion::getClassType(),
151 "baseRotation",
152 "Rotation value at the beginning of manipulation.\n",
153 BaseRotationFieldId, BaseRotationFieldMask,
154 false,
155 (Field::SFDefaultFlags | Field::FStdAccess),
156 static_cast<FieldEditMethodSig>(&PlaneMoveManipulator::editHandleBaseRotation),
157 static_cast<FieldGetMethodSig >(&PlaneMoveManipulator::getHandleBaseRotation));
159 oType.addInitialDesc(pDesc);
161 pDesc = new SFPnt3f::Description(
162 SFPnt3f::getClassType(),
163 "clickPoint",
164 "Point clicked on to start manipulation.\n",
165 ClickPointFieldId, ClickPointFieldMask,
166 false,
167 (Field::SFDefaultFlags | Field::FStdAccess),
168 static_cast<FieldEditMethodSig>(&PlaneMoveManipulator::editHandleClickPoint),
169 static_cast<FieldGetMethodSig >(&PlaneMoveManipulator::getHandleClickPoint));
171 oType.addInitialDesc(pDesc);
175 PlaneMoveManipulatorBase::TypeObject PlaneMoveManipulatorBase::_type(
176 PlaneMoveManipulatorBase::getClassname(),
177 Inherited::getClassname(),
178 "NULL",
179 nsOSG, //Namespace
180 reinterpret_cast<PrototypeCreateF>(&PlaneMoveManipulatorBase::createEmptyLocal),
181 reinterpret_cast<InitContainerF>(&PlaneMoveManipulator::initMethod),
182 reinterpret_cast<ExitContainerF>(&PlaneMoveManipulator::exitMethod),
183 reinterpret_cast<InitalInsertDescFunc>(
184 reinterpret_cast<void *>(&PlaneMoveManipulator::classDescInserter)),
185 false,
187 "<?xml version=\"1.0\"?>\n"
188 "\n"
189 "<FieldContainer\n"
190 "\tname=\"PlaneMoveManipulator\"\n"
191 "\tparent=\"Manipulator\"\n"
192 "\tlibrary=\"ContribGUI\"\n"
193 "\tpointerfieldtypes=\"none\"\n"
194 "\tstructure=\"concrete\"\n"
195 "\tsystemcomponent=\"true\"\n"
196 "\tparentsystemcomponent=\"true\"\n"
197 "\tdecoratable=\"false\"\n"
198 "\tuseLocalIncludes=\"true\"\n"
199 ">\n"
200 "\t<Field\n"
201 "\t\tname=\"axis\"\n"
202 "\t\ttype=\"UInt16\"\n"
203 "\t\tcardinality=\"single\"\n"
204 "\t\tvisibility=\"external\"\n"
205 "\t\taccess=\"protected\"\n"
206 " defaultValue=\"1\"\n"
207 "\t>\n"
208 "\tRotation axis to rotate around (0:X, 1:Y, 2:Z). Translation plane is defined by the other two axes. *** Not implemented yet ***\n"
209 "\t</Field>\n"
210 "\t<Field\n"
211 "\t\tname=\"baseTranslation\"\n"
212 "\t\ttype=\"Vec3f\"\n"
213 "\t\tcardinality=\"single\"\n"
214 "\t\tvisibility=\"external\"\n"
215 "\t\taccess=\"protected\"\n"
216 "\t>\n"
217 "\tTranslation value at the beginning of manipulation.\n"
218 "\t</Field>\n"
219 "\t<Field\n"
220 "\t\tname=\"baseRotation\"\n"
221 "\t\ttype=\"Quaternion\"\n"
222 "\t\tcardinality=\"single\"\n"
223 "\t\tvisibility=\"external\"\n"
224 "\t\taccess=\"protected\"\n"
225 "\t>\n"
226 "\tRotation value at the beginning of manipulation.\n"
227 "\t</Field>\n"
228 "\t<Field\n"
229 "\t\tname=\"clickPoint\"\n"
230 "\t\ttype=\"Pnt3f\"\n"
231 "\t\tcardinality=\"single\"\n"
232 "\t\tvisibility=\"external\"\n"
233 "\t\taccess=\"protected\"\n"
234 "\t>\n"
235 "\tPoint clicked on to start manipulation.\n"
236 "\t</Field>\n"
237 "The PlaneMoveHandle is used for moving objects in a plane and rotating them around one axis.\n"
238 "</FieldContainer>\n",
239 "The PlaneMoveHandle is used for moving objects in a plane and rotating them around one axis.\n"
242 /*------------------------------ get -----------------------------------*/
244 FieldContainerType &PlaneMoveManipulatorBase::getType(void)
246 return _type;
249 const FieldContainerType &PlaneMoveManipulatorBase::getType(void) const
251 return _type;
254 UInt32 PlaneMoveManipulatorBase::getContainerSize(void) const
256 return sizeof(PlaneMoveManipulator);
259 /*------------------------- decorator get ------------------------------*/
262 SFUInt16 *PlaneMoveManipulatorBase::editSFAxis(void)
264 editSField(AxisFieldMask);
266 return &_sfAxis;
269 const SFUInt16 *PlaneMoveManipulatorBase::getSFAxis(void) const
271 return &_sfAxis;
275 SFVec3f *PlaneMoveManipulatorBase::editSFBaseTranslation(void)
277 editSField(BaseTranslationFieldMask);
279 return &_sfBaseTranslation;
282 const SFVec3f *PlaneMoveManipulatorBase::getSFBaseTranslation(void) const
284 return &_sfBaseTranslation;
288 SFQuaternion *PlaneMoveManipulatorBase::editSFBaseRotation(void)
290 editSField(BaseRotationFieldMask);
292 return &_sfBaseRotation;
295 const SFQuaternion *PlaneMoveManipulatorBase::getSFBaseRotation(void) const
297 return &_sfBaseRotation;
301 SFPnt3f *PlaneMoveManipulatorBase::editSFClickPoint(void)
303 editSField(ClickPointFieldMask);
305 return &_sfClickPoint;
308 const SFPnt3f *PlaneMoveManipulatorBase::getSFClickPoint(void) const
310 return &_sfClickPoint;
318 /*------------------------------ access -----------------------------------*/
320 SizeT PlaneMoveManipulatorBase::getBinSize(ConstFieldMaskArg whichField)
322 SizeT returnValue = Inherited::getBinSize(whichField);
324 if(FieldBits::NoField != (AxisFieldMask & whichField))
326 returnValue += _sfAxis.getBinSize();
328 if(FieldBits::NoField != (BaseTranslationFieldMask & whichField))
330 returnValue += _sfBaseTranslation.getBinSize();
332 if(FieldBits::NoField != (BaseRotationFieldMask & whichField))
334 returnValue += _sfBaseRotation.getBinSize();
336 if(FieldBits::NoField != (ClickPointFieldMask & whichField))
338 returnValue += _sfClickPoint.getBinSize();
341 return returnValue;
344 void PlaneMoveManipulatorBase::copyToBin(BinaryDataHandler &pMem,
345 ConstFieldMaskArg whichField)
347 Inherited::copyToBin(pMem, whichField);
349 if(FieldBits::NoField != (AxisFieldMask & whichField))
351 _sfAxis.copyToBin(pMem);
353 if(FieldBits::NoField != (BaseTranslationFieldMask & whichField))
355 _sfBaseTranslation.copyToBin(pMem);
357 if(FieldBits::NoField != (BaseRotationFieldMask & whichField))
359 _sfBaseRotation.copyToBin(pMem);
361 if(FieldBits::NoField != (ClickPointFieldMask & whichField))
363 _sfClickPoint.copyToBin(pMem);
367 void PlaneMoveManipulatorBase::copyFromBin(BinaryDataHandler &pMem,
368 ConstFieldMaskArg whichField)
370 Inherited::copyFromBin(pMem, whichField);
372 if(FieldBits::NoField != (AxisFieldMask & whichField))
374 editSField(AxisFieldMask);
375 _sfAxis.copyFromBin(pMem);
377 if(FieldBits::NoField != (BaseTranslationFieldMask & whichField))
379 editSField(BaseTranslationFieldMask);
380 _sfBaseTranslation.copyFromBin(pMem);
382 if(FieldBits::NoField != (BaseRotationFieldMask & whichField))
384 editSField(BaseRotationFieldMask);
385 _sfBaseRotation.copyFromBin(pMem);
387 if(FieldBits::NoField != (ClickPointFieldMask & whichField))
389 editSField(ClickPointFieldMask);
390 _sfClickPoint.copyFromBin(pMem);
394 //! create a new instance of the class
395 PlaneMoveManipulatorTransitPtr PlaneMoveManipulatorBase::createLocal(BitVector bFlags)
397 PlaneMoveManipulatorTransitPtr fc;
399 if(getClassType().getPrototype() != NULL)
401 FieldContainerTransitPtr tmpPtr =
402 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
404 fc = dynamic_pointer_cast<PlaneMoveManipulator>(tmpPtr);
407 return fc;
410 //! create a new instance of the class, copy the container flags
411 PlaneMoveManipulatorTransitPtr PlaneMoveManipulatorBase::createDependent(BitVector bFlags)
413 PlaneMoveManipulatorTransitPtr fc;
415 if(getClassType().getPrototype() != NULL)
417 FieldContainerTransitPtr tmpPtr =
418 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
420 fc = dynamic_pointer_cast<PlaneMoveManipulator>(tmpPtr);
423 return fc;
426 //! create a new instance of the class
427 PlaneMoveManipulatorTransitPtr PlaneMoveManipulatorBase::create(void)
429 PlaneMoveManipulatorTransitPtr fc;
431 if(getClassType().getPrototype() != NULL)
433 FieldContainerTransitPtr tmpPtr =
434 getClassType().getPrototype()-> shallowCopy();
436 fc = dynamic_pointer_cast<PlaneMoveManipulator>(tmpPtr);
439 return fc;
442 PlaneMoveManipulator *PlaneMoveManipulatorBase::createEmptyLocal(BitVector bFlags)
444 PlaneMoveManipulator *returnValue;
446 newPtr<PlaneMoveManipulator>(returnValue, bFlags);
448 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
450 return returnValue;
453 //! create an empty new instance of the class, do not copy the prototype
454 PlaneMoveManipulator *PlaneMoveManipulatorBase::createEmpty(void)
456 PlaneMoveManipulator *returnValue;
458 newPtr<PlaneMoveManipulator>(returnValue, Thread::getCurrentLocalFlags());
460 returnValue->_pFieldFlags->_bNamespaceMask &=
461 ~Thread::getCurrentLocalFlags();
463 return returnValue;
467 FieldContainerTransitPtr PlaneMoveManipulatorBase::shallowCopyLocal(
468 BitVector bFlags) const
470 PlaneMoveManipulator *tmpPtr;
472 newPtr(tmpPtr, dynamic_cast<const PlaneMoveManipulator *>(this), bFlags);
474 FieldContainerTransitPtr returnValue(tmpPtr);
476 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
478 return returnValue;
481 FieldContainerTransitPtr PlaneMoveManipulatorBase::shallowCopyDependent(
482 BitVector bFlags) const
484 PlaneMoveManipulator *tmpPtr;
486 newPtr(tmpPtr, dynamic_cast<const PlaneMoveManipulator *>(this), ~bFlags);
488 FieldContainerTransitPtr returnValue(tmpPtr);
490 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
492 return returnValue;
495 FieldContainerTransitPtr PlaneMoveManipulatorBase::shallowCopy(void) const
497 PlaneMoveManipulator *tmpPtr;
499 newPtr(tmpPtr,
500 dynamic_cast<const PlaneMoveManipulator *>(this),
501 Thread::getCurrentLocalFlags());
503 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
505 FieldContainerTransitPtr returnValue(tmpPtr);
507 return returnValue;
513 /*------------------------- constructors ----------------------------------*/
515 PlaneMoveManipulatorBase::PlaneMoveManipulatorBase(void) :
516 Inherited(),
517 _sfAxis (UInt16(1)),
518 _sfBaseTranslation (),
519 _sfBaseRotation (),
520 _sfClickPoint ()
524 PlaneMoveManipulatorBase::PlaneMoveManipulatorBase(const PlaneMoveManipulatorBase &source) :
525 Inherited(source),
526 _sfAxis (source._sfAxis ),
527 _sfBaseTranslation (source._sfBaseTranslation ),
528 _sfBaseRotation (source._sfBaseRotation ),
529 _sfClickPoint (source._sfClickPoint )
534 /*-------------------------- destructors ----------------------------------*/
536 PlaneMoveManipulatorBase::~PlaneMoveManipulatorBase(void)
541 GetFieldHandlePtr PlaneMoveManipulatorBase::getHandleAxis (void) const
543 SFUInt16::GetHandlePtr returnValue(
544 new SFUInt16::GetHandle(
545 &_sfAxis,
546 this->getType().getFieldDesc(AxisFieldId),
547 const_cast<PlaneMoveManipulatorBase *>(this)));
549 return returnValue;
552 EditFieldHandlePtr PlaneMoveManipulatorBase::editHandleAxis (void)
554 SFUInt16::EditHandlePtr returnValue(
555 new SFUInt16::EditHandle(
556 &_sfAxis,
557 this->getType().getFieldDesc(AxisFieldId),
558 this));
561 editSField(AxisFieldMask);
563 return returnValue;
566 GetFieldHandlePtr PlaneMoveManipulatorBase::getHandleBaseTranslation (void) const
568 SFVec3f::GetHandlePtr returnValue(
569 new SFVec3f::GetHandle(
570 &_sfBaseTranslation,
571 this->getType().getFieldDesc(BaseTranslationFieldId),
572 const_cast<PlaneMoveManipulatorBase *>(this)));
574 return returnValue;
577 EditFieldHandlePtr PlaneMoveManipulatorBase::editHandleBaseTranslation(void)
579 SFVec3f::EditHandlePtr returnValue(
580 new SFVec3f::EditHandle(
581 &_sfBaseTranslation,
582 this->getType().getFieldDesc(BaseTranslationFieldId),
583 this));
586 editSField(BaseTranslationFieldMask);
588 return returnValue;
591 GetFieldHandlePtr PlaneMoveManipulatorBase::getHandleBaseRotation (void) const
593 SFQuaternion::GetHandlePtr returnValue(
594 new SFQuaternion::GetHandle(
595 &_sfBaseRotation,
596 this->getType().getFieldDesc(BaseRotationFieldId),
597 const_cast<PlaneMoveManipulatorBase *>(this)));
599 return returnValue;
602 EditFieldHandlePtr PlaneMoveManipulatorBase::editHandleBaseRotation (void)
604 SFQuaternion::EditHandlePtr returnValue(
605 new SFQuaternion::EditHandle(
606 &_sfBaseRotation,
607 this->getType().getFieldDesc(BaseRotationFieldId),
608 this));
611 editSField(BaseRotationFieldMask);
613 return returnValue;
616 GetFieldHandlePtr PlaneMoveManipulatorBase::getHandleClickPoint (void) const
618 SFPnt3f::GetHandlePtr returnValue(
619 new SFPnt3f::GetHandle(
620 &_sfClickPoint,
621 this->getType().getFieldDesc(ClickPointFieldId),
622 const_cast<PlaneMoveManipulatorBase *>(this)));
624 return returnValue;
627 EditFieldHandlePtr PlaneMoveManipulatorBase::editHandleClickPoint (void)
629 SFPnt3f::EditHandlePtr returnValue(
630 new SFPnt3f::EditHandle(
631 &_sfClickPoint,
632 this->getType().getFieldDesc(ClickPointFieldId),
633 this));
636 editSField(ClickPointFieldMask);
638 return returnValue;
642 #ifdef OSG_MT_CPTR_ASPECT
643 void PlaneMoveManipulatorBase::execSyncV( FieldContainer &oFrom,
644 ConstFieldMaskArg whichField,
645 AspectOffsetStore &oOffsets,
646 ConstFieldMaskArg syncMode,
647 const UInt32 uiSyncInfo)
649 PlaneMoveManipulator *pThis = static_cast<PlaneMoveManipulator *>(this);
651 pThis->execSync(static_cast<PlaneMoveManipulator *>(&oFrom),
652 whichField,
653 oOffsets,
654 syncMode,
655 uiSyncInfo);
657 #endif
660 #ifdef OSG_MT_CPTR_ASPECT
661 FieldContainer *PlaneMoveManipulatorBase::createAspectCopy(
662 const FieldContainer *pRefAspect) const
664 PlaneMoveManipulator *returnValue;
666 newAspectCopy(returnValue,
667 dynamic_cast<const PlaneMoveManipulator *>(pRefAspect),
668 dynamic_cast<const PlaneMoveManipulator *>(this));
670 return returnValue;
672 #endif
674 void PlaneMoveManipulatorBase::resolveLinks(void)
676 Inherited::resolveLinks();
682 OSG_END_NAMESPACE