VTK  9.1.0
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=========================================================================*/
84#ifndef vtkBoxWidget_h
85#define vtkBoxWidget_h
86
87#include "vtk3DWidget.h"
88#include "vtkInteractionWidgetsModule.h" // For export macro
89
90class vtkActor;
91class vtkCellPicker;
92class vtkPlanes;
93class vtkPoints;
94class vtkPolyData;
96class vtkProp;
97class vtkProperty;
98class vtkSphereSource;
99class vtkTransform;
100
101class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
102{
103public:
107 static vtkBoxWidget* New();
108
109 vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
110 void PrintSelf(ostream& os, vtkIndent indent) override;
111
113
116 void SetEnabled(int) override;
117 void PlaceWidget(double bounds[6]) override;
118 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
120 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
121 {
122 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
123 }
125
134 void GetPlanes(vtkPlanes* planes);
135
137
142 vtkSetMacro(InsideOut, vtkTypeBool);
143 vtkGetMacro(InsideOut, vtkTypeBool);
144 vtkBooleanMacro(InsideOut, vtkTypeBool);
146
154 virtual void GetTransform(vtkTransform* t);
155
162 virtual void SetTransform(vtkTransform* t);
163
175
177
182 vtkGetObjectMacro(HandleProperty, vtkProperty);
183 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
185
187
191 void HandlesOn();
194
196
201 vtkGetObjectMacro(FaceProperty, vtkProperty);
202 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
204
206
211 vtkGetObjectMacro(OutlineProperty, vtkProperty);
212 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
214
216
221 vtkGetMacro(OutlineFaceWires, int);
222 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
223 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
225
227
233 vtkGetMacro(OutlineCursorWires, int);
234 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
235 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
237
239
243 vtkSetMacro(TranslationEnabled, vtkTypeBool);
244 vtkGetMacro(TranslationEnabled, vtkTypeBool);
245 vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
246 vtkSetMacro(ScalingEnabled, vtkTypeBool);
247 vtkGetMacro(ScalingEnabled, vtkTypeBool);
248 vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
249 vtkSetMacro(RotationEnabled, vtkTypeBool);
250 vtkGetMacro(RotationEnabled, vtkTypeBool);
251 vtkBooleanMacro(RotationEnabled, vtkTypeBool);
253
254protected:
256 ~vtkBoxWidget() override;
257
258 // Manage the state of the widget
259 int State;
261 {
262 Start = 0,
265 Outside
266 };
267
268 // Handles the events
269 static void ProcessEvents(
270 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
271
272 // ProcessEvents() dispatches to these methods.
273 virtual void OnMouseMove();
274 virtual void OnLeftButtonDown();
275 virtual void OnLeftButtonUp();
276 virtual void OnMiddleButtonDown();
277 virtual void OnMiddleButtonUp();
278 virtual void OnRightButtonDown();
279 virtual void OnRightButtonUp();
280
281 // the hexahedron (6 faces)
285 vtkPoints* Points; // used by others as well
286 double N[6][3]; // the normals of the faces
287
288 // A face of the hexahedron
292
293 // glyphs representing hot spots (e.g., handles)
297 virtual void PositionHandles();
298 int HighlightHandle(vtkProp* prop); // returns cell id
299 void HighlightFace(int cellId);
300 void HighlightOutline(int highlight);
302 void SizeHandles() override;
303
304 // wireframe outline
308
309 // Do the picking
314
315 // Register internal Pickers within PickingManager
316 void RegisterPickers() override;
317
318 // Methods to manipulate the hexahedron.
319 virtual void Translate(double* p1, double* p2);
320 virtual void Scale(double* p1, double* p2, int X, int Y);
321 virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
322 void MovePlusXFace(double* p1, double* p2);
323 void MoveMinusXFace(double* p1, double* p2);
324 void MovePlusYFace(double* p1, double* p2);
325 void MoveMinusYFace(double* p1, double* p2);
326 void MovePlusZFace(double* p1, double* p2);
327 void MoveMinusZFace(double* p1, double* p2);
328
329 //"dir" is the direction in which the face can be moved i.e. the axis passing
330 // through the center
331 void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
332 double* x5);
333 // Helper method to obtain the direction in which the face is to be moved.
334 // Handles special cases where some of the scale factors are 0.
335 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
336
337 // Transform the hexahedral points (used for rotations)
339
340 // Properties used to control the appearance of selected objects and
341 // the manipulator in general.
349
350 // Control the orientation of the normals
355
356 // Control whether scaling, rotation, and translation are supported
360
361private:
362 vtkBoxWidget(const vtkBoxWidget&) = delete;
363 void operator=(const vtkBoxWidget&) = delete;
364};
365
366#endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:55
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:102
virtual void OnLeftButtonDown()
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:119
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.
Definition: vtkBoxWidget.h:235
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:118
virtual void Scale(double *p1, double *p2, int X, int Y)
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:358
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:284
void CreateDefaultProperties()
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:291
virtual void Translate(double *p1, double *p2)
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkActor * HexOutline
Definition: vtkBoxWidget.h:305
void ComputeNormals()
~vtkBoxWidget() override
void HighlightOutline(int highlight)
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:296
vtkTransform * Transform
Definition: vtkBoxWidget.h:338
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:345
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:310
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
Definition: vtkBoxWidget.h:342
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void OnRightButtonUp()
void OutlineCursorWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:234
void MovePlusYFace(double *p1, double *p2)
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:311
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:283
virtual void OnMiddleButtonDown()
vtkPoints * Points
Definition: vtkBoxWidget.h:285
int OutlineCursorWires
Definition: vtkBoxWidget.h:353
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:359
void HandlesOn()
Switches handles (the spheres) on or off by manipulating the actor visibility.
int OutlineFaceWires
Definition: vtkBoxWidget.h:352
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:351
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:357
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:290
int HighlightHandle(vtkProp *prop)
static vtkBoxWidget * New()
Instantiate the object.
vtkActor * HexActor
Definition: vtkBoxWidget.h:282
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:346
vtkActor ** Handle
Definition: vtkBoxWidget.h:294
void OutlineFaceWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:222
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:307
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
Definition: vtkBoxWidget.h:344
vtkActor * HexFace
Definition: vtkBoxWidget.h:289
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:223
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
Definition: vtkBoxWidget.h:343
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
Definition: vtkBoxWidget.h:306
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:347
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:295
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:312
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
Definition: vtkCellPicker.h:76
a simple class to control print indentation
Definition: vtkIndent.h:43
abstract base class for most VTK objects
Definition: vtkObject.h:63
implicit function for convex set of planes
Definition: vtkPlanes.h:59
represent and manipulate 3D points
Definition: vtkPoints.h:43
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:95
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:71
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:64
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69