VTK  9.3.0
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
38VTK_ABI_NAMESPACE_BEGIN
39class vtkActor;
41class vtkCellPicker;
42class vtkConeSource;
43class vtkLineSource;
44class vtkSphereSource;
45class vtkTubeFilter;
46class vtkCylinder;
47class vtkProperty;
48class vtkImageData;
50class vtkFeatureEdges;
51class vtkPolyData;
53class vtkTransform;
54class vtkBox;
55class vtkLookupTable;
56
57#define VTK_MAX_CYL_RESOLUTION 2048
58
59class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitCylinderRepresentation
61{
62public:
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;
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
428protected:
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
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);
526
527 // Properties used to control the appearance of selected objects and
528 // the manipulator in general.
537
538 // Intersect oriented infinite cylinder against bounding box
540
541 // Support GetBounds() method
543
544private:
546 void operator=(const vtkImplicitCylinderRepresentation&) = delete;
547};
548
549VTK_ABI_NAMESPACE_END
550#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
implicit function for a bounding box
Definition vtkBox.h:31
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
implicit function for a cylinder
Definition vtkCylinder.h:37
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:29
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
Definition vtkPolyData.h:80
an ordered list of Props
represent surface properties of a geometric object
Definition vtkProperty.h:57
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:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:25
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_3_0(reason)
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_MAX_CYL_RESOLUTION
#define VTK_FLOAT_MAX
Definition vtkType.h:152
#define VTK_SIZEHINT(...)