VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkColor.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 00024 #ifndef __vtkColor_h 00025 #define __vtkColor_h 00026 00027 #include "vtkVector.h" 00028 00029 // .NAME vtkColor3 - templated base type for storage of 3 component colors. 00030 // 00031 template<typename T> 00032 class vtkColor3 : public vtkVector<T, 3> 00033 { 00034 public: 00035 vtkColor3(const T& red = 0, const T& green = 0, const T& blue = 0) 00036 { 00037 this->Data[0] = red; 00038 this->Data[1] = green; 00039 this->Data[2] = blue; 00040 } 00041 explicit vtkColor3(const T* init) : vtkVector<T, 3>(init) 00042 { 00043 } 00044 00046 00047 void Set(const T& red, const T& green, const T& blue) 00048 { 00049 this->Data[0] = red; 00050 this->Data[1] = green; 00051 this->Data[2] = blue; 00052 } 00054 00056 void SetRed(const T& red) { this->Data[0] = red; } 00057 00059 00060 const T& GetRed() const { return this->Data[0]; } 00061 const T& Red() const { return this->Data[0]; } 00063 00065 void SetGreen(const T& green) { this->Data[1] = green; } 00066 00068 00069 const T& GetGreen() const { return this->Data[1]; } 00070 const T& Green() const { return this->Data[1]; } 00072 00074 void SetBlue(const T& blue) { this->Data[2] = blue; } 00075 00077 00078 const T& GetBlue() const { return this->Data[2]; } 00079 const T& Blue() const { return this->Data[2]; } 00080 }; 00082 00083 // .NAME vtkColor4 - templated base type for storage of 4 component colors. 00084 // 00085 template<typename T> 00086 class vtkColor4 : public vtkVector<T, 4> 00087 { 00088 public: 00089 vtkColor4(const T& red = 0, const T& green = 0, const T& blue = 0, 00090 const T& alpha = 0) 00091 { 00092 this->Data[0] = red; 00093 this->Data[1] = green; 00094 this->Data[2] = blue; 00095 this->Data[3] = alpha; 00096 } 00097 explicit vtkColor4(const T* init) : vtkVector<T, 4>(init) 00098 { 00099 } 00100 00102 00103 void Set(const T& red, const T& green, const T& blue) 00104 { 00105 this->Data[0] = red; 00106 this->Data[1] = green; 00107 this->Data[2] = blue; 00108 } 00110 00112 00113 void Set(const T& red, const T& green, const T& blue, const T& alpha) 00114 { 00115 this->Data[0] = red; 00116 this->Data[1] = green; 00117 this->Data[2] = blue; 00118 this->Data[3] = alpha; 00119 } 00121 00123 void SetRed(const T& red) { this->Data[0] = red; } 00124 00126 00127 const T& GetRed() const { return this->Data[0]; } 00128 const T& Red() const { return this->Data[0]; } 00130 00132 void SetGreen(const T& green) { this->Data[1] = green; } 00133 00135 00136 const T& GetGreen() const { return this->Data[1]; } 00137 const T& Green() const { return this->Data[1]; } 00139 00141 void SetBlue(const T& blue) { this->Data[2] = blue; } 00142 00144 00145 const T& GetBlue() const { return this->Data[2]; } 00146 const T& Blue() const { return this->Data[2]; } 00148 00150 void SetAlpha(const T& alpha) { this->Data[3] = alpha; } 00151 00153 00154 const T& GetAlpha() const { return this->Data[3]; } 00155 const T& Alpha() const { return this->Data[3]; } 00156 }; 00158 00160 00162 class vtkColor3ub : public vtkColor3<unsigned char> 00163 { 00164 public: 00165 vtkColor3ub(unsigned char r = 0, unsigned char g = 0, 00166 unsigned char b = 0) : vtkColor3<unsigned char>(r, g, b) {} 00167 explicit vtkColor3ub(const unsigned char* init) 00168 : vtkColor3<unsigned char>(init) {} 00169 }; 00171 00172 class vtkColor3f : public vtkColor3<float> 00173 { 00174 public: 00175 vtkColor3f(float r = 0.0, float g = 0.0, float b = 0.0) 00176 : vtkColor3<float>(r, g, b) {} 00177 explicit vtkColor3f(const float* init) : vtkColor3<float>(init) {} 00178 }; 00179 00180 class vtkColor3d : public vtkColor3<double> 00181 { 00182 public: 00183 vtkColor3d(double r = 0.0, double g = 0.0, double b = 0.0) 00184 : vtkColor3<double>(r, g, b) {} 00185 explicit vtkColor3d(const double* init) : vtkColor3<double>(init) {} 00186 }; 00187 00188 class vtkColor4ub : public vtkColor4<unsigned char> 00189 { 00190 public: 00191 vtkColor4ub(unsigned char r = 0, unsigned char g = 0, 00192 unsigned char b = 0, unsigned char a = 255) 00193 : vtkColor4<unsigned char>(r, g, b, a) {} 00194 explicit vtkColor4ub(const unsigned char* init) 00195 : vtkColor4<unsigned char>(init) {} 00196 vtkColor4ub(const vtkColor3ub &c) : 00197 vtkColor4<unsigned char>(c[0], c[1], c[2], 255) {} 00198 }; 00199 00200 class vtkColor4f : public vtkColor4<float> 00201 { 00202 public: 00203 vtkColor4f(float r = 0.0, float g = 0.0, float b = 0.0, float a = 1.0) 00204 : vtkColor4<float>(r, g, b, a) {} 00205 explicit vtkColor4f(const float* init) : vtkColor4<float>(init) {} 00206 }; 00207 00208 class vtkColor4d : public vtkColor4<double> 00209 { 00210 public: 00211 vtkColor4d(double r = 0.0, double g = 0.0, double b = 0.0, float a = 1.0) 00212 : vtkColor4<double>(r, g, b, a) {} 00213 explicit vtkColor4d(const double* init) : vtkColor4<double>(init) {} 00214 }; 00215 00216 #endif // __vtkColor_h