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);
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  virtual void PlaceWidget(double bounds[6]);
196  virtual void BuildRepresentation();
197  virtual int ComputeInteractionState(int X, int Y, int modify=0);
198  virtual void StartWidgetInteraction(double e[2]);
199  virtual void WidgetInteraction(double e[2]);
200  virtual double *GetBounds();
202 
204 
207  virtual void ReleaseGraphicsResources(vtkWindow*);
208  virtual int RenderOpaqueGeometry(vtkViewport*);
210  virtual int HasTranslucentPolygonalGeometry();
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:
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  virtual void RegisterPickers();
271 
272  // Transform the hexahedral points (used for rotations)
274 
275  // Support GetBounds() method
277 
278  // Properties used to control the appearance of selected objects and
279  // the manipulator in general.
286  virtual void CreateDefaultProperties();
287 
288  // Control the orientation of the normals
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
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
vtkProperty * SelectedHandleProperty
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
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:64
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
vtkProperty * SelectedFaceProperty
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
dynamic, self-adjusting array of double
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
create a polygonal sphere centered at the origin
virtual double * GetBounds()
Methods to make this class behave as a vtkProp.
Superclass for algorithms that produce only polydata as output.
virtual int HasTranslucentPolygonalGeometry()
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
virtual void WidgetInteraction(double newEventPos[2])
vtkPolyDataMapper * HexFaceMapper
vtkSphereSource ** HandleGeometry
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkProperty * SelectedOutlineProperty
create a line defined by two end points
Definition: vtkLineSource.h:42
map vtkPolyData to graphics primitives
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
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
vtkDoubleArray * PlaneNormals
void OutlineCursorWiresOn()
Control the representation of the outline.
vtkCellPicker * HandlePicker
void PrintSelf(ostream &os, vtkIndent indent)
Standard methods for instances of this class.
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
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
void OutlineFaceWiresOff()
Control the representation of the outline.
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkPolyDataMapper * OutlineMapper