Salome HOME
3a6576edb04ec5eef0dbfbb9d3ffb230fc941978
[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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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 #ifdef WIN32
42 #pragma warning ( disable:4251 )
43 #endif
44
45 /*! \class vtkAbstractPropPicker
46  * \brief For more information see <a href="http://www.vtk.org/">VTK documentation
47  */
48 /*! \class SVTK_RectPicker
49  * \brief Rectangular picker class.
50  */
51 class SVTK_EXPORT SVTK_RectPicker : public vtkAbstractPropPicker
52 {
53  public:
54   static
55   SVTK_RectPicker *New();
56
57   vtkTypeMacro(SVTK_RectPicker,vtkAbstractPropPicker);
58   
59   /*! 
60     Specify tolerance for performing pick operation. Tolerance is specified
61     as fraction of rendering window size. (Rendering window size is measured
62     across diagonal.)
63   */
64   vtkSetMacro(Tolerance,vtkFloatingPointType);
65   vtkGetMacro(Tolerance,vtkFloatingPointType);
66
67   //! Use these methods to pick points or points and cells
68   vtkSetMacro(PickPoints,int);
69   vtkGetMacro(PickPoints,int);
70   vtkBooleanMacro(PickPoints,int);
71
72   virtual 
73   int
74   Pick(vtkFloatingPointType theSelectionX, 
75        vtkFloatingPointType theSelectionY, 
76        vtkFloatingPointType theSelectionZ, 
77        vtkFloatingPointType theSelectionX2, 
78        vtkFloatingPointType theSelectionY2, 
79        vtkFloatingPointType theSelectionZ2,
80        vtkRenderer *theRenderer);  
81
82   int
83   Pick(vtkFloatingPointType theSelection[3], 
84        vtkFloatingPointType theSelection2[3], 
85        vtkRenderer *theRenderer);
86
87   typedef std::vector<vtkIdType> TVectorIds;
88   typedef std::map<vtkActor*,TVectorIds> TVectorIdsMap;
89
90   const TVectorIdsMap& 
91   GetPointIdsMap() const;
92
93   const TVectorIdsMap& 
94   GetCellIdsMap() const;
95
96  protected:
97   SVTK_RectPicker();
98   ~SVTK_RectPicker();
99
100   //! tolerance for computation (% of window)
101   vtkFloatingPointType Tolerance;
102
103   //! use the following to control picking mode
104   int PickPoints;
105
106   //! second rectangle selection point in window (pixel) coordinates
107   vtkFloatingPointType SelectionPoint2[3]; 
108
109   //! second rectangle selection point in world coordinates
110   vtkFloatingPointType PickPosition2[3]; 
111
112   TVectorIdsMap myPointIdsMap;
113   TVectorIdsMap myCellIdsMap;
114
115  private:
116   virtual 
117   int
118   Pick(vtkFloatingPointType, 
119        vtkFloatingPointType, 
120        vtkFloatingPointType, 
121        vtkRenderer*);
122 };
123
124 #ifdef WIN32
125 #pragma warning ( default:4251 )
126 #endif
127
128 #endif
129
130