VTK  9.4.20251007
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
15
16#ifndef vtkPlotBar_h
17#define vtkPlotBar_h
18
19#include "vtkChartsCoreModule.h" // For export macro
20#include "vtkPlot.h"
21#include "vtkSmartPointer.h" // Needed to hold ColorSeries
22#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
23
24VTK_ABI_NAMESPACE_BEGIN
25class vtkContext2D;
26class vtkTable;
27class vtkPoints2D;
28class vtkStdString;
29class vtkColorSeries;
32
33class vtkPlotBarPrivate;
34
35class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkPlotBar : public vtkPlot
36{
37public:
38 vtkTypeMacro(vtkPlotBar, vtkPlot);
39 void PrintSelf(ostream& os, vtkIndent indent) override;
40
44 enum
45 {
48 };
49
53 static vtkPlotBar* New();
54
58 bool Paint(vtkContext2D* painter) override;
59
66 bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex) override;
67
71 void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override;
72
74
77 void SetColorF(double r, double g, double b, double a) override;
78 void SetColorF(double r, double g, double b) override;
79
80 VTK_DEPRECATED_IN_9_3_0("Please use unambiguous SetColorF method instead.")
81 void SetColor(double r, double g, double b) override { this->SetColorF(r, g, b); }
83
85
88 void GetColorF(double rgb[3]) override;
89
90 VTK_DEPRECATED_IN_9_3_0("Please use unambiguous GetColorF method instead.")
91 void GetColor(double rgb[3]) override { this->GetColorF(rgb); }
93
95
98 void SetWidth(float _arg) override
99 {
100 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Width to " << _arg);
101 if (this->Width != _arg)
102 {
103 this->Width = _arg;
104 this->Modified();
105 }
106 }
107
108
110
113 float GetWidth() override
114 {
115 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning Width of "
116 << this->Width);
117 return this->Width;
118 }
119
120
122
128 vtkSetMacro(Offset, float);
129 vtkGetMacro(Offset, float);
131
133
137 virtual void SetOrientation(int orientation);
138 vtkGetMacro(Orientation, int);
140
144 virtual void GetBounds(double bounds[4], bool unscaled);
145
149 void GetBounds(double bounds[4]) override;
150
154 void GetUnscaledInputBounds(double bounds[4]) override;
155
159 void SetInputArray(int index, const vtkStdString& name) override;
160
164 void SetColorSeries(vtkColorSeries* colorSeries);
165
170
172
178
184
186
189 vtkSetMacro(ScalarVisibility, bool);
190 vtkGetMacro(ScalarVisibility, bool);
191 vtkBooleanMacro(ScalarVisibility, bool);
193
195
198 vtkSetMacro(EnableOpacityMapping, bool);
199 vtkGetMacro(EnableOpacityMapping, bool);
200 vtkBooleanMacro(EnableOpacityMapping, bool);
202
204
210 void SelectColorArray(const vtkStdString& arrayName);
212
217
222
226 virtual void SetGroupName(const vtkStdString& name);
227
232
238 const vtkVector2d& plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex) override;
239
243 bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) override;
244
253 vtkIdType* segmentIndex) override;
255
260
264 void GetDataBounds(double bounds[2]);
265
272 bool UpdateCache() override;
273
274protected:
276 ~vtkPlotBar() override;
277
281 bool CacheRequiresUpdate() override;
282
287
288 float Width;
289 float Offset;
290
292
297
299
308
309 bool LogX;
310 bool LogY;
311
312private:
313 vtkPlotBar(const vtkPlotBar&) = delete;
314 void operator=(const vtkPlotBar&) = delete;
315
316 vtkPlotBarPrivate* Private;
317};
318
319VTK_ABI_NAMESPACE_END
320#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:29
const char * GetClassName() const
Return the class name as a string.
virtual void Modified()
Update the modification time for this object.
virtual void SetLookupTable(vtkScalarsToColors *lut)
Specify a lookup table for the mapper to use.
float Width
Definition vtkPlotBar.h:288
int Orientation
Definition vtkPlotBar.h:291
vtkStringArray * GetLabels() override
Get the plot labels.
vtkStdString GetTooltipLabel(const vtkVector2d &plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex) override
Generate and return the tooltip label string for this plot The segmentIndex is implemented here.
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 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:302
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:303
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:113
bool UpdateCache() override
Update the internal cache.
bool ScalarVisibility
Lookup Table for coloring bars by scalar value.
Definition vtkPlotBar.h:304
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:306
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:286
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:305
void GetColor(double rgb[3]) override
Get the plot color as floating rgb values (comprised between 0.0 and 1.0)
Definition vtkPlotBar.h:91
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:296
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
float Offset
Definition vtkPlotBar.h:289
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:98
virtual void SetColorF(double r, double g, double b, double a)
Set the plot color with floating values (comprised between 0.0 and 1.0)
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.
virtual void GetColorF(double rgb[3])
Get the plot color as floating rgb values (comprised between 0.0 and 1.0)
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:60
dynamic, self-adjusting array of unsigned char
#define VTK_DEPRECATED_IN_9_3_0(reason)
int vtkIdType
Definition vtkType.h:315
#define VTK_MARSHALAUTO
#define max(a, b)