VTK  9.1.0
vtkColorLegend.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkColorLegend.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
43 #ifndef vtkColorLegend_h
44 #define vtkColorLegend_h
45 
46 #include "vtkChartLegend.h"
47 #include "vtkChartsCoreModule.h" // For export macro
48 #include "vtkSmartPointer.h" // For SP ivars
49 #include "vtkVector.h" // For vtkRectf
50 
51 class vtkAxis;
53 class vtkImageData;
54 class vtkScalarsToColors;
55 class vtkCallbackCommand;
56 
57 class VTKCHARTSCORE_EXPORT vtkColorLegend : public vtkChartLegend
58 {
59 public:
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62  static vtkColorLegend* New();
63 
67  enum
68  {
69  VERTICAL = 0,
70  HORIZONTAL
71  };
72 
77  virtual void GetBounds(double bounds[4]);
78 
84  void Update() override;
85 
91  bool Paint(vtkContext2D* painter) override;
92 
94 
98  virtual void SetTransferFunction(vtkScalarsToColors* transfer);
101 
105  void SetPoint(float x, float y) override;
106 
110  virtual void SetTextureSize(float w, float h);
111 
118  virtual void SetPosition(const vtkRectf& pos);
119 
125 
133 
135 
139  virtual void SetOrientation(int orientation);
140  vtkGetMacro(Orientation, int);
142 
144 
147  virtual void SetTitle(const vtkStdString& title);
150 
152 
156  vtkSetMacro(DrawBorder, bool);
157  vtkGetMacro(DrawBorder, bool);
158  vtkBooleanMacro(DrawBorder, bool);
160 
164  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
165 
166 protected:
168  ~vtkColorLegend() override;
169 
174  virtual void ComputeTexture();
175 
177 
181  virtual void ScalarsToColorsModified(vtkObject* caller, unsigned long eid, void* calldata);
183  vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
185 
190 
200 
201 private:
202  vtkColorLegend(const vtkColorLegend&) = delete;
203  void operator=(const vtkColorLegend&) = delete;
204 };
205 
206 #endif
vtkColorLegend::GetTransferFunction
virtual vtkScalarsToColors * GetTransferFunction()
Set/Get the transfer function that is used to draw the scalar bar within this legend.
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:54
vtkColorLegend::ComputeTexture
virtual void ComputeTexture()
Need to be reimplemented by subclasses, ComputeTexture() is called at paint time if the texture is no...
vtkColorLegend::~vtkColorLegend
~vtkColorLegend() override
vtkColorLegend::Orientation
int Orientation
Definition: vtkColorLegend.h:199
vtkColorLegend::Update
void Update() override
Perform any updates to the item that may be necessary before rendering.
vtkChartLegend
draw the chart legend
Definition: vtkChartLegend.h:69
vtkColorLegend::GetPosition
virtual vtkRectf GetPosition()
Returns the origin, width, and height of the scalar bar drawn by this legend.
vtkSmartPointer< vtkImageData >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:82
vtkVector.h
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:73
vtkColorLegend::SetPoint
void SetPoint(float x, float y) override
Set the point this legend is anchored to.
vtkColorLegend::MouseMoveEvent
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
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::Callback
vtkSmartPointer< vtkCallbackCommand > Callback
Definition: vtkColorLegend.h:194
vtkColorLegend::TransferFunction
vtkScalarsToColors * TransferFunction
Definition: vtkColorLegend.h:191
vtkColorLegend::GetTitle
virtual vtkStdString GetTitle()
Get/set the title text of the legend.
vtkX3D::title
@ title
Definition: vtkX3D.h:506
vtkColorLegend::ImageData
vtkSmartPointer< vtkImageData > ImageData
Definition: vtkColorLegend.h:192
vtkColorLegend::SetTitle
virtual void SetTitle(const vtkStdString &title)
Get/set the title text of the legend.
vtkColorLegend::OnScalarsToColorsModified
static void OnScalarsToColorsModified(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
Called whenever the ScalarsToColors function(s) is modified.
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkSmartPointer.h
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:109
vtkColorLegend::GetBoundingRect
vtkRectf GetBoundingRect(vtkContext2D *painter) override
Request the space the legend requires to be drawn.
vtkColorLegend::UpdateAxisPosition
void UpdateAxisPosition()
Moves the axis whenever the position of this legend changes.
vtkColorLegend::vtkColorLegend
vtkColorLegend()
vtkColorLegend
Legend item to display vtkScalarsToColors.
Definition: vtkColorLegend.h:58
vtkX3D::orientation
@ orientation
Definition: vtkX3D.h:268
vtkColorLegend::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:178
vtkChartLegend.h
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:154
vtkColorLegend::DrawBorder
bool DrawBorder
Definition: vtkColorLegend.h:197
vtkColorLegend::ScalarsToColorsModified
virtual void ScalarsToColorsModified(vtkObject *caller, unsigned long eid, void *calldata)
Called whenever the ScalarsToColors function(s) is modified.
vtkColorLegend::New
static vtkColorLegend * New()
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:105
vtkColorLegend::Axis
vtkSmartPointer< vtkAxis > Axis
Definition: vtkColorLegend.h:193
vtkColorLegend::SetTransferFunction
virtual void SetTransferFunction(vtkScalarsToColors *transfer)
Set/Get the transfer function that is used to draw the scalar bar within this legend.
vtkColorLegend::SetPosition
virtual void SetPosition(const vtkRectf &pos)
Set the origin, width, and height of the scalar bar drawn by this legend.
vtkRectf
Definition: vtkRect.h:336
vtkColorLegend::SetTextureSize
virtual void SetTextureSize(float w, float h)
Set the size of the scalar bar drawn by this legend.
h
vtkFrustumSelector is a vtkSelector that selects elements based on whether they are inside or interse...
vtkColorLegend::Paint
bool Paint(vtkContext2D *painter) override
Paint the texture into a rectangle defined by the bounds.
vtkColorLegend::SetOrientation
virtual void SetOrientation(int orientation)
Set/get the orientation of the legend.
vtkColorLegend::Position
vtkRectf Position
Definition: vtkColorLegend.h:198
vtkColorLegend::CustomPositionSet
bool CustomPositionSet
Definition: vtkColorLegend.h:196
vtkColorLegend::Interpolate
bool Interpolate
Definition: vtkColorLegend.h:195