VTK  9.3.20240423
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
101#ifndef vtkBoxWidget_h
102#define vtkBoxWidget_h
103
104#include "vtk3DWidget.h"
105#include "vtkInteractionWidgetsModule.h" // For export macro
106
107VTK_ABI_NAMESPACE_BEGIN
108class vtkActor;
109class vtkCellPicker;
110class vtkPlanes;
111class vtkPoints;
112class vtkPolyData;
114class vtkProp;
115class vtkProperty;
116class vtkSphereSource;
117class vtkTransform;
118
119class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
120{
121public:
125 static vtkBoxWidget* New();
126
127 vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
128 void PrintSelf(ostream& os, vtkIndent indent) override;
129
131
134 void SetEnabled(int) override;
135 void PlaceWidget(double bounds[6]) override;
136 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
138 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
139 {
140 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
141 }
143
152 void GetPlanes(vtkPlanes* planes);
153
155
160 vtkSetMacro(InsideOut, vtkTypeBool);
161 vtkGetMacro(InsideOut, vtkTypeBool);
162 vtkBooleanMacro(InsideOut, vtkTypeBool);
164
172 virtual void GetTransform(vtkTransform* t);
173
180 virtual void SetTransform(vtkTransform* t);
181
193
195
200 vtkGetObjectMacro(HandleProperty, vtkProperty);
201 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
203
205
209 void HandlesOn();
212
214
219 vtkGetObjectMacro(FaceProperty, vtkProperty);
220 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
222
224
229 vtkGetObjectMacro(OutlineProperty, vtkProperty);
230 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
232
234
239 vtkGetMacro(OutlineFaceWires, int);
240 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
241 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
243
245
251 vtkGetMacro(OutlineCursorWires, int);
252 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
253 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
255
257
261 vtkSetMacro(TranslationEnabled, vtkTypeBool);
262 vtkGetMacro(TranslationEnabled, vtkTypeBool);
263 vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
264 vtkSetMacro(ScalingEnabled, vtkTypeBool);
265 vtkGetMacro(ScalingEnabled, vtkTypeBool);
266 vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
267 vtkSetMacro(RotationEnabled, vtkTypeBool);
268 vtkGetMacro(RotationEnabled, vtkTypeBool);
269 vtkBooleanMacro(RotationEnabled, vtkTypeBool);
271
272protected:
274 ~vtkBoxWidget() override;
275
276 // Manage the state of the widget
277 int State;
279 {
280 Start = 0,
283 Outside
284 };
285
286 // Handles the events
287 static void ProcessEvents(
288 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
289
290 // ProcessEvents() dispatches to these methods.
291 virtual void OnMouseMove();
292 virtual void OnLeftButtonDown();
293 virtual void OnLeftButtonUp();
294 virtual void OnMiddleButtonDown();
295 virtual void OnMiddleButtonUp();
296 virtual void OnRightButtonDown();
297 virtual void OnRightButtonUp();
298
299 // the hexahedron (6 faces)
303 vtkPoints* Points; // used by others as well
304 double N[6][3]; // the normals of the faces
305
306 // A face of the hexahedron
310
311 // glyphs representing hot spots (e.g., handles)
315 virtual void PositionHandles();
316 int HighlightHandle(vtkProp* prop); // returns cell id
317 void HighlightFace(int cellId);
318 void HighlightOutline(int highlight);
320 void SizeHandles() override;
321
322 // wireframe outline
326
327 // Do the picking
332
333 // Register internal Pickers within PickingManager
334 void RegisterPickers() override;
335
336 // Methods to manipulate the hexahedron.
337 virtual void Translate(double* p1, double* p2);
338 virtual void Scale(double* p1, double* p2, int X, int Y);
339 virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
340 void MovePlusXFace(double* p1, double* p2);
341 void MoveMinusXFace(double* p1, double* p2);
342 void MovePlusYFace(double* p1, double* p2);
343 void MoveMinusYFace(double* p1, double* p2);
344 void MovePlusZFace(double* p1, double* p2);
345 void MoveMinusZFace(double* p1, double* p2);
346
347 //"dir" is the direction in which the face can be moved i.e. the axis passing
348 // through the center
349 void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
350 double* x5);
351 // Helper method to obtain the direction in which the face is to be moved.
352 // Handles special cases where some of the scale factors are 0.
353 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
354
355 // Transform the hexahedral points (used for rotations)
357
358 // Properties used to control the appearance of selected objects and
359 // the manipulator in general.
367
368 // Control the orientation of the normals
373
374 // Control whether scaling, rotation, and translation are supported
378
379private:
380 vtkBoxWidget(const vtkBoxWidget&) = delete;
381 void operator=(const vtkBoxWidget&) = delete;
382};
383
384VTK_ABI_NAMESPACE_END
385#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:60
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
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:108
abstract base class for most VTK objects
Definition vtkObject.h:162
implicit function for convex set of planes
Definition vtkPlanes.h:151
represent and manipulate 3D points
Definition vtkPoints.h:139
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
represent surface properties of a geometric object
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
int vtkTypeBool
Definition vtkABI.h:64