#6040 Facies import: use limestone color for calcite.

This commit is contained in:
Kristian Bendiksen 2020-09-02 13:47:55 +02:00
parent ed6b96777d
commit 304e370747
2 changed files with 27 additions and 4 deletions

View File

@ -91,7 +91,8 @@ void RicImportFaciesFeature::onActionTriggered( bool isChecked )
// Try to find a color from the rock type color legend by fuzzy matching names
cvf::Color3f color;
if ( !matchByName( it.second, rockTypeColorLegend, color ) )
if ( !predefinedColorMatch( it.second, rockTypeColorLegend, color ) &&
!matchByName( it.second, rockTypeColorLegend, color ) )
{
// No match use a random color
color = colorTable.cycledColor3f( it.first );
@ -118,7 +119,7 @@ void RicImportFaciesFeature::setupActionLook( QAction* actionToSetup )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicImportFaciesFeature::matchByName( const QString name, RimColorLegend* colorLegend, cvf::Color3f& color )
bool RicImportFaciesFeature::matchByName( const QString& name, RimColorLegend* colorLegend, cvf::Color3f& color )
{
// No match if color legend does not exist
if ( !colorLegend ) return false;
@ -167,3 +168,24 @@ int RicImportFaciesFeature::computeEditDistance( const QString& a, const QString
return RiaStdStringTools::computeEditDistance( aSimplified.toStdString(), bSimplified.toStdString() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicImportFaciesFeature::predefinedColorMatch( const QString& name, RimColorLegend* colorLegend, cvf::Color3f& color )
{
// Calcite should use limestone color
if ( name.toLower().trimmed() == QString( "calcite" ) )
{
for ( auto i : colorLegend->colorLegendItems() )
{
if ( i->categoryName() == QString( "Limestone" ) )
{
color = i->color();
return true;
}
}
}
return false;
}

View File

@ -39,6 +39,7 @@ protected:
void setupActionLook( QAction* actionToSetup ) override;
private:
int computeEditDistance( const QString& a, const QString& b );
bool matchByName( const QString name, RimColorLegend* colorLegend, cvf::Color3f& color );
static int computeEditDistance( const QString& a, const QString& b );
static bool matchByName( const QString& name, RimColorLegend* colorLegend, cvf::Color3f& color );
static bool predefinedColorMatch( const QString& name, RimColorLegend* colorLegend, cvf::Color3f& color );
};