Coin Logo http://www.sim.no
http://www.coin3d.org

SoSelection.h
1 #ifndef COIN_SOSELECTION_H
2 #define COIN_SOSELECTION_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Systems in Motion about acquiring
18  * a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <Inventor/nodes/SoSubNode.h>
28 #include <Inventor/nodes/SoSeparator.h>
29 #include <Inventor/fields/SoSFEnum.h>
30 #include <Inventor/lists/SoPathList.h>
31 
32 class SoSelection;
33 class SoPath;
34 class SoPickedPoint;
35 class SoCallbackList;
36 
37 typedef void SoSelectionPathCB(void * data, SoPath * path);
38 typedef void SoSelectionClassCB(void * data, SoSelection * sel);
39 typedef SoPath * SoSelectionPickCB(void * data, const SoPickedPoint * pick);
40 
41 class COIN_DLL_API SoSelection : public SoSeparator {
42  typedef SoSeparator inherited;
43 
44  SO_NODE_HEADER(SoSelection);
45 
46 public:
47  static void initClass(void);
48  SoSelection(void);
49 
50  enum Policy {
51  SINGLE, TOGGLE, SHIFT
52  };
53 
55 
56  SoSelection(const int nChildren);
57 
58  void select(const SoPath * path);
59  void select(SoNode *node);
60  void deselect(const SoPath * path);
61  void deselect(const int which);
62  void deselect(SoNode * node);
63  void toggle(const SoPath * path);
64  void toggle(SoNode * node);
65  SbBool isSelected(const SoPath * path) const;
66  SbBool isSelected(SoNode * node) const;
67  void deselectAll(void);
68  int getNumSelected(void) const;
69  const SoPathList * getList(void) const;
70  SoPath * getPath(const int index) const;
71  SoPath * operator[](const int i) const;
72  void addSelectionCallback(SoSelectionPathCB * f, void * userData = NULL);
73  void removeSelectionCallback(SoSelectionPathCB * f, void * userData = NULL);
74  void addDeselectionCallback(SoSelectionPathCB * f, void * userData = NULL);
75  void removeDeselectionCallback(SoSelectionPathCB * f,
76  void * userData = NULL);
77  void addStartCallback(SoSelectionClassCB * f, void * userData = NULL);
78  void removeStartCallback(SoSelectionClassCB * f, void * userData = NULL);
79  void addFinishCallback(SoSelectionClassCB * f, void * userData = NULL);
80  void removeFinishCallback(SoSelectionClassCB * f, void * userData = NULL);
81  void setPickFilterCallback(SoSelectionPickCB * f, void * userData = NULL,
82  const SbBool callOnlyIfSelectable = TRUE);
83  void setPickMatching(const SbBool pickMatching);
84  SbBool isPickMatching(void) const;
85  SbBool getPickMatching(void) const;
86  void addChangeCallback(SoSelectionClassCB * f, void * userData = NULL);
87  void removeChangeCallback(SoSelectionClassCB * f, void * userData = NULL);
88 
89 protected:
90  virtual ~SoSelection();
91 
92  void invokeSelectionPolicy(SoPath *path, SbBool shiftDown);
93  void performSingleSelection(SoPath *path);
94  void performToggleSelection(SoPath *path);
95  SoPath * copyFromThis(const SoPath * path) const;
96  void addPath(SoPath *path);
97  void removePath(const int which);
98  int findPath(const SoPath *path) const;
99 
100  virtual void handleEvent(SoHandleEventAction * action);
101 
102 protected: // unfortunately only protected in OIV
103 
105 
110 
111  SoSelectionPickCB *pickCBFunc;
112  void *pickCBData;
114 
116 
118  SbBool pickMatching;
119 
120 private:
121  void init();
122  SoPath *searchNode(SoNode * node) const;
123  SoPath *getSelectionPath(SoHandleEventAction *action,
124  SbBool &ignorepick, SbBool &haltaction);
125 };
126 
127 #endif // !COIN_SOSELECTION_H
SoSelection::setPickMatching
void setPickMatching(const SbBool pickMatching)
Definition: SoSelection.cpp:656
SbPList::getLength
int getLength(void) const
Definition: SbPList.h:94
SoSelection::removeDeselectionCallback
void removeDeselectionCallback(SoSelectionPathCB *f, void *userData=NULL)
Definition: SoSelection.cpp:555
SoSelection::callPickCBOnlyIfSelectable
SbBool callPickCBOnlyIfSelectable
Definition: SoSelection.h:113
SoSelection::TOGGLE
@ TOGGLE
Definition: SoSelection.h:51
SoCallbackList::removeCallback
void removeCallback(SoCallbackListCB *f, void *userdata=NULL)
Definition: SoCallbackList.cpp:71
SoBaseList::remove
void remove(const int index)
Definition: SoBaseList.cpp:121
SoAction::apply
virtual void apply(SoNode *root)
Definition: SoAction.cpp:476
SoSelection::addFinishCallback
void addFinishCallback(SoSelectionClassCB *f, void *userData=NULL)
Definition: SoSelection.cpp:594
SoSelection::pickCBFunc
SoSelectionPickCB * pickCBFunc
Definition: SoSelection.h:111
SoSelection::finishCBList
SoCallbackList * finishCBList
Definition: SoSelection.h:109
SoSelection::getNumSelected
int getNumSelected(void) const
Definition: SoSelection.cpp:482
SoSelection::addChangeCallback
void addChangeCallback(SoSelectionClassCB *f, void *userData=NULL)
Definition: SoSelection.cpp:688
SoSelection::pickMatching
SbBool pickMatching
Definition: SoSelection.h:118
SoSelection::removeChangeCallback
void removeChangeCallback(SoSelectionClassCB *f, void *userData=NULL)
Definition: SoSelection.cpp:698
SoSelection::removeStartCallback
void removeStartCallback(SoSelectionClassCB *f, void *userData=NULL)
Definition: SoSelection.cpp:581
SoSelection::isPickMatching
SbBool isPickMatching(void) const
Definition: SoSelection.cpp:667
SoSelection::setPickFilterCallback
void setPickFilterCallback(SoSelectionPickCB *f, void *userData=NULL, const SbBool callOnlyIfSelectable=1)
Definition: SoSelection.cpp:638
SoSelection::mouseDownPickPath
SoPath * mouseDownPickPath
Definition: SoSelection.h:117
SoSelection::~SoSelection
virtual ~SoSelection()
Definition: SoSelection.cpp:301
SoSearchAction
The SoSearchAction class provides methods for searching through scene graphs.
Definition: SoSearchAction.h:32
SoSelection::toggle
void toggle(const SoPath *path)
Definition: SoSelection.cpp:420
SoSearchAction::setNode
void setNode(SoNode *const node)
Definition: SoSearchAction.cpp:145
SoSelection::selCBList
SoCallbackList * selCBList
Definition: SoSelection.h:106
SoSelection::invokeSelectionPolicy
void invokeSelectionPolicy(SoPath *path, SbBool shiftDown)
Definition: SoSelection.cpp:707
SoSelection::copyFromThis
SoPath * copyFromThis(const SoPath *path) const
Definition: SoSelection.cpp:774
SoSelection::removeSelectionCallback
void removeSelectionCallback(SoSelectionPathCB *f, void *userData=NULL)
Definition: SoSelection.cpp:532
SoSelection::Policy
Policy
Definition: SoSelection.h:50
SoSelection::deselect
void deselect(const SoPath *path)
Definition: SoSelection.cpp:384
SoPathList
The SoPathList class is a container for pointers to SoPath objects.
Definition: SoPathList.h:31
SoCallbackList::addCallback
void addCallback(SoCallbackListCB *f, void *userData=NULL)
Definition: SoCallbackList.cpp:59
SoSelection::handleEvent
virtual void handleEvent(SoHandleEventAction *action)
Definition: SoSelection.cpp:835
SoSelection::deselCBList
SoCallbackList * deselCBList
Definition: SoSelection.h:107
SoSelection::findPath
int findPath(const SoPath *path) const
Definition: SoSelection.cpp:815
SoSelection::pickCBData
void * pickCBData
Definition: SoSelection.h:112
SoSelection::getPickMatching
SbBool getPickMatching(void) const
Definition: SoSelection.cpp:678
SoSelection::policy
SoSFEnum policy
Definition: SoSelection.h:54
SoCallbackList
The SoCallbackList is a container for callback function pointers.
Definition: SoCallbackList.h:35
SoSelection::changeCBList
SoCallbackList * changeCBList
Definition: SoSelection.h:115
SoHandleEventAction::setHandled
void setHandled(void)
Definition: SoHandleEventAction.cpp:211
SoBase::unref
void unref(void) const
Definition: SoBase.cpp:627
SoPathList::append
void append(SoPath *const path)
Definition: SoPathList.cpp:88
SoCallbackList::invokeCallbacks
void invokeCallbacks(void *callbackdata)
Definition: SoCallbackList.cpp:129
SoPath::findNode
int findNode(const SoNode *const node) const
Definition: SoPath.cpp:587
SoSelection::addDeselectionCallback
void addDeselectionCallback(SoSelectionPathCB *f, void *userData=NULL)
Definition: SoSelection.cpp:544
SoPath
The SoPath class is a container class for traversal path descriptions.
Definition: SoPath.h:43
SoSeparator::handleEvent
virtual void handleEvent(SoHandleEventAction *action)
Definition: SoSeparator.cpp:745
SoSelection::deselectAll
void deselectAll(void)
Definition: SoSelection.cpp:472
SoHandleEventAction::isHandled
SbBool isHandled(void) const
Definition: SoHandleEventAction.cpp:223
SoPath::getLength
int getLength(void) const
Definition: SoPath.cpp:473
SoSelection::getList
const SoPathList * getList(void) const
Definition: SoSelection.cpp:491
SoSelection::getPath
SoPath * getPath(const int index) const
Definition: SoSelection.cpp:500
SoSelection::SINGLE
@ SINGLE
Definition: SoSelection.h:51
SoSelection::isSelected
SbBool isSelected(const SoPath *path) const
Definition: SoSelection.cpp:447
SoSearchAction::getPath
SoPath * getPath(void) const
Definition: SoSearchAction.cpp:317
SoSFEnum
The SoSFEnum class is a container for an enum value.
Definition: SoSFEnum.h:31
SoSelection::removeFinishCallback
void removeFinishCallback(SoSelectionClassCB *f, void *userData=NULL)
Definition: SoSelection.cpp:605
SoSelection::performToggleSelection
void performToggleSelection(SoPath *path)
Definition: SoSelection.cpp:757
SoBase
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition: SoBase.h:41
SoSelection::operator[]
SoPath * operator[](const int i) const
Definition: SoSelection.cpp:509
SoSelection::performSingleSelection
void performSingleSelection(SoPath *path)
Definition: SoSelection.cpp:723
SoSelection::startCBList
SoCallbackList * startCBList
Definition: SoSelection.h:108
SoSelection::SoSelection
SoSelection(void)
Definition: SoSelection.cpp:279
SoBase::ref
void ref(void) const
Definition: SoBase.cpp:574
SoSearchAction::setInterest
void setInterest(const Interest interest)
Definition: SoSearchAction.cpp:249
SoSearchAction::reset
void reset(void)
Definition: SoSearchAction.cpp:341
SoSelection::select
void select(const SoPath *path)
Definition: SoSelection.cpp:353
SoSelection::SHIFT
@ SHIFT
Definition: SoSelection.h:51
SoPath::copy
SoPath * copy(const int startfromnodeindex=0, int numnodes=0) const
Definition: SoPath.cpp:673
SoSelection::addSelectionCallback
void addSelectionCallback(SoSelectionPathCB *f, void *userData=NULL)
Definition: SoSelection.cpp:521
SoPickedPoint
The SoPickedPoint class is used for specifying picked points.
Definition: SoPickedPoint.h:39
SoSeparator
The SoSeparator class is a state-preserving group node.
Definition: SoSeparator.h:34
SoSelection::removePath
void removePath(const int which)
Definition: SoSelection.cpp:801
SoPathList::findPath
int findPath(const SoPath &path) const
Definition: SoPathList.cpp:120
SoHandleEventAction::getEvent
const SoEvent * getEvent(void) const
Definition: SoHandleEventAction.cpp:196
SoPath::getNode
SoNode * getNode(const int index) const
Definition: SoPath.cpp:402
SoHandleEventAction::getPickedPoint
const SoPickedPoint * getPickedPoint(void)
Definition: SoHandleEventAction.cpp:315
SoSelection::addPath
void addPath(SoPath *path)
Definition: SoSelection.cpp:790
SoNode
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:47
SoSelection::addStartCallback
void addStartCallback(SoSelectionClassCB *f, void *userData=NULL)
Definition: SoSelection.cpp:570
SoHandleEventAction
The SoHandleEventAction class distributes user events to the scene.
Definition: SoHandleEventAction.h:36
SoEvent
The SoEvent class is the base class for all Coin events.
Definition: SoEvent.h:34
SoBase::unrefNoDelete
void unrefNoDelete(void) const
Definition: SoBase.cpp:665
SoPickedPoint::getPath
SoPath * getPath() const
Definition: SoPickedPoint.cpp:178
SoSelection::selectionList
SoPathList selectionList
Definition: SoSelection.h:104
SoPath::getHead
SoNode * getHead(void) const
Definition: SoPath.cpp:180
SoSelection
The SoSelection class manages a list of selected nodes.
Definition: SoSelection.h:41

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Wed Jul 24 2019 for Coin by Doxygen. 1.8.17