Version: 9.15.0
SVTK_SelectorDef.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2025 CEA, EDF, 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 "SVTK_Selector.h"
31 
32 #include <set>
33 #include <map>
34 
35 #include <TColStd_IndexedMapOfInteger.hxx>
36 #include <TColStd_MapOfInteger.hxx>
37 #include <vtkSmartPointer.h>
38 
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  SVTK_TIndexedMapOfVtkId& theIndex );
110 
111  virtual
112  bool
114  const SVTK_TIndexedMapOfVtkId& theIndices,
115  bool theIsModeShift);
116  virtual
117  bool
119  const SVTK_TVtkIDsMap& 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  //----------------------------------------------------------------------------
140  virtual
141  bool
142  HasCompositeIndex(const Handle(SALOME_InteractiveObject)& theIO ) const;
143 
144  virtual
145  void
147  SVTK_IndexedMapOfVtkIds& theIds );
148  virtual
149  bool
151  const SVTK_IndexedMapOfVtkIds& theIds,
152  bool theIsModeShift);
153 
154  virtual
155  bool
157  SVTK_ListOfVtk theIds,
158  bool theIsModeShift);
159 
160  virtual
161  void
163  SVTK_ListOfVtk theIds );
164 
165  virtual
166  bool
168  SVTK_ListOfVtk theIds ) const;
169 
170  virtual
171  void
173 
174  //----------------------------------------------------------------------------
175  virtual
176  void
177  SetFilter(const Handle(VTKViewer_Filter)& theFilter);
178 
179  virtual
181  GetFilter(const TFilterID theId) const;
182 
183  virtual
184  bool
185  IsFilterPresent(const TFilterID theId) const;
186 
187  virtual
188  void
189  RemoveFilter(const int theId);
190 
191  virtual
192  bool
193  IsValid(SALOME_Actor* theActor,
194  const TFilterID theId,
195  const bool theIsNode = false) const;
196 
197  //----------------------------------------------------------------------------
198  virtual
199  void
201 
202  virtual
203  void
204  EndPickCallback();
205 
206  //----------------------------------------------------------------------------
207  virtual
208  vtkActorCollection*
209  Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const;
210 
211  virtual
212  void
213  SetTolerance(const double& theTolerance);
214 
215  virtual
216  void
217  SetDynamicPreSelection( bool theIsDynPreselect );
218 
219  virtual
220  bool
221  GetDynamicPreSelection() const;
222 
223  virtual
224  void
225  SetPreSelectionEnabled( bool theEnabled );
226 
227  virtual
228  bool
229  IsPreSelectionEnabled() const;
230 
231  virtual
232  void
233  SetSelectionEnabled( bool theEnabled );
234 
235  virtual
236  bool
237  IsSelectionEnabled() const;
238 
239 private:
241 
245 
246  struct TIOLessThan
247  {
248  bool
250  const Handle(SALOME_InteractiveObject)& theLeftIO) const
251  {
252  return strcmp(theRightIO->getEntry(),theLeftIO->getEntry()) < 0;
253  }
254  };
255 
257  {
260  {}
261  TIndexedMapOfInteger(const TIndexedMapOfInteger& theIndexedMapOfInteger)
262  {
263  myMap = theIndexedMapOfInteger.myMap;
264  }
265  };
266 
268  typedef std::set<Handle(SALOME_InteractiveObject),
271 
272  typedef std::map<Handle(SALOME_InteractiveObject),
273  vtkSmartPointer<SALOME_Actor>,
276 
277  typedef std::map<Handle(SALOME_InteractiveObject),
281 
282  typedef std::map<Handle(SALOME_InteractiveObject),
286 
287 
290 
291  vtkSmartPointer<vtkPicker> myPicker;
292  vtkSmartPointer<vtkCellPicker> myCellPicker;
293 };
294 
295 #endif
Selection_Mode
Definition: SALOME_Selection.h:27
NCollection_Map< vtkIdType, svtkIdHasher > SVTK_TVtkIDsMap
Definition: SVTK_Hash.h:151
NCollection_IndexedMap< SVTK_ListOfVtk, SVTK_vtkHasher > SVTK_IndexedMapOfVtkIds
Definition: SVTK_Hash.h:150
std::vector< vtkIdType > SVTK_ListOfVtk
Definition: SVTK_Hash.h:40
NCollection_IndexedMap< vtkIdType, svtkIdHasher > SVTK_TIndexedMapOfVtkId
Definition: SVTK_Hash.h:153
The class is a basic one for all SALOME VTK presentation.
Definition: SALOME_Actor.h:73
Definition: SALOME_ListIO.hxx:29
Definition: SVTK_SelectorDef.h:49
TMapIOSubIndex myMapIOSubIndex
Definition: SVTK_SelectorDef.h:280
virtual void StartPickCallback()
Definition: SVTK_Selector.cxx:83
std::map< Handle(SALOME_InteractiveObject), TIndexedMapOfInteger, TIOLessThan > TMapIOSubIndex
Definition: SVTK_SelectorDef.h:279
virtual bool IsSelected(const Handle(SALOME_InteractiveObject)&theIO) const
Definition: SVTK_Selector.cxx:131
TMapIOSubCompositeIndex myMapIOSubCompositeIndex
Definition: SVTK_SelectorDef.h:285
virtual void SetPreSelectionEnabled(bool theEnabled)
Definition: SVTK_Selector.cxx:747
TIO2Actors myIO2Actors
Definition: SVTK_SelectorDef.h:275
vtkSmartPointer< vtkCellPicker > myCellPicker
Definition: SVTK_SelectorDef.h:292
virtual void SetFilter(const Handle(VTKViewer_Filter)&theFilter)
Definition: SVTK_Selector.cxx:631
virtual bool IsPreSelectionEnabled() const
Definition: SVTK_Selector.cxx:754
virtual void GetCompositeIndex(const Handle(SALOME_InteractiveObject)&theIO, SVTK_IndexedMapOfVtkIds &theIds)
Definition: SVTK_Selector.cxx:501
virtual void ClearIndex()
Definition: SVTK_Selector.cxx:479
virtual bool IsIndexSelected(const Handle(SALOME_InteractiveObject)&theIO, int theIndex) const
Definition: SVTK_Selector.cxx:292
virtual const SALOME_ListIO & StoredIObjects() const
Definition: SVTK_Selector.cxx:237
virtual bool GetDynamicPreSelection() const
Definition: SVTK_Selector.cxx:740
bool mySelectionEnabled
Definition: SVTK_SelectorDef.h:244
vtkSmartPointer< vtkPicker > myPicker
Definition: SVTK_SelectorDef.h:291
virtual void RemoveCompositeIndex(const Handle(SALOME_InteractiveObject)&theIO, SVTK_ListOfVtk theIds)
Definition: SVTK_Selector.cxx:586
virtual Handle(VTKViewer_Filter) GetFilter(const TFilterID theId) const
To get a section filter by its number.
virtual bool AddOrRemoveCompositeIndex(const Handle(SALOME_InteractiveObject)&theIO, const SVTK_IndexedMapOfVtkIds &theIds, bool theIsModeShift)
Definition: SVTK_Selector.cxx:519
virtual void SetSelectionMode(Selection_Mode theMode)
Definition: SVTK_Selector.cxx:103
SVTK_SelectorDef()
Definition: SVTK_Selector.cxx:57
int mySelectionMode
Definition: SVTK_SelectorDef.h:240
TFilters myFilters
Definition: SVTK_SelectorDef.h:289
virtual bool RemoveIObject(const Handle(SALOME_InteractiveObject)&theIO)
Definition: SVTK_Selector.cxx:203
virtual bool IsValid(SALOME_Actor *theActor, const TFilterID theId, const bool theIsNode=false) const
Definition: SVTK_Selector.cxx:667
virtual bool IsSelectionEnabled() const
Definition: SVTK_Selector.cxx:768
virtual SALOME_Actor * GetActor(const Handle(SALOME_InteractiveObject)&theIO) const
Definition: SVTK_Selector.cxx:153
virtual bool AddOrRemoveIndex(const Handle(SALOME_InteractiveObject)&theIO, const SVTK_TIndexedMapOfVtkId &theIndices, bool theIsModeShift)
Definition: SVTK_Selector.cxx:357
virtual vtkActorCollection * Pick(const SVTK_SelectionEvent *theEvent, vtkRenderer *theRenderer) const
virtual void GetIndex(const Handle(SALOME_InteractiveObject)&theIO, SVTK_TIndexedMapOfVtkId &theIndex)
Definition: SVTK_Selector.cxx:275
virtual bool IsCompositeIndexSelected(const Handle(SALOME_InteractiveObject)&theIO, SVTK_ListOfVtk theIds) const
Definition: SVTK_Selector.cxx:603
virtual void SetSelectionEnabled(bool theEnabled)
Definition: SVTK_Selector.cxx:761
bool myDynamicPreselection
Definition: SVTK_SelectorDef.h:242
bool myPreselectionEnabled
Definition: SVTK_SelectorDef.h:243
virtual void EndPickCallback()
Definition: SVTK_Selector.cxx:93
virtual void ClearCompositeIndex()
Definition: SVTK_Selector.cxx:619
virtual void RemoveFilter(const int theId)
Definition: SVTK_Selector.cxx:653
virtual void ClearIObjects()
Definition: SVTK_Selector.cxx:118
SALOME_ListIO myIObjectList
Definition: SVTK_SelectorDef.h:267
virtual Selection_Mode SelectionMode() const
Get current Selection_Mode.
Definition: SVTK_SelectorDef.h:60
virtual bool AddIObject(const Handle(SALOME_InteractiveObject)&theIO)
Definition: SVTK_Selector.cxx:167
virtual ~SVTK_SelectorDef()
Definition: SVTK_Selector.cxx:74
virtual bool HasIndex(const Handle(SALOME_InteractiveObject)&theIO) const
Definition: SVTK_Selector.cxx:264
std::map< Handle(SALOME_InteractiveObject), SVTK_IndexedMapOfVtkIds, TIOLessThan > TMapIOSubCompositeIndex
Definition: SVTK_SelectorDef.h:284
virtual int IObjectCount() const
Definition: SVTK_Selector.cxx:253
virtual bool HasCompositeIndex(const Handle(SALOME_InteractiveObject)&theIO) const
! Composite indexes
Definition: SVTK_Selector.cxx:490
std::set< Handle(SALOME_InteractiveObject), TIOLessThan > TIObjects
Definition: SVTK_SelectorDef.h:269
virtual void SetDynamicPreSelection(bool theIsDynPreselect)
Definition: SVTK_Selector.cxx:733
TIObjects myIObjects
Definition: SVTK_SelectorDef.h:270
std::map< Handle(SALOME_InteractiveObject), vtkSmartPointer< SALOME_Actor >, TIOLessThan > TIO2Actors
Definition: SVTK_SelectorDef.h:274
virtual void SetTolerance(const double &theTolerance)
virtual bool IsFilterPresent(const TFilterID theId) const
Definition: SVTK_Selector.cxx:642
std::map< TFilterID, Handle(VTKViewer_Filter)> TFilters
Definition: SVTK_SelectorDef.h:288
virtual void RemoveIndex(const Handle(SALOME_InteractiveObject)&theIO, int theIndex)
Definition: SVTK_Selector.cxx:464
Define an abstract interface for selection in SVTK package.
Definition: SVTK_Selector.h:58
int TFilterID
Definition: SVTK_Selector.h:216
Define a container for SALOME VTK view window.
Definition: SVTK_ViewWindow.h:86
Extends two interfaces SVTK_ViewModelBase and SALOME_View.
Definition: SVTK_ViewModel.h:46
Definition: VTKViewer_Filter.cxx:29
The structure is used for passing all infromation necessary for claculation of the selection.
Definition: SVTK_SelectionEvent.h:41
Definition: SVTK_SelectorDef.h:247
bool operator()(const Handle(SALOME_InteractiveObject)&theRightIO, const Handle(SALOME_InteractiveObject)&theLeftIO) const
Definition: SVTK_SelectorDef.h:249
Definition: SVTK_SelectorDef.h:257
TIndexedMapOfInteger()
Definition: SVTK_SelectorDef.h:259
TIndexedMapOfInteger(const TIndexedMapOfInteger &theIndexedMapOfInteger)
Definition: SVTK_SelectorDef.h:261
SVTK_TIndexedMapOfVtkId myMap
Definition: SVTK_SelectorDef.h:258