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 vtkPlanes;
54 class vtkBox;
55 class vtkDoubleArray;
56 class vtkMatrix4x4;
57 
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 
86 
92  vtkSetMacro(InsideOut,vtkTypeBool);
93  vtkGetMacro(InsideOut,vtkTypeBool);
94  vtkBooleanMacro(InsideOut,vtkTypeBool);
96 
104  virtual void GetTransform(vtkTransform *t);
105 
112  virtual void SetTransform(vtkTransform* t);
113 
124  void GetPolyData(vtkPolyData *pd);
125 
127 
132  vtkGetObjectMacro(HandleProperty,vtkProperty);
133  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
135 
137 
142  vtkGetObjectMacro(FaceProperty,vtkProperty);
143  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
145 
147 
152  vtkGetObjectMacro(OutlineProperty,vtkProperty);
153  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
155 
157 
161  void SetOutlineFaceWires(int);
162  vtkGetMacro(OutlineFaceWires,int);
163  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
164  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
166 
168 
173  void SetOutlineCursorWires(int);
174  vtkGetMacro(OutlineCursorWires,int);
175  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
176  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
178 
180 
184  virtual void HandlesOn();
185  virtual void HandlesOff();
187 
189 
192  void PlaceWidget(double bounds[6]) override;
193  void BuildRepresentation() override;
194  int ComputeInteractionState(int X, int Y, int modify=0) override;
195  void StartWidgetInteraction(double e[2]) override;
196  void WidgetInteraction(double e[2]) override;
197  double *GetBounds() VTK_SIZEHINT(6) override;
199 
201 
204  void ReleaseGraphicsResources(vtkWindow*) override;
205  int RenderOpaqueGeometry(vtkViewport*) override;
206  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
207  int HasTranslucentPolygonalGeometry() override;
209 
210  // Used to manage the state of the widget
211  enum {Outside=0,MoveF0,MoveF1,MoveF2,MoveF3,MoveF4,MoveF5,Translating,Rotating,Scaling};
212 
222  void SetInteractionState(int state);
223 
224 protected:
226  ~vtkBoxRepresentation() override;
227 
228  // Manage how the representation appears
229  double LastEventPosition[3];
230 
231  // the hexahedron (6 faces)
235  vtkPoints *Points; //used by others as well
236  double N[6][3]; //the normals of the faces
237 
238  // A face of the hexahedron
242 
243  // glyphs representing hot spots (e.g., handles)
247  virtual void PositionHandles();
248  int HighlightHandle(vtkProp *prop); //returns cell id
249  void HighlightFace(int cellId);
250  void HighlightOutline(int highlight);
251  virtual void ComputeNormals();
252  virtual void SizeHandles();
253 
254  // wireframe outline
258 
259  // Do the picking
265 
266  // Register internal Pickers within PickingManager
267  void RegisterPickers() override;
268 
269  // Transform the hexahedral points (used for rotations)
271 
272  // Support GetBounds() method
274 
275  // Properties used to control the appearance of selected objects and
276  // the manipulator in general.
283  virtual void CreateDefaultProperties();
284 
285  // Control the orientation of the normals
289  void GenerateOutline();
290 
291  // Helper methods
292  virtual void Translate(double *p1, double *p2);
293  virtual void Scale(double *p1, double *p2, int X, int Y);
294  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
295  void MovePlusXFace(double *p1, double *p2);
296  void MoveMinusXFace(double *p1, double *p2);
297  void MovePlusYFace(double *p1, double *p2);
298  void MoveMinusYFace(double *p1, double *p2);
299  void MovePlusZFace(double *p1, double *p2);
300  void MoveMinusZFace(double *p1, double *p2);
301 
302  // Internal ivars for performance
306 
307  //"dir" is the direction in which the face can be moved i.e. the axis passing
308  //through the center
309  void MoveFace(double *p1, double *p2, double *dir,
310  double *x1, double *x2, double *x3, double *x4,
311  double *x5);
312  //Helper method to obtain the direction in which the face is to be moved.
313  //Handles special cases where some of the scale factors are 0.
314  void GetDirection(const double Nx[3],const double Ny[3],
315  const double Nz[3], double dir[3]);
316 
317 
318 private:
320  void operator=(const vtkBoxRepresentation&) = delete;
321 };
322 
323 #endif
vtkProperty * SelectedHandleProperty
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
vtkPolyDataMapper * HexMapper
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
virtual int ComputeInteractionState(int X, int Y, int modify=0)
represent the position of a point in 3D space
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:60
virtual void StartWidgetInteraction(double eventPos[2])
implicit function for convex set of planes
Definition: vtkPlanes.h:48
a class defining the representation for the vtkBoxWidget2
vtkProperty * SelectedFaceProperty
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
abstract class defines interface between the widget and widget representation classes
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
double * GetBounds() override
Methods to make this class behave as a vtkProp.
dynamic, self-adjusting array of double
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkPolyDataMapper ** HandleMapper
virtual void WidgetInteraction(double newEventPos[2])
vtkPolyDataMapper * HexFaceMapper
vtkSphereSource ** HandleGeometry
#define VTK_SIZEHINT(...)
vtkProperty * SelectedOutlineProperty
create a line defined by two end points
Definition: vtkLineSource.h:36
map vtkPolyData to graphics primitives
void OutlineFaceWiresOn()
Control the representation of the outline.
void OutlineCursorWiresOff()
Control the representation of the outline.
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
The following is a suggested API for widget representations.
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkDoubleArray * PlaneNormals
void OutlineCursorWiresOn()
Control the representation of the outline.
vtkCellPicker * HandlePicker
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
implicit function for a bounding box
Definition: vtkBox.h:38
void OutlineFaceWiresOff()
Control the representation of the outline.
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkPolyDataMapper * OutlineMapper