VTK  9.4.20241031
vtkImplicitConeRepresentation.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
49#ifndef vtkImplicitConeRepresentation_h
50#define vtkImplicitConeRepresentation_h
51
52#include "vtkInteractionWidgetsModule.h" // For export macro
53#include "vtkVector.h" // For vtkVector3d
55#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
56
57VTK_ABI_NAMESPACE_BEGIN
58class vtkActor;
60class vtkConeSource;
61class vtkLineSource;
62class vtkSphereSource;
63class vtkTubeFilter;
64class vtkCone;
65class vtkProperty;
66class vtkImageData;
68class vtkPolyData;
69class vtkBox;
70class vtkCellPicker;
71
72#define VTK_MAX_CONE_RESOLUTION 2048
73
74class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkImplicitConeRepresentation
76{
77public:
78 // Manage the state of the widget
80 {
81 Outside = 0,
82 Moving, // Generic state set by the widget
88 TranslatingOrigin
89 };
90
93 void PrintSelf(ostream& os, vtkIndent indent) override;
94
96
100 void SetOrigin(double x, double y, double z);
101 void SetOrigin(double x[3]);
103 void GetOrigin(double xyz[3]);
105
107
111 void SetAxis(double x, double y, double z);
112 void SetAxis(double a[3]);
113 double* GetAxis() VTK_SIZEHINT(3);
114 void GetAxis(double a[3]);
116
118
121 void SetAngle(double r);
122 double GetAngle();
124
126
134 void SetAlongXAxis(bool);
135 vtkGetMacro(AlongXAxis, bool);
136 vtkBooleanMacro(AlongXAxis, bool);
137 void SetAlongYAxis(bool);
138 vtkGetMacro(AlongYAxis, bool);
139 vtkBooleanMacro(AlongYAxis, bool);
140 void SetAlongZAxis(bool);
141 vtkGetMacro(AlongZAxis, bool);
142 vtkBooleanMacro(AlongZAxis, bool);
144
146
152 void SetDrawCone(bool draw);
153 vtkGetMacro(DrawCone, bool);
154 vtkBooleanMacro(DrawCone, bool);
156
158
165 vtkSetClampMacro(Resolution, int, 8, VTK_MAX_CONE_RESOLUTION);
166 vtkGetMacro(Resolution, int);
168
170
176 vtkSetMacro(Tubing, bool);
177 vtkGetMacro(Tubing, bool);
178 vtkBooleanMacro(Tubing, bool);
180
182
187 vtkSetMacro(OutlineTranslation, bool);
188 vtkGetMacro(OutlineTranslation, bool);
189 vtkBooleanMacro(OutlineTranslation, bool);
191
193
198 vtkSetMacro(OutsideBounds, bool);
199 vtkGetMacro(OutsideBounds, bool);
200 vtkBooleanMacro(OutsideBounds, bool);
202
204
210 vtkSetVector6Macro(WidgetBounds, double);
211 vtkGetVector6Macro(WidgetBounds, double);
213
215
222 vtkSetMacro(ConstrainToWidgetBounds, bool);
223 vtkGetMacro(ConstrainToWidgetBounds, bool);
224 vtkBooleanMacro(ConstrainToWidgetBounds, bool);
226
228
232 vtkSetMacro(ScaleEnabled, bool);
233 vtkGetMacro(ScaleEnabled, bool);
234 vtkBooleanMacro(ScaleEnabled, bool);
236
241 void GetPolyData(vtkPolyData* pd);
242
247 void UpdatePlacement();
248
250
253 vtkGetObjectMacro(AxisProperty, vtkProperty);
254 vtkGetObjectMacro(SelectedAxisProperty, vtkProperty);
256
258
262 vtkGetObjectMacro(ConeProperty, vtkProperty);
263 vtkGetObjectMacro(SelectedConeProperty, vtkProperty);
265
267
270 vtkGetObjectMacro(OutlineProperty, vtkProperty);
271 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
273
275
279 vtkGetObjectMacro(EdgesProperty, vtkProperty);
281
283
288 void SetInteractionColor(double, double, double);
289 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
290 void SetHandleColor(double, double, double);
291 void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
292 void SetForegroundColor(double, double, double);
293 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
295
297
300 int ComputeInteractionState(int X, int Y, int modify = 0) override;
301 void PlaceWidget(double bounds[6]) override;
302 void BuildRepresentation() override;
303 void StartWidgetInteraction(double eventPos[2]) override;
304 void WidgetInteraction(double newEventPos[2]) override;
305 void EndWidgetInteraction(double newEventPos[2]) override;
307
309
312 double* GetBounds() override;
313 void GetActors(vtkPropCollection* pc) override;
319
321
327 vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
328 vtkGetMacro(BumpDistance, double);
330
338 void BumpCone(int dir, double factor);
339
346 void PushCone(double distance);
347
357 vtkSetClampMacro(InteractionState, InteractionStateType, InteractionStateType::Outside,
358 InteractionStateType::TranslatingOrigin);
359
361
366 vtkGetMacro(RepresentationState, InteractionStateType);
368
369 /*
370 * Register internal Pickers within PickingManager
371 */
372 void RegisterPickers() override;
373
375
379 vtkGetMacro(TranslationAxis, int);
380 vtkSetClampMacro(TranslationAxis, int, Axis::NONE, Axis::ZAxis);
382
384
387 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
388 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
389 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
390 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
392
396 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
397
398 void GetCone(vtkCone* cone) const;
399
400protected:
403
404 // The actual cone we're manipulating
406
407 InteractionStateType RepresentationState = InteractionStateType::Outside;
408 int TranslationAxis = Axis::NONE;
409
410 // Keep track of event positions
412
413 // Controlling the push operation
414 double BumpDistance = 0.01;
415
416 // Controlling ivars
417 bool AlongXAxis = false;
418 bool AlongYAxis = false;
419 bool AlongZAxis = false;
420
421 // The facet resolution for rendering purposes.
422 int Resolution = 128;
423
424 // The bounding box is represented by a single voxel image data
429 bool OutlineTranslation = true; // whether the outline can be moved
430 bool ScaleEnabled = true; // whether the widget can be scaled
431 bool OutsideBounds = true; // whether the widget can be moved outside input's bounds
432 double WidgetBounds[6];
433 bool ConstrainToWidgetBounds = true;
434
438 bool DrawCone = true;
439
440 // Optional tubes are represented by extracting boundary edges and tubing
445 bool Tubing = true; // control whether tubing is on
446
447 // The axis line
451
452 // Axis line arrow
456
457 // The origin positioning handle
461
462 // Do the picking
465
466 // Properties used to control the appearance of selected objects and
467 // the manipulator in general.
477
478 // Support GetBounds() method
480
481 void HighlightCone(bool highlight);
482 void HighlightOriginHandle(bool highlight);
483 void HighlightAxis(bool highlight);
484 void HighlightOutline(bool highlight);
485
486 // Methods to manipulate the cone
487 void Rotate(
488 double X, double Y, const vtkVector3d& p1, const vtkVector3d& p2, const vtkVector3d& vpn);
489 void TranslateCone(const vtkVector3d& p1, const vtkVector3d& p2);
490 void TranslateOutline(const vtkVector3d& p1, const vtkVector3d& p2);
491 void TranslateOrigin(const vtkVector3d& p1, const vtkVector3d& p2);
493 void ScaleAngle(const vtkVector3d& p1, const vtkVector3d& p2);
494 void AdjustAngle(double X, double Y, const vtkVector3d& p1, const vtkVector3d& p2);
495 void Scale(const vtkVector3d& p1, const vtkVector3d& p2, double X, double Y);
497
498 // Intersect oriented infinite cone against bounding box
499 void BuildCone();
500
503};
504
505VTK_ABI_NAMESPACE_END
506#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 cone
Definition vtkCone.h:91
topologically and geometrically regular array of data
defining the representation for a vtkImplicitConeWidget
~vtkImplicitConeRepresentation() override
void SetInteractionColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cone) and their color during interact...
void StartWidgetInteraction(double eventPos[2]) override
Methods to interface with the vtkImplicitConeWidget.
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
vtkImplicitConeRepresentation(const vtkImplicitConeRepresentation &)=delete
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
void SetForegroundColor(double, double, double)
Set the color of all the widgets handles (edges, axis, selected cone) and their color during interact...
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting the rendering process.
void SetHandleColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cone) and their color during interact...
double * GetOrigin()
Get the origin of the cone representation.
virtual void SetRepresentationState(InteractionStateType)
Sets the visual appearance of the representation based on the state it is in.
void HighlightCone(bool highlight)
void TranslateOrigin(const vtkVector3d &p1, const vtkVector3d &p2)
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
void SetOrigin(double x[3])
Get the origin of the cone representation.
vtkNew< vtkPolyDataMapper > AxisArrowMapper
void PushCone(double distance)
Push the cone the distance specified along the view vector.
int ComputeInteractionState(int X, int Y, int modify=0) override
Methods to interface with the vtkImplicitConeWidget.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting the rendering process.
void AdjustAngle(double X, double Y, const vtkVector3d &p1, const vtkVector3d &p2)
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting the rendering process.
void WidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkImplicitConeWidget.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting the rendering process.
void PlaceWidget(double bounds[6]) override
Methods to interface with the vtkImplicitConeWidget.
void EndWidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkImplicitConeWidget.
void SetOrigin(double x, double y, double z)
Get the origin of the cone representation.
vtkNew< vtkPolyDataMapper > OriginHandleMapper
void HighlightAxis(bool highlight)
void operator=(const vtkImplicitConeRepresentation &)=delete
void HighlightOutline(bool highlight)
void GetCone(vtkCone *cone) const
void HighlightOriginHandle(bool highlight)
void SetForegroundColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cone) and their color during interact...
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void TranslateOutline(const vtkVector3d &p1, const vtkVector3d &p2)
void GetActors(vtkPropCollection *pc) override
Methods supporting the rendering process.
double * GetBounds() override
Methods supporting the rendering process.
void SetHandleColor(double, double, double)
Set the color of all the widgets handles (edges, axis, selected cone) and their color during interact...
void Scale(const vtkVector3d &p1, const vtkVector3d &p2, double X, double Y)
void Rotate(double X, double Y, const vtkVector3d &p1, const vtkVector3d &p2, const vtkVector3d &vpn)
void ScaleAngle(const vtkVector3d &p1, const vtkVector3d &p2)
void TranslateOriginOnAxis(const vtkVector3d &p1, const vtkVector3d &p2)
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
static vtkImplicitConeRepresentation * New()
void BumpCone(int dir, double factor)
Translate the cone in the direction of the view vector by the specified BumpDistance.
void BuildRepresentation() override
Methods to interface with the vtkImplicitConeWidget.
void TranslateCone(const vtkVector3d &p1, const vtkVector3d &p2)
a simple class to control print indentation
Definition vtkIndent.h:108
create a line defined by two end points
Allocate and hold a VTK object.
Definition vtkNew.h:167
create wireframe outline for an arbitrary data set or composite dataset
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
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_MAX_CONE_RESOLUTION
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO