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 =========================================================================*/ 00097 #ifndef vtkLightKit_h 00098 #define vtkLightKit_h 00099 00100 #include "vtkRenderingCoreModule.h" // For export macro 00101 #include "vtkObject.h" 00102 00103 class vtkLight; 00104 class vtkPiecewiseFunction; 00105 class vtkRenderer; 00106 00107 class VTKRENDERINGCORE_EXPORT vtkLightKit : public vtkObject 00108 { 00109 public: 00110 static vtkLightKit *New(); 00111 vtkTypeMacro(vtkLightKit, vtkObject); 00112 void PrintSelf(ostream& os, vtkIndent indent); 00113 00114 //BTX 00115 enum LightKitType { 00116 TKeyLight, 00117 TFillLight, 00118 TBackLight, 00119 THeadLight 00120 }; 00121 00122 enum LightKitSubType { 00123 Warmth, 00124 Intensity, 00125 Elevation, 00126 Azimuth, 00127 KFRatio, 00128 KBRatio, 00129 KHRatio 00130 }; 00131 00132 //ETX 00133 00135 00138 vtkSetMacro(KeyLightIntensity, double); 00139 vtkGetMacro(KeyLightIntensity, double); 00141 00143 00151 vtkSetClampMacro(KeyToFillRatio, double, 0.5, VTK_DOUBLE_MAX); 00152 vtkGetMacro(KeyToFillRatio, double); 00154 00156 00165 vtkSetClampMacro(KeyToHeadRatio, double, 0.5, VTK_DOUBLE_MAX); 00166 vtkGetMacro(KeyToHeadRatio, double); 00168 00170 00175 vtkSetClampMacro(KeyToBackRatio, double, 0.5, VTK_DOUBLE_MAX); 00176 vtkGetMacro(KeyToBackRatio, double); 00178 00180 00189 vtkSetMacro(KeyLightWarmth, double); 00190 vtkGetMacro(KeyLightWarmth, double); 00192 00193 vtkSetMacro(FillLightWarmth, double); 00194 vtkGetMacro(FillLightWarmth, double); 00195 00196 vtkSetMacro(HeadLightWarmth, double); 00197 vtkGetMacro(HeadLightWarmth, double); 00198 00199 vtkSetMacro(BackLightWarmth, double); 00200 vtkGetMacro(BackLightWarmth, double); 00201 00203 00204 vtkGetVectorMacro(KeyLightColor, double, 3); 00205 vtkGetVectorMacro(FillLightColor, double, 3); 00206 vtkGetVectorMacro(HeadLightColor, double, 3); 00207 vtkGetVectorMacro(BackLightColor, double, 3); 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