VTK  9.0.1
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 
44 #include "vtkAbstractPropPicker.h"
45 #include "vtkRenderingCoreModule.h" // For export macro
46 
49 class vtkDataSet;
50 class vtkTransform;
51 class vtkActorCollection;
53 class vtkPoints;
54 
55 class VTKRENDERINGCORE_EXPORT vtkPicker : public vtkAbstractPropPicker
56 {
57 public:
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 
123  vtkActorCollection* GetActors();
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 
171 protected:
172  vtkPicker();
173  ~vtkPicker() override;
174 
175  // shared code for picking
176  virtual int Pick3DInternal(vtkRenderer* ren, double p1World[4], double p2World[4]);
177 
178  void MarkPicked(
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 
202 private:
203  vtkPicker(const vtkPicker&) = delete;
204  void operator=(const vtkPicker&) = delete;
205 };
206 
207 #endif
virtual int Pick3DPoint(double [3], vtkRenderer *)
Perform pick operation with selection point provided.
virtual int Pick3DRay(double [3], double [4], vtkRenderer *)
Perform pick operation with selection point and orientation provided.
vtkIdType FlatBlockIndex
Definition: vtkPicker.h:194
double Tolerance
Definition: vtkPicker.h:188
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkPoints * PickedPositions
Definition: vtkPicker.h:200
abstract specification for renderers
Definition: vtkRenderer.h:58
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:43
vtkActorCollection * Actors
Definition: vtkPicker.h:198
int vtkIdType
Definition: vtkType.h:338
superclass for 3D geometric pickers (uses ray cast)
Definition: vtkPicker.h:55
void Initialize() override
int Pick(double selectionPt[3], vtkRenderer *ren)
Perform pick operation with selection point provided.
Definition: vtkPicker.h:145
vtkTransform * Transform
Definition: vtkPicker.h:197
vtkProp3DCollection * GetProp3Ds()
Return a collection of all the prop 3D's that were intersected by the pick ray.
Definition: vtkPicker.h:116
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:130
a simple class to control print indentation
Definition: vtkIndent.h:33
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:39
vtkProp3DCollection * Prop3Ds
Definition: vtkPicker.h:199
abstract class specifies interface to map 3D data
an ordered list of 3D props
vtkCompositeDataSet * CompositeDataSet
Definition: vtkPicker.h:193
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.
vtkAbstractMapper3D * Mapper
Definition: vtkPicker.h:191
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
double GlobalTMin
Definition: vtkPicker.h:196
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkDataSet * DataSet
Definition: vtkPicker.h:192