VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkLightKit.h,v $ 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 =========================================================================*/ 00091 #ifndef __vtkLightKit_h 00092 #define __vtkLightKit_h 00093 00094 #include "vtkObject.h" 00095 00096 class vtkLight; 00097 class vtkPiecewiseFunction; 00098 class vtkRenderer; 00099 00100 class VTK_RENDERING_EXPORT vtkLightKit : public vtkObject 00101 { 00102 public: 00103 static vtkLightKit *New(); 00104 vtkTypeRevisionMacro(vtkLightKit, vtkObject); 00105 void PrintSelf(ostream& os, vtkIndent indent); 00106 00107 //BTX 00108 enum LightKitType { 00109 TKeyLight, 00110 TFillLight, 00111 TBackLight, 00112 THeadLight 00113 }; 00114 00115 enum LightKitSubType { 00116 Warmth, 00117 Intensity, 00118 Elevation, 00119 Azimuth, 00120 KFRatio, 00121 KBRatio, 00122 KHRatio 00123 }; 00124 00125 //ETX 00126 00128 00131 vtkSetMacro(KeyLightIntensity, double); 00132 vtkGetMacro(KeyLightIntensity, double); 00134 00136 00144 vtkSetClampMacro(KeyToFillRatio, double, 0.5, VTK_DOUBLE_MAX); 00145 vtkGetMacro(KeyToFillRatio, double); 00147 00149 00158 vtkSetClampMacro(KeyToHeadRatio, double, 0.5, VTK_DOUBLE_MAX); 00159 vtkGetMacro(KeyToHeadRatio, double); 00161 00163 00168 vtkSetClampMacro(KeyToBackRatio, double, 0.5, VTK_DOUBLE_MAX); 00169 vtkGetMacro(KeyToBackRatio, double); 00171 00173 00182 vtkSetMacro(KeyLightWarmth, double); 00183 vtkGetMacro(KeyLightWarmth, double); 00185 00186 vtkSetMacro(FillLightWarmth, double); 00187 vtkGetMacro(FillLightWarmth, double); 00188 00189 vtkSetMacro(HeadLightWarmth, double); 00190 vtkGetMacro(HeadLightWarmth, double); 00191 00192 vtkSetMacro(BackLightWarmth, double); 00193 vtkGetMacro(BackLightWarmth, double); 00194 00196 00197 vtkGetVectorMacro(KeyLightColor, double, 3); 00198 vtkGetVectorMacro(FillLightColor, double, 3); 00199 vtkGetVectorMacro(HeadLightColor, double, 3); 00200 vtkGetVectorMacro(BackLightColor, double, 3); 00202 00204 00205 VTK_LEGACY(void SetHeadlightWarmth(double v)); 00206 VTK_LEGACY(double GetHeadlightWarmth()); 00207 VTK_LEGACY(void GetHeadlightColor(double *color)); 00209 00211 00214 vtkBooleanMacro(MaintainLuminance, int); 00215 vtkGetMacro(MaintainLuminance, int); 00216 vtkSetMacro(MaintainLuminance, int); 00218 00220 00231 void SetKeyLightAngle(double elevation, double azimuth); 00232 void SetKeyLightAngle(double angle[2]) { 00233 this->SetKeyLightAngle(angle[0], angle[1]); }; 00235 00236 void SetKeyLightElevation(double x) { 00237 this->SetKeyLightAngle(x, this->KeyLightAngle[1]); }; 00238 00239 void SetKeyLightAzimuth(double x) { 00240 this->SetKeyLightAngle(this->KeyLightAngle[0], x); }; 00241 00242 vtkGetVectorMacro(KeyLightAngle, double, 2); 00243 double GetKeyLightElevation() { 00244 double ang[2]; this->GetKeyLightAngle(ang); return ang[0]; }; 00245 00246 double GetKeyLightAzimuth() { 00247 double ang[2]; this->GetKeyLightAngle(ang); return ang[1]; }; 00248 00249 void SetFillLightAngle(double elevation, double azimuth); 00250 void SetFillLightAngle(double angle[2]) { 00251 this->SetFillLightAngle(angle[0], angle[1]); }; 00252 00253 void SetFillLightElevation(double x) { 00254 this->SetFillLightAngle(x, this->FillLightAngle[1]); }; 00255 00256 void SetFillLightAzimuth(double x) { 00257 this->SetFillLightAngle(this->FillLightAngle[0], x); }; 00258 00259 vtkGetVectorMacro(FillLightAngle, double, 2); 00260 double GetFillLightElevation() { 00261 double ang[2]; this->GetFillLightAngle(ang); return ang[0]; }; 00262 00263 double GetFillLightAzimuth() { 00264 double ang[2]; this->GetFillLightAngle(ang); return ang[1]; }; 00265 00266 void SetBackLightAngle(double elevation, double azimuth); 00267 void SetBackLightAngle(double angle[2]) { 00268 this->SetBackLightAngle(angle[0], angle[1]); }; 00269 00270 void SetBackLightElevation(double x) { 00271 this->SetBackLightAngle(x, this->BackLightAngle[1]); }; 00272 00273 void SetBackLightAzimuth(double x) { 00274 this->SetBackLightAngle(this->BackLightAngle[0], x); }; 00275 00276 vtkGetVectorMacro(BackLightAngle, double, 2); 00277 double GetBackLightElevation() { 00278 double ang[2]; this->GetBackLightAngle(ang); return ang[0]; }; 00279 00280 double GetBackLightAzimuth() { 00281 double ang[2]; this->GetBackLightAngle(ang); return ang[1]; }; 00282 00284 00286 void AddLightsToRenderer(vtkRenderer *renderer); 00287 void RemoveLightsFromRenderer(vtkRenderer *renderer); 00289 00290 void DeepCopy(vtkLightKit *kit); 00291 00292 void Modified(); 00293 void Update(); 00294 00296 static const char *GetStringFromType(int type); 00297 00299 static const char *GetStringFromSubType(int type); 00300 00304 static const char *GetShortStringFromSubType(int subtype); 00305 00308 static LightKitSubType GetSubType(LightKitType type, int i); 00309 00310 protected: 00311 vtkLightKit(); 00312 ~vtkLightKit(); 00313 00314 void WarmthToRGBI(double w, double rgb[3], double& i); 00315 void WarmthToRGB(double w, double rgb[3]); 00316 void InitializeWarmthFunctions(); 00317 double WarmthToIntensity(double w); 00318 00319 00320 double KeyLightIntensity; 00321 double KeyToFillRatio; 00322 double KeyToHeadRatio; 00323 double KeyToBackRatio; 00324 00325 vtkLight *KeyLight; 00326 double KeyLightWarmth; 00327 double KeyLightAngle[2]; 00328 double KeyLightColor[3]; 00329 00330 vtkLight *FillLight; 00331 double FillLightWarmth; 00332 double FillLightAngle[2]; 00333 double FillLightColor[3]; 00334 00335 double BackLightWarmth; 00336 double BackLightColor[3]; 00337 00338 vtkLight *BackLight0; 00339 vtkLight *BackLight1; 00340 00341 double BackLightAngle[2]; 00342 00343 vtkLight *HeadLight; 00344 double HeadLightWarmth; 00345 double HeadLightColor[3]; 00346 00347 int MaintainLuminance; 00348 00349 vtkPiecewiseFunction *WarmthFunction[4]; // r, g, b, perceptual length 00350 00351 private: 00352 vtkLightKit(const vtkLightKit&); // Not implemented. 00353 void operator=(const vtkLightKit&); // Not implemented. 00354 }; 00355 00356 #endif