VTK  9.3.0
vtkBoxWidget.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
69#ifndef vtkBoxWidget_h
70#define vtkBoxWidget_h
71
72#include "vtk3DWidget.h"
73#include "vtkInteractionWidgetsModule.h" // For export macro
74
75VTK_ABI_NAMESPACE_BEGIN
76class vtkActor;
77class vtkCellPicker;
78class vtkPlanes;
79class vtkPoints;
80class vtkPolyData;
82class vtkProp;
83class vtkProperty;
84class vtkSphereSource;
85class vtkTransform;
86
87class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
88{
89public:
93 static vtkBoxWidget* New();
94
95 vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
96 void PrintSelf(ostream& os, vtkIndent indent) override;
97
99
102 void SetEnabled(int) override;
103 void PlaceWidget(double bounds[6]) override;
104 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
106 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
107 {
108 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
109 }
111
120 void GetPlanes(vtkPlanes* planes);
121
123
128 vtkSetMacro(InsideOut, vtkTypeBool);
129 vtkGetMacro(InsideOut, vtkTypeBool);
130 vtkBooleanMacro(InsideOut, vtkTypeBool);
132
140 virtual void GetTransform(vtkTransform* t);
141
148 virtual void SetTransform(vtkTransform* t);
149
161
163
168 vtkGetObjectMacro(HandleProperty, vtkProperty);
169 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
171
173
177 void HandlesOn();
180
182
187 vtkGetObjectMacro(FaceProperty, vtkProperty);
188 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
190
192
197 vtkGetObjectMacro(OutlineProperty, vtkProperty);
198 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
200
202
207 vtkGetMacro(OutlineFaceWires, int);
208 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
209 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
211
213
219 vtkGetMacro(OutlineCursorWires, int);
220 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
221 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
223
225
229 vtkSetMacro(TranslationEnabled, vtkTypeBool);
230 vtkGetMacro(TranslationEnabled, vtkTypeBool);
231 vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
232 vtkSetMacro(ScalingEnabled, vtkTypeBool);
233 vtkGetMacro(ScalingEnabled, vtkTypeBool);
234 vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
235 vtkSetMacro(RotationEnabled, vtkTypeBool);
236 vtkGetMacro(RotationEnabled, vtkTypeBool);
237 vtkBooleanMacro(RotationEnabled, vtkTypeBool);
239
240protected:
242 ~vtkBoxWidget() override;
243
244 // Manage the state of the widget
245 int State;
247 {
248 Start = 0,
251 Outside
252 };
253
254 // Handles the events
255 static void ProcessEvents(
256 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
257
258 // ProcessEvents() dispatches to these methods.
259 virtual void OnMouseMove();
260 virtual void OnLeftButtonDown();
261 virtual void OnLeftButtonUp();
262 virtual void OnMiddleButtonDown();
263 virtual void OnMiddleButtonUp();
264 virtual void OnRightButtonDown();
265 virtual void OnRightButtonUp();
266
267 // the hexahedron (6 faces)
271 vtkPoints* Points; // used by others as well
272 double N[6][3]; // the normals of the faces
273
274 // A face of the hexahedron
278
279 // glyphs representing hot spots (e.g., handles)
283 virtual void PositionHandles();
284 int HighlightHandle(vtkProp* prop); // returns cell id
285 void HighlightFace(int cellId);
286 void HighlightOutline(int highlight);
288 void SizeHandles() override;
289
290 // wireframe outline
294
295 // Do the picking
300
301 // Register internal Pickers within PickingManager
302 void RegisterPickers() override;
303
304 // Methods to manipulate the hexahedron.
305 virtual void Translate(double* p1, double* p2);
306 virtual void Scale(double* p1, double* p2, int X, int Y);
307 virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
308 void MovePlusXFace(double* p1, double* p2);
309 void MoveMinusXFace(double* p1, double* p2);
310 void MovePlusYFace(double* p1, double* p2);
311 void MoveMinusYFace(double* p1, double* p2);
312 void MovePlusZFace(double* p1, double* p2);
313 void MoveMinusZFace(double* p1, double* p2);
314
315 //"dir" is the direction in which the face can be moved i.e. the axis passing
316 // through the center
317 void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
318 double* x5);
319 // Helper method to obtain the direction in which the face is to be moved.
320 // Handles special cases where some of the scale factors are 0.
321 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
322
323 // Transform the hexahedral points (used for rotations)
325
326 // Properties used to control the appearance of selected objects and
327 // the manipulator in general.
335
336 // Control the orientation of the normals
341
342 // Control whether scaling, rotation, and translation are supported
346
347private:
348 vtkBoxWidget(const vtkBoxWidget&) = delete;
349 void operator=(const vtkBoxWidget&) = delete;
350};
351
352VTK_ABI_NAMESPACE_END
353#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:57
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
orthogonal hexahedron 3D widget
virtual void OnLeftButtonDown()
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
virtual void PositionHandles()
void SetOutlineCursorWires(int)
Control the representation of the outline.
void GenerateOutline()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void OutlineCursorWiresOff()
Control the representation of the outline.
void PlaceWidget() override
Methods that satisfy the superclass' API.
virtual void Scale(double *p1, double *p2, int X, int Y)
vtkTypeBool ScalingEnabled
vtkPolyData * HexPolyData
void CreateDefaultProperties()
vtkPolyData * HexFacePolyData
virtual void Translate(double *p1, double *p2)
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkActor * HexOutline
void ComputeNormals()
~vtkBoxWidget() override
void HighlightOutline(int highlight)
vtkSphereSource ** HandleGeometry
vtkTransform * Transform
vtkProperty * SelectedFaceProperty
vtkCellPicker * HandlePicker
virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn)
void SetEnabled(int) override
Methods that satisfy the superclass' API.
void MoveFace(double *p1, double *p2, double *dir, double *x1, double *x2, double *x3, double *x4, double *x5)
vtkProperty * HandleProperty
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void OnRightButtonUp()
void OutlineCursorWiresOn()
Control the representation of the outline.
void MovePlusYFace(double *p1, double *p2)
vtkCellPicker * HexPicker
vtkPolyDataMapper * HexMapper
virtual void OnMiddleButtonDown()
vtkPoints * Points
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
vtkTypeBool RotationEnabled
void HandlesOn()
Switches handles (the spheres) on or off by manipulating the actor visibility.
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkTypeBool InsideOut
vtkTypeBool TranslationEnabled
vtkPolyDataMapper * HexFaceMapper
int HighlightHandle(vtkProp *prop)
static vtkBoxWidget * New()
Instantiate the object.
vtkActor * HexActor
vtkProperty * OutlineProperty
vtkActor ** Handle
void OutlineFaceWiresOn()
Control the representation of the outline.
vtkPolyData * OutlinePolyData
void MoveMinusXFace(double *p1, double *p2)
void MovePlusXFace(double *p1, double *p2)
virtual void GetTransform(vtkTransform *t)
Retrieve a linear transform characterizing the transformation of the box.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
vtkProperty * FaceProperty
vtkActor * HexFace
void OutlineFaceWiresOff()
Control the representation of the outline.
void MoveMinusZFace(double *p1, double *p2)
virtual void SetTransform(vtkTransform *t)
Set the position, scale and orientation of the box widget using the transform specified.
virtual void OnLeftButtonUp()
void MovePlusZFace(double *p1, double *p2)
virtual void OnRightButtonDown()
virtual void OnMiddleButtonUp()
void HandlesOff()
Switches handles (the spheres) on or off by manipulating the actor visibility.
vtkProperty * SelectedHandleProperty
void MoveMinusYFace(double *p1, double *p2)
virtual void OnMouseMove()
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that define the box widget.
void SizeHandles() override
vtkPolyDataMapper * OutlineMapper
vtkProperty * SelectedOutlineProperty
vtkPolyDataMapper ** HandleMapper
vtkActor * CurrentHandle
void HighlightFace(int cellId)
void GetPlanes(vtkPlanes *planes)
Get the planes describing the implicit function defined by the box widget.
ray-cast cell picker for all kinds of Prop3Ds
a simple class to control print indentation
Definition vtkIndent.h:29
abstract base class for most VTK objects
Definition vtkObject.h:49
implicit function for convex set of planes
Definition vtkPlanes.h:42
represent and manipulate 3D points
Definition vtkPoints.h:29
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:80
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:43
represent surface properties of a geometric object
Definition vtkProperty.h:57
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
int vtkTypeBool
Definition vtkABI.h:64