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 =========================================================================*/
42 #ifndef vtkImplicitCylinderRepresentation_h
43 #define vtkImplicitCylinderRepresentation_h
44 
45 #include "vtkInteractionWidgetsModule.h" // For export macro
47 
48 class vtkActor;
49 class vtkPolyDataMapper;
50 class vtkCellPicker;
51 class vtkConeSource;
52 class vtkLineSource;
53 class vtkSphereSource;
54 class vtkTubeFilter;
55 class vtkCylinder;
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 #define VTK_MAX_CYL_RESOLUTION 2048
67 
68 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitCylinderRepresentation : public vtkWidgetRepresentation
69 {
70 public:
75 
77 
81  void PrintSelf(ostream& os, vtkIndent indent) override;
83 
85 
89  void SetCenter(double x, double y, double z);
90  void SetCenter(double x[3]);
91  double* GetCenter() VTK_SIZEHINT(3);
92  void GetCenter(double xyz[3]);
94 
96 
100  void SetAxis(double x, double y, double z);
101  void SetAxis(double a[3]);
102  double* GetAxis() VTK_SIZEHINT(3);
103  void GetAxis(double a[3]);
105 
107 
111  void SetRadius(double r);
112  double GetRadius();
114 
116 
123  vtkSetClampMacro(MinRadius,double,0.001,0.25);
124  vtkGetMacro(MinRadius,double);
125  vtkSetClampMacro(MaxRadius,double,0.25,VTK_FLOAT_MAX);
126  vtkGetMacro(MaxRadius,double);
128 
130 
137  void SetAlongXAxis(vtkTypeBool);
138  vtkGetMacro(AlongXAxis,vtkTypeBool);
139  vtkBooleanMacro(AlongXAxis,vtkTypeBool);
140  void SetAlongYAxis(vtkTypeBool);
141  vtkGetMacro(AlongYAxis,vtkTypeBool);
142  vtkBooleanMacro(AlongYAxis,vtkTypeBool);
143  void SetAlongZAxis(vtkTypeBool);
144  vtkGetMacro(AlongZAxis,vtkTypeBool);
145  vtkBooleanMacro(AlongZAxis,vtkTypeBool);
147 
149 
155  void SetDrawCylinder(vtkTypeBool drawCyl);
156  vtkGetMacro(DrawCylinder,vtkTypeBool);
157  vtkBooleanMacro(DrawCylinder,vtkTypeBool);
159 
161 
167  vtkSetClampMacro(Resolution,int,8,VTK_MAX_CYL_RESOLUTION);
168  vtkGetMacro(Resolution,int);
170 
172 
177  vtkSetMacro(Tubing,vtkTypeBool);
178  vtkGetMacro(Tubing,vtkTypeBool);
179  vtkBooleanMacro(Tubing,vtkTypeBool);
181 
183 
187  vtkSetMacro(OutlineTranslation,vtkTypeBool);
188  vtkGetMacro(OutlineTranslation,vtkTypeBool);
189  vtkBooleanMacro(OutlineTranslation,vtkTypeBool);
191 
193 
197  vtkSetMacro(OutsideBounds,vtkTypeBool);
198  vtkGetMacro(OutsideBounds,vtkTypeBool);
199  vtkBooleanMacro(OutsideBounds,vtkTypeBool);
201 
203 
209  vtkSetVector6Macro(WidgetBounds, double);
210  vtkGetVector6Macro(WidgetBounds, double);
212 
214 
222  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
223  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
224  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
226 
228 
231  vtkSetMacro(ScaleEnabled, vtkTypeBool);
232  vtkGetMacro(ScaleEnabled, vtkTypeBool);
233  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
235 
242  void GetCylinder(vtkCylinder *cyl);
243 
248  void GetPolyData(vtkPolyData *pd);
249 
254  void UpdatePlacement(void);
255 
257 
260  vtkGetObjectMacro(AxisProperty,vtkProperty);
261  vtkGetObjectMacro(SelectedAxisProperty,vtkProperty);
263 
265 
269  vtkGetObjectMacro(CylinderProperty,vtkProperty);
270  vtkGetObjectMacro(SelectedCylinderProperty,vtkProperty);
272 
274 
277  vtkGetObjectMacro(OutlineProperty,vtkProperty);
278  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
280 
282 
286  vtkGetObjectMacro(EdgesProperty,vtkProperty);
288 
289 
292  void SetEdgeColor(vtkLookupTable*);
293  void SetEdgeColor(double, double, double);
294  void SetEdgeColor(double x[3]);
296 
298 
301  int ComputeInteractionState(int X, int Y, int modify=0) override;
302  void PlaceWidget(double bounds[6]) override;
303  void BuildRepresentation() override;
304  void StartWidgetInteraction(double eventPos[2]) override;
305  void WidgetInteraction(double newEventPos[2]) override;
306  void EndWidgetInteraction(double newEventPos[2]) override;
308 
310 
313  double *GetBounds() override;
314  void GetActors(vtkPropCollection *pc) override;
315  void ReleaseGraphicsResources(vtkWindow*) override;
316  int RenderOpaqueGeometry(vtkViewport*) override;
317  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
318  vtkTypeBool HasTranslucentPolygonalGeometry() override;
320 
322 
327  vtkSetClampMacro(BumpDistance,double,0.000001,1);
328  vtkGetMacro(BumpDistance,double);
330 
338  void BumpCylinder(int dir, double factor);
339 
346  void PushCylinder(double distance);
347 
348  // Manage the state of the widget
350  {
351  Outside=0,
358  TranslatingCenter
359  };
360 
362 
371  vtkSetClampMacro(InteractionState,int,Outside,TranslatingCenter);
373 
375 
379  virtual void SetRepresentationState(int);
380  vtkGetMacro(RepresentationState, int);
382 
383  /*
384  * Register internal Pickers within PickingManager
385  */
386  void RegisterPickers() override;
387 
388 protected:
391 
393 
394  // Keep track of event positions
395  double LastEventPosition[3];
396 
397  // Control the radius
398  double MinRadius;
399  double MaxRadius;
400 
401  // Controlling the push operation
402  double BumpDistance;
403 
404  // Controlling ivars
408 
409  // The actual cylinder which is being manipulated
411 
412  // The facet resolution for rendering purposes.
414 
415  // The bounding box is represented by a single voxel image data
420  void HighlightOutline(int highlight);
421  vtkTypeBool OutlineTranslation; //whether the outline can be moved
422  vtkTypeBool ScaleEnabled; //whether the widget can be scaled
423  vtkTypeBool OutsideBounds; //whether the widget can be moved outside input's bounds
424  double WidgetBounds[6];
426 
427  // The cut cylinder is produced with a vtkCutter
432  void HighlightCylinder(int highlight);
433 
434  // Optional tubes are represented by extracting boundary edges and tubing
439  vtkTypeBool Tubing; //control whether tubing is on
440 
441  // The + normal cone (i.e., in positive direction along normal)
445  void HighlightNormal(int highlight);
446 
447  // The + normal line
451 
452  // The - normal cone
456 
457  // The - normal line
461 
462  // The center positioning handle
466 
467  // Do the picking
470 
471  // Transform the normal (used for rotation)
473 
474  // Methods to manipulate the cylinder
475  void Rotate(double X, double Y, double *p1, double *p2, double *vpn);
476  void TranslateCylinder(double *p1, double *p2);
477  void TranslateOutline(double *p1, double *p2);
478  void TranslateCenter(double *p1, double *p2);
479  void TranslateCenterOnAxis(double *p1, double *p2);
480  void ScaleRadius(double *p1, double *p2);
481  void AdjustRadius(double X, double Y, double *p1, double *p2);
482  void Scale(double *p1, double *p2, double X, double Y);
483  void SizeHandles();
484 
485  // Properties used to control the appearance of selected objects and
486  // the manipulator in general.
494  void CreateDefaultProperties();
495 
496  // Intersect oriented infinite cylinder against bounding box
497  void BuildCylinder();
498 
499  // Support GetBounds() method
501 
502 private:
504  void operator=(const vtkImplicitCylinderRepresentation&) = delete;
505 };
506 
507 #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:51
abstract specification for Viewports
Definition: vtkViewport.h:47
represent surface properties of a geometric object
Definition: vtkProperty.h:66
defining the representation for a vtkImplicitCylinderWidget
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
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
create wireframe outline for arbitrary data set
create a polygonal sphere centered at the origin
#define VTK_FLOAT_MAX
Definition: vtkType.h:167
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
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:45
#define VTK_SIZEHINT(...)
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
implicit function for a cylinder
Definition: vtkCylinder.h:44
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
#define VTK_MAX_CYL_RESOLUTION