VTK
dox/Common/vtkRect.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkVector.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 
00026 #ifndef __vtkRect_h
00027 #define __vtkRect_h
00028 
00029 #include "vtkVector.h"
00030 
00031 template<typename T>
00032 class vtkRect : public vtkVector<T, 4>
00033 {
00034 public:
00035   vtkRect()
00036   {
00037   }
00038 
00039   vtkRect(const T& x, const T& y, const T& width, const T& height)
00040   {
00041     this->Data[0] = x;
00042     this->Data[1] = y;
00043     this->Data[2] = width;
00044     this->Data[3] = height;
00045   }
00046 
00047   explicit vtkRect(const T* init) : vtkVector<T, 4>(init) { }
00048 
00050 
00051   void Set(const T& x, const T& y, const T& width, const T& height)
00052   {
00053     this->Data[0] = x;
00054     this->Data[1] = y;
00055     this->Data[2] = width;
00056     this->Data[3] = height;
00057   }
00059 
00061   void SetX(const T& x) { this->Data[0] = x; }
00062 
00064 
00065   const T& GetX() const { return this->Data[0]; }
00066   const T& X() const { return this->Data[0]; }
00068 
00070   void SetY(const T& y) { this->Data[1] = y; }
00071 
00073 
00074   const T& GetY() const { return this->Data[1]; }
00075   const T& Y() const { return this->Data[1]; }
00077 
00079   void SetWidth(const T& width) { this->Data[2] = width; }
00080 
00082 
00083   const T& GetWidth() const { return this->Data[2]; }
00084   const T& Width() const { return this->Data[2]; }
00086 
00088   void SetHeight(const T& height) { this->Data[3] = height; }
00089 
00091 
00092   const T& GetHeight() const { return this->Data[3]; }
00093   const T& Height() const { return this->Data[3]; }
00095 
00096 };
00097 
00098 class vtkRecti : public vtkRect<int>
00099 {
00100 public:
00101   vtkRecti() {}
00102   vtkRecti(int x, int y, int width, int height)
00103     : vtkRect<int>(x, y, width, height) {}
00104   explicit vtkRecti(const int *init) : vtkRect<int>(init) {}
00105 };
00106 
00107 class vtkRectf : public vtkRect<float>
00108 {
00109 public:
00110   vtkRectf() {}
00111   vtkRectf(float x, float y, float width, float height)
00112     : vtkRect<float>(x, y, width, height) {}
00113   explicit vtkRectf(const float *init) : vtkRect<float>(init) {}
00114 };
00115 
00116 class vtkRectd : public vtkRect<double>
00117 {
00118 public:
00119   vtkRectd() {}
00120   vtkRectd(double x, double y, double width, double height)
00121     : vtkRect<double>(x, y, width, height) {}
00122   explicit vtkRectd(const double *init) : vtkRect<double>(init) {}
00123 };
00124 
00125 #endif // __vtkRect_h