VTK  9.1.0
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=========================================================================*/
47#ifndef vtkPicker_h
48#define vtkPicker_h
49
51#include "vtkRenderingCoreModule.h" // For export macro
52
55class vtkDataSet;
56class vtkTransform;
59class vtkPoints;
60
61class VTKRENDERINGCORE_EXPORT vtkPicker : public vtkAbstractPropPicker
62{
63public:
64 static vtkPicker* New();
66 void PrintSelf(ostream& os, vtkIndent indent) override;
67
69
74 vtkSetMacro(Tolerance, double);
75 vtkGetMacro(Tolerance, double);
77
79
83 vtkGetVectorMacro(MapperPosition, double, 3);
85
87
90 vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
92
94
98 vtkGetObjectMacro(DataSet, vtkDataSet);
100
102
106 vtkGetObjectMacro(CompositeDataSet, vtkCompositeDataSet);
108
110
115 vtkGetMacro(FlatBlockIndex, vtkIdType);
117
122 vtkProp3DCollection* GetProp3Ds() { return this->Prop3Ds; }
123
130
136 vtkPoints* GetPickedPositions() { return this->PickedPositions; }
137
144 int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
145
151 int Pick(double selectionPt[3], vtkRenderer* ren)
152 {
153 return this->Pick(selectionPt[0], selectionPt[1], selectionPt[2], ren);
154 }
155
161 int Pick3DPoint(double selectionPt[3], vtkRenderer* ren) override;
162
163 /*
164 * Pick a point in the scene with the selection point and focal point
165 * provided. The two points are in world coordinates.
166 *
167 * Returns non-zero if something was successfully picked.
168 */
169 virtual int Pick3DPoint(double p1World[3], double p2World[3], vtkRenderer* ren);
175 int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer* ren) override;
176
177protected:
179 ~vtkPicker() override;
180
181 // shared code for picking
182 virtual int Pick3DInternal(vtkRenderer* ren, double p1World[4], double p2World[4]);
183
185 vtkAssemblyPath* path, vtkProp3D* p, vtkAbstractMapper3D* m, double tMin, double mapperPos[3]);
186 void MarkPickedData(vtkAssemblyPath* path, double tMin, double mapperPos[3],
187 vtkAbstractMapper3D* mapper, vtkDataSet* input, vtkIdType flatBlockIndex = -1);
188 virtual double IntersectWithLine(const double p1[3], const double p2[3], double tol,
190 void Initialize() override;
191 static bool CalculateRay(
192 const double p1[3], const double p2[3], double ray[3], double& rayFactor);
193
194 double Tolerance; // tolerance for computation (% of window)
195 double MapperPosition[3]; // selection point in untransformed coordinates
196
197 vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
198 vtkDataSet* DataSet; // selected dataset (if there is one)
200 vtkIdType FlatBlockIndex; // flat block index, for a composite data set
201
202 double GlobalTMin; // parametric coordinate along pick ray where hit occurred
203 vtkTransform* Transform; // use to perform ray transformation
204 vtkActorCollection* Actors; // candidate actors (based on bounding box)
205 vtkProp3DCollection* Prop3Ds; // candidate actors (based on bounding box)
206 vtkPoints* PickedPositions; // candidate positions
207
208private:
209 vtkPicker(const vtkPicker&) = delete;
210 void operator=(const vtkPicker&) = delete;
211};
212
213#endif
abstract class specifies interface to map 3D data
virtual int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer *renderer)=0
Perform pick operation with selection point provided.
abstract API for pickers that can pick an instance of vtkProp
an ordered list of actors
a list of nodes that form an assembly path
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
a simple class to control print indentation
Definition: vtkIndent.h:113
superclass for 3D geometric pickers (uses ray cast)
Definition: vtkPicker.h:62
virtual int Pick3DPoint(double p1World[3], double p2World[3], vtkRenderer *ren)
static vtkPicker * New()
vtkActorCollection * GetActors()
Return a collection of all the actors that were intersected.
vtkPoints * PickedPositions
Definition: vtkPicker.h:206
vtkPoints * GetPickedPositions()
Return a list of the points the actors returned by GetProp3Ds were intersected at.
Definition: vtkPicker.h:136
int Pick(double selectionPt[3], vtkRenderer *ren)
Perform pick operation with selection point provided.
Definition: vtkPicker.h:151
vtkTransform * Transform
Definition: vtkPicker.h:203
vtkIdType FlatBlockIndex
Definition: vtkPicker.h:200
vtkProp3DCollection * GetProp3Ds()
Return a collection of all the prop 3D's that were intersected by the pick ray.
Definition: vtkPicker.h:122
vtkCompositeDataSet * CompositeDataSet
Definition: vtkPicker.h:199
int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer *ren) override
Perform pick operation with selection point and orientation provided.
int Pick3DPoint(double selectionPt[3], vtkRenderer *ren) override
Perform pick operation with selection point provided.
void Initialize() override
virtual int Pick3DInternal(vtkRenderer *ren, double p1World[4], double p2World[4])
~vtkPicker() override
static bool CalculateRay(const double p1[3], const double p2[3], double ray[3], double &rayFactor)
vtkDataSet * DataSet
Definition: vtkPicker.h:198
virtual double IntersectWithLine(const double p1[3], const double p2[3], double tol, vtkAssemblyPath *path, vtkProp3D *p, vtkAbstractMapper3D *m)
int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer *renderer) override
Perform pick operation with selection point provided.
double GlobalTMin
Definition: vtkPicker.h:202
vtkProp3DCollection * Prop3Ds
Definition: vtkPicker.h:205
void MarkPickedData(vtkAssemblyPath *path, double tMin, double mapperPos[3], vtkAbstractMapper3D *mapper, vtkDataSet *input, vtkIdType flatBlockIndex=-1)
double Tolerance
Definition: vtkPicker.h:194
vtkActorCollection * Actors
Definition: vtkPicker.h:204
void MarkPicked(vtkAssemblyPath *path, vtkProp3D *p, vtkAbstractMapper3D *m, double tMin, double mapperPos[3])
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAbstractMapper3D * Mapper
Definition: vtkPicker.h:197
represent and manipulate 3D points
Definition: vtkPoints.h:143
an ordered list of 3D props
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:93
abstract specification for renderers
Definition: vtkRenderer.h:182
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
int vtkIdType
Definition: vtkType.h:332