VTK
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 =========================================================================*/
36 #ifndef vtkBoxRepresentation_h
37 #define vtkBoxRepresentation_h
38 
39 #include "vtkInteractionWidgetsModule.h" // For export macro
41 
42 class vtkActor;
43 class vtkPolyDataMapper;
44 class vtkLineSource;
45 class vtkSphereSource;
46 class vtkCellPicker;
47 class vtkProperty;
48 class vtkPolyData;
49 class vtkPoints;
52 class vtkTransform;
53 class vtkPlane;
54 class vtkPlanes;
55 class vtkBox;
56 class vtkDoubleArray;
57 class vtkMatrix4x4;
58 
59 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxRepresentation : public vtkWidgetRepresentation
60 {
61 public:
65  static vtkBoxRepresentation* New();
66 
68 
72  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
83  void GetPlanes(vtkPlanes* planes);
84 
85  // Get the underlying planes used by this rep
86  // this can be used as a cropping planes in vtkMapper
87  vtkPlane* GetUnderlyingPlane(int i) { return this->Planes[i]; }
88 
90 
96  vtkSetMacro(InsideOut, vtkTypeBool);
97  vtkGetMacro(InsideOut, vtkTypeBool);
98  vtkBooleanMacro(InsideOut, vtkTypeBool);
100 
108  virtual void GetTransform(vtkTransform* t);
109 
116  virtual void SetTransform(vtkTransform* t);
117 
128  void GetPolyData(vtkPolyData* pd);
129 
131 
136  vtkGetObjectMacro(HandleProperty, vtkProperty);
137  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
139 
141 
146  vtkGetObjectMacro(FaceProperty, vtkProperty);
147  vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
149 
151 
156  vtkGetObjectMacro(OutlineProperty, vtkProperty);
157  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
159 
161 
165  void SetOutlineFaceWires(int);
166  vtkGetMacro(OutlineFaceWires, int);
167  void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
168  void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
170 
172 
177  void SetOutlineCursorWires(int);
178  vtkGetMacro(OutlineCursorWires, int);
179  void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
180  void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
182 
184 
188  virtual void HandlesOn();
189  virtual void HandlesOff();
191 
193 
196  void PlaceWidget(double bounds[6]) override;
197  void BuildRepresentation() override;
198  int ComputeInteractionState(int X, int Y, int modify = 0) override;
199  void StartWidgetInteraction(double e[2]) override;
200  void WidgetInteraction(double e[2]) override;
201  double* GetBounds() VTK_SIZEHINT(6) override;
202  void StartComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
203  unsigned long event, void* calldata) override;
204  void ComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
205  unsigned long event, void* calldata) override;
206  int ComputeComplexInteractionState(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
207  unsigned long event, void* calldata, int modify = 0) override;
208  void EndComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
209  unsigned long event, void* calldata) override;
211 
213 
216  void ReleaseGraphicsResources(vtkWindow*) override;
217  int RenderOpaqueGeometry(vtkViewport*) override;
218  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
219  vtkTypeBool HasTranslucentPolygonalGeometry() override;
221 
222  // Used to manage the state of the widget
223  enum
224  {
225  Outside = 0,
234  Scaling
235  };
236 
246  void SetInteractionState(int state);
247 
249 
253  vtkGetMacro(TwoPlaneMode, bool);
254  void SetTwoPlaneMode(bool);
256 
258 
262  vtkGetMacro(SnapToAxes, bool);
263  vtkSetMacro(SnapToAxes, bool);
265 
267 
271  void StepForward();
272  void StepBackward();
274 
275  /*
276  * Register internal Pickers within PickingManager
277  */
278  void RegisterPickers() override;
279 
281 
285  vtkGetMacro(TranslationAxis, int);
286  vtkSetClampMacro(TranslationAxis, int, -1, 2);
288 
290 
293  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
294  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
295  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
296  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
298 
300 
303  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
305 
306 protected:
308  ~vtkBoxRepresentation() override;
309 
310  // Manage how the representation appears
311  double LastEventPosition[3];
312  double LastEventOrientation[4];
313  double StartEventOrientation[4];
314  double SnappedEventOrientations[3][4];
315  bool SnappedOrientation[3];
317 
319 
320  // Constraint axis translation
322 
323  // the hexahedron (6 faces)
327  vtkPoints* Points; // used by others as well
328  double N[6][3]; // the normals of the faces
329 
330  // A face of the hexahedron
334 
335  // glyphs representing hot spots (e.g., handles)
339  virtual void PositionHandles();
340  int HighlightHandle(vtkProp* prop); // returns cell id
341  void HighlightFace(int cellId);
342  void HighlightOutline(int highlight);
343  virtual void ComputeNormals();
344  virtual void SizeHandles();
345 
346  // wireframe outline
350 
351  // Do the picking
357 
358  // Transform the hexahedral points (used for rotations)
360 
361  // Support GetBounds() method
363 
364  // Properties used to control the appearance of selected objects and
365  // the manipulator in general.
372  virtual void CreateDefaultProperties();
373 
374  // Control the orientation of the normals
378  void GenerateOutline();
379 
380  // Helper methods
381  virtual void Translate(const double* p1, const double* p2);
382  virtual void Scale(const double* p1, const double* p2, int X, int Y);
383  virtual void Rotate(int X, int Y, const double* p1, const double* p2, const double* vpn);
384  void MovePlusXFace(const double* p1, const double* p2);
385  void MoveMinusXFace(const double* p1, const double* p2);
386  void MovePlusYFace(const double* p1, const double* p2);
387  void MoveMinusYFace(const double* p1, const double* p2);
388  void MovePlusZFace(const double* p1, const double* p2);
389  void MoveMinusZFace(const double* p1, const double* p2);
390  void UpdatePose(const double* p1, const double* d1, const double* p2, const double* d2);
391 
392  // Internal ivars for performance
396 
397  // The actual planes which are being manipulated
398  vtkPlane* Planes[6];
399 
400  //"dir" is the direction in which the face can be moved i.e. the axis passing
401  // through the center
402  void MoveFace(const double* p1, const double* p2, const double* dir, double* x1, double* x2,
403  double* x3, double* x4, double* x5);
404  // Helper method to obtain the direction in which the face is to be moved.
405  // Handles special cases where some of the scale factors are 0.
406  void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
407 
408 private:
410  void operator=(const vtkBoxRepresentation&) = delete;
411 };
412 
413 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkWidgetRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double eventPos[2])
Definition: vtkWidgetRepresentation.h:135
vtkWidgetRepresentation.h
vtkPlane
perform various plane computations
Definition: vtkPlane.h:31
vtkBoxRepresentation::PlaneNormals
vtkDoubleArray * PlaneNormals
Definition: vtkBoxRepresentation.h:394
vtkBoxRepresentation::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxRepresentation.h:371
vtkBoxRepresentation
a class defining the representation for the vtkBoxWidget2
Definition: vtkBoxRepresentation.h:59
vtkBoxRepresentation::SetYTranslationAxisOn
void SetYTranslationAxisOn()
Definition: vtkBoxRepresentation.h:294
vtkPointHandleRepresentation3D
represent the position of a point in 3D space
Definition: vtkPointHandleRepresentation3D.h:40
vtkBoxRepresentation::MoveF1
Definition: vtkBoxRepresentation.h:227
vtkBoxRepresentation::OutlineCursorWires
int OutlineCursorWires
Definition: vtkBoxRepresentation.h:377
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkBoxRepresentation::OutlineMapper
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxRepresentation.h:348
vtkBoxRepresentation::MoveF4
Definition: vtkBoxRepresentation.h:230
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:59
vtkBoxRepresentation::OutlinePolyData
vtkPolyData * OutlinePolyData
Definition: vtkBoxRepresentation.h:349
vtkBoxRepresentation::Points
vtkPoints * Points
Definition: vtkBoxRepresentation.h:327
vtkX3D::dir
Definition: vtkX3D.h:330
vtkBoxRepresentation::SetTranslationAxisOff
void SetTranslationAxisOff()
Definition: vtkBoxRepresentation.h:296
vtkBoxRepresentation::HexPicker
vtkCellPicker * HexPicker
Definition: vtkBoxRepresentation.h:353
vtkWidgetRepresentation::BuildRepresentation
virtual void BuildRepresentation()=0
vtkPlanes
implicit function for convex set of planes
Definition: vtkPlanes.h:49
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkBoxRepresentation::HexActor
vtkActor * HexActor
Definition: vtkBoxRepresentation.h:324
vtkBoxRepresentation::HandleMapper
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxRepresentation.h:337
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkBoxRepresentation::Handle
vtkActor ** Handle
Definition: vtkBoxRepresentation.h:336
vtkAbstractWidget
define the API for widget / widget representation
Definition: vtkAbstractWidget.h:62
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:136
vtkWidgetRepresentation::GetBounds
double * GetBounds() override
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:208
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkBoxRepresentation::HexMapper
vtkPolyDataMapper * HexMapper
Definition: vtkBoxRepresentation.h:325
vtkBoxRepresentation::TranslationAxis
int TranslationAxis
Definition: vtkBoxRepresentation.h:321
vtkBoxRepresentation::SnapToAxes
bool SnapToAxes
Definition: vtkBoxRepresentation.h:316
vtkBoxRepresentation::HexOutline
vtkActor * HexOutline
Definition: vtkBoxRepresentation.h:347
vtkBoxRepresentation::HexFacePolyData
vtkPolyData * HexFacePolyData
Definition: vtkBoxRepresentation.h:333
vtkBoxRepresentation::HexFaceMapper
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxRepresentation.h:332
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:40
vtkBoxRepresentation::SetZTranslationAxisOn
void SetZTranslationAxisOn()
Definition: vtkBoxRepresentation.h:295
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkBoxRepresentation::Matrix
vtkMatrix4x4 * Matrix
Definition: vtkBoxRepresentation.h:395
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkWidgetRepresentation::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkBoxRepresentation::TwoPlaneMode
bool TwoPlaneMode
Definition: vtkBoxRepresentation.h:318
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:36
vtkBoxRepresentation::OutlineFaceWiresOn
void OutlineFaceWiresOn()
Definition: vtkBoxRepresentation.h:167
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:72
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkBoxRepresentation::SetXTranslationAxisOn
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
Definition: vtkBoxRepresentation.h:293
vtkBoxRepresentation::MoveF2
Definition: vtkBoxRepresentation.h:228
vtkBoxRepresentation::HexPolyData
vtkPolyData * HexPolyData
Definition: vtkBoxRepresentation.h:326
vtkBoxRepresentation::GetUnderlyingPlane
vtkPlane * GetUnderlyingPlane(int i)
Definition: vtkBoxRepresentation.h:87
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:47
vtkWidgetRepresentation::PlaceWidget
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
The following is a suggested API for widget representations.
Definition: vtkWidgetRepresentation.h:134
vtkBoxRepresentation::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkBoxRepresentation.h:354
vtkBoxRepresentation::BoundingBox
vtkBox * BoundingBox
Definition: vtkBoxRepresentation.h:362
vtkBoxRepresentation::FaceProperty
vtkProperty * FaceProperty
Definition: vtkBoxRepresentation.h:368
vtkBox
implicit function for a bounding box
Definition: vtkBox.h:38
vtkBoxRepresentation::MoveF0
Definition: vtkBoxRepresentation.h:226
vtkBoxRepresentation::InsideOut
vtkTypeBool InsideOut
Definition: vtkBoxRepresentation.h:375
vtkBoxRepresentation::OutlineCursorWiresOff
void OutlineCursorWiresOff()
Definition: vtkBoxRepresentation.h:180
vtkBoxRepresentation::SelectedFaceProperty
vtkProperty * SelectedFaceProperty
Definition: vtkBoxRepresentation.h:369
vtkBoxRepresentation::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkBoxRepresentation.h:338
vtkBoxRepresentation::CurrentHexFace
int CurrentHexFace
Definition: vtkBoxRepresentation.h:355
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkBoxRepresentation::IsTranslationConstrained
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
Definition: vtkBoxRepresentation.h:303
vtkBoxRepresentation::OutlineCursorWiresOn
void OutlineCursorWiresOn()
Definition: vtkBoxRepresentation.h:179
vtkBoxRepresentation::Transform
vtkTransform * Transform
Definition: vtkBoxRepresentation.h:359
vtkBoxRepresentation::Translating
Definition: vtkBoxRepresentation.h:232
vtkBoxRepresentation::HexFace
vtkActor * HexFace
Definition: vtkBoxRepresentation.h:331
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkBoxRepresentation::OutlineFaceWires
int OutlineFaceWires
Definition: vtkBoxRepresentation.h:376
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkBoxRepresentation::LastPicker
vtkCellPicker * LastPicker
Definition: vtkBoxRepresentation.h:356
vtkBoxRepresentation::Rotating
Definition: vtkBoxRepresentation.h:233
vtkBoxRepresentation::OutlineFaceWiresOff
void OutlineFaceWiresOff()
Definition: vtkBoxRepresentation.h:168
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkBoxRepresentation::HandleProperty
vtkProperty * HandleProperty
Definition: vtkBoxRepresentation.h:366
vtkBoxRepresentation::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkBoxRepresentation.h:370
vtkBoxRepresentation::MoveF5
Definition: vtkBoxRepresentation.h:231
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkBoxRepresentation::PlanePoints
vtkPoints * PlanePoints
Definition: vtkBoxRepresentation.h:393
vtkWidgetRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkBoxRepresentation::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkBoxRepresentation.h:367
vtkBoxRepresentation::MoveF3
Definition: vtkBoxRepresentation.h:229
vtkBoxRepresentation::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkBoxRepresentation.h:352
vtkWidgetRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41