Skip to content
Permalink
Browse files

Ensure that not all the settings are displayed when opening dialog

but only the skybox type's
Clean group boxes use
Rely on combobox index instead of (translated) text for settings
  • Loading branch information
DelazJ authored and nyalldawson committed Aug 21, 2020
1 parent 8bffc6b commit b743db7aceb78e9e8f164e1a42a5672e45ef1ef2
@@ -36,7 +36,7 @@ class QgsImageTexture;

/**
* \brief base class for all skybox types
* It holds the commun member data between different skybox entity types
* It holds the common member data between different skybox entity types
* \ingroup 3d
* \since QGIS 3.16
*/
@@ -26,7 +26,7 @@ void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteC
QString skyboxTypeStr = element.attribute( QStringLiteral( "skybox-type" ) );
if ( skyboxTypeStr == QStringLiteral( "Distinct Faces" ) )
mSkyboxType = QgsSkyboxEntity::DistinctTexturesSkybox;
else if ( skyboxTypeStr == QStringLiteral( "Panoramic texture" ) )
else if ( skyboxTypeStr == QStringLiteral( "Panoramic Texture" ) )
mSkyboxType = QgsSkyboxEntity::PanoramicSkybox;
mPanoramicTexturePath = pathResolver.readPath( element.attribute( QStringLiteral( "panoramic-texture-path" ) ) );
mCubeMapFacesPaths.clear();
@@ -46,7 +46,7 @@ void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContex
element.setAttribute( QStringLiteral( "skybox-type" ), QStringLiteral( "Distinct Faces" ) );
break;
case QgsSkyboxEntity::PanoramicSkybox:
element.setAttribute( QStringLiteral( "skybox-type" ), QStringLiteral( "Panoramic texture" ) );
element.setAttribute( QStringLiteral( "skybox-type" ), QStringLiteral( "Panoramic Texture" ) );
break;
}

@@ -25,38 +25,23 @@ QgsSkyboxRenderingSettingsWidget::QgsSkyboxRenderingSettingsWidget( QWidget *par
{
setupUi( this );

layoutGroupBoxes.push_back( panoramicTextureGroupBox );
layoutGroupBoxes.push_back( faceTexturesGroupBox );

// To future maintainers: make sure the order of added items is the same as the order at QgsSkyboxEntity::SkyboxType
skyboxTypeComboBox->addItem( tr( "Panoramic texture" ) );
skyboxTypeComboBox->addItem( tr( "Panoramic Texture" ) );
skyboxTypeComboBox->addItem( tr( "Distinct Faces" ) );
connect( skyboxTypeComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), [&]( int index )
{
for ( QGroupBox *groupBox : layoutGroupBoxes )
groupBox->setVisible( false );
switch ( index )
{
case 0: // Panoramic texture
panoramicTextureGroupBox->setVisible( true );
break;
case 1: // Distinct Faces
faceTexturesGroupBox->setVisible( true );
break;
}
} );
skyboxTypeComboBox->setCurrentIndex( 0 );
connect( skyboxTypeComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), this, &QgsSkyboxRenderingSettingsWidget::showSkyboxSettings );

showSkyboxSettings( 0 );
}

void QgsSkyboxRenderingSettingsWidget::setSkyboxSettings( const QgsSkyboxSettings &skyboxSettings )
{
switch ( skyboxSettings.skyboxType() )
{
case QgsSkyboxEntity::PanoramicSkybox:
skyboxTypeComboBox->setCurrentText( tr( "Panoramic texture" ) );
skyboxTypeComboBox->setCurrentIndex( 0 ); // "Panoramic Texture"
break;
case QgsSkyboxEntity::DistinctTexturesSkybox:
skyboxTypeComboBox->setCurrentText( tr( "Distinct Faces" ) );
skyboxTypeComboBox->setCurrentIndex( 1 ); // "Distinct Faces"
break;
}

@@ -83,3 +68,27 @@ QgsSkyboxSettings QgsSkyboxRenderingSettingsWidget::toSkyboxSettings()
settings.setCubeMapFace( QStringLiteral( "negZ" ), negZImageSource->source() );
return settings;
}

void QgsSkyboxRenderingSettingsWidget::showSkyboxSettings( int )
{
QgsSkyboxEntity::SkyboxType type = static_cast< QgsSkyboxEntity::SkyboxType >( skyboxTypeComboBox->currentIndex() );
const bool isPanoramic = type == QgsSkyboxEntity::PanoramicSkybox;
const bool isDistinctFaces = type == QgsSkyboxEntity::DistinctTexturesSkybox;

panoramicTextureLabel->setVisible( isPanoramic );
panoramicTextureImageSource->setVisible( isPanoramic );

negXImageSourceLabel->setVisible( isDistinctFaces );
negXImageSource->setVisible( isDistinctFaces );
negYImageSourceLabel->setVisible( isDistinctFaces );
negYImageSource->setVisible( isDistinctFaces );
negZImageSourceLabel->setVisible( isDistinctFaces );
negZImageSource->setVisible( isDistinctFaces );
posXImageSourceLabel->setVisible( isDistinctFaces );
posXImageSource->setVisible( isDistinctFaces );
posYImageSourceLabel->setVisible( isDistinctFaces );
posYImageSource->setVisible( isDistinctFaces );
posZImageSourceLabel->setVisible( isDistinctFaces );
posZImageSource->setVisible( isDistinctFaces );

}
@@ -33,8 +33,9 @@ class QgsSkyboxRenderingSettingsWidget : public QWidget, private Ui::SkyboxRende
//! Returns the skybox settings from the widget UI
QgsSkyboxSettings toSkyboxSettings();

private:
QVector<QGroupBox *> layoutGroupBoxes;
private slots:
//! Shows settings of the enabled skybox type
void showSkyboxSettings( int index );
};

#endif // SKYBOXRENDERINGSETTINGSWIDGET_H

0 comments on commit b743db7

Please sign in to comment.
You can’t perform that action at this time.