VTK  9.3.1
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
72#ifndef vtkBoxWidget_h
73#define vtkBoxWidget_h
74
75#include "vtk3DWidget.h"
76#include "vtkInteractionWidgetsModule.h" // For export macro
77
78VTK_ABI_NAMESPACE_BEGIN
79class vtkActor;
80class vtkCellPicker;
81class vtkPlanes;
82class vtkPoints;
83class vtkPolyData;
85class vtkProp;
86class vtkProperty;
87class vtkSphereSource;
88class vtkTransform;
89
90class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
91{
92public:
96 static vtkBoxWidget* New();
97
98 vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
99 void PrintSelf(ostream& os, vtkIndent indent) override;
100
102
105 void SetEnabled(int) override;
106 void PlaceWidget(double bounds[6]) override;
107 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
109 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
110 {
111 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
112 }
114
123 void GetPlanes(vtkPlanes* planes);
124
126
131 vtkSetMacro(InsideOut, vtkTypeBool);
132 vtkGetMacro(InsideOut, vtkTypeBool);
133 vtkBooleanMacro(InsideOut, vtkTypeBool);
135
143 virtual void GetTransform(vtkTransform* t);
144
151 virtual void SetTransform(vtkTransform* t);
152
164
166
171 vtkGetObjectMacro(HandleProperty, vtkProperty);
172 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
174
176
180 void HandlesOn();
183
185
190 vtkGetObjectMacro(FaceProperty, vtkProperty);
191 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
193
195
200 vtkGetObjectMacro(OutlineProperty, vtkProperty);
201 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
203
205
210 vtkGetMacro(OutlineFaceWires, int);
211 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
212 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
214
216
222 vtkGetMacro(OutlineCursorWires, int);
223 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
224 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
226
228
232 vtkSetMacro(TranslationEnabled, vtkTypeBool);
233 vtkGetMacro(TranslationEnabled, vtkTypeBool);
234 vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
235 vtkSetMacro(ScalingEnabled, vtkTypeBool);
236 vtkGetMacro(ScalingEnabled, vtkTypeBool);
237 vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
238 vtkSetMacro(RotationEnabled, vtkTypeBool);
239 vtkGetMacro(RotationEnabled, vtkTypeBool);
240 vtkBooleanMacro(RotationEnabled, vtkTypeBool);
242
243protected:
245 ~vtkBoxWidget() override;
246
247 // Manage the state of the widget
248 int State;
250 {
251 Start = 0,
254 Outside
255 };
256
257 // Handles the events
258 static void ProcessEvents(
259 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
260
261 // ProcessEvents() dispatches to these methods.
262 virtual void OnMouseMove();
263 virtual void OnLeftButtonDown();
264 virtual void OnLeftButtonUp();
265 virtual void OnMiddleButtonDown();
266 virtual void OnMiddleButtonUp();
267 virtual void OnRightButtonDown();
268 virtual void OnRightButtonUp();
269
270 // the hexahedron (6 faces)
274 vtkPoints* Points; // used by others as well
275 double N[6][3]; // the normals of the faces
276
277 // A face of the hexahedron
281
282 // glyphs representing hot spots (e.g., handles)
286 virtual void PositionHandles();
287 int HighlightHandle(vtkProp* prop); // returns cell id
288 void HighlightFace(int cellId);
289 void HighlightOutline(int highlight);
291 void SizeHandles() override;
292
293 // wireframe outline
297
298 // Do the picking
303
304 // Register internal Pickers within PickingManager
305 void RegisterPickers() override;
306
307 // Methods to manipulate the hexahedron.
308 virtual void Translate(double* p1, double* p2);
309 virtual void Scale(double* p1, double* p2, int X, int Y);
310 virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
311 void MovePlusXFace(double* p1, double* p2);
312 void MoveMinusXFace(double* p1, double* p2);
313 void MovePlusYFace(double* p1, double* p2);
314 void MoveMinusYFace(double* p1, double* p2);
315 void MovePlusZFace(double* p1, double* p2);
316 void MoveMinusZFace(double* p1, double* p2);
317
318 //"dir" is the direction in which the face can be moved i.e. the axis passing
319 // through the center
320 void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
321 double* x5);
322 // Helper method to obtain the direction in which the face is to be moved.
323 // Handles special cases where some of the scale factors are 0.
324 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
325
326 // Transform the hexahedral points (used for rotations)
328
329 // Properties used to control the appearance of selected objects and
330 // the manipulator in general.
338
339 // Control the orientation of the normals
344
345 // Control whether scaling, rotation, and translation are supported
349
350private:
351 vtkBoxWidget(const vtkBoxWidget&) = delete;
352 void operator=(const vtkBoxWidget&) = delete;
353};
354
355VTK_ABI_NAMESPACE_END
356#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:60
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:52
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:46
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