VTK  9.3.1
vtkColorLegend.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 
12 #ifndef vtkColorLegend_h
13 #define vtkColorLegend_h
14 
15 #include "vtkChartLegend.h"
16 #include "vtkChartsCoreModule.h" // For export macro
17 #include "vtkSmartPointer.h" // For SP ivars
18 #include "vtkVector.h" // For vtkRectf
19 
20 VTK_ABI_NAMESPACE_BEGIN
21 class vtkAxis;
23 class vtkImageData;
24 class vtkScalarsToColors;
25 class vtkCallbackCommand;
26 
27 class VTKCHARTSCORE_EXPORT vtkColorLegend : public vtkChartLegend
28 {
29 public:
31  void PrintSelf(ostream& os, vtkIndent indent) override;
32  static vtkColorLegend* New();
33 
37  enum
38  {
39  VERTICAL = 0,
40  HORIZONTAL
41  };
42 
47  virtual void GetBounds(double bounds[4]);
48 
54  void Update() override;
55 
61  bool Paint(vtkContext2D* painter) override;
62 
64 
68  virtual void SetTransferFunction(vtkScalarsToColors* transfer);
69  virtual vtkScalarsToColors* GetTransferFunction();
71 
75  void SetPoint(float x, float y) override;
76 
80  virtual void SetTextureSize(float w, float h);
81 
88  virtual void SetPosition(const vtkRectf& pos);
89 
94  virtual vtkRectf GetPosition();
95 
102  vtkRectf GetBoundingRect(vtkContext2D* painter) override;
103 
105 
109  virtual void SetOrientation(int orientation);
110  vtkGetMacro(Orientation, int);
112 
114 
117  virtual void SetTitle(const vtkStdString& title);
118  virtual vtkStdString GetTitle();
120 
122 
126  vtkSetMacro(DrawBorder, bool);
127  vtkGetMacro(DrawBorder, bool);
128  vtkBooleanMacro(DrawBorder, bool);
130 
134  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
135 
136 protected:
137  vtkColorLegend();
138  ~vtkColorLegend() override;
139 
144  virtual void ComputeTexture();
145 
147 
151  virtual void ScalarsToColorsModified(vtkObject* caller, unsigned long eid, void* calldata);
152  static void OnScalarsToColorsModified(
153  vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
155 
159  void UpdateAxisPosition();
160 
170 
171 private:
172  vtkColorLegend(const vtkColorLegend&) = delete;
173  void operator=(const vtkColorLegend&) = delete;
174 };
175 
176 VTK_ABI_NAMESPACE_END
177 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:28
void GetBounds(T a, double bds[6])
abstract base class for most VTK objects
Definition: vtkObject.h:51
virtual vtkRectf GetBoundingRect(vtkContext2D *painter)
Request the space the legend requires to be drawn.
void Update() override
Update the geometry of the axis.
Legend item to display vtkScalarsToColors.
vtkSmartPointer< vtkCallbackCommand > Callback
Superclass for mapping scalar values to colors.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
supports function callbacks
takes care of drawing 2D axes
Definition: vtkAxis.h:60
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:28
static vtkChartLegend * New()
Creates a 2D Chart object.
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
virtual void SetPoint(float, float)
Set point the legend box is anchored to.
vtkScalarsToColors * TransferFunction
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
vtkSmartPointer< vtkImageData > ImageData
draw the chart legend
bool Paint(vtkContext2D *painter) override
Paint event for the axis, called whenever the axis needs to be drawn.
vtkSmartPointer< vtkAxis > Axis