VTK  9.2.6
vtkBoxWidget.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkBoxWidget.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
90#ifndef vtkBoxWidget_h
91#define vtkBoxWidget_h
92
93#include "vtk3DWidget.h"
94#include "vtkInteractionWidgetsModule.h" // For export macro
95
96class vtkActor;
97class vtkCellPicker;
98class vtkPlanes;
99class vtkPoints;
100class vtkPolyData;
102class vtkProp;
103class vtkProperty;
104class vtkSphereSource;
105class vtkTransform;
106
107class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
108{
109public:
113 static vtkBoxWidget* New();
114
115 vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
116 void PrintSelf(ostream& os, vtkIndent indent) override;
117
119
122 void SetEnabled(int) override;
123 void PlaceWidget(double bounds[6]) override;
124 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
126 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
127 {
128 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
129 }
131
140 void GetPlanes(vtkPlanes* planes);
141
143
148 vtkSetMacro(InsideOut, vtkTypeBool);
149 vtkGetMacro(InsideOut, vtkTypeBool);
150 vtkBooleanMacro(InsideOut, vtkTypeBool);
152
160 virtual void GetTransform(vtkTransform* t);
161
168 virtual void SetTransform(vtkTransform* t);
169
181
183
188 vtkGetObjectMacro(HandleProperty, vtkProperty);
189 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
191
193
197 void HandlesOn();
200
202
207 vtkGetObjectMacro(FaceProperty, vtkProperty);
208 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
210
212
217 vtkGetObjectMacro(OutlineProperty, vtkProperty);
218 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
220
222
227 vtkGetMacro(OutlineFaceWires, int);
228 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
229 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
231
233
239 vtkGetMacro(OutlineCursorWires, int);
240 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
241 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
243
245
249 vtkSetMacro(TranslationEnabled, vtkTypeBool);
250 vtkGetMacro(TranslationEnabled, vtkTypeBool);
251 vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
252 vtkSetMacro(ScalingEnabled, vtkTypeBool);
253 vtkGetMacro(ScalingEnabled, vtkTypeBool);
254 vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
255 vtkSetMacro(RotationEnabled, vtkTypeBool);
256 vtkGetMacro(RotationEnabled, vtkTypeBool);
257 vtkBooleanMacro(RotationEnabled, vtkTypeBool);
259
260protected:
262 ~vtkBoxWidget() override;
263
264 // Manage the state of the widget
265 int State;
267 {
268 Start = 0,
271 Outside
272 };
273
274 // Handles the events
275 static void ProcessEvents(
276 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
277
278 // ProcessEvents() dispatches to these methods.
279 virtual void OnMouseMove();
280 virtual void OnLeftButtonDown();
281 virtual void OnLeftButtonUp();
282 virtual void OnMiddleButtonDown();
283 virtual void OnMiddleButtonUp();
284 virtual void OnRightButtonDown();
285 virtual void OnRightButtonUp();
286
287 // the hexahedron (6 faces)
291 vtkPoints* Points; // used by others as well
292 double N[6][3]; // the normals of the faces
293
294 // A face of the hexahedron
298
299 // glyphs representing hot spots (e.g., handles)
303 virtual void PositionHandles();
304 int HighlightHandle(vtkProp* prop); // returns cell id
305 void HighlightFace(int cellId);
306 void HighlightOutline(int highlight);
308 void SizeHandles() override;
309
310 // wireframe outline
314
315 // Do the picking
320
321 // Register internal Pickers within PickingManager
322 void RegisterPickers() override;
323
324 // Methods to manipulate the hexahedron.
325 virtual void Translate(double* p1, double* p2);
326 virtual void Scale(double* p1, double* p2, int X, int Y);
327 virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
328 void MovePlusXFace(double* p1, double* p2);
329 void MoveMinusXFace(double* p1, double* p2);
330 void MovePlusYFace(double* p1, double* p2);
331 void MoveMinusYFace(double* p1, double* p2);
332 void MovePlusZFace(double* p1, double* p2);
333 void MoveMinusZFace(double* p1, double* p2);
334
335 //"dir" is the direction in which the face can be moved i.e. the axis passing
336 // through the center
337 void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
338 double* x5);
339 // Helper method to obtain the direction in which the face is to be moved.
340 // Handles special cases where some of the scale factors are 0.
341 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
342
343 // Transform the hexahedral points (used for rotations)
345
346 // Properties used to control the appearance of selected objects and
347 // the manipulator in general.
355
356 // Control the orientation of the normals
361
362 // Control whether scaling, rotation, and translation are supported
366
367private:
368 vtkBoxWidget(const vtkBoxWidget&) = delete;
369 void operator=(const vtkBoxWidget&) = delete;
370};
371
372#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:71
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:61
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:49
abstract base class for most VTK objects
Definition vtkObject.h:72
implicit function for convex set of planes
Definition vtkPlanes.h:62
represent and manipulate 3D points
Definition vtkPoints.h:49
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
Definition vtkProperty.h:77
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
int vtkTypeBool
Definition vtkABI.h:69