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 =========================================================================*/
36 #ifndef vtkBoxRepresentation_h
37 #define vtkBoxRepresentation_h
38 
39 #include "vtkInteractionWidgetsModule.h" // For export macro
41 
42 class vtkActor;
43 class vtkPolyDataMapper;
44 class vtkLineSource;
45 class vtkSphereSource;
46 class vtkCellPicker;
47 class vtkProperty;
48 class vtkPolyData;
49 class vtkPoints;
52 class vtkTransform;
53 class vtkPlane;
54 class vtkPlanes;
55 class vtkBox;
56 class vtkDoubleArray;
57 class vtkMatrix4x4;
58 
59 
60 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxRepresentation : public vtkWidgetRepresentation
61 {
62 public:
66  static vtkBoxRepresentation *New();
67 
69 
73  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
84  void GetPlanes(vtkPlanes *planes);
85 
86  // Get the underlying planes used by this rep
87  // this can be used as a cropping planes in vtkMapper
89  return this->Planes[i]; }
90 
92 
98  vtkSetMacro(InsideOut,vtkTypeBool);
99  vtkGetMacro(InsideOut,vtkTypeBool);
100  vtkBooleanMacro(InsideOut,vtkTypeBool);
102 
110  virtual void GetTransform(vtkTransform *t);
111 
118  virtual void SetTransform(vtkTransform* t);
119 
130  void GetPolyData(vtkPolyData *pd);
131 
133 
138  vtkGetObjectMacro(HandleProperty,vtkProperty);
139  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
141 
143 
148  vtkGetObjectMacro(FaceProperty,vtkProperty);
149  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
151 
153 
158  vtkGetObjectMacro(OutlineProperty,vtkProperty);
159  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
161 
163 
167  void SetOutlineFaceWires(int);
168  vtkGetMacro(OutlineFaceWires,int);
169  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
170  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
172 
174 
179  void SetOutlineCursorWires(int);
180  vtkGetMacro(OutlineCursorWires,int);
181  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
182  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
184 
186 
190  virtual void HandlesOn();
191  virtual void HandlesOff();
193 
195 
198  void PlaceWidget(double bounds[6]) override;
199  void BuildRepresentation() override;
200  int ComputeInteractionState(int X, int Y, int modify=0) override;
201  void StartWidgetInteraction(double e[2]) override;
202  void WidgetInteraction(double e[2]) override;
203  double *GetBounds() VTK_SIZEHINT(6) override;
204  void StartComplexInteraction(
206  vtkAbstractWidget *widget,
207  unsigned long event, void *calldata) override;
208  void ComplexInteraction(
210  vtkAbstractWidget *widget,
211  unsigned long event, void *calldata) override;
212  int ComputeComplexInteractionState(
214  vtkAbstractWidget *widget,
215  unsigned long event, void *calldata, int modify = 0) override;
216  void EndComplexInteraction(
218  vtkAbstractWidget *widget,
219  unsigned long event, void *calldata) override;
221 
223 
226  void ReleaseGraphicsResources(vtkWindow*) override;
227  int RenderOpaqueGeometry(vtkViewport*) override;
228  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
229  int HasTranslucentPolygonalGeometry() override;
231 
232  // Used to manage the state of the widget
233  enum {Outside=0,MoveF0,MoveF1,MoveF2,MoveF3,MoveF4,MoveF5,Translating,Rotating,Scaling};
234 
244  void SetInteractionState(int state);
245 
247 
251  vtkGetMacro(TwoPlaneMode, bool);
252  void SetTwoPlaneMode(bool);
254 
256 
260  vtkGetMacro(SnapToAxes, bool);
261  vtkSetMacro(SnapToAxes, bool);
263 
265 
269  void StepForward();
270  void StepBackward();
272 
273  /*
274  * Register internal Pickers within PickingManager
275  */
276  void RegisterPickers() override;
277 
278 protected:
280  ~vtkBoxRepresentation() override;
281 
282  // Manage how the representation appears
283  double LastEventPosition[3];
284  double LastEventOrientation[4];
285  double StartEventOrientation[4];
286  double SnappedEventOrientations[3][4];
287  bool SnappedOrientation[3];
289 
291 
292  // the hexahedron (6 faces)
296  vtkPoints *Points; //used by others as well
297  double N[6][3]; //the normals of the faces
298 
299  // A face of the hexahedron
303 
304  // glyphs representing hot spots (e.g., handles)
308  virtual void PositionHandles();
309  int HighlightHandle(vtkProp *prop); //returns cell id
310  void HighlightFace(int cellId);
311  void HighlightOutline(int highlight);
312  virtual void ComputeNormals();
313  virtual void SizeHandles();
314 
315  // wireframe outline
319 
320  // Do the picking
326 
327  // Transform the hexahedral points (used for rotations)
329 
330  // Support GetBounds() method
332 
333  // Properties used to control the appearance of selected objects and
334  // the manipulator in general.
341  virtual void CreateDefaultProperties();
342 
343  // Control the orientation of the normals
347  void GenerateOutline();
348 
349  // Helper methods
350  virtual void Translate(double *p1, double *p2);
351  virtual void Scale(double *p1, double *p2, int X, int Y);
352  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
353  void MovePlusXFace(double *p1, double *p2);
354  void MoveMinusXFace(double *p1, double *p2);
355  void MovePlusYFace(double *p1, double *p2);
356  void MoveMinusYFace(double *p1, double *p2);
357  void MovePlusZFace(double *p1, double *p2);
358  void MoveMinusZFace(double *p1, double *p2);
359  void UpdatePose(double *p1, double *d1, double *p2, double *d2);
360 
361  // Internal ivars for performance
365 
366  // The actual planes which are being manipulated
367  vtkPlane *Planes[6];
368 
369  //"dir" is the direction in which the face can be moved i.e. the axis passing
370  //through the center
371  void MoveFace(double *p1, double *p2, double *dir,
372  double *x1, double *x2, double *x3, double *x4,
373  double *x5);
374  //Helper method to obtain the direction in which the face is to be moved.
375  //Handles special cases where some of the scale factors are 0.
376  void GetDirection(const double Nx[3],const double Ny[3],
377  const double Nz[3], double dir[3]);
378 
379 
380 private:
382  void operator=(const vtkBoxRepresentation&) = delete;
383 };
384 
385 #endif
vtkProperty * SelectedHandleProperty
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
vtkPolyDataMapper * HexMapper
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
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:44
represent surface properties of a geometric object
Definition: vtkProperty.h:60
virtual void StartWidgetInteraction(double eventPos[2])
implicit function for convex set of planes
Definition: vtkPlanes.h:49
a class defining the representation for the vtkBoxWidget2
vtkProperty * SelectedFaceProperty
vtkPlane * GetUnderlyingPlane(int i)
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
abstract class defines interface between the widget and widget representation classes
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
double * GetBounds() override
Methods to make this class behave as a vtkProp.
dynamic, self-adjusting array of double
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
platform-independent render window interaction including picking and frame rate control.
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkPolyDataMapper ** HandleMapper
perform various plane computations
Definition: vtkPlane.h:31
virtual void WidgetInteraction(double newEventPos[2])
vtkPolyDataMapper * HexFaceMapper
vtkSphereSource ** HandleGeometry
#define VTK_SIZEHINT(...)
vtkProperty * SelectedOutlineProperty
define the API for widget / widget representation
create a line defined by two end points
Definition: vtkLineSource.h:36
map vtkPolyData to graphics primitives
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:63
vtkDoubleArray * PlaneNormals
void OutlineCursorWiresOn()
Control the representation of the outline.
vtkCellPicker * HandlePicker
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:38
void OutlineFaceWiresOff()
Control the representation of the outline.
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkPolyDataMapper * OutlineMapper