VTK  9.3.20240424
vtkPlotRangeHandlesItem.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
3
30#ifndef vtkPlotRangeHandlesItem_h
31#define vtkPlotRangeHandlesItem_h
32
33#include "vtkChartsCoreModule.h" // For export macro
34#include "vtkCommand.h" // For vtkCommand enum
35#include "vtkPlot.h"
36
37VTK_ABI_NAMESPACE_BEGIN
38class vtkBrush;
39
40class VTKCHARTSCORE_EXPORT vtkPlotRangeHandlesItem : public vtkPlot
41{
42public:
44 void PrintSelf(ostream& os, vtkIndent indent) override;
46
47 enum Handle
48 {
49 NO_HANDLE = -1,
50 LEFT_HANDLE = 0,
51 RIGHT_HANDLE = 1
52 };
53
55 {
56 VERTICAL = 0,
57 HORIZONTAL = 1
58 };
59
64 bool Paint(vtkContext2D* painter) override;
65
69 void GetBounds(double bounds[4]) override;
70
75 virtual void GetHandlesRange(double range[2]);
76
78
82 vtkSetMacro(HandleWidth, float);
83 vtkGetMacro(HandleWidth, float);
85
87
90 vtkSetClampMacro(HandleOrientation, int, VERTICAL, HORIZONTAL);
91 vtkGetMacro(HandleOrientation, int);
92 void SetHandleOrientationToVertical() { this->SetHandleOrientation(VERTICAL); }
93 void SetHandleOrientationToHorizontal() { this->SetHandleOrientation(HORIZONTAL); }
95
97
105 vtkSetVector4Macro(Extent, double);
106 vtkGetVector4Macro(Extent, double);
108
110
113 vtkSetMacro(ExtentToAxisRange, vtkTypeBool);
114 vtkGetMacro(ExtentToAxisRange, vtkTypeBool);
115 vtkBooleanMacro(ExtentToAxisRange, vtkTypeBool);
117
119
122 vtkSetMacro(SynchronizeRangeHandles, vtkTypeBool);
123 vtkGetMacro(SynchronizeRangeHandles, vtkTypeBool);
124 vtkBooleanMacro(SynchronizeRangeHandles, vtkTypeBool);
126
128
132 vtkSetMacro(LockTooltipToMouse, vtkTypeBool);
133 vtkGetMacro(LockTooltipToMouse, vtkTypeBool);
134 vtkBooleanMacro(LockTooltipToMouse, vtkTypeBool);
136
140 vtkGetObjectMacro(HighlightBrush, vtkBrush);
141
146
147protected:
150
152
160 void GetAxesRange(double* abcissaRange, double* ordinateRange);
161 void GetAxesUnscaledRange(double* abcissaRange, double* ordinateRange);
163
167 void ComputeRange(double* range);
168
172 void ComputeHandleDelta(double screenBounds[4]);
173
175
181 void TransformScreenToData(double inX, double inY, double& outX, double& outY) override;
182 void TransformDataToScreen(double inX, double inY, double& outX, double& outY) override;
184
188 bool Hit(const vtkContextMouseEvent& mouse) override;
189
191
194 bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
196 bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
197 bool MouseEnterEvent(const vtkContextMouseEvent& mouse) override;
198 bool MouseLeaveEvent(const vtkContextMouseEvent& mouse) override;
199 bool MouseDoubleClickEvent(const vtkContextMouseEvent& mouse) override;
201
206 virtual int FindRangeHandle(const vtkVector2f& point, const vtkVector2f& tolerance);
207
212 virtual void SetActiveHandlePosition(double position);
213
218 bool IsActiveHandleMoved(double tolerance);
219
223 void SetCursor(int cursor);
224
226 void operator=(const vtkPlotRangeHandlesItem&) = delete;
227
228 float HandleWidth = 2;
229 float HandleDelta = 0;
230 float LeftHandleDrawRange[2] = { 0, 0 };
231 float RightHandleDrawRange[2] = { 0, 0 };
232 int ActiveHandle = NO_HANDLE;
233 int HoveredHandle = NO_HANDLE;
234 float HoveredPosition[2] = { 0, 0 };
235 vtkTypeBool LockTooltipToMouse = true;
236 double ActiveHandlePosition = 0;
237 double ActiveHandleRangeValue = 0;
240 double Extent[4] = { 0, 1, 0, 1 };
241 vtkTypeBool ExtentToAxisRange = true;
242 vtkTypeBool SynchronizeRangeHandles = false;
243 int HandleOrientation = VERTICAL;
244};
245
246VTK_ABI_NAMESPACE_END
247#endif // vtkPlotRangeHandlesItem_h
provides a brush that fills shapes drawn by vtkContext2D.
Definition vtkBrush.h:89
Class for drawing 2D primitives to a graphical context.
data structure to represent mouse events.
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:160
item to show and control a range on vtkAxis
virtual void SetActiveHandlePosition(double position)
Internal method to set the ActiveHandlePosition and compute the ActiveHandleRangeValue accordingly.
vtkPlotRangeHandlesItem(const vtkPlotRangeHandlesItem &)=delete
void GetAxesUnscaledRange(double *abcissaRange, double *ordinateRange)
Get the logical range of abcissa or ordinate axis based on the handle orientation,...
static vtkPlotRangeHandlesItem * New()
void GetBounds(double bounds[4]) override
Recover the bounds of the item.
bool Paint(vtkContext2D *painter) override
Paint both handles and the range if a handle is active or hovered.
bool MouseEnterEvent(const vtkContextMouseEvent &mouse) override
Interaction methods to interact with the handles.
void TransformScreenToData(double inX, double inY, double &outX, double &outY) override
Transform the mouse event in the control-points space.
~vtkPlotRangeHandlesItem() override
bool Hit(const vtkContextMouseEvent &mouse) override
Returns true if the supplied x, y coordinate is around a handle.
bool MouseLeaveEvent(const vtkContextMouseEvent &mouse) override
Interaction methods to interact with the handles.
bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse) override
Interaction methods to interact with the handles.
bool IsActiveHandleMoved(double tolerance)
Internal method to check if the active handle have actually been moved.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GetAxesRange(double *abcissaRange, double *ordinateRange)
Get the logical range of abcissa or ordinate axis based on the handle orientation,...
void SetHandleOrientationToVertical()
Set/Get the handles orientation in the plot.
void SetCursor(int cursor)
Set the cursor shape.
bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override
Interaction methods to interact with the handles.
void SetHandleOrientationToHorizontal()
Set/Get the handles orientation in the plot.
virtual void GetHandlesRange(double range[2])
Recover the range currently set by the handles Use this method by observing EndInteractionEvent.
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Interaction methods to interact with the handles.
bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override
Interaction methods to interact with the handles.
void ComputeRange(double *range)
Compute the range used for the handles.
void TransformDataToScreen(double inX, double inY, double &outX, double &outY) override
Transform the mouse event in the control-points space.
void ComputeHandleDelta(double screenBounds[4])
Compute the delta used for the picking handle size.
virtual void ComputeHandlesDrawRange()
Compute the handles draw range by using the handle width and the transfer function.
void operator=(const vtkPlotRangeHandlesItem &)=delete
virtual int FindRangeHandle(const vtkVector2f &point, const vtkVector2f &tolerance)
Returns the handle the provided point is over with a provided tolerance, it can be NO_HANDLE,...
Abstract class for 2D plots.
Definition vtkPlot.h:153
virtual void TransformScreenToData(const vtkVector2f &in, vtkVector2f &out)
Transform the mouse event in the control-points space.
virtual void TransformDataToScreen(const vtkVector2f &in, vtkVector2f &out)
Transform the mouse event in the control-points space.
int vtkTypeBool
Definition vtkABI.h:64