VTK  9.6.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
11
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
21VTK_ABI_NAMESPACE_BEGIN
22class vtkAxis;
24class vtkImageData;
27
28class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkColorLegend : public vtkChartLegend
29{
30public:
32 void PrintSelf(ostream& os, vtkIndent indent) override;
34
38 enum
39 {
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);
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
97
105
107
111 virtual void SetOrientation(int orientation);
112 vtkGetMacro(Orientation, int);
114
116
119 virtual void SetTitle(const vtkStdString& title);
122
124
128 vtkSetMacro(DrawBorder, bool);
129 vtkGetMacro(DrawBorder, bool);
130 vtkBooleanMacro(DrawBorder, bool);
132
136 bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
137
138protected:
140 ~vtkColorLegend() override;
141
146 virtual void ComputeTexture();
147
149
153 virtual void ScalarsToColorsModified(vtkObject* caller, unsigned long eid, void* calldata);
155 vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
157
162
172
173private:
174 vtkColorLegend(const vtkColorLegend&) = delete;
175 void operator=(const vtkColorLegend&) = delete;
176};
177
178VTK_ABI_NAMESPACE_END
179#endif
takes care of drawing 2D axes
Definition vtkAxis.h:62
supports function callbacks
vtkRectf GetBoundingRect(vtkContext2D *painter) override
Request the space the legend requires to be drawn.
virtual void SetOrientation(int orientation)
Set/get the orientation of the legend.
virtual void GetBounds(double bounds[4])
Bounds of the item, by default (0, 1, 0, 1) but it mainly depends on the range of the vtkScalarsToCol...
virtual vtkRectf GetPosition()
Returns the origin, width, and height of the scalar bar drawn by this legend.
void SetPoint(float x, float y) override
Set the point this legend is anchored to.
static vtkColorLegend * New()
void UpdateAxisPosition()
Moves the axis whenever the position of this legend changes.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSmartPointer< vtkCallbackCommand > Callback
vtkSmartPointer< vtkImageData > ImageData
virtual void ComputeTexture()
Need to be reimplemented by subclasses, ComputeTexture() is called at paint time if the texture is no...
vtkSmartPointer< vtkScalarsToColors > TransferFunction
virtual vtkScalarsToColors * GetTransferFunction()
Set/Get the transfer function that is used to draw the scalar bar within this legend.
virtual void SetTextureSize(float w, float h)
Set the size of the scalar bar drawn by this legend.
virtual void GetTextureSize(float &w, float &h)
static void OnScalarsToColorsModified(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
Called whenever the ScalarsToColors function(s) is modified.
virtual void SetPosition(const vtkRectf &pos)
Set the origin, width, and height of the scalar bar drawn by this legend.
virtual vtkStdString GetTitle()
Get/set the title text of the legend.
~vtkColorLegend() override
void Update() override
Perform any updates to the item that may be necessary before rendering.
vtkSmartPointer< vtkAxis > Axis
virtual void ScalarsToColorsModified(vtkObject *caller, unsigned long eid, void *calldata)
Called whenever the ScalarsToColors function(s) is modified.
virtual void SetTitle(const vtkStdString &title)
Get/set the title text of the legend.
bool Paint(vtkContext2D *painter) override
Paint the texture into a rectangle defined by the bounds.
virtual void SetTransferFunction(vtkScalarsToColors *transfer)
Set/Get the transfer function that is used to draw the scalar bar within this legend.
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
Class for drawing 2D primitives to a graphical context.
data structure to represent mouse events.
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:29
abstract base class for most VTK objects
Definition vtkObject.h:53
Superclass for mapping scalar values to colors.
Computes the portion of a dataset which is inside a selection.
Hold a reference to a vtkObjectBase instance.
Wrapper around std::string to keep symbols short.
#define VTK_MARSHALAUTO