VTK  9.3.20240420
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 "vtkInteractionWidgetsModule.h" // For export macro
35#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
36
37VTK_ABI_NAMESPACE_BEGIN
38class vtkActor;
40class vtkCellPicker;
41class vtkConeSource;
42class vtkLineSource;
43class vtkSphereSource;
44class vtkTubeFilter;
45class vtkCylinder;
46class vtkProperty;
47class vtkImageData;
49class vtkFeatureEdges;
50class vtkPolyData;
52class vtkTransform;
53class vtkBox;
54class vtkLookupTable;
55
56#define VTK_MAX_CYL_RESOLUTION 2048
57
58class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkImplicitCylinderRepresentation
60{
61public:
66
68
72 void PrintSelf(ostream& os, vtkIndent indent) override;
74
76
80 void SetCenter(double x, double y, double z);
81 void SetCenter(double x[3]);
82 double* GetCenter() VTK_SIZEHINT(3);
83 void GetCenter(double xyz[3]);
85
87
91 void SetAxis(double x, double y, double z);
92 void SetAxis(double a[3]);
93 double* GetAxis() VTK_SIZEHINT(3);
94 void GetAxis(double a[3]);
96
98
102 void SetRadius(double r);
103 double GetRadius();
105
107
114 vtkSetClampMacro(MinRadius, double, 0.001, 0.25);
115 vtkGetMacro(MinRadius, double);
116 vtkSetClampMacro(MaxRadius, double, 0.25, VTK_FLOAT_MAX);
117 vtkGetMacro(MaxRadius, double);
119
121
128 void SetAlongXAxis(vtkTypeBool);
129 vtkGetMacro(AlongXAxis, vtkTypeBool);
130 vtkBooleanMacro(AlongXAxis, vtkTypeBool);
131 void SetAlongYAxis(vtkTypeBool);
132 vtkGetMacro(AlongYAxis, vtkTypeBool);
133 vtkBooleanMacro(AlongYAxis, vtkTypeBool);
134 void SetAlongZAxis(vtkTypeBool);
135 vtkGetMacro(AlongZAxis, vtkTypeBool);
136 vtkBooleanMacro(AlongZAxis, vtkTypeBool);
138
140
146 void SetDrawCylinder(vtkTypeBool drawCyl);
147 vtkGetMacro(DrawCylinder, vtkTypeBool);
148 vtkBooleanMacro(DrawCylinder, vtkTypeBool);
150
152
158 vtkSetClampMacro(Resolution, int, 8, VTK_MAX_CYL_RESOLUTION);
159 vtkGetMacro(Resolution, int);
161
163
168 vtkSetMacro(Tubing, vtkTypeBool);
169 vtkGetMacro(Tubing, vtkTypeBool);
170 vtkBooleanMacro(Tubing, vtkTypeBool);
172
174
178 vtkSetMacro(OutlineTranslation, vtkTypeBool);
179 vtkGetMacro(OutlineTranslation, vtkTypeBool);
180 vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
182
184
188 vtkSetMacro(OutsideBounds, vtkTypeBool);
189 vtkGetMacro(OutsideBounds, vtkTypeBool);
190 vtkBooleanMacro(OutsideBounds, vtkTypeBool);
192
194
200 vtkSetVector6Macro(WidgetBounds, double);
201 vtkGetVector6Macro(WidgetBounds, double);
203
205
213 vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
214 vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
215 vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
217
219
222 vtkSetMacro(ScaleEnabled, vtkTypeBool);
223 vtkGetMacro(ScaleEnabled, vtkTypeBool);
224 vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
226
233 void GetCylinder(vtkCylinder* cyl);
234
239 void GetPolyData(vtkPolyData* pd);
240
245 void UpdatePlacement();
246
248
251 vtkGetObjectMacro(AxisProperty, vtkProperty);
252 vtkGetObjectMacro(SelectedAxisProperty, vtkProperty);
254
256
260 vtkGetObjectMacro(CylinderProperty, vtkProperty);
261 vtkGetObjectMacro(SelectedCylinderProperty, vtkProperty);
263
265
268 vtkGetObjectMacro(OutlineProperty, vtkProperty);
269 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
271
273
277 vtkGetObjectMacro(EdgesProperty, vtkProperty);
279
281
286 void SetInteractionColor(double, double, double);
287 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
288 void SetHandleColor(double, double, double);
289 void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
290 void SetForegroundColor(double, double, double);
291 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
293
295
298 VTK_DEPRECATED_IN_9_3_0("Please use GetEdgesProperty or SetHandleColor instead.")
299 void SetEdgeColor(vtkLookupTable*) {}
300 VTK_DEPRECATED_IN_9_3_0("Please use GetEdgesProperty or SetHandleColor instead.")
301 void SetEdgeColor(double, double, double) {}
302 VTK_DEPRECATED_IN_9_3_0("Please use GetEdgesProperty or SetHandleColor instead.")
303 void SetEdgeColor(double[3]) {}
305
307
310 int ComputeInteractionState(int X, int Y, int modify = 0) override;
311 void PlaceWidget(double bounds[6]) override;
312 void BuildRepresentation() override;
313 void StartWidgetInteraction(double eventPos[2]) override;
314 void WidgetInteraction(double newEventPos[2]) override;
315 void EndWidgetInteraction(double newEventPos[2]) override;
317
319
322 double* GetBounds() override;
323 void GetActors(vtkPropCollection* pc) override;
329
331
336 vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
337 vtkGetMacro(BumpDistance, double);
339
347 void BumpCylinder(int dir, double factor);
348
355 void PushCylinder(double distance);
356
357 // Manage the state of the widget
359 {
360 Outside = 0,
367 TranslatingCenter
368 };
369
371
380 vtkSetClampMacro(InteractionState, int, Outside, TranslatingCenter);
382
384
388 virtual void SetRepresentationState(int);
389 vtkGetMacro(RepresentationState, int);
391
392 /*
393 * Register internal Pickers within PickingManager
394 */
395 void RegisterPickers() override;
396
398
402 vtkGetMacro(TranslationAxis, int);
403 vtkSetClampMacro(TranslationAxis, int, -1, 2);
405
407
410 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
411 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
412 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
413 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
415
417
420 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
422
423protected:
426
428
430
431 // Keep track of event positions
432 double LastEventPosition[3];
433
434 // Control the radius
435 double MinRadius;
436 double MaxRadius;
437
438 // Controlling the push operation
440
441 // Controlling ivars
445
446 // The actual cylinder which is being manipulated
448
449 // The facet resolution for rendering purposes.
451
452 // The bounding box is represented by a single voxel image data
457 void HighlightOutline(int highlight);
458 vtkTypeBool OutlineTranslation; // whether the outline can be moved
459 vtkTypeBool ScaleEnabled; // whether the widget can be scaled
460 vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
461 double WidgetBounds[6];
463
464 // The cut cylinder is produced with a vtkCutter
469 void HighlightCylinder(int highlight);
470
471 // Optional tubes are represented by extracting boundary edges and tubing
476 vtkTypeBool Tubing; // control whether tubing is on
477
478 // The + normal cone (i.e., in positive direction along normal)
482 void HighlightNormal(int highlight);
483
484 // The + normal line
488
489 // The - normal cone
493
494 // The - normal line
498
499 // The center positioning handle
503
504 // Do the picking
507
508 // Transform the normal (used for rotation)
510
511 // Methods to manipulate the cylinder
512 void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
513 void TranslateCylinder(double* p1, double* p2);
514 void TranslateOutline(double* p1, double* p2);
515 void TranslateCenter(double* p1, double* p2);
516 void TranslateCenterOnAxis(double* p1, double* p2);
517 void ScaleRadius(double* p1, double* p2);
518 void AdjustRadius(double X, double Y, double* p1, double* p2);
519 void Scale(double* p1, double* p2, double X, double Y);
521
522 // Properties used to control the appearance of selected objects and
523 // the manipulator in general.
532
533 // Intersect oriented infinite cylinder against bounding box
535
536 // Support GetBounds() method
538
539private:
541 void operator=(const vtkImplicitCylinderRepresentation&) = delete;
542};
543
544VTK_ABI_NAMESPACE_END
545#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
implicit function for a bounding box
Definition vtkBox.h:110
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
implicit function for a cylinder
Definition vtkCylinder.h:76
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
defining the representation for a vtkImplicitCylinderWidget
void HighlightOutline(int highlight)
void StartWidgetInteraction(double eventPos[2]) override
Methods to interface with the vtkImplicitCylinderWidget.
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting the rendering process.
void HighlightCylinder(int highlight)
void BumpCylinder(int dir, double factor)
Translate the cylinder in the direction of the view vector by the specified BumpDistance.
void HighlightNormal(int highlight)
void SetHandleColor(double, double, double)
Set the color of all the widgets handles (edges, axis, selected cylinder) and their color during inte...
void TranslateCylinder(double *p1, double *p2)
void TranslateCenterOnAxis(double *p1, double *p2)
void ScaleRadius(double *p1, double *p2)
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void AdjustRadius(double X, double Y, double *p1, double *p2)
void TranslateOutline(double *p1, double *p2)
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
void SetInteractionColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cylinder) and their color during inte...
void PlaceWidget(double bounds[6]) override
Methods to interface with the vtkImplicitCylinderWidget.
void SetCenter(double x, double y, double z)
Get the center of the cylinder.
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting the rendering process.
double * GetCenter()
Get the center of the cylinder.
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting the rendering process.
void GetActors(vtkPropCollection *pc) override
Methods supporting the rendering process.
void PushCylinder(double distance)
Push the cylinder the distance specified along the view vector.
static vtkImplicitCylinderRepresentation * New()
Instantiate the class.
void SetHandleColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cylinder) and their color during inte...
void Rotate(double X, double Y, double *p1, double *p2, double *vpn)
void BuildRepresentation() override
Methods to interface with the vtkImplicitCylinderWidget.
virtual void SetRepresentationState(int)
Sets the visual appearance of the representation based on the state it is in.
void EndWidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkImplicitCylinderWidget.
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
void WidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkImplicitCylinderWidget.
void Scale(double *p1, double *p2, double X, double Y)
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
void TranslateCenter(double *p1, double *p2)
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting the rendering process.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
void SetCenter(double x[3])
Get the center of the cylinder.
double * GetBounds() override
Methods supporting the rendering process.
void SetForegroundColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cylinder) and their color during inte...
void SetForegroundColor(double, double, double)
Set the color of all the widgets handles (edges, axis, selected cylinder) and their color during inte...
int ComputeInteractionState(int X, int Y, int modify=0) override
Methods to interface with the vtkImplicitCylinderWidget.
a simple class to control print indentation
Definition vtkIndent.h:108
create a line defined by two end points
map scalar values into colors via a lookup table
create wireframe outline for an arbitrary data set or composite dataset
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
an ordered list of Props
represent surface properties of a geometric object
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
filter that generates tubes around lines
abstract specification for Viewports
Definition vtkViewport.h:65
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_3_0(reason)
#define VTK_MAX_CYL_RESOLUTION
#define VTK_FLOAT_MAX
Definition vtkType.h:152
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO