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