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 
16 #ifndef vtkPlotBar_h
17 #define vtkPlotBar_h
18 
19 #include "vtkChartsCoreModule.h" // For export macro
20 #include "vtkPlot.h"
21 #include "vtkSmartPointer.h" // Needed to hold ColorSeries
22 
23 VTK_ABI_NAMESPACE_BEGIN
24 class vtkContext2D;
25 class vtkTable;
26 class vtkPoints2D;
27 class vtkStdString;
28 class vtkColorSeries;
30 class vtkScalarsToColors;
31 
32 class vtkPlotBarPrivate;
33 
34 class VTKCHARTSCORE_EXPORT vtkPlotBar : public vtkPlot
35 {
36 public:
37  vtkTypeMacro(vtkPlotBar, vtkPlot);
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
43  enum
44  {
45  VERTICAL = 0,
46  HORIZONTAL
47  };
48 
52  static vtkPlotBar* New();
53 
57  bool Paint(vtkContext2D* painter) override;
58 
65  bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex) override;
66 
70  void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override;
71 
73 
76  void SetColorF(double r, double g, double b, double a) override;
77  void SetColorF(double r, double g, double b) override;
78 
79  VTK_DEPRECATED_IN_9_3_0("Please use unambiguous SetColorF method instead.")
80  void SetColor(double r, double g, double b) override { this->SetColorF(r, g, b); };
82 
84 
87  void GetColorF(double rgb[3]) override;
88 
89  VTK_DEPRECATED_IN_9_3_0("Please use unambiguous GetColorF method instead.")
90  void GetColor(double rgb[3]) override { this->GetColorF(rgb); };
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 "
115  << this->Width);
116  return this->Width;
117  }
119 
121 
127  vtkSetMacro(Offset, float);
128  vtkGetMacro(Offset, float);
130 
132 
136  virtual void SetOrientation(int orientation);
137  vtkGetMacro(Orientation, int);
139 
143  virtual void GetBounds(double bounds[4], bool unscaled);
144 
148  void GetBounds(double bounds[4]) override;
149 
153  void GetUnscaledInputBounds(double bounds[4]) override;
154 
158  void SetInputArray(int index, const vtkStdString& name) override;
159 
163  void SetColorSeries(vtkColorSeries* colorSeries);
164 
168  vtkColorSeries* GetColorSeries();
169 
171 
174  virtual void SetLookupTable(vtkScalarsToColors* lut);
175  virtual vtkScalarsToColors* GetLookupTable();
177 
182  virtual void CreateDefaultLookupTable();
183 
185 
188  vtkSetMacro(ScalarVisibility, bool);
189  vtkGetMacro(ScalarVisibility, bool);
190  vtkBooleanMacro(ScalarVisibility, bool);
192 
194 
197  vtkSetMacro(EnableOpacityMapping, bool);
198  vtkGetMacro(EnableOpacityMapping, bool);
199  vtkBooleanMacro(EnableOpacityMapping, bool);
201 
203 
208  void SelectColorArray(vtkIdType arrayNum);
209  void SelectColorArray(const vtkStdString& arrayName);
211 
215  vtkStdString GetColorArrayName();
216 
220  vtkStringArray* GetLabels() override;
221 
225  virtual void SetGroupName(const vtkStdString& name);
226 
230  virtual vtkStdString GetGroupName();
231 
237  const vtkVector2d& plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex) override;
238 
242  bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) override;
243 
252  vtkIdType* segmentIndex) override;
254 
258  int GetBarsCount();
259 
263  void GetDataBounds(double bounds[2]);
264 
271  bool UpdateCache() override;
272 
273 protected:
274  vtkPlotBar();
275  ~vtkPlotBar() override;
276 
280  bool CacheRequiresUpdate() override;
281 
286 
287  float Width;
288  float Offset;
289 
291 
296 
298 
307 
308  bool LogX;
309  bool LogY;
310 
311 private:
312  vtkPlotBar(const vtkPlotBar&) = delete;
313  void operator=(const vtkPlotBar&) = delete;
314 
315  vtkPlotBarPrivate* Private;
316 };
317 
318 VTK_ABI_NAMESPACE_END
319 #endif // vtkPlotBar_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:28
vtkSmartPointer< vtkUnsignedCharArray > Colors
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:302
void SetWidth(float _arg) override
Set the width of the line.
Definition: vtkPlotBar.h:97
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:287
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)
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:367
a vtkAbstractArray subclass for strings
bool EnableOpacityMapping
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:304
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:315
virtual void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Set the plot color with integer values (comprised between 0 and 255)
int Orientation
Definition: vtkPlotBar.h:290
Superclass for mapping scalar values to colors.
virtual void GetColorF(double rgb[3])
Get the plot color as floating rgb values (comprised between 0.0 and 1.0)
#define VTK_DEPRECATED_IN_9_3_0(reason)
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
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:303
a simple class to control print indentation
Definition: vtkIndent.h:28
const char * GetClassName() const
Return the class name as a string.
represent and manipulate 2D points
Definition: vtkPoints2D.h:25
virtual vtkStringArray * GetLabels()
Get the plot labels.
virtual bool UpdateCache()
Update the internal cache.
Definition: vtkPlot.h:429
virtual void Modified()
Update the modification time for this object.
Abstract class for 2D plots.
Definition: vtkPlot.h:43
Class for drawing an XY plot given two columns from a vtkTable.
Definition: vtkPlotBar.h:34
float Offset
Definition: vtkPlotBar.h:288
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:58
stores a list of colors.
virtual void GetUnscaledInputBounds(double bounds[4])
Provide un-log-scaled bounds for the plot inputs.
Definition: vtkPlot.h:393
vtkSmartPointer< vtkScalarsToColors > LookupTable
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:301
vtkPoints2D * Points
Store a well packed set of XY coordinates for this data series.
Definition: vtkPlotBar.h:285
float GetWidth() override
Get the width of the line.
Definition: vtkPlotBar.h:112
vtkSmartPointer< vtkColorSeries > ColorSeries
The color series to use if this becomes a stacked bar.
Definition: vtkPlotBar.h:295
vtkStdString ColorArrayName
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:305
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...