VTK  9.1.0
vtkBoxRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkBoxRepresentation.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
55 #ifndef vtkBoxRepresentation_h
56 #define vtkBoxRepresentation_h
57 
58 #include "vtkInteractionWidgetsModule.h" // For export macro
60 
61 class vtkActor;
62 class vtkPolyDataMapper;
63 class vtkLineSource;
64 class vtkSphereSource;
65 class vtkCellPicker;
66 class vtkProperty;
67 class vtkPolyData;
68 class vtkPoints;
71 class vtkTransform;
72 class vtkPlane;
73 class vtkPlanes;
74 class vtkBox;
75 class vtkDoubleArray;
76 class vtkMatrix4x4;
77 
78 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxRepresentation : public vtkWidgetRepresentation
79 {
80 public:
85 
87 
91  void PrintSelf(ostream& os, vtkIndent indent) override;
93 
102  void GetPlanes(vtkPlanes* planes);
103 
104  // Get the underlying planes used by this rep
105  // this can be used as a cropping planes in vtkMapper
106  vtkPlane* GetUnderlyingPlane(int i) { return this->Planes[i]; }
107 
109 
115  vtkSetMacro(InsideOut, vtkTypeBool);
116  vtkGetMacro(InsideOut, vtkTypeBool);
117  vtkBooleanMacro(InsideOut, vtkTypeBool);
119 
127  virtual void GetTransform(vtkTransform* t);
128 
135  virtual void SetTransform(vtkTransform* t);
136 
148 
150 
155  vtkGetObjectMacro(HandleProperty, vtkProperty);
156  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
158 
160 
165  vtkGetObjectMacro(FaceProperty, vtkProperty);
166  vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
168 
170 
175  vtkGetObjectMacro(OutlineProperty, vtkProperty);
176  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
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 
290  void StepForward();
291  void StepBackward();
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 
325 protected:
328 
329  // Manage how the representation appears
330  double LastEventPosition[3];
331  double LastEventOrientation[4];
332  double StartEventOrientation[4];
333  double SnappedEventOrientations[3][4];
334  bool SnappedOrientation[3];
336 
338 
339  // Constraint axis translation
341 
342  // the hexahedron (6 faces)
346  vtkPoints* Points; // used by others as well
347  double N[6][3]; // the normals of the faces
348 
349  // A face of the hexahedron
353 
354  // glyphs representing hot spots (e.g., handles)
358  virtual void PositionHandles();
359  int HighlightHandle(vtkProp* prop); // returns cell id
360  void HighlightFace(int cellId);
361  void HighlightOutline(int highlight);
362  virtual void ComputeNormals();
363  virtual void SizeHandles();
364 
365  // wireframe outline
369 
370  // Do the picking
376 
377  // Transform the hexahedral points (used for rotations)
379 
380  // Support GetBounds() method
382 
383  // Properties used to control the appearance of selected objects and
384  // the manipulator in general.
391  virtual void CreateDefaultProperties();
392 
393  // Control the orientation of the normals
398 
399  // Helper methods
400  virtual void Translate(const double* p1, const double* p2);
401  virtual void Scale(const double* p1, const double* p2, int X, int Y);
402  virtual void Rotate(int X, int Y, const double* p1, const double* p2, const double* vpn);
403  void MovePlusXFace(const double* p1, const double* p2);
404  void MoveMinusXFace(const double* p1, const double* p2);
405  void MovePlusYFace(const double* p1, const double* p2);
406  void MoveMinusYFace(const double* p1, const double* p2);
407  void MovePlusZFace(const double* p1, const double* p2);
408  void MoveMinusZFace(const double* p1, const double* p2);
409  void UpdatePose(const double* p1, const double* d1, const double* p2, const double* d2);
410 
411  // Internal ivars for performance
415 
416  // The actual planes which are being manipulated
417  vtkPlane* Planes[6];
418 
419  //"dir" is the direction in which the face can be moved i.e. the axis passing
420  // through the center
421  void MoveFace(const double* p1, const double* p2, const double* dir, double* x1, double* x2,
422  double* x3, double* x4, double* x5);
423  // Helper method to obtain the direction in which the face is to be moved.
424  // Handles special cases where some of the scale factors are 0.
425  void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
426 
427 private:
429  void operator=(const vtkBoxRepresentation&) = delete;
430 };
431 
432 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:146
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkWidgetRepresentation.h
vtkBoxRepresentation::HandlesOff
virtual void HandlesOff()
Switches handles (the spheres) on or off by manipulating the underlying actor visibility.
vtkPlane
perform various plane computations
Definition: vtkPlane.h:143
vtkBoxRepresentation::PlaceWidget
void PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkBoxRepresentation::GetBounds
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkBoxRepresentation::MoveMinusYFace
void MoveMinusYFace(const double *p1, const double *p2)
vtkBoxRepresentation::PlaneNormals
vtkDoubleArray * PlaneNormals
Definition: vtkBoxRepresentation.h:413
vtkBoxRepresentation::MovePlusXFace
void MovePlusXFace(const double *p1, const double *p2)
vtkBoxRepresentation::GetDirection
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
vtkBoxRepresentation::MoveFace
void MoveFace(const double *p1, const double *p2, const double *dir, double *x1, double *x2, double *x3, double *x4, double *x5)
vtkBoxRepresentation::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxRepresentation.h:390
vtkBoxRepresentation::MoveMinusZFace
void MoveMinusZFace(const double *p1, const double *p2)
vtkBoxRepresentation
a class defining the representation for the vtkBoxWidget2
Definition: vtkBoxRepresentation.h:79
vtkBoxRepresentation::BuildRepresentation
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkBoxRepresentation::SetYTranslationAxisOn
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
Definition: vtkBoxRepresentation.h:313
vtkBoxRepresentation::MoveF5
@ MoveF5
Definition: vtkBoxRepresentation.h:250
vtkPointHandleRepresentation3D
represent the position of a point in 3D space
Definition: vtkPointHandleRepresentation3D.h:41
vtkBoxRepresentation::HighlightFace
void HighlightFace(int cellId)
vtkBoxRepresentation::OutlineCursorWires
int OutlineCursorWires
Definition: vtkBoxRepresentation.h:396
vtkBoxRepresentation::OutlineMapper
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxRepresentation.h:367
vtkBoxRepresentation::MoveF1
@ MoveF1
Definition: vtkBoxRepresentation.h:246
vtkBoxRepresentation::GetPolyData
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that define the box widget.
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:60
vtkBoxRepresentation::OutlinePolyData
vtkPolyData * OutlinePolyData
Definition: vtkBoxRepresentation.h:368
vtkBoxRepresentation::Points
vtkPoints * Points
Definition: vtkBoxRepresentation.h:346
vtkBoxRepresentation::MoveF3
@ MoveF3
Definition: vtkBoxRepresentation.h:248
vtkBoxRepresentation::Translate
virtual void Translate(const double *p1, const double *p2)
vtkX3D::dir
@ dir
Definition: vtkX3D.h:330
vtkBoxRepresentation::UpdatePose
void UpdatePose(const double *p1, const double *d1, const double *p2, const double *d2)
vtkBoxRepresentation::ComputeInteractionState
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkBoxRepresentation::SetTranslationAxisOff
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
Definition: vtkBoxRepresentation.h:315
vtkBoxRepresentation::HexPicker
vtkCellPicker * HexPicker
Definition: vtkBoxRepresentation.h:372
vtkPlanes
implicit function for convex set of planes
Definition: vtkPlanes.h:159
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
vtkBoxRepresentation::HexActor
vtkActor * HexActor
Definition: vtkBoxRepresentation.h:343
vtkBoxRepresentation::HandleMapper
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxRepresentation.h:356
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
vtkBoxRepresentation::Translating
@ Translating
Definition: vtkBoxRepresentation.h:251
vtkBoxRepresentation::Handle
vtkActor ** Handle
Definition: vtkBoxRepresentation.h:355
vtkBoxRepresentation::StepForward
void StepForward()
For complex events should we snap orientations to be aligned with the x y z axes.
vtkAbstractWidget
define the API for widget / widget representation
Definition: vtkAbstractWidget.h:66
vtkBoxRepresentation::HandlesOn
virtual void HandlesOn()
Switches handles (the spheres) on or off by manipulating the underlying actor visibility.
vtkBoxRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
vtkBoxRepresentation::MoveF4
@ MoveF4
Definition: vtkBoxRepresentation.h:249
vtkBoxRepresentation::RegisterPickers
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:48
vtkBoxRepresentation::HexMapper
vtkPolyDataMapper * HexMapper
Definition: vtkBoxRepresentation.h:344
vtkBoxRepresentation::vtkBoxRepresentation
vtkBoxRepresentation()
vtkBoxRepresentation::TranslationAxis
int TranslationAxis
Definition: vtkBoxRepresentation.h:340
vtkBoxRepresentation::SnapToAxes
bool SnapToAxes
Definition: vtkBoxRepresentation.h:335
vtkBoxRepresentation::HexOutline
vtkActor * HexOutline
Definition: vtkBoxRepresentation.h:366
vtkBoxRepresentation::HexFacePolyData
vtkPolyData * HexFacePolyData
Definition: vtkBoxRepresentation.h:352
vtkBoxRepresentation::HexFaceMapper
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxRepresentation.h:351
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:149
vtkBoxRepresentation::GenerateOutline
void GenerateOutline()
vtkBoxRepresentation::Scale
virtual void Scale(const double *p1, const double *p2, int X, int Y)
vtkBoxRepresentation::SetZTranslationAxisOn
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
Definition: vtkBoxRepresentation.h:314
vtkBoxRepresentation::HighlightOutline
void HighlightOutline(int highlight)
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
vtkBoxRepresentation::Matrix
vtkMatrix4x4 * Matrix
Definition: vtkBoxRepresentation.h:414
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
vtkBoxRepresentation::TwoPlaneMode
bool TwoPlaneMode
Definition: vtkBoxRepresentation.h:337
vtkBoxRepresentation::GetTransform
virtual void GetTransform(vtkTransform *t)
Retrieve a linear transform characterizing the transformation of the box.
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:170
vtkBoxRepresentation::OutlineFaceWiresOn
void OutlineFaceWiresOn()
Control the representation of the outline.
Definition: vtkBoxRepresentation.h:186
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:192
vtkBoxRepresentation::WidgetInteraction
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkBoxRepresentation::SetXTranslationAxisOn
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
Definition: vtkBoxRepresentation.h:312
vtkBoxRepresentation::CreateDefaultProperties
virtual void CreateDefaultProperties()
vtkBoxRepresentation::Rotate
virtual void Rotate(int X, int Y, const double *p1, const double *p2, const double *vpn)
vtkBoxRepresentation::HexPolyData
vtkPolyData * HexPolyData
Definition: vtkBoxRepresentation.h:345
vtkBoxRepresentation::GetUnderlyingPlane
vtkPlane * GetUnderlyingPlane(int i)
Definition: vtkBoxRepresentation.h:106
vtkBoxRepresentation::MoveF2
@ MoveF2
Definition: vtkBoxRepresentation.h:247
vtkBoxRepresentation::ComputeNormals
virtual void ComputeNormals()
vtkBoxRepresentation::MovePlusZFace
void MovePlusZFace(const double *p1, const double *p2)
vtkBoxRepresentation::New
static vtkBoxRepresentation * New()
Instantiate the class.
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:76
vtkBoxRepresentation::HighlightHandle
int HighlightHandle(vtkProp *prop)
vtkBoxRepresentation::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkBoxRepresentation.h:373
vtkBoxRepresentation::BoundingBox
vtkBox * BoundingBox
Definition: vtkBoxRepresentation.h:381
vtkBoxRepresentation::FaceProperty
vtkProperty * FaceProperty
Definition: vtkBoxRepresentation.h:387
vtkBox
implicit function for a bounding box
Definition: vtkBox.h:138
vtkBoxRepresentation::SizeHandles
virtual void SizeHandles()
vtkBoxRepresentation::InsideOut
vtkTypeBool InsideOut
Definition: vtkBoxRepresentation.h:394
vtkBoxRepresentation::Rotating
@ Rotating
Definition: vtkBoxRepresentation.h:252
vtkBoxRepresentation::OutlineCursorWiresOff
void OutlineCursorWiresOff()
Control the representation of the outline.
Definition: vtkBoxRepresentation.h:199
vtkBoxRepresentation::SelectedFaceProperty
vtkProperty * SelectedFaceProperty
Definition: vtkBoxRepresentation.h:388
vtkBoxRepresentation::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkBoxRepresentation.h:357
vtkBoxRepresentation::CurrentHexFace
int CurrentHexFace
Definition: vtkBoxRepresentation.h:374
vtkBoxRepresentation::GetPlanes
void GetPlanes(vtkPlanes *planes)
Get the planes describing the implicit function defined by the box widget.
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
vtkBoxRepresentation::MoveF0
@ MoveF0
Definition: vtkBoxRepresentation.h:245
vtkBoxRepresentation::IsTranslationConstrained
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
Definition: vtkBoxRepresentation.h:322
vtkBoxRepresentation::OutlineCursorWiresOn
void OutlineCursorWiresOn()
Control the representation of the outline.
Definition: vtkBoxRepresentation.h:198
vtkBoxRepresentation::MovePlusYFace
void MovePlusYFace(const double *p1, const double *p2)
vtkBoxRepresentation::SetOutlineCursorWires
void SetOutlineCursorWires(int)
Control the representation of the outline.
vtkBoxRepresentation::Transform
vtkTransform * Transform
Definition: vtkBoxRepresentation.h:378
vtkBoxRepresentation::PositionHandles
virtual void PositionHandles()
vtkBoxRepresentation::SetInteractionState
void SetInteractionState(int state)
The interaction state may be set from a widget (e.g., vtkBoxWidget2) or other object.
vtkBoxRepresentation::MoveMinusXFace
void MoveMinusXFace(const double *p1, const double *p2)
vtkBoxRepresentation::HexFace
vtkActor * HexFace
Definition: vtkBoxRepresentation.h:350
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:145
vtkBoxRepresentation::OutlineFaceWires
int OutlineFaceWires
Definition: vtkBoxRepresentation.h:395
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:171
vtkBoxRepresentation::LastPicker
vtkCellPicker * LastPicker
Definition: vtkBoxRepresentation.h:375
vtkBoxRepresentation::SetTransform
virtual void SetTransform(vtkTransform *t)
Set the position, scale and orientation of the box widget using the transform specified.
vtkBoxRepresentation::~vtkBoxRepresentation
~vtkBoxRepresentation() override
vtkBoxRepresentation::SetTwoPlaneMode
void SetTwoPlaneMode(bool)
In two plane mode only the X planes are shown this is useful for defining thick slabs.
vtkBoxRepresentation::OutlineFaceWiresOff
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxRepresentation.h:187
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:96
vtkBoxRepresentation::HandleProperty
vtkProperty * HandleProperty
Definition: vtkBoxRepresentation.h:385
vtkBoxRepresentation::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkBoxRepresentation.h:389
vtkBoxRepresentation::SetOutlineFaceWires
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkBoxRepresentation::PlanePoints
vtkPoints * PlanePoints
Definition: vtkBoxRepresentation.h:412
vtkBoxRepresentation::StartWidgetInteraction
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkBoxRepresentation::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkBoxRepresentation.h:386
vtkBoxRepresentation::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkBoxRepresentation.h:371
vtkBoxRepresentation::StepBackward
void StepBackward()
For complex events should we snap orientations to be aligned with the x y z axes.
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:151