VTK  9.1.0
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 
44 #ifndef vtkPlotBar_h
45 #define vtkPlotBar_h
46 
47 #include "vtkChartsCoreModule.h" // For export macro
48 #include "vtkPlot.h"
49 #include "vtkSmartPointer.h" // Needed to hold ColorSeries
50 
51 class vtkContext2D;
52 class vtkTable;
53 class vtkPoints2D;
54 class vtkStdString;
55 class vtkColorSeries;
57 class vtkScalarsToColors;
58 
59 class vtkPlotBarPrivate;
60 
61 class VTKCHARTSCORE_EXPORT vtkPlotBar : public vtkPlot
62 {
63 public:
64  vtkTypeMacro(vtkPlotBar, vtkPlot);
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
70  enum
71  {
72  VERTICAL = 0,
73  HORIZONTAL
74  };
75 
79  static vtkPlotBar* New();
80 
84  void Update() override;
85 
89  bool Paint(vtkContext2D* painter) override;
90 
97  bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex) override;
98 
100 
103  void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override;
104  void SetColor(double r, double g, double b) override;
105  void GetColor(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 
189  virtual void SetLookupTable(vtkScalarsToColors* lut);
192 
197  virtual void CreateDefaultLookupTable();
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 
223  void SelectColorArray(vtkIdType arrayNum);
224  void SelectColorArray(const vtkStdString& arrayName);
226 
231 
236 
240  virtual void SetGroupName(const vtkStdString& name);
241 
246 
252  const vtkVector2d& plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex) override;
253 
257  bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) override;
258 
267  vtkIdType* segmentIndex) override;
269 
274 
278  void GetDataBounds(double bounds[2]);
279 
280 protected:
282  ~vtkPlotBar() override;
283 
288 
293 
294  float Width;
295  float Offset;
296 
298 
303 
308 
310 
319 
320  bool LogX;
321  bool LogY;
322 
323 private:
324  vtkPlotBar(const vtkPlotBar&) = delete;
325  void operator=(const vtkPlotBar&) = delete;
326 
327  vtkPlotBarPrivate* Private;
328 };
329 
330 #endif // vtkPlotBar_h
vtkPlotBar::SetColorSeries
void SetColorSeries(vtkColorSeries *colorSeries)
Set the color series to use if this becomes a stacked bar plot.
vtkPoints2D
represent and manipulate 2D points
Definition: vtkPoints2D.h:34
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::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPlotBar::Paint
bool Paint(vtkContext2D *painter) override
Paint event for the XY plot, called whenever the chart needs to be drawn.
vtkPlot.h
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkPlotBar::ScalarVisibility
bool ScalarVisibility
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:315
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:172
vtkColorSeries
stores a list of colors.
Definition: vtkColorSeries.h:168
vtkPlotBar::ColorArrayName
vtkStdString ColorArrayName
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:317
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:52
vtkPlotBar::Offset
float Offset
Definition: vtkPlotBar.h:295
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:145
vtkPlotBar::GetUnscaledInputBounds
void GetUnscaledInputBounds(double bounds[4]) override
Get un-log-scaled bounds for this mapper as (Xmin,Xmax,Ymin,Ymax).
vtkPlotBar::SelectColorArray
void SelectColorArray(vtkIdType arrayNum)
When ScalarMode is set to UsePointFieldData or UseCellFieldData, you can specify which array to use f...
vtkPlotBar::GetDataBounds
void GetDataBounds(double bounds[2])
Get the data bounds for this mapper as (Xmin,Xmax).
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkSmartPointer< vtkColorSeries >
vtkPlotBar::GetColorArrayName
vtkStdString GetColorArrayName()
Get the array name to color by.
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:73
vtkPlot
Abstract class for 2D plots.
Definition: vtkPlot.h:157
vtkPlotBar::Update
void Update() override
Perform any updates to the item that may be necessary before rendering.
vtkPlotBar::LogX
bool LogX
Definition: vtkPlotBar.h:320
vtkPlotBar::Points
vtkPoints2D * Points
Store a well packed set of XY coordinates for this data series.
Definition: vtkPlotBar.h:292
vtkPlotBar::~vtkPlotBar
~vtkPlotBar() override
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
vtkVector2d
Definition: vtkVector.h:503
vtkPlotBar::ColorSeries
vtkSmartPointer< vtkColorSeries > ColorSeries
The color series to use if this becomes a stacked bar.
Definition: vtkPlotBar.h:307
vtkPlotBar::GetColor
void GetColor(double rgb[3]) override
Set the plot color.
vtkPlotBar::LookupTable
vtkSmartPointer< vtkScalarsToColors > LookupTable
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:313
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.
vtkPlotBar
Class for drawing an XY plot given two columns from a vtkTable.
Definition: vtkPlotBar.h:62
vtkX3D::point
@ point
Definition: vtkX3D.h:242
vtkObjectBase::GetClassName
const char * GetClassName() const
Return the class name as a string.
vtkPlotBar::GetWidth
float GetWidth() override
Get the width of the line.
Definition: vtkPlotBar.h:127
vtkPlotBar::GetColorSeries
vtkColorSeries * GetColorSeries()
Get the color series used if when this is a stacked bar plot.
vtkPlotBar::CreateDefaultLookupTable
virtual void CreateDefaultLookupTable()
Create default lookup table.
vtkPlotBar::SetWidth
void SetWidth(float _arg) override
Set the width of the line.
Definition: vtkPlotBar.h:112
vtkPlotBar::Colors
vtkSmartPointer< vtkUnsignedCharArray > Colors
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:314
vtkPlotBar::BuildTime
vtkTimeStamp BuildTime
The point cache is marked dirty until it has been initialized.
Definition: vtkPlotBar.h:302
vtkPlotBar::LogY
bool LogY
Definition: vtkPlotBar.h:321
vtkPlotBar::Width
float Width
Definition: vtkPlotBar.h:294
vtkPlotBar::GetBounds
void GetBounds(double bounds[4]) override
Get the bounds for this mapper as (Xmin,Xmax,Ymin,Ymax).
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
vtkPlotBar::SelectPoints
bool SelectPoints(const vtkVector2f &min, const vtkVector2f &max) override
Select all points in the specified rectangle.
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkPlotBar::UpdateTableCache
bool UpdateTableCache(vtkTable *table)
Update the table cache.
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::GetBarsCount
int GetBarsCount()
Get amount of plotted bars.
vtkPlotBar::New
static vtkPlotBar * New()
Creates a 2D Chart object.
vtkX3D::orientation
@ orientation
Definition: vtkX3D.h:268
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::SetLookupTable
virtual void SetLookupTable(vtkScalarsToColors *lut)
Specify a lookup table for the mapper to use.
vtkPlotBar::EnableOpacityMapping
bool EnableOpacityMapping
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:316
vtkPlotBar::SetColor
void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override
Set the plot color.
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:146
vtkX3D::location
@ location
Definition: vtkX3D.h:412
vtkPlotBar::SetOrientation
virtual void SetOrientation(int orientation)
Set/get the orientation of the bars.
vtkPlotBar::SetColor
void SetColor(double r, double g, double b) override
Set the plot color.
vtkPlotBar::GetLabels
vtkStringArray * GetLabels() override
Get the plot labels.
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:105
vtkPlotBar::SetInputArray
void SetInputArray(int index, const vtkStdString &name) override
When used to set additional arrays, stacked bars are created.
vtkPlotBar::Orientation
int Orientation
Definition: vtkPlotBar.h:297
vtkPlotBar::SetGroupName
virtual void SetGroupName(const vtkStdString &name)
Set the group name of the bar chart - can be displayed on the X axis.
vtkPlotBar::GetLookupTable
virtual vtkScalarsToColors * GetLookupTable()
Specify a lookup table for the mapper to use.
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkPlotBar::GetBounds
virtual void GetBounds(double bounds[4], bool unscaled)
A helper used by both GetUnscaledBounds and GetBounds(double[4]).
vtkPlotBar::SelectColorArray
void SelectColorArray(const vtkStdString &arrayName)
When ScalarMode is set to UsePointFieldData or UseCellFieldData, you can specify which array to use f...
vtkRectf
Definition: vtkRect.h:336
vtkPlotBar::vtkPlotBar
vtkPlotBar()
vtkVector2f
Definition: vtkVector.h:491
vtkPlotBar::GetGroupName
virtual vtkStdString GetGroupName()
Get the group name of the bar char - can be displayed on the X axis.