VTK  9.3.0
vtkHardwarePicker.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
24#ifndef vtkHardwarePicker_h
25#define vtkHardwarePicker_h
26
28#include "vtkNew.h" // For vtkNew
29#include "vtkRenderingCoreModule.h" // For export macro
30#include "vtkSmartPointer.h" // For vtkSmartPointer
31
32VTK_ABI_NAMESPACE_BEGIN
34class vtkCell;
36class vtkDataSet;
37class vtkSelection;
38
39class VTKRENDERINGCORE_EXPORT vtkHardwarePicker : public vtkAbstractPropPicker
40{
41public:
44 void PrintSelf(ostream& os, vtkIndent indent) override;
45
47
51 vtkSetMacro(SnapToMeshPoint, bool);
52 vtkGetMacro(SnapToMeshPoint, bool);
53 vtkBooleanMacro(SnapToMeshPoint, bool);
55
57
61 vtkSetMacro(PixelTolerance, int);
62 vtkGetMacro(PixelTolerance, int);
64
66
71 vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
73
75
81 vtkGetObjectMacro(DataSet, vtkDataSet);
83
85
91 vtkGetObjectMacro(CompositeDataSet, vtkCompositeDataSet);
93
95
100 vtkGetMacro(FlatBlockIndex, vtkIdType);
102
104
114 vtkGetMacro(PointId, vtkIdType);
116
118
128 vtkGetMacro(CellId, vtkIdType);
130
132
144 vtkGetMacro(SubId, int);
146
148
160 vtkGetVector3Macro(PCoords, double);
162
164
177 vtkGetVectorMacro(PickNormal, double, 3);
179
186 vtkGetMacro(NormalFlipped, bool);
187
197 int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
198
199protected:
202
203 void Initialize() override;
204 // converts the propCandidate into a vtkAbstractMapper3D and returns its pickability
206
216
221 int ComputeSurfaceNormal(vtkDataSet* data, vtkCell* cell, double* weights);
222
227
228 bool SnapToMeshPoint; // if true, the pick position is snapped to the closest point on the mesh
229 int PixelTolerance; // tolerance for picking when snapping the closest point on the mesh
230
231 vtkNew<vtkPropCollection> PickableProps; // list of pickable props
232 vtkSmartPointer<vtkSelection> HardwareSelection; // result of the hardware selector
233
234 double NearRayPoint[3]; // near ray point
235 double FarRayPoint[3]; // far ray point
236
237 vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
238 vtkDataSet* DataSet; // selected dataset (if there is one)
239 vtkCompositeDataSet* CompositeDataSet; // selected dataset (if there is one)
240 vtkIdType FlatBlockIndex; // flat block index, for a composite data set
241
242 vtkIdType PointId; // id of the picked point
243 vtkIdType CellId; // id of the picked cell
244 int SubId; // sub id of the picked cell
245 double PCoords[3]; // parametric coordinates of the picked point
246 double PickNormal[3]; // normal of the picked surface
247 bool NormalFlipped; // Flag to indicate if the normal has been flipped
248
249private:
250 vtkHardwarePicker(const vtkHardwarePicker&) = delete;
251 void operator=(const vtkHardwarePicker&) = delete;
252};
253
254VTK_ABI_NAMESPACE_END
255#endif
abstract class specifies interface to map 3D data
abstract API for pickers that can pick an instance of vtkProp
abstract class to specify cell behavior
Definition vtkCell.h:50
abstract superclass for composite (multi-block or AMR) datasets
abstract class to specify dataset behavior
Definition vtkDataSet.h:53
pick a point or snap to point of an actor/prop using graphics hardware
void Initialize() override
static vtkHardwarePicker * New()
~vtkHardwarePicker() override
vtkAbstractMapper3D * Mapper
void ComputeIntersectionFromDataSet(vtkDataSet *ds)
Compute the intersection using provided dataset.
int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer *renderer) override
Perform the pick operation set the PickedProp.
void FixNormalSign()
Fix normal sign in case the orientation of the picked cell is wrong.
vtkNew< vtkPropCollection > PickableProps
int TypeDecipher(vtkProp *, vtkAbstractMapper3D **)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkCompositeDataSet * CompositeDataSet
vtkSmartPointer< vtkSelection > HardwareSelection
int ComputeSurfaceNormal(vtkDataSet *data, vtkCell *cell, double *weights)
Compute the intersection normal either by interpolating the point normals at the intersected point,...
a simple class to control print indentation
Definition vtkIndent.h:29
Allocate and hold a VTK object.
Definition vtkNew.h:51
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:43
abstract specification for renderers
Definition vtkRenderer.h:59
data object that represents a "selection" in VTK.
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition vtkType.h:315