Skip to content

Commit

Permalink
add SIP_FACTO to QgsAbstractMaterialSettings::toExportParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem committed Jul 25, 2020
1 parent 4488739 commit 860be14
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions python/3d/auto_generated/qgsphongmaterialsettings.sip.in
Expand Up @@ -54,6 +54,9 @@ Returns specular color component
Returns shininess of the surface
%End

virtual QMap<QString, QString> toExportParameters() const;


bool diffuseTextureEnabled() const;
%Docstring
Returns whether the diffuse texture is used.
Expand Down
2 changes: 1 addition & 1 deletion src/3d/qgs3dexportobject.cpp
Expand Up @@ -85,7 +85,7 @@ void Qgs3DExportObject::setupTextureCoordinates( const QVector<float> &texturesB
void Qgs3DExportObject::setupMaterial( QgsAbstractMaterialSettings *material )
{
QMap<QString, QString> parameters = material->toExportParameters();
for (QString& key : parameters.keys()) setMaterialParameter(key, parameters[key]);
for ( QString &key : parameters.keys() ) setMaterialParameter( key, parameters[key] );
}

void Qgs3DExportObject::objectBounds( float &minX, float &minY, float &minZ, float &maxX, float &maxY, float &maxZ )
Expand Down
2 changes: 1 addition & 1 deletion src/3d/qgs3dexportobject.h
Expand Up @@ -83,7 +83,7 @@ class Qgs3DExportObject : public QObject
//! Sets texture coordinates for each vertex
void setupTextureCoordinates( const QVector<float> &texturesBuffer );
//! Sets the material parameters (diffuse color, shininess...) from phong material
void setupMaterial( QgsAbstractMaterialSettings* material );
void setupMaterial( QgsAbstractMaterialSettings *material );

//! Sets the texture image used by the object
void setTextureImage( const QImage &image ) { this->mTextureImage = image; };
Expand Down
3 changes: 2 additions & 1 deletion src/3d/qgsabstractmaterialsettings.h
Expand Up @@ -118,7 +118,8 @@ class _3D_EXPORT QgsAbstractMaterialSettings SIP_ABSTRACT
/*
* Returns the parameters to be exported to .mtl file
*/
virtual QMap<QString, QString> toExportParameters() const = 0;
virtual QMap<QString, QString> toExportParameters() const = 0 SIP_FACTORY;

/**
* Adds parameters from the material to a destination \a effect.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/3d/qgsphongmaterialsettings.cpp
Expand Up @@ -143,7 +143,8 @@ QgsLineMaterial *QgsPhongMaterialSettings::toLineMaterial( const QgsMaterialCont
return mat;
}

QMap<QString, QString> QgsPhongMaterialSettings::toExportParameters() const {
QMap<QString, QString> QgsPhongMaterialSettings::toExportParameters() const
{
QMap<QString, QString> parameters;
parameters[ QString( "Kd" ) ] = QStringLiteral( "%1 %2 %3" ).arg( mDiffuse.redF() ).arg( mDiffuse.greenF() ).arg( mDiffuse.blueF() );
parameters[ QString( "Ka" ) ] = QStringLiteral( "%1 %2 %3" ).arg( mAmbient.redF() ).arg( mAmbient.greenF() ).arg( mAmbient.blueF() );
Expand Down

0 comments on commit 860be14

Please sign in to comment.