VTK: Charts/Core/vtkPlotBar.h Source File

| VTK 9.3.1

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
25 #ifndef vtkPlotBar_h
26 #define vtkPlotBar_h
27
28 #include "vtkChartsCoreModule.h" // For export macro
29 #include "vtkPlot.h"
30 #include "vtkSmartPointer.h" // Needed to hold ColorSeries
31
32 VTK_ABI_NAMESPACE_BEGIN
33 class vtkContext2D;
34 class vtkTable;
35 class vtkPoints2D;
36 class vtkStdString;
37 class vtkColorSeries;
38 class vtkUnsignedCharArray;
39 class vtkScalarsToColors;
40
41 class vtkPlotBarPrivate;
42
43 class VTKCHARTSCORE_EXPORT vtkPlotBar : public vtkPlot
44 {
45 public:
46 vtkTypeMacro(vtkPlotBar, vtkPlot);
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
52 enum
53 {
54 VERTICAL = 0,
55 HORIZONTAL
56 };
57
61 static vtkPlotBar* New();
62
66 bool Paint(vtkContext2D* painter) override;
67
74 bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex) override;
75
79 void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override;
80
82
85 void SetColorF(double r, double g, double b, double a) override;
86 void SetColorF(double r, double g, double b) override;
87
88 VTK_DEPRECATED_IN_9_3_0("Please use unambiguous SetColorF method instead.")
89 void SetColor(double r, double g, double b) override { this->SetColorF(r, g, b); };
91
93
96 void GetColorF(double rgb[3]) override;
97
98 VTK_DEPRECATED_IN_9_3_0("Please use unambiguous GetColorF method instead.")
99 void GetColor(double rgb[3]) override { this->GetColorF(rgb); };
101
103
106 void SetWidth(float _arg) override
107 {
108 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Width to " << _arg);
109 if (this->Width != _arg)
110 {
111 this->Width = _arg;
112 this->Modified();
113 }
114 }
116
118
121 float GetWidth() override
122 {
123 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning Width of "
124 << this->Width);
125 return this->Width;
126 }
128
130
136 vtkSetMacro(Offset, float);
137 vtkGetMacro(Offset, float);
139
141
145 virtual void SetOrientation(int orientation);
146 vtkGetMacro(Orientation, int);
148
152 virtual void GetBounds(double bounds[4], bool unscaled);
153
157 void GetBounds(double bounds[4]) override;
158
162 void GetUnscaledInputBounds(double bounds[4]) override;
163
167 void SetInputArray(int index, const vtkStdString& name) override;
168
172 void SetColorSeries(vtkColorSeries* colorSeries);
173
177 vtkColorSeries* GetColorSeries();
178
180
183 virtual void SetLookupTable(vtkScalarsToColors* lut);
184 virtual vtkScalarsToColors* GetLookupTable();
186
191 virtual void CreateDefaultLookupTable();
192
194
197 vtkSetMacro(ScalarVisibility, bool);
198 vtkGetMacro(ScalarVisibility, bool);
199 vtkBooleanMacro(ScalarVisibility, bool);
201
203
206 vtkSetMacro(EnableOpacityMapping, bool);
207 vtkGetMacro(EnableOpacityMapping, bool);
208 vtkBooleanMacro(EnableOpacityMapping, bool);
210
212
217 void SelectColorArray(vtkIdType arrayNum);
218 void SelectColorArray(const vtkStdString& arrayName);
220
224 vtkStdString GetColorArrayName();
225
229 vtkStringArray* GetLabels() override;
230
234 virtual void SetGroupName(const vtkStdString& name);
235
239 virtual vtkStdString GetGroupName();
240
245 vtkStdString GetTooltipLabel(
246 const vtkVector2d& plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex) override;
247
251 bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) override;
252
260 vtkIdType GetNearestPoint(const vtkVector2f& point, const vtkVector2f&, vtkVector2f* location,
261 vtkIdType* segmentIndex) override;
262 using vtkPlot::GetNearestPoint;
263
267 int GetBarsCount();
268
272 void GetDataBounds(double bounds[2]);
273
280 bool UpdateCache() override;
281
282 protected:
283 vtkPlotBar();
284 ~vtkPlotBar() override;
285
289 bool CacheRequiresUpdate() override;
290
294 vtkPoints2D* Points;
295
296 float Width;
297 float Offset;
298
299 int Orientation;
300
304 vtkSmartPointer<vtkColorSeries> ColorSeries;
305
307
310 vtkSmartPointer<vtkScalarsToColors> LookupTable;
311 vtkSmartPointer<vtkUnsignedCharArray> Colors;
312 bool ScalarVisibility;
313 bool EnableOpacityMapping;
314 vtkStdString ColorArrayName;
316
317 bool LogX;
318 bool LogY;
319
320 private:
321 vtkPlotBar(const vtkPlotBar&) = delete;
322 void operator=(const vtkPlotBar&) = delete;
323
324 vtkPlotBarPrivate* Private;
325 };
326
327 VTK_ABI_NAMESPACE_END
328 #endif // vtkPlotBar_h
vtkColorSeries
stores a list of colors.
Definition: vtkColorSeries.h:60
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:59
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkObjectBase::GetClassName
const char * GetClassName() const
Return the class name as a string.
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkPlotBar
Class for drawing an XY plot given two columns from a vtkTable.
Definition: vtkPlotBar.h:44
vtkPlotBar::SetLookupTable
virtual void SetLookupTable(vtkScalarsToColors *lut)
Specify a lookup table for the mapper to use.
vtkPlotBar::Width
float Width
Definition: vtkPlotBar.h:296
vtkPlotBar::Orientation
int Orientation
Definition: vtkPlotBar.h:299
vtkPlotBar::New
static vtkPlotBar * New()
Creates a 2D Chart object.
vtkPlotBar::GetTooltipLabel
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.
vtkPlotBar::GetUnscaledInputBounds
void GetUnscaledInputBounds(double bounds[4]) override
Get un-log-scaled bounds for this mapper as (Xmin,Xmax,Ymin,Ymax).
vtkPlotBar::GetBarsCount
int GetBarsCount()
Get amount of plotted bars.
vtkPlotBar::GetBounds
void GetBounds(double bounds[4]) override
Get the bounds for this mapper as (Xmin,Xmax,Ymin,Ymax).
vtkPlotBar::SetColor
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)
vtkPlotBar::LookupTable
vtkSmartPointer< vtkScalarsToColors > LookupTable
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:310
vtkPlotBar::SelectColorArray
void SelectColorArray(vtkIdType arrayNum)
When ScalarMode is set to UsePointFieldData or UseCellFieldData, you can specify which array to use f...
vtkPlotBar::Colors
vtkSmartPointer< vtkUnsignedCharArray > Colors
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:311
vtkPlotBar::GetColorF
void GetColorF(double rgb[3]) override
Get the plot color as floating rgb values (comprised between 0.0 and 1.0)
vtkPlotBar::GetColorArrayName
vtkStdString GetColorArrayName()
Get the array name to color by.
vtkPlotBar::GetLookupTable
virtual vtkScalarsToColors * GetLookupTable()
Specify a lookup table for the mapper to use.
vtkPlotBar::SetGroupName
virtual void SetGroupName(const vtkStdString &name)
Set the group name of the bar chart - can be displayed on the X axis.
vtkPlotBar::GetWidth
float GetWidth() override
Get the width of the line.
Definition: vtkPlotBar.h:121
vtkPlotBar::UpdateCache
bool UpdateCache() override
Update the internal cache.
vtkPlotBar::ScalarVisibility
bool ScalarVisibility
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:312
vtkPlotBar::SetInputArray
void SetInputArray(int index, const vtkStdString &name) override
When used to set additional arrays, stacked bars are created.
vtkPlotBar::GetColorSeries
vtkColorSeries * GetColorSeries()
Get the color series used if when this is a stacked bar plot.
vtkPlotBar::ColorArrayName
vtkStdString ColorArrayName
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:314
vtkPlotBar::SetColorF
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)
vtkPlotBar::GetBounds
virtual void GetBounds(double bounds[4], bool unscaled)
A helper used by both GetUnscaledBounds and GetBounds(double[4]).
vtkPlotBar::SetColorF
void SetColorF(double r, double g, double b) override
Set the plot color with floating values (comprised between 0.0 and 1.0)
vtkPlotBar::~vtkPlotBar
~vtkPlotBar() override
vtkPlotBar::SetColorSeries
void SetColorSeries(vtkColorSeries *colorSeries)
Set the color series to use if this becomes a stacked bar plot.
vtkPlotBar::Points
vtkPoints2D * Points
Store a well packed set of XY coordinates for this data series.
Definition: vtkPlotBar.h:294
vtkPlotBar::SelectColorArray
void SelectColorArray(const vtkStdString &arrayName)
When ScalarMode is set to UsePointFieldData or UseCellFieldData, you can specify which array to use f...
vtkPlotBar::EnableOpacityMapping
bool EnableOpacityMapping
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:313
vtkPlotBar::GetNearestPoint
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.
vtkPlotBar::ColorSeries
vtkSmartPointer< vtkColorSeries > ColorSeries
The color series to use if this becomes a stacked bar.
Definition: vtkPlotBar.h:304
vtkPlotBar::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPlotBar::LogY
bool LogY
Definition: vtkPlotBar.h:318
vtkPlotBar::vtkPlotBar
vtkPlotBar()
vtkPlotBar::Offset
float Offset
Definition: vtkPlotBar.h:297
vtkPlotBar::CacheRequiresUpdate
bool CacheRequiresUpdate() override
Test if the internal cache requires an update.
vtkPlotBar::GetGroupName
virtual vtkStdString GetGroupName()
Get the group name of the bar char - can be displayed on the X axis.
vtkPlotBar::Paint
bool Paint(vtkContext2D *painter) override
Paint event for the XY plot, called whenever the chart needs to be drawn.
vtkPlotBar::GetDataBounds
void GetDataBounds(double bounds[2])
Get the data bounds for this mapper as (Xmin,Xmax).
vtkPlotBar::SetOrientation
virtual void SetOrientation(int orientation)
Set/get the orientation of the bars.
vtkPlotBar::CreateDefaultLookupTable
virtual void CreateDefaultLookupTable()
Create default lookup table.
vtkPlotBar::SelectPoints
bool SelectPoints(const vtkVector2f &min, const vtkVector2f &max) override
Select all points in the specified rectangle.
vtkPlotBar::GetLabels
vtkStringArray * GetLabels() override
Get the plot labels.
vtkPlotBar::PaintLegend
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 ...
vtkPlotBar::SetWidth
void SetWidth(float _arg) override
Set the width of the line.
Definition: vtkPlotBar.h:106
vtkPlotBar::LogX
bool LogX
Definition: vtkPlotBar.h:317
vtkPlot
Abstract class for 2D plots.
Definition: vtkPlot.h:53
vtkPlot::SetColorF
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)
vtkPlot::GetNearestPoint
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.
vtkPlot::GetColorF
virtual void GetColorF(double rgb[3])
Get the plot color as floating rgb values (comprised between 0.0 and 1.0)
vtkPoints2D
represent and manipulate 2D points
Definition: vtkPoints2D.h:26
vtkRectf
Definition: vtkRect.h:328
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:65
vtkSmartPointer< vtkColorSeries >
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:41
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:68
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:40
vtkVector2d
Definition: vtkVector.h:475
vtkVector2f
Definition: vtkVector.h:463
vtkX3D::point
@ point
Definition: vtkX3D.h:236
vtkX3D::location
@ location
Definition: vtkX3D.h:406
vtkX3D::orientation
@ orientation
Definition: vtkX3D.h:262
vtkX3D::name
@ name
Definition: vtkX3D.h:219
vtkX3D::index
@ index
Definition: vtkX3D.h:246
VTK_DEPRECATED_IN_9_3_0
#define VTK_DEPRECATED_IN_9_3_0(reason)
Definition: vtkDeprecation.h:99
vtkPlot.h
vtkSmartPointer.h
vtkIdType
int vtkIdType
Definition: vtkType.h:315
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:19