Skip to content

Commit

Permalink
[feature] Allow 3d material texture files to be embedded in style/pro…
Browse files Browse the repository at this point in the history
…ject

Users can opt to embed images into the project to avoid placing dependancies
on external resources
  • Loading branch information
nyalldawson committed Jul 10, 2020
1 parent 3d1b819 commit 1bbf43d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 3 additions & 6 deletions src/app/3d/qgsphongmaterialwidget.cpp
Expand Up @@ -24,9 +24,6 @@ QgsPhongMaterialWidget::QgsPhongMaterialWidget( QWidget *parent )
setupUi( this );

setMaterial( QgsPhongMaterialSettings() );

textureFile->setFilter( "Images (*.png *.xpm *.jpg *.jpeg *.bmp)" );

textureScaleSpinBox->setClearValue( 0 );
textureRotationSpinBox->setClearValue( 0 );

Expand All @@ -35,7 +32,7 @@ QgsPhongMaterialWidget::QgsPhongMaterialWidget( QWidget *parent )
connect( btnSpecular, &QgsColorButton::colorChanged, this, &QgsPhongMaterialWidget::changed );
connect( spinShininess, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPhongMaterialWidget::changed );
connect( useDiffuseCheckBox, &QCheckBox::stateChanged, this, &QgsPhongMaterialWidget::changed );
connect( textureFile, &QgsFileWidget::fileChanged, this, &QgsPhongMaterialWidget::changed );
connect( textureFile, &QgsImageSourceLineEdit::sourceChanged, this, &QgsPhongMaterialWidget::changed );
connect( textureScaleSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPhongMaterialWidget::changed );
connect( textureRotationSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPhongMaterialWidget::changed );
this->activateTexturingUI( false );
Expand All @@ -59,7 +56,7 @@ void QgsPhongMaterialWidget::setMaterial( const QgsPhongMaterialSettings &materi
btnSpecular->setColor( material.specular() );
spinShininess->setValue( material.shininess() );
useDiffuseCheckBox->setCheckState( material.diffuseTextureEnabled() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked );
textureFile->setFilePath( material.texturePath() );
textureFile->setSource( material.texturePath() );
textureScaleSpinBox->setValue( material.textureScale() );
textureRotationSpinBox->setValue( material.textureRotation() );
}
Expand All @@ -72,7 +69,7 @@ QgsPhongMaterialSettings QgsPhongMaterialWidget::material() const
m.setSpecular( btnSpecular->color() );
m.setShininess( spinShininess->value() );
m.setDiffuseTextureEnabled( useDiffuseCheckBox->checkState() == Qt::CheckState::Checked );
m.setTexturePath( textureFile->filePath() );
m.setTexturePath( textureFile->source() );
m.setTextureScale( textureScaleSpinBox->value() );
m.setTextureRotation( textureRotationSpinBox->value() );
return m;
Expand Down
6 changes: 3 additions & 3 deletions src/ui/3d/phongmaterialwidget.ui
Expand Up @@ -108,7 +108,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QgsFileWidget" name="textureFile" native="true"/>
<widget class="QgsImageSourceLineEdit" name="textureFile" native="true"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lblTextureScale">
Expand Down Expand Up @@ -171,9 +171,9 @@
<container>1</container>
</customwidget>
<customwidget>
<class>QgsFileWidget</class>
<class>QgsImageSourceLineEdit</class>
<extends>QWidget</extends>
<header>qgsfilewidget.h</header>
<header>qgsfilecontentsourcelineedit.h</header>
<container>1</container>
</customwidget>
</customwidgets>
Expand Down

0 comments on commit 1bbf43d

Please sign in to comment.