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  virtual void PrintSelf(ostream &os, vtkIndent indent);
63 
64  static vtkContextArea *New();
65 
69  vtkAxis* GetAxis(vtkAxis::Location location);
70 
75  vtkAbstractContextItem* GetDrawAreaItem();
76 
80  virtual bool Paint(vtkContext2D *painter);
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();
189 
195  void LayoutAxes(vtkContext2D *painter);
196 
200  vtkRecti ComputeDrawAreaGeometry(vtkContext2D *painter);
201 
203 
206  vtkRecti ComputeExpandedDrawAreaGeometry(vtkContext2D *painter);
207  vtkRecti ComputeFixedAspectDrawAreaGeometry(vtkContext2D *painter);
208  vtkRecti ComputeFixedRectDrawAreaGeometry(vtkContext2D *painter);
209  vtkRecti ComputeFixedMarginsDrawAreaGeometry(vtkContext2D *painter);
211 
216  void UpdateDrawArea();
217 
222 
227 
232 
237 
243 
249 
255 
260 
265  float FixedAspect;
266 
272 
278  Margins FixedMargins;
279 
286 
287 private:
288  vtkContextArea(const vtkContextArea &) VTK_DELETE_FUNCTION;
289  void operator=(const vtkContextArea &) VTK_DELETE_FUNCTION;
290 
291  // Smart pointers for axis lifetime management. See this->Axes.
292  vtkNew<vtkAxis> TopAxis;
293  vtkNew<vtkAxis> BottomAxis;
294  vtkNew<vtkAxis> LeftAxis;
295  vtkNew<vtkAxis> RightAxis;
296 };
297 
298 #endif //vtkContextArea_h
bool FillViewport
If true, Geometry is set to (0, 0, vpSize[0], vpSize[1]) at the start of each Paint call...
vtkTuple< int, 4 > Margins
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.
vtkRecti DrawAreaGeometry
The rect defining the pixel location and size of the clipped and transformed area inside the axes...
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:57
takes care of drawing 2D axes
Definition: vtkAxis.h:71
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkNew< vtkContextTransform > Transform
The context item that clips rendered data.
Clipped, transformed area with axes for context items.
vtkRecti FixedRect
The fixed rect to use for the draw area, if DrawAreaResizeBehavior is FixedRect.
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:38
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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.