VTK
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 "vtkRenderingCoreModule.h" // For export macro
45 #include "vtkAbstractPropPicker.h"
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 
117  { return this->Prop3Ds; }
118 
124  vtkActorCollection *GetActors();
125 
132  { return this->PickedPositions; }
133 
140  int Pick(double selectionX, double selectionY, double selectionZ,
141  vtkRenderer *renderer) override;
142 
148  int Pick(double selectionPt[3], vtkRenderer *ren)
149  { return this->Pick(selectionPt[0], selectionPt[1], selectionPt[2], ren); }
150 
156  int Pick3DPoint(double selectionPt[3], vtkRenderer *ren) override;
157 
163  int Pick3DRay(double selectionPt[3], double orient[4], vtkRenderer *ren) override;
164 
165 protected:
166  vtkPicker();
167  ~vtkPicker() override;
168 
169  // shared code for picking
170  virtual int Pick3DInternal(vtkRenderer *ren, double p1World[4], double p2World[4]);
171 
172  void MarkPicked(vtkAssemblyPath *path, vtkProp3D *p, vtkAbstractMapper3D *m,
173  double tMin, double mapperPos[3]);
174  void MarkPickedData(vtkAssemblyPath *path,
175  double tMin, double mapperPos[3], vtkAbstractMapper3D* mapper,
176  vtkDataSet* input, vtkIdType flatBlockIndex = -1);
177  virtual double IntersectWithLine(const double p1[3], const double p2[3], double tol,
178  vtkAssemblyPath *path, vtkProp3D *p,
180  void Initialize() override;
181  static bool CalculateRay(const double p1[3], const double p2[3],
182  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 
198 private:
199  vtkPicker(const vtkPicker&) = delete;
200  void operator=(const vtkPicker&) = delete;
201 };
202 
203 #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:190
double Tolerance
Definition: vtkPicker.h:184
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkPoints * PickedPositions
Definition: vtkPicker.h:196
abstract specification for renderers
Definition: vtkRenderer.h:57
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:194
int vtkIdType
Definition: vtkType.h:347
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:148
vtkTransform * Transform
Definition: vtkPicker.h:193
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:131
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.
vtkProp3DCollection * Prop3Ds
Definition: vtkPicker.h:195
abstract class specifies interface to map 3D data
an ordered list of 3D props
vtkCompositeDataSet * CompositeDataSet
Definition: vtkPicker.h:189
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:187
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
double GlobalTMin
Definition: vtkPicker.h:192
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkDataSet * DataSet
Definition: vtkPicker.h:188