VTK
vtkImplicitCylinderRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImplicitCylinderRepresentation.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 vtkImplicitCylinderRepresentation_h
40 #define vtkImplicitCylinderRepresentation_h
41 
42 #include "vtkInteractionWidgetsModule.h" // For export macro
44 
45 class vtkActor;
46 class vtkPolyDataMapper;
47 class vtkCellPicker;
48 class vtkConeSource;
49 class vtkLineSource;
50 class vtkSphereSource;
51 class vtkTubeFilter;
52 class vtkCylinder;
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 #define VTK_MAX_CYL_RESOLUTION 2048
64 
65 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitCylinderRepresentation : public vtkWidgetRepresentation
66 {
67 public:
72 
74 
78  void PrintSelf(ostream& os, vtkIndent indent) override;
80 
82 
86  void SetCenter(double x, double y, double z);
87  void SetCenter(double x[3]);
88  double* GetCenter() VTK_SIZEHINT(3);
89  void GetCenter(double xyz[3]);
91 
93 
97  void SetAxis(double x, double y, double z);
98  void SetAxis(double a[3]);
99  double* GetAxis() VTK_SIZEHINT(3);
100  void GetAxis(double a[3]);
102 
104 
108  void SetRadius(double r);
109  double GetRadius();
111 
113 
120  vtkSetClampMacro(MinRadius,double,0.001,0.25);
121  vtkGetMacro(MinRadius,double);
122  vtkSetClampMacro(MaxRadius,double,0.25,VTK_FLOAT_MAX);
123  vtkGetMacro(MaxRadius,double);
125 
127 
134  void SetAlongXAxis(vtkTypeBool);
135  vtkGetMacro(AlongXAxis,vtkTypeBool);
136  vtkBooleanMacro(AlongXAxis,vtkTypeBool);
137  void SetAlongYAxis(vtkTypeBool);
138  vtkGetMacro(AlongYAxis,vtkTypeBool);
139  vtkBooleanMacro(AlongYAxis,vtkTypeBool);
140  void SetAlongZAxis(vtkTypeBool);
141  vtkGetMacro(AlongZAxis,vtkTypeBool);
142  vtkBooleanMacro(AlongZAxis,vtkTypeBool);
144 
146 
152  void SetDrawCylinder(vtkTypeBool drawCyl);
153  vtkGetMacro(DrawCylinder,vtkTypeBool);
154  vtkBooleanMacro(DrawCylinder,vtkTypeBool);
156 
158 
164  vtkSetClampMacro(Resolution,int,8,VTK_MAX_CYL_RESOLUTION);
165  vtkGetMacro(Resolution,int);
167 
169 
174  vtkSetMacro(Tubing,vtkTypeBool);
175  vtkGetMacro(Tubing,vtkTypeBool);
176  vtkBooleanMacro(Tubing,vtkTypeBool);
178 
180 
184  vtkSetMacro(OutlineTranslation,vtkTypeBool);
185  vtkGetMacro(OutlineTranslation,vtkTypeBool);
186  vtkBooleanMacro(OutlineTranslation,vtkTypeBool);
188 
190 
194  vtkSetMacro(OutsideBounds,vtkTypeBool);
195  vtkGetMacro(OutsideBounds,vtkTypeBool);
196  vtkBooleanMacro(OutsideBounds,vtkTypeBool);
198 
200 
206  vtkSetVector6Macro(WidgetBounds, double);
207  vtkGetVector6Macro(WidgetBounds, double);
209 
211 
219  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
220  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
221  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
223 
225 
228  vtkSetMacro(ScaleEnabled, vtkTypeBool);
229  vtkGetMacro(ScaleEnabled, vtkTypeBool);
230  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
232 
239  void GetCylinder(vtkCylinder *cyl);
240 
245  void GetPolyData(vtkPolyData *pd);
246 
251  void UpdatePlacement(void);
252 
254 
257  vtkGetObjectMacro(AxisProperty,vtkProperty);
258  vtkGetObjectMacro(SelectedAxisProperty,vtkProperty);
260 
262 
266  vtkGetObjectMacro(CylinderProperty,vtkProperty);
267  vtkGetObjectMacro(SelectedCylinderProperty,vtkProperty);
269 
271 
274  vtkGetObjectMacro(OutlineProperty,vtkProperty);
275  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
277 
279 
283  vtkGetObjectMacro(EdgesProperty,vtkProperty);
285 
286 
289  void SetEdgeColor(vtkLookupTable*);
290  void SetEdgeColor(double, double, double);
291  void SetEdgeColor(double x[3]);
293 
295 
298  int ComputeInteractionState(int X, int Y, int modify=0) override;
299  void PlaceWidget(double bounds[6]) override;
300  void BuildRepresentation() override;
301  void StartWidgetInteraction(double eventPos[2]) override;
302  void WidgetInteraction(double newEventPos[2]) override;
303  void EndWidgetInteraction(double newEventPos[2]) override;
305 
307 
310  double *GetBounds() override;
311  void GetActors(vtkPropCollection *pc) override;
312  void ReleaseGraphicsResources(vtkWindow*) override;
313  int RenderOpaqueGeometry(vtkViewport*) override;
314  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
315  int HasTranslucentPolygonalGeometry() override;
317 
319 
324  vtkSetClampMacro(BumpDistance,double,0.000001,1);
325  vtkGetMacro(BumpDistance,double);
327 
335  void BumpCylinder(int dir, double factor);
336 
343  void PushCylinder(double distance);
344 
345  // Manage the state of the widget
347  {
348  Outside=0,
355  TranslatingCenter
356  };
357 
359 
368  vtkSetClampMacro(InteractionState,int,Outside,TranslatingCenter);
370 
372 
376  virtual void SetRepresentationState(int);
377  vtkGetMacro(RepresentationState, int);
379 
380 protected:
383 
385 
386  // Keep track of event positions
387  double LastEventPosition[3];
388 
389  // Control the radius
390  double MinRadius;
391  double MaxRadius;
392 
393  // Controlling the push operation
394  double BumpDistance;
395 
396  // Controlling ivars
400 
401  // The actual cylinder which is being manipulated
403 
404  // The facet resolution for rendering purposes.
406 
407  // The bounding box is represented by a single voxel image data
412  void HighlightOutline(int highlight);
413  vtkTypeBool OutlineTranslation; //whether the outline can be moved
414  vtkTypeBool ScaleEnabled; //whether the widget can be scaled
415  vtkTypeBool OutsideBounds; //whether the widget can be moved outside input's bounds
416  double WidgetBounds[6];
418 
419  // The cut cylinder is produced with a vtkCutter
424  void HighlightCylinder(int highlight);
425 
426  // Optional tubes are represented by extracting boundary edges and tubing
431  vtkTypeBool Tubing; //control whether tubing is on
432 
433  // The + normal cone (i.e., in positive direction along normal)
437  void HighlightNormal(int highlight);
438 
439  // The + normal line
443 
444  // The - normal cone
448 
449  // The - normal line
453 
454  // The center positioning handle
458 
459  // Do the picking
462 
463  // Register internal Pickers within PickingManager
464  void RegisterPickers() override;
465 
466  // Transform the normal (used for rotation)
468 
469  // Methods to manipulate the cylinder
470  void Rotate(double X, double Y, double *p1, double *p2, double *vpn);
471  void TranslateCylinder(double *p1, double *p2);
472  void TranslateOutline(double *p1, double *p2);
473  void TranslateCenter(double *p1, double *p2);
474  void TranslateCenterOnAxis(double *p1, double *p2);
475  void ScaleRadius(double *p1, double *p2);
476  void AdjustRadius(double X, double Y, double *p1, double *p2);
477  void Scale(double *p1, double *p2, double X, double Y);
478  void SizeHandles();
479 
480  // Properties used to control the appearance of selected objects and
481  // the manipulator in general.
489  void CreateDefaultProperties();
490 
491  // Intersect oriented infinite cylinder against bounding box
492  void BuildCylinder();
493 
494  // Support GetBounds() method
496 
497 private:
499  void operator=(const vtkImplicitCylinderRepresentation&) = delete;
500 };
501 
502 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:60
defining the representation for a vtkImplicitCylinderWidget
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
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
create wireframe outline for arbitrary data set
create a polygonal sphere centered at the origin
#define VTK_FLOAT_MAX
Definition: vtkType.h:165
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
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
extract boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
#define VTK_SIZEHINT(...)
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
implicit function for a cylinder
Definition: vtkCylinder.h:41
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
#define VTK_MAX_CYL_RESOLUTION