VTK
vtkImplicitPlaneRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImplicitPlaneRepresentation.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 =========================================================================*/
41 #ifndef vtkImplicitPlaneRepresentation_h
42 #define vtkImplicitPlaneRepresentation_h
43 
44 #include "vtkInteractionWidgetsModule.h" // For export macro
46 
47 class vtkActor;
48 class vtkPolyDataMapper;
49 class vtkCellPicker;
50 class vtkConeSource;
51 class vtkLineSource;
52 class vtkSphereSource;
53 class vtkTubeFilter;
54 class vtkPlane;
55 class vtkCutter;
56 class vtkProperty;
57 class vtkImageData;
58 class vtkOutlineFilter;
59 class vtkFeatureEdges;
60 class vtkPolyData;
62 class vtkTransform;
63 class vtkBox;
64 class vtkLookupTable;
65 
66 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
67 {
68 public:
73 
75 
79  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
81 
83 
86  void SetOrigin(double x, double y, double z);
87  void SetOrigin(double x[3]);
88  double* GetOrigin();
89  void GetOrigin(double xyz[3]);
91 
93 
96  void SetNormal(double x, double y, double z);
97  void SetNormal(double x[3]);
98  void SetNormalToCamera();
99  double* GetNormal();
100  void GetNormal(double xyz[3]);
102 
104 
111  void SetNormalToXAxis(int);
112  vtkGetMacro(NormalToXAxis,int);
113  vtkBooleanMacro(NormalToXAxis,int);
114  void SetNormalToYAxis(int);
115  vtkGetMacro(NormalToYAxis,int);
116  vtkBooleanMacro(NormalToYAxis,int);
117  void SetNormalToZAxis(int);
118  vtkGetMacro(NormalToZAxis,int);
119  vtkBooleanMacro(NormalToZAxis,int);
121 
123 
128  virtual void SetLockNormalToCamera(int);
129  vtkGetMacro(LockNormalToCamera,int);
130  vtkBooleanMacro(LockNormalToCamera,int);
132 
134 
138  vtkSetMacro(Tubing,int);
139  vtkGetMacro(Tubing,int);
140  vtkBooleanMacro(Tubing,int);
142 
144 
150  void SetDrawPlane(int plane);
151  vtkGetMacro(DrawPlane,int);
152  vtkBooleanMacro(DrawPlane,int);
154 
156 
160  vtkSetMacro(OutlineTranslation,int);
161  vtkGetMacro(OutlineTranslation,int);
162  vtkBooleanMacro(OutlineTranslation,int);
164 
166 
170  vtkSetMacro(OutsideBounds,int);
171  vtkGetMacro(OutsideBounds,int);
172  vtkBooleanMacro(OutsideBounds,int);
174 
176 
182  vtkSetVector6Macro(WidgetBounds, double);
183  vtkGetVector6Macro(WidgetBounds, double);
185 
187 
194  vtkSetMacro(ConstrainToWidgetBounds,int);
195  vtkGetMacro(ConstrainToWidgetBounds,int);
196  vtkBooleanMacro(ConstrainToWidgetBounds,int);
198 
200 
203  vtkSetMacro(ScaleEnabled,int);
204  vtkGetMacro(ScaleEnabled,int);
205  vtkBooleanMacro(ScaleEnabled,int);
207 
212  void GetPolyData(vtkPolyData *pd);
213 
218  vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
219 
227  void GetPlane(vtkPlane *plane);
228 
234  void SetPlane(vtkPlane *plane);
235 
240  void UpdatePlacement(void);
241 
243 
246  vtkGetObjectMacro(NormalProperty,vtkProperty);
247  vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
249 
251 
255  vtkGetObjectMacro(PlaneProperty,vtkProperty);
256  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
258 
260 
263  vtkGetObjectMacro(OutlineProperty,vtkProperty);
264  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
266 
268 
272  vtkGetObjectMacro(EdgesProperty,vtkProperty);
274 
275 
278  void SetEdgeColor(vtkLookupTable*);
279  void SetEdgeColor(double, double, double);
280  void SetEdgeColor(double x[3]);
282 
284 
289  vtkSetClampMacro(BumpDistance,double,0.000001,1);
290  vtkGetMacro(BumpDistance,double);
292 
301  void BumpPlane(int dir, double factor);
302 
309  void PushPlane(double distance);
310 
312 
315  int ComputeInteractionState(int X, int Y, int modify=0) VTK_OVERRIDE;
316  void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
317  void BuildRepresentation() VTK_OVERRIDE;
318  void StartWidgetInteraction(double eventPos[2]) VTK_OVERRIDE;
319  void WidgetInteraction(double newEventPos[2]) VTK_OVERRIDE;
320  void EndWidgetInteraction(double newEventPos[2]) VTK_OVERRIDE;
322 
323 
326  double *GetBounds() VTK_OVERRIDE;
327  void GetActors(vtkPropCollection *pc) VTK_OVERRIDE;
328  void ReleaseGraphicsResources(vtkWindow*) VTK_OVERRIDE;
329  int RenderOpaqueGeometry(vtkViewport*) VTK_OVERRIDE;
330  int RenderTranslucentPolygonalGeometry(vtkViewport*) VTK_OVERRIDE;
331  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
333 
334  // Manage the state of the widget
336  {
337  Outside=0,
343  Scaling
344  };
345 
347 
356  vtkSetClampMacro(InteractionState,int,Outside,Scaling);
358 
360 
364  virtual void SetRepresentationState(int);
365  vtkGetMacro(RepresentationState, int);
367 
368 protected:
370  ~vtkImplicitPlaneRepresentation() VTK_OVERRIDE;
371 
372  int RepresentationState;
373 
374  // Keep track of event positions
375  double LastEventPosition[3];
376 
377  // Controlling ivars
378  int NormalToXAxis;
379  int NormalToYAxis;
380  int NormalToZAxis;
381 
382  // Locking normal to camera
383  int LockNormalToCamera;
384 
385  // Controlling the push operation
386  double BumpDistance;
387 
388  // The actual plane which is being manipulated
389  vtkPlane *Plane;
390 
391  // The bounding box is represented by a single voxel image data
394  vtkPolyDataMapper *OutlineMapper;
395  vtkActor *OutlineActor;
396  void HighlightOutline(int highlight);
397  int OutlineTranslation; //whether the outline can be moved
398  int ScaleEnabled; //whether the widget can be scaled
399  int OutsideBounds; //whether the widget can be moved outside input's bounds
400  double WidgetBounds[6];
401  int ConstrainToWidgetBounds;
402 
403  // The cut plane is produced with a vtkCutter
404  vtkCutter *Cutter;
405  vtkPolyDataMapper *CutMapper;
406  vtkActor *CutActor;
407  int DrawPlane;
408  void HighlightPlane(int highlight);
409 
410  // Optional tubes are represented by extracting boundary edges and tubing
412  vtkTubeFilter *EdgesTuber;
413  vtkPolyDataMapper *EdgesMapper;
414  vtkActor *EdgesActor;
415  int Tubing; //control whether tubing is on
416 
417  // The + normal cone
418  vtkConeSource *ConeSource;
419  vtkPolyDataMapper *ConeMapper;
420  vtkActor *ConeActor;
421  void HighlightNormal(int highlight);
422 
423  // The + normal line
424  vtkLineSource *LineSource;
425  vtkPolyDataMapper *LineMapper;
426  vtkActor *LineActor;
427 
428  // The - normal cone
429  vtkConeSource *ConeSource2;
430  vtkPolyDataMapper *ConeMapper2;
431  vtkActor *ConeActor2;
432 
433  // The - normal line
434  vtkLineSource *LineSource2;
435  vtkPolyDataMapper *LineMapper2;
436  vtkActor *LineActor2;
437 
438  // The origin positioning handle
440  vtkPolyDataMapper *SphereMapper;
441  vtkActor *SphereActor;
442 
443  // Do the picking
444  vtkCellPicker *Picker;
445 
446  // Register internal Pickers within PickingManager
447  void RegisterPickers() VTK_OVERRIDE;
448 
449  // Transform the normal (used for rotation)
451 
452  // Methods to manipulate the plane
453  void Rotate(double X, double Y, double *p1, double *p2, double *vpn);
454  void TranslatePlane(double *p1, double *p2);
455  void TranslateOutline(double *p1, double *p2);
456  void TranslateOrigin(double *p1, double *p2);
457  void Push(double *p1, double *p2);
458  void Scale(double *p1, double *p2, double X, double Y);
459  void SizeHandles();
460 
461  // Properties used to control the appearance of selected objects and
462  // the manipulator in general.
463  vtkProperty *NormalProperty;
464  vtkProperty *SelectedNormalProperty;
465  vtkProperty *PlaneProperty;
466  vtkProperty *SelectedPlaneProperty;
467  vtkProperty *OutlineProperty;
468  vtkProperty *SelectedOutlineProperty;
469  vtkProperty *EdgesProperty;
470  void CreateDefaultProperties();
471 
472  void GeneratePlane();
473 
474  // Support GetBounds() method
475  vtkBox *BoundingBox;
476 
477 private:
479  void operator=(const vtkImplicitPlaneRepresentation&) VTK_DELETE_FUNCTION;
480 };
481 
482 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:69
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
virtual int ComputeInteractionState(int X, int Y, int modify=0)
abstract specification for Viewports
Definition: vtkViewport.h:47
represent surface properties of a geometric object
Definition: vtkProperty.h:64
map scalar values into colors via a lookup table
generate polygonal cone
Definition: vtkConeSource.h:44
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 ...
an ordered list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
create wireframe outline for arbitrary data set
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
filter that generates tubes around lines
Definition: vtkTubeFilter.h:83
a simple class to control print indentation
Definition: vtkIndent.h:39
a class defining the representation for a vtkImplicitPlaneWidget2
extract boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
perform various plane computations
Definition: vtkPlane.h:37
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
create a line defined by two end points
Definition: vtkLineSource.h:42
map vtkPolyData to graphics primitives
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
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
Transform
Definition: ADIOSDefs.h:39