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
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:42
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkWidgetRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double eventPos[2])
Definition: vtkWidgetRepresentation.h:130
vtkWidgetRepresentation.h
vtkBoxRepresentation::PlaneNormals
vtkDoubleArray * PlaneNormals
Definition: vtkBoxRepresentation.h:307
vtkBoxRepresentation::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxRepresentation.h:285
vtkBoxRepresentation
a class defining the representation for the vtkBoxWidget2
Definition: vtkBoxRepresentation.h:62
vtkPointHandleRepresentation3D
represent the position of a point in 3D space
Definition: vtkPointHandleRepresentation3D.h:43
vtkBoxRepresentation::OutlineCursorWires
int OutlineCursorWires
Definition: vtkBoxRepresentation.h:291
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkBoxRepresentation::OutlineMapper
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxRepresentation.h:259
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:54
vtkBoxRepresentation::OutlinePolyData
vtkPolyData * OutlinePolyData
Definition: vtkBoxRepresentation.h:260
vtkBoxRepresentation::Points
vtkPoints * Points
Definition: vtkBoxRepresentation.h:238
vtkX3D::dir
@ dir
Definition: vtkX3D.h:324
vtkBoxRepresentation::HexPicker
vtkCellPicker * HexPicker
Definition: vtkBoxRepresentation.h:264
vtkWidgetRepresentation::BuildRepresentation
virtual void BuildRepresentation()=0
vtkPlanes
implicit function for convex set of planes
Definition: vtkPlanes.h:54
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
vtkBoxRepresentation::HexActor
vtkActor * HexActor
Definition: vtkBoxRepresentation.h:235
vtkBoxRepresentation::HandleMapper
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxRepresentation.h:248
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkBoxRepresentation::Handle
vtkActor ** Handle
Definition: vtkBoxRepresentation.h:247
vtkBoxRepresentation::InsideOut
int InsideOut
Definition: vtkBoxRepresentation.h:289
vtkWidgetRepresentation::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkWidgetRepresentation.h:186
vtkWidgetRepresentation::GetBounds
virtual double * GetBounds()
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:181
vtkWidgetRepresentation::HasTranslucentPolygonalGeometry
virtual int HasTranslucentPolygonalGeometry()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkWidgetRepresentation.h:191
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:131
vtkBoxRepresentation::HexMapper
vtkPolyDataMapper * HexMapper
Definition: vtkBoxRepresentation.h:236
vtkBoxRepresentation::HexOutline
vtkActor * HexOutline
Definition: vtkBoxRepresentation.h:258
vtkBoxRepresentation::HexFacePolyData
vtkPolyData * HexFacePolyData
Definition: vtkBoxRepresentation.h:244
vtkBoxRepresentation::HexFaceMapper
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxRepresentation.h:243
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:46
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
vtkBoxRepresentation::Matrix
vtkMatrix4x4 * Matrix
Definition: vtkBoxRepresentation.h:308
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
vtkWidgetRepresentation::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkWidgetRepresentation::RenderOpaqueGeometry
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
Definition: vtkWidgetRepresentation.h:188
vtkBoxRepresentation::Translating
@ Translating
Definition: vtkBoxRepresentation.h:214
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:42
vtkBoxRepresentation::OutlineFaceWiresOn
void OutlineFaceWiresOn()
Definition: vtkBoxRepresentation.h:166
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkBoxRepresentation::HexPolyData
vtkPolyData * HexPolyData
Definition: vtkBoxRepresentation.h:237
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkWidgetRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:47
vtkWidgetRepresentation::PlaceWidget
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
The following is a suggested API for widget representations.
Definition: vtkWidgetRepresentation.h:129
vtkBoxRepresentation::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkBoxRepresentation.h:265
vtkBoxRepresentation::BoundingBox
vtkBox * BoundingBox
Definition: vtkBoxRepresentation.h:276
vtkBoxRepresentation::FaceProperty
vtkProperty * FaceProperty
Definition: vtkBoxRepresentation.h:282
vtkBox
implicit function for a bounding box
Definition: vtkBox.h:41
vtkBoxRepresentation::OutlineCursorWiresOff
void OutlineCursorWiresOff()
Definition: vtkBoxRepresentation.h:179
vtkBoxRepresentation::SelectedFaceProperty
vtkProperty * SelectedFaceProperty
Definition: vtkBoxRepresentation.h:283
vtkBoxRepresentation::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkBoxRepresentation.h:249
vtkBoxRepresentation::CurrentHexFace
int CurrentHexFace
Definition: vtkBoxRepresentation.h:266
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkBoxRepresentation::OutlineCursorWiresOn
void OutlineCursorWiresOn()
Definition: vtkBoxRepresentation.h:178
vtkBoxRepresentation::Transform
vtkTransform * Transform
Definition: vtkBoxRepresentation.h:273
vtkWidgetRepresentation::RenderTranslucentPolygonalGeometry
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
Definition: vtkWidgetRepresentation.h:189
vtkBoxRepresentation::HexFace
vtkActor * HexFace
Definition: vtkBoxRepresentation.h:242
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:41
vtkBoxRepresentation::OutlineFaceWires
int OutlineFaceWires
Definition: vtkBoxRepresentation.h:290
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:64
vtkBoxRepresentation::LastPicker
vtkCellPicker * LastPicker
Definition: vtkBoxRepresentation.h:267
vtkBoxRepresentation::OutlineFaceWiresOff
void OutlineFaceWiresOff()
Definition: vtkBoxRepresentation.h:167
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
vtkBoxRepresentation::HandleProperty
vtkProperty * HandleProperty
Definition: vtkBoxRepresentation.h:280
vtkBoxRepresentation::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkBoxRepresentation.h:284
vtkBoxRepresentation::PlanePoints
vtkPoints * PlanePoints
Definition: vtkBoxRepresentation.h:306
vtkWidgetRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkBoxRepresentation::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkBoxRepresentation.h:281
vtkBoxRepresentation::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkBoxRepresentation.h:263
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:44