1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
24 // File : SALOME_Selection.h
25 // Author : Nicolas REJNERI
27 #ifndef SVTK_SELECTORDEF_H
28 #define SVTK_SELECTORDEF_H
30 #include "SVTK_Selector.h"
35 #include <TColStd_IndexedMapOfInteger.hxx>
36 #include <TColStd_MapOfInteger.hxx>
37 #include <vtkSmartPointer.h>
39 #include "SALOME_InteractiveObject.hxx"
44 class SVTK_ViewWindow;
48 class SVTK_SelectorDef: public SVTK_Selector
52 virtual ~SVTK_SelectorDef();
56 SetSelectionMode(Selection_Mode theMode);
60 SelectionMode() const { return mySelectionMode; }
68 GetActor(const Handle(SALOME_InteractiveObject)& theIO) const;
72 IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const;
76 IsSelected(SALOME_Actor* theActor) const;
80 AddIObject(const Handle(SALOME_InteractiveObject)& theIO);
84 AddIObject(SALOME_Actor* theActor);
88 RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO);
92 RemoveIObject(SALOME_Actor* theActor);
96 StoredIObjects() const;
100 IObjectCount() const;
104 HasIndex(const Handle(SALOME_InteractiveObject)& theIO ) const;
108 GetIndex( const Handle(SALOME_InteractiveObject)& theIO,
109 SVTK_TIndexedMapOfVtkId& theIndex );
113 AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
114 const SVTK_TIndexedMapOfVtkId& theIndices,
115 bool theIsModeShift);
118 AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
119 const SVTK_TVtkIDsMap& theIndices,
120 bool theIsModeShift);
123 AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
125 bool theIsModeShift);
128 RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
132 IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO,
138 //----------------------------------------------------------------------------
139 /// ! Composite indexes
142 HasCompositeIndex(const Handle(SALOME_InteractiveObject)& theIO ) const;
146 GetCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO,
147 SVTK_IndexedMapOfVtkIds& theIds );
150 AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO,
151 const SVTK_IndexedMapOfVtkIds& theIds,
152 bool theIsModeShift);
156 AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO,
157 SVTK_ListOfVtk theIds,
158 bool theIsModeShift);
162 RemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO,
163 SVTK_ListOfVtk theIds );
167 IsCompositeIndexSelected(const Handle(SALOME_InteractiveObject)& theIO,
168 SVTK_ListOfVtk theIds ) const;
172 ClearCompositeIndex();
174 //----------------------------------------------------------------------------
177 SetFilter(const Handle(VTKViewer_Filter)& theFilter);
180 Handle(VTKViewer_Filter)
181 GetFilter(const TFilterID theId) const;
185 IsFilterPresent(const TFilterID theId) const;
189 RemoveFilter(const int theId);
193 IsValid(SALOME_Actor* theActor,
194 const TFilterID theId,
195 const bool theIsNode = false) const;
197 //----------------------------------------------------------------------------
206 //----------------------------------------------------------------------------
209 Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const;
213 SetTolerance(const double& theTolerance);
217 SetDynamicPreSelection( bool theIsDynPreselect );
221 GetDynamicPreSelection() const;
225 SetPreSelectionEnabled( bool theEnabled );
229 IsPreSelectionEnabled() const;
233 SetSelectionEnabled( bool theEnabled );
237 IsSelectionEnabled() const;
242 bool myDynamicPreselection;
243 bool myPreselectionEnabled;
244 bool mySelectionEnabled;
249 operator()(const Handle(SALOME_InteractiveObject)& theRightIO,
250 const Handle(SALOME_InteractiveObject)& theLeftIO) const
252 return strcmp(theRightIO->getEntry(),theLeftIO->getEntry()) < 0;
256 struct TIndexedMapOfInteger
258 SVTK_TIndexedMapOfVtkId myMap;
259 TIndexedMapOfInteger()
261 TIndexedMapOfInteger(const TIndexedMapOfInteger& theIndexedMapOfInteger)
263 myMap = theIndexedMapOfInteger.myMap;
267 mutable SALOME_ListIO myIObjectList;
268 typedef std::set<Handle(SALOME_InteractiveObject),
269 TIOLessThan> TIObjects;
270 TIObjects myIObjects;
272 typedef std::map<Handle(SALOME_InteractiveObject),
273 vtkSmartPointer<SALOME_Actor>,
274 TIOLessThan> TIO2Actors;
275 TIO2Actors myIO2Actors;
277 typedef std::map<Handle(SALOME_InteractiveObject),
278 TIndexedMapOfInteger,
279 TIOLessThan> TMapIOSubIndex;
280 TMapIOSubIndex myMapIOSubIndex;
282 typedef std::map<Handle(SALOME_InteractiveObject),
283 SVTK_IndexedMapOfVtkIds,
284 TIOLessThan> TMapIOSubCompositeIndex;
285 TMapIOSubCompositeIndex myMapIOSubCompositeIndex;
288 typedef std::map<TFilterID,Handle(VTKViewer_Filter)> TFilters;
291 vtkSmartPointer<vtkPicker> myPicker;
292 vtkSmartPointer<vtkCellPicker> myCellPicker;