Thanks to visit codestin.com
Credit goes to vtk.org

VTK  9.5.20251001
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
362 {
363 ROTATE_FREE = 0,
364 ROTATE_X = 1,
365 ROTATE_Y = 2,
366 ROTATE_Z = 3
367 };
368
370
375 vtkSetMacro(RotationAxisMode, int);
376 vtkGetMacro(RotationAxisMode, int);
377 void SetRotationAxisModeToFree() { this->SetRotationAxisMode(ROTATE_FREE); }
378 void SetRotationAxisModeToX() { this->SetRotationAxisMode(ROTATE_X); }
379 void SetRotationAxisModeToY() { this->SetRotationAxisMode(ROTATE_Y); }
380 void SetRotationAxisModeToZ() { this->SetRotationAxisMode(ROTATE_Z); }
381
382 bool IsRotationAxisLocked() const { return this->RotationAxisMode != ROTATE_FREE; }
384
385protected:
388
389 // Manage how the representation appears
390 double LastEventPosition[3];
391 double LastEventOrientation[4];
392 double StartEventOrientation[4];
393 double SnappedEventOrientations[3][4];
394 bool SnappedOrientation[3];
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
477 vtkPlane* Planes[6];
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
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.
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)
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 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
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 SetRotationAxisModeToX()
Get/Set the rotation mode of the box.
void MoveMinusZFace(const double *p1, const double *p2)
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
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:69
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
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)