Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3D material color data defined (#39683)
- Loading branch information
Showing
34 changed files
with
1,131 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/*************************************************************************** | ||
qgsabstractmaterialsettings.cpp | ||
-------------------------------------- | ||
Date : July 2020 | ||
Copyright : (C) 2020 by Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include <qgsabstractmaterialsettings.h> | ||
|
||
QgsPropertiesDefinition QgsAbstractMaterialSettings::sPropertyDefinitions; | ||
|
||
void QgsAbstractMaterialSettings::readXml( const QDomElement &element, const QgsReadWriteContext & ) | ||
{ | ||
QDomElement elemDataDefinedProperties = element.firstChildElement( QStringLiteral( "data-defined-properties" ) ); | ||
if ( !elemDataDefinedProperties.isNull() ) | ||
mDataDefinedProperties.readXml( elemDataDefinedProperties, propertyDefinitions() ); | ||
} | ||
|
||
void QgsAbstractMaterialSettings::writeXml( QDomElement &element, const QgsReadWriteContext & ) const | ||
{ | ||
QDomElement elemDataDefinedProperties = element.ownerDocument().createElement( QStringLiteral( "data-defined-properties" ) ); | ||
mDataDefinedProperties.writeXml( elemDataDefinedProperties, propertyDefinitions() ); | ||
element.appendChild( elemDataDefinedProperties ); | ||
} | ||
|
||
void QgsAbstractMaterialSettings::setDataDefinedProperties( const QgsPropertyCollection &collection ) | ||
{ | ||
mDataDefinedProperties = collection; | ||
} | ||
|
||
QgsPropertyCollection QgsAbstractMaterialSettings::dataDefinedProperties() const {return mDataDefinedProperties;} | ||
|
||
const QgsPropertiesDefinition &QgsAbstractMaterialSettings::propertyDefinitions() const | ||
{ | ||
if ( sPropertyDefinitions.isEmpty() ) | ||
initPropertyDefinitions(); | ||
return sPropertyDefinitions; | ||
} | ||
|
||
QByteArray QgsAbstractMaterialSettings::dataDefinedVertexColorsAsByte( const QgsExpressionContext &expressionContext ) const | ||
{ | ||
Q_UNUSED( expressionContext ) | ||
return QByteArray(); | ||
} | ||
|
||
void QgsAbstractMaterialSettings::applyDataDefinedToGeometry( Qt3DRender::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes ) const | ||
{ | ||
Q_UNUSED( geometry ) | ||
Q_UNUSED( vertexCount ) | ||
Q_UNUSED( dataDefinedBytes ) | ||
} | ||
|
||
void QgsAbstractMaterialSettings::initPropertyDefinitions() const | ||
{ | ||
if ( !sPropertyDefinitions.isEmpty() ) | ||
return; | ||
|
||
QString origin = QStringLiteral( "material3d" ); | ||
|
||
sPropertyDefinitions = QgsPropertiesDefinition | ||
{ | ||
{ Diffuse, QgsPropertyDefinition( "diffuse", QObject::tr( "Diffuse" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, | ||
{ Ambient, QgsPropertyDefinition( "ambient", QObject::tr( "Ambient" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, | ||
{ Warm, QgsPropertyDefinition( "warm", QObject::tr( "Warm" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, | ||
{ Cool, QgsPropertyDefinition( "cool", QObject::tr( "Cool" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, | ||
{ Specular, QgsPropertyDefinition( "specular", QObject::tr( "Specular" ), QgsPropertyDefinition::ColorNoAlpha, origin ) } | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.