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_SELECTOR_H
28 #define SVTK_SELECTOR_H
31 #include "SVTK_Selection.h"
32 #include "SVTK_Hash.h"
34 #include "SALOME_ListIO.hxx"
36 #include <VTKViewer_Filter.h>
38 #include <TColStd_MapOfInteger.hxx>
39 #include <TColStd_IndexedMapOfInteger.hxx>
41 #include <vtkObject.h>
43 class SALOME_InteractiveObject;
45 class SVTK_SelectionEvent;
46 class vtkActorCollection;
49 //! Define an abstract interface for selection in SVTK package
51 The class implements selection functionality through storing corresponding
52 references to #SALOME_InteractiveObject. For implementation of subselection
53 modes it keeps a corresponding map of sub indexes.
55 Also, for each #SALOME_InteractiveObject it tries to keep corresponding refenrence to #SALOME_Actor
57 class SVTK_EXPORT SVTK_Selector: public vtkObject
60 static SVTK_Selector* New();
62 vtkTypeMacro(SVTK_Selector,vtkObject);
64 //! To change current Selection_Mode (as outside effect, it invokes selectionChange signal)
67 SetSelectionMode(Selection_Mode theMode) = 0;
69 //! Get current Selection_Mode
72 SelectionMode() const = 0;
79 //! Try to find corresponding #SALOME_Actor for given reference on #SALOME_InteractiveObject
82 GetActor(const Handle(SALOME_InteractiveObject)& theIO) const = 0;
84 //! Check, is the #SALOME_InteractiveObject is present into selection
87 IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const = 0;
89 //! Check, is the #SALOME_Actor is present into selection
92 IsSelected(SALOME_Actor* theActor) const = 0;
94 //! Modify the selection by adding new reference on #SALOME_InteractiveObject
97 AddIObject(const Handle(SALOME_InteractiveObject)& theIO) = 0;
99 //! Modify the selection by adding new reference on #SALOME_Actor
102 AddIObject(SALOME_Actor* theActor) = 0;
104 //! Modify the selection by removing a reference on #SALOME_InteractiveObject
107 RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO) = 0;
109 //! Modify the selection by removing a reference on #SALOME_Actor
112 RemoveIObject(SALOME_Actor* theActor) = 0;
114 //! Get all #SALOME_InteractiveObject references that is present into selection
117 StoredIObjects() const = 0;
119 //! Get number of selected objects
122 IObjectCount() const = 0;
124 //! Check, if the #SALOME_InteractiveObject has a subselection
127 HasIndex(const Handle(SALOME_InteractiveObject)& theIO ) const = 0;
129 //! Get indexes of subslection for given #SALOME_InteractiveObject
132 GetIndex( const Handle(SALOME_InteractiveObject)& theIO,
133 TColStd_IndexedMapOfInteger& theIndex ) = 0;
135 //! Change indices of subselection for given #SALOME_InteractiveObject
138 AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
139 const TColStd_IndexedMapOfInteger& theIndices,
140 bool theIsModeShift) = 0;
142 //! Change indexes of subslection for given #SALOME_InteractiveObject
145 AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
146 const TColStd_MapOfInteger& theIndices,
147 bool theIsModeShift) = 0;
149 //! Change index of subslection for given #SALOME_InteractiveObject
152 AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
154 bool theIsModeShift) = 0;
156 //! Change index of subslection for given #SALOME_InteractiveObject
159 RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
162 //! Check, if the given index is present in subselection
165 IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO,
166 int theIndex) const = 0;
168 //! Clear subselection
173 /// ! Composite indexes
176 HasCompositeIndex(const Handle(SALOME_InteractiveObject)& theIO ) const = 0;
178 //! Get composite indexes of subslection for given #SALOME_InteractiveObject
181 GetCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO,
182 SVTK_IndexedMapOfIds& theIds ) = 0;
184 //! Change composite indices of subselection for given #SALOME_InteractiveObject
187 AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO,
188 const SVTK_IndexedMapOfIds& theIds,
189 bool theIsModeShift) = 0;
191 //! Change composite index of subslection for given #SALOME_InteractiveObject
194 AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO,
195 SVTK_ListOfInteger ids,
196 bool theIsModeShift) = 0;
198 //! Change composite index of subslection for given #SALOME_InteractiveObject
201 RemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO,
202 SVTK_ListOfInteger ids ) = 0;
204 //! Check, if the given composite index is present in subselection
207 IsCompositeIndexSelected(const Handle(SALOME_InteractiveObject)& theIO,
208 SVTK_ListOfInteger ids ) const = 0;
210 //! Clear composite indexes subselection
213 ClearCompositeIndex() = 0;
215 //----------------------------------------------------------------------------
216 typedef int TFilterID;
218 //! To apply a filter on the selection
221 SetFilter(const Handle(VTKViewer_Filter)& theFilter) = 0;
223 //! To get a section filter by its number
225 Handle(VTKViewer_Filter)
226 GetFilter(const TFilterID theId) const = 0;
228 //! Check, if a filter with given number is applyed
231 IsFilterPresent(const TFilterID theId) const = 0;
233 //! To remove a filter from the selection
236 RemoveFilter(const TFilterID theId) = 0;
238 //! Check, if the index satisfy to the installed filters
241 IsValid(SALOME_Actor* theActor,
243 const bool theIsNode = false) const = 0;
245 //----------------------------------------------------------------------------
248 StartPickCallback() = 0;
250 //! To invoke selectionChanged signals
253 EndPickCallback() = 0;
255 //----------------------------------------------------------------------------
258 Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const = 0;
262 SetTolerance(const double& theTolerance) = 0;
266 SetDynamicPreSelection( bool theIsDynPreselect ) = 0;
270 GetDynamicPreSelection() const = 0;
274 SetPreSelectionEnabled( bool theEnabled ) = 0;
278 IsPreSelectionEnabled() const = 0;
282 SetSelectionEnabled( bool theEnabled ) = 0;
286 IsSelectionEnabled() const = 0;