Debian Codegraph @

src/Gui/Inventor/SoFCPlacementIndicatorKit.h

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /****************************************************************************
3 * *
4 * Copyright (c) 2024 Kacper Donat <[email protected]> *
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 SOFCPLACEMENTINDICATORKIT_H
25 #define SOFCPLACEMENTINDICATORKIT_H
26
27 #include <Inventor/nodekits/SoBaseKit.h>
28
29 #include <Inventor/fields/SoSFBool.h>
30 #include <Inventor/fields/SoSFEnum.h>
31 #include <Inventor/fields/SoSFFloat.h>
32
33 #include <FCGlobal.h>
34
35 namespace Gui
36 {
37
38 class GuiExport SoFCPlacementIndicatorKit: public SoBaseKit
39 {
40 using inherited = SoBaseKit;
41
42 static constexpr float planeIndicatorRadius = 0.4F;
43 static constexpr double planeIndicatorMargin = 0.2;
44 static constexpr float planeIndicatorTransparency = 0.3F;
45
46 static constexpr double axisMargin = 0.0;
47 static constexpr float axisLengthDefault = 0.6F;
48 static constexpr float axisThickness = 0.065F;
49
50 static constexpr float arrowHeadRadius = axisThickness * 1.25F;
51 static constexpr float arrowHeadHeight = arrowHeadRadius * 3.F;
52
53 static constexpr double labelOffset = 0.4;
54 static constexpr int labelFontSize = 9;
55
56 static constexpr float scaleFactorDefault = 40.F;
57
58 SO_KIT_HEADER(SoFCPlacementIndicatorKit);
59
60 SO_KIT_CATALOG_ENTRY_HEADER(root);
61
62 public:
63 SoFCPlacementIndicatorKit();
64 static void initClass();
65
66 void notify(SoNotList* l) override;
67
68 // clang-format off
69 enum Part
70 {
71 Axes = 1 << 0,
72 ArrowHeads = 1 << 1,
73 Labels = 1 << 2,
74 PlaneIndicator = 1 << 3,
75 OriginIndicator = 1 << 4,
76
77 // common configurations
78 AllParts = Axes | OriginIndicator | Labels | ArrowHeads,
79 AxisCross = Axes | Labels | ArrowHeads
80 };
81
82 enum Axis
83 {
84 X = 1 << 0,
85 Y = 1 << 1,
86 Z = 1 << 2,
87 AllAxes = X | Y | Z
88 };
89 // clang-format on
90
91 SoSFEnum parts;
92 SoSFEnum axes;
93 SoSFBool coloredAxis;
94 SoSFFloat scaleFactor;
95 SoSFFloat axisLength;
96
97 private:
98 void recomputeGeometry();
99
100 SoSeparator* createOriginIndicator();
101 SoSeparator* createGeometry();
102 SoSeparator* createAxes();
103 SoSeparator* createPlaneIndicator();
104
105 ~SoFCPlacementIndicatorKit() override;
106 };
107
108 } // namespace Gui
109
110 #endif // SOFCPLACEMENTINDICATORKIT_H