VTK  9.6.1
vtkImplicitAnnulusRepresentation.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
28
29#ifndef vtkImplicitAnnulusRepresentation_h
30#define vtkImplicitAnnulusRepresentation_h
31
33#include "vtkInteractionWidgetsModule.h" // For export macro
34#include "vtkVector.h" // For vtkVector3d
35#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
36
37VTK_ABI_NAMESPACE_BEGIN
38class vtkActor;
40class vtkConeSource;
41class vtkLineSource;
42class vtkSphereSource;
43class vtkTubeFilter;
44class vtkAnnulus;
45class vtkProperty;
46class vtkPolyData;
47class vtkBox;
48class vtkCellPicker;
49
50#define VTK_MAX_ANNULUS_RESOLUTION 2048
51
52class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkImplicitAnnulusRepresentation
54{
55public:
56 // Manage the state of the widget
69
72 void PrintSelf(ostream& os, vtkIndent indent) override;
73
75
80 void SetCenter(double x, double y, double z);
81 void SetCenter(double x[3]);
82 double* GetCenter() const VTK_SIZEHINT(3);
83 void GetCenter(double xyz[3]) const;
85
87
92 void SetAxis(double x, double y, double z);
93 void SetAxis(double a[3]);
94 double* GetAxis() const VTK_SIZEHINT(3);
95 void GetAxis(double a[3]) const;
97
99
105 void SetInnerRadius(double r);
106 double GetInnerRadius() const;
108
110
116 void SetOuterRadius(double r);
117 double GetOuterRadius() const;
119
121
129 void SetAlongXAxis(bool);
130 vtkGetMacro(AlongXAxis, bool);
131 vtkBooleanMacro(AlongXAxis, bool);
132 void SetAlongYAxis(bool);
133 vtkGetMacro(AlongYAxis, bool);
134 vtkBooleanMacro(AlongYAxis, bool);
135 void SetAlongZAxis(bool);
136 vtkGetMacro(AlongZAxis, bool);
137 vtkBooleanMacro(AlongZAxis, bool);
139
141
147 void SetDrawAnnulus(bool draw);
148 vtkGetMacro(DrawAnnulus, bool);
149 vtkBooleanMacro(DrawAnnulus, bool);
151
153
160 vtkSetClampMacro(Resolution, int, 8, VTK_MAX_ANNULUS_RESOLUTION);
161 vtkGetMacro(Resolution, int);
163
165
171 vtkSetMacro(Tubing, bool);
172 vtkGetMacro(Tubing, bool);
173 vtkBooleanMacro(Tubing, bool);
175
177
181 vtkSetMacro(ScaleEnabled, bool);
182 vtkGetMacro(ScaleEnabled, bool);
183 vtkBooleanMacro(ScaleEnabled, bool);
185
191
197
199
202 vtkGetObjectMacro(AxisProperty, vtkProperty);
203 vtkGetObjectMacro(SelectedAxisProperty, vtkProperty);
205
207
211 vtkGetObjectMacro(AnnulusProperty, vtkProperty);
212 vtkGetObjectMacro(SelectedAnnulusProperty, vtkProperty);
214
216
220 vtkGetObjectMacro(RadiusHandleProperty, vtkProperty);
221 vtkGetObjectMacro(SelectedRadiusHandleProperty, vtkProperty);
223
225
230 void SetInteractionColor(double, double, double);
231 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
232 void SetHandleColor(double, double, double);
233 void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
234 void SetForegroundColor(double, double, double);
235 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
237
239
242 int ComputeInteractionState(int X, int Y, int modify = 0) override;
243 void PlaceWidget(double bounds[6]) override;
244 void BuildRepresentation() override;
245 void StartWidgetInteraction(double eventPos[2]) override;
246 void WidgetInteraction(double newEventPos[2]) override;
247 void EndWidgetInteraction(double newEventPos[2]) override;
249
251
254 double* GetBounds() override;
255 void GetActors(vtkPropCollection* pc) override;
261
263
269 vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
270 vtkGetMacro(BumpDistance, double);
272
280 void BumpAnnulus(int dir, double factor);
281
288 void PushAnnulus(double distance);
289
301
303
308 vtkGetMacro(RepresentationState, InteractionStateType);
310
311 /*
312 * Register internal Pickers within PickingManager
313 */
314 void RegisterPickers() override;
315
316 void GetAnnulus(vtkAnnulus* annulus) const;
317
318protected:
321
322private:
323 struct AxisHandleRepresentation
324 {
325 vtkNew<vtkLineSource> LineSource;
326 vtkNew<vtkPolyDataMapper> LineMapper;
327 vtkNew<vtkActor> LineActor;
328
329 vtkNew<vtkConeSource> ArrowSource;
330 vtkNew<vtkPolyDataMapper> ArrowMapper;
331 vtkNew<vtkActor> ArrowActor;
332 };
333
334 struct RadiusHandleRepresentation
335 {
336 vtkNew<vtkPolyData> PolyData;
339 vtkNew<vtkActor> Actor;
340 };
341
342 vtkImplicitAnnulusRepresentation(const vtkImplicitAnnulusRepresentation&) = delete;
343 void operator=(const vtkImplicitAnnulusRepresentation&) = delete;
344
345 void HighlightAnnulus(bool highlight);
346 void HighlightCenterHandle(bool highlight);
347 void HighlightAxis(bool highlight);
348 void HighlightInnerRadiusHandle(bool highlight);
349 void HighlightOuterRadiusHandle(bool highlight);
350
351 // Methods to manipulate the annulus
352 void Rotate(
353 double X, double Y, const vtkVector3d& p1, const vtkVector3d& p2, const vtkVector3d& vpn);
354 void TranslateAnnulus(const vtkVector3d& p1, const vtkVector3d& p2);
355 void TranslateRepresentation(const vtkVector3d& motion) override;
356 void TranslateCenter(const vtkVector3d& p1, const vtkVector3d& p2);
357 void TranslateCenterOnAxis(const vtkVector3d& p1, const vtkVector3d& p2);
358 void ScaleRadii(const vtkVector3d& p1, const vtkVector3d& p2);
359 void AdjustOuterRadius(double x, double y, const vtkVector3d& point);
360 void AdjustInnerRadius(double x, double y, const vtkVector3d& point);
361 void Scale(const vtkVector3d& p1, const vtkVector3d& p2, double X, double Y);
362 void SizeHandles();
363
364 // Generate the annulus polydata, cropped by the bounding box
365 void BuildAnnulus();
366
367 // The actual annulus we're manipulating
368 vtkNew<vtkAnnulus> Annulus;
369
370 InteractionStateType RepresentationState = InteractionStateType::Outside;
371
372 // Keep track of event positions
373 vtkVector3d LastEventPosition;
374
375 // Controlling the push operation
376 double BumpDistance = 0.01;
377
378 // Controlling ivars
379 bool AlongXAxis = false;
380 bool AlongYAxis = false;
381 bool AlongZAxis = false;
382
383 // The facet resolution for rendering purposes.
384 int Resolution = 128;
385
386 bool ScaleEnabled = true; // whether the widget can be scaled
387
388 vtkNew<vtkPolyData> AnnulusPD;
389 vtkNew<vtkPolyDataMapper> AnnulusMapper;
390 vtkNew<vtkActor> AnnulusActor;
391 bool DrawAnnulus = true;
392
393 // Optional tubes are represented by extracting boundary edges and tubing
394 RadiusHandleRepresentation InnerRadiusRepresentation;
395 RadiusHandleRepresentation OuterRadiusRepresentation;
396 bool Tubing = true; // control whether tubing is on
397
398 // Axis representations
399 AxisHandleRepresentation LowerAxisRepresentation;
400 AxisHandleRepresentation UpperAxisRepresentation;
401
402 // Center positioning handle
403 vtkNew<vtkSphereSource> CenterHandleSource;
404 vtkNew<vtkPolyDataMapper> CenterHandleMapper;
405 vtkNew<vtkActor> CenterHandleActor;
406
407 // Do the picking
408 vtkNew<vtkCellPicker> Picker;
409 vtkNew<vtkCellPicker> AnnulusPicker;
410
411 // Properties used to control the appearance of selected objects and
412 // the manipulator in general.
413 vtkNew<vtkProperty> AxisProperty;
414 vtkNew<vtkProperty> SelectedAxisProperty;
415 vtkNew<vtkProperty> AnnulusProperty;
416 vtkNew<vtkProperty> SelectedAnnulusProperty;
417 vtkNew<vtkProperty> RadiusHandleProperty;
418 vtkNew<vtkProperty> SelectedRadiusHandleProperty;
419 vtkNew<vtkProperty> CenterHandleProperty;
420 vtkNew<vtkProperty> SelectedCenterHandleProperty;
421
422 vtkNew<vtkBox> BoundingBox;
423};
424
425VTK_ABI_NAMESPACE_END
426#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:42
implicit function for a annulus
Definition vtkAnnulus.h:41
virtual void TranslateRepresentation(const vtkVector3d &)
Translate the representation, to be implemented in derived class.
implicit function for a bounding box
Definition vtkBox.h:31
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting the rendering process.
void SetAlongYAxis(bool)
Force the annulus widget to be aligned with one of the x-y-z axes.
void UpdatePlacement()
Satisfies the superclass API.
void PushAnnulus(double distance)
Push the annulus the distance specified along the view vector.
void PlaceWidget(double bounds[6]) override
Methods to interface with the vtkImplicitAnnulusWidget.
static vtkImplicitAnnulusRepresentation * New()
void SetDrawAnnulus(bool draw)
Enable/disable the drawing of the annulus.
double * GetBounds() override
Methods supporting the rendering process.
void GetAnnulus(vtkAnnulus *annulus) const
void BuildRepresentation() override
Methods to interface with the vtkImplicitAnnulusWidget.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
void SetAlongZAxis(bool)
Force the annulus widget to be aligned with one of the x-y-z axes.
void SetOuterRadius(double r)
Set/Get the annulus outer radius.
void SetHandleColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected annulus) and their color during inter...
void SetInteractionColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected annulus) and their color during inter...
void SetForegroundColor(double, double, double)
Set the color of all the widgets handles (edges, axis, selected annulus) and their color during inter...
void SetInteractionColor(double, double, double)
Set the color of all the widgets handles (edges, axis, selected annulus) and their color during inter...
double * GetCenter() const
Get the center of the annulus representation.
double GetOuterRadius() const
Set/Get the annulus outer radius.
void BumpAnnulus(int dir, double factor)
Translate the annulus in the direction of the view vector by the specified BumpDistance.
void GetPolyData(vtkPolyData *pd)
Grab the polydata that defines the annulus.
void SetAxis(double x, double y, double z)
Set/Get the axis of rotation for the annulus.
void SetForegroundColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected annulus) and their color during inter...
double GetInnerRadius() const
Set/Get the annulus inner radius.
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting the rendering process.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting the rendering process.
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting the rendering process.
void SetCenter(double x[3])
Get the center of the annulus representation.
virtual void SetRepresentationState(InteractionStateType)
Sets the visual appearance of the representation based on the state it is in.
void SetAlongXAxis(bool)
Force the annulus widget to be aligned with one of the x-y-z axes.
void SetInnerRadius(double r)
Set/Get the annulus inner radius.
void SetCenter(double x, double y, double z)
Get the center of the annulus representation.
int ComputeInteractionState(int X, int Y, int modify=0) override
Methods to interface with the vtkImplicitAnnulusWidget.
void EndWidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkImplicitAnnulusWidget.
void WidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkImplicitAnnulusWidget.
void SetHandleColor(double, double, double)
Set the color of all the widgets handles (edges, axis, selected annulus) and their color during inter...
void GetActors(vtkPropCollection *pc) override
Methods supporting the rendering process.
void StartWidgetInteraction(double eventPos[2]) override
Methods to interface with the vtkImplicitAnnulusWidget.
double * GetAxis() const
Set/Get the axis of rotation for the annulus.
a simple class to control print indentation
Definition vtkIndent.h:29
create a line defined by two end points
Allocate and hold a VTK object.
Definition vtkNew.h:58
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
an ordered list of Props
represent surface properties of a geometric object
Definition vtkProperty.h:60
create a polygonal sphere centered at the origin
filter that generates tubes around lines
abstract specification for Viewports
Definition vtkViewport.h:47
window superclass for vtkRenderWindow
Definition vtkWindow.h:29
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_MAX_ANNULUS_RESOLUTION
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO