VTK  9.4.20250509
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
35#ifndef vtkPicker_h
36#define vtkPicker_h
37
39#include "vtkRenderingCoreModule.h" // For export macro
40#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
41
42VTK_ABI_NAMESPACE_BEGIN
45class vtkDataSet;
46class vtkTransform;
49class vtkPoints;
50
51class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkPicker : public vtkAbstractPropPicker
52{
53public:
54 static vtkPicker* New();
56 void PrintSelf(ostream& os, vtkIndent indent) override;
57
59
64 vtkSetMacro(Tolerance, double);
65 vtkGetMacro(Tolerance, double);
67
69
73 vtkGetVectorMacro(MapperPosition, double, 3);
75
77
80 vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
82
84
88 vtkGetObjectMacro(DataSet, vtkDataSet);
90
92
96 vtkGetObjectMacro(CompositeDataSet, vtkCompositeDataSet);
98
100
105 vtkGetMacro(FlatBlockIndex, vtkIdType);
107
112 vtkProp3DCollection* GetProp3Ds() { return this->Prop3Ds; }
113
120
126 vtkPoints* GetPickedPositions() { return this->PickedPositions; }
127
134 int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
135
141 int Pick(double selectionPt[3], vtkRenderer* ren)
142 {
143 return this->Pick(selectionPt[0], selectionPt[1], selectionPt[2], ren);
144 }
145
151 int Pick3DPoint(double selectionPt[3], vtkRenderer* ren) override;
152
153 /*
154 * Pick a point in the scene with the selection point and focal point
155 * provided. The two points are in world coordinates.
156 *
157 * Returns non-zero if something was successfully picked.
158 */
159 virtual int Pick3DPoint(double p1World[3], double p2World[3], vtkRenderer* ren);
165 int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer* ren) override;
166
167protected:
169 ~vtkPicker() override;
170
171 // shared code for picking
172 virtual int Pick3DInternal(vtkRenderer* ren, double p1World[4], double p2World[4]);
173
175 vtkAssemblyPath* path, vtkProp3D* p, vtkAbstractMapper3D* m, double tMin, double mapperPos[3]);
176 void MarkPickedData(vtkAssemblyPath* path, double tMin, double mapperPos[3],
177 vtkAbstractMapper3D* mapper, vtkDataSet* input, vtkIdType flatBlockIndex = -1);
178 virtual double IntersectWithLine(const double p1[3], const double p2[3], double tol,
180 void Initialize() override;
181 static bool CalculateRay(
182 const double p1[3], const double p2[3], double ray[3], double& rayFactor);
183
184 double Tolerance; // tolerance for computation (% of window)
185 double MapperPosition[3]; // selection point in untransformed coordinates
186
187 vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
188 vtkDataSet* DataSet; // selected dataset (if there is one)
190 vtkIdType FlatBlockIndex; // flat block index, for a composite data set
191
192 double GlobalTMin; // parametric coordinate along pick ray where hit occurred
193 vtkTransform* Transform; // use to perform ray transformation
194 vtkActorCollection* Actors; // candidate actors (based on bounding box)
195 vtkProp3DCollection* Prop3Ds; // candidate actors (based on bounding box)
196 vtkPoints* PickedPositions; // candidate positions
197
198private:
199 vtkPicker(const vtkPicker&) = delete;
200 void operator=(const vtkPicker&) = delete;
201};
202
203VTK_ABI_NAMESPACE_END
204#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:165
a simple class to control print indentation
Definition vtkIndent.h:108
superclass for 3D geometric pickers (uses ray cast)
Definition vtkPicker.h:52
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:196
vtkPoints * GetPickedPositions()
Return a list of the points the actors returned by GetProp3Ds were intersected at.
Definition vtkPicker.h:126
int Pick(double selectionPt[3], vtkRenderer *ren)
Perform pick operation with selection point provided.
Definition vtkPicker.h:141
vtkTransform * Transform
Definition vtkPicker.h:193
vtkIdType FlatBlockIndex
Definition vtkPicker.h:190
vtkProp3DCollection * GetProp3Ds()
Return a collection of all the prop 3D's that were intersected by the pick ray.
Definition vtkPicker.h:112
vtkCompositeDataSet * CompositeDataSet
Definition vtkPicker.h:189
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:188
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:192
vtkProp3DCollection * Prop3Ds
Definition vtkPicker.h:195
void MarkPickedData(vtkAssemblyPath *path, double tMin, double mapperPos[3], vtkAbstractMapper3D *mapper, vtkDataSet *input, vtkIdType flatBlockIndex=-1)
double Tolerance
Definition vtkPicker.h:184
vtkActorCollection * Actors
Definition vtkPicker.h:194
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:187
represent and manipulate 3D points
Definition vtkPoints.h:139
an ordered list of 3D props
represents an 3D object for placement in a rendered scene
Definition vtkProp3D.h:89
abstract specification for renderers
describes linear transformations via a 4x4 matrix
int vtkIdType
Definition vtkType.h:332
#define VTK_MARSHALAUTO