VTK
vtkPicker.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPicker.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
44 #ifndef vtkPicker_h
45 #define vtkPicker_h
46 
47 #include "vtkRenderingCoreModule.h" // For export macro
48 #include "vtkAbstractPropPicker.h"
49 
52 class vtkDataSet;
53 class vtkTransform;
54 class vtkActorCollection;
56 class vtkPoints;
57 
58 class VTKRENDERINGCORE_EXPORT vtkPicker : public vtkAbstractPropPicker
59 {
60 public:
61  static vtkPicker *New();
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
66 
71  vtkSetMacro(Tolerance, double);
72  vtkGetMacro(Tolerance, double);
74 
76 
80  vtkGetVectorMacro(MapperPosition, double, 3);
82 
84 
87  vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
89 
91 
95  vtkGetObjectMacro(DataSet, vtkDataSet);
97 
99 
103  vtkGetObjectMacro(CompositeDataSet, vtkCompositeDataSet);
105 
107 
112  vtkGetMacro(FlatBlockIndex, vtkIdType);
114 
120  { return this->Prop3Ds; }
121 
127  vtkActorCollection *GetActors();
128 
135  { return this->PickedPositions; }
136 
143  int Pick(double selectionX, double selectionY, double selectionZ,
144  vtkRenderer *renderer) override;
145 
151  int Pick(double selectionPt[3], vtkRenderer *ren)
152  { return this->Pick(selectionPt[0], selectionPt[1], selectionPt[2], ren); }
153 
159  int Pick3DPoint(double selectionPt[3], vtkRenderer *ren) override;
160 
166  int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer *ren) override;
167 
168 protected:
169  vtkPicker();
170  ~vtkPicker() override;
171 
172  // shared code for picking
173  virtual int Pick3DInternal(vtkRenderer *ren, double p1World[4], double p2World[4]);
174 
175  void MarkPicked(vtkAssemblyPath *path, vtkProp3D *p, vtkAbstractMapper3D *m,
176  double tMin, double mapperPos[3]);
177  void MarkPickedData(vtkAssemblyPath *path,
178  double tMin, double mapperPos[3], vtkAbstractMapper3D* mapper,
179  vtkDataSet* input, vtkIdType flatBlockIndex = -1);
180  virtual double IntersectWithLine(const double p1[3], const double p2[3], double tol,
181  vtkAssemblyPath *path, vtkProp3D *p,
183  void Initialize() override;
184  static bool CalculateRay(const double p1[3], const double p2[3],
185  double ray[3], double &rayFactor);
186 
187  double Tolerance; //tolerance for computation (% of window)
188  double MapperPosition[3]; //selection point in untransformed coordinates
189 
190  vtkAbstractMapper3D *Mapper; //selected mapper (if the prop has a mapper)
191  vtkDataSet *DataSet; //selected dataset (if there is one)
193  vtkIdType FlatBlockIndex; // flat block index, for a composite data set
194 
195  double GlobalTMin; //parametric coordinate along pick ray where hit occurred
196  vtkTransform *Transform; //use to perform ray transformation
197  vtkActorCollection *Actors; //candidate actors (based on bounding box)
198  vtkProp3DCollection *Prop3Ds; //candidate actors (based on bounding box)
199  vtkPoints *PickedPositions; // candidate positions
200 
201 private:
202  vtkPicker(const vtkPicker&) = delete;
203  void operator=(const vtkPicker&) = delete;
204 };
205 
206 #endif
vtkIdType FlatBlockIndex
Definition: vtkPicker.h:193
double Tolerance
Definition: vtkPicker.h:187
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkPoints * PickedPositions
Definition: vtkPicker.h:199
abstract specification for renderers
Definition: vtkRenderer.h:63
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:46
vtkActorCollection * Actors
Definition: vtkPicker.h:197
int vtkIdType
Definition: vtkType.h:347
virtual int Pick3DPoint(double[3], vtkRenderer *)
Perform pick operation with selection point provided.
superclass for 3D geometric pickers (uses ray cast)
Definition: vtkPicker.h:58
void Initialize() override
int Pick(double selectionPt[3], vtkRenderer *ren)
Perform pick operation with selection point provided.
Definition: vtkPicker.h:151
vtkTransform * Transform
Definition: vtkPicker.h:196
vtkProp3DCollection * GetProp3Ds()
Return a collection of all the prop 3D's that were intersected by the pick ray.
Definition: vtkPicker.h:119
abstract superclass for composite (multi-block or AMR) datasets
a list of nodes that form an assembly path
vtkPoints * GetPickedPositions()
Return a list of the points the actors returned by GetProp3Ds were intersected at.
Definition: vtkPicker.h:134
a simple class to control print indentation
Definition: vtkIndent.h:39
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkProp3DCollection * Prop3Ds
Definition: vtkPicker.h:198
abstract class specifies interface to map 3D data
an ordered list of 3D props
vtkCompositeDataSet * CompositeDataSet
Definition: vtkPicker.h:192
an ordered list of actors
abstract API for pickers that can pick an instance of vtkProp
virtual int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer *renderer)=0
Perform pick operation with selection point provided.
virtual int Pick3DRay(double[3], double[4], vtkRenderer *)
Perform pick operation with selection point and orientation provided.
vtkAbstractMapper3D * Mapper
Definition: vtkPicker.h:190
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
double GlobalTMin
Definition: vtkPicker.h:195
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkDataSet * DataSet
Definition: vtkPicker.h:191