VTK  9.2.6
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 "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
46 #include "vtkInteractionWidgetsModule.h" // For export macro
48 
49 class vtkActor;
50 class vtkPolyDataMapper;
51 class vtkCellPicker;
52 class vtkConeSource;
53 class vtkLineSource;
54 class vtkSphereSource;
55 class vtkTubeFilter;
56 class vtkCylinder;
57 class vtkProperty;
58 class vtkImageData;
59 class vtkOutlineFilter;
60 class vtkFeatureEdges;
61 class vtkPolyData;
63 class vtkTransform;
64 class vtkBox;
65 class vtkLookupTable;
66 
67 #define VTK_MAX_CYL_RESOLUTION 2048
68 
69 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitCylinderRepresentation
71 {
72 public:
77 
79 
83  void PrintSelf(ostream& os, vtkIndent indent) override;
85 
87 
91  void SetCenter(double x, double y, double z);
92  void SetCenter(double x[3]);
93  double* GetCenter() VTK_SIZEHINT(3);
94  void GetCenter(double xyz[3]);
96 
98 
102  void SetAxis(double x, double y, double z);
103  void SetAxis(double a[3]);
104  double* GetAxis() VTK_SIZEHINT(3);
105  void GetAxis(double a[3]);
107 
109 
113  void SetRadius(double r);
114  double GetRadius();
116 
118 
125  vtkSetClampMacro(MinRadius, double, 0.001, 0.25);
126  vtkGetMacro(MinRadius, double);
127  vtkSetClampMacro(MaxRadius, double, 0.25, VTK_FLOAT_MAX);
128  vtkGetMacro(MaxRadius, double);
130 
132 
139  void SetAlongXAxis(vtkTypeBool);
140  vtkGetMacro(AlongXAxis, vtkTypeBool);
141  vtkBooleanMacro(AlongXAxis, vtkTypeBool);
142  void SetAlongYAxis(vtkTypeBool);
143  vtkGetMacro(AlongYAxis, vtkTypeBool);
144  vtkBooleanMacro(AlongYAxis, vtkTypeBool);
145  void SetAlongZAxis(vtkTypeBool);
146  vtkGetMacro(AlongZAxis, vtkTypeBool);
147  vtkBooleanMacro(AlongZAxis, vtkTypeBool);
149 
151 
157  void SetDrawCylinder(vtkTypeBool drawCyl);
158  vtkGetMacro(DrawCylinder, vtkTypeBool);
159  vtkBooleanMacro(DrawCylinder, vtkTypeBool);
161 
163 
169  vtkSetClampMacro(Resolution, int, 8, VTK_MAX_CYL_RESOLUTION);
170  vtkGetMacro(Resolution, int);
172 
174 
179  vtkSetMacro(Tubing, vtkTypeBool);
180  vtkGetMacro(Tubing, vtkTypeBool);
181  vtkBooleanMacro(Tubing, vtkTypeBool);
183 
185 
189  vtkSetMacro(OutlineTranslation, vtkTypeBool);
190  vtkGetMacro(OutlineTranslation, vtkTypeBool);
191  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
193 
195 
199  vtkSetMacro(OutsideBounds, vtkTypeBool);
200  vtkGetMacro(OutsideBounds, vtkTypeBool);
201  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
203 
205 
211  vtkSetVector6Macro(WidgetBounds, double);
212  vtkGetVector6Macro(WidgetBounds, double);
214 
216 
224  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
225  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
226  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
228 
230 
233  vtkSetMacro(ScaleEnabled, vtkTypeBool);
234  vtkGetMacro(ScaleEnabled, vtkTypeBool);
235  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
237 
244  void GetCylinder(vtkCylinder* cyl);
245 
250  void GetPolyData(vtkPolyData* pd);
251 
256  void UpdatePlacement(void);
257 
259 
262  vtkGetObjectMacro(AxisProperty, vtkProperty);
263  vtkGetObjectMacro(SelectedAxisProperty, vtkProperty);
265 
267 
271  vtkGetObjectMacro(CylinderProperty, vtkProperty);
272  vtkGetObjectMacro(SelectedCylinderProperty, vtkProperty);
274 
276 
279  vtkGetObjectMacro(OutlineProperty, vtkProperty);
280  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
282 
284 
288  vtkGetObjectMacro(EdgesProperty, vtkProperty);
291 
294  void SetEdgeColor(vtkLookupTable*);
295  void SetEdgeColor(double, double, double);
296  void SetEdgeColor(double c[3]);
298 
300 
303  int ComputeInteractionState(int X, int Y, int modify = 0) override;
304  void PlaceWidget(double bounds[6]) override;
305  void BuildRepresentation() override;
306  void StartWidgetInteraction(double eventPos[2]) override;
307  void WidgetInteraction(double newEventPos[2]) override;
308  void EndWidgetInteraction(double newEventPos[2]) override;
310 
312 
315  double* GetBounds() override;
316  void GetActors(vtkPropCollection* pc) override;
317  void ReleaseGraphicsResources(vtkWindow*) override;
318  int RenderOpaqueGeometry(vtkViewport*) override;
319  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
320  vtkTypeBool HasTranslucentPolygonalGeometry() override;
322 
324 
329  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
330  vtkGetMacro(BumpDistance, double);
332 
340  void BumpCylinder(int dir, double factor);
341 
348  void PushCylinder(double distance);
349 
350  // Manage the state of the widget
352  {
353  Outside = 0,
360  TranslatingCenter
361  };
362 #if !defined(VTK_LEGACY_REMOVE)
363  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
365 #endif
366 
368 
377  vtkSetClampMacro(InteractionState, int, Outside, TranslatingCenter);
379 
381 
385  virtual void SetRepresentationState(int);
386  vtkGetMacro(RepresentationState, int);
388 
389  /*
390  * Register internal Pickers within PickingManager
391  */
392  void RegisterPickers() override;
393 
395 
399  vtkGetMacro(TranslationAxis, int);
400  vtkSetClampMacro(TranslationAxis, int, -1, 2);
402 
404 
407  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
408  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
409  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
410  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
412 
414 
417  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
419 
420 protected:
423 
425 
427 
428  // Keep track of event positions
429  double LastEventPosition[3];
430 
431  // Control the radius
432  double MinRadius;
433  double MaxRadius;
434 
435  // Controlling the push operation
436  double BumpDistance;
437 
438  // Controlling ivars
442 
443  // The actual cylinder which is being manipulated
445 
446  // The facet resolution for rendering purposes.
448 
449  // The bounding box is represented by a single voxel image data
454  void HighlightOutline(int highlight);
455  vtkTypeBool OutlineTranslation; // whether the outline can be moved
456  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
457  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
458  double WidgetBounds[6];
460 
461  // The cut cylinder is produced with a vtkCutter
466  void HighlightCylinder(int highlight);
467 
468  // Optional tubes are represented by extracting boundary edges and tubing
473  vtkTypeBool Tubing; // control whether tubing is on
474 
475  // The + normal cone (i.e., in positive direction along normal)
479  void HighlightNormal(int highlight);
480 
481  // The + normal line
485 
486  // The - normal cone
490 
491  // The - normal line
495 
496  // The center positioning handle
500 
501  // Do the picking
504 
505  // Transform the normal (used for rotation)
507 
508  // Methods to manipulate the cylinder
509  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
510  void TranslateCylinder(double* p1, double* p2);
511  void TranslateOutline(double* p1, double* p2);
512  void TranslateCenter(double* p1, double* p2);
513  void TranslateCenterOnAxis(double* p1, double* p2);
514  void ScaleRadius(double* p1, double* p2);
515  void AdjustRadius(double X, double Y, double* p1, double* p2);
516  void Scale(double* p1, double* p2, double X, double Y);
517  void SizeHandles();
518 
519  // Properties used to control the appearance of selected objects and
520  // the manipulator in general.
528  void CreateDefaultProperties();
529 
530  // Intersect oriented infinite cylinder against bounding box
531  void BuildCylinder();
532 
533  // Support GetBounds() method
535 
536 private:
538  void operator=(const vtkImplicitCylinderRepresentation&) = delete;
539 };
540 
541 #endif
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
void GetBounds(T a, double bds[6])
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
abstract specification for Viewports
Definition: vtkViewport.h:55
represent surface properties of a geometric object
Definition: vtkProperty.h:67
#define VTK_DEPRECATED_IN_9_2_0(reason)
defining the representation for a vtkImplicitCylinderWidget
map scalar values into colors via a lookup table
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
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:90
abstract class defines interface between the widget and widget representation classes ...
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
create wireframe outline for an arbitrary data set or composite dataset
create a polygonal sphere centered at the origin
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
Superclass for algorithms that produce only polydata as output.
filter that generates tubes around lines
Definition: vtkTubeFilter.h:85
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
#define VTK_SIZEHINT(...)
create a line defined by two end points
Definition: vtkLineSource.h:63
map vtkPolyData to graphics primitives
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:72
implicit function for a cylinder
Definition: vtkCylinder.h:47
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