diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index a3e838d946..da61be1501 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -169,6 +169,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimFractureModelStressCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimAbstractPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimFractureModelPropertyCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimFaciesProperties.h +${CMAKE_CURRENT_LIST_DIR}/RimNonNetLayers.h ) @@ -340,6 +341,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimElasticPropertiesCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimLayerCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimFractureModelStressCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimFaciesProperties.cpp +${CMAKE_CURRENT_LIST_DIR}/RimNonNetLayers.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureModelTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureModelTemplate.cpp index eabab4eb6b..cdfb86f958 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureModelTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureModelTemplate.cpp @@ -42,6 +42,7 @@ #include "RimEllipseFractureTemplate.h" #include "RimFaciesProperties.h" #include "RimFractureModelPlot.h" +#include "RimNonNetLayers.h" #include "RimOilField.h" #include "RimProject.h" #include "RimTools.h" @@ -164,6 +165,11 @@ RimFractureModelTemplate::RimFractureModelTemplate() m_faciesProperties.uiCapability()->setUiHidden( true ); m_faciesProperties.uiCapability()->setUiTreeHidden( true ); + CAF_PDM_InitScriptableFieldNoDefault( &m_nonNetLayers, "NonNetLayers", "Non-Net Layers", "", "", "" ); + m_nonNetLayers.uiCapability()->setUiHidden( true ); + m_nonNetLayers.uiCapability()->setUiTreeHidden( true ); + setNonNetLayers( new RimNonNetLayers ); + setDeletable( true ); } @@ -349,6 +355,36 @@ void RimFractureModelTemplate::setFaciesProperties( RimFaciesProperties* faciesP } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureModelTemplate::setNonNetLayers( RimNonNetLayers* nonNetLayers ) +{ + if ( m_nonNetLayers ) + { + m_nonNetLayers->changed.disconnect( this ); + } + + m_nonNetLayers = nonNetLayers; + + if ( m_nonNetLayers ) + { + m_nonNetLayers->changed.connect( this, &RimFractureModelTemplate::nonNetLayersChanged ); + RimEclipseCase* eclipseCase = getEclipseCase(); + if ( !eclipseCase ) return; + + m_nonNetLayers->setEclipseCase( eclipseCase ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimNonNetLayers* RimFractureModelTemplate::nonNetLayers() const +{ + return m_nonNetLayers; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -379,6 +415,14 @@ void RimFractureModelTemplate::elasticPropertiesChanged( const caf::SignalEmitte changed.send(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureModelTemplate::nonNetLayersChanged( const caf::SignalEmitter* emitter ) +{ + changed.send(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureModelTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureModelTemplate.h index 0b2a09c222..2c51485cc2 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureModelTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureModelTemplate.h @@ -33,6 +33,7 @@ class RimEclipseCase; class RimElasticProperties; class RigEclipseCaseData; class RimFaciesProperties; +class RimNonNetLayers; //================================================================================================== /// @@ -90,6 +91,9 @@ public: void setFaciesProperties( RimFaciesProperties* faciesProperties ); RimFaciesProperties* faciesProperties() const; + void setNonNetLayers( RimNonNetLayers* nonNetLayers ); + RimNonNetLayers* nonNetLayers() const; + void updateReferringPlots(); protected: @@ -107,6 +111,7 @@ private: void faciesPropertiesChanged( const caf::SignalEmitter* emitter ); void elasticPropertiesChanged( const caf::SignalEmitter* emitter ); + void nonNetLayersChanged( const caf::SignalEmitter* emitter ); static double computeDefaultStressDepth(); @@ -133,4 +138,5 @@ private: caf::PdmField m_underburdenFluidDensity; caf::PdmChildField m_elasticProperties; caf::PdmChildField m_faciesProperties; + caf::PdmChildField m_nonNetLayers; }; diff --git a/ApplicationCode/ProjectDataModel/RimNonNetLayers.cpp b/ApplicationCode/ProjectDataModel/RimNonNetLayers.cpp new file mode 100644 index 0000000000..7e7d843682 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimNonNetLayers.cpp @@ -0,0 +1,211 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimNonNetLayers.h" + +#include "RigFormationNames.h" +#include "RimColorLegend.h" +#include "RimColorLegendItem.h" +#include "RimEclipseCase.h" +#include "RimEclipseResultDefinition.h" +#include "RimFaciesProperties.h" +#include "RimFractureModelTemplate.h" +#include "RimProject.h" +#include "RimRegularLegendConfig.h" +#include "RimTools.h" + +#include "RigEclipseCaseData.h" + +#include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiLineEditor.h" +#include "cafPdmUiTextEditor.h" + +CAF_PDM_SOURCE_INIT( RimNonNetLayers, "NonNetLayers" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimNonNetLayers::RimNonNetLayers() + : changed( this ) +{ + CAF_PDM_InitScriptableObject( "RimNonNetLayers", "", "", "" ); + + CAF_PDM_InitScriptableField( &m_cutOff, "Cutoff", 0.5, "Cutoff", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_formation, "Formation", "Formation", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_facies, "Facies", "Facies", "", "", "" ); + + CAF_PDM_InitScriptableFieldNoDefault( &m_resultDefinition, "FaciesDefinition", "", "", "", "" ); + m_resultDefinition.uiCapability()->setUiHidden( true ); + m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); + m_resultDefinition = new RimEclipseResultDefinition; + m_resultDefinition->findField( "MResultType" )->uiCapability()->setUiName( "Facies Definiton" ); + + setUiName( "Non-Net Layers" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimNonNetLayers::~RimNonNetLayers() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimNonNetLayers::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly ) +{ + QList options; + if ( fieldNeedingOptions == &m_formation ) + { + std::vector formationNames = getFormationNames(); + for ( const QString& formationName : formationNames ) + { + options.push_back( caf::PdmOptionItemInfo( formationName, formationName ) ); + } + } + else if ( fieldNeedingOptions == &m_facies ) + { + RimColorLegend* faciesColors = getFaciesColorLegend(); + if ( !faciesColors ) return options; + + for ( RimColorLegendItem* item : faciesColors->colorLegendItems() ) + { + options.push_back( caf::PdmOptionItemInfo( item->categoryName(), item->categoryName() ) ); + } + } + + // QList options; + // if ( fieldNeedingOptions == &m_colorLegend ) + // { + // RimTools::colorLegendOptionItems( &options ); + // } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimNonNetLayers::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + caf::PdmUiGroup* resultDefinitionGroup = uiOrdering.addNewGroup( "Facies Definition" ); + m_resultDefinition->uiOrdering( uiConfigName, *resultDefinitionGroup ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimNonNetLayers::fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) +{ + changed.send(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimNonNetLayers::setEclipseCase( RimEclipseCase* eclipseCase ) +{ + m_resultDefinition->setEclipseCase( eclipseCase ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimEclipseResultDefinition* RimNonNetLayers::resultDefinition() const +{ + return m_resultDefinition.value(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimNonNetLayers::cutOff() const +{ + return m_cutOff; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RimNonNetLayers::formation() const +{ + return m_formation(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RimNonNetLayers::facies() const +{ + return m_facies(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimColorLegend* RimNonNetLayers::getFaciesColorLegend() +{ + RimFractureModelTemplate* fractureModelTemplate; + firstAncestorOrThisOfType( fractureModelTemplate ); + if ( !fractureModelTemplate ) return nullptr; + + RimFaciesProperties* faciesProperties = fractureModelTemplate->faciesProperties(); + if ( !faciesProperties ) return nullptr; + + return faciesProperties->colorLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimNonNetLayers::getFormationNames() +{ + RigEclipseCaseData* eclipseCaseData = getEclipseCaseData(); + if ( !eclipseCaseData ) return std::vector(); + + return eclipseCaseData->formationNames(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase* RimNonNetLayers::getEclipseCase() +{ + // Find an eclipse case + RimProject* proj = RimProject::current(); + if ( proj->eclipseCases().empty() ) return nullptr; + + return proj->eclipseCases()[0]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigEclipseCaseData* RimNonNetLayers::getEclipseCaseData() +{ + // Find an eclipse case + RimEclipseCase* eclipseCase = getEclipseCase(); + if ( !eclipseCase ) return nullptr; + + return eclipseCase->eclipseCaseData(); +} diff --git a/ApplicationCode/ProjectDataModel/RimNonNetLayers.h b/ApplicationCode/ProjectDataModel/RimNonNetLayers.h new file mode 100644 index 0000000000..96e4b6787d --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimNonNetLayers.h @@ -0,0 +1,71 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafFilePath.h" +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrField.h" + +#include +#include + +class RimEclipseResultDefinition; +class RimEclipseCase; +class RimColorLegend; +class RigEclipseCaseData; + +//================================================================================================== +/// +//================================================================================================== +class RimNonNetLayers : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimNonNetLayers(); + ~RimNonNetLayers() override; + + caf::Signal<> changed; + + void setEclipseCase( RimEclipseCase* eclipseCase ); + + const RimEclipseResultDefinition* resultDefinition() const; + double cutOff() const; + const QString& formation() const; + const QString& facies() const; + +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + + RimColorLegend* getFaciesColorLegend(); + static std::vector getFormationNames(); + static RimEclipseCase* getEclipseCase(); + static RigEclipseCaseData* getEclipseCaseData(); + +private: + caf::PdmField m_cutOff; + caf::PdmChildField m_resultDefinition; + caf::PdmField m_formation; + caf::PdmField m_facies; +};