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  const T& GetHeight() const { return this->Data[3]; }
83 
85  VTK_LEGACY(const T& X() const);
86 
88  VTK_LEGACY(const T& Y() const);
89 
91  VTK_LEGACY(const T& Width() const);
92 
94 
95  VTK_LEGACY(const T& Height() const);
96 };
98 
99 class vtkRecti : public vtkRect<int>
100 {
101 public:
102  vtkRecti() {}
103  vtkRecti(int x, int y, int width, int height)
104  : vtkRect<int>(x, y, width, height) {}
105  explicit vtkRecti(const int *init) : vtkRect<int>(init) {}
106 };
107 
108 class vtkRectf : public vtkRect<float>
109 {
110 public:
111  vtkRectf() {}
112  vtkRectf(float x, float y, float width, float height)
113  : vtkRect<float>(x, y, width, height) {}
114  explicit vtkRectf(const float *init) : vtkRect<float>(init) {}
115 };
116 
117 class vtkRectd : public vtkRect<double>
118 {
119 public:
120  vtkRectd() {}
121  vtkRectd(double x, double y, double width, double height)
122  : vtkRect<double>(x, y, width, height) {}
123  explicit vtkRectd(const double *init) : vtkRect<double>(init) {}
124 };
125 
126 #ifndef VTK_LEGACY_REMOVE
127 template<typename T>
128 const T& vtkRect<T>::X() const
129 {
131  return this->GetX();
132 }
133 
134 template<typename T>
135 const T& vtkRect<T>::Y() const
136 {
138  return this->GetY();
139 }
140 
141 template<typename T>
142 const T& vtkRect<T>::Width() const
143 {
145  return this->GetWidth();
146 }
147 
148 template<typename T>
149 const T& vtkRect<T>::Height() const
150 {
152  return this->GetHeight();
153 }
154 
155 #endif // VTK_LEGACY_REMOVE
156 
157 
158 #endif // __vtkRect_h
159 // VTK-HeaderTest-Exclude: vtkRect.h
T Data[Size]
Definition: vtkTuple.h:136
const T & X() const
Definition: vtkRect.h:128
vtkRectf()
Definition: vtkRect.h:111
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:123
templated base type for storage of 2D rectangles.
Definition: vtkRect.h:32
const T & Width() const
Definition: vtkRect.h:142
#define VTK_LEGACY_REPLACED_BODY(method, version, replace)
Definition: vtkSetGet.h:814
vtkRecti()
Definition: vtkRect.h:102
void SetWidth(const T &width)
Definition: vtkRect.h:73
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
const T & GetWidth() const
Definition: vtkRect.h:76
GLint GLint GLsizei GLsizei height
Definition: vtkgl.h:11316
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkRect()
Definition: vtkRect.h:35
void Set(const T &x, const T &y, const T &width, const T &height)
Definition: vtkRect.h:51
const T & Height() const
Definition: vtkRect.h:149
vtkRectf(float x, float y, float width, float height)
Definition: vtkRect.h:112
GLint GLint GLsizei width
Definition: vtkgl.h:11316
const T & GetY() const
Definition: vtkRect.h:70
const T & Y() const
Definition: vtkRect.h:135
vtkRect(const T *init)
Definition: vtkRect.h:47
vtkRecti(int x, int y, int width, int height)
Definition: vtkRect.h:103
#define VTK_LEGACY(method)
Definition: vtkSetGet.h:787
vtkRecti(const int *init)
Definition: vtkRect.h:105
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:120
const T & GetHeight() const
Definition: vtkRect.h:82
vtkRectd(double x, double y, double width, double height)
Definition: vtkRect.h:121
vtkRect(const T &x, const T &y, const T &width, const T &height)
Definition: vtkRect.h:39
vtkRectf(const float *init)
Definition: vtkRect.h:114