VTK  9.2.5
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 
48 #ifndef vtkChartMatrix_h
49 #define vtkChartMatrix_h
50 
51 #include "vtkAbstractContextItem.h"
52 #include "vtkChartsCoreModule.h" // For export macro
53 #include "vtkRect.h" // for ivars
54 #include "vtkVector.h" // For ivars
55 
56 #include <map> // For specific gutter
57 #include <utility> // For specific gutter
58 
59 class vtkChart;
60 
61 class VTKCHARTSCORE_EXPORT vtkChartMatrix : public vtkAbstractContextItem
62 {
63 public:
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
70  static vtkChartMatrix* New();
71 
75  void Update() override;
76 
80  bool Paint(vtkContext2D* painter) override;
81 
87  virtual void SetSize(const vtkVector2i& size);
88 
92  virtual vtkVector2i GetSize() const { return this->Size; }
93 
95 
98  virtual void SetBorders(int left, int bottom, int right, int top);
99  void SetBorderLeft(int value);
102  void SetBorderTop(int value);
103  virtual void GetBorders(int borders[4])
104  {
105  for (int i = 0; i < 4; i++)
106  {
107  borders[i] = this->Borders[i];
108  }
109  }
111 
113 
116  virtual void SetGutter(const vtkVector2f& gutter);
117  void SetGutterX(float value);
118  void SetGutterY(float value);
120 
122 
125  virtual void SetPadding(const float& padding);
127 
129 
132  virtual void SetSpecificResize(const vtkVector2i& index, const vtkVector2f& resize);
133  virtual void ClearSpecificResizes();
135 
139  virtual vtkVector2f GetGutter() const { return this->Gutter; }
140 
144  virtual void Allocate();
145 
152  virtual bool SetChart(const vtkVector2i& position, vtkChart* chart);
153 
160 
166  virtual bool SetChartSpan(const vtkVector2i& position, const vtkVector2i& span);
167 
172 
178 
182  virtual std::size_t GetFlatIndex(const vtkVector2i& index);
183 
187  virtual std::size_t GetNumberOfCharts();
188 
194  virtual void LabelOuter(const vtkVector2i& leftBottomIdx, const vtkVector2i& rightTopIdx);
195 
197 
203  virtual void Link(const vtkVector2i& index1, const vtkVector2i& index2, int axis = 1);
204  virtual void Link(const size_t& flatIndex1, const size_t& flatIndex2, int axis = 1);
206 
208 
211  virtual void LinkAll(const vtkVector2i& index, int axis = 1);
212  virtual void LinkAll(const size_t& flatIndex, int axis = 1);
214 
216 
220  virtual void Unlink(const vtkVector2i& index1, const vtkVector2i& index2, int axis = 1);
221  virtual void Unlink(const size_t& flatIndex1, const size_t& flatIndex2, int axis = 1);
223 
225 
228  virtual void UnlinkAll(const vtkVector2i& index, int axis = 1);
229  virtual void UnlinkAll(const size_t& flatIndex, int axis = 1);
231 
233 
240  virtual void ResetLinks(int axis = 1);
241  virtual void ResetLinkedLayout();
243 
245 
249  virtual void SetRect(vtkRecti rect);
250  vtkGetMacro(Rect, vtkRecti);
252 
260  virtual bool SetChartMatrix(const vtkVector2i& position, vtkChartMatrix* chartMatrix);
261 
268 
270 
277  virtual bool IsDoneWithTraversal();
279 
286  const vtkVector2i& index, const vtkVector2f& offset, const vtkVector2f& increment);
287 
288  enum class StretchType : unsigned int
289  {
290  SCENE = 0,
291  CUSTOM
292  };
294 
298  vtkSetEnumMacro(FillStrategy, StretchType);
299  StretchType GetFillStrategy() { return this->FillStrategy; }
301 
302 protected:
304  ~vtkChartMatrix() override;
305 
306  // The number of charts in x and y.
308 
309  // The gutter between each chart.
311 
312  // The padding used inside each chart
313  float Padding;
314  std::map<vtkVector2i, vtkVector2f> SpecificResize;
315  int Borders[4];
317 
318  // The rectangular region to occupy. (in scene coordinates.)
319  vtkRecti Rect = { 0, 0, 100, 100 };
320  StretchType FillStrategy = StretchType::SCENE;
321 
322  virtual void SynchronizeAxisRanges(vtkObject* caller, unsigned long eventId, void* calldata);
323 
324 private:
325  vtkChartMatrix(const vtkChartMatrix&) = delete;
326  void operator=(const vtkChartMatrix&) = delete;
327 
328  class PIMPL;
329  PIMPL* Private;
330 };
331 
332 #endif // vtkChartMatrix_h
base class for items that are part of a vtkContextScene.
container for a matrix of charts.
virtual void Link(const vtkVector2i &index1, const vtkVector2i &index2, int axis=1)
The chart at index2 will be setup to mimic axis range of chart at index1 for specified axis.
StretchType GetFillStrategy()
This specifies whether the chart matrix will fill the entire scene or instead draw itself in a user p...
void SetBorderBottom(int value)
Set/get the borders of the chart matrix (space in pixels around each chart).
void SetBorderRight(int value)
Set/get the borders of the chart matrix (space in pixels around each chart).
virtual void SynchronizeAxisRanges(vtkObject *caller, unsigned long eventId, void *calldata)
virtual void SetGutter(const vtkVector2f &gutter)
Set the gutter that should be left between the charts in the matrix.
virtual bool SetChart(const vtkVector2i &position, vtkChart *chart)
Set the chart element, note that the chart matrix must be large enough to accommodate the element bei...
virtual void GoToNextElement(vtkVector2i &index, vtkVector2f &offset)
These methods offer an API to iterate over the layout and obtain the offset of each child element (ch...
virtual vtkVector2i GetSize() const
Get the width and height of the chart matrix.
virtual void GetBorders(int borders[4])
Set/get the borders of the chart matrix (space in pixels around each chart).
vtkVector2i Size
virtual void Unlink(const vtkVector2i &index1, const vtkVector2i &index2, int axis=1)
Unlink the two charts for specified axis i.e, Chart at index2 will no longer mimic the axis range of ...
vtkVector2f Gutter
virtual vtkVector2i GetChartSpan(const vtkVector2i &position)
Get the span of the specified element.
virtual void InitLayoutTraversal(vtkVector2i &index, vtkVector2f &offset, vtkVector2f &increment)
These methods offer an API to iterate over the layout and obtain the offset of each child element (ch...
void SetBorderTop(int value)
Set/get the borders of the chart matrix (space in pixels around each chart).
virtual std::size_t GetFlatIndex(const vtkVector2i &index)
Get internal 1-D index corresponding to the 2-D element index.
virtual void Unlink(const size_t &flatIndex1, const size_t &flatIndex2, int axis=1)
Unlink the two charts for specified axis i.e, Chart at index2 will no longer mimic the axis range of ...
virtual void LinkAll(const size_t &flatIndex, int axis=1)
Link a chart to all other charts in this chart matrix for specified axis.
std::map< vtkVector2i, vtkVector2f > SpecificResize
void SetGutterY(float value)
Set the gutter that should be left between the charts in the matrix.
~vtkChartMatrix() override
virtual void UnlinkAll(const vtkVector2i &index, int axis=1)
Unlink all charts from given chart for a specified axis.
bool Paint(vtkContext2D *painter) override
Paint event for the chart matrix.
void SetGutterX(float value)
Set the gutter that should be left between the charts in the matrix.
virtual bool SetChartSpan(const vtkVector2i &position, const vtkVector2i &span)
Set the span of an element in the matrix.
virtual bool SetChartMatrix(const vtkVector2i &position, vtkChartMatrix *chartMatrix)
Set the element at position to a chart matrix, note that the chart matrix must be large enough to acc...
virtual void ResetLinkedLayout()
Unlink every chart from all other charts for a specified axis.
virtual vtkVector2f GetGutter() const
Get the gutter that should be left between the charts in the matrix.
virtual void SetRect(vtkRecti rect)
Set the rectangular region that this chart matrix will occupy.
virtual vtkChart * GetChart(const vtkVector2i &position)
Get the specified chart element, if the element does not exist nullptr will be returned.
virtual void ResetLinks(int axis=1)
Unlink every chart from all other charts for a specified axis.
virtual void SetPadding(const float &padding)
Set the gutter that should be left between the charts in the matrix.
virtual std::size_t GetNumberOfCharts()
Total number of charts within this chart matrix.
virtual void Link(const size_t &flatIndex1, const size_t &flatIndex2, int axis=1)
The chart at index2 will be setup to mimic axis range of chart at index1 for specified axis.
virtual void LabelOuter(const vtkVector2i &leftBottomIdx, const vtkVector2i &rightTopIdx)
Link all charts in the rectangle from leftBottom to rightTop.
static vtkChartMatrix * New()
Creates a new object.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetSize(const vtkVector2i &size)
Set the width and height of the chart matrix.
virtual void LinkAll(const vtkVector2i &index, int axis=1)
Link a chart to all other charts in this chart matrix for specified axis.
virtual vtkVector2i GetChartIndex(const vtkVector2f &position)
Get the position of an element in the matrix at the specified location.
virtual void SetSpecificResize(const vtkVector2i &index, const vtkVector2f &resize)
Set a specific resize that will move the bottom left point of a chart.
virtual void ClearSpecificResizes()
Set a specific resize that will move the bottom left point of a chart.
virtual vtkRectf ComputeCurrentElementSceneRect(const vtkVector2i &index, const vtkVector2f &offset, const vtkVector2f &increment)
Override this method if you want to customize layout instead of the default.
virtual void Allocate()
Allocate the charts, this will cause any null chart to be allocated.
virtual bool IsDoneWithTraversal()
These methods offer an API to iterate over the layout and obtain the offset of each child element (ch...
virtual void SetBorders(int left, int bottom, int right, int top)
Set/get the borders of the chart matrix (space in pixels around each chart).
vtkSetEnumMacro(FillStrategy, StretchType)
This specifies whether the chart matrix will fill the entire scene or instead draw itself in a user p...
void Update() override
Perform any updates to the item that may be necessary before rendering.
virtual vtkChartMatrix * GetChartMatrix(const vtkVector2i &position)
Get the specified chart matrix element.
virtual void UnlinkAll(const size_t &flatIndex, int axis=1)
Unlink all charts from given chart for a specified axis.
void SetBorderLeft(int value)
Set/get the borders of the chart matrix (space in pixels around each chart).
Factory class for drawing 2D charts.
Definition: vtkChart.h:52
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:77
a simple class to control print indentation
Definition: vtkIndent.h:119
abstract base class for most VTK objects
Definition: vtkObject.h:82
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:481
@ top
Definition: vtkX3D.h:508
@ value
Definition: vtkX3D.h:226
@ bottom
Definition: vtkX3D.h:296
@ position
Definition: vtkX3D.h:267
@ size
Definition: vtkX3D.h:259
@ index
Definition: vtkX3D.h:252
@ offset
Definition: vtkX3D.h:444