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 =========================================================================*/
95 #ifndef vtkLightKit_h
96 #define vtkLightKit_h
97 
98 #include "vtkRenderingCoreModule.h" // For export macro
99 #include "vtkObject.h"
100 
101 class vtkLight;
103 class vtkRenderer;
104 
105 class VTKRENDERINGCORE_EXPORT vtkLightKit : public vtkObject
106 {
107 public:
108  static vtkLightKit *New();
109  vtkTypeMacro(vtkLightKit, vtkObject);
110  void PrintSelf(ostream& os, vtkIndent indent) override;
111 
116  THeadLight
117  };
118 
126  KHRatio
127  };
128 
130 
135  vtkSetMacro(KeyLightIntensity, double);
136  vtkGetMacro(KeyLightIntensity, double);
138 
140 
151  vtkSetClampMacro(KeyToFillRatio, double, 0.5, VTK_DOUBLE_MAX);
152  vtkGetMacro(KeyToFillRatio, double);
154 
156 
167  vtkSetClampMacro(KeyToHeadRatio, double, 0.5, VTK_DOUBLE_MAX);
168  vtkGetMacro(KeyToHeadRatio, double);
170 
172 
179  vtkSetClampMacro(KeyToBackRatio, double, 0.5, VTK_DOUBLE_MAX);
180  vtkGetMacro(KeyToBackRatio, double);
182 
184 
196  vtkSetMacro(KeyLightWarmth, double);
197  vtkGetMacro(KeyLightWarmth, double);
199 
200  vtkSetMacro(FillLightWarmth, double);
201  vtkGetMacro(FillLightWarmth, double);
202 
203  vtkSetMacro(HeadLightWarmth, double);
204  vtkGetMacro(HeadLightWarmth, double);
205 
206  vtkSetMacro(BackLightWarmth, double);
207  vtkGetMacro(BackLightWarmth, double);
208 
210 
213  vtkGetVectorMacro(KeyLightColor, double, 3);
214  vtkGetVectorMacro(FillLightColor, double, 3);
215  vtkGetVectorMacro(HeadLightColor, double, 3);
216  vtkGetVectorMacro(BackLightColor, double, 3);
218 
220 
225  vtkBooleanMacro(MaintainLuminance, vtkTypeBool);
226  vtkGetMacro(MaintainLuminance, vtkTypeBool);
227  vtkSetMacro(MaintainLuminance, vtkTypeBool);
229 
243  void SetKeyLightAngle(double elevation, double azimuth);
244  void SetKeyLightAngle(double angle[2])
245  { this->SetKeyLightAngle(angle[0], angle[1]); }
246 
247  void SetKeyLightElevation(double x)
248  { this->SetKeyLightAngle(x, this->KeyLightAngle[1]); }
249 
250  void SetKeyLightAzimuth(double x)
251  { this->SetKeyLightAngle(this->KeyLightAngle[0], x); }
252 
253  vtkGetVectorMacro(KeyLightAngle, double, 2);
255  { double ang[2]; this->GetKeyLightAngle(ang); return ang[0]; }
256 
258  { double ang[2]; this->GetKeyLightAngle(ang); return ang[1]; }
259 
260  void SetFillLightAngle(double elevation, double azimuth);
261  void SetFillLightAngle(double angle[2])
262  { this->SetFillLightAngle(angle[0], angle[1]); }
263 
264  void SetFillLightElevation(double x)
265  { this->SetFillLightAngle(x, this->FillLightAngle[1]); }
266 
267  void SetFillLightAzimuth(double x)
268  { this->SetFillLightAngle(this->FillLightAngle[0], x); }
269 
270  vtkGetVectorMacro(FillLightAngle, double, 2);
272  double ang[2]; this->GetFillLightAngle(ang); return ang[0]; }
273 
275  { double ang[2]; this->GetFillLightAngle(ang); return ang[1]; }
276 
277  void SetBackLightAngle(double elevation, double azimuth);
278  void SetBackLightAngle(double angle[2])
279  { this->SetBackLightAngle(angle[0], angle[1]); }
280 
281  void SetBackLightElevation(double x)
282  { this->SetBackLightAngle(x, this->BackLightAngle[1]); }
283 
284  void SetBackLightAzimuth(double x)
285  { this->SetBackLightAngle(this->BackLightAngle[0], x); }
286 
287  vtkGetVectorMacro(BackLightAngle, double, 2);
289  { double ang[2]; this->GetBackLightAngle(ang); return ang[0]; }
290 
292  { double ang[2]; this->GetBackLightAngle(ang); return ang[1]; }
293 
295 
299  void AddLightsToRenderer(vtkRenderer *renderer);
300  void RemoveLightsFromRenderer(vtkRenderer *renderer);
302 
303  void DeepCopy(vtkLightKit *kit);
304 
305  void Modified() override;
306  void Update();
307 
311  static const char *GetStringFromType(int type);
312 
316  static const char *GetStringFromSubType(int type);
317 
323  static const char *GetShortStringFromSubType(int subtype);
324 
329  static LightKitSubType GetSubType(LightKitType type, int i);
330 
331 protected:
332  vtkLightKit();
333  ~vtkLightKit() override;
334 
335  void WarmthToRGBI(double w, double rgb[3], double& i);
336  void WarmthToRGB(double w, double rgb[3]);
337  void InitializeWarmthFunctions();
338  double WarmthToIntensity(double w);
339 
340 
345 
348  double KeyLightAngle[2];
349  double KeyLightColor[3];
350 
353  double FillLightAngle[2];
354  double FillLightColor[3];
355 
357  double BackLightColor[3];
358 
361 
362  double BackLightAngle[2];
363 
366  double HeadLightColor[3];
367 
369 
370  vtkPiecewiseFunction *WarmthFunction[4]; // r, g, b, perceptual length
371 
372 private:
373  vtkLightKit(const vtkLightKit&) = delete;
374  void operator=(const vtkLightKit&) = delete;
375 };
376 
377 #endif
void SetFillLightAngle(double angle[2])
Definition: vtkLightKit.h:261
abstract base class for most VTK objects
Definition: vtkObject.h:59
double KeyLightIntensity
Definition: vtkLightKit.h:341
double GetFillLightAzimuth()
Definition: vtkLightKit.h:274
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_DOUBLE_MAX
Definition: vtkType.h:169
Defines a 1D piecewise function.
vtkLight * BackLight0
Definition: vtkLightKit.h:359
double KeyToBackRatio
Definition: vtkLightKit.h:344
double GetBackLightAzimuth()
Definition: vtkLightKit.h:291
void SetBackLightAzimuth(double x)
Definition: vtkLightKit.h:284
double KeyToFillRatio
Definition: vtkLightKit.h:342
void SetBackLightElevation(double x)
Definition: vtkLightKit.h:281
abstract specification for renderers
Definition: vtkRenderer.h:63
a simple but quality lighting kit
Definition: vtkLightKit.h:105
vtkLight * KeyLight
Definition: vtkLightKit.h:346
void SetKeyLightAngle(double angle[2])
Definition: vtkLightKit.h:244
vtkTypeBool MaintainLuminance
Definition: vtkLightKit.h:368
double KeyLightWarmth
Definition: vtkLightKit.h:347
int vtkTypeBool
Definition: vtkABI.h:69
vtkLight * FillLight
Definition: vtkLightKit.h:351
a simple class to control print indentation
Definition: vtkIndent.h:39
double GetKeyLightElevation()
Definition: vtkLightKit.h:254
void SetKeyLightElevation(double x)
Definition: vtkLightKit.h:247
a virtual light for 3D rendering
Definition: vtkLight.h:62
void SetKeyLightAzimuth(double x)
Definition: vtkLightKit.h:250
double GetKeyLightAzimuth()
Definition: vtkLightKit.h:257
double GetBackLightElevation()
Definition: vtkLightKit.h:288
vtkLight * BackLight1
Definition: vtkLightKit.h:360
virtual void Modified()
Update the modification time for this object.
void SetFillLightElevation(double x)
Definition: vtkLightKit.h:264
void SetBackLightAngle(double angle[2])
Definition: vtkLightKit.h:278
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
double BackLightWarmth
Definition: vtkLightKit.h:356
double HeadLightWarmth
Definition: vtkLightKit.h:365
double FillLightWarmth
Definition: vtkLightKit.h:352
vtkLight * HeadLight
Definition: vtkLightKit.h:364
double KeyToHeadRatio
Definition: vtkLightKit.h:343
double GetFillLightElevation()
Definition: vtkLightKit.h:271
void SetFillLightAzimuth(double x)
Definition: vtkLightKit.h:267