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