VTK  9.7.1
vtkLightKit.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
86 #ifndef vtkLightKit_h
87 #define vtkLightKit_h
88 
89 #include "vtkObject.h"
90 #include "vtkRenderingCoreModule.h" // For export macro
91 
92 VTK_ABI_NAMESPACE_BEGIN
93 class vtkLight;
95 class vtkRenderer;
96 
97 class VTKRENDERINGCORE_EXPORT vtkLightKit : public vtkObject
98 {
99 public:
100  static vtkLightKit* New();
101  vtkTypeMacro(vtkLightKit, vtkObject);
102  void PrintSelf(ostream& os, vtkIndent indent) override;
103 
105  {
109  THeadLight
110  };
111 
113  {
120  KHRatio
121  };
122 
124 
129  vtkSetMacro(KeyLightIntensity, double);
130  vtkGetMacro(KeyLightIntensity, double);
132 
134 
145  vtkSetClampMacro(KeyToFillRatio, double, 0.5, VTK_DOUBLE_MAX);
146  vtkGetMacro(KeyToFillRatio, double);
148 
150 
161  vtkSetClampMacro(KeyToHeadRatio, double, 0.5, VTK_DOUBLE_MAX);
162  vtkGetMacro(KeyToHeadRatio, double);
164 
166 
173  vtkSetClampMacro(KeyToBackRatio, double, 0.5, VTK_DOUBLE_MAX);
174  vtkGetMacro(KeyToBackRatio, double);
176 
178 
190  vtkSetMacro(KeyLightWarmth, double);
191  vtkGetMacro(KeyLightWarmth, double);
193 
194  vtkSetMacro(FillLightWarmth, double);
195  vtkGetMacro(FillLightWarmth, double);
196 
197  vtkSetMacro(HeadLightWarmth, double);
198  vtkGetMacro(HeadLightWarmth, double);
199 
200  vtkSetMacro(BackLightWarmth, double);
201  vtkGetMacro(BackLightWarmth, double);
202 
204 
207  vtkGetVectorMacro(KeyLightColor, double, 3);
208  vtkGetVectorMacro(FillLightColor, double, 3);
209  vtkGetVectorMacro(HeadLightColor, double, 3);
210  vtkGetVectorMacro(BackLightColor, double, 3);
212 
214 
219  vtkBooleanMacro(MaintainLuminance, vtkTypeBool);
220  vtkGetMacro(MaintainLuminance, vtkTypeBool);
221  vtkSetMacro(MaintainLuminance, vtkTypeBool);
223 
237  void SetKeyLightAngle(double elevation, double azimuth);
238  void SetKeyLightAngle(double angle[2]) { this->SetKeyLightAngle(angle[0], angle[1]); }
239 
240  void SetKeyLightElevation(double x) { this->SetKeyLightAngle(x, this->KeyLightAngle[1]); }
241 
242  void SetKeyLightAzimuth(double x) { this->SetKeyLightAngle(this->KeyLightAngle[0], x); }
243 
244  vtkGetVectorMacro(KeyLightAngle, double, 2);
246  {
247  double ang[2];
248  this->GetKeyLightAngle(ang);
249  return ang[0];
250  }
251 
253  {
254  double ang[2];
255  this->GetKeyLightAngle(ang);
256  return ang[1];
257  }
258 
259  void SetFillLightAngle(double elevation, double azimuth);
260  void SetFillLightAngle(double angle[2]) { this->SetFillLightAngle(angle[0], angle[1]); }
261 
262  void SetFillLightElevation(double x) { this->SetFillLightAngle(x, this->FillLightAngle[1]); }
263 
264  void SetFillLightAzimuth(double x) { this->SetFillLightAngle(this->FillLightAngle[0], x); }
265 
266  vtkGetVectorMacro(FillLightAngle, double, 2);
268  {
269  double ang[2];
270  this->GetFillLightAngle(ang);
271  return ang[0];
272  }
273 
275  {
276  double ang[2];
277  this->GetFillLightAngle(ang);
278  return ang[1];
279  }
280 
281  void SetBackLightAngle(double elevation, double azimuth);
282  void SetBackLightAngle(double angle[2]) { this->SetBackLightAngle(angle[0], angle[1]); }
283 
284  void SetBackLightElevation(double x) { this->SetBackLightAngle(x, this->BackLightAngle[1]); }
285 
286  void SetBackLightAzimuth(double x) { this->SetBackLightAngle(this->BackLightAngle[0], x); }
287 
288  vtkGetVectorMacro(BackLightAngle, double, 2);
290  {
291  double ang[2];
292  this->GetBackLightAngle(ang);
293  return ang[0];
294  }
295 
297  {
298  double ang[2];
299  this->GetBackLightAngle(ang);
300  return ang[1];
301  }
302 
304 
308  void AddLightsToRenderer(vtkRenderer* renderer);
309  void RemoveLightsFromRenderer(vtkRenderer* renderer);
311 
312  void DeepCopy(vtkLightKit* kit);
313 
314  void Modified() override;
315  void Update();
316 
320  static const char* GetStringFromType(int type);
321 
325  static const char* GetStringFromSubType(int type);
326 
332  static const char* GetShortStringFromSubType(int subtype);
333 
338  static LightKitSubType GetSubType(LightKitType type, int i);
339 
340 protected:
341  vtkLightKit();
342  ~vtkLightKit() override;
343 
344  void WarmthToRGBI(double w, double rgb[3], double& i);
345  void WarmthToRGB(double w, double rgb[3]);
346  void InitializeWarmthFunctions();
347  double WarmthToIntensity(double w);
348 
353 
356  double KeyLightAngle[2];
357  double KeyLightColor[3];
358 
361  double FillLightAngle[2];
362  double FillLightColor[3];
363 
365  double BackLightColor[3];
366 
369 
370  double BackLightAngle[2];
371 
374  double HeadLightColor[3];
375 
377 
378  vtkPiecewiseFunction* WarmthFunction[4]; // r, g, b, perceptual length
379 
380 private:
381  vtkLightKit(const vtkLightKit&) = delete;
382  void operator=(const vtkLightKit&) = delete;
383 };
384 
385 VTK_ABI_NAMESPACE_END
386 #endif
void SetFillLightAngle(double angle[2])
Definition: vtkLightKit.h:260
abstract base class for most VTK objects
Definition: vtkObject.h:52
double KeyLightIntensity
Definition: vtkLightKit.h:349
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:202
Defines a 1D piecewise function.
vtkLight * BackLight0
Definition: vtkLightKit.h:367
double KeyToBackRatio
Definition: vtkLightKit.h:352
double GetBackLightAzimuth()
Definition: vtkLightKit.h:296
void SetBackLightAzimuth(double x)
Definition: vtkLightKit.h:286
double KeyToFillRatio
Definition: vtkLightKit.h:350
void SetBackLightElevation(double x)
Definition: vtkLightKit.h:284
abstract specification for renderers
Definition: vtkRenderer.h:63
a simple but quality lighting kit
Definition: vtkLightKit.h:97
vtkLight * KeyLight
Definition: vtkLightKit.h:354
void SetKeyLightAngle(double angle[2])
Definition: vtkLightKit.h:238
vtkTypeBool MaintainLuminance
Definition: vtkLightKit.h:376
double KeyLightWarmth
Definition: vtkLightKit.h:355
int vtkTypeBool
Definition: vtkABI.h:64
vtkLight * FillLight
Definition: vtkLightKit.h:359
a simple class to control print indentation
Definition: vtkIndent.h:28
double GetKeyLightElevation()
Definition: vtkLightKit.h:245
void SetKeyLightElevation(double x)
Definition: vtkLightKit.h:240
a virtual light for 3D rendering
Definition: vtkLight.h:49
void SetKeyLightAzimuth(double x)
Definition: vtkLightKit.h:242
double GetKeyLightAzimuth()
Definition: vtkLightKit.h:252
double GetBackLightElevation()
Definition: vtkLightKit.h:289
vtkLight * BackLight1
Definition: vtkLightKit.h:368
virtual void Modified()
Update the modification time for this object.
void SetFillLightElevation(double x)
Definition: vtkLightKit.h:262
void SetBackLightAngle(double angle[2])
Definition: vtkLightKit.h:282
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
double BackLightWarmth
Definition: vtkLightKit.h:364
double HeadLightWarmth
Definition: vtkLightKit.h:373
double FillLightWarmth
Definition: vtkLightKit.h:360
vtkLight * HeadLight
Definition: vtkLightKit.h:372
double KeyToHeadRatio
Definition: vtkLightKit.h:351
double GetFillLightElevation()
Definition: vtkLightKit.h:267
void SetFillLightAzimuth(double x)
Definition: vtkLightKit.h:264