Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

SoSelection.h

00001 /**************************************************************************\ 00002 * 00003 * This file is part of the Coin 3D visualization library. 00004 * Copyright (C) 1998-2003 by Systems in Motion. All rights reserved. 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * version 2.1 as published by the Free Software Foundation. See the 00009 * file LICENSE.LGPL at the root directory of the distribution for 00010 * more details. 00011 * 00012 * If you want to use Coin for applications not compatible with the 00013 * LGPL, please contact SIM to acquire a Professional Edition license. 00014 * 00015 * Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY 00016 * http://www.sim.no support@sim.no Voice: +47 22114160 Fax: +47 22207097 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: // unfortunately only protected in OIV 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

Generated on Tue Jul 27 23:53:02 2004 for Coin by doxygen 1.3.7