VTK  9.5.20250815
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
30#ifndef vtkHardwarePicker_h
31#define vtkHardwarePicker_h
32
34#include "vtkNew.h" // For vtkNew
35#include "vtkRenderingCoreModule.h" // For export macro
36#include "vtkSmartPointer.h" // For vtkSmartPointer
37#include "vtkStringToken.h" // for vtkStringToken
38#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
39
40VTK_ABI_NAMESPACE_BEGIN
42class vtkCell;
44class vtkDataObject;
45class vtkDataSet;
46class vtkSelection;
47
48class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkHardwarePicker : public vtkAbstractPropPicker
49{
50public:
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
56
60 vtkSetMacro(SnapToMeshPoint, bool);
61 vtkGetMacro(SnapToMeshPoint, bool);
62 vtkBooleanMacro(SnapToMeshPoint, bool);
64
66
70 vtkSetMacro(PixelTolerance, int);
71 vtkGetMacro(PixelTolerance, int);
73
75
80 vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
82
84
90 vtkGetObjectMacro(DataSet, vtkDataSet);
92
94
100 vtkGetObjectMacro(DataObject, vtkDataObject);
102
104
110 vtkGetObjectMacro(CompositeDataSet, vtkCompositeDataSet);
112
114
119 vtkGetMacro(FlatBlockIndex, vtkIdType);
121
123
133 vtkGetMacro(PointId, vtkIdType);
135
137
147 vtkGetMacro(CellId, vtkIdType);
149
151
163 vtkGetMacro(SubId, int);
165
167
174 vtkGetMacro(CellGridCellTypeId, vtkIdType);
176
178
189 vtkGetMacro(CellGridSourceSpecId, vtkIdType);
191
193
200 vtkGetMacro(CellGridTupleId, vtkIdType);
202
204
216 vtkGetVector3Macro(PCoords, double);
218
220
233 vtkGetVectorMacro(PickNormal, double, 3);
235
242 vtkGetMacro(NormalFlipped, bool);
243
253 int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
254
255protected:
258
259 void Initialize() override;
260 // converts the propCandidate into a vtkAbstractMapper3D and returns its pickability
262
272
277 int ComputeSurfaceNormal(vtkDataSet* data, vtkCell* cell, double* weights);
278
283
284 bool SnapToMeshPoint; // if true, the pick position is snapped to the closest point on the mesh
285 int PixelTolerance; // tolerance for picking when snapping the closest point on the mesh
286
287 vtkNew<vtkPropCollection> PickableProps; // list of pickable props
288 vtkSmartPointer<vtkSelection> HardwareSelection; // result of the hardware selector
289
290 double NearRayPoint[3]; // near ray point
291 double FarRayPoint[3]; // far ray point
292
293 vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
294 vtkDataSet* DataSet; // selected dataset (if there is one)
295 vtkDataObject* DataObject; // selected dataobject (useful when the picked object is directly
296 // derived from vtkDataObject)
297 vtkCompositeDataSet* CompositeDataSet; // selected dataset (if there is one)
298 vtkIdType FlatBlockIndex; // flat block index, for a composite data set
299
300 vtkIdType PointId; // id of the picked point
301 vtkIdType CellId; // id of the picked cell
302 int SubId; // sub id of the picked cell
303 vtkIdType CellGridCellTypeId; // id of the picked cell type in a vtkCellGrid
304 vtkIdType CellGridSourceSpecId; // id of the picked cell/side spec in a vtkCellGrid. 0 is for cell
305 // spec, 1+ is for side specs
307 CellGridTupleId; // id of the picked tuple in the cell/side connectivity of a vtkCellGrid
308 double PCoords[3]; // parametric coordinates of the picked point
309 double PickNormal[3]; // normal of the picked surface
310 bool NormalFlipped; // Flag to indicate if the normal has been flipped
311
312private:
313 vtkHardwarePicker(const vtkHardwarePicker&) = delete;
314 void operator=(const vtkHardwarePicker&) = delete;
315};
316
317VTK_ABI_NAMESPACE_END
318#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:129
abstract superclass for composite (multi-block or AMR) datasets
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
pick a point or snap to point of an actor/prop using graphics hardware
void Initialize() override
static vtkHardwarePicker * New()
~vtkHardwarePicker() override
vtkAbstractMapper3D * Mapper
vtkDataObject * DataObject
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:108
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:69
abstract specification for renderers
data object that represents a "selection" in VTK.
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition vtkType.h:332
#define VTK_MARSHALAUTO