VTK
vtkLightKit.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLightKit.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
94 #ifndef __vtkLightKit_h
95 #define __vtkLightKit_h
96 
97 #include "vtkRenderingCoreModule.h" // For export macro
98 #include "vtkObject.h"
99 
100 class vtkLight;
102 class vtkRenderer;
103 
104 class VTKRENDERINGCORE_EXPORT vtkLightKit : public vtkObject
105 {
106 public:
107  static vtkLightKit *New();
108  vtkTypeMacro(vtkLightKit, vtkObject);
109  void PrintSelf(ostream& os, vtkIndent indent);
110 
111  //BTX
116  THeadLight
117  };
118 
126  KHRatio
127  };
128 
129  //ETX
130 
132 
135  vtkSetMacro(KeyLightIntensity, double);
136  vtkGetMacro(KeyLightIntensity, double);
138 
140 
148  vtkSetClampMacro(KeyToFillRatio, double, 0.5, VTK_DOUBLE_MAX);
149  vtkGetMacro(KeyToFillRatio, double);
151 
153 
162  vtkSetClampMacro(KeyToHeadRatio, double, 0.5, VTK_DOUBLE_MAX);
163  vtkGetMacro(KeyToHeadRatio, double);
165 
167 
172  vtkSetClampMacro(KeyToBackRatio, double, 0.5, VTK_DOUBLE_MAX);
173  vtkGetMacro(KeyToBackRatio, double);
175 
177 
186  vtkSetMacro(KeyLightWarmth, double);
187  vtkGetMacro(KeyLightWarmth, double);
189 
190  vtkSetMacro(FillLightWarmth, double);
191  vtkGetMacro(FillLightWarmth, double);
192 
193  vtkSetMacro(HeadLightWarmth, double);
194  vtkGetMacro(HeadLightWarmth, double);
195 
196  vtkSetMacro(BackLightWarmth, double);
197  vtkGetMacro(BackLightWarmth, double);
198 
200 
201  vtkGetVectorMacro(KeyLightColor, double, 3);
202  vtkGetVectorMacro(FillLightColor, double, 3);
203  vtkGetVectorMacro(HeadLightColor, double, 3);
204  vtkGetVectorMacro(BackLightColor, double, 3);
206 
208 
211  vtkBooleanMacro(MaintainLuminance, int);
212  vtkGetMacro(MaintainLuminance, int);
213  vtkSetMacro(MaintainLuminance, int);
215 
217 
228  void SetKeyLightAngle(double elevation, double azimuth);
229  void SetKeyLightAngle(double angle[2]) {
230  this->SetKeyLightAngle(angle[0], angle[1]); };
232 
233  void SetKeyLightElevation(double x) {
234  this->SetKeyLightAngle(x, this->KeyLightAngle[1]); };
235 
236  void SetKeyLightAzimuth(double x) {
237  this->SetKeyLightAngle(this->KeyLightAngle[0], x); };
238 
239  vtkGetVectorMacro(KeyLightAngle, double, 2);
241  double ang[2]; this->GetKeyLightAngle(ang); return ang[0]; };
242 
244  double ang[2]; this->GetKeyLightAngle(ang); return ang[1]; };
245 
246  void SetFillLightAngle(double elevation, double azimuth);
247  void SetFillLightAngle(double angle[2]) {
248  this->SetFillLightAngle(angle[0], angle[1]); };
249 
250  void SetFillLightElevation(double x) {
251  this->SetFillLightAngle(x, this->FillLightAngle[1]); };
252 
253  void SetFillLightAzimuth(double x) {
254  this->SetFillLightAngle(this->FillLightAngle[0], x); };
255 
256  vtkGetVectorMacro(FillLightAngle, double, 2);
258  double ang[2]; this->GetFillLightAngle(ang); return ang[0]; };
259 
261  double ang[2]; this->GetFillLightAngle(ang); return ang[1]; };
262 
263  void SetBackLightAngle(double elevation, double azimuth);
264  void SetBackLightAngle(double angle[2]) {
265  this->SetBackLightAngle(angle[0], angle[1]); };
266 
267  void SetBackLightElevation(double x) {
268  this->SetBackLightAngle(x, this->BackLightAngle[1]); };
269 
270  void SetBackLightAzimuth(double x) {
271  this->SetBackLightAngle(this->BackLightAngle[0], x); };
272 
273  vtkGetVectorMacro(BackLightAngle, double, 2);
275  double ang[2]; this->GetBackLightAngle(ang); return ang[0]; };
276 
278  double ang[2]; this->GetBackLightAngle(ang); return ang[1]; };
279 
281 
283  void AddLightsToRenderer(vtkRenderer *renderer);
284  void RemoveLightsFromRenderer(vtkRenderer *renderer);
286 
287  void DeepCopy(vtkLightKit *kit);
288 
289  void Modified();
290  void Update();
291 
293  static const char *GetStringFromType(int type);
294 
296  static const char *GetStringFromSubType(int type);
297 
301  static const char *GetShortStringFromSubType(int subtype);
302 
305  static LightKitSubType GetSubType(LightKitType type, int i);
306 
307 protected:
308  vtkLightKit();
309  ~vtkLightKit();
310 
311  void WarmthToRGBI(double w, double rgb[3], double& i);
312  void WarmthToRGB(double w, double rgb[3]);
313  void InitializeWarmthFunctions();
314  double WarmthToIntensity(double w);
315 
316 
321 
324  double KeyLightAngle[2];
325  double KeyLightColor[3];
326 
329  double FillLightAngle[2];
330  double FillLightColor[3];
331 
333  double BackLightColor[3];
334 
337 
338  double BackLightAngle[2];
339 
342  double HeadLightColor[3];
343 
345 
346  vtkPiecewiseFunction *WarmthFunction[4]; // r, g, b, perceptual length
347 
348 private:
349  vtkLightKit(const vtkLightKit&); // Not implemented.
350  void operator=(const vtkLightKit&); // Not implemented.
351 };
352 
353 #endif