VTK  9.0.2
vtkRangeHandlesItem.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkRangeHandlesItem.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 
35 #ifndef vtkRangeHandlesItem_h
36 #define vtkRangeHandlesItem_h
37 
38 #include "vtkChartsCoreModule.h" // For export macro
39 #include "vtkCommand.h" // For vtkCommand enum
40 #include "vtkPlot.h"
41 
43 class vtkBrush;
44 
45 class VTKCHARTSCORE_EXPORT vtkRangeHandlesItem : public vtkPlot
46 {
47 public:
48  vtkTypeMacro(vtkRangeHandlesItem, vtkPlot);
49  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
52  enum Handle
53  {
54  NO_HANDLE = -1,
55  LEFT_HANDLE = 0,
56  RIGHT_HANDLE = 1
57  };
58 
63  bool Paint(vtkContext2D* painter) override;
64 
68  void GetBounds(double bounds[4]) override;
69 
74  virtual void GetHandlesRange(double range[2]);
75 
77 
81  vtkGetObjectMacro(ColorTransferFunction, vtkColorTransferFunction);
83 
85 
89  vtkSetMacro(HandleWidth, float);
90  vtkGetMacro(HandleWidth, float);
92 
97 
98 protected:
101 
105  bool Hit(const vtkContextMouseEvent& mouse) override;
106 
108 
111  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
112  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
113  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
114  bool MouseEnterEvent(const vtkContextMouseEvent& mouse) override;
115  bool MouseLeaveEvent(const vtkContextMouseEvent& mouse) override;
116  bool MouseDoubleClickEvent(const vtkContextMouseEvent& mouse) override;
118 
123  virtual int FindRangeHandle(const vtkVector2f& point, const vtkVector2f& tolerance);
124 
130 
135  bool IsActiveHandleMoved(double tolerance);
136 
140  void SetCursor(int cursor);
141 
142 private:
143  vtkRangeHandlesItem(const vtkRangeHandlesItem&) = delete;
144  void operator=(const vtkRangeHandlesItem&) = delete;
145 
146  vtkColorTransferFunction* ColorTransferFunction = nullptr;
147 
148  float HandleWidth = 2;
149  float HandleDelta = 0;
150  float LeftHandleDrawRange[2] = { 0, 0 };
151  float RightHandleDrawRange[2] = { 0, 0 };
152  int ActiveHandle = NO_HANDLE;
153  int HoveredHandle = NO_HANDLE;
154  double ActiveHandlePosition = 0;
155  double ActiveHandleRangeValue = 0;
156  vtkNew<vtkBrush> HighlightBrush;
157  vtkNew<vtkBrush> RangeLabelBrush;
158 };
159 
160 #endif // vtkRangeHandlesItem_h
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:38
Defines a transfer function for mapping a property to an RGB color value.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:53
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:34
Abstract class for 2D plots.
Definition: vtkPlot.h:47
item to show and control the range of a vtkColorTransferFunction
void SetActiveHandlePosition(double position)
Internal method to set the ActiveHandlePosition and compute the ActiveHandleRangeValue accordingly.
bool Hit(const vtkContextMouseEvent &mouse) override
Returns true if the supplied x, y coordinate is around a handle.
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override
Mouse button release event.
bool MouseEnterEvent(const vtkContextMouseEvent &mouse) override
Mouse enter event.
virtual void GetHandlesRange(double range[2])
Recover the range currently set by the handles Use this method by observing EndInteractionEvent.
bool MouseLeaveEvent(const vtkContextMouseEvent &mouse) override
Mouse leave event.
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,...
bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override
Interaction methods to interact with the handles.
bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse) override
Mouse button double click event.
void SetColorTransferFunction(vtkColorTransferFunction *ctf)
Get/set the color transfer function to interact with.
bool Paint(vtkContext2D *painter) override
Paint both handles and the range if a handle is active or hovered.
static vtkRangeHandlesItem * New()
bool IsActiveHandleMoved(double tolerance)
Internal method to check if the active handle have actually been moved.
void SetCursor(int cursor)
Set the cursor shape.
void GetBounds(double bounds[4]) override
Recover the bounds of the item.
~vtkRangeHandlesItem() override
void ComputeHandlesDrawRange()
Compute the handles draw range by using the handle width and the transfer function.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
@ point
Definition: vtkX3D.h:242
@ range
Definition: vtkX3D.h:244
@ position
Definition: vtkX3D.h:267