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 
41 #include "vtkInteractionWidgetsModule.h" // For export macro
43 
44 class vtkActor;
45 class vtkPolyDataMapper;
46 class vtkLineSource;
47 class vtkSphereSource;
48 class vtkCellPicker;
49 class vtkProperty;
50 class vtkPolyData;
51 class vtkPoints;
54 class vtkTransform;
55 class vtkPlanes;
56 class vtkBox;
57 class vtkDoubleArray;
58 class vtkMatrix4x4;
59 
60 
62 {
63 public:
65  static vtkBoxRepresentation *New();
66 
68 
70  void PrintSelf(ostream& os, vtkIndent indent);
72 
79  void GetPlanes(vtkPlanes *planes);
80 
82 
86  vtkSetMacro(InsideOut,int);
87  vtkGetMacro(InsideOut,int);
88  vtkBooleanMacro(InsideOut,int);
90 
96  virtual void GetTransform(vtkTransform *t);
97 
102  virtual void SetTransform(vtkTransform* t);
103 
113  void GetPolyData(vtkPolyData *pd);
114 
116 
118  vtkGetObjectMacro(HandleProperty,vtkProperty);
119  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
121 
123 
125  vtkGetObjectMacro(FaceProperty,vtkProperty);
126  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
128 
130 
132  vtkGetObjectMacro(OutlineProperty,vtkProperty);
133  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
135 
137 
139  void SetOutlineFaceWires(int);
140  vtkGetMacro(OutlineFaceWires,int);
141  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
142  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
144 
146 
149  void SetOutlineCursorWires(int);
150  vtkGetMacro(OutlineCursorWires,int);
151  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
152  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
154 
156 
158  virtual void HandlesOn();
159  virtual void HandlesOff();
161 
163 
164  virtual void PlaceWidget(double bounds[6]);
165  virtual void BuildRepresentation();
166  virtual int ComputeInteractionState(int X, int Y, int modify=0);
167  virtual void StartWidgetInteraction(double e[2]);
168  virtual void WidgetInteraction(double e[2]);
169  virtual double *GetBounds();
171 
173 
174  virtual void ReleaseGraphicsResources(vtkWindow*);
175  virtual int RenderOpaqueGeometry(vtkViewport*);
177  virtual int HasTranslucentPolygonalGeometry();
179 
180  // Used to manage the state of the widget
181  enum {Outside=0,MoveF0,MoveF1,MoveF2,MoveF3,MoveF4,MoveF5,Translating,Rotating,Scaling};
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  // Register internal Pickers within PickingManager
235  virtual void RegisterPickers();
236 
237  // Transform the hexahedral points (used for rotations)
239 
240  // Support GetBounds() method
242 
243  // Properties used to control the appearance of selected objects and
244  // the manipulator in general.
251  virtual void CreateDefaultProperties();
252 
253  // Control the orientation of the normals
257  void GenerateOutline();
258 
259  // Helper methods
260  virtual void Translate(double *p1, double *p2);
261  virtual void Scale(double *p1, double *p2, int X, int Y);
262  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
263  void MovePlusXFace(double *p1, double *p2);
264  void MoveMinusXFace(double *p1, double *p2);
265  void MovePlusYFace(double *p1, double *p2);
266  void MoveMinusYFace(double *p1, double *p2);
267  void MovePlusZFace(double *p1, double *p2);
268  void MoveMinusZFace(double *p1, double *p2);
269 
270  // Internal ivars for performance
274 
275  //"dir" is the direction in which the face can be moved i.e. the axis passing
276  //through the center
277  void MoveFace(double *p1, double *p2, double *dir,
278  double *x1, double *x2, double *x3, double *x4,
279  double *x5);
280  //Helper method to obtain the direction in which the face is to be moved.
281  //Handles special cases where some of the scale factors are 0.
282  void GetDirection(const double Nx[3],const double Ny[3],
283  const double Nz[3], double dir[3]);
284 
285 
286 private:
287  vtkBoxRepresentation(const vtkBoxRepresentation&); //Not implemented
288  void operator=(const vtkBoxRepresentation&); //Not implemented
289 };
290 
291 #endif
vtkProperty * SelectedHandleProperty
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
vtkPolyDataMapper * HexMapper
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
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:46
represent surface properties of a geometric object
Definition: vtkProperty.h:63
virtual void StartWidgetInteraction(double eventPos[2])
implicit function for convex set of planes
Definition: vtkPlanes.h:53
a class defining the representation for the vtkBoxWidget2
vtkProperty * SelectedFaceProperty
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
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:36
#define VTKINTERACTIONWIDGETS_EXPORT
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:38
virtual void RegisterPickers()
vtkPolyDataMapper ** HandleMapper
virtual void WidgetInteraction(double newEventPos[2])
vtkPolyDataMapper * HexFaceMapper
vtkSphereSource ** HandleGeometry
vtkProperty * SelectedOutlineProperty
create a line defined by two end points
Definition: vtkLineSource.h:41
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:68
vtkDoubleArray * PlaneNormals
vtkCellPicker * HandlePicker
void PrintSelf(ostream &os, vtkIndent indent)
static vtkObject * New()
implicit function for a bounding box
Definition: vtkBox.h:40
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkPolyDataMapper * OutlineMapper