Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef SVTK_SELECTORDEF_H
00030 #define SVTK_SELECTORDEF_H
00031
00032 #include <set>
00033 #include <map>
00034
00035 #include <TColStd_IndexedMapOfInteger.hxx>
00036 #include <TColStd_MapOfInteger.hxx>
00037 #include <vtkSmartPointer.h>
00038
00039 #include "SALOME_InteractiveObject.hxx"
00040
00041 #include "SVTK_Selector.h"
00042
00043 class SALOME_Actor;
00044
00045 class SVTK_Viewer;
00046 class SVTK_ViewWindow;
00047 class vtkPicker;
00048 class vtkCellPicker;
00049
00050 class SVTK_SelectorDef: public SVTK_Selector
00051 {
00052 public:
00053 SVTK_SelectorDef();
00054 virtual ~SVTK_SelectorDef();
00055
00056 virtual
00057 void
00058 SetSelectionMode(Selection_Mode theMode);
00059
00060 virtual
00061 Selection_Mode
00062 SelectionMode() const { return mySelectionMode; }
00063
00064 virtual
00065 void
00066 ClearIObjects();
00067
00068 virtual
00069 SALOME_Actor*
00070 GetActor(const Handle(SALOME_InteractiveObject)& theIO) const;
00071
00072 virtual
00073 bool
00074 IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const;
00075
00076 virtual
00077 bool
00078 IsSelected(SALOME_Actor* theActor) const;
00079
00080 virtual
00081 bool
00082 AddIObject(const Handle(SALOME_InteractiveObject)& theIO);
00083
00084 virtual
00085 bool
00086 AddIObject(SALOME_Actor* theActor);
00087
00088 virtual
00089 bool
00090 RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO);
00091
00092 virtual
00093 bool
00094 RemoveIObject(SALOME_Actor* theActor);
00095
00096 virtual
00097 const SALOME_ListIO&
00098 StoredIObjects() const;
00099
00100 virtual
00101 int
00102 IObjectCount() const;
00103
00104 virtual
00105 bool
00106 HasIndex(const Handle(SALOME_InteractiveObject)& theIO ) const;
00107
00108 virtual
00109 void
00110 GetIndex( const Handle(SALOME_InteractiveObject)& theIO,
00111 TColStd_IndexedMapOfInteger& theIndex );
00112
00113 virtual
00114 bool
00115 AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
00116 const TColStd_IndexedMapOfInteger& theIndices,
00117 bool theIsModeShift);
00118 virtual
00119 bool
00120 AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
00121 const TColStd_MapOfInteger& theIndices,
00122 bool theIsModeShift);
00123 virtual
00124 bool
00125 AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
00126 int theIndex,
00127 bool theIsModeShift);
00128 virtual
00129 void
00130 RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
00131 int theIndex);
00132 virtual
00133 bool
00134 IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO,
00135 int theIndex) const;
00136 virtual
00137 void
00138 ClearIndex();
00139
00140
00141 virtual
00142 void
00143 SetFilter(const Handle(VTKViewer_Filter)& theFilter);
00144
00145 virtual
00146 Handle(VTKViewer_Filter)
00147 GetFilter(const TFilterID theId) const;
00148
00149 virtual
00150 bool
00151 IsFilterPresent(const TFilterID theId) const;
00152
00153 virtual
00154 void
00155 RemoveFilter(const int theId);
00156
00157 virtual
00158 bool
00159 IsValid(SALOME_Actor* theActor,
00160 const TFilterID theId,
00161 const bool theIsNode = false) const;
00162
00163
00164 virtual
00165 void
00166 StartPickCallback();
00167
00168 virtual
00169 void
00170 EndPickCallback();
00171
00172
00173 virtual
00174 vtkActorCollection*
00175 Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const;
00176
00177 virtual
00178 void
00179 SetTolerance(const double& theTolerance);
00180
00181 private:
00182 int mySelectionMode;
00183
00184 struct TIOLessThan
00185 {
00186 bool
00187 operator()(const Handle(SALOME_InteractiveObject)& theRightIO,
00188 const Handle(SALOME_InteractiveObject)& theLeftIO) const
00189 {
00190 return strcmp(theRightIO->getEntry(),theLeftIO->getEntry()) < 0;
00191 }
00192 };
00193
00194 struct TIndexedMapOfInteger
00195 {
00196 TColStd_IndexedMapOfInteger myMap;
00197 TIndexedMapOfInteger()
00198 {}
00199 TIndexedMapOfInteger(const TIndexedMapOfInteger& theIndexedMapOfInteger)
00200 {
00201 myMap = theIndexedMapOfInteger.myMap;
00202 }
00203 };
00204
00205 mutable SALOME_ListIO myIObjectList;
00206 typedef std::set<Handle(SALOME_InteractiveObject),
00207 TIOLessThan> TIObjects;
00208 TIObjects myIObjects;
00209
00210 typedef std::map<Handle(SALOME_InteractiveObject),
00211 vtkSmartPointer<SALOME_Actor>,
00212 TIOLessThan> TIO2Actors;
00213 TIO2Actors myIO2Actors;
00214
00215 typedef std::map<Handle(SALOME_InteractiveObject),
00216 TIndexedMapOfInteger,
00217 TIOLessThan> TMapIOSubIndex;
00218 TMapIOSubIndex myMapIOSubIndex;
00219
00220 typedef std::map<TFilterID,Handle(VTKViewer_Filter)> TFilters;
00221 TFilters myFilters;
00222
00223 vtkSmartPointer<vtkPicker> myPicker;
00224 vtkSmartPointer<vtkCellPicker> myCellPicker;
00225 };
00226
00227 #endif