]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/SVTK_RectPicker.h
Salome HOME
77c9a3b16674543b3c743ff6ddc36c9fe20535b9
[modules/gui.git] / src / SVTK / SVTK_RectPicker.h
1 //  SALOME VTKViewer : build VTK viewer into Salome desktop
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   : SVTK_RectPicker.h
25 //  Author : 
26 //  Module : SALOME
27
28 #ifndef __SVTK_RectPicker_h
29 #define __SVTK_RectPicker_h
30
31 #include "SVTK.h"
32 #include "VTKViewer.h"
33
34 #include <map>
35 #include <vector>
36
37 #include <vtkAbstractPropPicker.h>
38
39 class vtkRenderer;
40
41 /*! \class vtkAbstractPropPicker
42  * \brief For more information see <a href="http://www.vtk.org/">VTK documentation
43  */
44 /*! \class SVTK_RectPicker
45  * \brief Rectangular picker class.
46  */
47 class SVTK_EXPORT SVTK_RectPicker : public vtkAbstractPropPicker
48 {
49  public:
50   static
51   SVTK_RectPicker *New();
52
53   vtkTypeMacro(SVTK_RectPicker,vtkAbstractPropPicker);
54   
55   /*! 
56     Specify tolerance for performing pick operation. Tolerance is specified
57     as fraction of rendering window size. (Rendering window size is measured
58     across diagonal.)
59   */
60   vtkSetMacro(Tolerance,vtkFloatingPointType);
61   vtkGetMacro(Tolerance,vtkFloatingPointType);
62
63   //! Use these methods to pick points or points and cells
64   vtkSetMacro(PickPoints,int);
65   vtkGetMacro(PickPoints,int);
66   vtkBooleanMacro(PickPoints,int);
67
68   virtual 
69   int
70   Pick(vtkFloatingPointType theSelectionX, 
71        vtkFloatingPointType theSelectionY, 
72        vtkFloatingPointType theSelectionZ, 
73        vtkFloatingPointType theSelectionX2, 
74        vtkFloatingPointType theSelectionY2, 
75        vtkFloatingPointType theSelectionZ2,
76        vtkRenderer *theRenderer);  
77
78   int
79   Pick(vtkFloatingPointType theSelection[3], 
80        vtkFloatingPointType theSelection2[3], 
81        vtkRenderer *theRenderer);
82
83   typedef std::vector<vtkIdType> TVectorIds;
84   typedef std::map<vtkActor*,TVectorIds> TVectorIdsMap;
85
86   const TVectorIdsMap& 
87   GetPointIdsMap() const;
88
89   const TVectorIdsMap& 
90   GetCellIdsMap() const;
91
92  protected:
93   SVTK_RectPicker();
94   ~SVTK_RectPicker();
95
96   //! tolerance for computation (% of window)
97   vtkFloatingPointType Tolerance;
98
99   //! use the following to control picking mode
100   int PickPoints;
101
102   //! second rectangle selection point in window (pixel) coordinates
103   vtkFloatingPointType SelectionPoint2[3]; 
104
105   //! second rectangle selection point in world coordinates
106   vtkFloatingPointType PickPosition2[3]; 
107
108   TVectorIdsMap myPointIdsMap;
109   TVectorIdsMap myCellIdsMap;
110
111  private:
112   virtual 
113   int
114   Pick(vtkFloatingPointType, 
115        vtkFloatingPointType, 
116        vtkFloatingPointType, 
117        vtkRenderer*);
118 };
119
120 #endif
121
122