VTK  9.5.20251126
vtkBoxRepresentation.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
45
46#ifndef vtkBoxRepresentation_h
47#define vtkBoxRepresentation_h
48
49#include "vtkInteractionWidgetsModule.h" // For export macro
51#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
52
53VTK_ABI_NAMESPACE_BEGIN
54class vtkActor;
56class vtkLineSource;
57class vtkSphereSource;
58class vtkCellPicker;
59class vtkProperty;
60class vtkPolyData;
61class vtkPoints;
64class vtkTransform;
65class vtkPlane;
66class vtkPlanes;
67class vtkBox;
68class vtkDoubleArray;
69class vtkMatrix4x4;
70
71class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkBoxRepresentation
73{
74public:
79
81
85 void PrintSelf(ostream& os, vtkIndent indent) override;
87
96 void GetPlanes(vtkPlanes* planes);
97
98 // Get the underlying planes used by this rep
99 // this can be used as a cropping planes in vtkMapper
100 vtkPlane* GetUnderlyingPlane(int i) { return this->Planes[i]; }
101
103
109 vtkSetMacro(InsideOut, vtkTypeBool);
110 vtkGetMacro(InsideOut, vtkTypeBool);
111 vtkBooleanMacro(InsideOut, vtkTypeBool);
113
122 virtual void GetTransform(vtkTransform* t);
123
131 virtual void SetTransform(vtkTransform* t);
132
144
146
151 vtkGetObjectMacro(HandleProperty, vtkProperty);
154
156
161 vtkGetObjectMacro(FaceProperty, vtkProperty);
164
166
171 vtkGetObjectMacro(OutlineProperty, vtkProperty);
174
176
179 void SetForegroundColor(double _arg1, double _arg2, double _arg3);
180 void SetForegroundColor(const double _arg[3])
181 {
182 this->SetForegroundColor(_arg[0], _arg[1], _arg[2]);
183 }
184
185
187
191 void SetInteractionColor(double _arg1, double _arg2, double _arg3);
192 void SetInteractionColor(const double _arg[3])
193 {
194 this->SetInteractionColor(_arg[0], _arg[1], _arg[2]);
195 }
196
197
199
204 vtkGetMacro(OutlineFaceWires, int);
208
210
216 vtkGetMacro(OutlineCursorWires, int);
220
222
226 virtual void HandlesOn();
227 virtual void HandlesOff();
229
231
234 void PlaceWidget(double bounds[6]) override;
235 void BuildRepresentation() override;
236 int ComputeInteractionState(int X, int Y, int modify = 0) override;
237 void StartWidgetInteraction(double e[2]) override;
238 void WidgetInteraction(double e[2]) override;
239 double* GetBounds() VTK_SIZEHINT(6) override;
241 unsigned long event, void* calldata) override;
243 unsigned long event, void* calldata) override;
245 unsigned long event, void* calldata, int modify = 0) override;
247 unsigned long event, void* calldata) override;
249
251
259
260 // Used to manage the state of the widget
261 enum
262 {
273 };
274
284 void SetInteractionState(int state);
285
287
291 vtkGetMacro(TwoPlaneMode, bool);
292 void SetTwoPlaneMode(bool);
294
296
300 vtkGetMacro(SnapToAxes, bool);
301 vtkSetMacro(SnapToAxes, bool);
303
305
312
313 /*
314 * Register internal Pickers within PickingManager
315 */
316 void RegisterPickers() override;
317
319
323 vtkGetMacro(TranslationAxis, int);
324 vtkSetClampMacro(TranslationAxis, int, -1, 2);
326
328
336
338
343
350
352
357 std::vector<double> GetCorners();
358 void SetCorners(std::vector<double> points);
360
368
370
375 vtkSetMacro(RotationAxisMode, int);
376 vtkGetMacro(RotationAxisMode, int);
381
382 bool IsRotationAxisLocked() const { return this->RotationAxisMode != ROTATE_FREE; }
384
385protected:
388
389 // Manage how the representation appears
396
398
399 // Constraint axis translation
401
402 // the hexahedron (6 faces)
406 vtkPoints* Points; // used by others as well
407 double N[6][3]; // the normals of the faces
408
409 // A face of the hexahedron
413
414 // glyphs representing hot spots (e.g., handles)
418 virtual void PositionHandles();
419 int HighlightHandle(vtkProp* prop); // returns cell id
420 void HighlightFace(int cellId);
421 void HighlightOutline(int highlight);
422 virtual void ComputeNormals();
423 virtual void SizeHandles();
424
425 // wireframe outline
429
430 // Do the picking
436
437 // Transform the hexahedral points (used for rotations)
439
440 // Support GetBounds() method
442
443 // Properties used to control the appearance of selected objects and
444 // the manipulator in general.
452
453 // Control the orientation of the normals
458
459 // Helper methods
460 virtual void Translate(const double* p1, const double* p2);
461 virtual void Scale(const double* p1, const double* p2, int X, int Y);
462 virtual void Rotate(int X, int Y, const double* p1, const double* p2, const double* vpn);
463 void MovePlusXFace(const double* p1, const double* p2);
464 void MoveMinusXFace(const double* p1, const double* p2);
465 void MovePlusYFace(const double* p1, const double* p2);
466 void MoveMinusYFace(const double* p1, const double* p2);
467 void MovePlusZFace(const double* p1, const double* p2);
468 void MoveMinusZFace(const double* p1, const double* p2);
469 void UpdatePose(const double* p1, const double* d1, const double* p2, const double* d2);
470
471 // Internal ivars for performance
475
476 // The actual planes which are being manipulated
478
479 //"dir" is the direction in which the face can be moved i.e. the axis passing
480 // through the center
481 void MoveFace(const double* p1, const double* p2, const double* dir, double* x1, double* x2,
482 double* x3, double* x4, double* x5);
483 // Helper method to obtain the direction in which the face is to be moved.
484 // Handles special cases where some of the scale factors are 0.
485 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
486
487private:
489 void operator=(const vtkBoxRepresentation&) = delete;
490
491 int RotationAxisMode = ROTATE_FREE;
492};
493
494VTK_ABI_NAMESPACE_END
495#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual void PositionHandles()
virtual void SetTransform(vtkTransform *t)
Set the position, scale and orientation of the box widget using the transform specified.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
void MovePlusZFace(const double *p1, const double *p2)
void OutlineCursorWiresOff()
Control the representation of the outline.
void MoveMinusYFace(const double *p1, const double *p2)
int ComputeComplexInteractionState(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
void GetPlanes(vtkPlanes *planes)
Get the planes describing the implicit function defined by the box widget.
void SetOutlineCursorWires(int)
Control the representation of the outline.
vtkPolyDataMapper * HexFaceMapper
void StepBackward()
For complex events should we snap orientations to be aligned with the x y z axes.
void SetCorners(std::vector< double > points)
Get/Set the x,y,z coordinates for the corner points of the 3D box.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
void GetActors(vtkPropCollection *) override
These methods are necessary to make this representation behave as a vtkProp (i.e.,...
void MoveMinusXFace(const double *p1, const double *p2)
void MoveFace(const double *p1, const double *p2, const double *dir, double *x1, double *x2, double *x3, double *x4, double *x5)
virtual void HandlesOff()
Switches handles (the spheres) on or off by manipulating the underlying actor visibility.
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
bool IsRotationAxisLocked() const
Get/Set the rotation mode of the box.
void HighlightFace(int cellId)
int HighlightHandle(vtkProp *prop)
void SetRotationAxisModeToZ()
Get/Set the rotation mode of the box.
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
void OutlineFaceWiresOn()
Control the representation of the outline.
vtkPolyDataMapper * OutlineMapper
vtkPlane * GetUnderlyingPlane(int i)
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual void Translate(const double *p1, const double *p2)
void MovePlusYFace(const double *p1, const double *p2)
void EndComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
These are methods that satisfy vtkWidgetRepresentation's API.
virtual void SizeHandles()
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
virtual void Rotate(int X, int Y, const double *p1, const double *p2, const double *vpn)
vtkSphereSource ** HandleGeometry
virtual void SetRotationAxisMode(int)
Get/Set the rotation mode of the box.
virtual void GetTransform(vtkTransform *t)
Retrieve a linear transform characterizing the transformation of the box.
vtkDoubleArray * PlaneNormals
void SetTwoPlaneMode(bool)
In two plane mode only the X planes are shown this is useful for defining thick slabs.
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkProperty * SelectedOutlineProperty
void OutlineCursorWiresOn()
Control the representation of the outline.
virtual void ComputeNormals()
void HighlightOutline(int highlight)
void SetInteractionColor(const double _arg[3])
Set the interaction color.
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that define the box widget.
void SetRotationAxisModeToFree()
Get/Set the rotation mode of the box.
void UpdatePose(const double *p1, const double *d1, const double *p2, const double *d2)
vtkProperty * SelectedHandleProperty
void MovePlusXFace(const double *p1, const double *p2)
vtkPolyDataMapper * HexMapper
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting, and required by, the rendering process.
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
void StepForward()
For complex events should we snap orientations to be aligned with the x y z axes.
vtkPolyDataMapper ** HandleMapper
void SetInteractionState(int state)
The interaction state may be set from a widget (e.g., vtkBoxWidget2) or other object.
virtual void HandlesOn()
Switches handles (the spheres) on or off by manipulating the underlying actor visibility.
void SetOutlineFaceWires(int)
Control the representation of the outline.
~vtkBoxRepresentation() override
void StartComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
These are methods that satisfy vtkWidgetRepresentation's API.
void OutlineFaceWiresOff()
Control the representation of the outline.
virtual void CreateDefaultProperties()
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
std::vector< double > GetCorners()
Get/Set the x,y,z coordinates for the corner points of the 3D box.
void ComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
These are methods that satisfy vtkWidgetRepresentation's API.
void PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting, and required by, the rendering process.
virtual void Scale(const double *p1, const double *p2, int X, int Y)
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
static vtkBoxRepresentation * New()
Instantiate the class.
void SetForegroundColor(double _arg1, double _arg2, double _arg3)
Set the foreground color (the outline of the box).
void SetRotationAxisModeToX()
Get/Set the rotation mode of the box.
void MoveMinusZFace(const double *p1, const double *p2)
double SnappedEventOrientations[3][4]
void SetInteractionColor(double _arg1, double _arg2, double _arg3)
Set the interaction color.
void SetRotationAxisModeToY()
Get/Set the rotation mode of the box.
implicit function for a bounding box
Definition vtkBox.h:110
ray-cast cell picker for all kinds of Prop3Ds
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:108
create a line defined by two end points
represent and manipulate 4x4 transformation matrices
perform various plane computations
Definition vtkPlane.h:141
implicit function for convex set of planes
Definition vtkPlanes.h:151
represent the position of a point in 3D space
represent and manipulate 3D points
Definition vtkPoints.h:139
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
an ordered list of Props
represent surface properties of a geometric object
platform-independent render window interaction including picking and frame rate control.
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
abstract specification for Viewports
Definition vtkViewport.h:66
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)
#define vtkPolyDataAlgorithm