VTK  9.3.0
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 
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:
177  ~vtkContextArea() override;
178 
184  void LayoutAxes(vtkContext2D* painter);
185  virtual void SetAxisRange(vtkRectd const& data);
186  virtual void ComputeViewTransform();
187 
192 
194 
202 
208 
213 
218 
223 
228 
234 
240 
246 
251 
256  float FixedAspect;
257 
263 
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
base class for items that are part of a vtkContextScene.
takes care of drawing 2D axes
Definition: vtkAxis.h:70
Location
Enumeration of the axis locations in a conventional XY chart.
Definition: vtkAxis.h:80
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:59
Clipped, transformed area with axes for context items.
vtkAxis * GetAxis(vtkAxis::Location location)
Get the vtkAxis associated with the specified location.
vtkRecti ComputeDrawAreaGeometry(vtkContext2D *painter)
Return the draw area's geometry.
vtkRecti ComputeFixedRectDrawAreaGeometry(vtkContext2D *painter)
Working implementations for ComputeDrawAreaGeometry.
virtual void ComputeViewTransform()
virtual void GetFixedMarginsArray(int margins[4])
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
bool Paint(vtkContext2D *painter) override
Paint event for the item, called whenever the item needs to be drawn.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRecti ComputeExpandedDrawAreaGeometry(vtkContext2D *painter)
Working implementations for ComputeDrawAreaGeometry.
virtual void SetFixedRect(int x, int y, int width, int height)
The fixed rect to use for the draw area, if DrawAreaResizeBehavior is FixedRect.
vtkRecti DrawAreaGeometry
The rect defining the pixel location and size of the clipped and transformed area inside the axes.
vtkNew< vtkAxis > LeftAxis
virtual void SetAxisRange(vtkRectd const &data)
vtkTuple< vtkAxis *, 4 > Axes
vtkAxis objects that surround the draw area, indexed by vtkAxis::Location.
virtual void ShowGridOff()
Turn on/off grid visibility.
vtkNew< vtkContextClip > Clip
The context item that clips rendered data.
float FixedAspect
The fixed aspect ratio, if DrawAreaResizeBehavior is FixedAspect.
virtual void ShowGridOn()
Turn on/off grid visibility.
vtkTuple< int, 4 > Margins
virtual const Margins & GetFixedMargins()
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
vtkNew< vtkAxis > BottomAxis
void UpdateDrawArea()
Set the transform to map DrawAreaBounds to DrawAreaGeometry.
vtkRecti ComputeFixedMarginsDrawAreaGeometry(vtkContext2D *painter)
Working implementations for ComputeDrawAreaGeometry.
bool FillViewport
If true, Geometry is set to (0, 0, vpSize[0], vpSize[1]) at the start of each Paint call.
virtual void SetShowGrid(bool show)
Turn on/off grid visibility.
vtkNew< vtkAxis > TopAxis
vtkRecti FixedRect
The fixed rect to use for the draw area, if DrawAreaResizeBehavior is FixedRect.
vtkRecti Geometry
The rect defining the pixel location and size of the entire vtkContextArea, including axis label,...
vtkNew< vtkContextTransform > Transform
The context item that clips rendered data.
~vtkContextArea() override
void LayoutAxes(vtkContext2D *painter)
Sync the Axes locations with Geometry, and update the DrawAreaGeometry to account for Axes size (marg...
vtkNew< vtkAxis > RightAxis
virtual void SetFixedRect(vtkRecti rect)
The fixed rect to use for the draw area, if DrawAreaResizeBehavior is FixedRect.
virtual const int * GetFixedMarginsArray()
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
virtual void SetFixedMargins(Margins margins)
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
Margins FixedMargins
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
vtkRectd DrawAreaBounds
The data bounds of the clipped and transformed area inside of the axes.
virtual void SetFixedMargins(int margins[4])
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
vtkAbstractContextItem * GetDrawAreaItem()
Returns the vtkAbstractContextItem that will draw in the clipped, transformed space.
virtual void InitializeDrawArea()
Initialize the drawing area's item hierarchy.
static vtkContextArea * New()
virtual bool GetShowGrid()
Turn on/off grid visibility.
vtkNew< vtkPlotGrid > Grid
The vtkPlotGrid that renders a grid atop the data in the draw area.
virtual void SetFixedMargins(int left, int right, int bottom, int top)
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
vtkRecti ComputeFixedAspectDrawAreaGeometry(vtkContext2D *painter)
Working implementations for ComputeDrawAreaGeometry.
DrawAreaResizeBehaviorType DrawAreaResizeBehavior
Controls how the draw area size is determined.
all children of this item are clipped by the specified area.
all children of this item are transformed by the vtkTransform2D of this item.
a simple class to control print indentation
Definition: vtkIndent.h:38
takes care of drawing the plot grid
Definition: vtkPlotGrid.h:27
void show(std::shared_ptr< QObject > widgetOrWindow, const QSize &size)
@ location
Definition: vtkX3D.h:406
@ top
Definition: vtkX3D.h:502
@ bottom
Definition: vtkX3D.h:290
@ height
Definition: vtkX3D.h:254
@ data
Definition: vtkX3D.h:315