QGIS API Documentation  3.21.0-Master (5b68dc587e)
qgspointlightsettings.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspointlightsettings.h
3  --------------------------------------
4  Date : November 2018
5  Copyright : (C) 2018 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSPOINTLIGHTSETTINGS_H
17 #define QGSPOINTLIGHTSETTINGS_H
18 
19 #include "qgis_3d.h"
20 
21 #include "qgsvector3d.h"
22 #include <QColor>
23 
24 class QDomDocument;
25 class QDomElement;
26 
38 class _3D_EXPORT QgsPointLightSettings
39 {
40  public:
42  QgsPointLightSettings() = default;
43 
45  QgsVector3D position() const { return mPosition; }
47  void setPosition( const QgsVector3D &pos ) { mPosition = pos; }
48 
50  QColor color() const { return mColor; }
52  void setColor( const QColor &color ) { mColor = color; }
53 
55  float intensity() const { return mIntensity; }
57  void setIntensity( float intensity ) { mIntensity = intensity; }
58 
60  float constantAttenuation() const { return mConstantAttenuation; }
62  void setConstantAttenuation( float value ) { mConstantAttenuation = value; }
63 
65  float linearAttenuation() const { return mLinearAttenuation; }
67  void setLinearAttenuation( float value ) { mLinearAttenuation = value; }
68 
70  float quadraticAttenuation() const { return mQuadraticAttenuation; }
72  void setQuadraticAttenuation( float value ) { mQuadraticAttenuation = value; }
73 
75  QDomElement writeXml( QDomDocument &doc ) const;
77  void readXml( const QDomElement &elem );
78 
79  // TODO c++20 - replace with = default
80  bool operator==( const QgsPointLightSettings &other );
81 
82  private:
83  QgsVector3D mPosition { 0, 1000, 0 };
84  QColor mColor = Qt::white;
85  float mIntensity = 1.0;
86  float mConstantAttenuation = 1.0f;
87  float mLinearAttenuation = 0.0f;
88  float mQuadraticAttenuation = 0.0f;
89 };
90 
91 #endif // QGSPOINTLIGHTSETTINGS_H
QgsPointLightSettings()=default
Construct a point light with default values.
float quadraticAttenuation() const
Returns quadratic attenuation (A_2)
void setIntensity(float intensity)
Sets intensity of the light.
void setPosition(const QgsVector3D &pos)
Sets position of the light (in 3D world coordinates)
float linearAttenuation() const
Returns linear attenuation (A_1)
void setColor(const QColor &color)
Sets color of the light.
float intensity() const
Returns intensity of the light.
void setLinearAttenuation(float value)
Sets linear attenuation (A_1)
void setConstantAttenuation(float value)
Sets constant attenuation (A_0)
QgsVector3D position() const
Returns position of the light (in 3D world coordinates)
void setQuadraticAttenuation(float value)
Sets quadratic attenuation (A_2)
float constantAttenuation() const
Returns constant attenuation (A_0)
QColor color() const
Returns color of the light.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)