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 "vtkObject.h"
98 
99 class vtkLight;
101 class vtkRenderer;
102 
104 {
105 public:
106  static vtkLightKit *New();
107  vtkTypeMacro(vtkLightKit, vtkObject);
108  void PrintSelf(ostream& os, vtkIndent indent);
109 
110  //BTX
115  THeadLight
116  };
117 
125  KHRatio
126  };
127 
128  //ETX
129 
131 
134  vtkSetMacro(KeyLightIntensity, double);
135  vtkGetMacro(KeyLightIntensity, double);
137 
139 
147  vtkSetClampMacro(KeyToFillRatio, double, 0.5, VTK_DOUBLE_MAX);
148  vtkGetMacro(KeyToFillRatio, double);
150 
152 
161  vtkSetClampMacro(KeyToHeadRatio, double, 0.5, VTK_DOUBLE_MAX);
162  vtkGetMacro(KeyToHeadRatio, double);
164 
166 
171  vtkSetClampMacro(KeyToBackRatio, double, 0.5, VTK_DOUBLE_MAX);
172  vtkGetMacro(KeyToBackRatio, double);
174 
176 
185  vtkSetMacro(KeyLightWarmth, double);
186  vtkGetMacro(KeyLightWarmth, double);
188 
189  vtkSetMacro(FillLightWarmth, double);
190  vtkGetMacro(FillLightWarmth, double);
191 
192  vtkSetMacro(HeadLightWarmth, double);
193  vtkGetMacro(HeadLightWarmth, double);
194 
195  vtkSetMacro(BackLightWarmth, double);
196  vtkGetMacro(BackLightWarmth, double);
197 
199 
200  vtkGetVectorMacro(KeyLightColor, double, 3);
201  vtkGetVectorMacro(FillLightColor, double, 3);
202  vtkGetVectorMacro(HeadLightColor, double, 3);
203  vtkGetVectorMacro(BackLightColor, double, 3);
205 
207 
208  VTK_LEGACY(void SetHeadlightWarmth(double v));
209  VTK_LEGACY(double GetHeadlightWarmth());
210  VTK_LEGACY(void GetHeadlightColor(double *color));
212 
214 
217  vtkBooleanMacro(MaintainLuminance, int);
218  vtkGetMacro(MaintainLuminance, int);
219  vtkSetMacro(MaintainLuminance, int);
221 
223 
234  void SetKeyLightAngle(double elevation, double azimuth);
235  void SetKeyLightAngle(double angle[2]) {
236  this->SetKeyLightAngle(angle[0], angle[1]); };
238 
239  void SetKeyLightElevation(double x) {
240  this->SetKeyLightAngle(x, this->KeyLightAngle[1]); };
241 
242  void SetKeyLightAzimuth(double x) {
243  this->SetKeyLightAngle(this->KeyLightAngle[0], x); };
244 
245  vtkGetVectorMacro(KeyLightAngle, double, 2);
247  double ang[2]; this->GetKeyLightAngle(ang); return ang[0]; };
248 
250  double ang[2]; this->GetKeyLightAngle(ang); return ang[1]; };
251 
252  void SetFillLightAngle(double elevation, double azimuth);
253  void SetFillLightAngle(double angle[2]) {
254  this->SetFillLightAngle(angle[0], angle[1]); };
255 
256  void SetFillLightElevation(double x) {
257  this->SetFillLightAngle(x, this->FillLightAngle[1]); };
258 
259  void SetFillLightAzimuth(double x) {
260  this->SetFillLightAngle(this->FillLightAngle[0], x); };
261 
262  vtkGetVectorMacro(FillLightAngle, double, 2);
264  double ang[2]; this->GetFillLightAngle(ang); return ang[0]; };
265 
267  double ang[2]; this->GetFillLightAngle(ang); return ang[1]; };
268 
269  void SetBackLightAngle(double elevation, double azimuth);
270  void SetBackLightAngle(double angle[2]) {
271  this->SetBackLightAngle(angle[0], angle[1]); };
272 
273  void SetBackLightElevation(double x) {
274  this->SetBackLightAngle(x, this->BackLightAngle[1]); };
275 
276  void SetBackLightAzimuth(double x) {
277  this->SetBackLightAngle(this->BackLightAngle[0], x); };
278 
279  vtkGetVectorMacro(BackLightAngle, double, 2);
281  double ang[2]; this->GetBackLightAngle(ang); return ang[0]; };
282 
284  double ang[2]; this->GetBackLightAngle(ang); return ang[1]; };
285 
287 
289  void AddLightsToRenderer(vtkRenderer *renderer);
290  void RemoveLightsFromRenderer(vtkRenderer *renderer);
292 
293  void DeepCopy(vtkLightKit *kit);
294 
295  void Modified();
296  void Update();
297 
299  static const char *GetStringFromType(int type);
300 
302  static const char *GetStringFromSubType(int type);
303 
307  static const char *GetShortStringFromSubType(int subtype);
308 
311  static LightKitSubType GetSubType(LightKitType type, int i);
312 
313 protected:
314  vtkLightKit();
315  ~vtkLightKit();
316 
317  void WarmthToRGBI(double w, double rgb[3], double& i);
318  void WarmthToRGB(double w, double rgb[3]);
319  void InitializeWarmthFunctions();
320  double WarmthToIntensity(double w);
321 
322 
327 
330  double KeyLightAngle[2];
331  double KeyLightColor[3];
332 
335  double FillLightAngle[2];
336  double FillLightColor[3];
337 
339  double BackLightColor[3];
340 
343 
344  double BackLightAngle[2];
345 
348  double HeadLightColor[3];
349 
351 
352  vtkPiecewiseFunction *WarmthFunction[4]; // r, g, b, perceptual length
353 
354 private:
355  vtkLightKit(const vtkLightKit&); // Not implemented.
356  void operator=(const vtkLightKit&); // Not implemented.
357 };
358 
359 #endif
void SetFillLightAngle(double angle[2])
Definition: vtkLightKit.h:253
abstract base class for most VTK objects
Definition: vtkObject.h:60
double KeyLightIntensity
Definition: vtkLightKit.h:323
double GetFillLightAzimuth()
Definition: vtkLightKit.h:266
#define VTK_DOUBLE_MAX
Definition: vtkType.h:133
Defines a 1D piecewise function.
vtkLight * BackLight0
Definition: vtkLightKit.h:341
double KeyToBackRatio
Definition: vtkLightKit.h:326
double GetBackLightAzimuth()
Definition: vtkLightKit.h:283
void SetBackLightAzimuth(double x)
Definition: vtkLightKit.h:276
double KeyToFillRatio
Definition: vtkLightKit.h:324
void SetBackLightElevation(double x)
Definition: vtkLightKit.h:273
abstract specification for renderers
Definition: vtkRenderer.h:69
a simple but quality lighting kit
Definition: vtkLightKit.h:103
vtkLight * KeyLight
Definition: vtkLightKit.h:328
void SetKeyLightAngle(double angle[2])
Definition: vtkLightKit.h:235
double KeyLightWarmth
Definition: vtkLightKit.h:329
vtkLight * FillLight
Definition: vtkLightKit.h:333
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
double GetKeyLightElevation()
Definition: vtkLightKit.h:246
void SetKeyLightElevation(double x)
Definition: vtkLightKit.h:239
a virtual light for 3D rendering
Definition: vtkLight.h:59
void SetKeyLightAzimuth(double x)
Definition: vtkLightKit.h:242
double GetKeyLightAzimuth()
Definition: vtkLightKit.h:249
double GetBackLightElevation()
Definition: vtkLightKit.h:280
vtkLight * BackLight1
Definition: vtkLightKit.h:342
virtual void Modified()
int MaintainLuminance
Definition: vtkLightKit.h:350
void SetFillLightElevation(double x)
Definition: vtkLightKit.h:256
#define VTK_RENDERING_EXPORT
void SetBackLightAngle(double angle[2])
Definition: vtkLightKit.h:270
static vtkObject * New()
double BackLightWarmth
Definition: vtkLightKit.h:338
double HeadLightWarmth
Definition: vtkLightKit.h:347
double FillLightWarmth
Definition: vtkLightKit.h:334
vtkLight * HeadLight
Definition: vtkLightKit.h:346
double KeyToHeadRatio
Definition: vtkLightKit.h:325
double GetFillLightElevation()
Definition: vtkLightKit.h:263
void SetFillLightAzimuth(double x)
Definition: vtkLightKit.h:259