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 
61 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxRepresentation : public vtkWidgetRepresentation
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 //BTX - used to manage the state of the widget
181  enum {Outside=0,MoveF0,MoveF1,MoveF2,MoveF3,MoveF4,MoveF5,Translating,Rotating,Scaling};
182 //ETX
183 
191  void SetInteractionState(int state);
192 
193 protected:
196 
197  // Manage how the representation appears
198  double LastEventPosition[3];
199 
200  // the hexahedron (6 faces)
204  vtkPoints *Points; //used by others as well
205  double N[6][3]; //the normals of the faces
206 
207  // A face of the hexahedron
211 
212  // glyphs representing hot spots (e.g., handles)
216  virtual void PositionHandles();
217  int HighlightHandle(vtkProp *prop); //returns cell id
218  void HighlightFace(int cellId);
219  void HighlightOutline(int highlight);
220  virtual void ComputeNormals();
221  virtual void SizeHandles();
222 
223  // wireframe outline
227 
228  // Do the picking
234 
235  // Transform the hexahedral points (used for rotations)
237 
238  // Support GetBounds() method
240 
241  // Properties used to control the appearance of selected objects and
242  // the manipulator in general.
249  virtual void CreateDefaultProperties();
250 
251  // Control the orientation of the normals
255  void GenerateOutline();
256 
257  // Helper methods
258  virtual void Translate(double *p1, double *p2);
259  virtual void Scale(double *p1, double *p2, int X, int Y);
260  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
261  void MovePlusXFace(double *p1, double *p2);
262  void MoveMinusXFace(double *p1, double *p2);
263  void MovePlusYFace(double *p1, double *p2);
264  void MoveMinusYFace(double *p1, double *p2);
265  void MovePlusZFace(double *p1, double *p2);
266  void MoveMinusZFace(double *p1, double *p2);
267 
268  // Internal ivars for performance
272 
273  //"dir" is the direction in which the face can be moved i.e. the axis passing
274  //through the center
275  void MoveFace(double *p1, double *p2, double *dir,
276  double *x1, double *x2, double *x3, double *x4,
277  double *x5);
278  //Helper method to obtain the direction in which the face is to be moved.
279  //Handles special cases where some of the scale factors are 0.
280  void GetDirection(const double Nx[3],const double Ny[3],
281  const double Nz[3], double dir[3]);
282 
283 
284 private:
285  vtkBoxRepresentation(const vtkBoxRepresentation&); //Not implemented
286  void operator=(const vtkBoxRepresentation&); //Not implemented
287 };
288 
289 #endif