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 
65  const T& GetX() const { return this->Data[0]; }
66  const T& X() const { return this->Data[0]; }
68 
70  void SetY(const T& y) { this->Data[1] = y; }
71 
73 
74  const T& GetY() const { return this->Data[1]; }
75  const T& Y() const { return this->Data[1]; }
77 
79  void SetWidth(const T& width) { this->Data[2] = width; }
80 
82 
83  const T& GetWidth() const { return this->Data[2]; }
84  const T& Width() const { return this->Data[2]; }
86 
88  void SetHeight(const T& height) { this->Data[3] = height; }
89 
91 
92  const T& GetHeight() const { return this->Data[3]; }
93  const T& Height() const { return this->Data[3]; }
95 
96 };
97 
98 class vtkRecti : public vtkRect<int>
99 {
100 public:
101  vtkRecti() {}
102  vtkRecti(int x, int y, int width, int height)
103  : vtkRect<int>(x, y, width, height) {}
104  explicit vtkRecti(const int *init) : vtkRect<int>(init) {}
105 };
106 
107 class vtkRectf : public vtkRect<float>
108 {
109 public:
110  vtkRectf() {}
111  vtkRectf(float x, float y, float width, float height)
112  : vtkRect<float>(x, y, width, height) {}
113  explicit vtkRectf(const float *init) : vtkRect<float>(init) {}
114 };
115 
116 class vtkRectd : public vtkRect<double>
117 {
118 public:
119  vtkRectd() {}
120  vtkRectd(double x, double y, double width, double height)
121  : vtkRect<double>(x, y, width, height) {}
122  explicit vtkRectd(const double *init) : vtkRect<double>(init) {}
123 };
124 
125 #endif // __vtkRect_h
126 // VTK-HeaderTest-Exclude: vtkRect.h