VTK  9.5.20250715
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
27#ifndef vtkHardwarePicker_h
28#define vtkHardwarePicker_h
29
31#include "vtkNew.h" // For vtkNew
32#include "vtkRenderingCoreModule.h" // For export macro
33#include "vtkSmartPointer.h" // For vtkSmartPointer
34#include "vtkStringToken.h" // for vtkStringToken
35#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
36
37VTK_ABI_NAMESPACE_BEGIN
39class vtkCell;
41class vtkDataObject;
42class vtkDataSet;
43class vtkSelection;
44
45class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkHardwarePicker : public vtkAbstractPropPicker
46{
47public:
50 void PrintSelf(ostream& os, vtkIndent indent) override;
51
53
57 vtkSetMacro(SnapToMeshPoint, bool);
58 vtkGetMacro(SnapToMeshPoint, bool);
59 vtkBooleanMacro(SnapToMeshPoint, bool);
61
63
67 vtkSetMacro(PixelTolerance, int);
68 vtkGetMacro(PixelTolerance, int);
70
72
77 vtkGetObjectMacro(Mapper, vtkAbstractMapper3D);
79
81
87 vtkGetObjectMacro(DataSet, vtkDataSet);
89
91
97 vtkGetObjectMacro(DataObject, vtkDataObject);
99
101
107 vtkGetObjectMacro(CompositeDataSet, vtkCompositeDataSet);
109
111
116 vtkGetMacro(FlatBlockIndex, vtkIdType);
118
120
130 vtkGetMacro(PointId, vtkIdType);
132
134
144 vtkGetMacro(CellId, vtkIdType);
146
148
160 vtkGetMacro(SubId, int);
162
164
171 vtkGetMacro(CellGridCellTypeId, vtkIdType);
173
175
186 vtkGetMacro(CellGridSourceSpecId, vtkIdType);
188
190
197 vtkGetMacro(CellGridTupleId, vtkIdType);
199
201
213 vtkGetVector3Macro(PCoords, double);
215
217
230 vtkGetVectorMacro(PickNormal, double, 3);
232
239 vtkGetMacro(NormalFlipped, bool);
240
250 int Pick(double selectionX, double selectionY, double selectionZ, vtkRenderer* renderer) override;
251
252protected:
255
256 void Initialize() override;
257 // converts the propCandidate into a vtkAbstractMapper3D and returns its pickability
259
269
274 int ComputeSurfaceNormal(vtkDataSet* data, vtkCell* cell, double* weights);
275
280
281 bool SnapToMeshPoint; // if true, the pick position is snapped to the closest point on the mesh
282 int PixelTolerance; // tolerance for picking when snapping the closest point on the mesh
283
284 vtkNew<vtkPropCollection> PickableProps; // list of pickable props
285 vtkSmartPointer<vtkSelection> HardwareSelection; // result of the hardware selector
286
287 double NearRayPoint[3]; // near ray point
288 double FarRayPoint[3]; // far ray point
289
290 vtkAbstractMapper3D* Mapper; // selected mapper (if the prop has a mapper)
291 vtkDataSet* DataSet; // selected dataset (if there is one)
292 vtkDataObject* DataObject; // selected dataobject (useful when the picked object is directly
293 // derived from vtkDataObject)
294 vtkCompositeDataSet* CompositeDataSet; // selected dataset (if there is one)
295 vtkIdType FlatBlockIndex; // flat block index, for a composite data set
296
297 vtkIdType PointId; // id of the picked point
298 vtkIdType CellId; // id of the picked cell
299 int SubId; // sub id of the picked cell
300 vtkIdType CellGridCellTypeId; // id of the picked cell type in a vtkCellGrid
301 vtkIdType CellGridSourceSpecId; // id of the picked cell/side spec in a vtkCellGrid. 0 is for cell
302 // spec, 1+ is for side specs
304 CellGridTupleId; // id of the picked tuple in the cell/side connectivity of a vtkCellGrid
305 double PCoords[3]; // parametric coordinates of the picked point
306 double PickNormal[3]; // normal of the picked surface
307 bool NormalFlipped; // Flag to indicate if the normal has been flipped
308
309private:
310 vtkHardwarePicker(const vtkHardwarePicker&) = delete;
311 void operator=(const vtkHardwarePicker&) = delete;
312};
313
314VTK_ABI_NAMESPACE_END
315#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:66
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