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 "vtkTuple.h" 00028 00029 // .NAME vtkColor3 - templated base type for storage of 3 component colors. 00030 // 00031 template<typename T> 00032 class vtkColor3 : public vtkTuple<T, 3> 00033 { 00034 public: 00035 vtkColor3() 00036 { 00037 } 00038 00039 explicit vtkColor3(const T& scalar) : vtkTuple<T, 3>(scalar) 00040 { 00041 } 00042 00043 explicit vtkColor3(const T* init) : vtkTuple<T, 3>(init) 00044 { 00045 } 00046 00047 vtkColor3(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 } 00053 00055 00056 void Set(const T& red, const T& green, const T& blue) 00057 { 00058 this->Data[0] = red; 00059 this->Data[1] = green; 00060 this->Data[2] = blue; 00061 } 00063 00065 void SetRed(const T& red) { this->Data[0] = red; } 00066 00068 00069 const T& GetRed() const { return this->Data[0]; } 00070 const T& Red() const { return this->Data[0]; } 00072 00074 void SetGreen(const T& green) { this->Data[1] = green; } 00075 00077 00078 const T& GetGreen() const { return this->Data[1]; } 00079 const T& Green() const { return this->Data[1]; } 00081 00083 void SetBlue(const T& blue) { this->Data[2] = blue; } 00084 00086 00087 const T& GetBlue() const { return this->Data[2]; } 00088 const T& Blue() const { return this->Data[2]; } 00089 }; 00091 00092 // .NAME vtkColor4 - templated base type for storage of 4 component colors. 00093 // 00094 template<typename T> 00095 class vtkColor4 : public vtkTuple<T, 4> 00096 { 00097 public: 00098 vtkColor4() 00099 { 00100 } 00101 00102 explicit vtkColor4(const T& scalar) : vtkTuple<T, 4>(scalar) 00103 { 00104 } 00105 00106 explicit vtkColor4(const T* init) : vtkTuple<T, 4>(init) 00107 { 00108 } 00109 00110 vtkColor4(const T& red, const T& green, const T& blue, const T& alpha) 00111 { 00112 this->Data[0] = red; 00113 this->Data[1] = green; 00114 this->Data[2] = blue; 00115 this->Data[3] = alpha; 00116 } 00117 00119 00120 void Set(const T& red, const T& green, const T& blue) 00121 { 00122 this->Data[0] = red; 00123 this->Data[1] = green; 00124 this->Data[2] = blue; 00125 } 00127 00129 00130 void Set(const T& red, const T& green, const T& blue, const T& alpha) 00131 { 00132 this->Data[0] = red; 00133 this->Data[1] = green; 00134 this->Data[2] = blue; 00135 this->Data[3] = alpha; 00136 } 00138 00140 void SetRed(const T& red) { this->Data[0] = red; } 00141 00143 00144 const T& GetRed() const { return this->Data[0]; } 00145 const T& Red() const { return this->Data[0]; } 00147 00149 void SetGreen(const T& green) { this->Data[1] = green; } 00150 00152 00153 const T& GetGreen() const { return this->Data[1]; } 00154 const T& Green() const { return this->Data[1]; } 00156 00158 void SetBlue(const T& blue) { this->Data[2] = blue; } 00159 00161 00162 const T& GetBlue() const { return this->Data[2]; } 00163 const T& Blue() const { return this->Data[2]; } 00165 00167 void SetAlpha(const T& alpha) { this->Data[3] = alpha; } 00168 00170 00171 const T& GetAlpha() const { return this->Data[3]; } 00172 const T& Alpha() const { return this->Data[3]; } 00173 }; 00175 00177 00179 class vtkColor3ub : public vtkColor3<unsigned char> 00180 { 00181 public: 00182 vtkColor3ub() {} 00183 explicit vtkColor3ub(unsigned char scalar) 00184 : vtkColor3<unsigned char>(scalar) {} 00185 explicit vtkColor3ub(const unsigned char* init) 00186 : vtkColor3<unsigned char>(init) {} 00187 vtkColor3ub(unsigned char r, unsigned char g, unsigned char b) 00188 : vtkColor3<unsigned char>(r, g, b) {} 00189 }; 00191 00192 class vtkColor3f : public vtkColor3<float> 00193 { 00194 public: 00195 vtkColor3f() {} 00196 explicit vtkColor3f(float scalar) : vtkColor3<float>(scalar) {} 00197 explicit vtkColor3f(const float* init) : vtkColor3<float>(init) {} 00198 vtkColor3f(float r, float g, float b) : vtkColor3<float>(r, g, b) {} 00199 }; 00200 00201 class vtkColor3d : public vtkColor3<double> 00202 { 00203 public: 00204 vtkColor3d() {} 00205 explicit vtkColor3d(double scalar) : vtkColor3<double>(scalar) {} 00206 explicit vtkColor3d(const double* init) : vtkColor3<double>(init) {} 00207 vtkColor3d(double r, double g, double b) : vtkColor3<double>(r, g, b) {} 00208 }; 00209 00210 class vtkColor4ub : public vtkColor4<unsigned char> 00211 { 00212 public: 00213 vtkColor4ub() {} 00214 explicit vtkColor4ub(unsigned char scalar) 00215 : vtkColor4<unsigned char>(scalar) {} 00216 explicit vtkColor4ub(const unsigned char* init) 00217 : vtkColor4<unsigned char>(init) {} 00218 vtkColor4ub(unsigned char r, unsigned char g, 00219 unsigned char b, unsigned char a = 255) 00220 : vtkColor4<unsigned char>(r, g, b, a) {} 00221 vtkColor4ub(const vtkColor3ub &c) : 00222 vtkColor4<unsigned char>(c[0], c[1], c[2], 255) {} 00223 }; 00224 00225 class vtkColor4f : public vtkColor4<float> 00226 { 00227 public: 00228 vtkColor4f() {} 00229 explicit vtkColor4f(float scalar) : vtkColor4<float>(scalar) {} 00230 explicit vtkColor4f(const float* init) : vtkColor4<float>(init) {} 00231 vtkColor4f(float r, float g, float b, float a = 1.0) 00232 : vtkColor4<float>(r, g, b, a) {} 00233 }; 00234 00235 class vtkColor4d : public vtkColor4<double> 00236 { 00237 public: 00238 vtkColor4d() {} 00239 explicit vtkColor4d(double scalar) : vtkColor4<double>(scalar) {} 00240 explicit vtkColor4d(const double* init) : vtkColor4<double>(init) {} 00241 vtkColor4d(double r, double g, double b, double a = 1.0) 00242 : vtkColor4<double>(r, g, b, a) {} 00243 }; 00244 00245 #endif // __vtkColor_h