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(const T& x = 0, const T& y = 0, const T& width = 0,
00036           const T& height = 0 )
00037   {
00038     this->Data[0] = x;
00039     this->Data[1] = y;
00040     this->Data[2] = width;
00041     this->Data[3] = height;
00042   }
00043 
00044   explicit vtkRect(const T* init) : vtkVector<T, 4>(init) { }
00045 
00047 
00048   void Set(const T& x, const T& y, const T& width, const T& height)
00049   {
00050     this->Data[0] = x;
00051     this->Data[1] = y;
00052     this->Data[2] = width;
00053     this->Data[3] = height;
00054   }
00056 
00058   void SetX(const T& x) { this->Data[0] = x; }
00059 
00061 
00062   const T& GetX() const { return this->Data[0]; }
00063   const T& X() const { return this->Data[0]; }
00065 
00067   void SetY(const T& y) { this->Data[1] = y; }
00068 
00070 
00071   const T& GetY() const { return this->Data[1]; }
00072   const T& Y() const { return this->Data[1]; }
00074 
00076   void SetWidth(const T& width) { this->Data[2] = width; }
00077 
00079 
00080   const T& GetWidth() const { return this->Data[2]; }
00081   const T& Width() const { return this->Data[2]; }
00083 
00085   void SetHeight(const T& height) { this->Data[3] = height; }
00086 
00088 
00089   const T& GetHeight() const { return this->Data[3]; }
00090   const T& Height() const { return this->Data[3]; }
00092 
00093 };
00094 
00095 class vtkRecti : public vtkRect<int>
00096 {
00097 public:
00098   vtkRecti(int x = 0, int y = 0, int width = 0, int height = 0)
00099     : vtkRect<int>(x, y, width, height) {}
00100   explicit vtkRecti(const int *init) : vtkRect<int>(init) {}
00101 };
00102 
00103 class vtkRectf : public vtkRect<float>
00104 {
00105 public:
00106   vtkRectf(float x = 0.0, float y = 0.0, float width = 0.0, float height = 0.0)
00107     : vtkRect<float>(x, y, width, height) {}
00108   explicit vtkRectf(const float *init) : vtkRect<float>(init) {}
00109 };
00110 
00111 class vtkRectd : public vtkRect<double>
00112 {
00113 public:
00114   vtkRectd(double x = 0.0, double y = 0.0, double width = 0.0,
00115            double height = 0.0)
00116     : vtkRect<double>(x, y, width, height) {}
00117   explicit vtkRectd(const double *init) : vtkRect<double>(init) {}
00118 };
00119 
00120 #endif // __vtkRect_h