mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 06:55:56 -06:00
#6495 Fracture Model: add facies properties.
This commit is contained in:
parent
b262cc02dc
commit
d70f82c251
@ -64,6 +64,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicReloadWellMeasurementsFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellMeasurementImportTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportElasticPropertiesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicElasticPropertiesImportTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicFaciesPropertiesImportTools.h
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.h
|
||||
|
||||
@ -159,6 +160,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicReloadWellMeasurementsFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellMeasurementImportTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportElasticPropertiesFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicElasticPropertiesImportTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicFaciesPropertiesImportTools.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.cpp
|
||||
|
||||
|
179
ApplicationCode/Commands/RicFaciesPropertiesImportTools.cpp
Normal file
179
ApplicationCode/Commands/RicFaciesPropertiesImportTools.cpp
Normal file
@ -0,0 +1,179 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicFaciesPropertiesImportTools.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaFractureDefines.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaStdStringTools.h"
|
||||
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimColorLegendCollection.h"
|
||||
#include "RimColorLegendItem.h"
|
||||
#include "RimFaciesProperties.h"
|
||||
#include "RimFractureModel.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RifColorLegendData.h"
|
||||
#include "RifRoffReader.h"
|
||||
|
||||
#include "cafColorTable.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicFaciesPropertiesImportTools::importFaciesPropertiesFromFile( const QString& filePath,
|
||||
RimFractureModel* fractureModel,
|
||||
bool createColorLegend )
|
||||
{
|
||||
if ( filePath.isEmpty() ) return;
|
||||
|
||||
std::map<int, QString> codeNames;
|
||||
try
|
||||
{
|
||||
RifRoffReader::readCodeNames( filePath, codeNames );
|
||||
}
|
||||
catch ( RifRoffReaderException& ex )
|
||||
{
|
||||
RiaLogging::error( QString::fromStdString( ex.message ) );
|
||||
return;
|
||||
}
|
||||
|
||||
RimFaciesProperties* faciesProperties = fractureModel->faciesProperties();
|
||||
if ( !faciesProperties )
|
||||
{
|
||||
faciesProperties = new RimFaciesProperties;
|
||||
}
|
||||
|
||||
for ( auto it : codeNames )
|
||||
{
|
||||
faciesProperties->setFaciesCodeName( it.first, it.second );
|
||||
}
|
||||
|
||||
if ( createColorLegend )
|
||||
{
|
||||
const caf::ColorTable& colorTable = RiaColorTables::contrastCategoryPaletteColors();
|
||||
RimColorLegendCollection* colorLegendCollection = RimProject::current()->colorLegendCollection;
|
||||
RimColorLegend* rockTypeColorLegend = colorLegendCollection->findByName( RiaDefines::rockTypeColorLegendName() );
|
||||
|
||||
RimColorLegend* colorLegend = new RimColorLegend;
|
||||
colorLegend->setColorLegendName( RiaDefines::faciesColorLegendName() );
|
||||
|
||||
for ( auto it : codeNames )
|
||||
{
|
||||
RimColorLegendItem* colorLegendItem = new RimColorLegendItem;
|
||||
|
||||
// Try to find a color from the rock type color legend by fuzzy matching names
|
||||
cvf::Color3f color;
|
||||
if ( !predefinedColorMatch( it.second, rockTypeColorLegend, color ) &&
|
||||
!matchByName( it.second, rockTypeColorLegend, color ) )
|
||||
{
|
||||
// No match use a random color
|
||||
color = colorTable.cycledColor3f( it.first );
|
||||
}
|
||||
|
||||
colorLegendItem->setValues( it.second, it.first, color );
|
||||
colorLegend->appendColorLegendItem( colorLegendItem );
|
||||
}
|
||||
|
||||
colorLegendCollection->appendCustomColorLegend( colorLegend );
|
||||
colorLegendCollection->updateConnectedEditors();
|
||||
}
|
||||
|
||||
faciesProperties->setFilePath( filePath );
|
||||
|
||||
fractureModel->setFaciesProperties( faciesProperties );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicFaciesPropertiesImportTools::matchByName( const QString& name, RimColorLegend* colorLegend, cvf::Color3f& color )
|
||||
{
|
||||
// No match if color legend does not exist
|
||||
if ( !colorLegend ) return false;
|
||||
|
||||
// Find the best matching name from the legend
|
||||
int bestScore = std::numeric_limits<int>::max();
|
||||
RimColorLegendItem* bestItem = nullptr;
|
||||
for ( RimColorLegendItem* item : colorLegend->colorLegendItems() )
|
||||
{
|
||||
int score = computeEditDistance( name, item->categoryName() );
|
||||
if ( score < bestScore )
|
||||
{
|
||||
bestScore = score;
|
||||
bestItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
// Allow only small difference when determining if something matches
|
||||
const int maximumScoreToMatch = 1;
|
||||
if ( bestScore <= maximumScoreToMatch )
|
||||
{
|
||||
color = bestItem->color();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RicFaciesPropertiesImportTools::computeEditDistance( const QString& a, const QString& b )
|
||||
{
|
||||
// Remove common words from the domain which does not help in the matching
|
||||
std::vector<QString> stopWords = {"rocks", "rock", "stones", "stone"};
|
||||
QString aSimplified = a.toLower();
|
||||
QString bSimplified = b.toLower();
|
||||
for ( auto r : stopWords )
|
||||
{
|
||||
aSimplified.remove( r );
|
||||
bSimplified.remove( r );
|
||||
}
|
||||
|
||||
aSimplified = aSimplified.trimmed();
|
||||
bSimplified = bSimplified.trimmed();
|
||||
|
||||
return RiaStdStringTools::computeEditDistance( aSimplified.toStdString(), bSimplified.toStdString() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicFaciesPropertiesImportTools::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;
|
||||
}
|
45
ApplicationCode/Commands/RicFaciesPropertiesImportTools.h
Normal file
45
ApplicationCode/Commands/RicFaciesPropertiesImportTools.h
Normal file
@ -0,0 +1,45 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
class RimColorLegend;
|
||||
class RimFractureModel;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class Color3f;
|
||||
}
|
||||
|
||||
class QString;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicFaciesPropertiesImportTools
|
||||
{
|
||||
public:
|
||||
static void importFaciesPropertiesFromFile( const QString& filePath,
|
||||
RimFractureModel* fractureModel,
|
||||
bool createColorLegend = false );
|
||||
|
||||
private:
|
||||
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 );
|
||||
};
|
@ -19,23 +19,15 @@
|
||||
#include "RicImportFaciesFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaFractureDefines.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaStdStringTools.h"
|
||||
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimColorLegendCollection.h"
|
||||
#include "RimColorLegendItem.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RifColorLegendData.h"
|
||||
#include "RifRoffReader.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "RiuFileDialogTools.h"
|
||||
|
||||
#include "cafColorTable.h"
|
||||
#include "RicFaciesPropertiesImportTools.h"
|
||||
|
||||
#include "RimFractureModel.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
@ -55,6 +47,9 @@ bool RicImportFaciesFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportFaciesFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimFractureModel* fractureModel = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimFractureModel>();
|
||||
if ( !fractureModel ) return;
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString defaultDir = app->lastUsedDialogDirectoryWithFallbackToProjectFolder( "STIMPLAN_DIR" );
|
||||
|
||||
@ -70,43 +65,8 @@ void RicImportFaciesFeature::onActionTriggered( bool isChecked )
|
||||
// Remember the path to next time
|
||||
app->setLastUsedDialogDirectory( "STIMPLAN_DIR", QFileInfo( fileName ).absolutePath() );
|
||||
|
||||
std::map<int, QString> codeNames;
|
||||
try
|
||||
{
|
||||
RifRoffReader::readCodeNames( fileName, codeNames );
|
||||
}
|
||||
catch ( RifRoffReaderException& ex )
|
||||
{
|
||||
RiaLogging::error( QString::fromStdString( ex.message ) );
|
||||
return;
|
||||
}
|
||||
|
||||
const caf::ColorTable& colorTable = RiaColorTables::contrastCategoryPaletteColors();
|
||||
RimColorLegendCollection* colorLegendCollection = RimProject::current()->colorLegendCollection;
|
||||
RimColorLegend* rockTypeColorLegend = colorLegendCollection->findByName( RiaDefines::rockTypeColorLegendName() );
|
||||
|
||||
RimColorLegend* colorLegend = new RimColorLegend;
|
||||
colorLegend->setColorLegendName( RiaDefines::faciesColorLegendName() );
|
||||
|
||||
for ( auto it : codeNames )
|
||||
{
|
||||
RimColorLegendItem* colorLegendItem = new RimColorLegendItem;
|
||||
|
||||
// Try to find a color from the rock type color legend by fuzzy matching names
|
||||
cvf::Color3f color;
|
||||
if ( !predefinedColorMatch( it.second, rockTypeColorLegend, color ) &&
|
||||
!matchByName( it.second, rockTypeColorLegend, color ) )
|
||||
{
|
||||
// No match use a random color
|
||||
color = colorTable.cycledColor3f( it.first );
|
||||
}
|
||||
|
||||
colorLegendItem->setValues( it.second, it.first, color );
|
||||
colorLegend->appendColorLegendItem( colorLegendItem );
|
||||
}
|
||||
|
||||
colorLegendCollection->appendCustomColorLegend( colorLegend );
|
||||
colorLegendCollection->updateConnectedEditors();
|
||||
bool createColorLegend = true;
|
||||
RicFaciesPropertiesImportTools::importFaciesPropertiesFromFile( fileName, fractureModel, createColorLegend );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -118,77 +78,3 @@ void RicImportFaciesFeature::setupActionLook( QAction* actionToSetup )
|
||||
// actionToSetup->setIcon( QIcon( ":/Formations16x16.png" ) );
|
||||
actionToSetup->setText( "Import Facies" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicImportFaciesFeature::matchByName( const QString& name, RimColorLegend* colorLegend, cvf::Color3f& color )
|
||||
{
|
||||
// No match if color legend does not exist
|
||||
if ( !colorLegend ) return false;
|
||||
|
||||
// Find the best matching name from the legend
|
||||
int bestScore = std::numeric_limits<int>::max();
|
||||
RimColorLegendItem* bestItem = nullptr;
|
||||
for ( RimColorLegendItem* item : colorLegend->colorLegendItems() )
|
||||
{
|
||||
int score = computeEditDistance( name, item->categoryName() );
|
||||
if ( score < bestScore )
|
||||
{
|
||||
bestScore = score;
|
||||
bestItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
// Allow only small difference when determining if something matches
|
||||
const int maximumScoreToMatch = 1;
|
||||
if ( bestScore <= maximumScoreToMatch )
|
||||
{
|
||||
color = bestItem->color();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RicImportFaciesFeature::computeEditDistance( const QString& a, const QString& b )
|
||||
{
|
||||
// Remove common words from the domain which does not help in the matching
|
||||
std::vector<QString> stopWords = {"rocks", "rock", "stones", "stone"};
|
||||
QString aSimplified = a.toLower();
|
||||
QString bSimplified = b.toLower();
|
||||
for ( auto r : stopWords )
|
||||
{
|
||||
aSimplified.remove( r );
|
||||
bSimplified.remove( r );
|
||||
}
|
||||
|
||||
aSimplified = aSimplified.trimmed();
|
||||
bSimplified = bSimplified.trimmed();
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -166,6 +166,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimLayerCurve.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFractureModelStressCurve.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimAbstractPlotCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFractureModelPropertyCurve.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFaciesProperties.h
|
||||
)
|
||||
|
||||
|
||||
@ -334,6 +335,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimElasticProperties.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimElasticPropertiesCurve.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimLayerCurve.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFractureModelStressCurve.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFaciesProperties.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimElasticProperties.h"
|
||||
#include "RimEllipseFractureTemplate.h"
|
||||
#include "RimFaciesProperties.h"
|
||||
#include "RimFractureModelPlot.h"
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RimOilField.h"
|
||||
@ -68,7 +70,7 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimFractureModel, "RimFractureModel" );
|
||||
CAF_PDM_SOURCE_INIT( RimFractureModel, "RimFractureModel" );
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@ -249,6 +251,9 @@ RimFractureModel::RimFractureModel()
|
||||
m_elasticProperties.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_barrierAnnotation, "BarrierAnnotation", "Barrier Annotation", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_faciesProperties, "FaciesProperties", "Facies Properties", "", "", "" );
|
||||
m_faciesProperties.uiCapability()->setUiHidden( true );
|
||||
m_faciesProperties.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
setDeletable( true );
|
||||
}
|
||||
@ -957,6 +962,22 @@ void RimFractureModel::setElasticProperties( RimElasticProperties* elasticProper
|
||||
m_elasticProperties = elasticProperties;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFaciesProperties* RimFractureModel::faciesProperties() const
|
||||
{
|
||||
return m_faciesProperties;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFractureModel::setFaciesProperties( RimFaciesProperties* faciesProperties )
|
||||
{
|
||||
m_faciesProperties = faciesProperties;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -966,6 +987,11 @@ void RimFractureModel::loadDataAndUpdate()
|
||||
{
|
||||
m_elasticProperties->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
if ( m_faciesProperties )
|
||||
{
|
||||
m_faciesProperties->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1119,9 +1145,9 @@ double RimFractureModel::getDefaultValueForProperty( RiaDefines::CurveProperty c
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimFractureModel::hasDefaultValueForProperty( RiaDefines::CurveProperty curveProperty ) const
|
||||
{
|
||||
auto withDefaults = {RiaDefines::CurveProperty::RELATIVE_PERMEABILITY_FACTOR,
|
||||
RiaDefines::CurveProperty::PORO_ELASTIC_CONSTANT,
|
||||
RiaDefines::CurveProperty::THERMAL_EXPANSION_COEFFICIENT};
|
||||
auto withDefaults = { RiaDefines::CurveProperty::RELATIVE_PERMEABILITY_FACTOR,
|
||||
RiaDefines::CurveProperty::PORO_ELASTIC_CONSTANT,
|
||||
RiaDefines::CurveProperty::THERMAL_EXPANSION_COEFFICIENT };
|
||||
return std::find( withDefaults.begin(), withDefaults.end(), curveProperty ) != withDefaults.end();
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ class RimElasticProperties;
|
||||
class RigEclipseCaseData;
|
||||
class RimAnnotationCollection;
|
||||
class RimUserDefinedPolylinesAnnotation;
|
||||
class RimFaciesProperties;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -136,6 +137,9 @@ public:
|
||||
double getOverburdenGradient( const QString& keyword ) const;
|
||||
double getUnderburdenGradient( const QString& keyword ) const;
|
||||
|
||||
void setFaciesProperties( RimFaciesProperties* faciesProperties );
|
||||
RimFaciesProperties* faciesProperties() const;
|
||||
|
||||
void updateReferringPlots();
|
||||
|
||||
protected:
|
||||
@ -183,6 +187,7 @@ protected:
|
||||
caf::PdmField<double> m_boundingBoxHorizontal;
|
||||
caf::PdmPtrField<RimModeledWellPath*> m_thicknessDirectionWellPath;
|
||||
caf::PdmChildField<RimElasticProperties*> m_elasticProperties;
|
||||
caf::PdmChildField<RimFaciesProperties*> m_faciesProperties;
|
||||
caf::PdmField<double> m_defaultPorosity;
|
||||
caf::PdmField<double> m_defaultPermeability;
|
||||
caf::PdmField<double> m_verticalStress;
|
||||
|
172
ApplicationCode/ProjectDataModel/RimFaciesProperties.cpp
Normal file
172
ApplicationCode/ProjectDataModel/RimFaciesProperties.cpp
Normal file
@ -0,0 +1,172 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimFaciesProperties.h"
|
||||
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimEclipseResultDefinition.h"
|
||||
#include "RimFractureModel.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
|
||||
#include "RicFaciesPropertiesImportTools.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
#include "cafPdmObjectScriptingCapability.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiTextEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimFaciesProperties, "FaciesProperties" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFaciesProperties::RimFaciesProperties()
|
||||
{
|
||||
CAF_PDM_InitScriptableObject( "RimFaciesProperties", "", "", "" );
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "File Path", "", "", "" );
|
||||
m_filePath.uiCapability()->setUiReadOnly( true );
|
||||
m_filePath.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_propertiesTable, "PropertiesTable", "Properties Table", "", "", "" );
|
||||
m_propertiesTable.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() );
|
||||
m_propertiesTable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
m_propertiesTable.uiCapability()->setUiReadOnly( true );
|
||||
m_propertiesTable.xmlCapability()->disableIO();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_faciesDefinition, "FaciesDefinition", "", "", "", "" );
|
||||
m_faciesDefinition.uiCapability()->setUiHidden( true );
|
||||
m_faciesDefinition.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
m_faciesDefinition = new RimEclipseResultDefinition;
|
||||
m_faciesDefinition->findField( "MResultType" )->uiCapability()->setUiName( "Facies Definiton" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_colorLegend, "ColorLegend", "Colors", "", "", "" );
|
||||
m_colorLegend = RimRegularLegendConfig::mapToColorLegend( RimRegularLegendConfig::ColorRangesType::NORMAL );
|
||||
|
||||
setUiName( "Facies Properties" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFaciesProperties::~RimFaciesProperties()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFaciesProperties::filePath() const
|
||||
{
|
||||
return m_filePath.v().path();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFaciesProperties::setFilePath( const QString& filePath )
|
||||
{
|
||||
m_filePath = filePath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFaciesProperties::setFaciesCodeName( int code, const QString& name )
|
||||
{
|
||||
m_faciesCodeNames[code] = name;
|
||||
m_propertiesTable = generatePropertiesTable();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFaciesProperties::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( &m_filePath );
|
||||
uiOrdering.add( &m_propertiesTable );
|
||||
uiOrdering.add( &m_colorLegend );
|
||||
|
||||
caf::PdmUiGroup* faciesDefinitionGroup = uiOrdering.addNewGroup( "Facies Definition" );
|
||||
m_faciesDefinition->uiOrdering( uiConfigName, *faciesDefinitionGroup );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFaciesProperties::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
if ( field == &m_propertiesTable )
|
||||
{
|
||||
auto myAttr = dynamic_cast<caf::PdmUiTextEditorAttribute*>( attribute );
|
||||
if ( myAttr )
|
||||
{
|
||||
myAttr->wrapMode = caf::PdmUiTextEditorAttribute::NoWrap;
|
||||
myAttr->textMode = caf::PdmUiTextEditorAttribute::HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFaciesProperties::generatePropertiesTable()
|
||||
{
|
||||
QString header( "<table border=1>"
|
||||
" <thead>"
|
||||
" <tr bgcolor=lightblue>"
|
||||
" <th>Name</th>"
|
||||
" <th>Index</th>"
|
||||
" </tr>"
|
||||
" </thead>"
|
||||
" <tbody>" );
|
||||
|
||||
QString body;
|
||||
for ( auto prop : m_faciesCodeNames )
|
||||
{
|
||||
int index = prop.first;
|
||||
const QString& name = prop.second;
|
||||
|
||||
QString format( "<tr>"
|
||||
" <td>%1</td>"
|
||||
" <td>%2</td>"
|
||||
"</tr>" );
|
||||
|
||||
QString line = format.arg( name ).arg( index );
|
||||
body.append( line );
|
||||
}
|
||||
|
||||
QString footer( "</tbody></table>" );
|
||||
|
||||
return header + body + footer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFaciesProperties::loadDataAndUpdate()
|
||||
{
|
||||
if ( !m_filePath().path().isEmpty() )
|
||||
{
|
||||
RimFractureModel* fractureModel;
|
||||
firstAncestorOrThisOfType( fractureModel );
|
||||
RicFaciesPropertiesImportTools::importFaciesPropertiesFromFile( m_filePath().path(), fractureModel );
|
||||
}
|
||||
}
|
65
ApplicationCode/ProjectDataModel/RimFaciesProperties.h
Normal file
65
ApplicationCode/ProjectDataModel/RimFaciesProperties.h
Normal file
@ -0,0 +1,65 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafFilePath.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class RimEclipseResultDefinition;
|
||||
class RimColorLegend;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimFaciesProperties : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimFaciesProperties();
|
||||
~RimFaciesProperties() override;
|
||||
|
||||
QString filePath() const;
|
||||
void setFilePath( const QString& filePath );
|
||||
|
||||
void setFaciesCodeName( int code, const QString& name );
|
||||
|
||||
void loadDataAndUpdate();
|
||||
|
||||
protected:
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
|
||||
|
||||
private:
|
||||
QString generatePropertiesTable();
|
||||
|
||||
caf::PdmField<caf::FilePath> m_filePath;
|
||||
caf::PdmField<QString> m_propertiesTable;
|
||||
caf::PdmChildField<RimEclipseResultDefinition*> m_faciesDefinition;
|
||||
caf::PdmPtrField<RimColorLegend*> m_colorLegend;
|
||||
|
||||
std::map<int, QString> m_faciesCodeNames;
|
||||
};
|
Loading…
Reference in New Issue
Block a user