Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoSelection.h
Go to the documentation of this file.
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : David Mott (MMM yyyy)
25** Modified by : Thad Beier (MMM yyyy)
26**=======================================================================*/
27/*=======================================================================
28 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
29 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
30 *** ***
31 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
32 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
33 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
34 *** ***
35 *** RESTRICTED RIGHTS LEGEND ***
36 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
37 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
38 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
39 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
40 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
41 *** ***
42 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
43 *** BORDEAUX, FRANCE ***
44 *** ALL RIGHTS RESERVED ***
45**=======================================================================*/
46/*=======================================================================
47** Modified by : VSG (MMM YYYY)
48**=======================================================================*/
49
50
51#ifndef _SO_SELECTION_
52#define _SO_SELECTION_
53
54#include <Inventor/SoLists.h>
55#include <Inventor/SbColor.h>
58
59#include <Inventor/STL/list>
60
61class SoCallbackList;
62class SoEvent;
64class SoSearchAction;
65class SoPickedPoint;
67class SoTypeList;
68class SoSelection;
69class SoPath;
70
71
72// callback function prototypes
76typedef void SoSelectionPathCB(void *userData, SoPath *path);
80typedef void SoSelectionClassCB(void *userData, SoSelection *sel);
84typedef SoPath * SoSelectionPickCB(void *userData, const SoPickedPoint *pick);
85
87//
88// Class: SoSelection
89//
90// Selection group node: Manages selection list from picks of its children.
91//
93
95
96
303class SoSelection : public SoSeparator {
304
306 SO_PIMPL_PUBLIC_HEADER( SoSelection );
307
308 public:
316 SoSelection(int nChildren);
317
318 //
319 // Selection policy
320 // ----------------
321
322 // Default selection policy is SoSelection::SHIFT.
323 enum Policy {
330
336
342
346 DISABLE
347 };
348
349 // Fields
356
357 //
358 // Selection list management
359 // -------------------------
360
368 void select(const SoPath *path);
375 void select(SoNode *node);
376
380 void deselect(const SoPath *path);
385 void deselect(int which);
392 void deselect(SoNode *node);
393
398 void toggle(const SoPath *path);
404 void toggle(SoNode *node);
405
410 SbBool isSelected(const SoPath *path) const;
423 SbBool isSelected(const SoNode *node) const;
424
429
433 int getNumSelected() const;
437 const SoPathList* getList() const;
441 SoPath *getPath(int index) const;
442
446 SoPath * operator [](int i) const
447 { return getPath(i); }
448
455 void setPickRadius( float radiusInPixels );
456
461 float getPickRadius() const;
462
463 //
464 // Selection change callbacks
465 // --------------------------
466 //
467 // Callbacks are invoked when an object is selected or deselected.
468 //
469
477 void addSelectionCallback(SoSelectionPathCB *f, void *userData = NULL);
485 void removeSelectionCallback(SoSelectionPathCB *f, void *userData = NULL);
486
494 void addDeselectionCallback(SoSelectionPathCB *f, void *userData = NULL);
502 void removeDeselectionCallback(SoSelectionPathCB *f, void *userData = NULL);
503
514 void addStartCallback(SoSelectionClassCB *f, void *userData = NULL);
525 void removeStartCallback(SoSelectionClassCB *f, void *userData = NULL);
526
536 void addFinishCallback(SoSelectionClassCB *f, void *userData = NULL);
546 void removeFinishCallback(SoSelectionClassCB *f, void *userData = NULL);
547
588 void *userData = NULL,
589 SbBool callOnlyIfSelectable = TRUE);
590
599 void setPickMatching( SbBool pickTwice );
604
605 private:
606 // Traversal routine for SoHandleEventAction - this will call
607 // action->setHandled() if the event is handled
608 virtual void handleEvent(SoHandleEventAction *action);
609
610 private:
611
612 virtual void notify(SoNotList *list);
613
614 // Selection notify callbacks - invoked whenever the selection changes.
615 // Used by the render area to redraw for selection highlighting.
616 void addChangeCallback(SoSelectionClassCB *f, void *userData = NULL);
617 void removeChangeCallback(SoSelectionClassCB *f, void *userData = NULL);
618
619 SbBool getPickMatching() const;
620
621 // Internal:
622 static void initClass();
623 static void exitClass();
624
625 // add a list of paths without duplication check
626 void addPaths( const SoPathList &in );
627
628 private:
629
630 // Destructor removes everything from the list.
631 virtual ~SoSelection();
632
633 private:
634
635 // this is called from the two constructors.
636 void constructorCommon();
637};
638
639#endif /* _SO_SELECTION_ */
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
SO_PIMPL_PUBLIC_DECLARATION(SoFileDataAdapter)
void SoSelectionClassCB(void *userData, SoSelection *sel)
Definition SoSelection.h:80
SoPath * SoSelectionPickCB(void *userData, const SoPickedPoint *pick)
Definition SoSelection.h:84
void SoSelectionPathCB(void *userData, SoPath *path)
Definition SoSelection.h:76
#define SO_NODE_HEADER(className)
Definition SoSubNode.h:151
Manages a list of callbacks and associated data.
Base class for all events.
Definition SoEvent.h:116
Allows nodes in a graph to receive input events.
Abstract base class for all database nodes.
Definition SoNode.h:145
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Maintains a list of pointers to paths.
Definition SoPathList.h:81
Represents point on surface of picked object.
Maintains a list of pointers to SoPickedPoint instances.
Field containing an enumerated value.
Definition SoSFEnum.h:89
Searches for nodes in a scene graph.
Manages a list of selected objects.
void removeSelectionCallback(SoSelectionPathCB *f, void *userData=NULL)
Removes selection callback.
void select(SoNode *node)
Selects the passed node by creating a path to it, and adding the path to the selection list by callin...
SbBool isSelected(const SoPath *path) const
Returns TRUE if the passed path is selected, that is, if it is in the selection list.
SbBool isSelected(const SoNode *node) const
Returns TRUE if the passed node is selected by creating a path to it, then calling isSelected().
void deselectAll()
Deselects all paths in the selection list, that is, clear the list.
const SoPathList * getList() const
Returns the list of selected paths.
void deselect(const SoPath *path)
Deselects the passed path by removing it from the selection list.
float getPickRadius() const
Returns the radius (in pixels) around the viewport-space point through which the ray passes when doin...
void toggle(const SoPath *path)
Toggles the selection status of the passed path - if the path is in the selection list,...
void setPickRadius(float radiusInPixels)
Sets the radius (in pixels) around the viewport-space point through which the ray passes when doing r...
void deselect(SoNode *node)
Deselects the passed node by creating a path to it, and removing the node from the selection list by ...
SoSelection()
Creates a selection node with the default settings.
void toggle(SoNode *node)
Toggles the selection status of the passed node by creating a path to it, then calling toggle(path) ...
void removeStartCallback(SoSelectionClassCB *f, void *userData=NULL)
Removes start callback.
SoSelection(int nChildren)
Constructor that specifies the approximate number of children.
void addDeselectionCallback(SoSelectionPathCB *f, void *userData=NULL)
Adds deselection callback.
SoSFEnum policy
Selection policy that is followed in response to user interaction.
void setPickMatching(SbBool pickTwice)
SoSelection will pick once on mouse down and once on mouse up, and make sure the picks match before c...
void addFinishCallback(SoSelectionClassCB *f, void *userData=NULL)
Adds finish callback.
SbBool isSelected(SoNode *node) const
Returns TRUE if the passed node is selected by creating a path to it, then calling isSelected().
void addSelectionCallback(SoSelectionPathCB *f, void *userData=NULL)
Adds selection callback.
SoPath * getPath(int index) const
Returns the ith path in the selection list.
void removeDeselectionCallback(SoSelectionPathCB *f, void *userData=NULL)
Removes deselection callback.
SbBool isPickMatching() const
Returns pick matching flag.
@ SHIFT
When shift key is down, selection policy is TOGGLE.
@ SINGLE
Picking an object object clears current selection, then selects object.
@ TOGGLE
Picking an object toggles its selection status.
void deselect(int which)
Deselects a path by removing it from the selection list.
void removeFinishCallback(SoSelectionClassCB *f, void *userData=NULL)
Removes finish callback.
void setPickFilterCallback(SoSelectionPickCB *f, void *userData=NULL, SbBool callOnlyIfSelectable=TRUE)
The pick filter callback is invoked when a pick has occurred and the selection node is about to chang...
void select(const SoPath *path)
Selects the passed path by adding it to the selection list.
int getNumSelected() const
Returns the number of paths in the selection list.
void addStartCallback(SoSelectionClassCB *f, void *userData=NULL)
Adds start callback.
Group node that saves and restores traversal state.
Maintains a list of SoTypes.
Definition SoTypeList.h:72
int SbBool
Boolean type.
Definition SbBase.h:87
void notify(SoNotList *list)