Open Inventor Reference
SoSelection.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37
38/*
39 * Copyright (C) 1990-93 Silicon Graphics, Inc.
40 *
41 _______________________________________________________________________
42 ______________ S I L I C O N G R A P H I C S I N C . ____________
43 |
44 |
45 | $Revision: 1.1.1.1 $
46 |
47 | Description:
48 | This file defines the SoSelection node class.
49 |
50 | Classes: SoSelection
51 |
52 | Author(s) : David Mott, Thad Beier
53 |
54 ______________ S I L I C O N G R A P H I C S I N C . ____________
55 _______________________________________________________________________
56 */
57
58#ifndef _SO_SELECTION_
59#define _SO_SELECTION_
60
61#include <Inventor/SbColor.h>
65
66class SoCallbackList;
67class SoEvent;
69class SoSearchAction;
70class SoPickedPoint;
72class SoTypeList;
73class SoSelection;
74class SoPath;
75
77typedef INVENTOR_API void SoSelectionPathCB(void *userData, SoPath *path);
78typedef INVENTOR_API void SoSelectionClassCB(void *userData, SoSelection *sel);
79typedef INVENTOR_API SoPath * SoSelectionPickCB(void *userData, const SoPickedPoint *pick);
80
81
84
125
127
129
130 public:
131
136 SoSelection(int nChildren);
137
141
143 enum Policy {
148
153
157 SHIFT
158 };
159
161
162
167
172
174
181 void select(const SoPath *path);
182
188 void select(SoNode *node);
189
191 void deselect(const SoPath *path);
194 void deselect(int which);
195
201 void deselect(SoNode *node);
202
205 void toggle(const SoPath *path);
206
212 void toggle(SoNode *node);
213
215 bool isSelected(const SoPath *path) const;
219 bool isSelected(SoNode *node) const;
220
223
225 int getNumSelected() const { return selectionList.getLength(); }
227 const SoPathList *getList() const { return &selectionList; }
229 SoPath *getPath(int index) const;
230
232 SoPath * operator [](int i) const
233 { return getPath(i); }
234
238 void addSelectionCallback(SoSelectionPathCB *f, void *userData = NULL);
240 void removeSelectionCallback(SoSelectionPathCB *f, void *userData = NULL);
241
245 void addDeselectionCallback(SoSelectionPathCB *f, void *userData = NULL);
247 void removeDeselectionCallback(SoSelectionPathCB *f, void *userData = NULL);
248
256 void addStartCallback(SoSelectionClassCB *f, void *userData = NULL);
258 void removeStartCallback(SoSelectionClassCB *f, void *userData = NULL);
259
266 void addFinishCallback(SoSelectionClassCB *f, void *userData = NULL);
268 void removeFinishCallback(SoSelectionClassCB *f, void *userData = NULL);
269
322 void *userData = NULL,
323 bool callOnlyIfSelectable = TRUE);
324
333 void setPickMatching(bool pickTwice) { pickMatching = pickTwice; }
335 bool isPickMatching() const { return pickMatching; }
337 bool getPickMatching() const { return pickMatching; }
338
339 SoINTERNAL public:
342 void addChangeCallback(SoSelectionClassCB *f, void *userData = NULL);
343 void removeChangeCallback(SoSelectionClassCB *f, void *userData = NULL);
344
346 static void initClass();
347
348 protected:
351
357
362
365
369
371
373
379 void invokeSelectionPolicy(SoPath *path, bool shiftDown);
382
385 SoPath *copyFromThis(const SoPath *path) const;
386
388 SoPath *getPickedPath(const SoPickedPoint* pickedPoint);
389
391 void addPath(SoPath *path);
392 void removePath(int which);
393
396 int findPath(const SoPath *path) const;
397
400 virtual void handleEvent(SoHandleEventAction *action);
401
404
405 private:
406
408 static SoSearchAction *searchAction;
409
411 void constructorCommon();
412};
413
414
415
416#endif /* _SO_SELECTION_ */
#define TRUE
Definition SbBasic.h:76
#define SoINTERNAL
Definition SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition SbSystem.h:77
INVENTOR_API void SoSelectionClassCB(void *userData, SoSelection *sel)
Definition SoSelection.h:78
INVENTOR_API SoPath * SoSelectionPickCB(void *userData, const SoPickedPoint *pick)
Definition SoSelection.h:79
INVENTOR_API void SoSelectionPathCB(void *userData, SoPath *path)
callback function prototypes
Definition SoSelection.h:77
#define SO_NODE_HEADER(className)
Non-abstract classes have everything abstract classes have, plus a way to create an instance.
Definition SoSubNode.h:170
2D vector class.
Definition SbLinear.h:354
Manages a list of callback functions and associated data.
Base class for all events.
Definition SoEvent.h:84
Allows nodes in a graph to receive input events.
Abstract base class for all database nodes.
Definition SoNode.h:103
Maintains a list of pointers to paths.
Definition SoLists.h:212
Path that points to a list of hierarchical nodes.
Definition SoPath.h:109
Maintains a list of pointers to SoPickedPoint instances.
Definition SoLists.h:383
Represents point on surface of picked object.
Field containing a single boolean value.
Definition SoSFBool.h:78
Field containing an enumerated value.
Definition SoSFEnum.h:93
Searches for nodes in a scene graph.
Manages a list of selected objects.
bool abortSelection
void removeSelectionCallback(SoSelectionPathCB *f, void *userData=NULL)
Remove selection callback.
void invokeSelectionPolicy(SoPath *path, bool shiftDown)
Selection policies (shiftSelection is a combination of these) invokeSelectionPolicy() is called from ...
void select(SoNode *node)
Select the passed node by creating a path to it, and adding the path to the selection list by calling...
void addPath(SoPath *path)
addPath() assumes the path is rooted by 'this'
SoCallbackList * selCBList
Selection callback lists.
void deselectAll()
Deselect all paths in the selection list, that is, clear the list.
SoCallbackList * finishCBList
const SoPathList * getList() const
Return the list of selected paths.
void deselect(const SoPath *path)
Deselect the passed path by removing it from the selection list.
SoPathList selectionList
List of paths of selected objects.
SoPath * mouseDownPickPath
Mouse down picked path.
SbVec2s mouseDownPosition
void toggle(const SoPath *path)
Toggle the selection status of the passed path em if the path is in the selection list,...
SoCallbackList * startCBList
bool callPickCBOnlyIfSelectable
void deselect(SoNode *node)
Deselect the passed node by creating a path to it, and removing the node from the selection list by c...
SoSelection()
Creates a selection node with the default settings.
void removePath(int which)
int findPath(const SoPath *path) const
This locates path in the selection list.
static void initClass()
Internal:
bool pickMatching
void performToggleSelection(SoPath *path)
SoPath * copyFromThis(const SoPath *path) const
This copies the path so the copy is rooted by 'this'.
void toggle(SoNode *node)
Toggle the selection status of the passed node by creating a path to it, then calling toggle(path).
void removeStartCallback(SoSelectionClassCB *f, void *userData=NULL)
Remove the start callback.
SoSelection(int nChildren)
Constructor that specifies the approximate number of children.
SoCallbackList * changeCBList
Change callbacks.
void addDeselectionCallback(SoSelectionPathCB *f, void *userData=NULL)
The deselection callbacks are invoked every time an object is deselected, whether it be from user int...
SoSFEnum policy
Selection policy that is followed in response to user interaction.
void addFinishCallback(SoSelectionClassCB *f, void *userData=NULL)
The finish callbacks are invoked when the user has finished interactively changing the selection list...
SoSFBool selectOnlyOnClick
If on, only perform selection on a single click, and not after the mouse has been dragged from the in...
void * pickCBData
SoSelectionPickCB * pickCBFunc
Pick filter is a single callback function, not a list.
bool isPickMatching() const
Returns if pick matching is on.
~SoSelection()
Destructor removes everything from the list.
void removeChangeCallback(SoSelectionClassCB *f, void *userData=NULL)
void addSelectionCallback(SoSelectionPathCB *f, void *userData=NULL)
The selection callbacks are invoked every time an object is selected, whether it be from user interac...
bool isSelected(SoNode *node) const
This convenience version of deselect will search for the first instance of the passed node under this...
SoPath * getPath(int index) const
Return the ith path in the selection list.
void removeDeselectionCallback(SoSelectionPathCB *f, void *userData=NULL)
Remove deselection callback.
virtual void handleEvent(SoHandleEventAction *action)
Traversal routine for SoHandleEventAction - this will call action->setHandled() if the event is handl...
Policy
Default selection policy is SoSelection::SHIFT.
@ SINGLE
left mouse pick on object clears selection, then selects object.
@ TOGGLE
left mouse pick on object toggles its selection status.
bool getPickMatching() const
Returns if pick matching is on.
bool isSelected(const SoPath *path) const
returns TRUE if the path is selected
void deselect(int which)
Deselect a path by removing it from the selection list.
void removeFinishCallback(SoSelectionClassCB *f, void *userData=NULL)
Remove finish callback.
void setPickFilterCallback(SoSelectionPickCB *f, void *userData=NULL, bool callOnlyIfSelectable=TRUE)
The pick filter callback is invoked when a pick has occurred and the selection node is about to chang...
SoPath * getPickedPath(const SoPickedPoint *pickedPoint)
Get path from picked point, calls callbacks.
void addChangeCallback(SoSelectionClassCB *f, void *userData=NULL)
Selection notify callbacks - invoked whenever the selection changes.
void setPickMatching(bool pickTwice)
SoSelection will pick once on mouse down and once on mouse up, and make sure the picks match before c...
void performSingleSelection(SoPath *path)
void select(const SoPath *path)
Select the passed path by adding it to the selection list.
int getNumSelected() const
Return the number of paths in the selection list.
void addStartCallback(SoSelectionClassCB *f, void *userData=NULL)
The start callbacks are invoked when the user has initiated an interactive change to the selection li...
SoCallbackList * deselCBList
Group node that saves and restores traversal state.
Maintains a list of SoTypes.
Definition SoLists.h:295