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 =========================================================================*/
39 #ifndef vtkBoxRepresentation_h
40 #define vtkBoxRepresentation_h
41 
42 #include "vtkInteractionWidgetsModule.h" // For export macro
44 
45 class vtkActor;
46 class vtkPolyDataMapper;
47 class vtkLineSource;
48 class vtkSphereSource;
49 class vtkCellPicker;
50 class vtkProperty;
51 class vtkPolyData;
52 class vtkPoints;
55 class vtkTransform;
56 class vtkPlanes;
57 class vtkBox;
58 class vtkDoubleArray;
59 class vtkMatrix4x4;
60 
61 
62 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxRepresentation : public vtkWidgetRepresentation
63 {
64 public:
68  static vtkBoxRepresentation *New();
69 
71 
75  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
77 
86  void GetPlanes(vtkPlanes *planes);
87 
89 
95  vtkSetMacro(InsideOut,int);
96  vtkGetMacro(InsideOut,int);
97  vtkBooleanMacro(InsideOut,int);
99 
107  virtual void GetTransform(vtkTransform *t);
108 
115  virtual void SetTransform(vtkTransform* t);
116 
127  void GetPolyData(vtkPolyData *pd);
128 
130 
135  vtkGetObjectMacro(HandleProperty,vtkProperty);
136  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
138 
140 
145  vtkGetObjectMacro(FaceProperty,vtkProperty);
146  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
148 
150 
155  vtkGetObjectMacro(OutlineProperty,vtkProperty);
156  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
158 
160 
164  void SetOutlineFaceWires(int);
165  vtkGetMacro(OutlineFaceWires,int);
166  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
167  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
169 
171 
176  void SetOutlineCursorWires(int);
177  vtkGetMacro(OutlineCursorWires,int);
178  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
179  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
181 
183 
187  virtual void HandlesOn();
188  virtual void HandlesOff();
190 
192 
195  void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
196  void BuildRepresentation() VTK_OVERRIDE;
197  int ComputeInteractionState(int X, int Y, int modify=0) VTK_OVERRIDE;
198  void StartWidgetInteraction(double e[2]) VTK_OVERRIDE;
199  void WidgetInteraction(double e[2]) VTK_OVERRIDE;
200  double *GetBounds() VTK_OVERRIDE;
202 
204 
207  void ReleaseGraphicsResources(vtkWindow*) VTK_OVERRIDE;
208  int RenderOpaqueGeometry(vtkViewport*) VTK_OVERRIDE;
210  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
212 
213  // Used to manage the state of the widget
214  enum {Outside=0,MoveF0,MoveF1,MoveF2,MoveF3,MoveF4,MoveF5,Translating,Rotating,Scaling};
215 
225  void SetInteractionState(int state);
226 
227 protected:
229  ~vtkBoxRepresentation() VTK_OVERRIDE;
230 
231  // Manage how the representation appears
232  double LastEventPosition[3];
233 
234  // the hexahedron (6 faces)
238  vtkPoints *Points; //used by others as well
239  double N[6][3]; //the normals of the faces
240 
241  // A face of the hexahedron
245 
246  // glyphs representing hot spots (e.g., handles)
250  virtual void PositionHandles();
251  int HighlightHandle(vtkProp *prop); //returns cell id
252  void HighlightFace(int cellId);
253  void HighlightOutline(int highlight);
254  virtual void ComputeNormals();
255  virtual void SizeHandles();
256 
257  // wireframe outline
261 
262  // Do the picking
268 
269  // Register internal Pickers within PickingManager
270  void RegisterPickers() VTK_OVERRIDE;
271 
272  // Transform the hexahedral points (used for rotations)
274 
275  // Support GetBounds() method
276  vtkBox *BoundingBox;
277 
278  // Properties used to control the appearance of selected objects and
279  // the manipulator in general.
280  vtkProperty *HandleProperty;
281  vtkProperty *SelectedHandleProperty;
282  vtkProperty *FaceProperty;
283  vtkProperty *SelectedFaceProperty;
284  vtkProperty *OutlineProperty;
285  vtkProperty *SelectedOutlineProperty;
286  virtual void CreateDefaultProperties();
287 
288  // Control the orientation of the normals
289  int InsideOut;
290  int OutlineFaceWires;
291  int OutlineCursorWires;
292  void GenerateOutline();
293 
294  // Helper methods
295  virtual void Translate(double *p1, double *p2);
296  virtual void Scale(double *p1, double *p2, int X, int Y);
297  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
298  void MovePlusXFace(double *p1, double *p2);
299  void MoveMinusXFace(double *p1, double *p2);
300  void MovePlusYFace(double *p1, double *p2);
301  void MoveMinusYFace(double *p1, double *p2);
302  void MovePlusZFace(double *p1, double *p2);
303  void MoveMinusZFace(double *p1, double *p2);
304 
305  // Internal ivars for performance
306  vtkPoints *PlanePoints;
307  vtkDoubleArray *PlaneNormals;
308  vtkMatrix4x4 *Matrix;
309 
310  //"dir" is the direction in which the face can be moved i.e. the axis passing
311  //through the center
312  void MoveFace(double *p1, double *p2, double *dir,
313  double *x1, double *x2, double *x3, double *x4,
314  double *x5);
315  //Helper method to obtain the direction in which the face is to be moved.
316  //Handles special cases where some of the scale factors are 0.
317  void GetDirection(const double Nx[3],const double Ny[3],
318  const double Nz[3], double dir[3]);
319 
320 
321 private:
322  vtkBoxRepresentation(const vtkBoxRepresentation&) VTK_DELETE_FUNCTION;
323  void operator=(const vtkBoxRepresentation&) VTK_DELETE_FUNCTION;
324 };
325 
326 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
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:51
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
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:47
represent surface properties of a geometric object
Definition: vtkProperty.h:65
virtual void StartWidgetInteraction(double eventPos[2])
implicit function for convex set of planes
Definition: vtkPlanes.h:54
a class defining the representation for the vtkBoxWidget2
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
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
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
create a polygonal sphere centered at the origin
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
Superclass for algorithms that produce only polydata as output.
int HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkPolyDataMapper ** HandleMapper
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
virtual void WidgetInteraction(double newEventPos[2])
vtkPolyDataMapper * HexFaceMapper
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
vtkSphereSource ** HandleGeometry
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
create a line defined by two end points
Definition: vtkLineSource.h:42
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:69
void OutlineCursorWiresOn()
Control the representation of the outline.
vtkCellPicker * HandlePicker
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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:41
void OutlineFaceWiresOff()
Control the representation of the outline.
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkPolyDataMapper * OutlineMapper
Transform
Definition: ADIOSDefs.h:39