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 =========================================================================*/
38 #ifndef __vtkBoxRepresentation_h
39 #define __vtkBoxRepresentation_h
40 
42 
43 class vtkActor;
44 class vtkPolyDataMapper;
45 class vtkLineSource;
46 class vtkSphereSource;
47 class vtkCellPicker;
48 class vtkProperty;
49 class vtkPolyData;
50 class vtkPoints;
53 class vtkTransform;
54 class vtkPlanes;
55 class vtkBox;
56 class vtkDoubleArray;
57 class vtkMatrix4x4;
58 
59 
61 {
62 public:
64  static vtkBoxRepresentation *New();
65 
67 
69  void PrintSelf(ostream& os, vtkIndent indent);
71 
78  void GetPlanes(vtkPlanes *planes);
79 
81 
85  vtkSetMacro(InsideOut,int);
86  vtkGetMacro(InsideOut,int);
87  vtkBooleanMacro(InsideOut,int);
89 
95  virtual void GetTransform(vtkTransform *t);
96 
101  virtual void SetTransform(vtkTransform* t);
102 
112  void GetPolyData(vtkPolyData *pd);
113 
115 
117  vtkGetObjectMacro(HandleProperty,vtkProperty);
118  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
120 
122 
124  vtkGetObjectMacro(FaceProperty,vtkProperty);
125  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
127 
129 
131  vtkGetObjectMacro(OutlineProperty,vtkProperty);
132  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
134 
136 
138  void SetOutlineFaceWires(int);
139  vtkGetMacro(OutlineFaceWires,int);
140  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
141  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
143 
145 
148  void SetOutlineCursorWires(int);
149  vtkGetMacro(OutlineCursorWires,int);
150  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
151  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
153 
155 
157  virtual void HandlesOn();
158  virtual void HandlesOff();
160 
162 
163  virtual void PlaceWidget(double bounds[6]);
164  virtual void BuildRepresentation();
165  virtual int ComputeInteractionState(int X, int Y, int modify=0);
166  virtual void StartWidgetInteraction(double e[2]);
167  virtual void WidgetInteraction(double e[2]);
168  virtual double *GetBounds();
170 
172 
173  virtual void ReleaseGraphicsResources(vtkWindow*);
174  virtual int RenderOpaqueGeometry(vtkViewport*);
176  virtual int HasTranslucentPolygonalGeometry();
178 
179 //BTX - used to manage the state of the widget
180  enum {Outside=0,MoveF0,MoveF1,MoveF2,MoveF3,MoveF4,MoveF5,Translating,Rotating,Scaling};
181 //ETX
182 
190  void SetInteractionState(int state);
191 
192 protected:
195 
196  // Manage how the representation appears
197  double LastEventPosition[3];
198 
199  // the hexahedron (6 faces)
203  vtkPoints *Points; //used by others as well
204  double N[6][3]; //the normals of the faces
205 
206  // A face of the hexahedron
210 
211  // glyphs representing hot spots (e.g., handles)
215  virtual void PositionHandles();
216  int HighlightHandle(vtkProp *prop); //returns cell id
217  void HighlightFace(int cellId);
218  void HighlightOutline(int highlight);
219  virtual void ComputeNormals();
220  virtual void SizeHandles();
221 
222  // wireframe outline
226 
227  // Do the picking
233 
234  // Transform the hexahedral points (used for rotations)
236 
237  // Support GetBounds() method
239 
240  // Properties used to control the appearance of selected objects and
241  // the manipulator in general.
248  virtual void CreateDefaultProperties();
249 
250  // Control the orientation of the normals
254  void GenerateOutline();
255 
256  // Helper methods
257  virtual void Translate(double *p1, double *p2);
258  virtual void Scale(double *p1, double *p2, int X, int Y);
259  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
260  void MovePlusXFace(double *p1, double *p2);
261  void MoveMinusXFace(double *p1, double *p2);
262  void MovePlusYFace(double *p1, double *p2);
263  void MoveMinusYFace(double *p1, double *p2);
264  void MovePlusZFace(double *p1, double *p2);
265  void MoveMinusZFace(double *p1, double *p2);
266 
267  // Internal ivars for performance
271 
272  //"dir" is the direction in which the face can be moved i.e. the axis passing
273  //through the center
274  void MoveFace(double *p1, double *p2, double *dir,
275  double *x1, double *x2, double *x3, double *x4,
276  double *x5);
277  //Helper method to obtain the direction in which the face is to be moved.
278  //Handles special cases where some of the scale factors are 0.
279  void GetDirection(const double Nx[3],const double Ny[3],
280  const double Nz[3], double dir[3]);
281 
282 
283 private:
284  vtkBoxRepresentation(const vtkBoxRepresentation&); //Not implemented
285  void operator=(const vtkBoxRepresentation&); //Not implemented
286 };
287 
288 #endif
vtkProperty * SelectedHandleProperty
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
vtkPolyDataMapper * HexMapper
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:49
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:37
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:45
represent surface properties of a geometric object
Definition: vtkProperty.h:61
virtual void StartWidgetInteraction(double eventPos[2])
implicit function for convex set of planes
Definition: vtkPlanes.h:52
a class defining the representation for the vtkBoxWidget2
vtkProperty * SelectedFaceProperty
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:58
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:81
virtual void ReleaseGraphicsResources(vtkWindow *)
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
dynamic, self-adjusting array of double
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
virtual int HasTranslucentPolygonalGeometry()
a simple class to control print indentation
Definition: vtkIndent.h:37
vtkPolyDataMapper ** HandleMapper
virtual void WidgetInteraction(double newEventPos[2])
vtkPolyDataMapper * HexFaceMapper
vtkSphereSource ** HandleGeometry
#define VTK_WIDGETS_EXPORT
vtkProperty * SelectedOutlineProperty
create a line defined by two end points
Definition: vtkLineSource.h:34
map vtkPolyData to graphics primitives
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkDoubleArray * PlaneNormals
vtkCellPicker * HandlePicker
void PrintSelf(ostream &os, vtkIndent indent)
static vtkObject * New()
implicit function for a bounding box
Definition: vtkBox.h:39
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkPolyDataMapper * OutlineMapper