VTK  9.0.1
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 
25 #ifndef vtkPlotBar_h
26 #define vtkPlotBar_h
27 
28 #include "vtkChartsCoreModule.h" // For export macro
29 #include "vtkPlot.h"
30 #include "vtkSmartPointer.h" // Needed to hold ColorSeries
31 
32 class vtkContext2D;
33 class vtkTable;
34 class vtkPoints2D;
35 class vtkStdString;
36 class vtkColorSeries;
38 class vtkScalarsToColors;
39 
40 class vtkPlotBarPrivate;
41 
42 class VTKCHARTSCORE_EXPORT vtkPlotBar : public vtkPlot
43 {
44 public:
45  vtkTypeMacro(vtkPlotBar, vtkPlot);
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
51  enum
52  {
53  VERTICAL = 0,
54  HORIZONTAL
55  };
56 
60  static vtkPlotBar* New();
61 
65  void Update() override;
66 
70  bool Paint(vtkContext2D* painter) override;
71 
78  bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex) override;
79 
81 
84  void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override;
85  void SetColor(double r, double g, double b) override;
86  void GetColor(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 
233  const vtkVector2d& plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex) override;
234 
238  bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) override;
239 
247  virtual vtkIdType GetNearestPoint(const vtkVector2f& point, const vtkVector2f&,
249 #ifndef VTK_LEGACY_REMOVE
250  vtkIdType* segmentId) override;
251 #else
252  vtkIdType* segmentId = nullptr) override;
253 #endif // VTK_LEGACY_REMOVE
254 
255 #ifndef VTK_LEGACY_REMOVE
257 #endif // VTK_LEGACY_REMOVE
258 
262  int GetBarsCount();
263 
267  void GetDataBounds(double bounds[2]);
268 
269 protected:
270  vtkPlotBar();
271  ~vtkPlotBar() override;
272 
276  bool UpdateTableCache(vtkTable* table);
277 
282 
283  float Width;
284  float Offset;
285 
287 
292 
297 
299 
308 
309  bool LogX;
310  bool LogY;
311 
312 private:
313  vtkPlotBar(const vtkPlotBar&) = delete;
314  void operator=(const vtkPlotBar&) = delete;
315 
316  vtkPlotBarPrivate* Private;
317 };
318 
319 #endif // vtkPlotBar_h
vtkPoints2D
represent and manipulate 2D points
Definition: vtkPoints2D.h:33
vtkPlot::GetTooltipLabel
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,...
vtkPlot.h
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkPlotBar::ScalarVisibility
bool ScalarVisibility
Definition: vtkPlotBar.h:304
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:62
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkColorSeries
stores a list of colors.
Definition: vtkColorSeries.h:59
vtkPlotBar::ColorArrayName
vtkStdString ColorArrayName
Definition: vtkPlotBar.h:306
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkPlotBar::Offset
float Offset
Definition: vtkPlotBar.h:284
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:35
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkSmartPointer< vtkColorSeries >
vtkPlot::SetColor
virtual void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Set the plot color.
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
vtkPlot
Abstract class for 2D plots.
Definition: vtkPlot.h:46
vtkPlotBar::LogX
bool LogX
Definition: vtkPlotBar.h:309
vtkPlotBar::Points
vtkPoints2D * Points
Store a well packed set of XY coordinates for this data series.
Definition: vtkPlotBar.h:281
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
vtkVector2d
Definition: vtkVector.h:444
vtkPlotBar::ColorSeries
vtkSmartPointer< vtkColorSeries > ColorSeries
The color series to use if this becomes a stacked bar.
Definition: vtkPlotBar.h:296
vtkPlotBar::LookupTable
vtkSmartPointer< vtkScalarsToColors > LookupTable
Lookup Table for coloring bars by scalar value.
Definition: vtkPlotBar.h:302
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:42
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:108
vtkPlot::SelectPoints
virtual bool SelectPoints(const vtkVector2f &min, const vtkVector2f &max)
Select all points in the specified rectangle.
vtkPlotBar::SetWidth
void SetWidth(float _arg) override
Set the width of the line.
Definition: vtkPlotBar.h:93
vtkPlotBar::Colors
vtkSmartPointer< vtkUnsignedCharArray > Colors
Definition: vtkPlotBar.h:303
vtkPlotBar::BuildTime
vtkTimeStamp BuildTime
The point cache is marked dirty until it has been initialized.
Definition: vtkPlotBar.h:291
vtkPlotBar::LogY
bool LogY
Definition: vtkPlotBar.h:310
vtkPlotBar::Width
float Width
Definition: vtkPlotBar.h:283
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkSmartPointer.h
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:59
vtkPlot::PaintLegend
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...
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkPlot::SetInputArray
virtual void SetInputArray(int index, const vtkStdString &name)
Convenience function to set the input arrays.
vtkX3D::orientation
@ orientation
Definition: vtkX3D.h:268
vtkPlot::GetLabels
virtual vtkStringArray * GetLabels()
Get the plot labels.
vtkAbstractContextItem::Paint
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
vtkPlot::GetUnscaledInputBounds
virtual void GetUnscaledInputBounds(double bounds[4])
Provide un-log-scaled bounds for the plot inputs.
Definition: vtkPlot.h:369
vtkPlotBar::EnableOpacityMapping
bool EnableOpacityMapping
Definition: vtkPlotBar.h:305
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:36
vtkX3D::location
@ location
Definition: vtkX3D.h:412
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:34
vtkPlotBar::Orientation
int Orientation
Definition: vtkPlotBar.h:286
vtkPlot::GetBounds
virtual void GetBounds(double bounds[4])
Get the bounds for this plot as (Xmin, Xmax, Ymin, Ymax).
Definition: vtkPlot.h:343
vtkPlot::GetColor
virtual void GetColor(double rgb[3])
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkPlot::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRectf
Definition: vtkRect.h:326
vtkVector2f
Definition: vtkVector.h:432
vtkAbstractContextItem::Update
virtual void Update()
Perform any updates to the item that may be necessary before rendering.