VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkLightKit.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 =========================================================================*/ 00094 #ifndef __vtkLightKit_h 00095 #define __vtkLightKit_h 00096 00097 #include "vtkRenderingCoreModule.h" // For export macro 00098 #include "vtkObject.h" 00099 00100 class vtkLight; 00101 class vtkPiecewiseFunction; 00102 class vtkRenderer; 00103 00104 class VTKRENDERINGCORE_EXPORT vtkLightKit : public vtkObject 00105 { 00106 public: 00107 static vtkLightKit *New(); 00108 vtkTypeMacro(vtkLightKit, vtkObject); 00109 void PrintSelf(ostream& os, vtkIndent indent); 00110 00111 //BTX 00112 enum LightKitType { 00113 TKeyLight, 00114 TFillLight, 00115 TBackLight, 00116 THeadLight 00117 }; 00118 00119 enum LightKitSubType { 00120 Warmth, 00121 Intensity, 00122 Elevation, 00123 Azimuth, 00124 KFRatio, 00125 KBRatio, 00126 KHRatio 00127 }; 00128 00129 //ETX 00130 00132 00135 vtkSetMacro(KeyLightIntensity, double); 00136 vtkGetMacro(KeyLightIntensity, double); 00138 00140 00148 vtkSetClampMacro(KeyToFillRatio, double, 0.5, VTK_DOUBLE_MAX); 00149 vtkGetMacro(KeyToFillRatio, double); 00151 00153 00162 vtkSetClampMacro(KeyToHeadRatio, double, 0.5, VTK_DOUBLE_MAX); 00163 vtkGetMacro(KeyToHeadRatio, double); 00165 00167 00172 vtkSetClampMacro(KeyToBackRatio, double, 0.5, VTK_DOUBLE_MAX); 00173 vtkGetMacro(KeyToBackRatio, double); 00175 00177 00186 vtkSetMacro(KeyLightWarmth, double); 00187 vtkGetMacro(KeyLightWarmth, double); 00189 00190 vtkSetMacro(FillLightWarmth, double); 00191 vtkGetMacro(FillLightWarmth, double); 00192 00193 vtkSetMacro(HeadLightWarmth, double); 00194 vtkGetMacro(HeadLightWarmth, double); 00195 00196 vtkSetMacro(BackLightWarmth, double); 00197 vtkGetMacro(BackLightWarmth, double); 00198 00200 00201 vtkGetVectorMacro(KeyLightColor, double, 3); 00202 vtkGetVectorMacro(FillLightColor, double, 3); 00203 vtkGetVectorMacro(HeadLightColor, double, 3); 00204 vtkGetVectorMacro(BackLightColor, double, 3); 00206 00208 00211 vtkBooleanMacro(MaintainLuminance, int); 00212 vtkGetMacro(MaintainLuminance, int); 00213 vtkSetMacro(MaintainLuminance, int); 00215 00217 00228 void SetKeyLightAngle(double elevation, double azimuth); 00229 void SetKeyLightAngle(double angle[2]) 00230 { this->SetKeyLightAngle(angle[0], angle[1]); } 00232 00233 void SetKeyLightElevation(double x) 00234 { this->SetKeyLightAngle(x, this->KeyLightAngle[1]); } 00235 00236 void SetKeyLightAzimuth(double x) 00237 { this->SetKeyLightAngle(this->KeyLightAngle[0], x); } 00238 00239 vtkGetVectorMacro(KeyLightAngle, double, 2); 00240 double GetKeyLightElevation() 00241 { double ang[2]; this->GetKeyLightAngle(ang); return ang[0]; } 00242 00243 double GetKeyLightAzimuth() 00244 { double ang[2]; this->GetKeyLightAngle(ang); return ang[1]; } 00245 00246 void SetFillLightAngle(double elevation, double azimuth); 00247 void SetFillLightAngle(double angle[2]) 00248 { this->SetFillLightAngle(angle[0], angle[1]); } 00249 00250 void SetFillLightElevation(double x) 00251 { this->SetFillLightAngle(x, this->FillLightAngle[1]); } 00252 00253 void SetFillLightAzimuth(double x) 00254 { this->SetFillLightAngle(this->FillLightAngle[0], x); } 00255 00256 vtkGetVectorMacro(FillLightAngle, double, 2); 00257 double GetFillLightElevation() { 00258 double ang[2]; this->GetFillLightAngle(ang); return ang[0]; } 00259 00260 double GetFillLightAzimuth() 00261 { double ang[2]; this->GetFillLightAngle(ang); return ang[1]; } 00262 00263 void SetBackLightAngle(double elevation, double azimuth); 00264 void SetBackLightAngle(double angle[2]) 00265 { this->SetBackLightAngle(angle[0], angle[1]); } 00266 00267 void SetBackLightElevation(double x) 00268 { this->SetBackLightAngle(x, this->BackLightAngle[1]); } 00269 00270 void SetBackLightAzimuth(double x) 00271 { this->SetBackLightAngle(this->BackLightAngle[0], x); } 00272 00273 vtkGetVectorMacro(BackLightAngle, double, 2); 00274 double GetBackLightElevation() 00275 { double ang[2]; this->GetBackLightAngle(ang); return ang[0]; } 00276 00277 double GetBackLightAzimuth() 00278 { double ang[2]; this->GetBackLightAngle(ang); return ang[1]; } 00279 00281 00283 void AddLightsToRenderer(vtkRenderer *renderer); 00284 void RemoveLightsFromRenderer(vtkRenderer *renderer); 00286 00287 void DeepCopy(vtkLightKit *kit); 00288 00289 void Modified(); 00290 void Update(); 00291 00293 static const char *GetStringFromType(int type); 00294 00296 static const char *GetStringFromSubType(int type); 00297 00301 static const char *GetShortStringFromSubType(int subtype); 00302 00305 static LightKitSubType GetSubType(LightKitType type, int i); 00306 00307 protected: 00308 vtkLightKit(); 00309 ~vtkLightKit(); 00310 00311 void WarmthToRGBI(double w, double rgb[3], double& i); 00312 void WarmthToRGB(double w, double rgb[3]); 00313 void InitializeWarmthFunctions(); 00314 double WarmthToIntensity(double w); 00315 00316 00317 double KeyLightIntensity; 00318 double KeyToFillRatio; 00319 double KeyToHeadRatio; 00320 double KeyToBackRatio; 00321 00322 vtkLight *KeyLight; 00323 double KeyLightWarmth; 00324 double KeyLightAngle[2]; 00325 double KeyLightColor[3]; 00326 00327 vtkLight *FillLight; 00328 double FillLightWarmth; 00329 double FillLightAngle[2]; 00330 double FillLightColor[3]; 00331 00332 double BackLightWarmth; 00333 double BackLightColor[3]; 00334 00335 vtkLight *BackLight0; 00336 vtkLight *BackLight1; 00337 00338 double BackLightAngle[2]; 00339 00340 vtkLight *HeadLight; 00341 double HeadLightWarmth; 00342 double HeadLightColor[3]; 00343 00344 int MaintainLuminance; 00345 00346 vtkPiecewiseFunction *WarmthFunction[4]; // r, g, b, perceptual length 00347 00348 private: 00349 vtkLightKit(const vtkLightKit&); // Not implemented. 00350 void operator=(const vtkLightKit&); // Not implemented. 00351 }; 00352 00353 #endif