VTK  9.3.1
vtkContextArea.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 
31 #ifndef vtkContextArea_h
32 #define vtkContextArea_h
33 
34 #include "vtkAbstractContextItem.h"
35 
36 #include "vtkAxis.h" // For enums
37 #include "vtkChartsCoreModule.h" // For export macro
38 #include "vtkNew.h" // For vtkNew
39 #include "vtkRect.h" // For vtkRect/vtkVector/vtkTuple
40 
41 VTK_ABI_NAMESPACE_BEGIN
42 class vtkContextClip;
44 class vtkPlotGrid;
45 
46 class VTKCHARTSCORE_EXPORT vtkContextArea : public vtkAbstractContextItem
47 {
48 public:
51  void PrintSelf(ostream& os, vtkIndent indent) override;
52 
53  static vtkContextArea* New();
54 
59 
64  vtkAbstractContextItem* GetDrawAreaItem();
65 
69  bool Paint(vtkContext2D* painter) override;
70 
72 
77  vtkGetMacro(Geometry, vtkRecti);
78  vtkSetMacro(Geometry, vtkRecti);
80 
82 
86  vtkGetMacro(DrawAreaBounds, vtkRectd);
87  vtkSetMacro(DrawAreaBounds, vtkRectd);
89 
91  {
95  DARB_FixedMargins
96  };
97 
99 
112  vtkGetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType);
113  vtkSetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType);
115 
117 
123  vtkGetMacro(FixedAspect, float) virtual void SetFixedAspect(float aspect);
125 
127 
133  vtkGetMacro(FixedRect, vtkRecti);
134  virtual void SetFixedRect(vtkRecti rect);
135  virtual void SetFixedRect(int x, int y, int width, int height);
137 
139 
146  virtual const Margins& GetFixedMargins() { return this->FixedMargins; }
147  virtual void GetFixedMarginsArray(int margins[4]);
148  virtual const int* GetFixedMarginsArray();
149  virtual void SetFixedMargins(Margins margins);
150  virtual void SetFixedMargins(int margins[4]);
151  virtual void SetFixedMargins(int left, int right, int bottom, int top);
153 
155 
160  vtkGetMacro(FillViewport, bool);
161  vtkSetMacro(FillViewport, bool);
162  vtkBooleanMacro(FillViewport, bool);
164 
166 
169  virtual void SetShowGrid(bool show);
170  virtual bool GetShowGrid();
171  virtual void ShowGridOn() { this->SetShowGrid(true); }
172  virtual void ShowGridOff() { this->SetShowGrid(false); }
174 
175 protected:
176  vtkContextArea();
177  ~vtkContextArea() override;
178 
184  void LayoutAxes(vtkContext2D* painter);
185  virtual void SetAxisRange(vtkRectd const& data);
186  virtual void ComputeViewTransform();
187 
191  vtkRecti ComputeDrawAreaGeometry(vtkContext2D* painter);
192 
194 
197  vtkRecti ComputeExpandedDrawAreaGeometry(vtkContext2D* painter);
198  vtkRecti ComputeFixedAspectDrawAreaGeometry(vtkContext2D* painter);
199  vtkRecti ComputeFixedRectDrawAreaGeometry(vtkContext2D* painter);
200  vtkRecti ComputeFixedMarginsDrawAreaGeometry(vtkContext2D* painter);
202 
207  void UpdateDrawArea();
208 
213 
218 
223 
228 
234 
240 
246 
251 
256  float FixedAspect;
257 
263 
269  Margins FixedMargins;
270 
277 
281  virtual void InitializeDrawArea();
282 
283  // Smart pointers for axis lifetime management. See this->Axes.
288 
289 private:
290  vtkContextArea(const vtkContextArea&) = delete;
291  void operator=(const vtkContextArea&) = delete;
292 };
293 
294 VTK_ABI_NAMESPACE_END
295 #endif // vtkContextArea_h
bool FillViewport
If true, Geometry is set to (0, 0, vpSize[0], vpSize[1]) at the start of each Paint call...
Location
Enumeration of the axis locations in a conventional XY chart.
Definition: vtkAxis.h:70
vtkTuple< int, 4 > Margins
vtkNew< vtkAxis > BottomAxis
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
virtual void ShowGridOff()
Turn on/off grid visibility.
vtkRecti Geometry
The rect defining the pixel location and size of the entire vtkContextArea, including axis label...
Margins FixedMargins
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
vtkNew< vtkContextClip > Clip
The context item that clips rendered data.
all children of this item are transformed by the vtkTransform2D of this item.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRecti DrawAreaGeometry
The rect defining the pixel location and size of the clipped and transformed area inside the axes...
virtual void ShowGridOn()
Turn on/off grid visibility.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
takes care of drawing 2D axes
Definition: vtkAxis.h:60
a simple class to control print indentation
Definition: vtkIndent.h:28
void show(std::shared_ptr< QObject > widgetOrWindow, const QSize &size)
vtkNew< vtkContextTransform > Transform
The context item that clips rendered data.
Clipped, transformed area with axes for context items.
vtkNew< vtkAxis > TopAxis
vtkNew< vtkAxis > LeftAxis
vtkRecti FixedRect
The fixed rect to use for the draw area, if DrawAreaResizeBehavior is FixedRect.
vtkNew< vtkAxis > RightAxis
float FixedAspect
The fixed aspect ratio, if DrawAreaResizeBehavior is FixedAspect.
base class for items that are part of a vtkContextScene.
takes care of drawing the plot grid
Definition: vtkPlotGrid.h:26
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkNew< vtkPlotGrid > Grid
The vtkPlotGrid that renders a grid atop the data in the draw area.
vtkRectd DrawAreaBounds
The data bounds of the clipped and transformed area inside of the axes.
vtkTuple< vtkAxis *, 4 > Axes
vtkAxis objects that surround the draw area, indexed by vtkAxis::Location.
all children of this item are clipped by the specified area.
DrawAreaResizeBehaviorType DrawAreaResizeBehavior
Controls how the draw area size is determined.