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
78#ifndef vtkBoxWidget_h
79#define vtkBoxWidget_h
80
81#include "vtk3DWidget.h"
82#include "vtkInteractionWidgetsModule.h" // For export macro
83
84VTK_ABI_NAMESPACE_BEGIN
85class vtkActor;
86class vtkCellPicker;
87class vtkPlanes;
88class vtkPoints;
89class vtkPolyData;
91class vtkProp;
92class vtkProperty;
93class vtkSphereSource;
94class vtkTransform;
95
96class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
97{
98public:
102 static vtkBoxWidget* New();
103
104 vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
105 void PrintSelf(ostream& os, vtkIndent indent) override;
106
108
111 void SetEnabled(int) override;
112 void PlaceWidget(double bounds[6]) override;
113 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
115 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
116 {
117 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
118 }
120
129 void GetPlanes(vtkPlanes* planes);
130
132
137 vtkSetMacro(InsideOut, vtkTypeBool);
138 vtkGetMacro(InsideOut, vtkTypeBool);
139 vtkBooleanMacro(InsideOut, vtkTypeBool);
141
149 virtual void GetTransform(vtkTransform* t);
150
157 virtual void SetTransform(vtkTransform* t);
158
170
172
177 vtkGetObjectMacro(HandleProperty, vtkProperty);
178 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
180
182
186 void HandlesOn();
189
191
196 vtkGetObjectMacro(FaceProperty, vtkProperty);
197 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
199
201
206 vtkGetObjectMacro(OutlineProperty, vtkProperty);
207 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
209
211
216 vtkGetMacro(OutlineFaceWires, int);
217 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
218 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
220
222
228 vtkGetMacro(OutlineCursorWires, int);
229 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
230 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
232
234
238 vtkSetMacro(TranslationEnabled, vtkTypeBool);
239 vtkGetMacro(TranslationEnabled, vtkTypeBool);
240 vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
241 vtkSetMacro(ScalingEnabled, vtkTypeBool);
242 vtkGetMacro(ScalingEnabled, vtkTypeBool);
243 vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
244 vtkSetMacro(RotationEnabled, vtkTypeBool);
245 vtkGetMacro(RotationEnabled, vtkTypeBool);
246 vtkBooleanMacro(RotationEnabled, vtkTypeBool);
248
249protected:
251 ~vtkBoxWidget() override;
252
253 // Manage the state of the widget
254 int State;
256 {
257 Start = 0,
260 Outside
261 };
262
263 // Handles the events
264 static void ProcessEvents(
265 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
266
267 // ProcessEvents() dispatches to these methods.
268 virtual void OnMouseMove();
269 virtual void OnLeftButtonDown();
270 virtual void OnLeftButtonUp();
271 virtual void OnMiddleButtonDown();
272 virtual void OnMiddleButtonUp();
273 virtual void OnRightButtonDown();
274 virtual void OnRightButtonUp();
275
276 // the hexahedron (6 faces)
280 vtkPoints* Points; // used by others as well
281 double N[6][3]; // the normals of the faces
282
283 // A face of the hexahedron
287
288 // glyphs representing hot spots (e.g., handles)
292 virtual void PositionHandles();
293 int HighlightHandle(vtkProp* prop); // returns cell id
294 void HighlightFace(int cellId);
295 void HighlightOutline(int highlight);
297 void SizeHandles() override;
298
299 // wireframe outline
303
304 // Do the picking
309
310 // Register internal Pickers within PickingManager
311 void RegisterPickers() override;
312
313 // Methods to manipulate the hexahedron.
314 virtual void Translate(double* p1, double* p2);
315 virtual void Scale(double* p1, double* p2, int X, int Y);
316 virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
317 void MovePlusXFace(double* p1, double* p2);
318 void MoveMinusXFace(double* p1, double* p2);
319 void MovePlusYFace(double* p1, double* p2);
320 void MoveMinusYFace(double* p1, double* p2);
321 void MovePlusZFace(double* p1, double* p2);
322 void MoveMinusZFace(double* p1, double* p2);
323
324 //"dir" is the direction in which the face can be moved i.e. the axis passing
325 // through the center
326 void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
327 double* x5);
328 // Helper method to obtain the direction in which the face is to be moved.
329 // Handles special cases where some of the scale factors are 0.
330 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
331
332 // Transform the hexahedral points (used for rotations)
334
335 // Properties used to control the appearance of selected objects and
336 // the manipulator in general.
344
345 // Control the orientation of the normals
350
351 // Control whether scaling, rotation, and translation are supported
355
356private:
357 vtkBoxWidget(const vtkBoxWidget&) = delete;
358 void operator=(const vtkBoxWidget&) = delete;
359};
360
361VTK_ABI_NAMESPACE_END
362#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:57
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:50
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:38
abstract base class for most VTK objects
Definition vtkObject.h:58
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
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:52
represent surface properties of a geometric object
Definition vtkProperty.h:66
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
int vtkTypeBool
Definition vtkABI.h:64