Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoSelection.h
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-2024 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>
56#include <Inventor/misc/SoCallbackList.h>
57#include <Inventor/nodes/SoSeparator.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
78typedef void SoSelectionPathCB(void *userData, SoPath *path);
84typedef void SoSelectionClassCB(void *userData, SoSelection *sel);
90typedef SoPath * SoSelectionPickCB(void *userData, const SoPickedPoint *pick);
91
93//
94// Class: SoSelection
95//
96// Selection group node: Manages selection list from picks of its children.
97//
99
100 SO_PIMPL_PUBLIC_DECLARATION( SoSelection )
101
102
309class SoSelection : public SoSeparator {
310
311 SO_NODE_HEADER(SoSelection);
312 SO_PIMPL_PUBLIC_HEADER( SoSelection );
313
314 public:
322 SoSelection(int nChildren);
323
324 //
325 // Selection policy
326 // ----------------
327
328 // Default selection policy is SoSelection::SHIFT.
329 enum Policy {
336
342
348
352 DISABLE
353 };
354
355 // Fields
362
363 //
364 // Selection list management
365 // -------------------------
366
374 void select(const SoPath *path);
381 void select(SoNode *node);
382
386 void deselect(const SoPath *path);
391 void deselect(int which);
398 void deselect(SoNode *node);
399
404 void toggle(const SoPath *path);
410 void toggle(SoNode *node);
411
416 SbBool isSelected(const SoPath *path) const;
429 SbBool isSelected(const SoNode *node) const;
430
435
439 int getNumSelected() const;
443 const SoPathList* getList() const;
447 SoPath *getPath(int index) const;
448
452 SoPath * operator [](int i) const
453 { return getPath(i); }
454
461 void setPickRadius( float radiusInPixels );
462
467 float getPickRadius() const;
468
469 //
470 // Selection change callbacks
471 // --------------------------
472 //
473 // Callbacks are invoked when an object is selected or deselected.
474 //
475
483 void addSelectionCallback(SoSelectionPathCB *f, void *userData = NULL);
491 void removeSelectionCallback(SoSelectionPathCB *f, void *userData = NULL);
492
500 void addDeselectionCallback(SoSelectionPathCB *f, void *userData = NULL);
508 void removeDeselectionCallback(SoSelectionPathCB *f, void *userData = NULL);
509
520 void addStartCallback(SoSelectionClassCB *f, void *userData = NULL);
531 void removeStartCallback(SoSelectionClassCB *f, void *userData = NULL);
532
542 void addFinishCallback(SoSelectionClassCB *f, void *userData = NULL);
552 void removeFinishCallback(SoSelectionClassCB *f, void *userData = NULL);
553
593 SoSelectionPickCB *f,
594 void *userData = NULL,
595 SbBool callOnlyIfSelectable = TRUE);
596
605 void setPickMatching( SbBool pickTwice );
610
611 private:
612 // Traversal routine for SoHandleEventAction - this will call
613 // action->setHandled() if the event is handled
614 virtual void handleEvent(SoHandleEventAction *action);
615
616 private:
617
618 virtual void notify(SoNotList *list);
619
620 // Selection notify callbacks - invoked whenever the selection changes.
621 // Used by the render area to redraw for selection highlighting.
622 void addChangeCallback(SoSelectionClassCB *f, void *userData = NULL);
623 void removeChangeCallback(SoSelectionClassCB *f, void *userData = NULL);
624
625 SbBool getPickMatching() const;
626
627 // Internal:
628 static void initClass();
629 static void exitClass();
630
631 // add a list of paths without duplication check
632 void addPaths( const SoPathList &in );
633
634 private:
635
636 // Destructor removes everything from the list.
637 virtual ~SoSelection();
638
639 private:
640
641 // this is called from the two constructors.
642 void constructorCommon();
643};
644
645#endif /* _SO_SELECTION_ */
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 SoSelectionClassCB(void *userData, SoSelection *sel)
Definition SoSelection.h:84
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...
SoPath * SoSelectionPickCB(void *userData, const SoPickedPoint *pick)
Definition SoSelection.h:90
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 SoSelectionPathCB(void *userData, SoPath *path)
Definition SoSelection.h:78
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