VTK  9.7.1
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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
37 
38 VTK_ABI_NAMESPACE_BEGIN
39 class vtkBrush;
40 
41 class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkPlotRangeHandlesItem : public vtkPlot
42 {
43 public:
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46  static vtkPlotRangeHandlesItem* New();
47 
48  enum Handle
49  {
50  NO_HANDLE = -1,
51  LEFT_HANDLE = 0,
52  RIGHT_HANDLE = 1
53  };
54 
56  {
57  VERTICAL = 0,
58  HORIZONTAL = 1
59  };
60 
65  bool Paint(vtkContext2D* painter) override;
66 
70  void GetBounds(double bounds[4]) override;
71 
76  virtual void GetHandlesRange(double range[2]);
77 
79 
83  vtkSetMacro(HandleWidth, float);
84  vtkGetMacro(HandleWidth, float);
86 
88 
91  vtkSetClampMacro(HandleOrientation, int, VERTICAL, HORIZONTAL);
92  vtkGetMacro(HandleOrientation, int);
93  void SetHandleOrientationToVertical() { this->SetHandleOrientation(VERTICAL); }
94  void SetHandleOrientationToHorizontal() { this->SetHandleOrientation(HORIZONTAL); }
96 
98 
106  vtkSetVector4Macro(Extent, double);
107  vtkGetVector4Macro(Extent, double);
109 
111 
114  vtkSetMacro(ExtentToAxisRange, vtkTypeBool);
115  vtkGetMacro(ExtentToAxisRange, vtkTypeBool);
116  vtkBooleanMacro(ExtentToAxisRange, vtkTypeBool);
118 
120 
123  vtkSetMacro(SynchronizeRangeHandles, vtkTypeBool);
124  vtkGetMacro(SynchronizeRangeHandles, vtkTypeBool);
125  vtkBooleanMacro(SynchronizeRangeHandles, vtkTypeBool);
127 
129 
133  vtkSetMacro(LockTooltipToMouse, vtkTypeBool);
134  vtkGetMacro(LockTooltipToMouse, vtkTypeBool);
135  vtkBooleanMacro(LockTooltipToMouse, vtkTypeBool);
137 
141  vtkGetObjectMacro(HighlightBrush, vtkBrush);
142 
146  virtual void ComputeHandlesDrawRange();
147 
148 protected:
150  ~vtkPlotRangeHandlesItem() override;
151 
153 
161  void GetAxesRange(double* abcissaRange, double* ordinateRange);
162  void GetAxesUnscaledRange(double* abcissaRange, double* ordinateRange);
164 
168  void ComputeRange(double* range);
169 
173  void ComputeHandleDelta(double screenBounds[4]);
174 
176 
182  void TransformScreenToData(double inX, double inY, double& outX, double& outY) override;
183  void TransformDataToScreen(double inX, double inY, double& outX, double& outY) override;
185 
189  bool Hit(const vtkContextMouseEvent& mouse) override;
190 
192 
195  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
196  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
197  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
198  bool MouseEnterEvent(const vtkContextMouseEvent& mouse) override;
199  bool MouseLeaveEvent(const vtkContextMouseEvent& mouse) override;
200  bool MouseDoubleClickEvent(const vtkContextMouseEvent& mouse) override;
202 
207  virtual int FindRangeHandle(const vtkVector2f& point, const vtkVector2f& tolerance);
208 
213  virtual void SetActiveHandlePosition(double position);
214 
219  bool IsActiveHandleMoved(double tolerance);
220 
224  void SetCursor(int cursor);
225 
227  void operator=(const vtkPlotRangeHandlesItem&) = delete;
228 
229  float HandleWidth = 2;
230  float HandleDelta = 0;
231  float LeftHandleDrawRange[2] = { 0, 0 };
232  float RightHandleDrawRange[2] = { 0, 0 };
233  int ActiveHandle = NO_HANDLE;
234  int HoveredHandle = NO_HANDLE;
235  float HoveredPosition[2] = { 0, 0 };
236  vtkTypeBool LockTooltipToMouse = true;
237  double ActiveHandlePosition = 0;
238  double ActiveHandleRangeValue = 0;
241  double Extent[4] = { 0, 1, 0, 1 };
242  vtkTypeBool ExtentToAxisRange = true;
243  vtkTypeBool SynchronizeRangeHandles = false;
244  int HandleOrientation = VERTICAL;
245 };
246 
247 VTK_ABI_NAMESPACE_END
248 #endif // vtkPlotRangeHandlesItem_h
vtkNew< vtkBrush > RangeLabelBrush
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
Mouse button down event Return true if the item holds the event, false if the event can be propagated...
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
virtual void GetBounds(double bounds[4])
Get the bounds for this plot as (Xmin, Xmax, Ymin, Ymax).
Definition: vtkPlot.h:393
bool Hit(const vtkContextMouseEvent &mouse) override
Returns true if the supplied x, y coordinate is inside the item.
virtual void TransformScreenToData(const vtkVector2f &in, vtkVector2f &out)
Transform the mouse event in the control-points space.
item to show and control a range on vtkAxis
int vtkTypeBool
Definition: vtkABI.h:64
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:30
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
void SetHandleOrientationToVertical()
Set/Get the handles orientation in the plot.
Abstract class for 2D plots.
Definition: vtkPlot.h:43
virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse)
Mouse enter event.
void SetHandleOrientationToHorizontal()
Set/Get the handles orientation in the plot.
virtual void TransformDataToScreen(const vtkVector2f &in, vtkVector2f &out)
Transform the mouse event in the control-points space.
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse)
Mouse button double click event.
virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse)
Mouse leave event.