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:
35  vtkRect(const T& x = 0, const T& y = 0, const T& width = 0,
36  const T& height = 0 )
37  {
38  this->Data[0] = x;
39  this->Data[1] = y;
40  this->Data[2] = width;
41  this->Data[3] = height;
42  }
43 
44  explicit vtkRect(const T* init) : vtkVector<T, 4>(init) { }
45 
47 
48  void Set(const T& x, const T& y, const T& width, const T& height)
49  {
50  this->Data[0] = x;
51  this->Data[1] = y;
52  this->Data[2] = width;
53  this->Data[3] = height;
54  }
56 
58  void SetX(const T& x) { this->Data[0] = x; }
59 
61 
62  const T& GetX() const { return this->Data[0]; }
63  const T& X() const { return this->Data[0]; }
65 
67  void SetY(const T& y) { this->Data[1] = y; }
68 
70 
71  const T& GetY() const { return this->Data[1]; }
72  const T& Y() const { return this->Data[1]; }
74 
76  void SetWidth(const T& width) { this->Data[2] = width; }
77 
79 
80  const T& GetWidth() const { return this->Data[2]; }
81  const T& Width() const { return this->Data[2]; }
83 
85  void SetHeight(const T& height) { this->Data[3] = height; }
86 
88 
89  const T& GetHeight() const { return this->Data[3]; }
90  const T& Height() const { return this->Data[3]; }
92 
93 };
94 
95 class vtkRecti : public vtkRect<int>
96 {
97 public:
98  vtkRecti(int x = 0, int y = 0, int width = 0, int height = 0)
99  : vtkRect<int>(x, y, width, height) {}
100  explicit vtkRecti(const int *init) : vtkRect<int>(init) {}
101 };
102 
103 class vtkRectf : public vtkRect<float>
104 {
105 public:
106  vtkRectf(float x = 0.0, float y = 0.0, float width = 0.0, float height = 0.0)
107  : vtkRect<float>(x, y, width, height) {}
108  explicit vtkRectf(const float *init) : vtkRect<float>(init) {}
109 };
110 
111 class vtkRectd : public vtkRect<double>
112 {
113 public:
114  vtkRectd(double x = 0.0, double y = 0.0, double width = 0.0,
115  double height = 0.0)
116  : vtkRect<double>(x, y, width, height) {}
117  explicit vtkRectd(const double *init) : vtkRect<double>(init) {}
118 };
119 
120 #endif // __vtkRect_h
const T & X() const
Definition: vtkRect.h:63
templated base type for storage of vectors.
Definition: vtkVector.h:34
void SetY(const T &y)
Definition: vtkRect.h:67
vtkRectd(const double *init)
Definition: vtkRect.h:117
templated base type for storage of 2D rectangles.
Definition: vtkRect.h:32
const T & Height() const
Definition: vtkRect.h:90
void SetWidth(const T &width)
Definition: vtkRect.h:76
const T & Width() const
Definition: vtkRect.h:81
const T & GetWidth() const
Definition: vtkRect.h:80
vtkRect(const T &x=0, const T &y=0, const T &width=0, const T &height=0)
Definition: vtkRect.h:35
vtkRecti(int x=0, int y=0, int width=0, int height=0)
Definition: vtkRect.h:98
void Set(const T &x, const T &y, const T &width, const T &height)
Definition: vtkRect.h:48
vtkRectd(double x=0.0, double y=0.0, double width=0.0, double height=0.0)
Definition: vtkRect.h:114
const T & GetY() const
Definition: vtkRect.h:71
vtkRect(const T *init)
Definition: vtkRect.h:44
vtkRecti(const int *init)
Definition: vtkRect.h:100
void SetHeight(const T &height)
Definition: vtkRect.h:85
const T & GetX() const
Definition: vtkRect.h:62
const T & Y() const
Definition: vtkRect.h:72
void SetX(const T &x)
Definition: vtkRect.h:58
const T & GetHeight() const
Definition: vtkRect.h:89
vtkRectf(float x=0.0, float y=0.0, float width=0.0, float height=0.0)
Definition: vtkRect.h:106
vtkRectf(const float *init)
Definition: vtkRect.h:108