Debian Codegraph @

src/Gui/Inventor/Draggers/SoRotationDraggerGeometry.h

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /****************************************************************************
3 * *
4 * Copyright (c) 2025 Sayantan Deb <sayantandebin[at]gmail.com> *
5 * *
6 * This file is part of FreeCAD. *
7 * *
8 * FreeCAD is free software: you can redistribute it and/or modify it *
9 * under the terms of the GNU Lesser General Public License as *
10 * published by the Free Software Foundation, either version 2.1 of the *
11 * License, or (at your option) any later version. *
12 * *
13 * FreeCAD is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with FreeCAD. If not, see *
20 * <https://www.gnu.org/licenses/>. *
21 * *
22 ***************************************************************************/
23
24 #ifndef GUI_ROTATION_DRAGGER_GEOMETRY_H
25 #define GUI_ROTATION_DRAGGER_GEOMETRY_H
26
27 #include <Inventor/fields/SoSFBool.h>
28 #include <Inventor/fields/SoSFColor.h>
29 #include <Inventor/fields/SoSFFloat.h>
30 #include <Inventor/fields/SoSFRotation.h>
31 #include <Inventor/fields/SoSFVec3f.h>
32 #include <Inventor/nodekits/SoBaseKit.h>
33 #include <Inventor/nodekits/SoSubKit.h>
34
35 #include <FCGlobal.h>
36
37 namespace Gui
38 {
39
40 class GuiExport SoRotatorGeometryKit: public SoBaseKit
41 {
42 SO_KIT_HEADER(SoLinearGeometryKit);
43
44 public:
45 static void initClass();
46
47 SoSFVec3f pivotPosition;
48 SoSFVec3f geometryScale;
49
50 protected:
51 SoRotatorGeometryKit();
52 ~SoRotatorGeometryKit() override = default;
53
54 private:
55 using inherited = SoBaseKit;
56 };
57
58 class GuiExport SoRotatorGeometry: public SoRotatorGeometryKit
59 {
60 SO_KIT_HEADER(SoRotatorGeometry);
61 SO_KIT_CATALOG_ENTRY_HEADER(separator);
62 SO_KIT_CATALOG_ENTRY_HEADER(lightModel);
63 SO_KIT_CATALOG_ENTRY_HEADER(pickStyle);
64 SO_KIT_CATALOG_ENTRY_HEADER(drawStyle);
65 SO_KIT_CATALOG_ENTRY_HEADER(arcCoords);
66 SO_KIT_CATALOG_ENTRY_HEADER(arc);
67 SO_KIT_CATALOG_ENTRY_HEADER(pivotSeparator);
68 SO_KIT_CATALOG_ENTRY_HEADER(rotorPivot);
69
70 SO_KIT_CATALOG_ENTRY_HEADER(_rotorPivotTranslation);
71
72 public:
73 static void initClass();
74 SoRotatorGeometry();
75
76 SoSFFloat arcAngle; //!< in radians
77 SoSFFloat arcRadius;
78 SoSFFloat sphereRadius;
79 SoSFFloat arcThickness;
80
81 protected:
82 ~SoRotatorGeometry() override = default;
83
84 void notify(SoNotList* notList) override;
85
86 private:
87 constexpr static int segments = 10; //!< segments of the arc per arcAngle
88
89 using inherited = SoRotatorGeometryKit;
90 };
91
92 class GuiExport SoRotatorGeometry2: public SoRotatorGeometry
93 {
94 SO_KIT_HEADER(SoRotatorGeometry2);
95 SO_KIT_CATALOG_ENTRY_HEADER(leftArrowSwitch);
96 SO_KIT_CATALOG_ENTRY_HEADER(leftArrowSeparator);
97 SO_KIT_CATALOG_ENTRY_HEADER(leftArrowTransform);
98 SO_KIT_CATALOG_ENTRY_HEADER(leftArrow);
99 SO_KIT_CATALOG_ENTRY_HEADER(rightArrowSwitch);
100 SO_KIT_CATALOG_ENTRY_HEADER(rightArrowSeparator);
101 SO_KIT_CATALOG_ENTRY_HEADER(rightArrowTransform);
102 SO_KIT_CATALOG_ENTRY_HEADER(rightArrow);
103
104 public:
105 static void initClass();
106 SoRotatorGeometry2();
107
108 SoSFFloat coneBottomRadius;
109 SoSFFloat coneHeight;
110 SoSFBool leftArrowVisible;
111 SoSFBool rightArrowVisible;
112
113 void toggleArrowVisibility();
114
115 protected:
116 ~SoRotatorGeometry2() override = default;
117
118 void notify(SoNotList* notList) override;
119
120 private:
121 constexpr static int segments = 10; //!< segments of the arc per arcAngle
122
123 using inherited = SoRotatorGeometry;
124 };
125
126 class GuiExport SoRotatorArrow: public SoRotatorGeometryKit
127 {
128 SO_KIT_HEADER(SoRotatorArrow);
129 SO_KIT_CATALOG_ENTRY_HEADER(separator);
130 SO_KIT_CATALOG_ENTRY_HEADER(lightModel);
131 SO_KIT_CATALOG_ENTRY_HEADER(pickStyle);
132 SO_KIT_CATALOG_ENTRY_HEADER(arrowBody);
133 SO_KIT_CATALOG_ENTRY_HEADER(arrowTip);
134
135 SO_KIT_CATALOG_ENTRY_HEADER(_arrowTransform);
136 SO_KIT_CATALOG_ENTRY_HEADER(_arrowBodyTranslation);
137 SO_KIT_CATALOG_ENTRY_HEADER(_arrowTipTranslation);
138
139 public:
140 static void initClass();
141 SoRotatorArrow();
142
143 SoSFFloat coneBottomRadius;
144 SoSFFloat coneHeight;
145 SoSFFloat cylinderHeight;
146 SoSFFloat cylinderRadius;
147 SoSFFloat radius;
148 SoSFFloat minRadius;
149
150 void flipArrow();
151
152 protected:
153 ~SoRotatorArrow() override = default;
154
155 void notify(SoNotList* notList) override;
156
157 private:
158 constexpr static int segments = 10; //!< segments of the arc per arcAngle
159
160 using inherited = SoRotatorGeometryKit;
161 };
162
163 class GuiExport SoRotatorGeometryBaseKit: public SoBaseKit
164 {
165 SO_KIT_HEADER(SoRotatorGeometryBaseKit);
166
167 public:
168 static void initClass();
169
170 SoSFRotation rotation; //!< set from the parent dragger
171 SoSFVec3f geometryScale; //!< set from the parent dragger
172 SoSFBool active; //!< set from the parent dragger
173
174 protected:
175 SoRotatorGeometryBaseKit();
176 ~SoRotatorGeometryBaseKit() override = default;
177
178 private:
179 using inherited = SoBaseKit;
180 };
181
182 class GuiExport SoRotatorBase: public SoRotatorGeometryBaseKit
183 {
184 SO_KIT_HEADER(SoArrowBase);
185 SO_KIT_CATALOG_ENTRY_HEADER(separator);
186 SO_KIT_CATALOG_ENTRY_HEADER(lightModel);
187 SO_KIT_CATALOG_ENTRY_HEADER(pickStyle);
188 SO_KIT_CATALOG_ENTRY_HEADER(baseColor);
189 SO_KIT_CATALOG_ENTRY_HEADER(drawStyle);
190 SO_KIT_CATALOG_ENTRY_HEADER(arcCoords);
191 SO_KIT_CATALOG_ENTRY_HEADER(arc);
192
193 public:
194 static void initClass();
195 SoRotatorBase();
196
197 SoSFFloat arcRadius;
198 SoSFFloat minArcRadius;
199 SoSFFloat arcThickness;
200 SoSFColor color;
201
202 protected:
203 ~SoRotatorBase() override = default;
204
205 void notify(SoNotList* notList) override;
206
207 private:
208 constexpr static int segments = 50; //!< segments of the arc per arcAngle
209
210 using inherited = SoRotatorGeometryBaseKit;
211 };
212
213 } // namespace Gui
214
215 #endif /* GUI_ROTATION_DRAGGER_GEOMETRY_H */