VTK  9.3.0
vtkPicker.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
32#ifndef vtkPicker_h
33#define vtkPicker_h
34
36#include "vtkRenderingCoreModule.h" // For export macro
37
38VTK_ABI_NAMESPACE_BEGIN
41class vtkDataSet;
42class vtkTransform;
45class vtkPoints;
46
47class VTKRENDERINGCORE_EXPORT vtkPicker : public vtkAbstractPropPicker
48{
49public:
50 static vtkPicker* New();
52 void PrintSelf(ostream& os, vtkIndent indent) override;
53
55
60 vtkSetMacro(Tolerance, double);
61 vtkGetMacro(Tolerance, double);
63
65
69 vtkGetVectorMacro(MapperPosition, double, 3);
71
73
76 vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
78
80
84 vtkGetObjectMacro(DataSet, vtkDataSet);
86
88
92 vtkGetObjectMacro(CompositeDataSet, vtkCompositeDataSet);
94
96
101 vtkGetMacro(FlatBlockIndex, vtkIdType);
103
108 vtkProp3DCollection* GetProp3Ds() { return this->Prop3Ds; }
109
116
122 vtkPoints* GetPickedPositions() { return this->PickedPositions; }
123
130 int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
131
137 int Pick(double selectionPt[3], vtkRenderer* ren)
138 {
139 return this->Pick(selectionPt[0], selectionPt[1], selectionPt[2], ren);
140 }
141
147 int Pick3DPoint(double selectionPt[3], vtkRenderer* ren) override;
148
149 /*
150 * Pick a point in the scene with the selection point and focal point
151 * provided. The two points are in world coordinates.
152 *
153 * Returns non-zero if something was successfully picked.
154 */
155 virtual int Pick3DPoint(double p1World[3], double p2World[3], vtkRenderer* ren);
161 int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer* ren) override;
162
163protected:
165 ~vtkPicker() override;
166
167 // shared code for picking
168 virtual int Pick3DInternal(vtkRenderer* ren, double p1World[4], double p2World[4]);
169
171 vtkAssemblyPath* path, vtkProp3D* p, vtkAbstractMapper3D* m, double tMin, double mapperPos[3]);
172 void MarkPickedData(vtkAssemblyPath* path, double tMin, double mapperPos[3],
173 vtkAbstractMapper3D* mapper, vtkDataSet* input, vtkIdType flatBlockIndex = -1);
174 virtual double IntersectWithLine(const double p1[3], const double p2[3], double tol,
176 void Initialize() override;
177 static bool CalculateRay(
178 const double p1[3], const double p2[3], double ray[3], double& rayFactor);
179
180 double Tolerance; // tolerance for computation (% of window)
181 double MapperPosition[3]; // selection point in untransformed coordinates
182
183 vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
184 vtkDataSet* DataSet; // selected dataset (if there is one)
186 vtkIdType FlatBlockIndex; // flat block index, for a composite data set
187
188 double GlobalTMin; // parametric coordinate along pick ray where hit occurred
189 vtkTransform* Transform; // use to perform ray transformation
190 vtkActorCollection* Actors; // candidate actors (based on bounding box)
191 vtkProp3DCollection* Prop3Ds; // candidate actors (based on bounding box)
192 vtkPoints* PickedPositions; // candidate positions
193
194private:
195 vtkPicker(const vtkPicker&) = delete;
196 void operator=(const vtkPicker&) = delete;
197};
198
199VTK_ABI_NAMESPACE_END
200#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:53
a simple class to control print indentation
Definition vtkIndent.h:29
superclass for 3D geometric pickers (uses ray cast)
Definition vtkPicker.h:48
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:192
vtkPoints * GetPickedPositions()
Return a list of the points the actors returned by GetProp3Ds were intersected at.
Definition vtkPicker.h:122
int Pick(double selectionPt[3], vtkRenderer *ren)
Perform pick operation with selection point provided.
Definition vtkPicker.h:137
vtkTransform * Transform
Definition vtkPicker.h:189
vtkIdType FlatBlockIndex
Definition vtkPicker.h:186
vtkProp3DCollection * GetProp3Ds()
Return a collection of all the prop 3D's that were intersected by the pick ray.
Definition vtkPicker.h:108
vtkCompositeDataSet * CompositeDataSet
Definition vtkPicker.h:185
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:184
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:188
vtkProp3DCollection * Prop3Ds
Definition vtkPicker.h:191
void MarkPickedData(vtkAssemblyPath *path, double tMin, double mapperPos[3], vtkAbstractMapper3D *mapper, vtkDataSet *input, vtkIdType flatBlockIndex=-1)
double Tolerance
Definition vtkPicker.h:180
vtkActorCollection * Actors
Definition vtkPicker.h:190
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:183
represent and manipulate 3D points
Definition vtkPoints.h:29
an ordered list of 3D props
represents an 3D object for placement in a rendered scene
Definition vtkProp3D.h:39
abstract specification for renderers
Definition vtkRenderer.h:59
describes linear transformations via a 4x4 matrix
int vtkIdType
Definition vtkType.h:315