VTK
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 
28 #ifndef vtkPlotBar_h
29 #define vtkPlotBar_h
30 
31 #include "vtkChartsCoreModule.h" // For export macro
32 #include "vtkPlot.h"
33 #include "vtkSmartPointer.h" // Needed to hold ColorSeries
34 
35 class vtkContext2D;
36 class vtkTable;
37 class vtkPoints2D;
38 class vtkStdString;
39 class vtkColorSeries;
41 class vtkScalarsToColors;
42 
43 class vtkPlotBarPrivate;
44 
45 class VTKCHARTSCORE_EXPORT vtkPlotBar : public vtkPlot
46 {
47 public:
48  vtkTypeMacro(vtkPlotBar, vtkPlot);
49  void PrintSelf(ostream &os, vtkIndent indent) override;
50 
54  enum {
55  VERTICAL = 0,
56  HORIZONTAL
57  };
58 
62  static vtkPlotBar *New();
63 
67  void Update() override;
68 
72  bool Paint(vtkContext2D *painter) override;
73 
80  bool PaintLegend(vtkContext2D *painter, const vtkRectf& rect,
81  int legendIndex) override;
82 
84 
87  void SetColor(unsigned char r, unsigned char g, unsigned char b,
88  unsigned char a) override;
89  void SetColor(double r, double g, double b) override;
90  void GetColor(double rgb[3]) override;
92 
94 
97  void SetWidth(float _arg) override
98  {
99  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Width to " << _arg);
100  if (this->Width != _arg)
101  {
102  this->Width = _arg;
103  this->Modified();
104  }
105  }
107 
109 
112  float GetWidth() override
113  {
114  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning Width of " << this->Width );
115  return this->Width;
116  }
118 
120 
126  vtkSetMacro(Offset, float);
127  vtkGetMacro(Offset, float);
129 
131 
135  virtual void SetOrientation(int orientation);
136  vtkGetMacro(Orientation, int);
138 
142  virtual void GetBounds(double bounds[4], bool unscaled);
143 
147  void GetBounds(double bounds[4]) override;
148 
152  void GetUnscaledInputBounds(double bounds[4]) override;
153 
157  void SetInputArray(int index, const vtkStdString &name) override;
158 
162  void SetColorSeries(vtkColorSeries *colorSeries);
163 
168 
170 
173  virtual void SetLookupTable(vtkScalarsToColors *lut);
176 
181  virtual void CreateDefaultLookupTable();
182 
184 
187  vtkSetMacro(ScalarVisibility, bool);
188  vtkGetMacro(ScalarVisibility, bool);
189  vtkBooleanMacro(ScalarVisibility, bool);
191 
193 
198  void SelectColorArray(vtkIdType arrayNum);
199  void SelectColorArray(const vtkStdString& arrayName);
201 
206 
211 
215  virtual void SetGroupName(const vtkStdString& name);
216 
221 
227  vtkIdType seriesIndex,
228  vtkIdType segmentIndex) override;
229 
233  bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) override;
234 
241  const vtkVector2f& tolerance,
242  vtkVector2f* location) override;
243 
252  const vtkVector2f&,
254  vtkIdType* segmentIndex);
255 
260 
264  void GetDataBounds(double bounds[2]);
265 
266 protected:
268  ~vtkPlotBar() override;
269 
274 
279 
280  float Width;
281  float Offset;
282 
284 
289 
294 
296 
304 
305  bool LogX;
306  bool LogY;
307 
308 private:
309  vtkPlotBar(const vtkPlotBar &) = delete;
310  void operator=(const vtkPlotBar &) = delete;
311 
312  vtkPlotBarPrivate *Private;
313 
314 };
315 
316 #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:37
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:347
vtkPlotBar::ScalarVisibility
bool ScalarVisibility
Definition: vtkPlotBar.h:301
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:69
vtkColorSeries
stores a list of colors.
Definition: vtkColorSeries.h:55
vtkPlotBar::ColorArrayName
vtkStdString ColorArrayName
Definition: vtkPlotBar.h:302
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
vtkPlotBar::Offset
float Offset
Definition: vtkPlotBar.h:281
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:42
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::GetNearestPoint
vtkIdType GetNearestPoint(const vtkVector2f &point, const vtkVector2f &tolerance, vtkVector2f *location) override
Function to query a plot for the nearest point to the specified coordinate.
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:59
vtkPlot
Abstract class for 2D plots.
Definition: vtkPlot.h:53
vtkPlotBar::Update
void Update() override
Perform any updates to the item that may be necessary before rendering.
vtkPlotBar::LogX
bool LogX
Definition: vtkPlotBar.h:305
vtkPlotBar::Points
vtkPoints2D * Points
Store a well packed set of XY coordinates for this data series.
Definition: vtkPlotBar.h:278
vtkPlotBar::~vtkPlotBar
~vtkPlotBar() override
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
vtkVector2d
Definition: vtkVector.h:428
vtkPlotBar::ColorSeries
vtkSmartPointer< vtkColorSeries > ColorSeries
The color series to use if this becomes a stacked bar.
Definition: vtkPlotBar.h:293
vtkPlotBar::GetColor
void GetColor(double rgb[3]) override
vtkPlotBar::LookupTable
vtkSmartPointer< vtkScalarsToColors > LookupTable
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:299
vtkPlotBar
Class for drawing an XY plot given two columns from a vtkTable.
Definition: vtkPlotBar.h:46
vtkX3D::point
@ point
Definition: vtkX3D.h:236
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:112
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:97
vtkPlotBar::Colors
vtkSmartPointer< vtkUnsignedCharArray > Colors
Definition: vtkPlotBar.h:300
vtkPlotBar::BuildTime
vtkTimeStamp BuildTime
The point cache is marked dirty until it has been initialized.
Definition: vtkPlotBar.h:288
vtkPlotBar::LogY
bool LogY
Definition: vtkPlotBar.h:306
vtkPlotBar::Width
float Width
Definition: vtkPlotBar.h:280
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:40
vtkSmartPointer.h
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:67
vtkPlotBar::SelectPoints
bool SelectPoints(const vtkVector2f &min, const vtkVector2f &max) override
Select all points in the specified rectangle.
vtkX3D::name
@ name
Definition: vtkX3D.h:219
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:262
vtkPlotBar::SetLookupTable
virtual void SetLookupTable(vtkScalarsToColors *lut)
Specify a lookup table for the mapper to use.
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:43
vtkX3D::location
@ location
Definition: vtkX3D.h:406
vtkPlotBar::SetOrientation
virtual void SetOrientation(int orientation)
Set/get the orientation of the bars.
vtkPlotBar::GetNearestPoint
virtual vtkIdType GetNearestPoint(const vtkVector2f &point, const vtkVector2f &, vtkVector2f *location, vtkIdType *segmentIndex)
Function to query a plot for the nearest point to the specified coordinate.
vtkPlotBar::SetColor
void SetColor(double r, double g, double b) override
vtkPlotBar::GetLabels
vtkStringArray * GetLabels() override
Get the plot labels.
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:41
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:283
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()
vtkX3D::index
@ index
Definition: vtkX3D.h:246
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)
vtkRectf
Definition: vtkRect.h:333
vtkPlotBar::vtkPlotBar
vtkPlotBar()
vtkVector2f
Definition: vtkVector.h:419
vtkPlotBar::GetGroupName
virtual vtkStdString GetGroupName()
Get the group name of the bar char - can be displayed on the X axis.