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