VTK
vtkRect.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkVector.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 
26 #ifndef vtkRect_h
27 #define vtkRect_h
28 
29 #include "vtkVector.h"
30 
31 template<typename T>
32 class vtkRect : public vtkVector<T, 4>
33 {
34 public:
36  {
37  }
38 
39  vtkRect(const T& x, const T& y, const T& width, const T& height)
40  {
41  this->Data[0] = x;
42  this->Data[1] = y;
43  this->Data[2] = width;
44  this->Data[3] = height;
45  }
46 
47  explicit vtkRect(const T* init) : vtkVector<T, 4>(init) { }
48 
50 
51  void Set(const T& x, const T& y, const T& width, const T& height)
52  {
53  this->Data[0] = x;
54  this->Data[1] = y;
55  this->Data[2] = width;
56  this->Data[3] = height;
57  }
59 
61  void SetX(const T& x) { this->Data[0] = x; }
62 
64  const T& GetX() const { return this->Data[0]; }
65 
67  void SetY(const T& y) { this->Data[1] = y; }
68 
70  const T& GetY() const { return this->Data[1]; }
71 
73  void SetWidth(const T& width) { this->Data[2] = width; }
74 
76  const T& GetWidth() const { return this->Data[2]; }
77 
79  void SetHeight(const T& height) { this->Data[3] = height; }
80 
82 
83  const T& GetHeight() const { return this->Data[3]; }
84 };
86 
87 class vtkRecti : public vtkRect<int>
88 {
89 public:
90  vtkRecti() {}
91  vtkRecti(int x, int y, int width, int height)
92  : vtkRect<int>(x, y, width, height) {}
93  explicit vtkRecti(const int *init) : vtkRect<int>(init) {}
94 };
95 
96 class vtkRectf : public vtkRect<float>
97 {
98 public:
99  vtkRectf() {}
100  vtkRectf(float x, float y, float width, float height)
101  : vtkRect<float>(x, y, width, height) {}
102  explicit vtkRectf(const float *init) : vtkRect<float>(init) {}
103 };
104 
105 class vtkRectd : public vtkRect<double>
106 {
107 public:
108  vtkRectd() {}
109  vtkRectd(double x, double y, double width, double height)
110  : vtkRect<double>(x, y, width, height) {}
111  explicit vtkRectd(const double *init) : vtkRect<double>(init) {}
112 };
113 
114 #endif // vtkRect_h
115 // VTK-HeaderTest-Exclude: vtkRect.h
T Data[Size]
Definition: vtkTuple.h:136
vtkRectf()
Definition: vtkRect.h:99
templated base type for storage of vectors.
Definition: vtkVector.h:39
void SetY(const T &y)
Definition: vtkRect.h:67
vtkRectd(const double *init)
Definition: vtkRect.h:111
templated base type for storage of 2D rectangles.
Definition: vtkRect.h:32
vtkRecti()
Definition: vtkRect.h:90
void SetWidth(const T &width)
Definition: vtkRect.h:73
const T & GetWidth() const
Definition: vtkRect.h:76
vtkRect()
Definition: vtkRect.h:35
void Set(const T &x, const T &y, const T &width, const T &height)
Definition: vtkRect.h:51
vtkRectf(float x, float y, float width, float height)
Definition: vtkRect.h:100
const T & GetY() const
Definition: vtkRect.h:70
vtkRect(const T *init)
Definition: vtkRect.h:47
vtkRecti(int x, int y, int width, int height)
Definition: vtkRect.h:91
vtkRecti(const int *init)
Definition: vtkRect.h:93
void SetHeight(const T &height)
Definition: vtkRect.h:79
const T & GetX() const
Definition: vtkRect.h:64
void SetX(const T &x)
Definition: vtkRect.h:61
vtkRectd()
Definition: vtkRect.h:108
const T & GetHeight() const
Definition: vtkRect.h:83
vtkRectd(double x, double y, double width, double height)
Definition: vtkRect.h:109
vtkRect(const T &x, const T &y, const T &width, const T &height)
Definition: vtkRect.h:39
vtkRectf(const float *init)
Definition: vtkRect.h:102