VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
41 
42 VTK_ABI_NAMESPACE_BEGIN
43 class vtkContextClip;
45 class vtkPlotGrid;
46 
47 class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkContextArea : public vtkAbstractContextItem
48 {
49 public:
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
54  static vtkContextArea* New();
55 
60 
65  vtkAbstractContextItem* GetDrawAreaItem();
66 
70  bool Paint(vtkContext2D* painter) override;
71 
73 
78  vtkGetMacro(Geometry, vtkRecti);
79  vtkSetMacro(Geometry, vtkRecti);
81 
83 
87  vtkGetMacro(DrawAreaBounds, vtkRectd);
88  vtkSetMacro(DrawAreaBounds, vtkRectd);
90 
92  {
96  DARB_FixedMargins
97  };
98 
100 
113  vtkGetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType);
114  vtkSetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType);
116 
118 
124  vtkGetMacro(FixedAspect, float)
125  virtual void SetFixedAspect(float aspect);
127 
129 
135  vtkGetMacro(FixedRect, vtkRecti);
136  virtual void SetFixedRect(vtkRecti rect);
137  virtual void SetFixedRect(int x, int y, int width, int height);
139 
141 
148  virtual const Margins& GetFixedMargins() { return this->FixedMargins; }
149  virtual void GetFixedMarginsArray(int margins[4]);
150  virtual const int* GetFixedMarginsArray();
151  virtual void SetFixedMargins(Margins margins);
152  virtual void SetFixedMargins(int margins[4]);
153  virtual void SetFixedMargins(int left, int right, int bottom, int top);
155 
157 
162  vtkGetMacro(FillViewport, bool);
163  vtkSetMacro(FillViewport, bool);
164  vtkBooleanMacro(FillViewport, bool);
166 
168 
171  virtual void SetShowGrid(bool show);
172  virtual bool GetShowGrid();
173  virtual void ShowGridOn() { this->SetShowGrid(true); }
174  virtual void ShowGridOff() { this->SetShowGrid(false); }
176 
177 protected:
178  vtkContextArea();
179  ~vtkContextArea() override;
180 
186  void LayoutAxes(vtkContext2D* painter);
187  virtual void SetAxisRange(vtkRectd const& data);
188  virtual void ComputeViewTransform();
189 
193  vtkRecti ComputeDrawAreaGeometry(vtkContext2D* painter);
194 
196 
199  vtkRecti ComputeExpandedDrawAreaGeometry(vtkContext2D* painter);
200  vtkRecti ComputeFixedAspectDrawAreaGeometry(vtkContext2D* painter);
201  vtkRecti ComputeFixedRectDrawAreaGeometry(vtkContext2D* painter);
202  vtkRecti ComputeFixedMarginsDrawAreaGeometry(vtkContext2D* painter);
204 
209  void UpdateDrawArea();
210 
215 
220 
225 
230 
236 
242 
248 
253 
258  float FixedAspect;
259 
265 
271  Margins FixedMargins;
272 
279 
283  virtual void InitializeDrawArea();
284 
285  // Smart pointers for axis lifetime management. See this->Axes.
290 
291 private:
292  vtkContextArea(const vtkContextArea&) = delete;
293  void operator=(const vtkContextArea&) = delete;
294 };
295 
296 VTK_ABI_NAMESPACE_END
297 #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:71
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:61
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:27
#define VTK_MARSHALAUTO
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.