![]() |
http://www.sim.no http://www.coin3d.org |
00001 #ifndef COIN_SOSELECTION_H 00002 #define COIN_SOSELECTION_H 00003 00004 /**************************************************************************\ 00005 * 00006 * This file is part of the Coin 3D visualization library. 00007 * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * ("GPL") version 2 as published by the Free Software Foundation. 00012 * See the file LICENSE.GPL at the root directory of this source 00013 * distribution for additional information about the GNU GPL. 00014 * 00015 * For using Coin with software that can not be combined with the GNU 00016 * GPL, and for taking advantage of the additional benefits of our 00017 * support services, please contact Systems in Motion about acquiring 00018 * a Coin Professional Edition License. 00019 * 00020 * See http://www.coin3d.org/ for more information. 00021 * 00022 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY. 00023 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org 00024 * 00025 \**************************************************************************/ 00026 00027 #include <Inventor/nodes/SoSubNode.h> 00028 #include <Inventor/nodes/SoSeparator.h> 00029 #include <Inventor/fields/SoSFEnum.h> 00030 #include <Inventor/lists/SoPathList.h> 00031 00032 class SoSelection; 00033 class SoPath; 00034 class SoPickedPoint; 00035 class SoCallbackList; 00036 00037 typedef void SoSelectionPathCB(void * data, SoPath * path); 00038 typedef void SoSelectionClassCB(void * data, SoSelection * sel); 00039 typedef SoPath * SoSelectionPickCB(void * data, const SoPickedPoint * pick); 00040 00041 class COIN_DLL_API SoSelection : public SoSeparator { 00042 typedef SoSeparator inherited; 00043 00044 SO_NODE_HEADER(SoSelection); 00045 00046 public: 00047 static void initClass(void); 00048 SoSelection(void); 00049 00050 enum Policy { 00051 SINGLE, TOGGLE, SHIFT 00052 }; 00053 00054 SoSFEnum policy; 00055 00056 SoSelection(const int nChildren); 00057 00058 void select(const SoPath * path); 00059 void select(SoNode *node); 00060 void deselect(const SoPath * path); 00061 void deselect(const int which); 00062 void deselect(SoNode * node); 00063 void toggle(const SoPath * path); 00064 void toggle(SoNode * node); 00065 SbBool isSelected(const SoPath * path) const; 00066 SbBool isSelected(SoNode * node) const; 00067 void deselectAll(void); 00068 int getNumSelected(void) const; 00069 const SoPathList * getList(void) const; 00070 SoPath * getPath(const int index) const; 00071 SoPath * operator[](const int i) const; 00072 void addSelectionCallback(SoSelectionPathCB * f, void * userData = NULL); 00073 void removeSelectionCallback(SoSelectionPathCB * f, void * userData = NULL); 00074 void addDeselectionCallback(SoSelectionPathCB * f, void * userData = NULL); 00075 void removeDeselectionCallback(SoSelectionPathCB * f, 00076 void * userData = NULL); 00077 void addStartCallback(SoSelectionClassCB * f, void * userData = NULL); 00078 void removeStartCallback(SoSelectionClassCB * f, void * userData = NULL); 00079 void addFinishCallback(SoSelectionClassCB * f, void * userData = NULL); 00080 void removeFinishCallback(SoSelectionClassCB * f, void * userData = NULL); 00081 void setPickFilterCallback(SoSelectionPickCB * f, void * userData = NULL, 00082 const SbBool callOnlyIfSelectable = TRUE); 00083 void setPickMatching(const SbBool pickMatching); 00084 SbBool isPickMatching(void) const; 00085 SbBool getPickMatching(void) const; 00086 void addChangeCallback(SoSelectionClassCB * f, void * userData = NULL); 00087 void removeChangeCallback(SoSelectionClassCB * f, void * userData = NULL); 00088 00089 protected: 00090 virtual ~SoSelection(); 00091 00092 void invokeSelectionPolicy(SoPath *path, SbBool shiftDown); 00093 void performSingleSelection(SoPath *path); 00094 void performToggleSelection(SoPath *path); 00095 SoPath * copyFromThis(const SoPath * path) const; 00096 void addPath(SoPath *path); 00097 void removePath(const int which); 00098 int findPath(const SoPath *path) const; 00099 00100 virtual void handleEvent(SoHandleEventAction * action); 00101 00102 protected: // unfortunately only protected in OIV 00103 00104 SoPathList selectionList; 00105 00106 SoCallbackList *selCBList; 00107 SoCallbackList *deselCBList; 00108 SoCallbackList *startCBList; 00109 SoCallbackList *finishCBList; 00110 00111 SoSelectionPickCB *pickCBFunc; 00112 void *pickCBData; 00113 SbBool callPickCBOnlyIfSelectable; 00114 00115 SoCallbackList *changeCBList; 00116 00117 SoPath *mouseDownPickPath; 00118 SbBool pickMatching; 00119 00120 private: 00121 void init(); 00122 SoPath *searchNode(SoNode * node) const; 00123 SoPath *getSelectionPath(SoHandleEventAction *action, 00124 SbBool &ignorepick, SbBool &haltaction); 00125 }; 00126 00127 #endif // !COIN_SOSELECTION_H
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Mon Feb 28 2011 10:11:57 for Coin by Doxygen. 1.7.3