VTK: Charts/Core/vtkColorLegend.h Source File

| 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
21 #ifndef vtkColorLegend_h
22 #define vtkColorLegend_h
23
24 #include "vtkChartLegend.h"
25 #include "vtkChartsCoreModule.h" // For export macro
26 #include "vtkSmartPointer.h" // For SP ivars
27 #include "vtkVector.h" // For vtkRectf
28
29 VTK_ABI_NAMESPACE_BEGIN
30 class vtkAxis;
31 class vtkContextMouseEvent;
32 class vtkImageData;
33 class vtkScalarsToColors;
34 class vtkCallbackCommand;
35
36 class VTKCHARTSCORE_EXPORT vtkColorLegend : public vtkChartLegend
37 {
38 public:
39 vtkTypeMacro(vtkColorLegend, vtkChartLegend);
40 void PrintSelf(ostream& os, vtkIndent indent) override;
41 static vtkColorLegend* New();
42
46 enum
47 {
48 VERTICAL = 0,
49 HORIZONTAL
50 };
51
56 virtual void GetBounds(double bounds[4]);
57
63 void Update() override;
64
70 bool Paint(vtkContext2D* painter) override;
71
73
77 virtual void SetTransferFunction(vtkScalarsToColors* transfer);
78 virtual vtkScalarsToColors* GetTransferFunction();
80
84 void SetPoint(float x, float y) override;
85
89 virtual void SetTextureSize(float w, float h);
90
97 virtual void SetPosition(const vtkRectf& pos);
98
103 virtual vtkRectf GetPosition();
104
111 vtkRectf GetBoundingRect(vtkContext2D* painter) override;
112
114
118 virtual void SetOrientation(int orientation);
119 vtkGetMacro(Orientation, int);
121
123
126 virtual void SetTitle(const vtkStdString& title);
127 virtual vtkStdString GetTitle();
129
131
135 vtkSetMacro(DrawBorder, bool);
136 vtkGetMacro(DrawBorder, bool);
137 vtkBooleanMacro(DrawBorder, bool);
139
143 bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
144
145 protected:
146 vtkColorLegend();
147 ~vtkColorLegend() override;
148
153 virtual void ComputeTexture();
154
156
160 virtual void ScalarsToColorsModified(vtkObject* caller, unsigned long eid, void* calldata);
161 static void OnScalarsToColorsModified(
162 vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
164
168 void UpdateAxisPosition();
169
170 vtkScalarsToColors* TransferFunction;
171 vtkSmartPointer<vtkImageData> ImageData;
172 vtkSmartPointer<vtkAxis> Axis;
173 vtkSmartPointer<vtkCallbackCommand> Callback;
174 bool Interpolate;
175 bool CustomPositionSet;
176 bool DrawBorder;
177 vtkRectf Position;
178 int Orientation;
179
180 private:
181 vtkColorLegend(const vtkColorLegend&) = delete;
182 void operator=(const vtkColorLegend&) = delete;
183 };
184
185 VTK_ABI_NAMESPACE_END
186 #endif
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:70
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:49
vtkChartLegend
draw the chart legend
Definition: vtkChartLegend.h:41
vtkColorLegend
Legend item to display vtkScalarsToColors.
Definition: vtkColorLegend.h:37
vtkColorLegend::Position
vtkRectf Position
Definition: vtkColorLegend.h:177
vtkColorLegend::CustomPositionSet
bool CustomPositionSet
Definition: vtkColorLegend.h:175
vtkColorLegend::New
static vtkColorLegend * New()
vtkColorLegend::GetBoundingRect
vtkRectf GetBoundingRect(vtkContext2D *painter) override
Request the space the legend requires to be drawn.
vtkColorLegend::DrawBorder
bool DrawBorder
Definition: vtkColorLegend.h:176
vtkColorLegend::SetOrientation
virtual void SetOrientation(int orientation)
Set/get the orientation of the legend.
vtkColorLegend::GetBounds
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...
vtkColorLegend::GetPosition
virtual vtkRectf GetPosition()
Returns the origin, width, and height of the scalar bar drawn by this legend.
vtkColorLegend::GetTransferFunction
virtual vtkScalarsToColors * GetTransferFunction()
Set/Get the transfer function that is used to draw the scalar bar within this legend.
vtkColorLegend::SetPoint
void SetPoint(float x, float y) override
Set the point this legend is anchored to.
vtkColorLegend::Orientation
int Orientation
Definition: vtkColorLegend.h:178
vtkColorLegend::UpdateAxisPosition
void UpdateAxisPosition()
Moves the axis whenever the position of this legend changes.
vtkColorLegend::vtkColorLegend
vtkColorLegend()
vtkColorLegend::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkColorLegend::Callback
vtkSmartPointer< vtkCallbackCommand > Callback
Definition: vtkColorLegend.h:173
vtkColorLegend::ImageData
vtkSmartPointer< vtkImageData > ImageData
Definition: vtkColorLegend.h:171
vtkColorLegend::ComputeTexture
virtual void ComputeTexture()
Need to be reimplemented by subclasses, ComputeTexture() is called at paint time if the texture is no...
vtkColorLegend::SetTextureSize
virtual void SetTextureSize(float w, float h)
Set the size of the scalar bar drawn by this legend.
vtkColorLegend::OnScalarsToColorsModified
static void OnScalarsToColorsModified(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
Called whenever the ScalarsToColors function(s) is modified.
vtkColorLegend::SetPosition
virtual void SetPosition(const vtkRectf &pos)
Set the origin, width, and height of the scalar bar drawn by this legend.
vtkColorLegend::GetTitle
virtual vtkStdString GetTitle()
Get/set the title text of the legend.
vtkColorLegend::~vtkColorLegend
~vtkColorLegend() override
vtkColorLegend::Update
void Update() override
Perform any updates to the item that may be necessary before rendering.
vtkColorLegend::Axis
vtkSmartPointer< vtkAxis > Axis
Definition: vtkColorLegend.h:172
vtkColorLegend::ScalarsToColorsModified
virtual void ScalarsToColorsModified(vtkObject *caller, unsigned long eid, void *calldata)
Called whenever the ScalarsToColors function(s) is modified.
vtkColorLegend::TransferFunction
vtkScalarsToColors * TransferFunction
Definition: vtkColorLegend.h:170
vtkColorLegend::SetTitle
virtual void SetTitle(const vtkStdString &title)
Get/set the title text of the legend.
vtkColorLegend::Paint
bool Paint(vtkContext2D *painter) override
Paint the texture into a rectangle defined by the bounds.
vtkColorLegend::SetTransferFunction
virtual void SetTransferFunction(vtkScalarsToColors *transfer)
Set/Get the transfer function that is used to draw the scalar bar within this legend.
vtkColorLegend::Interpolate
bool Interpolate
Definition: vtkColorLegend.h:174
vtkColorLegend::MouseMoveEvent
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:59
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:39
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkRectf
Definition: vtkRect.h:328
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:65
h
Computes the portion of a dataset which is inside a selection.
vtkSmartPointer< vtkImageData >
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
vtkX3D::orientation
@ orientation
Definition: vtkX3D.h:262
vtkX3D::title
@ title
Definition: vtkX3D.h:500
vtkChartLegend.h
vtkSmartPointer.h
vtkVector.h