VTK  9.6.2
vtkCameraOrientationRepresentation.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
77
78#ifndef vtkCameraOrientationRepresentation_h
79#define vtkCameraOrientationRepresentation_h
80
81#include "vtkInteractionWidgetsModule.h" // needed for export macro
83#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
84
85#include <algorithm> // std::min, std::max
86
87VTK_ABI_NAMESPACE_BEGIN
88class vtkActor;
89class vtkDiskSource;
90class vtkDoubleArray;
92class vtkImageData;
93class vtkPoints;
94class vtkPolyData;
96class vtkProperty;
97class vtkPropPicker;
98class vtkTextProperty;
99class vtkTexture;
100class vtkTubeFilter;
101
102class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkCameraOrientationRepresentation
104{
105public:
108 void PrintSelf(ostream& os, vtkIndent indent) override;
109
110 enum class InteractionStateType : int
111 {
112 Outside = 0, // corresponds to vtkCameraOrientationWidget::Inactive
113 Hovering, // corresponds to vtkCameraOrientationWidget::Hot
114 Rotating // corresponds to vtkCameraOrientationWidget::Active
115 };
116
122 void ApplyInteractionState(const int& state);
123
130 {
131 // clamp to 0-2
132 this->InteractionState = std::min(std::max(this->InteractionState, 0), 2);
133 // convert
134 return static_cast<InteractionStateType>(this->InteractionState);
135 }
136
138
141 vtkSetVector2Macro(Size, int);
142 vtkGetVector2Macro(Size, int);
144
146
149 vtkSetVector2Macro(Padding, int);
150 vtkGetVector2Macro(Padding, int);
152
153 enum class AnchorType : int
154 {
155 LowerLeft = 0,
156 UpperLeft,
157 LowerRight,
158 UpperRight
159 };
160
162
168 {
170 this->Modified();
171 }
173 {
175 this->Modified();
176 }
178 {
180 this->Modified();
181 }
183 {
185 this->Modified();
186 }
187
188
190
194 vtkSetMacro(TotalLength, double);
195 vtkGetMacro(TotalLength, double);
197
199
203 vtkSetMacro(NormalizedHandleDia, double);
204 vtkGetMacro(NormalizedHandleDia, double);
206
208
211 vtkGetMacro(Azimuth, double);
212 vtkGetVector3Macro(Back, double);
213 vtkGetMacro(Elevation, double);
214 vtkGetVector3Macro(Up, double);
216
218
221 vtkSetClampMacro(ShaftResolution, int, 3, 256);
222 vtkGetMacro(ShaftResolution, int);
224
226
229 vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
232
234
237 vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
240
242
245 vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
246 vtkGetMacro(ContainerRadialResolution, int);
248
250
253 vtkGetMacro(PickedAxis, int);
254 vtkGetMacro(PickedDir, int);
256
258
261 void SetXPlusLabelText(const std::string& label)
262 {
263 this->AxisLabelsText[0][0] = label;
264 this->Modified();
265 }
266 std::string GetXPlusLabelText() { return this->AxisLabelsText[0][0]; }
267 void SetYPlusLabelText(const std::string& label)
268 {
269 this->AxisLabelsText[1][0] = label;
270 this->Modified();
271 }
272 std::string GetYPlusLabelText() { return this->AxisLabelsText[1][0]; }
273 void SetZPlusLabelText(const std::string& label)
274 {
275 this->AxisLabelsText[2][0] = label;
276 this->Modified();
277 }
278 std::string GetZPlusLabelText() { return this->AxisLabelsText[2][0]; }
280
282
285 void SetXMinusLabelText(const std::string& label)
286 {
287 this->AxisLabelsText[0][1] = label;
288 this->Modified();
289 }
290 std::string GetXMinusLabelText() { return this->AxisLabelsText[0][1]; }
291 void SetYMinusLabelText(const std::string& label)
292 {
293 this->AxisLabelsText[1][1] = label;
294 this->Modified();
295 }
296 std::string GetYMinusLabelText() { return this->AxisLabelsText[1][1]; }
297 void SetZMinusLabelText(const std::string& label)
298 {
299 this->AxisLabelsText[2][1] = label;
300 this->Modified();
301 }
302 std::string GetZMinusLabelText() { return this->AxisLabelsText[2][1]; }
304
306
313
315
322
324
327 void SetXAxisColor(double color[3]);
328 void SetXAxisColor(double, double, double);
330
332
335 void SetYAxisColor(double color[3]);
336 void SetYAxisColor(double, double, double);
338
340
343 void SetZAxisColor(double color[3]);
344 void SetZAxisColor(double, double, double);
346
348
351 void SetAxisColor(int ax, double color[3]);
352 void SetAxisColor(int ax, double, double, double);
354
356
360 void GetXAxisColor(double color[3]);
362
364
368 void GetYAxisColor(double color[3]);
370
372
376 void GetZAxisColor(double color[3]);
378
380
383 double* GetAxisColor(int ax) VTK_SIZEHINT(3);
384 void GetAxisColor(int ax, double color[3]);
386
391
393
396 void SetContainerVisibility(bool state);
397 vtkBooleanMacro(ContainerVisibility, bool);
400
407
412
414
417 void PlaceWidget(double*) override {} // this representation is an overlay. Doesn't need this.
418 void BuildRepresentation() override;
419 void StartWidgetInteraction(double eventPos[2]) override;
420 void WidgetInteraction(double newEventPos[2]) override;
421 void EndWidgetInteraction(double newEventPos[2]) override;
422 int ComputeInteractionState(int X, int Y, int modify = 0) override;
423 double* GetBounds() VTK_SIZEHINT(6) override;
425
427
435
439 void ShallowCopy(vtkProp* prop) override;
440
444 bool IsAnyHandleSelected() { return (this->PickedAxis != -1) && (this->PickedDir != -1); }
445
446protected:
449
450 virtual void CreateDefaultGeometry();
452 virtual void PositionHandles();
453 virtual void HighlightHandle();
454 virtual void Rotate(double newEventPos[2]);
455 void RegisterPickers() override;
457
458 // description of source shapes.
462
463 // geometries of handles and shafts. (position, color info)
465 vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
466
467 // defaults are slight variations of r, y, g
469
470 // props
474
475 // font-sz, font-type, frame color of the labels.
479
481
482 // Store rotation of gizmo.
484
485 // Positioning of the representation within a parent renderer.
487 int Padding[2] = { 10, 10 }; // In display coords.
488 int Size[2] = { 120, 120 }; // In display coords.
489
490 // Geometrical, textual, interaction description of the representation.
491 std::string AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
492 double Azimuth = 0.;
493 double Back[3] = { 0., 0., -1. };
494 double Bounds[6] = {};
495 double Elevation = 0.;
496 double MotionFactor = 1.;
498 double TotalLength = 1.;
499 double Up[3] = { 0., 1., 0. };
504
505 // Picking information.
506 int PickedAxis = -1;
507 int LastPickedAx = -1;
508 int PickedDir = -1;
510
511 // Event tracking
512 double LastEventPosition[3] = {};
513
514private:
516 void operator=(const vtkCameraOrientationRepresentation&) = delete;
517};
518
519VTK_ABI_NAMESPACE_END
520#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
A 3D representation for vtkCameraOrientationWidget.
void StartWidgetInteraction(double eventPos[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkNew< vtkEllipticalButtonSource > HandleSources[3][2]
vtkTextProperty * GetXPlusLabelProperty()
Get the '+' axis label properties.
void AnchorToUpperRight()
Get/Set the widget anchor type.
void PlaceWidget(double *) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetZAxisColor(double, double, double)
Set the Z axis color.
void SetYAxisColor(double color[3])
Set the Y axis color.
vtkTextProperty * GetXMinusLabelProperty()
Get the '-' axis label properties.
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes.
std::string GetYPlusLabelText()
Set/Get the '+' axis label text.
void SetZPlusLabelText(const std::string &label)
Set/Get the '+' axis label text.
void SetYMinusLabelText(const std::string &label)
Set/Get the '-' axis label text.
void AnchorToLowerLeft()
Get/Set the widget anchor type.
std::string GetZMinusLabelText()
Set/Get the '-' axis label text.
vtkNew< vtkTextProperty > AxisVectorTextProperties[3][2]
std::string GetXMinusLabelText()
Set/Get the '-' axis label text.
vtkTextProperty * GetZMinusLabelProperty()
Get the '-' axis label properties.
void AnchorToLowerRight()
Get/Set the widget anchor type.
vtkTextProperty * GetYMinusLabelProperty()
Get the '-' axis label properties.
void SetAxisColor(int ax, double, double, double)
Set the axis color for the axis ax.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
vtkTextProperty * GetZPlusLabelProperty()
Get the '+' axis label properties.
virtual void Rotate(double newEventPos[2])
std::string GetZPlusLabelText()
Set/Get the '+' axis label text.
double * GetXAxisColor()
Get the X axis color.
bool IsAnyHandleSelected()
Is a grabber button picked.
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
void WidgetInteraction(double newEventPos[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
std::string GetXPlusLabelText()
Set/Get the '+' axis label text.
void SetAxisColor(int ax, double color[3])
Set the axis color for the axis ax.
vtkSetEnumMacro(AnchorPosition, AnchorType)
Get/Set the widget anchor type.
double * GetYAxisColor()
Get the Y axis color.
vtkGetEnumMacro(AnchorPosition, AnchorType)
Get/Set the widget anchor type.
void SetZMinusLabelText(const std::string &label)
Set/Get the '-' axis label text.
bool GetContainerVisibility()
Show container to indicate mouse presence.
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetXPlusLabelText(const std::string &label)
Set/Get the '+' axis label text.
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
vtkTransform * GetTransform()
Retrieve internal transform of this widget representation.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting, and required by, the rendering process.
void ApplyInteractionState(const InteractionStateType &state)
The interaction state may be set from a widget (e.g., vtkCameraOrientationWidget) or other object.
void SetYPlusLabelText(const std::string &label)
Set/Get the '+' axis label text.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::string GetYMinusLabelText()
Set/Get the '-' axis label text.
void ShallowCopy(vtkProp *prop) override
Shallow copy of an axes actor.
static vtkCameraOrientationRepresentation * New()
void EndWidgetInteraction(double newEventPos[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetContainerVisibility(bool state)
Show container to indicate mouse presence.
vtkTextProperty * GetYPlusLabelProperty()
Get the '+' axis label properties.
InteractionStateType GetInteractionStateAsEnum() noexcept
Convenient method to get InteractionState as enum.
void SetYAxisColor(double, double, double)
Set the Y axis color.
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting, and required by, the rendering process.
void SetXAxisColor(double color[3])
Set the X axis color.
double * GetZAxisColor()
Get the Z axis color.
void SetXAxisColor(double, double, double)
Set the X axis color.
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
void SetZAxisColor(double color[3])
Set the Z axis color.
void ApplyInteractionState(const int &state)
vtkProperty * GetContainerProperty()
Get the container property.
void AnchorToUpperLeft()
Get/Set the widget anchor type.
double * GetAxisColor(int ax)
Get the axis color for the axis ax.
void SetXMinusLabelText(const std::string &label)
Set/Get the '-' axis label text.
create a disk with hole in center
dynamic, self-adjusting array of double
create a ellipsoidal-shaped button
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:167
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition vtkPoints.h:139
concrete dataset represents vertices, lines, polygons, and triangle strips
an ordered list of Props
pick an actor/prop using graphics hardware
represent surface properties of a geometric object
represent text properties.
handles properties associated with a texture map
Definition vtkTexture.h:168
describes linear transformations via a 4x4 matrix
filter that generates tubes around lines
abstract specification for Viewports
Definition vtkViewport.h:66
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO