VTK  9.2.6
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 "vtkObject.h"
99 #include "vtkRenderingCoreModule.h" // For export macro
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 
113  {
117  THeadLight
118  };
119 
121  {
128  KHRatio
129  };
130 
132 
137  vtkSetMacro(KeyLightIntensity, double);
138  vtkGetMacro(KeyLightIntensity, double);
140 
142 
153  vtkSetClampMacro(KeyToFillRatio, double, 0.5, VTK_DOUBLE_MAX);
154  vtkGetMacro(KeyToFillRatio, double);
156 
158 
169  vtkSetClampMacro(KeyToHeadRatio, double, 0.5, VTK_DOUBLE_MAX);
170  vtkGetMacro(KeyToHeadRatio, double);
172 
174 
181  vtkSetClampMacro(KeyToBackRatio, double, 0.5, VTK_DOUBLE_MAX);
182  vtkGetMacro(KeyToBackRatio, double);
184 
186 
198  vtkSetMacro(KeyLightWarmth, double);
199  vtkGetMacro(KeyLightWarmth, double);
201 
202  vtkSetMacro(FillLightWarmth, double);
203  vtkGetMacro(FillLightWarmth, double);
204 
205  vtkSetMacro(HeadLightWarmth, double);
206  vtkGetMacro(HeadLightWarmth, double);
207 
208  vtkSetMacro(BackLightWarmth, double);
209  vtkGetMacro(BackLightWarmth, double);
210 
212 
215  vtkGetVectorMacro(KeyLightColor, double, 3);
216  vtkGetVectorMacro(FillLightColor, double, 3);
217  vtkGetVectorMacro(HeadLightColor, double, 3);
218  vtkGetVectorMacro(BackLightColor, double, 3);
220 
222 
227  vtkBooleanMacro(MaintainLuminance, vtkTypeBool);
228  vtkGetMacro(MaintainLuminance, vtkTypeBool);
229  vtkSetMacro(MaintainLuminance, vtkTypeBool);
231 
245  void SetKeyLightAngle(double elevation, double azimuth);
246  void SetKeyLightAngle(double angle[2]) { this->SetKeyLightAngle(angle[0], angle[1]); }
247 
248  void SetKeyLightElevation(double x) { this->SetKeyLightAngle(x, this->KeyLightAngle[1]); }
249 
250  void SetKeyLightAzimuth(double x) { this->SetKeyLightAngle(this->KeyLightAngle[0], x); }
251 
252  vtkGetVectorMacro(KeyLightAngle, double, 2);
254  {
255  double ang[2];
256  this->GetKeyLightAngle(ang);
257  return ang[0];
258  }
259 
261  {
262  double ang[2];
263  this->GetKeyLightAngle(ang);
264  return ang[1];
265  }
266 
267  void SetFillLightAngle(double elevation, double azimuth);
268  void SetFillLightAngle(double angle[2]) { this->SetFillLightAngle(angle[0], angle[1]); }
269 
270  void SetFillLightElevation(double x) { this->SetFillLightAngle(x, this->FillLightAngle[1]); }
271 
272  void SetFillLightAzimuth(double x) { this->SetFillLightAngle(this->FillLightAngle[0], x); }
273 
274  vtkGetVectorMacro(FillLightAngle, double, 2);
276  {
277  double ang[2];
278  this->GetFillLightAngle(ang);
279  return ang[0];
280  }
281 
283  {
284  double ang[2];
285  this->GetFillLightAngle(ang);
286  return ang[1];
287  }
288 
289  void SetBackLightAngle(double elevation, double azimuth);
290  void SetBackLightAngle(double angle[2]) { this->SetBackLightAngle(angle[0], angle[1]); }
291 
292  void SetBackLightElevation(double x) { this->SetBackLightAngle(x, this->BackLightAngle[1]); }
293 
294  void SetBackLightAzimuth(double x) { this->SetBackLightAngle(this->BackLightAngle[0], x); }
295 
296  vtkGetVectorMacro(BackLightAngle, double, 2);
298  {
299  double ang[2];
300  this->GetBackLightAngle(ang);
301  return ang[0];
302  }
303 
305  {
306  double ang[2];
307  this->GetBackLightAngle(ang);
308  return ang[1];
309  }
310 
312 
316  void AddLightsToRenderer(vtkRenderer* renderer);
317  void RemoveLightsFromRenderer(vtkRenderer* renderer);
319 
320  void DeepCopy(vtkLightKit* kit);
321 
322  void Modified() override;
323  void Update();
324 
328  static const char* GetStringFromType(int type);
329 
333  static const char* GetStringFromSubType(int type);
334 
340  static const char* GetShortStringFromSubType(int subtype);
341 
346  static LightKitSubType GetSubType(LightKitType type, int i);
347 
348 protected:
349  vtkLightKit();
350  ~vtkLightKit() override;
351 
352  void WarmthToRGBI(double w, double rgb[3], double& i);
353  void WarmthToRGB(double w, double rgb[3]);
354  void InitializeWarmthFunctions();
355  double WarmthToIntensity(double w);
356 
361 
364  double KeyLightAngle[2];
365  double KeyLightColor[3];
366 
369  double FillLightAngle[2];
370  double FillLightColor[3];
371 
373  double BackLightColor[3];
374 
377 
378  double BackLightAngle[2];
379 
382  double HeadLightColor[3];
383 
385 
386  vtkPiecewiseFunction* WarmthFunction[4]; // r, g, b, perceptual length
387 
388 private:
389  vtkLightKit(const vtkLightKit&) = delete;
390  void operator=(const vtkLightKit&) = delete;
391 };
392 
393 #endif
void SetFillLightAngle(double angle[2])
Definition: vtkLightKit.h:268
abstract base class for most VTK objects
Definition: vtkObject.h:62
double KeyLightIntensity
Definition: vtkLightKit.h:357
double GetFillLightAzimuth()
Definition: vtkLightKit.h:282
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:165
Defines a 1D piecewise function.
vtkLight * BackLight0
Definition: vtkLightKit.h:375
double KeyToBackRatio
Definition: vtkLightKit.h:360
double GetBackLightAzimuth()
Definition: vtkLightKit.h:304
void SetBackLightAzimuth(double x)
Definition: vtkLightKit.h:294
double KeyToFillRatio
Definition: vtkLightKit.h:358
void SetBackLightElevation(double x)
Definition: vtkLightKit.h:292
abstract specification for renderers
Definition: vtkRenderer.h:72
a simple but quality lighting kit
Definition: vtkLightKit.h:105
vtkLight * KeyLight
Definition: vtkLightKit.h:362
void SetKeyLightAngle(double angle[2])
Definition: vtkLightKit.h:246
vtkTypeBool MaintainLuminance
Definition: vtkLightKit.h:384
double KeyLightWarmth
Definition: vtkLightKit.h:363
int vtkTypeBool
Definition: vtkABI.h:69
vtkLight * FillLight
Definition: vtkLightKit.h:367
a simple class to control print indentation
Definition: vtkIndent.h:39
double GetKeyLightElevation()
Definition: vtkLightKit.h:253
void SetKeyLightElevation(double x)
Definition: vtkLightKit.h:248
a virtual light for 3D rendering
Definition: vtkLight.h:59
void SetKeyLightAzimuth(double x)
Definition: vtkLightKit.h:250
double GetKeyLightAzimuth()
Definition: vtkLightKit.h:260
double GetBackLightElevation()
Definition: vtkLightKit.h:297
vtkLight * BackLight1
Definition: vtkLightKit.h:376
virtual void Modified()
Update the modification time for this object.
void SetFillLightElevation(double x)
Definition: vtkLightKit.h:270
void SetBackLightAngle(double angle[2])
Definition: vtkLightKit.h:290
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
double BackLightWarmth
Definition: vtkLightKit.h:372
double HeadLightWarmth
Definition: vtkLightKit.h:381
double FillLightWarmth
Definition: vtkLightKit.h:368
vtkLight * HeadLight
Definition: vtkLightKit.h:380
double KeyToHeadRatio
Definition: vtkLightKit.h:359
double GetFillLightElevation()
Definition: vtkLightKit.h:275
void SetFillLightAzimuth(double x)
Definition: vtkLightKit.h:272