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 
60 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxRepresentation : public vtkWidgetRepresentation
61 {
62 public:
66  static vtkBoxRepresentation *New();
67 
69 
73  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
84  void GetPlanes(vtkPlanes *planes);
85 
86  // Get the underlying planes used by this rep
87  // this can be used as a cropping planes in vtkMapper
89  return this->Planes[i]; }
90 
92 
98  vtkSetMacro(InsideOut,vtkTypeBool);
99  vtkGetMacro(InsideOut,vtkTypeBool);
100  vtkBooleanMacro(InsideOut,vtkTypeBool);
102 
110  virtual void GetTransform(vtkTransform *t);
111 
118  virtual void SetTransform(vtkTransform* t);
119 
130  void GetPolyData(vtkPolyData *pd);
131 
133 
138  vtkGetObjectMacro(HandleProperty,vtkProperty);
139  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
141 
143 
148  vtkGetObjectMacro(FaceProperty,vtkProperty);
149  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
151 
153 
158  vtkGetObjectMacro(OutlineProperty,vtkProperty);
159  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
161 
163 
167  void SetOutlineFaceWires(int);
168  vtkGetMacro(OutlineFaceWires,int);
169  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
170  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
172 
174 
179  void SetOutlineCursorWires(int);
180  vtkGetMacro(OutlineCursorWires,int);
181  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
182  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
184 
186 
190  virtual void HandlesOn();
191  virtual void HandlesOff();
193 
195 
198  void PlaceWidget(double bounds[6]) override;
199  void BuildRepresentation() override;
200  int ComputeInteractionState(int X, int Y, int modify=0) override;
201  void StartWidgetInteraction(double e[2]) override;
202  void WidgetInteraction(double e[2]) override;
203  double *GetBounds() VTK_SIZEHINT(6) override;
204  void StartComplexInteraction(
206  vtkAbstractWidget *widget,
207  unsigned long event, void *calldata) override;
208  void ComplexInteraction(
210  vtkAbstractWidget *widget,
211  unsigned long event, void *calldata) override;
212  int ComputeComplexInteractionState(
214  vtkAbstractWidget *widget,
215  unsigned long event, void *calldata, int modify = 0) override;
216  void EndComplexInteraction(
218  vtkAbstractWidget *widget,
219  unsigned long event, void *calldata) override;
221 
223 
226  void ReleaseGraphicsResources(vtkWindow*) override;
227  int RenderOpaqueGeometry(vtkViewport*) override;
228  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
229  int HasTranslucentPolygonalGeometry() override;
231 
232  // Used to manage the state of the widget
233  enum {Outside=0,MoveF0,MoveF1,MoveF2,MoveF3,MoveF4,MoveF5,Translating,Rotating,Scaling};
234 
244  void SetInteractionState(int state);
245 
247 
251  vtkGetMacro(TwoPlaneMode, bool);
252  void SetTwoPlaneMode(bool);
254 
256 
260  vtkGetMacro(SnapToAxes, bool);
261  vtkSetMacro(SnapToAxes, bool);
263 
265 
269  void StepForward();
270  void StepBackward();
272 
273  /*
274  * Register internal Pickers within PickingManager
275  */
276  void RegisterPickers() override;
277 
278 protected:
280  ~vtkBoxRepresentation() override;
281 
282  // Manage how the representation appears
283  double LastEventPosition[3];
284  double LastEventOrientation[4];
285  double StartEventOrientation[4];
286  double SnappedEventOrientations[3][4];
287  bool SnappedOrientation[3];
289 
291 
292  // the hexahedron (6 faces)
296  vtkPoints *Points; //used by others as well
297  double N[6][3]; //the normals of the faces
298 
299  // A face of the hexahedron
303 
304  // glyphs representing hot spots (e.g., handles)
308  virtual void PositionHandles();
309  int HighlightHandle(vtkProp *prop); //returns cell id
310  void HighlightFace(int cellId);
311  void HighlightOutline(int highlight);
312  virtual void ComputeNormals();
313  virtual void SizeHandles();
314 
315  // wireframe outline
319 
320  // Do the picking
326 
327  // Transform the hexahedral points (used for rotations)
329 
330  // Support GetBounds() method
332 
333  // Properties used to control the appearance of selected objects and
334  // the manipulator in general.
341  virtual void CreateDefaultProperties();
342 
343  // Control the orientation of the normals
347  void GenerateOutline();
348 
349  // Helper methods
350  virtual void Translate(double *p1, double *p2);
351  virtual void Scale(double *p1, double *p2, int X, int Y);
352  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
353  void MovePlusXFace(double *p1, double *p2);
354  void MoveMinusXFace(double *p1, double *p2);
355  void MovePlusYFace(double *p1, double *p2);
356  void MoveMinusYFace(double *p1, double *p2);
357  void MovePlusZFace(double *p1, double *p2);
358  void MoveMinusZFace(double *p1, double *p2);
359  void UpdatePose(double *p1, double *d1, double *p2, double *d2);
360 
361  // Internal ivars for performance
365 
366  // The actual planes which are being manipulated
367  vtkPlane *Planes[6];
368 
369  //"dir" is the direction in which the face can be moved i.e. the axis passing
370  //through the center
371  void MoveFace(double *p1, double *p2, double *dir,
372  double *x1, double *x2, double *x3, double *x4,
373  double *x5);
374  //Helper method to obtain the direction in which the face is to be moved.
375  //Handles special cases where some of the scale factors are 0.
376  void GetDirection(const double Nx[3],const double Ny[3],
377  const double Nz[3], double dir[3]);
378 
379 
380 private:
382  void operator=(const vtkBoxRepresentation&) = delete;
383 };
384 
385 #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:136
vtkWidgetRepresentation.h
vtkPlane
perform various plane computations
Definition: vtkPlane.h:31
vtkBoxRepresentation::PlaneNormals
vtkDoubleArray * PlaneNormals
Definition: vtkBoxRepresentation.h:363
vtkBoxRepresentation::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxRepresentation.h:340
vtkBoxRepresentation
a class defining the representation for the vtkBoxWidget2
Definition: vtkBoxRepresentation.h:60
vtkPointHandleRepresentation3D
represent the position of a point in 3D space
Definition: vtkPointHandleRepresentation3D.h:40
vtkBoxRepresentation::OutlineCursorWires
int OutlineCursorWires
Definition: vtkBoxRepresentation.h:346
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:317
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:60
vtkBoxRepresentation::OutlinePolyData
vtkPolyData * OutlinePolyData
Definition: vtkBoxRepresentation.h:318
vtkBoxRepresentation::Points
vtkPoints * Points
Definition: vtkBoxRepresentation.h:296
vtkX3D::dir
Definition: vtkX3D.h:324
vtkBoxRepresentation::HexPicker
vtkCellPicker * HexPicker
Definition: vtkBoxRepresentation.h:322
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::Translating
Definition: vtkBoxRepresentation.h:233
vtkBoxRepresentation::HexActor
vtkActor * HexActor
Definition: vtkBoxRepresentation.h:293
vtkBoxRepresentation::HandleMapper
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxRepresentation.h:306
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkBoxRepresentation::Handle
vtkActor ** Handle
Definition: vtkBoxRepresentation.h:305
vtkAbstractWidget
define the API for widget / widget representation
Definition: vtkAbstractWidget.h:63
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:137
vtkWidgetRepresentation::GetBounds
double * GetBounds() override
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:215
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkBoxRepresentation::HexMapper
vtkPolyDataMapper * HexMapper
Definition: vtkBoxRepresentation.h:294
vtkBoxRepresentation::SnapToAxes
bool SnapToAxes
Definition: vtkBoxRepresentation.h:288
vtkBoxRepresentation::HexOutline
vtkActor * HexOutline
Definition: vtkBoxRepresentation.h:316
vtkBoxRepresentation::HexFacePolyData
vtkPolyData * HexFacePolyData
Definition: vtkBoxRepresentation.h:302
vtkBoxRepresentation::HexFaceMapper
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxRepresentation.h:301
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:40
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkBoxRepresentation::Matrix
vtkMatrix4x4 * Matrix
Definition: vtkBoxRepresentation.h:364
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:290
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:36
vtkBoxRepresentation::OutlineFaceWiresOn
void OutlineFaceWiresOn()
Definition: vtkBoxRepresentation.h:169
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::HexPolyData
vtkPolyData * HexPolyData
Definition: vtkBoxRepresentation.h:295
vtkBoxRepresentation::GetUnderlyingPlane
vtkPlane * GetUnderlyingPlane(int i)
Definition: vtkBoxRepresentation.h:88
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
vtkWidgetRepresentation::PlaceWidget
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
The following is a suggested API for widget representations.
Definition: vtkWidgetRepresentation.h:135
vtkBoxRepresentation::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkBoxRepresentation.h:323
vtkBoxRepresentation::BoundingBox
vtkBox * BoundingBox
Definition: vtkBoxRepresentation.h:331
vtkBoxRepresentation::FaceProperty
vtkProperty * FaceProperty
Definition: vtkBoxRepresentation.h:337
vtkBox
implicit function for a bounding box
Definition: vtkBox.h:38
vtkBoxRepresentation::InsideOut
vtkTypeBool InsideOut
Definition: vtkBoxRepresentation.h:344
vtkBoxRepresentation::OutlineCursorWiresOff
void OutlineCursorWiresOff()
Definition: vtkBoxRepresentation.h:182
vtkBoxRepresentation::SelectedFaceProperty
vtkProperty * SelectedFaceProperty
Definition: vtkBoxRepresentation.h:338
vtkBoxRepresentation::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkBoxRepresentation.h:307
vtkBoxRepresentation::CurrentHexFace
int CurrentHexFace
Definition: vtkBoxRepresentation.h:324
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkBoxRepresentation::OutlineCursorWiresOn
void OutlineCursorWiresOn()
Definition: vtkBoxRepresentation.h:181
vtkBoxRepresentation::Transform
vtkTransform * Transform
Definition: vtkBoxRepresentation.h:328
vtkBoxRepresentation::HexFace
vtkActor * HexFace
Definition: vtkBoxRepresentation.h:300
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkBoxRepresentation::OutlineFaceWires
int OutlineFaceWires
Definition: vtkBoxRepresentation.h:345
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:60
vtkBoxRepresentation::LastPicker
vtkCellPicker * LastPicker
Definition: vtkBoxRepresentation.h:325
vtkBoxRepresentation::OutlineFaceWiresOff
void OutlineFaceWiresOff()
Definition: vtkBoxRepresentation.h:170
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkBoxRepresentation::HandleProperty
vtkProperty * HandleProperty
Definition: vtkBoxRepresentation.h:335
vtkBoxRepresentation::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkBoxRepresentation.h:339
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkBoxRepresentation::PlanePoints
vtkPoints * PlanePoints
Definition: vtkBoxRepresentation.h:362
vtkWidgetRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkBoxRepresentation::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkBoxRepresentation.h:336
vtkBoxRepresentation::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkBoxRepresentation.h:321
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