/usr/include/vtk-7.1/vtkContextArea.h is in libvtk7-dev 7.1.1+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkContextArea.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkContextArea
* @brief Clipped, transformed area with axes for context items.
*
*
* vtkContextArea provides an clipped drawing area surrounded by four axes.
* The drawing area is transformed to map the 2D area described by
* DrawAreaBounds into pixel coordinates. DrawAreaBounds is also used to
* configure the axes. Item to be rendered in the draw area should be added
* to the context item returned by GetDrawAreaItem().
*
* The size and shape of the draw area is configured by the following member
* variables:
* - Geometry: The rect (pixel coordinates) defining the location of the context
* area in the scene. This includes the draw area and axis ticks/labels.
* - FillViewport: If true (default), Geometry is set to span the size returned
* by vtkContextDevice2D::GetViewportSize().
* - DrawAreaResizeBehavior: Controls how the draw area should be shaped.
* Available options: Expand (default), FixedAspect, FixedRect, FixedMargins.
* - FixedAspect: Aspect ratio to enforce for FixedAspect resize behavior.
* - FixedRect: Rect used to enforce for FixedRect resize behavior.
* - FixedMargins: Margins to enforce for FixedMargins resize behavior.
*/
#ifndef vtkContextArea_h
#define vtkContextArea_h
#include "vtkAbstractContextItem.h"
#include "vtkAxis.h" // For enums
#include "vtkChartsCoreModule.h" // For export macro
#include "vtkRect.h" // For vtkRect/vtkVector/vtkTuple
#include "vtkNew.h" // For vtkNew
class vtkContextClip;
class vtkContextTransform;
class vtkPlotGrid;
class VTKCHARTSCORE_EXPORT vtkContextArea: public vtkAbstractContextItem
{
public:
typedef vtkTuple<int, 4> Margins;
vtkTypeMacro(vtkContextArea, vtkAbstractContextItem)
virtual void PrintSelf(ostream &os, vtkIndent indent);
static vtkContextArea *New();
/**
* Get the vtkAxis associated with the specified location.
*/
vtkAxis* GetAxis(vtkAxis::Location location);
/**
* Returns the vtkAbstractContextItem that will draw in the clipped,
* transformed space. This is the item to add children for.
*/
vtkAbstractContextItem* GetDrawAreaItem();
/**
* Paint event for the item, called whenever the item needs to be drawn.
*/
virtual bool Paint(vtkContext2D *painter);
//@{
/**
* The rect defining the pixel location and size of the entire vtkContextArea,
* including axis labels, title, etc. Note that this will be updated to the
* window geometry if FillWindow is true.
*/
vtkGetMacro(Geometry, vtkRecti)
vtkSetMacro(Geometry, vtkRecti)
//@}
//@{
/**
* The data bounds of the clipped and transformed area inside of the axes.
* This is used to configure the axes labels and setup the transform.
*/
vtkGetMacro(DrawAreaBounds, vtkRectd)
vtkSetMacro(DrawAreaBounds, vtkRectd)
//@}
enum DrawAreaResizeBehaviorType {
DARB_Expand,
DARB_FixedAspect,
DARB_FixedRect,
DARB_FixedMargins
};
//@{
/**
* Set the resize behavior for the draw area:
* - @a Expand: The default behavior. The draw area will automatically resize
* to take up as much of @a Geometry as possible. Margin sizes are
* minimized based on the space required for axis labels/tick marks.
* - FixedAspect: Same as Expand, but a fixed aspected ratio is enforced.
* See SetFixedAspect.
* - FixedRect: Draw area is always constrained to a fixed rectangle.
* See SetFixedRect.
* - FixMargins: The draw area expands to fill @a Geometry, but margins
* (axis labels, etc) are fixed, rather than dynamically sized.
* See SetFixedMargins.
*/
vtkGetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType)
vtkSetMacro(DrawAreaResizeBehavior, DrawAreaResizeBehaviorType)
//@}
//@{
/**
* The fixed aspect ratio, if DrawAreaResizeBehavior is FixedAspect.
* Defined as width/height. Default is 1.
* Setting the aspect ratio will also set DrawAreaResizeBehavior to
* FixedAspect.
*/
vtkGetMacro(FixedAspect, float)
virtual void SetFixedAspect(float aspect);
//@}
//@{
/**
* The fixed rect to use for the draw area, if DrawAreaResizeBehavior is
* FixedRect. Units are in pixels, default is 300x300+0+0.
* Setting the fixed rect will also set DrawAreaResizeBehavior to
* FixedRect.
*/
vtkGetMacro(FixedRect, vtkRecti)
virtual void SetFixedRect(vtkRecti rect);
virtual void SetFixedRect(int x, int y, int width, int height);
//@}
//@{
/**
* The left, right, bottom, and top margins for the draw area, if
* DrawAreaResizeBehavior is FixedMargins. Units are in pixels, default is
* { 0, 0, 0, 0 }.
* Setting the fixed margins will also set DrawAreaResizeBehavior to
* FixedMargins.
*/
virtual const Margins& GetFixedMargins() { return this->FixedMargins; }
virtual void GetFixedMarginsArray(int margins[4]);
virtual const int* GetFixedMarginsArray();
virtual void SetFixedMargins(Margins margins);
virtual void SetFixedMargins(int margins[4]);
virtual void SetFixedMargins(int left, int right, int bottom, int top);
//@}
//@{
/**
* If true, Geometry is set to (0, 0, vpSize[0], vpSize[1]) at the start
* of each Paint call. vpSize is vtkContextDevice2D::GetViewportSize. Default
* is true.
*/
vtkGetMacro(FillViewport, bool)
vtkSetMacro(FillViewport, bool)
vtkBooleanMacro(FillViewport, bool)
//@}
//@{
/**
* Turn on/off grid visibility.
*/
virtual void SetShowGrid(bool show);
virtual bool GetShowGrid();
virtual void ShowGridOn() { this->SetShowGrid(true); }
virtual void ShowGridOff() { this->SetShowGrid(false); }
//@}
protected:
vtkContextArea();
~vtkContextArea();
/**
* Sync the Axes locations with Geometry, and update the DrawAreaGeometry
* to account for Axes size (margins). Must be called while the painter
* is active.
*/
void LayoutAxes(vtkContext2D *painter);
/**
* Return the draw area's geometry.
*/
vtkRecti ComputeDrawAreaGeometry(vtkContext2D *painter);
//@{
/**
* Working implementations for ComputeDrawAreaGeometry.
*/
vtkRecti ComputeExpandedDrawAreaGeometry(vtkContext2D *painter);
vtkRecti ComputeFixedAspectDrawAreaGeometry(vtkContext2D *painter);
vtkRecti ComputeFixedRectDrawAreaGeometry(vtkContext2D *painter);
vtkRecti ComputeFixedMarginsDrawAreaGeometry(vtkContext2D *painter);
//@}
/**
* Set the transform to map DrawAreaBounds to DrawAreaGeometry. Should be
* called after LayoutAxes to ensure that DrawAreaGeometry is up to date.
*/
void UpdateDrawArea();
/**
* vtkAxis objects that surround the draw area, indexed by vtkAxis::Location.
*/
vtkTuple<vtkAxis*, 4> Axes;
/**
* The vtkPlotGrid that renders a grid atop the data in the draw area.
*/
vtkNew<vtkPlotGrid> Grid;
/**
* The context item that clips rendered data.
*/
vtkNew<vtkContextClip> Clip;
/**
* The context item that clips rendered data.
*/
vtkNew<vtkContextTransform> Transform;
/**
* The rect defining the pixel location and size of the entire vtkContextArea,
* including axis label, title, etc.
*/
vtkRecti Geometry;
/**
* The data bounds of the clipped and transformed area inside of the axes.
* This is used to configure the axes labels and setup the transform.
*/
vtkRectd DrawAreaBounds;
/**
* The rect defining the pixel location and size of the clipped and
* transformed area inside the axes. Relative to Geometry.
*/
vtkRecti DrawAreaGeometry;
/**
* Controls how the draw area size is determined.
*/
DrawAreaResizeBehaviorType DrawAreaResizeBehavior;
/**
* The fixed aspect ratio, if DrawAreaResizeBehavior is FixedAspect.
* Defined as width/height. Default is 1.
*/
float FixedAspect;
/**
* The fixed rect to use for the draw area, if DrawAreaResizeBehavior is
* FixedRect. Units are in pixels, default is 300x300+0+0.
*/
vtkRecti FixedRect;
/**
* The left, right, bottom, and top margins for the draw area, if
* DrawAreaResizeBehavior is FixedMargins. Units are in pixels, default is
* { 0, 0, 0, 0 }
*/
Margins FixedMargins;
/**
* If true, Geometry is set to (0, 0, vpSize[0], vpSize[1]) at the start
* of each Paint call. vpSize is vtkContextDevice2D::GetViewportSize. Default
* is true.
*/
bool FillViewport;
private:
vtkContextArea(const vtkContextArea &) VTK_DELETE_FUNCTION;
void operator=(const vtkContextArea &) VTK_DELETE_FUNCTION;
// Smart pointers for axis lifetime management. See this->Axes.
vtkNew<vtkAxis> TopAxis;
vtkNew<vtkAxis> BottomAxis;
vtkNew<vtkAxis> LeftAxis;
vtkNew<vtkAxis> RightAxis;
};
#endif //vtkContextArea_h
|