VTK  9.3.0
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;
32 class vtkImageData;
33 class vtkScalarsToColors;
34 class vtkCallbackCommand;
35 
36 class VTKCHARTSCORE_EXPORT vtkColorLegend : public vtkChartLegend
37 {
38 public:
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);
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 
104 
112 
114 
118  virtual void SetOrientation(int orientation);
119  vtkGetMacro(Orientation, int);
121 
123 
126  virtual void SetTitle(const vtkStdString& title);
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:
147  ~vtkColorLegend() override;
148 
153  virtual void ComputeTexture();
154 
156 
160  virtual void ScalarsToColorsModified(vtkObject* caller, unsigned long eid, void* calldata);
162  vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
164 
169 
179 
180 private:
181  vtkColorLegend(const vtkColorLegend&) = delete;
182  void operator=(const vtkColorLegend&) = delete;
183 };
184 
185 VTK_ABI_NAMESPACE_END
186 #endif
takes care of drawing 2D axes
Definition: vtkAxis.h:70
supports function callbacks
draw the chart legend
Legend item to display vtkScalarsToColors.
static vtkColorLegend * New()
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.
virtual vtkScalarsToColors * GetTransferFunction()
Set/Get the transfer function that is used to draw the scalar bar within this legend.
void SetPoint(float x, float y) override
Set the point this legend is anchored to.
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...
virtual void SetTextureSize(float w, float h)
Set the size of the scalar bar drawn by this legend.
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.
vtkScalarsToColors * TransferFunction
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.
Definition: vtkContext2D.h:59
data structure to represent mouse events.
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract base class for most VTK objects
Definition: vtkObject.h:61
Superclass for mapping scalar values to colors.
Computes the portion of a dataset which is inside a selection.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
@ orientation
Definition: vtkX3D.h:262
@ title
Definition: vtkX3D.h:500