From e069dfe9cc660c8462362a0f2325167895594375 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 4 Aug 2020 09:03:31 +0200 Subject: [PATCH] #5961 Color Legend : Creation custom color legend only when required --- .../RicImportFormationNamesFeature.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp index 6befbd4463..0de007ebf3 100644 --- a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp +++ b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp @@ -66,7 +66,22 @@ RimFormationNames* RicImportFormationNamesFeature::importFormationFiles( const Q for ( int i = 0; i < fileNames.size(); i++ ) { - RicImportFormationNamesFeature::addCustomColorLegend( QFileInfo( fileNames[i] ).baseName(), formationNames[i] ); + auto colors = formationNames[i]->formationNamesData()->formationColors(); + + bool anyValidColor = false; + for ( const auto& color : colors ) + { + if ( color.isValid() ) + { + anyValidColor = true; + break; + } + } + + if ( anyValidColor ) + { + RicImportFormationNamesFeature::addCustomColorLegend( QFileInfo( fileNames[i] ).baseName(), formationNames[i] ); + } } return formationNames.back(); @@ -82,7 +97,7 @@ bool RicImportFormationNamesFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- /// If only one formation file is imported, the formation will automatically be set in the active -/// view’s case. Import of LYR files with colors create custom color legends according to color +/// view�s case. Import of LYR files with colors create custom color legends according to color /// definition on each file. However, color legend must be set by the user. //-------------------------------------------------------------------------------------------------- void RicImportFormationNamesFeature::onActionTriggered( bool isChecked )