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 
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  {
56  VERTICAL = 0,
57  HORIZONTAL
58  };
59 
63  static vtkPlotBar* New();
64 
68  bool Paint(vtkContext2D* painter) override;
69 
76  bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex) override;
77 
79 
82  void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override;
83  void SetColor(double r, double g, double b) override;
84  void GetColor(double rgb[3]) override;
86 
88 
91  void SetWidth(float _arg) override
92  {
93  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Width to " << _arg);
94  if (this->Width != _arg)
95  {
96  this->Width = _arg;
97  this->Modified();
98  }
99  }
101 
103 
106  float GetWidth() override
107  {
108  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning Width of "
109  << this->Width);
110  return this->Width;
111  }
113 
115 
121  vtkSetMacro(Offset, float);
122  vtkGetMacro(Offset, float);
124 
126 
130  virtual void SetOrientation(int orientation);
131  vtkGetMacro(Orientation, int);
133 
137  virtual void GetBounds(double bounds[4], bool unscaled);
138 
142  void GetBounds(double bounds[4]) override;
143 
147  void GetUnscaledInputBounds(double bounds[4]) override;
148 
152  void SetInputArray(int index, const vtkStdString& name) override;
153 
157  void SetColorSeries(vtkColorSeries* colorSeries);
158 
162  vtkColorSeries* GetColorSeries();
163 
165 
168  virtual void SetLookupTable(vtkScalarsToColors* lut);
169  virtual vtkScalarsToColors* GetLookupTable();
171 
176  virtual void CreateDefaultLookupTable();
177 
179 
182  vtkSetMacro(ScalarVisibility, bool);
183  vtkGetMacro(ScalarVisibility, bool);
184  vtkBooleanMacro(ScalarVisibility, bool);
186 
188 
191  vtkSetMacro(EnableOpacityMapping, bool);
192  vtkGetMacro(EnableOpacityMapping, bool);
193  vtkBooleanMacro(EnableOpacityMapping, bool);
195 
197 
202  void SelectColorArray(vtkIdType arrayNum);
203  void SelectColorArray(const vtkStdString& arrayName);
205 
209  vtkStdString GetColorArrayName();
210 
214  vtkStringArray* GetLabels() override;
215 
219  virtual void SetGroupName(const vtkStdString& name);
220 
224  virtual vtkStdString GetGroupName();
225 
231  const vtkVector2d& plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex) override;
232 
236  bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) override;
237 
246  vtkIdType* segmentIndex) override;
248 
252  int GetBarsCount();
253 
257  void GetDataBounds(double bounds[2]);
258 
265  bool UpdateCache() override;
266 
267 protected:
268  vtkPlotBar();
269  ~vtkPlotBar() override;
270 
274  virtual bool CacheRequiresUpdate() override;
275 
280 
281  float Width;
282  float Offset;
283 
285 
290 
292 
301 
302  bool LogX;
303  bool LogY;
304 
305 private:
306  vtkPlotBar(const vtkPlotBar&) = delete;
307  void operator=(const vtkPlotBar&) = delete;
308 
309  vtkPlotBarPrivate* Private;
310 };
311 
312 #endif // vtkPlotBar_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
vtkSmartPointer< vtkUnsignedCharArray > Colors
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:296
void SetWidth(float _arg) override
Set the width of the line.
Definition: vtkPlotBar.h:91
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool PaintLegend(vtkContext2D *painter, const vtkRectf &rect, int legendIndex)
Paint legend event for the plot, called whenever the legend needs the plot items symbol/mark/line dra...
float Width
Definition: vtkPlotBar.h:281
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
virtual void GetBounds(double bounds[4])
Get the bounds for this plot as (Xmin, Xmax, Ymin, Ymax).
Definition: vtkPlot.h:352
a vtkAbstractArray subclass for strings
bool EnableOpacityMapping
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:298
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.
int vtkIdType
Definition: vtkType.h:332
virtual void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Set the plot color.
int Orientation
Definition: vtkPlotBar.h:284
Superclass for mapping scalar values to colors.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:57
virtual bool SelectPoints(const vtkVector2f &min, const vtkVector2f &max)
Select all points in the specified rectangle.
bool ScalarVisibility
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:297
a simple class to control print indentation
Definition: vtkIndent.h:39
const char * GetClassName() const
Return the class name as a string.
represent and manipulate 2D points
Definition: vtkPoints2D.h:36
virtual vtkStringArray * GetLabels()
Get the plot labels.
virtual bool UpdateCache()
Update the internal cache.
Definition: vtkPlot.h:414
virtual void Modified()
Update the modification time for this object.
Abstract class for 2D plots.
Definition: vtkPlot.h:53
Class for drawing an XY plot given two columns from a vtkTable.
Definition: vtkPlotBar.h:45
float Offset
Definition: vtkPlotBar.h:282
dynamic, self-adjusting array of unsigned char
virtual bool CacheRequiresUpdate()
Test if the internal cache requires an update.
virtual void SetInputArray(int index, const vtkStdString &name)
Convenience function to set the input arrays.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:73
stores a list of colors.
virtual void GetUnscaledInputBounds(double bounds[4])
Provide un-log-scaled bounds for the plot inputs.
Definition: vtkPlot.h:378
virtual void GetColor(double rgb[3])
Set the plot color.
vtkSmartPointer< vtkScalarsToColors > LookupTable
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:295
vtkPoints2D * Points
Store a well packed set of XY coordinates for this data series.
Definition: vtkPlotBar.h:279
float GetWidth() override
Get the width of the line.
Definition: vtkPlotBar.h:106
vtkSmartPointer< vtkColorSeries > ColorSeries
The color series to use if this becomes a stacked bar.
Definition: vtkPlotBar.h:289
vtkStdString ColorArrayName
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:299
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
#define max(a, b)
virtual vtkStdString GetTooltipLabel(const vtkVector2d &plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex)
Generate and return the tooltip label string for this plot The segmentIndex parameter is ignored...