]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/SVTK_SelectorDef.h
Salome HOME
050a6838a3fd15d48c442c9b2b494778e1482e3a
[modules/gui.git] / src / SVTK / SVTK_SelectorDef.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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOME_Selection.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef SVTK_SELECTORDEF_H
30 #define SVTK_SELECTORDEF_H
31
32 #include <set>
33 #include <map>
34
35 #include <TColStd_IndexedMapOfInteger.hxx>
36 #include <TColStd_MapOfInteger.hxx>
37 #include <vtkSmartPointer.h>
38
39 #include "SVTK_Selector.h"
40
41 class SALOME_Actor;
42
43 class SVTK_Viewer;
44 class SVTK_ViewWindow;
45
46 class SVTK_SelectorDef: public SVTK_Selector
47 {
48 public:
49   SVTK_SelectorDef();
50   virtual ~SVTK_SelectorDef();
51
52   virtual
53   void 
54   SetSelectionMode(Selection_Mode theMode);
55
56   virtual
57   Selection_Mode
58   SelectionMode() const { return mySelectionMode; }
59
60   virtual
61   void
62   ClearIObjects();
63
64   virtual
65   SALOME_Actor* 
66   GetActor(const Handle(SALOME_InteractiveObject)& theIO) const;
67
68   virtual
69   bool
70   IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const;
71
72   virtual
73   bool
74   IsSelected(SALOME_Actor* theActor) const;
75
76   virtual
77   bool
78   AddIObject(const Handle(SALOME_InteractiveObject)& theIO);
79
80   virtual
81   bool
82   AddIObject(SALOME_Actor* theActor);
83
84   virtual
85   bool 
86   RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO);
87
88   virtual
89   bool 
90   RemoveIObject(SALOME_Actor* theActor);
91
92   virtual
93   const SALOME_ListIO& 
94   StoredIObjects() const;
95
96   virtual
97   int 
98   IObjectCount() const;
99
100   virtual
101   bool 
102   HasIndex(const Handle(SALOME_InteractiveObject)& theIO ) const;
103
104   virtual
105   void 
106   GetIndex( const Handle(SALOME_InteractiveObject)& theIO, 
107             TColStd_IndexedMapOfInteger& theIndex );
108         
109   virtual
110   bool 
111   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
112                     const TColStd_IndexedMapOfInteger& theIndices, 
113                     bool theIsModeShift);
114   virtual
115   bool 
116   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
117                     const TColStd_MapOfInteger& theIndices, 
118                     bool theIsModeShift);
119   virtual
120   bool
121   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
122                     int theIndex, 
123                     bool theIsModeShift);
124   virtual
125   void 
126   RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
127                int theIndex);
128   virtual
129   bool 
130   IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, 
131                   int theIndex) const;
132   virtual
133   void 
134   ClearIndex();
135
136   //----------------------------------------------------------------------------
137   virtual
138   void 
139   SetFilter(const Handle(VTKViewer_Filter)& theFilter);
140
141   virtual
142   Handle(VTKViewer_Filter) 
143   GetFilter(const TFilterID theId) const;
144
145   virtual
146   bool
147   IsFilterPresent(const TFilterID theId) const;
148
149   virtual
150   void
151   RemoveFilter(const int theId);
152
153   virtual
154   bool
155   IsValid(SALOME_Actor* theActor,
156           const TFilterID theId,
157           const bool theIsNode = false) const;
158   
159   //----------------------------------------------------------------------------
160   virtual
161   void 
162   StartPickCallback();
163
164   virtual
165   void 
166   EndPickCallback();
167
168 private:
169   int mySelectionMode;
170
171   struct TIOLessThan
172   {
173     bool 
174     operator()(const Handle(SALOME_InteractiveObject)& theRightIO,
175                const Handle(SALOME_InteractiveObject)& theLeftIO) const
176     {
177       return strcmp(theRightIO->getEntry(),theLeftIO->getEntry()) < 0;
178     }
179   };
180
181   struct TIndexedMapOfInteger
182   {
183     TColStd_IndexedMapOfInteger myMap;
184     TIndexedMapOfInteger()
185     {}
186     TIndexedMapOfInteger(const TIndexedMapOfInteger& theIndexedMapOfInteger)
187     {
188       myMap = theIndexedMapOfInteger.myMap;
189     }
190   };
191
192   mutable SALOME_ListIO myIObjectList;
193   typedef std::set<Handle(SALOME_InteractiveObject),
194                    TIOLessThan> TIObjects;
195   TIObjects myIObjects;
196
197   typedef std::map<Handle(SALOME_InteractiveObject),
198                    vtkSmartPointer<SALOME_Actor>,
199                    TIOLessThan> TIO2Actors;
200   TIO2Actors myIO2Actors;
201
202   typedef std::map<Handle(SALOME_InteractiveObject),
203                    TIndexedMapOfInteger,
204                    TIOLessThan> TMapIOSubIndex;
205   TMapIOSubIndex myMapIOSubIndex;
206
207   typedef std::map<TFilterID,Handle(VTKViewer_Filter)> TFilters;
208   TFilters myFilters;
209 };
210
211 #endif