VTK: Interaction/Widgets/vtkBoxWidget.h Source File

| 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
81 #ifndef vtkBoxWidget_h
82 #define vtkBoxWidget_h
83
84 #include "vtk3DWidget.h"
85 #include "vtkInteractionWidgetsModule.h" // For export macro
86
87 VTK_ABI_NAMESPACE_BEGIN
88 class vtkActor;
89 class vtkCellPicker;
90 class vtkPlanes;
91 class vtkPoints;
92 class vtkPolyData;
93 class vtkPolyDataMapper;
94 class vtkProp;
95 class vtkProperty;
96 class vtkSphereSource;
97 class vtkTransform;
98
99 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
100 {
101 public:
105 static vtkBoxWidget* New();
106
107 vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
108 void PrintSelf(ostream& os, vtkIndent indent) override;
109
111
114 void SetEnabled(int) override;
115 void PlaceWidget(double bounds[6]) override;
116 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
117 void PlaceWidget(
118 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
119 {
120 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
121 }
123
132 void GetPlanes(vtkPlanes* planes);
133
135
140 vtkSetMacro(InsideOut, vtkTypeBool);
141 vtkGetMacro(InsideOut, vtkTypeBool);
142 vtkBooleanMacro(InsideOut, vtkTypeBool);
144
152 virtual void GetTransform(vtkTransform* t);
153
160 virtual void SetTransform(vtkTransform* t);
161
172 void GetPolyData(vtkPolyData* pd);
173
175
180 vtkGetObjectMacro(HandleProperty, vtkProperty);
181 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
183
185
189 void HandlesOn();
190 void HandlesOff();
192
194
199 vtkGetObjectMacro(FaceProperty, vtkProperty);
200 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
202
204
209 vtkGetObjectMacro(OutlineProperty, vtkProperty);
210 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
212
214
218 void SetOutlineFaceWires(int);
219 vtkGetMacro(OutlineFaceWires, int);
220 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
221 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
223
225
230 void SetOutlineCursorWires(int);
231 vtkGetMacro(OutlineCursorWires, int);
232 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
233 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
235
237
241 vtkSetMacro(TranslationEnabled, vtkTypeBool);
242 vtkGetMacro(TranslationEnabled, vtkTypeBool);
243 vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
244 vtkSetMacro(ScalingEnabled, vtkTypeBool);
245 vtkGetMacro(ScalingEnabled, vtkTypeBool);
246 vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
247 vtkSetMacro(RotationEnabled, vtkTypeBool);
248 vtkGetMacro(RotationEnabled, vtkTypeBool);
249 vtkBooleanMacro(RotationEnabled, vtkTypeBool);
251
252 protected:
253 vtkBoxWidget();
254 ~vtkBoxWidget() override;
255
256 // Manage the state of the widget
257 int State;
258 enum WidgetState
259 {
260 Start = 0,
261 Moving,
262 Scaling,
263 Outside
264 };
265
266 // Handles the events
267 static void ProcessEvents(
268 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
269
270 // ProcessEvents() dispatches to these methods.
271 virtual void OnMouseMove();
272 virtual void OnLeftButtonDown();
273 virtual void OnLeftButtonUp();
274 virtual void OnMiddleButtonDown();
275 virtual void OnMiddleButtonUp();
276 virtual void OnRightButtonDown();
277 virtual void OnRightButtonUp();
278
279 // the hexahedron (6 faces)
280 vtkActor* HexActor;
281 vtkPolyDataMapper* HexMapper;
282 vtkPolyData* HexPolyData;
283 vtkPoints* Points; // used by others as well
284 double N[6][3]; // the normals of the faces
285
286 // A face of the hexahedron
287 vtkActor* HexFace;
288 vtkPolyDataMapper* HexFaceMapper;
289 vtkPolyData* HexFacePolyData;
290
291 // glyphs representing hot spots (e.g., handles)
292 vtkActor** Handle;
293 vtkPolyDataMapper** HandleMapper;
294 vtkSphereSource** HandleGeometry;
295 virtual void PositionHandles();
296 int HighlightHandle(vtkProp* prop); // returns cell id
297 void HighlightFace(int cellId);
298 void HighlightOutline(int highlight);
299 void ComputeNormals();
300 void SizeHandles() override;
301
302 // wireframe outline
303 vtkActor* HexOutline;
304 vtkPolyDataMapper* OutlineMapper;
305 vtkPolyData* OutlinePolyData;
306
307 // Do the picking
308 vtkCellPicker* HandlePicker;
309 vtkCellPicker* HexPicker;
310 vtkActor* CurrentHandle;
311 int CurrentHexFace;
312
313 // Register internal Pickers within PickingManager
314 void RegisterPickers() override;
315
316 // Methods to manipulate the hexahedron.
317 virtual void Translate(double* p1, double* p2);
318 virtual void Scale(double* p1, double* p2, int X, int Y);
319 virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
320 void MovePlusXFace(double* p1, double* p2);
321 void MoveMinusXFace(double* p1, double* p2);
322 void MovePlusYFace(double* p1, double* p2);
323 void MoveMinusYFace(double* p1, double* p2);
324 void MovePlusZFace(double* p1, double* p2);
325 void MoveMinusZFace(double* p1, double* p2);
326
327 //"dir" is the direction in which the face can be moved i.e. the axis passing
328 // through the center
329 void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
330 double* x5);
331 // Helper method to obtain the direction in which the face is to be moved.
332 // Handles special cases where some of the scale factors are 0.
333 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
334
335 // Transform the hexahedral points (used for rotations)
336 vtkTransform* Transform;
337
338 // Properties used to control the appearance of selected objects and
339 // the manipulator in general.
340 vtkProperty* HandleProperty;
341 vtkProperty* SelectedHandleProperty;
342 vtkProperty* FaceProperty;
343 vtkProperty* SelectedFaceProperty;
344 vtkProperty* OutlineProperty;
345 vtkProperty* SelectedOutlineProperty;
346 void CreateDefaultProperties();
347
348 // Control the orientation of the normals
349 vtkTypeBool InsideOut;
350 int OutlineFaceWires;
351 int OutlineCursorWires;
352 void GenerateOutline();
353
354 // Control whether scaling, rotation, and translation are supported
355 vtkTypeBool TranslationEnabled;
356 vtkTypeBool ScalingEnabled;
357 vtkTypeBool RotationEnabled;
358
359 private:
360 vtkBoxWidget(const vtkBoxWidget&) = delete;
361 void operator=(const vtkBoxWidget&) = delete;
362 };
363
364 VTK_ABI_NAMESPACE_END
365 #endif
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:60
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
vtkBoxWidget
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:100
vtkBoxWidget::OnLeftButtonDown
virtual void OnLeftButtonDown()
vtkBoxWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:117
vtkBoxWidget::State
int State
Definition: vtkBoxWidget.h:257
vtkBoxWidget::PositionHandles
virtual void PositionHandles()
vtkBoxWidget::SetOutlineCursorWires
void SetOutlineCursorWires(int)
Control the representation of the outline.
vtkBoxWidget::GenerateOutline
void GenerateOutline()
vtkBoxWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkBoxWidget::OutlineCursorWiresOff
void OutlineCursorWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:233
vtkBoxWidget::PlaceWidget
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:116
vtkBoxWidget::Scale
virtual void Scale(double *p1, double *p2, int X, int Y)
vtkBoxWidget::ScalingEnabled
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:356
vtkBoxWidget::HexPolyData
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:282
vtkBoxWidget::CreateDefaultProperties
void CreateDefaultProperties()
vtkBoxWidget::HexFacePolyData
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:289
vtkBoxWidget::Translate
virtual void Translate(double *p1, double *p2)
vtkBoxWidget::PlaceWidget
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkBoxWidget::HexOutline
vtkActor * HexOutline
Definition: vtkBoxWidget.h:303
vtkBoxWidget::New
static vtkBoxWidget * New()
Instantiate the object.
vtkBoxWidget::ComputeNormals
void ComputeNormals()
vtkBoxWidget::~vtkBoxWidget
~vtkBoxWidget() override
vtkBoxWidget::HighlightOutline
void HighlightOutline(int highlight)
vtkBoxWidget::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:294
vtkBoxWidget::Transform
vtkTransform * Transform
Definition: vtkBoxWidget.h:336
vtkBoxWidget::SelectedFaceProperty
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:343
vtkBoxWidget::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:308
vtkBoxWidget::Rotate
virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn)
vtkBoxWidget::SetEnabled
void SetEnabled(int) override
Methods that satisfy the superclass' API.
vtkBoxWidget::MoveFace
void MoveFace(double *p1, double *p2, double *dir, double *x1, double *x2, double *x3, double *x4, double *x5)
vtkBoxWidget::vtkBoxWidget
vtkBoxWidget()
vtkBoxWidget::HandleProperty
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:340
vtkBoxWidget::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkBoxWidget::OnRightButtonUp
virtual void OnRightButtonUp()
vtkBoxWidget::OutlineCursorWiresOn
void OutlineCursorWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:232
vtkBoxWidget::MovePlusYFace
void MovePlusYFace(double *p1, double *p2)
vtkBoxWidget::HexPicker
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:309
vtkBoxWidget::HexMapper
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:281
vtkBoxWidget::OnMiddleButtonDown
virtual void OnMiddleButtonDown()
vtkBoxWidget::Points
vtkPoints * Points
Definition: vtkBoxWidget.h:283
vtkBoxWidget::OutlineCursorWires
int OutlineCursorWires
Definition: vtkBoxWidget.h:351
vtkBoxWidget::GetDirection
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
vtkBoxWidget::RotationEnabled
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:357
vtkBoxWidget::HandlesOn
void HandlesOn()
Switches handles (the spheres) on or off by manipulating the actor visibility.
vtkBoxWidget::OutlineFaceWires
int OutlineFaceWires
Definition: vtkBoxWidget.h:350
vtkBoxWidget::SetOutlineFaceWires
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkBoxWidget::WidgetState
WidgetState
Definition: vtkBoxWidget.h:259
vtkBoxWidget::Scaling
@ Scaling
Definition: vtkBoxWidget.h:262
vtkBoxWidget::Moving
@ Moving
Definition: vtkBoxWidget.h:261
vtkBoxWidget::InsideOut
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:349
vtkBoxWidget::TranslationEnabled
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:355
vtkBoxWidget::HexFaceMapper
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:288
vtkBoxWidget::HighlightHandle
int HighlightHandle(vtkProp *prop)
vtkBoxWidget::HexActor
vtkActor * HexActor
Definition: vtkBoxWidget.h:280
vtkBoxWidget::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:344
vtkBoxWidget::Handle
vtkActor ** Handle
Definition: vtkBoxWidget.h:292
vtkBoxWidget::OutlineFaceWiresOn
void OutlineFaceWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:220
vtkBoxWidget::OutlinePolyData
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:305
vtkBoxWidget::MoveMinusXFace
void MoveMinusXFace(double *p1, double *p2)
vtkBoxWidget::MovePlusXFace
void MovePlusXFace(double *p1, double *p2)
vtkBoxWidget::GetTransform
virtual void GetTransform(vtkTransform *t)
Retrieve a linear transform characterizing the transformation of the box.
vtkBoxWidget::RegisterPickers
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
vtkBoxWidget::FaceProperty
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:342
vtkBoxWidget::HexFace
vtkActor * HexFace
Definition: vtkBoxWidget.h:287
vtkBoxWidget::OutlineFaceWiresOff
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:221
vtkBoxWidget::MoveMinusZFace
void MoveMinusZFace(double *p1, double *p2)
vtkBoxWidget::SetTransform
virtual void SetTransform(vtkTransform *t)
Set the position, scale and orientation of the box widget using the transform specified.
vtkBoxWidget::OnLeftButtonUp
virtual void OnLeftButtonUp()
vtkBoxWidget::MovePlusZFace
void MovePlusZFace(double *p1, double *p2)
vtkBoxWidget::OnRightButtonDown
virtual void OnRightButtonDown()
vtkBoxWidget::OnMiddleButtonUp
virtual void OnMiddleButtonUp()
vtkBoxWidget::HandlesOff
void HandlesOff()
Switches handles (the spheres) on or off by manipulating the actor visibility.
vtkBoxWidget::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:341
vtkBoxWidget::MoveMinusYFace
void MoveMinusYFace(double *p1, double *p2)
vtkBoxWidget::OnMouseMove
virtual void OnMouseMove()
vtkBoxWidget::GetPolyData
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that define the box widget.
vtkBoxWidget::SizeHandles
void SizeHandles() override
vtkBoxWidget::OutlineMapper
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:304
vtkBoxWidget::CurrentHexFace
int CurrentHexFace
Definition: vtkBoxWidget.h:311
vtkBoxWidget::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:345
vtkBoxWidget::HandleMapper
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:293
vtkBoxWidget::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:310
vtkBoxWidget::HighlightFace
void HighlightFace(int cellId)
vtkBoxWidget::GetPlanes
void GetPlanes(vtkPlanes *planes)
Get the planes describing the implicit function defined by the box widget.
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:71
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkPlanes
implicit function for convex set of planes
Definition: vtkPlanes.h:51
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:42
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:55
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:66
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:44
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
vtkX3D::dir
@ dir
Definition: vtkX3D.h:324
vtk3DWidget.h
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64