VTK  9.0.1
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;
50  static vtkRangeHandlesItem* New();
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 
80  void SetColorTransferFunction(vtkColorTransferFunction* ctf);
81  vtkGetObjectMacro(ColorTransferFunction, vtkColorTransferFunction);
83 
85 
89  vtkSetMacro(HandleWidth, float);
90  vtkGetMacro(HandleWidth, float);
92 
96  void ComputeHandlesDrawRange();
97 
98 protected:
100  ~vtkRangeHandlesItem() override;
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 
129  void SetActiveHandlePosition(double position);
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
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:343
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:37
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
item to show and control the range of a vtkColorTransferFunction
Abstract class for 2D plots.
Definition: vtkPlot.h:46
virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse)
Mouse enter event.
Defines a transfer function for mapping a property to an RGB color value.
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
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.