VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
20 
21 VTK_ABI_NAMESPACE_BEGIN
22 class vtkAxis;
24 class vtkImageData;
25 class vtkScalarsToColors;
26 class vtkCallbackCommand;
27 
28 class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkColorLegend : public vtkChartLegend
29 {
30 public:
32  void PrintSelf(ostream& os, vtkIndent indent) override;
33  static vtkColorLegend* New();
34 
38  enum
39  {
40  VERTICAL = 0,
41  HORIZONTAL
42  };
43 
48  virtual void GetBounds(double bounds[4]);
49 
55  void Update() override;
56 
62  bool Paint(vtkContext2D* painter) override;
63 
65 
69  virtual void SetTransferFunction(vtkScalarsToColors* transfer);
70  virtual vtkScalarsToColors* GetTransferFunction();
72 
76  void SetPoint(float x, float y) override;
77 
81  virtual void SetTextureSize(float w, float h);
82  virtual void GetTextureSize(float& w, float& h);
83 
90  virtual void SetPosition(const vtkRectf& pos);
91 
96  virtual vtkRectf GetPosition();
97 
104  vtkRectf GetBoundingRect(vtkContext2D* painter) override;
105 
107 
111  virtual void SetOrientation(int orientation);
112  vtkGetMacro(Orientation, int);
114 
116 
119  virtual void SetTitle(const vtkStdString& title);
120  virtual vtkStdString GetTitle();
122 
124 
128  vtkSetMacro(DrawBorder, bool);
129  vtkGetMacro(DrawBorder, bool);
130  vtkBooleanMacro(DrawBorder, bool);
132 
136  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
137 
138 protected:
139  vtkColorLegend();
140  ~vtkColorLegend() override;
141 
146  virtual void ComputeTexture();
147 
149 
153  virtual void ScalarsToColorsModified(vtkObject* caller, unsigned long eid, void* calldata);
154  static void OnScalarsToColorsModified(
155  vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
157 
161  void UpdateAxisPosition();
162 
172 
173 private:
174  vtkColorLegend(const vtkColorLegend&) = delete;
175  void operator=(const vtkColorLegend&) = delete;
176 };
177 
178 VTK_ABI_NAMESPACE_END
179 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:27
void GetBounds(T a, double bds[6])
abstract base class for most VTK objects
Definition: vtkObject.h:52
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:61
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:45
virtual void SetPoint(float, float)
Set point the legend box is anchored to.
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
#define VTK_MARSHALAUTO
vtkSmartPointer< vtkScalarsToColors > TransferFunction