VTK  9.2.6
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 
42 #ifndef vtkPlotRangeHandlesItem_h
43 #define vtkPlotRangeHandlesItem_h
44 
45 #include "vtkChartsCoreModule.h" // For export macro
46 #include "vtkCommand.h" // For vtkCommand enum
47 #include "vtkPlot.h"
48 
49 class vtkBrush;
50 
51 class VTKCHARTSCORE_EXPORT vtkPlotRangeHandlesItem : public vtkPlot
52 {
53 public:
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56  static vtkPlotRangeHandlesItem* New();
57 
58  enum Handle
59  {
60  NO_HANDLE = -1,
61  LEFT_HANDLE = 0,
62  RIGHT_HANDLE = 1
63  };
64 
66  {
67  VERTICAL = 0,
68  HORIZONTAL = 1
69  };
70 
75  bool Paint(vtkContext2D* painter) override;
76 
80  void GetBounds(double bounds[4]) override;
81 
86  virtual void GetHandlesRange(double range[2]);
87 
89 
93  vtkSetMacro(HandleWidth, float);
94  vtkGetMacro(HandleWidth, float);
96 
98 
101  vtkSetClampMacro(HandleOrientation, int, VERTICAL, HORIZONTAL);
102  vtkGetMacro(HandleOrientation, int);
103  void SetHandleOrientationToVertical() { this->SetHandleOrientation(VERTICAL); }
104  void SetHandleOrientationToHorizontal() { this->SetHandleOrientation(HORIZONTAL); }
106 
108 
116  vtkSetVector4Macro(Extent, double);
117  vtkGetVector4Macro(Extent, double);
119 
121 
124  vtkSetMacro(ExtentToAxisRange, vtkTypeBool);
125  vtkGetMacro(ExtentToAxisRange, vtkTypeBool);
126  vtkBooleanMacro(ExtentToAxisRange, vtkTypeBool);
128 
130 
133  vtkSetMacro(SynchronizeRangeHandles, vtkTypeBool);
134  vtkGetMacro(SynchronizeRangeHandles, vtkTypeBool);
135  vtkBooleanMacro(SynchronizeRangeHandles, vtkTypeBool);
137 
139 
143  vtkSetMacro(LockTooltipToMouse, vtkTypeBool);
144  vtkGetMacro(LockTooltipToMouse, vtkTypeBool);
145  vtkBooleanMacro(LockTooltipToMouse, vtkTypeBool);
147 
151  vtkGetObjectMacro(HighlightBrush, vtkBrush);
152 
156  virtual void ComputeHandlesDrawRange();
157 
158 protected:
160  ~vtkPlotRangeHandlesItem() override;
161 
163 
171  void GetAxesRange(double* abcissaRange, double* ordinateRange);
172  void GetAxesUnscaledRange(double* abcissaRange, double* ordinateRange);
174 
178  void ComputeRange(double* range);
179 
183  void ComputeHandleDelta(double screenBounds[4]);
184 
186 
193  const double inX, const double inY, double& outX, double& outY) override;
195  const double inX, const double inY, double& outX, double& outY) override;
197 
201  bool Hit(const vtkContextMouseEvent& mouse) override;
202 
204 
207  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
208  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
209  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
210  bool MouseEnterEvent(const vtkContextMouseEvent& mouse) override;
211  bool MouseLeaveEvent(const vtkContextMouseEvent& mouse) override;
212  bool MouseDoubleClickEvent(const vtkContextMouseEvent& mouse) override;
214 
219  virtual int FindRangeHandle(const vtkVector2f& point, const vtkVector2f& tolerance);
220 
225  virtual void SetActiveHandlePosition(double position);
226 
231  bool IsActiveHandleMoved(double tolerance);
232 
236  void SetCursor(int cursor);
237 
239  void operator=(const vtkPlotRangeHandlesItem&) = delete;
240 
241  float HandleWidth = 2;
242  float HandleDelta = 0;
243  float LeftHandleDrawRange[2] = { 0, 0 };
244  float RightHandleDrawRange[2] = { 0, 0 };
245  int ActiveHandle = NO_HANDLE;
246  int HoveredHandle = NO_HANDLE;
247  float HoveredPosition[2] = { 0, 0 };
248  vtkTypeBool LockTooltipToMouse = true;
249  double ActiveHandlePosition = 0;
250  double ActiveHandleRangeValue = 0;
253  double Extent[4] = { 0, 1, 0, 1 };
254  vtkTypeBool ExtentToAxisRange = true;
255  vtkTypeBool SynchronizeRangeHandles = false;
256  int HandleOrientation = VERTICAL;
257 };
258 
259 #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:352
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:69
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:57
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:40
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:39
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:53
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.
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.