VTK  9.5.20250901
vtkPlotBar.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
35#ifndef vtkPlotBar_h
36#define vtkPlotBar_h
37
38#include "vtkChartsCoreModule.h" // For export macro
39#include "vtkPlot.h"
40#include "vtkSmartPointer.h" // Needed to hold ColorSeries
41#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
42
43VTK_ABI_NAMESPACE_BEGIN
44class vtkContext2D;
45class vtkTable;
46class vtkPoints2D;
47class vtkStdString;
48class vtkColorSeries;
51
52class vtkPlotBarPrivate;
53
54class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkPlotBar : public vtkPlot
55{
56public:
57 vtkTypeMacro(vtkPlotBar, vtkPlot);
58 void PrintSelf(ostream& os, vtkIndent indent) override;
59
63 enum
64 {
65 VERTICAL = 0,
66 HORIZONTAL
67 };
68
72 static vtkPlotBar* New();
73
77 bool Paint(vtkContext2D* painter) override;
78
85 bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex) override;
86
90 void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override;
91 void SetColor(unsigned char r, unsigned char g, unsigned char b) override;
92
94
97 void SetColorF(double r, double g, double b, double a) override;
98 void SetColorF(double r, double g, double b) override;
100
102
105 void GetColorF(double rgb[3]) override;
107
109
112 void SetWidth(float _arg) override
113 {
114 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Width to " << _arg);
115 if (this->Width != _arg)
116 {
117 this->Width = _arg;
118 this->Modified();
119 }
120 }
122
124
127 float GetWidth() override
128 {
129 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning Width of "
130 << this->Width);
131 return this->Width;
132 }
134
136
142 vtkSetMacro(Offset, float);
143 vtkGetMacro(Offset, float);
145
147
151 virtual void SetOrientation(int orientation);
152 vtkGetMacro(Orientation, int);
154
158 virtual void GetBounds(double bounds[4], bool unscaled);
159
163 void GetBounds(double bounds[4]) override;
164
168 void GetUnscaledInputBounds(double bounds[4]) override;
169
173 void SetInputArray(int index, const vtkStdString& name) override;
174
178 void SetColorSeries(vtkColorSeries* colorSeries);
179
184
186
192
198
200
203 vtkSetMacro(ScalarVisibility, bool);
204 vtkGetMacro(ScalarVisibility, bool);
205 vtkBooleanMacro(ScalarVisibility, bool);
207
209
212 vtkSetMacro(EnableOpacityMapping, bool);
213 vtkGetMacro(EnableOpacityMapping, bool);
214 vtkBooleanMacro(EnableOpacityMapping, bool);
216
218
224 void SelectColorArray(const vtkStdString& arrayName);
226
231
236
240 virtual void SetGroupName(const vtkStdString& name);
241
246
250 bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) override;
251
260 vtkIdType* segmentIndex) override;
262
267
271 void GetDataBounds(double bounds[2]);
272
279 bool UpdateCache() override;
280
281protected:
283 ~vtkPlotBar() override;
284
288 bool CacheRequiresUpdate() override;
289
294
295 float Width;
296 float Offset;
297
299
304
306
315
316 bool LogX;
317 bool LogY;
318
319private:
320 vtkPlotBar(const vtkPlotBar&) = delete;
321 void operator=(const vtkPlotBar&) = delete;
322
323 vtkPlotBarPrivate* Private;
324};
325
326VTK_ABI_NAMESPACE_END
327#endif // vtkPlotBar_h
stores a list of colors.
Class for drawing 2D primitives to a graphical context.
a simple class to control print indentation
Definition vtkIndent.h:108
const char * GetClassName() const
Return the class name as a string.
virtual void Modified()
Update the modification time for this object.
Class for drawing an XY plot given two columns from a vtkTable.
Definition vtkPlotBar.h:55
virtual void SetLookupTable(vtkScalarsToColors *lut)
Specify a lookup table for the mapper to use.
float Width
Definition vtkPlotBar.h:295
int Orientation
Definition vtkPlotBar.h:298
vtkStringArray * GetLabels() override
Get the plot labels.
void GetUnscaledInputBounds(double bounds[4]) override
Get un-log-scaled bounds for this mapper as (Xmin,Xmax,Ymin,Ymax).
int GetBarsCount()
Get amount of plotted bars.
void SetColor(unsigned char r, unsigned char g, unsigned char b) override
Set the plot color with integer values (comprised between 0 and 255)
void GetBounds(double bounds[4]) override
Get the bounds for this mapper as (Xmin,Xmax,Ymin,Ymax).
static vtkPlotBar * New()
Creates a 2D Chart object.
void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override
Set the plot color with integer values (comprised between 0 and 255)
vtkSmartPointer< vtkScalarsToColors > LookupTable
Lookup Table for coloring bars by scalar value.
Definition vtkPlotBar.h:309
void SelectColorArray(vtkIdType arrayNum)
When ScalarMode is set to UsePointFieldData or UseCellFieldData, you can specify which array to use f...
vtkSmartPointer< vtkUnsignedCharArray > Colors
Lookup Table for coloring bars by scalar value.
Definition vtkPlotBar.h:310
void GetColorF(double rgb[3]) override
Get the plot color as floating rgb values (comprised between 0.0 and 1.0)
virtual vtkScalarsToColors * GetLookupTable()
Specify a lookup table for the mapper to use.
vtkStdString GetColorArrayName()
Get the array name to color by.
vtkColorSeries * GetColorSeries()
Get the color series used if when this is a stacked bar plot.
virtual void SetGroupName(const vtkStdString &name)
Set the group name of the bar chart - can be displayed on the X axis.
float GetWidth() override
Get the width of the line.
Definition vtkPlotBar.h:127
bool UpdateCache() override
Update the internal cache.
bool ScalarVisibility
Lookup Table for coloring bars by scalar value.
Definition vtkPlotBar.h:311
void SetInputArray(int index, const vtkStdString &name) override
When used to set additional arrays, stacked bars are created.
vtkStdString ColorArrayName
Lookup Table for coloring bars by scalar value.
Definition vtkPlotBar.h:313
void SetColorF(double r, double g, double b, double a) override
Set the plot color with floating values (comprised between 0.0 and 1.0)
virtual void GetBounds(double bounds[4], bool unscaled)
A helper used by both GetUnscaledBounds and GetBounds(double[4]).
void SetColorF(double r, double g, double b) override
Set the plot color with floating values (comprised between 0.0 and 1.0)
~vtkPlotBar() override
void SetColorSeries(vtkColorSeries *colorSeries)
Set the color series to use if this becomes a stacked bar plot.
vtkPoints2D * Points
Store a well packed set of XY coordinates for this data series.
Definition vtkPlotBar.h:293
void SelectColorArray(const vtkStdString &arrayName)
When ScalarMode is set to UsePointFieldData or UseCellFieldData, you can specify which array to use f...
bool EnableOpacityMapping
Lookup Table for coloring bars by scalar value.
Definition vtkPlotBar.h:312
vtkIdType GetNearestPoint(const vtkVector2f &point, const vtkVector2f &, vtkVector2f *location, vtkIdType *segmentIndex) override
Function to query a plot for the nearest point to the specified coordinate.
vtkSmartPointer< vtkColorSeries > ColorSeries
The color series to use if this becomes a stacked bar.
Definition vtkPlotBar.h:303
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
float Offset
Definition vtkPlotBar.h:296
bool CacheRequiresUpdate() override
Test if the internal cache requires an update.
virtual vtkStdString GetGroupName()
Get the group name of the bar char - can be displayed on the X axis.
bool Paint(vtkContext2D *painter) override
Paint event for the XY plot, called whenever the chart needs to be drawn.
void GetDataBounds(double bounds[2])
Get the data bounds for this mapper as (Xmin,Xmax).
virtual void SetOrientation(int orientation)
Set/get the orientation of the bars.
virtual void CreateDefaultLookupTable()
Create default lookup table.
bool SelectPoints(const vtkVector2f &min, const vtkVector2f &max) override
Select all points in the specified rectangle.
bool PaintLegend(vtkContext2D *painter, const vtkRectf &rect, int legendIndex) override
Paint legend event for the XY plot, called whenever the legend needs the plot items symbol/mark/line ...
void SetWidth(float _arg) override
Set the width of the line.
Definition vtkPlotBar.h:112
Abstract class for 2D plots.
Definition vtkPlot.h:153
virtual vtkIdType GetNearestPoint(const vtkVector2f &point, const vtkVector2f &tolerance, vtkVector2f *location, vtkIdType *segmentId)
Function to query a plot for the nearest point to the specified coordinate.
represent and manipulate 2D points
Definition vtkPoints2D.h:27
Superclass for mapping scalar values to colors.
Hold a reference to a vtkObjectBase instance.
Wrapper around std::string to keep symbols short.
a vtkAbstractArray subclass for strings
A table, which contains similar-typed columns of data.
Definition vtkTable.h:169
dynamic, self-adjusting array of unsigned char
int vtkIdType
Definition vtkType.h:332
#define VTK_MARSHALAUTO
#define max(a, b)