#6597 Add pdm objects and context menu for elastic property scaling.

This commit is contained in:
Kristian Bendiksen 2020-10-01 15:30:34 +02:00
parent 825a9bb531
commit 7c555658ec
11 changed files with 460 additions and 2 deletions

View File

@ -15,6 +15,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewFractureModelFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureModelAtPosFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewFractureModelTemplateFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewElasticPropertyScalingFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateMultipleFracturesFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateMultipleFracturesOptionItemUi.h
@ -39,6 +40,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewFractureModelFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureModelAtPosFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewFractureModelTemplateFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewElasticPropertyScalingFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateMultipleFracturesFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateMultipleFracturesOptionItemUi.cpp

View File

@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewElasticPropertyScalingFeature.h"
#include "RimElasticProperties.h"
#include "RimElasticPropertyScaling.h"
#include "RimElasticPropertyScalingCollection.h"
#include "Riu3DMainWindowTools.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewElasticPropertyScalingFeature, "RicNewElasticPropertyScalingFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewElasticPropertyScalingFeature::onActionTriggered( bool isChecked )
{
RimElasticProperties* elasticProperties =
caf::SelectionManager::instance()->selectedItemOfType<RimElasticProperties>();
if ( !elasticProperties ) return;
RimElasticPropertyScalingCollection* scalingColl = elasticProperties->scalingCollection();
if ( !scalingColl ) return;
RimElasticPropertyScaling* fractureModelTemplate = new RimElasticPropertyScaling;
scalingColl->addElasticPropertyScaling( fractureModelTemplate );
scalingColl->updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem( fractureModelTemplate );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewElasticPropertyScalingFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Property Scaling" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewElasticPropertyScalingFeature::isCommandEnabled()
{
return true;
}

View File

@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicNewElasticPropertyScalingFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
bool isCommandEnabled() override;
};

View File

@ -161,6 +161,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimFractureModelPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimFractureModelPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimFractureModelCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimElasticProperties.h
${CMAKE_CURRENT_LIST_DIR}/RimElasticPropertyScaling.h
${CMAKE_CURRENT_LIST_DIR}/RimElasticPropertyScalingCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimElasticPropertiesCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimLayerCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimFractureModelStressCurve.h
@ -332,6 +334,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimFractureModelPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimFractureModelPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimFractureModelCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimElasticProperties.cpp
${CMAKE_CURRENT_LIST_DIR}/RimElasticPropertyScaling.cpp
${CMAKE_CURRENT_LIST_DIR}/RimElasticPropertyScalingCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimElasticPropertiesCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimLayerCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimFractureModelStressCurve.cpp

View File

@ -56,6 +56,7 @@
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseStatisticsCase.h"
#include "RimEclipseView.h"
#include "RimElasticProperties.h"
#include "RimEllipseFractureTemplate.h"
#include "RimEnsembleCurveFilterCollection.h"
#include "RimEnsembleCurveSet.h"
@ -929,6 +930,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "Separator";
menuBuilder << "RicConvertFractureTemplateUnitFeature";
}
else if ( dynamic_cast<RimElasticProperties*>( firstUiItem ) )
{
menuBuilder << "RicNewElasticPropertyScalingFeature";
}
else if ( dynamic_cast<RimSurfaceCollection*>( firstUiItem ) )
{
menuBuilder << "RicImportSurfacesFeature";

View File

@ -18,6 +18,7 @@
#include "RimElasticProperties.h"
#include "RimElasticPropertyScalingCollection.h"
#include "RimFractureModelTemplate.h"
#include "RicElasticPropertiesImportTools.h"
@ -46,6 +47,11 @@ RimElasticProperties::RimElasticProperties()
m_propertiesTable.uiCapability()->setUiReadOnly( true );
m_propertiesTable.xmlCapability()->disableIO();
CAF_PDM_InitScriptableFieldNoDefault( &m_scalings, "PropertyScalingCollection", "PropertyScalingCollection", "", "", "" );
m_scalings.uiCapability()->setUiHidden( true );
m_scalings.uiCapability()->setUiTreeHidden( true );
m_scalings = new RimElasticPropertyScalingCollection;
setUiName( "Elastic Properties" );
}
@ -218,3 +224,11 @@ void RimElasticProperties::loadDataAndUpdate()
RicElasticPropertiesImportTools::importElasticPropertiesFromFile( m_filePath().path(), fractureModelTemplate );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimElasticPropertyScalingCollection* RimElasticProperties::scalingCollection()
{
return m_scalings.value();
}

View File

@ -19,6 +19,7 @@
#pragma once
#include "cafFilePath.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
@ -28,6 +29,8 @@
#include <tuple>
class RimElasticPropertyScalingCollection;
typedef std::tuple<QString, QString, QString> FaciesKey;
//==================================================================================================
@ -50,6 +53,8 @@ public:
void loadDataAndUpdate();
RimElasticPropertyScalingCollection* scalingCollection();
protected:
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
@ -59,8 +64,9 @@ protected:
private:
QString generatePropertiesTable();
caf::PdmField<caf::FilePath> m_filePath;
caf::PdmField<QString> m_propertiesTable;
caf::PdmField<caf::FilePath> m_filePath;
caf::PdmField<QString> m_propertiesTable;
caf::PdmChildField<RimElasticPropertyScalingCollection*> m_scalings;
std::map<FaciesKey, RigElasticProperties> m_properties;
};

View File

@ -0,0 +1,140 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimElasticPropertyScaling.h"
#include "RigEclipseCaseData.h"
#include "RimColorLegend.h"
#include "RimColorLegendItem.h"
#include "RimEclipseCase.h"
#include "RimFaciesProperties.h"
#include "RimFractureModelTemplate.h"
#include "RimProject.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiTextEditor.h"
CAF_PDM_SOURCE_INIT( RimElasticPropertyScaling, "RimElasticPropertyScaling" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimElasticPropertyScaling::RimElasticPropertyScaling()
: changed( this )
{
CAF_PDM_InitScriptableObject( "RimElasticPropertyScaling", "", "", "" );
CAF_PDM_InitScriptableFieldNoDefault( &m_formation, "Formation", "Formation", "", "", "" );
CAF_PDM_InitScriptableFieldNoDefault( &m_facies, "Facies", "Facies", "", "", "" );
CAF_PDM_InitScriptableFieldNoDefault( &m_property, "Property", "Property", "", "", "" );
CAF_PDM_InitScriptableField( &m_scale, "Scale", 1.0, "Scale", "", "", "" );
setUiName( "Property Scaling" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimElasticPropertyScaling::~RimElasticPropertyScaling()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimElasticPropertyScaling::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_formation )
{
RigEclipseCaseData* eclipseCaseData = getEclipseCaseData();
if ( !eclipseCaseData ) return options;
std::vector<QString> formationNames = eclipseCaseData->formationNames();
for ( const QString& formationName : formationNames )
{
options.push_back( caf::PdmOptionItemInfo( formationName, formationName ) );
}
}
else if ( fieldNeedingOptions == &m_facies )
{
RimFractureModelTemplate* fractureModelTemplate;
firstAncestorOrThisOfType( fractureModelTemplate );
if ( !fractureModelTemplate ) return options;
RimFaciesProperties* faciesProperties = fractureModelTemplate->faciesProperties();
if ( !faciesProperties ) return options;
RimColorLegend* faciesColors = faciesProperties->colorLegend();
if ( !faciesColors ) return options;
for ( RimColorLegendItem* item : faciesColors->colorLegendItems() )
{
options.push_back( caf::PdmOptionItemInfo( item->categoryName(), item->categoryName() ) );
}
}
else if ( fieldNeedingOptions == &m_property )
{
std::vector<RiaDefines::CurveProperty> properties = {RiaDefines::CurveProperty::YOUNGS_MODULUS,
RiaDefines::CurveProperty::POISSONS_RATIO};
for ( auto property : properties )
{
options.push_back(
caf::PdmOptionItemInfo( caf::AppEnum<RiaDefines::CurveProperty>::uiText( property ), property ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimElasticPropertyScaling::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
changed.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RimElasticPropertyScaling::getEclipseCase()
{
// Find an eclipse case
RimProject* proj = RimProject::current();
if ( proj->eclipseCases().empty() ) return nullptr;
return proj->eclipseCases()[0];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEclipseCaseData* RimElasticPropertyScaling::getEclipseCaseData()
{
// Find an eclipse case
RimEclipseCase* eclipseCase = getEclipseCase();
if ( !eclipseCase ) return nullptr;
return eclipseCase->eclipseCaseData();
}

View File

@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmField.h"
#include "cafPdmObject.h"
#include "RiaFractureModelDefines.h"
#include <QString>
class RimEclipseCase;
class RigEclipseCaseData;
//==================================================================================================
///
//==================================================================================================
class RimElasticPropertyScaling : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimElasticPropertyScaling();
~RimElasticPropertyScaling() override;
caf::Signal<> changed;
protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
static RimEclipseCase* getEclipseCase();
static RigEclipseCaseData* getEclipseCaseData();
private:
caf::PdmField<QString> m_formation;
caf::PdmField<QString> m_facies;
caf::PdmField<caf::AppEnum<RiaDefines::CurveProperty>> m_property;
caf::PdmField<double> m_scale;
};

View File

@ -0,0 +1,81 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimElasticPropertyScalingCollection.h"
#include "RimElasticPropertyScaling.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObject.h"
#include "cafPdmObjectScriptingCapability.h"
CAF_PDM_SOURCE_INIT( RimElasticPropertyScalingCollection, "ElasticPropertyScalingCollection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimElasticPropertyScalingCollection::RimElasticPropertyScalingCollection()
{
CAF_PDM_InitScriptableObject( "Elastic Property Scalings", "", "", "" );
CAF_PDM_InitScriptableFieldNoDefault( &m_elasticPropertyScalings,
"ElasticPropertyScalings",
"Elastic Property Scalings",
"",
"",
"" );
m_elasticPropertyScalings.uiCapability()->setUiHidden( true );
m_elasticPropertyScalings.uiCapability()->setUiTreeHidden( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimElasticPropertyScalingCollection::~RimElasticPropertyScalingCollection()
{
m_elasticPropertyScalings.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimElasticPropertyScaling*> RimElasticPropertyScalingCollection::elasticPropertyScalings() const
{
std::vector<RimElasticPropertyScaling*> templates;
for ( auto& templ : m_elasticPropertyScalings )
{
templates.push_back( templ );
}
return templates;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimElasticPropertyScalingCollection::addElasticPropertyScaling( RimElasticPropertyScaling* templ )
{
m_elasticPropertyScalings.push_back( templ );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimElasticPropertyScalingCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects )
{
}

View File

@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
class RimElasticPropertyScaling;
//==================================================================================================
///
///
//==================================================================================================
class RimElasticPropertyScalingCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimElasticPropertyScalingCollection();
~RimElasticPropertyScalingCollection() override;
std::vector<RimElasticPropertyScaling*> elasticPropertyScalings() const;
void addElasticPropertyScaling( RimElasticPropertyScaling* templ );
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
private:
caf::PdmChildArrayField<RimElasticPropertyScaling*> m_elasticPropertyScalings;
};