VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class vtkContext2D;
26 class vtkTable;
27 class vtkPoints2D;
28 class vtkStdString;
29 class vtkColorSeries;
31 class vtkScalarsToColors;
32 
33 class vtkPlotBarPrivate;
34 
35 class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkPlotBar : public vtkPlot
36 {
37 public:
38  vtkTypeMacro(vtkPlotBar, vtkPlot);
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
44  enum
45  {
46  VERTICAL = 0,
47  HORIZONTAL
48  };
49 
53  static vtkPlotBar* New();
54 
58  bool Paint(vtkContext2D* painter) override;
59 
66  bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex) override;
67 
71  void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override;
72  void SetColor(unsigned char r, unsigned char g, unsigned char b) override;
73 
75 
78  void SetColorF(double r, double g, double b, double a) override;
79  void SetColorF(double r, double g, double b) override;
81 
83 
86  void GetColorF(double rgb[3]) override;
88 
90 
93  void SetWidth(float _arg) override
94  {
95  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Width to " << _arg);
96  if (this->Width != _arg)
97  {
98  this->Width = _arg;
99  this->Modified();
100  }
101  }
103 
105 
108  float GetWidth() override
109  {
110  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning Width of "
111  << this->Width);
112  return this->Width;
113  }
115 
117 
123  vtkSetMacro(Offset, float);
124  vtkGetMacro(Offset, float);
126 
128 
132  virtual void SetOrientation(int orientation);
133  vtkGetMacro(Orientation, int);
135 
139  virtual void GetBounds(double bounds[4], bool unscaled);
140 
144  void GetBounds(double bounds[4]) override;
145 
149  void GetUnscaledInputBounds(double bounds[4]) override;
150 
154  void SetInputArray(int index, const vtkStdString& name) override;
155 
159  void SetColorSeries(vtkColorSeries* colorSeries);
160 
164  vtkColorSeries* GetColorSeries();
165 
167 
170  virtual void SetLookupTable(vtkScalarsToColors* lut);
171  virtual vtkScalarsToColors* GetLookupTable();
173 
178  virtual void CreateDefaultLookupTable();
179 
181 
184  vtkSetMacro(ScalarVisibility, bool);
185  vtkGetMacro(ScalarVisibility, bool);
186  vtkBooleanMacro(ScalarVisibility, bool);
188 
190 
193  vtkSetMacro(EnableOpacityMapping, bool);
194  vtkGetMacro(EnableOpacityMapping, bool);
195  vtkBooleanMacro(EnableOpacityMapping, bool);
197 
199 
204  void SelectColorArray(vtkIdType arrayNum);
205  void SelectColorArray(const vtkStdString& arrayName);
207 
211  vtkStdString GetColorArrayName();
212 
216  vtkStringArray* GetLabels() override;
217 
221  virtual void SetGroupName(const vtkStdString& name);
222 
226  virtual vtkStdString GetGroupName();
227 
231  bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) override;
232 
241  vtkIdType* segmentIndex) override;
243 
247  int GetBarsCount();
248 
252  void GetDataBounds(double bounds[2]);
253 
260  bool UpdateCache() override;
261 
262 protected:
263  vtkPlotBar();
264  ~vtkPlotBar() override;
265 
269  bool CacheRequiresUpdate() override;
270 
275 
276  float Width;
277  float Offset;
278 
280 
285 
287 
296 
297  bool LogX;
298  bool LogY;
299 
300 private:
301  vtkPlotBar(const vtkPlotBar&) = delete;
302  void operator=(const vtkPlotBar&) = delete;
303 
304  vtkPlotBarPrivate* Private;
305 };
306 
307 VTK_ABI_NAMESPACE_END
308 #endif // vtkPlotBar_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:27
vtkSmartPointer< vtkUnsignedCharArray > Colors
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:291
void SetWidth(float _arg) override
Set the width of the line.
Definition: vtkPlotBar.h:93
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:276
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:393
a vtkAbstractArray subclass for strings
bool EnableOpacityMapping
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:293
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:363
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:279
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)
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:292
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:27
virtual vtkStringArray * GetLabels()
Get the plot labels.
virtual bool UpdateCache()
Update the internal cache.
Definition: vtkPlot.h:455
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:35
float Offset
Definition: vtkPlotBar.h:277
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:59
stores a list of colors.
virtual void GetUnscaledInputBounds(double bounds[4])
Provide un-log-scaled bounds for the plot inputs.
Definition: vtkPlot.h:419
vtkSmartPointer< vtkScalarsToColors > LookupTable
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:290
vtkPoints2D * Points
Store a well packed set of XY coordinates for this data series.
Definition: vtkPlotBar.h:274
float GetWidth() override
Get the width of the line.
Definition: vtkPlotBar.h:108
vtkSmartPointer< vtkColorSeries > ColorSeries
The color series to use if this becomes a stacked bar.
Definition: vtkPlotBar.h:284
vtkStdString ColorArrayName
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:294
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
#define max(a, b)