VTK  9.3.0
vtkConstrainedPointHandleRepresentation.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
28 #ifndef vtkConstrainedPointHandleRepresentation_h
29 #define vtkConstrainedPointHandleRepresentation_h
30 
32 #include "vtkInteractionWidgetsModule.h" // For export macro
33 
34 VTK_ABI_NAMESPACE_BEGIN
35 class vtkProperty;
36 class vtkActor;
37 class vtkPolyDataMapper;
38 class vtkPolyData;
39 class vtkGlyph3D;
40 class vtkPoints;
41 class vtkPolyData;
42 class vtkPlane;
43 class vtkPlaneCollection;
44 class vtkPlanes;
45 class vtkRenderer;
46 
47 class VTKINTERACTIONWIDGETS_EXPORT vtkConstrainedPointHandleRepresentation
49 {
50 public:
55 
57 
61  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
65 
67 
72  void SetCursorShape(vtkPolyData* cursorShape);
75 
77 
82  void SetActiveCursorShape(vtkPolyData* activeShape);
85 
87 
92  vtkSetClampMacro(ProjectionNormal, int, vtkConstrainedPointHandleRepresentation::XAxis,
94  vtkGetMacro(ProjectionNormal, int);
96 
98  {
99  this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::XAxis);
100  }
102  {
103  this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::YAxis);
104  }
106  {
107  this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::ZAxis);
108  }
110  {
111  this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::Oblique);
112  }
113 
115 
120  vtkGetObjectMacro(ObliquePlane, vtkPlane);
122 
124 
132  vtkGetMacro(ProjectionPosition, double);
134 
136 
148  vtkGetObjectMacro(BoundingPlanes, vtkPlaneCollection);
151 
157  int CheckConstraint(vtkRenderer* renderer, double pos[2]) override;
158 
160 
165  void SetPosition(double x, double y, double z);
166  void SetPosition(double xyz[3]);
167  double* GetPosition();
168  void GetPosition(double xyz[3]);
170 
172 
176  vtkGetObjectMacro(Property, vtkProperty);
178 
180 
184  vtkGetObjectMacro(SelectedProperty, vtkProperty);
186 
188 
192  vtkGetObjectMacro(ActiveProperty, vtkProperty);
194 
196 
201  void SetRenderer(vtkRenderer* ren) override;
202  void BuildRepresentation() override;
203  void StartWidgetInteraction(double eventPos[2]) override;
204  void WidgetInteraction(double eventPos[2]) override;
205  int ComputeInteractionState(int X, int Y, int modify) override;
207 
212  void SetDisplayPosition(double pos[3]) override;
213 
215 
218  void GetActors(vtkPropCollection*) override;
220  int RenderOverlay(vtkViewport* viewport) override;
221  int RenderOpaqueGeometry(vtkViewport* viewport) override;
224  void ShallowCopy(vtkProp* prop) override;
226 
227  enum
228  {
229  XAxis = 0,
232  Oblique
233  };
234 
235  void Highlight(int highlight) override;
236 
237 protected:
240 
241  // Render the cursor
249 
250  // Support picking
251  double LastPickPosition[3];
252  double LastEventPosition[2];
253 
254  // Methods to manipulate the cursor
255  void Translate(const double* eventPos) override;
256  void Scale(const double* eventPos);
257 
258  // Properties used to control the appearance of selected objects and
259  // the manipulator in general.
264 
265  // Controlling vars
270 
272 
273  // Internal method for computing 3D location from 2D screen position
274  int GetIntersectionPosition(const double eventPos[2], double worldPos[3], double tolerance = 0.0,
275  vtkRenderer* renderer = nullptr);
276 
277  // Internal method for getting the project normal as a vector
278  void GetProjectionNormal(double normal[3]);
279 
280  // Internal method for getting the origin of the
281  // constraining plane as a 3-tuple
282  void GetProjectionOrigin(double origin[3]);
283 
284  // Distance between where the mouse event happens and where the
285  // widget is focused - maintain this distance during interaction.
286  double InteractionOffset[2];
287 
288 private:
290  void operator=(const vtkConstrainedPointHandleRepresentation&) = delete;
291 };
292 
293 VTK_ABI_NAMESPACE_END
294 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
point representation constrained to a 2D plane
void Translate(const double *eventPos) override
Translates world position by vector v projected on the constraint axis if any.
void ShallowCopy(vtkProp *prop) override
Methods to make this class behave as a vtkProp.
vtkPolyData * GetCursorShape()
Specify the cursor shape.
void StartWidgetInteraction(double eventPos[2]) override
Subclasses of vtkConstrainedPointHandleRepresentation must implement these methods.
void RemoveAllBoundingPlanes()
A collection of plane equations used to bound the position of the point.
double * GetPosition()
Set/Get the position of the point in display coordinates.
void Scale(const double *eventPos)
int ComputeInteractionState(int X, int Y, int modify) override
Subclasses of vtkConstrainedPointHandleRepresentation must implement these methods.
void Highlight(int highlight) override
void SetDisplayPosition(double pos[3]) override
Method overridden from Superclass.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods to make this class behave as a vtkProp.
void WidgetInteraction(double eventPos[2]) override
Subclasses of vtkConstrainedPointHandleRepresentation must implement these methods.
void AddBoundingPlane(vtkPlane *plane)
A collection of plane equations used to bound the position of the point.
void GetActors(vtkPropCollection *) override
Methods to make this class behave as a vtkProp.
int CheckConstraint(vtkRenderer *renderer, double pos[2]) override
Overridden from the base class.
int RenderOpaqueGeometry(vtkViewport *viewport) override
Methods to make this class behave as a vtkProp.
void GetPosition(double xyz[3])
Set/Get the position of the point in display coordinates.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
Methods to make this class behave as a vtkProp.
void SetProjectionPosition(double position)
The position of the bounding plane from the origin along the normal.
void SetPosition(double xyz[3])
Set/Get the position of the point in display coordinates.
void SetRenderer(vtkRenderer *ren) override
Subclasses of vtkConstrainedPointHandleRepresentation must implement these methods.
void SetPosition(double x, double y, double z)
Set/Get the position of the point in display coordinates.
void SetActiveCursorShape(vtkPolyData *activeShape)
Specify the shape of the cursor (handle) when it is active.
void BuildRepresentation() override
Subclasses of vtkConstrainedPointHandleRepresentation must implement these methods.
void SetCursorShape(vtkPolyData *cursorShape)
Specify the cursor shape.
static vtkConstrainedPointHandleRepresentation * New()
Instantiate this class.
void SetBoundingPlanes(vtkPlanes *planes)
A collection of plane equations used to bound the position of the point.
virtual void SetBoundingPlanes(vtkPlaneCollection *)
A collection of plane equations used to bound the position of the point.
void RemoveBoundingPlane(vtkPlane *plane)
A collection of plane equations used to bound the position of the point.
void GetProjectionOrigin(double origin[3])
vtkPolyData * GetActiveCursorShape()
Specify the shape of the cursor (handle) when it is active.
void ReleaseGraphicsResources(vtkWindow *) override
Methods to make this class behave as a vtkProp.
int GetIntersectionPosition(const double eventPos[2], double worldPos[3], double tolerance=0.0, vtkRenderer *renderer=nullptr)
void GetProjectionNormal(double normal[3])
int RenderOverlay(vtkViewport *viewport) override
Methods to make this class behave as a vtkProp.
void SetObliquePlane(vtkPlane *)
If the ProjectionNormal is set to Oblique, then this is the oblique plane used to constrain the handl...
copy oriented and scaled glyph geometry to every input point
Definition: vtkGlyph3D.h:111
abstract class for representing widget handles
virtual void Translate(const double *p1, const double *p2)
Translates world position by vector p1p2 projected on the constraint axis if any.
a simple class to control print indentation
Definition: vtkIndent.h:38
maintain a list of planes
perform various plane computations
Definition: vtkPlane.h:35
implicit function for convex set of planes
Definition: vtkPlanes.h:51
represent and manipulate 3D points
Definition: vtkPoints.h:38
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:55
represent surface properties of a geometric object
Definition: vtkProperty.h:66
abstract specification for renderers
Definition: vtkRenderer.h:71
abstract specification for Viewports
Definition: vtkViewport.h:54
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
@ position
Definition: vtkX3D.h:261
int vtkTypeBool
Definition: vtkABI.h:64