Debian Codegraph @

src/Gui/Selection/SoFCSelectionAction.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 _SoFCSelectionAction_h
25 #define _SoFCSelectionAction_h
26
27 #include <Inventor/SbColor.h>
28 #include <Inventor/actions/SoGLRenderAction.h>
29 #include <Inventor/fields/SoSFColor.h>
30 #include <Inventor/fields/SoSFString.h>
31 #include <vector>
32 #include <FCGlobal.h>
33
34 class SoSFString;
35 class SoSFColor;
36
37 namespace Gui
38 {
39
40 class SelectionChanges;
41
42 /**
43 * The SoFCPreselectionAction class is used to inform an SoFCSelection node
44 * whether an object gets preselected.
45 * @author Jürgen Riegel
46 */
47 class GuiExport SoFCPreselectionAction: public SoAction
48 {
49 SO_ACTION_HEADER(SoFCPreselectionAction);
50
51 public:
52 SoFCPreselectionAction(const SelectionChanges& SelCh);
53 ~SoFCPreselectionAction() override;
54
55 static void initClass();
56 static void finish();
57
58 const SelectionChanges& SelChange;
59
60 protected:
61 void beginTraversal(SoNode* node) override;
62
63 private:
64 static void callDoAction(SoAction* action, SoNode* node);
65 };
66
67 /**
68 * The SoFCSelectionAction class is used to inform an SoFCSelection node
69 * whether an object gets selected.
70 * @author Jürgen Riegel
71 */
72 class GuiExport SoFCSelectionAction: public SoAction
73 {
74 SO_ACTION_HEADER(SoFCSelectionAction);
75
76 public:
77 SoFCSelectionAction(const SelectionChanges& SelCh);
78 ~SoFCSelectionAction() override;
79
80 static void initClass();
81 static void finish();
82
83 const SelectionChanges& SelChange;
84
85 protected:
86 void beginTraversal(SoNode* node) override;
87
88 private:
89 static void callDoAction(SoAction* action, SoNode* node);
90 };
91
92 /**
93 * The SoFCEnableSelectionAction class is used to inform an SoFCSelection node
94 * whether selection is enabled or disabled.
95 * @author Werner Mayer
96 */
97 class GuiExport SoFCEnableSelectionAction: public SoAction
98 {
99 SO_ACTION_HEADER(SoFCEnableSelectionAction);
100
101 public:
102 SoFCEnableSelectionAction(const SbBool& sel);
103 ~SoFCEnableSelectionAction() override;
104
105 SbBool enabled;
106
107 static void initClass();
108 static void finish();
109
110 protected:
111 void beginTraversal(SoNode* node) override;
112
113 private:
114 static void callDoAction(SoAction* action, SoNode* node);
115 };
116
117 /**
118 * The SoFCEnablePreselectionAction class is used to inform an SoFCSelection node
119 * whether preselection is enabled or disabled.
120 * @author Werner Mayer
121 */
122 class GuiExport SoFCEnablePreselectionAction: public SoAction
123 {
124 SO_ACTION_HEADER(SoFCEnablePreselectionAction);
125
126 public:
127 SoFCEnablePreselectionAction(const SbBool& sel);
128 ~SoFCEnablePreselectionAction() override;
129
130 SbBool enabled;
131
132 static void initClass();
133 static void finish();
134
135 protected:
136 void beginTraversal(SoNode* node) override;
137
138 private:
139 static void callDoAction(SoAction* action, SoNode* node);
140 };
141
142 /**
143 * The SoFCSelectionColorAction class is used to inform an SoFCSelection node
144 * which selection color is used.
145 * @author Werner Mayer
146 */
147 class GuiExport SoFCSelectionColorAction: public SoAction
148 {
149 SO_ACTION_HEADER(SoFCSelectionColorAction);
150
151 public:
152 SoFCSelectionColorAction(const SoSFColor& col);
153 ~SoFCSelectionColorAction() override;
154
155 SoSFColor selectionColor;
156
157 static void initClass();
158 static void finish();
159
160 protected:
161 void beginTraversal(SoNode* node) override;
162
163 private:
164 static void callDoAction(SoAction* action, SoNode* node);
165 };
166
167 /**
168 * The SoFCHighlightColorAction class is used to inform an SoFCSelection node
169 * which highlight color is used.
170 * @author Werner Mayer
171 */
172 class GuiExport SoFCHighlightColorAction: public SoAction
173 {
174 SO_ACTION_HEADER(SoFCHighlightColorAction);
175
176 public:
177 SoFCHighlightColorAction(const SoSFColor& col);
178 ~SoFCHighlightColorAction() override;
179
180 SoSFColor highlightColor;
181
182 static void initClass();
183 static void finish();
184
185 protected:
186 void beginTraversal(SoNode* node) override;
187
188 private:
189 static void callDoAction(SoAction* action, SoNode* node);
190 };
191
192 /**
193 * The SoFCDocumentAction class is used to inform an SoFCSelection node
194 * when a document has been renamed.
195 * @author Werner Mayer
196 */
197 class GuiExport SoFCDocumentAction: public SoAction
198 {
199 SO_ACTION_HEADER(SoFCDocumentAction);
200
201 public:
202 SoFCDocumentAction(const SoSFString& docName);
203 ~SoFCDocumentAction() override;
204
205 SoSFString documentName;
206
207 static void initClass();
208 static void finish();
209
210 protected:
211 void beginTraversal(SoNode* node) override;
212
213 private:
214 static void callDoAction(SoAction* action, SoNode* node);
215 };
216
217 /**
218 * The SoFCDocumentObjectAction class is used to get the name of the document,
219 * object and component at a certain position of an SoFCSelection node.
220 * @author Werner Mayer
221 */
222 class GuiExport SoFCDocumentObjectAction: public SoAction
223 {
224 SO_ACTION_HEADER(SoFCDocumentObjectAction);
225
226 public:
227 SoFCDocumentObjectAction();
228 ~SoFCDocumentObjectAction() override;
229
230 void setHandled();
231 SbBool isHandled() const;
232
233 static void initClass();
234 static void finish();
235
236 protected:
237 void beginTraversal(SoNode* node) override;
238
239 private:
240 static void callDoAction(SoAction* action, SoNode* node);
241
242 public:
243 SbString documentName;
244 SbString objectName;
245 SbString componentName;
246
247 private:
248 SbBool _handled {false};
249 };
250
251 /**
252 * The SoGLSelectAction class is used to get all data under a selected area.
253 * @author Werner Mayer
254 */
255 class GuiExport SoGLSelectAction: public SoAction
256 {
257 SO_ACTION_HEADER(SoGLSelectAction);
258
259 public:
260 SoGLSelectAction(const SbViewportRegion& region, const SbViewportRegion& select);
261 ~SoGLSelectAction() override;
262
263 void setHandled();
264 SbBool isHandled() const;
265 const SbViewportRegion& getViewportRegion() const;
266
267 static void initClass();
268
269 protected:
270 void beginTraversal(SoNode* node) override;
271
272 private:
273 static void callDoAction(SoAction* action, SoNode* node);
274
275 public:
276 std::vector<unsigned long> indices;
277
278 private:
279 const SbViewportRegion& vpregion;
280 const SbViewportRegion& vpselect;
281 SbBool _handled {false};
282 };
283
284 /**
285 * @author Werner Mayer
286 */
287 class GuiExport SoVisibleFaceAction: public SoAction
288 {
289 SO_ACTION_HEADER(SoVisibleFaceAction);
290
291 public:
292 SoVisibleFaceAction();
293 ~SoVisibleFaceAction() override;
294
295 void setHandled();
296 SbBool isHandled() const;
297
298 static void initClass();
299
300 protected:
301 void beginTraversal(SoNode* node) override;
302
303 private:
304 static void callDoAction(SoAction* action, SoNode* node);
305
306 private:
307 SbBool _handled {false};
308 };
309
310 class SoBoxSelectionRenderActionP;
311 /**
312 * The SoBoxSelectionRenderAction class renders the scene with highlighted boxes around selections.
313 * @author Werner Mayer
314 */
315 class GuiExport SoBoxSelectionRenderAction: public SoGLRenderAction
316 {
317 using inherited = SoGLRenderAction;
318
319 SO_ACTION_HEADER(SoBoxSelectionRenderAction);
320
321 public:
322 SoBoxSelectionRenderAction();
323 SoBoxSelectionRenderAction(const SbViewportRegion& viewportregion);
324 ~SoBoxSelectionRenderAction() override;
325
326 static void initClass();
327
328 void apply(SoNode* node) override;
329 void apply(SoPath* path) override;
330 void apply(const SoPathList& pathlist, SbBool obeysrules = false) override;
331 void setVisible(SbBool b)
332 {
333 hlVisible = b;
334 }
335 SbBool isVisible() const
336 {
337 return hlVisible;
338 }
339 void setColor(const SbColor& color);
340 const SbColor& getColor();
341 void setLinePattern(unsigned short pattern);
342 unsigned short getLinePattern() const;
343 void setLineWidth(const float width);
344 float getLineWidth() const;
345
346 protected:
347 SbBool hlVisible;
348
349 private:
350 void constructorCommon();
351 void drawBoxes(SoPath* pathtothis, const SoPathList* pathlist);
352
353 SoBoxSelectionRenderActionP* pimpl;
354 };
355
356 /**
357 * Helper class no notify nodes to update VBO.
358 * @author Werner Mayer
359 */
360 class GuiExport SoUpdateVBOAction: public SoAction
361 {
362 SO_ACTION_HEADER(SoUpdateVBOAction);
363
364 public:
365 SoUpdateVBOAction();
366 ~SoUpdateVBOAction() override;
367
368 static void initClass();
369 static void finish();
370
371 protected:
372 void beginTraversal(SoNode* node) override;
373
374 private:
375 static void callDoAction(SoAction* action, SoNode* node);
376 };
377
378 } // namespace Gui
379
380
381 #endif // _SoFCSelectionAction_h