VTK  9.4.20241108
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
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
143 void GetPolyData(vtkPolyData* pd);
144
146
151 vtkGetObjectMacro(HandleProperty, vtkProperty);
152 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
154
156
161 vtkGetObjectMacro(FaceProperty, vtkProperty);
162 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
164
166
171 vtkGetObjectMacro(OutlineProperty, vtkProperty);
172 vtkGetObjectMacro(SelectedOutlineProperty, 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 }
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 }
197
199
204 vtkGetMacro(OutlineFaceWires, int);
205 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
206 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
208
210
216 vtkGetMacro(OutlineCursorWires, int);
217 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
218 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
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;
240 void StartComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
241 unsigned long event, void* calldata) override;
242 void ComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
243 unsigned long event, void* calldata) override;
244 int ComputeComplexInteractionState(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
245 unsigned long event, void* calldata, int modify = 0) override;
246 void EndComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
247 unsigned long event, void* calldata) override;
249
251
254 void ReleaseGraphicsResources(vtkWindow*) override;
255 int RenderOpaqueGeometry(vtkViewport*) override;
256 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
257 vtkTypeBool HasTranslucentPolygonalGeometry() override;
259
260 // Used to manage the state of the widget
261 enum
262 {
263 Outside = 0,
272 Scaling
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
331 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
332 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
333 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
334 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
336
338
341 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
343
350
352
357 std::vector<double> GetCorners();
358 void SetCorners(std::vector<double> points);
360
361protected:
364
365 // Manage how the representation appears
366 double LastEventPosition[3];
367 double LastEventOrientation[4];
368 double StartEventOrientation[4];
369 double SnappedEventOrientations[3][4];
370 bool SnappedOrientation[3];
372
374
375 // Constraint axis translation
377
378 // the hexahedron (6 faces)
382 vtkPoints* Points; // used by others as well
383 double N[6][3]; // the normals of the faces
384
385 // A face of the hexahedron
389
390 // glyphs representing hot spots (e.g., handles)
394 virtual void PositionHandles();
395 int HighlightHandle(vtkProp* prop); // returns cell id
396 void HighlightFace(int cellId);
397 void HighlightOutline(int highlight);
398 virtual void ComputeNormals();
399 virtual void SizeHandles();
400
401 // wireframe outline
405
406 // Do the picking
412
413 // Transform the hexahedral points (used for rotations)
415
416 // Support GetBounds() method
418
419 // Properties used to control the appearance of selected objects and
420 // the manipulator in general.
428
429 // Control the orientation of the normals
434
435 // Helper methods
436 virtual void Translate(const double* p1, const double* p2);
437 virtual void Scale(const double* p1, const double* p2, int X, int Y);
438 virtual void Rotate(int X, int Y, const double* p1, const double* p2, const double* vpn);
439 void MovePlusXFace(const double* p1, const double* p2);
440 void MoveMinusXFace(const double* p1, const double* p2);
441 void MovePlusYFace(const double* p1, const double* p2);
442 void MoveMinusYFace(const double* p1, const double* p2);
443 void MovePlusZFace(const double* p1, const double* p2);
444 void MoveMinusZFace(const double* p1, const double* p2);
445 void UpdatePose(const double* p1, const double* d1, const double* p2, const double* d2);
446
447 // Internal ivars for performance
451
452 // The actual planes which are being manipulated
453 vtkPlane* Planes[6];
454
455 //"dir" is the direction in which the face can be moved i.e. the axis passing
456 // through the center
457 void MoveFace(const double* p1, const double* p2, const double* dir, double* x1, double* x2,
458 double* x3, double* x4, double* x5);
459 // Helper method to obtain the direction in which the face is to be moved.
460 // Handles special cases where some of the scale factors are 0.
461 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
462
463private:
465 void operator=(const vtkBoxRepresentation&) = delete;
466};
467
468VTK_ABI_NAMESPACE_END
469#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
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: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:138
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
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
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:65
abstract class defines interface between the widget and widget representation classes
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)