Salome HOME
47f593e9a3b438ee3bd533b4affe93f653d34846
[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 private:
137   Selection_Mode mySelectionMode;
138
139   struct TIOLessThan
140   {
141     bool 
142     operator()(const Handle(SALOME_InteractiveObject)& theRightIO,
143                const Handle(SALOME_InteractiveObject)& theLeftIO) const
144     {
145       return strcmp(theRightIO->getEntry(),theLeftIO->getEntry()) < 0;
146     }
147   };
148
149   struct TIndexedMapOfInteger{
150     TColStd_IndexedMapOfInteger myMap;
151     TIndexedMapOfInteger()
152     {}
153     TIndexedMapOfInteger(const TIndexedMapOfInteger& theIndexedMapOfInteger)
154     {
155       myMap = theIndexedMapOfInteger.myMap;
156     }
157   };
158
159   mutable SALOME_ListIO myIObjectList;
160   typedef std::set<Handle(SALOME_InteractiveObject),
161                    TIOLessThan> TIObjects;
162   TIObjects myIObjects;
163
164   typedef std::map<Handle(SALOME_InteractiveObject),
165                    vtkSmartPointer<SALOME_Actor>,
166                    TIOLessThan> TIO2Actors;
167   TIO2Actors myIO2Actors;
168
169   typedef std::map<Handle(SALOME_InteractiveObject),
170                    TIndexedMapOfInteger,
171                    TIOLessThan> TMapIOSubIndex;
172   TMapIOSubIndex myMapIOSubIndex;
173 };
174
175
176 #endif