Debian Codegraph @

src/Gui/Selection/SoFCSelection.h

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /***************************************************************************
3 * Copyright (c) 2005 Jürgen Riegel <[email protected]> *
4 * *
5 * This file is part of the FreeCAD CAx development system. *
6 * *
7 * This library is free software; you can redistribute it and/or *
8 * modify it under the terms of the GNU Library General Public *
9 * License as published by the Free Software Foundation; either *
10 * version 2 of the License, or (at your option) any later version. *
11 * *
12 * This library is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU Library General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Library General Public *
18 * License along with this library; see the file COPYING.LIB. If not, *
19 * write to the Free Software Foundation, Inc., 59 Temple Place, *
20 * Suite 330, Boston, MA 02111-1307, USA *
21 * *
22 ***************************************************************************/
23
24 #ifndef GUI_SOFCSELECTION_H
25 #define GUI_SOFCSELECTION_H
26
27 #include <FCConfig.h>
28
29 #ifdef FC_OS_MACOSX
30 # include <OpenGL/gl.h>
31 #else
32 # ifdef FC_OS_WIN32
33 # include <windows.h>
34 # endif
35 # include <GL/gl.h>
36 #endif
37
38 #include <Inventor/elements/SoLazyElement.h>
39 #include <Inventor/fields/SoSFBool.h>
40 #include <Inventor/fields/SoSFColor.h>
41 #include <Inventor/fields/SoSFEnum.h>
42 #include <Inventor/fields/SoSFString.h>
43 #include <Inventor/nodes/SoGroup.h>
44
45 #include "SoFCSelectionContext.h"
46
47
48 class SoFullPath;
49 class SoPickedPoint;
50
51
52 namespace Gui
53 {
54
55
56 /** Selection node
57 * This node does the complete highlighting and selection together with the viewer
58 * \author Jürgen Riegel
59 */
60 class GuiExport SoFCSelection: public SoGroup
61 {
62 using inherited = SoGroup;
63
64 SO_NODE_HEADER(Gui::SoFCSelection);
65
66 public:
67 static void initClass();
68 static void finish();
69 SoFCSelection();
70
71 /// Load highlight settings from the configuration
72 void applySettings();
73
74 enum PreselectionModes
75 {
76 AUTO,
77 ON,
78 OFF
79 };
80
81 enum SelectionModes
82 {
83 SEL_ON,
84 SEL_OFF
85 };
86
87 enum Selected
88 {
89 NOTSELECTED,
90 SELECTED
91 };
92
93 enum Styles
94 {
95 EMISSIVE,
96 EMISSIVE_DIFFUSE,
97 BOX
98 };
99
100 SbBool isHighlighted() const
101 {
102 return highlighted;
103 }
104
105 SoSFColor colorHighlight;
106 SoSFColor colorSelection;
107 SoSFEnum style;
108 SoSFEnum selected;
109 SoSFEnum preselectionMode;
110 SoSFEnum selectionMode;
111
112 SoSFString documentName;
113 SoSFString objectName;
114 SoSFString subElementName;
115 SoSFBool useNewSelection;
116
117 void doAction(SoAction* action) override;
118 void GLRender(SoGLRenderAction* action) override;
119
120 void handleEvent(SoHandleEventAction* action) override;
121 void GLRenderBelowPath(SoGLRenderAction* action) override;
122 void GLRenderInPath(SoGLRenderAction* action) override;
123 static void turnOffCurrentHighlight(SoGLRenderAction* action);
124
125 protected:
126 ~SoFCSelection() override;
127
128 using SelContext = SoFCSelectionContext;
129 using SelContextPtr = std::shared_ptr<SelContext>;
130 SelContextPtr selContext;
131 SelContextPtr selContext2;
132
133 virtual void redrawHighlighted(SoAction* act, SbBool flag);
134
135 SbBool readInstance(SoInput* in, unsigned short flags) override;
136
137 private:
138 static int getPriority(const SoPickedPoint*);
139 static void turnoffcurrent(SoAction* action);
140 bool setOverride(SoGLRenderAction* action, SelContextPtr);
141 SbBool isHighlighted(SoAction* action);
142 SbBool preRender(SoGLRenderAction* act, GLint& oldDepthFunc);
143 const SoPickedPoint* getPickedPoint(SoHandleEventAction*) const;
144
145 static SoFullPath* currenthighlight;
146
147 SbBool highlighted;
148 SoColorPacker colorpacker;
149
150 SbBool bShift;
151 SbBool bCtrl;
152 };
153
154
155 } // namespace Gui
156
157 #endif // !GUI_SOFCSELECTION_H