VTK  9.2.6
vtkPlotBar.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkPlotBar.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
47#ifndef vtkPlotBar_h
48#define vtkPlotBar_h
49
50#include "vtkChartsCoreModule.h" // For export macro
51#include "vtkPlot.h"
52#include "vtkSmartPointer.h" // Needed to hold ColorSeries
53
54class vtkContext2D;
55class vtkTable;
56class vtkPoints2D;
57class vtkStdString;
58class vtkColorSeries;
61
62class vtkPlotBarPrivate;
63
64class VTKCHARTSCORE_EXPORT vtkPlotBar : public vtkPlot
65{
66public:
67 vtkTypeMacro(vtkPlotBar, vtkPlot);
68 void PrintSelf(ostream& os, vtkIndent indent) override;
69
73 enum
74 {
75 VERTICAL = 0,
76 HORIZONTAL
77 };
78
82 static vtkPlotBar* New();
83
87 bool Paint(vtkContext2D* painter) override;
88
95 bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex) override;
96
98
101 void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override;
102 void SetColor(double r, double g, double b) override;
103 void GetColor(double rgb[3]) override;
105
107
110 void SetWidth(float _arg) override
111 {
112 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Width to " << _arg);
113 if (this->Width != _arg)
114 {
115 this->Width = _arg;
116 this->Modified();
117 }
118 }
120
122
125 float GetWidth() override
126 {
127 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning Width of "
128 << this->Width);
129 return this->Width;
130 }
132
134
140 vtkSetMacro(Offset, float);
141 vtkGetMacro(Offset, float);
143
145
149 virtual void SetOrientation(int orientation);
150 vtkGetMacro(Orientation, int);
152
156 virtual void GetBounds(double bounds[4], bool unscaled);
157
161 void GetBounds(double bounds[4]) override;
162
166 void GetUnscaledInputBounds(double bounds[4]) override;
167
171 void SetInputArray(int index, const vtkStdString& name) override;
172
176 void SetColorSeries(vtkColorSeries* colorSeries);
177
182
184
190
196
198
201 vtkSetMacro(ScalarVisibility, bool);
202 vtkGetMacro(ScalarVisibility, bool);
203 vtkBooleanMacro(ScalarVisibility, bool);
205
207
210 vtkSetMacro(EnableOpacityMapping, bool);
211 vtkGetMacro(EnableOpacityMapping, bool);
212 vtkBooleanMacro(EnableOpacityMapping, bool);
214
216
222 void SelectColorArray(const vtkStdString& arrayName);
224
229
234
238 virtual void SetGroupName(const vtkStdString& name);
239
244
250 const vtkVector2d& plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex) override;
251
255 bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) override;
256
265 vtkIdType* segmentIndex) override;
267
272
276 void GetDataBounds(double bounds[2]);
277
284 bool UpdateCache() override;
285
286protected:
288 ~vtkPlotBar() override;
289
293 virtual bool CacheRequiresUpdate() override;
294
299
300 float Width;
301 float Offset;
302
304
309
311
320
321 bool LogX;
322 bool LogY;
323
324private:
325 vtkPlotBar(const vtkPlotBar&) = delete;
326 void operator=(const vtkPlotBar&) = delete;
327
328 vtkPlotBarPrivate* Private;
329};
330
331#endif // vtkPlotBar_h
stores a list of colors.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:77
a simple class to control print indentation
Definition: vtkIndent.h:119
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:65
virtual void SetLookupTable(vtkScalarsToColors *lut)
Specify a lookup table for the mapper to use.
float Width
Definition: vtkPlotBar.h:300
int Orientation
Definition: vtkPlotBar.h:303
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.
void SetColor(double r, double g, double b) override
Set the plot color.
vtkSmartPointer< vtkScalarsToColors > LookupTable
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:314
virtual bool CacheRequiresUpdate() override
Test if the internal cache requires an update.
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:315
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:125
bool UpdateCache() override
Update the internal cache.
bool ScalarVisibility
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:316
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:318
virtual void GetBounds(double bounds[4], bool unscaled)
A helper used by both GetUnscaledBounds and GetBounds(double[4]).
~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:298
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:317
void GetColor(double rgb[3]) override
Set the plot color.
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:308
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
float Offset
Definition: vtkPlotBar.h:301
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:110
Abstract class for 2D plots.
Definition: vtkPlot.h:163
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:37
Superclass for mapping scalar values to colors.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:108
a vtkAbstractArray subclass for strings
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:183
dynamic, self-adjusting array of unsigned char
@ point
Definition: vtkX3D.h:242
@ location
Definition: vtkX3D.h:412
@ orientation
Definition: vtkX3D.h:268
@ name
Definition: vtkX3D.h:225
@ index
Definition: vtkX3D.h:252
int vtkIdType
Definition: vtkType.h:332
#define max(a, b)