VTK  9.3.1
vtkChartMatrix.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 
17 #ifndef vtkChartMatrix_h
18 #define vtkChartMatrix_h
19 
20 #include "vtkAbstractContextItem.h"
21 #include "vtkChartsCoreModule.h" // For export macro
22 #include "vtkRect.h" // for ivars
23 #include "vtkVector.h" // For ivars
24 
25 #include <map> // For specific gutter
26 #include <utility> // For specific gutter
27 
28 VTK_ABI_NAMESPACE_BEGIN
29 class vtkChart;
30 
31 class VTKCHARTSCORE_EXPORT vtkChartMatrix : public vtkAbstractContextItem
32 {
33 public:
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36 
40  static vtkChartMatrix* New();
41 
45  void Update() override;
46 
50  bool Paint(vtkContext2D* painter) override;
51 
57  virtual void SetSize(const vtkVector2i& size);
58 
62  virtual vtkVector2i GetSize() const { return this->Size; }
63 
65 
68  virtual void SetBorders(int left, int bottom, int right, int top);
69  void SetBorderLeft(int value);
70  void SetBorderBottom(int value);
71  void SetBorderRight(int value);
72  void SetBorderTop(int value);
73  virtual void GetBorders(int borders[4])
74  {
75  for (int i = 0; i < 4; i++)
76  {
77  borders[i] = this->Borders[i];
78  }
79  }
81 
83 
86  virtual void SetGutter(const vtkVector2f& gutter);
87  void SetGutterX(float value);
88  void SetGutterY(float value);
90 
92 
95  virtual void SetPadding(const float& padding);
97 
99 
102  virtual void SetSpecificResize(const vtkVector2i& index, const vtkVector2f& resize);
103  virtual void ClearSpecificResizes();
105 
109  virtual vtkVector2f GetGutter() const { return this->Gutter; }
110 
114  virtual void Allocate();
115 
122  virtual bool SetChart(const vtkVector2i& position, vtkChart* chart);
123 
129  virtual vtkChart* GetChart(const vtkVector2i& position);
130 
136  virtual bool SetChartSpan(const vtkVector2i& position, const vtkVector2i& span);
137 
141  virtual vtkVector2i GetChartSpan(const vtkVector2i& position);
142 
147  virtual vtkVector2i GetChartIndex(const vtkVector2f& position);
148 
152  virtual std::size_t GetFlatIndex(const vtkVector2i& index);
153 
157  virtual std::size_t GetNumberOfCharts();
158 
164  virtual void LabelOuter(const vtkVector2i& leftBottomIdx, const vtkVector2i& rightTopIdx);
165 
167 
173  virtual void Link(const vtkVector2i& index1, const vtkVector2i& index2, int axis = 1);
174  virtual void Link(const size_t& flatIndex1, const size_t& flatIndex2, int axis = 1);
176 
178 
181  virtual void LinkAll(const vtkVector2i& index, int axis = 1);
182  virtual void LinkAll(const size_t& flatIndex, int axis = 1);
184 
186 
190  virtual void Unlink(const vtkVector2i& index1, const vtkVector2i& index2, int axis = 1);
191  virtual void Unlink(const size_t& flatIndex1, const size_t& flatIndex2, int axis = 1);
193 
195 
198  virtual void UnlinkAll(const vtkVector2i& index, int axis = 1);
199  virtual void UnlinkAll(const size_t& flatIndex, int axis = 1);
201 
203 
210  virtual void ResetLinks(int axis = 1);
211  virtual void ResetLinkedLayout();
213 
215 
219  virtual void SetRect(vtkRecti rect);
220  vtkGetMacro(Rect, vtkRecti);
222 
230  virtual bool SetChartMatrix(const vtkVector2i& position, vtkChartMatrix* chartMatrix);
231 
237  virtual vtkChartMatrix* GetChartMatrix(const vtkVector2i& position);
238 
240 
245  virtual void InitLayoutTraversal(vtkVector2i& index, vtkVector2f& offset, vtkVector2f& increment);
246  virtual void GoToNextElement(vtkVector2i& index, vtkVector2f& offset);
247  virtual bool IsDoneWithTraversal();
249 
255  virtual vtkRectf ComputeCurrentElementSceneRect(
256  const vtkVector2i& index, const vtkVector2f& offset, const vtkVector2f& increment);
257 
258  enum class StretchType : unsigned int
259  {
260  SCENE = 0,
261  CUSTOM
262  };
264 
268  vtkSetEnumMacro(FillStrategy, StretchType);
269  StretchType GetFillStrategy() { return this->FillStrategy; }
271 
272 protected:
273  vtkChartMatrix();
274  ~vtkChartMatrix() override;
275 
276  // The number of charts in x and y.
278 
279  // The gutter between each chart.
281 
282  // The padding used inside each chart
283  float Padding;
284  std::map<vtkVector2i, vtkVector2f> SpecificResize;
285  int Borders[4];
287 
288  // The rectangular region to occupy. (in scene coordinates.)
289  vtkRecti Rect = { 0, 0, 100, 100 };
290  StretchType FillStrategy = StretchType::SCENE;
291 
292  virtual void SynchronizeAxisRanges(vtkObject* caller, unsigned long eventId, void* calldata);
293 
294 private:
295  vtkChartMatrix(const vtkChartMatrix&) = delete;
296  void operator=(const vtkChartMatrix&) = delete;
297 
298  class PIMPL;
299  PIMPL* Private;
300 };
301 
302 VTK_ABI_NAMESPACE_END
303 #endif // vtkChartMatrix_h
abstract base class for most VTK objects
Definition: vtkObject.h:51
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:49
Factory class for drawing 2D charts.
Definition: vtkChart.h:40
a simple class to control print indentation
Definition: vtkIndent.h:28
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:440
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.