VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
25 
26 #include <map> // For specific gutter
27 #include <utility> // For specific gutter
28 
29 VTK_ABI_NAMESPACE_BEGIN
30 class vtkChart;
31 
32 class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkChartMatrix : public vtkAbstractContextItem
33 {
34 public:
36  void PrintSelf(ostream& os, vtkIndent indent) override;
37 
41  static vtkChartMatrix* New();
42 
46  void Update() override;
47 
51  bool Paint(vtkContext2D* painter) override;
52 
58  virtual void SetSize(const vtkVector2i& size);
59 
63  virtual vtkVector2i GetSize() const { return this->Size; }
64 
66 
69  virtual void SetBorders(int left, int bottom, int right, int top);
70  void SetBorderLeft(int value);
71  void SetBorderBottom(int value);
72  void SetBorderRight(int value);
73  void SetBorderTop(int value);
74  virtual void GetBorders(int borders[4])
75  {
76  for (int i = 0; i < 4; i++)
77  {
78  borders[i] = this->Borders[i];
79  }
80  }
82 
84 
87  virtual void SetGutter(const vtkVector2f& gutter);
88  void SetGutterX(float value);
89  void SetGutterY(float value);
91 
93 
96  virtual void SetPadding(const float& padding);
98 
100 
103  virtual void SetSpecificResize(const vtkVector2i& index, const vtkVector2f& resize);
104  virtual void ClearSpecificResizes();
106 
110  virtual vtkVector2f GetGutter() const { return this->Gutter; }
111 
115  virtual void Allocate();
116 
123  virtual bool SetChart(const vtkVector2i& position, vtkChart* chart);
124 
130  virtual vtkChart* GetChart(const vtkVector2i& position);
131 
137  virtual bool SetChartSpan(const vtkVector2i& position, const vtkVector2i& span);
138 
142  virtual vtkVector2i GetChartSpan(const vtkVector2i& position);
143 
148  virtual vtkVector2i GetChartIndex(const vtkVector2f& position);
149 
153  virtual std::size_t GetFlatIndex(const vtkVector2i& index);
154 
158  virtual std::size_t GetNumberOfCharts();
159 
165  virtual void LabelOuter(const vtkVector2i& leftBottomIdx, const vtkVector2i& rightTopIdx);
166 
168 
174  virtual void Link(const vtkVector2i& index1, const vtkVector2i& index2, int axis = 1);
175  virtual void Link(const size_t& flatIndex1, const size_t& flatIndex2, int axis = 1);
177 
179 
182  virtual void LinkAll(const vtkVector2i& index, int axis = 1);
183  virtual void LinkAll(const size_t& flatIndex, int axis = 1);
185 
187 
191  virtual void Unlink(const vtkVector2i& index1, const vtkVector2i& index2, int axis = 1);
192  virtual void Unlink(const size_t& flatIndex1, const size_t& flatIndex2, int axis = 1);
194 
196 
199  virtual void UnlinkAll(const vtkVector2i& index, int axis = 1);
200  virtual void UnlinkAll(const size_t& flatIndex, int axis = 1);
202 
204 
211  virtual void ResetLinks(int axis = 1);
212  virtual void ResetLinkedLayout();
214 
216 
220  virtual void SetRect(vtkRecti rect);
221  vtkGetMacro(Rect, vtkRecti);
223 
231  virtual bool SetChartMatrix(const vtkVector2i& position, vtkChartMatrix* chartMatrix);
232 
238  virtual vtkChartMatrix* GetChartMatrix(const vtkVector2i& position);
239 
241 
246  virtual void InitLayoutTraversal(vtkVector2i& index, vtkVector2f& offset, vtkVector2f& increment);
247  virtual void GoToNextElement(vtkVector2i& index, vtkVector2f& offset);
248  virtual bool IsDoneWithTraversal();
250 
256  virtual vtkRectf ComputeCurrentElementSceneRect(
257  const vtkVector2i& index, const vtkVector2f& offset, const vtkVector2f& increment);
258 
259  enum class StretchType : unsigned int
260  {
261  SCENE = 0,
262  CUSTOM
263  };
265 
269  vtkSetEnumMacro(FillStrategy, StretchType);
270  StretchType GetFillStrategy() { return this->FillStrategy; }
272 
273 protected:
274  vtkChartMatrix();
275  ~vtkChartMatrix() override;
276 
277  // The number of charts in x and y.
279 
280  // The gutter between each chart.
282 
283  // The padding used inside each chart
284  float Padding;
285  std::map<vtkVector2i, vtkVector2f> SpecificResize;
286  int Borders[4];
288 
289  // The rectangular region to occupy. (in scene coordinates.)
290  vtkRecti Rect = { 0, 0, 100, 100 };
291  StretchType FillStrategy = StretchType::SCENE;
292 
293  virtual void SynchronizeAxisRanges(vtkObject* caller, unsigned long eventId, void* calldata);
294 
295 private:
296  vtkChartMatrix(const vtkChartMatrix&) = delete;
297  void operator=(const vtkChartMatrix&) = delete;
298 
299  class PIMPL;
300  PIMPL* Private;
301 };
302 
303 VTK_ABI_NAMESPACE_END
304 #endif // vtkChartMatrix_h
abstract base class for most VTK objects
Definition: vtkObject.h:52
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:41
a simple class to control print indentation
Definition: vtkIndent.h:28
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:410
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.
#define VTK_MARSHALAUTO
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.