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=========================================================================*/
41#ifndef vtkPicker_h
42#define vtkPicker_h
43
45#include "vtkRenderingCoreModule.h" // For export macro
46
49class vtkDataSet;
50class vtkTransform;
53class vtkPoints;
54
55class VTKRENDERINGCORE_EXPORT vtkPicker : public vtkAbstractPropPicker
56{
57public:
58 static vtkPicker* New();
60 void PrintSelf(ostream& os, vtkIndent indent) override;
61
63
68 vtkSetMacro(Tolerance, double);
69 vtkGetMacro(Tolerance, double);
71
73
77 vtkGetVectorMacro(MapperPosition, double, 3);
79
81
84 vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
86
88
92 vtkGetObjectMacro(DataSet, vtkDataSet);
94
96
100 vtkGetObjectMacro(CompositeDataSet, vtkCompositeDataSet);
102
104
109 vtkGetMacro(FlatBlockIndex, vtkIdType);
111
116 vtkProp3DCollection* GetProp3Ds() { return this->Prop3Ds; }
117
124
130 vtkPoints* GetPickedPositions() { return this->PickedPositions; }
131
138 int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
139
145 int Pick(double selectionPt[3], vtkRenderer* ren)
146 {
147 return this->Pick(selectionPt[0], selectionPt[1], selectionPt[2], ren);
148 }
149
155 int Pick3DPoint(double selectionPt[3], vtkRenderer* ren) override;
156
157 /*
158 * Pick a point in the scene with the selection point and focal point
159 * provided. The two points are in world coordinates.
160 *
161 * Returns non-zero if something was successfully picked.
162 */
163 virtual int Pick3DPoint(double p1World[3], double p2World[3], vtkRenderer* ren);
169 int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer* ren) override;
170
171protected:
173 ~vtkPicker() override;
174
175 // shared code for picking
176 virtual int Pick3DInternal(vtkRenderer* ren, double p1World[4], double p2World[4]);
177
179 vtkAssemblyPath* path, vtkProp3D* p, vtkAbstractMapper3D* m, double tMin, double mapperPos[3]);
180 void MarkPickedData(vtkAssemblyPath* path, double tMin, double mapperPos[3],
181 vtkAbstractMapper3D* mapper, vtkDataSet* input, vtkIdType flatBlockIndex = -1);
182 virtual double IntersectWithLine(const double p1[3], const double p2[3], double tol,
184 void Initialize() override;
185 static bool CalculateRay(
186 const double p1[3], const double p2[3], double ray[3], double& rayFactor);
187
188 double Tolerance; // tolerance for computation (% of window)
189 double MapperPosition[3]; // selection point in untransformed coordinates
190
191 vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
192 vtkDataSet* DataSet; // selected dataset (if there is one)
194 vtkIdType FlatBlockIndex; // flat block index, for a composite data set
195
196 double GlobalTMin; // parametric coordinate along pick ray where hit occurred
197 vtkTransform* Transform; // use to perform ray transformation
198 vtkActorCollection* Actors; // candidate actors (based on bounding box)
199 vtkProp3DCollection* Prop3Ds; // candidate actors (based on bounding box)
200 vtkPoints* PickedPositions; // candidate positions
201
202private:
203 vtkPicker(const vtkPicker&) = delete;
204 void operator=(const vtkPicker&) = delete;
205};
206
207#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:56
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:200
vtkPoints * GetPickedPositions()
Return a list of the points the actors returned by GetProp3Ds were intersected at.
Definition: vtkPicker.h:130
int Pick(double selectionPt[3], vtkRenderer *ren)
Perform pick operation with selection point provided.
Definition: vtkPicker.h:145
vtkTransform * Transform
Definition: vtkPicker.h:197
vtkIdType FlatBlockIndex
Definition: vtkPicker.h:194
vtkProp3DCollection * GetProp3Ds()
Return a collection of all the prop 3D's that were intersected by the pick ray.
Definition: vtkPicker.h:116
vtkCompositeDataSet * CompositeDataSet
Definition: vtkPicker.h:193
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:192
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:196
vtkProp3DCollection * Prop3Ds
Definition: vtkPicker.h:199
void MarkPickedData(vtkAssemblyPath *path, double tMin, double mapperPos[3], vtkAbstractMapper3D *mapper, vtkDataSet *input, vtkIdType flatBlockIndex=-1)
double Tolerance
Definition: vtkPicker.h:188
vtkActorCollection * Actors
Definition: vtkPicker.h:198
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:191
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:173
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:39
int vtkIdType
Definition: vtkType.h:332