1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, 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
33 #include <TColStd_IndexedMapOfInteger.hxx>
34 #include <TColStd_MapOfInteger.hxx>
35 #include <vtkSmartPointer.h>
37 #include "SALOME_InteractiveObject.hxx"
39 #include "SVTK_Selector.h"
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 TColStd_IndexedMapOfInteger& theIndex );
113 AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
114 const TColStd_IndexedMapOfInteger& theIndices,
115 bool theIsModeShift);
118 AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
119 const TColStd_MapOfInteger& 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 //----------------------------------------------------------------------------
141 SetFilter(const Handle(VTKViewer_Filter)& theFilter);
144 Handle(VTKViewer_Filter)
145 GetFilter(const TFilterID theId) const;
149 IsFilterPresent(const TFilterID theId) const;
153 RemoveFilter(const int theId);
157 IsValid(SALOME_Actor* theActor,
158 const TFilterID theId,
159 const bool theIsNode = false) const;
161 //----------------------------------------------------------------------------
170 //----------------------------------------------------------------------------
173 Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const;
177 SetTolerance(const double& theTolerance);
181 SetDynamicPreSelection( bool theIsDynPreselect );
185 GetDynamicPreSelection() const;
189 SetPreSelectionEnabled( bool theEnabled );
193 IsPreSelectionEnabled() const;
197 SetSelectionEnabled( bool theEnabled );
201 IsSelectionEnabled() const;
206 bool myDynamicPreselection;
207 bool myPreselectionEnabled;
208 bool mySelectionEnabled;
213 operator()(const Handle(SALOME_InteractiveObject)& theRightIO,
214 const Handle(SALOME_InteractiveObject)& theLeftIO) const
216 return strcmp(theRightIO->getEntry(),theLeftIO->getEntry()) < 0;
220 struct TIndexedMapOfInteger
222 TColStd_IndexedMapOfInteger myMap;
223 TIndexedMapOfInteger()
225 TIndexedMapOfInteger(const TIndexedMapOfInteger& theIndexedMapOfInteger)
227 myMap = theIndexedMapOfInteger.myMap;
231 mutable SALOME_ListIO myIObjectList;
232 typedef std::set<Handle(SALOME_InteractiveObject),
233 TIOLessThan> TIObjects;
234 TIObjects myIObjects;
236 typedef std::map<Handle(SALOME_InteractiveObject),
237 vtkSmartPointer<SALOME_Actor>,
238 TIOLessThan> TIO2Actors;
239 TIO2Actors myIO2Actors;
241 typedef std::map<Handle(SALOME_InteractiveObject),
242 TIndexedMapOfInteger,
243 TIOLessThan> TMapIOSubIndex;
244 TMapIOSubIndex myMapIOSubIndex;
246 typedef std::map<TFilterID,Handle(VTKViewer_Filter)> TFilters;
249 vtkSmartPointer<vtkPicker> myPicker;
250 vtkSmartPointer<vtkCellPicker> myCellPicker;