Salome HOME
Updated copyright comment
[modules/gui.git] / src / SVTK / SVTK_Selector.h
1 // Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
24 //  File   : SALOME_Selection.h
25 //  Author : Nicolas REJNERI
26
27 #ifndef SVTK_SELECTOR_H
28 #define SVTK_SELECTOR_H
29
30 #include "SVTK.h"
31 #include "SVTK_Selection.h"
32 #include "SVTK_Hash.h"
33
34 #include "SALOME_ListIO.hxx"
35
36 #include <VTKViewer_Filter.h>
37
38 #include <TColStd_MapOfInteger.hxx>
39 #include <TColStd_IndexedMapOfInteger.hxx>
40
41 #include <vtkObject.h>
42
43 class SALOME_InteractiveObject;
44 class SALOME_Actor;
45 class SVTK_SelectionEvent;
46 class vtkActorCollection;
47 class vtkRenderer;
48
49 //! Define an abstract interface for selection in SVTK package
50 /*!
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.
54   \note
55   Also, for each #SALOME_InteractiveObject it tries to keep corresponding refenrence to #SALOME_Actor
56  */
57 class SVTK_EXPORT SVTK_Selector: public vtkObject
58 {
59 public:
60   static SVTK_Selector* New();
61   
62   vtkTypeMacro(SVTK_Selector,vtkObject)
63
64   //! To change current Selection_Mode (as outside effect, it invokes selectionChange signal)
65   virtual
66   void 
67   SetSelectionMode(Selection_Mode theMode) = 0;
68
69   //! Get current Selection_Mode
70   virtual
71   Selection_Mode
72   SelectionMode() const = 0;
73
74   //! Clear selection
75   virtual
76   void
77   ClearIObjects() = 0;
78
79   //! Try to find corresponding #SALOME_Actor for given reference on #SALOME_InteractiveObject
80   virtual
81   SALOME_Actor* 
82   GetActor(const Handle(SALOME_InteractiveObject)& theIO) const = 0;
83
84   //! Check, is the #SALOME_InteractiveObject is present into selection
85   virtual
86   bool
87   IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const = 0;
88
89   //! Check, is the #SALOME_Actor is present into selection
90   virtual
91   bool
92   IsSelected(SALOME_Actor* theActor) const = 0;
93
94   //! Modify the selection by adding new reference on #SALOME_InteractiveObject
95   virtual
96   bool
97   AddIObject(const Handle(SALOME_InteractiveObject)& theIO) = 0;
98
99   //! Modify the selection by adding new reference on #SALOME_Actor
100   virtual
101   bool
102   AddIObject(SALOME_Actor* theActor) = 0;
103
104   //! Modify the selection by removing a reference on #SALOME_InteractiveObject
105   virtual
106   bool 
107   RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO) = 0;
108
109   //! Modify the selection by removing a reference on #SALOME_Actor
110   virtual
111   bool 
112   RemoveIObject(SALOME_Actor* theActor) = 0;
113
114   //! Get all #SALOME_InteractiveObject references that is present into selection
115   virtual
116   const SALOME_ListIO& 
117   StoredIObjects() const = 0;
118
119   //! Get number of selected objects
120   virtual
121   int 
122   IObjectCount() const = 0;
123
124   //! Check, if the #SALOME_InteractiveObject has a subselection
125   virtual
126   bool 
127   HasIndex(const Handle(SALOME_InteractiveObject)& theIO ) const = 0;
128
129   //! Get indexes of subslection for given #SALOME_InteractiveObject
130   virtual
131   void 
132   GetIndex( const Handle(SALOME_InteractiveObject)& theIO, 
133             SVTK_TIndexedMapOfVtkId& theIndex ) = 0;
134         
135   //! Change indices of subselection for given #SALOME_InteractiveObject
136   virtual
137   bool 
138   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
139                     const SVTK_TIndexedMapOfVtkId& theIndices, 
140                     bool theIsModeShift) = 0;
141
142   //! Change indexes of subslection for given #SALOME_InteractiveObject
143   virtual
144   bool 
145   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
146                     const SVTK_TVtkIDsMap& theIndices, 
147                     bool theIsModeShift) = 0;
148
149   //! Change index of subslection for given #SALOME_InteractiveObject
150   virtual
151   bool
152   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
153                     int theIndex, 
154                     bool theIsModeShift) = 0;
155
156   //! Change index of subslection for given #SALOME_InteractiveObject
157   virtual
158   void 
159   RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
160                int theIndex) = 0;
161
162   //! Check, if the given index is present in subselection 
163   virtual
164   bool 
165   IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, 
166                   int theIndex) const = 0;
167
168   //! Clear subselection
169   virtual
170   void 
171   ClearIndex() = 0;
172
173   /// ! Composite indexes 
174   virtual
175   bool 
176   HasCompositeIndex(const Handle(SALOME_InteractiveObject)& theIO ) const = 0;
177
178   //! Get composite indexes of subslection for given #SALOME_InteractiveObject
179   virtual
180   void 
181   GetCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, 
182                      SVTK_IndexedMapOfVtkIds& theIds ) = 0;
183         
184   //! Change composite indices of subselection for given #SALOME_InteractiveObject
185   virtual
186   bool 
187   AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, 
188                              const SVTK_IndexedMapOfVtkIds& theIds,
189                              bool theIsModeShift) = 0;
190
191   //! Change composite index of subslection for given #SALOME_InteractiveObject
192   virtual
193   bool
194   AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, 
195                              SVTK_ListOfVtk ids, 
196                              bool theIsModeShift) = 0;
197
198   //! Change composite index of subslection for given #SALOME_InteractiveObject
199   virtual
200   void 
201   RemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, 
202                         SVTK_ListOfVtk ids ) = 0;
203
204   //! Check, if the given composite index is present in subselection 
205   virtual
206   bool 
207   IsCompositeIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, 
208                            SVTK_ListOfVtk ids ) const = 0;
209
210   //! Clear composite indexes subselection
211   virtual
212   void 
213   ClearCompositeIndex() = 0;
214
215   //----------------------------------------------------------------------------
216   typedef int TFilterID;
217
218   //! To apply a filter on the selection
219   virtual
220   void 
221   SetFilter(const Handle(VTKViewer_Filter)& theFilter) = 0;
222
223   //! To get a section filter by its number
224   virtual
225   Handle(VTKViewer_Filter) 
226   GetFilter(const TFilterID theId) const = 0;
227
228   //! Check, if a filter with given number is applyed
229   virtual
230   bool
231   IsFilterPresent(const TFilterID theId) const = 0;
232
233   //! To remove a filter from the selection
234   virtual
235   void
236   RemoveFilter(const TFilterID theId) = 0;
237
238   //! Check, if the index satisfy to the installed filters
239   virtual
240   bool
241   IsValid(SALOME_Actor* theActor,
242           const int theId,
243           const bool theIsNode = false) const = 0;
244   
245   //----------------------------------------------------------------------------
246   virtual
247   void 
248   StartPickCallback() = 0;
249
250   //! To invoke selectionChanged signals
251   virtual
252   void 
253   EndPickCallback() = 0;
254
255   //----------------------------------------------------------------------------
256   virtual
257   vtkActorCollection*
258   Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const = 0;
259
260   virtual
261   void
262   SetTolerance(const double& theTolerance) = 0;
263
264   virtual
265   void
266   SetDynamicPreSelection( bool theIsDynPreselect ) = 0;
267
268   virtual
269   bool
270   GetDynamicPreSelection() const = 0;
271
272   virtual
273   void
274   SetPreSelectionEnabled( bool theEnabled ) = 0;
275
276   virtual
277   bool
278   IsPreSelectionEnabled() const = 0;
279
280   virtual
281   void
282   SetSelectionEnabled( bool theEnabled ) = 0;
283
284   virtual
285   bool
286   IsSelectionEnabled() const = 0;
287 };
288
289
290 #endif