VTK
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 
46 #include "vtkAbstractContextItem.h"
47 
48 #include "vtkAxis.h" // For enums
49 #include "vtkChartsCoreModule.h" // For export macro
50 #include "vtkRect.h" // For vtkRect/vtkVector/vtkTuple
51 #include "vtkNew.h" // For vtkNew
52 
53 class vtkContextClip;
55 class vtkPlotGrid;
56 
57 class VTKCHARTSCORE_EXPORT vtkContextArea: public vtkAbstractContextItem
58 {
59 public:
62  void PrintSelf(ostream &os, vtkIndent indent) override;
63 
64  static vtkContextArea *New();
65 
70 
75  vtkAbstractContextItem* GetDrawAreaItem();
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 
105  DARB_FixedMargins
106  };
107 
109 
122  vtkGetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType)
123  vtkSetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType)
125 
127 
133  vtkGetMacro(FixedAspect, float)
134  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 
186 protected:
187  vtkContextArea();
188  ~vtkContextArea() override;
189 
195  void LayoutAxes(vtkContext2D *painter);
196  virtual void SetAxisRange(vtkRectd const& data);
197  virtual void ComputeViewTransform();
198 
202  vtkRecti ComputeDrawAreaGeometry(vtkContext2D *painter);
203 
205 
208  vtkRecti ComputeExpandedDrawAreaGeometry(vtkContext2D *painter);
209  vtkRecti ComputeFixedAspectDrawAreaGeometry(vtkContext2D *painter);
210  vtkRecti ComputeFixedRectDrawAreaGeometry(vtkContext2D *painter);
211  vtkRecti ComputeFixedMarginsDrawAreaGeometry(vtkContext2D *painter);
213 
218  void UpdateDrawArea();
219 
224 
229 
234 
239 
245 
251 
257 
262 
267  float FixedAspect;
268 
274 
281 
288 
292  virtual void InitializeDrawArea();
293 
294  // Smart pointers for axis lifetime management. See this->Axes.
299 
300 private:
301  vtkContextArea(const vtkContextArea &) = delete;
302  void operator=(const vtkContextArea &) = delete;
303 };
304 
305 #endif //vtkContextArea_h
vtkContextArea::FixedAspect
float FixedAspect
The fixed aspect ratio, if DrawAreaResizeBehavior is FixedAspect.
Definition: vtkContextArea.h:267
vtkContextArea::Axes
vtkTuple< vtkAxis *, 4 > Axes
vtkAxis objects that surround the draw area, indexed by vtkAxis::Location.
Definition: vtkContextArea.h:223
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:287
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:256
vtkContextArea::GetFixedMargins
virtual const Margins & GetFixedMargins()
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
Definition: vtkContextArea.h:157
vtkAbstractContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkAbstractContextItem.h:40
vtkX3D::data
Definition: vtkX3D.h:315
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkContextArea::Margins
vtkTuple< int, 4 > Margins
Definition: vtkContextArea.h:60
vtkContextArea::DARB_FixedRect
Definition: vtkContextArea.h:104
vtkContextArea::FixedMargins
Margins FixedMargins
The left, right, bottom, and top margins for the draw area, if DrawAreaResizeBehavior is FixedMargins...
Definition: vtkContextArea.h:280
vtkContextArea
Clipped, transformed area with axes for context items.
Definition: vtkContextArea.h:57
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:58
vtkX3D::top
Definition: vtkX3D.h:502
vtkContextArea::BottomAxis
vtkNew< vtkAxis > BottomAxis
Definition: vtkContextArea.h:296
vtkRectd
Definition: vtkRect.h:341
vtkContextClip
all children of this item are clipped by the specified area.
Definition: vtkContextClip.h:33
vtkContextArea::DARB_FixedAspect
Definition: vtkContextArea.h:103
vtkAbstractContextItem::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkContextArea::DrawAreaResizeBehavior
DrawAreaResizeBehaviorType DrawAreaResizeBehavior
Controls how the draw area size is determined.
Definition: vtkContextArea.h:261
vtkContextArea::TopAxis
vtkNew< vtkAxis > TopAxis
Definition: vtkContextArea.h:295
vtkX3D::bottom
Definition: vtkX3D.h:290
vtkX3D::height
Definition: vtkX3D.h:254
vtkContextArea::Geometry
vtkRecti Geometry
The rect defining the pixel location and size of the entire vtkContextArea, including axis label,...
Definition: vtkContextArea.h:244
vtkPlotGrid
takes care of drawing the plot grid
Definition: vtkPlotGrid.h:38
vtkRect.h
vtkAxis::Location
Location
Enumeration of the axis locations in a conventional XY chart.
Definition: vtkAxis.h:81
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkContextArea::LeftAxis
vtkNew< vtkAxis > LeftAxis
Definition: vtkContextArea.h:297
vtkContextArea::ShowGridOn
virtual void ShowGridOn()
Definition: vtkContextArea.h:182
vtkNew< vtkPlotGrid >
vtkContextArea::Transform
vtkNew< vtkContextTransform > Transform
The context item that clips rendered data.
Definition: vtkContextArea.h:238
vtkContextArea::RightAxis
vtkNew< vtkAxis > RightAxis
Definition: vtkContextArea.h:298
vtkContextArea::DrawAreaResizeBehaviorType
DrawAreaResizeBehaviorType
Definition: vtkContextArea.h:101
vtkAbstractContextItem.h
vtkContextTransform
all children of this item are transformed by the vtkTransform2D of this item.
Definition: vtkContextTransform.h:39
vtkContextArea::DrawAreaBounds
vtkRectd DrawAreaBounds
The data bounds of the clipped and transformed area inside of the axes.
Definition: vtkContextArea.h:250
vtkNew.h
vtkAbstractContextItem::Paint
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:71
vtkContextArea::DARB_Expand
Definition: vtkContextArea.h:102
vtkX3D::location
Definition: vtkX3D.h:406
vtkContextArea::Grid
vtkNew< vtkPlotGrid > Grid
The vtkPlotGrid that renders a grid atop the data in the draw area.
Definition: vtkContextArea.h:228
vtkRecti
Definition: vtkRect.h:323
vtkContextArea::ShowGridOff
virtual void ShowGridOff()
Definition: vtkContextArea.h:183
vtkTuple< int, 4 >
vtkContextArea::FixedRect
vtkRecti FixedRect
The fixed rect to use for the draw area, if DrawAreaResizeBehavior is FixedRect.
Definition: vtkContextArea.h:273
vtkContextArea::Clip
vtkNew< vtkContextClip > Clip
The context item that clips rendered data.
Definition: vtkContextArea.h:233