VTK  9.0.1
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 
40 #ifndef vtkContextArea_h
41 #define vtkContextArea_h
42 
43 #include "vtkAbstractContextItem.h"
44 
45 #include "vtkAxis.h" // For enums
46 #include "vtkChartsCoreModule.h" // For export macro
47 #include "vtkNew.h" // For vtkNew
48 #include "vtkRect.h" // For vtkRect/vtkVector/vtkTuple
49 
50 class vtkContextClip;
52 class vtkPlotGrid;
53 
54 class VTKCHARTSCORE_EXPORT vtkContextArea : public vtkAbstractContextItem
55 {
56 public:
59  void PrintSelf(ostream& os, vtkIndent indent) override;
60 
61  static vtkContextArea* New();
62 
67 
73 
77  bool Paint(vtkContext2D* painter) override;
78 
80 
85  vtkGetMacro(Geometry, vtkRecti);
86  vtkSetMacro(Geometry, vtkRecti);
88 
90 
94  vtkGetMacro(DrawAreaBounds, vtkRectd);
95  vtkSetMacro(DrawAreaBounds, vtkRectd);
97 
99  {
103  DARB_FixedMargins
104  };
105 
107 
120  vtkGetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType);
121  vtkSetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType);
123 
125 
131  vtkGetMacro(FixedAspect, float) virtual void SetFixedAspect(float aspect);
133 
135 
141  vtkGetMacro(FixedRect, vtkRecti);
142  virtual void SetFixedRect(vtkRecti rect);
143  virtual void SetFixedRect(int x, int y, int width, int height);
145 
147 
154  virtual const Margins& GetFixedMargins() { return this->FixedMargins; }
155  virtual void GetFixedMarginsArray(int margins[4]);
156  virtual const int* GetFixedMarginsArray();
157  virtual void SetFixedMargins(Margins margins);
158  virtual void SetFixedMargins(int margins[4]);
159  virtual void SetFixedMargins(int left, int right, int bottom, int top);
161 
163 
168  vtkGetMacro(FillViewport, bool);
169  vtkSetMacro(FillViewport, bool);
170  vtkBooleanMacro(FillViewport, bool);
172 
174 
177  virtual void SetShowGrid(bool show);
178  virtual bool GetShowGrid();
179  virtual void ShowGridOn() { this->SetShowGrid(true); }
180  virtual void ShowGridOff() { this->SetShowGrid(false); }
182 
183 protected:
185  ~vtkContextArea() override;
186 
192  void LayoutAxes(vtkContext2D* painter);
193  virtual void SetAxisRange(vtkRectd const& data);
194  virtual void ComputeViewTransform();
195 
200 
202 
210 
216 
221 
226 
231 
236 
242 
248 
254 
259 
264  float FixedAspect;
265 
271 
278 
285 
289  virtual void InitializeDrawArea();
290 
291  // Smart pointers for axis lifetime management. See this->Axes.
296 
297 private:
298  vtkContextArea(const vtkContextArea&) = delete;
299  void operator=(const vtkContextArea&) = delete;
300 };
301 
302 #endif // vtkContextArea_h
vtkContextArea::FixedAspect
float FixedAspect
The fixed aspect ratio, if DrawAreaResizeBehavior is FixedAspect.
Definition: vtkContextArea.h:264
vtkContextArea::Axes
vtkTuple< vtkAxis *, 4 > Axes
vtkAxis objects that surround the draw area, indexed by vtkAxis::Location.
Definition: vtkContextArea.h:220
vtkContextArea::FillViewport
bool FillViewport
If true, Geometry is set to (0, 0, vpSize[0], vpSize[1]) at the start of each Paint call.
Definition: vtkContextArea.h:284
vtkContextArea::InitializeDrawArea
virtual void InitializeDrawArea()
Initialize the drawing area's item hierarchy.
vtkAxis.h
vtkContextArea::DrawAreaGeometry
vtkRecti DrawAreaGeometry
The rect defining the pixel location and size of the clipped and transformed area inside the axes.
Definition: vtkContextArea.h:253
vtkContextArea::GetFixedMargins
virtual const Margins & GetFixedMargins()
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
Definition: vtkContextArea.h:154
vtkContextArea::SetFixedMargins
virtual void SetFixedMargins(Margins margins)
vtkContextArea::New
static vtkContextArea * New()
vtkAbstractContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkAbstractContextItem.h:41
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkContextArea::ComputeFixedAspectDrawAreaGeometry
vtkRecti ComputeFixedAspectDrawAreaGeometry(vtkContext2D *painter)
vtkContextArea::ComputeExpandedDrawAreaGeometry
vtkRecti ComputeExpandedDrawAreaGeometry(vtkContext2D *painter)
Working implementations for ComputeDrawAreaGeometry.
vtkContextArea::GetShowGrid
virtual bool GetShowGrid()
vtkContextArea::Margins
vtkTuple< int, 4 > Margins
Definition: vtkContextArea.h:57
vtkContextArea::DARB_FixedRect
@ DARB_FixedRect
Definition: vtkContextArea.h:102
vtkContextArea::FixedMargins
Margins FixedMargins
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
Definition: vtkContextArea.h:277
vtkContextArea
Clipped, transformed area with axes for context items.
Definition: vtkContextArea.h:55
vtkContextArea::GetAxis
vtkAxis * GetAxis(vtkAxis::Location location)
Get the vtkAxis associated with the specified location.
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:53
vtkX3D::top
@ top
Definition: vtkX3D.h:508
vtkContextArea::BottomAxis
vtkNew< vtkAxis > BottomAxis
Definition: vtkContextArea.h:293
vtkRectd
Definition: vtkRect.h:341
vtkContextClip
all children of this item are clipped by the specified area.
Definition: vtkContextClip.h:34
vtkContextArea::DARB_FixedAspect
@ DARB_FixedAspect
Definition: vtkContextArea.h:101
vtkContextArea::Paint
bool Paint(vtkContext2D *painter) override
Paint event for the item, called whenever the item needs to be drawn.
vtkContextArea::GetFixedMarginsArray
virtual const int * GetFixedMarginsArray()
vtkContextArea::DrawAreaResizeBehavior
DrawAreaResizeBehaviorType DrawAreaResizeBehavior
Controls how the draw area size is determined.
Definition: vtkContextArea.h:258
vtkContextArea::TopAxis
vtkNew< vtkAxis > TopAxis
Definition: vtkContextArea.h:292
vtkX3D::bottom
@ bottom
Definition: vtkX3D.h:296
vtkX3D::height
@ height
Definition: vtkX3D.h:260
vtkContextArea::SetFixedMargins
virtual void SetFixedMargins(int left, int right, int bottom, int top)
vtkContextArea::Geometry
vtkRecti Geometry
The rect defining the pixel location and size of the entire vtkContextArea, including axis label,...
Definition: vtkContextArea.h:241
vtkPlotGrid
takes care of drawing the plot grid
Definition: vtkPlotGrid.h:39
vtkRect.h
vtkContextArea::~vtkContextArea
~vtkContextArea() override
vtkAxis::Location
Location
Enumeration of the axis locations in a conventional XY chart.
Definition: vtkAxis.h:79
vtkContextArea::ComputeFixedMarginsDrawAreaGeometry
vtkRecti ComputeFixedMarginsDrawAreaGeometry(vtkContext2D *painter)
vtkContextArea::ComputeDrawAreaGeometry
vtkRecti ComputeDrawAreaGeometry(vtkContext2D *painter)
Return the draw area's geometry.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkContextArea::SetAxisRange
virtual void SetAxisRange(vtkRectd const &data)
vtkContextArea::LeftAxis
vtkNew< vtkAxis > LeftAxis
Definition: vtkContextArea.h:294
detail::show
void show(std::shared_ptr< QObject > widgetOrWindow, const QSize &size)
vtkContextArea::GetDrawAreaItem
vtkAbstractContextItem * GetDrawAreaItem()
Returns the vtkAbstractContextItem that will draw in the clipped, transformed space.
vtkContextArea::SetShowGrid
virtual void SetShowGrid(bool show)
Turn on/off grid visibility.
vtkContextArea::ShowGridOn
virtual void ShowGridOn()
Definition: vtkContextArea.h:179
vtkNew< vtkPlotGrid >
vtkContextArea::Transform
vtkNew< vtkContextTransform > Transform
The context item that clips rendered data.
Definition: vtkContextArea.h:235
vtkContextArea::RightAxis
vtkNew< vtkAxis > RightAxis
Definition: vtkContextArea.h:295
vtkContextArea::SetFixedRect
virtual void SetFixedRect(int x, int y, int width, int height)
vtkContextArea::UpdateDrawArea
void UpdateDrawArea()
Set the transform to map DrawAreaBounds to DrawAreaGeometry.
vtkContextArea::ComputeViewTransform
virtual void ComputeViewTransform()
vtkContextArea::DrawAreaResizeBehaviorType
DrawAreaResizeBehaviorType
Definition: vtkContextArea.h:99
vtkContextArea::SetFixedMargins
virtual void SetFixedMargins(int margins[4])
vtkAbstractContextItem.h
vtkContextTransform
all children of this item are transformed by the vtkTransform2D of this item.
Definition: vtkContextTransform.h:37
vtkContextArea::DrawAreaBounds
vtkRectd DrawAreaBounds
The data bounds of the clipped and transformed area inside of the axes.
Definition: vtkContextArea.h:247
vtkContextArea::SetFixedAspect
virtual void SetFixedAspect(float aspect)
vtkContextArea::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkNew.h
vtkContextArea::ComputeFixedRectDrawAreaGeometry
vtkRecti ComputeFixedRectDrawAreaGeometry(vtkContext2D *painter)
vtkContextArea::SetFixedRect
virtual void SetFixedRect(vtkRecti rect)
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:69
vtkContextArea::DARB_Expand
@ DARB_Expand
Definition: vtkContextArea.h:100
vtkContextArea::LayoutAxes
void LayoutAxes(vtkContext2D *painter)
Sync the Axes locations with Geometry, and update the DrawAreaGeometry to account for Axes size (marg...
vtkX3D::location
@ location
Definition: vtkX3D.h:412
vtkContextArea::Grid
vtkNew< vtkPlotGrid > Grid
The vtkPlotGrid that renders a grid atop the data in the draw area.
Definition: vtkContextArea.h:225
vtkRecti
Definition: vtkRect.h:313
vtkContextArea::ShowGridOff
virtual void ShowGridOff()
Definition: vtkContextArea.h:180
vtkContextArea::GetFixedMarginsArray
virtual void GetFixedMarginsArray(int margins[4])
vtkContextArea::vtkContextArea
vtkContextArea()
vtkTuple< int, 4 >
vtkContextArea::FixedRect
vtkRecti FixedRect
The fixed rect to use for the draw area, if DrawAreaResizeBehavior is FixedRect.
Definition: vtkContextArea.h:270
vtkContextArea::Clip
vtkNew< vtkContextClip > Clip
The context item that clips rendered data.
Definition: vtkContextArea.h:230