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 vtkPlane;
57 class vtkPlanes;
58 class vtkBox;
59 class vtkDoubleArray;
60 class vtkMatrix4x4;
61 
62 
63 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxRepresentation : public vtkWidgetRepresentation
64 {
65 public:
69  static vtkBoxRepresentation *New();
70 
72 
76  void PrintSelf(ostream& os, vtkIndent indent) override;
78 
87  void GetPlanes(vtkPlanes *planes);
88 
89  // Get the underlying planes used by this rep
90  // this can be used as a cropping planes in vtkMapper
92  return this->Planes[i]; }
93 
95 
101  vtkSetMacro(InsideOut,vtkTypeBool);
102  vtkGetMacro(InsideOut,vtkTypeBool);
103  vtkBooleanMacro(InsideOut,vtkTypeBool);
105 
113  virtual void GetTransform(vtkTransform *t);
114 
121  virtual void SetTransform(vtkTransform* t);
122 
133  void GetPolyData(vtkPolyData *pd);
134 
136 
141  vtkGetObjectMacro(HandleProperty,vtkProperty);
142  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
144 
146 
151  vtkGetObjectMacro(FaceProperty,vtkProperty);
152  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
154 
156 
161  vtkGetObjectMacro(OutlineProperty,vtkProperty);
162  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
164 
166 
170  void SetOutlineFaceWires(int);
171  vtkGetMacro(OutlineFaceWires,int);
172  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
173  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
175 
177 
182  void SetOutlineCursorWires(int);
183  vtkGetMacro(OutlineCursorWires,int);
184  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
185  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
187 
189 
193  virtual void HandlesOn();
194  virtual void HandlesOff();
196 
198 
201  void PlaceWidget(double bounds[6]) override;
202  void BuildRepresentation() override;
203  int ComputeInteractionState(int X, int Y, int modify=0) override;
204  void StartWidgetInteraction(double e[2]) override;
205  void WidgetInteraction(double e[2]) override;
206  double *GetBounds() VTK_SIZEHINT(6) override;
209  vtkAbstractWidget *widget,
210  unsigned long event, void *calldata) override;
211  void ComplexInteraction(
213  vtkAbstractWidget *widget,
214  unsigned long event, void *calldata) override;
217  vtkAbstractWidget *widget,
218  unsigned long event, void *calldata, int modify = 0) override;
221  vtkAbstractWidget *widget,
222  unsigned long event, void *calldata) override;
224 
226 
229  void ReleaseGraphicsResources(vtkWindow*) override;
230  int RenderOpaqueGeometry(vtkViewport*) override;
234 
235  // Used to manage the state of the widget
236  enum {Outside=0,MoveF0,MoveF1,MoveF2,MoveF3,MoveF4,MoveF5,Translating,Rotating,Scaling};
237 
247  void SetInteractionState(int state);
248 
250 
254  vtkGetMacro(TwoPlaneMode, bool);
255  void SetTwoPlaneMode(bool);
257 
259 
263  vtkGetMacro(SnapToAxes, bool);
264  vtkSetMacro(SnapToAxes, bool);
266 
268 
272  void StepForward();
273  void StepBackward();
275 
276  /*
277  * Register internal Pickers within PickingManager
278  */
279  void RegisterPickers() override;
280 
281 protected:
283  ~vtkBoxRepresentation() override;
284 
285  // Manage how the representation appears
286  double LastEventPosition[3];
287  double LastEventOrientation[4];
288  double StartEventOrientation[4];
289  double SnappedEventOrientations[3][4];
290  bool SnappedOrientation[3];
292 
294 
295  // the hexahedron (6 faces)
299  vtkPoints *Points; //used by others as well
300  double N[6][3]; //the normals of the faces
301 
302  // A face of the hexahedron
306 
307  // glyphs representing hot spots (e.g., handles)
311  virtual void PositionHandles();
312  int HighlightHandle(vtkProp *prop); //returns cell id
313  void HighlightFace(int cellId);
314  void HighlightOutline(int highlight);
315  virtual void ComputeNormals();
316  virtual void SizeHandles();
317 
318  // wireframe outline
322 
323  // Do the picking
329 
330  // Transform the hexahedral points (used for rotations)
332 
333  // Support GetBounds() method
335 
336  // Properties used to control the appearance of selected objects and
337  // the manipulator in general.
344  virtual void CreateDefaultProperties();
345 
346  // Control the orientation of the normals
350  void GenerateOutline();
351 
352  // Helper methods
353  virtual void Translate(double *p1, double *p2);
354  virtual void Scale(double *p1, double *p2, int X, int Y);
355  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
356  void MovePlusXFace(double *p1, double *p2);
357  void MoveMinusXFace(double *p1, double *p2);
358  void MovePlusYFace(double *p1, double *p2);
359  void MoveMinusYFace(double *p1, double *p2);
360  void MovePlusZFace(double *p1, double *p2);
361  void MoveMinusZFace(double *p1, double *p2);
362  void UpdatePose(double *p1, double *d1, double *p2, double *d2);
363 
364  // Internal ivars for performance
368 
369  // The actual planes which are being manipulated
370  vtkPlane *Planes[6];
371 
372  //"dir" is the direction in which the face can be moved i.e. the axis passing
373  //through the center
374  void MoveFace(double *p1, double *p2, double *dir,
375  double *x1, double *x2, double *x3, double *x4,
376  double *x5);
377  //Helper method to obtain the direction in which the face is to be moved.
378  //Handles special cases where some of the scale factors are 0.
379  void GetDirection(const double Nx[3],const double Ny[3],
380  const double Nz[3], double dir[3]);
381 
382 
383 private:
385  void operator=(const vtkBoxRepresentation&) = delete;
386 };
387 
388 #endif
vtkProperty * SelectedHandleProperty
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
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: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:66
virtual void StartWidgetInteraction(double eventPos[2])
virtual int ComputeComplexInteractionState(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *callData, int modify=0)
implicit function for convex set of planes
Definition: vtkPlanes.h:55
a class defining the representation for the vtkBoxWidget2
vtkProperty * SelectedFaceProperty
virtual void ComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
virtual void EndComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
vtkPlane * GetUnderlyingPlane(int i)
virtual void StartComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
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:37
platform-independent render window interaction including picking and frame rate control.
create a polygonal sphere centered at the origin
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkPolyDataMapper ** HandleMapper
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
perform various plane computations
Definition: vtkPlane.h:37
virtual void WidgetInteraction(double newEventPos[2])
vtkPolyDataMapper * HexFaceMapper
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
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:42
map vtkPolyData to graphics primitives
void OutlineFaceWiresOn()
Control the representation of the outline.
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
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
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
void OutlineFaceWiresOff()
Control the representation of the outline.
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkPolyDataMapper * OutlineMapper