VTK  9.1.0
vtkPlotRangeHandlesItem.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkPlotRangeHandlesItem.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15
39#ifndef vtkPlotRangeHandlesItem_h
40#define vtkPlotRangeHandlesItem_h
41
42#include "vtkChartsCoreModule.h" // For export macro
43#include "vtkCommand.h" // For vtkCommand enum
44#include "vtkPlot.h"
45
46class vtkBrush;
47
48class VTKCHARTSCORE_EXPORT vtkPlotRangeHandlesItem : public vtkPlot
49{
50public:
52 void PrintSelf(ostream& os, vtkIndent indent) override;
54
55 enum Handle
56 {
57 NO_HANDLE = -1,
58 LEFT_HANDLE = 0,
59 RIGHT_HANDLE = 1
60 };
61
63 {
64 VERTICAL = 0,
65 HORIZONTAL = 1
66 };
67
72 bool Paint(vtkContext2D* painter) override;
73
77 void GetBounds(double bounds[4]) override;
78
83 virtual void GetHandlesRange(double range[2]);
84
86
90 vtkSetMacro(HandleWidth, float);
91 vtkGetMacro(HandleWidth, float);
93
95
98 vtkSetClampMacro(HandleOrientation, int, VERTICAL, HORIZONTAL);
99 vtkGetMacro(HandleOrientation, int);
100 void SetHandleOrientationToVertical() { this->SetHandleOrientation(VERTICAL); }
101 void SetHandleOrientationToHorizontal() { this->SetHandleOrientation(HORIZONTAL); }
103
105
113 vtkSetVector4Macro(Extent, double);
114 vtkGetVector4Macro(Extent, double);
116
118
121 vtkSetMacro(ExtentToAxisRange, vtkTypeBool);
122 vtkGetMacro(ExtentToAxisRange, vtkTypeBool);
123 vtkBooleanMacro(ExtentToAxisRange, vtkTypeBool);
125
127
130 vtkSetMacro(SynchronizeRangeHandles, vtkTypeBool);
131 vtkGetMacro(SynchronizeRangeHandles, vtkTypeBool);
132 vtkBooleanMacro(SynchronizeRangeHandles, vtkTypeBool);
134
136
140 vtkSetMacro(LockTooltipToMouse, vtkTypeBool);
141 vtkGetMacro(LockTooltipToMouse, vtkTypeBool);
142 vtkBooleanMacro(LockTooltipToMouse, vtkTypeBool);
144
148 vtkGetObjectMacro(HighlightBrush, vtkBrush);
149
154
155protected:
158
160
168 void GetAxesRange(double* abcissaRange, double* ordinateRange);
169 void GetAxesUnscaledRange(double* abcissaRange, double* ordinateRange);
171
175 void ComputeRange(double* range);
176
180 void ComputeHandleDelta(double screenBounds[4]);
181
183
190 const double inX, const double inY, double& outX, double& outY) override;
192 const double inX, const double inY, double& outX, double& outY) override;
194
198 bool Hit(const vtkContextMouseEvent& mouse) override;
199
201
204 bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
206 bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
207 bool MouseEnterEvent(const vtkContextMouseEvent& mouse) override;
208 bool MouseLeaveEvent(const vtkContextMouseEvent& mouse) override;
209 bool MouseDoubleClickEvent(const vtkContextMouseEvent& mouse) override;
211
216 virtual int FindRangeHandle(const vtkVector2f& point, const vtkVector2f& tolerance);
217
222 virtual void SetActiveHandlePosition(double position);
223
228 bool IsActiveHandleMoved(double tolerance);
229
233 void SetCursor(int cursor);
234
236 void operator=(const vtkPlotRangeHandlesItem&) = delete;
237
238 float HandleWidth = 2;
239 float HandleDelta = 0;
240 float LeftHandleDrawRange[2] = { 0, 0 };
241 float RightHandleDrawRange[2] = { 0, 0 };
242 int ActiveHandle = NO_HANDLE;
243 int HoveredHandle = NO_HANDLE;
244 float HoveredPosition[2] = { 0, 0 };
245 vtkTypeBool LockTooltipToMouse = true;
246 double ActiveHandlePosition = 0;
247 double ActiveHandleRangeValue = 0;
250 double Extent[4] = { 0, 1, 0, 1 };
251 vtkTypeBool ExtentToAxisRange = true;
252 vtkTypeBool SynchronizeRangeHandles = false;
253 int HandleOrientation = VERTICAL;
254};
255
256#endif // vtkPlotRangeHandlesItem_h
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:97
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:73
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:113
Allocate and hold a VTK object.
Definition: vtkNew.h:165
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.
~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.
void TransformDataToScreen(const double inX, const double inY, double &outX, double &outY) override
Transform the mouse event in the control-points space.
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.
void TransformScreenToData(const double inX, const double inY, double &outX, double &outY) override
Transform the mouse event in the control-points space.
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.
vtkNew< vtkBrush > RangeLabelBrush
void ComputeRange(double *range)
Compute the range used for the handles.
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:157
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:69