Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SVTK_SelectorDef.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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_SELECTORDEF_H
28 #define SVTK_SELECTORDEF_H
29 
30 #include <set>
31 #include <map>
32 
33 #include <TColStd_IndexedMapOfInteger.hxx>
34 #include <TColStd_MapOfInteger.hxx>
35 #include <vtkSmartPointer.h>
36 
38 
39 #include "SVTK_Selector.h"
40 
41 class SALOME_Actor;
42 
43 class SVTK_Viewer;
44 class SVTK_ViewWindow;
45 class vtkPicker;
46 class vtkCellPicker;
47 
49 {
50 public:
52  virtual ~SVTK_SelectorDef();
53 
54  virtual
55  void
57 
58  virtual
60  SelectionMode() const { return mySelectionMode; }
61 
62  virtual
63  void
64  ClearIObjects();
65 
66  virtual
67  SALOME_Actor*
68  GetActor(const Handle(SALOME_InteractiveObject)& theIO) const;
69 
70  virtual
71  bool
72  IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const;
73 
74  virtual
75  bool
76  IsSelected(SALOME_Actor* theActor) const;
77 
78  virtual
79  bool
81 
82  virtual
83  bool
84  AddIObject(SALOME_Actor* theActor);
85 
86  virtual
87  bool
89 
90  virtual
91  bool
92  RemoveIObject(SALOME_Actor* theActor);
93 
94  virtual
95  const SALOME_ListIO&
96  StoredIObjects() const;
97 
98  virtual
99  int
100  IObjectCount() const;
101 
102  virtual
103  bool
104  HasIndex(const Handle(SALOME_InteractiveObject)& theIO ) const;
105 
106  virtual
107  void
108  GetIndex( const Handle(SALOME_InteractiveObject)& theIO,
109  TColStd_IndexedMapOfInteger& theIndex );
110 
111  virtual
112  bool
114  const TColStd_IndexedMapOfInteger& theIndices,
115  bool theIsModeShift);
116  virtual
117  bool
119  const TColStd_MapOfInteger& theIndices,
120  bool theIsModeShift);
121  virtual
122  bool
124  int theIndex,
125  bool theIsModeShift);
126  virtual
127  void
129  int theIndex);
130  virtual
131  bool
133  int theIndex) const;
134  virtual
135  void
136  ClearIndex();
137 
138  //----------------------------------------------------------------------------
139  virtual
140  void
141  SetFilter(const Handle(VTKViewer_Filter)& theFilter);
142 
143  virtual
145  GetFilter(const TFilterID theId) const;
146 
147  virtual
148  bool
149  IsFilterPresent(const TFilterID theId) const;
150 
151  virtual
152  void
153  RemoveFilter(const int theId);
154 
155  virtual
156  bool
157  IsValid(SALOME_Actor* theActor,
158  const TFilterID theId,
159  const bool theIsNode = false) const;
160 
161  //----------------------------------------------------------------------------
162  virtual
163  void
165 
166  virtual
167  void
168  EndPickCallback();
169 
170  //----------------------------------------------------------------------------
171  virtual
172  vtkActorCollection*
173  Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const;
174 
175  virtual
176  void
177  SetTolerance(const double& theTolerance);
178 
179  virtual
180  void
181  SetDynamicPreSelection( bool theIsDynPreselect );
182 
183  virtual
184  bool
185  GetDynamicPreSelection() const;
186 
187  virtual
188  void
189  SetPreSelectionEnabled( bool theEnabled );
190 
191  virtual
192  bool
193  IsPreSelectionEnabled() const;
194 
195  virtual
196  void
197  SetSelectionEnabled( bool theEnabled );
198 
199  virtual
200  bool
201  IsSelectionEnabled() const;
202 
203 private:
205 
209 
210  struct TIOLessThan
211  {
212  bool
213  operator()(const Handle(SALOME_InteractiveObject)& theRightIO,
214  const Handle(SALOME_InteractiveObject)& theLeftIO) const
215  {
216  return strcmp(theRightIO->getEntry(),theLeftIO->getEntry()) < 0;
217  }
218  };
219 
221  {
222  TColStd_IndexedMapOfInteger myMap;
224  {}
225  TIndexedMapOfInteger(const TIndexedMapOfInteger& theIndexedMapOfInteger)
226  {
227  myMap = theIndexedMapOfInteger.myMap;
228  }
229  };
230 
232  typedef std::set<Handle(SALOME_InteractiveObject),
233  TIOLessThan> TIObjects;
235 
236  typedef std::map<Handle(SALOME_InteractiveObject),
237  vtkSmartPointer<SALOME_Actor>,
238  TIOLessThan> TIO2Actors;
240 
241  typedef std::map<Handle(SALOME_InteractiveObject),
243  TIOLessThan> TMapIOSubIndex;
245 
246  typedef std::map<TFilterID,Handle(VTKViewer_Filter)> TFilters;
248 
249  vtkSmartPointer<vtkPicker> myPicker;
250  vtkSmartPointer<vtkCellPicker> myCellPicker;
251 };
252 
253 #endif