VTK  9.2.5
vtkContextArea.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkContextArea.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
43#ifndef vtkContextArea_h
44#define vtkContextArea_h
45
47
48#include "vtkAxis.h" // For enums
49#include "vtkChartsCoreModule.h" // For export macro
50#include "vtkNew.h" // For vtkNew
51#include "vtkRect.h" // For vtkRect/vtkVector/vtkTuple
52
53class vtkContextClip;
55class vtkPlotGrid;
56
57class VTKCHARTSCORE_EXPORT vtkContextArea : public vtkAbstractContextItem
58{
59public:
62 void PrintSelf(ostream& os, vtkIndent indent) override;
63
65
70
76
80 bool Paint(vtkContext2D* painter) override;
81
83
88 vtkGetMacro(Geometry, vtkRecti);
89 vtkSetMacro(Geometry, vtkRecti);
91
93
97 vtkGetMacro(DrawAreaBounds, vtkRectd);
98 vtkSetMacro(DrawAreaBounds, vtkRectd);
100
102 {
106 DARB_FixedMargins
107 };
108
110
123 vtkGetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType);
124 vtkSetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType);
126
128
134 vtkGetMacro(FixedAspect, float) virtual void SetFixedAspect(float aspect);
136
138
144 vtkGetMacro(FixedRect, vtkRecti);
145 virtual void SetFixedRect(vtkRecti rect);
146 virtual void SetFixedRect(int x, int y, int width, int height);
148
150
157 virtual const Margins& GetFixedMargins() { return this->FixedMargins; }
158 virtual void GetFixedMarginsArray(int margins[4]);
159 virtual const int* GetFixedMarginsArray();
160 virtual void SetFixedMargins(Margins margins);
161 virtual void SetFixedMargins(int margins[4]);
162 virtual void SetFixedMargins(int left, int right, int bottom, int top);
164
166
171 vtkGetMacro(FillViewport, bool);
172 vtkSetMacro(FillViewport, bool);
173 vtkBooleanMacro(FillViewport, bool);
175
177
180 virtual void SetShowGrid(bool show);
181 virtual bool GetShowGrid();
182 virtual void ShowGridOn() { this->SetShowGrid(true); }
183 virtual void ShowGridOff() { this->SetShowGrid(false); }
185
186protected:
188 ~vtkContextArea() override;
189
195 void LayoutAxes(vtkContext2D* painter);
196 virtual void SetAxisRange(vtkRectd const& data);
197 virtual void ComputeViewTransform();
198
203
205
213
219
224
229
234
239
245
251
257
262
268
274
281
288
292 virtual void InitializeDrawArea();
293
294 // Smart pointers for axis lifetime management. See this->Axes.
299
300private:
301 vtkContextArea(const vtkContextArea&) = delete;
302 void operator=(const vtkContextArea&) = delete;
303};
304
305#endif // vtkContextArea_h
base class for items that are part of a vtkContextScene.
takes care of drawing 2D axes
Definition: vtkAxis.h:72
Location
Enumeration of the axis locations in a conventional XY chart.
Definition: vtkAxis.h:82
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:58
Clipped, transformed area with axes for context items.
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 const int * GetFixedMarginsArray()
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
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.
vtkAxis * GetAxis(vtkAxis::Location location)
Get the vtkAxis associated with the specified location.
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.
static vtkContextArea * New()
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 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...
virtual void InitializeDrawArea()
Initialize the drawing area's item hierarchy.
vtkAbstractContextItem * GetDrawAreaItem()
Returns the vtkAbstractContextItem that will draw in the clipped, transformed space.
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:40
Allocate and hold a VTK object.
Definition: vtkNew.h:62
takes care of drawing the plot grid
Definition: vtkPlotGrid.h:39
templated base type for containers of constant size.
Definition: vtkTuple.h:38