Debian Codegraph @

src/Gui/Inventor/Draggers/SoRotationDragger.h

raw
1 /***************************************************************************
2 * Copyright (c) 2015 Thomas Anderson <blobfish[at]gmx.com> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23 #ifndef GUI_ROTATION_DRAGGER_H
24 #define GUI_ROTATION_DRAGGER_H
25
26 #include <Inventor/draggers/SoDragger.h>
27 #include <Inventor/fields/SoSFColor.h>
28 #include <Inventor/fields/SoSFDouble.h>
29 #include <Inventor/fields/SoSFInt32.h>
30 #include <Inventor/fields/SoSFRotation.h>
31 #include <Inventor/projectors/SbPlaneProjector.h>
32
33 #include <FCGlobal.h>
34
35 class SoTransform;
36 class SoCoordinate3;
37 class SoBaseColor;
38 class SoSensor;
39
40 namespace Gui
41 {
42 /*! @brief Rotation Dragger.
43 *
44 * used for rotating around an axis. Set the rotation
45 * increment to desired step. Use rotationIncrementCount
46 * multiplied with rotationIncrement for full double
47 * precision vector scalar.
48 */
49 class GuiExport SoRotationDragger: public SoDragger
50 {
51 SO_KIT_HEADER(SoRotationDragger);
52 SO_KIT_CATALOG_ENTRY_HEADER(baseGeomSwitch);
53 SO_KIT_CATALOG_ENTRY_HEADER(baseGeom);
54 SO_KIT_CATALOG_ENTRY_HEADER(baseColor);
55 SO_KIT_CATALOG_ENTRY_HEADER(activeSwitch);
56 SO_KIT_CATALOG_ENTRY_HEADER(secondaryColor);
57 SO_KIT_CATALOG_ENTRY_HEADER(scale);
58 SO_KIT_CATALOG_ENTRY_HEADER(rotator);
59
60 public:
61 static void initClass();
62 SoRotationDragger();
63
64 SoSFRotation rotation; //!< set from outside and used from outside for single precision.
65 SoSFDouble rotationIncrement; //!< set from outside and used for rounding.
66 SoSFInt32 rotationIncrementCount; //!< number of steps. used from outside.
67 SoSFColor color; //!< colour of the dragger
68 SoSFColor activeColor; //!< colour of the dragger while being dragged.
69 SoSFVec3f geometryScale; //!< the scale of the dragger geometry
70 SoSFBool active; //!< set when the dragger is being dragged
71 SoSFBool baseGeomVisible; //!< toggles if the dragger has a base geometry or not
72
73 void instantiateBaseGeometry();
74
75 protected:
76 ~SoRotationDragger() override;
77 SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE) override;
78
79 static void startCB(void*, SoDragger* d);
80 static void motionCB(void*, SoDragger* d);
81 static void finishCB(void*, SoDragger* d);
82 static void fieldSensorCB(void* f, SoSensor*);
83 static void valueChangedCB(void*, SoDragger* d);
84
85 void dragStart();
86 void drag();
87 void dragFinish();
88
89 SoFieldSensor fieldSensor;
90 SbPlaneProjector projector;
91
92 private:
93 int roundIncrement(const float& radiansIn);
94 SoBaseColor* buildActiveColor();
95 SoBaseColor* buildColor();
96
97 using inherited = SoDragger;
98 };
99
100 class GuiExport SoRotationDraggerContainer: public SoInteractionKit
101 {
102 SO_KIT_HEADER(SoRotationDraggerContainer);
103 SO_KIT_CATALOG_ENTRY_HEADER(draggerSwitch);
104 SO_KIT_CATALOG_ENTRY_HEADER(transform);
105 SO_KIT_CATALOG_ENTRY_HEADER(dragger);
106
107 public:
108 static void initClass();
109 SoRotationDraggerContainer();
110
111 SoSFRotation rotation;
112 SoSFColor color;
113 SoSFVec3f translation;
114 SoSFBool visible;
115
116 SbVec3f getPointerDirection();
117 void setPointerDirection(const SbVec3f& dir);
118 void setArcNormalDirection(const SbVec3f& dir);
119
120 SoRotationDragger* getDragger();
121
122 private:
123 SoTransform* buildTransform();
124
125 using inherited = SoInteractionKit;
126 };
127
128 } // namespace Gui
129
130 #endif /* GUI_ROTATION_DRAGGER_H */