00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef COIN_SOSELECTION_H
00021 #define COIN_SOSELECTION_H
00022
00023 #include <Inventor/nodes/SoSubNode.h>
00024 #include <Inventor/nodes/SoSeparator.h>
00025 #include <Inventor/fields/SoSFEnum.h>
00026 #include <Inventor/lists/SoPathList.h>
00027
00028 class SoSelection;
00029 class SoPath;
00030 class SoPickedPoint;
00031 class SoCallbackList;
00032
00033 typedef void SoSelectionPathCB(void * data, SoPath * path);
00034 typedef void SoSelectionClassCB(void * data, SoSelection * sel);
00035 typedef SoPath * SoSelectionPickCB(void * data, const SoPickedPoint * pick);
00036
00037
00038 class COIN_DLL_API SoSelection : public SoSeparator {
00039 typedef SoSeparator inherited;
00040
00041 SO_NODE_HEADER(SoSelection);
00042
00043 public:
00044 static void initClass(void);
00045 SoSelection(void);
00046
00047 enum Policy {
00048 SINGLE, TOGGLE, SHIFT
00049 };
00050
00051 SoSFEnum policy;
00052
00053 SoSelection(const int nChildren);
00054
00055 void select(const SoPath * path);
00056 void select(SoNode *node);
00057 void deselect(const SoPath * path);
00058 void deselect(const int which);
00059 void deselect(SoNode * node);
00060 void toggle(const SoPath * path);
00061 void toggle(SoNode * node);
00062 SbBool isSelected(const SoPath * path) const;
00063 SbBool isSelected(SoNode * node) const;
00064 void deselectAll(void);
00065 int getNumSelected(void) const;
00066 const SoPathList * getList(void) const;
00067 SoPath * getPath(const int index) const;
00068 SoPath * operator[](const int i) const;
00069 void addSelectionCallback(SoSelectionPathCB * f, void * userData = NULL);
00070 void removeSelectionCallback(SoSelectionPathCB * f, void * userData = NULL);
00071 void addDeselectionCallback(SoSelectionPathCB * f, void * userData = NULL);
00072 void removeDeselectionCallback(SoSelectionPathCB * f,
00073 void * userData = NULL);
00074 void addStartCallback(SoSelectionClassCB * f, void * userData = NULL);
00075 void removeStartCallback(SoSelectionClassCB * f, void * userData = NULL);
00076 void addFinishCallback(SoSelectionClassCB * f, void * userData = NULL);
00077 void removeFinishCallback(SoSelectionClassCB * f, void * userData = NULL);
00078 void setPickFilterCallback(SoSelectionPickCB * f, void * userData = NULL,
00079 const SbBool callOnlyIfSelectable = TRUE);
00080 void setPickMatching(const SbBool pickMatching);
00081 SbBool isPickMatching(void) const;
00082 SbBool getPickMatching(void) const;
00083 void addChangeCallback(SoSelectionClassCB * f, void * userData = NULL);
00084 void removeChangeCallback(SoSelectionClassCB * f, void * userData = NULL);
00085
00086 protected:
00087 virtual ~SoSelection();
00088
00089 void invokeSelectionPolicy(SoPath *path, SbBool shiftDown);
00090 void performSingleSelection(SoPath *path);
00091 void performToggleSelection(SoPath *path);
00092 SoPath * copyFromThis(const SoPath * path) const;
00093 void addPath(SoPath *path);
00094 void removePath(const int which);
00095 int findPath(const SoPath *path) const;
00096
00097 virtual void handleEvent(SoHandleEventAction * action);
00098
00099 protected:
00100
00101 SoPathList selectionList;
00102
00103 SoCallbackList *selCBList;
00104 SoCallbackList *deselCBList;
00105 SoCallbackList *startCBList;
00106 SoCallbackList *finishCBList;
00107
00108 SoSelectionPickCB *pickCBFunc;
00109 void *pickCBData;
00110 SbBool callPickCBOnlyIfSelectable;
00111
00112 SoCallbackList *changeCBList;
00113
00114 SoPath *mouseDownPickPath;
00115 SbBool pickMatching;
00116
00117 private:
00118 void init();
00119 SoPath *searchNode(SoNode * node) const;
00120 SoPath *getSelectionPath(SoHandleEventAction *action,
00121 SbBool &ignorepick, SbBool &haltaction);
00122
00123 };
00124
00125 #endif // !COIN_SOSELECTION_H