Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[3d] Rework texture scale widget to show scale in %, as the raw Qt
texture scale values work opposite to what you'd expect and a larger
scaling value actually results in a smaller texture size!
  • Loading branch information
nyalldawson committed Aug 4, 2020
1 parent 56535cb commit f410b9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/app/3d/qgsphongtexturedmaterialwidget.cpp
Expand Up @@ -25,7 +25,7 @@ QgsPhongTexturedMaterialWidget::QgsPhongTexturedMaterialWidget( QWidget *parent

QgsPhongTexturedMaterialSettings defaultMaterial;
setSettings( &defaultMaterial, nullptr );
textureScaleSpinBox->setClearValue( 0 );
textureScaleSpinBox->setClearValue( 100 );
textureRotationSpinBox->setClearValue( 0 );

connect( btnAmbient, &QgsColorButton::colorChanged, this, &QgsPhongTexturedMaterialWidget::changed );
Expand All @@ -50,7 +50,7 @@ void QgsPhongTexturedMaterialWidget::setSettings( const QgsAbstractMaterialSetti
btnSpecular->setColor( phongMaterial->specular() );
spinShininess->setValue( phongMaterial->shininess() );
textureFile->setSource( phongMaterial->diffuseTexturePath() );
textureScaleSpinBox->setValue( phongMaterial->textureScale() );
textureScaleSpinBox->setValue( 100.0 / phongMaterial->textureScale() );
textureRotationSpinBox->setValue( phongMaterial->textureRotation() );
}

Expand All @@ -61,7 +61,7 @@ QgsAbstractMaterialSettings *QgsPhongTexturedMaterialWidget::settings()
m->setSpecular( btnSpecular->color() );
m->setShininess( spinShininess->value() );
m->setDiffuseTexturePath( textureFile->source() );
m->setTextureScale( textureScaleSpinBox->value() );
m->setTextureScale( 100.0 / textureScaleSpinBox->value() );
m->setTextureRotation( textureRotationSpinBox->value() );
return m.release();
}
Expand Down
17 changes: 10 additions & 7 deletions src/ui/3d/phongtexturedmaterialwidgetbase.ui
Expand Up @@ -69,17 +69,20 @@
</item>
<item row="4" column="1">
<widget class="QgsDoubleSpinBox" name="textureScaleSpinBox">
<property name="suffix">
<string> %</string>
</property>
<property name="minimum">
<double>0.010000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
<double>100000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
<double>100.000000000000000</double>
</property>
</widget>
</item>
Expand Down Expand Up @@ -133,17 +136,17 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsColorButton</class>
<extends>QToolButton</extends>
<header>qgscolorbutton.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsImageSourceLineEdit</class>
<extends>QWidget</extends>
Expand Down

0 comments on commit f410b9c

Please sign in to comment.