VTK  9.4.20251203
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
27#ifndef vtkBoxRepresentation_h
28#define vtkBoxRepresentation_h
29
30#include "vtkInteractionWidgetsModule.h" // For export macro
32#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
33
34VTK_ABI_NAMESPACE_BEGIN
35class vtkActor;
37class vtkLineSource;
38class vtkSphereSource;
39class vtkCellPicker;
40class vtkProperty;
41class vtkPolyData;
42class vtkPoints;
45class vtkTransform;
46class vtkPlane;
47class vtkPlanes;
48class vtkBox;
49class vtkDoubleArray;
50class vtkMatrix4x4;
51
52class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkBoxRepresentation
54{
55public:
60
62
66 void PrintSelf(ostream& os, vtkIndent indent) override;
68
77 void GetPlanes(vtkPlanes* planes);
78
79 // Get the underlying planes used by this rep
80 // this can be used as a cropping planes in vtkMapper
81 vtkPlane* GetUnderlyingPlane(int i) { return this->Planes[i]; }
82
84
90 vtkSetMacro(InsideOut, vtkTypeBool);
91 vtkGetMacro(InsideOut, vtkTypeBool);
92 vtkBooleanMacro(InsideOut, vtkTypeBool);
94
103 virtual void GetTransform(vtkTransform* t);
104
112 virtual void SetTransform(vtkTransform* t);
113
124 void GetPolyData(vtkPolyData* pd);
125
127
132 vtkGetObjectMacro(HandleProperty, vtkProperty);
133 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
135
137
142 vtkGetObjectMacro(FaceProperty, vtkProperty);
143 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
145
147
152 vtkGetObjectMacro(OutlineProperty, vtkProperty);
153 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
155
157
160 void SetForegroundColor(double _arg1, double _arg2, double _arg3);
161 void SetForegroundColor(const double _arg[3])
162 {
163 this->SetForegroundColor(_arg[0], _arg[1], _arg[2]);
164 }
166
168
172 void SetInteractionColor(double _arg1, double _arg2, double _arg3);
173 void SetInteractionColor(const double _arg[3])
174 {
175 this->SetInteractionColor(_arg[0], _arg[1], _arg[2]);
176 }
178
180
185 vtkGetMacro(OutlineFaceWires, int);
186 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
187 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
189
191
197 vtkGetMacro(OutlineCursorWires, int);
198 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
199 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
201
203
207 virtual void HandlesOn();
208 virtual void HandlesOff();
210
212
215 void PlaceWidget(double bounds[6]) override;
216 void BuildRepresentation() override;
217 int ComputeInteractionState(int X, int Y, int modify = 0) override;
218 void StartWidgetInteraction(double e[2]) override;
219 void WidgetInteraction(double e[2]) override;
220 double* GetBounds() VTK_SIZEHINT(6) override;
221 void StartComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
222 unsigned long event, void* calldata) override;
223 void ComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
224 unsigned long event, void* calldata) override;
225 int ComputeComplexInteractionState(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
226 unsigned long event, void* calldata, int modify = 0) override;
227 void EndComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
228 unsigned long event, void* calldata) override;
230
232
235 void ReleaseGraphicsResources(vtkWindow*) override;
236 int RenderOpaqueGeometry(vtkViewport*) override;
237 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
238 vtkTypeBool HasTranslucentPolygonalGeometry() override;
240
241 // Used to manage the state of the widget
242 enum
243 {
244 Outside = 0,
253 Scaling
254 };
255
265 void SetInteractionState(int state);
266
268
272 vtkGetMacro(TwoPlaneMode, bool);
273 void SetTwoPlaneMode(bool);
275
277
281 vtkGetMacro(SnapToAxes, bool);
282 vtkSetMacro(SnapToAxes, bool);
284
286
293
294 /*
295 * Register internal Pickers within PickingManager
296 */
297 void RegisterPickers() override;
298
300
304 vtkGetMacro(TranslationAxis, int);
305 vtkSetClampMacro(TranslationAxis, int, -1, 2);
307
309
312 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
313 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
314 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
315 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
317
319
322 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
324
331
333
338 std::vector<double> GetCorners();
339 void SetCorners(std::vector<double> points);
341
342protected:
345
346 // Manage how the representation appears
347 double LastEventPosition[3];
348 double LastEventOrientation[4];
349 double StartEventOrientation[4];
350 double SnappedEventOrientations[3][4];
351 bool SnappedOrientation[3];
353
355
356 // Constraint axis translation
358
359 // the hexahedron (6 faces)
363 vtkPoints* Points; // used by others as well
364 double N[6][3]; // the normals of the faces
365
366 // A face of the hexahedron
370
371 // glyphs representing hot spots (e.g., handles)
375 virtual void PositionHandles();
376 int HighlightHandle(vtkProp* prop); // returns cell id
377 void HighlightFace(int cellId);
378 void HighlightOutline(int highlight);
379 virtual void ComputeNormals();
380 virtual void SizeHandles();
381
382 // wireframe outline
386
387 // Do the picking
393
394 // Transform the hexahedral points (used for rotations)
396
397 // Support GetBounds() method
399
400 // Properties used to control the appearance of selected objects and
401 // the manipulator in general.
409
410 // Control the orientation of the normals
415
416 // Helper methods
417 virtual void Translate(const double* p1, const double* p2);
418 virtual void Scale(const double* p1, const double* p2, int X, int Y);
419 virtual void Rotate(int X, int Y, const double* p1, const double* p2, const double* vpn);
420 void MovePlusXFace(const double* p1, const double* p2);
421 void MoveMinusXFace(const double* p1, const double* p2);
422 void MovePlusYFace(const double* p1, const double* p2);
423 void MoveMinusYFace(const double* p1, const double* p2);
424 void MovePlusZFace(const double* p1, const double* p2);
425 void MoveMinusZFace(const double* p1, const double* p2);
426 void UpdatePose(const double* p1, const double* d1, const double* p2, const double* d2);
427
428 // Internal ivars for performance
432
433 // The actual planes which are being manipulated
434 vtkPlane* Planes[6];
435
436 //"dir" is the direction in which the face can be moved i.e. the axis passing
437 // through the center
438 void MoveFace(const double* p1, const double* p2, const double* dir, double* x1, double* x2,
439 double* x3, double* x4, double* x5);
440 // Helper method to obtain the direction in which the face is to be moved.
441 // Handles special cases where some of the scale factors are 0.
442 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
443
444private:
446 void operator=(const vtkBoxRepresentation&) = delete;
447};
448
449VTK_ABI_NAMESPACE_END
450#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:42
a class defining the representation for the vtkBoxWidget2
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()
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)
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.
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.
void HighlightFace(int cellId)
int HighlightHandle(vtkProp *prop)
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)
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
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 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
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 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 PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
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 MoveMinusZFace(const double *p1, const double *p2)
void SetInteractionColor(double _arg1, double _arg2, double _arg3)
Set the interaction color.
implicit function for a bounding box
Definition vtkBox.h:31
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:29
create a line defined by two end points
represent and manipulate 4x4 transformation matrices
perform various plane computations
Definition vtkPlane.h:29
implicit function for convex set of planes
Definition vtkPlanes.h:42
represent the position of a point in 3D space
represent and manipulate 3D points
Definition vtkPoints.h:30
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:47
represent surface properties of a geometric object
Definition vtkProperty.h:60
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:46
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:29
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)