QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgslightsource.h"
23 #include <QColor>
24 
25 class QDomDocument;
26 class QDomElement;
27 
39 class _3D_EXPORT QgsPointLightSettings : public QgsLightSource
40 {
41  public:
43  QgsPointLightSettings() = default;
44 
45  Qgis::LightSourceType type() const override;
46  QgsPointLightSettings *clone() const override SIP_FACTORY;
47  Qt3DCore::QEntity *createEntity( const Qgs3DMapSettings &map, Qt3DCore::QEntity *parent ) const override SIP_SKIP;
48  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const override;
49  void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() ) override;
50 
52  QgsVector3D position() const { return mPosition; }
54  void setPosition( const QgsVector3D &pos ) { mPosition = pos; }
55 
57  QColor color() const { return mColor; }
59  void setColor( const QColor &color ) { mColor = color; }
60 
62  float intensity() const { return mIntensity; }
64  void setIntensity( float intensity ) { mIntensity = intensity; }
65 
67  float constantAttenuation() const { return mConstantAttenuation; }
69  void setConstantAttenuation( float value ) { mConstantAttenuation = value; }
70 
72  float linearAttenuation() const { return mLinearAttenuation; }
74  void setLinearAttenuation( float value ) { mLinearAttenuation = value; }
75 
77  float quadraticAttenuation() const { return mQuadraticAttenuation; }
79  void setQuadraticAttenuation( float value ) { mQuadraticAttenuation = value; }
80 
81  // TODO c++20 - replace with = default
82  bool operator==( const QgsPointLightSettings &other );
83 
84  private:
85  QgsVector3D mPosition { 0, 1000, 0 };
86  QColor mColor = Qt::white;
87  float mIntensity = 1.0;
88  float mConstantAttenuation = 1.0f;
89  float mLinearAttenuation = 0.0f;
90  float mQuadraticAttenuation = 0.0f;
91 };
92 
93 #endif // QGSPOINTLIGHTSETTINGS_H
QgsPointLightSettings::constantAttenuation
float constantAttenuation() const
Returns constant attenuation (A_0)
Definition: qgspointlightsettings.h:67
QgsPointLightSettings::setIntensity
void setIntensity(float intensity)
Sets intensity of the light.
Definition: qgspointlightsettings.h:64
QgsPointLightSettings::position
QgsVector3D position() const
Returns position of the light (in 3D world coordinates)
Definition: qgspointlightsettings.h:52
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:425
QgsVector3D
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition: qgsvector3d.h:31
QgsPointLightSettings::setPosition
void setPosition(const QgsVector3D &pos)
Sets position of the light (in 3D world coordinates)
Definition: qgspointlightsettings.h:54
QgsPointLightSettings::color
QColor color() const
Returns color of the light.
Definition: qgspointlightsettings.h:57
QgsLightSource::createEntity
virtual Qt3DCore::QEntity * createEntity(const Qgs3DMapSettings &map, Qt3DCore::QEntity *parent) const =0
Creates an entity representing the light source.
QgsPointLightSettings::setQuadraticAttenuation
void setQuadraticAttenuation(float value)
Sets quadratic attenuation (A_2)
Definition: qgspointlightsettings.h:79
QgsLightSource::readXml
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context=QgsReadWriteContext())=0
Reads configuration from a DOM element previously written using writeXml().
QgsLightSource
Base class for light sources in 3d scenes.
Definition: qgslightsource.h:46
Qgis::LightSourceType
LightSourceType
Light source types for 3D scenes.
Definition: qgis.h:1837
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsLightSource::type
virtual Qgis::LightSourceType type() const =0
Returns the light source type.
QgsPointLightSettings::setColor
void setColor(const QColor &color)
Sets color of the light.
Definition: qgspointlightsettings.h:59
QgsPointLightSettings
Definition of a point light in a 3D map scene.
Definition: qgspointlightsettings.h:39
QgsPointLightSettings::quadraticAttenuation
float quadraticAttenuation() const
Returns quadratic attenuation (A_2)
Definition: qgspointlightsettings.h:77
qgslightsource.h
Qgs3DMapSettings
Definition of the world.
Definition: qgs3dmapsettings.h:57
QgsPointLightSettings::intensity
float intensity() const
Returns intensity of the light.
Definition: qgspointlightsettings.h:62
qgsvector3d.h
QgsLightSource::writeXml
virtual QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const =0
Writes the light source's configuration to a new DOM element and returns it.
QgsPointLightSettings::setConstantAttenuation
void setConstantAttenuation(float value)
Sets constant attenuation (A_0)
Definition: qgspointlightsettings.h:69
QgsPointLightSettings::linearAttenuation
float linearAttenuation() const
Returns linear attenuation (A_1)
Definition: qgspointlightsettings.h:72
QgsLightSource::clone
virtual QgsLightSource * clone() const =0
Returns a copy of the light source.
QgsPointLightSettings::setLinearAttenuation
void setLinearAttenuation(float value)
Sets linear attenuation (A_1)
Definition: qgspointlightsettings.h:74