VTK  9.3.1
vtkImplicitCylinderRepresentation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
30 #ifndef vtkImplicitCylinderRepresentation_h
31 #define vtkImplicitCylinderRepresentation_h
32 
33 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
34 #include "vtkInteractionWidgetsModule.h" // For export macro
35 #include "vtkLegacy.h" // for VTK_LEGACY_REMOVE
37 
38 VTK_ABI_NAMESPACE_BEGIN
39 class vtkActor;
40 class vtkPolyDataMapper;
41 class vtkCellPicker;
42 class vtkConeSource;
43 class vtkLineSource;
44 class vtkSphereSource;
45 class vtkTubeFilter;
46 class vtkCylinder;
47 class vtkProperty;
48 class vtkImageData;
49 class vtkOutlineFilter;
50 class vtkFeatureEdges;
51 class vtkPolyData;
53 class vtkTransform;
54 class vtkBox;
55 class vtkLookupTable;
56 
57 #define VTK_MAX_CYL_RESOLUTION 2048
58 
59 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitCylinderRepresentation
61 {
62 public:
67 
69 
73  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
77 
81  void SetCenter(double x, double y, double z);
82  void SetCenter(double x[3]);
83  double* GetCenter() VTK_SIZEHINT(3);
84  void GetCenter(double xyz[3]);
86 
88 
92  void SetAxis(double x, double y, double z);
93  void SetAxis(double a[3]);
94  double* GetAxis() VTK_SIZEHINT(3);
95  void GetAxis(double a[3]);
97 
99 
103  void SetRadius(double r);
104  double GetRadius();
106 
108 
115  vtkSetClampMacro(MinRadius, double, 0.001, 0.25);
116  vtkGetMacro(MinRadius, double);
117  vtkSetClampMacro(MaxRadius, double, 0.25, VTK_FLOAT_MAX);
118  vtkGetMacro(MaxRadius, double);
120 
122 
129  void SetAlongXAxis(vtkTypeBool);
130  vtkGetMacro(AlongXAxis, vtkTypeBool);
131  vtkBooleanMacro(AlongXAxis, vtkTypeBool);
132  void SetAlongYAxis(vtkTypeBool);
133  vtkGetMacro(AlongYAxis, vtkTypeBool);
134  vtkBooleanMacro(AlongYAxis, vtkTypeBool);
135  void SetAlongZAxis(vtkTypeBool);
136  vtkGetMacro(AlongZAxis, vtkTypeBool);
137  vtkBooleanMacro(AlongZAxis, vtkTypeBool);
139 
141 
147  void SetDrawCylinder(vtkTypeBool drawCyl);
148  vtkGetMacro(DrawCylinder, vtkTypeBool);
149  vtkBooleanMacro(DrawCylinder, vtkTypeBool);
151 
153 
159  vtkSetClampMacro(Resolution, int, 8, VTK_MAX_CYL_RESOLUTION);
160  vtkGetMacro(Resolution, int);
162 
164 
169  vtkSetMacro(Tubing, vtkTypeBool);
170  vtkGetMacro(Tubing, vtkTypeBool);
171  vtkBooleanMacro(Tubing, vtkTypeBool);
173 
175 
179  vtkSetMacro(OutlineTranslation, vtkTypeBool);
180  vtkGetMacro(OutlineTranslation, vtkTypeBool);
181  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
183 
185 
189  vtkSetMacro(OutsideBounds, vtkTypeBool);
190  vtkGetMacro(OutsideBounds, vtkTypeBool);
191  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
193 
195 
201  vtkSetVector6Macro(WidgetBounds, double);
202  vtkGetVector6Macro(WidgetBounds, double);
204 
206 
214  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
215  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
216  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
218 
220 
223  vtkSetMacro(ScaleEnabled, vtkTypeBool);
224  vtkGetMacro(ScaleEnabled, vtkTypeBool);
225  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
227 
234  void GetCylinder(vtkCylinder* cyl);
235 
240  void GetPolyData(vtkPolyData* pd);
241 
246  void UpdatePlacement();
247 
249 
252  vtkGetObjectMacro(AxisProperty, vtkProperty);
253  vtkGetObjectMacro(SelectedAxisProperty, vtkProperty);
255 
257 
261  vtkGetObjectMacro(CylinderProperty, vtkProperty);
262  vtkGetObjectMacro(SelectedCylinderProperty, vtkProperty);
264 
266 
269  vtkGetObjectMacro(OutlineProperty, vtkProperty);
270  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
272 
274 
278  vtkGetObjectMacro(EdgesProperty, vtkProperty);
280 
282 
287  void SetInteractionColor(double, double, double);
288  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
289  void SetHandleColor(double, double, double);
290  void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
291  void SetForegroundColor(double, double, double);
292  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
294 
296 
299  VTK_DEPRECATED_IN_9_3_0("Please use GetEdgesProperty or SetHandleColor instead.")
300  void SetEdgeColor(vtkLookupTable*) {}
301  VTK_DEPRECATED_IN_9_3_0("Please use GetEdgesProperty or SetHandleColor instead.")
302  void SetEdgeColor(double, double, double) {}
303  VTK_DEPRECATED_IN_9_3_0("Please use GetEdgesProperty or SetHandleColor instead.")
304  void SetEdgeColor(double[3]) {}
306 
308 
311  int ComputeInteractionState(int X, int Y, int modify = 0) override;
312  void PlaceWidget(double bounds[6]) override;
313  void BuildRepresentation() override;
314  void StartWidgetInteraction(double eventPos[2]) override;
315  void WidgetInteraction(double newEventPos[2]) override;
316  void EndWidgetInteraction(double newEventPos[2]) override;
318 
320 
323  double* GetBounds() override;
324  void GetActors(vtkPropCollection* pc) override;
325  void ReleaseGraphicsResources(vtkWindow*) override;
326  int RenderOpaqueGeometry(vtkViewport*) override;
330 
332 
337  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
338  vtkGetMacro(BumpDistance, double);
340 
348  void BumpCylinder(int dir, double factor);
349 
356  void PushCylinder(double distance);
357 
358  // Manage the state of the widget
360  {
361  Outside = 0,
368  TranslatingCenter
369  };
370 #if !defined(VTK_LEGACY_REMOVE)
371  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
373 #endif
374 
376 
385  vtkSetClampMacro(InteractionState, int, Outside, TranslatingCenter);
387 
389 
393  virtual void SetRepresentationState(int);
394  vtkGetMacro(RepresentationState, int);
396 
397  /*
398  * Register internal Pickers within PickingManager
399  */
400  void RegisterPickers() override;
401 
403 
407  vtkGetMacro(TranslationAxis, int);
408  vtkSetClampMacro(TranslationAxis, int, -1, 2);
410 
412 
415  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
416  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
417  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
418  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
420 
422 
425  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
427 
428 protected:
431 
433 
435 
436  // Keep track of event positions
437  double LastEventPosition[3];
438 
439  // Control the radius
440  double MinRadius;
441  double MaxRadius;
442 
443  // Controlling the push operation
444  double BumpDistance;
445 
446  // Controlling ivars
450 
451  // The actual cylinder which is being manipulated
453 
454  // The facet resolution for rendering purposes.
456 
457  // The bounding box is represented by a single voxel image data
462  void HighlightOutline(int highlight);
463  vtkTypeBool OutlineTranslation; // whether the outline can be moved
464  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
465  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
466  double WidgetBounds[6];
468 
469  // The cut cylinder is produced with a vtkCutter
474  void HighlightCylinder(int highlight);
475 
476  // Optional tubes are represented by extracting boundary edges and tubing
481  vtkTypeBool Tubing; // control whether tubing is on
482 
483  // The + normal cone (i.e., in positive direction along normal)
487  void HighlightNormal(int highlight);
488 
489  // The + normal line
493 
494  // The - normal cone
498 
499  // The - normal line
503 
504  // The center positioning handle
508 
509  // Do the picking
512 
513  // Transform the normal (used for rotation)
515 
516  // Methods to manipulate the cylinder
517  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
518  void TranslateCylinder(double* p1, double* p2);
519  void TranslateOutline(double* p1, double* p2);
520  void TranslateCenter(double* p1, double* p2);
521  void TranslateCenterOnAxis(double* p1, double* p2);
522  void ScaleRadius(double* p1, double* p2);
523  void AdjustRadius(double X, double Y, double* p1, double* p2);
524  void Scale(double* p1, double* p2, double X, double Y);
525  void SizeHandles();
526 
527  // Properties used to control the appearance of selected objects and
528  // the manipulator in general.
536  void CreateDefaultProperties();
537 
538  // Intersect oriented infinite cylinder against bounding box
539  void BuildCylinder();
540 
541  // Support GetBounds() method
543 
544 private:
546  void operator=(const vtkImplicitCylinderRepresentation&) = delete;
547 };
548 
549 VTK_ABI_NAMESPACE_END
550 #endif
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
virtual void EndWidgetInteraction(double newEventPos[2])
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
virtual void PlaceWidget(double vtkNotUsed(bounds)[6])
The following is a suggested API for widget representations.
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:56
virtual void StartWidgetInteraction(double eventPos[2])
#define VTK_DEPRECATED_IN_9_2_0(reason)
defining the representation for a vtkImplicitCylinderWidget
map scalar values into colors via a lookup table
void SetForegroundColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cylinder) and their color during inte...
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
generate polygonal cone
Definition: vtkConeSource.h:33
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
abstract class defines interface between the widget and widget representation classes ...
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
double * GetBounds() override
Methods to make this class behave as a vtkProp.
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
create wireframe outline for an arbitrary data set or composite dataset
create a polygonal sphere centered at the origin
#define VTK_DEPRECATED_IN_9_3_0(reason)
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
#define VTK_FLOAT_MAX
Definition: vtkType.h:152
Superclass for algorithms that produce only polydata as output.
filter that generates tubes around lines
Definition: vtkTubeFilter.h:74
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
void SetInteractionColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cylinder) and their color during inte...
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
virtual void WidgetInteraction(double newEventPos[2])
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
#define VTK_SIZEHINT(...)
create a line defined by two end points
Definition: vtkLineSource.h:52
map vtkPolyData to graphics primitives
void SetHandleColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cylinder) and their color during inte...
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:61
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes...
implicit function for a cylinder
Definition: vtkCylinder.h:36
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:30
#define VTK_MAX_CYL_RESOLUTION