VTK  9.2.6
vtkChartMatrix.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkChartMatrix.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 
29 #ifndef vtkChartMatrix_h
30 #define vtkChartMatrix_h
31 
32 #include "vtkAbstractContextItem.h"
33 #include "vtkChartsCoreModule.h" // For export macro
34 #include "vtkRect.h" // for ivars
35 #include "vtkVector.h" // For ivars
36 
37 #include <map> // For specific gutter
38 #include <utility> // For specific gutter
39 
40 class vtkChart;
41 
42 class VTKCHARTSCORE_EXPORT vtkChartMatrix : public vtkAbstractContextItem
43 {
44 public:
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
51  static vtkChartMatrix* New();
52 
56  void Update() override;
57 
61  bool Paint(vtkContext2D* painter) override;
62 
68  virtual void SetSize(const vtkVector2i& size);
69 
73  virtual vtkVector2i GetSize() const { return this->Size; }
74 
76 
79  virtual void SetBorders(int left, int bottom, int right, int top);
80  void SetBorderLeft(int value);
81  void SetBorderBottom(int value);
82  void SetBorderRight(int value);
83  void SetBorderTop(int value);
84  virtual void GetBorders(int borders[4])
85  {
86  for (int i = 0; i < 4; i++)
87  {
88  borders[i] = this->Borders[i];
89  }
90  }
92 
94 
97  virtual void SetGutter(const vtkVector2f& gutter);
98  void SetGutterX(float value);
99  void SetGutterY(float value);
101 
103 
106  virtual void SetPadding(const float& padding);
108 
110 
113  virtual void SetSpecificResize(const vtkVector2i& index, const vtkVector2f& resize);
114  virtual void ClearSpecificResizes();
116 
120  virtual vtkVector2f GetGutter() const { return this->Gutter; }
121 
125  virtual void Allocate();
126 
133  virtual bool SetChart(const vtkVector2i& position, vtkChart* chart);
134 
140  virtual vtkChart* GetChart(const vtkVector2i& position);
141 
147  virtual bool SetChartSpan(const vtkVector2i& position, const vtkVector2i& span);
148 
152  virtual vtkVector2i GetChartSpan(const vtkVector2i& position);
153 
158  virtual vtkVector2i GetChartIndex(const vtkVector2f& position);
159 
163  virtual std::size_t GetFlatIndex(const vtkVector2i& index);
164 
168  virtual std::size_t GetNumberOfCharts();
169 
175  virtual void LabelOuter(const vtkVector2i& leftBottomIdx, const vtkVector2i& rightTopIdx);
176 
178 
184  virtual void Link(const vtkVector2i& index1, const vtkVector2i& index2, int axis = 1);
185  virtual void Link(const size_t& flatIndex1, const size_t& flatIndex2, int axis = 1);
187 
189 
192  virtual void LinkAll(const vtkVector2i& index, int axis = 1);
193  virtual void LinkAll(const size_t& flatIndex, int axis = 1);
195 
197 
201  virtual void Unlink(const vtkVector2i& index1, const vtkVector2i& index2, int axis = 1);
202  virtual void Unlink(const size_t& flatIndex1, const size_t& flatIndex2, int axis = 1);
204 
206 
209  virtual void UnlinkAll(const vtkVector2i& index, int axis = 1);
210  virtual void UnlinkAll(const size_t& flatIndex, int axis = 1);
212 
214 
221  virtual void ResetLinks(int axis = 1);
222  virtual void ResetLinkedLayout();
224 
226 
230  virtual void SetRect(vtkRecti rect);
231  vtkGetMacro(Rect, vtkRecti);
233 
241  virtual bool SetChartMatrix(const vtkVector2i& position, vtkChartMatrix* chartMatrix);
242 
248  virtual vtkChartMatrix* GetChartMatrix(const vtkVector2i& position);
249 
251 
256  virtual void InitLayoutTraversal(vtkVector2i& index, vtkVector2f& offset, vtkVector2f& increment);
257  virtual void GoToNextElement(vtkVector2i& index, vtkVector2f& offset);
258  virtual bool IsDoneWithTraversal();
260 
266  virtual vtkRectf ComputeCurrentElementSceneRect(
267  const vtkVector2i& index, const vtkVector2f& offset, const vtkVector2f& increment);
268 
269  enum class StretchType : unsigned int
270  {
271  SCENE = 0,
272  CUSTOM
273  };
275 
279  vtkSetEnumMacro(FillStrategy, StretchType);
280  StretchType GetFillStrategy() { return this->FillStrategy; }
282 
283 protected:
284  vtkChartMatrix();
285  ~vtkChartMatrix() override;
286 
287  // The number of charts in x and y.
289 
290  // The gutter between each chart.
292 
293  // The padding used inside each chart
294  float Padding;
295  std::map<vtkVector2i, vtkVector2f> SpecificResize;
296  int Borders[4];
298 
299  // The rectangular region to occupy. (in scene coordinates.)
300  vtkRecti Rect = { 0, 0, 100, 100 };
301  StretchType FillStrategy = StretchType::SCENE;
302 
303  virtual void SynchronizeAxisRanges(vtkObject* caller, unsigned long eventId, void* calldata);
304 
305 private:
306  vtkChartMatrix(const vtkChartMatrix&) = delete;
307  void operator=(const vtkChartMatrix&) = delete;
308 
309  class PIMPL;
310  PIMPL* Private;
311 };
312 
313 #endif // vtkChartMatrix_h
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkVector2i Size
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
virtual vtkVector2i GetSize() const
Get the width and height of the chart matrix.
std::map< vtkVector2i, vtkVector2f > SpecificResize
vtkVector2f Gutter
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
StretchType GetFillStrategy()
This specifies whether the chart matrix will fill the entire scene or instead draw itself in a user p...
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:57
Factory class for drawing 2D charts.
Definition: vtkChart.h:51
a simple class to control print indentation
Definition: vtkIndent.h:39
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:421
virtual void GetBorders(int borders[4])
Set/get the borders of the chart matrix (space in pixels around each chart).
container for a matrix of charts.
base class for items that are part of a vtkContextScene.
virtual vtkVector2f GetGutter() const
Get the gutter that should be left between the charts in the matrix.
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.