Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/gui.git] / src / SVTK / SVTK_Selector.h
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, 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.
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 "SALOME_ListIO.hxx"
33
34 #include <TColStd_MapOfInteger.hxx>
35 #include <TColStd_IndexedMapOfInteger.hxx>
36
37 #include <vtkObject.h>
38
39 class Handle(VTKViewer_Filter);
40
41 class SALOME_Actor;
42 class SVTK_SelectionEvent;
43 class vtkActorCollection;
44 class vtkRenderer;
45 class Handle(SALOME_InteractiveObject);
46
47 //! Define an abstract interface for selection in SVTK package
48 /*!
49   The class implements selection functionality through storing corresponding
50   references to #SALOME_InteractiveObject. For implementation of subselection
51   modes it keeps a corresponding map of sub indexes.
52   \note
53   Also, for each #SALOME_InteractiveObject it tries to keep corresponding refenrence to #SALOME_Actor
54  */
55 class SVTK_EXPORT SVTK_Selector: public vtkObject
56 {
57 public:
58   static SVTK_Selector* New();
59   
60   vtkTypeMacro(SVTK_Selector,vtkObject);
61
62   //! To change current Selection_Mode (as outside effect, it invokes selectionChange signal)
63   virtual
64   void 
65   SetSelectionMode(Selection_Mode theMode) = 0;
66
67   //! Get current Selection_Mode
68   virtual
69   Selection_Mode
70   SelectionMode() const = 0;
71
72   //! Clear selection
73   virtual
74   void
75   ClearIObjects() = 0;
76
77   //! Try to find corresponding #SALOME_Actor for given reference on #SALOME_InteractiveObject
78   virtual
79   SALOME_Actor* 
80   GetActor(const Handle(SALOME_InteractiveObject)& theIO) const = 0;
81
82   //! Check, is the #SALOME_InteractiveObject is present into selection
83   virtual
84   bool
85   IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const = 0;
86
87   //! Check, is the #SALOME_Actor is present into selection
88   virtual
89   bool
90   IsSelected(SALOME_Actor* theActor) const = 0;
91
92   //! Modify the selection by adding new reference on #SALOME_InteractiveObject
93   virtual
94   bool
95   AddIObject(const Handle(SALOME_InteractiveObject)& theIO) = 0;
96
97   //! Modify the selection by adding new reference on #SALOME_Actor
98   virtual
99   bool
100   AddIObject(SALOME_Actor* theActor) = 0;
101
102   //! Modify the selection by removing a reference on #SALOME_InteractiveObject
103   virtual
104   bool 
105   RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO) = 0;
106
107   //! Modify the selection by removing a reference on #SALOME_Actor
108   virtual
109   bool 
110   RemoveIObject(SALOME_Actor* theActor) = 0;
111
112   //! Get all #SALOME_InteractiveObject references that is present into selection
113   virtual
114   const SALOME_ListIO& 
115   StoredIObjects() const = 0;
116
117   //! Get number of selected objects
118   virtual
119   int 
120   IObjectCount() const = 0;
121
122   //! Check, if the #SALOME_InteractiveObject has a subselection
123   virtual
124   bool 
125   HasIndex(const Handle(SALOME_InteractiveObject)& theIO ) const = 0;
126
127   //! Get indexes of subslection for given #SALOME_InteractiveObject
128   virtual
129   void 
130   GetIndex( const Handle(SALOME_InteractiveObject)& theIO, 
131             TColStd_IndexedMapOfInteger& theIndex ) = 0;
132         
133   //! Change indices of subselection for given #SALOME_InteractiveObject
134   virtual
135   bool 
136   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
137                     const TColStd_IndexedMapOfInteger& theIndices, 
138                     bool theIsModeShift) = 0;
139
140   //! Change indexes of subslection for given #SALOME_InteractiveObject
141   virtual
142   bool 
143   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
144                     const TColStd_MapOfInteger& theIndices, 
145                     bool theIsModeShift) = 0;
146
147   //! Change index of subslection for given #SALOME_InteractiveObject
148   virtual
149   bool
150   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
151                     int theIndex, 
152                     bool theIsModeShift) = 0;
153
154   //! Change index of subslection for given #SALOME_InteractiveObject
155   virtual
156   void 
157   RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
158                int theIndex) = 0;
159
160   //! Check, if the given index is present in subselection 
161   virtual
162   bool 
163   IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, 
164                   int theIndex) const = 0;
165
166   //! Clear subselection
167   virtual
168   void 
169   ClearIndex() = 0;
170
171   //----------------------------------------------------------------------------
172   typedef int TFilterID;
173
174   //! To apply a filter on the selection
175   virtual
176   void 
177   SetFilter(const Handle(VTKViewer_Filter)& theFilter) = 0;
178
179   //! To get a section filter by its number
180   virtual
181   Handle(VTKViewer_Filter) 
182   GetFilter(const TFilterID theId) const = 0;
183
184   //! Check, if a filter with given number is applyed
185   virtual
186   bool
187   IsFilterPresent(const TFilterID theId) const = 0;
188
189   //! To remove a filter from the selection
190   virtual
191   void
192   RemoveFilter(const TFilterID theId) = 0;
193
194   //! Check, if the index satisfy to the installed filters
195   virtual
196   bool
197   IsValid(SALOME_Actor* theActor,
198           const int theId,
199           const bool theIsNode = false) const = 0;
200   
201   //----------------------------------------------------------------------------
202   virtual
203   void 
204   StartPickCallback() = 0;
205
206   //! To invoke selectionChanged signals
207   virtual
208   void 
209   EndPickCallback() = 0;
210
211   //----------------------------------------------------------------------------
212   virtual
213   vtkActorCollection*
214   Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const = 0;
215
216   virtual
217   void
218   SetTolerance(const double& theTolerance) = 0;
219
220   virtual
221   void
222   SetDynamicPreSelection( bool theIsDynPreselect ) = 0;
223
224   virtual
225   bool
226   GetDynamicPreSelection() const = 0;
227 };
228
229
230 #endif