fw4spl
fwVtkPicker.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 /*=========================================================================
8 
9  Program: Visualization Toolkit
10  Module: $RCSfile: fwVtkPicker.h,v $
11 
12  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
13  All rights reserved.
14  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
15 
16  This software is distributed WITHOUT ANY WARRANTY; without even
17  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  PURPOSE. See the above copyright notice for more information.
19 
20  =========================================================================*/
21 // .NAME fwVtkPicker - superclass for 3D geometric pickers (uses ray cast)
22 // .SECTION Description
23 // fwVtkPicker is used to select instances of vtkProp3D by shooting a ray
24 // into a graphics window and intersecting with the actor's bounding box.
25 // The ray is defined from a point defined in window (or pixel) coordinates,
26 // and a point located from the camera's position.
27 //
28 // fwVtkPicker may return more than one vtkProp3D, since more than one bounding
29 // box may be intersected. fwVtkPicker returns the list of props that were hit,
30 // the pick coordinates in world and untransformed mapper space, and the
31 // prop (vtkProp3D) and mapper that are "closest" to the camera. The closest
32 // prop is the one whose center point (i.e., center of bounding box)
33 // projected on the ray is closest to the camera.
34 
35 // .SECTION See Also
36 // fwVtkPicker is used for quick geometric picking. If you desire to pick
37 // points or cells, use the subclass vtkPointPicker or vtkCellPicker,
38 // respectively. Or you may use hardware picking to pick any type of vtkProp
39 // - see vtkPropPicker or vtkWorldPointPicker.
40 
41 #ifndef __FWRENDERVTK_VTK_FWVTKPICKER_HPP__
42 #define __FWRENDERVTK_VTK_FWVTKPICKER_HPP__
43 
44 #include "fwRenderVTK/config.hpp"
45 
46 #include <vtkPicker.h>
47 
48 class vtkAbstractMapper3D;
49 class vtkDataSet;
50 class vtkTransform;
51 class vtkActorCollection;
52 class vtkProp3DCollection;
53 class vtkPropCollection;
54 class vtkPolyData;
55 class vtkPoints;
56 
57 class FWRENDERVTK_CLASS_API fwVtkPicker : public vtkPicker
58 {
59 public:
60  FWRENDERVTK_API static fwVtkPicker* New();
61 
62  vtkTypeMacro(fwVtkPicker, vtkPicker);
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
65  // Description:
66  // Perform pick operation with selection point provided. Normally the
67  // first two values for the selection point are x-y pixel coordinate, and
68  // the third value is =0. Return non-zero if something was successfully
69  // picked.
70  FWRENDERVTK_API virtual int Pick(double selectionX, double selectionY, double selectionZ,
71  vtkRenderer* renderer) override;
72 
73  FWRENDERVTK_API int PickPolyData( double p1[3], double p2[3], vtkPolyData *polydata);
74  FWRENDERVTK_API int Pick( double p1[3], double p2[3], vtkPropCollection *props);
75  // Description:
76  // Perform pick operation with selection point provided. Normally the first
77  // two values for the selection point are x-y pixel coordinate, and the
78  // third value is =0. Return non-zero if something was successfully picked.
79  int Pick(double selectionPt[3], vtkRenderer* ren)
80  {
81  return this->Pick(selectionPt[0], selectionPt[1], selectionPt[2], ren);
82  }
83 
84 protected:
85  fwVtkPicker();
86  ~fwVtkPicker();
87 
88 private:
89  fwVtkPicker(const fwVtkPicker&); // Not implemented.
90  void operator=(const fwVtkPicker&); // Not implemented.
91 };
92 
93 #endif //__FWRENDERVTK_VTK_FWVTKPICKER_HPP__
94