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 =========================================================================*/
38 #ifndef vtkImplicitPlaneRepresentation_h
39 #define vtkImplicitPlaneRepresentation_h
40 
41 #include "vtkInteractionWidgetsModule.h" // For export macro
43 
44 class vtkActor;
45 class vtkPolyDataMapper;
46 class vtkCellPicker;
47 class vtkConeSource;
48 class vtkLineSource;
49 class vtkSphereSource;
50 class vtkTubeFilter;
51 class vtkPlane;
52 class vtkCutter;
53 class vtkProperty;
54 class vtkImageData;
55 class vtkOutlineFilter;
56 class vtkFeatureEdges;
57 class vtkPolyData;
59 class vtkTransform;
60 class vtkBox;
61 class vtkLookupTable;
62 
63 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
64 {
65 public:
70 
72 
76  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
78 
80 
83  void SetOrigin(double x, double y, double z);
84  void SetOrigin(double x[3]);
85  double* GetOrigin();
86  void GetOrigin(double xyz[3]);
88 
90 
93  void SetNormal(double x, double y, double z);
94  void SetNormal(double x[3]);
95  void SetNormalToCamera();
96  double* GetNormal();
97  void GetNormal(double xyz[3]);
99 
101 
108  void SetNormalToXAxis(int);
109  vtkGetMacro(NormalToXAxis,int);
110  vtkBooleanMacro(NormalToXAxis,int);
111  void SetNormalToYAxis(int);
112  vtkGetMacro(NormalToYAxis,int);
113  vtkBooleanMacro(NormalToYAxis,int);
114  void SetNormalToZAxis(int);
115  vtkGetMacro(NormalToZAxis,int);
116  vtkBooleanMacro(NormalToZAxis,int);
118 
120 
125  virtual void SetLockNormalToCamera(int);
126  vtkGetMacro(LockNormalToCamera,int);
127  vtkBooleanMacro(LockNormalToCamera,int);
129 
131 
135  vtkSetMacro(Tubing,int);
136  vtkGetMacro(Tubing,int);
137  vtkBooleanMacro(Tubing,int);
139 
141 
147  void SetDrawPlane(int plane);
148  vtkGetMacro(DrawPlane,int);
149  vtkBooleanMacro(DrawPlane,int);
151 
153 
157  vtkSetMacro(OutlineTranslation,int);
158  vtkGetMacro(OutlineTranslation,int);
159  vtkBooleanMacro(OutlineTranslation,int);
161 
163 
167  vtkSetMacro(OutsideBounds,int);
168  vtkGetMacro(OutsideBounds,int);
169  vtkBooleanMacro(OutsideBounds,int);
171 
173 
179  vtkSetVector6Macro(WidgetBounds, double);
180  vtkGetVector6Macro(WidgetBounds, double);
182 
184 
191  vtkSetMacro(ConstrainToWidgetBounds,int);
192  vtkGetMacro(ConstrainToWidgetBounds,int);
193  vtkBooleanMacro(ConstrainToWidgetBounds,int);
195 
197 
200  vtkSetMacro(ScaleEnabled,int);
201  vtkGetMacro(ScaleEnabled,int);
202  vtkBooleanMacro(ScaleEnabled,int);
204 
209  void GetPolyData(vtkPolyData *pd);
210 
215  vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
216 
224  void GetPlane(vtkPlane *plane);
225 
231  void SetPlane(vtkPlane *plane);
232 
237  void UpdatePlacement(void);
238 
240 
243  vtkGetObjectMacro(NormalProperty,vtkProperty);
244  vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
246 
248 
252  vtkGetObjectMacro(PlaneProperty,vtkProperty);
253  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
255 
257 
260  vtkGetObjectMacro(OutlineProperty,vtkProperty);
261  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
263 
265 
269  vtkGetObjectMacro(EdgesProperty,vtkProperty);
271 
272 
275  void SetEdgeColor(vtkLookupTable*);
276  void SetEdgeColor(double, double, double);
277  void SetEdgeColor(double x[3]);
279 
281 
286  vtkSetClampMacro(BumpDistance,double,0.000001,1);
287  vtkGetMacro(BumpDistance,double);
289 
298  void BumpPlane(int dir, double factor);
299 
306  void PushPlane(double distance);
307 
309 
312  int ComputeInteractionState(int X, int Y, int modify=0) VTK_OVERRIDE;
313  void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
314  void BuildRepresentation() VTK_OVERRIDE;
315  void StartWidgetInteraction(double eventPos[2]) VTK_OVERRIDE;
316  void WidgetInteraction(double newEventPos[2]) VTK_OVERRIDE;
317  void EndWidgetInteraction(double newEventPos[2]) VTK_OVERRIDE;
319 
320 
323  double *GetBounds() VTK_OVERRIDE;
324  void GetActors(vtkPropCollection *pc) VTK_OVERRIDE;
325  void ReleaseGraphicsResources(vtkWindow*) VTK_OVERRIDE;
326  int RenderOpaqueGeometry(vtkViewport*) VTK_OVERRIDE;
327  int RenderTranslucentPolygonalGeometry(vtkViewport*) VTK_OVERRIDE;
328  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
330 
331  // Manage the state of the widget
333  {
334  Outside=0,
340  Scaling
341  };
342 
344 
353  vtkSetClampMacro(InteractionState,int,Outside,Scaling);
355 
357 
361  virtual void SetRepresentationState(int);
362  vtkGetMacro(RepresentationState, int);
364 
365 protected:
367  ~vtkImplicitPlaneRepresentation() VTK_OVERRIDE;
368 
369  int RepresentationState;
370 
371  // Keep track of event positions
372  double LastEventPosition[3];
373 
374  // Controlling ivars
375  int NormalToXAxis;
376  int NormalToYAxis;
377  int NormalToZAxis;
378 
379  // Locking normal to camera
380  int LockNormalToCamera;
381 
382  // Controlling the push operation
383  double BumpDistance;
384 
385  // The actual plane which is being manipulated
386  vtkPlane *Plane;
387 
388  // The bounding box is represented by a single voxel image data
391  vtkPolyDataMapper *OutlineMapper;
392  vtkActor *OutlineActor;
393  void HighlightOutline(int highlight);
394  int OutlineTranslation; //whether the outline can be moved
395  int ScaleEnabled; //whether the widget can be scaled
396  int OutsideBounds; //whether the widget can be moved outside input's bounds
397  double WidgetBounds[6];
398  int ConstrainToWidgetBounds;
399 
400  // The cut plane is produced with a vtkCutter
401  vtkCutter *Cutter;
402  vtkPolyDataMapper *CutMapper;
403  vtkActor *CutActor;
404  int DrawPlane;
405  void HighlightPlane(int highlight);
406 
407  // Optional tubes are represented by extracting boundary edges and tubing
409  vtkTubeFilter *EdgesTuber;
410  vtkPolyDataMapper *EdgesMapper;
411  vtkActor *EdgesActor;
412  int Tubing; //control whether tubing is on
413 
414  // The + normal cone
415  vtkConeSource *ConeSource;
416  vtkPolyDataMapper *ConeMapper;
417  vtkActor *ConeActor;
418  void HighlightNormal(int highlight);
419 
420  // The + normal line
421  vtkLineSource *LineSource;
422  vtkPolyDataMapper *LineMapper;
423  vtkActor *LineActor;
424 
425  // The - normal cone
426  vtkConeSource *ConeSource2;
427  vtkPolyDataMapper *ConeMapper2;
428  vtkActor *ConeActor2;
429 
430  // The - normal line
431  vtkLineSource *LineSource2;
432  vtkPolyDataMapper *LineMapper2;
433  vtkActor *LineActor2;
434 
435  // The origin positioning handle
437  vtkPolyDataMapper *SphereMapper;
438  vtkActor *SphereActor;
439 
440  // Do the picking
441  vtkCellPicker *Picker;
442 
443  // Register internal Pickers within PickingManager
444  void RegisterPickers() VTK_OVERRIDE;
445 
446  // Transform the normal (used for rotation)
448 
449  // Methods to manipulate the plane
450  void Rotate(double X, double Y, double *p1, double *p2, double *vpn);
451  void TranslatePlane(double *p1, double *p2);
452  void TranslateOutline(double *p1, double *p2);
453  void TranslateOrigin(double *p1, double *p2);
454  void Push(double *p1, double *p2);
455  void Scale(double *p1, double *p2, double X, double Y);
456  void SizeHandles();
457 
458  // Properties used to control the appearance of selected objects and
459  // the manipulator in general.
460  vtkProperty *NormalProperty;
461  vtkProperty *SelectedNormalProperty;
462  vtkProperty *PlaneProperty;
463  vtkProperty *SelectedPlaneProperty;
464  vtkProperty *OutlineProperty;
465  vtkProperty *SelectedOutlineProperty;
466  vtkProperty *EdgesProperty;
467  void CreateDefaultProperties();
468 
469  void GeneratePlane();
470 
471  // Support GetBounds() method
472  vtkBox *BoundingBox;
473 
474 private:
476  void operator=(const vtkImplicitPlaneRepresentation&) VTK_DELETE_FUNCTION;
477 };
478 
479 #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:63
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
virtual int ComputeInteractionState(int X, int Y, int modify=0)
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:58
map scalar values into colors via a lookup table
generate polygonal cone
Definition: vtkConeSource.h:38
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 ...
an ordered list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
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:77
a simple class to control print indentation
Definition: vtkIndent.h:33
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:39
perform various plane computations
Definition: vtkPlane.h:31
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:36
map vtkPolyData to graphics primitives
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
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:38
Transform
Definition: ADIOSDefs.h:39