Debian Codegraph @

src/Gui/AxisOrigin.h

raw
1 /****************************************************************************
2 * Copyright (c) 2019 Zheng Lei (realthunder) <[email protected]> *
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_AxisOrigin_H
24 #define GUI_AxisOrigin_H
25
26 #include "ViewProvider.h"
27
28 namespace Gui
29 {
30
31 /// A class to create a Coin3D node representation of an coordinate system
32 class GuiExport AxisOrigin: public Base::BaseClass
33 {
34 TYPESYSTEM_HEADER();
35
36 public:
37 AxisOrigin();
38
39 /// Set axis line width
40 void setLineWidth(float size);
41
42 /// Get axis line width
43 float getLineWidth() const
44 {
45 return lineSize;
46 }
47
48 /// Set origin point size
49 void setPointSize(float size);
50
51 /// Get origin point size
52 float getPointSize() const
53 {
54 return pointSize;
55 }
56
57 /// Set the axis line length
58 void setAxisLength(float size);
59
60 /// Get axis base line length
61 float getAxisLength() const
62 {
63 return size;
64 }
65
66 /// Set the origin plane size and distance from the axis
67 void setPlane(float size, float dist);
68
69 /// Get the origin plane size and distance from the axis
70 std::pair<float, float> getPlane() const
71 {
72 return std::make_pair(pSize, dist);
73 }
74
75 /// Set the auto scale factor, 0 to disable it
76 void setScale(float scale);
77
78 /// Get the auto scale factor
79 float getScale() const
80 {
81 return scale;
82 }
83
84 /** Set customized names for axis components
85 *
86 * @param labels: the input names. Available keys are, O: origin,
87 * X: x axis, Y: y axis, Z: z axis, XY: XY plane,
88 * XZ: XY plane, YZ: YZ plane
89 *
90 * There are default labels for all components. You can also use
91 * this function to choose which components are hidden, by not
92 * include the key in the input labels.
93 */
94 void setLabels(const std::map<std::string, std::string>& labels);
95
96 /// Obtain the axis component names
97 const std::map<std::string, std::string>& getLabels() const
98 {
99 return labels;
100 }
101
102 /// Obtain the constructed Coin3D representation
103 SoGroup* getNode();
104
105 /** Return the name of picked element
106 * @sa ViewProvider::getElementPicked()
107 */
108 bool getElementPicked(const SoPickedPoint* pp, std::string& subname) const;
109
110 /** Return the coin path of a named element
111 * @sa ViewProvider::getDetailPath()
112 */
113 bool getDetailPath(const char* subname, SoFullPath* pPath, SoDetail*& det) const;
114
115 private:
116 float size = 6;
117 float pSize = 4;
118 float dist = 2;
119 float scale = 1;
120 float lineSize = 2;
121 float pointSize = 4;
122 std::map<std::string, std::string> labels;
123 CoinPtr<SoGroup> node;
124 std::map<std::string, CoinPtr<SoNode>> nodeMap;
125 };
126
127 } // namespace Gui
128
129 #endif // GUI_AxisOrigin_H