1
/***************************************************************************
2
* Copyright (c) 2005 Jürgen Riegel <juergen.riegel@web.de> *
4
* This file is part of the FreeCAD CAx development system. *
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. *
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. *
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 *
21
***************************************************************************/
23
#include "PreCompiled.h"
26
# include <Inventor/actions/SoSearchAction.h>
27
# include <Inventor/actions/SoGetBoundingBoxAction.h>
28
# include <Inventor/elements/SoComplexityElement.h>
29
# include <Inventor/elements/SoComplexityTypeElement.h>
30
# include <Inventor/elements/SoCoordinateElement.h>
31
# include <Inventor/elements/SoFontNameElement.h>
32
# include <Inventor/elements/SoFontSizeElement.h>
33
# include <Inventor/elements/SoModelMatrixElement.h>
34
# include <Inventor/elements/SoProfileCoordinateElement.h>
35
# include <Inventor/elements/SoProfileElement.h>
36
# include <Inventor/elements/SoProjectionMatrixElement.h>
37
# include <Inventor/elements/SoShapeStyleElement.h>
38
# include <Inventor/elements/SoSwitchElement.h>
39
# include <Inventor/elements/SoUnitsElement.h>
40
# include <Inventor/elements/SoViewingMatrixElement.h>
41
# include <Inventor/elements/SoViewportRegionElement.h>
42
# include <Inventor/elements/SoViewVolumeElement.h>
43
# include <Inventor/nodes/SoBaseColor.h>
44
# include <Inventor/nodes/SoCallback.h>
45
# include <Inventor/nodes/SoCamera.h>
46
# include <Inventor/nodes/SoComplexity.h>
47
# include <Inventor/nodes/SoCoordinate3.h>
48
# include <Inventor/nodes/SoCoordinate4.h>
49
# include <Inventor/nodes/SoCube.h>
50
# include <Inventor/nodes/SoDrawStyle.h>
51
# include <Inventor/nodes/SoFont.h>
52
# include <Inventor/nodes/SoIndexedLineSet.h>
53
# include <Inventor/nodes/SoIndexedFaceSet.h>
54
# include <Inventor/nodes/SoLightModel.h>
55
# include <Inventor/nodes/SoMatrixTransform.h>
56
# include <Inventor/nodes/SoPointSet.h>
57
# include <Inventor/nodes/SoProfile.h>
58
# include <Inventor/nodes/SoProfileCoordinate2.h>
59
# include <Inventor/nodes/SoProfileCoordinate3.h>
60
# include <Inventor/nodes/SoSeparator.h>
61
# include <Inventor/nodes/SoSwitch.h>
62
# include <Inventor/nodes/SoTransformation.h>
65
#include "SoFCSelectionAction.h"
66
#include "SoFCSelection.h"
72
SO_ACTION_SOURCE(SoFCHighlightAction)
75
* The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base
76
* classes and afterwards subclasses of them must be listed, otherwise the registered methods
77
* of subclasses will be overridden. For more details see the thread in the Coin3d forum
78
* https://www.coin3d.org/pipermail/coin-discuss/2004-May/004346.html.
79
* This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after
80
* \c SoSeparator because both classes inherits the others.
82
void SoFCHighlightAction::initClass()
84
SO_ACTION_INIT_CLASS(SoFCHighlightAction,SoAction);
86
SO_ENABLE(SoFCHighlightAction, SoSwitchElement);
88
SO_ACTION_ADD_METHOD(SoNode,nullAction);
90
SO_ENABLE(SoFCHighlightAction, SoModelMatrixElement);
91
SO_ENABLE(SoFCHighlightAction, SoShapeStyleElement);
92
SO_ENABLE(SoFCHighlightAction, SoComplexityElement);
93
SO_ENABLE(SoFCHighlightAction, SoComplexityTypeElement);
94
SO_ENABLE(SoFCHighlightAction, SoCoordinateElement);
95
SO_ENABLE(SoFCHighlightAction, SoFontNameElement);
96
SO_ENABLE(SoFCHighlightAction, SoFontSizeElement);
97
SO_ENABLE(SoFCHighlightAction, SoProfileCoordinateElement);
98
SO_ENABLE(SoFCHighlightAction, SoProfileElement);
99
SO_ENABLE(SoFCHighlightAction, SoSwitchElement);
100
SO_ENABLE(SoFCHighlightAction, SoUnitsElement);
101
SO_ENABLE(SoFCHighlightAction, SoViewVolumeElement);
102
SO_ENABLE(SoFCHighlightAction, SoViewingMatrixElement);
103
SO_ENABLE(SoFCHighlightAction, SoViewportRegionElement);
108
SO_ACTION_ADD_METHOD(SoCallback,callDoAction);
109
SO_ACTION_ADD_METHOD(SoComplexity,callDoAction);
110
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
111
SO_ACTION_ADD_METHOD(SoCoordinate4,callDoAction);
112
SO_ACTION_ADD_METHOD(SoFont,callDoAction);
113
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
114
SO_ACTION_ADD_METHOD(SoProfile,callDoAction);
115
SO_ACTION_ADD_METHOD(SoProfileCoordinate2,callDoAction);
116
SO_ACTION_ADD_METHOD(SoProfileCoordinate3,callDoAction);
117
SO_ACTION_ADD_METHOD(SoTransformation,callDoAction);
118
SO_ACTION_ADD_METHOD(SoSwitch,callDoAction);
120
SO_ACTION_ADD_METHOD(SoSeparator,callDoAction);
121
SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction);
123
SO_ACTION_ADD_METHOD(SoIndexedLineSet,callDoAction);
124
SO_ACTION_ADD_METHOD(SoIndexedFaceSet,callDoAction);
125
SO_ACTION_ADD_METHOD(SoPointSet,callDoAction);
128
void SoFCHighlightAction::finish()
134
SoFCHighlightAction::SoFCHighlightAction (const SelectionChanges &SelCh)
137
SO_ACTION_CONSTRUCTOR(SoFCHighlightAction);
141
SoFCHighlightAction::~SoFCHighlightAction() = default;
144
void SoFCHighlightAction::beginTraversal(SoNode *node)
149
void SoFCHighlightAction::callDoAction(SoAction *action,SoNode *node)
151
node->doAction(action);
154
// ---------------------------------------------------------------
156
SO_ACTION_SOURCE(SoFCSelectionAction)
159
* The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base
160
* classes and afterwards subclasses of them must be listed, otherwise the registered methods
161
* of subclasses will be overridden. For more details see the thread in the Coin3d forum
162
* https://www.coin3d.org/pipermail/coin-discuss/2004-May/004346.html.
163
* This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after
164
* \c SoSeparator because both classes inherits the others.
166
void SoFCSelectionAction::initClass()
168
SO_ACTION_INIT_CLASS(SoFCSelectionAction,SoAction);
170
SO_ENABLE(SoFCSelectionAction, SoSwitchElement);
172
SO_ACTION_ADD_METHOD(SoNode,nullAction);
174
SO_ENABLE(SoFCSelectionAction, SoModelMatrixElement);
175
SO_ENABLE(SoFCSelectionAction, SoShapeStyleElement);
176
SO_ENABLE(SoFCSelectionAction, SoComplexityElement);
177
SO_ENABLE(SoFCSelectionAction, SoComplexityTypeElement);
178
SO_ENABLE(SoFCSelectionAction, SoCoordinateElement);
179
SO_ENABLE(SoFCSelectionAction, SoFontNameElement);
180
SO_ENABLE(SoFCSelectionAction, SoFontSizeElement);
181
SO_ENABLE(SoFCSelectionAction, SoProfileCoordinateElement);
182
SO_ENABLE(SoFCSelectionAction, SoProfileElement);
183
SO_ENABLE(SoFCSelectionAction, SoSwitchElement);
184
SO_ENABLE(SoFCSelectionAction, SoUnitsElement);
185
SO_ENABLE(SoFCSelectionAction, SoViewVolumeElement);
186
SO_ENABLE(SoFCSelectionAction, SoViewingMatrixElement);
187
SO_ENABLE(SoFCSelectionAction, SoViewportRegionElement);
192
SO_ACTION_ADD_METHOD(SoCallback,callDoAction);
193
SO_ACTION_ADD_METHOD(SoComplexity,callDoAction);
194
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
195
SO_ACTION_ADD_METHOD(SoCoordinate4,callDoAction);
196
SO_ACTION_ADD_METHOD(SoFont,callDoAction);
197
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
198
SO_ACTION_ADD_METHOD(SoProfile,callDoAction);
199
SO_ACTION_ADD_METHOD(SoProfileCoordinate2,callDoAction);
200
SO_ACTION_ADD_METHOD(SoProfileCoordinate3,callDoAction);
201
SO_ACTION_ADD_METHOD(SoTransformation,callDoAction);
202
SO_ACTION_ADD_METHOD(SoSwitch,callDoAction);
204
SO_ACTION_ADD_METHOD(SoSeparator,callDoAction);
205
SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction);
207
SO_ACTION_ADD_METHOD(SoIndexedLineSet,callDoAction);
208
SO_ACTION_ADD_METHOD(SoIndexedFaceSet,callDoAction);
209
SO_ACTION_ADD_METHOD(SoPointSet,callDoAction);
212
void SoFCSelectionAction::finish()
218
SoFCSelectionAction::SoFCSelectionAction (const SelectionChanges &SelCh)
221
SO_ACTION_CONSTRUCTOR(SoFCSelectionAction);
225
SoFCSelectionAction::~SoFCSelectionAction() = default;
228
void SoFCSelectionAction::beginTraversal(SoNode *node)
233
void SoFCSelectionAction::callDoAction(SoAction *action,SoNode *node)
235
node->doAction(action);
238
// ---------------------------------------------------------------
240
SO_ACTION_SOURCE(SoFCEnableSelectionAction)
243
* The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base
244
* classes and afterwards subclasses of them must be listed, otherwise the registered methods
245
* of subclasses will be overridden. For more details see the thread in the Coin3d forum
246
* https://www.coin3d.org/pipermail/coin-discuss/2004-May/004346.html.
247
* This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after
248
* \c SoSeparator because both classes inherits the others.
250
void SoFCEnableSelectionAction::initClass()
252
SO_ACTION_INIT_CLASS(SoFCEnableSelectionAction,SoAction);
254
SO_ENABLE(SoFCEnableSelectionAction, SoSwitchElement);
256
SO_ACTION_ADD_METHOD(SoNode,nullAction);
258
SO_ENABLE(SoFCEnableSelectionAction, SoModelMatrixElement);
259
SO_ENABLE(SoFCEnableSelectionAction, SoShapeStyleElement);
260
SO_ENABLE(SoFCEnableSelectionAction, SoComplexityElement);
261
SO_ENABLE(SoFCEnableSelectionAction, SoComplexityTypeElement);
262
SO_ENABLE(SoFCEnableSelectionAction, SoCoordinateElement);
263
SO_ENABLE(SoFCEnableSelectionAction, SoFontNameElement);
264
SO_ENABLE(SoFCEnableSelectionAction, SoFontSizeElement);
265
SO_ENABLE(SoFCEnableSelectionAction, SoProfileCoordinateElement);
266
SO_ENABLE(SoFCEnableSelectionAction, SoProfileElement);
267
SO_ENABLE(SoFCEnableSelectionAction, SoSwitchElement);
268
SO_ENABLE(SoFCEnableSelectionAction, SoUnitsElement);
269
SO_ENABLE(SoFCEnableSelectionAction, SoViewVolumeElement);
270
SO_ENABLE(SoFCEnableSelectionAction, SoViewingMatrixElement);
271
SO_ENABLE(SoFCEnableSelectionAction, SoViewportRegionElement);
276
SO_ACTION_ADD_METHOD(SoCallback,callDoAction);
277
SO_ACTION_ADD_METHOD(SoComplexity,callDoAction);
278
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
279
SO_ACTION_ADD_METHOD(SoCoordinate4,callDoAction);
280
SO_ACTION_ADD_METHOD(SoFont,callDoAction);
281
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
282
SO_ACTION_ADD_METHOD(SoProfile,callDoAction);
283
SO_ACTION_ADD_METHOD(SoProfileCoordinate2,callDoAction);
284
SO_ACTION_ADD_METHOD(SoProfileCoordinate3,callDoAction);
285
SO_ACTION_ADD_METHOD(SoTransformation,callDoAction);
286
SO_ACTION_ADD_METHOD(SoSwitch,callDoAction);
288
SO_ACTION_ADD_METHOD(SoSeparator,callDoAction);
289
SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction);
292
void SoFCEnableSelectionAction::finish()
298
SoFCEnableSelectionAction::SoFCEnableSelectionAction (const SbBool& sel)
301
SO_ACTION_CONSTRUCTOR(SoFCEnableSelectionAction);
305
SoFCEnableSelectionAction::~SoFCEnableSelectionAction() = default;
308
void SoFCEnableSelectionAction::beginTraversal(SoNode *node)
313
void SoFCEnableSelectionAction::callDoAction(SoAction *action,SoNode *node)
315
node->doAction(action);
318
// ---------------------------------------------------------------
320
SO_ACTION_SOURCE(SoFCEnableHighlightAction)
323
* The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base
324
* classes and afterwards subclasses of them must be listed, otherwise the registered methods
325
* of subclasses will be overridden. For more details see the thread in the Coin3d forum
326
* https://www.coin3d.org/pipermail/coin-discuss/2004-May/004346.html.
327
* This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after
328
* \c SoSeparator because both classes inherits the others.
330
void SoFCEnableHighlightAction::initClass()
332
SO_ACTION_INIT_CLASS(SoFCEnableHighlightAction,SoAction);
334
SO_ENABLE(SoFCEnableHighlightAction, SoSwitchElement);
336
SO_ACTION_ADD_METHOD(SoNode,nullAction);
338
SO_ENABLE(SoFCEnableHighlightAction, SoModelMatrixElement);
339
SO_ENABLE(SoFCEnableHighlightAction, SoShapeStyleElement);
340
SO_ENABLE(SoFCEnableHighlightAction, SoComplexityElement);
341
SO_ENABLE(SoFCEnableHighlightAction, SoComplexityTypeElement);
342
SO_ENABLE(SoFCEnableHighlightAction, SoCoordinateElement);
343
SO_ENABLE(SoFCEnableHighlightAction, SoFontNameElement);
344
SO_ENABLE(SoFCEnableHighlightAction, SoFontSizeElement);
345
SO_ENABLE(SoFCEnableHighlightAction, SoProfileCoordinateElement);
346
SO_ENABLE(SoFCEnableHighlightAction, SoProfileElement);
347
SO_ENABLE(SoFCEnableHighlightAction, SoSwitchElement);
348
SO_ENABLE(SoFCEnableHighlightAction, SoUnitsElement);
349
SO_ENABLE(SoFCEnableHighlightAction, SoViewVolumeElement);
350
SO_ENABLE(SoFCEnableHighlightAction, SoViewingMatrixElement);
351
SO_ENABLE(SoFCEnableHighlightAction, SoViewportRegionElement);
356
SO_ACTION_ADD_METHOD(SoCallback,callDoAction);
357
SO_ACTION_ADD_METHOD(SoComplexity,callDoAction);
358
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
359
SO_ACTION_ADD_METHOD(SoCoordinate4,callDoAction);
360
SO_ACTION_ADD_METHOD(SoFont,callDoAction);
361
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
362
SO_ACTION_ADD_METHOD(SoProfile,callDoAction);
363
SO_ACTION_ADD_METHOD(SoProfileCoordinate2,callDoAction);
364
SO_ACTION_ADD_METHOD(SoProfileCoordinate3,callDoAction);
365
SO_ACTION_ADD_METHOD(SoTransformation,callDoAction);
366
SO_ACTION_ADD_METHOD(SoSwitch,callDoAction);
368
SO_ACTION_ADD_METHOD(SoSeparator,callDoAction);
369
SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction);
372
void SoFCEnableHighlightAction::finish()
378
SoFCEnableHighlightAction::SoFCEnableHighlightAction (const SbBool& sel)
381
SO_ACTION_CONSTRUCTOR(SoFCEnableHighlightAction);
385
SoFCEnableHighlightAction::~SoFCEnableHighlightAction() = default;
388
void SoFCEnableHighlightAction::beginTraversal(SoNode *node)
393
void SoFCEnableHighlightAction::callDoAction(SoAction *action,SoNode *node)
395
node->doAction(action);
398
// ---------------------------------------------------------------
400
SO_ACTION_SOURCE(SoFCSelectionColorAction)
403
* The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base
404
* classes and afterwards subclasses of them must be listed, otherwise the registered methods
405
* of subclasses will be overridden. For more details see the thread in the Coin3d forum
406
* https://www.coin3d.org/pipermail/coin-discuss/2004-May/004346.html.
407
* This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after
408
* \c SoSeparator because both classes inherits the others.
410
void SoFCSelectionColorAction::initClass()
412
SO_ACTION_INIT_CLASS(SoFCSelectionColorAction,SoAction);
414
SO_ENABLE(SoFCSelectionColorAction, SoSwitchElement);
416
SO_ACTION_ADD_METHOD(SoNode,nullAction);
418
SO_ENABLE(SoFCSelectionColorAction, SoModelMatrixElement);
419
SO_ENABLE(SoFCSelectionColorAction, SoShapeStyleElement);
420
SO_ENABLE(SoFCSelectionColorAction, SoComplexityElement);
421
SO_ENABLE(SoFCSelectionColorAction, SoComplexityTypeElement);
422
SO_ENABLE(SoFCSelectionColorAction, SoCoordinateElement);
423
SO_ENABLE(SoFCSelectionColorAction, SoFontNameElement);
424
SO_ENABLE(SoFCSelectionColorAction, SoFontSizeElement);
425
SO_ENABLE(SoFCSelectionColorAction, SoProfileCoordinateElement);
426
SO_ENABLE(SoFCSelectionColorAction, SoProfileElement);
427
SO_ENABLE(SoFCSelectionColorAction, SoSwitchElement);
428
SO_ENABLE(SoFCSelectionColorAction, SoUnitsElement);
429
SO_ENABLE(SoFCSelectionColorAction, SoViewVolumeElement);
430
SO_ENABLE(SoFCSelectionColorAction, SoViewingMatrixElement);
431
SO_ENABLE(SoFCSelectionColorAction, SoViewportRegionElement);
436
SO_ACTION_ADD_METHOD(SoCallback,callDoAction);
437
SO_ACTION_ADD_METHOD(SoComplexity,callDoAction);
438
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
439
SO_ACTION_ADD_METHOD(SoCoordinate4,callDoAction);
440
SO_ACTION_ADD_METHOD(SoFont,callDoAction);
441
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
442
SO_ACTION_ADD_METHOD(SoProfile,callDoAction);
443
SO_ACTION_ADD_METHOD(SoProfileCoordinate2,callDoAction);
444
SO_ACTION_ADD_METHOD(SoProfileCoordinate3,callDoAction);
445
SO_ACTION_ADD_METHOD(SoTransformation,callDoAction);
446
SO_ACTION_ADD_METHOD(SoSwitch,callDoAction);
448
SO_ACTION_ADD_METHOD(SoSeparator,callDoAction);
449
SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction);
452
void SoFCSelectionColorAction::finish()
458
SoFCSelectionColorAction::SoFCSelectionColorAction (const SoSFColor& col)
459
: selectionColor(col)
461
SO_ACTION_CONSTRUCTOR(SoFCSelectionColorAction);
465
SoFCSelectionColorAction::~SoFCSelectionColorAction() = default;
468
void SoFCSelectionColorAction::beginTraversal(SoNode *node)
473
void SoFCSelectionColorAction::callDoAction(SoAction *action,SoNode *node)
475
node->doAction(action);
478
// ---------------------------------------------------------------
480
SO_ACTION_SOURCE(SoFCHighlightColorAction)
483
* The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base
484
* classes and afterwards subclasses of them must be listed, otherwise the registered methods
485
* of subclasses will be overridden. For more details see the thread in the Coin3d forum
486
* https://www.coin3d.org/pipermail/coin-discuss/2004-May/004346.html.
487
* This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after
488
* \c SoSeparator because both classes inherits the others.
490
void SoFCHighlightColorAction::initClass()
492
SO_ACTION_INIT_CLASS(SoFCHighlightColorAction,SoAction);
494
SO_ENABLE(SoFCHighlightColorAction, SoSwitchElement);
496
SO_ACTION_ADD_METHOD(SoNode,nullAction);
498
SO_ENABLE(SoFCHighlightColorAction, SoModelMatrixElement);
499
SO_ENABLE(SoFCHighlightColorAction, SoShapeStyleElement);
500
SO_ENABLE(SoFCHighlightColorAction, SoComplexityElement);
501
SO_ENABLE(SoFCHighlightColorAction, SoComplexityTypeElement);
502
SO_ENABLE(SoFCHighlightColorAction, SoCoordinateElement);
503
SO_ENABLE(SoFCHighlightColorAction, SoFontNameElement);
504
SO_ENABLE(SoFCHighlightColorAction, SoFontSizeElement);
505
SO_ENABLE(SoFCHighlightColorAction, SoProfileCoordinateElement);
506
SO_ENABLE(SoFCHighlightColorAction, SoProfileElement);
507
SO_ENABLE(SoFCHighlightColorAction, SoSwitchElement);
508
SO_ENABLE(SoFCHighlightColorAction, SoUnitsElement);
509
SO_ENABLE(SoFCHighlightColorAction, SoViewVolumeElement);
510
SO_ENABLE(SoFCHighlightColorAction, SoViewingMatrixElement);
511
SO_ENABLE(SoFCHighlightColorAction, SoViewportRegionElement);
516
SO_ACTION_ADD_METHOD(SoCallback,callDoAction);
517
SO_ACTION_ADD_METHOD(SoComplexity,callDoAction);
518
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
519
SO_ACTION_ADD_METHOD(SoCoordinate4,callDoAction);
520
SO_ACTION_ADD_METHOD(SoFont,callDoAction);
521
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
522
SO_ACTION_ADD_METHOD(SoProfile,callDoAction);
523
SO_ACTION_ADD_METHOD(SoProfileCoordinate2,callDoAction);
524
SO_ACTION_ADD_METHOD(SoProfileCoordinate3,callDoAction);
525
SO_ACTION_ADD_METHOD(SoTransformation,callDoAction);
526
SO_ACTION_ADD_METHOD(SoSwitch,callDoAction);
528
SO_ACTION_ADD_METHOD(SoSeparator,callDoAction);
529
SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction);
532
void SoFCHighlightColorAction::finish()
538
SoFCHighlightColorAction::SoFCHighlightColorAction (const SoSFColor& col)
539
: highlightColor(col)
541
SO_ACTION_CONSTRUCTOR(SoFCHighlightColorAction);
545
SoFCHighlightColorAction::~SoFCHighlightColorAction() = default;
548
void SoFCHighlightColorAction::beginTraversal(SoNode *node)
553
void SoFCHighlightColorAction::callDoAction(SoAction *action,SoNode *node)
555
node->doAction(action);
558
// ---------------------------------------------------------------
560
SO_ACTION_SOURCE(SoFCDocumentAction)
563
* The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base
564
* classes and afterwards subclasses of them must be listed, otherwise the registered methods
565
* of subclasses will be overridden. For more details see the thread in the Coin3d forum
566
* https://www.coin3d.org/pipermail/coin-discuss/2004-May/004346.html.
567
* This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after
568
* \c SoSeparator because both classes inherits the others.
570
void SoFCDocumentAction::initClass()
572
SO_ACTION_INIT_CLASS(SoFCDocumentAction,SoAction);
574
SO_ENABLE(SoFCDocumentAction, SoSwitchElement);
576
SO_ACTION_ADD_METHOD(SoNode,nullAction);
578
SO_ENABLE(SoFCDocumentAction, SoModelMatrixElement);
579
SO_ENABLE(SoFCDocumentAction, SoShapeStyleElement);
580
SO_ENABLE(SoFCDocumentAction, SoComplexityElement);
581
SO_ENABLE(SoFCDocumentAction, SoComplexityTypeElement);
582
SO_ENABLE(SoFCDocumentAction, SoCoordinateElement);
583
SO_ENABLE(SoFCDocumentAction, SoFontNameElement);
584
SO_ENABLE(SoFCDocumentAction, SoFontSizeElement);
585
SO_ENABLE(SoFCDocumentAction, SoProfileCoordinateElement);
586
SO_ENABLE(SoFCDocumentAction, SoProfileElement);
587
SO_ENABLE(SoFCDocumentAction, SoSwitchElement);
588
SO_ENABLE(SoFCDocumentAction, SoUnitsElement);
589
SO_ENABLE(SoFCDocumentAction, SoViewVolumeElement);
590
SO_ENABLE(SoFCDocumentAction, SoViewingMatrixElement);
591
SO_ENABLE(SoFCDocumentAction, SoViewportRegionElement);
596
SO_ACTION_ADD_METHOD(SoCallback,callDoAction);
597
SO_ACTION_ADD_METHOD(SoComplexity,callDoAction);
598
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
599
SO_ACTION_ADD_METHOD(SoCoordinate4,callDoAction);
600
SO_ACTION_ADD_METHOD(SoFont,callDoAction);
601
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
602
SO_ACTION_ADD_METHOD(SoProfile,callDoAction);
603
SO_ACTION_ADD_METHOD(SoProfileCoordinate2,callDoAction);
604
SO_ACTION_ADD_METHOD(SoProfileCoordinate3,callDoAction);
605
SO_ACTION_ADD_METHOD(SoTransformation,callDoAction);
606
SO_ACTION_ADD_METHOD(SoSwitch,callDoAction);
608
SO_ACTION_ADD_METHOD(SoSeparator,callDoAction);
609
SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction);
612
void SoFCDocumentAction::finish()
618
SoFCDocumentAction::SoFCDocumentAction (const SoSFString& docName)
619
: documentName(docName)
621
SO_ACTION_CONSTRUCTOR(SoFCDocumentAction);
625
SoFCDocumentAction::~SoFCDocumentAction() = default;
628
void SoFCDocumentAction::beginTraversal(SoNode *node)
633
void SoFCDocumentAction::callDoAction(SoAction *action,SoNode *node)
635
node->doAction(action);
639
// ---------------------------------------------------------------
641
SO_ACTION_SOURCE(SoFCDocumentObjectAction)
644
* The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base
645
* classes and afterwards subclasses of them must be listed, otherwise the registered methods
646
* of subclasses will be overridden. For more details see the thread in the Coin3d forum
647
* https://www.coin3d.org/pipermail/coin-discuss/2004-May/004346.html.
648
* This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after
649
* \c SoSeparator because both classes inherits the others.
651
void SoFCDocumentObjectAction::initClass()
653
SO_ACTION_INIT_CLASS(SoFCDocumentObjectAction,SoAction);
655
SO_ENABLE(SoFCDocumentObjectAction, SoSwitchElement);
657
SO_ACTION_ADD_METHOD(SoNode,nullAction);
659
SO_ENABLE(SoFCDocumentObjectAction, SoModelMatrixElement);
660
SO_ENABLE(SoFCDocumentObjectAction, SoShapeStyleElement);
661
SO_ENABLE(SoFCDocumentObjectAction, SoComplexityElement);
662
SO_ENABLE(SoFCDocumentObjectAction, SoComplexityTypeElement);
663
SO_ENABLE(SoFCDocumentObjectAction, SoCoordinateElement);
664
SO_ENABLE(SoFCDocumentObjectAction, SoFontNameElement);
665
SO_ENABLE(SoFCDocumentObjectAction, SoFontSizeElement);
666
SO_ENABLE(SoFCDocumentObjectAction, SoProfileCoordinateElement);
667
SO_ENABLE(SoFCDocumentObjectAction, SoProfileElement);
668
SO_ENABLE(SoFCDocumentObjectAction, SoSwitchElement);
669
SO_ENABLE(SoFCDocumentObjectAction, SoUnitsElement);
670
SO_ENABLE(SoFCDocumentObjectAction, SoViewVolumeElement);
671
SO_ENABLE(SoFCDocumentObjectAction, SoViewingMatrixElement);
672
SO_ENABLE(SoFCDocumentObjectAction, SoViewportRegionElement);
674
SO_ACTION_ADD_METHOD(SoCallback,callDoAction);
675
SO_ACTION_ADD_METHOD(SoComplexity,callDoAction);
676
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
677
SO_ACTION_ADD_METHOD(SoCoordinate4,callDoAction);
678
SO_ACTION_ADD_METHOD(SoFont,callDoAction);
679
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
680
SO_ACTION_ADD_METHOD(SoProfile,callDoAction);
681
SO_ACTION_ADD_METHOD(SoProfileCoordinate2,callDoAction);
682
SO_ACTION_ADD_METHOD(SoProfileCoordinate3,callDoAction);
683
SO_ACTION_ADD_METHOD(SoTransformation,callDoAction);
684
SO_ACTION_ADD_METHOD(SoSwitch,callDoAction);
686
SO_ACTION_ADD_METHOD(SoSeparator,callDoAction);
687
SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction);
690
void SoFCDocumentObjectAction::finish()
695
SoFCDocumentObjectAction::SoFCDocumentObjectAction()
697
SO_ACTION_CONSTRUCTOR(SoFCDocumentObjectAction);
700
SoFCDocumentObjectAction::~SoFCDocumentObjectAction() = default;
702
void SoFCDocumentObjectAction::beginTraversal(SoNode *node)
707
void SoFCDocumentObjectAction::callDoAction(SoAction *action,SoNode *node)
709
node->doAction(action);
712
void SoFCDocumentObjectAction::setHandled()
714
this->_handled = true;
717
SbBool SoFCDocumentObjectAction::isHandled() const
719
return this->_handled;
722
// ---------------------------------------------------------------
724
SO_ACTION_SOURCE(SoGLSelectAction)
727
* The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base
728
* classes and afterwards subclasses of them must be listed, otherwise the registered methods
729
* of subclasses will be overridden. For more details see the thread in the Coin3d forum
730
* https://www.coin3d.org/pipermail/coin-discuss/2004-May/004346.html.
731
* This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after
732
* \c SoSeparator because both classes inherits the others.
734
void SoGLSelectAction::initClass()
736
SO_ACTION_INIT_CLASS(SoGLSelectAction,SoAction);
738
SO_ENABLE(SoGLSelectAction, SoSwitchElement);
740
SO_ACTION_ADD_METHOD(SoNode,nullAction);
742
SO_ENABLE(SoGLSelectAction, SoModelMatrixElement);
743
SO_ENABLE(SoGLSelectAction, SoProjectionMatrixElement);
744
SO_ENABLE(SoGLSelectAction, SoCoordinateElement);
745
SO_ENABLE(SoGLSelectAction, SoViewVolumeElement);
746
SO_ENABLE(SoGLSelectAction, SoViewingMatrixElement);
747
SO_ENABLE(SoGLSelectAction, SoViewportRegionElement);
749
SO_ACTION_ADD_METHOD(SoCamera,callDoAction);
750
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
751
SO_ACTION_ADD_METHOD(SoCoordinate4,callDoAction);
752
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
753
SO_ACTION_ADD_METHOD(SoSwitch,callDoAction);
754
SO_ACTION_ADD_METHOD(SoShape,callDoAction);
755
SO_ACTION_ADD_METHOD(SoIndexedFaceSet,callDoAction);
757
SO_ACTION_ADD_METHOD(SoSeparator,callDoAction);
758
SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction);
761
SoGLSelectAction::SoGLSelectAction (const SbViewportRegion& region,
762
const SbViewportRegion& select)
763
: vpregion(region), vpselect(select)
765
SO_ACTION_CONSTRUCTOR(SoGLSelectAction);
768
SoGLSelectAction::~SoGLSelectAction() = default;
770
const SbViewportRegion& SoGLSelectAction::getViewportRegion () const
772
return this->vpselect;
775
void SoGLSelectAction::beginTraversal(SoNode *node)
777
SoViewportRegionElement::set(this->getState(), this->vpregion);
781
void SoGLSelectAction::callDoAction(SoAction *action,SoNode *node)
783
node->doAction(action);
786
void SoGLSelectAction::setHandled()
788
this->_handled = true;
791
SbBool SoGLSelectAction::isHandled() const
793
return this->_handled;
796
// ---------------------------------------------------------------
798
SO_ACTION_SOURCE(SoVisibleFaceAction)
801
* The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base
802
* classes and afterwards subclasses of them must be listed, otherwise the registered methods
803
* of subclasses will be overridden. For more details see the thread in the Coin3d forum
804
* https://www.coin3d.org/pipermail/coin-discuss/2004-May/004346.html.
805
* This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after
806
* \c SoSeparator because both classes inherits the others.
808
void SoVisibleFaceAction::initClass()
810
SO_ACTION_INIT_CLASS(SoVisibleFaceAction,SoAction);
812
SO_ENABLE(SoVisibleFaceAction, SoSwitchElement);
814
SO_ACTION_ADD_METHOD(SoNode,nullAction);
816
SO_ENABLE(SoVisibleFaceAction, SoModelMatrixElement);
817
SO_ENABLE(SoVisibleFaceAction, SoProjectionMatrixElement);
818
SO_ENABLE(SoVisibleFaceAction, SoCoordinateElement);
819
SO_ENABLE(SoVisibleFaceAction, SoViewVolumeElement);
820
SO_ENABLE(SoVisibleFaceAction, SoViewingMatrixElement);
821
SO_ENABLE(SoVisibleFaceAction, SoViewportRegionElement);
824
SO_ACTION_ADD_METHOD(SoCamera,callDoAction);
825
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
826
SO_ACTION_ADD_METHOD(SoCoordinate4,callDoAction);
827
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
828
SO_ACTION_ADD_METHOD(SoSwitch,callDoAction);
829
SO_ACTION_ADD_METHOD(SoShape,callDoAction);
830
SO_ACTION_ADD_METHOD(SoIndexedFaceSet,callDoAction);
832
SO_ACTION_ADD_METHOD(SoSeparator,callDoAction);
833
SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction);
836
SoVisibleFaceAction::SoVisibleFaceAction ()
838
SO_ACTION_CONSTRUCTOR(SoVisibleFaceAction);
841
SoVisibleFaceAction::~SoVisibleFaceAction() = default;
843
void SoVisibleFaceAction::beginTraversal(SoNode *node)
848
void SoVisibleFaceAction::callDoAction(SoAction *action,SoNode *node)
850
node->doAction(action);
853
void SoVisibleFaceAction::setHandled()
855
this->_handled = true;
858
SbBool SoVisibleFaceAction::isHandled() const
860
return this->_handled;
863
// ---------------------------------------------------------------
866
SO_ACTION_SOURCE(SoUpdateVBOAction)
869
* The order of the defined SO_ACTION_ADD_METHOD statements is very important. First the base
870
* classes and afterwards subclasses of them must be listed, otherwise the registered methods
871
* of subclasses will be overridden. For more details see the thread in the Coin3d forum
872
* https://www.coin3d.org/pipermail/coin-discuss/2004-May/004346.html.
873
* This means that \c SoSwitch must be listed after \c SoGroup and \c SoFCSelection after
874
* \c SoSeparator because both classes inherits the others.
876
void SoUpdateVBOAction::initClass()
878
SO_ACTION_INIT_CLASS(SoUpdateVBOAction,SoAction);
880
SO_ENABLE(SoUpdateVBOAction, SoSwitchElement);
882
SO_ACTION_ADD_METHOD(SoNode,nullAction);
884
SO_ENABLE(SoUpdateVBOAction, SoModelMatrixElement);
885
SO_ENABLE(SoUpdateVBOAction, SoProjectionMatrixElement);
886
SO_ENABLE(SoUpdateVBOAction, SoCoordinateElement);
887
SO_ENABLE(SoUpdateVBOAction, SoViewVolumeElement);
888
SO_ENABLE(SoUpdateVBOAction, SoViewingMatrixElement);
889
SO_ENABLE(SoUpdateVBOAction, SoViewportRegionElement);
892
SO_ACTION_ADD_METHOD(SoCamera,callDoAction);
893
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
894
SO_ACTION_ADD_METHOD(SoCoordinate4,callDoAction);
895
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
896
SO_ACTION_ADD_METHOD(SoSwitch,callDoAction);
897
SO_ACTION_ADD_METHOD(SoShape,callDoAction);
898
SO_ACTION_ADD_METHOD(SoIndexedFaceSet,callDoAction);
900
SO_ACTION_ADD_METHOD(SoSeparator,callDoAction);
901
SO_ACTION_ADD_METHOD(SoFCSelection,callDoAction);
904
SoUpdateVBOAction::SoUpdateVBOAction ()
906
SO_ACTION_CONSTRUCTOR(SoUpdateVBOAction);
909
SoUpdateVBOAction::~SoUpdateVBOAction() = default;
911
void SoUpdateVBOAction::finish()
916
void SoUpdateVBOAction::beginTraversal(SoNode *node)
921
void SoUpdateVBOAction::callDoAction(SoAction *action,SoNode *node)
923
node->doAction(action);
926
// ---------------------------------------------------------------
929
class SoBoxSelectionRenderActionP {
931
SoBoxSelectionRenderActionP(SoBoxSelectionRenderAction * master)
936
SoBoxSelectionRenderAction * master;
937
SoSearchAction * searchaction{nullptr};
938
SoSearchAction * selectsearch{nullptr};
939
SoSearchAction * camerasearch{nullptr};
940
SoGetBoundingBoxAction * bboxaction{nullptr};
941
SoBaseColor * basecolor{nullptr};
942
SoTempPath * postprocpath{nullptr};
943
SoPath * highlightPath{nullptr};
944
SoSeparator * localRoot{nullptr};
945
SoMatrixTransform * xform{nullptr};
946
SoCube * cube{nullptr};
947
SoDrawStyle * drawstyle{nullptr};
948
SoColorPacker colorpacker;
951
void updateBbox(const SoPath * path);
957
#define PRIVATE(p) ((p)->pimpl)
959
#define PUBLIC(p) ((p)->master)
961
// used to initialize the internal storage class with variables
963
SoBoxSelectionRenderActionP::initBoxGraph()
965
this->localRoot = new SoSeparator;
966
this->localRoot->ref();
967
this->localRoot->renderCaching = SoSeparator::OFF;
968
this->localRoot->boundingBoxCaching = SoSeparator::OFF;
970
this->xform = new SoMatrixTransform;
971
this->cube = new SoCube;
973
this->drawstyle = new SoDrawStyle;
974
this->drawstyle->style = SoDrawStyleElement::LINES;
975
this->basecolor = new SoBaseColor;
977
auto lightmodel = new SoLightModel;
978
lightmodel->model = SoLightModel::BASE_COLOR;
980
auto complexity = new SoComplexity;
981
complexity->textureQuality = 0.0f;
982
complexity->type = SoComplexityTypeElement::BOUNDING_BOX;
984
this->localRoot->addChild(this->drawstyle);
985
this->localRoot->addChild(this->basecolor);
987
this->localRoot->addChild(lightmodel);
988
this->localRoot->addChild(complexity);
990
this->localRoot->addChild(this->xform);
991
this->localRoot->addChild(this->cube);
995
// used to render shape and non-shape nodes (usually SoGroup or SoSeparator).
997
SoBoxSelectionRenderActionP::updateBbox(const SoPath * path)
999
if (!this->camerasearch) {
1000
this->camerasearch = new SoSearchAction;
1003
// find camera used to render node
1004
this->camerasearch->setFind(SoSearchAction::TYPE);
1005
this->camerasearch->setInterest(SoSearchAction::LAST);
1006
this->camerasearch->setType(SoCamera::getClassTypeId());
1007
this->camerasearch->apply(const_cast<SoPath*>(path));
1009
if (!this->camerasearch->getPath()) {
1010
// if there is no camera there is no point rendering the bbox
1013
this->localRoot->insertChild(this->camerasearch->getPath()->getTail(), 0);
1014
this->camerasearch->reset();
1016
if (!this->bboxaction) {
1017
this->bboxaction = new SoGetBoundingBoxAction(SbViewportRegion(100, 100));
1019
this->bboxaction->setViewportRegion(PUBLIC(this)->getViewportRegion());
1020
this->bboxaction->apply(const_cast<SoPath*>(path));
1022
SbXfBox3f & box = this->bboxaction->getXfBoundingBox();
1024
if (!box.isEmpty()) {
1027
box.getSize(x, y, z);
1028
this->cube->width = x;
1029
this->cube->height = y;
1030
this->cube->depth = z;
1032
SbMatrix transform = box.getTransform(); // clazy:exclude=rule-of-two-soft
1034
// get center (in the local bbox coordinate system)
1035
SbVec3f center = box.SbBox3f::getCenter();
1037
// if center != (0,0,0), move the cube
1038
if (center != SbVec3f(0.0f, 0.0f, 0.0f)) {
1040
t.setTranslate(center);
1041
transform.multLeft(t);
1043
this->xform->matrix = transform;
1045
PUBLIC(this)->SoGLRenderAction::apply(this->localRoot);
1048
this->localRoot->removeChild(0);
1051
SO_ACTION_SOURCE(SoBoxSelectionRenderAction)
1053
// Overridden from parent class.
1055
SoBoxSelectionRenderAction::initClass()
1057
SO_ACTION_INIT_CLASS(SoBoxSelectionRenderAction, SoGLRenderAction);
1060
SoBoxSelectionRenderAction::SoBoxSelectionRenderAction()
1061
: inherited(SbViewportRegion())
1063
this->constructorCommon();
1066
SoBoxSelectionRenderAction::SoBoxSelectionRenderAction(const SbViewportRegion & viewportregion)
1067
: inherited(viewportregion)
1069
this->constructorCommon();
1073
// private. called by both constructors
1076
SoBoxSelectionRenderAction::constructorCommon()
1078
SO_ACTION_CONSTRUCTOR(SoBoxSelectionRenderAction);
1080
PRIVATE(this) = new SoBoxSelectionRenderActionP(this);
1082
// Initialize local variables
1083
PRIVATE(this)->initBoxGraph();
1085
this->hlVisible = false;
1087
PRIVATE(this)->basecolor->rgb.setValue(1.0f, 0.0f, 0.0f);
1088
PRIVATE(this)->drawstyle->linePattern = 0xffff;
1089
PRIVATE(this)->drawstyle->lineWidth = 1.0f;
1090
PRIVATE(this)->searchaction = nullptr;
1091
PRIVATE(this)->selectsearch = nullptr;
1092
PRIVATE(this)->camerasearch = nullptr;
1093
PRIVATE(this)->bboxaction = nullptr;
1095
// SoBase-derived objects should be dynamically allocated.
1096
PRIVATE(this)->postprocpath = new SoTempPath(32);
1097
PRIVATE(this)->postprocpath->ref();
1098
PRIVATE(this)->highlightPath = nullptr;
1101
SoBoxSelectionRenderAction::~SoBoxSelectionRenderAction()
1103
// clear highlighting node
1104
if (PRIVATE(this)->highlightPath) {
1105
PRIVATE(this)->highlightPath->unref();
1107
PRIVATE(this)->postprocpath->unref();
1108
PRIVATE(this)->localRoot->unref();
1110
delete PRIVATE(this)->searchaction;
1111
delete PRIVATE(this)->selectsearch;
1112
delete PRIVATE(this)->camerasearch;
1113
delete PRIVATE(this)->bboxaction;
1114
delete PRIVATE(this);
1118
SoBoxSelectionRenderAction::apply(SoNode * node)
1120
SoGLRenderAction::apply(node);
1121
if (this->hlVisible) {
1122
if (!PRIVATE(this)->searchaction) {
1123
PRIVATE(this)->searchaction = new SoSearchAction;
1125
PRIVATE(this)->searchaction->setType(SoFCSelection::getClassTypeId());
1126
PRIVATE(this)->searchaction->setInterest(SoSearchAction::ALL);
1127
PRIVATE(this)->searchaction->apply(node);
1128
const SoPathList & pathlist = PRIVATE(this)->searchaction->getPaths();
1129
if (pathlist.getLength() > 0) {
1130
for (int i = 0; i < pathlist.getLength(); i++ ) {
1131
SoPath * path = pathlist[i];
1133
auto selection = static_cast<SoFCSelection *>(path->getTail());
1134
assert(selection->getTypeId().isDerivedFrom(SoFCSelection::getClassTypeId()));
1135
if (selection->selected.getValue() && selection->style.getValue() == SoFCSelection::BOX) {
1136
PRIVATE(this)->basecolor->rgb.setValue(selection->colorSelection.getValue());
1137
if (!PRIVATE(this)->selectsearch) {
1138
PRIVATE(this)->selectsearch = new SoSearchAction;
1140
PRIVATE(this)->selectsearch->setType(SoShape::getClassTypeId());
1141
PRIVATE(this)->selectsearch->setInterest(SoSearchAction::FIRST);
1142
PRIVATE(this)->selectsearch->apply(selection);
1143
SoPath* shapepath = PRIVATE(this)->selectsearch->getPath();
1146
list.append(shapepath);
1147
this->drawBoxes(path, &list);
1149
PRIVATE(this)->selectsearch->reset();
1151
else if (selection->isHighlighted() &&
1152
selection->selected.getValue() == SoFCSelection::NOTSELECTED &&
1153
selection->style.getValue() == SoFCSelection::BOX) {
1154
PRIVATE(this)->basecolor->rgb.setValue(selection->colorHighlight.getValue());
1156
if (!PRIVATE(this)->selectsearch) {
1157
PRIVATE(this)->selectsearch = new SoSearchAction;
1159
PRIVATE(this)->selectsearch->setType(SoShape::getClassTypeId());
1160
PRIVATE(this)->selectsearch->setInterest(SoSearchAction::FIRST);
1161
PRIVATE(this)->selectsearch->apply(selection);
1162
SoPath* shapepath = PRIVATE(this)->selectsearch->getPath();
1165
list.append(shapepath);
1166
// clear old highlighting node if still active
1167
if (PRIVATE(this)->highlightPath) {
1168
PRIVATE(this)->highlightPath->unref();
1170
PRIVATE(this)->highlightPath = path;
1171
PRIVATE(this)->highlightPath->ref();
1172
this->drawBoxes(path, &list);
1174
PRIVATE(this)->selectsearch->reset();
1178
PRIVATE(this)->searchaction->reset();
1183
SoBoxSelectionRenderAction::apply(SoPath * path)
1185
SoGLRenderAction::apply(path);
1186
SoNode* node = path->getTail();
1187
if (node && node->getTypeId() == SoFCSelection::getClassTypeId()) {
1188
auto selection = static_cast<SoFCSelection *>(node);
1190
// This happens when dehighlighting the current shape
1191
if (PRIVATE(this)->highlightPath == path) {
1192
PRIVATE(this)->highlightPath->unref();
1193
PRIVATE(this)->highlightPath = nullptr;
1194
// FIXME: Doing a redraw to remove the shown bounding box causes
1195
// some problems when moving the mouse from one shape to another
1196
// because this will destroy the box immediately
1197
selection->touch(); // force a redraw when dehighlighting
1199
else if (selection->isHighlighted() &&
1200
selection->selected.getValue() == SoFCSelection::NOTSELECTED &&
1201
selection->style.getValue() == SoFCSelection::BOX) {
1202
PRIVATE(this)->basecolor->rgb.setValue(selection->colorHighlight.getValue());
1204
if (!PRIVATE(this)->selectsearch) {
1205
PRIVATE(this)->selectsearch = new SoSearchAction;
1207
PRIVATE(this)->selectsearch->setType(SoShape::getClassTypeId());
1208
PRIVATE(this)->selectsearch->setInterest(SoSearchAction::FIRST);
1209
PRIVATE(this)->selectsearch->apply(selection);
1210
SoPath* shapepath = PRIVATE(this)->selectsearch->getPath();
1213
list.append(shapepath);
1214
// clear old highlighting node if still active
1215
if (PRIVATE(this)->highlightPath) {
1216
PRIVATE(this)->highlightPath->unref();
1218
PRIVATE(this)->highlightPath = path;
1219
PRIVATE(this)->highlightPath->ref();
1220
this->drawBoxes(path, &list);
1222
PRIVATE(this)->selectsearch->reset();
1228
SoBoxSelectionRenderAction::apply(const SoPathList & pathlist,
1231
SoGLRenderAction::apply(pathlist, obeysrules);
1235
SoBoxSelectionRenderAction::setColor(const SbColor & color)
1237
PRIVATE(this)->basecolor->rgb = color;
1241
SoBoxSelectionRenderAction::getColor()
1243
return PRIVATE(this)->basecolor->rgb[0];
1247
SoBoxSelectionRenderAction::setLinePattern(unsigned short pattern)
1249
PRIVATE(this)->drawstyle->linePattern = pattern;
1253
SoBoxSelectionRenderAction::getLinePattern() const
1255
return PRIVATE(this)->drawstyle->linePattern.getValue();
1259
SoBoxSelectionRenderAction::setLineWidth(const float width)
1261
PRIVATE(this)->drawstyle->lineWidth = width;
1265
SoBoxSelectionRenderAction::getLineWidth() const
1267
return PRIVATE(this)->drawstyle->lineWidth.getValue();
1271
SoBoxSelectionRenderAction::drawBoxes(SoPath * pathtothis, const SoPathList * pathlist)
1274
int thispos = static_cast<SoFullPath *>(pathtothis)->getLength()-1;
1275
assert(thispos >= 0);
1276
PRIVATE(this)->postprocpath->truncate(0); // reset
1278
for (i = 0; i < thispos; i++)
1279
PRIVATE(this)->postprocpath->append(pathtothis->getNode(i));
1281
// we need to disable accumulation buffer antialiasing while
1282
// rendering selected objects
1283
int oldnumpasses = this->getNumPasses();
1284
this->setNumPasses(1);
1286
SoState * thestate = this->getState();
1289
for (i = 0; i < pathlist->getLength(); i++) {
1290
auto path = static_cast<SoFullPath *>((*pathlist)[i]);
1292
for (int j = 0; j < path->getLength(); j++) {
1293
PRIVATE(this)->postprocpath->append(path->getNode(j));
1296
// Previously SoGLRenderAction was used to draw the bounding boxes
1297
// of shapes in selection paths, by overriding renderstyle state
1298
// elements to lines drawstyle and simply doing:
1300
// SoGLRenderAction::apply(PRIVATE(this)->postprocpath); // Bug
1302
// This could have the unwanted side effect of rendering
1303
// non-selected shapes, as they could be part of the path (due to
1304
// being placed below SoGroup nodes (instead of SoSeparator
1305
// nodes)) up to the selected shape.
1308
// A better approach turned out to be to soup up and draw only the
1309
// bounding boxes of the selected shapes:
1310
PRIVATE(this)->updateBbox(PRIVATE(this)->postprocpath);
1312
// Remove temporary path from path buffer
1313
PRIVATE(this)->postprocpath->truncate(thispos);
1316
this->setNumPasses(oldnumpasses);