VTK  9.1.0
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 
45 #ifndef vtkChartMatrix_h
46 #define vtkChartMatrix_h
47 
48 #include "vtkAbstractContextItem.h"
49 #include "vtkChartsCoreModule.h" // For export macro
50 #include "vtkRect.h" // for ivars
51 #include "vtkVector.h" // For ivars
52 
53 #include <map> // For specific gutter
54 #include <utility> // For specific gutter
55 
56 class vtkChart;
57 
58 class VTKCHARTSCORE_EXPORT vtkChartMatrix : public vtkAbstractContextItem
59 {
60 public:
62  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
67  static vtkChartMatrix* New();
68 
72  void Update() override;
73 
77  bool Paint(vtkContext2D* painter) override;
78 
84  virtual void SetSize(const vtkVector2i& size);
85 
89  virtual vtkVector2i GetSize() const { return this->Size; }
90 
92 
95  virtual void SetBorders(int left, int bottom, int right, int top);
96  void SetBorderLeft(int value);
98  void SetBorderRight(int value);
99  void SetBorderTop(int value);
100  virtual void GetBorders(int borders[4])
101  {
102  for (int i = 0; i < 4; i++)
103  {
104  borders[i] = this->Borders[i];
105  }
106  }
108 
110 
113  virtual void SetGutter(const vtkVector2f& gutter);
114  void SetGutterX(float value);
115  void SetGutterY(float value);
117 
119 
122  virtual void SetSpecificResize(const vtkVector2i& index, const vtkVector2f& resize);
123  virtual void ClearSpecificResizes();
125 
129  virtual vtkVector2f GetGutter() const { return this->Gutter; }
130 
134  virtual void Allocate();
135 
142  virtual bool SetChart(const vtkVector2i& position, vtkChart* chart);
143 
150 
156  virtual bool SetChartSpan(const vtkVector2i& position, const vtkVector2i& span);
157 
162 
168 
172  virtual std::size_t GetFlatIndex(const vtkVector2i& index);
173 
177  virtual std::size_t GetNumberOfCharts();
178 
184  virtual void LabelOuter(const vtkVector2i& leftBottomIdx, const vtkVector2i& rightTopIdx);
185 
187 
193  virtual void Link(const vtkVector2i& index1, const vtkVector2i& index2, int axis = 1);
194  virtual void Link(const size_t& flatIndex1, const size_t& flatIndex2, int axis = 1);
196 
198 
201  virtual void LinkAll(const vtkVector2i& index, int axis = 1);
202  virtual void LinkAll(const size_t& flatIndex, int axis = 1);
204 
206 
210  virtual void Unlink(const vtkVector2i& index1, const vtkVector2i& index2, int axis = 1);
211  virtual void Unlink(const size_t& flatIndex1, const size_t& flatIndex2, int axis = 1);
213 
215 
218  virtual void UnlinkAll(const vtkVector2i& index, int axis = 1);
219  virtual void UnlinkAll(const size_t& flatIndex, int axis = 1);
221 
223 
230  virtual void ResetLinks(int axis = 1);
231  virtual void ResetLinkedLayout();
233 
235 
239  virtual void SetRect(vtkRecti rect);
240  vtkGetMacro(Rect, vtkRecti);
242 
250  virtual bool SetChartMatrix(const vtkVector2i& position, vtkChartMatrix* chartMatrix);
251 
258 
260 
267  virtual bool IsDoneWithTraversal();
269 
276  const vtkVector2i& index, const vtkVector2f& offset, const vtkVector2f& increment);
277 
278  enum class StretchType : unsigned int
279  {
280  SCENE = 0,
281  CUSTOM
282  };
284 
288  vtkSetEnumMacro(FillStrategy, StretchType);
289  StretchType GetFillStrategy() { return this->FillStrategy; }
291 
292 protected:
294  ~vtkChartMatrix() override;
295 
296  // The number of charts in x and y.
298 
299  // The gutter between each chart.
301  std::map<vtkVector2i, vtkVector2f> SpecificResize;
302  int Borders[4];
304 
305  // The rectangular region to occupy. (in scene coordinates.)
306  vtkRecti Rect = { 0, 0, 100, 100 };
307  StretchType FillStrategy = StretchType::SCENE;
308 
309  virtual void SynchronizeAxisRanges(vtkObject* caller, unsigned long eventId, void* calldata);
310 
311 private:
312  vtkChartMatrix(const vtkChartMatrix&) = delete;
313  void operator=(const vtkChartMatrix&) = delete;
314 
315  class PIMPL;
316  PIMPL* Private;
317 };
318 
319 #endif // vtkChartMatrix_h
vtkChart
Factory class for drawing 2D charts.
Definition: vtkChart.h:45
vtkChartMatrix::SetBorderBottom
void SetBorderBottom(int value)
Set/get the borders of the chart matrix (space in pixels around each chart).
vtkChartMatrix::StretchType
StretchType
Definition: vtkChartMatrix.h:279
vtkChartMatrix::ResetLinkedLayout
virtual void ResetLinkedLayout()
Unlink every chart from all other charts for a specified axis.
vtkChartMatrix::Gutter
vtkVector2f Gutter
Definition: vtkChartMatrix.h:300
vtkChartMatrix::SpecificResize
std::map< vtkVector2i, vtkVector2f > SpecificResize
Definition: vtkChartMatrix.h:301
vtkX3D::value
@ value
Definition: vtkX3D.h:226
vtkChartMatrix::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAbstractContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkAbstractContextItem.h:41
vtkChartMatrix::GetSize
virtual vtkVector2i GetSize() const
Get the width and height of the chart matrix.
Definition: vtkChartMatrix.h:89
vtkChartMatrix::LinkAll
virtual void LinkAll(const size_t &flatIndex, int axis=1)
Link a chart to all other charts in this chart matrix for specified axis.
vtkChartMatrix::Link
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.
vtkChartMatrix::Paint
bool Paint(vtkContext2D *painter) override
Paint event for the chart matrix.
vtkChartMatrix::Size
vtkVector2i Size
Definition: vtkChartMatrix.h:297
vtkChartMatrix
container for a matrix of charts.
Definition: vtkChartMatrix.h:59
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:82
vtkVector.h
vtkChartMatrix::SetBorders
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).
vtkChartMatrix::SetRect
virtual void SetRect(vtkRecti rect)
Set the rectangular region that this chart matrix will occupy.
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:73
vtkX3D::top
@ top
Definition: vtkX3D.h:508
vtkChartMatrix::UnlinkAll
virtual void UnlinkAll(const size_t &flatIndex, int axis=1)
Unlink all charts from given chart for a specified axis.
vtkChartMatrix::GetNumberOfCharts
virtual std::size_t GetNumberOfCharts()
Total number of charts within this chart matrix.
vtkChartMatrix::SetChartMatrix
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...
vtkChartMatrix::GetFlatIndex
virtual std::size_t GetFlatIndex(const vtkVector2i &index)
Get internal 1-D index corresponding to the 2-D element index.
vtkChartMatrix::~vtkChartMatrix
~vtkChartMatrix() override
vtkChartMatrix::IsDoneWithTraversal
virtual bool IsDoneWithTraversal()
These methods offer an API to iterate over the layout and obtain the offset of each child element (ch...
vtkChartMatrix::GoToNextElement
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...
vtkX3D::position
@ position
Definition: vtkX3D.h:267
vtkChartMatrix::SynchronizeAxisRanges
virtual void SynchronizeAxisRanges(vtkObject *caller, unsigned long eventId, void *calldata)
vtkChartMatrix::GetChartIndex
virtual vtkVector2i GetChartIndex(const vtkVector2f &position)
Get the position of an element in the matrix at the specified location.
vtkChartMatrix::GetBorders
virtual void GetBorders(int borders[4])
Set/get the borders of the chart matrix (space in pixels around each chart).
Definition: vtkChartMatrix.h:100
vtkX3D::bottom
@ bottom
Definition: vtkX3D.h:296
vtkChartMatrix::SetSize
virtual void SetSize(const vtkVector2i &size)
Set the width and height of the chart matrix.
vtkX3D::offset
@ offset
Definition: vtkX3D.h:444
vtkChartMatrix::Allocate
virtual void Allocate()
Allocate the charts, this will cause any null chart to be allocated.
vtkChartMatrix::SetSpecificResize
virtual void SetSpecificResize(const vtkVector2i &index, const vtkVector2f &resize)
Set a specific resize that will move the bottom left point of a chart.
vtkRect.h
vtkChartMatrix::SetBorderRight
void SetBorderRight(int value)
Set/get the borders of the chart matrix (space in pixels around each chart).
vtkChartMatrix::UnlinkAll
virtual void UnlinkAll(const vtkVector2i &index, int axis=1)
Unlink all charts from given chart for a specified axis.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkChartMatrix::Link
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.
vtkChartMatrix::GetChartSpan
virtual vtkVector2i GetChartSpan(const vtkVector2i &position)
Get the span of the specified element.
vtkChartMatrix::vtkChartMatrix
vtkChartMatrix()
vtkChartMatrix::GetGutter
virtual vtkVector2f GetGutter() const
Get the gutter that should be left between the charts in the matrix.
Definition: vtkChartMatrix.h:129
vtkX3D::size
@ size
Definition: vtkX3D.h:259
vtkChartMatrix::New
static vtkChartMatrix * New()
Creates a new object.
vtkChartMatrix::SetChartSpan
virtual bool SetChartSpan(const vtkVector2i &position, const vtkVector2i &span)
Set the span of an element in the matrix.
vtkChartMatrix::SetBorderLeft
void SetBorderLeft(int value)
Set/get the borders of the chart matrix (space in pixels around each chart).
vtkChartMatrix::ComputeCurrentElementSceneRect
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.
vtkChartMatrix::LinkAll
virtual void LinkAll(const vtkVector2i &index, int axis=1)
Link a chart to all other charts in this chart matrix for specified axis.
vtkAbstractContextItem.h
vtkChartMatrix::Update
void Update() override
Perform any updates to the item that may be necessary before rendering.
vtkChartMatrix::LabelOuter
virtual void LabelOuter(const vtkVector2i &leftBottomIdx, const vtkVector2i &rightTopIdx)
Link all charts in the rectangle from leftBottom to rightTop.
vtkChartMatrix::vtkSetEnumMacro
vtkSetEnumMacro(FillStrategy, StretchType)
This specifies whether the chart matrix will fill the entire scene or instead draw itself in a user p...
vtkChartMatrix::Unlink
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 ...
vtkChartMatrix::SetGutterX
void SetGutterX(float value)
Set the gutter that should be left between the charts in the matrix.
vtkChartMatrix::LayoutIsDirty
bool LayoutIsDirty
Definition: vtkChartMatrix.h:303
vtkChartMatrix::GetChart
virtual vtkChart * GetChart(const vtkVector2i &position)
Get the specified chart element, if the element does not exist nullptr will be returned.
vtkRecti
Definition: vtkRect.h:322
vtkChartMatrix::SetBorderTop
void SetBorderTop(int value)
Set/get the borders of the chart matrix (space in pixels around each chart).
vtkVector2i
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:478
vtkChartMatrix::SetGutterY
void SetGutterY(float value)
Set the gutter that should be left between the charts in the matrix.
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkRectf
Definition: vtkRect.h:336
vtkVector2f
Definition: vtkVector.h:491
vtkChartMatrix::InitLayoutTraversal
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...
vtkChartMatrix::SetChart
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...
vtkChartMatrix::GetChartMatrix
virtual vtkChartMatrix * GetChartMatrix(const vtkVector2i &position)
Get the specified chart matrix element.
vtkChartMatrix::GetFillStrategy
StretchType GetFillStrategy()
This specifies whether the chart matrix will fill the entire scene or instead draw itself in a user p...
Definition: vtkChartMatrix.h:289
vtkChartMatrix::SetGutter
virtual void SetGutter(const vtkVector2f &gutter)
Set the gutter that should be left between the charts in the matrix.
vtkChartMatrix::ResetLinks
virtual void ResetLinks(int axis=1)
Unlink every chart from all other charts for a specified axis.
vtkChartMatrix::Unlink
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 ...
vtkChartMatrix::ClearSpecificResizes
virtual void ClearSpecificResizes()
Set a specific resize that will move the bottom left point of a chart.