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 
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) VTK_OVERRIDE;
47 
51  enum {
52  VERTICAL = 0,
53  HORIZONTAL
54  };
55 
59  static vtkPlotBar *New();
60 
64  void Update() VTK_OVERRIDE;
65 
69  bool Paint(vtkContext2D *painter) VTK_OVERRIDE;
70 
77  bool PaintLegend(vtkContext2D *painter, const vtkRectf& rect,
78  int legendIndex) VTK_OVERRIDE;
79 
81 
84  void SetColor(unsigned char r, unsigned char g, unsigned char b,
85  unsigned char a) VTK_OVERRIDE;
86  void SetColor(double r, double g, double b) VTK_OVERRIDE;
87  void GetColor(double rgb[3]) VTK_OVERRIDE;
89 
91 
94  void SetWidth(float _arg) VTK_OVERRIDE
95  {
96  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting Width to " << _arg);
97  if (this->Width != _arg)
98  {
99  this->Width = _arg;
100  this->Modified();
101  }
102  }
104 
106 
109  float GetWidth() VTK_OVERRIDE
110  {
111  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning Width of " << 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]) VTK_OVERRIDE;
145 
149  void GetUnscaledInputBounds(double bounds[4]) VTK_OVERRIDE;
150 
154  void SetInputArray(int index, const vtkStdString &name) VTK_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 
195  void SelectColorArray(vtkIdType arrayNum);
196  void SelectColorArray(const vtkStdString& arrayName);
198 
202  vtkStdString GetColorArrayName();
203 
207  vtkStringArray *GetLabels() VTK_OVERRIDE;
208 
212  virtual void SetGroupName(const vtkStdString& name);
213 
217  virtual vtkStdString GetGroupName();
218 
223  vtkStdString GetTooltipLabel(const vtkVector2d &plotPos,
224  vtkIdType seriesIndex,
225  vtkIdType segmentIndex) VTK_OVERRIDE;
226 
230  bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) VTK_OVERRIDE;
231 
237  vtkIdType GetNearestPoint(const vtkVector2f& point,
238  const vtkVector2f& tolerance,
239  vtkVector2f* location) VTK_OVERRIDE;
240 
248  virtual vtkIdType GetNearestPoint(const vtkVector2f& point,
249  const vtkVector2f&,
250  vtkVector2f* location,
251  vtkIdType* segmentIndex);
252 
256  int GetBarsCount();
257 
261  void GetDataBounds(double bounds[2]);
262 
263 protected:
264  vtkPlotBar();
265  ~vtkPlotBar() VTK_OVERRIDE;
266 
270  bool UpdateTableCache(vtkTable *table);
271 
275  vtkPoints2D *Points;
276 
277  float Width;
278  float Offset;
279 
280  int Orientation;
281 
286 
291 
293 
298  bool ScalarVisibility;
299  vtkStdString ColorArrayName;
301 
302  bool LogX;
303  bool LogY;
304 
305 private:
306  vtkPlotBar(const vtkPlotBar &) VTK_DELETE_FUNCTION;
307  void operator=(const vtkPlotBar &) VTK_DELETE_FUNCTION;
308 
309  vtkPlotBarPrivate *Private;
310 
311 };
312 
313 #endif //vtkPlotBar_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:41
vtkTimeStamp BuildTime
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
record modification and/or execution time
Definition: vtkTimeStamp.h:32
virtual void GetBounds(double bounds[4])
Get the bounds for this plot as (Xmin, Xmax, Ymin, Ymax).
Definition: vtkPlot.h:330
a vtkAbstractArray subclass for strings
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition: vtkType.h:345
Superclass for mapping scalar values to colors.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
a simple class to control print indentation
Definition: vtkIndent.h:33
const char * GetClassName() const
Return the class name as a string.
represent and manipulate 2D points
Definition: vtkPoints2D.h:33
virtual vtkStringArray * GetLabels()
Get the plot labels.
virtual void Modified()
Update the modification time for this object.
Abstract class for 2D plots.
Definition: vtkPlot.h:46
Class for drawing an XY plot given two columns from a vtkTable.
Definition: vtkPlotBar.h:42
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
dynamic, self-adjusting array of unsigned char
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:62
stores a list of colors.
virtual void GetUnscaledInputBounds(double bounds[4])
Provide un-log-scaled bounds for the plot inputs.
Definition: vtkPlot.h:357
float GetWidth() override
Get the width of the line.
Definition: vtkPlotBar.h:109
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void Update()
Perform any updates to the item that may be necessary before rendering.
#define max(a, b)