From 820fa561ba8c86b008078c425ad5b5640ab50043 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 Mar 2024 12:57:49 +0100 Subject: [PATCH 001/332] Fix deploy to pypi --- .github/workflows/ResInsightWithCache.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 7c83bd0a88..1124335926 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -294,7 +294,7 @@ jobs: steps: - name: Download python distribution folder - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: python-distribution path: dist @@ -307,5 +307,5 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 # uncomment the two lines below to publish to test PyPi # with: - # repository-url: https://test.pypi.org/legacy/ + # repository-url: https://test.pypi.org/legacy/ From d72a45d3fea1ddc0ccd09029b5c3a2f4716a16b9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 Mar 2024 12:59:48 +0100 Subject: [PATCH 002/332] Bump version to 2024.03.1-dev.01 --- ResInsightVersion.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index b7fdbae98b..6c1556992b 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,17 +1,17 @@ set(RESINSIGHT_MAJOR_VERSION 2024) set(RESINSIGHT_MINOR_VERSION 03) -set(RESINSIGHT_PATCH_VERSION 0) +set(RESINSIGHT_PATCH_VERSION 1) # Opional text with no restrictions -#set(RESINSIGHT_VERSION_TEXT "-dev") +set(RESINSIGHT_VERSION_TEXT "-dev") #set(RESINSIGHT_VERSION_TEXT "-RC_05") # Optional text # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -#set(RESINSIGHT_DEV_VERSION ".24") +set(RESINSIGHT_DEV_VERSION ".01") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From ef637e30531dc40b535488bb6a12d754b2184401 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 Mar 2024 15:14:04 +0100 Subject: [PATCH 003/332] Move stream operator from AppEnum header This PR will reduce the compile time of code using AppEnum. * AppEnum: Move QTextStream operator to avoid include of QTextStream * Avoid use of iostream in cafAssert rator to avoid include of QTextStream Include file profiling shows that include of QTextStream is a performance issue. Create a non-templated base class for AppEnum. Implement the QTextStream operator for this interface. --- .../RicRunCommandFileFeature.cpp | 1 + .../FileInterface/RifEclipseInputFileTools.h | 1 + .../FileInterface/RifHdf5SummaryReader.cpp | 2 + .../FileInterface/RifOpmGridTools.cpp | 3 +- .../FileInterface/RifReaderOpmCommon.cpp | 2 + .../Streamlines/RimStreamlineDataAccess.h | 2 +- .../RigFaultReactivationModelGenerator.h | 5 +- .../RigThermalFractureDefinition.cpp | 2 + Fwk/AppFwk/cafPdmCvf/cafPdmCoreMat4d.h | 2 + Fwk/AppFwk/cafPdmCvf/cafPdmCoreVec3d.h | 2 + .../cafPdmFieldScriptingCapability.h | 1 + .../cafPdmCore/cafAppEnum.h | 42 ++++-------- .../cafPdmCore/cafAssert.h | 65 +++---------------- .../cafInternalPdmFilePathStreamOperators.cpp | 1 + .../cafInternalPdmFilePathStreamOperators.h | 2 - .../cafInternalPdmStreamOperators.cpp | 20 ++++++ .../cafPdmXml/cafInternalPdmStreamOperators.h | 11 +++- .../cafUserInterface/cafProgressInfo.cpp | 1 + 18 files changed, 73 insertions(+), 92 deletions(-) diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp index 51712ed4af..09428a9645 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp @@ -25,6 +25,7 @@ #include #include #include +#include CAF_CMD_SOURCE_INIT( RicRunCommandFileFeature, "RicRunCommandFileFeature" ); diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.h b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.h index baff69028d..70db3f726e 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.h +++ b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.h @@ -35,6 +35,7 @@ class RigEclipseCaseData; class QFile; +class QTextStream; //-------------------------------------------------------------------------------------------------- /// Structure used to cache file position of keywords diff --git a/ApplicationLibCode/FileInterface/RifHdf5SummaryReader.cpp b/ApplicationLibCode/FileInterface/RifHdf5SummaryReader.cpp index b7b63ebfd0..bc1747f91a 100644 --- a/ApplicationLibCode/FileInterface/RifHdf5SummaryReader.cpp +++ b/ApplicationLibCode/FileInterface/RifHdf5SummaryReader.cpp @@ -30,6 +30,8 @@ #include #include +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifOpmGridTools.cpp b/ApplicationLibCode/FileInterface/RifOpmGridTools.cpp index b7eef1dcc1..25ff8fc5c8 100644 --- a/ApplicationLibCode/FileInterface/RifOpmGridTools.cpp +++ b/ApplicationLibCode/FileInterface/RifOpmGridTools.cpp @@ -27,11 +27,12 @@ #include "RigEclipseCaseData.h" #include "RigMainGrid.h" -#include "cvfGeometryTools.h" +#include "cafAssert.h" #include "opm/io/eclipse/EGrid.hpp" #include +#include //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp index a71d9b4a04..2d92279529 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp @@ -46,6 +46,8 @@ #include "opm/output/eclipse/VectorItems/intehead.hpp" #include "opm/output/eclipse/VectorItems/well.hpp" +#include + using namespace Opm; //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamlineDataAccess.h b/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamlineDataAccess.h index 5addbc8cd2..eeb590f796 100644 --- a/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamlineDataAccess.h +++ b/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamlineDataAccess.h @@ -25,7 +25,7 @@ #include #include -#include +#include class RigCell; class RimStreamline; diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h index 23fbe91dc4..3c8618a30c 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h @@ -23,12 +23,13 @@ #include "cvfStructGrid.h" #include "cvfVector3.h" +#include + #include +#include #include #include -#include - class RigFault; class RigMainGrid; class RigGriddedPart3d; diff --git a/ApplicationLibCode/ReservoirDataModel/RigThermalFractureDefinition.cpp b/ApplicationLibCode/ReservoirDataModel/RigThermalFractureDefinition.cpp index b4ee0f7db6..d9ea687f24 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigThermalFractureDefinition.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigThermalFractureDefinition.cpp @@ -21,6 +21,8 @@ #include "RiaEclipseUnitTools.h" #include "RiaLogging.h" +#include "cafAssert.h" + #include //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafPdmCvf/cafPdmCoreMat4d.h b/Fwk/AppFwk/cafPdmCvf/cafPdmCoreMat4d.h index d8d500d599..44188bb187 100644 --- a/Fwk/AppFwk/cafPdmCvf/cafPdmCoreMat4d.h +++ b/Fwk/AppFwk/cafPdmCvf/cafPdmCoreMat4d.h @@ -43,6 +43,8 @@ #include "cafPdmXmlMat4d.h" +#include + namespace caf { template <> diff --git a/Fwk/AppFwk/cafPdmCvf/cafPdmCoreVec3d.h b/Fwk/AppFwk/cafPdmCvf/cafPdmCoreVec3d.h index 60c9b6e025..b52e275858 100644 --- a/Fwk/AppFwk/cafPdmCvf/cafPdmCoreVec3d.h +++ b/Fwk/AppFwk/cafPdmCvf/cafPdmCoreVec3d.h @@ -43,6 +43,8 @@ #include "cafPdmXmlVec3d.h" +#include + Q_DECLARE_METATYPE( cvf::Vec3d ); namespace caf diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h b/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h index 0440d0c237..796dfea3c6 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h @@ -45,6 +45,7 @@ #include "cafPdmScriptIOMessages.h" #include +#include #define CAF_PDM_InitScriptableField( field, keyword, default, uiName, ... ) \ { \ diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAppEnum.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAppEnum.h index 7a09b0f028..02e4ab362a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAppEnum.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAppEnum.h @@ -40,7 +40,6 @@ #include #include -#include #include @@ -98,8 +97,18 @@ namespace caf /// } //================================================================================================== +class AppEnumInterface +{ + // This non-templated base class is used in cafInternalPdmStreamOperators.h to create a QTextStream operator. Having + // the QTextStream operator working on each templated type was seen as a performance issue when profiling use of + // include files +public: + virtual QString textForSerialization() const = 0; + virtual void setTextForSerialization( const QString& text ) = 0; +}; + template -class AppEnum +class AppEnum : public AppEnumInterface { public: AppEnum() { m_value = EnumMapper::instance()->defaultValue(); } @@ -123,6 +132,9 @@ class AppEnum bool setFromText( const QString& text ) { return EnumMapper::instance()->enumVal( m_value, text ); } bool setFromIndex( size_t index ) { return EnumMapper::instance()->enumVal( m_value, index ); } + QString textForSerialization() const override { return text(); } + void setTextForSerialization( const QString& text ) override { setFromText( text ); } + // Static interface to access the properties of the enum definition static bool isValid( const QString& text ) { return EnumMapper::instance()->isValid( text ); } @@ -343,29 +355,3 @@ class AppEnum }; } // namespace caf - -//================================================================================================== -/// Implementation of stream operators to make PdmField > work smoothly -/// Assumes that the stream ends at the end of the enum text -//================================================================================================== - -template -QTextStream& operator>>( QTextStream& str, caf::AppEnum& appEnum ) -{ - QString text; - str >> text; - - // Make sure the text parsed from a text stream is trimmed - // https://github.com/OPM/ResInsight/issues/7829 - appEnum.setFromText( text.trimmed() ); - - return str; -} - -template -QTextStream& operator<<( QTextStream& str, const caf::AppEnum& appEnum ) -{ - str << appEnum.text(); - - return str; -} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAssert.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAssert.h index e38d214901..3add52c1e0 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAssert.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAssert.h @@ -1,62 +1,15 @@ #pragma once +#include #include -#include -#define CAF_ASSERT( expr ) \ - do \ - { \ - if ( !( expr ) ) /* NOLINT */ \ - { \ - std::cout << __FILE__ << ":" << __LINE__ << ": CAF_ASSERT(" << #expr << ") failed" << std::endl; \ - std::abort(); \ - } \ +#define CAF_ASSERT( expr ) \ + do \ + { \ + if ( !( expr ) ) /* NOLINT */ \ + { \ + std::printf( "%s : %i : CAF_ASSERT( %s ) failed\n", __FILE__, __LINE__, #expr ); \ + std::abort(); \ + } \ } while ( false ) - -#if 0 // Bits and pieces for reference to improve the assert -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable : 4668 ) -#include -#pragma warning( pop ) -#endif - - -void openDebugWindow() -{ -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable : 4996 ) - AllocConsole(); - freopen("conin$", "r", stdin); - freopen("conout$", "w", stdout); - freopen("conout$", "w", stderr); -#pragma warning( pop ) -#endif -} - -void assertAbort() -{ -#ifdef _MSC_VER -#if ( _MSC_VER >= 1600 ) - //if (::IsDebuggerPresent()) -#endif - { - __debugbreak(); - } -#endif - - std::terminate(); -} - -#define ASSERT_TEST( expr ) \ - do \ - { \ - if ( !( expr ) ) \ - { \ - std::cout << __FILE__ << ":" << __LINE__ << ": CAF_ASSERT(" << #expr << ") failed" << std::endl; \ - assertAbort(); \ - } \ - } while ( false ) -#endif diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp index 294128cb5a..6367e175b5 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp @@ -1,6 +1,7 @@ #include "cafInternalPdmFilePathStreamOperators.h" #include +#include //-------------------------------------------------------------------------------------------------- /// diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.h index c43d0f1719..4ddd379251 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.h @@ -2,8 +2,6 @@ #include "cafFilePath.h" -#include - #include QTextStream& operator<<( QTextStream& str, const std::vector& sobj ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmStreamOperators.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmStreamOperators.cpp index d326cefcb8..964bacbc26 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmStreamOperators.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmStreamOperators.cpp @@ -1,6 +1,8 @@ #include #include +#include "cafAppEnum.h" + //-------------------------------------------------------------------------------------------------- /// Specialized read operation for Bool`s //-------------------------------------------------------------------------------------------------- @@ -83,3 +85,21 @@ QTextStream& operator<<( QTextStream& str, const QTime& value ) str << text; return str; } + +//-------------------------------------------------------------------------------------------------- +/// Specialized read operation for AppEnum +//-------------------------------------------------------------------------------------------------- +QTextStream& operator>>( QTextStream& str, caf::AppEnumInterface& value ) +{ + QString text; + str >> text; + value.setTextForSerialization( text ); + return str; +} + +QTextStream& operator<<( QTextStream& str, const caf::AppEnumInterface& value ) +{ + QString text = value.textForSerialization(); + str << text; + return str; +} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmStreamOperators.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmStreamOperators.h index 8983658a4b..cc7a04201c 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmStreamOperators.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmStreamOperators.h @@ -1,7 +1,5 @@ #pragma once -#include - //================================================================================================== /// QTextStream Stream operator overloading for bool`s /// Prints bool`s as "True"/"False", and reads them too @@ -34,6 +32,15 @@ QTextStream& operator<<( QTextStream& str, const QDate& value ); QTextStream& operator>>( QTextStream& str, QTime& value ); QTextStream& operator<<( QTextStream& str, const QTime& value ); +// AppEnum +namespace caf +{ +class AppEnumInterface; +} + +QTextStream& operator>>( QTextStream& str, caf::AppEnumInterface& value ); +QTextStream& operator<<( QTextStream& str, const caf::AppEnumInterface& value ); + //================================================================================================== /// QTextStream Stream operator overloading for std::vector of things. /// Makes automated IO of PdmField< std::vector< Whatever > possible as long as diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index 6a20a01e84..46cf1688c5 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -46,6 +46,7 @@ #include #include +#include namespace caf { From be3d06c5494532a87d80db4824b2d4b7fbe889a9 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 3 Apr 2024 14:53:20 +0200 Subject: [PATCH 004/332] Refactor: improve api for views and oil fields. --- .../Application/RiaApplication.cpp | 4 +- .../RicNewValveTemplateFeature.cpp | 4 +- .../RicHoloLensExportToFolderUi.cpp | 4 +- .../RicExportContourMapToTextFeature.cpp | 6 +-- .../RicWellMeasurementImportTools.cpp | 3 +- .../RicNewSeismicViewFeature.cpp | 3 +- .../ViewLink/RicLinkVisibleViewsFeature.cpp | 8 +-- .../RicNewPolylineTargetFeature.cpp | 3 +- .../RimAnnotationCollectionBase.cpp | 4 +- .../RimFractureTemplateCollection.cpp | 3 +- .../Polygons/RimPolygonCollection.cpp | 3 +- .../ProjectDataModel/Rim3dView.cpp | 7 +-- .../ProjectDataModel/RimGridCalculation.cpp | 4 +- .../ProjectDataModel/RimProject.cpp | 50 ++++++++++--------- .../ProjectDataModel/RimProject.h | 14 +++--- .../ProjectDataModel/RimViewController.cpp | 5 +- .../Seismic/RimSeismicDataCollection.cpp | 9 ++-- .../RimStimPlanModelTemplateCollection.cpp | 3 +- .../Surfaces/RimSurfaceCollection.cpp | 8 ++- .../RiuSelectionChangedHandler.cpp | 3 +- .../RiuSummaryVectorSelectionUi.cpp | 6 +-- 21 files changed, 61 insertions(+), 93 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 7bef9598e1..86e2b1df0b 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -690,9 +690,7 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct } { - std::vector views; - m_project->allViews( views ); - + std::vector views = m_project->allViews(); for ( auto view : views ) { if ( auto eclipseView = dynamic_cast( view ) ) diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewValveTemplateFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicNewValveTemplateFeature.cpp index 30f846cf87..01deef6656 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewValveTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewValveTemplateFeature.cpp @@ -50,9 +50,7 @@ void RicNewValveTemplateFeature::selectValveTemplateAndUpdate( RimValveTemplate* RimProject* project = RimProject::current(); - std::vector views; - project->allVisibleViews( views ); - + std::vector views = project->allVisibleViews(); for ( Rim3dView* view : views ) { if ( dynamic_cast( view ) ) diff --git a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp index fd3406b999..2fab89dc56 100644 --- a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp +++ b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp @@ -74,9 +74,7 @@ QList RicHoloLensExportToFolderUi::calculateValueOptions if ( fieldNeedingOptions == &m_viewForExport ) { - std::vector visibleViews; - RimProject::current()->allVisibleGridViews( visibleViews ); - + std::vector visibleViews = RimProject::current()->allVisibleGridViews(); for ( RimGridView* v : visibleViews ) { RiaOptionItemFactory::appendOptionItemFromViewNameAndCaseName( v, &options ); diff --git a/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp b/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp index 7d09675933..8773dd0450 100644 --- a/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp +++ b/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp @@ -277,10 +277,8 @@ caf::PdmScriptResponse RicExportContourMapToTextFeature::execute() RimProject* proj = app->project(); CAF_ASSERT( proj ); - std::vector allViews; - proj->allViews( allViews ); - - Rim3dView* myView = nullptr; + std::vector allViews = proj->allViews(); + Rim3dView* myView = nullptr; for ( auto view : allViews ) { if ( m_viewId == view->id() ) diff --git a/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp b/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp index 9f2f650c85..2906b7a661 100644 --- a/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp +++ b/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp @@ -102,8 +102,7 @@ void RicWellMeasurementImportTools::importWellMeasurementsFromFiles( const QStri auto proj = RimProject::current(); if ( proj ) { - std::vector views; - proj->allViews( views ); + std::vector views = proj->allViews(); for ( auto& view : views ) { RimGridView* gridView = dynamic_cast( view ); diff --git a/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp b/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp index 061321542c..c0d21855dc 100644 --- a/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp +++ b/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp @@ -85,8 +85,7 @@ RimSeismicView* RicNewSeismicViewFeature::createInitialViewIfNeeded( RimSeismicD { auto proj = RimProject::current(); - std::vector views; - proj->allViews( views ); + std::vector views = proj->allViews(); if ( !views.empty() ) return nullptr; return createSeismicView( seisData ); diff --git a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp index a1b68fb873..d6295c11c2 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp +++ b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp @@ -44,15 +44,13 @@ bool RicLinkVisibleViewsFeature::isCommandEnabled() const RimProject* proj = RimProject::current(); if ( !proj ) return false; - std::vector visibleViews; - proj->allVisibleViews( visibleViews ); - std::vector linkedviews; if ( proj->viewLinkerCollection() && proj->viewLinkerCollection()->viewLinker() ) { linkedviews = proj->viewLinkerCollection()->viewLinker()->allViews(); } + std::vector visibleViews = proj->allVisibleViews(); if ( visibleViews.size() >= 2 && ( linkedviews.size() < visibleViews.size() ) ) { return !findLinkableVisibleViews().empty(); @@ -88,9 +86,7 @@ std::vector RicLinkVisibleViewsFeature::findLinkableVisibleViews() std::vector views; - std::vector candidates; - proj->allVisibleViews( candidates ); - + std::vector candidates = proj->allVisibleViews(); for ( auto gridView : candidates ) { if ( gridView && !gridView->assosiatedViewLinker() ) views.push_back( gridView ); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp index eec85c6ce3..0bf3de1c30 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp @@ -133,8 +133,7 @@ void RicNewPolylineTargetFeature::onActionTriggered( bool isChecked ) } else { - std::vector gridViews; - RimProject::current()->allVisibleGridViews( gridViews ); + std::vector gridViews = RimProject::current()->allVisibleGridViews(); if ( !gridViews.empty() ) { auto minPos = gridViews.front()->ownerCase()->allCellsBoundingBox().min(); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollectionBase.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollectionBase.cpp index 79d1e39d19..7a39002cd6 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollectionBase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollectionBase.cpp @@ -132,9 +132,7 @@ std::vector RimAnnotationCollectionBase::viewsContainingAnnotations( RimProject* project = RimProject::current(); if ( !project ) return {}; - std::vector views; - project->allViews( views ); - return views; + return project->allViews(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 70111e999a..2b06de3325 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -316,8 +316,7 @@ void RimFractureTemplateCollection::onChildDeleted( caf::PdmChildArrayFieldHandl proj->scheduleCreateDisplayModelAndRedrawAllViews(); } - std::vector views; - proj->allVisibleViews( views ); + std::vector views = proj->allVisibleViews(); for ( Rim3dView* visibleView : views ) { if ( dynamic_cast( visibleView ) ) diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp index ee52064c39..96c30a8218 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp @@ -189,8 +189,7 @@ void RimPolygonCollection::updateViewTreeItems() RimProject* proj = RimProject::current(); // Make sure the tree items are synchronized - std::vector views; - proj->allViews( views ); + std::vector views = proj->allViews(); for ( auto view : views ) { view->updateViewTreeItems( RiaDefines::ItemIn3dView::POLYGON ); diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp index 8d98b5067c..00ee9e06a9 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp @@ -197,9 +197,7 @@ Rim3dView::~Rim3dView() if ( auto proj = RimProject::current() ) { - std::vector allViews; - proj->allViews( allViews ); - + std::vector allViews = proj->allViews(); for ( auto v : allViews ) { if ( v->activeComparisonView() == this ) @@ -591,8 +589,7 @@ std::vector Rim3dView::validComparisonViews() const { auto isIntersectionView = []( const Rim3dView* view ) { return dynamic_cast( view ) != nullptr; }; - std::vector views; - RimProject::current()->allViews( views ); + std::vector views = RimProject::current()->allViews(); std::vector validComparisonViews; for ( auto view : views ) diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp index 7160b3d9ed..0dfe24312f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp @@ -344,9 +344,6 @@ QList RimGridCalculation::calculateValueOptions( const c { options.push_back( caf::PdmOptionItemInfo( "Disabled", nullptr ) ); - std::vector views; - RimProject::current()->allViews( views ); - RimEclipseCase* firstEclipseCase = nullptr; if ( !inputCases().empty() ) { @@ -361,6 +358,7 @@ QList RimGridCalculation::calculateValueOptions( const c if ( firstEclipseCase ) { + std::vector views = RimProject::current()->allViews(); for ( auto* view : views ) { auto eclipseView = dynamic_cast( view ); diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 2fa9253844..be14bb558e 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -737,16 +737,17 @@ RimSummaryCaseMainCollection* RimProject::firstSummaryCaseMainCollection() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allNotLinkedViews( std::vector& views ) +std::vector RimProject::allNotLinkedViews() const { - std::vector cases = allGridCases(); - std::vector alreadyLinkedViews; if ( viewLinkerCollection->viewLinker() ) { alreadyLinkedViews = viewLinkerCollection->viewLinker()->allViews(); } + std::vector views; + + std::vector cases = allGridCases(); for ( size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++ ) { RimCase* rimCase = cases[caseIdx]; @@ -773,15 +774,18 @@ void RimProject::allNotLinkedViews( std::vector& views ) } } } + + return views; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allViews( std::vector& views ) const +std::vector RimProject::allViews() const { - std::vector cases = allGridCases(); + std::vector views; + std::vector cases = allGridCases(); for ( size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++ ) { RimCase* rimCase = cases[caseIdx]; @@ -808,15 +812,18 @@ void RimProject::allViews( std::vector& views ) const views.push_back( seisview ); } } + + return views; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allVisibleViews( std::vector& views ) const +std::vector RimProject::allVisibleViews() const { - std::vector cases = allGridCases(); + std::vector views; + std::vector cases = allGridCases(); for ( size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++ ) { RimCase* rimCase = cases[caseIdx]; @@ -831,20 +838,24 @@ void RimProject::allVisibleViews( std::vector& views ) const } } } + + return views; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allVisibleGridViews( std::vector& views ) const +std::vector RimProject::allVisibleGridViews() const { - std::vector visibleViews; - allVisibleViews( visibleViews ); + std::vector views; + std::vector visibleViews = allVisibleViews(); for ( Rim3dView* view : visibleViews ) { RimGridView* gridView = dynamic_cast( view ); if ( gridView ) views.push_back( gridView ); } + + return views; } //-------------------------------------------------------------------------------------------------- @@ -878,13 +889,9 @@ void RimProject::scheduleCreateDisplayModelAndRedrawAllViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allOilFields( std::vector& allOilFields ) const +std::vector RimProject::allOilFields() const { - allOilFields.clear(); - for ( const auto& oilField : oilFields ) - { - allOilFields.push_back( oilField ); - } + return oilFields.childrenByType(); } //-------------------------------------------------------------------------------------------------- @@ -1176,8 +1183,7 @@ std::vector RimProject::textAnnotations() const } // 'Local' text annotations - std::vector visibleViews; - allVisibleGridViews( visibleViews ); + std::vector visibleViews = allVisibleGridViews(); for ( const auto& view : visibleViews ) { std::vector annotationColls = view->descendantsIncludingThisOfType(); @@ -1263,9 +1269,7 @@ std::vector RimProject::geoMechCases() const std::vector RimProject::allFractureTemplateCollections() const { std::vector templColls; - std::vector rimOilFields; - - allOilFields( rimOilFields ); + std::vector rimOilFields = allOilFields(); for ( RimOilField* oilField : rimOilFields ) { templColls.push_back( oilField->fractureDefinitionCollection() ); @@ -1295,9 +1299,7 @@ std::vector RimProject::allFractureTemplates() const std::vector RimProject::allValveTemplateCollections() const { std::vector templColls; - std::vector rimOilFields; - - allOilFields( rimOilFields ); + std::vector rimOilFields = allOilFields(); for ( RimOilField* oilField : rimOilFields ) { templColls.push_back( oilField->valveTemplateCollection() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.h b/ApplicationLibCode/ProjectDataModel/RimProject.h index ab87066486..6dbbcfe9d9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.h +++ b/ApplicationLibCode/ProjectDataModel/RimProject.h @@ -137,18 +137,18 @@ class RimProject : public caf::PdmDocument std::vector summaryGroups() const; RimSummaryCaseMainCollection* firstSummaryCaseMainCollection() const; - void allViews( std::vector& views ) const; - void allVisibleViews( std::vector& views ) const; - void allVisibleGridViews( std::vector& views ) const; - void allNotLinkedViews( std::vector& views ); + [[nodiscard]] std::vector allViews() const; + [[nodiscard]] std::vector allVisibleViews() const; + [[nodiscard]] std::vector allVisibleGridViews() const; + [[nodiscard]] std::vector allNotLinkedViews() const; void scheduleCreateDisplayModelAndRedrawAllViews(); void computeUtmAreaOfInterest(); - void allOilFields( std::vector& allOilFields ) const; - RimOilField* activeOilField(); - const RimOilField* activeOilField() const; + [[nodiscard]] std::vector allOilFields() const; + RimOilField* activeOilField(); + const RimOilField* activeOilField() const; void actionsBasedOnSelection( QMenu& contextMenu ); diff --git a/ApplicationLibCode/ProjectDataModel/RimViewController.cpp b/ApplicationLibCode/ProjectDataModel/RimViewController.cpp index 3e0f249dc2..1014876c87 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewController.cpp @@ -108,9 +108,8 @@ QList RimViewController::calculateValueOptions( const ca if ( fieldNeedingOptions == &m_managedView ) { - RimProject* proj = RimProject::current(); - std::vector views; - proj->allNotLinkedViews( views ); + RimProject* proj = RimProject::current(); + std::vector views = proj->allNotLinkedViews(); // Add currently linked view to list if ( managedView() ) diff --git a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicDataCollection.cpp b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicDataCollection.cpp index 935f165949..36ee35519c 100644 --- a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicDataCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicDataCollection.cpp @@ -109,10 +109,8 @@ void RimSeismicDataCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* ch //-------------------------------------------------------------------------------------------------- void RimSeismicDataCollection::updateViews() { - RimProject* proj = RimProject::current(); - std::vector views; - proj->allVisibleGridViews( views ); - + RimProject* proj = RimProject::current(); + std::vector views = proj->allVisibleGridViews(); for ( auto view : views ) { view->scheduleCreateDisplayModelAndRedraw(); @@ -127,8 +125,7 @@ void RimSeismicDataCollection::updateTreeForAllViews() RimProject* proj = RimProject::current(); if ( proj != nullptr ) { - std::vector views; - proj->allVisibleGridViews( views ); + std::vector views = proj->allVisibleGridViews(); for ( auto view : views ) { view->updateAllRequiredEditors(); diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp index b9b819be84..b024a6e570 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp @@ -132,8 +132,7 @@ void RimStimPlanModelTemplateCollection::onChildDeleted( caf::PdmChildArrayField proj->scheduleCreateDisplayModelAndRedrawAllViews(); } - std::vector views; - proj->allVisibleViews( views ); + std::vector views = proj->allVisibleViews(); for ( Rim3dView* visibleView : views ) { if ( dynamic_cast( visibleView ) ) diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp index 6332511ee5..f577a3746b 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp @@ -298,8 +298,7 @@ void RimSurfaceCollection::updateViews( const std::vector& surfsToR RimProject* proj = RimProject::current(); // Make sure the tree items are synchronized - std::vector views; - proj->allViews( views ); + std::vector views = proj->allViews(); for ( auto view : views ) { view->updateViewTreeItems( RiaDefines::ItemIn3dView::SURFACE ); @@ -347,9 +346,8 @@ void RimSurfaceCollection::updateViews( const std::vector& surfsToR //-------------------------------------------------------------------------------------------------- void RimSurfaceCollection::updateViews() { - RimProject* proj = RimProject::current(); - std::vector views; - proj->allViews( views ); + RimProject* proj = RimProject::current(); + std::vector views = proj->allViews(); // Make sure the tree items are synchronized diff --git a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp index 62c7a5a7c4..f44f9e195c 100644 --- a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -325,8 +325,7 @@ void RiuSelectionChangedHandler::scheduleUpdateForAllVisibleViews() const RimProject* proj = RimProject::current(); if ( proj ) { - std::vector visibleViews; - proj->allVisibleViews( visibleViews ); + std::vector visibleViews = proj->allVisibleViews(); for ( size_t i = 0; i < visibleViews.size(); i++ ) { diff --git a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp index 8e08798a76..046059581d 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp @@ -552,10 +552,8 @@ QList { QList options; - RimProject* proj = RimProject::current(); - std::vector oilFields; - - proj->allOilFields( oilFields ); + RimProject* proj = RimProject::current(); + std::vector oilFields = proj->allOilFields(); for ( RimOilField* oilField : oilFields ) { RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); From e862bd259fc44e53b4b9be06ac3e896563b91387 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 3 Apr 2024 15:54:28 +0200 Subject: [PATCH 005/332] Refactor: modernize for loops. --- .../ProjectDataModel/RimProject.cpp | 85 ++++++++----------- 1 file changed, 35 insertions(+), 50 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index be14bb558e..0656f7f33f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -418,7 +418,7 @@ void RimProject::setScriptDirectories( const QString& scriptDirectories, int max scriptCollection->subDirectories().deleteChildren(); QStringList pathList = scriptDirectories.split( ';' ); - foreach ( QString path, pathList ) + for ( const QString& path : pathList ) { QDir dir( path ); if ( !path.isEmpty() && dir.exists() && dir.isReadable() ) @@ -548,36 +548,34 @@ std::vector RimProject::allGridCases() const { std::vector cases; - for ( size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++ ) + for ( RimOilField* oilField : oilFields() ) { - RimOilField* oilField = oilFields[oilFieldIdx]; if ( !oilField ) continue; RimEclipseCaseCollection* analysisModels = oilField->analysisModels(); if ( analysisModels ) { - for ( size_t caseIdx = 0; caseIdx < analysisModels->cases.size(); caseIdx++ ) + for ( RimEclipseCase* eclipseCase : analysisModels->cases ) { - cases.push_back( analysisModels->cases[caseIdx] ); + cases.push_back( eclipseCase ); } - for ( size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); cgIdx++ ) + for ( RimIdenticalGridCaseGroup* cg : analysisModels->caseGroups ) { // Load the Main case of each IdenticalGridCaseGroup - RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups[cgIdx]; if ( cg == nullptr ) continue; if ( cg->statisticsCaseCollection() ) { - for ( size_t caseIdx = 0; caseIdx < cg->statisticsCaseCollection()->reservoirs.size(); caseIdx++ ) + for ( RimEclipseCase* eclipseCase : cg->statisticsCaseCollection()->reservoirs ) { - cases.push_back( cg->statisticsCaseCollection()->reservoirs[caseIdx] ); + cases.push_back( eclipseCase ); } } if ( cg->caseCollection() ) { - for ( size_t caseIdx = 0; caseIdx < cg->caseCollection()->reservoirs.size(); caseIdx++ ) + for ( RimEclipseCase* eclipseCase : cg->caseCollection()->reservoirs ) { - cases.push_back( cg->caseCollection()->reservoirs[caseIdx] ); + cases.push_back( eclipseCase ); } } } @@ -748,15 +746,14 @@ std::vector RimProject::allNotLinkedViews() const std::vector views; std::vector cases = allGridCases(); - for ( size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++ ) + for ( RimCase* rimCase : cases ) { - RimCase* rimCase = cases[caseIdx]; if ( !rimCase ) continue; std::vector caseViews = rimCase->views(); - for ( size_t viewIdx = 0; viewIdx < caseViews.size(); viewIdx++ ) + for ( Rim3dView* caseView : caseViews ) { - RimGridView* gridView = dynamic_cast( caseViews[viewIdx] ); + RimGridView* gridView = dynamic_cast( caseView ); if ( !gridView ) continue; @@ -786,24 +783,22 @@ std::vector RimProject::allViews() const std::vector views; std::vector cases = allGridCases(); - for ( size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++ ) + for ( RimCase* rimCase : cases ) { - RimCase* rimCase = cases[caseIdx]; if ( !rimCase ) continue; std::vector caseViews = rimCase->views(); - for ( size_t viewIdx = 0; viewIdx < caseViews.size(); viewIdx++ ) + for ( Rim3dView* view : caseViews ) { - if ( caseViews[viewIdx] ) + if ( view ) { - views.push_back( caseViews[viewIdx] ); + views.push_back( view ); } } } - for ( size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++ ) + for ( RimOilField* oilField : oilFields() ) { - RimOilField* oilField = oilFields[oilFieldIdx]; if ( !oilField ) continue; if ( !oilField->seismicViewCollection() ) continue; @@ -824,17 +819,16 @@ std::vector RimProject::allVisibleViews() const std::vector views; std::vector cases = allGridCases(); - for ( size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++ ) + for ( RimCase* rimCase : cases ) { - RimCase* rimCase = cases[caseIdx]; if ( !rimCase ) continue; std::vector caseViews = rimCase->views(); - for ( size_t viewIdx = 0; viewIdx < caseViews.size(); viewIdx++ ) + for ( Rim3dView* view : caseViews ) { - if ( caseViews[viewIdx] && caseViews[viewIdx]->viewer() ) + if ( view && view->viewer() ) { - views.push_back( caseViews[viewIdx] ); + views.push_back( view ); } } } @@ -864,15 +858,13 @@ std::vector RimProject::allVisibleGridViews() const void RimProject::scheduleCreateDisplayModelAndRedrawAllViews() { std::vector cases = allGridCases(); - for ( size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++ ) + for ( RimCase* rimCase : cases ) { - RimCase* rimCase = cases[caseIdx]; - if ( rimCase == nullptr ) continue; + if ( !rimCase ) continue; std::vector views = rimCase->views(); - - for ( size_t viewIdx = 0; viewIdx < views.size(); viewIdx++ ) + for ( Rim3dView* view : views ) { - views[viewIdx]->scheduleCreateDisplayModelAndRedraw(); + view->scheduleCreateDisplayModelAndRedraw(); } } @@ -925,16 +917,14 @@ void RimProject::computeUtmAreaOfInterest() cvf::BoundingBox projectBB; - for ( size_t i = 0; i < cases.size(); i++ ) + for ( RimCase* rimCase : cases ) { - RimEclipseCase* rimCase = dynamic_cast( cases[i] ); - - if ( rimCase && rimCase->eclipseCaseData() ) + RimEclipseCase* eclipseCase = dynamic_cast( rimCase ); + if ( eclipseCase && eclipseCase->eclipseCaseData() ) { - for ( size_t gridIdx = 0; gridIdx < rimCase->eclipseCaseData()->gridCount(); gridIdx++ ) + for ( size_t gridIdx = 0; gridIdx < eclipseCase->eclipseCaseData()->gridCount(); gridIdx++ ) { - RigGridBase* rigGrid = rimCase->eclipseCaseData()->grid( gridIdx ); - + RigGridBase* rigGrid = eclipseCase->eclipseCaseData()->grid( gridIdx ); projectBB.add( rigGrid->boundingBox() ); } } @@ -1245,10 +1235,8 @@ std::vector RimProject::polylineAnnotations() const std::vector RimProject::geoMechCases() const { std::vector cases; - - for ( size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++ ) + for ( RimOilField* oilField : oilFields() ) { - RimOilField* oilField = oilFields[oilFieldIdx]; if ( !oilField ) continue; RimGeoMechModels* geomModels = oilField->geoMechModels(); @@ -1269,8 +1257,7 @@ std::vector RimProject::geoMechCases() const std::vector RimProject::allFractureTemplateCollections() const { std::vector templColls; - std::vector rimOilFields = allOilFields(); - for ( RimOilField* oilField : rimOilFields ) + for ( RimOilField* oilField : allOilFields() ) { templColls.push_back( oilField->fractureDefinitionCollection() ); } @@ -1299,8 +1286,7 @@ std::vector RimProject::allFractureTemplates() const std::vector RimProject::allValveTemplateCollections() const { std::vector templColls; - std::vector rimOilFields = allOilFields(); - for ( RimOilField* oilField : rimOilFields ) + for ( RimOilField* oilField : allOilFields() ) { templColls.push_back( oilField->valveTemplateCollection() ); } @@ -1385,10 +1371,9 @@ std::vector RimProject::allFilePaths() const void RimProject::reloadCompletionTypeResultsForEclipseCase( RimEclipseCase* eclipseCase ) { std::vector views = eclipseCase->views(); - - for ( size_t viewIdx = 0; viewIdx < views.size(); viewIdx++ ) + for ( Rim3dView* view : views ) { - views[viewIdx]->scheduleCreateDisplayModelAndRedraw(); + view->scheduleCreateDisplayModelAndRedraw(); } RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews( { eclipseCase } ); From 873282b339b4fa2c012abe224cb2bdec6d18732b Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Thu, 4 Apr 2024 08:50:28 +0200 Subject: [PATCH 006/332] Refactor: avoid local variable only used in range-based for loops --- .../Application/RiaApplication.cpp | 3 +- .../RicNewValveTemplateFeature.cpp | 3 +- .../RicExportContourMapToTextFeature.cpp | 5 +- .../RicWellMeasurementImportTools.cpp | 3 +- .../RicNewSeismicViewFeature.cpp | 3 +- .../ViewLink/RicLinkVisibleViewsFeature.cpp | 4 +- .../RimFractureTemplateCollection.cpp | 3 +- .../Polygons/RimPolygonCollection.cpp | 3 +- .../ProjectDataModel/Rim3dView.cpp | 7 +-- .../ProjectDataModel/RimProject.cpp | 55 ++++++------------- .../Surfaces/RimSurfaceCollection.cpp | 3 +- .../RiuSelectionChangedHandler.cpp | 8 +-- 12 files changed, 32 insertions(+), 68 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 86e2b1df0b..c9a0651f29 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -690,8 +690,7 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct } { - std::vector views = m_project->allViews(); - for ( auto view : views ) + for ( auto view : m_project->allViews() ) { if ( auto eclipseView = dynamic_cast( view ) ) { diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewValveTemplateFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicNewValveTemplateFeature.cpp index 01deef6656..7a352b12aa 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewValveTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewValveTemplateFeature.cpp @@ -50,8 +50,7 @@ void RicNewValveTemplateFeature::selectValveTemplateAndUpdate( RimValveTemplate* RimProject* project = RimProject::current(); - std::vector views = project->allVisibleViews(); - for ( Rim3dView* view : views ) + for ( Rim3dView* view : project->allVisibleViews() ) { if ( dynamic_cast( view ) ) { diff --git a/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp b/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp index 8773dd0450..4614bb5be0 100644 --- a/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp +++ b/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp @@ -277,9 +277,8 @@ caf::PdmScriptResponse RicExportContourMapToTextFeature::execute() RimProject* proj = app->project(); CAF_ASSERT( proj ); - std::vector allViews = proj->allViews(); - Rim3dView* myView = nullptr; - for ( auto view : allViews ) + Rim3dView* myView = nullptr; + for ( auto view : proj->allViews() ) { if ( m_viewId == view->id() ) { diff --git a/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp b/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp index 2906b7a661..8f5438705a 100644 --- a/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp +++ b/ApplicationLibCode/Commands/RicWellMeasurementImportTools.cpp @@ -102,8 +102,7 @@ void RicWellMeasurementImportTools::importWellMeasurementsFromFiles( const QStri auto proj = RimProject::current(); if ( proj ) { - std::vector views = proj->allViews(); - for ( auto& view : views ) + for ( auto& view : proj->allViews() ) { RimGridView* gridView = dynamic_cast( view ); if ( gridView ) diff --git a/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp b/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp index c0d21855dc..f8158a2e69 100644 --- a/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp +++ b/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicViewFeature.cpp @@ -85,8 +85,7 @@ RimSeismicView* RicNewSeismicViewFeature::createInitialViewIfNeeded( RimSeismicD { auto proj = RimProject::current(); - std::vector views = proj->allViews(); - if ( !views.empty() ) return nullptr; + if ( !proj->allViews().empty() ) return nullptr; return createSeismicView( seisData ); } diff --git a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp index d6295c11c2..cde23500b5 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp +++ b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp @@ -85,9 +85,7 @@ std::vector RicLinkVisibleViewsFeature::findLinkableVisibleViews() RimProject* proj = RimProject::current(); std::vector views; - - std::vector candidates = proj->allVisibleViews(); - for ( auto gridView : candidates ) + for ( auto gridView : proj->allVisibleViews() ) { if ( gridView && !gridView->assosiatedViewLinker() ) views.push_back( gridView ); } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 2b06de3325..17cbcd59a2 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -316,8 +316,7 @@ void RimFractureTemplateCollection::onChildDeleted( caf::PdmChildArrayFieldHandl proj->scheduleCreateDisplayModelAndRedrawAllViews(); } - std::vector views = proj->allVisibleViews(); - for ( Rim3dView* visibleView : views ) + for ( Rim3dView* visibleView : proj->allVisibleViews() ) { if ( dynamic_cast( visibleView ) ) { diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp index 96c30a8218..6298db2e68 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp @@ -189,8 +189,7 @@ void RimPolygonCollection::updateViewTreeItems() RimProject* proj = RimProject::current(); // Make sure the tree items are synchronized - std::vector views = proj->allViews(); - for ( auto view : views ) + for ( auto view : proj->allViews() ) { view->updateViewTreeItems( RiaDefines::ItemIn3dView::POLYGON ); } diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp index 00ee9e06a9..584c719847 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp @@ -197,8 +197,7 @@ Rim3dView::~Rim3dView() if ( auto proj = RimProject::current() ) { - std::vector allViews = proj->allViews(); - for ( auto v : allViews ) + for ( auto v : proj->allViews() ) { if ( v->activeComparisonView() == this ) { @@ -589,10 +588,8 @@ std::vector Rim3dView::validComparisonViews() const { auto isIntersectionView = []( const Rim3dView* view ) { return dynamic_cast( view ) != nullptr; }; - std::vector views = RimProject::current()->allViews(); - std::vector validComparisonViews; - for ( auto view : views ) + for ( auto view : RimProject::current()->allViews() ) { if ( dynamic_cast( view ) ) continue; diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 0656f7f33f..ab1945d156 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -514,8 +514,7 @@ void RimProject::assignCaseIdToSummaryCase( RimSummaryCase* summaryCase ) { if ( summaryCase ) { - std::vector summaryCases = allSummaryCases(); - for ( RimSummaryCase* s : summaryCases ) + for ( RimSummaryCase* s : allSummaryCases() ) { m_nextValidSummaryCaseId = std::max( m_nextValidSummaryCaseId, s->caseId() + 1 ); } @@ -531,8 +530,7 @@ void RimProject::assignIdToEnsemble( RimSummaryCaseCollection* summaryCaseCollec { if ( summaryCaseCollection ) { - std::vector summaryGroups = RimProject::summaryGroups(); - for ( RimSummaryCaseCollection* s : summaryGroups ) + for ( RimSummaryCaseCollection* s : RimProject::summaryGroups() ) { m_nextValidEnsembleId = std::max( m_nextValidEnsembleId, s->ensembleId() + 1 ); } @@ -745,13 +743,11 @@ std::vector RimProject::allNotLinkedViews() const std::vector views; - std::vector cases = allGridCases(); - for ( RimCase* rimCase : cases ) + for ( RimCase* rimCase : allGridCases() ) { if ( !rimCase ) continue; - std::vector caseViews = rimCase->views(); - for ( Rim3dView* caseView : caseViews ) + for ( Rim3dView* caseView : rimCase->views() ) { RimGridView* gridView = dynamic_cast( caseView ); @@ -782,13 +778,11 @@ std::vector RimProject::allViews() const { std::vector views; - std::vector cases = allGridCases(); - for ( RimCase* rimCase : cases ) + for ( RimCase* rimCase : allGridCases() ) { if ( !rimCase ) continue; - std::vector caseViews = rimCase->views(); - for ( Rim3dView* view : caseViews ) + for ( Rim3dView* view : rimCase->views() ) { if ( view ) { @@ -817,14 +811,11 @@ std::vector RimProject::allViews() const std::vector RimProject::allVisibleViews() const { std::vector views; - - std::vector cases = allGridCases(); - for ( RimCase* rimCase : cases ) + for ( RimCase* rimCase : allGridCases() ) { if ( !rimCase ) continue; - std::vector caseViews = rimCase->views(); - for ( Rim3dView* view : caseViews ) + for ( Rim3dView* view : rimCase->views() ) { if ( view && view->viewer() ) { @@ -842,8 +833,7 @@ std::vector RimProject::allVisibleViews() const std::vector RimProject::allVisibleGridViews() const { std::vector views; - std::vector visibleViews = allVisibleViews(); - for ( Rim3dView* view : visibleViews ) + for ( Rim3dView* view : allVisibleViews() ) { RimGridView* gridView = dynamic_cast( view ); if ( gridView ) views.push_back( gridView ); @@ -857,12 +847,10 @@ std::vector RimProject::allVisibleGridViews() const //-------------------------------------------------------------------------------------------------- void RimProject::scheduleCreateDisplayModelAndRedrawAllViews() { - std::vector cases = allGridCases(); - for ( RimCase* rimCase : cases ) + for ( RimCase* rimCase : allGridCases() ) { if ( !rimCase ) continue; - std::vector views = rimCase->views(); - for ( Rim3dView* view : views ) + for ( Rim3dView* view : rimCase->views() ) { view->scheduleCreateDisplayModelAndRedraw(); } @@ -913,11 +901,8 @@ const RimOilField* RimProject::activeOilField() const //-------------------------------------------------------------------------------------------------- void RimProject::computeUtmAreaOfInterest() { - std::vector cases = allGridCases(); - cvf::BoundingBox projectBB; - - for ( RimCase* rimCase : cases ) + for ( RimCase* rimCase : allGridCases() ) { RimEclipseCase* eclipseCase = dynamic_cast( rimCase ); if ( eclipseCase && eclipseCase->eclipseCaseData() ) @@ -1173,8 +1158,7 @@ std::vector RimProject::textAnnotations() const } // 'Local' text annotations - std::vector visibleViews = allVisibleGridViews(); - for ( const auto& view : visibleViews ) + for ( const auto& view : allVisibleGridViews() ) { std::vector annotationColls = view->descendantsIncludingThisOfType(); @@ -1314,11 +1298,9 @@ std::vector RimProject::allValveTemplates() const //-------------------------------------------------------------------------------------------------- caf::AppEnum RimProject::commonUnitSystemForAllCases() const { - std::vector rimCases = allGridCases(); - RiaDefines::EclipseUnitSystem commonUnitSystem = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN; - for ( const auto& c : rimCases ) + for ( const auto& c : allGridCases() ) { auto eclipseCase = dynamic_cast( c ); if ( eclipseCase && eclipseCase->eclipseCaseData() ) @@ -1370,8 +1352,7 @@ std::vector RimProject::allFilePaths() const //-------------------------------------------------------------------------------------------------- void RimProject::reloadCompletionTypeResultsForEclipseCase( RimEclipseCase* eclipseCase ) { - std::vector views = eclipseCase->views(); - for ( Rim3dView* view : views ) + for ( Rim3dView* view : eclipseCase->views() ) { view->scheduleCreateDisplayModelAndRedraw(); } @@ -1537,8 +1518,7 @@ void RimProject::transferPathsToGlobalPathList() { RiaVariableMapper variableMapper( m_globalPathList() ); - std::vector filePaths = allFilePaths(); - for ( caf::FilePath* filePath : filePaths ) + for ( caf::FilePath* filePath : allFilePaths() ) { QString path = filePath->path(); if ( !path.isEmpty() ) @@ -1602,8 +1582,7 @@ void RimProject::distributePathsFromGlobalPathList() { RiaVariableMapper pathListMapper( m_globalPathList() ); - std::vector filePaths = allFilePaths(); - for ( caf::FilePath* filePath : filePaths ) + for ( caf::FilePath* filePath : allFilePaths() ) { QString pathIdCandidate = filePath->path().trimmed(); QStringList pathIdComponents = pathIdCandidate.split( RiaVariableMapper::variableToken() ); diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp index f577a3746b..c26cc39498 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp @@ -298,8 +298,7 @@ void RimSurfaceCollection::updateViews( const std::vector& surfsToR RimProject* proj = RimProject::current(); // Make sure the tree items are synchronized - std::vector views = proj->allViews(); - for ( auto view : views ) + for ( auto view : proj->allViews() ) { view->updateViewTreeItems( RiaDefines::ItemIn3dView::SURFACE ); diff --git a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp index f44f9e195c..e71596e7f7 100644 --- a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -325,12 +325,10 @@ void RiuSelectionChangedHandler::scheduleUpdateForAllVisibleViews() const RimProject* proj = RimProject::current(); if ( proj ) { - std::vector visibleViews = proj->allVisibleViews(); - - for ( size_t i = 0; i < visibleViews.size(); i++ ) + for ( Rim3dView* visibleView : proj->allVisibleViews() ) { - visibleViews[i]->createHighlightAndGridBoxDisplayModelAndRedraw(); - visibleViews[i]->createMeasurementDisplayModelAndRedraw(); + visibleView->createHighlightAndGridBoxDisplayModelAndRedraw(); + visibleView->createMeasurementDisplayModelAndRedraw(); } } } From c074033dc218c6b2d2fe30c0444dc91835f2410a Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Thu, 4 Apr 2024 09:16:57 +0200 Subject: [PATCH 007/332] Refactor: Fix misspelling of "synchronize". --- .../Commands/RicNewContourMapViewFeature.cpp | 2 +- .../Faults/RimFaultInViewCollection.cpp | 4 ++-- .../ProjectDataModel/Faults/RimFaultInViewCollection.h | 2 +- .../GridCrossPlots/RimGridCrossPlotDataSet.cpp | 8 ++++---- .../Intersections/RimIntersectionCollection.cpp | 8 ++++---- .../Intersections/RimIntersectionCollection.h | 2 +- ApplicationLibCode/ProjectDataModel/Rim3dView.cpp | 2 +- ApplicationLibCode/ProjectDataModel/Rim3dView.h | 2 +- .../ProjectDataModel/RimEclipseInputProperty.h | 2 +- ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp | 10 +++++----- ApplicationLibCode/ProjectDataModel/RimEclipseView.h | 2 +- .../ProjectDataModel/Seismic/RimSeismicView.cpp | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp index 5793c615c0..55d36360da 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp @@ -256,7 +256,7 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFr eclipseCase->contourMapCollection()->push_back( contourMap ); - contourMap->syncronizeLocalAnnotationsFromGlobal(); + contourMap->synchronizeLocalAnnotationsFromGlobal(); // Resolve references after contour map has been inserted into Rim structures std::vector fieldsWithFailingResolve; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp index 2f082dcf16..79a75e944b 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp @@ -238,7 +238,7 @@ RimFaultInView* RimFaultInViewCollection::findFaultByName( QString name ) } //-------------------------------------------------------------------------------------------------- -/// A comparing function used to sort Faults in the RimFaultCollection::syncronizeFaults() method +/// A comparing function used to sort Faults in the RimFaultCollection::synchronizeFaults() method //-------------------------------------------------------------------------------------------------- bool faultComparator( const cvf::ref& a, const cvf::ref& b ) { @@ -252,7 +252,7 @@ bool faultComparator( const cvf::ref& a, const cvf::ref& b ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFaultInViewCollection::syncronizeFaults() +void RimFaultInViewCollection::synchronizeFaults() { if ( !( parentView() && parentView()->mainGrid() ) ) return; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h index e0c2620c47..1a2856d482 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h @@ -73,7 +73,7 @@ class RimFaultInViewCollection : public caf::PdmObject void setShowOppositeFaultFaces( bool bEnabled ); void setShowFaultLabelWithFieldChanged( bool bEnabled ); - void syncronizeFaults(); + void synchronizeFaults(); bool isGridVisualizationMode() const; bool shouldApplyCellFiltersToFaults() const; diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp index 977fd86dac..6d51700cc6 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp @@ -688,7 +688,7 @@ void RimGridCrossPlotDataSet::createCurves( const RigEclipseCrossPlotResult& res legendConfig()->scalarMapper()->majorTickValues( &tickValues ); } - // NB : Make sure iteration of curve and groups are syncronized with createCurves() + // NB : Make sure iteration of curve and groups are synchronized with createCurves() for ( auto it = m_groupedResults.rbegin(); it != m_groupedResults.rend(); ++it ) { auto [groupIndex, values] = *it; @@ -724,7 +724,7 @@ void RimGridCrossPlotDataSet::fillCurveDataInExistingCurves( const RigEclipseCro } else { - // NB : Make sure iteration of curve and groups are syncronized with fillCurveDataInExistingCurves() + // NB : Make sure iteration of curve and groups are synchronized with fillCurveDataInExistingCurves() auto curveIt = m_crossPlotCurves.begin(); auto groupIt = m_groupedResults.rbegin(); for ( ; curveIt != m_crossPlotCurves.end() && groupIt != m_groupedResults.rend(); ++curveIt, ++groupIt ) @@ -768,7 +768,7 @@ void RimGridCrossPlotDataSet::createRegressionCurves( const RigEclipseCrossPlotR legendConfig()->scalarMapper()->majorTickValues( &tickValues ); } - // NB : Make sure iteration of curve and groups are syncronized with createCurves() + // NB : Make sure iteration of curve and groups are synchronized with createCurves() for ( auto it = m_groupedResults.rbegin(); it != m_groupedResults.rend(); ++it ) { auto [groupIndex, values] = *it; @@ -808,7 +808,7 @@ void RimGridCrossPlotDataSet::fillCurveDataInExistingRegressionCurves( const Rig } else { - // NB : Make sure iteration of curve and groups are syncronized with fillCurveDataInExistingCurves() + // NB : Make sure iteration of curve and groups are synchronized with fillCurveDataInExistingCurves() auto curveIt = m_crossPlotRegressionCurves.begin(); auto groupIt = m_groupedResults.rbegin(); for ( ; curveIt != m_crossPlotRegressionCurves.end() && groupIt != m_groupedResults.rend(); ++curveIt, ++groupIt ) diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp index 3157f32f49..f5845391b8 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp @@ -305,7 +305,7 @@ void RimIntersectionCollection::appendIntersectionAndUpdate( RimExtrudedCurveInt intersection->setDepthOverride( m_depthThresholdOverridden ); intersection->setDepthOverrideParameters( m_depthUpperThreshold, m_depthLowerThreshold, m_depthFilterType() ); - syncronize2dIntersectionViews(); + synchronize2dIntersectionViews(); updateConnectedEditors(); Riu3DMainWindowTools::selectAsCurrentItem( intersection, allowActiveViewChange ); @@ -326,7 +326,7 @@ void RimIntersectionCollection::appendIntersectionNoUpdate( RimExtrudedCurveInte //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersectionCollection::syncronize2dIntersectionViews() +void RimIntersectionCollection::synchronize2dIntersectionViews() { auto ownerCase = firstAncestorOrThisOfTypeAsserted(); ownerCase->intersectionViewCollection()->syncFromExistingIntersections( true ); @@ -427,7 +427,7 @@ void RimIntersectionCollection::fieldChangedByUi( const caf::PdmFieldHandle* cha //-------------------------------------------------------------------------------------------------- void RimIntersectionCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) { - syncronize2dIntersectionViews(); + synchronize2dIntersectionViews(); rebuild3dView(); } @@ -436,7 +436,7 @@ void RimIntersectionCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* c //-------------------------------------------------------------------------------------------------- void RimIntersectionCollection::onChildAdded( caf::PdmFieldHandle* containerForNewObject ) { - syncronize2dIntersectionViews(); + synchronize2dIntersectionViews(); rebuild3dView(); } diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h index 47e67d35e9..7e6eb07ee8 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h @@ -66,7 +66,7 @@ class RimIntersectionCollection : public caf::PdmObject void updateIntersectionBoxGeometry(); - void syncronize2dIntersectionViews(); + void synchronize2dIntersectionViews(); void scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); bool shouldApplyCellFiltersToIntersections() const; diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp index 584c719847..b48917ba63 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp @@ -1845,7 +1845,7 @@ RimAnnotationInViewCollection* Rim3dView::annotationCollection() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim3dView::syncronizeLocalAnnotationsFromGlobal() +void Rim3dView::synchronizeLocalAnnotationsFromGlobal() { RimProject* proj = RimProject::current(); if ( proj && proj->activeOilField() ) diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.h b/ApplicationLibCode/ProjectDataModel/Rim3dView.h index a193617c6a..7272e8ea8a 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.h @@ -195,7 +195,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public virtual void updateViewTreeItems( RiaDefines::ItemIn3dView itemType ); RimAnnotationInViewCollection* annotationCollection() const; - void syncronizeLocalAnnotationsFromGlobal(); + void synchronizeLocalAnnotationsFromGlobal(); protected: static void removeModelByName( cvf::Scene* scene, const cvf::String& modelName ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseInputProperty.h b/ApplicationLibCode/ProjectDataModel/RimEclipseInputProperty.h index f9d7e3793a..d11ad42645 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseInputProperty.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseInputProperty.h @@ -51,7 +51,7 @@ class RimEclipseInputProperty : public caf::PdmObject // Fields: caf::PdmField resultName; caf::PdmField eclipseKeyword; - caf::PdmField fileName; // ReadOnly Serves as key to syncronize + caf::PdmField fileName; // ReadOnly Serves as key to synchronize // read eclipse prop data and this inputProp object. caf::PdmField resolvedState; // ReadOnly and not writable diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 0668713db3..20df13f052 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -1109,7 +1109,7 @@ void RimEclipseView::onLoadDataAndUpdate() m_propertyFilterCollection()->loadAndInitializePropertyFilters(); - faultCollection()->syncronizeFaults(); + faultCollection()->synchronizeFaults(); m_wellCollection->scaleWellDisks(); @@ -1118,9 +1118,9 @@ void RimEclipseView::onLoadDataAndUpdate() scheduleReservoirGridGeometryRegen(); m_simWellsPartManager->clearGeometryCache(); - syncronizeWellsWithResults(); + synchronizeWellsWithResults(); - syncronizeLocalAnnotationsFromGlobal(); + synchronizeLocalAnnotationsFromGlobal(); { // Update simulation well fractures after well cell results are imported @@ -1586,7 +1586,7 @@ RimEclipseCase* RimEclipseView::eclipseCase() const */ //-------------------------------------------------------------------------------------------------- -void RimEclipseView::syncronizeWellsWithResults() +void RimEclipseView::synchronizeWellsWithResults() { if ( !( eclipseCase() && eclipseCase()->eclipseCaseData() ) ) return; @@ -1781,7 +1781,7 @@ void RimEclipseView::updateDisplayModelForWellResults() m_reservoirGridPartManager->clearGeometryCache(); m_simWellsPartManager->clearGeometryCache(); - syncronizeWellsWithResults(); + synchronizeWellsWithResults(); onCreateDisplayModel(); updateDisplayModelVisibility(); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h index 75c45ee640..573dad6557 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h @@ -209,7 +209,7 @@ class RimEclipseView : public RimGridView void updateFaultColors(); - void syncronizeWellsWithResults(); + void synchronizeWellsWithResults(); void onClampCurrentTimestep() override; size_t onTimeStepCountRequested() override; diff --git a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.cpp b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.cpp index 800bc01985..c5bed5b6be 100644 --- a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.cpp @@ -408,7 +408,7 @@ void RimSeismicView::onUpdateLegends() void RimSeismicView::onLoadDataAndUpdate() { updateViewTreeItems( RiaDefines::ItemIn3dView::ALL ); - syncronizeLocalAnnotationsFromGlobal(); + synchronizeLocalAnnotationsFromGlobal(); onUpdateScaleTransform(); updateMdiWindowVisibility(); From 29d991159be3f38b327467bc279dc9af2e302d79 Mon Sep 17 00:00:00 2001 From: Eirik Marthinsen Date: Thu, 4 Apr 2024 14:49:44 +0200 Subject: [PATCH 008/332] AppFwk: Move include of windows.h to top of file The include was located in the middle of a file inside a namespace caf block and lead to ambiguous symbols when compiling with unity build and Qt6. It is also considered good practice to have includes at the top. The pragma warning disable is also removed as the warning seems to be gone (and none of the other windows.h includes have it). Closes #11327 --- .../cafUserInterface/cafProgressInfo.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index 46cf1688c5..3d7bac7dd3 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -48,6 +48,14 @@ #include #include +#ifdef _MSC_VER +// Define this one to tell windows.h to not define min() and max() as macros +#if defined WIN32 && !defined NOMINMAX +#define NOMINMAX +#endif +#include +#endif + namespace caf { //-------------------------------------------------------------------------------------------------- @@ -358,17 +366,6 @@ bool ProgressState::isActive() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable : 4668 ) -// Define this one to tell windows.h to not define min() and max() as macros -#if defined WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif -#include -#pragma warning( pop ) -#endif - void openDebugWindow() { #ifdef _MSC_VER From bce4dcfe540da00b482c6b597e9410cd004d2ce1 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 5 Apr 2024 13:59:51 +0200 Subject: [PATCH 009/332] #11310 Fix assert on single cell model. Well pipe radius would become HUGE_VAL due to off-by-one error. The assert could only happen on model with a single cell. Fixes #11310. --- Fwk/AppFwk/CommonCode/cvfStructGrid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp b/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp index d3f653021a..5f872be8bc 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp +++ b/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp @@ -380,7 +380,7 @@ void StructGridInterface::computeCharacteristicCellSize( const std::vector Date: Fri, 5 Apr 2024 11:28:02 +0200 Subject: [PATCH 010/332] Interpolation: Fix "trend" extrapolation for value outside of range on high end. --- .../Application/Tools/RiaInterpolationTools.cpp | 17 ++++++++++++++++- .../Application/Tools/RiaInterpolationTools.h | 2 ++ .../UnitTests/RiaInterpolationTools-Test.cpp | 13 +++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/Application/Tools/RiaInterpolationTools.cpp b/ApplicationLibCode/Application/Tools/RiaInterpolationTools.cpp index 71d3e64326..4ac0e11aff 100644 --- a/ApplicationLibCode/Application/Tools/RiaInterpolationTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaInterpolationTools.cpp @@ -103,7 +103,22 @@ double RiaInterpolationTools::linear( const std::vector& x, const std::v //-------------------------------------------------------------------------------------------------- double RiaInterpolationTools::extrapolate( const std::vector& x, const std::vector& y, double value ) { - return y[0] + ( value - x[0] ) / ( x[1] - x[0] ) * ( y[1] - y[0] ); + if ( value <= x[0] ) + return extrapolate( x[0], y[0], x[1], y[1], value ); + else + { + size_t lastIndex = x.size() - 1; + size_t secondLastIndex = x.size() - 2; + return extrapolate( x[secondLastIndex], y[secondLastIndex], x[lastIndex], y[lastIndex], value ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaInterpolationTools::extrapolate( double x0, double y0, double x1, double y1, double value ) +{ + return y0 + ( value - x0 ) / ( x1 - x0 ) * ( y1 - y0 ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaInterpolationTools.h b/ApplicationLibCode/Application/Tools/RiaInterpolationTools.h index e564f38f42..c126bd4e6a 100644 --- a/ApplicationLibCode/Application/Tools/RiaInterpolationTools.h +++ b/ApplicationLibCode/Application/Tools/RiaInterpolationTools.h @@ -47,5 +47,7 @@ class RiaInterpolationTools static int findNextDataPoint( const std::vector& values, int index ); static int findPreviousDataPoint( const std::vector& values, int index ); static double extrapolate( const std::vector& x, const std::vector& y, double value ); + static double extrapolate( double x0, double y0, double x1, double y1, double value ); + static double extrapolateClosestValue( const std::vector& x, const std::vector& y, double value ); }; diff --git a/ApplicationLibCode/UnitTests/RiaInterpolationTools-Test.cpp b/ApplicationLibCode/UnitTests/RiaInterpolationTools-Test.cpp index 59c2496073..b6826bb7b3 100644 --- a/ApplicationLibCode/UnitTests/RiaInterpolationTools-Test.cpp +++ b/ApplicationLibCode/UnitTests/RiaInterpolationTools-Test.cpp @@ -117,6 +117,19 @@ TEST( RiaInterpolationToolsTest, ValidIntervalValueTooLowExtrapolationTrend ) EXPECT_DOUBLE_EQ( -2.0, res ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RiaInterpolationToolsTest, ValidIntervalValueTooHighExtrapolationTrend ) +{ + std::vector x = { 0.0, 1.0, 2.0, 3.0 }; + std::vector y = { 0.0, 1.0, 10.0, 20.0 }; + + // Outside interval on low side + double res = RiaInterpolationTools::linear( x, y, 4.0, RiaInterpolationTools::ExtrapolationMode::TREND ); + EXPECT_DOUBLE_EQ( 30.0, res ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- From efe37bb06353504fa3dc3fc284ef0b0c647a2356 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 5 Apr 2024 11:44:20 +0200 Subject: [PATCH 011/332] Well Log CSV: fix interpolation of CSV data. The TVD measurements from the well path were used to interpolate the CSV data. The typically well path is too coarsely sampled which would lead unwanted smoothing of the data. Fixed by resampling the well path to a one meter sampling interval. --- .../ReservoirDataModel/RigWellLogCsvFile.cpp | 44 +++++++++++++++++-- .../ReservoirDataModel/RigWellLogCsvFile.h | 3 ++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp index 849a32c29f..f94c4470d3 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp @@ -58,6 +58,8 @@ RigWellLogCsvFile::~RigWellLogCsvFile() bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QString* errorMessage ) { m_wellLogChannelNames.clear(); + double samplingInterval = 1.0; + cvf::cref resampledWellPath = resampleWellPath( *wellPath, samplingInterval ); RifCsvUserDataFileParser parser( fileName, errorMessage ); @@ -104,14 +106,14 @@ bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QS if ( channelName == m_tvdMslLogName ) { // Use TVD from well path. - m_values[m_tvdMslLogName] = wellPath->trueVerticalDepths(); + m_values[m_tvdMslLogName] = resampledWellPath->trueVerticalDepths(); } else { CAF_ASSERT( readValues.size() == readTvds.size() ); - auto wellPathMds = wellPath->measuredDepths(); - auto wellPathTvds = wellPath->trueVerticalDepths(); + auto wellPathMds = resampledWellPath->measuredDepths(); + auto wellPathTvds = resampledWellPath->trueVerticalDepths(); // Interpolate values for the well path depths (from TVD). // Assumes that the well channel values is dependent on TVD only (MD is not considered). @@ -128,7 +130,7 @@ bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QS // Use MD from well path. m_depthLogName = "DEPTH"; - m_values[m_depthLogName] = wellPath->measuredDepths(); + m_values[m_depthLogName] = resampledWellPath->measuredDepths(); return true; } @@ -229,3 +231,37 @@ double RigWellLogCsvFile::getMissingValue() const { return std::numeric_limits::infinity(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellPath* RigWellLogCsvFile::resampleWellPath( const RigWellPath& wellPath, double samplingInterval ) +{ + std::vector measuredDepths = resampleMeasuredDepths( wellPath.measuredDepths(), samplingInterval ); + + std::vector wellPathPoints; + for ( double md : measuredDepths ) + { + wellPathPoints.push_back( wellPath.interpolatedPointAlongWellPath( md ) ); + } + + return new RigWellPath( wellPathPoints, measuredDepths ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigWellLogCsvFile::resampleMeasuredDepths( const std::vector& measuredDepths, double samplingInterval ) +{ + double firstMd = measuredDepths.front(); + double lastMd = measuredDepths.back(); + + std::vector resampledMds; + for ( double md = firstMd; md < lastMd; md += samplingInterval ) + { + resampledMds.push_back( md ); + } + resampledMds.push_back( lastMd ); + + return resampledMds; +} diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h index 78857d8779..aa25027fb8 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h @@ -60,6 +60,9 @@ class RigWellLogCsvFile : public RigWellLogFile void close(); QString depthUnitString() const override; + static RigWellPath* resampleWellPath( const RigWellPath& wellPath, double samplingInterval ); + static std::vector resampleMeasuredDepths( const std::vector& measuredDepths, double samplingInterval ); + QStringList m_wellLogChannelNames; QString m_depthLogName; QString m_tvdMslLogName; From 85b6ea397a6b6d8425c0aea80ccb32f7238e87f9 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 5 Apr 2024 12:08:10 +0200 Subject: [PATCH 012/332] Interpolation: Add check for array size for extrapolation. --- .../Application/Tools/RiaInterpolationTools.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/Application/Tools/RiaInterpolationTools.cpp b/ApplicationLibCode/Application/Tools/RiaInterpolationTools.cpp index 4ac0e11aff..b2b436a433 100644 --- a/ApplicationLibCode/Application/Tools/RiaInterpolationTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaInterpolationTools.cpp @@ -76,7 +76,7 @@ double RiaInterpolationTools::linear( const std::vector& x, const std::v { return extrapolateClosestValue( x, y, value ); } - else if ( extrapolationMode == ExtrapolationMode::TREND ) + else if ( extrapolationMode == ExtrapolationMode::TREND && x.size() >= 2 ) { return extrapolate( x, y, value ); } @@ -103,6 +103,9 @@ double RiaInterpolationTools::linear( const std::vector& x, const std::v //-------------------------------------------------------------------------------------------------- double RiaInterpolationTools::extrapolate( const std::vector& x, const std::vector& y, double value ) { + CAF_ASSERT( x.size() == y.size() ); + CAF_ASSERT( x.size() >= 2 && "Need at least two points for extrapolation" ); + if ( value <= x[0] ) return extrapolate( x[0], y[0], x[1], y[1], value ); else From 55ca147f9d251898ec9b7ef54418868787f44eda Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 5 Apr 2024 14:17:30 +0200 Subject: [PATCH 013/332] Bump to version dev 02. --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 6c1556992b..b7263c0b40 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".01") +set(RESINSIGHT_DEV_VERSION ".02") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From df0a86f076b81a8bb2d01a6f71e5e98851922d8e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 7 Apr 2024 11:57:06 +0200 Subject: [PATCH 014/332] Pin cmake to 3.28.x due to build issues with 3.29 --- .github/workflows/ResInsightWithCache.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 1124335926..854e676585 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -91,6 +91,8 @@ jobs: - name: Use CMake uses: lukka/get-cmake@latest + with: + cmakeVersion: "~3.28.0" - name: Use MSVC (Windows) uses: ilammy/msvc-dev-cmd@v1 From 3f3b5a621da7ce39f82c4706aae58c83f3eb74a2 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 8 Apr 2024 12:21:02 +0200 Subject: [PATCH 015/332] #11334 Fix cvf::Viewport assert triggered for small contour map/2d intersection Size of the overlay is could become negative, and would overflow for small views. Fixes #11334. --- ApplicationLibCode/UserInterface/RiuViewer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/UserInterface/RiuViewer.cpp b/ApplicationLibCode/UserInterface/RiuViewer.cpp index c929010946..dbbe9b31e2 100644 --- a/ApplicationLibCode/UserInterface/RiuViewer.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewer.cpp @@ -790,7 +790,7 @@ void RiuViewer::updateLegendLayout() { int legendWidth = prefSize.x(); legend->setLayoutFixedPosition( cvf::Vec2i( xPos, yPos ) ); - legend->setRenderSize( cvf::Vec2ui( legendWidth, viewPortHeight - 2 * border - 2 * edgeAxisBorderHeight ) ); + legend->setRenderSize( cvf::Vec2ui( legendWidth, std::max( 0, viewPortHeight - 2 * border - 2 * edgeAxisBorderHeight ) ) ); xPos += legendWidth + border; } else @@ -858,7 +858,7 @@ void RiuViewer::updateLegendLayout() { int legendWidth = prefSize.x(); legend->setLayoutFixedPosition( cvf::Vec2i( xPos - legendWidth, yPos ) ); - legend->setRenderSize( cvf::Vec2ui( legendWidth, viewPortHeight - yPosStart - border - edgeAxisBorderHeight ) ); + legend->setRenderSize( cvf::Vec2ui( legendWidth, std::max( 0, viewPortHeight - yPosStart - border - edgeAxisBorderHeight ) ) ); xPos -= legendWidth + border; } else From 8b1b9acd8460307516e3800388de134521e7ba45 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 8 Apr 2024 15:29:49 +0200 Subject: [PATCH 016/332] #11337 Summary import: Make sure ESMRY includes restart history --- .../Summary/RimFileSummaryCase.cpp | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp index e4815a8c2b..59ad93b809 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp @@ -99,18 +99,14 @@ QString RimFileSummaryCase::caseName() const //-------------------------------------------------------------------------------------------------- void RimFileSummaryCase::createSummaryReaderInterfaceThreadSafe( RiaThreadSafeLogger* threadSafeLogger ) { - bool lookForRestartFiles = false; - - if ( RiaPreferencesSummary::current()->summaryDataReader() == RiaPreferencesSummary::SummaryReaderMode::LIBECL ) - { - // It is only the libecl reader that requires manual search for referenced restart files - // opm-common reader handles restart files internally based on m_includeRestartFiles in RifOpmCommonEclipseSummary::openFileReader - // - // The performance of the function looking for restart files is bad, and will affect the performance significantly - lookForRestartFiles = m_includeRestartFiles; - } - - m_fileSummaryReader = RimFileSummaryCase::findRelatedFilesAndCreateReader( summaryHeaderFilename(), lookForRestartFiles, threadSafeLogger ); + // RimFileSummaryCase::findRelatedFilesAndCreateReader is a performance bottleneck. The function + // RifEclipseSummaryTools::getRestartFile() should be refactored to use opm-common instead of libecl. + // It is not possible to use restart files in ESMRY file format, see see ESmry::make_esmry_file() + // + // https://github.com/OPM/ResInsight/issues/11342 + + m_fileSummaryReader = + RimFileSummaryCase::findRelatedFilesAndCreateReader( summaryHeaderFilename(), m_includeRestartFiles, threadSafeLogger ); m_multiSummaryReader = new RifMultipleSummaryReaders; m_multiSummaryReader->addReader( m_fileSummaryReader.p() ); From bbc279d5875c39e3e534b470b69057e43e4dff7d Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Mon, 8 Apr 2024 23:07:23 +0200 Subject: [PATCH 017/332] Improve cell filter collection menu --- .../CellFilterCommands/RicNewPolygonFilterFeature.cpp | 2 +- .../ProjectDataModel/RimContextCommandBuilder.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp index dab91b8510..8ffa493ef8 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp @@ -78,5 +78,5 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked ) void RicNewPolygonFilterFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setIcon( QIcon( ":/CellFilter_Polygon.png" ) ); - actionToSetup->setText( "Create Polygon Filter" ); + actionToSetup->setText( "New Polygon Filter" ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 71841548ff..5eb216b2d5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -1040,16 +1040,16 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicPasteCellFiltersFeature"; menuBuilder << "Separator"; menuBuilder << "RicNewPolygonFilterFeature"; - menuBuilder << "RicNewUserDefinedFilterFeature"; - menuBuilder << "RicNewUserDefinedIndexFilterFeature"; - menuBuilder << "RicNewCellIndexFilterFeature"; - menuBuilder << "Separator"; menuBuilder << "RicNewCellRangeFilterFeature"; menuBuilder.subMenuStart( "Slice Filters" ); menuBuilder << "RicNewRangeFilterSliceIFeature"; menuBuilder << "RicNewRangeFilterSliceJFeature"; menuBuilder << "RicNewRangeFilterSliceKFeature"; menuBuilder.subMenuEnd(); + menuBuilder << "RicNewCellIndexFilterFeature"; + menuBuilder << "Separator"; + menuBuilder << "RicNewUserDefinedFilterFeature"; + menuBuilder << "RicNewUserDefinedIndexFilterFeature"; } else if ( dynamic_cast( firstUiItem ) ) { From 25361ad79668f9fc7eb461f3df7f48a807b4a014 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Wed, 10 Apr 2024 10:47:06 +0200 Subject: [PATCH 018/332] Allow polygon line filter with only one point (#11345) Allow polygon line filter with only one point, for both eclipse and geomech --- .../CellFilters/RimPolygonFilter.cpp | 32 +++++++++++++++---- .../RigCellGeometryTools.cpp | 17 ++++++++++ .../ReservoirDataModel/RigCellGeometryTools.h | 2 ++ 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index b8a28f811f..c1d4cc0b80 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -497,6 +497,7 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector& std::list foundCells; const bool closedPolygon = isPolygonClosed(); + const bool singlePoint = ( points.size() == 1 ); // find all cells in the K layer that matches the polygon #pragma omp parallel for @@ -524,8 +525,16 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector& } else { + if ( singlePoint ) + { + if ( RigCellGeometryTools::pointInsideCellNegK2D( points[0], hexCorners ) ) + { +#pragma omp critical + foundCells.push_back( cellIdx ); + } + } // check if the polyline touches the top face of the cell - if ( RigCellGeometryTools::polylineIntersectsCellNegK2D( points, hexCorners ) ) + else if ( RigCellGeometryTools::polylineIntersectsCellNegK2D( points, hexCorners ) ) { #pragma omp critical foundCells.push_back( cellIdx ); @@ -634,6 +643,7 @@ void RimPolygonFilter::updateCellsDepthGeoMech( const std::vector& p void RimPolygonFilter::updateCellsKIndexGeoMech( const std::vector& points, const RigFemPartGrid* grid, int partId ) { const bool closedPolygon = isPolygonClosed(); + const bool singlePoint = ( points.size() == 1 ); // we need to find the K layer we hit with the first point size_t nk; @@ -660,7 +670,7 @@ void RimPolygonFilter::updateCellsKIndexGeoMech( const std::vector& bb.add( point ); // check all points for a bb match - for ( size_t p = 0; p < points.size() - 1; p++ ) + for ( size_t p = 0; p < points.size(); p++ ) { // is the point inside? if ( bb.contains( points[p] ) ) @@ -709,8 +719,16 @@ void RimPolygonFilter::updateCellsKIndexGeoMech( const std::vector& } else { + if ( singlePoint ) + { + if ( RigCellGeometryTools::pointInsideCellNegK2D( points[0], hexCorners ) ) + { +#pragma omp critical + foundCells.push_back( cellIdx ); + } + } // check if the polyline touches the top face of the cell - if ( RigCellGeometryTools::polylineIntersectsCellNegK2D( points, hexCorners ) ) + else if ( RigCellGeometryTools::polylineIntersectsCellNegK2D( points, hexCorners ) ) { #pragma omp critical foundCells.push_back( cellIdx ); @@ -785,7 +803,7 @@ void RimPolygonFilter::updateCells() } // We need at least three points to make a closed polygon, or just 2 for a polyline - if ( ( !isPolygonClosed() && ( points.size() < 2 ) ) || ( isPolygonClosed() && ( points.size() < 3 ) ) ) return; + if ( ( !isPolygonClosed() && ( points.size() < 1 ) ) || ( isPolygonClosed() && ( points.size() < 3 ) ) ) return; // make sure first and last point is the same (req. by closed polygon methods used later) if ( isPolygonClosed() ) points.push_back( points.front() ); @@ -992,7 +1010,7 @@ int RimPolygonFilter::findEclipseKLayer( const std::vector& points, // look for a hit in the main grid frist RigMainGrid* mainGrid = data->mainGrid(); - for ( size_t p = 0; p < points.size() - 1; p++ ) + for ( size_t p = 0; p < points.size(); p++ ) { size_t cIdx = mainGrid->findReservoirCellIndexFromPoint( points[p] ); if ( cIdx != cvf::UNDEFINED_SIZE_T ) @@ -1035,7 +1053,7 @@ int RimPolygonFilter::findEclipseKLayer( const std::vector& points, }; // shoot a ray down from each point to try to find a valid hit there - for ( size_t p = 0; p < points.size() - 1; p++ ) + for ( size_t p = 0; p < points.size(); p++ ) { int k = findKLayerBelowPoint( points[p], data->mainGrid() ); if ( k != -1 ) return k; @@ -1063,7 +1081,7 @@ int RimPolygonFilter::findEclipseKLayer( const std::vector& points, } // loop over all points to find at least one point with a valid K layer - for ( size_t p = 0; p < points.size() - 1; p++ ) + for ( size_t p = 0; p < points.size(); p++ ) { if ( bb.contains( points[p] ) ) { diff --git a/ApplicationLibCode/ReservoirDataModel/RigCellGeometryTools.cpp b/ApplicationLibCode/ReservoirDataModel/RigCellGeometryTools.cpp index 9a78a40f7d..3c078d9188 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCellGeometryTools.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCellGeometryTools.cpp @@ -932,3 +932,20 @@ bool RigCellGeometryTools::polylineIntersectsCellNegK2D( const std::vector& cellCorners ) +{ + std::vector polygon; + + const std::vector negK = { 0, 3, 2, 1, 0 }; + + for ( auto i : negK ) + { + polygon.push_back( cellCorners[i] ); + } + + return RigCellGeometryTools::pointInsidePolygon2D( point, polygon ); +} diff --git a/ApplicationLibCode/ReservoirDataModel/RigCellGeometryTools.h b/ApplicationLibCode/ReservoirDataModel/RigCellGeometryTools.h index 28f3f91dc0..38eca15ce7 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCellGeometryTools.h +++ b/ApplicationLibCode/ReservoirDataModel/RigCellGeometryTools.h @@ -79,6 +79,8 @@ class RigCellGeometryTools // *** the 2D methods only looks at the X and Y coordinates of the input points *** static bool pointInsidePolygon2D( const cvf::Vec3d point, const std::vector& polygon ); + static bool pointInsideCellNegK2D( const cvf::Vec3d& point, const std::array& cellCorners ); + static std::pair lineLineIntersection2D( const cvf::Vec3d a1, const cvf::Vec3d b1, const cvf::Vec3d a2, const cvf::Vec3d b2 ); static bool lineIntersectsLine2D( const cvf::Vec3d a1, const cvf::Vec3d b1, const cvf::Vec3d a2, const cvf::Vec3d b2 ); From 67a9e14417f275b92fdcb673b51bf982c17d2b43 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Apr 2024 10:38:12 +0200 Subject: [PATCH 019/332] CSV Well Log: change sampling rate from 1.0 meter to 0.1 meter. --- ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp index f94c4470d3..f6f0283304 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp @@ -58,7 +58,7 @@ RigWellLogCsvFile::~RigWellLogCsvFile() bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QString* errorMessage ) { m_wellLogChannelNames.clear(); - double samplingInterval = 1.0; + double samplingInterval = 0.1; cvf::cref resampledWellPath = resampleWellPath( *wellPath, samplingInterval ); RifCsvUserDataFileParser parser( fileName, errorMessage ); From c367fe5e7fe96771cf87dcf28e0eed77305bc522 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Apr 2024 10:42:23 +0200 Subject: [PATCH 020/332] Bump to version dev 03. --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index b7263c0b40..f30fa7979b 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".02") +set(RESINSIGHT_DEV_VERSION ".03") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 7836181ad112780db844051ad91f846a7838c1ec Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 8 Apr 2024 16:10:14 +0200 Subject: [PATCH 021/332] Refactor: use lambda instead of define. --- .../RivExtrudedCurveIntersectionGeometryGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp index d30e0b6d9c..1dc7597798 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp @@ -226,7 +226,7 @@ class MeshLinesAccumulator const cvf::Vec3d& p0, const cvf::Vec3d& p1 ) { -#define isFace( faceEnum ) ( 0 <= faceEnum && faceEnum <= 5 ) + auto isFace = []( int faceEnum ) { return 0 <= faceEnum && faceEnum <= 5; }; using FaceType = cvf::StructGridInterface::FaceType; if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx] ) ) From eb02e9e0a5d48b00723f168818b3ca1b1acf2417 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 8 Apr 2024 16:10:37 +0200 Subject: [PATCH 022/332] #11332 2D Intersection Views: Improve automatic depth resolution. --- .../RivWindowEdgeAxesOverlayItem.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp b/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp index 02e15ba76a..5c0f58a1e3 100644 --- a/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp +++ b/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp @@ -141,8 +141,13 @@ void RivWindowEdgeAxesOverlayItem::updateFromCamera( const Camera* camera ) double domainMinY = m_domainAxes == XY_AXES ? windowOrigoInDomain.y() : windowOrigoInDomain.z(); double domainMaxY = m_domainAxes == XY_AXES ? windowMaxInDomain.y() : windowMaxInDomain.z(); - int xTickMaxCount = m_windowSize.x() / ( 2 * m_textSize.x() ); - int yTickMaxCount = m_windowSize.y() / ( 2 * m_textSize.x() ); + int textSizeX = 2 * m_textSize.x(); + int xTickMaxCount = m_windowSize.x() / textSizeX; + + // Use same textsize for Y dimension for XY axes to get square "tiles". + // For XZ axes more ticks looks better in Z (depth) axis. + int textSizeY = m_domainAxes == XY_AXES ? textSizeX : 4 * m_textSize.y(); + int yTickMaxCount = m_windowSize.y() / textSizeY; double minDomainXStepSize = ( domainMaxX - domainMinX ) / xTickMaxCount; caf::TickMarkGenerator xTickCreator( domainMinX, domainMaxX, minDomainXStepSize ); From c402142e58d6c7c3023736886f69946cba785ebd Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Apr 2024 09:14:52 +0200 Subject: [PATCH 023/332] Refactor: extract duplicated code. --- .../RivWindowEdgeAxesOverlayItem.cpp | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp b/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp index 5c0f58a1e3..02883cedb9 100644 --- a/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp +++ b/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp @@ -157,19 +157,14 @@ void RivWindowEdgeAxesOverlayItem::updateFromCamera( const Camera* camera ) caf::TickMarkGenerator yTickCreator( domainMinY, domainMaxY, minDomainYStepSize ); m_domainCoordsYValues = yTickCreator.tickMarkValues(); + auto createDomainVec = []( auto domainAxes, double x, double y ) + { return ( domainAxes == XY_AXES ) ? Vec3d( x, y, 0 ) : Vec3d( x, 0, y ); }; + m_windowTickXValues.clear(); Vec3d windowPoint; for ( double domainX : m_domainCoordsXValues ) { - Vec3d displayDomainTick; - if ( m_domainAxes == XY_AXES ) - { - displayDomainTick = Vec3d( domainX, domainMinY, 0 ); - } - else - { - displayDomainTick = Vec3d( domainX, 0, domainMinY ); - } + Vec3d displayDomainTick = createDomainVec( m_domainAxes, domainX, domainMinY ); if ( m_dispalyCoordsTransform.notNull() ) { displayDomainTick = m_dispalyCoordsTransform->transformToDisplayCoord( displayDomainTick ); @@ -181,17 +176,7 @@ void RivWindowEdgeAxesOverlayItem::updateFromCamera( const Camera* camera ) m_windowTickYValues.clear(); for ( double domainY : m_domainCoordsYValues ) { - Vec3d displayDomainTick; - - if ( m_domainAxes == XY_AXES ) - { - displayDomainTick = Vec3d( domainMinX, domainY, 0 ); - } - else - { - displayDomainTick = Vec3d( domainMinX, 0, domainY ); - } - + Vec3d displayDomainTick = createDomainVec( m_domainAxes, domainMinX, domainY ); if ( m_dispalyCoordsTransform.notNull() ) { displayDomainTick = m_dispalyCoordsTransform->transformToDisplayCoord( displayDomainTick ); From eeecc41ad171a1a057811b1350fe3cdb8a49e909 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Apr 2024 09:16:26 +0200 Subject: [PATCH 024/332] Fix typo. --- .../RivWindowEdgeAxesOverlayItem.cpp | 16 ++++++++-------- .../RivWindowEdgeAxesOverlayItem.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp b/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp index 02883cedb9..71b44ebe63 100644 --- a/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp +++ b/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp @@ -89,7 +89,7 @@ RivWindowEdgeAxesOverlayItem::~RivWindowEdgeAxesOverlayItem() //-------------------------------------------------------------------------------------------------- void RivWindowEdgeAxesOverlayItem::setDisplayCoordTransform( const caf::DisplayCoordTransform* displayCoordTransform ) { - m_dispalyCoordsTransform = displayCoordTransform; + m_displayCoordsTransform = displayCoordTransform; } //-------------------------------------------------------------------------------------------------- @@ -126,10 +126,10 @@ void RivWindowEdgeAxesOverlayItem::updateFromCamera( const Camera* camera ) camera->unproject( Vec3d( 0, 0, 0 ), &windowOrigoInDomain ); camera->unproject( Vec3d( m_windowSize.x(), m_windowSize.y(), 0 ), &windowMaxInDomain ); - if ( m_dispalyCoordsTransform.notNull() ) + if ( m_displayCoordsTransform.notNull() ) { - windowOrigoInDomain = m_dispalyCoordsTransform->transformToDomainCoord( windowOrigoInDomain ); - windowMaxInDomain = m_dispalyCoordsTransform->transformToDomainCoord( windowMaxInDomain ); + windowOrigoInDomain = m_displayCoordsTransform->transformToDomainCoord( windowOrigoInDomain ); + windowMaxInDomain = m_displayCoordsTransform->transformToDomainCoord( windowMaxInDomain ); } // For extreme zoom factors we might end up with both variables as zero. Return to avoid divide by zero. @@ -165,9 +165,9 @@ void RivWindowEdgeAxesOverlayItem::updateFromCamera( const Camera* camera ) for ( double domainX : m_domainCoordsXValues ) { Vec3d displayDomainTick = createDomainVec( m_domainAxes, domainX, domainMinY ); - if ( m_dispalyCoordsTransform.notNull() ) + if ( m_displayCoordsTransform.notNull() ) { - displayDomainTick = m_dispalyCoordsTransform->transformToDisplayCoord( displayDomainTick ); + displayDomainTick = m_displayCoordsTransform->transformToDisplayCoord( displayDomainTick ); } camera->project( displayDomainTick, &windowPoint ); m_windowTickXValues.push_back( windowPoint.x() ); @@ -177,9 +177,9 @@ void RivWindowEdgeAxesOverlayItem::updateFromCamera( const Camera* camera ) for ( double domainY : m_domainCoordsYValues ) { Vec3d displayDomainTick = createDomainVec( m_domainAxes, domainMinX, domainY ); - if ( m_dispalyCoordsTransform.notNull() ) + if ( m_displayCoordsTransform.notNull() ) { - displayDomainTick = m_dispalyCoordsTransform->transformToDisplayCoord( displayDomainTick ); + displayDomainTick = m_displayCoordsTransform->transformToDisplayCoord( displayDomainTick ); } camera->project( displayDomainTick, &windowPoint ); m_windowTickYValues.push_back( windowPoint.y() ); diff --git a/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h b/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h index f523e7ac93..a5558fe5a7 100644 --- a/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h +++ b/ApplicationLibCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h @@ -122,7 +122,7 @@ class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem std::array frameVertexArray(); private: - cvf::cref m_dispalyCoordsTransform; + cvf::cref m_displayCoordsTransform; Vec2ui m_windowSize; // Pixel size of the window Vec2ui m_textSize; From 869a2430ae341b01bb0fb345da4326e20963ff50 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 14 Apr 2024 12:59:08 +0200 Subject: [PATCH 025/332] Revert "Pin cmake to 3.28.x due to build issues with 3.29" This reverts commit df0a86f076b81a8bb2d01a6f71e5e98851922d8e. Issue was fixed in 3.29.2 https://gitlab.kitware.com/cmake/cmake/-/issues/25873 --- .github/workflows/ResInsightWithCache.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 854e676585..1124335926 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -91,8 +91,6 @@ jobs: - name: Use CMake uses: lukka/get-cmake@latest - with: - cmakeVersion: "~3.28.0" - name: Use MSVC (Windows) uses: ilammy/msvc-dev-cmd@v1 From 9dc5e99be01501f5e098b155e4a7a56282e2c18b Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Thu, 11 Apr 2024 09:53:30 +0200 Subject: [PATCH 026/332] #11354 Fix FG_MK_MIN/FG_MK_EXP calculations Was not using Kirsch at all due to misunderstanding. Fixes #11354. --- .../RigGeoMechWellLogExtractor.cpp | 190 ++++++++---------- .../RigGeoMechWellLogExtractor.h | 2 - 2 files changed, 86 insertions(+), 106 deletions(-) diff --git a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index 86ded27774..cbf79fe38c 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -152,18 +152,12 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd wellBoreFGShale( RigWbsParameter::FG_Shale(), timeStepIndex, frameIndex, values ); values->front() = wbsCurveValuesAtMsl(); } - else if ( resAddr.fieldName == RiaResultNames::wbsSFGResult().toStdString() ) + else if ( resAddr.fieldName == RiaResultNames::wbsSFGResult().toStdString() || + resAddr.fieldName == RiaResultNames::wbsFGMkMinResult().toStdString() || + resAddr.fieldName == RiaResultNames::wbsFGMkExpResult().toStdString() ) { wellBoreWallCurveData( resAddr, timeStepIndex, frameIndex, values ); } - else if ( resAddr.fieldName == RiaResultNames::wbsFGMkMinResult().toStdString() ) - { - wellBoreFG_MatthewsKelly( RigWbsParameter::FG_MkMin(), timeStepIndex, frameIndex, values ); - } - else if ( resAddr.fieldName == RiaResultNames::wbsFGMkExpResult().toStdString() ) - { - wellBoreFG_MatthewsKelly( RigWbsParameter::FG_MkExp(), timeStepIndex, frameIndex, values ); - } else if ( resAddr.fieldName == RiaResultNames::wbsPPResult().toStdString() || resAddr.fieldName == RiaResultNames::wbsOBGResult().toStdString() || resAddr.fieldName == RiaResultNames::wbsSHResult().toStdString() ) @@ -628,10 +622,6 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres resAddr.fieldName == RiaResultNames::wbsFGMkMinResult().toStdString() || resAddr.fieldName == RiaResultNames::wbsFGMkExpResult().toStdString() ); - // The result addresses needed - RigFemResultAddress stressResAddr( RIG_ELEMENT_NODAL, "ST", "" ); - RigFemResultAddress porBarResAddr = RigFemAddressDefines::elementNodalPorBarAddress(); - RigFemPartResultsCollection* resultCollection = m_caseData->femPartResults(); auto mapFGResultToPP = []( const QString& fgResultName ) @@ -641,27 +631,14 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres return RigWbsParameter::PP_Reservoir(); }; - RigWbsParameter ppParameter = mapFGResultToPP( QString::fromStdString( resAddr.fieldName ) ); - - // Load results - std::vector vertexStressesFloat = resultCollection->tensors( stressResAddr, m_partId, timeStepIndex, frameIndex ); - if ( vertexStressesFloat.empty() ) return; - - std::vector vertexStresses; - vertexStresses.reserve( vertexStressesFloat.size() ); - for ( const caf::Ten3f& floatTensor : vertexStressesFloat ) - { - vertexStresses.push_back( caf::Ten3d( floatTensor ) ); - } - - std::vector interpolatedInterfaceStressBar = - interpolateInterfaceValues( stressResAddr, timeStepIndex, frameIndex, vertexStresses ); + bool useGridStress = !( resAddr.fieldName == RiaResultNames::wbsFGMkMinResult().toStdString() || + resAddr.fieldName == RiaResultNames::wbsFGMkExpResult().toStdString() ); values->resize( intersections().size(), std::numeric_limits::infinity() ); std::vector ppSandAllSegments( intersections().size(), std::numeric_limits::infinity() ); std::vector ppSources = - calculateWbsParameterForAllSegments( ppParameter, timeStepIndex, frameIndex, &ppSandAllSegments, false ); + calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), timeStepIndex, frameIndex, &ppSandAllSegments, false ); std::vector poissonAllSegments( intersections().size(), std::numeric_limits::infinity() ); calculateWbsParameterForAllSegments( RigWbsParameter::poissonRatio(), timeStepIndex, frameIndex, &poissonAllSegments, false ); @@ -669,17 +646,86 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres std::vector ucsAllSegments( intersections().size(), std::numeric_limits::infinity() ); calculateWbsParameterForAllSegments( RigWbsParameter::UCS(), timeStepIndex, frameIndex, &ucsAllSegments, false ); + std::vector> segmentStresses( intersections().size(), { caf::Ten3d::invalid(), false } ); + + if ( useGridStress ) + { + // The result addresses needed + RigFemResultAddress stressResAddr( RIG_ELEMENT_NODAL, "ST", "" ); + + // Load results + std::vector vertexStressesFloat = resultCollection->tensors( stressResAddr, m_partId, timeStepIndex, frameIndex ); + if ( vertexStressesFloat.empty() ) return; + + std::vector vertexStresses; + vertexStresses.reserve( vertexStressesFloat.size() ); + for ( const caf::Ten3f& floatTensor : vertexStressesFloat ) + { + vertexStresses.push_back( caf::Ten3d( floatTensor ) ); + } + + std::vector interpolatedInterfaceStressBar = + interpolateInterfaceValues( stressResAddr, timeStepIndex, frameIndex, vertexStresses ); + #pragma omp parallel for - for ( int64_t intersectionIdx = 0; intersectionIdx < static_cast( intersections().size() ); ++intersectionIdx ) + for ( int64_t intersectionIdx = 0; intersectionIdx < static_cast( intersections().size() ); ++intersectionIdx ) + { + caf::Ten3d segmentStress; + bool validSegmentStress = + averageIntersectionValuesToSegmentValue( intersectionIdx, interpolatedInterfaceStressBar, caf::Ten3d::invalid(), &segmentStress ); + segmentStresses[intersectionIdx] = { segmentStress, validSegmentStress }; + } + } + else { - // FG is for sands, SFG for shale. Sands has valid PP, shale does not. - bool isFGregion = ppSources[intersectionIdx] == RigWbsParameter::GRID; - if ( resAddr.fieldName == RiaResultNames::wbsFGMkMinResult().toStdString() || - resAddr.fieldName == RiaResultNames::wbsFGMkExpResult().toStdString() ) + std::vector obgAllSegments( intersections().size(), std::numeric_limits::infinity() ); + calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, 0, &obgAllSegments, false ); + + auto mapFGResultToSH = []( const QString& fgResultName ) { - // Assume only FG for entire well log for FG_MK_MIN/EXP. - isFGregion = true; + if ( fgResultName == RiaResultNames::wbsFGMkMinResult() ) + return RiaResultNames::wbsSHMkMinResult(); + else + return RiaResultNames::wbsSHMkExpResult(); + }; + + std::vector SH; + QString SHMkResultName = mapFGResultToSH( QString::fromStdString( resAddr.fieldName ) ); + RigFemResultAddress SHMkAddr( RIG_WELLPATH_DERIVED, SHMkResultName.toStdString(), "" ); + + curveData( SHMkAddr, timeStepIndex, frameIndex, &SH ); + + CVF_ASSERT( SH.size() == intersections().size() ); + +#pragma omp parallel for + for ( int64_t intersectionIdx = 0; intersectionIdx < static_cast( intersections().size() ); ++intersectionIdx ) + { + double horizontalStress = obgAllSegments[intersectionIdx]; + double verticalStress = SH[intersectionIdx] * hydroStaticPorePressureForIntersection( intersectionIdx ); + double shear = 0.0; + caf::Ten3d segmentStress( horizontalStress, horizontalStress, verticalStress, shear, shear, shear ); + // Only for pp defined?? + bool validSegmentStress = true; + segmentStresses[intersectionIdx] = { segmentStress, validSegmentStress }; } + } + + CAF_ASSERT( segmentStresses.size() == intersections().size() ); + + std::vector pp( intersections().size(), std::numeric_limits::infinity() ); + if ( !useGridStress ) + { + RigWbsParameter ppParameter = mapFGResultToPP( QString::fromStdString( resAddr.fieldName ) ); + calculateWbsParameterForAllSegments( ppParameter, timeStepIndex, frameIndex, &pp, false ); + ppSandAllSegments = pp; + } + + CAF_ASSERT( pp.size() == intersections().size() ); + +#pragma omp parallel for + for ( int64_t intersectionIdx = 0; intersectionIdx < static_cast( intersections().size() ); ++intersectionIdx ) + { + bool isFGregion = ppSources[intersectionIdx] == RigWbsParameter::GRID; double hydroStaticPorePressureBar = hydroStaticPorePressureForSegment( intersectionIdx ); @@ -692,15 +738,11 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres double poissonRatio = poissonAllSegments[intersectionIdx]; double ucsBar = ucsAllSegments[intersectionIdx]; - caf::Ten3d segmentStress; - bool validSegmentStress = - averageIntersectionValuesToSegmentValue( intersectionIdx, interpolatedInterfaceStressBar, caf::Ten3d::invalid(), &segmentStress ); + auto [segmentStress, validSegmentStress] = segmentStresses[intersectionIdx]; + cvf::Vec3d wellPathTangent = calculateWellPathTangent( intersectionIdx, TangentConstantWithinCell ); + caf::Ten3d wellPathStress = transformTensorToWellPathOrientation( wellPathTangent, segmentStress ); - cvf::Vec3d wellPathTangent = calculateWellPathTangent( intersectionIdx, TangentConstantWithinCell ); - caf::Ten3d wellPathStressFloat = transformTensorToWellPathOrientation( wellPathTangent, segmentStress ); - caf::Ten3d wellPathStressDouble( wellPathStressFloat ); - - RigGeoMechBoreHoleStressCalculator sigmaCalculator( wellPathStressDouble, porePressureBar, poissonRatio, ucsBar, 32 ); + RigGeoMechBoreHoleStressCalculator sigmaCalculator( wellPathStress, porePressureBar, poissonRatio, ucsBar, 32 ); double resultValue = std::numeric_limits::infinity(); if ( resAddr.fieldName == RiaResultNames::wbsFGResult().toStdString() || resAddr.fieldName == RiaResultNames::wbsFGMkMinResult().toStdString() || @@ -812,66 +854,6 @@ void RigGeoMechWellLogExtractor::wellBoreFGDerivedFromK0FG( const QString& } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigGeoMechWellLogExtractor::wellBoreFG_MatthewsKelly( const RigWbsParameter& parameter, - int timeStepIndex, - int frameIndex, - std::vector* values ) -{ - values->resize( intersections().size(), std::numeric_limits::infinity() ); - - // Use FG_Shale source to avoid creating more options. - WbsParameterSource source = m_parameterSources.at( RigWbsParameter::FG_Shale() ); - if ( source == RigWbsParameter::DERIVED_FROM_K0FG ) - { - auto mapParameterToPPResult = []( const RigWbsParameter& parameter ) - { - if ( parameter.name() == RiaResultNames::wbsFGMkMinResult() ) return RiaResultNames::wbsPPMinResult(); - if ( parameter.name() == RiaResultNames::wbsFGMkExpResult() ) return RiaResultNames::wbsPPExpResult(); - return RiaResultNames::wbsPPResult(); - }; - - QString ppResultName = mapParameterToPPResult( parameter ); - bool onlyForPPReservoir = true; - wellBoreFGDerivedFromK0FG( ppResultName, timeStepIndex, frameIndex, values, onlyForPPReservoir ); - } - else - { - auto mapParameterToSHMkResult = []( const RigWbsParameter& parameter ) - { - if ( parameter.name() == RiaResultNames::wbsFGMkMinResult() ) return RiaResultNames::wbsSHMkMinResult(); - if ( parameter.name() == RiaResultNames::wbsFGMkExpResult() ) return RiaResultNames::wbsSHMkExpResult(); - return RiaResultNames::wbsSHMkResult(); - }; - - std::vector SH; - QString SHMkResultName = mapParameterToSHMkResult( parameter ); - RigFemResultAddress SHMkAddr( RIG_WELLPATH_DERIVED, SHMkResultName.toStdString(), "" ); - - curveData( SHMkAddr, timeStepIndex, frameIndex, &SH ); - - CVF_ASSERT( SH.size() == intersections().size() ); - - std::vector PP( intersections().size(), std::numeric_limits::infinity() ); - std::vector ppSources = - calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), timeStepIndex, frameIndex, &PP, false ); - - double multiplier = m_userDefinedValues.at( parameter ); - CVF_ASSERT( multiplier != std::numeric_limits::infinity() ); -#pragma omp parallel for - for ( int64_t intersectionIdx = 0; intersectionIdx < static_cast( intersections().size() ); ++intersectionIdx ) - { - if ( !isValid( ( *values )[intersectionIdx] ) && ppSources[intersectionIdx] == RigWbsParameter::GRID && - isValid( PP[intersectionIdx] ) && isValid( SH[intersectionIdx] ) ) - { - ( *values )[intersectionIdx] = SH[intersectionIdx] * multiplier; - } - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h index e846bf440d..5178dca748 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h @@ -133,8 +133,6 @@ class RigGeoMechWellLogExtractor : public RigWellLogExtractor void wellBoreFGDerivedFromK0FG( const QString& ppResult, int timeStepIndex, int frameIndex, std::vector* values, bool onlyForPPReservoir ); - void wellBoreFG_MatthewsKelly( const RigWbsParameter& parameter, int timeStepIndex, int frameIndex, std::vector* values ); - template T interpolateGridResultValue( RigFemResultPosEnum resultPosType, const std::vector& gridResultValues, int64_t intersectionIdx ) const; size_t gridResultIndexFace( size_t elementIdx, cvf::StructGridInterface::FaceType cellFace, int faceLocalNodeIdx ) const; From b181c55db8875e10dba7b450048592d611df14d5 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 15 Apr 2024 12:05:56 +0200 Subject: [PATCH 027/332] WBS Plot: use PP (from any source) for shale for SFG. --- .../ReservoirDataModel/RigGeoMechWellLogExtractor.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index cbf79fe38c..714ce59142 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -722,6 +722,10 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres CAF_ASSERT( pp.size() == intersections().size() ); + std::vector ppShaleValues( intersections().size(), std::numeric_limits::infinity() ); + calculateWbsParameterForAllSegments( RigWbsParameter::PP_NonReservoir(), 0, 0, &ppShaleValues, true ); + CAF_ASSERT( ppShaleValues.size() == intersections().size() ); + #pragma omp parallel for for ( int64_t intersectionIdx = 0; intersectionIdx < static_cast( intersections().size() ); ++intersectionIdx ) { @@ -730,6 +734,12 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres double hydroStaticPorePressureBar = hydroStaticPorePressureForSegment( intersectionIdx ); double porePressureBar = ppSandAllSegments[intersectionIdx]; + if ( resAddr.fieldName == RiaResultNames::wbsSFGResult().toStdString() ) + { + // SFG needs PP for shale. + porePressureBar = ppShaleValues[intersectionIdx] * hydroStaticPorePressureBar; + } + if ( porePressureBar == std::numeric_limits::infinity() ) { porePressureBar = hydroStaticPorePressureBar; From 8f96d8b13104cb088a77f5b31e0f0ff79415a3f5 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 15 Apr 2024 12:11:19 +0200 Subject: [PATCH 028/332] Bump to version dev 04. --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index f30fa7979b..7483c0f93e 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".03") +set(RESINSIGHT_DEV_VERSION ".04") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From b5666c333acb70327991d0316823d1d29d2c2020 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 15 Mar 2024 09:32:45 +0100 Subject: [PATCH 029/332] Refactor connection between cases and views. Eclipse grid views and contour maps are not longer a child of the case. The views are not separate collections (one for grid and one for contour maps) on root level. --- .../RicNewCellIndexFilterFeature.cpp | 11 +- .../RicNewPolygonFilterFeature.cpp | 10 +- .../RicNewRangeFilterSliceFeature.cpp | 15 +- .../RicNewUserDefinedFilterFeature.cpp | 13 +- .../RicNewUserDefinedIndexFilterFeature.cpp | 12 +- .../RicNewAzimuthDipIntersectionFeature.cpp | 6 +- .../RicAdvancedSnapshotExportFeature.cpp | 22 ++- .../RicAdvancedSnapshotExportFeature.h | 2 + .../RicPasteCellFiltersFeature.cpp | 19 +-- .../RicPasteEclipseCasesFeature.cpp | 3 +- .../Commands/RicNewContourMapViewFeature.cpp | 29 +++- .../Commands/RicVec3dPickEventHandler.cpp | 5 +- .../ModelVisualization/RivWellPathPartMgr.cpp | 2 +- .../Surfaces/RivSurfacePartMgr.cpp | 9 +- .../RimAnnotationInViewCollection.cpp | 22 +-- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../CellFilters/RimCellFilter.cpp | 3 +- .../CellFilters/RimCellFilterCollection.cpp | 5 +- .../Flow/RimFlowCharacteristicsPlot.cpp | 6 +- .../Flow/RimWellConnectivityTable.cpp | 2 +- .../GeoMech/RimGeoMechContourMapView.cpp | 6 +- .../GeoMech/RimGeoMechView.cpp | 6 +- .../RimGridCrossPlotDataSet.cpp | 2 +- .../Intersections/RimBoxIntersection.cpp | 2 +- .../RimIntersectionCollection.cpp | 2 +- ...ntersectionResultsDefinitionCollection.cpp | 9 +- .../Rim2dIntersectionView.cpp | 2 +- .../Rim3dOverlayInfoConfig.cpp | 10 +- .../RimAdvancedSnapshotExportDefinition.cpp | 8 +- .../ProjectDataModel/RimEclipseCase.cpp | 154 ++++++++++++------ .../ProjectDataModel/RimEclipseCase.h | 28 ++-- .../RimEclipseContourMapProjection.cpp | 6 +- .../RimEclipseContourMapView.cpp | 6 +- .../RimEclipseContourMapViewCollection.cpp | 16 ++ .../RimEclipseContourMapViewCollection.h | 3 + .../ProjectDataModel/RimEclipseResultCase.cpp | 3 +- .../RimEclipseResultDefinition.cpp | 21 ++- .../RimEclipseStatisticsCase.cpp | 31 ++-- .../RimEclipseStatisticsCaseEvaluator.cpp | 2 +- .../ProjectDataModel/RimEclipseView.cpp | 38 ++--- .../ProjectDataModel/RimEclipseView.h | 4 +- .../RimEclipseViewCollection.cpp | 122 ++++++++++++++ .../RimEclipseViewCollection.h | 49 ++++++ .../RimGridStatisticsPlot.cpp | 6 +- .../ProjectDataModel/RimGridView.cpp | 3 +- .../RimIdenticalGridCaseGroup.cpp | 5 +- .../ProjectDataModel/RimOilField.cpp | 8 + .../ProjectDataModel/RimOilField.h | 32 ++-- .../ProjectDataModel/RimProject.cpp | 4 + .../RimSimWellInViewCollection.cpp | 3 +- .../SocketInterface/RiaNNCCommands.cpp | 17 +- .../RiaPropertyDataCommands.cpp | 34 ++-- .../RiuAdvancedSnapshotExportWidget.cpp | 2 +- GrpcInterface/Python/rips/case.py | 26 ++- GrpcInterface/Python/rips/simulation_well.py | 7 +- GrpcInterface/Python/rips/view.py | 20 ++- GrpcInterface/RiaGrpcNNCPropertiesService.cpp | 17 +- 57 files changed, 626 insertions(+), 286 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.h diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellIndexFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellIndexFilterFeature.cpp index 95121dd465..88584f7830 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellIndexFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellIndexFilterFeature.cpp @@ -59,12 +59,15 @@ void RicNewCellIndexFilterFeature::onActionTriggered( bool isChecked ) RimCellFilterCollection* filtColl = colls[0]; // and the case to use - RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted(); + RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted()->ownerCase(); - RimCellIndexFilter* lastCreatedOrUpdated = filtColl->addNewCellIndexFilter( sourceCase ); - if ( lastCreatedOrUpdated ) + if ( sourceCase ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + RimCellIndexFilter* lastCreatedOrUpdated = filtColl->addNewCellIndexFilter( sourceCase ); + if ( lastCreatedOrUpdated ) + { + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + } } } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp index 8ffa493ef8..80a329c593 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp @@ -64,11 +64,13 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked ) } } - auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted(); - - if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) ) + auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted()->ownerCase(); + if ( sourceCase ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) ) + { + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + } } } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp index 124d299f63..a0d6b7772f 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp @@ -18,9 +18,11 @@ #include "RicNewRangeFilterSliceFeature.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimCellFilterCollection.h" #include "RimCellRangeFilter.h" + #include "Riu3DMainWindowTools.h" #include "cafCmdExecCommandManager.h" @@ -45,13 +47,16 @@ void RicNewRangeFilterSliceFeature::onActionTriggered( bool isChecked ) RimCellFilterCollection* filtColl = colls[0]; // and the case to use - RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted(); + RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted()->ownerCase(); - int gridIndex = 0; - RimCellFilter* lastCreatedOrUpdated = filtColl->addNewCellRangeFilter( sourceCase, gridIndex, m_sliceDirection ); - if ( lastCreatedOrUpdated ) + if ( sourceCase ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + int gridIndex = 0; + RimCellFilter* lastCreatedOrUpdated = filtColl->addNewCellRangeFilter( sourceCase, gridIndex, m_sliceDirection ); + if ( lastCreatedOrUpdated ) + { + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + } } } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp index db2ab3d874..414d96d9d0 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp @@ -18,9 +18,11 @@ #include "RicNewUserDefinedFilterFeature.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimCellFilterCollection.h" #include "RimUserDefinedFilter.h" + #include "Riu3DMainWindowTools.h" #include "cafSelectionManagerTools.h" @@ -41,12 +43,15 @@ void RicNewUserDefinedFilterFeature::onActionTriggered( bool isChecked ) RimCellFilterCollection* filtColl = colls[0]; // and the case to use - RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted(); + RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted()->ownerCase(); - RimUserDefinedFilter* lastCreatedOrUpdated = filtColl->addNewUserDefinedFilter( sourceCase ); - if ( lastCreatedOrUpdated ) + if ( sourceCase ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + RimUserDefinedFilter* lastCreatedOrUpdated = filtColl->addNewUserDefinedFilter( sourceCase ); + if ( lastCreatedOrUpdated ) + { + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + } } } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp index ec90f7893d..3e41191ae9 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp @@ -18,6 +18,7 @@ #include "RicNewUserDefinedIndexFilterFeature.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimCellFilterCollection.h" #include "RimUserDefinedIndexFilter.h" @@ -42,12 +43,15 @@ void RicNewUserDefinedIndexFilterFeature::onActionTriggered( bool isChecked ) RimCellFilterCollection* filtColl = colls[0]; // and the case to use - RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted(); + RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted()->ownerCase(); - auto* lastCreatedOrUpdated = filtColl->addNewUserDefinedIndexFilter( sourceCase ); - if ( lastCreatedOrUpdated ) + if ( sourceCase ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + auto* lastCreatedOrUpdated = filtColl->addNewUserDefinedIndexFilter( sourceCase ); + if ( lastCreatedOrUpdated ) + { + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + } } } diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp index 65a2d59a56..e24c88e6e1 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp @@ -103,8 +103,10 @@ void RicNewAzimuthDipIntersectionFeatureCmd::redo() intersection->setName( "Azimuth and Dip" ); intersection->configureForAzimuthLine(); - RimCase* rimCase = m_intersectionCollection->firstAncestorOrThisOfTypeAsserted(); - cvf::BoundingBox bBox = rimCase->allCellsBoundingBox(); + RimCase* rimCase = m_intersectionCollection->firstAncestorOrThisOfTypeAsserted()->ownerCase(); + if ( !rimCase ) return; + + cvf::BoundingBox bBox = rimCase->allCellsBoundingBox(); if ( bBox.isValid() ) { intersection->setLengthUp( cvf::Math::floor( bBox.extent()[2] / 2 ) ); diff --git a/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp index 0a4085f80f..f0951bac66 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp @@ -33,10 +33,12 @@ #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" +#include "RimEclipseViewCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "RimOilField.h" #include "RimProject.h" #include "RiuAdvancedSnapshotExportWidget.h" @@ -146,7 +148,7 @@ void RicAdvancedSnapshotExportFeature::exportMultipleSnapshots( const QString& f exportViewVariations( copyOfEclipseView, msd, folder ); - eclCase->reservoirViews().removeChild( copyOfEclipseView ); + removeViewFromViewCollection( copyOfEclipseView ); delete copyOfEclipseView; } @@ -207,7 +209,7 @@ void RicAdvancedSnapshotExportFeature::exportViewVariations( Rim3dView* rimView, exportViewVariationsToFolder( copyOfView, msd, folder ); } - eclCase->reservoirViews().removeChild( copyOfView ); + removeViewFromViewCollection( copyOfView ); delete copyOfView; } @@ -338,3 +340,19 @@ QString RicAdvancedSnapshotExportFeature::resultName( Rim3dView* rimView ) return ""; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdvancedSnapshotExportFeature::removeViewFromViewCollection( RimEclipseView* view ) +{ + RimProject* project = RimProject::current(); + if ( !project ) return; + + RimOilField* oilField = project->activeOilField(); + if ( !oilField ) return; + + RimEclipseViewCollection* viewColl = oilField->eclipseViewCollection(); + if ( !viewColl ) return; + viewColl->removeView( view ); +} diff --git a/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.h index 760b714b87..b5a0549b16 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.h @@ -24,6 +24,7 @@ class RimAdvancedSnapshotExportDefinition; class RimProject; class Rim3dView; class RimGridView; +class RimEclipseView; //================================================================================================== /// @@ -45,4 +46,5 @@ class RicAdvancedSnapshotExportFeature : public caf::CmdFeature private: static void exportViewVariationsToFolder( RimGridView* rimView, RimAdvancedSnapshotExportDefinition* msd, const QString& folder ); static QString resultName( Rim3dView* rimView ); + static void removeViewFromViewCollection( RimEclipseView* view ); }; diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp index c809985609..d2b68bd085 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp @@ -20,6 +20,7 @@ #include "RicPasteFeatureImpl.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimCellFilter.h" #include "RimCellFilterCollection.h" @@ -42,17 +43,9 @@ bool RicPasteCellFiltersFeature::isCommandEnabled() const std::vector> typedObjects; objectGroup.objectsByType( &typedObjects ); - if ( typedObjects.empty() ) - { - return false; - } - - if ( dynamic_cast( caf::SelectionManager::instance()->selectedItem() ) ) - { - return true; - } + if ( typedObjects.empty() ) return false; - return false; + return dynamic_cast( caf::SelectionManager::instance()->selectedItem() ) != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -63,7 +56,11 @@ void RicPasteCellFiltersFeature::onActionTriggered( bool isChecked ) auto cellFilterCollection = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); if ( !cellFilterCollection ) return; - auto eclipseCase = cellFilterCollection->firstAncestorOfType(); + auto view = cellFilterCollection->firstAncestorOfType(); + if ( !view ) return; + + auto eclipseCase = view->ownerCase(); + if ( !eclipseCase ) return; caf::PdmObjectGroup objectGroup; RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup ); diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp index 72c540ace8..0b94768e3b 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp @@ -186,9 +186,8 @@ void RicPasteEclipseCasesFeature::addCasesToGridCaseGroup( caf::PdmObjectGroup& gridCaseGroup->updateConnectedEditors(); - for ( size_t rvIdx = 0; rvIdx < rimResultReservoir->reservoirViews.size(); rvIdx++ ) + for ( RimEclipseView* riv : rimResultReservoir->reservoirViews() ) { - RimEclipseView* riv = rimResultReservoir->reservoirViews()[rvIdx]; riv->loadDataAndUpdate(); } } diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp index 55d36360da..c5b496630f 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp @@ -24,21 +24,22 @@ #include "Rim3dView.h" #include "RimCellEdgeColors.h" +#include "RimCellFilterCollection.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseContourMapProjection.h" #include "RimEclipseContourMapView.h" #include "RimEclipseContourMapViewCollection.h" #include "RimEclipseView.h" +#include "RimFaultInViewCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechContourMapView.h" #include "RimGeoMechContourMapViewCollection.h" #include "RimGeoMechView.h" +#include "RimOilField.h" +#include "RimProject.h" #include "RimRegularLegendConfig.h" - -#include "RimCellFilterCollection.h" -#include "RimFaultInViewCollection.h" #include "RimSimWellInViewCollection.h" #include "RimSurfaceInViewCollection.h" @@ -86,7 +87,7 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked ) { RimEclipseView* reservoirView = caf::SelectionManager::instance()->selectedItemOfType(); RimEclipseContourMapView* existingEclipseContourMap = caf::SelectionManager::instance()->selectedItemOfType(); - RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemAncestorOfType(); + RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemOfType(); RimEclipseContourMapView* eclipseContourMap = nullptr; RimGeoMechView* geoMechView = caf::SelectionManager::instance()->selectedItemOfType(); @@ -97,11 +98,19 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked ) // Find case to insert into if ( existingEclipseContourMap ) { - eclipseContourMap = createEclipseContourMapFromExistingContourMap( eclipseCase, existingEclipseContourMap ); + eclipseCase = existingEclipseContourMap->eclipseCase(); + if ( eclipseCase ) + { + eclipseContourMap = createEclipseContourMapFromExistingContourMap( eclipseCase, existingEclipseContourMap ); + } } else if ( reservoirView ) { - eclipseContourMap = createEclipseContourMapFrom3dView( eclipseCase, reservoirView ); + eclipseCase = reservoirView->eclipseCase(); + if ( eclipseCase ) + { + eclipseContourMap = createEclipseContourMapFrom3dView( eclipseCase, reservoirView ); + } } else if ( eclipseCase ) { @@ -138,6 +147,12 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked ) eclipseContourMap->createDisplayModelAndRedraw(); eclipseContourMap->zoomAll(); + RimProject* project = RimProject::current(); + + RimOilField* oilField = project->activeOilField(); + + oilField->eclipseContourMapCollection()->updateConnectedEditors(); + Riu3DMainWindowTools::setExpanded( eclipseContourMap ); } else if ( geoMechContourMap ) @@ -268,6 +283,8 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFr contourMap->initAfterReadRecursively(); + eclipseCase->contourMapCollection()->updateConnectedEditors(); + return contourMap; } diff --git a/ApplicationLibCode/Commands/RicVec3dPickEventHandler.cpp b/ApplicationLibCode/Commands/RicVec3dPickEventHandler.cpp index 995f59c40b..652a0e772f 100644 --- a/ApplicationLibCode/Commands/RicVec3dPickEventHandler.cpp +++ b/ApplicationLibCode/Commands/RicVec3dPickEventHandler.cpp @@ -42,10 +42,9 @@ bool RicVec3dPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eventObj cvf::Vec3d pickedPosition = eventObject.m_pickItemInfos.front().globalPickedPoint(); - RimCase* ownerCase = rimView->firstAncestorOrThisOfType(); - if ( ownerCase ) + if ( rimView->ownerCase() ) { - double zPickOffset = ownerCase->characteristicCellSize() * m_zOffsetFactor; + double zPickOffset = rimView->ownerCase()->characteristicCellSize() * m_zOffsetFactor; pickedPosition.z() += zPickOffset; } diff --git a/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp index 8b84699cb0..97dfdaaf22 100644 --- a/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -388,7 +388,7 @@ void RivWellPathPartMgr::appendPerforationsToModel( cvf::ModelBasicList* QDateTime currentTimeStamp; if ( m_rimView ) { - auto rimCase = m_rimView->firstAncestorOrThisOfType(); + auto rimCase = m_rimView->ownerCase(); if ( rimCase ) { diff --git a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp index 36ab921eb7..42d72709e2 100644 --- a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp @@ -382,8 +382,13 @@ void RivSurfacePartMgr::generatePartGeometry() void RivSurfacePartMgr::generateNativePartGeometry() { cvf::Vec3d displayModOffset( 0, 0, 0 ); - auto ownerCase = m_surfaceInView->firstAncestorOrThisOfType(); - if ( ownerCase ) displayModOffset = ownerCase->displayModelOffset(); + + auto view = m_surfaceInView->firstAncestorOrThisOfType(); + if ( view ) + { + auto ownerCase = view->ownerCase(); + if ( ownerCase ) displayModOffset = ownerCase->displayModelOffset(); + } m_usedSurfaceData = m_surfaceInView->surface()->surfaceData(); if ( m_usedSurfaceData.isNull() ) return; diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp index b8234e9da9..55d43e08cd 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp @@ -279,17 +279,19 @@ void RimAnnotationInViewCollection::defineEditorAttribute( const caf::PdmFieldHa if ( attr ) { - auto rimCase = firstAncestorOrThisOfType(); - if ( rimCase ) + if ( auto view = firstAncestorOrThisOfType() ) { - auto bb = rimCase->allCellsBoundingBox(); - attr->m_minimum = -bb.max().z(); - attr->m_maximum = -bb.min().z(); - } - else - { - attr->m_minimum = 0; - attr->m_maximum = 10000; + if ( auto rimCase = view->ownerCase() ) + { + auto bb = rimCase->allCellsBoundingBox(); + attr->m_minimum = -bb.max().z(); + attr->m_maximum = -bb.min().z(); + } + else + { + attr->m_minimum = 0; + attr->m_maximum = 10000; + } } } } diff --git a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake index d3366768f1..b132ac136d 100644 --- a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake @@ -134,6 +134,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimResultSelectionUi.h ${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.h ${CMAKE_CURRENT_LIST_DIR}/RimEmCase.h + ${CMAKE_CURRENT_LIST_DIR}/RimEclipseViewCollection.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -268,6 +269,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEmCase.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPolylinePickerInterface.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimEclipseViewCollection.cpp ) if(RESINSIGHT_USE_QT_CHARTS) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp index c78d1a630f..691d23a2ed 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp @@ -298,7 +298,8 @@ QString RimCellFilter::modeString() const //-------------------------------------------------------------------------------------------------- const cvf::StructGridInterface* RimCellFilter::selectedGrid() const { - auto rimCase = firstAncestorOrThisOfTypeAsserted(); + auto rimCase = firstAncestorOrThisOfTypeAsserted()->ownerCase(); + if ( !rimCase ) return nullptr; int clampedIndex = gridIndex(); if ( clampedIndex >= RigReservoirGridTools::gridCount( rimCase ) ) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp index 5fe2bb0774..a2074e16a4 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp @@ -160,7 +160,10 @@ void RimCellFilterCollection::initAfterRead() // Copy by xml serialization does not give a RimCase parent the first time initAfterRead is called here when creating a new a contour // view from a 3d view. The second time we get called it is ok, so just skip setting up the filter connections if we have no case. - auto rimCase = firstAncestorOrThisOfType(); + auto rimView = firstAncestorOrThisOfType(); + if ( rimView == nullptr ) return; + + auto rimCase = rimView->ownerCase(); if ( rimCase == nullptr ) return; for ( const auto& filter : m_cellFilters ) diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp index 805a5dde6e..a22bed1f95 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp @@ -145,7 +145,7 @@ void RimFlowCharacteristicsPlot::setFromFlowSolution( RimFlowDiagSolution* flowS { auto eclCase = flowSolution->firstAncestorOrThisOfType(); m_case = eclCase; - if ( !eclCase->reservoirViews.empty() ) + if ( !eclCase->reservoirViews().empty() ) { m_cellFilterView = eclCase->reservoirViews()[0]; } @@ -399,7 +399,7 @@ void RimFlowCharacteristicsPlot::defineUiOrdering( QString uiConfigName, caf::Pd { m_case = defaultCase; m_flowDiagSolution = m_case->defaultFlowDiagSolution(); - if ( !m_case()->reservoirViews.empty() ) + if ( !m_case()->reservoirViews().empty() ) { m_cellFilterView = m_case()->reservoirViews()[0]; } @@ -506,7 +506,7 @@ void RimFlowCharacteristicsPlot::fieldChangedByUi( const caf::PdmFieldHandle* ch { m_flowDiagSolution = m_case->defaultFlowDiagSolution(); m_currentlyPlottedTimeSteps.clear(); - if ( !m_case()->reservoirViews.empty() ) + if ( !m_case()->reservoirViews().empty() ) { m_cellFilterView = m_case()->reservoirViews()[0]; } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp index 2788a18535..ff0208564f 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp @@ -706,7 +706,7 @@ QList RimWellConnectivityTable::calculateValueOptions( c else if ( fieldNeedingOptions == &m_cellFilterView && m_case() ) { options.push_back( caf::PdmOptionItemInfo( "Disabled", nullptr ) ); - for ( RimEclipseView* view : m_case()->reservoirViews.childrenByType() ) + for ( RimEclipseView* view : m_case()->reservoirViews() ) { CVF_ASSERT( view && "Really always should have a valid view pointer in ReservoirViews" ); options.push_back( caf::PdmOptionItemInfo( view->name(), view, false, view->uiIconProvider() ) ); diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp index c047e8c101..d7eaf4b47f 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp @@ -104,11 +104,9 @@ QString RimGeoMechContourMapView::createAutoName() const QStringList generatedAutoTags; - auto ownerCase = firstAncestorOrThisOfTypeAsserted(); - - if ( nameConfig()->addCaseName() ) + if ( nameConfig()->addCaseName() && ownerCase() ) { - generatedAutoTags.push_back( ownerCase->caseUserDescription() ); + generatedAutoTags.push_back( ownerCase()->caseUserDescription() ); } if ( nameConfig()->addAggregationType() ) diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index 293eea1334..7b9777b9b6 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -226,11 +226,9 @@ QString RimGeoMechView::createAutoName() const QStringList generatedAutoTags; - RimCase* ownerCase = firstAncestorOrThisOfTypeAsserted(); - - if ( nameConfig()->addCaseName() ) + if ( nameConfig()->addCaseName() && ownerCase() ) { - generatedAutoTags.push_back( ownerCase->caseUserDescription() ); + generatedAutoTags.push_back( ownerCase()->caseUserDescription() ); } if ( nameConfig()->addProperty() ) diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp index 6d51700cc6..6c42e23180 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp @@ -1136,7 +1136,7 @@ QList RimGridCrossPlotDataSet::calculateValueOptions( co if ( eclipseCase ) { options.push_back( caf::PdmOptionItemInfo( "Disabled", nullptr ) ); - for ( RimEclipseView* view : eclipseCase->reservoirViews.childrenByType() ) + for ( RimEclipseView* view : eclipseCase->reservoirViews() ) { CVF_ASSERT( view && "Really always should have a valid view pointer in ReservoirViews" ); options.push_back( caf::PdmOptionItemInfo( view->name(), view, false, view->uiIconProvider() ) ); diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp index 3633f6a7f1..6ec5f151c7 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp @@ -656,7 +656,7 @@ void RimBoxIntersection::switchSingelPlaneState() //-------------------------------------------------------------------------------------------------- cvf::BoundingBox RimBoxIntersection::currentCellBoundingBox() { - auto rimCase = firstAncestorOrThisOfTypeAsserted(); + auto rimCase = firstAncestorOrThisOfTypeAsserted()->ownerCase(); return rimCase->activeCellsBoundingBox(); } diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp index f5845391b8..81d138bd53 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp @@ -328,7 +328,7 @@ void RimIntersectionCollection::appendIntersectionNoUpdate( RimExtrudedCurveInte //-------------------------------------------------------------------------------------------------- void RimIntersectionCollection::synchronize2dIntersectionViews() { - auto ownerCase = firstAncestorOrThisOfTypeAsserted(); + auto ownerCase = firstAncestorOrThisOfTypeAsserted()->ownerCase(); ownerCase->intersectionViewCollection()->syncFromExistingIntersections( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp index adaa8a426c..2769f569bb 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp @@ -72,8 +72,13 @@ void RimIntersectionResultsDefinitionCollection::appendIntersectionResultDefinit if ( interResDef->activeCase() == nullptr ) { - auto ownerCase = firstAncestorOrThisOfType(); - interResDef->setActiveCase( ownerCase ); + if ( auto gridView = firstAncestorOrThisOfType() ) + { + if ( auto ownerCase = gridView->ownerCase() ) + { + interResDef->setActiveCase( ownerCase ); + } + } } } diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp index 4fc6d0bd04..43b10d393e 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -176,7 +176,7 @@ RimCase* Rim2dIntersectionView::ownerCase() const if ( !rimCase ) { - rimCase = firstAncestorOrThisOfTypeAsserted(); + rimCase = firstAncestorOrThisOfTypeAsserted()->ownerCase(); } return rimCase; diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index d81b519916..86f6ef7e2e 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -1013,12 +1013,14 @@ void Rim3dOverlayInfoConfig::updateSeismicInfo( RimSeismicView* seisView ) //-------------------------------------------------------------------------------------------------- void Rim3dOverlayInfoConfig::update3DInfoIn2dViews() const { - RimCase* rimCase = firstAncestorOrThisOfType(); - if ( rimCase ) + if ( auto rimView = firstAncestorOrThisOfType() ) { - for ( Rim2dIntersectionView* view : rimCase->intersectionViewCollection()->views() ) + if ( RimCase* rimCase = rimView->ownerCase() ) { - view->update3dInfo(); + for ( Rim2dIntersectionView* view : rimCase->intersectionViewCollection()->views() ) + { + view->update3dInfo(); + } } } } diff --git a/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp b/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp index 046c5e7b7d..e02f198250 100644 --- a/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp @@ -190,9 +190,11 @@ void RimAdvancedSnapshotExportDefinition::fieldChangedByUi( const caf::PdmFieldH { actCellInfo = RigReservoirGridTools::activeCellInfo( view() ); - auto rimCase = view()->firstAncestorOrThisOfTypeAsserted(); - - mainGrid = RigReservoirGridTools::mainGrid( rimCase ); + auto rimCase = view()->ownerCase(); + if ( rimCase ) + { + mainGrid = RigReservoirGridTools::mainGrid( rimCase ); + } } if ( mainGrid && actCellInfo ) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index 17c2c98d8a..c0a904e64b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -58,6 +58,7 @@ #include "RimEclipseResultAddressCollection.h" #include "RimEclipseStatisticsCase.h" #include "RimEclipseView.h" +#include "RimEclipseViewCollection.h" #include "RimFaultInViewCollection.h" #include "RimFormationNames.h" #include "RimGridCollection.h" @@ -91,7 +92,7 @@ RimEclipseCase::RimEclipseCase() { CAF_PDM_InitScriptableObjectWithNameAndComment( "EclipseCase", ":/Case48x48.png", "", "", "Reservoir", "Abstract base class for Eclipse Cases" ); - CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault( &reservoirViews, "ReservoirViews", "Views", "", "", "", "All Eclipse Views in the case" ); + CAF_PDM_InitFieldNoDefault( &m_reservoirViews_OBSOLETE, "ReservoirViews", "Views", "", "", "", "All Eclipse Views in the case" ); CAF_PDM_InitFieldNoDefault( &m_matrixModelResults, "MatrixModelResults", "" ); CAF_PDM_InitFieldNoDefault( &m_fractureModelResults, "FractureModelResults", "" ); @@ -105,8 +106,8 @@ RimEclipseCase::RimEclipseCase() // https://github.com/OPM/ResInsight/issues/7308 m_filesContainingFaults.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps" ); - m_contourMapCollection = new RimEclipseContourMapViewCollection; + CAF_PDM_InitFieldNoDefault( &m_contourMapCollection_OBSOLETE, "ContourMaps", "2d Contour Maps" ); + m_contourMapCollection_OBSOLETE = new RimEclipseContourMapViewCollection; CAF_PDM_InitFieldNoDefault( &m_inputPropertyCollection, "InputPropertyCollection", "" ); m_inputPropertyCollection = new RimEclipseInputPropertyCollection; @@ -132,8 +133,6 @@ RimEclipseCase::RimEclipseCase() //-------------------------------------------------------------------------------------------------- RimEclipseCase::~RimEclipseCase() { - reservoirViews.deleteChildren(); - delete m_matrixModelResults(); delete m_fractureModelResults(); delete m_inputPropertyCollection; @@ -276,17 +275,32 @@ void RimEclipseCase::initAfterRead() { RimCase::initAfterRead(); - size_t j; - for ( j = 0; j < reservoirViews().size(); j++ ) + if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2024.03.0" ) ) { - RimEclipseView* riv = reservoirViews()[j]; - CVF_ASSERT( riv ); + // Move views to view collection. + RimEclipseViewCollection* viewColl = viewCollection(); + for ( size_t j = 0; j < m_reservoirViews_OBSOLETE.size(); j++ ) + { + RimEclipseView* riv = m_reservoirViews_OBSOLETE()[j]; + CVF_ASSERT( riv ); - riv->setEclipseCase( this ); - } - for ( RimEclipseContourMapView* contourMap : m_contourMapCollection->views() ) - { - contourMap->setEclipseCase( this ); + riv->setEclipseCase( this ); + m_reservoirViews_OBSOLETE.removeChild( riv ); + viewColl->addView( riv ); + } + + m_reservoirViews_OBSOLETE.clearWithoutDelete(); + + // Move contour maps + auto mapViewColl = contourMapCollection(); + for ( RimEclipseContourMapView* contourMap : m_contourMapCollection_OBSOLETE->views() ) + { + contourMap->setEclipseCase( this ); + m_contourMapCollection_OBSOLETE->removeChild( contourMap ); + mapViewColl->push_back( contourMap ); + } + + m_contourMapCollection_OBSOLETE->clearWithoutDelete(); } } @@ -295,29 +309,10 @@ void RimEclipseCase::initAfterRead() //-------------------------------------------------------------------------------------------------- RimEclipseView* RimEclipseCase::createAndAddReservoirView() { - RimEclipseView* rimEclipseView = new RimEclipseView(); - - rimEclipseView->setEclipseCase( this ); - - // Set default values - if ( rimEclipseView->currentGridCellResults() ) - { - auto defaultResult = rimEclipseView->currentGridCellResults()->defaultResult(); - rimEclipseView->cellResult()->setFromEclipseResultAddress( defaultResult ); - } - - auto prefs = RiaPreferences::current(); - rimEclipseView->faultCollection()->setActive( prefs->enableFaultsByDefault() ); - - rimEclipseView->cellEdgeResult()->setResultVariable( "MULT" ); - rimEclipseView->cellEdgeResult()->setActive( false ); - rimEclipseView->fractureColors()->setDefaultResultName(); + RimEclipseViewCollection* viewColl = viewCollection(); + if ( !viewColl ) return nullptr; - caf::PdmDocument::updateUiIconStateRecursively( rimEclipseView ); - - reservoirViews().push_back( rimEclipseView ); - - return rimEclipseView; + return viewColl->addView( this ); } //-------------------------------------------------------------------------------------------------- @@ -334,7 +329,10 @@ RimEclipseView* RimEclipseCase::createCopyAndAddView( const RimEclipseView* sour caf::PdmDocument::updateUiIconStateRecursively( rimEclipseView ); - reservoirViews().push_back( rimEclipseView ); + RimEclipseViewCollection* viewColl = viewCollection(); + if ( !viewColl ) return nullptr; + + viewColl->addView( rimEclipseView ); // Resolve references after reservoir view has been inserted into Rim structures rimEclipseView->resolveReferencesRecursively(); @@ -468,10 +466,8 @@ void RimEclipseCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField, computeCachedData(); - for ( size_t i = 0; i < reservoirViews().size(); i++ ) + for ( RimEclipseView* reservoirView : reservoirViews() ) { - RimEclipseView* reservoirView = reservoirViews()[i]; - reservoirView->scheduleReservoirGridGeometryRegen(); reservoirView->scheduleSimWellGeometryRegen(); reservoirView->createDisplayModelAndRedraw(); @@ -554,20 +550,10 @@ void RimEclipseCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin { if ( uiConfigName == "MainWindow.ProjectTree" ) { - std::vector children = reservoirViews.children(); - - for ( auto child : children ) - uiTreeOrdering.add( child ); - if ( !m_2dIntersectionViewCollection->views().empty() ) { uiTreeOrdering.add( &m_2dIntersectionViewCollection ); } - - if ( !m_contourMapCollection->views().empty() ) - { - uiTreeOrdering.add( &m_contourMapCollection ); - } } else if ( uiConfigName == "MainWindow.DataSources" ) { @@ -668,9 +654,15 @@ RimCaseCollection* RimEclipseCase::parentCaseCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEclipseContourMapViewCollection* RimEclipseCase::contourMapCollection() +RimEclipseContourMapViewCollection* RimEclipseCase::contourMapCollection() const { - return m_contourMapCollection; + RimProject* project = RimProject::current(); + if ( !project ) return nullptr; + + RimOilField* oilField = project->activeOilField(); + if ( !oilField ) return nullptr; + + return oilField->eclipseContourMapCollection(); } //-------------------------------------------------------------------------------------------------- @@ -1080,12 +1072,12 @@ bool RimEclipseCase::openReserviorCase() std::vector RimEclipseCase::allSpecialViews() const { std::vector views; - for ( RimEclipseView* view : reservoirViews ) + for ( RimEclipseView* view : reservoirViews() ) { views.push_back( view ); } - for ( RimEclipseContourMapView* view : m_contourMapCollection->views() ) + for ( RimEclipseContourMapView* view : contourMapViews() ) { views.push_back( view ); } @@ -1198,3 +1190,57 @@ void RimEclipseCase::updateResultAddressCollection() m_resultAddressCollections.deleteChildren(); updateConnectedEditors(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseViewCollection* RimEclipseCase::viewCollection() const +{ + RimProject* project = RimProject::current(); + if ( !project ) return nullptr; + + RimOilField* oilField = project->activeOilField(); + if ( !oilField ) return nullptr; + + return oilField->eclipseViewCollection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseCase::reservoirViews() const +{ + std::vector views; + if ( RimEclipseViewCollection* viewColl = viewCollection() ) + { + for ( auto view : viewColl->views() ) + { + if ( view && view->eclipseCase() && view->eclipseCase() == this ) + { + views.push_back( view ); + } + } + } + + return views; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseCase::contourMapViews() const +{ + std::vector views; + if ( RimEclipseContourMapViewCollection* viewColl = contourMapCollection() ) + { + for ( auto view : viewColl->views() ) + { + if ( view && view->eclipseCase() && view->eclipseCase() == this ) + { + views.push_back( view ); + } + } + } + + return views; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h index dad144c78d..bcd29f88df 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h @@ -52,6 +52,7 @@ class RimIdenticalGridCaseGroup; class RimReservoirCellResultsStorage; class RimEclipseResultAddressCollection; class RifReaderSettings; +class RimEclipseViewCollection; //================================================================================================== // @@ -66,8 +67,7 @@ class RimEclipseCase : public RimCase RimEclipseCase(); ~RimEclipseCase() override; - // Fields: - caf::PdmChildArrayField reservoirViews; + std::vector reservoirViews() const; std::vector filesContainingFaults() const; void setFilesContainingFaults( const std::vector& val ); @@ -99,7 +99,7 @@ class RimEclipseCase : public RimCase virtual QString locationOnDisc() const { return QString(); } RimCaseCollection* parentCaseCollection(); - RimEclipseContourMapViewCollection* contourMapCollection(); + RimEclipseContourMapViewCollection* contourMapCollection() const; RimEclipseInputPropertyCollection* inputPropertyCollection() const; QStringList timeStepStrings() const override; @@ -137,14 +137,18 @@ class RimEclipseCase : public RimCase // Internal methods protected: - void computeCachedData(); - void setReservoirData( RigEclipseCaseData* eclipseCase ); - std::vector additionalFiles() const; + void computeCachedData(); + void setReservoirData( RigEclipseCaseData* eclipseCase ); + std::vector additionalFiles() const; + RimEclipseViewCollection* viewCollection() const; + RimEclipseContourMapViewCollection* contourMapViewCollection() const; private: - void createTimeStepFormatString(); - std::vector allSpecialViews() const override; - void buildResultChildNodes(); + void createTimeStepFormatString(); + std::vector allSpecialViews() const override; + std::vector contourMapViews() const; + + void buildResultChildNodes(); protected: caf::PdmField m_flipXAxis; @@ -156,8 +160,6 @@ class RimEclipseCase : public RimCase private: caf::PdmField m_releaseResultMemory; - caf::PdmChildField m_contourMapCollection; - cvf::ref m_rigEclipseCase; QString m_timeStepFormatString; std::map m_wellToColorMap; @@ -168,4 +170,8 @@ class RimEclipseCase : public RimCase caf::PdmChildField m_fractureModelResults; caf::PdmField> m_filesContainingFaults; + + // Obsolete fields: + caf::PdmChildArrayField m_reservoirViews_OBSOLETE; + caf::PdmChildField m_contourMapCollection_OBSOLETE; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp index bda217ec3c..5fd2902241 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp @@ -31,6 +31,7 @@ #include "RigHexIntersectionTools.h" #include "RigMainGrid.h" +#include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseContourMapView.h" @@ -385,7 +386,10 @@ std::vector RimEclipseContourMapProjection::retrieveParameterWeights() //-------------------------------------------------------------------------------------------------- RimEclipseCase* RimEclipseContourMapProjection::eclipseCase() const { - return firstAncestorOrThisOfType(); + auto view = firstAncestorOrThisOfType(); + if ( !view ) return nullptr; + + return dynamic_cast( view->ownerCase() ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp index 67e3b0f960..ab7d42a662 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp @@ -108,11 +108,9 @@ QString RimEclipseContourMapView::createAutoName() const QStringList generatedAutoTags; - RimCase* ownerCase = firstAncestorOrThisOfTypeAsserted(); - - if ( nameConfig()->addCaseName() ) + if ( nameConfig()->addCaseName() && ownerCase() ) { - generatedAutoTags.push_back( ownerCase->caseUserDescription() ); + generatedAutoTags.push_back( ownerCase()->caseUserDescription() ); } if ( nameConfig()->addAggregationType() ) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp index 317765fca5..e688d7763b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp @@ -47,3 +47,19 @@ void RimEclipseContourMapViewCollection::onChildDeleted( caf::PdmChildArrayField auto eclipseCase = firstAncestorOrThisOfType(); if ( eclipseCase ) eclipseCase->updateConnectedEditors(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseContourMapViewCollection::clearWithoutDelete() +{ + m_contourMapViews.clearWithoutDelete(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseContourMapViewCollection::removeChild( RimEclipseContourMapView* contourMap ) +{ + m_contourMapViews.removeChild( contourMap ); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.h b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.h index ef7f60a1cf..1a7290a7de 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.h @@ -37,6 +37,9 @@ class RimEclipseContourMapViewCollection : public caf::PdmObject void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; + void clearWithoutDelete(); + void removeChild( RimEclipseContourMapView* contourMap ); + private: caf::PdmChildArrayField m_contourMapViews; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp index 5cb28a8360..63540ec2ab 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -500,12 +500,11 @@ RimEclipseResultCase::~RimEclipseResultCase() { // Disconnect all comparison views. In debug build on Windows, a crash occurs. The comparison view is also set to zero in the destructor // of Rim3dView() - for ( auto v : reservoirViews ) + for ( auto v : reservoirViews() ) { if ( v ) v->setComparisonView( nullptr ); } - reservoirViews.deleteChildren(); m_flowDiagSolutions.deleteChildren(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp index ee64dffbd6..c5dea97ccf 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -769,7 +769,9 @@ QList RimEclipseResultDefinition::calculateValueOptions( { options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) ); - auto eclipseCase = firstAncestorOrThisOfTypeAsserted(); + RimEclipseView* eclView = firstAncestorOrThisOfTypeAsserted(); + + auto eclipseCase = eclView->eclipseCase(); if ( eclipseCase && eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->mainGrid() ) { RimProject* proj = RimProject::current(); @@ -792,7 +794,9 @@ QList RimEclipseResultDefinition::calculateValueOptions( } else if ( fieldNeedingOptions == &m_timeLapseBaseTimestep ) { - RimEclipseCase* currentCase = firstAncestorOrThisOfTypeAsserted(); + RimEclipseView* eclView = firstAncestorOrThisOfTypeAsserted(); + + RimEclipseCase* currentCase = eclView->eclipseCase(); RimEclipseCase* baseCase = currentCase; if ( m_differenceCase ) @@ -802,13 +806,16 @@ QList RimEclipseResultDefinition::calculateValueOptions( options.push_back( caf::PdmOptionItemInfo( "Disabled", RigEclipseResultAddress::noTimeLapseValue() ) ); - std::vector stepDates = baseCase->timeStepDates(); - for ( size_t stepIdx = 0; stepIdx < stepDates.size(); ++stepIdx ) + if ( baseCase ) { - QString displayString = stepDates[stepIdx].toString( RiaQDateTimeTools::dateFormatString() ); - displayString += QString( " (#%1)" ).arg( stepIdx ); + std::vector stepDates = baseCase->timeStepDates(); + for ( size_t stepIdx = 0; stepIdx < stepDates.size(); ++stepIdx ) + { + QString displayString = stepDates[stepIdx].toString( RiaQDateTimeTools::dateFormatString() ); + displayString += QString( " (#%1)" ).arg( stepIdx ); - options.push_back( caf::PdmOptionItemInfo( displayString, static_cast( stepIdx ) ) ); + options.push_back( caf::PdmOptionItemInfo( displayString, static_cast( stepIdx ) ) ); + } } } } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp index 1feb6ca34b..1309f4709c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp @@ -444,11 +444,9 @@ void RimEclipseStatisticsCase::computeStatistics() //-------------------------------------------------------------------------------------------------- void RimEclipseStatisticsCase::scheduleACTIVEGeometryRegenOnReservoirViews() { - for ( size_t i = 0; i < reservoirViews().size(); i++ ) + for ( RimEclipseView* reservoirView : reservoirViews() ) { - RimEclipseView* reservoirView = reservoirViews()[i]; CVF_ASSERT( reservoirView ); - reservoirView->scheduleGeometryRegen( ACTIVE ); } } @@ -755,9 +753,8 @@ void RimEclipseStatisticsCase::fieldChangedByUi( const caf::PdmFieldHandle* chan caf::ProgressInfo progInfo( reservoirViews().size() + 1, "Updating Well Data for Views" ); // Update views - for ( size_t i = 0; i < reservoirViews().size(); i++ ) + for ( RimEclipseView* reservoirView : reservoirViews() ) { - RimEclipseView* reservoirView = reservoirViews()[i]; CVF_ASSERT( reservoirView ); reservoirView->wellCollection()->wells.deleteChildren(); @@ -961,18 +958,16 @@ bool RimEclipseStatisticsCase::hasComputedStatistics() const //-------------------------------------------------------------------------------------------------- void RimEclipseStatisticsCase::updateConnectedEditorsAndReservoirViews() { - for ( size_t i = 0; i < reservoirViews.size(); ++i ) + auto views = reservoirViews(); + for ( RimEclipseView* view : reservoirViews() ) { - if ( reservoirViews[i] ) - { - // As new result might have been introduced, update all editors connected - reservoirViews[i]->cellResult()->updateConnectedEditors(); + // As new result might have been introduced, update all editors connected + view->cellResult()->updateConnectedEditors(); - // It is usually not needed to create new display model, but if any derived geometry based on generated data - // (from Octave) a full display model rebuild is required - reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); - reservoirViews[i]->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); - } + // It is usually not needed to create new display model, but if any derived geometry based on generated data + // (from Octave) a full display model rebuild is required + view->scheduleCreateDisplayModelAndRedraw(); + view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } updateConnectedEditors(); @@ -1007,18 +1002,18 @@ void RimEclipseStatisticsCase::computeStatisticsAndUpdateViews() scheduleACTIVEGeometryRegenOnReservoirViews(); updateConnectedEditorsAndReservoirViews(); - if ( reservoirViews.empty() ) + if ( reservoirViews().empty() ) { RicNewViewFeature::addReservoirView( this, nullptr ); } - if ( reservoirViews.size() == 1 ) + if ( reservoirViews().size() == 1 ) { // If only one view, set the first result as active if ( auto cellResultsData = results( RiaDefines::PorosityModelType::MATRIX_MODEL ) ) { - auto firstView = reservoirViews[0]; + auto firstView = reservoirViews()[0]; std::vector resAddresses = cellResultsData->existingResults(); if ( firstView && !resAddresses.empty() ) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp index 3fcf0c53fd..23339631e6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp @@ -327,7 +327,7 @@ void RimEclipseStatisticsCaseEvaluator::evaluateForResults( const QList for ( RimEclipseCase* eclipseCase : m_sourceCases ) { - if ( eclipseCase->reservoirViews.empty() ) + if ( eclipseCase->reservoirViews().empty() ) { eclipseCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepIdx ); eclipseCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepIdx ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 20df13f052..ac89e2a377 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -144,7 +144,9 @@ RimEclipseView::RimEclipseView() "EclipseView", "The Eclipse 3d Reservoir View" ); - CAF_PDM_InitFieldNoDefault( &m_customEclipseCase, "CustomEclipseCase", "Custom Case" ); + CAF_PDM_InitFieldNoDefault( &m_customEclipseCase_OBSOLETE, "CustomEclipseCase", "Custom Case" ); + + CAF_PDM_InitScriptableFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case" ); CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault( &m_cellResult, "GridCellResult", "CellResult", "Cell Result", ":/CellResult.png" ); m_cellResult = new RimEclipseCellColors(); @@ -392,7 +394,7 @@ void RimEclipseView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, { RimGridView::fieldChangedByUi( changedField, oldValue, newValue ); - if ( changedField == &m_customEclipseCase ) + if ( changedField == &m_eclipseCase ) { propagateEclipseCaseToChildObjects(); @@ -1262,11 +1264,9 @@ QString RimEclipseView::createAutoName() const QStringList generatedAutoTags; - RimCase* ownerCase = firstAncestorOrThisOfTypeAsserted(); - - if ( nameConfig()->addCaseName() ) + if ( m_eclipseCase && nameConfig()->addCaseName() ) { - generatedAutoTags.push_back( ownerCase->caseUserDescription() ); + generatedAutoTags.push_back( m_eclipseCase->caseUserDescription() ); } if ( nameConfig()->addProperty() ) @@ -1568,8 +1568,6 @@ void RimEclipseView::setEclipseCase( RimEclipseCase* reservoir ) //-------------------------------------------------------------------------------------------------- RimEclipseCase* RimEclipseView::eclipseCase() const { - if ( m_customEclipseCase() != nullptr ) return m_customEclipseCase(); - return m_eclipseCase; } @@ -1897,6 +1895,8 @@ void RimEclipseView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& { Rim3dView::defineUiOrdering( uiConfigName, uiOrdering ); + uiOrdering.add( &m_eclipseCase ); + caf::PdmUiGroup* cellGroup = uiOrdering.addNewGroup( "Cell Visibility" ); cellGroup->add( &m_showInactiveCells ); cellGroup->add( &m_showInvalidCells ); @@ -1904,10 +1904,6 @@ void RimEclipseView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "View Name" ); nameConfig()->uiOrdering( uiConfigName, *nameGroup ); - caf::PdmUiGroup* advancedGroup = uiOrdering.addNewGroup( "Advanced" ); - advancedGroup->setCollapsedByDefault(); - advancedGroup->add( &m_customEclipseCase ); - uiOrdering.skipRemainingFields( true ); } @@ -1984,27 +1980,15 @@ std::set RimEclipseView::allVisibleFaultGeometryTypes() const //-------------------------------------------------------------------------------------------------- QList RimEclipseView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - if ( fieldNeedingOptions == &m_customEclipseCase ) + if ( fieldNeedingOptions == &m_eclipseCase ) { QList options; options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) ); - if ( m_eclipseCase && m_eclipseCase->mainGrid() ) + for ( auto eclCase : RimEclipseCaseTools::allEclipseGridCases() ) { - auto currentGridCount = m_eclipseCase->mainGrid()->gridCount(); - - for ( auto eclCase : RimEclipseCaseTools::allEclipseGridCases() ) - { - // Find all grid cases with same number of LGRs. If the grid count differs, a crash will happen related to - // RimGridCollection::mainEclipseGrid(). This function is using firstAncestorOrThisOfType() to find the Eclipse case. If the - // custom case in RimEclipseView has a different number of LGRs, a crash will happen - - if ( eclCase && ( eclCase != m_eclipseCase ) && eclCase->mainGrid() && eclCase->mainGrid()->gridCount() == currentGridCount ) - { - options.push_back( caf::PdmOptionItemInfo( eclCase->caseUserDescription(), eclCase, false, eclCase->uiIconProvider() ) ); - } - } + options.push_back( caf::PdmOptionItemInfo( eclCase->caseUserDescription(), eclCase, false, eclCase->uiIconProvider() ) ); } return options; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h index 573dad6557..4ff0b550b4 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h @@ -245,8 +245,8 @@ class RimEclipseView : public RimGridView caf::PdmChildField m_propertyFilterCollection; caf::PdmPointer m_overridePropertyFilterCollection; - caf::PdmPointer m_eclipseCase; - caf::PdmPtrField m_customEclipseCase; + caf::PdmPtrField m_eclipseCase; + caf::PdmPtrField m_customEclipseCase_OBSOLETE; cvf::ref m_reservoirGridPartManager; cvf::ref m_simWellsPartManager; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.cpp new file mode 100644 index 0000000000..aa67681149 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.cpp @@ -0,0 +1,122 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimEclipseViewCollection.h" + +#include "RiaLogging.h" +#include "RiaPreferences.h" + +#include "RigCaseCellResultsData.h" + +#include "Rim3dView.h" +#include "RimCellEdgeColors.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseView.h" +#include "RimFaultInViewCollection.h" +#include "RimGridView.h" +#include "RimProject.h" +#include "RimStimPlanColors.h" + +CAF_PDM_SOURCE_INIT( RimEclipseViewCollection, "EclipseViewCollection", "EclipseViewCollection" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseViewCollection::RimEclipseViewCollection() +{ + CAF_PDM_InitObject( "Views", ":/3DView16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_views, "Views", "Eclipse Views" ); + + setDeletable( false ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseViewCollection::~RimEclipseViewCollection() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseViewCollection::views() const +{ + return m_views.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseViewCollection::isEmpty() +{ + return !m_views.hasChildren(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseView* RimEclipseViewCollection::addView( RimEclipseCase* eclipseCase ) +{ + RimEclipseView* view = new RimEclipseView(); + + view->setEclipseCase( eclipseCase ); + + // Set default values + if ( view->currentGridCellResults() ) + { + auto defaultResult = view->currentGridCellResults()->defaultResult(); + view->cellResult()->setFromEclipseResultAddress( defaultResult ); + } + + auto prefs = RiaPreferences::current(); + view->faultCollection()->setActive( prefs->enableFaultsByDefault() ); + + view->cellEdgeResult()->setResultVariable( "MULT" ); + view->cellEdgeResult()->setActive( false ); + view->fractureColors()->setDefaultResultName(); + + caf::PdmDocument::updateUiIconStateRecursively( view ); + + m_views.push_back( view ); + + view->loadDataAndUpdate(); + + updateConnectedEditors(); + + return view; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseViewCollection::addView( RimEclipseView* view ) +{ + m_views.push_back( view ); + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseViewCollection::removeView( RimEclipseView* view ) +{ + m_views.removeChild( view ); + updateConnectedEditors(); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.h b/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.h new file mode 100644 index 0000000000..024b6b5e03 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "cafPdmField.h" + +#include "cafPdmChildArrayField.h" +#include "cafPdmObject.h" + +#include + +class RimEclipseView; +class RimEclipseCase; + +class RimEclipseViewCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimEclipseViewCollection(); + ~RimEclipseViewCollection() override; + + bool isEmpty(); + + RimEclipseView* addView( RimEclipseCase* eclipseCase ); + void addView( RimEclipseView* view ); + + void removeView( RimEclipseView* view ); + + std::vector views() const; + +private: + caf::PdmChildArrayField m_views; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.cpp index 0325337b75..868447158d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.cpp @@ -96,9 +96,9 @@ void RimGridStatisticsPlot::setDefaults() m_property->setResultType( RiaDefines::ResultCatType::STATIC_NATIVE ); m_property->setResultVariable( "PORO" ); - if ( eclipseCase && !eclipseCase->reservoirViews.children().empty() ) + if ( eclipseCase && !eclipseCase->reservoirViews().empty() ) { - m_cellFilterView.setValue( eclipseCase->reservoirViews.childrenByType().front() ); + m_cellFilterView.setValue( eclipseCase->reservoirViews().front() ); } m_numHistogramBins = 15; @@ -196,7 +196,7 @@ QList RimGridStatisticsPlot::calculateValueOptions( cons if ( eclipseCase ) { options.push_back( caf::PdmOptionItemInfo( "Disabled", nullptr ) ); - for ( RimEclipseView* view : eclipseCase->reservoirViews.childrenByType() ) + for ( RimEclipseView* view : eclipseCase->reservoirViews() ) { CVF_ASSERT( view && "Really always should have a valid view pointer in ReservoirViews" ); options.push_back( caf::PdmOptionItemInfo( view->name(), view, false, view->uiIconProvider() ) ); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp index d9074993b9..0de0fb62b9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp @@ -378,9 +378,8 @@ void RimGridView::onCreatePartCollectionFromSelection( cvf::Collection( items[i] ); - if ( eclipseSelItem && eclipseSelItem->m_view == this ) + if ( eclipseSelItem && eclipseSelItem->m_view == this && eclipseSelItem->m_resultDefinition->eclipseCase() ) { - CVF_ASSERT( eclipseSelItem->m_resultDefinition->eclipseCase() ); CVF_ASSERT( eclipseSelItem->m_resultDefinition->eclipseCase()->eclipseCaseData() ); RivSingleCellPartGenerator partGen( eclipseSelItem->m_resultDefinition->eclipseCase()->eclipseCaseData(), diff --git a/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 8b740585af..8fce6f1add 100644 --- a/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -398,9 +398,10 @@ void RimIdenticalGridCaseGroup::clearStatisticsResults() rimStaticsCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->clearAllResults(); } - for ( size_t j = 0; j < rimStaticsCase->reservoirViews.size(); j++ ) + auto views = rimStaticsCase->reservoirViews(); + for ( size_t j = 0; j < views.size(); j++ ) { - RimEclipseView* rimReservoirView = rimStaticsCase->reservoirViews[j]; + RimEclipseView* rimReservoirView = views[j]; rimReservoirView->cellResult()->setResultVariable( RiaResultNames::undefinedResultName() ); rimReservoirView->cellEdgeResult()->setResultVariable( RiaResultNames::undefinedResultName() ); rimReservoirView->loadDataAndUpdate(); diff --git a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp index ac36308e79..0497cf065f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp @@ -23,6 +23,8 @@ #include "RimAnnotationCollection.h" #include "RimCompletionTemplateCollection.h" #include "RimEclipseCaseCollection.h" +#include "RimEclipseContourMapViewCollection.h" +#include "RimEclipseViewCollection.h" #include "RimEnsembleWellLogsCollection.h" #include "RimFormationNamesCollection.h" #include "RimFractureTemplateCollection.h" @@ -75,6 +77,12 @@ RimOilField::RimOilField() CAF_PDM_InitFieldNoDefault( &seismicViewCollection, "SeismicViewCollection", "Seismic Views" ); seismicViewCollection = new RimSeismicViewCollection(); + CAF_PDM_InitFieldNoDefault( &eclipseViewCollection, "EclipseViewCollection", "Eclipse Views", ":/3DView16x16.png" ); + eclipseViewCollection = new RimEclipseViewCollection(); + + CAF_PDM_InitFieldNoDefault( &eclipseContourMapCollection, "ContourMaps", "2d Contour Maps" ); + eclipseContourMapCollection = new RimEclipseContourMapViewCollection; + completionTemplateCollection = new RimCompletionTemplateCollection; analysisModels = new RimEclipseCaseCollection(); wellPathCollection = new RimWellPathCollection(); diff --git a/ApplicationLibCode/ProjectDataModel/RimOilField.h b/ApplicationLibCode/ProjectDataModel/RimOilField.h index 60b17c698b..246ad5ea0f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimOilField.h +++ b/ApplicationLibCode/ProjectDataModel/RimOilField.h @@ -42,6 +42,8 @@ class RimSeismicViewCollection; class RimSurfaceCollection; class RimEnsembleWellLogsCollection; class RimPolygonCollection; +class RimEclipseViewCollection; +class RimEclipseContourMapViewCollection; //================================================================================================== /// @@ -61,20 +63,22 @@ class RimOilField : public caf::PdmObject RimValveTemplateCollection* valveTemplateCollection(); const RimValveTemplateCollection* valveTemplateCollection() const; - caf::PdmChildField analysisModels; - caf::PdmChildField geoMechModels; - caf::PdmChildField wellPathCollection; - caf::PdmChildField completionTemplateCollection; - caf::PdmChildField summaryCaseMainCollection; - caf::PdmChildField observedDataCollection; - caf::PdmChildField formationNamesCollection; - caf::PdmChildField annotationCollection; - caf::PdmChildField measurement; - caf::PdmChildField surfaceCollection; - caf::PdmChildField seismicDataCollection; - caf::PdmChildField seismicViewCollection; - caf::PdmChildField ensembleWellLogsCollection; - caf::PdmChildField polygonCollection; + caf::PdmChildField analysisModels; + caf::PdmChildField geoMechModels; + caf::PdmChildField wellPathCollection; + caf::PdmChildField completionTemplateCollection; + caf::PdmChildField summaryCaseMainCollection; + caf::PdmChildField observedDataCollection; + caf::PdmChildField formationNamesCollection; + caf::PdmChildField annotationCollection; + caf::PdmChildField measurement; + caf::PdmChildField surfaceCollection; + caf::PdmChildField seismicDataCollection; + caf::PdmChildField seismicViewCollection; + caf::PdmChildField eclipseViewCollection; + caf::PdmChildField ensembleWellLogsCollection; + caf::PdmChildField polygonCollection; + caf::PdmChildField eclipseContourMapCollection; protected: void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index ab1945d156..4494e782aa 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -49,6 +49,8 @@ #include "RimDialogData.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" +#include "RimEclipseContourMapViewCollection.h" +#include "RimEclipseViewCollection.h" #include "RimEnsembleWellLogsCollection.h" #include "RimFileWellPath.h" #include "RimFlowPlotCollection.h" @@ -1490,6 +1492,7 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q if ( oilField ) { if ( oilField->analysisModels() ) uiTreeOrdering.add( oilField->analysisModels() ); + if ( oilField->eclipseViewCollection() ) uiTreeOrdering.add( oilField->eclipseViewCollection() ); if ( oilField->geoMechModels() ) uiTreeOrdering.add( oilField->geoMechModels() ); if ( oilField->wellPathCollection() ) uiTreeOrdering.add( oilField->wellPathCollection() ); if ( oilField->polygonCollection() ) uiTreeOrdering.add( oilField->polygonCollection() ); @@ -1503,6 +1506,7 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q if ( oilField->formationNamesCollection() ) uiTreeOrdering.add( oilField->formationNamesCollection() ); if ( oilField->completionTemplateCollection() ) uiTreeOrdering.add( oilField->completionTemplateCollection() ); if ( oilField->annotationCollection() ) uiTreeOrdering.add( oilField->annotationCollection() ); + if ( oilField->eclipseContourMapCollection() ) uiTreeOrdering.add( oilField->eclipseContourMapCollection() ); } uiTreeOrdering.add( colorLegendCollection() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp index 4124a28645..00519da768 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -567,8 +567,7 @@ void RimSimWellInViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& u //-------------------------------------------------------------------------------------------------- void RimSimWellInViewCollection::assignDefaultWellColors() { - auto ownerCase = firstAncestorOrThisOfTypeAsserted(); - + auto ownerCase = m_reservoirView->eclipseCase(); for ( size_t wIdx = 0; wIdx < wells.size(); ++wIdx ) { RimSimWellInView* well = wells[wIdx]; diff --git a/ApplicationLibCode/SocketInterface/RiaNNCCommands.cpp b/ApplicationLibCode/SocketInterface/RiaNNCCommands.cpp index aa567a5f91..b46b1d114b 100644 --- a/ApplicationLibCode/SocketInterface/RiaNNCCommands.cpp +++ b/ApplicationLibCode/SocketInterface/RiaNNCCommands.cpp @@ -554,18 +554,15 @@ class RiaSetNNCProperty : public RiaSocketCommand m_currentReservoir->eclipseCaseData()->results( m_porosityModelEnum )->recalculateStatistics( m_currentEclResultAddress ); } - for ( size_t i = 0; i < m_currentReservoir->reservoirViews.size(); ++i ) + for ( RimEclipseView* view : m_currentReservoir->reservoirViews() ) { - if ( m_currentReservoir->reservoirViews[i] ) - { - // As new result might have been introduced, update all editors connected - m_currentReservoir->reservoirViews[i]->cellResult()->updateConnectedEditors(); + // As new result might have been introduced, update all editors connected + view->cellResult()->updateConnectedEditors(); - // It is usually not needed to create new display model, but if any derived geometry based on - // generated data (from Octave) a full display model rebuild is required - m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); - m_currentReservoir->reservoirViews[i]->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); - } + // It is usually not needed to create new display model, but if any derived geometry based on + // generated data (from Octave) a full display model rebuild is required + view->scheduleCreateDisplayModelAndRedraw(); + view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } diff --git a/ApplicationLibCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationLibCode/SocketInterface/RiaPropertyDataCommands.cpp index 0d7380a81e..5f91a374d9 100644 --- a/ApplicationLibCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationLibCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -658,18 +658,15 @@ class RiaSetActiveCellProperty : public RiaSocketCommand m_currentReservoir->eclipseCaseData()->results( m_porosityModelEnum )->recalculateStatistics( m_currentEclResultAddress ); } - for ( size_t i = 0; i < m_currentReservoir->reservoirViews.size(); ++i ) + for ( RimEclipseView* view : m_currentReservoir->reservoirViews() ) { - if ( m_currentReservoir->reservoirViews[i] ) - { - // As new result might have been introduced, update all editors connected - m_currentReservoir->reservoirViews[i]->cellResult()->updateConnectedEditors(); + // As new result might have been introduced, update all editors connected + view->cellResult()->updateConnectedEditors(); - // It is usually not needed to create new display model, but if any derived geometry based on - // generated data (from Octave) a full display model rebuild is required - m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); - m_currentReservoir->reservoirViews[i]->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); - } + // It is usually not needed to create new display model, but if any derived geometry based on + // generated data (from Octave) a full display model rebuild is required + view->scheduleCreateDisplayModelAndRedraw(); + view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } @@ -1033,18 +1030,15 @@ class RiaSetGridProperty : public RiaSocketCommand ->recalculateStatistics( RigEclipseResultAddress( m_currentResultAddress ) ); } - for ( size_t i = 0; i < m_currentReservoir->reservoirViews.size(); ++i ) + for ( RimEclipseView* view : m_currentReservoir->reservoirViews() ) { - if ( m_currentReservoir->reservoirViews[i] ) - { - // As new result might have been introduced, update all editors connected - m_currentReservoir->reservoirViews[i]->cellResult()->updateConnectedEditors(); + // As new result might have been introduced, update all editors connected + view->cellResult()->updateConnectedEditors(); - // It is usually not needed to create new display model, but if any derived geometry based on - // generated data (from Octave) a full display model rebuild is required - m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); - m_currentReservoir->reservoirViews[i]->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); - } + // It is usually not needed to create new display model, but if any derived geometry based on + // generated data (from Octave) a full display model rebuild is required + view->scheduleCreateDisplayModelAndRedraw(); + view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } diff --git a/ApplicationLibCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp b/ApplicationLibCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp index f4ea30066e..9889804058 100644 --- a/ApplicationLibCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp +++ b/ApplicationLibCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp @@ -147,7 +147,7 @@ void RiuAdvancedSnapshotExportWidget::addSnapshotItemFromActiveView() multiSnapshot->timeStepStart = activeView->currentTimeStep(); multiSnapshot->timeStepEnd = activeView->currentTimeStep(); - auto sourceCase = activeView->firstAncestorOrThisOfType(); + auto sourceCase = activeView->ownerCase(); if ( sourceCase ) { multiSnapshot->additionalCases().push_back( sourceCase ); diff --git a/GrpcInterface/Python/rips/case.py b/GrpcInterface/Python/rips/case.py index 695ec6b22b..6b36fdc80a 100644 --- a/GrpcInterface/Python/rips/case.py +++ b/GrpcInterface/Python/rips/case.py @@ -325,13 +325,31 @@ def view(self, view_id): Returns: :class:`rips.generated.generated_classes.View` """ - views = self.views() + project = self.ancestor(rips.project.Project) + views = project.views() for view_object in views: if view_object.id == view_id: return view_object return None +@add_method(Case) +def views(self): + """Get all views of a case + + Returns: + List of :class:`rips.generated.generated_classes.View` + """ + project = self.ancestor(rips.project.Project) + views = project.views() + views_for_case = [] + for view_object in views: + view_object.print_object_info() + if view_object.id == self.id: + views_for_case.append(view_object) + return views_for_case + + @add_method(Case) def create_view(self): """Create a new view in the current case @@ -990,8 +1008,10 @@ def simulation_wells(self): :class:`rips.generated.generated_classes.SimulationWell` """ - wells = self.descendants(SimulationWell) - return wells + if self.views(): + # Use the first view to get simulation wells. + return self.views()[0].descendants(SimulationWell) + return [] @add_method(Case) diff --git a/GrpcInterface/Python/rips/simulation_well.py b/GrpcInterface/Python/rips/simulation_well.py index 7c29d1c4e0..9b6f1b3e81 100644 --- a/GrpcInterface/Python/rips/simulation_well.py +++ b/GrpcInterface/Python/rips/simulation_well.py @@ -14,6 +14,7 @@ from .resinsight_classes import SimulationWell from .case import Case +from .view import View from .pdmobject import PdmObjectBase, add_method from typing import List, Optional @@ -80,4 +81,8 @@ def cells( @add_method(SimulationWell) def case(self: SimulationWell) -> Optional[Case]: - return self.ancestor(Case) + view = self.ancestor(View) + if view: + return view.case() + else: + return None diff --git a/GrpcInterface/Python/rips/view.py b/GrpcInterface/Python/rips/view.py index b034d2be1e..cf7cb53bd2 100644 --- a/GrpcInterface/Python/rips/view.py +++ b/GrpcInterface/Python/rips/view.py @@ -187,12 +187,24 @@ def export_property(self, undefined_value=0.0): ) -@add_method(ViewWindow) +def extract_address(address) -> int: + # Address form: "RimReservoir:123345345345435" + parts = address.split(":") + return int(parts[1]) + + +@add_method(View) def case(self): """Get the case the view belongs to""" - mycase = self.ancestor(rips.case.Case) - assert mycase is not None - return mycase + project = self.ancestor(rips.project.Project) + + eclipse_case_addr = extract_address(self.eclipse_case) + + cases = project.cases() + for c in cases: + if c.address() == eclipse_case_addr: + return c + return None @add_method(ViewWindow) diff --git a/GrpcInterface/RiaGrpcNNCPropertiesService.cpp b/GrpcInterface/RiaGrpcNNCPropertiesService.cpp index 4ffcf58c52..ef9075635f 100644 --- a/GrpcInterface/RiaGrpcNNCPropertiesService.cpp +++ b/GrpcInterface/RiaGrpcNNCPropertiesService.cpp @@ -462,18 +462,15 @@ void RiaNNCInputValuesStateHandler::finish() inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED_NOT_SAVED; } - for ( size_t i = 0; i < m_eclipseCase->reservoirViews.size(); ++i ) + for ( RimEclipseView* view : m_eclipseCase->reservoirViews() ) { - if ( m_eclipseCase->reservoirViews[i] ) - { - // As new result might have been introduced, update all editors connected - m_eclipseCase->reservoirViews[i]->cellResult()->updateConnectedEditors(); + // As new result might have been introduced, update all editors connected + view->cellResult()->updateConnectedEditors(); - // It is usually not needed to create new display model, but if any derived geometry based on - // generated data (from Octave) a full display model rebuild is required - m_eclipseCase->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); - m_eclipseCase->reservoirViews[i]->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); - } + // It is usually not needed to create new display model, but if any derived geometry based on + // generated data (from Octave) a full display model rebuild is required + view->scheduleCreateDisplayModelAndRedraw(); + view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } From 4f8c0816698b9a8abbad8e4b61e242b9934153be Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 12 Apr 2024 12:43:16 +0200 Subject: [PATCH 030/332] Support global and local views. --- .../Commands/RicNewViewFeature.cpp | 39 ++++++++++++++++--- .../Commands/RicNewViewFeature.h | 14 ++++--- .../RimContextCommandBuilder.cpp | 5 +++ .../ProjectDataModel/RimEclipseCase.cpp | 36 ++++++++++++++--- .../ProjectDataModel/RimEclipseCase.h | 5 ++- .../ProjectDataModel/RimGridCollection.cpp | 6 ++- 6 files changed, 86 insertions(+), 19 deletions(-) diff --git a/ApplicationLibCode/Commands/RicNewViewFeature.cpp b/ApplicationLibCode/Commands/RicNewViewFeature.cpp index 1907f42cd3..eed089898a 100644 --- a/ApplicationLibCode/Commands/RicNewViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewViewFeature.cpp @@ -23,8 +23,10 @@ #include "Rim3dView.h" #include "RimEclipseCase.h" +#include "RimEclipseCaseTools.h" #include "RimEclipseContourMapView.h" #include "RimEclipseView.h" +#include "RimEclipseViewCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechView.h" @@ -39,9 +41,9 @@ CAF_CMD_SOURCE_INIT( RicNewViewFeature, "RicNewViewFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewViewFeature::addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase ) +void RicNewViewFeature::addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, bool useGlobalViewCollection ) { - Rim3dView* newView = createReservoirView( eclipseCase, geomCase ); + Rim3dView* newView = createReservoirView( eclipseCase, geomCase, useGlobalViewCollection ); if ( newView ) { @@ -58,7 +60,7 @@ void RicNewViewFeature::addReservoirView( RimEclipseCase* eclipseCase, RimGeoMec bool RicNewViewFeature::isCommandEnabled() const { return selectedEclipseCase() != nullptr || selectedEclipseView() != nullptr || selectedGeoMechCase() != nullptr || - selectedGeoMechView() != nullptr; + selectedGeoMechView() != nullptr || selectedEclipseViewCollection() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -76,7 +78,21 @@ void RicNewViewFeature::onActionTriggered( bool isChecked ) if ( geoMechView ) geomCase = geoMechView->geoMechCase(); if ( reservoirView ) eclipseCase = reservoirView->eclipseCase(); - addReservoirView( eclipseCase, geomCase ); + bool useGlobalViewCollection = false; + if ( selectedEclipseViewCollection() ) + { + // Use global view collection if view collection is not descendant of Eclipse case. + useGlobalViewCollection = selectedEclipseViewCollection()->firstAncestorOrThisOfType() == nullptr; + if ( !eclipseCase ) + { + auto eclipseCases = RimEclipseCaseTools::allEclipseGridCases(); + if ( !eclipseCases.empty() ) + { + eclipseCase = eclipseCases[0]; + } + } + } + addReservoirView( eclipseCase, geomCase, useGlobalViewCollection ); } //-------------------------------------------------------------------------------------------------- @@ -91,13 +107,13 @@ void RicNewViewFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim3dView* RicNewViewFeature::createReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase ) +Rim3dView* RicNewViewFeature::createReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, bool useGlobalViewCollection ) { RimGridView* insertedView = nullptr; if ( eclipseCase ) { - insertedView = eclipseCase->createAndAddReservoirView(); + insertedView = eclipseCase->createAndAddReservoirView( useGlobalViewCollection ); } else if ( geomCase ) { @@ -171,6 +187,17 @@ RimEclipseView* RicNewViewFeature::selectedEclipseView() return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseViewCollection* RicNewViewFeature::selectedEclipseViewCollection() +{ + std::vector selection; + caf::SelectionManager::instance()->objectsByType( &selection ); + if ( !selection.empty() ) return selection[0]; + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicNewViewFeature.h b/ApplicationLibCode/Commands/RicNewViewFeature.h index f5a6645e9a..c145641072 100644 --- a/ApplicationLibCode/Commands/RicNewViewFeature.h +++ b/ApplicationLibCode/Commands/RicNewViewFeature.h @@ -26,6 +26,7 @@ class RimEclipseView; class RimGeoMechCase; class RimGeoMechView; class Rim3dView; +class RimEclipseViewCollection; //================================================================================================== /// @@ -35,7 +36,7 @@ class RicNewViewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static void addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase ); + static void addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, bool useGlobalViewCollection = false ); protected: bool isCommandEnabled() const override; @@ -43,10 +44,11 @@ class RicNewViewFeature : public caf::CmdFeature void setupActionLook( QAction* actionToSetup ) override; private: - static Rim3dView* createReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase ); + static Rim3dView* createReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, bool useGlobalViewCollectin ); - static RimEclipseCase* selectedEclipseCase(); - static RimGeoMechCase* selectedGeoMechCase(); - static RimEclipseView* selectedEclipseView(); - static RimGeoMechView* selectedGeoMechView(); + static RimEclipseCase* selectedEclipseCase(); + static RimGeoMechCase* selectedGeoMechCase(); + static RimEclipseView* selectedEclipseView(); + static RimGeoMechView* selectedGeoMechView(); + static RimEclipseViewCollection* selectedEclipseViewCollection(); }; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 5eb216b2d5..5cf14ed840 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -60,6 +60,7 @@ #include "RimEclipseResultCase.h" #include "RimEclipseStatisticsCase.h" #include "RimEclipseView.h" +#include "RimEclipseViewCollection.h" #include "RimElasticProperties.h" #include "RimEllipseFractureTemplate.h" #include "RimEnsembleCurveFilterCollection.h" @@ -282,6 +283,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicComputeStatisticsFeature"; menuBuilder << "Separator"; } + else if ( dynamic_cast( firstUiItem ) ) + { + menuBuilder << "RicNewViewFeature"; + } else if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicRenameCaseFeature"; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index c0a904e64b..e8fe32a5e9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -117,6 +117,9 @@ RimEclipseCase::RimEclipseCase() m_resultAddressCollections.uiCapability()->setUiHidden( true ); m_resultAddressCollections.xmlCapability()->disableIO(); + CAF_PDM_InitFieldNoDefault( &m_viewCollection, "ViewCollection", "Views" ); + m_viewCollection = new RimEclipseViewCollection; + // Init m_matrixModelResults = new RimReservoirCellResultsStorage; @@ -136,6 +139,7 @@ RimEclipseCase::~RimEclipseCase() delete m_matrixModelResults(); delete m_fractureModelResults(); delete m_inputPropertyCollection; + delete m_viewCollection; RimProject* project = RimProject::current(); if ( project ) @@ -307,9 +311,9 @@ void RimEclipseCase::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEclipseView* RimEclipseCase::createAndAddReservoirView() +RimEclipseView* RimEclipseCase::createAndAddReservoirView( bool useGlobalViewCollection ) { - RimEclipseViewCollection* viewColl = viewCollection(); + RimEclipseViewCollection* viewColl = useGlobalViewCollection ? globalViewCollection() : viewCollection(); if ( !viewColl ) return nullptr; return viewColl->addView( this ); @@ -550,6 +554,11 @@ void RimEclipseCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin { if ( uiConfigName == "MainWindow.ProjectTree" ) { + for ( auto view : m_viewCollection->views() ) + { + uiTreeOrdering.add( view ); + } + if ( !m_2dIntersectionViewCollection->views().empty() ) { uiTreeOrdering.add( &m_2dIntersectionViewCollection ); @@ -1195,6 +1204,14 @@ void RimEclipseCase::updateResultAddressCollection() /// //-------------------------------------------------------------------------------------------------- RimEclipseViewCollection* RimEclipseCase::viewCollection() const +{ + return m_viewCollection; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseViewCollection* RimEclipseCase::globalViewCollection() const { RimProject* project = RimProject::current(); if ( !project ) return nullptr; @@ -1211,7 +1228,18 @@ RimEclipseViewCollection* RimEclipseCase::viewCollection() const std::vector RimEclipseCase::reservoirViews() const { std::vector views; - if ( RimEclipseViewCollection* viewColl = viewCollection() ) + + addViewsFromViewCollection( views, viewCollection() ); + addViewsFromViewCollection( views, globalViewCollection() ); + return views; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::addViewsFromViewCollection( std::vector& views, const RimEclipseViewCollection* viewColl ) const +{ + if ( viewColl ) { for ( auto view : viewColl->views() ) { @@ -1221,8 +1249,6 @@ std::vector RimEclipseCase::reservoirViews() const } } } - - return views; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h index bcd29f88df..933fc62742 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h @@ -91,7 +91,7 @@ class RimEclipseCase : public RimCase RimReservoirCellResultsStorage* resultsStorage( RiaDefines::PorosityModelType porosityModel ); const RimReservoirCellResultsStorage* resultsStorage( RiaDefines::PorosityModelType porosityModel ) const; - RimEclipseView* createAndAddReservoirView(); + RimEclipseView* createAndAddReservoirView( bool useGlobalViewCollection = false ); RimEclipseView* createCopyAndAddView( const RimEclipseView* sourceView ); const RigVirtualPerforationTransmissibilities* computeAndGetVirtualPerforationTransmissibilities(); @@ -141,7 +141,9 @@ class RimEclipseCase : public RimCase void setReservoirData( RigEclipseCaseData* eclipseCase ); std::vector additionalFiles() const; RimEclipseViewCollection* viewCollection() const; + RimEclipseViewCollection* globalViewCollection() const; RimEclipseContourMapViewCollection* contourMapViewCollection() const; + void addViewsFromViewCollection( std::vector& views, const RimEclipseViewCollection* viewColl ) const; private: void createTimeStepFormatString(); @@ -168,6 +170,7 @@ class RimEclipseCase : public RimCase caf::PdmChildField m_matrixModelResults; caf::PdmChildField m_fractureModelResults; + caf::PdmChildField m_viewCollection; caf::PdmField> m_filesContainingFaults; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimGridCollection.cpp index 6afed2a8bb..3de30778da 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridCollection.cpp @@ -19,6 +19,7 @@ #include "RimGridCollection.h" #include "RimEclipseCase.h" +#include "RimEclipseView.h" #include "RimGridView.h" #include "RigMainGrid.h" @@ -479,7 +480,10 @@ void RimGridCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrde //-------------------------------------------------------------------------------------------------- const RigMainGrid* RimGridCollection::mainEclipseGrid() const { - auto eclipseCase = firstAncestorOrThisOfType(); + RimEclipseView* gridView = firstAncestorOrThisOfType(); + if ( !gridView ) return nullptr; + + auto eclipseCase = gridView->eclipseCase(); return eclipseCase ? eclipseCase->mainGrid() : nullptr; } From 9c0f601ba64f7e648e538daa5444cdf7ff3d0e8e Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 12 Apr 2024 13:36:29 +0200 Subject: [PATCH 031/332] Fix crash when creating contour map from 3d view. --- .../Commands/RicNewContourMapViewFeature.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp index c5b496630f..38efadedc4 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp @@ -273,14 +273,6 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFr contourMap->synchronizeLocalAnnotationsFromGlobal(); - // Resolve references after contour map has been inserted into Rim structures - std::vector fieldsWithFailingResolve; - contourMap->resolveReferencesRecursively( &fieldsWithFailingResolve ); - - // TODO: Introduce the assert when code is stable - // If we have intersections on well paths, the resolving is now failing - // CVF_ASSERT(fieldsWithFailingResolve.empty()); - contourMap->initAfterReadRecursively(); eclipseCase->contourMapCollection()->updateConnectedEditors(); From 21041c476dc2e7734d9238f5509828ce8158d7ea Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 12 Apr 2024 14:01:45 +0200 Subject: [PATCH 032/332] Show case option in contour map view. --- .../ProjectDataModel/RimEclipseContourMapView.cpp | 2 ++ ApplicationLibCode/ProjectDataModel/RimEclipseView.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp index ab7d42a662..56a6407ede 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp @@ -212,6 +212,8 @@ void RimEclipseContourMapView::defineUiOrdering( QString uiConfigName, caf::PdmU viewGroup->add( &m_showAxisLines ); viewGroup->add( &m_showScaleLegend ); + uiOrdering.add( &m_eclipseCase ); + caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Contour Map Name" ); nameConfig()->uiOrdering( uiConfigName, *nameGroup ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h index 4ff0b550b4..a5730e9a4b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h @@ -222,7 +222,8 @@ class RimEclipseView : public RimGridView void propagateEclipseCaseToChildObjects(); protected: - cvf::ref m_faultReactVizModel; + cvf::ref m_faultReactVizModel; + caf::PdmPtrField m_eclipseCase; private: caf::PdmField m_showInvalidCells; @@ -245,7 +246,6 @@ class RimEclipseView : public RimGridView caf::PdmChildField m_propertyFilterCollection; caf::PdmPointer m_overridePropertyFilterCollection; - caf::PdmPtrField m_eclipseCase; caf::PdmPtrField m_customEclipseCase_OBSOLETE; cvf::ref m_reservoirGridPartManager; From ce6199289f30f0e7a1851d3b2bc117b38554a833 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 12 Apr 2024 14:29:41 +0200 Subject: [PATCH 033/332] Show case option when not in the tree. --- ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index ac89e2a377..5500a07395 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -1895,7 +1895,8 @@ void RimEclipseView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& { Rim3dView::defineUiOrdering( uiConfigName, uiOrdering ); - uiOrdering.add( &m_eclipseCase ); + // Only show case option when not under a case in the project tree. + if ( !firstAncestorOrThisOfType() ) uiOrdering.add( &m_eclipseCase ); caf::PdmUiGroup* cellGroup = uiOrdering.addNewGroup( "Cell Visibility" ); cellGroup->add( &m_showInactiveCells ); From 39b9a25faaa9d08926f6b4ad1096fa781976716d Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 12 Apr 2024 14:56:32 +0200 Subject: [PATCH 034/332] Fix update of grid nodes. --- ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp | 9 --------- ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index e8fe32a5e9..0be60bdcb4 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -1063,15 +1063,6 @@ bool RimEclipseCase::openReserviorCase() } } - // Update grids node - { - std::vector gridColls = descendantsIncludingThisOfType(); - for ( RimGridCollection* gridCollection : gridColls ) - { - gridCollection->syncFromMainEclipseGrid(); - } - } - return true; } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 5500a07395..1b5edba896 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -385,6 +385,13 @@ void RimEclipseView::propagateEclipseCaseToChildObjects() faultResultSettings()->customFaultResult()->setEclipseCase( currentEclipseCase ); cellFilterCollection()->setCase( currentEclipseCase ); m_streamlineCollection->setEclipseCase( currentEclipseCase ); + + // Update grids node + std::vector gridColls = descendantsIncludingThisOfType(); + for ( RimGridCollection* gridCollection : gridColls ) + { + gridCollection->syncFromMainEclipseGrid(); + } } //-------------------------------------------------------------------------------------------------- From 030688cff673c175dd2504ee8564218f72155358 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 16 Apr 2024 14:22:15 +0200 Subject: [PATCH 035/332] Several adjustments related to Qt6 * Avoid ambiguous definition during unity build on Windows * Add missing include * Add Qt6 to expressionparser * Add Qt6 to nightcharts * Replace forward define of QStringList with include * Use toMSecsSinceEpoch * Use setContentsMargins --- .../Application/RiaRftPltCurveDefinition.cpp | 2 +- .../Application/RiaStringListSerializer.h | 3 +-- .../Tools/RiaImportEclipseCaseTools.h | 3 ++- .../Application/Tools/RiaSummaryStringTools.h | 3 ++- .../Application/Tools/RiaSummaryTools.h | 3 +-- .../Application/Tools/RiaTextStringTools.h | 4 ++-- .../RicfApplicationTools.h | 3 ++- .../Commands/RicGridStatisticsDialog.cpp | 2 +- .../RicSummaryPlotFeatureImpl.h | 3 +-- .../RifCaseRealizationParametersReader.h | 2 +- .../FileInterface/RifEclipseSummaryTools.h | 2 +- .../FileInterface/RifHdf5ReaderInterface.h | 7 +++--- .../RimContextCommandBuilder.h | 3 ++- .../RigHexIntersectionTools.h | 1 + .../ReservoirDataModel/RigNNCData.h | 3 ++- .../RiuGroupedBarChartBuilder.cpp | 4 ++-- .../RiuFlowCharacteristicsPlot.cpp | 2 +- .../RiuGridStatisticsHistogramWidget.h | 2 +- .../UserInterface/RiuMessagePanel.cpp | 5 +++- .../UserInterface/RiuMultiPlotPage.cpp | 2 +- .../UserInterface/RiuProjectPropertyView.cpp | 4 ++-- .../UserInterface/RiuPropertyViewTabWidget.h | 2 +- .../UserInterface/RiuResultTextBuilder.cpp | 2 +- .../UserInterface/RiuSimpleHistogramWidget.h | 3 +-- .../UserInterface/RiuWellAllocationPlot.cpp | 2 +- Fwk/AppFwk/cafAnimControl/CMakeLists.txt | 24 +++++++++++++------ .../cafUserInterface/cafProgressInfo.cpp | 6 +++++ ThirdParty/expressionparser/CMakeLists.txt | 11 ++++++--- ThirdParty/nightcharts/CMakeLists.txt | 11 ++++++--- ThirdParty/nightcharts/nightcharts.cpp | 6 ++--- 30 files changed, 81 insertions(+), 49 deletions(-) diff --git a/ApplicationLibCode/Application/RiaRftPltCurveDefinition.cpp b/ApplicationLibCode/Application/RiaRftPltCurveDefinition.cpp index 4c32f442f6..ef60ecd6d2 100644 --- a/ApplicationLibCode/Application/RiaRftPltCurveDefinition.cpp +++ b/ApplicationLibCode/Application/RiaRftPltCurveDefinition.cpp @@ -72,7 +72,7 @@ auto RiaRftPltCurveDefinition::operator<=>( const RiaRftPltCurveDefinition& othe { if ( m_wellName == other.m_wellName ) { - return m_timeStep.toTime_t() <=> other.m_timeStep.toTime_t(); + return m_timeStep.toMSecsSinceEpoch() <=> other.m_timeStep.toMSecsSinceEpoch(); } return m_wellName.toStdString() <=> other.m_wellName.toStdString(); } diff --git a/ApplicationLibCode/Application/RiaStringListSerializer.h b/ApplicationLibCode/Application/RiaStringListSerializer.h index 1848e02224..cdcfce4692 100644 --- a/ApplicationLibCode/Application/RiaStringListSerializer.h +++ b/ApplicationLibCode/Application/RiaStringListSerializer.h @@ -19,8 +19,7 @@ #pragma once #include - -class QStringList; +#include //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h index 35e91708c2..ec6be06c67 100644 --- a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h +++ b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h @@ -18,13 +18,14 @@ #pragma once +#include + #include #include #include #include class QString; -class QStringList; class RimIdenticalGridCaseGroup; class RimRoffCase; diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h b/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h index 056850a755..1c9150026c 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h +++ b/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h @@ -18,6 +18,8 @@ #pragma once +#include + #include #include @@ -26,7 +28,6 @@ class RifEclipseSummaryAddress; class RimSummaryCaseCollection; class QString; -class QStringList; //================================================================================================== // diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h index e293625716..e232162407 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h +++ b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h @@ -22,6 +22,7 @@ #include "RimObservedDataCollection.h" #include +#include #include @@ -38,8 +39,6 @@ class RimObservedDataCollection; class RimSummaryCurve; class RimUserDefinedCalculation; -class QStringList; - namespace caf { class PdmObject; diff --git a/ApplicationLibCode/Application/Tools/RiaTextStringTools.h b/ApplicationLibCode/Application/Tools/RiaTextStringTools.h index a3b726273a..cd14bc3beb 100644 --- a/ApplicationLibCode/Application/Tools/RiaTextStringTools.h +++ b/ApplicationLibCode/Application/Tools/RiaTextStringTools.h @@ -19,9 +19,9 @@ #pragma once #include -#include +#include -class QStringList; +#include //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationLibCode/CommandFileInterface/RicfApplicationTools.h b/ApplicationLibCode/CommandFileInterface/RicfApplicationTools.h index 74c9a02184..16a037cda4 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfApplicationTools.h +++ b/ApplicationLibCode/CommandFileInterface/RicfApplicationTools.h @@ -19,12 +19,13 @@ #pragma once #include +#include + #include class RimEclipseCase; class RimEclipseView; class RimWellPath; -class QStringList; //================================================================================================== // diff --git a/ApplicationLibCode/Commands/RicGridStatisticsDialog.cpp b/ApplicationLibCode/Commands/RicGridStatisticsDialog.cpp index 7f6a619854..86a012275c 100644 --- a/ApplicationLibCode/Commands/RicGridStatisticsDialog.cpp +++ b/ApplicationLibCode/Commands/RicGridStatisticsDialog.cpp @@ -79,7 +79,7 @@ RicGridStatisticsDialog::RicGridStatisticsDialog( QWidget* parent ) dialogLayout->addWidget( m_mainViewWidget ); QVBoxLayout* mainViewLayout = new QVBoxLayout(); - mainViewLayout->setMargin( 0 ); + mainViewLayout->setContentsMargins( 0, 0, 0, 0 ); m_mainViewWidget->setLayout( mainViewLayout ); mainViewLayout->addWidget( m_label ); mainViewLayout->addWidget( m_textEdit ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h index ecad0cca8d..e083e3a887 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h @@ -18,6 +18,7 @@ #pragma once #include +#include #include #include @@ -35,8 +36,6 @@ class RimSummaryCase; class RimSummaryCaseCollection; class RimEnsembleCurveSet; -class QStringList; - class RicSummaryPlotFeatureImpl { public: diff --git a/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.h b/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.h index 1487796f73..231a3fa6f1 100644 --- a/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.h +++ b/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.h @@ -23,6 +23,7 @@ #include "RigCaseRealizationParameters.h" #include +#include #include #include @@ -30,7 +31,6 @@ #include #include -class QStringList; class QTextStream; class QXmlStreamReader; class QFile; diff --git a/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.h b/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.h index 6fe52bc5cb..053c3c5a8f 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.h +++ b/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.h @@ -23,12 +23,12 @@ #include "ert/ecl/ecl_sum.hpp" #include +#include #include #include class RifSummaryReaderInterface; -class QStringList; //================================================================================================== // diff --git a/ApplicationLibCode/FileInterface/RifHdf5ReaderInterface.h b/ApplicationLibCode/FileInterface/RifHdf5ReaderInterface.h index efaccdd192..084ee8f445 100644 --- a/ApplicationLibCode/FileInterface/RifHdf5ReaderInterface.h +++ b/ApplicationLibCode/FileInterface/RifHdf5ReaderInterface.h @@ -18,13 +18,14 @@ #pragma once -class QString; -class QDateTime; -class QStringList; +#include #include #include +class QString; +class QDateTime; + //================================================================================================== // // diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.h b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.h index 86b70ddeb7..894400a06f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.h +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.h @@ -20,6 +20,8 @@ #pragma once #include +#include + #include namespace caf @@ -28,7 +30,6 @@ class CmdFeatureMenuBuilder; } class QString; -class QStringList; class QMenu; class RimWellPath; class RimScriptCollection; diff --git a/ApplicationLibCode/ReservoirDataModel/RigHexIntersectionTools.h b/ApplicationLibCode/ReservoirDataModel/RigHexIntersectionTools.h index c8f256231f..7ec4b9b1fc 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigHexIntersectionTools.h +++ b/ApplicationLibCode/ReservoirDataModel/RigHexIntersectionTools.h @@ -22,6 +22,7 @@ #include "cvfVector3.h" #include +#include //================================================================================================== /// Internal class for intersection point info diff --git a/ApplicationLibCode/ReservoirDataModel/RigNNCData.h b/ApplicationLibCode/ReservoirDataModel/RigNNCData.h index ad034a9daf..189d2d1ea5 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationLibCode/ReservoirDataModel/RigNNCData.h @@ -27,6 +27,8 @@ #include "cvfStructGrid.h" #include "cvfVector3.h" +#include + #include // Needed for HUGE_VAL on Linux #include #include @@ -36,7 +38,6 @@ class RigActiveCellInfo; class RigMainGrid; class RigCell; class RigEclipseResultAddress; -class QStringList; class RigNNCData : public cvf::Object { diff --git a/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.cpp b/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.cpp index 272fdf5d12..4404c3b6cc 100644 --- a/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.cpp +++ b/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.cpp @@ -138,13 +138,13 @@ class RiuBarChartScaleDraw : public QwtScaleDraw { int lineCount = 1 + posTickTypeText.second.label.count( "\n" ); mediumTextLineCount = std::max( mediumTextLineCount, lineCount ); - medTickMaxTextSize = std::max( posTickTypeText.second.label.size(), medTickMaxTextSize ); + medTickMaxTextSize = std::max( (int)posTickTypeText.second.label.size(), medTickMaxTextSize ); } else if ( posTickTypeText.second.tickType == QwtScaleDiv::MinorTick ) { int lineCount = 1 + posTickTypeText.second.label.count( "\n" ); minorTextLineCount = std::max( minorTextLineCount, lineCount ); - minTickMaxTextSize = std::max( posTickTypeText.second.label.size(), minTickMaxTextSize ); + minTickMaxTextSize = std::max( (int)posTickTypeText.second.label.size(), minTickMaxTextSize ); } } diff --git a/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.cpp b/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.cpp index 0ce10200fe..4d0dc9efb4 100644 --- a/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.cpp @@ -63,7 +63,7 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPl QGridLayout* mainLayout = new QGridLayout(); setLayout( mainLayout ); - layout()->setMargin( 3 ); + layout()->setContentsMargins( 3, 3, 3, 3 ); layout()->setSpacing( 3 ); // White background diff --git a/ApplicationLibCode/UserInterface/RiuGridStatisticsHistogramWidget.h b/ApplicationLibCode/UserInterface/RiuGridStatisticsHistogramWidget.h index 29d44de659..7868ae36fd 100644 --- a/ApplicationLibCode/UserInterface/RiuGridStatisticsHistogramWidget.h +++ b/ApplicationLibCode/UserInterface/RiuGridStatisticsHistogramWidget.h @@ -20,11 +20,11 @@ #pragma once +#include #include class QPaintEvent; class QString; -class QStringList; class RiuGridStatisticsHistogramWidget : public QWidget { diff --git a/ApplicationLibCode/UserInterface/RiuMessagePanel.cpp b/ApplicationLibCode/UserInterface/RiuMessagePanel.cpp index 2e4bcdb8f5..a4fb4dd7e3 100644 --- a/ApplicationLibCode/UserInterface/RiuMessagePanel.cpp +++ b/ApplicationLibCode/UserInterface/RiuMessagePanel.cpp @@ -44,7 +44,10 @@ RiuMessagePanel::RiuMessagePanel( QWidget* parent ) : QWidget( parent ) { QVBoxLayout* layout = new QVBoxLayout( this ); - layout->setMargin( caf::StyleSheetTools::smallContentMargin() ); + layout->setContentsMargins( caf::StyleSheetTools::smallContentMargin(), + caf::StyleSheetTools::smallContentMargin(), + caf::StyleSheetTools::smallContentMargin(), + caf::StyleSheetTools::smallContentMargin() ); m_textEdit = new QPlainTextEdit; m_textEdit->setReadOnly( true ); diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp index 8bee618c16..a353d17f61 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp @@ -91,7 +91,7 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* pare CAF_ASSERT( m_plotDefinition ); m_layout = new QVBoxLayout( this ); - m_layout->setMargin( 0 ); + m_layout->setContentsMargins( 0, 0, 0, 0 ); m_layout->setSpacing( 4 ); m_plotTitle = createTitleLabel(); diff --git a/ApplicationLibCode/UserInterface/RiuProjectPropertyView.cpp b/ApplicationLibCode/UserInterface/RiuProjectPropertyView.cpp index eb38dcf905..bedf57652f 100644 --- a/ApplicationLibCode/UserInterface/RiuProjectPropertyView.cpp +++ b/ApplicationLibCode/UserInterface/RiuProjectPropertyView.cpp @@ -74,7 +74,7 @@ RiuProjectAndPropertyView::RiuProjectAndPropertyView( QWidget* parent, Qt::Windo propertyHeader->setFixedHeight( 20 ); QVBoxLayout* layout = new QVBoxLayout; - layout->setMargin( 0 ); + layout->setContentsMargins( 0, 0, 0, 0 ); layout->addWidget( propertyHeader ); layout->addWidget( m_propertyView ); @@ -87,7 +87,7 @@ RiuProjectAndPropertyView::RiuProjectAndPropertyView( QWidget* parent, Qt::Windo splitter->addWidget( propertyEditorWithHeader ); QVBoxLayout* layout = new QVBoxLayout; - layout->setMargin( 0 ); + layout->setContentsMargins( 0, 0, 0, 0 ); layout->addWidget( splitter ); setLayout( layout ); diff --git a/ApplicationLibCode/UserInterface/RiuPropertyViewTabWidget.h b/ApplicationLibCode/UserInterface/RiuPropertyViewTabWidget.h index 81690cb5f1..f4e0e3ed38 100644 --- a/ApplicationLibCode/UserInterface/RiuPropertyViewTabWidget.h +++ b/ApplicationLibCode/UserInterface/RiuPropertyViewTabWidget.h @@ -19,6 +19,7 @@ #pragma once #include +#include namespace caf { @@ -29,7 +30,6 @@ class PdmUiPropertyView; class QDialogButtonBox; class QWidget; class QString; -class QStringList; class RiuPropertyViewTabWidget : public QDialog { diff --git a/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp index 566f1bf07b..1b6108486f 100644 --- a/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp @@ -999,7 +999,7 @@ QString RiuResultTextBuilder::cellResultText( const std::vector #include class QPaintEvent; -class QString; -class QStringList; class RiuSimpleHistogramWidget : public QWidget { diff --git a/ApplicationLibCode/UserInterface/RiuWellAllocationPlot.cpp b/ApplicationLibCode/UserInterface/RiuWellAllocationPlot.cpp index e922448f72..1138ebe7ef 100644 --- a/ApplicationLibCode/UserInterface/RiuWellAllocationPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuWellAllocationPlot.cpp @@ -46,7 +46,7 @@ RiuWellAllocationPlot::RiuWellAllocationPlot( RimWellAllocationPlot* plotDefinit QVBoxLayout* mainLayout = new QVBoxLayout(); setLayout( mainLayout ); - layout()->setMargin( 0 ); + layout()->setContentsMargins( 0, 0, 0, 0 ); layout()->setSpacing( 2 ); m_titleLabel = new QLabel( this ); diff --git a/Fwk/AppFwk/cafAnimControl/CMakeLists.txt b/Fwk/AppFwk/cafAnimControl/CMakeLists.txt index c2ae404234..c8dc1fc27d 100644 --- a/Fwk/AppFwk/cafAnimControl/CMakeLists.txt +++ b/Fwk/AppFwk/cafAnimControl/CMakeLists.txt @@ -11,13 +11,23 @@ set(MOC_HEADER_FILES cafFrameAnimationControl.h cafAnimationToolBar.h cafPopupMenuButton.h ) -find_package( - Qt5 - COMPONENTS - REQUIRED Core Gui Widgets -) -set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets) -qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) +if(CEE_USE_QT6) + find_package( + Qt6 + COMPONENTS + REQUIRED Core Gui Widgets + ) + set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets) + qt_standard_project_setup() +else() + find_package( + Qt5 + COMPONENTS + REQUIRED Core Gui Widgets + ) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets) + qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) +endif() # NOTE! Resources in this subfolder appends to the variable QRC_FILES in parent # scope CMakeList.txt in the application folder (parent scope) must use the diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index 3d7bac7dd3..7980caa197 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -34,7 +34,13 @@ // //################################################################################################## +// This include is required to avoid ambiguous definition during unity build +#ifdef WIN32 +#include +#endif // WIN32 + #include "cafProgressInfo.h" + #include "cafAssert.h" #include "cafMemoryInspector.h" #include "cafProgressState.h" diff --git a/ThirdParty/expressionparser/CMakeLists.txt b/ThirdParty/expressionparser/CMakeLists.txt index 83045dbe6e..f9afaa51e0 100644 --- a/ThirdParty/expressionparser/CMakeLists.txt +++ b/ThirdParty/expressionparser/CMakeLists.txt @@ -7,9 +7,14 @@ if(MSVC) message(STATUS "MSVC: Enabled increased number of sections in object files") endif() - -find_package(Qt5 COMPONENTS REQUIRED Core) -set(QT_LIBRARIES Qt5::Core) +if (CEE_USE_QT6) + find_package(Qt6 COMPONENTS REQUIRED Core) + set(QT_LIBRARIES Qt6::Core) + qt_standard_project_setup() +else() + find_package(Qt5 COMPONENTS REQUIRED Core) + set(QT_LIBRARIES Qt5::Core) +endif() list (APPEND MAIN_SOURCE_FILES ExpressionParser.h diff --git a/ThirdParty/nightcharts/CMakeLists.txt b/ThirdParty/nightcharts/CMakeLists.txt index 63d6a88f43..8c79e7386a 100644 --- a/ThirdParty/nightcharts/CMakeLists.txt +++ b/ThirdParty/nightcharts/CMakeLists.txt @@ -2,9 +2,14 @@ cmake_minimum_required (VERSION 2.8.12) project (nightcharts) -find_package(Qt5 COMPONENTS REQUIRED Core Widgets) -set(QT_LIBRARIES Qt5::Core Qt5::Widgets) -qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) +if (CEE_USE_QT6) + find_package(Qt6 COMPONENTS REQUIRED Core Gui Widgets) + set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets) + qt_standard_project_setup() +else() + find_package(Qt5 COMPONENTS REQUIRED Core Gui Widgets) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets) +endif() list (APPEND MAIN_SOURCE_FILES nightcharts.h diff --git a/ThirdParty/nightcharts/nightcharts.cpp b/ThirdParty/nightcharts/nightcharts.cpp index bb2ebd9ddd..207489719e 100644 --- a/ThirdParty/nightcharts/nightcharts.cpp +++ b/ThirdParty/nightcharts/nightcharts.cpp @@ -330,7 +330,7 @@ int Nightcharts::draw(QPainter *painter) painter->drawRect(cX+pDist+i*(pW + pDist),cY+cH,pW,-cH/100*pieces[i].pPerc-5); QString label = QString::number(pieces[i].pPerc)+"%"; painter->setPen(Qt::SolidLine); - painter->drawText(cX+pDist+i*(pW + pDist)+pW/2-painter->fontMetrics().width(label)/2,cY+cH-cH/100*pieces[i].pPerc-painter->fontMetrics().height()/2,label); + painter->drawText(cX+pDist+i*(pW + pDist)+pW/2-painter->fontMetrics().horizontalAdvance(label)/2,cY+cH-cH/100*pieces[i].pPerc-painter->fontMetrics().height()/2,label); } painter->setPen(Qt::SolidLine); for (int i=1;i<10;i++) @@ -386,12 +386,12 @@ void Nightcharts::drawLegend(QPainter *painter) } painter->drawLine(p.x(),p.y(),p_.x(),p_.y()); QString label = pieces[i].pname + " - " + QString::number(pieces[i].pPerc)+"%"; - float recW = painter->fontMetrics().width(label)+10; + float recW = painter->fontMetrics().horizontalAdvance(label)+10; float recH = painter->fontMetrics().height()+10; p_.setX(p_.x()-recW/2 + recW/2*cos(angle*M_PI/180)); p_.setY(p_.y()+recH/2 + recH/2*sin(angle*M_PI/180)); painter->setBrush(textColor); - painter->drawRoundRect(p_.x() ,p_.y(), recW, -recH); + painter->drawRect(p_.x() ,p_.y(), recW, -recH); painter->drawText(p_.x()+5, p_.y()-recH/2+5, label); angle -= pdegree/2; } From abf61090cc7dc7251140461c3fd5c8db6d1e6542 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Tue, 16 Apr 2024 12:55:06 +0200 Subject: [PATCH 036/332] Fix intersection view regression. --- .../RimIntersectionResultsDefinitionCollection.cpp | 7 ++++++- .../ProjectDataModel/Rim2dIntersectionView.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp index 2769f569bb..81cfec0ea0 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp @@ -72,7 +72,12 @@ void RimIntersectionResultsDefinitionCollection::appendIntersectionResultDefinit if ( interResDef->activeCase() == nullptr ) { - if ( auto gridView = firstAncestorOrThisOfType() ) + auto ownerCase = firstAncestorOrThisOfType(); + if ( ownerCase ) + { + interResDef->setActiveCase( ownerCase ); + } + else if ( auto gridView = firstAncestorOrThisOfType() ) { if ( auto ownerCase = gridView->ownerCase() ) { diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp index 43b10d393e..f2952ac03b 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -176,7 +176,7 @@ RimCase* Rim2dIntersectionView::ownerCase() const if ( !rimCase ) { - rimCase = firstAncestorOrThisOfTypeAsserted()->ownerCase(); + rimCase = firstAncestorOrThisOfType(); } return rimCase; @@ -258,7 +258,7 @@ void Rim2dIntersectionView::update3dInfo() } } - if ( overlayInfoConfig->showCaseInfo() ) + if ( overlayInfoConfig->showCaseInfo() && ownerCase() ) { overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; } @@ -467,7 +467,7 @@ bool Rim2dIntersectionView::hasResults() //-------------------------------------------------------------------------------------------------- size_t Rim2dIntersectionView::onTimeStepCountRequested() { - if ( isTimeStepDependentDataVisible() ) + if ( isTimeStepDependentDataVisible() && ownerCase() ) { return ownerCase()->timeStepStrings().size(); } @@ -557,7 +557,7 @@ void Rim2dIntersectionView::onCreateDisplayModel() if ( m_intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_WELL_PATH && m_intersection->wellPath() ) { Rim3dView* settingsView = m_intersection->firstAncestorOrThisOfType(); - if ( settingsView ) + if ( settingsView && ownerCase() ) { m_flatWellpathPartMgr = new RivWellPathPartMgr( m_intersection->wellPath(), settingsView ); m_flatWellpathPartMgr->appendFlattenedStaticGeometryPartsToModel( m_intersectionVizModel.p(), From 2d688b1c8b9bd65c9fcfbb4365e212d2174b1780 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Tue, 16 Apr 2024 14:21:47 +0200 Subject: [PATCH 037/332] Eclipse case: avoid invalidating vector while iterating over it. --- ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index 0be60bdcb4..b98292dcbd 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -283,11 +283,9 @@ void RimEclipseCase::initAfterRead() { // Move views to view collection. RimEclipseViewCollection* viewColl = viewCollection(); - for ( size_t j = 0; j < m_reservoirViews_OBSOLETE.size(); j++ ) + for ( RimEclipseView* riv : m_reservoirViews_OBSOLETE.childrenByType() ) { - RimEclipseView* riv = m_reservoirViews_OBSOLETE()[j]; CVF_ASSERT( riv ); - riv->setEclipseCase( this ); m_reservoirViews_OBSOLETE.removeChild( riv ); viewColl->addView( riv ); From 85136fb343490c566509b0867079c2c83d83a872 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 16 Apr 2024 15:07:31 +0200 Subject: [PATCH 038/332] Make sure project tree is updated when view is deleted --- .../ProjectDataModel/RimEclipseViewCollection.cpp | 13 +++++++++++++ .../ProjectDataModel/RimEclipseViewCollection.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.cpp index aa67681149..967e0c5443 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.cpp @@ -24,6 +24,7 @@ #include "RigCaseCellResultsData.h" #include "Rim3dView.h" +#include "RimCase.h" #include "RimCellEdgeColors.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" @@ -61,6 +62,18 @@ std::vector RimEclipseViewCollection::views() const return m_views.childrenByType(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseViewCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) +{ + // If a view is child of a case, the view collection object is hidden in the tree view. Find the parent case and update connected editors. + if ( auto parentCase = firstAncestorOrThisOfType() ) + { + parentCase->updateConnectedEditors(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.h b/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.h index 024b6b5e03..9922c7a08b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.h @@ -44,6 +44,9 @@ class RimEclipseViewCollection : public caf::PdmObject std::vector views() const; +private: + void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; + private: caf::PdmChildArrayField m_views; }; From 38e4cc364be99f3abfba097d3c08c30679cf3744 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 16 Apr 2024 15:22:20 +0200 Subject: [PATCH 039/332] Update qwt with optional Qt6 support --- ThirdParty/qwt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdParty/qwt b/ThirdParty/qwt index 886436d422..eb4316bea1 160000 --- a/ThirdParty/qwt +++ b/ThirdParty/qwt @@ -1 +1 @@ -Subproject commit 886436d42226eb2f978735717da03d4e1a912d55 +Subproject commit eb4316bea10d32065ce2e477fa0e410360f57451 From 5b4da8284414a7776f0a99b91cb407bc222646bc Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Wed, 17 Apr 2024 11:53:29 +0200 Subject: [PATCH 040/332] Fix eclipse case contour map left click (#11378) * Make sure we operate in the correct domain when picking points in the contour map --- .../RicContourMapPickEventHandler.cpp | 43 ++++++++++--------- .../RimContourMapProjection.cpp | 4 +- .../RimContourMapProjection.h | 2 +- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/ApplicationLibCode/Commands/RicContourMapPickEventHandler.cpp b/ApplicationLibCode/Commands/RicContourMapPickEventHandler.cpp index 09af2bbf59..f42664607b 100644 --- a/ApplicationLibCode/Commands/RicContourMapPickEventHandler.cpp +++ b/ApplicationLibCode/Commands/RicContourMapPickEventHandler.cpp @@ -61,34 +61,35 @@ bool RicContourMapPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve RimGridView* view = contourMap->firstAncestorOrThisOfTypeAsserted(); if ( !view ) return false; - cvf::Vec2d pickedPoint; + const auto& firstPickItem = eventObject.m_pickItemInfos.front(); + auto targetPointInDomain = view->displayCoordTransform()->transformToDomainCoord( firstPickItem.globalPickedPoint() ); + + QString curveText = QString( "%1\n" ).arg( view->createAutoName() ); + + cvf::Vec2d pickedPoint( cvf::Vec2d::UNDEFINED ); double valueAtPoint = 0.0; - if ( contourMap->checkForMapIntersection( firstPickedItem.globalPickedPoint(), &pickedPoint, &valueAtPoint ) ) + + if ( contourMap->checkForMapIntersection( targetPointInDomain, &pickedPoint, &valueAtPoint ) ) { - QString curveText; - curveText += QString( "%1\n" ).arg( view->createAutoName() ); curveText += QString( "Picked Point X, Y: %1, %2\n" ).arg( pickedPoint.x(), 5, 'f', 0 ).arg( pickedPoint.y(), 5, 'f', 0 ); curveText += QString( "Result Type: %1\n" ).arg( contourMap->resultDescriptionText() ); curveText += QString( "Aggregated Value: %1\n" ).arg( valueAtPoint ); + } + + contourMap->setPickPoint( pickedPoint ); - RiuMainWindow::instance()->setResultInfo( curveText ); - - contourMap->setPickPoint( pickedPoint ); - - RimGeoMechContourMapView* geoMechContourView = dynamic_cast( view ); - RimEclipseContourMapView* eclipseContourView = dynamic_cast( view ); - if ( geoMechContourView ) - { - geoMechContourView->updatePickPointAndRedraw(); - } - else if ( eclipseContourView ) - { - eclipseContourView->updatePickPointAndRedraw(); - } - return true; + RimGeoMechContourMapView* geoMechContourView = dynamic_cast( view ); + RimEclipseContourMapView* eclipseContourView = dynamic_cast( view ); + if ( geoMechContourView ) + { + geoMechContourView->updatePickPointAndRedraw(); + } + else if ( eclipseContourView ) + { + eclipseContourView->updatePickPointAndRedraw(); } - contourMap->setPickPoint( cvf::Vec2d::UNDEFINED ); - view->updateDisplayModelForCurrentTimeStepAndRedraw(); + + RiuMainWindow::instance()->setResultInfo( curveText ); return true; } diff --git a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp index cf1eb274a2..793286a413 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp @@ -399,12 +399,12 @@ size_t RimContourMapProjection::numberOfVertices() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimContourMapProjection::checkForMapIntersection( const cvf::Vec3d& localPoint3d, cvf::Vec2d* contourMapPoint, double* valueAtPoint ) const +bool RimContourMapProjection::checkForMapIntersection( const cvf::Vec3d& domainPoint3d, cvf::Vec2d* contourMapPoint, double* valueAtPoint ) const { CVF_TIGHT_ASSERT( contourMapPoint ); CVF_TIGHT_ASSERT( valueAtPoint ); - cvf::Vec3d mapPos3d = localPoint3d - m_expandedBoundingBox.min() + m_gridBoundingBox.min(); + cvf::Vec3d mapPos3d = domainPoint3d - m_expandedBoundingBox.min(); cvf::Vec2d mapPos2d( mapPos3d.x(), mapPos3d.y() ); cvf::Vec2d gridorigin( m_expandedBoundingBox.min().x(), m_expandedBoundingBox.min().y() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h index bb1c7c957c..a0872066e5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h +++ b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h @@ -113,7 +113,7 @@ class RimContourMapProjection : public RimCheckableNamedObject uint numberOfValidCells() const; size_t numberOfVertices() const; - bool checkForMapIntersection( const cvf::Vec3d& localPoint3d, cvf::Vec2d* contourMapPoint, double* valueAtPoint ) const; + bool checkForMapIntersection( const cvf::Vec3d& domainPoint3d, cvf::Vec2d* contourMapPoint, double* valueAtPoint ) const; void setPickPoint( cvf::Vec2d globalPickPoint ); cvf::Vec3d origin3d() const; From acb06b1f539a105a11a6ba98311d56cf629a44d8 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 9 Feb 2024 14:11:19 +0100 Subject: [PATCH 041/332] Grid Ensemble: add pdm object. --- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../RimEclipseCaseCollection.cpp | 4 + .../RimEclipseCaseCollection.h | 2 + .../RimEclipseCaseEnsemble.cpp | 93 +++++++++++++++++++ .../ProjectDataModel/RimEclipseCaseEnsemble.h | 49 ++++++++++ 5 files changed, 150 insertions(+) create mode 100644 ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h diff --git a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake index b132ac136d..2c0f181ea4 100644 --- a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake @@ -135,6 +135,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.h ${CMAKE_CURRENT_LIST_DIR}/RimEmCase.h ${CMAKE_CURRENT_LIST_DIR}/RimEclipseViewCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseEnsemble.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -270,6 +271,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimEmCase.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPolylinePickerInterface.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEclipseViewCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseEnsemble.cpp ) if(RESINSIGHT_USE_QT_CHARTS) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp index 7d770d090f..d46966ca09 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp @@ -31,6 +31,7 @@ #include "RimCaseCollection.h" #include "RimEclipseCase.h" +#include "RimEclipseCaseEnsemble.h" #include "RimEclipseStatisticsCase.h" #include "RimIdenticalGridCaseGroup.h" #include "RimProject.h" @@ -47,6 +48,8 @@ RimEclipseCaseCollection::RimEclipseCaseCollection() CAF_PDM_InitFieldNoDefault( &caseGroups, "CaseGroups", "" ); + CAF_PDM_InitFieldNoDefault( &caseEnsembles, "CaseEnsembles", "" ); + m_gridCollection = new RigGridManager; } @@ -67,6 +70,7 @@ void RimEclipseCaseCollection::close() cases.deleteChildren(); caseGroups.deleteChildren(); + caseEnsembles.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.h index f70144b8e5..e204d454d3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.h @@ -33,6 +33,7 @@ class RigMainGrid; class RimEclipseCase; class RimIdenticalGridCaseGroup; class RimWellPathCollection; +class RimEclipseCaseEnsemble; //================================================================================================== /// @@ -48,6 +49,7 @@ class RimEclipseCaseCollection : public caf::PdmObject caf::PdmChildArrayField cases; caf::PdmChildArrayField caseGroups; + caf::PdmChildArrayField caseEnsembles; void close(); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp new file mode 100644 index 0000000000..fe6e8f80b2 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp @@ -0,0 +1,93 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- Eqinor 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 "RimEclipseCaseEnsemble.h" + +#include "RimCaseCollection.h" +#include "RimEclipseCase.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseResultCase.h" + +#include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" + +CAF_PDM_SOURCE_INIT( RimEclipseCaseEnsemble, "RimEclipseCaseEnsemble" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCaseEnsemble::RimEclipseCaseEnsemble() +{ + CAF_PDM_InitScriptableObjectWithNameAndComment( "Grid Ensemble", ":/GridCaseGroup16x16.png", "", "", "EclipseCaseEnsemble", "Grid Ensemble" ); + + CAF_PDM_InitScriptableField( &m_groupId, "Id", -1, "Id" ); + m_groupId.uiCapability()->setUiReadOnly( true ); + m_groupId.capability()->setIOWriteable( false ); + + CAF_PDM_InitFieldNoDefault( &m_caseCollection, "CaseCollection", "Ensemble Cases" ); + + m_caseCollection = new RimCaseCollection; + m_caseCollection->uiCapability()->setUiName( "Cases" ); + m_caseCollection->uiCapability()->setUiIconFromResourceString( ":/Cases16x16.png" ); + + setDeletable( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCaseEnsemble::~RimEclipseCaseEnsemble() +{ + delete m_caseCollection; + m_caseCollection = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCaseEnsemble::addCase( RimEclipseCase* reservoir ) +{ + CVF_ASSERT( reservoir ); + + m_caseCollection()->reservoirs().push_back( reservoir ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCaseEnsemble::removeCase( RimEclipseCase* reservoir ) +{ + if ( m_caseCollection()->reservoirs().count( reservoir ) == 0 ) return; + + m_caseCollection()->reservoirs().removeChild( reservoir ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseCaseEnsemble::contains( RimEclipseCase* reservoir ) const +{ + CVF_ASSERT( reservoir ); + + for ( RimEclipseCase* rimReservoir : cases() ) + { + if ( reservoir->gridFileName() == rimReservoir->gridFileName() ) return true; + } + + return false; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h new file mode 100644 index 0000000000..6239dc0a63 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimNamedObject.h" + +#include "cafPdmChildField.h" +#include "cafPdmField.h" + +class RimCaseCollection; +class RimEclipseCase; + +//================================================================================================== +// +// +// +//================================================================================================== +class RimEclipseCaseEnsemble : public RimNamedObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimEclipseCaseEnsemble(); + ~RimEclipseCaseEnsemble() override; + + void addCase( RimEclipseCase* reservoir ); + void removeCase( RimEclipseCase* reservoir ); + bool contains( RimEclipseCase* reservoir ) const; + +private: + caf::PdmField m_groupId; + caf::PdmChildField m_caseCollection; +}; From b84362dfc0b22cb67c5d4c0e585d6f8d297e38f5 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 12 Feb 2024 13:21:53 +0100 Subject: [PATCH 042/332] Grid Ensemble: add menu item for importing grid ensemble. --- .../EclipseCommands/CMakeLists_files.cmake | 2 + ...reateGridCaseEnsemblesFromFilesFeature.cpp | 134 ++++++++++++++++++ ...cCreateGridCaseEnsemblesFromFilesFeature.h | 51 +++++++ .../RimContextCommandBuilder.cpp | 1 + 4 files changed, 188 insertions(+) create mode 100644 ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.cpp create mode 100644 ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.h diff --git a/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake index c2c13c3069..b829a33814 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake @@ -21,6 +21,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicRenameCaseFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicImportRoffCaseFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAddGridCalculationFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseEnsemblesFromFilesFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -46,6 +47,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicRenameCaseFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportRoffCaseFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAddGridCalculationFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseEnsemblesFromFilesFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.cpp new file mode 100644 index 0000000000..daef75bc99 --- /dev/null +++ b/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.cpp @@ -0,0 +1,134 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RicCreateGridCaseEnsemblesFromFilesFeature.h" + +#include "RiaApplication.h" +#include "RiaImportEclipseCaseTools.h" + +#include "RicCreateGridCaseGroupFromFilesFeature.h" +#include "RicRecursiveFileSearchDialog.h" + +#include "RimEclipseCaseCollection.h" +#include "RimEclipseCaseEnsemble.h" +#include "RimEclipseResultCase.h" +#include "RimOilField.h" +#include "RimProject.h" + +#include "cafProgressInfo.h" +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT( RicCreateGridCaseEnsemblesFromFilesFeature, "RicCreateGridCaseEnsemblesFromFilesFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateGridCaseEnsemblesFromFilesFeature::onActionTriggered( bool isChecked ) +{ + QString pathCacheName = "INPUT_FILES"; + auto [fileNames, groupByEnsemble] = runRecursiveFileSearchDialog( "Import Grid Ensembles", pathCacheName ); + + if ( groupByEnsemble == RiaEnsembleNameTools::EnsembleGroupingMode::NONE ) + { + importSingleGridCaseEnsemble( fileNames ); + } + else + { + std::vector groupedByEnsemble = RiaEnsembleNameTools::groupFilesByEnsemble( fileNames, groupByEnsemble ); + for ( const QStringList& groupedFileNames : groupedByEnsemble ) + { + importSingleGridCaseEnsemble( groupedFileNames ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateGridCaseEnsemblesFromFilesFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setIcon( QIcon( ":/CreateGridCaseGroup16x16.png" ) ); + actionToSetup->setText( "&Create Grid Case Ensembles" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateGridCaseEnsemblesFromFilesFeature::importSingleGridCaseEnsemble( const QStringList& fileNames ) +{ + auto eclipseCaseEnsemble = new RimEclipseCaseEnsemble; + QString ensembleNameSuggestion = + RiaEnsembleNameTools::findSuitableEnsembleName( fileNames, RiaEnsembleNameTools::EnsembleGroupingMode::FMU_FOLDER_STRUCTURE ); + eclipseCaseEnsemble->setName( ensembleNameSuggestion ); + + caf::ProgressInfo progInfo( fileNames.size() + 1, "Creating Grid Ensembles" ); + + RimProject* project = RimProject::current(); + CVF_ASSERT( project ); + + RimOilField* oilfield = project->activeOilField(); + if ( !oilfield ) return; + + for ( auto caseFileName : fileNames ) + { + auto task = progInfo.task( "Loading files", 1 ); + + QFileInfo gridFileName( caseFileName ); + + QString caseName = gridFileName.completeBaseName(); + + auto* rimResultReservoir = new RimEclipseResultCase(); + rimResultReservoir->setCaseInfo( caseName, caseFileName ); + eclipseCaseEnsemble->addCase( rimResultReservoir ); + } + + oilfield->analysisModels()->caseEnsembles.push_back( eclipseCaseEnsemble ); + oilfield->analysisModels()->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair + RicCreateGridCaseEnsemblesFromFilesFeature::runRecursiveFileSearchDialog( const QString& dialogTitle, const QString& pathCacheName ) +{ + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory( pathCacheName ); + + RicRecursiveFileSearchDialogResult result = + RicRecursiveFileSearchDialog::runRecursiveSearchDialog( nullptr, + dialogTitle, + defaultDir, + m_pathFilter, + m_fileNameFilter, + { RicRecursiveFileSearchDialog::FileType::EGRID } ); + + // Remember filters + m_pathFilter = result.pathFilter; + m_fileNameFilter = result.fileNameFilter; + + if ( !result.ok ) return std::make_pair( QStringList(), RiaEnsembleNameTools::EnsembleGroupingMode::NONE ); + + // Remember the path to next time + app->setLastUsedDialogDirectory( pathCacheName, QFileInfo( result.rootDir ).absoluteFilePath() ); + + return std::make_pair( result.files, result.groupingMode ); +} diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.h new file mode 100644 index 0000000000..a32681e548 --- /dev/null +++ b/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "cafCmdFeature.h" + +#include "RiaEnsembleNameTools.h" + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicCreateGridCaseEnsemblesFromFilesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + + RicCreateGridCaseEnsemblesFromFilesFeature() + : m_pathFilter( "*" ) + , m_fileNameFilter( "*" ) + { + } + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + + void importSingleGridCaseEnsemble( const QStringList& fileNames ); + std::pair runRecursiveFileSearchDialog( const QString& dialogTitle, + const QString& pathCacheName ); + +private: + QString m_pathFilter; + QString m_fileNameFilter; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 5cf14ed840..4b20e19c08 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -227,6 +227,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicImportEclipseCasesFeature"; menuBuilder << "RicImportInputEclipseCaseFeature"; menuBuilder << "RicCreateGridCaseGroupFromFilesFeature"; + menuBuilder << "RicCreateGridCaseEnsemblesFromFilesFeature"; menuBuilder.subMenuEnd(); menuBuilder << "RicEclipseCaseNewGroupFeature"; } From ade044adbf2d6bf351bc95d1636da9bbd26af904 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 19 Feb 2024 09:23:23 +0100 Subject: [PATCH 043/332] Grid Ensemble: add methods to add view --- .../Commands/CMakeLists_files.cmake | 2 + .../Commands/RicNewViewFeature.cpp | 53 +++++++--- .../Commands/RicNewViewFeature.h | 6 +- .../RicNewViewForGridEnsembleFeature.cpp | 96 +++++++++++++++++++ .../RicNewViewForGridEnsembleFeature.h | 42 ++++++++ .../RimContextCommandBuilder.cpp | 5 + .../ProjectDataModel/RimEclipseCase.cpp | 8 ++ .../ProjectDataModel/RimEclipseCase.h | 3 +- .../RimEclipseCaseEnsemble.cpp | 82 +++++++++++++++- .../ProjectDataModel/RimEclipseCaseEnsemble.h | 21 +++- .../RimEclipseStatisticsCase.cpp | 2 +- .../ProjectDataModel/RimEclipseView.cpp | 5 +- 12 files changed, 300 insertions(+), 25 deletions(-) create mode 100644 ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp create mode 100644 ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.h diff --git a/ApplicationLibCode/Commands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/CMakeLists_files.cmake index be2b342e52..b3ce72161b 100644 --- a/ApplicationLibCode/Commands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/CMakeLists_files.cmake @@ -94,6 +94,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicExportSummaryCalculationExpressionsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCalculationExpressionsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicImportWellLogCsvFileFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewViewForGridEnsembleFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -191,6 +192,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicExportSummaryCalculationExpressionsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCalculationExpressionsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportWellLogCsvFileFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewViewForGridEnsembleFeature.cpp ) if(RESINSIGHT_USE_QT_CHARTS) diff --git a/ApplicationLibCode/Commands/RicNewViewFeature.cpp b/ApplicationLibCode/Commands/RicNewViewFeature.cpp index eed089898a..e5ec6a4b9b 100644 --- a/ApplicationLibCode/Commands/RicNewViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewViewFeature.cpp @@ -23,6 +23,7 @@ #include "Rim3dView.h" #include "RimEclipseCase.h" +#include "RimEclipseCaseEnsemble.h" #include "RimEclipseCaseTools.h" #include "RimEclipseContourMapView.h" #include "RimEclipseView.h" @@ -41,9 +42,9 @@ CAF_CMD_SOURCE_INIT( RicNewViewFeature, "RicNewViewFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewViewFeature::addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, bool useGlobalViewCollection ) +void RicNewViewFeature::addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, RimEclipseViewCollection* viewColl ) { - Rim3dView* newView = createReservoirView( eclipseCase, geomCase, useGlobalViewCollection ); + Rim3dView* newView = createReservoirView( eclipseCase, geomCase, viewColl ); if ( newView ) { @@ -69,30 +70,45 @@ bool RicNewViewFeature::isCommandEnabled() const void RicNewViewFeature::onActionTriggered( bool isChecked ) { // Establish type of selected object - RimEclipseCase* eclipseCase = selectedEclipseCase(); - RimGeoMechCase* geomCase = selectedGeoMechCase(); - RimGeoMechView* geoMechView = selectedGeoMechView(); - RimEclipseView* reservoirView = selectedEclipseView(); + RimEclipseCase* eclipseCase = selectedEclipseCase(); + RimGeoMechCase* geomCase = selectedGeoMechCase(); + RimGeoMechView* geoMechView = selectedGeoMechView(); + RimEclipseView* reservoirView = selectedEclipseView(); + RimEclipseViewCollection* viewCollection = selectedEclipseViewCollection(); + RimEclipseCaseEnsemble* eclipseEnsemble = selectedEclipseCaseEnsemble(); // Find case to insert into if ( geoMechView ) geomCase = geoMechView->geoMechCase(); if ( reservoirView ) eclipseCase = reservoirView->eclipseCase(); - bool useGlobalViewCollection = false; - if ( selectedEclipseViewCollection() ) + if ( eclipseCase ) + { + viewCollection = eclipseCase->viewCollection(); + } + else if ( eclipseEnsemble ) + { + viewCollection = eclipseEnsemble->viewCollection(); + auto eclipseCases = eclipseEnsemble->cases(); + eclipseCase = !eclipseCases.empty() ? eclipseCases[0] : nullptr; + } + else if ( viewCollection ) { // Use global view collection if view collection is not descendant of Eclipse case. - useGlobalViewCollection = selectedEclipseViewCollection()->firstAncestorOrThisOfType() == nullptr; + eclipseCase = viewCollection->firstAncestorOrThisOfType(); if ( !eclipseCase ) { - auto eclipseCases = RimEclipseCaseTools::allEclipseGridCases(); + // Use cases from grid ensemble if applicable + auto gridEnsemble = viewCollection->firstAncestorOfType(); + auto eclipseCases = gridEnsemble ? gridEnsemble->cases() : RimEclipseCaseTools::allEclipseGridCases(); + if ( !eclipseCases.empty() ) { eclipseCase = eclipseCases[0]; } } } - addReservoirView( eclipseCase, geomCase, useGlobalViewCollection ); + + addReservoirView( eclipseCase, geomCase, viewCollection ); } //-------------------------------------------------------------------------------------------------- @@ -107,13 +123,13 @@ void RicNewViewFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim3dView* RicNewViewFeature::createReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, bool useGlobalViewCollection ) +Rim3dView* RicNewViewFeature::createReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, RimEclipseViewCollection* viewColl ) { RimGridView* insertedView = nullptr; if ( eclipseCase ) { - insertedView = eclipseCase->createAndAddReservoirView( useGlobalViewCollection ); + insertedView = eclipseCase->createAndAddReservoirView( viewColl ); } else if ( geomCase ) { @@ -198,6 +214,17 @@ RimEclipseViewCollection* RicNewViewFeature::selectedEclipseViewCollection() return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCaseEnsemble* RicNewViewFeature::selectedEclipseCaseEnsemble() +{ + std::vector selection; + caf::SelectionManager::instance()->objectsByType( &selection ); + if ( !selection.empty() ) return selection[0]; + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicNewViewFeature.h b/ApplicationLibCode/Commands/RicNewViewFeature.h index c145641072..acc145bbdb 100644 --- a/ApplicationLibCode/Commands/RicNewViewFeature.h +++ b/ApplicationLibCode/Commands/RicNewViewFeature.h @@ -27,6 +27,7 @@ class RimGeoMechCase; class RimGeoMechView; class Rim3dView; class RimEclipseViewCollection; +class RimEclipseCaseEnsemble; //================================================================================================== /// @@ -36,7 +37,7 @@ class RicNewViewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static void addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, bool useGlobalViewCollection = false ); + static void addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, RimEclipseViewCollection* viewColl ); protected: bool isCommandEnabled() const override; @@ -44,11 +45,12 @@ class RicNewViewFeature : public caf::CmdFeature void setupActionLook( QAction* actionToSetup ) override; private: - static Rim3dView* createReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, bool useGlobalViewCollectin ); + static Rim3dView* createReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, RimEclipseViewCollection* viewColl ); static RimEclipseCase* selectedEclipseCase(); static RimGeoMechCase* selectedGeoMechCase(); static RimEclipseView* selectedEclipseView(); static RimGeoMechView* selectedGeoMechView(); static RimEclipseViewCollection* selectedEclipseViewCollection(); + static RimEclipseCaseEnsemble* selectedEclipseCaseEnsemble(); }; diff --git a/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp b/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp new file mode 100644 index 0000000000..dc9c9c4eb0 --- /dev/null +++ b/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.cpp @@ -0,0 +1,96 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RicNewViewForGridEnsembleFeature.h" + +#include "RiaLogging.h" + +#include "Rim3dView.h" +#include "RimEclipseCase.h" +#include "RimEclipseCaseEnsemble.h" +#include "RimEclipseContourMapView.h" +#include "RimEclipseView.h" +#include "RimGeoMechCase.h" +#include "RimGeoMechView.h" + +#include "Riu3DMainWindowTools.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewViewForGridEnsembleFeature, "RicNewViewForGridEnsembleFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewViewForGridEnsembleFeature::addView( RimEclipseCaseEnsemble* eclipseCaseEnsemble ) +{ + std::vector cases = eclipseCaseEnsemble->cases(); + if ( cases.empty() ) return; + + auto newView = eclipseCaseEnsemble->addViewForCase( cases[0] ); + eclipseCaseEnsemble->updateConnectedEditors(); + + Riu3DMainWindowTools::setExpanded( newView ); + + // Select the new view to make sure RiaApplication::setActiveReservoirView() is called + Riu3DMainWindowTools::selectAsCurrentItem( newView ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewViewForGridEnsembleFeature::isCommandEnabled() const +{ + return selectedEclipseCaseEnsemble() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewViewForGridEnsembleFeature::onActionTriggered( bool isChecked ) +{ + RimEclipseCaseEnsemble* eclipseCaseEnsemble = selectedEclipseCaseEnsemble(); + addView( eclipseCaseEnsemble ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewViewForGridEnsembleFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "New View" ); + actionToSetup->setIcon( QIcon( ":/3DView16x16.png" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCaseEnsemble* RicNewViewForGridEnsembleFeature::selectedEclipseCaseEnsemble() +{ + std::vector selection; + caf::SelectionManager::instance()->objectsByType( &selection ); + + if ( !selection.empty() ) + { + return selection[0]; + } + + return nullptr; +} diff --git a/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.h b/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.h new file mode 100644 index 0000000000..4e03d25847 --- /dev/null +++ b/ApplicationLibCode/Commands/RicNewViewForGridEnsembleFeature.h @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "cafCmdFeature.h" + +class RimEclipseCaseEnsemble; +class RimEclipseView; + +//================================================================================================== +/// +//================================================================================================== +class RicNewViewForGridEnsembleFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static void addView( RimEclipseCaseEnsemble* eclipseCaseEnsemble ); + +protected: + bool isCommandEnabled() const override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + + static RimEclipseCaseEnsemble* selectedEclipseCaseEnsemble(); +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 4b20e19c08..82f4f97148 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -49,6 +49,7 @@ #include "RimCustomObjectiveFunctionCollection.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" +#include "RimEclipseCaseEnsemble.h" #include "RimEclipseCellColors.h" #include "RimEclipseContourMapView.h" #include "RimEclipseContourMapViewCollection.h" @@ -273,6 +274,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; menuBuilder << "RicNewStatisticsCaseFeature"; } + else if ( dynamic_cast( firstUiItem ) ) + { + menuBuilder << "RicNewViewForGridEnsembleFeature"; + } else if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicImportGeoMechCaseFeature"; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index b98292dcbd..6a7c23b939 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -312,6 +312,14 @@ void RimEclipseCase::initAfterRead() RimEclipseView* RimEclipseCase::createAndAddReservoirView( bool useGlobalViewCollection ) { RimEclipseViewCollection* viewColl = useGlobalViewCollection ? globalViewCollection() : viewCollection(); + return createAndAddReservoirView( viewColl ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseView* RimEclipseCase::createAndAddReservoirView( RimEclipseViewCollection* viewColl ) +{ if ( !viewColl ) return nullptr; return viewColl->addView( this ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h index 933fc62742..a623643622 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h @@ -68,6 +68,7 @@ class RimEclipseCase : public RimCase ~RimEclipseCase() override; std::vector reservoirViews() const; + RimEclipseViewCollection* viewCollection() const; std::vector filesContainingFaults() const; void setFilesContainingFaults( const std::vector& val ); @@ -92,6 +93,7 @@ class RimEclipseCase : public RimCase const RimReservoirCellResultsStorage* resultsStorage( RiaDefines::PorosityModelType porosityModel ) const; RimEclipseView* createAndAddReservoirView( bool useGlobalViewCollection = false ); + RimEclipseView* createAndAddReservoirView( RimEclipseViewCollection* viewColl ); RimEclipseView* createCopyAndAddView( const RimEclipseView* sourceView ); const RigVirtualPerforationTransmissibilities* computeAndGetVirtualPerforationTransmissibilities(); @@ -140,7 +142,6 @@ class RimEclipseCase : public RimCase void computeCachedData(); void setReservoirData( RigEclipseCaseData* eclipseCase ); std::vector additionalFiles() const; - RimEclipseViewCollection* viewCollection() const; RimEclipseViewCollection* globalViewCollection() const; RimEclipseContourMapViewCollection* contourMapViewCollection() const; void addViewsFromViewCollection( std::vector& views, const RimEclipseViewCollection* viewColl ) const; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp index fe6e8f80b2..65fb04e8d5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp @@ -20,8 +20,8 @@ #include "RimCaseCollection.h" #include "RimEclipseCase.h" -#include "RimEclipseCellColors.h" -#include "RimEclipseResultCase.h" +#include "RimEclipseView.h" +#include "RimEclipseViewCollection.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" @@ -40,11 +40,15 @@ RimEclipseCaseEnsemble::RimEclipseCaseEnsemble() m_groupId.capability()->setIOWriteable( false ); CAF_PDM_InitFieldNoDefault( &m_caseCollection, "CaseCollection", "Ensemble Cases" ); - m_caseCollection = new RimCaseCollection; m_caseCollection->uiCapability()->setUiName( "Cases" ); m_caseCollection->uiCapability()->setUiIconFromResourceString( ":/Cases16x16.png" ); + CAF_PDM_InitFieldNoDefault( &m_selectedCase, "SelectedCase", "Selected Case" ); + + CAF_PDM_InitFieldNoDefault( &m_viewCollection, "ViewCollection", "Views" ); + m_viewCollection = new RimEclipseViewCollection; + setDeletable( true ); } @@ -55,6 +59,9 @@ RimEclipseCaseEnsemble::~RimEclipseCaseEnsemble() { delete m_caseCollection; m_caseCollection = nullptr; + + delete m_viewCollection; + m_viewCollection = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -91,3 +98,72 @@ bool RimEclipseCaseEnsemble::contains( RimEclipseCase* reservoir ) const return false; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseCaseEnsemble::cases() const +{ + return m_caseCollection->reservoirs.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCaseEnsemble::addView( RimEclipseView* view ) +{ + m_viewCollection->addView( view ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseView* RimEclipseCaseEnsemble::addViewForCase( RimEclipseCase* eclipseCase ) +{ + return m_viewCollection->addView( eclipseCase ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimEclipseCaseEnsemble::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + + if ( fieldNeedingOptions == &m_selectedCase ) + { + for ( auto eclCase : cases() ) + { + options.push_back( caf::PdmOptionItemInfo( eclCase->caseUserDescription(), eclCase, false, eclCase->uiIconProvider() ) ); + } + + return options; + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCaseEnsemble::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + if ( changedField == &m_selectedCase ) + { + for ( auto view : m_viewCollection->views() ) + { + view->setEclipseCase( m_selectedCase() ); + view->loadDataAndUpdate(); + view->updateGridBoxData(); + view->updateAnnotationItems(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseViewCollection* RimEclipseCaseEnsemble::viewCollection() const +{ + return m_viewCollection; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h index 6239dc0a63..4104428af1 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h @@ -20,11 +20,15 @@ #include "RimNamedObject.h" +#include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmField.h" +#include "cafPdmPtrField.h" class RimCaseCollection; class RimEclipseCase; +class RimEclipseView; +class RimEclipseViewCollection; //================================================================================================== // @@ -43,7 +47,20 @@ class RimEclipseCaseEnsemble : public RimNamedObject void removeCase( RimEclipseCase* reservoir ); bool contains( RimEclipseCase* reservoir ) const; + std::vector cases() const; + + void addView( RimEclipseView* view ); + RimEclipseView* addViewForCase( RimEclipseCase* eclipseCase ); + + RimEclipseViewCollection* viewCollection() const; + +protected: + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + private: - caf::PdmField m_groupId; - caf::PdmChildField m_caseCollection; + caf::PdmField m_groupId; + caf::PdmChildField m_caseCollection; + caf::PdmChildField m_viewCollection; + caf::PdmPtrField m_selectedCase; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp index 1309f4709c..5dc9974cbb 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp @@ -1004,7 +1004,7 @@ void RimEclipseStatisticsCase::computeStatisticsAndUpdateViews() if ( reservoirViews().empty() ) { - RicNewViewFeature::addReservoirView( this, nullptr ); + RicNewViewFeature::addReservoirView( this, nullptr, viewCollection() ); } if ( reservoirViews().size() == 1 ) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 1b5edba896..6fd8898b77 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -1270,10 +1270,9 @@ QString RimEclipseView::createAutoName() const } QStringList generatedAutoTags; - - if ( m_eclipseCase && nameConfig()->addCaseName() ) + if ( nameConfig()->addCaseName() && ownerCase() ) { - generatedAutoTags.push_back( m_eclipseCase->caseUserDescription() ); + generatedAutoTags.push_back( ownerCase()->caseUserDescription() ); } if ( nameConfig()->addProperty() ) From 174123f8b544812df1a7672790c3cfd9149da5e1 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 17 Apr 2024 13:46:31 +0200 Subject: [PATCH 044/332] Refactor: rename confusing push_back method on view collections. --- .../RicPasteEclipseViewsFeature.cpp | 2 +- .../Commands/RicNewContourMapViewFeature.cpp | 12 ++++++------ .../GeoMech/RimGeoMechContourMapViewCollection.cpp | 2 +- .../GeoMech/RimGeoMechContourMapViewCollection.h | 2 +- .../ProjectDataModel/RimEclipseCase.cpp | 2 +- .../RimEclipseContourMapViewCollection.cpp | 2 +- .../RimEclipseContourMapViewCollection.h | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp index 0b1f0b5301..cde76028af 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp @@ -98,7 +98,7 @@ void RicPasteEclipseViewsFeature::onActionTriggered( bool isChecked ) auto contourMapView = dynamic_cast( rimReservoirView ); CVF_ASSERT( contourMapView ); - eclipseCase->contourMapCollection()->push_back( contourMapView ); + eclipseCase->contourMapCollection()->addView( contourMapView ); } else { diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp index 38efadedc4..bff1e3cedd 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp @@ -219,7 +219,7 @@ RimEclipseContourMapView* size_t i = eclipseCase->contourMapCollection()->views().size(); contourMap->setName( QString( "Contour Map %1" ).arg( i + 1 ) ); - eclipseCase->contourMapCollection()->push_back( contourMap ); + eclipseCase->contourMapCollection()->addView( contourMap ); // Resolve references after contour map has been inserted into Rim structures contourMap->resolveReferencesRecursively(); @@ -269,7 +269,7 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFr caf::PdmDocument::updateUiIconStateRecursively( contourMap ); - eclipseCase->contourMapCollection()->push_back( contourMap ); + eclipseCase->contourMapCollection()->addView( contourMap ); contourMap->synchronizeLocalAnnotationsFromGlobal(); @@ -313,7 +313,7 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMap( contourMap->faultCollection()->setActive( false ); contourMap->wellCollection()->isActive = false; - eclipseCase->contourMapCollection()->push_back( contourMap ); + eclipseCase->contourMapCollection()->addView( contourMap ); auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" ); contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background @@ -343,7 +343,7 @@ RimGeoMechContourMapView* size_t i = geoMechCase->contourMapCollection()->views().size(); contourMap->setName( QString( "Contour Map %1" ).arg( i + 1 ) ); - geoMechCase->contourMapCollection()->push_back( contourMap ); + geoMechCase->contourMapCollection()->addView( contourMap ); // Resolve references after contour map has been inserted into Rim structures contourMap->resolveReferencesRecursively(); @@ -373,7 +373,7 @@ RimGeoMechContourMapView* RicNewContourMapViewFeature::createGeoMechContourMapFr caf::PdmDocument::updateUiIconStateRecursively( contourMap ); - geoMechCase->contourMapCollection()->push_back( contourMap ); + geoMechCase->contourMapCollection()->addView( contourMap ); // Resolve references after contour map has been inserted into Rim structures std::vector fieldsWithFailingResolve; @@ -395,7 +395,7 @@ RimGeoMechContourMapView* RicNewContourMapViewFeature::createGeoMechContourMap( size_t i = geoMechCase->contourMapCollection()->views().size(); contourMap->setName( QString( "Contour Map %1" ).arg( i + 1 ) ); - geoMechCase->contourMapCollection()->push_back( contourMap ); + geoMechCase->contourMapCollection()->addView( contourMap ); auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" ); contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.cpp index 1041d6b6a7..fd4c373b96 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.cpp @@ -33,7 +33,7 @@ std::vector RimGeoMechContourMapViewCollection::views //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGeoMechContourMapViewCollection::push_back( RimGeoMechContourMapView* contourMap ) +void RimGeoMechContourMapViewCollection::addView( RimGeoMechContourMapView* contourMap ) { m_contourMapViews.push_back( contourMap ); } diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.h index 3abb3cb9f6..60dc775e66 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.h @@ -33,7 +33,7 @@ class RimGeoMechContourMapViewCollection : public caf::PdmObject ~RimGeoMechContourMapViewCollection() override; std::vector views(); - void push_back( RimGeoMechContourMapView* contourMap ); + void addView( RimGeoMechContourMapView* contourMap ); private: caf::PdmChildArrayField m_contourMapViews; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index 6a7c23b939..10e5d5c514 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -299,7 +299,7 @@ void RimEclipseCase::initAfterRead() { contourMap->setEclipseCase( this ); m_contourMapCollection_OBSOLETE->removeChild( contourMap ); - mapViewColl->push_back( contourMap ); + mapViewColl->addView( contourMap ); } m_contourMapCollection_OBSOLETE->clearWithoutDelete(); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp index e688d7763b..c84450c3e6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp @@ -33,7 +33,7 @@ std::vector RimEclipseContourMapViewCollection::views //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseContourMapViewCollection::push_back( RimEclipseContourMapView* contourMap ) +void RimEclipseContourMapViewCollection::addView( RimEclipseContourMapView* contourMap ) { m_contourMapViews.push_back( contourMap ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.h b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.h index 1a7290a7de..063b8d7673 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.h @@ -33,7 +33,7 @@ class RimEclipseContourMapViewCollection : public caf::PdmObject ~RimEclipseContourMapViewCollection() override; std::vector views(); - void push_back( RimEclipseContourMapView* contourMap ); + void addView( RimEclipseContourMapView* contourMap ); void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; From c759a118888246d9784d38676e5c9c09c6cd647f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 17 Apr 2024 15:06:51 +0200 Subject: [PATCH 045/332] Cmake cleanup and selected Qt6 adjustments - Avoid warning using newer CMake by removing obsolete cmake requirements in sub projects - Several adjustments preparing for Qt6 --- ApplicationExeCode/RiaMain.cpp | 2 +- .../ExportCommands/RicSnapshotViewToFileFeature.cpp | 1 - .../Summary/RimSummaryTimeAxisProperties.cpp | 3 +-- ApplicationLibCode/UserInterface/RiuMainWindow.cpp | 1 + ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp | 1 - Fwk/AppFwk/cafHexInterpolator/cafHexInterpolator.h | 2 +- Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt | 4 +++- Fwk/AppFwk/cafViewer/CMakeLists.txt | 2 -- ThirdParty/Ert/CMakeLists.txt | 1 - ThirdParty/Ert/external/catch2/CMakeLists.txt | 1 - ThirdParty/NRLib/CMakeLists.txt | 2 -- ThirdParty/NRLib/nrlib/well/laswell.hpp | 6 +++--- ThirdParty/NRLib/nrlib/well/well.hpp | 6 +++--- ThirdParty/clipper/CMakeLists.txt | 2 -- ThirdParty/custom-opm-common/CMakeLists.txt | 3 --- ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt | 2 -- ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt | 2 -- ThirdParty/expressionparser/CMakeLists.txt | 2 -- ThirdParty/nightcharts/CMakeLists.txt | 2 -- 19 files changed, 13 insertions(+), 32 deletions(-) diff --git a/ApplicationExeCode/RiaMain.cpp b/ApplicationExeCode/RiaMain.cpp index b8d35b48c2..da1e71c972 100644 --- a/ApplicationExeCode/RiaMain.cpp +++ b/ApplicationExeCode/RiaMain.cpp @@ -181,7 +181,7 @@ int main( int argc, char* argv[] ) if ( file.open( QIODevice::WriteOnly | QIODevice::Text ) ) { QTextStream out( &file ); - out << portNumber << endl; + out << portNumber << "\n"; } file.close(); diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp index efbf0ca313..8cc57dc646 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp index 4d10357f62..5338521b65 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp @@ -319,8 +319,7 @@ QDateTime RimSummaryTimeAxisProperties::fromDisplayTimeToDate( double displayTim time_t startOfSimulation = rimSummaryPlot->firstTimeStepOfFirstCurve(); time_t secsSinceSimulationStart = displayTime / fromTimeTToDisplayUnitScale(); - QDateTime date; - date.setTime_t( startOfSimulation + secsSinceSimulationStart ); + QDateTime date = RiaQDateTimeTools::fromTime_t( startOfSimulation + secsSinceSimulationStart ); return date; } diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp index 01ef0bb120..9c99e50029 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp @@ -92,6 +92,7 @@ #include "DockManager.h" #include +#include #include #include #include diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp index a353d17f61..4668d2590e 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp @@ -58,7 +58,6 @@ #include "qwt_scale_widget.h" #include -#include #include #include #include diff --git a/Fwk/AppFwk/cafHexInterpolator/cafHexInterpolator.h b/Fwk/AppFwk/cafHexInterpolator/cafHexInterpolator.h index 1ae037d185..f9d70f463a 100644 --- a/Fwk/AppFwk/cafHexInterpolator/cafHexInterpolator.h +++ b/Fwk/AppFwk/cafHexInterpolator/cafHexInterpolator.h @@ -39,7 +39,7 @@ /* Interpolating inside a general 8 node hexahedral element Calculating an interpolated value at a position inside the element from values at each corner. -Author Jacob Støren +Author Jacob Storen | v1 | Vectors: [v] = | v2 | = { v1, v2, v3 } diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt b/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt index 328c2d4218..58491526c2 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt +++ b/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt @@ -14,6 +14,7 @@ set(MOC_HEADER_FILES MainWindow.h WidgetLayoutTest.h CustomObjectEditor.h # Resource file set(QRC_FILES ${QRC_FILES} textedit.qrc) +message("QRC_FILES: ${QRC_FILES}") if(CEE_USE_QT6) find_package( @@ -23,6 +24,7 @@ if(CEE_USE_QT6) ) set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGL Qt6::Svg) qt_standard_project_setup() + set(CMAKE_AUTORCC ON) else() find_package( Qt5 @@ -64,7 +66,7 @@ if(CEE_USE_QT6) ${PROJECT_NAME} ${PROJECT_FILES} ${MOC_SOURCE_FILES} - ${QRC_FILES_CPP} + ${QRC_FILES} $ # Needed for cmake version < 3.12. # Remove # when we can use target_link_libraries with OBJECT libraries diff --git a/Fwk/AppFwk/cafViewer/CMakeLists.txt b/Fwk/AppFwk/cafViewer/CMakeLists.txt index 33411039bf..1c09b2cd31 100644 --- a/Fwk/AppFwk/cafViewer/CMakeLists.txt +++ b/Fwk/AppFwk/cafViewer/CMakeLists.txt @@ -42,8 +42,6 @@ add_library( cafNavigationPolicy.cpp cafNavigationPolicy.h cafPointOfInterestVisualizer.h - cafOpenGLWidget.cpp - cafOpenGLWidget.h cafViewer.cpp cafViewer.h ${MOC_SOURCE_FILES} diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index 5f8283f86f..22dafde9c3 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required( VERSION 2.8.12 ) # If you are creating Python wrappers for Windows, the actual version requirement is 3.4 project( ERT C CXX ) include(GNUInstallDirs) diff --git a/ThirdParty/Ert/external/catch2/CMakeLists.txt b/ThirdParty/Ert/external/catch2/CMakeLists.txt index acc362ba8a..7327241a02 100644 --- a/ThirdParty/Ert/external/catch2/CMakeLists.txt +++ b/ThirdParty/Ert/external/catch2/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.8.12) project(catch2 CXX) # Dummy source file added because INTERFACE type diff --git a/ThirdParty/NRLib/CMakeLists.txt b/ThirdParty/NRLib/CMakeLists.txt index 0ad5839f44..858365e8a6 100644 --- a/ThirdParty/NRLib/CMakeLists.txt +++ b/ThirdParty/NRLib/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required (VERSION 2.8.12) - project (NRLib) if (CMAKE_COMPILER_IS_GNUCXX) diff --git a/ThirdParty/NRLib/nrlib/well/laswell.hpp b/ThirdParty/NRLib/nrlib/well/laswell.hpp index 074c177ef2..61741bf356 100644 --- a/ThirdParty/NRLib/nrlib/well/laswell.hpp +++ b/ThirdParty/NRLib/nrlib/well/laswell.hpp @@ -1,12 +1,12 @@ -// $Id: laswell.hpp 1244 2014-02-24 15:57:16Z hauge $ +// $Id: laswell.hpp 1244 2014-02-24 15:57:16Z hauge $ // Copyright (c) 2011, Norwegian Computing Center // All rights reserved. // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: -// • Redistributions of source code must retain the above copyright notice, this +// • Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. -// • Redistributions in binary form must reproduce the above copyright notice, this list of +// • Redistributions in binary form must reproduce the above copyright notice, this list of // conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY diff --git a/ThirdParty/NRLib/nrlib/well/well.hpp b/ThirdParty/NRLib/nrlib/well/well.hpp index 09b9baa9dd..2cdad1e3ed 100644 --- a/ThirdParty/NRLib/nrlib/well/well.hpp +++ b/ThirdParty/NRLib/nrlib/well/well.hpp @@ -1,12 +1,12 @@ -// $Id: well.hpp 883 2011-09-26 09:17:05Z perroe $ +// $Id: well.hpp 883 2011-09-26 09:17:05Z perroe $ // Copyright (c) 2011, Norwegian Computing Center // All rights reserved. // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: -// • Redistributions of source code must retain the above copyright notice, this +// • Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. -// • Redistributions in binary form must reproduce the above copyright notice, this list of +// • Redistributions in binary form must reproduce the above copyright notice, this list of // conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY diff --git a/ThirdParty/clipper/CMakeLists.txt b/ThirdParty/clipper/CMakeLists.txt index 9f84a5e20b..69c88036ec 100644 --- a/ThirdParty/clipper/CMakeLists.txt +++ b/ThirdParty/clipper/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required (VERSION 2.8.12) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy") endif() diff --git a/ThirdParty/custom-opm-common/CMakeLists.txt b/ThirdParty/custom-opm-common/CMakeLists.txt index 5439d66b38..d13eea7271 100644 --- a/ThirdParty/custom-opm-common/CMakeLists.txt +++ b/ThirdParty/custom-opm-common/CMakeLists.txt @@ -1,6 +1,3 @@ -cmake_minimum_required (VERSION 2.8.12) - -# Languages and global compiler settings if(CMAKE_VERSION VERSION_LESS 3.8) message(WARNING "CMake version does not support c++17, guessing -std=c++17") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") diff --git a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt index a44c68d824..d6748f8a5b 100644 --- a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required (VERSION 2.8.12) - project (custom-opm-flowdiag-app) if (CMAKE_COMPILER_IS_GNUCXX) diff --git a/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt b/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt index a9c22ebe98..8829324303 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required (VERSION 2.8.12) - project (custom-opm-flowdiagnostics) if (CMAKE_COMPILER_IS_GNUCXX) diff --git a/ThirdParty/expressionparser/CMakeLists.txt b/ThirdParty/expressionparser/CMakeLists.txt index f9afaa51e0..0bbd626767 100644 --- a/ThirdParty/expressionparser/CMakeLists.txt +++ b/ThirdParty/expressionparser/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required (VERSION 2.8.12) - project (expressionparser) if(MSVC) diff --git a/ThirdParty/nightcharts/CMakeLists.txt b/ThirdParty/nightcharts/CMakeLists.txt index 8c79e7386a..0b1724ce3a 100644 --- a/ThirdParty/nightcharts/CMakeLists.txt +++ b/ThirdParty/nightcharts/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required (VERSION 2.8.12) - project (nightcharts) if (CEE_USE_QT6) From 3255b649caeca89d6ef3b4e395d1441d510e9c09 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 17 Apr 2024 14:34:28 +0200 Subject: [PATCH 046/332] #11072 Refactor: remove homemade atomic counter. std::atomic was introduced in C++11, and provides same functionality in platform-independent way. Fixes #11072. --- CMakeLists.txt | 28 --- Fwk/VizFwk/LibCore/CMakeLists.txt | 2 - Fwk/VizFwk/LibCore/cvfAtomicCounter.cpp | 187 ------------------ Fwk/VizFwk/LibCore/cvfAtomicCounter.h | 91 --------- Fwk/VizFwk/LibCore/cvfObject.h | 16 +- .../Tests/LibCore_UnitTests/CMakeLists.txt | 1 - .../cvfAtomicCounter-Test.cpp | 141 ------------- 7 files changed, 2 insertions(+), 464 deletions(-) delete mode 100644 Fwk/VizFwk/LibCore/cvfAtomicCounter.cpp delete mode 100644 Fwk/VizFwk/LibCore/cvfAtomicCounter.h delete mode 100644 Fwk/VizFwk/Tests/LibCore_UnitTests/cvfAtomicCounter-Test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index be662dc9da..d08245e64c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -725,34 +725,6 @@ endif() # Vizualization Framework # ############################################################################## -# Allow use of non-threadsafe reference counter in cvf::Object on systems with -# no atomics support -if(CMAKE_COMPILER_IS_GNUCC) - - if(NOT DEFINED HAVE_GCC_SYNC_FUNCTIONS) - check_c_source_compiles( - "int main(int argc, char **argv) { - int a; - __sync_add_and_fetch(&a, 1); - __sync_fetch_and_add(&a, 1); - __sync_sub_and_fetch(&a, 1); - __sync_fetch_and_sub(&a, 1); }" - HAVE_GCC_SYNC_FUNCTIONS - ) - endif() - - if(HAVE_GCC_SYNC_FUNCTIONS) - message(STATUS "GCC synchronization functions detected") - else() - message( - STATUS - "GCC synchronization functions NOT detected, fallback to non threadsafe reference counting" - ) - add_definitions(-DCVF_USE_NON_THREADSAFE_REFERENCE_COUNT) - endif() - -endif() - # !!! For now, we force Qt to version 5 message(STATUS "Forcing setting of CEE_USE_QT5 to ON") set(CEE_USE_QT5 diff --git a/Fwk/VizFwk/LibCore/CMakeLists.txt b/Fwk/VizFwk/LibCore/CMakeLists.txt index 517acbf9e9..3f2417463e 100644 --- a/Fwk/VizFwk/LibCore/CMakeLists.txt +++ b/Fwk/VizFwk/LibCore/CMakeLists.txt @@ -19,7 +19,6 @@ cvfArray.inl cvfArrayWrapperConst.h cvfArrayWrapperToEdit.h cvfAssert.h -cvfAtomicCounter.h cvfBase.h cvfBase64.h cvfCharArray.h @@ -75,7 +74,6 @@ cvfVersion.h set(CEE_SOURCE_FILES cvfAssert.cpp -cvfAtomicCounter.cpp cvfBase64.cpp cvfCharArray.cpp cvfCodeLocation.cpp diff --git a/Fwk/VizFwk/LibCore/cvfAtomicCounter.cpp b/Fwk/VizFwk/LibCore/cvfAtomicCounter.cpp deleted file mode 100644 index 0cb825a83f..0000000000 --- a/Fwk/VizFwk/LibCore/cvfAtomicCounter.cpp +++ /dev/null @@ -1,187 +0,0 @@ -//################################################################################################## -// -// Custom Visualization Core library -// Copyright (C) 2014 Ceetron Solutions AS -// -// This library may be used under the terms of either the GNU General Public License or -// the GNU Lesser General Public License as follows: -// -// GNU General Public License Usage -// This library 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. -// -// This library 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. -// -// GNU Lesser General Public License Usage -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library 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 Lesser General Public License at <> -// for more details. -// -//################################################################################################## - - -#include "cvfAtomicCounter.h" - -// Some older GCC version do not support atomics, we have seen this for RHEL5 -#if defined(CVF_ATOMIC_COUNTER_CLASS_EXISTS) - -namespace cvf { - -#ifdef WIN32 -#pragma warning (push) -#pragma warning (disable: 4668) -#include -#pragma warning (pop) - - -AtomicCounter::AtomicCounter(int initialValue) - : m_counter(initialValue) -{ -} - - -AtomicCounter::~AtomicCounter() -{ -} - - -AtomicCounter::operator int () const -{ - return m_counter; -} - -int AtomicCounter::operator ++ () // prefix -{ - return InterlockedIncrement(&m_counter); -} - - -int AtomicCounter::operator ++ (int) // postfix -{ - int result = InterlockedIncrement(&m_counter); - return --result; -} - - -int AtomicCounter::operator -- () // prefix -{ - return InterlockedDecrement(&m_counter); -} - - -int AtomicCounter::operator -- (int) // postfix -{ - int result = InterlockedDecrement(&m_counter); - return ++result; -} - - -#elif defined(CVF_IOS) || defined(CVF_OSX) - -AtomicCounter::AtomicCounter(int initialValue) - : m_counter(initialValue) -{ -} - - -AtomicCounter::~AtomicCounter() -{ -} - -AtomicCounter::operator int () const -{ - return m_counter; -} - - -int AtomicCounter::operator ++ () // prefix -{ - return OSAtomicIncrement32(&m_counter); -} - - -int AtomicCounter::operator ++ (int) // postfix -{ - int result = OSAtomicIncrement32(&m_counter); - return --result; -} - - -int AtomicCounter::operator -- () // prefix -{ - return OSAtomicDecrement32(&m_counter); -} - - -int AtomicCounter::operator -- (int) // postfix -{ - int result = OSAtomicDecrement32(&m_counter); - return ++result; -} - - -#elif defined(CVF_GCC_DEFINED) - - -AtomicCounter::AtomicCounter(int initialValue) - : m_counter(initialValue) -{ -} - -AtomicCounter::~AtomicCounter() -{ -} - -AtomicCounter::operator int () const -{ - return m_counter; -} - - -int AtomicCounter::operator ++ () // prefix -{ - return __sync_add_and_fetch(&m_counter, 1); -} - - -int AtomicCounter::operator ++ (int) // postfix -{ - return __sync_fetch_and_add(&m_counter, 1); -} - - -int AtomicCounter::operator -- () // prefix -{ - return __sync_sub_and_fetch(&m_counter, 1); -} - - -int AtomicCounter::operator -- (int) // postfix -{ - return __sync_fetch_and_sub(&m_counter, 1); -} - - -#endif - - -} // namespace cvf - - - -#endif // CVF_ATOMICS_COMPILED diff --git a/Fwk/VizFwk/LibCore/cvfAtomicCounter.h b/Fwk/VizFwk/LibCore/cvfAtomicCounter.h deleted file mode 100644 index 424e822b1a..0000000000 --- a/Fwk/VizFwk/LibCore/cvfAtomicCounter.h +++ /dev/null @@ -1,91 +0,0 @@ -//################################################################################################## -// -// Custom Visualization Core library -// Copyright (C) 2014 Ceetron Solutions AS -// -// This library may be used under the terms of either the GNU General Public License or -// the GNU Lesser General Public License as follows: -// -// GNU General Public License Usage -// This library 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. -// -// This library 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. -// -// GNU Lesser General Public License Usage -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library 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 Lesser General Public License at <> -// for more details. -// -//################################################################################################## - - -#pragma once - -#include "cvfBase.h" - -#ifdef WIN32 - #define CVF_ATOMIC_COUNTER_CLASS_EXISTS -#elif defined(CVF_IOS) || defined(CVF_OSX) - #include - #define CVF_ATOMIC_COUNTER_CLASS_EXISTS -#elif defined __GNUC__ - #define CVF_GCC_DEFINED - #define CVF_ATOMIC_COUNTER_CLASS_EXISTS -#endif - -#if defined(CVF_ATOMIC_COUNTER_CLASS_EXISTS) - -namespace cvf { - -// Inspired by Poco - - -class AtomicCounter -{ -public: - explicit AtomicCounter(int initialValue); - ~AtomicCounter(); - - operator int () const; - - int operator ++ (); // prefix - int operator ++ (int); // postfix - - int operator -- (); // prefix - int operator -- (int); // postfix - -private: - - CVF_DISABLE_COPY_AND_ASSIGN(AtomicCounter); - -#ifdef WIN32 - typedef volatile long ImplType; -#elif defined(CVF_IOS) || defined(CVF_OSX) - typedef int32_t ImplType; -#else - typedef int ImplType; -#endif - - ImplType m_counter; -}; - - -} // namespace cvf - -#endif diff --git a/Fwk/VizFwk/LibCore/cvfObject.h b/Fwk/VizFwk/LibCore/cvfObject.h index 98f5e8389f..67a691a7a9 100644 --- a/Fwk/VizFwk/LibCore/cvfObject.h +++ b/Fwk/VizFwk/LibCore/cvfObject.h @@ -41,12 +41,8 @@ #include "cvfSystem.h" #include +#include -#include "cvfAtomicCounter.h" - -#if !defined(CVF_ATOMIC_COUNTER_CLASS_EXISTS) && !defined(CVF_USE_NON_THREADSAFE_REFERENCE_COUNT) -#error No support for atomics. Define CVF_USE_NON_THREADSAFE_REFERENCE_COUNT to be able to compile -#endif namespace cvf { @@ -71,15 +67,7 @@ class Object static void dumpActiveObjectInstances(); private: - -#if defined(CVF_USE_NON_THREADSAFE_REFERENCE_COUNT) - mutable int m_refCount; -#elif defined(CVF_ATOMIC_COUNTER_CLASS_EXISTS) - mutable AtomicCounter m_refCount; -#else - #error No support for atomics. Define CVF_USE_NON_THREADSAFE_REFERENCE_COUNT to be able to compile -#endif - + mutable std::atomic m_refCount; CVF_DISABLE_COPY_AND_ASSIGN(Object); }; diff --git a/Fwk/VizFwk/Tests/LibCore_UnitTests/CMakeLists.txt b/Fwk/VizFwk/Tests/LibCore_UnitTests/CMakeLists.txt index 68901eb664..9aaec9492e 100644 --- a/Fwk/VizFwk/Tests/LibCore_UnitTests/CMakeLists.txt +++ b/Fwk/VizFwk/Tests/LibCore_UnitTests/CMakeLists.txt @@ -12,7 +12,6 @@ set(CEE_LIBS LibCore) set(CEE_SOURCE_FILES cvfArray-Test.cpp cvfArrayWrapper-Test.cpp -cvfAtomicCounter-Test.cpp cvfBase-Test.cpp cvfBase64-Test.cpp cvfCharArray-Test.cpp diff --git a/Fwk/VizFwk/Tests/LibCore_UnitTests/cvfAtomicCounter-Test.cpp b/Fwk/VizFwk/Tests/LibCore_UnitTests/cvfAtomicCounter-Test.cpp deleted file mode 100644 index 1899a2141b..0000000000 --- a/Fwk/VizFwk/Tests/LibCore_UnitTests/cvfAtomicCounter-Test.cpp +++ /dev/null @@ -1,141 +0,0 @@ -//################################################################################################## -// -// Custom Visualization Core library -// Copyright (C) 2014 Ceetron Solutions AS -// -// This library may be used under the terms of either the GNU General Public License or -// the GNU Lesser General Public License as follows: -// -// GNU General Public License Usage -// This library 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. -// -// This library 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. -// -// GNU Lesser General Public License Usage -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library 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 Lesser General Public License at <> -// for more details. -// -//################################################################################################## - - - -#include "cvfAtomicCounter.h" - -#ifdef CVF_ATOMIC_COUNTER_CLASS_EXISTS - -#include "cvfDebugTimer.h" -#include "cvfObject.h" -#include "cvfCollection.h" - -#include "gtest/gtest.h" - -using namespace cvf; - -class MyObj : public Object -{ -public: - MyObj() { num_ = 0; } - MyObj(int num) { num_ = num; } - - int num() const { return num_; } - void num(int num) { num_ = num; } - - bool operator<(const MyObj& rhs) - { - return num_ < rhs.num_; - } - -private: - int num_; -}; - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -TEST(DISABLED_ObjectConstructionBenchmark, TestBasicObjectConstruction) -{ - int objectCount = 1000000; - int iterationCount = 5; - - String sNumber(objectCount); - String refCountTxt = String("TestBasicObjectConstruction : ") + sNumber; - DebugTimer tim(refCountTxt.toAscii().ptr()); - - for (int iteration = 0; iteration < iterationCount; iteration++) - { - for (int i = 0; i < objectCount; i++) - { - MyObj* r2 = new MyObj(); - - r2->addRef(); - r2->release(); - } - - tim.reportLapTimeMS(); - } -} - - - -class ObjectReferencingSharedObject : public Object -{ -public: - ObjectReferencingSharedObject() { } - - cvf::ref m_sharedObject; -}; - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -TEST(DISABLED_ObjectConstructionBenchmark, TestReferenceOtherObject) -{ - int objectCount = 1000000; - int iterationCount = 5; - - String sNumber(objectCount); - String refCountTxt = String("TestReferenceOtherObjectClass : ") + sNumber; - DebugTimer tim(refCountTxt.toAscii().ptr()); - - for (int iteration = 0; iteration < iterationCount; iteration++) - { - cvf::ref sharedObj = new MyObj(); - - std::vector< cvf::ref > col; - col.resize(objectCount); - - for (int i = 0; i < objectCount; i++) - { - cvf::ref newObj = new ObjectReferencingSharedObject(); - newObj->m_sharedObject = sharedObj.p(); - - col[i] = newObj; - } - - String sNumber(sharedObj->refCount()); - String refCountTxt = String("Shared object reference count : ") + sNumber; - - tim.reportLapTimeMS(refCountTxt.toAscii().ptr()); - } -} - - -#endif //#ifdef CVF_ATOMIC_COUNTER_CLASS_EXISTS From e77b4f9e3befb8a2ee6f48b000b5ca2c049bd6ee Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 17 Apr 2024 15:36:43 +0200 Subject: [PATCH 047/332] Bump to version dev 05. --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 7483c0f93e..19d477d55e 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".04") +set(RESINSIGHT_DEV_VERSION ".05") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 932464ea55e12f3ad907418f2d639b6e0ef4ebdf Mon Sep 17 00:00:00 2001 From: magnesj <1793152+magnesj@users.noreply.github.com> Date: Thu, 18 Apr 2024 02:34:08 +0000 Subject: [PATCH 048/332] Fixes by clang-tidy --- .../ProjectDataModel/CellFilters/RimPolygonFilter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index c1d4cc0b80..7145f05834 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -803,7 +803,7 @@ void RimPolygonFilter::updateCells() } // We need at least three points to make a closed polygon, or just 2 for a polyline - if ( ( !isPolygonClosed() && ( points.size() < 1 ) ) || ( isPolygonClosed() && ( points.size() < 3 ) ) ) return; + if ( ( !isPolygonClosed() && ( points.empty() ) ) || ( isPolygonClosed() && ( points.size() < 3 ) ) ) return; // make sure first and last point is the same (req. by closed polygon methods used later) if ( isPolygonClosed() ) points.push_back( points.front() ); From e9ff3540baa46005261207c3d5083f0c1283f960 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Apr 2024 15:09:15 +0200 Subject: [PATCH 049/332] Update dev branch after patch release * Fix calculation for active cell values Always allocate result data for active cells in destination case. Make sure that active cells is used for both population of expression variables and filtering of data. Improved naming to make it clear that we always work with active cell data. * Check if scalar result index is valid * Create the static scalar results once addStaticScalarResult will clear already computed data, causing calculations to be triggered once more * Early return if data already is available If not checking if data is available, data is read from file and appended to result vector. * Always check date for H5 files, and recreate if required * Always recreate ESMRY if file exists and is older than SMSPEC * #11355 Use category if result name starts with FIP or ends with NUM * #11337 Summary import: Make sure ESMRY includes restart history * #11334 Fix cvf::Viewport assert triggered for small contour map/2d intersection Size of the overlay is could become negative, and would overflow for small views. * #11310 Fix assert on single cell model. Well pipe radius would become HUGE_VAL due to off-by-one error. The assert could only happen on model with a single cell. * Check equal grid size only when required Equal grid size is required if there is more than one grid case in the expression. If a cell filter view is active, the visibility is based on one view and reused for all other grid models, and requires equal grid size. * Remove obsolete log message * Do not show dialog during regression tests * Fix eclipse case contour map left click (#11378) * Make sure we operate in the correct domain when picking points in the contour map * Remove obsolete code causing grid to be loaded for all cases * Bump version to 2024.03.1 --------- Co-authored-by: Kristian Bendiksen Co-authored-by: jonjenssen <69144954+jonjenssen@users.noreply.github.com> --- .../Application/RiaResultNames.cpp | 11 ++ .../Application/RiaResultNames.h | 1 + .../RifEclipseInputFileTools.cpp | 3 +- .../RifEclipseInputPropertyLoader.cpp | 5 +- .../FileInterface/RifHdf5SummaryExporter.cpp | 47 ++++-- .../FileInterface/RifHdf5SummaryExporter.h | 6 +- .../FileInterface/RifOpmCommonSummary.cpp | 85 ++++++---- .../FileInterface/RifReaderEclipseSummary.cpp | 20 +-- .../ProjectDataModel/RimEclipseResultCase.cpp | 2 - .../RimEclipseResultDefinition.cpp | 2 + .../ProjectDataModel/RimGridCalculation.cpp | 148 +++++++++++------- .../ProjectDataModel/RimGridCalculation.h | 43 +++-- .../Summary/RimSummaryCaseMainCollection.cpp | 7 +- .../RigCaseCellResultsData.cpp | 18 ++- .../UnitTests/HDF5FileWriter-Test.cpp | 8 +- ResInsightVersion.cmake | 6 +- 16 files changed, 262 insertions(+), 150 deletions(-) diff --git a/ApplicationLibCode/Application/RiaResultNames.cpp b/ApplicationLibCode/Application/RiaResultNames.cpp index cac4338ada..6b6884d631 100644 --- a/ApplicationLibCode/Application/RiaResultNames.cpp +++ b/ApplicationLibCode/Application/RiaResultNames.cpp @@ -97,6 +97,17 @@ bool RiaResultNames::isFlowResultWithBothPosAndNegValues( const QString& resultN return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaResultNames::isCategoryResult( const QString& resultName ) +{ + if ( resultName.endsWith( "NUM", Qt::CaseInsensitive ) ) return true; + if ( resultName.startsWith( "FIP", Qt::CaseInsensitive ) ) return true; + + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaResultNames.h b/ApplicationLibCode/Application/RiaResultNames.h index 184aa85ff6..96c97c6046 100644 --- a/ApplicationLibCode/Application/RiaResultNames.h +++ b/ApplicationLibCode/Application/RiaResultNames.h @@ -32,6 +32,7 @@ namespace RiaResultNames bool isPerCellFaceResult( const QString& resultName ); bool isLogarithmicResult( const QString& resultName ); bool isFlowResultWithBothPosAndNegValues( const QString& resultName ); +bool isCategoryResult( const QString& resultName ); QString undefinedResultName(); QString undefinedGridFaultName(); diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp index 1682fb25cf..da706c9788 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp @@ -22,6 +22,7 @@ #include "RiaCellDividingTools.h" #include "RiaLogging.h" +#include "RiaResultNames.h" #include "RiaStringEncodingTools.h" #include "RiaTextStringTools.h" @@ -439,7 +440,7 @@ bool RifEclipseInputFileTools::exportKeywords( const QString& resul if ( resultValues.empty() ) continue; double defaultExportValue = 0.0; - if ( keyword.endsWith( "NUM" ) ) + if ( RiaResultNames::isCategoryResult( keyword ) ) { defaultExportValue = 1.0; } diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputPropertyLoader.cpp b/ApplicationLibCode/FileInterface/RifEclipseInputPropertyLoader.cpp index 9afa42eae3..aa98ed155a 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputPropertyLoader.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseInputPropertyLoader.cpp @@ -19,6 +19,7 @@ #include "RifEclipseInputPropertyLoader.h" #include "RiaLogging.h" +#include "RiaResultNames.h" #include "RifEclipseInputFileTools.h" #include "RifEclipseKeywordContent.h" @@ -177,8 +178,8 @@ bool RifEclipseInputPropertyLoader::appendNewInputPropertyResult( RigEclipseCase return false; } - bool endsWithNum = eclipseKeyword.ends_with( "NUM" ); - auto dataType = endsWithNum ? RiaDefines::ResultDataType::INTEGER : RiaDefines::ResultDataType::FLOAT; + bool isCategory = RiaResultNames::isCategoryResult( resultName ); + auto dataType = isCategory ? RiaDefines::ResultDataType::INTEGER : RiaDefines::ResultDataType::FLOAT; RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::INPUT_PROPERTY, dataType, resultName ); caseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->createResultEntry( resAddr, false ); diff --git a/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.cpp b/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.cpp index 89e614139a..5dcf45760d 100644 --- a/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.cpp +++ b/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.cpp @@ -45,6 +45,7 @@ //-------------------------------------------------------------------------------------------------- bool RifHdf5SummaryExporter::ensureHdf5FileIsCreatedMultithreaded( const std::vector& smspecFileNames, const std::vector& h5FileNames, + bool createHdfIfNotPresent, int threadCount ) { if ( smspecFileNames.empty() ) return true; @@ -61,7 +62,7 @@ bool RifHdf5SummaryExporter::ensureHdf5FileIsCreatedMultithreaded( const std::ve const auto& smspecFileName = smspecFileNames[cIdx]; const auto& h5FileName = h5FileNames[cIdx]; - RifHdf5SummaryExporter::ensureHdf5FileIsCreated( smspecFileName, h5FileName, hdfFilesCreatedCount ); + RifHdf5SummaryExporter::ensureHdf5FileIsCreated( smspecFileName, h5FileName, createHdfIfNotPresent, hdfFilesCreatedCount ); } if ( hdfFilesCreatedCount > 0 ) @@ -78,29 +79,47 @@ bool RifHdf5SummaryExporter::ensureHdf5FileIsCreatedMultithreaded( const std::ve //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifHdf5SummaryExporter::ensureHdf5FileIsCreated( const std::string& smspecFileName, const std::string& h5FileName, size_t& hdfFilesCreatedCount ) +bool RifHdf5SummaryExporter::ensureHdf5FileIsCreated( const std::string& smspecFileName, + const std::string& h5FileName, + bool createHdfIfNotPresent, + size_t& hdfFilesCreatedCount ) { - if ( !std::filesystem::exists( smspecFileName ) ) return false; - - { - // Check if we have write permission in the folder - QFileInfo info( QString::fromStdString( smspecFileName ) ); + // If an H5 file is present, and the SMSPEC file is newer than the H5 file, the H5 file will be recreated. + // If no H5 file is present, the H5 file will be created if the flag createHdfIfNotPresent is set to true. + // + // NB! Always make sure the logic is consistent with the logic in RifOpmCommonEclipseSummary::open - if ( !info.isWritable() ) return true; - } + if ( !std::filesystem::exists( smspecFileName ) ) return false; bool exportIsRequired = false; + bool h5FileExists = std::filesystem::exists( h5FileName ); + if ( !h5FileExists ) { - bool h5FileExists = std::filesystem::exists( h5FileName ); - if ( !h5FileExists ) + if ( createHdfIfNotPresent ) { exportIsRequired = true; } - else if ( RiaFilePathTools::isFirstOlderThanSecond( h5FileName, smspecFileName ) ) + } + else if ( RiaFilePathTools::isFirstOlderThanSecond( h5FileName, smspecFileName ) ) + { + // If both files are present, check if the SMSPEC file is newer than the H5 file. If the SMSPEC file is newer, we abort if it is not + // possible to write to the H5 file + + // Check if we have write permission in the folder + QFileInfo info( QString::fromStdString( smspecFileName ) ); + + if ( !info.isWritable() ) { - exportIsRequired = true; + QString txt = + QString( "HDF is older than SMSPEC, but export to file %1 failed due to missing write permissions. Aborting operation." ) + .arg( QString::fromStdString( h5FileName ) ); + RiaLogging::error( txt ); + + return false; } + + exportIsRequired = true; } if ( exportIsRequired ) @@ -127,7 +146,7 @@ bool RifHdf5SummaryExporter::ensureHdf5FileIsCreated( const std::string& smspecF } catch ( std::exception& e ) { - QString txt = QString( "HDF export to file %1 failed : %3" ).arg( QString::fromStdString( smspecFileName ), e.what() ); + QString txt = QString( "HDF export to file %1 failed : %2" ).arg( QString::fromStdString( smspecFileName ), e.what() ); RiaLogging::error( txt ); diff --git a/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.h b/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.h index 692b5d2787..991b9e35ea 100644 --- a/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.h +++ b/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.h @@ -42,9 +42,13 @@ class RifHdf5SummaryExporter public: static bool ensureHdf5FileIsCreatedMultithreaded( const std::vector& smspecFileNames, const std::vector& h5FileNames, + bool createHdfIfNotPresent, int threadCount ); - static bool ensureHdf5FileIsCreated( const std::string& smspecFileName, const std::string& h5FileName, size_t& hdfFilesCreatedCount ); + static bool ensureHdf5FileIsCreated( const std::string& smspecFileName, + const std::string& h5FileName, + bool createHdfIfNotPresent, + size_t& hdfFilesCreatedCount ); private: static bool writeGeneralSection( RifHdf5Exporter& exporter, Opm::EclIO::ESmry& sourceSummaryData ); diff --git a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp index bfad38a75b..448653b8d8 100644 --- a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp +++ b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp @@ -84,50 +84,73 @@ size_t RifOpmCommonEclipseSummary::numberOfEnhancedSummaryFileCreated() //-------------------------------------------------------------------------------------------------- bool RifOpmCommonEclipseSummary::open( const QString& fileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger ) { - if ( m_createEsmryFiles ) + // If an ESMRY file is present, and the SMSPEC file is newer than the ESMRY file, the ESMRY file will be recreated. + // If no ESMRY file is present, the ESMRY file will be created if the flag m_createEsmryFiles is set to true. + // + // NB! Always make sure the logic is consistent with the logic in RifHdf5SummaryExporter::ensureHdf5FileIsCreated + + bool writeDataToEsmry = false; + + auto candidateEsmryFileName = enhancedSummaryFilename( fileName ); + + // Make sure to check the smspec file name, as it is supported to import ESMRY files without any SMSPEC data + auto smspecFileName = smspecSummaryFilename( fileName ); + + if ( !QFile::exists( candidateEsmryFileName ) && QFile::exists( smspecFileName ) && m_createEsmryFiles ) + { + writeDataToEsmry = true; + } + + if ( RiaFilePathTools::isFirstOlderThanSecond( candidateEsmryFileName.toStdString(), smspecFileName.toStdString() ) ) { - auto candidateEsmryFileName = enhancedSummaryFilename( fileName ); + QString root = QFileInfo( smspecFileName ).canonicalPath(); - // Make sure to check the smspec file name, as it is supported to import ESMRY files without any SMSPEC data - auto smspecFileName = smspecSummaryFilename( fileName ); + const QString smspecFileNameShort = QFileInfo( smspecFileName ).fileName(); + const QString esmryFileNameShort = QFileInfo( candidateEsmryFileName ).fileName(); - if ( QFile::exists( candidateEsmryFileName ) && QFile::exists( smspecFileName ) && - RiaFilePathTools::isFirstOlderThanSecond( candidateEsmryFileName.toStdString(), smspecFileName.toStdString() ) ) - { - QString root = QFileInfo( smspecFileName ).canonicalPath(); + RiaLogging::debug( + QString( " %3 : %1 is older than %2, recreating %1." ).arg( esmryFileNameShort ).arg( smspecFileNameShort ).arg( root ) ); - const QString smspecFileNameShort = QFileInfo( smspecFileName ).fileName(); - const QString esmryFileNameShort = QFileInfo( candidateEsmryFileName ).fileName(); + // Check if we have write permission in the folder + QFileInfo info( smspecFileName ); - RiaLogging::debug( - QString( " %3 : %1 is older than %2, recreating %1." ).arg( esmryFileNameShort ).arg( smspecFileNameShort ).arg( root ) ); + if ( !info.isWritable() ) + { + QString txt = + QString( "ESMRY is older than SMSPEC, but export to file %1 failed due to missing write permissions. Aborting operation." ) + .arg( candidateEsmryFileName ); + RiaLogging::error( txt ); - std::filesystem::remove( candidateEsmryFileName.toStdString() ); + return false; } - if ( !QFile::exists( candidateEsmryFileName ) && QFile::exists( smspecFileName ) ) - { - try - { - auto temporarySummaryFile = std::make_unique( smspecFileName.toStdString(), includeRestartFiles ); + std::filesystem::remove( candidateEsmryFileName.toStdString() ); - if ( temporarySummaryFile->numberOfTimeSteps() > 0 ) - { - temporarySummaryFile->make_esmry_file(); - } + writeDataToEsmry = true; + } - RifOpmCommonEclipseSummary::increaseEsmryFileCount(); - } - catch ( std::exception& ) + if ( writeDataToEsmry ) + { + try + { + auto temporarySummaryFile = std::make_unique( smspecFileName.toStdString(), includeRestartFiles ); + + if ( temporarySummaryFile->numberOfTimeSteps() > 0 ) { - if ( threadSafeLogger ) - { - QString txt = QString( "Warning, could not open summary file : %1" ).arg( smspecFileName ); - threadSafeLogger->warning( txt ); - } + temporarySummaryFile->make_esmry_file(); + } - return false; + RifOpmCommonEclipseSummary::increaseEsmryFileCount(); + } + catch ( std::exception& ) + { + if ( threadSafeLogger ) + { + QString txt = QString( "Warning, could not open summary file : %1" ).arg( smspecFileName ); + threadSafeLogger->warning( txt ); } + + return false; } } diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp index 68f4c0ef1d..0ef8e0ee62 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp @@ -95,18 +95,18 @@ bool RifReaderEclipseSummary::open( const QString& headerFileName, RiaThreadSafe ( h5FileFound || ( prefSummary->summaryDataReader() == RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON ) ) ) { #ifdef USE_HDF5 - if ( prefSummary->createH5SummaryDataFiles() ) - { - size_t createdH5FileCount = 0; - RifHdf5SummaryExporter::ensureHdf5FileIsCreated( headerFileName.toStdString(), h5FileName.toStdString(), createdH5FileCount ); + size_t createdH5FileCount = 0; + RifHdf5SummaryExporter::ensureHdf5FileIsCreated( headerFileName.toStdString(), + h5FileName.toStdString(), + prefSummary->createH5SummaryDataFiles(), + createdH5FileCount ); - if ( createdH5FileCount > 0 ) - { - QString txt = QString( "Created %1 " ).arg( h5FileName ); - if ( threadSafeLogger ) threadSafeLogger->info( txt ); - } - h5FileFound = QFile::exists( h5FileName ); + if ( createdH5FileCount > 0 ) + { + QString txt = QString( "Created %1 " ).arg( h5FileName ); + if ( threadSafeLogger ) threadSafeLogger->info( txt ); } + h5FileFound = QFile::exists( h5FileName ); if ( h5FileFound ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp index 63540ec2ab..fa389c7185 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -374,8 +374,6 @@ void RimEclipseResultCase::ensureRftDataIsImported() if ( rftFileInfo.exists() ) { - RiaLogging::info( QString( "RFT file found" ) ); - if ( m_useOpmRftReader ) { m_readerOpmRft = new RifReaderOpmRft( rftFileInfo.filePath() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp index c5dea97ccf..e35bddd12b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -1426,6 +1426,8 @@ bool RimEclipseResultDefinition::isCompletionTypeSelected() const //-------------------------------------------------------------------------------------------------- bool RimEclipseResultDefinition::hasCategoryResult() const { + if ( RiaResultNames::isCategoryResult( m_resultVariable() ) ) return true; + if ( auto* gridCellResults = currentGridCellResults() ) { const auto addresses = gridCellResults->existingResults(); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp index 0dfe24312f..ac64cf6395 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp @@ -22,6 +22,7 @@ #include "RiaGuiApplication.h" #include "RiaLogging.h" #include "RiaPorosityModel.h" +#include "RiaRegressionTestRunner.h" #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" @@ -118,7 +119,8 @@ RimGridCalculation::RimGridCalculation() //-------------------------------------------------------------------------------------------------- bool RimGridCalculation::preCalculate() const { - if ( RiaGuiApplication::isRunning() && m_additionalCasesType() != RimGridCalculation::AdditionalCasesType::NONE ) + if ( !RiaRegressionTestRunner::instance()->isRunningRegressionTests() && RiaGuiApplication::isRunning() && + m_additionalCasesType() != RimGridCalculation::AdditionalCasesType::NONE ) { const QString cacheKey = "GridCalculatorMessage"; @@ -171,18 +173,40 @@ RimGridCalculationVariable* RimGridCalculation::createVariable() //-------------------------------------------------------------------------------------------------- bool RimGridCalculation::calculate() { + // Equal grid size is required if there is more than one grid case in the expression. If a cell filter view is active, the visibility is + // based on one view and reused for all other grid models, and requires equal grid size. + bool checkIfGridSizeIsEqual = !allSourceCasesAreEqualToDestinationCase() || m_cellFilterView != nullptr; + for ( auto calculationCase : outputEclipseCases() ) { if ( !calculationCase ) continue; - for ( auto inputCase : inputCases() ) + if ( !calculationCase->eclipseCaseData() ) + { + QString msg = QString( "No data available for case %1, aborting calculation" ).arg( calculationCase->caseUserDescription() ); + RiaLogging::errorInMessageBox( nullptr, "Grid Property Calculator", msg ); + return false; + } + + if ( !calculationCase->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ) ) + { + QString msg = + QString( "No active cell data available for case %1, aborting calculation" ).arg( calculationCase->caseUserDescription() ); + RiaLogging::errorInMessageBox( nullptr, "Grid Property Calculator", msg ); + return false; + } + + if ( checkIfGridSizeIsEqual ) { - if ( !calculationCase->isGridSizeEqualTo( inputCase ) ) + for ( auto inputCase : inputCases() ) { - QString msg = "Detected IJK mismatch between input cases and destination case. All grid " - "cases must have identical IJK sizes."; - RiaLogging::errorInMessageBox( nullptr, "Grid Property Calculator", msg ); - return false; + if ( !calculationCase->isGridSizeEqualTo( inputCase ) ) + { + QString msg = "Detected IJK mismatch between input cases and destination case. All grid " + "cases must have identical IJK sizes."; + RiaLogging::errorInMessageBox( nullptr, "Grid Property Calculator", msg ); + return false; + } } } } @@ -537,11 +561,11 @@ RigEclipseResultAddress RimGridCalculation::outputAddress() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimGridCalculation::getDataForVariable( RimGridCalculationVariable* variable, - size_t tsId, - RiaDefines::PorosityModelType porosityModel, - RimEclipseCase* sourceCase, - RimEclipseCase* destinationCase ) const +std::vector RimGridCalculation::getActiveCellValuesForVariable( RimGridCalculationVariable* variable, + size_t tsId, + RiaDefines::PorosityModelType porosityModel, + RimEclipseCase* sourceCase, + RimEclipseCase* destinationCase ) const { if ( !sourceCase || !destinationCase ) return {}; @@ -562,18 +586,19 @@ std::vector RimGridCalculation::getDataForVariable( RimGridCalculationVa timeStepToUse = timeStep; } - return getDataForResult( variable->resultVariable(), resultCategoryType, timeStepToUse, porosityModel, sourceCase, destinationCase ); + return getActiveCellValues( variable->resultVariable(), resultCategoryType, timeStepToUse, porosityModel, sourceCase, destinationCase ); } //-------------------------------------------------------------------------------------------------- -/// +/// Return values for active cells, both for dynamic and static results. Use the active cell info from the destination case, and read data +/// from the source case. //-------------------------------------------------------------------------------------------------- -std::vector RimGridCalculation::getDataForResult( const QString& resultName, - const RiaDefines::ResultCatType resultCategoryType, - size_t tsId, - RiaDefines::PorosityModelType porosityModel, - RimEclipseCase* sourceCase, - RimEclipseCase* destinationCase ) const +std::vector RimGridCalculation::getActiveCellValues( const QString& resultName, + const RiaDefines::ResultCatType resultCategoryType, + size_t tsId, + RiaDefines::PorosityModelType porosityModel, + RimEclipseCase* sourceCase, + RimEclipseCase* destinationCase ) const { if ( !sourceCase || !destinationCase ) return {}; @@ -588,12 +613,15 @@ std::vector RimGridCalculation::getDataForResult( const QString& auto eclipseCaseData = sourceCase->eclipseCaseData(); auto rigCaseCellResultsData = eclipseCaseData->results( porosityModel ); - if ( !rigCaseCellResultsData->findOrLoadKnownScalarResultForTimeStep( resAddr, timeStepToUse ) ) return {}; + if ( rigCaseCellResultsData->findOrLoadKnownScalarResultForTimeStep( resAddr, timeStepToUse ) == cvf::UNDEFINED_SIZE_T ) return {}; // Active cell info must always be retrieved from the destination case, as the returned vector must be of the same size as // number of active cells in the destination case. Active cells can be different between source and destination case. auto activeCellInfoDestination = destinationCase->eclipseCaseData()->activeCellInfo( porosityModel ); - auto activeReservoirCells = activeCellInfoDestination->activeReservoirCellIndices(); + if ( !activeCellInfoDestination ) return {}; + + auto activeReservoirCells = activeCellInfoDestination->activeReservoirCellIndices(); + if ( activeReservoirCells.empty() ) return {}; std::vector values( activeCellInfoDestination->activeReservoirCellIndices().size() ); @@ -621,23 +649,25 @@ std::vector RimGridCalculation::getDataForResult( const QString& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGridCalculation::replaceFilteredValuesWithVector( const std::vector& inputValues, - cvf::ref visibility, - std::vector& resultValues, - RiaDefines::PorosityModelType porosityModel, - RimEclipseCase* outputEclipseCase ) +void RimGridCalculation::replaceFilteredValuesWithVector( const std::vector& inputValues, + cvf::ref visibility, + std::vector& resultValues, + RigActiveCellInfo* activeCellInfo ) { - auto activeCellInfo = outputEclipseCase->eclipseCaseData()->activeCellInfo( porosityModel ); - int numCells = static_cast( visibility->size() ); + auto activeReservoirCellIndices = activeCellInfo->activeReservoirCellIndices(); + int numActiveCells = static_cast( activeReservoirCellIndices.size() ); + + CAF_ASSERT( numActiveCells == (int)resultValues.size() ); + CAF_ASSERT( numActiveCells == (int)inputValues.size() ); #pragma omp parallel for - for ( int i = 0; i < numCells; i++ ) + for ( int i = 0; i < numActiveCells; i++ ) { - if ( !visibility->val( i ) && activeCellInfo->isActive( i ) ) + const auto reservoirCellIndex = activeReservoirCellIndices[i]; + if ( !visibility->val( reservoirCellIndex ) ) { - size_t cellResultIndex = activeCellInfo->cellResultIndex( i ); - resultValues[cellResultIndex] = inputValues[cellResultIndex]; + resultValues[i] = inputValues[i]; } } } @@ -645,23 +675,24 @@ void RimGridCalculation::replaceFilteredValuesWithVector( const std::vector visibility, - std::vector& resultValues, - RiaDefines::PorosityModelType porosityModel, - RimEclipseCase* outputEclipseCase ) +void RimGridCalculation::replaceFilteredValuesWithDefaultValue( double defaultValue, + cvf::ref visibility, + std::vector& resultValues, + RigActiveCellInfo* activeCellInfo ) { - auto activeCellInfo = outputEclipseCase->eclipseCaseData()->activeCellInfo( porosityModel ); - int numCells = static_cast( visibility->size() ); + auto activeReservoirCellIndices = activeCellInfo->activeReservoirCellIndices(); + int numActiveCells = static_cast( activeReservoirCellIndices.size() ); + + CAF_ASSERT( numActiveCells == (int)resultValues.size() ); #pragma omp parallel for - for ( int i = 0; i < numCells; i++ ) + for ( int i = 0; i < numActiveCells; i++ ) { - if ( !visibility->val( i ) && activeCellInfo->isActive( i ) ) + const auto reservoirCellIndex = activeReservoirCellIndices[i]; + if ( !visibility->val( reservoirCellIndex ) ) { - size_t cellResultIndex = activeCellInfo->cellResultIndex( i ); - resultValues[cellResultIndex] = defaultValue; + resultValues[i] = defaultValue; } } } @@ -681,18 +712,20 @@ void RimGridCalculation::filterResults( RimGridView* { auto visibility = cellFilterView->currentTotalCellVisibility(); + auto activeCellInfo = outputEclipseCase->eclipseCaseData()->activeCellInfo( porosityModel ); + if ( defaultValueType == RimGridCalculation::DefaultValueType::FROM_PROPERTY ) { - auto nonVisibleValues = getDataForResult( m_nonVisibleResultAddress->resultName(), - m_nonVisibleResultAddress->resultType(), - timeStep, - porosityModel, - m_nonVisibleResultAddress->eclipseCase(), - outputEclipseCase ); + auto nonVisibleValues = getActiveCellValues( m_nonVisibleResultAddress->resultName(), + m_nonVisibleResultAddress->resultType(), + timeStep, + porosityModel, + outputEclipseCase, + outputEclipseCase ); if ( !nonVisibleValues.empty() ) { - replaceFilteredValuesWithVector( nonVisibleValues, visibility, resultValues, porosityModel, outputEclipseCase ); + replaceFilteredValuesWithVector( nonVisibleValues, visibility, resultValues, activeCellInfo ); } else { @@ -706,7 +739,7 @@ void RimGridCalculation::filterResults( RimGridView* double valueToUse = defaultValue; if ( defaultValueType == RimGridCalculation::DefaultValueType::POSITIVE_INFINITY ) valueToUse = HUGE_VAL; - replaceFilteredValuesWithDefaultValue( valueToUse, visibility, resultValues, porosityModel, outputEclipseCase ); + replaceFilteredValuesWithDefaultValue( valueToUse, visibility, resultValues, activeCellInfo ); } } @@ -873,15 +906,16 @@ bool RimGridCalculation::calculateForCases( const std::vector& bool useDataFromSourceCase = ( v->eclipseCase() == m_destinationCase ); auto sourceCase = useDataFromSourceCase ? calculationCase : v->eclipseCase(); - auto dataForVariable = getDataForVariable( v, tsId, porosityModel, sourceCase, calculationCase ); + auto dataForVariable = getActiveCellValuesForVariable( v, tsId, porosityModel, sourceCase, calculationCase ); if ( dataForVariable.empty() ) { RiaLogging::error( QString( " No data found for variable '%1'." ).arg( v->name() ) ); } else if ( inputValueVisibilityFilter && hasAggregationExpression ) { - const double defaultValue = 0.0; - replaceFilteredValuesWithDefaultValue( defaultValue, inputValueVisibilityFilter, dataForVariable, porosityModel, calculationCase ); + const double defaultValue = 0.0; + auto activeCellInfo = calculationCase->eclipseCaseData()->activeCellInfo( porosityModel ); + replaceFilteredValuesWithDefaultValue( defaultValue, inputValueVisibilityFilter, dataForVariable, activeCellInfo ); } dataForAllVariables.push_back( dataForVariable ); @@ -896,10 +930,10 @@ bool RimGridCalculation::calculateForCases( const std::vector& } std::vector resultValues; - if ( m_destinationCase && m_destinationCase->eclipseCaseData() ) + if ( calculationCase && calculationCase->eclipseCaseData() ) { // Find number of active cells in the destination case. - auto activeCellInfoDestination = m_destinationCase->eclipseCaseData()->activeCellInfo( porosityModel ); + auto activeCellInfoDestination = calculationCase->eclipseCaseData()->activeCellInfo( porosityModel ); if ( activeCellInfoDestination ) { resultValues.resize( activeCellInfoDestination->reservoirActiveCellCount() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.h b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.h index 45f1e75309..a4454f5a5b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.h +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.h @@ -34,6 +34,7 @@ class RimGridView; class RigEclipseResultAddress; class RimEclipseResultAddress; class RimIdenticalGridCaseGroup; +class RigActiveCellInfo; //================================================================================================== /// @@ -88,18 +89,18 @@ class RimGridCalculation : public RimUserDefinedCalculation std::pair validateVariables(); - std::vector getDataForVariable( RimGridCalculationVariable* variable, - size_t tsId, - RiaDefines::PorosityModelType porosityModel, - RimEclipseCase* sourceCase, - RimEclipseCase* destinationCase ) const; + std::vector getActiveCellValuesForVariable( RimGridCalculationVariable* variable, + size_t tsId, + RiaDefines::PorosityModelType porosityModel, + RimEclipseCase* sourceCase, + RimEclipseCase* destinationCase ) const; - std::vector getDataForResult( const QString& resultName, - const RiaDefines::ResultCatType resultCategoryType, - size_t tsId, - RiaDefines::PorosityModelType porosityModel, - RimEclipseCase* sourceCase, - RimEclipseCase* destinationCase ) const; + std::vector getActiveCellValues( const QString& resultName, + const RiaDefines::ResultCatType resultCategoryType, + size_t tsId, + RiaDefines::PorosityModelType porosityModel, + RimEclipseCase* sourceCase, + RimEclipseCase* destinationCase ) const; void filterResults( RimGridView* cellFilterView, const std::vector>& values, @@ -110,17 +111,15 @@ class RimGridCalculation : public RimUserDefinedCalculation RiaDefines::PorosityModelType porosityModel, RimEclipseCase* outputEclipseCase ) const; - static void replaceFilteredValuesWithVector( const std::vector& inputValues, - cvf::ref visibility, - std::vector& resultValues, - RiaDefines::PorosityModelType porosityModel, - RimEclipseCase* outputEclipseCase ); - - static void replaceFilteredValuesWithDefaultValue( double defaultValue, - cvf::ref visibility, - std::vector& resultValues, - RiaDefines::PorosityModelType porosityModel, - RimEclipseCase* outputEclipseCase ); + static void replaceFilteredValuesWithVector( const std::vector& inputValues, + cvf::ref visibility, + std::vector& resultValues, + RigActiveCellInfo* activeCellInfo ); + + static void replaceFilteredValuesWithDefaultValue( double defaultValue, + cvf::ref visibility, + std::vector& resultValues, + RigActiveCellInfo* activeCellInfo ); using DefaultValueConfig = std::pair; DefaultValueConfig defaultValueConfiguration() const; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index fb52c03c40..d38616948d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -411,7 +411,7 @@ void RimSummaryCaseMainCollection::loadFileSummaryCaseData( std::vectorsummaryDataReader() == RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON && prefs->createH5SummaryDataFiles() ) + if ( prefs->summaryDataReader() == RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON ) { int threadCount = 1; #ifdef USE_OPENMP @@ -433,7 +433,10 @@ void RimSummaryCaseMainCollection::loadFileSummaryCaseData( std::vectorcreateH5SummaryDataFiles(), + threadCount ); } } #endif diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp index cb64d22518..3f635d809f 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -1116,14 +1116,20 @@ void RigCaseCellResultsData::createPlaceholderResultEntries() // Cell Volume { - addStaticScalarResult( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::riCellVolumeResultName(), needsToBeStored, 0 ); + if ( !hasResultEntry( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::riCellVolumeResultName() ) ) ) + { + addStaticScalarResult( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::riCellVolumeResultName(), needsToBeStored, 0 ); + } } // Mobile Pore Volume { if ( hasResultEntry( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, "PORV" ) ) ) { - addStaticScalarResult( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::mobilePoreVolumeName(), needsToBeStored, 0 ); + if ( !hasResultEntry( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::mobilePoreVolumeName() ) ) ) + { + addStaticScalarResult( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::mobilePoreVolumeName(), needsToBeStored, 0 ); + } } } @@ -1581,6 +1587,13 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResultByResultTypeOrder( con //-------------------------------------------------------------------------------------------------- size_t RigCaseCellResultsData::findOrLoadKnownScalarResultForTimeStep( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ) { + size_t scalarResultIndex = findScalarResultIndexFromAddress( resVarAddr ); + if ( scalarResultIndex == cvf::UNDEFINED_SIZE_T ) + { + return cvf::UNDEFINED_SIZE_T; + } + if ( isDataPresent( scalarResultIndex ) ) return scalarResultIndex; + RiaDefines::ResultCatType type = resVarAddr.resultCatType(); QString resultName = resVarAddr.resultName(); @@ -1609,7 +1622,6 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResultForTimeStep( const Rig return completionTypeScalarResultIndex; } - size_t scalarResultIndex = findScalarResultIndexFromAddress( resVarAddr ); if ( scalarResultIndex == cvf::UNDEFINED_SIZE_T ) return cvf::UNDEFINED_SIZE_T; if ( type == RiaDefines::ResultCatType::GENERATED ) diff --git a/ApplicationLibCode/UnitTests/HDF5FileWriter-Test.cpp b/ApplicationLibCode/UnitTests/HDF5FileWriter-Test.cpp index 5c90f4d1ff..207016b9c8 100644 --- a/ApplicationLibCode/UnitTests/HDF5FileWriter-Test.cpp +++ b/ApplicationLibCode/UnitTests/HDF5FileWriter-Test.cpp @@ -35,8 +35,12 @@ TEST( DISABLED_HDFTests, WriteToHdf5SummaryExporter ) std::string exportFileName = "e:/project/scratch_export/hdf_complete.h5"; - int threadCount = 1; - RifHdf5SummaryExporter::ensureHdf5FileIsCreatedMultithreaded( { file_path.toStdString() }, { exportFileName }, threadCount ); + int threadCount = 1; + bool createEnhancedSummaryFiles = true; + RifHdf5SummaryExporter::ensureHdf5FileIsCreatedMultithreaded( { file_path.toStdString() }, + { exportFileName }, + createEnhancedSummaryFiles, + threadCount ); } //-------------------------------------------------------------------------------------------------- diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 19d477d55e..0a6fef1f9e 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,17 +1,17 @@ set(RESINSIGHT_MAJOR_VERSION 2024) set(RESINSIGHT_MINOR_VERSION 03) -set(RESINSIGHT_PATCH_VERSION 1) +set(RESINSIGHT_PATCH_VERSION 2) # Opional text with no restrictions set(RESINSIGHT_VERSION_TEXT "-dev") -#set(RESINSIGHT_VERSION_TEXT "-RC_05") +#set(RESINSIGHT_VERSION_TEXT "-RC_02") # Optional text # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".05") +set(RESINSIGHT_DEV_VERSION ".01") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 16be653826f17c6ae50dc1709884cd0e0e23ac3d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Apr 2024 10:33:45 +0200 Subject: [PATCH 050/332] Updates after patch release --- .../ReservoirDataModel/RigCaseCellResultsData.cpp | 7 +++++-- ResInsightVersion.cmake | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 3f635d809f..966a40ecd5 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -1653,9 +1653,12 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResultForTimeStep( const Rig m_cellScalarResults[scalarResultIndex].resize( 1 ); std::vector& values = m_cellScalarResults[scalarResultIndex][0]; - if ( !m_readerInterface->staticResult( resultName, m_porosityModel, &values ) ) + if ( values.empty() ) { - resultLoadingSuccess = false; + if ( !m_readerInterface->staticResult( resultName, m_porosityModel, &values ) ) + { + resultLoadingSuccess = false; + } } } diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 0a6fef1f9e..4024d63881 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,7 +1,7 @@ set(RESINSIGHT_MAJOR_VERSION 2024) set(RESINSIGHT_MINOR_VERSION 03) -set(RESINSIGHT_PATCH_VERSION 2) +set(RESINSIGHT_PATCH_VERSION 3) # Opional text with no restrictions set(RESINSIGHT_VERSION_TEXT "-dev") From c17e5237ca23274bc0ccc423207b089d77db15c5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Apr 2024 09:07:22 +0200 Subject: [PATCH 051/332] Revert "Early return if data already is available" This reverts commit 274d4fc0db872b4032230dc5013667238572ca34. --- .../ReservoirDataModel/RigCaseCellResultsData.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 966a40ecd5..2b8937a09e 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -1587,13 +1587,6 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResultByResultTypeOrder( con //-------------------------------------------------------------------------------------------------- size_t RigCaseCellResultsData::findOrLoadKnownScalarResultForTimeStep( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ) { - size_t scalarResultIndex = findScalarResultIndexFromAddress( resVarAddr ); - if ( scalarResultIndex == cvf::UNDEFINED_SIZE_T ) - { - return cvf::UNDEFINED_SIZE_T; - } - if ( isDataPresent( scalarResultIndex ) ) return scalarResultIndex; - RiaDefines::ResultCatType type = resVarAddr.resultCatType(); QString resultName = resVarAddr.resultName(); @@ -1622,6 +1615,7 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResultForTimeStep( const Rig return completionTypeScalarResultIndex; } + size_t scalarResultIndex = findScalarResultIndexFromAddress( resVarAddr ); if ( scalarResultIndex == cvf::UNDEFINED_SIZE_T ) return cvf::UNDEFINED_SIZE_T; if ( type == RiaDefines::ResultCatType::GENERATED ) From 98144078c883bd0dd2cd27c9396e9dc9341b33bf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Apr 2024 19:56:10 +0200 Subject: [PATCH 052/332] Rename to resdata * Rename to resdata * Remove development feature for storing grid import type in project file * Clean up comments --- ApplicationLibCode/Application/RiaDefines.cpp | 4 +- ApplicationLibCode/Application/RiaDefines.h | 2 +- .../Application/RiaPreferencesSummary.cpp | 4 +- .../Application/RiaPreferencesSummary.h | 2 +- .../RifEclipseInputFileTools.cpp | 2 +- .../RifEclipseOutputFileTools.cpp | 2 +- .../FileInterface/RifEclipseSummaryTools.cpp | 2 +- .../FileInterface/RifOpmGridTools.cpp | 2 +- .../FileInterface/RifReaderEclipseRft.cpp | 2 +- .../FileInterface/RifReaderEclipseSummary.cpp | 8 +-- .../RifSummaryReaderMultipleFiles.cpp | 2 +- .../ProjectDataModel/RimEclipseResultCase.cpp | 13 +--- .../ProjectDataModel/RimEclipseResultCase.h | 1 - .../Summary/RimFileSummaryCase.cpp | 2 +- .../UnitTests/RifSummaryDataReader-Test.cpp | 4 +- CMakeLists.txt | 34 ++++----- .../Python/rips/tests/test_summary_cases.py | 2 +- ThirdParty/Ert/CMakeLists.txt | 4 +- ThirdParty/Ert/applications/ecl/run_gravity.c | 2 +- ThirdParty/Ert/lib/CMakeLists.txt | 72 +++++++++---------- ThirdParty/Ert/lib/ecl/ecl_grav.cpp | 2 +- ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp | 2 +- ThirdParty/Ert/lib/ecl/ecl_grid.cpp | 9 +-- ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp | 2 +- ThirdParty/Ert/lib/ecl/ecl_region.cpp | 2 +- ThirdParty/Ert/lib/ecl/ecl_sum.cpp | 2 +- ThirdParty/Ert/lib/ecl/layer.cpp | 2 +- ThirdParty/Ert/lib/ecl/smspec_node.cpp | 2 +- .../Ert/lib/include/ert/ecl/ecl_kw_magic.hpp | 2 +- ThirdParty/Ert/lib/util/util.c | 4 +- .../custom-opm-flowdiag-app/CMakeLists.txt | 2 +- 31 files changed, 93 insertions(+), 104 deletions(-) diff --git a/ApplicationLibCode/Application/RiaDefines.cpp b/ApplicationLibCode/Application/RiaDefines.cpp index 14dad18650..82640c21d0 100644 --- a/ApplicationLibCode/Application/RiaDefines.cpp +++ b/ApplicationLibCode/Application/RiaDefines.cpp @@ -65,10 +65,10 @@ void caf::AppEnum::setUp() template <> void caf::AppEnum::setUp() { - addItem( RiaDefines::GridModelReader::LIBECL, "LIBECL", "libecl" ); + addItem( RiaDefines::GridModelReader::RESDATA, "RESDATA", "resdata", { "LIBECL" } ); addItem( RiaDefines::GridModelReader::OPM_COMMON, "OPM_COMMON", "opm-common (beta)" ); - setDefault( RiaDefines::GridModelReader::LIBECL ); + setDefault( RiaDefines::GridModelReader::RESDATA ); } template <> diff --git a/ApplicationLibCode/Application/RiaDefines.h b/ApplicationLibCode/Application/RiaDefines.h index 33dc5d6eef..f75a8c171f 100644 --- a/ApplicationLibCode/Application/RiaDefines.h +++ b/ApplicationLibCode/Application/RiaDefines.h @@ -172,7 +172,7 @@ enum class GridCaseAxis enum class GridModelReader { - LIBECL, + RESDATA, OPM_COMMON }; diff --git a/ApplicationLibCode/Application/RiaPreferencesSummary.cpp b/ApplicationLibCode/Application/RiaPreferencesSummary.cpp index ae0b493ff3..e68fe4904e 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSummary.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesSummary.cpp @@ -57,7 +57,7 @@ void RiaPreferencesSummary::SummaryHistoryCurveStyleModeType::setUp() template <> void RiaPreferencesSummary::SummaryReaderModeType::setUp() { - addItem( RiaPreferencesSummary::SummaryReaderMode::LIBECL, "LIBECL", "UNSMRY (libecl)" ); + addItem( RiaPreferencesSummary::SummaryReaderMode::RESDATA, "RESDATA", "UNSMRY (resdata)", { "LIBECL" } ); addItem( RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON, "HDF5_OPM_COMMON", "h5 (HDF5)" ); addItem( RiaPreferencesSummary::SummaryReaderMode::OPM_COMMON, "OPM_COMMON", "ESMRY (opm-common)" ); setDefault( RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON ); @@ -471,7 +471,7 @@ QList RiaPreferencesSummary::calculateValueOptions( cons #ifdef USE_HDF5 availableModes.push_back( SummaryReaderMode::HDF5_OPM_COMMON ); #endif // USE_HDF5 - availableModes.push_back( SummaryReaderMode::LIBECL ); + availableModes.push_back( SummaryReaderMode::RESDATA ); availableModes.push_back( SummaryReaderMode::OPM_COMMON ); for ( auto enumValue : availableModes ) diff --git a/ApplicationLibCode/Application/RiaPreferencesSummary.h b/ApplicationLibCode/Application/RiaPreferencesSummary.h index 7effa71a5f..7fa9c1d54a 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSummary.h +++ b/ApplicationLibCode/Application/RiaPreferencesSummary.h @@ -42,7 +42,7 @@ class RiaPreferencesSummary : public caf::PdmObject public: enum class SummaryReaderMode { - LIBECL, + RESDATA, OPM_COMMON, HDF5_OPM_COMMON }; diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp index da706c9788..ee4c7f9c19 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp @@ -342,7 +342,7 @@ bool RifEclipseInputFileTools::exportGrid( const QString& fileName, // Do not perform the transformation (applyMapaxes == false): // The coordinates have been transformed to the map axes coordinate system already. - // However, send the map axes data in to libecl so that the coordinate system description is saved. + // However, send the map axes data in to resdata so that the coordinate system description is saved. bool applyMapaxes = false; ecl_grid_type* mainEclGrid = ecl_grid_alloc_GRID_data( (int)ecl_coords.size(), ecl_nx, ecl_ny, ecl_nz, 5, &ecl_coords[0], &ecl_corners[0], applyMapaxes, mapAxes.data() ); diff --git a/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp index 950118c570..84e175f1b9 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -379,7 +379,7 @@ QStringList RifEclipseOutputFileTools::filterFileNamesOfType( const QStringList& } //------------------------------------------------------------------------------------------------------- -/// Check if libecl accepts the file name. libecl refuses to open files with mixed case in the file name. +/// Check if resdata accepts the file name. resdata refuses to open files with mixed case in the file name. //------------------------------------------------------------------------------------------------------- bool RifEclipseOutputFileTools::isValidEclipseFileName( const QString& fileName ) { diff --git a/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.cpp index 77208b4bb6..7f0857de6a 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.cpp @@ -160,7 +160,7 @@ std::vector RifEclipseSummaryTools::getRestartFiles( const Q currFile.fileName = headerFileName; while ( !currFile.fileName.isEmpty() ) { - // Due to a weakness in libecl regarding restart summary header file selection, + // Due to a weakness in resdata regarding restart summary header file selection, // do some extra checking { QString formattedHeaderExtension = ".FSMSPEC"; diff --git a/ApplicationLibCode/FileInterface/RifOpmGridTools.cpp b/ApplicationLibCode/FileInterface/RifOpmGridTools.cpp index 25ff8fc5c8..56183d2212 100644 --- a/ApplicationLibCode/FileInterface/RifOpmGridTools.cpp +++ b/ApplicationLibCode/FileInterface/RifOpmGridTools.cpp @@ -358,7 +358,7 @@ void RifOpmGridTools::transferCoordinatesCartesian( Opm::EclIO::EGrid& opmMainG riActiveCells->setReservoirCellCount( riMainGrid->cellCount() ); - // same mapping as libecl + // same mapping as resdata const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 }; #pragma omp parallel for diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseRft.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseRft.cpp index 4d344cddf4..66c212048d 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseRft.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseRft.cpp @@ -68,7 +68,7 @@ void RifReaderEclipseRft::open() if ( m_ecl_rft_file == nullptr ) { - RiaLogging::warning( QString( "Libecl could not find/open file '%1" ).arg( m_fileName ) ); + RiaLogging::warning( QString( "resdata library could not find/open file '%1" ).arg( m_fileName ) ); return; } diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp index 0ef8e0ee62..3b89e9c43c 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp @@ -68,7 +68,7 @@ bool RifReaderEclipseSummary::open( const QString& headerFileName, RiaThreadSafe // - else // - create ESMRY file if defined in preference // - use ESMRY reader - // - if no reader has been created, fallback to libecl + // - if no reader has been created, fallback to resdata // // H5 // - if h5 file is present on disk @@ -76,9 +76,9 @@ bool RifReaderEclipseSummary::open( const QString& headerFileName, RiaThreadSafe // - else // - create h5 file if defined in preference // - use h5 reader - // - if no reader has been created, fallback to libecl + // - if no reader has been created, fallback to resdata // - // For all import modes, use libecl to read data if no data is imported with ESMRY or h5 + // For all import modes, use resdata to read data if no data is imported with ESMRY or h5 RiaPreferencesSummary* prefSummary = RiaPreferencesSummary::current(); @@ -136,7 +136,7 @@ bool RifReaderEclipseSummary::open( const QString& headerFileName, RiaThreadSafe } } - // If no summary reader has been created, always try to read data using libecl + // If no summary reader has been created, always try to read data using resdata if ( !isValid ) { auto libeclReader = std::make_unique(); diff --git a/ApplicationLibCode/FileInterface/RifSummaryReaderMultipleFiles.cpp b/ApplicationLibCode/FileInterface/RifSummaryReaderMultipleFiles.cpp index 176e5717c1..e24b2e608e 100644 --- a/ApplicationLibCode/FileInterface/RifSummaryReaderMultipleFiles.cpp +++ b/ApplicationLibCode/FileInterface/RifSummaryReaderMultipleFiles.cpp @@ -55,7 +55,7 @@ std::pair> RifSummaryReaderMultipleFiles::values( cons // When a well is introduced, no data is present before the time step the well is introduced // Add values of zero for this interval // - // This issue was reported for libecl, but it is not relevant now as the low level file readers only handle + // This issue was reported for resdata, but it is not relevant now as the low level file readers only handle // a single file. // https://github.com/OPM/ResInsight/issues/7065 diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp index fa389c7185..c9da240294 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -81,14 +81,6 @@ RimEclipseResultCase::RimEclipseResultCase() { CAF_PDM_InitScriptableObject( "Eclipse Case", ":/Case48x48.png", "", "The Regular Eclipse Results Case" ); - auto defaultReader = RiaPreferences::current()->gridModelReader(); - CAF_PDM_InitField( &m_gridModelReader, "gridModelReader", caf::AppEnum( defaultReader ), "Grid Model Reader" ); - if ( !RiaApplication::enableDevelopmentFeatures() ) - { - m_gridModelReader.xmlCapability()->disableIO(); - m_gridModelReader.uiCapability()->setUiHidden( true ); - } - CAF_PDM_InitFieldNoDefault( &m_unitSystem, "UnitSystem", "Unit System" ); m_unitSystem.registerGetMethod( RimProject::current(), &RimProject::commonUnitSystemForAllCases ); m_unitSystem.uiCapability()->setUiReadOnly( true ); @@ -145,7 +137,9 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter return false; } - if ( m_gridModelReader == RiaDefines::GridModelReader::LIBECL ) + auto defaultReader = RiaPreferences::current()->gridModelReader(); + + if ( defaultReader == RiaDefines::GridModelReader::RESDATA ) { auto readerEclipseOutput = new RifReaderEclipseOutput(); @@ -620,7 +614,6 @@ bool RimEclipseResultCase::hasSourSimFile() //-------------------------------------------------------------------------------------------------- void RimEclipseResultCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - uiOrdering.add( &m_gridModelReader ); uiOrdering.add( &m_caseUserDescription ); uiOrdering.add( &m_displayNameOption ); uiOrdering.add( &m_caseId ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h index a208056f70..a39edec3f2 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h @@ -94,7 +94,6 @@ class RimEclipseResultCase : public RimEclipseCase cvf::ref m_readerEclipseRft; cvf::ref m_readerOpmRft; - caf::PdmField> m_gridModelReader; caf::PdmProxyValueField> m_unitSystem; caf::PdmChildArrayField m_flowDiagSolutions; caf::PdmField m_sourSimFileName; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp index 59ad93b809..1a8cfc3376 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp @@ -100,7 +100,7 @@ QString RimFileSummaryCase::caseName() const void RimFileSummaryCase::createSummaryReaderInterfaceThreadSafe( RiaThreadSafeLogger* threadSafeLogger ) { // RimFileSummaryCase::findRelatedFilesAndCreateReader is a performance bottleneck. The function - // RifEclipseSummaryTools::getRestartFile() should be refactored to use opm-common instead of libecl. + // RifEclipseSummaryTools::getRestartFile() should be refactored to use opm-common instead of resdata. // It is not possible to use restart files in ESMRY file format, see see ESmry::make_esmry_file() // // https://github.com/OPM/ResInsight/issues/11342 diff --git a/ApplicationLibCode/UnitTests/RifSummaryDataReader-Test.cpp b/ApplicationLibCode/UnitTests/RifSummaryDataReader-Test.cpp index 4d32a18d2f..1fdae47a91 100644 --- a/ApplicationLibCode/UnitTests/RifSummaryDataReader-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifSummaryDataReader-Test.cpp @@ -75,7 +75,7 @@ TEST( DISABLED_RifSummaryDataTest, LibEclAllData ) auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration diff = end - start; - std::cout << "LibEcl : Open " << std::setw( 9 ) << diff.count() << " s\n"; + std::cout << "resdata : Open " << std::setw( 9 ) << diff.count() << " s\n"; } // for ( auto adr : reader.allResultAddresses() ) @@ -101,7 +101,7 @@ TEST( DISABLED_RifSummaryDataTest, LibEclAllData ) auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration diff = end - start; - std::cout << "LibEcl read data" << std::setw( 9 ) << totalValuesRead << "totalValueCount" << diff.count() << " s\n"; + std::cout << "resdata read data" << std::setw( 9 ) << totalValuesRead << "totalValueCount" << diff.count() << " s\n"; } } } diff --git a/CMakeLists.txt b/CMakeLists.txt index d08245e64c..b0010b31b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,10 +199,10 @@ if(RESINSIGHT_ENABLE_UNITY_BUILD) endif() # ############################################################################## -# ERT +# resdata # ############################################################################## -# Use of CMAKE_CXX_COMPILER_LAUNCHER is not working with libecl. Disable by +# Use of CMAKE_CXX_COMPILER_LAUNCHER is not working with resdata. Disable by # temporarily setting compiler launcher to nothing set(TEMP_CMAKE_CXX_COMPILER_LAUNCHER ${CMAKE_CXX_COMPILER_LAUNCHER}) set(CMAKE_CXX_COMPILER_LAUNCHER) @@ -237,7 +237,7 @@ if(RESINSIGHT_ERT_EXTERNAL_LIB_ROOT OR RESINSIGHT_ERT_EXTERNAL_INCLUDE_ROOT) list(APPEND ERT_INCLUDE_DIRS ${RESINSIGHT_ERT_EXTERNAL_INCLUDE_ROOT}) - list(APPEND ERT_LIBRARIES ${RESINSIGHT_ERT_EXTERNAL_LIB_ROOT}/libecl.so) + list(APPEND ERT_LIBRARIES ${RESINSIGHT_ERT_EXTERNAL_LIB_ROOT}/resdata.so) else() @@ -279,35 +279,35 @@ else() endif() if(MSVC) - # libecl : Disable some warnings + # resdata : Disable some warnings set_target_properties( - ecl + resdata PROPERTIES COMPILE_FLAGS "/wd4244 /wd4267 /wd4013 /wd4190 /wd4018 /wd4477 /wd4098 /wd4293 /wd4305 /wd4020 /wd4028 /wd4715 /wd4245 /wd4804 /wd4100 /wd4456 /wd4458 /wd4090 /wd4297 /wd4701 /wd4101 /wd4702 /wd4457" ) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set_target_properties( - ecl + resdata PROPERTIES COMPILE_FLAGS "-Wno-deprecated -Wno-deprecated-declarations -Wno-sign-compare" ) else() set_target_properties( - ecl + resdata PROPERTIES COMPILE_FLAGS "-Wno-deprecated -Wno-deprecated-declarations -Wno-clobbered -Wno-int-in-bool-context" ) target_compile_options( - ecl PRIVATE $<$:-Wno-class-memaccess> + resdata PRIVATE $<$:-Wno-class-memaccess> ) endif() - list(APPEND THIRD_PARTY_LIBRARIES ecl) + list(APPEND THIRD_PARTY_LIBRARIES resdata) set_property(TARGET catch2 PROPERTY FOLDER "Thirdparty") @@ -316,7 +316,7 @@ else() endif(RESINSIGHT_ERT_EXTERNAL_LIB_ROOT OR RESINSIGHT_ERT_EXTERNAL_INCLUDE_ROOT) -# restore buildcache when libecl has been configured +# restore buildcache when resdata has been configured set(CMAKE_CXX_COMPILER_LAUNCHER ${TEMP_CMAKE_CXX_COMPILER_LAUNCHER}) # ############################################################################## @@ -884,7 +884,7 @@ set(RESINSIGHT_INSTALL_FOLDER ".") # override system install prefix if private installation chosen option(RESINSIGHT_PRIVATE_INSTALL - "Linux only: Install the libecl shared libraries along the executable" + "Linux only: Install the resdata shared libraries along the executable" ON ) mark_as_advanced(FORCE RESINSIGHT_PRIVATE_INSTALL) @@ -898,9 +898,9 @@ if(RESINSIGHT_PRIVATE_INSTALL) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(ERT_SHARED_LIB_FILES - ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libecl.so - ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libecl.so.2 - ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libecl.so.2.4 + ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libresdata.so + ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libresdata.so.2 + ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libresdata.so.2.4 ) install(FILES ${ERT_SHARED_LIB_FILES} DESTINATION ${RESINSIGHT_INSTALL_FOLDER} @@ -909,9 +909,9 @@ if(RESINSIGHT_PRIVATE_INSTALL) if(APPLE) set(ERT_SHARED_LIB_FILES - ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libecl.dylib - ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libecl.2.dylib - ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libecl.2.4.dylib + ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libresdata.dylib + ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libresdata.2.dylib + ${CMAKE_BINARY_DIR}/ThirdParty/Ert/${CMAKE_INSTALL_LIBDIR}/libresdata.2.4.dylib ) install( FILES ${ERT_SHARED_LIB_FILES} diff --git a/GrpcInterface/Python/rips/tests/test_summary_cases.py b/GrpcInterface/Python/rips/tests/test_summary_cases.py index 49618f1ea2..497b88ad38 100644 --- a/GrpcInterface/Python/rips/tests/test_summary_cases.py +++ b/GrpcInterface/Python/rips/tests/test_summary_cases.py @@ -37,7 +37,7 @@ def test_summary_data(rips_instance, initialize_test): assert summary_case.id == 1 addresses = summary_case.available_addresses() - # Summary reader type is controlled from Preferences. libecl reports 343 vectors, opm_common (ESMRY) reports 339. + # Summary reader type is controlled from Preferences. resdata reports 343 vectors, opm_common (ESMRY) reports 339. # As this configuration can be different, allow both variants assert len(addresses.values) == 335 or len(addresses.values) == 339 diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index 22dafde9c3..3976e8fe94 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -353,5 +353,5 @@ if (INSTALL_ERT) install(EXPORT ecl-config DESTINATION share/cmake/ecl) endif() -export(TARGETS ecl FILE eclConfig.cmake) -export(PACKAGE ecl) +export(TARGETS resdata FILE eclConfig.cmake) +export(PACKAGE resdata) diff --git a/ThirdParty/Ert/applications/ecl/run_gravity.c b/ThirdParty/Ert/applications/ecl/run_gravity.c index d0b3c17fca..7f611a8a92 100644 --- a/ThirdParty/Ert/applications/ecl/run_gravity.c +++ b/ThirdParty/Ert/applications/ecl/run_gravity.c @@ -815,7 +815,7 @@ static int gravity_check_input( const ecl_grid_type * ecl_grid , /** Check that the rporv values are in the right ballpark. For - ECLIPSE version 2008.2 they are way fucking off. Check PORV + ECLIPSE version 2008.2 they are way off. Check PORV versus RPORV for ten 'random' locations in the grid. */ { diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt index e537313011..b362eb6c38 100644 --- a/ThirdParty/Ert/lib/CMakeLists.txt +++ b/ThirdParty/Ert/lib/CMakeLists.txt @@ -20,6 +20,7 @@ if (ERT_HAVE_SPAWN) list(APPEND opt_srcs util/util_spawn.cpp) endif() + if (ERT_HAVE_LOCKF) list(APPEND opt_srcs util/util_lockf.cpp) endif () @@ -60,7 +61,7 @@ configure_file(ert_api_config.h.in include/ert/util/ert_api_config.h) configure_file(build_config.hpp.in include/ert/util/build_config.hpp) configure_file(ert_api_config.hpp.in include/ert/util/ert_api_config.hpp) -add_library(ecl util/rng.cpp +add_library(resdata util/rng.cpp util/lookup_table.cpp util/statistics.cpp util/mzran.cpp @@ -153,13 +154,12 @@ add_library(ecl util/rng.cpp ) if (ERT_WINDOWS) - set_target_properties(ecl PROPERTIES PREFIX "lib") if (MSVC) - set_target_properties(ecl PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + set_target_properties(resdata PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() endif () -target_link_libraries(ecl PUBLIC ${m} +target_link_libraries(resdata PUBLIC ${m} ${dl} ${pthread} ${blas} @@ -167,7 +167,7 @@ target_link_libraries(ecl PUBLIC ${m} ${shlwapi} ) -target_include_directories(ecl +target_include_directories(resdata PUBLIC $ $ $ @@ -186,7 +186,7 @@ if (NOT INSTALL_ERT) set(GIT_COMMIT_SHORT 0) endif() -target_compile_definitions(ecl PRIVATE +target_compile_definitions(resdata PRIVATE -DGIT_COMMIT=${GIT_COMMIT} -DGIT_COMMIT_SHORT=${GIT_COMMIT_SHORT} -DECL_VERSION_MAJOR=${ECL_VERSION_MAJOR} @@ -195,20 +195,20 @@ target_compile_definitions(ecl PRIVATE $<$:HOST_BIG_ENDIAN> ) -target_compile_options(ecl PUBLIC ${pthreadarg}) +target_compile_options(resdata PUBLIC ${pthreadarg}) if (ERT_USE_OPENMP) - target_compile_options(ecl PUBLIC ${OpenMP_CXX_FLAGS}) - set_property(TARGET ecl APPEND PROPERTY LINK_FLAGS ${OpenMP_CXX_FLAGS}) - target_link_libraries( ecl PUBLIC ${OpenMP_EXE_LINKER_FLAGS}) + target_compile_options(resdata PUBLIC ${OpenMP_CXX_FLAGS}) + set_property(TARGET resdata APPEND PROPERTY LINK_FLAGS ${OpenMP_CXX_FLAGS}) + target_link_libraries( resdata PUBLIC ${OpenMP_EXE_LINKER_FLAGS}) endif () -set_target_properties(ecl PROPERTIES +set_target_properties(resdata PROPERTIES VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} SOVERSION ${ECL_VERSION_MAJOR}) if (INSTALL_ERT) -install(TARGETS ecl +install(TARGETS resdata EXPORT ecl-config ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -231,7 +231,7 @@ add_executable(ecl3-testsuite test/testsuite.cpp target_include_directories(ecl3-testsuite PRIVATE e3 ) -target_link_libraries(ecl3-testsuite catch2 ecl) +target_link_libraries(ecl3-testsuite catch2 resdata) add_test(NAME ecl3 COMMAND ecl3-testsuite) @@ -265,17 +265,17 @@ foreach (name ert_util_alloc_file_components add_executable(${name} util/tests/${name}.cpp) target_include_directories(${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/private-include) - target_link_libraries(${name} ecl) + target_link_libraries(${name} resdata) add_test(NAME ${name} COMMAND ${name}) endforeach () add_executable(ecl_smspec_node ecl/tests/ecl_smspec_node.cpp) -target_link_libraries( ecl_smspec_node ecl) +target_link_libraries( ecl_smspec_node resdata) add_test(NAME ecl_smspec_node COMMAND ecl_smspec_node) add_executable(ert_util_work_area util/tests/ert_util_work_area.cpp) -target_link_libraries(ert_util_work_area ecl) +target_link_libraries(ert_util_work_area resdata) add_test(NAME ert_util_work_area COMMAND ert_util_work_area data2/file1 ${CMAKE_CURRENT_SOURCE_DIR}/util/tests/data2/file2 @@ -284,49 +284,49 @@ add_test(NAME ert_util_work_area ) add_executable(ert_util_cwd_test util/tests/ert_util_cwd_test.cpp) -target_link_libraries(ert_util_cwd_test ecl) +target_link_libraries(ert_util_cwd_test resdata) add_test(NAME ert_util_cwd_test COMMAND ert_util_cwd_test ${CMAKE_CURRENT_BINARY_DIR}) add_executable(ert_util_copy_file util/tests/ert_util_copy_file.cpp) -target_link_libraries(ert_util_copy_file ecl) +target_link_libraries(ert_util_copy_file resdata) add_test(NAME ert_util_copy_file COMMAND ert_util_copy_file $) add_executable(ert_util_file_readable util/tests/ert_util_file_readable.cpp) -target_link_libraries(ert_util_file_readable ecl) +target_link_libraries(ert_util_file_readable resdata) add_test(NAME ert_util_file_readable COMMAND ert_util_file_readable) add_executable(ert_util_path_stack_test util/tests/ert_util_path_stack_test.cpp) -target_link_libraries(ert_util_path_stack_test ecl) +target_link_libraries(ert_util_path_stack_test resdata) add_test(NAME ert_util_path_stack_test COMMAND ert_util_path_stack_test ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) if (HAVE_BACKTRACE) add_executable(ert_util_abort_gnu_tests util/tests/ert_util_abort_gnu_tests.cpp) - target_link_libraries(ert_util_abort_gnu_tests ecl) + target_link_libraries(ert_util_abort_gnu_tests resdata) add_test(NAME ert_util_abort_gnu_tests COMMAND ert_util_abort_gnu_tests) add_executable(ert_util_addr2line util/tests/ert_util_addr2line.cpp) - target_link_libraries(ert_util_addr2line ecl) + target_link_libraries(ert_util_addr2line resdata) add_test(NAME ert_util_addr2line COMMAND ert_util_addr2line) endif() if (HAVE_UTIL_ABORT_INTERCEPT) add_executable(ert_util_type_vector_test util/tests/ert_util_type_vector_test.cpp) - target_link_libraries(ert_util_type_vector_test ecl) + target_link_libraries(ert_util_type_vector_test resdata) add_test(NAME ert_util_type_vector_test COMMAND ert_util_type_vector_test) endif() if (ERT_HAVE_SPAWN) add_executable(ert_util_spawn util/tests/ert_util_spawn.cpp) - target_link_libraries(ert_util_spawn ecl) + target_link_libraries(ert_util_spawn resdata) add_test(NAME ert_util_spawn COMMAND ert_util_spawn) endif() # -# ecl +# resdata # foreach (name ecl_alloc_cpgrid @@ -381,24 +381,24 @@ foreach (name ecl_alloc_cpgrid ecl_file ) add_executable(${name} ecl/tests/${name}.cpp) - target_link_libraries(${name} ecl) + target_link_libraries(${name} resdata) target_include_directories(${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/private-include) add_test(NAME ${name} COMMAND ${name}) endforeach () if (HAVE_UTIL_ABORT_INTERCEPT) add_executable(ecl_grid_corner ecl/tests/ecl_grid_corner.cpp) - target_link_libraries(ecl_grid_corner ecl) + target_link_libraries(ecl_grid_corner resdata) add_test(NAME ecl_grid_corner COMMAND ecl_grid_corner) add_executable(ecl_layer ecl/tests/ecl_layer.cpp) - target_link_libraries(ecl_layer ecl) + target_link_libraries(ecl_layer resdata) target_include_directories(ecl_layer PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/private-include) add_test(NAME ecl_layer COMMAND ecl_layer) endif() add_executable(ecl_get_num_cpu ecl/tests/ecl_get_num_cpu_test.cpp) -target_link_libraries(ecl_get_num_cpu ecl) +target_link_libraries(ecl_get_num_cpu resdata) add_test(NAME ecl_get_num_cpu COMMAND ecl_get_num_cpu ${CMAKE_CURRENT_SOURCE_DIR}/ecl/tests/data/num_cpu1 ${CMAKE_CURRENT_SOURCE_DIR}/ecl/tests/data/num_cpu2 @@ -409,7 +409,7 @@ add_test(NAME ecl_get_num_cpu COMMAND ecl_get_num_cpu # into the CTEST system. Should be invoked manually on Windows. if (ERT_WINDOWS) add_executable(ecl_lfs ecl/tests/ecl_lfs.cpp) - target_link_libraries(ecl_lfs ecl) + target_link_libraries(ecl_lfs resdata) endif() # @@ -419,19 +419,19 @@ endif() foreach (name geo_util_xlines geo_polygon geo_polygon_collection) add_executable(${name} geometry/tests/${name}.cpp) - target_link_libraries(${name} ecl) + target_link_libraries(${name} resdata) add_test(NAME ${name} COMMAND ${name}) endforeach () foreach (test ert_util_unique_ptr) add_executable(${test} util/tests/${test}.cpp) - target_link_libraries(${test} ecl) + target_link_libraries(${test} resdata) add_test(NAME ${test} COMMAND ${test}) endforeach() foreach (test eclxx_kw eclxx_fortio eclxx_filename eclxx_types) add_executable(${test} ecl/tests/${test}.cpp) - target_link_libraries(${test} ecl) + target_link_libraries(${test} resdata) add_test(NAME ${test} COMMAND ${test}) endforeach () @@ -477,7 +477,7 @@ foreach(name ecl_coarse_test well_lgr_load) add_executable(${name} ecl/tests/${name}.cpp) - target_link_libraries(${name} ecl) + target_link_libraries(${name} resdata) target_include_directories(${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/private-include) endforeach() @@ -641,7 +641,7 @@ add_test(NAME ecl_fault_block_layer_equinor COMMAND ecl_fault_block_layer_equino if (HAVE_UTIL_ABORT_INTERCEPT) add_executable(ecl_fortio ecl/tests/ecl_fortio.cpp) - target_link_libraries( ecl_fortio ecl) + target_link_libraries( ecl_fortio resdata) add_test(NAME ecl_fortio COMMAND ecl_fortio ${_eclpath}/Gurbat/ECLIPSE.UNRST) endif() @@ -698,7 +698,7 @@ add_test(NAME well_lgr_load2 COMMAND well_lgr_load ${_eclpath}/AmalgLGRcase/TEST # geometry # add_executable(geo_surface geometry/tests/geo_surface.cpp) -target_link_libraries(geo_surface ecl) +target_link_libraries(geo_surface resdata) add_test(NAME geo_surface COMMAND geo_surface ${_geopath}/Surface.irap ${_geopath}/Surface_incompatible.irap) diff --git a/ThirdParty/Ert/lib/ecl/ecl_grav.cpp b/ThirdParty/Ert/lib/ecl/ecl_grav.cpp index 2503317369..3daa04710d 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grav.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_grav.cpp @@ -361,7 +361,7 @@ static ecl_grav_survey_type * ecl_grav_survey_alloc_empty(const ecl_grav_type * /** Check that the rporv values are in the right ballpark. For ECLIPSE - version 2008.2 they are way fucking off. Check PORV versus RPORV + version 2008.2 they are way off. Check PORV versus RPORV for some random locations in the grid. */ diff --git a/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp b/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp index 1c758a4701..e41d5d66bc 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp @@ -39,7 +39,7 @@ /** Check that the rporv values are in the right ballpark. For - ECLIPSE version 2008.2 they are way fucking off. Check PORV + ECLIPSE version 2008.2 they are way off. Check PORV versus RPORV for ten 'random' locations in the grid. */ diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid.cpp b/ThirdParty/Ert/lib/ecl/ecl_grid.cpp index 0736911016..35cfdb272b 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_grid.cpp @@ -674,9 +674,7 @@ static void point_copy_values(point_type * p , const point_type * src) { #define CELL_FLAG_VALID 1 /* In the case of GRID files not necessarily all cells geometry values set - in that case this will be left as false. */ #define CELL_FLAG_CENTER 2 /* Has the center value been calculated - this is by default not done to speed up loading a tiny bit. */ -#define CELL_FLAG_TAINTED 4 /* lazy fucking stupid reservoir engineers make invalid grid - cells - for kicks?? must try to keep those cells out of - real-world calculations with some hysteric heuristics.*/ +#define CELL_FLAG_TAINTED 4 /* */ #define CELL_FLAG_VOLUME 8 typedef struct ecl_cell_struct ecl_cell_type; @@ -996,8 +994,7 @@ static double ecl_cell_max_y( const ecl_cell_type * cell ) { /** - The problem is that some extremely fucking stupid reservoir - engineers purpousely have made grids with invalid cells. Typically + Grids with invalid cells. Typically the cells accomodating numerical aquifers are located at an utm position (0,0). @@ -2065,7 +2062,7 @@ static void ecl_grid_pillar_cross_planes(const point_type * p0, static void ecl_grid_init_mapaxes( ecl_grid_type * ecl_grid , bool apply_mapaxes, const float * mapaxes) { if (ecl_grid->global_grid != NULL) - util_abort("%s: hmmmm - this is a major fuck up; trying to grid transformation data from mapaxes for a subgrid(lgr)\n",__func__); + util_abort("%s: Invalid operation: trying to grid transformation data from mapaxes for a subgrid(lgr)\n",__func__); { const double unit_y[2] = {mapaxes[0] - mapaxes[2] , mapaxes[1] - mapaxes[3]}; const double unit_x[2] = {mapaxes[4] - mapaxes[2] , mapaxes[5] - mapaxes[3]}; diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp index 3e60d55dc0..85bd44ae43 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp @@ -554,7 +554,7 @@ ecl_kw_type * ecl_kw_fscanf_alloc_grdecl( FILE * stream , const char * kw , int This function will read and allocate the next keyword in the file. This function does not take either kw or the size of the kw as input, and has virtually zero possibilities to check what it is - doing. The possibilities of failure are fucking endless, and the + doing. The possibilities of failure are endless, and the function should only be used when you are goddamn certain that the input file is well formatted. */ diff --git a/ThirdParty/Ert/lib/ecl/ecl_region.cpp b/ThirdParty/Ert/lib/ecl/ecl_region.cpp index ad92928efa..7620ad0596 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_region.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_region.cpp @@ -428,7 +428,7 @@ void ecl_region_deselect_in_interval( ecl_region_type * region , const ecl_kw_ty /*****************************************************************/ /** - This is waaaay to fucking large: + This is waaaay to large: Float / Int / double * Active / Global * More / Less ==> In total 12 code blocks written out ... */ diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum.cpp b/ThirdParty/Ert/lib/ecl/ecl_sum.cpp index a64e2e4bd8..a5c5d149fc 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_sum.cpp @@ -226,7 +226,7 @@ static bool ecl_sum_fread(ecl_sum_type * ecl_sum , const char *header_file , con else if (file_type == ECL_UNIFIED_SUMMARY_FILE) ecl_sum_set_unified( ecl_sum , true); else - util_abort("%s: what the fuck? \n",__func__); + util_abort("%s: error \n",__func__); } else return false; diff --git a/ThirdParty/Ert/lib/ecl/layer.cpp b/ThirdParty/Ert/lib/ecl/layer.cpp index 3cbcbf5073..03f6c7fc10 100644 --- a/ThirdParty/Ert/lib/ecl/layer.cpp +++ b/ThirdParty/Ert/lib/ecl/layer.cpp @@ -490,7 +490,7 @@ bool layer_trace_block_edge( const layer_type * layer , int start_i , int start_ point_shift( &start_corner , 0 , 1 ); layer_trace_block_edge__(layer , start_corner , i , j , value , LEFT_EDGE , corner_list , cell_list); } else - util_abort("%s: what the fuck - internal error \n",__func__); + util_abort("%s: internal error \n",__func__); int_vector_select_unique( cell_list ); return true; diff --git a/ThirdParty/Ert/lib/ecl/smspec_node.cpp b/ThirdParty/Ert/lib/ecl/smspec_node.cpp index fdeada0d78..8d71e8e70f 100644 --- a/ThirdParty/Ert/lib/ecl/smspec_node.cpp +++ b/ThirdParty/Ert/lib/ecl/smspec_node.cpp @@ -51,7 +51,7 @@ For instance the keyword 'NEWTON' starts with 'N' and is classified as a NETWORK type variable. However it should rather - be classified as a MISC type variable. (What a fucking mess). + be classified as a MISC type variable. The special_vars list is used in the functions ecl_smspec_identify_special_var() and ecl_smspec_identify_var_type(). diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.hpp index 02dab28681..c54ab05330 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.hpp @@ -623,7 +623,7 @@ values (2e20) are denoted with '*'. #define FILEHEAD_ORGFORMAT_INDEX 6 #define GRIDHEAD_GRIDTYPE_CORNERPOINT 1 /* <----\ */ - /* | Fucking hysterical! */ + /* | */ #define FILEHEAD_GRIDTYPE_CORNERPOINT 0 /* <----/ */ #define FILEHEAD_ORGTYPE_CORNERPOINT 1 diff --git a/ThirdParty/Ert/lib/util/util.c b/ThirdParty/Ert/lib/util/util.c index 7eefe13f20..5923dd5ba3 100644 --- a/ThirdParty/Ert/lib/util/util.c +++ b/ThirdParty/Ert/lib/util/util.c @@ -871,7 +871,7 @@ char * util_alloc_realpath(const char * input_path) { the entry exists; and if not we abort. If the entry indeed exists we call the util_alloc_cwd_abs_path() function: */ #ifdef ERT_HAVE_SYMLINK - ERROR - What the fuck; have symlinks and not realpath()?! + ERROR - internal error - have symlinks and not realpath()?! #endif if (!util_entry_exists( input_path )) util_abort("%s: input_path:%s does not exist - failed.\n",__func__ , input_path); @@ -912,7 +912,7 @@ char * util_alloc_abs_path( const char * path ) { /** Both path arguments must be absolute paths; if not a copy of the input path will be returned. Neither of the input arguments can - have "/../" elements - that will just fuck things up. + have "/../" elements root_path can be NULL - in which case cwd is used. */ diff --git a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt index d6748f8a5b..c9f65024ef 100644 --- a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt @@ -33,7 +33,7 @@ add_library(custom-opm-flowdiag-app find_package(Boost REQUIRED filesystem system) target_link_libraries(custom-opm-flowdiag-app - ecl + resdata Boost::filesystem ) From 26df3dda7da900461119be8821de54c84c08750f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Apr 2024 09:37:27 +0200 Subject: [PATCH 053/332] Prepare dev branch for new features --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 4024d63881..680810b33e 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,7 +1,7 @@ set(RESINSIGHT_MAJOR_VERSION 2024) set(RESINSIGHT_MINOR_VERSION 03) -set(RESINSIGHT_PATCH_VERSION 3) +set(RESINSIGHT_PATCH_VERSION 4) # Opional text with no restrictions set(RESINSIGHT_VERSION_TEXT "-dev") From df7112e6154481d027be3d8280e406a6bb54d88f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Apr 2024 10:00:25 +0200 Subject: [PATCH 054/332] Add missing includes --- ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp index 5f3fcba038..cc9fdeb11c 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp @@ -38,7 +38,9 @@ #include "RimGeoMechContourMapView.h" #include "RimGeoMechContourMapViewCollection.h" #include "RimGeoMechView.h" +#include "RimOilField.h" #include "RimPolygonFilter.h" +#include "RimProject.h" #include "RimRegularLegendConfig.h" #include "RimSimWellInViewCollection.h" #include "RimSurfaceInViewCollection.h" From 55c0e81d9e59dcb9432e187b1605289d7c29ac11 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 26 Apr 2024 11:16:15 +0200 Subject: [PATCH 055/332] OpenSSL: remove OpenSSL bundling. The OpenSSL library from vcpkg is unlikely to be the one needed by Qt. --- .github/workflows/ResInsightWithCache.yml | 13 ------ ApplicationExeCode/CMakeLists.txt | 48 ----------------------- 2 files changed, 61 deletions(-) diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 1124335926..13d30c5daa 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -185,18 +185,6 @@ jobs: "${{ github.workspace }}/ThirdParty/vcpkg" appendedCacheKey: ${{ matrix.config.os }}-${{ matrix.config.cxx }}-cache-key-v2 - - name: Cache dynamic version of OpenSSL (Linux) - if: contains( matrix.config.os, 'ubuntu_disabled') - uses: actions/cache@v4 - with: - path: ${{ github.workspace }}/ThirdParty/vcpkg/installed/x64-linux-dynamic - key: ${{ matrix.config.os }}-vcpkg-x64-linux-dynamic_v05 - - - name: Install dynamic version of OpenSSL (Linux) - if: contains( matrix.config.os, 'ubuntu') - run: | - $VCPKG_ROOT/vcpkg install --overlay-triplets=${{ github.workspace }}/ThirdParty/vcpkg-custom-triplets --triplet x64-linux-dynamic openssl - - name: Configure shell: cmake -P {0} run: | @@ -209,7 +197,6 @@ jobs: -B cmakebuild -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} -D CMAKE_INSTALL_PREFIX=cmakebuild/install - -D RESINSIGHT_BUNDLE_OPENSSL=true -D RESINSIGHT_QT5_BUNDLE_LIBRARIES=true -D RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true -D RESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true diff --git a/ApplicationExeCode/CMakeLists.txt b/ApplicationExeCode/CMakeLists.txt index e749eca703..ca5d0ff7a7 100644 --- a/ApplicationExeCode/CMakeLists.txt +++ b/ApplicationExeCode/CMakeLists.txt @@ -662,50 +662,6 @@ else(RESINSIGHT_PRIVATE_INSTALL) ) endif(RESINSIGHT_PRIVATE_INSTALL) -# OpenSSL -option(RESINSIGHT_BUNDLE_OPENSSL "Bundle the OpenSSL binary library files" OFF) -mark_as_advanced(FORCE RESINSIGHT_BUNDLE_OPENSSL) - -if(RESINSIGHT_BUNDLE_OPENSSL) - if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - find_package(OpenSSL) - - if(OPENSSL_FOUND) - message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}") - set(OPENSSL_BIN_DIR ${OPENSSL_INCLUDE_DIR}) - string(REPLACE "include" "bin" OPENSSL_BIN_DIR ${OPENSSL_BIN_DIR}) - message("OpenSSL binary dir: ${OPENSSL_BIN_DIR}") - - install(FILES ${OPENSSL_BIN_DIR}/libcrypto-3-x64.dll - DESTINATION ${RESINSIGHT_INSTALL_FOLDER} - ) - install(FILES ${OPENSSL_BIN_DIR}/libssl-3-x64.dll - DESTINATION ${RESINSIGHT_INSTALL_FOLDER} - ) - endif(OPENSSL_FOUND) - elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - # Assumes that OpenSSL is installed by ./vcpkg install - # --overlay-triplets=custom-triplets --triplet x64-linux-dynamic openssl - set(OPENSSL_BIN_DIR - ${CMAKE_SOURCE_DIR}/ThirdParty/vcpkg/installed/x64-linux-dynamic/lib - ) - message("OpenSSL binary dir: ${OPENSSL_BIN_DIR}") - - install(FILES ${OPENSSL_BIN_DIR}/libcrypto.so - DESTINATION ${RESINSIGHT_INSTALL_FOLDER} - ) - install(FILES ${OPENSSL_BIN_DIR}/libcrypto.so.3 - DESTINATION ${RESINSIGHT_INSTALL_FOLDER} - ) - install(FILES ${OPENSSL_BIN_DIR}/libssl.so - DESTINATION ${RESINSIGHT_INSTALL_FOLDER} - ) - install(FILES ${OPENSSL_BIN_DIR}/libssl.so.3 - DESTINATION ${RESINSIGHT_INSTALL_FOLDER} - ) - endif() -endif(RESINSIGHT_BUNDLE_OPENSSL) - # ############################################################################## # Installation packaging # ############################################################################## @@ -742,10 +698,6 @@ if(NOT ${OCTAVE_VERSION_STRING} EQUAL "") ) endif() -if(RESINSIGHT_BUNDLE_OPENSSL AND OPENSSL_FOUND) - set(RESINSIGHT_PACKAGE_NAME "${RESINSIGHT_PACKAGE_NAME}_openssl") -endif() - # Append el5 when compiled on RHEL5 and el6 if compiled on RHEL6 if(NOT "${RESINSIGHT_RHEL_SYSTEM_NAME}" STREQUAL "") set(RESINSIGHT_PACKAGE_NAME From 3cd80f087143564b7ef465ce6cf36e9ed032d000 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 28 Apr 2024 08:26:15 +0200 Subject: [PATCH 056/332] Always move views from obsolete fields into view collection The original code caused ProjectFiles2024Tests\TestCase_GridCalculations to fail --- .../ProjectDataModel/RimEclipseCase.cpp | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index 10e5d5c514..a95f60104a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -279,31 +279,28 @@ void RimEclipseCase::initAfterRead() { RimCase::initAfterRead(); - if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2024.03.0" ) ) + // Move views to view collection. + RimEclipseViewCollection* viewColl = viewCollection(); + for ( RimEclipseView* riv : m_reservoirViews_OBSOLETE.childrenByType() ) { - // Move views to view collection. - RimEclipseViewCollection* viewColl = viewCollection(); - for ( RimEclipseView* riv : m_reservoirViews_OBSOLETE.childrenByType() ) - { - CVF_ASSERT( riv ); - riv->setEclipseCase( this ); - m_reservoirViews_OBSOLETE.removeChild( riv ); - viewColl->addView( riv ); - } + CVF_ASSERT( riv ); + riv->setEclipseCase( this ); + m_reservoirViews_OBSOLETE.removeChild( riv ); + viewColl->addView( riv ); + } - m_reservoirViews_OBSOLETE.clearWithoutDelete(); + m_reservoirViews_OBSOLETE.clearWithoutDelete(); - // Move contour maps - auto mapViewColl = contourMapCollection(); - for ( RimEclipseContourMapView* contourMap : m_contourMapCollection_OBSOLETE->views() ) - { - contourMap->setEclipseCase( this ); - m_contourMapCollection_OBSOLETE->removeChild( contourMap ); - mapViewColl->addView( contourMap ); - } - - m_contourMapCollection_OBSOLETE->clearWithoutDelete(); + // Move contour maps + auto mapViewColl = contourMapCollection(); + for ( RimEclipseContourMapView* contourMap : m_contourMapCollection_OBSOLETE->views() ) + { + contourMap->setEclipseCase( this ); + m_contourMapCollection_OBSOLETE->removeChild( contourMap ); + mapViewColl->addView( contourMap ); } + + m_contourMapCollection_OBSOLETE->clearWithoutDelete(); } //-------------------------------------------------------------------------------------------------- From 4617bcc673eee9e00ac48ff48bc2dba8f156cdab Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 1 May 2024 09:46:22 +0200 Subject: [PATCH 057/332] 11402 Save copy of project file to a backup database when saving project file --- ApplicationExeCode/CMakeLists.txt | 9 ++ .../Application/RiaPreferences.cpp | 13 ++- .../Application/RiaPreferences.h | 3 + .../Application/Tools/CMakeLists_files.cmake | 2 + .../Tools/RiaProjectBackupTools.cpp | 109 ++++++++++++++++++ .../Application/Tools/RiaProjectBackupTools.h | 29 +++++ ApplicationLibCode/CMakeLists.txt | 2 + .../ProjectDataModel/RimProject.cpp | 18 ++- .../cafProjectDataModel/cafPdmDocument.cpp | 39 +++++-- .../cafProjectDataModel/cafPdmDocument.h | 7 ++ 10 files changed, 220 insertions(+), 11 deletions(-) create mode 100644 ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp create mode 100644 ApplicationLibCode/Application/Tools/RiaProjectBackupTools.h diff --git a/ApplicationExeCode/CMakeLists.txt b/ApplicationExeCode/CMakeLists.txt index ca5d0ff7a7..6a7f38f147 100644 --- a/ApplicationExeCode/CMakeLists.txt +++ b/ApplicationExeCode/CMakeLists.txt @@ -33,6 +33,7 @@ if(Qt5Core_FOUND) Concurrent PrintSupport Svg + Sql OPTIONAL_COMPONENTS Charts ) set(QT_LIBRARIES @@ -45,6 +46,7 @@ if(Qt5Core_FOUND) Qt5::Concurrent Qt5::PrintSupport Qt5::Svg + Qt5::Sql ) if(Qt5Charts_FOUND) list(APPEND QT_LIBRARIES Qt5::Charts) @@ -484,6 +486,13 @@ if(RESINSIGHT_PRIVATE_INSTALL) OPTIONAL ) + # Required sql driver + install( + FILES ${QT_PLUGIN_PATH}/sqldrivers/libqsqlite.so + DESTINATION ${RESINSIGHT_INSTALL_FOLDER}/sqldrivers/ + OPTIONAL + ) + install(FILES qt.conf DESTINATION ${RESINSIGHT_INSTALL_FOLDER}/) endif(RESINSIGHT_QT5_BUNDLE_LIBRARIES) diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index d0ea2ebdee..1f0269778f 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -140,6 +140,8 @@ RiaPreferences::RiaPreferences() CAF_PDM_InitField( &m_loggerFlushInterval, "loggerFlushInterval", 500, "Logging Flush Interval [ms]" ); CAF_PDM_InitField( &m_loggerTrapSignalAndFlush, "loggerTrapSignalAndFlush", false, "Trap SIGNAL and Flush File Logs" ); + CAF_PDM_InitField( &m_storeBackupOfProjectFile, "storeBackupOfProjectFile", true, "Store Backup of Project Files" ); + CAF_PDM_InitField( &ssihubAddress, "ssihubAddress", QString( "http://" ), "SSIHUB Address" ); ssihubAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); @@ -477,7 +479,8 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& otherGroup->add( &m_gridCalculationExpressionFolder ); otherGroup->add( &m_summaryCalculationExpressionFolder ); - caf::PdmUiGroup* loggingGroup = uiOrdering.addNewGroup( "Logging" ); + caf::PdmUiGroup* loggingGroup = uiOrdering.addNewGroup( "Logging and Backup" ); + loggingGroup->add( &m_storeBackupOfProjectFile ); loggingGroup->add( &m_loggerFilename ); loggingGroup->add( &m_loggerFlushInterval ); loggingGroup->add( &m_loggerTrapSignalAndFlush ); @@ -983,6 +986,14 @@ bool RiaPreferences::loggerTrapSignalAndFlush() const return m_loggerTrapSignalAndFlush(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferences::storeBackupOfProjectFiles() const +{ + return m_storeBackupOfProjectFile(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferences.h b/ApplicationLibCode/Application/RiaPreferences.h index 96628784f7..78f6d283c8 100644 --- a/ApplicationLibCode/Application/RiaPreferences.h +++ b/ApplicationLibCode/Application/RiaPreferences.h @@ -120,6 +120,7 @@ class RiaPreferences : public caf::PdmObject QString loggerFilename() const; int loggerFlushInterval() const; bool loggerTrapSignalAndFlush() const; + bool storeBackupOfProjectFiles() const; RiaPreferencesGeoMech* geoMechPreferences() const; RiaPreferencesSummary* summaryPreferences() const; @@ -212,6 +213,8 @@ class RiaPreferences : public caf::PdmObject caf::PdmField m_loggerFlushInterval; caf::PdmField m_loggerTrapSignalAndFlush; + caf::PdmField m_storeBackupOfProjectFile; + // Surface Import caf::PdmField m_surfaceImportResamplingDistance; diff --git a/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake b/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake index ad437b02db..ceb110c3a9 100644 --- a/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake @@ -54,6 +54,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaNumericalTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTextTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaFileLogger.h + ${CMAKE_CURRENT_LIST_DIR}/RiaProjectBackupTools.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -105,6 +106,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaNumericalTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTextTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaFileLogger.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaProjectBackupTools.cpp ) list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) diff --git a/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp b/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp new file mode 100644 index 0000000000..7ca26035f8 --- /dev/null +++ b/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp @@ -0,0 +1,109 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RiaProjectBackupTools.h" +#include "RiaLogging.h" + +#include +#include +#include +#include +#include + +namespace RiaProjectBackupTools +{ + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool createTableIfNeeded() +{ + QSqlQuery query; + if ( !query.exec( "CREATE TABLE IF NOT EXISTS file_versions (" + "id INTEGER PRIMARY KEY AUTOINCREMENT," + "timestamp DATETIME," + "content TEXT)" ) ) + { + QString txt = "Error creating table:" + query.lastError().text(); + RiaLogging::error( txt ); + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool insertContent( const QString& content ) +{ + QSqlQuery query; + query.prepare( "INSERT INTO file_versions (timestamp, content) " + "VALUES (:timestamp, :content)" ); + query.bindValue( ":timestamp", QDateTime::currentDateTime() ); + query.bindValue( ":content", content ); + if ( !query.exec() ) + { + QString txt = "Error saving file content to database:" + query.lastError().text(); + RiaLogging::error( txt ); + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool appendTextToDatabase( const QString& databaseFilePath, const QString& content ) +{ + const QString databaseType = "QSQLITE"; + + if ( !QSqlDatabase::isDriverAvailable( databaseType ) ) + { + RiaLogging::error( "sqlite database is not available." ); + return false; + } + + // Try to open the SQLITE database + QSqlDatabase db = QSqlDatabase::database(); + if ( !db.isValid() || !db.open() ) + { + RiaLogging::info( "Adding database" ); + + // Add the SQLITE database, and it it required to do this once per session. The database will be available during the lifetime of + // the application, and can be accessed using QSqlDatabase::database() + db = QSqlDatabase::addDatabase( databaseType ); + } + if ( !db.open() ) + { + QString txt = "Error opening database:" + db.lastError().text(); + RiaLogging::error( txt ); + return false; + } + + // Set the file name for the database. The database will be created if it does not exist. + db.setDatabaseName( databaseFilePath ); + + if ( !createTableIfNeeded() ) return false; + if ( !insertContent( content ) ) return false; + + return true; +} + +} // namespace RiaProjectBackupTools diff --git a/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.h b/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.h new file mode 100644 index 0000000000..a265702e12 --- /dev/null +++ b/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.h @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 + +//================================================================================================== +// +//================================================================================================== +namespace RiaProjectBackupTools +{ +bool appendTextToDatabase( const QString& databaseFilePath, const QString& content ); +} diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index e88e49300d..75cfd28df2 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -37,6 +37,7 @@ if(Qt5Core_FOUND) Concurrent PrintSupport Svg + Sql OPTIONAL_COMPONENTS Charts ) set(QT_LIBRARIES @@ -49,6 +50,7 @@ if(Qt5Core_FOUND) Qt5::Concurrent Qt5::PrintSupport Qt5::Svg + Qt5::Sql ) if(Qt5Charts_FOUND) list(APPEND QT_LIBRARIES Qt5::Charts) diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 4494e782aa..4300f3714c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -24,6 +24,8 @@ #include "RiaFieldHandleTools.h" #include "RiaFilePathTools.h" #include "RiaGuiApplication.h" +#include "RiaPreferences.h" +#include "RiaProjectBackupTools.h" #include "RiaProjectFileVersionTools.h" #include "RiaTextStringTools.h" #include "RiaVersionInfo.h" @@ -405,10 +407,22 @@ RimMainPlotCollection* RimProject::mainPlotCollection() const bool RimProject::writeProjectFile() { transferPathsToGlobalPathList(); - bool couldOpenFile = writeFile(); + + QFile xmlFile( fileName ); + if ( !xmlFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false; + + QString content = documentAsString(); + xmlFile.write( content.toUtf8() ); + + if ( RiaPreferences::current()->storeBackupOfProjectFiles() ) + { + QString backupFilename = fileName + "db"; + RiaProjectBackupTools::appendTextToDatabase( backupFilename, content ); + } + distributePathsFromGlobalPathList(); - return couldOpenFile; + return true; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp index b7bcf264b0..8fe5ecadc8 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp @@ -83,7 +83,7 @@ void PdmDocument::readFile( QIODevice* xmlFile ) } } - // Ask all objects to initialize and set up internal datastructure and pointers + // Ask all objects to initialize and set up internal data structures and pointers // after everything is read from file resolveReferencesRecursively(); @@ -113,16 +113,22 @@ void PdmDocument::writeFile( QIODevice* xmlFile ) setupBeforeSaveRecursively(); QXmlStreamWriter xmlStream( xmlFile ); - xmlStream.setAutoFormatting( true ); + writeDocumentToXmlStream( xmlStream ); +} - xmlStream.writeStartDocument(); - QString className = classKeyword(); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString PdmDocument::documentAsString() +{ + // Ask all objects to make them ready to write themselves to file + setupBeforeSaveRecursively(); - xmlStream.writeStartElement( "", className ); - writeFields( xmlStream ); - xmlStream.writeEndElement(); + QString content; + QXmlStreamWriter xmlStream( &content ); + writeDocumentToXmlStream( xmlStream ); - xmlStream.writeEndDocument(); + return content; } //-------------------------------------------------------------------------------------------------- @@ -162,4 +168,21 @@ void PdmDocument::beforeInitAfterRead() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmDocument::writeDocumentToXmlStream( QXmlStreamWriter& xmlStream ) +{ + xmlStream.setAutoFormatting( true ); + + xmlStream.writeStartDocument(); + QString className = classKeyword(); + + xmlStream.writeStartElement( "", className ); + writeFields( xmlStream ); + xmlStream.writeEndElement(); + + xmlStream.writeEndDocument(); +} + } // End of namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h index 21164263a2..6451c43c20 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h @@ -39,6 +39,8 @@ #include "cafPdmField.h" #include "cafPdmObject.h" +class QXmlStreamWriter; + namespace caf { //================================================================================================== @@ -57,6 +59,8 @@ class PdmDocument : public PdmObject void readFile(); bool writeFile(); + QString documentAsString(); + void readFile( QIODevice* device ); void writeFile( QIODevice* device ); @@ -64,6 +68,9 @@ class PdmDocument : public PdmObject protected: virtual void beforeInitAfterRead(); + +private: + void writeDocumentToXmlStream( QXmlStreamWriter& xmlStream ); }; } // End of namespace caf From 2e4ca390c76c4d0ed06b86a03295e1f10c2234d0 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Wed, 1 May 2024 10:50:19 +0200 Subject: [PATCH 058/332] Remove old polygon annotations. (#11404) * Remove old polygon annotations from GUI. * Upgrade old annotation objects to new polygon objects on load. --- .../Application/RiaApplication.cpp | 2 - .../AnnotationCommands/CMakeLists_files.cmake | 4 - ...eUserDefinedPolylinesAnnotationFeature.cpp | 89 -------- ...ateUserDefinedPolylinesAnnotationFeature.h | 41 ---- .../RicImportPolylinesAnnotationFeature.cpp | 100 --------- .../RicImportPolylinesAnnotationFeature.h | 34 --- ...eUserDefinedPolylinesAnnotationFeature.cpp | 78 ------- .../RivAnnotationsPartMgr.cpp | 30 +-- .../RivAnnotationsPartMgr.h | 2 - .../Annotations/CMakeLists_files.cmake | 6 - .../Annotations/RimAnnotationCollection.cpp | 210 ++++++------------ .../Annotations/RimAnnotationCollection.h | 22 +- .../RimAnnotationInViewCollection.cpp | 93 +------- .../RimAnnotationInViewCollection.h | 8 +- .../RimPolylinesAnnotationInView.cpp | 138 ------------ .../RimPolylinesAnnotationInView.h | 74 ------ .../RimPolylinesFromFileAnnotationInView.cpp | 39 ---- .../RimPolylinesFromFileAnnotationInView.h | 54 ----- ...imUserDefinedPolylinesAnnotationInView.cpp | 39 ---- .../RimUserDefinedPolylinesAnnotationInView.h | 56 ----- .../Polygons/RimPolygonFile.cpp | 2 +- .../RimContextCommandBuilder.cpp | 2 - .../ProjectDataModel/RimProject.cpp | 66 +++--- .../ProjectDataModel/RimProject.h | 4 +- 24 files changed, 114 insertions(+), 1079 deletions(-) delete mode 100644 ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp delete mode 100644 ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.h delete mode 100644 ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp delete mode 100644 ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.h delete mode 100644 ApplicationLibCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp delete mode 100644 ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.cpp delete mode 100644 ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.h delete mode 100644 ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.cpp delete mode 100644 ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.h delete mode 100644 ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.cpp delete mode 100644 ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.h diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index c9a0651f29..8e68e20e7b 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -720,8 +720,6 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct sumCaseGroup->loadDataAndUpdate(); } - oilField->annotationCollection()->loadDataAndUpdate(); - for ( auto well : oilField->wellPathCollection()->allWellPaths() ) { for ( auto stimPlan : well->stimPlanModelCollection()->allStimPlanModels() ) diff --git a/ApplicationLibCode/Commands/AnnotationCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/AnnotationCommands/CMakeLists_files.cmake index eee729026e..a48bf8d500 100644 --- a/ApplicationLibCode/Commands/AnnotationCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/AnnotationCommands/CMakeLists_files.cmake @@ -1,18 +1,14 @@ set(SOURCE_GROUP_HEADER_FILES - ${CMAKE_CURRENT_LIST_DIR}/RicImportPolylinesAnnotationFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationIn3dViewFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCreateReachCircleAnnotationFeature.h - ${CMAKE_CURRENT_LIST_DIR}/RicCreateUserDefinedPolylinesAnnotationFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicTextAnnotation3dEditor.h ) set(SOURCE_GROUP_SOURCE_FILES - ${CMAKE_CURRENT_LIST_DIR}/RicImportPolylinesAnnotationFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationIn3dViewFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCreateReachCircleAnnotationFeature.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicCreateUserDefinedPolylinesAnnotationFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicTextAnnotation3dEditor.cpp ) diff --git a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp b/ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp deleted file mode 100644 index 43d2f566cf..0000000000 --- a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp +++ /dev/null @@ -1,89 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2018- 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 "RicCreateUserDefinedPolylinesAnnotationFeature.h" - -#include "RiaColorTables.h" - -#include "RimAnnotationCollection.h" -#include "RimAnnotationGroupCollection.h" -#include "RimAnnotationInViewCollection.h" -#include "RimAnnotationLineAppearance.h" -#include "RimOilField.h" -#include "RimProject.h" -#include "RimReachCircleAnnotation.h" -#include "RimTextAnnotation.h" -#include "RimUserDefinedPolylinesAnnotation.h" - -#include "RiuMainWindow.h" - -#include - -#include - -CAF_CMD_SOURCE_INIT( RicCreateUserDefinedPolylinesAnnotationFeature, "RicCreateUserDefinedPolylinesAnnotationFeature" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicCreateUserDefinedPolylinesAnnotationFeature::isCommandEnabled() const -{ - auto selObjs = caf::selectedObjectsByTypeStrict(); - auto selGroupColl = caf::selectedObjectsByTypeStrict(); - - return selObjs.size() == 1 || ( selGroupColl.size() == 1 && selGroupColl.front()->uiCapability()->uiName() == - RimAnnotationGroupCollection::USED_DEFINED_POLYLINE_ANNOTATION_UI_NAME ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicCreateUserDefinedPolylinesAnnotationFeature::onActionTriggered( bool isChecked ) -{ - auto coll = annotationCollection(); - if ( coll ) - { - auto newAnnotation = new RimUserDefinedPolylinesAnnotation(); - auto newColor = RiaColorTables::categoryPaletteColors().cycledColor3f( coll->lineBasedAnnotationsCount() ); - newAnnotation->appearance()->setColor( newColor ); - newAnnotation->appearance()->setSphereColor( newColor ); - newAnnotation->enablePicking( true ); - coll->addAnnotation( newAnnotation ); - coll->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem( newAnnotation ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicCreateUserDefinedPolylinesAnnotationFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setIcon( QIcon( ":/Plus.png" ) ); - actionToSetup->setText( "Create User Defined Polyline Annotation" ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimAnnotationCollection* RicCreateUserDefinedPolylinesAnnotationFeature::annotationCollection() const -{ - auto project = RimProject::current(); - auto oilField = project->activeOilField(); - return oilField ? oilField->annotationCollection() : nullptr; -} diff --git a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.h b/ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.h deleted file mode 100644 index 2046649ffa..0000000000 --- a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.h +++ /dev/null @@ -1,41 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2018- 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 "cafCmdFeature.h" - -#include - -class RimAnnotationCollection; - -//================================================================================================== -/// -//================================================================================================== -class RicCreateUserDefinedPolylinesAnnotationFeature : public caf::CmdFeature -{ - CAF_CMD_HEADER_INIT; - -protected: - bool isCommandEnabled() const override; - void onActionTriggered( bool isChecked ) override; - void setupActionLook( QAction* actionToSetup ) override; - -private: - RimAnnotationCollection* annotationCollection() const; -}; diff --git a/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp b/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp deleted file mode 100644 index b1dea910c5..0000000000 --- a/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp +++ /dev/null @@ -1,100 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2018- 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 "RicImportPolylinesAnnotationFeature.h" - -#include "RiaApplication.h" - -#include "RimAnnotationCollection.h" -#include "RimAnnotationGroupCollection.h" -#include "RimOilField.h" -#include "RimPolylinesFromFileAnnotation.h" -#include "RimProject.h" - -#include "Riu3DMainWindowTools.h" -#include "RiuFileDialogTools.h" - -#include -#include - -#include "cafSelectionManagerTools.h" - -CAF_CMD_SOURCE_INIT( RicImportPolylinesAnnotationFeature, "RicImportPolylinesAnnotationFeature" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicImportPolylinesAnnotationFeature::isCommandEnabled() const -{ - auto selObjs = caf::selectedObjectsByTypeStrict(); - auto selGroupColl = caf::selectedObjectsByTypeStrict(); - - return selObjs.size() == 1 || ( selGroupColl.size() == 1 && selGroupColl.front()->uiCapability()->uiName() == - RimAnnotationGroupCollection::POLYLINE_FROM_FILE_ANNOTATION_UI_NAME ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicImportPolylinesAnnotationFeature::onActionTriggered( bool isChecked ) -{ - RiaApplication* app = RiaApplication::instance(); - QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" ); - QStringList fileNames = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), - "Import Poly Lines Annotation", - defaultDir, - "Text Files (*.txt);;Polylines (*.dat);;All Files (*.*)" ); - - if ( fileNames.isEmpty() ) return; - - // Remember the path to next time - app->setLastUsedDialogDirectory( "BINARY_GRID", QFileInfo( fileNames.last() ).absolutePath() ); - - // Find or create the AnnotationsCollection - - RimProject* proj = RimProject::current(); - RimAnnotationCollection* annotColl = proj->activeOilField()->annotationCollection(); - - if ( !annotColl ) - { - annotColl = new RimAnnotationCollection; - proj->activeOilField()->annotationCollection = annotColl; - } - - // For each file, - - RimPolylinesFromFileAnnotation* lastCreatedOrUpdated = annotColl->importOrUpdatePolylinesFromFile( fileNames ); - - proj->activeOilField()->updateConnectedEditors(); - - if ( lastCreatedOrUpdated ) - { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); - } - - annotColl->scheduleRedrawOfRelevantViews(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicImportPolylinesAnnotationFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) ); - actionToSetup->setText( "Import Poly Lines Annotation" ); -} diff --git a/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.h b/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.h deleted file mode 100644 index 31ca5d1046..0000000000 --- a/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.h +++ /dev/null @@ -1,34 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2018- 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 "cafCmdFeature.h" - -//================================================================================================== -/// -//================================================================================================== -class RicImportPolylinesAnnotationFeature : public caf::CmdFeature -{ - CAF_CMD_HEADER_INIT; - -protected: - bool isCommandEnabled() const override; - void onActionTriggered( bool isChecked ) override; - void setupActionLook( QAction* actionToSetup ) override; -}; diff --git a/ApplicationLibCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp b/ApplicationLibCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp deleted file mode 100644 index db78651105..0000000000 --- a/ApplicationLibCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp +++ /dev/null @@ -1,78 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2016- Statoil 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 "RicCreateUserDefinedPolylinesAnnotationFeature.h" - -#include "RimAnnotationCollection.h" -#include "RimAnnotationInViewCollection.h" -#include "RimOilField.h" -#include "RimPolylinesAnnotation.h" -#include "RimProject.h" -#include "RimReachCircleAnnotation.h" -#include "RimTextAnnotation.h" - -#include "RiuMainWindow.h" - -#include - -#include - -CAF_CMD_SOURCE_INIT( RicCreateUserDefinedPolylinesAnnotationFeature, "RicCreateUserDefinedPolylinesAnnotationFeature" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicCreateUserDefinedPolylinesAnnotationFeature::isCommandEnabled() -{ - auto selObjs = caf::selectedObjectsByTypeStrict(); - return selObjs.size() == 1; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicCreateUserDefinedPolylinesAnnotationFeature::onActionTriggered( bool isChecked ) -{ - auto coll = annotationCollection(); - if ( coll ) - { - auto newAnnotation = new RimUserDefinedPolylinesAnnotation(); - coll->addAnnotation( newAnnotation ); - coll->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem( newAnnotation ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicCreateUserDefinedPolylinesAnnotationFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setIcon( QIcon( ":/Plus.png" ) ); - actionToSetup->setText( "Create User Defined Polyline Annotation" ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimAnnotationCollection* RicCreateUserDefinedPolylinesAnnotationFeature::annotationCollection() const -{ - auto project = RimProject::current(); - auto oilField = project->activeOilField(); - return oilField ? oilField->annotationCollection() : nullptr; -} diff --git a/ApplicationLibCode/ModelVisualization/RivAnnotationsPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivAnnotationsPartMgr.cpp index 84544f5ddc..07c20bb426 100644 --- a/ApplicationLibCode/ModelVisualization/RivAnnotationsPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivAnnotationsPartMgr.cpp @@ -24,10 +24,6 @@ #include "RimAnnotationInViewCollection.h" #include "RimProject.h" -#include "RimPolylinesFromFileAnnotationInView.h" -#include "RimUserDefinedPolylinesAnnotationInView.h" - -#include "RivPolylinePartMgr.h" #include "RivReachCircleAnnotationPartMgr.h" #include "RivTextAnnotationPartMgr.h" @@ -65,10 +61,6 @@ void RivAnnotationsPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList* { partMgr->appendDynamicGeometryPartsToModel( model, displayCoordTransform, boundingBox ); } - for ( auto& partMgr : m_polylineAnnotationPartMgrs ) - { - partMgr->appendDynamicGeometryPartsToModel( model, displayCoordTransform, boundingBox ); - } } //-------------------------------------------------------------------------------------------------- @@ -81,11 +73,9 @@ void RivAnnotationsPartMgr::createAnnotationPartManagers() if ( colls.empty() ) return; auto coll = colls.front(); - auto localTextAnnotations = coll->textAnnotations(); - auto textAnnotations = coll->globalTextAnnotations(); - auto reachCircleAnnotations = coll->globalReachCircleAnnotations(); - auto userDefinedPolylineAnnotations = coll->globalUserDefinedPolylineAnnotations(); - auto polylineFromFileAnnotations = coll->globalPolylineFromFileAnnotations(); + auto localTextAnnotations = coll->textAnnotations(); + auto textAnnotations = coll->globalTextAnnotations(); + auto reachCircleAnnotations = coll->globalReachCircleAnnotations(); clearGeometryCache(); @@ -110,19 +100,6 @@ void RivAnnotationsPartMgr::createAnnotationPartManagers() m_reachCircleAnnotationPartMgrs.push_back( apm ); } } - if ( m_polylineAnnotationPartMgrs.size() != userDefinedPolylineAnnotations.size() + polylineFromFileAnnotations.size() ) - { - for ( auto annotation : userDefinedPolylineAnnotations ) - { - auto* apm = new RivPolylinePartMgr( m_rimView, annotation, coll ); - m_polylineAnnotationPartMgrs.push_back( apm ); - } - for ( auto annotation : polylineFromFileAnnotations ) - { - auto* apm = new RivPolylinePartMgr( m_rimView, annotation, coll ); - m_polylineAnnotationPartMgrs.push_back( apm ); - } - } } //-------------------------------------------------------------------------------------------------- @@ -132,5 +109,4 @@ void RivAnnotationsPartMgr::clearGeometryCache() { m_textAnnotationPartMgrs.clear(); m_reachCircleAnnotationPartMgrs.clear(); - m_polylineAnnotationPartMgrs.clear(); } diff --git a/ApplicationLibCode/ModelVisualization/RivAnnotationsPartMgr.h b/ApplicationLibCode/ModelVisualization/RivAnnotationsPartMgr.h index 967ea0132b..7182d6979f 100644 --- a/ApplicationLibCode/ModelVisualization/RivAnnotationsPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/RivAnnotationsPartMgr.h @@ -39,7 +39,6 @@ class DisplayCoordTransform; class Rim3dView; class RivTextAnnotationPartMgr; class RivReachCircleAnnotationPartMgr; -class RivPolylinePartMgr; class RivAnnotationsPartMgr : public cvf::Object { @@ -60,5 +59,4 @@ class RivAnnotationsPartMgr : public cvf::Object caf::PdmPointer m_rimView; cvf::Collection m_textAnnotationPartMgrs; cvf::Collection m_reachCircleAnnotationPartMgrs; - cvf::Collection m_polylineAnnotationPartMgrs; }; diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Annotations/CMakeLists_files.cmake index 4366ff8992..5e9991a981 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Annotations/CMakeLists_files.cmake @@ -9,9 +9,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInViewCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationLineAppearance.h ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationTextAppearance.h - ${CMAKE_CURRENT_LIST_DIR}/RimPolylinesFromFileAnnotationInView.h - ${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedPolylinesAnnotationInView.h - ${CMAKE_CURRENT_LIST_DIR}/RimPolylinesAnnotationInView.h ${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotationInView.h ${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotationInView.h ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationGroupCollection.h @@ -29,9 +26,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInViewCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationLineAppearance.cpp ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationTextAppearance.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimPolylinesFromFileAnnotationInView.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedPolylinesAnnotationInView.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimPolylinesAnnotationInView.cpp ${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotationInView.cpp ${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotationInView.cpp ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationGroupCollection.cpp diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp index 02c209b37f..2ef1ab58fc 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp @@ -22,15 +22,20 @@ #include "RiaLogging.h" #include "RimAnnotationGroupCollection.h" +#include "RimAnnotationInViewCollection.h" #include "RimAnnotationLineAppearance.h" +#include "RimGridView.h" +#include "RimOilField.h" +#include "RimPolylineTarget.h" #include "RimPolylinesFromFileAnnotation.h" +#include "RimProject.h" #include "RimReachCircleAnnotation.h" #include "RimTextAnnotation.h" #include "RimUserDefinedPolylinesAnnotation.h" -#include "RimAnnotationInViewCollection.h" -#include "RimGridView.h" -#include "RimProject.h" +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" +#include "Polygons/RimPolygonFile.h" #include @@ -44,148 +49,98 @@ RimAnnotationCollection::RimAnnotationCollection() CAF_PDM_InitObject( "Annotations", ":/Annotations16x16.png" ); CAF_PDM_InitFieldNoDefault( &m_reachCircleAnnotations, "ReachCircleAnnotations", "Reach Circle Annotations" ); - CAF_PDM_InitFieldNoDefault( &m_userDefinedPolylineAnnotations, "UserDefinedPolylineAnnotations", "User Defined Polyline Annotations" ); - CAF_PDM_InitFieldNoDefault( &m_polylineFromFileAnnotations, "PolylineFromFileAnnotations", "Polylines From File" ); - - m_reachCircleAnnotations = new RimAnnotationGroupCollection(); - m_userDefinedPolylineAnnotations = new RimAnnotationGroupCollection(); - m_polylineFromFileAnnotations = new RimAnnotationGroupCollection(); - + m_reachCircleAnnotations = new RimAnnotationGroupCollection(); m_reachCircleAnnotations->uiCapability()->setUiName( RimAnnotationGroupCollection::REACH_CIRCLE_ANNOTATION_UI_NAME ); - m_userDefinedPolylineAnnotations->uiCapability()->setUiName( RimAnnotationGroupCollection::USED_DEFINED_POLYLINE_ANNOTATION_UI_NAME ); - m_polylineFromFileAnnotations->uiCapability()->setUiName( RimAnnotationGroupCollection::POLYLINE_FROM_FILE_ANNOTATION_UI_NAME ); - m_reachCircleAnnotations->uiCapability()->setUiIconFromResourceString( ":/ReachCircle16x16.png" ); - m_userDefinedPolylineAnnotations->uiCapability()->setUiIconFromResourceString( ":/PolylinesFromFile16x16.png" ); - m_polylineFromFileAnnotations->uiCapability()->setUiIconFromResourceString( ":/PolylinesFromFile16x16.png" ); -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimAnnotationCollection::~RimAnnotationCollection() -{ -} + // obsolete things + CAF_PDM_InitFieldNoDefault( &m_userDefinedPolylineAnnotations_OBSOLETE, + "UserDefinedPolylineAnnotations", + "User Defined Polyline Annotations" ); + m_userDefinedPolylineAnnotations_OBSOLETE = new RimAnnotationGroupCollection(); + m_userDefinedPolylineAnnotations_OBSOLETE.xmlCapability()->setIOWritable( false ); + m_userDefinedPolylineAnnotations_OBSOLETE->uiCapability()->setUiTreeHidden( true ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimAnnotationCollection::addAnnotation( RimReachCircleAnnotation* annotation ) -{ - m_reachCircleAnnotations->addAnnotation( annotation ); - updateViewAnnotationCollections(); + CAF_PDM_InitFieldNoDefault( &m_polylineFromFileAnnotations_OBSOLETE, "PolylineFromFileAnnotations", "Polylines From File" ); + m_polylineFromFileAnnotations_OBSOLETE = new RimAnnotationGroupCollection(); + m_polylineFromFileAnnotations_OBSOLETE.xmlCapability()->setIOWritable( false ); + m_polylineFromFileAnnotations_OBSOLETE->uiCapability()->setUiTreeHidden( true ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimAnnotationCollection::addAnnotation( RimUserDefinedPolylinesAnnotation* annotation ) +RimAnnotationCollection::~RimAnnotationCollection() { - m_userDefinedPolylineAnnotations->addAnnotation( annotation ); - updateViewAnnotationCollections(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimAnnotationCollection::addAnnotation( RimPolylinesFromFileAnnotation* annotation ) +void RimAnnotationCollection::initAfterRead() { - m_polylineFromFileAnnotations->addAnnotation( annotation ); - updateViewAnnotationCollections(); -} + auto polycoll = RimProject::current()->activeOilField()->polygonCollection(); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimAnnotationCollection::reachCircleAnnotations() const -{ - std::vector annotations; - for ( auto& a : m_reachCircleAnnotations->annotations() ) + for ( auto oldPolyObj : m_userDefinedPolylineAnnotations_OBSOLETE->annotations() ) { - annotations.push_back( dynamic_cast( a ) ); - } - return annotations; -} + auto oldPoly = dynamic_cast( oldPolyObj ); + if ( oldPoly == nullptr ) continue; -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimAnnotationCollection::userDefinedPolylineAnnotations() const -{ - std::vector annotations; - for ( auto& a : m_userDefinedPolylineAnnotations->annotations() ) - { - annotations.push_back( dynamic_cast( a ) ); - } - return annotations; -} + RimPolygon* newPoly = new RimPolygon(); + newPoly->setName( oldPoly->uiName() ); + newPoly->setIsClosed( oldPoly->closePolyline() ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimAnnotationCollection::polylinesFromFileAnnotations() const -{ - std::vector annotations; - for ( auto& a : m_polylineFromFileAnnotations->annotations() ) - { - annotations.push_back( dynamic_cast( a ) ); - } - return annotations; -} + std::vector points; -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPolylinesFromFileAnnotation* RimAnnotationCollection::importOrUpdatePolylinesFromFile( const QStringList& fileNames ) -{ - QStringList newFileNames; - std::vector polyLinesObjsToReload; - - for ( const QString& newFileName : fileNames ) - { - bool isFound = false; - for ( RimPolylinesFromFileAnnotation* polyLinesAnnot : polylinesFromFileAnnotations() ) + for ( auto target : oldPoly->activeTargets() ) { - if ( polyLinesAnnot->fileName() == newFileName ) - { - polyLinesObjsToReload.push_back( polyLinesAnnot ); - isFound = true; - break; - } + points.push_back( target->targetPointXYZ() ); } - if ( !isFound ) - { - newFileNames.push_back( newFileName ); - } + newPoly->setPointsInDomainCoords( points ); + newPoly->setColor( oldPoly->appearance()->color() ); + + polycoll->addUserDefinedPolygon( newPoly ); } - for ( const QString& newFileName : newFileNames ) + for ( auto oldPolyObj : m_polylineFromFileAnnotations_OBSOLETE->annotations() ) { - RimPolylinesFromFileAnnotation* newPolyLinesAnnot = new RimPolylinesFromFileAnnotation; + auto oldPoly = dynamic_cast( oldPolyObj ); + if ( oldPoly == nullptr ) continue; - auto newColor = RiaColorTables::categoryPaletteColors().cycledColor3f( lineBasedAnnotationsCount() ); + RimPolygonFile* newPoly = new RimPolygonFile(); + newPoly->setName( oldPoly->uiName() ); - newPolyLinesAnnot->setFileName( newFileName ); - newPolyLinesAnnot->setDescriptionFromFileName(); - newPolyLinesAnnot->appearance()->setColor( newColor ); + QString fileName = RimProject::current()->updatedFilePathFromPathId( oldPoly->fileName() ); + newPoly->setFileName( fileName ); - m_polylineFromFileAnnotations->addAnnotation( newPolyLinesAnnot ); - polyLinesObjsToReload.push_back( newPolyLinesAnnot ); + polycoll->addPolygonFile( newPoly ); } - updateViewAnnotationCollections(); + m_userDefinedPolylineAnnotations_OBSOLETE.children().clear(); + m_polylineFromFileAnnotations_OBSOLETE.children().clear(); +} - reloadPolylinesFromFile( polyLinesObjsToReload ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimAnnotationCollection::addAnnotation( RimReachCircleAnnotation* annotation ) +{ + m_reachCircleAnnotations->addAnnotation( annotation ); + updateViewAnnotationCollections(); +} - if ( !newFileNames.empty() ) - { - return polylinesFromFileAnnotations().back(); - } - else +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimAnnotationCollection::reachCircleAnnotations() const +{ + std::vector annotations; + for ( auto& a : m_reachCircleAnnotations->annotations() ) { - return nullptr; + annotations.push_back( dynamic_cast( a ) ); } + return annotations; } //-------------------------------------------------------------------------------------------------- @@ -193,8 +148,7 @@ RimPolylinesFromFileAnnotation* RimAnnotationCollection::importOrUpdatePolylines //-------------------------------------------------------------------------------------------------- size_t RimAnnotationCollection::lineBasedAnnotationsCount() const { - return m_reachCircleAnnotations->annotations().size() + m_userDefinedPolylineAnnotations->annotations().size() + - m_polylineFromFileAnnotations->annotations().size(); + return m_reachCircleAnnotations->annotations().size(); } //-------------------------------------------------------------------------------------------------- @@ -230,43 +184,9 @@ std::vector RimAnnotationCollection::allPdmAnnotations() const std::vector all; all.insert( all.end(), m_textAnnotations->m_annotations.begin(), m_textAnnotations->m_annotations.end() ); all.insert( all.end(), m_reachCircleAnnotations->m_annotations.begin(), m_reachCircleAnnotations->m_annotations.end() ); - all.insert( all.end(), m_userDefinedPolylineAnnotations->m_annotations.begin(), m_userDefinedPolylineAnnotations->m_annotations.end() ); - all.insert( all.end(), m_polylineFromFileAnnotations->m_annotations.begin(), m_polylineFromFileAnnotations->m_annotations.end() ); return all; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimAnnotationCollection::reloadPolylinesFromFile( const std::vector& polyLinesObjsToReload ) -{ - QString totalErrorMessage; - - for ( RimPolylinesFromFileAnnotation* polyLinesAnnot : polyLinesObjsToReload ) - { - QString errormessage; - - polyLinesAnnot->readPolyLinesFile( &errormessage ); - if ( !errormessage.isEmpty() ) - { - totalErrorMessage += "\nError in: " + polyLinesAnnot->fileName() + "\n\t" + errormessage; - } - } - - if ( !totalErrorMessage.isEmpty() ) - { - RiaLogging::errorInMessageBox( nullptr, "Import Polylines", totalErrorMessage ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimAnnotationCollection::loadDataAndUpdate() -{ - reloadPolylinesFromFile( polylinesFromFileAnnotations() ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.h index cac9209ff1..d4832b9ce4 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.h @@ -30,8 +30,6 @@ class QString; class RimAnnotationGroupCollection; class RimTextAnnotation; class RimReachCircleAnnotation; -class RimUserDefinedPolylinesAnnotation; -class RimPolylinesFromFileAnnotation; class RimGridView; //================================================================================================== @@ -46,17 +44,9 @@ class RimAnnotationCollection : public RimAnnotationCollectionBase RimAnnotationCollection(); ~RimAnnotationCollection() override; - void loadDataAndUpdate(); - void addAnnotation( RimReachCircleAnnotation* annotation ); - void addAnnotation( RimUserDefinedPolylinesAnnotation* annotation ); - void addAnnotation( RimPolylinesFromFileAnnotation* annotation ); - - std::vector reachCircleAnnotations() const; - std::vector userDefinedPolylineAnnotations() const; - std::vector polylinesFromFileAnnotations() const; - RimPolylinesFromFileAnnotation* importOrUpdatePolylinesFromFile( const QStringList& fileNames ); + std::vector reachCircleAnnotations() const; size_t lineBasedAnnotationsCount() const; @@ -68,10 +58,12 @@ class RimAnnotationCollection : public RimAnnotationCollectionBase void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; -private: - void reloadPolylinesFromFile( const std::vector& polyLinesObjsToReload ); +protected: + void initAfterRead() override; +private: caf::PdmChildField m_reachCircleAnnotations; - caf::PdmChildField m_userDefinedPolylineAnnotations; - caf::PdmChildField m_polylineFromFileAnnotations; + + caf::PdmChildField m_userDefinedPolylineAnnotations_OBSOLETE; + caf::PdmChildField m_polylineFromFileAnnotations_OBSOLETE; }; diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp index 55d43e08cd..0446cdafb6 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp @@ -26,14 +26,12 @@ #include "RimCase.h" #include "RimGridView.h" #include "RimPolylinesFromFileAnnotation.h" -#include "RimPolylinesFromFileAnnotationInView.h" #include "RimProject.h" #include "RimReachCircleAnnotation.h" #include "RimReachCircleAnnotationInView.h" #include "RimTextAnnotation.h" #include "RimTextAnnotationInView.h" #include "RimUserDefinedPolylinesAnnotation.h" -#include "RimUserDefinedPolylinesAnnotationInView.h" #include @@ -56,18 +54,6 @@ caf::PdmObject* sourcePdmAnnotation( const caf::PdmObject* annotationInView ) return c->sourceAnnotation(); } - auto up = dynamic_cast( annotationInView ); - if ( up ) - { - return up->sourceAnnotation(); - } - - auto pf = dynamic_cast( annotationInView ); - if ( pf ) - { - return pf->sourceAnnotation(); - } - return nullptr; } @@ -88,29 +74,16 @@ RimAnnotationInViewCollection::RimAnnotationInViewCollection() CAF_PDM_InitFieldNoDefault( &m_globalTextAnnotations, "TextAnnotationsInView", "Global Text Annotations" ); CAF_PDM_InitFieldNoDefault( &m_globalReachCircleAnnotations, "ReachCircleAnnotationsInView", "Global Reach Circle Annotations" ); - CAF_PDM_InitFieldNoDefault( &m_globalUserDefinedPolylineAnnotations, - "UserDefinedPolylinesAnnotationsInView", - "Global User Defined Polylines Annotations" ); - CAF_PDM_InitFieldNoDefault( &m_globalPolylineFromFileAnnotations, - "PolylinesFromFileAnnotationsInView", - "Global Polylines From File Annotations" ); - CAF_PDM_InitFieldNoDefault( &m_annotationFontSize, "AnnotationFontSize", "Default Font Size" ); - m_globalTextAnnotations = new RimAnnotationGroupCollection(); - m_globalReachCircleAnnotations = new RimAnnotationGroupCollection(); - m_globalUserDefinedPolylineAnnotations = new RimAnnotationGroupCollection(); - m_globalPolylineFromFileAnnotations = new RimAnnotationGroupCollection(); + m_globalTextAnnotations = new RimAnnotationGroupCollection(); + m_globalReachCircleAnnotations = new RimAnnotationGroupCollection(); m_globalTextAnnotations->uiCapability()->setUiName( "Global Text Annotations" ); m_globalReachCircleAnnotations->uiCapability()->setUiName( "Global Reach Circle Annotations" ); - m_globalUserDefinedPolylineAnnotations->uiCapability()->setUiName( "Global User Defined Polylines Annotations" ); - m_globalPolylineFromFileAnnotations->uiCapability()->setUiName( "Global Polylines From File Annotations" ); m_globalTextAnnotations->uiCapability()->setUiIconFromResourceString( ":/TextAnnotation16x16.png" ); m_globalReachCircleAnnotations->uiCapability()->setUiIconFromResourceString( ":/ReachCircle16x16.png" ); - m_globalUserDefinedPolylineAnnotations->uiCapability()->setUiIconFromResourceString( ":/PolylinesFromFile16x16.png" ); - m_globalPolylineFromFileAnnotations->uiCapability()->setUiIconFromResourceString( ":/PolylinesFromFile16x16.png" ); } //-------------------------------------------------------------------------------------------------- @@ -162,32 +135,6 @@ std::vector RimAnnotationInViewCollection::glob return annotations; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimAnnotationInViewCollection::globalUserDefinedPolylineAnnotations() const -{ - std::vector annotations; - for ( auto& a : m_globalUserDefinedPolylineAnnotations->annotations() ) - { - annotations.push_back( dynamic_cast( a ) ); - } - return annotations; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimAnnotationInViewCollection::globalPolylineFromFileAnnotations() const -{ - std::vector annotations; - for ( auto& a : m_globalPolylineFromFileAnnotations->annotations() ) - { - annotations.push_back( dynamic_cast( a ) ); - } - return annotations; -} - //-------------------------------------------------------------------------------------------------- /// Called when the global annotation collection has changed //-------------------------------------------------------------------------------------------------- @@ -305,10 +252,6 @@ std::vector RimAnnotationInViewCollection::allGlobalPdmAnnotati std::vector all; all.insert( all.end(), m_globalTextAnnotations->m_annotations.begin(), m_globalTextAnnotations->m_annotations.end() ); all.insert( all.end(), m_globalReachCircleAnnotations->m_annotations.begin(), m_globalReachCircleAnnotations->m_annotations.end() ); - all.insert( all.end(), - m_globalUserDefinedPolylineAnnotations->m_annotations.begin(), - m_globalUserDefinedPolylineAnnotations->m_annotations.end() ); - all.insert( all.end(), m_globalPolylineFromFileAnnotations->m_annotations.begin(), m_globalPolylineFromFileAnnotations->m_annotations.end() ); return all; } @@ -330,20 +273,6 @@ void RimAnnotationInViewCollection::addGlobalAnnotation( caf::PdmObject* annotat m_globalReachCircleAnnotations->addAnnotation( new RimReachCircleAnnotationInView( c ) ); return; } - - auto up = dynamic_cast( annotation ); - if ( up ) - { - m_globalUserDefinedPolylineAnnotations->addAnnotation( new RimUserDefinedPolylinesAnnotationInView( up ) ); - return; - } - - auto pf = dynamic_cast( annotation ); - if ( pf ) - { - m_globalPolylineFromFileAnnotations->addAnnotation( new RimPolylinesFromFileAnnotationInView( pf ) ); - return; - } } //-------------------------------------------------------------------------------------------------- @@ -368,24 +297,6 @@ void RimAnnotationInViewCollection::deleteGlobalAnnotation( const caf::PdmObject return; } } - - for ( size_t i = 0; i < m_globalUserDefinedPolylineAnnotations->m_annotations.size(); i++ ) - { - if ( m_globalUserDefinedPolylineAnnotations->m_annotations[i] == annotation ) - { - m_globalUserDefinedPolylineAnnotations->m_annotations.erase( i ); - return; - } - } - - for ( size_t i = 0; i < m_globalPolylineFromFileAnnotations->m_annotations.size(); i++ ) - { - if ( m_globalPolylineFromFileAnnotations->m_annotations[i] == annotation ) - { - m_globalPolylineFromFileAnnotations->m_annotations.erase( i ); - return; - } - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.h index 544ad86483..a138676114 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.h @@ -52,10 +52,8 @@ class RimAnnotationInViewCollection : public RimAnnotationCollectionBase, public double annotationPlaneZ() const; bool snapAnnotations() const; - std::vector globalTextAnnotations() const; - std::vector globalReachCircleAnnotations() const; - std::vector globalUserDefinedPolylineAnnotations() const; - std::vector globalPolylineFromFileAnnotations() const; + std::vector globalTextAnnotations() const; + std::vector globalReachCircleAnnotations() const; void onGlobalCollectionChanged( const RimAnnotationCollection* globalCollection ); @@ -80,6 +78,4 @@ class RimAnnotationInViewCollection : public RimAnnotationCollectionBase, public caf::PdmField m_annotationFontSize; caf::PdmChildField m_globalTextAnnotations; caf::PdmChildField m_globalReachCircleAnnotations; - caf::PdmChildField m_globalUserDefinedPolylineAnnotations; - caf::PdmChildField m_globalPolylineFromFileAnnotations; }; diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.cpp deleted file mode 100644 index 6275989514..0000000000 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.cpp +++ /dev/null @@ -1,138 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2018- 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 "RimPolylinesAnnotationInView.h" -#include "RimAnnotationCollectionBase.h" -#include "RimAnnotationGroupCollection.h" -#include "RimAnnotationInViewCollection.h" -#include "RimPolylinesAnnotation.h" - -#include "RigPolyLinesData.h" - -CAF_PDM_SOURCE_INIT( RimPolylinesAnnotationInView, "RimPolylinesAnnotationInView" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPolylinesAnnotationInView::RimPolylinesAnnotationInView() -{ - CAF_PDM_InitObject( "PolyLinesAnnotationInView", ":/WellCollection.png" ); - - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active" ); - CAF_PDM_InitFieldNoDefault( &m_sourceAnnotation, "SourceAnnotation", "Source Annotation" ); - - m_isActive.uiCapability()->setUiHidden( true ); - m_sourceAnnotation.uiCapability()->setUiHidden( true ); - m_sourceAnnotation = nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPolylinesAnnotationInView::RimPolylinesAnnotationInView( RimPolylinesAnnotation* sourceAnnotation ) - : RimPolylinesAnnotationInView() -{ - CVF_ASSERT( sourceAnnotation ); - - m_isActive = sourceAnnotation->isActive(); - m_sourceAnnotation = sourceAnnotation; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimPolylinesAnnotationInView::isActive() const -{ - return m_isActive(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPolylinesAnnotation* RimPolylinesAnnotationInView::sourceAnnotation() const -{ - return m_sourceAnnotation; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimPolylinesAnnotationInView::isVisible() const -{ - auto coll = firstAncestorOrThisOfType(); - - bool visible = true; - if ( coll ) visible = coll->isVisible(); - if ( visible && m_sourceAnnotation ) - { - visible = m_sourceAnnotation->isVisible(); - - if ( visible ) - { - auto globalColl = m_sourceAnnotation->firstAncestorOrThisOfType(); - if ( globalColl ) visible = globalColl->isVisible(); - } - } - if ( visible ) visible = m_isActive; - return visible; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolylinesAnnotationInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) -{ - if ( changedField == &m_isActive ) - { - auto coll = firstAncestorOrThisOfType(); - if ( coll ) coll->scheduleRedrawOfRelevantViews(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimPolylinesAnnotationInView::objectToggleField() -{ - return &m_isActive; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimPolylinesAnnotationInView::userDescriptionField() -{ - return m_sourceAnnotation ? m_sourceAnnotation->userDescriptionField() : nullptr; -} - -cvf::ref RimPolylinesAnnotationInView::polyLinesData() const -{ - auto retval = m_sourceAnnotation->polyLinesData(); - if ( !isVisible() ) - { - retval->setVisibility( false, false ); - } - - auto coll = firstAncestorOrThisOfType(); - if ( coll ) - { - retval->setZPlaneLock( coll->snapAnnotations(), coll->annotationPlaneZ() ); - } - - return retval; -} diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.h deleted file mode 100644 index 83852d2f6e..0000000000 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.h +++ /dev/null @@ -1,74 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2018- 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 "RimAnnotationLineAppearance.h" - -#include "RimPolylinesDataInterface.h" - -#include "cafAppEnum.h" -#include "cafPdmChildArrayField.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" -#include "cafPdmPointer.h" -#include "cafPdmPtrField.h" - -// Include to make Pdm work for cvf::Color -#include "cafPdmChildField.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfVec3d.h" - -#include "cvfObject.h" -#include "cvfVector3.h" - -#include - -class QString; -class RimGridView; -class RimPolylinesAnnotation; - -//================================================================================================== -/// -/// -//================================================================================================== -class RimPolylinesAnnotationInView : public caf::PdmObject, public RimPolylinesDataInterface -{ - CAF_PDM_HEADER_INIT; - -public: - RimPolylinesAnnotationInView(); - RimPolylinesAnnotationInView( RimPolylinesAnnotation* sourceAnnotation ); - ~RimPolylinesAnnotationInView() override {} - - bool isActive() const; - RimPolylinesAnnotation* sourceAnnotation() const; - - bool isVisible() const; - - cvf::ref polyLinesData() const override; - -protected: - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - caf::PdmFieldHandle* objectToggleField() override; - caf::PdmFieldHandle* userDescriptionField() override; - -private: - caf::PdmField m_isActive; - caf::PdmPtrField m_sourceAnnotation; -}; diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.cpp deleted file mode 100644 index 4905bd91a7..0000000000 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.cpp +++ /dev/null @@ -1,39 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2018- 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 "RimPolylinesFromFileAnnotationInView.h" -#include "RimPolylinesFromFileAnnotation.h" - -CAF_PDM_SOURCE_INIT( RimPolylinesFromFileAnnotationInView, "RimPolylinesFromFileAnnotationInView" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPolylinesFromFileAnnotationInView::RimPolylinesFromFileAnnotationInView() -{ - CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png" ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPolylinesFromFileAnnotationInView::RimPolylinesFromFileAnnotationInView( RimPolylinesFromFileAnnotation* sourceAnnotation ) - : RimPolylinesAnnotationInView( sourceAnnotation ) -{ - CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png" ); -} diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.h deleted file mode 100644 index 2562dfb70e..0000000000 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.h +++ /dev/null @@ -1,54 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2018- 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 "RimPolylinesAnnotationInView.h" - -#include "cafAppEnum.h" -#include "cafPdmChildArrayField.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" -#include "cafPdmPointer.h" -#include "cafPdmPtrField.h" - -// Include to make Pdm work for cvf::Color -#include "cafPdmChildField.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfVec3d.h" - -#include "cvfObject.h" -#include "cvfVector3.h" - -#include - -class RimPolylinesFromFileAnnotation; - -//================================================================================================== -/// -/// -//================================================================================================== -class RimPolylinesFromFileAnnotationInView : public RimPolylinesAnnotationInView -{ - CAF_PDM_HEADER_INIT; - -public: - RimPolylinesFromFileAnnotationInView(); - RimPolylinesFromFileAnnotationInView( RimPolylinesFromFileAnnotation* sourceAnnotation ); - ~RimPolylinesFromFileAnnotationInView() override {} -}; diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.cpp deleted file mode 100644 index cf35f05cf1..0000000000 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.cpp +++ /dev/null @@ -1,39 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2018- 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 "RimUserDefinedPolylinesAnnotationInView.h" -#include "RimUserDefinedPolylinesAnnotation.h" - -CAF_PDM_SOURCE_INIT( RimUserDefinedPolylinesAnnotationInView, "RimUserDefinedPolylinesAnnotationInView" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimUserDefinedPolylinesAnnotationInView::RimUserDefinedPolylinesAnnotationInView() -{ - CAF_PDM_InitObject( "PolyLinesAnnotationInView", ":/WellCollection.png" ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimUserDefinedPolylinesAnnotationInView::RimUserDefinedPolylinesAnnotationInView( RimUserDefinedPolylinesAnnotation* sourceAnnotation ) - : RimPolylinesAnnotationInView( sourceAnnotation ) -{ - CAF_PDM_InitObject( "PolyLinesAnnotationInView", ":/WellCollection.png" ); -} diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.h deleted file mode 100644 index 8a707a46a2..0000000000 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.h +++ /dev/null @@ -1,56 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2018- 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 "RimPolylinesAnnotationInView.h" - -#include "cafAppEnum.h" -#include "cafPdmChildArrayField.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" -#include "cafPdmPointer.h" -#include "cafPdmPtrField.h" - -// Include to make Pdm work for cvf::Color -#include "cafPdmChildField.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfVec3d.h" - -#include "cvfObject.h" -#include "cvfVector3.h" - -#include - -class QString; -class RimGridView; -class RimUserDefinedPolylinesAnnotation; - -//================================================================================================== -/// -/// -//================================================================================================== -class RimUserDefinedPolylinesAnnotationInView : public RimPolylinesAnnotationInView -{ - CAF_PDM_HEADER_INIT; - -public: - RimUserDefinedPolylinesAnnotationInView(); - RimUserDefinedPolylinesAnnotationInView( RimUserDefinedPolylinesAnnotation* sourceAnnotation ); - ~RimUserDefinedPolylinesAnnotationInView() override {} -}; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp index d09e29af02..105af7ea7d 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp @@ -87,7 +87,7 @@ void RimPolygonFile::loadData() } else { - RiaLogging::info( QString( "Imported %1 polygons from file: " ).arg( polygonsFromFile.size() ) + m_fileName().path() ); + RiaLogging::info( QString( "Imported %1 polygon(s) from file: " ).arg( polygonsFromFile.size() ) + m_fileName().path() ); } } diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 82f4f97148..6050b8ce10 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -1083,8 +1083,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicCreateTextAnnotationFeature"; menuBuilder << "RicCreateReachCircleAnnotationFeature"; - menuBuilder << "RicCreateUserDefinedPolylinesAnnotationFeature"; - menuBuilder << "RicImportPolylinesAnnotationFeature"; } else if ( dynamic_cast( firstUiItem ) ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 4300f3714c..d462447062 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -1207,28 +1207,6 @@ std::vector RimProject::reachCircleAnnotations() cons return annotations; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimProject::polylineAnnotations() const -{ - std::vector annotations; - for ( const auto& oilField : oilFields() ) - { - auto annotationColl = oilField->annotationCollection(); - for ( const auto& annotation : annotationColl->userDefinedPolylineAnnotations() ) - { - annotations.push_back( annotation ); - } - - for ( const auto& annotation : annotationColl->polylinesFromFileAnnotations() ) - { - annotations.push_back( annotation ); - } - } - return annotations; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1596,27 +1574,45 @@ void RimProject::transferPathsToGlobalPathList() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::distributePathsFromGlobalPathList() +QString RimProject::updatedFilePathFromPathId( QString filePath, RiaVariableMapper* pathListMapper /*=nullptr*/ ) const { - RiaVariableMapper pathListMapper( m_globalPathList() ); + std::unique_ptr internalMapper; - for ( caf::FilePath* filePath : allFilePaths() ) + if ( pathListMapper == nullptr ) { - QString pathIdCandidate = filePath->path().trimmed(); - QStringList pathIdComponents = pathIdCandidate.split( RiaVariableMapper::variableToken() ); + internalMapper.reset( new RiaVariableMapper( m_globalPathList ) ); + pathListMapper = internalMapper.get(); + } + + QString returnValue = filePath; + QString pathIdCandidate = filePath.trimmed(); + QStringList pathIdComponents = pathIdCandidate.split( RiaVariableMapper::variableToken() ); - if ( pathIdComponents.size() == 3 && pathIdComponents[0].size() == 0 && pathIdComponents[1].size() > 0 && - pathIdComponents[2].size() == 0 ) + if ( pathIdComponents.size() == 3 && pathIdComponents[0].size() == 0 && pathIdComponents[1].size() > 0 && pathIdComponents[2].size() == 0 ) + { + bool isFound = false; + QString path = pathListMapper->valueForVariable( pathIdCandidate, &isFound ); + if ( isFound ) { - bool isFound = false; - QString path = pathListMapper.valueForVariable( pathIdCandidate, &isFound ); - if ( isFound ) - { - filePath->setPath( path ); - } + returnValue = path; } } + return returnValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProject::distributePathsFromGlobalPathList() +{ + RiaVariableMapper pathListMapper( m_globalPathList() ); + + for ( caf::FilePath* filePath : allFilePaths() ) + { + filePath->setPath( updatedFilePathFromPathId( filePath->path(), &pathListMapper ) ); + } + for ( auto summaryCase : allSummaryCases() ) { if ( summaryCase->displayNameType() == RimCaseDisplayNameTools::DisplayName::CUSTOM ) diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.h b/ApplicationLibCode/ProjectDataModel/RimProject.h index 6dbbcfe9d9..0809df9649 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.h +++ b/ApplicationLibCode/ProjectDataModel/RimProject.h @@ -30,6 +30,8 @@ #include +class RiaVariableMapper; + class RigEclipseCaseData; class RigGridManager; class RigMainGrid; @@ -177,7 +179,6 @@ class RimProject : public caf::PdmDocument std::vector allWellPaths() const; std::vector textAnnotations() const; std::vector reachCircleAnnotations() const; - std::vector polylineAnnotations() const; std::vector geoMechCases() const; @@ -193,6 +194,7 @@ class RimProject : public caf::PdmDocument RimPlotTemplateFolderItem* rootPlotTemplateItem() const; std::vector allFilePaths() const; + QString updatedFilePathFromPathId( QString filePath, RiaVariableMapper* pathListMapper = nullptr ) const; protected: void beforeInitAfterRead() override; From 03e1d4e7620e039f65012ab3314ed4391e3d64b5 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Thu, 2 May 2024 09:35:43 +0200 Subject: [PATCH 059/332] #11405 Fault reactivation: fix unexpected temperature change outside reservoir. No change in temperature is expected outside of reservoir between first (geostatic) and other time steps when exporting reactivation model. I.e. the temperature gradient and "top of reservoir" temperature from the geostatic step should be used on all time steps. Fixes #11405. --- .../Faults/RimFaultReactivationDataAccess.cpp | 3 +- ...ultReactivationDataAccessorTemperature.cpp | 33 +++++++++++++------ ...FaultReactivationDataAccessorTemperature.h | 4 ++- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.cpp index 46bdb8f00e..73c1db1713 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.cpp @@ -58,7 +58,8 @@ RimFaultReactivationDataAccess::RimFaultReactivationDataAccess( const RimFaultRe double seabedDepth = -model.seaBedDepth(); m_accessors.push_back( std::make_shared( eCase, porePressureGradient, seabedDepth ) ); m_accessors.push_back( std::make_shared( eCase, 0.0001 ) ); - m_accessors.push_back( std::make_shared( eCase, topTemperature, seabedDepth ) ); + m_accessors.push_back( + std::make_shared( eCase, topTemperature, seabedDepth, timeSteps.front() ) ); std::vector stressProperties = { RimFaultReactivation::Property::StressTop, RimFaultReactivation::Property::DepthTop, diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.cpp index be16499b68..e647dfe84f 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.cpp @@ -42,12 +42,14 @@ //-------------------------------------------------------------------------------------------------- RimFaultReactivationDataAccessorTemperature::RimFaultReactivationDataAccessorTemperature( RimEclipseCase* eclipseCase, double seabedTemperature, - double seabedDepth ) + double seabedDepth, + size_t firstTimeStep ) : m_eclipseCase( eclipseCase ) , m_caseData( nullptr ) , m_mainGrid( nullptr ) , m_seabedTemperature( seabedTemperature ) , m_seabedDepth( seabedDepth ) + , m_firstTimeStep( firstTimeStep ) { if ( m_eclipseCase ) { @@ -75,14 +77,23 @@ void RimFaultReactivationDataAccessorTemperature::updateResultAccessor() m_resultAccessor = RigResultAccessorFactory::createFromResultAddress( m_caseData, 0, RiaDefines::PorosityModelType::MATRIX_MODEL, m_timeStep, resVarAddress ); - if ( m_resultAccessor.notNull() ) + // Only create the first time step accessor once: it is always the same. + if ( m_resultAccessor0.isNull() ) { - auto [wellPaths, extractors] = - RimFaultReactivationDataAccessorWellLogExtraction::createEclipseWellPathExtractors( *m_model, *m_caseData, m_seabedDepth ); - m_wellPaths = wellPaths; - m_extractors = extractors; + m_resultAccessor0 = RigResultAccessorFactory::createFromResultAddress( m_caseData, + 0, + RiaDefines::PorosityModelType::MATRIX_MODEL, + m_firstTimeStep, + resVarAddress ); + if ( m_resultAccessor0.notNull() ) + { + auto [wellPaths, extractors] = + RimFaultReactivationDataAccessorWellLogExtraction::createEclipseWellPathExtractors( *m_model, *m_caseData, m_seabedDepth ); + m_wellPaths = wellPaths; + m_extractors = extractors; - m_gradient = computeGradient(); + m_gradient = computeGradient(); + } } } @@ -99,7 +110,7 @@ double RimFaultReactivationDataAccessorTemperature::computeGradient() const auto wellPath = m_wellPaths.find( gridPart )->second; auto [values, intersections] = - RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor.p(), *extractor.p(), *wellPath ); + RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor0.p(), *extractor.p(), *wellPath ); int lastOverburdenIndex = RimFaultReactivationDataAccessorWellLogExtraction::findLastOverburdenIndex( values ); if ( lastOverburdenIndex != -1 ) @@ -144,7 +155,7 @@ double RimFaultReactivationDataAccessorTemperature::valueAtPosition( const cvf:: double bottomDepth, size_t elementIndex ) const { - if ( ( m_mainGrid != nullptr ) && m_resultAccessor.notNull() ) + if ( ( m_mainGrid != nullptr ) && m_resultAccessor.notNull() && m_resultAccessor0.notNull() ) { auto cellIdx = m_mainGrid->findReservoirCellIndexFromPoint( position ); if ( cellIdx != cvf::UNDEFINED_SIZE_T ) @@ -159,8 +170,10 @@ double RimFaultReactivationDataAccessorTemperature::valueAtPosition( const cvf:: CAF_ASSERT( m_wellPaths.find( gridPart ) != m_wellPaths.end() ); auto wellPath = m_wellPaths.find( gridPart )->second; + // Use data from first time step when not in reservoir. This ensures that the only difference between the + // timesteps in the fault-reactivation model is in the reservoir. auto [values, intersections] = - RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor.p(), *extractor.p(), *wellPath ); + RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor0.p(), *extractor.p(), *wellPath ); auto [value, pos] = RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( intersections, position, m_seabedTemperature, m_gradient ); diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.h index d8b5b1fce0..0ae440d3e8 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.h @@ -38,7 +38,7 @@ class RigEclipseWellLogExtractor; class RimFaultReactivationDataAccessorTemperature : public RimFaultReactivationDataAccessor { public: - RimFaultReactivationDataAccessorTemperature( RimEclipseCase* eclipseCase, double seabedTemperature, double seabedDepth ); + RimFaultReactivationDataAccessorTemperature( RimEclipseCase* eclipseCase, double seabedTemperature, double seabedDepth, size_t firstTimeStep ); ~RimFaultReactivationDataAccessorTemperature(); bool isMatching( RimFaultReactivation::Property property ) const override; @@ -60,7 +60,9 @@ class RimFaultReactivationDataAccessorTemperature : public RimFaultReactivationD double m_seabedTemperature; double m_seabedDepth; double m_gradient; + size_t m_firstTimeStep; + cvf::ref m_resultAccessor0; cvf::ref m_resultAccessor; std::map> m_wellPaths; From 3dcca744e1da6a3d238f100e041a96c6b940af4b Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Thu, 2 May 2024 10:10:51 +0200 Subject: [PATCH 060/332] #11405 Fault Reactivation: add temperature initial conditions. --- .../RifFaultReactivationModelExporter.cpp | 21 +++++++++++++++++-- .../RifFaultReactivationModelExporter.h | 3 ++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp index 22cb9bbbc3..0515186829 100644 --- a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp +++ b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp @@ -114,7 +114,7 @@ std::pair RifFaultReactivationModelExporter::exportToStream( }, [&]() { return printInteractionProperties( stream, frictionValue ); }, [&]() { return printBoundaryConditions( stream, *model, partNames, boundaries ); }, - [&]() { return printPredefinedFields( stream, *model, *dataAccess, basePath, partNames, useGridVoidRatio ); }, + [&]() { return printPredefinedFields( stream, *model, *dataAccess, basePath, partNames, useGridVoidRatio, useGridTemperature ); }, [&]() { return printInteractions( stream, partNames, borders ); }, [&]() { @@ -514,7 +514,8 @@ std::pair const RimFaultReactivationDataAccess& dataAccess, const std::string& exportBasePath, const std::map& partNames, - bool voidRatioFromEclipse ) + bool voidRatioFromEclipse, + bool useGridTemperature ) { // PREDEFINED FIELDS struct PredefinedField @@ -558,6 +559,22 @@ std::pair RifInpExportTools::printHeading( stream, "INCLUDE, input=" + fileName.toStdString() ); } + if ( useGridTemperature ) + { + // Export the temperature to a separate inp file for each step + std::string propertyName = "TEMPERATURE"; + std::string fullPath = exportBasePath + "_" + propertyName + ".inp"; + auto [filePath, fileName] = RiaFilePathTools::toFolderAndFileName( QString::fromStdString( fullPath ) ); + + // Use temperature from first time step + size_t timeStep = 0; + bool isOk = writePropertyToFile( model, dataAccess, RimFaultReactivation::Property::Temperature, timeStep, fullPath, partNames, "" ); + if ( !isOk ) return { false, "Failed to create " + propertyName + " file." }; + + RifInpExportTools::printHeading( stream, "Initial Conditions, TYPE=" + propertyName ); + RifInpExportTools::printHeading( stream, "INCLUDE, input=" + fileName.toStdString() ); + } + // stress export { // Export the stress to a separate inp file diff --git a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.h b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.h index 033cdf091a..6683519d44 100644 --- a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.h +++ b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.h @@ -74,7 +74,8 @@ class RifFaultReactivationModelExporter const RimFaultReactivationDataAccess& dataAccess, const std::string& exportDirectory, const std::map& partNames, - bool useGridVoidRatio ); + bool useGridVoidRatio, + bool useGridTemperature ); static std::pair printSteps( std::ostream& stream, const RigFaultReactivationModel& model, const RimFaultReactivationDataAccess& dataAccess, From 6b76aad16292bd3283004b897357749b9e60d92d Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Thu, 2 May 2024 10:18:48 +0200 Subject: [PATCH 061/332] Bump version to 2024.03.4-dev.02. --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 680810b33e..716c1427b9 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".01") +set(RESINSIGHT_DEV_VERSION ".02") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From aea804b16160cdfc9bec92835054279966752df6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 May 2024 11:26:52 +0200 Subject: [PATCH 062/332] Rename to improve readability --- .../Flow/RimWellDistributionPlot.cpp | 4 ++-- .../ProjectDataModel/Flow/RimWellDistributionPlot.h | 4 ++-- .../Flow/RimWellDistributionPlotCollection.cpp | 2 +- .../GridCrossPlots/RimGridCrossPlot.cpp | 12 ++++++------ .../GridCrossPlots/RimGridCrossPlot.h | 4 ++-- .../ProjectDataModel/RimDepthTrackPlot.cpp | 2 +- .../ProjectDataModel/RimGridTimeHistoryCurve.cpp | 2 +- ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp | 2 +- ApplicationLibCode/ProjectDataModel/RimPlot.cpp | 4 ++-- ApplicationLibCode/ProjectDataModel/RimPlot.h | 4 ++-- .../ProjectDataModel/Summary/RimAsciiDataCurve.cpp | 2 +- .../ProjectDataModel/Summary/RimSummaryCurve.cpp | 2 +- .../ProjectDataModel/Summary/RimSummaryPlot.cpp | 12 ++++++------ .../ProjectDataModel/Summary/RimSummaryPlot.h | 4 ++-- .../ProjectDataModel/WellLog/RimWellLogTrack.cpp | 6 +++--- .../ProjectDataModel/WellLog/RimWellLogTrack.h | 4 ++-- 16 files changed, 35 insertions(+), 35 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.cpp index 6060151728..7a63e0c8c3 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.cpp @@ -165,7 +165,7 @@ void RimWellDistributionPlot::updateLegend() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellDistributionPlot::updateZoomInParentPlot() +void RimWellDistributionPlot::updatePlotWidgetFromAxisRanges() { // cvf::Trace::show("RimWellDistributionPlot::updateZoomInParentPlot()"); } @@ -173,7 +173,7 @@ void RimWellDistributionPlot::updateZoomInParentPlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellDistributionPlot::updateZoomFromParentPlot() +void RimWellDistributionPlot::updateAxisRangesFromPlotWidget() { // cvf::Trace::show("RimWellDistributionPlot::updateZoomFromParentPlot()"); } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.h index 5637b1410b..463ff8bd8a 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.h @@ -54,8 +54,8 @@ class RimWellDistributionPlot : public RimPlot void setAutoScaleYEnabled( bool enabled ) override; void updateAxes() override; void updateLegend() override; - void updateZoomInParentPlot() override; - void updateZoomFromParentPlot() override; + void updatePlotWidgetFromAxisRanges() override; + void updateAxisRangesFromPlotWidget() override; QString asciiDataForPlotExport() const override; void reattachAllCurves() override; void detachAllCurves() override; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp index 365c13fc44..b47fa6fdc4 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp @@ -395,7 +395,7 @@ void RimWellDistributionPlotCollection::updatePlots() for ( RimPlot* plot : m_plots() ) { plot->loadDataAndUpdate(); - plot->updateZoomInParentPlot(); + plot->updatePlotWidgetFromAxisRanges(); } } } diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp index 7154c02f8a..690acba998 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp @@ -182,7 +182,7 @@ void RimGridCrossPlot::zoomAll() setAutoScaleXEnabled( true ); setAutoScaleYEnabled( true ); - updateZoomInParentPlot(); + updatePlotWidgetFromAxisRanges(); } //-------------------------------------------------------------------------------------------------- @@ -215,7 +215,7 @@ void RimGridCrossPlot::reattachAllCurves() } updateCurveNamesAndPlotTitle(); updateLegend(); - updateZoomInParentPlot(); + updatePlotWidgetFromAxisRanges(); } } @@ -454,7 +454,7 @@ void RimGridCrossPlot::onPlotZoomed() { setAutoScaleXEnabled( false ); setAutoScaleYEnabled( false ); - updateZoomFromParentPlot(); + updateAxisRangesFromPlotWidget(); } //-------------------------------------------------------------------------------------------------- @@ -766,14 +766,14 @@ void RimGridCrossPlot::updateLegend() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGridCrossPlot::updateZoomInParentPlot() +void RimGridCrossPlot::updatePlotWidgetFromAxisRanges() { if ( m_plotWidget ) { updateAxisInQwt( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); updateAxisInQwt( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); m_plotWidget->qwtPlot()->updateAxes(); - updateZoomFromParentPlot(); + updateAxisRangesFromPlotWidget(); m_plotWidget->scheduleReplot(); } } @@ -781,7 +781,7 @@ void RimGridCrossPlot::updateZoomInParentPlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGridCrossPlot::updateZoomFromParentPlot() +void RimGridCrossPlot::updateAxisRangesFromPlotWidget() { updateAxisFromQwt( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); updateAxisFromQwt( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h index ab28be59e8..57a4b8f519 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h @@ -100,8 +100,8 @@ class RimGridCrossPlot : public RimPlot, public RimNameConfigHolderInterface void updateLegend() override; - void updateZoomInParentPlot() override; - void updateZoomFromParentPlot() override; + void updatePlotWidgetFromAxisRanges() override; + void updateAxisRangesFromPlotWidget() override; void setAutoScaleXEnabled( bool enabled ) override; void setAutoScaleYEnabled( bool enabled ) override; diff --git a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp index d65dca2134..9a0f59a664 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp @@ -341,7 +341,7 @@ void RimDepthTrackPlot::updateZoom() for ( RimPlot* plot : plots() ) { static_cast( plot )->setVisibleDepthRange( m_minVisibleDepth(), m_maxVisibleDepth() ); - plot->updateZoomInParentPlot(); + plot->updatePlotWidgetFromAxisRanges(); } if ( m_viewer ) diff --git a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp index 8377899de8..030f63e3ec 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp @@ -368,7 +368,7 @@ void RimGridTimeHistoryCurve::updateZoomInParentPlot() { auto plot = firstAncestorOrThisOfType(); - plot->updateZoomInParentPlot(); + plot->updatePlotWidgetFromAxisRanges(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp index 2949f0c5f2..1d8c982032 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp @@ -851,7 +851,7 @@ void RimMultiPlot::updateZoom() { for ( RimPlot* plot : plots() ) { - plot->updateZoomInParentPlot(); + plot->updatePlotWidgetFromAxisRanges(); } } diff --git a/ApplicationLibCode/ProjectDataModel/RimPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimPlot.cpp index 5c7759ba29..c352604e8b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlot.cpp @@ -252,14 +252,14 @@ void RimPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::ve //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlot::updateZoomInParentPlot() +void RimPlot::updatePlotWidgetFromAxisRanges() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlot::updateZoomFromParentPlot() +void RimPlot::updateAxisRangesFromPlotWidget() { } diff --git a/ApplicationLibCode/ProjectDataModel/RimPlot.h b/ApplicationLibCode/ProjectDataModel/RimPlot.h index bae31df97e..19ce220fa9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlot.h @@ -96,8 +96,8 @@ class RimPlot : public QObject, public RimPlotWindow virtual RiuPlotWidget* plotWidget() = 0; - virtual void updateZoomInParentPlot(); - virtual void updateZoomFromParentPlot(); + virtual void updatePlotWidgetFromAxisRanges(); + virtual void updateAxisRangesFromPlotWidget(); virtual caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const; virtual void handleDroppedObjects( const std::vector& objects ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp index 98257caf97..472756fd5f 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp @@ -118,7 +118,7 @@ void RimAsciiDataCurve::updateZoomInParentPlot() { auto plot = firstAncestorOrThisOfType(); - plot->updateZoomInParentPlot(); + plot->updatePlotWidgetFromAxisRanges(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 1521504979..dcac98d73d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -597,7 +597,7 @@ void RimSummaryCurve::updateZoomInParentPlot() { auto plot = firstAncestorOrThisOfTypeAsserted(); - plot->updateZoomInParentPlot(); + plot->updatePlotWidgetFromAxisRanges(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 73623f3d3d..0e76314dd0 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -236,7 +236,7 @@ void RimSummaryPlot::updateAxes() updateNumericalAxis( RiaDefines::PlotAxis::PLOT_AXIS_TOP ); updateTimeAxis( timeAxisProperties() ); - updateZoomInParentPlot(); + updatePlotWidgetFromAxisRanges(); } //-------------------------------------------------------------------------------------------------- @@ -1442,7 +1442,7 @@ void RimSummaryPlot::zoomAll() { setAutoScaleXEnabled( true ); setAutoScaleYEnabled( true ); - updateZoomInParentPlot(); + updatePlotWidgetFromAxisRanges(); axisChanged.send( this ); } @@ -1929,7 +1929,7 @@ void RimSummaryPlot::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateZoomInParentPlot() +void RimSummaryPlot::updatePlotWidgetFromAxisRanges() { if ( !plotWidget() ) return; @@ -1939,7 +1939,7 @@ void RimSummaryPlot::updateZoomInParentPlot() } plotWidget()->updateAxes(); - updateZoomFromParentPlot(); + updateAxisRangesFromPlotWidget(); plotWidget()->updateZoomDependentCurveProperties(); // Must create and set new custom tickmarks for time axis after zoom update @@ -1960,7 +1960,7 @@ void RimSummaryPlot::updateZoomInParentPlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateZoomFromParentPlot() +void RimSummaryPlot::updateAxisRangesFromPlotWidget() { if ( !plotWidget() ) return; @@ -2641,7 +2641,7 @@ void RimSummaryPlot::onPlotZoomed() plotZoomedByUser.send(); - updateZoomFromParentPlot(); + updateAxisRangesFromPlotWidget(); timeAxisSettingsChanged( nullptr ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h index a54133b8cf..5c340e22e0 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -184,8 +184,8 @@ class RimSummaryPlot : public RimPlot, public RimSummaryDataSourceStepping void setAutoScaleYEnabled( bool enabled ) override; RiuPlotWidget* plotWidget() override; void zoomAll() override; - void updateZoomInParentPlot() override; - void updateZoomFromParentPlot() override; + void updatePlotWidgetFromAxisRanges() override; + void updateAxisRangesFromPlotWidget() override; caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const override; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp index 1ff066b7e7..6b60209760 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp @@ -1076,7 +1076,7 @@ QString RimWellLogTrack::asciiDataForPlotExport() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::updateZoomFromParentPlot() +void RimWellLogTrack::updateAxisRangesFromPlotWidget() { auto [xIntervalMin, xIntervalMax] = m_plotWidget->axisRange( valueAxis() ); auto [depthIntervalMin, depthIntervalMax] = m_plotWidget->axisRange( depthAxis() ); @@ -1789,7 +1789,7 @@ void RimWellLogTrack::setVisibleDepthRange( double minValue, double maxValue ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::updateZoomInParentPlot() +void RimWellLogTrack::updatePlotWidgetFromAxisRanges() { updatePropertyValueZoom(); updateDepthZoom(); @@ -3381,7 +3381,7 @@ void RimWellLogTrack::doUpdateLayout() void RimWellLogTrack::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) { setAutoScalePropertyValuesEnabled( true ); - updateZoomInParentPlot(); + updatePlotWidgetFromAxisRanges(); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); mainPlotWindow->updateWellLogPlotToolBar(); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h index 2290d1525e..4ab1a6009e 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h @@ -153,8 +153,8 @@ class RimWellLogTrack : public RimPlot void setVisiblePropertyValueRange( double minValue, double maxValue ); void setVisibleDepthRange( double minValue, double maxValue ); - void updateZoomInParentPlot() override; - void updateZoomFromParentPlot() override; + void updatePlotWidgetFromAxisRanges() override; + void updateAxisRangesFromPlotWidget() override; void updateParentPlotZoom(); From 24aa7fca3e482d7e5ebb8ad675828e14c8a16ce4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 3 May 2024 09:50:04 +0200 Subject: [PATCH 063/332] Make sure onChildrenUpdated is called in RicToggleItemsOnOthersOffFeature --- .../ToggleCommands/RicToggleItemsFeatureImpl.h | 4 ++-- .../RicToggleItemsOnOthersOffFeature.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h index a4eeac73ab..6bfcae356e 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h @@ -52,10 +52,10 @@ class RicToggleItemsFeatureImpl static QString findCollectionName( SelectionToggleType state ); + static std::pair findOwnerAndChildArrayField( caf::PdmFieldHandle* fieldHandle ); + private: static caf::PdmUiTreeView* findTreeView( const caf::PdmUiItem* uiItem ); static caf::PdmUiTreeOrdering* findTreeItemFromSelectedUiItem( const caf::PdmUiItem* uiItem ); static std::vector*> findToggleFieldsFromSelection( SelectionToggleType state ); - - static std::pair findOwnerAndChildArrayField( caf::PdmFieldHandle* fieldHandle ); }; diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp index 9d8e7e9b5d..3783e57015 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp @@ -55,12 +55,16 @@ void RicToggleItemsOnOthersOffFeature::onActionTriggered( bool isChecked ) // First toggle off all siblings caf::PdmFieldHandle* commonParent = commonParentForAllSelections( selectedObjects ); + caf::PdmFieldHandle* firstField = nullptr; + for ( caf::PdmObjectHandle* child : childObjects( commonParent ) ) { caf::PdmField* field = objectToggleField( child ); if ( field ) { + if ( !firstField ) firstField = field; + // Avoid calling setValueWithFieldChanged() here, as this potentially can trigger heavy computations. Assume // that the update logic is sufficient when setting the selected objects. field->setValue( false ); @@ -74,6 +78,15 @@ void RicToggleItemsOnOthersOffFeature::onActionTriggered( bool isChecked ) field->setValueWithFieldChanged( true ); } + + // If multiple fields are updated, we call onChildrenUpdated() on the owner of the first field + // Example: Trigger replot of curves when multiple curves are toggled + auto [ownerOfChildArrayField, childArrayFieldHandle] = RicToggleItemsFeatureImpl::findOwnerAndChildArrayField( firstField ); + if ( ownerOfChildArrayField && childArrayFieldHandle ) + { + std::vector objs; + ownerOfChildArrayField->onChildrenUpdated( childArrayFieldHandle, objs ); + } } //-------------------------------------------------------------------------------------------------- From 6d478ddb3c2ba7cc3517f1aa1c0fb7fe922eebba Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 3 May 2024 09:52:43 +0200 Subject: [PATCH 064/332] Use opm parser to find all VFP data based on a *.DATA file --- .../ProjectDataModel/RiaOpmParserTools.cpp | 149 +++++++++++++----- .../ProjectDataModel/RiaOpmParserTools.h | 21 +-- 2 files changed, 124 insertions(+), 46 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp index c039cd01c5..58cf2c552e 100644 --- a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp @@ -30,6 +30,7 @@ #include "opm/input/eclipse/Parser/Parser.hpp" #include "opm/input/eclipse/Parser/ParserKeywords/I.hpp" #include "opm/input/eclipse/Parser/ParserKeywords/P.hpp" +#include "opm/input/eclipse/Parser/ParserKeywords/T.hpp" #include "opm/input/eclipse/Parser/ParserKeywords/V.hpp" #include "opm/input/eclipse/Parser/ParserKeywords/W.hpp" @@ -37,10 +38,55 @@ #include +namespace RiaOpmParserTools +{ + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiaOpmParserTools::extractVfpInjectionTables( const std::string& filename ) +Opm::VFPInjTable createInjectionTable( const Opm::DeckKeyword& keyword ) +{ + Opm::UnitSystem unitSystem; + { + const auto& header = keyword.getRecord( 0 ); + + if ( header.getItem().hasValue( 0 ) ) + { + std::string units_string; + units_string = header.getItem().get( 0 ); + unitSystem = Opm::UnitSystem( units_string ); + } + } + + return { keyword, unitSystem }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Opm::VFPProdTable createProductionTable( const Opm::DeckKeyword& keyword ) +{ + Opm::UnitSystem unitSystem; + { + const auto& header = keyword.getRecord( 0 ); + + if ( header.getItem().hasValue( 0 ) ) + { + std::string units_string; + units_string = header.getItem().get( 0 ); + unitSystem = Opm::UnitSystem( units_string ); + } + } + + bool gaslift_opt_active = false; + + return { keyword, gaslift_opt_active, unitSystem }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector extractVfpInjectionTables( const std::string& filename ) { std::vector tables; @@ -60,21 +106,7 @@ std::vector RiaOpmParserTools::extractVfpInjectionTables( cons for ( auto kw : keywordList ) { - auto name = kw->name(); - - Opm::UnitSystem unitSystem; - { - const auto& header = kw->getRecord( 0 ); - - if ( header.getItem().hasValue( 0 ) ) - { - std::string units_string; - units_string = header.getItem().get( 0 ); - unitSystem = Opm::UnitSystem( units_string ); - } - } - - Opm::VFPInjTable table( *kw, unitSystem ); + auto table = createInjectionTable( *kw ); tables.push_back( table ); } } @@ -88,7 +120,7 @@ std::vector RiaOpmParserTools::extractVfpInjectionTables( cons //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiaOpmParserTools::extractVfpProductionTables( const std::string& filename ) +std::vector extractVfpProductionTables( const std::string& filename ) { std::vector tables; @@ -106,36 +138,79 @@ std::vector RiaOpmParserTools::extractVfpProductionTables( co for ( auto kw : keywordList ) { - auto name = kw->name(); + auto table = createProductionTable( *kw ); + tables.push_back( table ); + } + } + catch ( ... ) + { + } - Opm::UnitSystem unitSystem; - { - const auto& header = kw->getRecord( 0 ); + return tables; +} - if ( header.getItem().hasValue( 0 ) ) - { - std::string units_string; - units_string = header.getItem().get( 0 ); - unitSystem = Opm::UnitSystem( units_string ); - } - } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair, std::vector> extractVfpTablesFromDataFile( const std::string& dataDeckFilename ) +{ + if ( !std::filesystem::exists( dataDeckFilename ) ) return {}; - bool gaslift_opt_active = false; - Opm::VFPProdTable table( *kw, gaslift_opt_active, unitSystem ); - tables.push_back( table ); + std::vector prodTables; + std::vector injTables; + + try + { + Opm::Parser parser( false ); + + // Required to include the TUNING keyword to avoid parsing error of a Norne DATA file containing the TUNING keyword + // The TUNING keyword is not required nor related to VFP data + std::vector parserKeywords = { Opm::ParserKeywords::VFPPROD(), + Opm::ParserKeywords::VFPINJ(), + Opm::ParserKeywords::INCLUDE(), + Opm::ParserKeywords::TUNING() }; + for ( const auto& kw : parserKeywords ) + { + parser.addParserKeyword( kw ); + } + + Opm::ParseContext parseContext( Opm::InputError::Action::WARN ); + auto deck = parser.parseFile( dataDeckFilename, parseContext ); + + { + std::string prodKeyword = "VFPPROD"; + auto keywordList = deck.getKeywordList( prodKeyword ); + for ( auto kw : keywordList ) + { + auto table = createProductionTable( *kw ); + prodTables.push_back( table ); + } + } + { + std::string injKeyword = "VFPINJ"; + auto keywordList = deck.getKeywordList( injKeyword ); + for ( auto kw : keywordList ) + { + auto table = createInjectionTable( *kw ); + injTables.push_back( table ); + } } } catch ( ... ) { + QString text = QString( "Error detected when parsing '%1'. Imported data might be missing or incomplete." ) + .arg( QString::fromStdString( dataDeckFilename ) ); + + RiaLogging::warning( text ); } - return tables; + return { prodTables, injTables }; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::map>> RiaOpmParserTools::extractWseglink( const std::string& filename ) +std::map>> extractWseglink( const std::string& filename ) { if ( !std::filesystem::exists( filename ) ) return {}; @@ -205,7 +280,7 @@ std::map>> RiaOpmParserTools::extra //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiaOpmParserTools::extractWsegAicd( const std::string& filename ) +std::vector extractWsegAicd( const std::string& filename ) { if ( !std::filesystem::exists( filename ) ) return {}; @@ -291,7 +366,7 @@ std::vector RiaOpmParserTools::extractWse //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiaOpmParserTools::extractWsegAicdCompletor( const std::string& filename ) +std::vector extractWsegAicdCompletor( const std::string& filename ) { QFile file( QString::fromStdString( filename ) ); if ( !file.open( QFile::ReadOnly ) ) return {}; @@ -346,7 +421,9 @@ std::vector RiaOpmParserTools::extractWse //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::string RiaOpmParserTools::aicdTemplateId() +std::string aicdTemplateId() { return "ID_NUMBER"; } + +} // namespace RiaOpmParserTools diff --git a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.h b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.h index 473922b596..0841fb579a 100644 --- a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.h +++ b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.h @@ -28,17 +28,18 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -class RiaOpmParserTools +namespace RiaOpmParserTools { -public: - static std::vector extractVfpInjectionTables( const std::string& filename ); - static std::vector extractVfpProductionTables( const std::string& filename ); +std::vector extractVfpInjectionTables( const std::string& filename ); +std::vector extractVfpProductionTables( const std::string& filename ); - static std::map>> extractWseglink( const std::string& filename ); +std::pair, std::vector> extractVfpTablesFromDataFile( const std::string& dataDeckFilename ); - using AicdTemplateValues = std::map; - static std::vector extractWsegAicd( const std::string& filename ); - static std::vector extractWsegAicdCompletor( const std::string& filename ); +std::map>> extractWseglink( const std::string& filename ); - static std::string aicdTemplateId(); -}; +using AicdTemplateValues = std::map; +std::vector extractWsegAicd( const std::string& filename ); +std::vector extractWsegAicdCompletor( const std::string& filename ); + +std::string aicdTemplateId(); +}; // namespace RiaOpmParserTools From b7e5867430975fb6abeb43ad7ec6e5ed9bf98b03 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 3 May 2024 09:54:34 +0200 Subject: [PATCH 065/332] Move qwt axis functions to RimPlotAxisTools --- .../GridCrossPlots/RimGridCrossPlot.cpp | 169 +++--------------- .../GridCrossPlots/RimGridCrossPlot.h | 4 +- .../Tools/CMakeLists_files.cmake | 8 +- .../Tools/RimPlotAxisTools.cpp | 125 +++++++++++++ .../ProjectDataModel/Tools/RimPlotAxisTools.h | 39 ++++ 5 files changed, 199 insertions(+), 146 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp index 690acba998..96a5d3c709 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp @@ -15,11 +15,8 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// -#include "RimGridCrossPlot.h" -#include "RiaDefines.h" -#include "RiaFontCache.h" -#include "RiaPreferences.h" +#include "RimGridCrossPlot.h" #include "RifTextDataTableFormatter.h" #include "RiuDraggableOverlayFrame.h" @@ -27,24 +24,14 @@ #include "RiuPlotMainWindowTools.h" #include "RiuQwtPlotTools.h" -#include "RimGridCrossPlotCollection.h" #include "RimGridCrossPlotCurve.h" #include "RimGridCrossPlotDataSet.h" #include "RimMultiPlot.h" -#include "RimPlotAxisLogRangeCalculator.h" #include "RimPlotAxisProperties.h" -#include "cafPdmUiCheckBoxEditor.h" -#include "cafPdmUiTreeOrdering.h" - -#include "cafProgressInfo.h" -#include "cvfAssert.h" - -#include "qwt_legend.h" -#include "qwt_plot.h" -#include "qwt_plot_curve.h" +#include "Tools/RimPlotAxisTools.h" -#include +#include "cafPdmUiTreeOrdering.h" CAF_PDM_SOURCE_INIT( RimGridCrossPlot, "RimGridCrossPlot" ); @@ -447,6 +434,26 @@ void RimGridCrossPlot::axisLogarithmicChanged( const caf::SignalEmitter* emitter loadDataAndUpdate(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCrossPlot::applyPropertiesOnPlotAxes() +{ + auto curves = visibleCurves(); + + RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, + RiuPlotAxis::defaultBottom(), + m_xAxisProperties(), + xAxisParameterString(), + curves ); + + RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, + RiuPlotAxis::defaultLeft(), + m_yAxisProperties(), + yAxisParameterString(), + curves ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -574,8 +581,7 @@ void RimGridCrossPlot::updateAxes() { if ( !m_plotWidget ) return; - updateAxisInQwt( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); - updateAxisInQwt( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); + applyPropertiesOnPlotAxes(); m_plotWidget->updateAnnotationObjects( m_xAxisProperties ); m_plotWidget->updateAnnotationObjects( m_yAxisProperties ); @@ -770,8 +776,8 @@ void RimGridCrossPlot::updatePlotWidgetFromAxisRanges() { if ( m_plotWidget ) { - updateAxisInQwt( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); - updateAxisInQwt( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); + applyPropertiesOnPlotAxes(); + m_plotWidget->qwtPlot()->updateAxes(); updateAxisRangesFromPlotWidget(); m_plotWidget->scheduleReplot(); @@ -783,8 +789,8 @@ void RimGridCrossPlot::updatePlotWidgetFromAxisRanges() //-------------------------------------------------------------------------------------------------- void RimGridCrossPlot::updateAxisRangesFromPlotWidget() { - updateAxisFromQwt( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); - updateAxisFromQwt( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); + RimPlotAxisTools::updateVisibleRangesFromPlotWidget( m_xAxisProperties(), RiuPlotAxis::defaultBottom(), m_plotWidget ); + RimPlotAxisTools::updateVisibleRangesFromPlotWidget( m_yAxisProperties(), RiuPlotAxis::defaultLeft(), m_plotWidget ); } //-------------------------------------------------------------------------------------------------- @@ -835,125 +841,6 @@ QString RimGridCrossPlot::yAxisParameterString() const return yAxisParams.join( ", " ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridCrossPlot::updateAxisInQwt( RiaDefines::PlotAxis axisType ) -{ - if ( !m_plotWidget ) return; - - RimPlotAxisProperties* axisProperties = m_xAxisProperties(); - QString axisParameterString = xAxisParameterString(); - - if ( axisType == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) - { - axisProperties = m_yAxisProperties(); - axisParameterString = yAxisParameterString(); - } - - RiuPlotAxis axis = axisProperties->plotAxis(); - if ( axisProperties->isActive() ) - { - m_plotWidget->enableAxis( axis, true ); - - Qt::AlignmentFlag alignment = Qt::AlignCenter; - if ( axisProperties->titlePosition() == RimPlotAxisPropertiesInterface::AXIS_TITLE_END ) - { - alignment = Qt::AlignRight; - } - m_plotWidget->setAxisFontsAndAlignment( axis, - caf::FontTools::pointSizeToPixelSize( axisProperties->titleFontSize() ), - caf::FontTools::pointSizeToPixelSize( axisProperties->valuesFontSize() ), - true, - alignment ); - m_plotWidget->setAxisTitleText( axis, axisParameterString ); - m_plotWidget->setAxisTitleEnabled( axis, true ); - - if ( axisProperties->isLogarithmicScaleEnabled() ) - { - bool isLogScale = m_plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC; - if ( !isLogScale ) - { - m_plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC ); - m_plotWidget->setAxisMaxMinor( axis, 5 ); - } - - double min = axisProperties->visibleRangeMin(); - double max = axisProperties->visibleRangeMax(); - if ( axisProperties->isAutoZoom() ) - { - std::vector plotCurves = visibleCurves(); - RimPlotAxisLogRangeCalculator logRangeCalculator( axis.axis(), plotCurves ); - logRangeCalculator.computeAxisRange( &min, &max ); - } - - if ( axisProperties->isAxisInverted() ) - { - std::swap( min, max ); - } - m_plotWidget->setAxisScale( axis, min, max ); - } - else - { - bool isLinearScale = m_plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LINEAR; - if ( !isLinearScale ) - { - m_plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LINEAR ); - m_plotWidget->setAxisMaxMinor( axis, 3 ); - } - - if ( axisProperties->isAutoZoom() ) - { - m_plotWidget->setAxisAutoScale( axis, true ); - m_plotWidget->setAxisInverted( axis, axisProperties->isAxisInverted() ); - } - else - { - double min = axisProperties->visibleRangeMin(); - double max = axisProperties->visibleRangeMax(); - if ( axisProperties->isAxisInverted() ) - { - std::swap( min, max ); - } - - m_plotWidget->setAxisScale( axis, min, max ); - } - } - } - else - { - m_plotWidget->enableAxis( axis, false ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridCrossPlot::updateAxisFromQwt( RiaDefines::PlotAxis axisType ) -{ - if ( !m_plotWidget ) return; - - auto [xAxisRangeMin, xAxisRangeMax] = m_plotWidget->axisRange( RiuPlotAxis::defaultBottom() ); - - RimPlotAxisProperties* axisProperties = m_xAxisProperties(); - double axisRangeMin = xAxisRangeMin; - double axisRangeMax = xAxisRangeMax; - - if ( axisType == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) - { - axisProperties = m_yAxisProperties(); - auto [yAxisRangeMin, yAxisRangeMax] = m_plotWidget->axisRange( RiuPlotAxis::defaultLeft() ); - - axisRangeMin = yAxisRangeMin; - axisRangeMax = yAxisRangeMax; - } - - axisProperties->setVisibleRangeMin( std::min( axisRangeMin, axisRangeMax ) ); - axisProperties->setVisibleRangeMax( std::max( axisRangeMin, axisRangeMax ) ); - - axisProperties->updateConnectedEditors(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h index 57a4b8f519..78415a6417 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h @@ -21,7 +21,6 @@ #include "cafPdmChildField.h" #include "cafPdmObject.h" -#include "RiaPlotDefines.h" #include "RimNameConfig.h" #include "RimPlot.h" @@ -125,8 +124,6 @@ class RimGridCrossPlot : public RimPlot, public RimNameConfigHolderInterface virtual QString xAxisParameterString() const; QString yAxisParameterString() const; - void updateAxisInQwt( RiaDefines::PlotAxis axisType ); - void updateAxisFromQwt( RiaDefines::PlotAxis axisType ); std::vector visibleCurves() const; RimPlotAxisProperties* xAxisProperties(); @@ -148,6 +145,7 @@ class RimGridCrossPlot : public RimPlot, public RimNameConfigHolderInterface void connectAxisSignals( RimPlotAxisProperties* axis ); void axisSettingsChanged( const caf::SignalEmitter* emitter ); void axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic ); + void applyPropertiesOnPlotAxes(); private slots: void onPlotZoomed(); diff --git a/ApplicationLibCode/ProjectDataModel/Tools/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Tools/CMakeLists_files.cmake index 9bc7ea43e0..a4f5e2686c 100644 --- a/ApplicationLibCode/ProjectDataModel/Tools/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Tools/CMakeLists_files.cmake @@ -1,6 +1,10 @@ -set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaVariableMapper.h) +set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaVariableMapper.h + ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisTools.h +) -set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaVariableMapper.cpp) +set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaVariableMapper.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisTools.cpp +) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp new file mode 100644 index 0000000000..c733bf1221 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp @@ -0,0 +1,125 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimPlotAxisTools.h" +#include "RimPlotAxisLogRangeCalculator.h" +#include "RimPlotAxisProperties.h" +#include "RimPlotCurve.h" + +#include "RiuPlotAxis.h" +#include "RiuPlotWidget.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisTools::updateVisibleRangesFromPlotWidget( RimPlotAxisProperties* axisProperties, + RiuPlotAxis plotAxis, + const RiuPlotWidget* const plotWidget ) +{ + if ( !plotWidget || !axisProperties ) return; + + auto [axisRangeMin, axisRangeMax] = plotWidget->axisRange( plotAxis ); + + axisProperties->setVisibleRangeMin( std::min( axisRangeMin, axisRangeMax ) ); + axisProperties->setVisibleRangeMax( std::max( axisRangeMin, axisRangeMax ) ); + + axisProperties->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisTools::updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget, + RiuPlotAxis axis, + const RimPlotAxisProperties* const axisProperties, + const QString& axisTitle, + std::vector plotCurves ) +{ + if ( !plotWidget || !axisProperties ) return; + + if ( axisProperties->isActive() ) + { + plotWidget->enableAxis( axis, true ); + + Qt::AlignmentFlag alignment = Qt::AlignCenter; + if ( axisProperties->titlePosition() == RimPlotAxisPropertiesInterface::AXIS_TITLE_END ) + { + alignment = Qt::AlignRight; + } + plotWidget->setAxisFontsAndAlignment( axis, axisProperties->titleFontSize(), axisProperties->valuesFontSize(), false, alignment ); + if ( !axisTitle.isEmpty() ) + { + plotWidget->setAxisTitleText( axis, axisTitle ); + } + plotWidget->setAxisTitleEnabled( axis, true ); + + if ( axisProperties->isLogarithmicScaleEnabled() ) + { + bool isLogScale = plotWidget->axisScaleType( axis ) == RiuPlotWidget::AxisScaleType::LOGARITHMIC; + if ( !isLogScale ) + { + plotWidget->setAxisScaleType( axis, RiuPlotWidget::AxisScaleType::LOGARITHMIC ); + plotWidget->setAxisMaxMinor( axis, 5 ); + } + + double min = axisProperties->visibleRangeMin(); + double max = axisProperties->visibleRangeMax(); + if ( axisProperties->isAutoZoom() ) + { + RimPlotAxisLogRangeCalculator logRangeCalculator( axis.axis(), plotCurves ); + logRangeCalculator.computeAxisRange( &min, &max ); + } + + if ( axisProperties->isAxisInverted() ) + { + std::swap( min, max ); + } + plotWidget->setAxisScale( axis, min, max ); + } + else + { + bool isLinearScale = plotWidget->axisScaleType( axis ) == RiuPlotWidget::AxisScaleType::LINEAR; + if ( !isLinearScale ) + { + plotWidget->setAxisScaleType( axis, RiuPlotWidget::AxisScaleType::LINEAR ); + plotWidget->setAxisMaxMinor( axis, 3 ); + } + + if ( axisProperties->isAutoZoom() ) + { + plotWidget->setAxisAutoScale( axis, true ); + plotWidget->setAxisInverted( axis, axisProperties->isAxisInverted() ); + } + else + { + double min = axisProperties->visibleRangeMin(); + double max = axisProperties->visibleRangeMax(); + if ( axisProperties->isAxisInverted() ) + { + std::swap( min, max ); + } + + plotWidget->setAxisScale( axis, min, max ); + } + } + } + else + { + plotWidget->enableAxis( axis, false ); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h new file mode 100644 index 0000000000..269bba909b --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 + +class RimPlotAxisProperties; +class RimPlotCurve; +class RiuPlotAxis; +class RiuPlotWidget; + +#include +#include + +namespace RimPlotAxisTools +{ +void updateVisibleRangesFromPlotWidget( RimPlotAxisProperties* axisProperties, RiuPlotAxis plotAxis, const RiuPlotWidget* const plotWidget ); + +void updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget, + RiuPlotAxis plotAxis, + const RimPlotAxisProperties* const axisProperties, + const QString& axisTitle, + std::vector plotCurves ); + +}; // namespace RimPlotAxisTools From a55b53c7251ed6a9f15cd089986beba903bd3a43 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 3 May 2024 09:58:55 +0200 Subject: [PATCH 066/332] Add parsing of *.DATA and add zoom to VFP plots Parse *.DATA and create VFP plots for all tables Add zoom in VFP plots --- ApplicationLibCode/CMakeLists.txt | 1 + .../RicShowPlotDataFeature.cpp | 3 +- .../Commands/RicNewVfpPlotFeature.cpp | 66 ++-- .../Commands/RicNewVfpPlotFeature.h | 2 - .../ProjectDataModel/CMakeLists_files.cmake | 6 - .../ProjectDataModel/RiaOpmParserTools.cpp | 22 +- .../RimContextCommandBuilder.cpp | 5 - .../RimMainPlotCollection.cpp | 2 +- .../ProjectDataModel/RimProject.cpp | 2 +- .../Tools/RimPlotAxisTools.cpp | 10 +- .../ProjectDataModel/Tools/RimPlotAxisTools.h | 10 +- .../CMakeLists_files.cmake | 21 ++ .../VerticalFlowPerformance/RimVfpDeck.cpp | 139 ++++++++ .../VerticalFlowPerformance/RimVfpDeck.h | 47 +++ .../RimVfpDefines.cpp | 0 .../RimVfpDefines.h | 0 .../RimVfpPlot.cpp | 327 +++++++++++++----- .../RimVfpPlot.h | 20 +- .../RimVfpPlotCollection.cpp | 68 +++- .../RimVfpPlotCollection.h | 12 + 20 files changed, 614 insertions(+), 149 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake create mode 100644 ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.h rename ApplicationLibCode/ProjectDataModel/{ => VerticalFlowPerformance}/RimVfpDefines.cpp (100%) rename ApplicationLibCode/ProjectDataModel/{ => VerticalFlowPerformance}/RimVfpDefines.h (100%) rename ApplicationLibCode/ProjectDataModel/{ => VerticalFlowPerformance}/RimVfpPlot.cpp (77%) rename ApplicationLibCode/ProjectDataModel/{ => VerticalFlowPerformance}/RimVfpPlot.h (91%) rename ApplicationLibCode/ProjectDataModel/{ => VerticalFlowPerformance}/RimVfpPlotCollection.cpp (61%) rename ApplicationLibCode/ProjectDataModel/{ => VerticalFlowPerformance}/RimVfpPlotCollection.h (78%) diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index 75cfd28df2..67ad84624b 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -132,6 +132,7 @@ list( ProjectDataModel/Tools/CMakeLists_files.cmake ProjectDataModelCommands/CMakeLists_files.cmake ProjectDataModelCommands/CommandRouter/CMakeLists_files.cmake + ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake GeoMech/GeoMechVisualization/CMakeLists_files.cmake ModelVisualization/CMakeLists_files.cmake ModelVisualization/Faults/CMakeLists_files.cmake diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp index 9f78905824..fa142c7b25 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp @@ -33,11 +33,12 @@ #include "RimPlotWindow.h" #include "RimProject.h" #include "RimSummaryPlot.h" -#include "RimVfpPlot.h" #include "RimWellAllocationOverTimePlot.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" +#include "VerticalFlowPerformance/RimVfpPlot.h" + #include "RiuPlotMainWindow.h" #include "RiuTextDialog.h" diff --git a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp index 5a0ba0e125..2e1d2e17d9 100644 --- a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp @@ -22,12 +22,10 @@ #include "RiaGuiApplication.h" #include "RimMainPlotCollection.h" -#include "RimSimWellInView.h" -#include "RimVfpPlot.h" -#include "RimVfpPlotCollection.h" -#include "RimWellLogPlot.h" -#include "RimWellLogTrack.h" -#include "RimWellPath.h" + +#include "VerticalFlowPerformance/RimVfpDeck.h" +#include "VerticalFlowPerformance/RimVfpPlot.h" +#include "VerticalFlowPerformance/RimVfpPlotCollection.h" #include "RiuFileDialogTools.h" #include "RiuPlotMainWindow.h" @@ -38,8 +36,6 @@ #include #include -#include - CAF_CMD_SOURCE_INIT( RicNewVfpPlotFeature, "RicNewVfpPlotFeature" ); //-------------------------------------------------------------------------------------------------- @@ -47,7 +43,7 @@ CAF_CMD_SOURCE_INIT( RicNewVfpPlotFeature, "RicNewVfpPlotFeature" ); //-------------------------------------------------------------------------------------------------- bool RicNewVfpPlotFeature::isCommandEnabled() const { - RimVfpPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject(); + auto plotColl = caf::firstAncestorOfTypeFromSelectedObject(); return ( plotColl != nullptr ); } @@ -56,44 +52,64 @@ bool RicNewVfpPlotFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicNewVfpPlotFeature::onActionTriggered( bool isChecked ) { + RimVfpPlotCollection* vfpPlotColl = RimMainPlotCollection::current()->vfpPlotCollection(); + if ( !vfpPlotColl ) return; + RiaApplication* app = RiaGuiApplication::instance(); RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow(); const QString vfpDataKey = "VFP_DATA"; QString defaultDir = app->lastUsedDialogDirectory( vfpDataKey ); QStringList fileNames = - RiuFileDialogTools::getOpenFileNames( mpw, "Import VFP Files", defaultDir, "VFP Text Files (*.ecl *.vfp);;All Files (*.*)" ); + RiuFileDialogTools::getOpenFileNames( mpw, "Import VFP Files", defaultDir, "VFP Text Files (*.ecl *.vfp *.data);;All Files (*.*)" ); if ( fileNames.isEmpty() ) return; app->setLastUsedDialogDirectory( vfpDataKey, QFileInfo( fileNames.last() ).absolutePath() ); - RimVfpPlotCollection* vfpPlotColl = RimMainPlotCollection::current()->vfpPlotCollection(); - if ( vfpPlotColl ) + std::vector vfpPlots; + std::vector vfpDecks; + + for ( const auto& fileName : fileNames ) { - std::vector vfpPlots; - for ( const auto& fileName : fileNames ) + if ( fileName.contains( ".DATA" ) ) { - RimVfpPlot* vfpPlot = new RimVfpPlot(); + auto vfpDeck = vfpPlotColl->addDeck( fileName ); + vfpDecks.push_back( vfpDeck ); + } + else + { + auto vfpPlot = new RimVfpPlot(); vfpPlot->setFileName( fileName ); vfpPlotColl->addPlot( vfpPlot ); vfpPlots.push_back( vfpPlot ); } + } - vfpPlotColl->updateConnectedEditors(); + vfpPlotColl->updateConnectedEditors(); - for ( auto plot : vfpPlots ) - { - plot->loadDataAndUpdate(); - } + for ( auto deck : vfpDecks ) + { + deck->loadDataAndUpdate(); + deck->updateConnectedEditors(); + } - RiuPlotMainWindowTools::showPlotMainWindow(); + for ( auto plot : vfpPlots ) + { + plot->loadDataAndUpdate(); + } - if ( !vfpPlots.empty() ) - { - RiuPlotMainWindowTools::onObjectAppended( vfpPlots.front() ); - } + RiuPlotMainWindowTools::showPlotMainWindow(); + + if ( !vfpPlots.empty() ) + { + RiuPlotMainWindowTools::onObjectAppended( vfpPlots.front() ); + } + + if ( !vfpDecks.empty() ) + { + RiuPlotMainWindowTools::onObjectAppended( vfpDecks.front() ); } } diff --git a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h index ba670d6b07..1b616a6337 100644 --- a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h +++ b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h @@ -31,6 +31,4 @@ class RicNewVfpPlotFeature : public caf::CmdFeature bool isCommandEnabled() const override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; - - static QString selectedWellName(); }; diff --git a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake index 2c0f181ea4..abefbff49e 100644 --- a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake @@ -48,9 +48,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.h - ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.h - ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.h - ${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.h ${CMAKE_CURRENT_LIST_DIR}/RimPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.h ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlot.h @@ -188,9 +185,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlot.cpp diff --git a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp index 58cf2c552e..9d7c7a815b 100644 --- a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp @@ -52,9 +52,9 @@ Opm::VFPInjTable createInjectionTable( const Opm::DeckKeyword& keyword ) if ( header.getItem().hasValue( 0 ) ) { - std::string units_string; - units_string = header.getItem().get( 0 ); - unitSystem = Opm::UnitSystem( units_string ); + std::string unitString; + unitString = header.getItem().get( 0 ); + unitSystem = Opm::UnitSystem( unitString ); } } @@ -72,9 +72,9 @@ Opm::VFPProdTable createProductionTable( const Opm::DeckKeyword& keyword ) if ( header.getItem().hasValue( 0 ) ) { - std::string units_string; - units_string = header.getItem().get( 0 ); - unitSystem = Opm::UnitSystem( units_string ); + std::string unitString; + unitString = header.getItem().get( 0 ); + unitSystem = Opm::UnitSystem( unitString ); } } @@ -101,9 +101,8 @@ std::vector extractVfpInjectionTables( const std::string& file auto deck = parser.parseFile( filename ); - std::string myKeyword = "VFPINJ"; - auto keywordList = deck.getKeywordList( myKeyword ); - + std::string keyword = ::Opm::ParserKeywords::VFPINJ::keywordName; + auto keywordList = deck.getKeywordList( keyword ); for ( auto kw : keywordList ) { auto table = createInjectionTable( *kw ); @@ -133,9 +132,8 @@ std::vector extractVfpProductionTables( const std::string& fi auto deck = parser.parseFile( filename ); - std::string myKeyword = "VFPPROD"; - auto keywordList = deck.getKeywordList( myKeyword ); - + std::string keyword = ::Opm::ParserKeywords::VFPPROD::keywordName; + auto keywordList = deck.getKeywordList( keyword ); for ( auto kw : keywordList ) { auto table = createProductionTable( *kw ); diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 6050b8ce10..19dbea920c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -148,7 +148,6 @@ #include "RimSurfaceCollection.h" #include "RimValveTemplate.h" #include "RimValveTemplateCollection.h" -#include "RimVfpPlotCollection.h" #include "RimViewController.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" @@ -587,10 +586,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicNewPltPlotFeature"; } - else if ( dynamic_cast( firstUiItem ) ) - { - menuBuilder << "RicNewVfpPlotFeature"; - } else if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicNewSummaryMultiPlotFeature"; diff --git a/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp index b93aaf4915..d5d928f0ce 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp @@ -49,7 +49,6 @@ #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlotCollection.h" #include "RimSummaryTableCollection.h" -#include "RimVfpPlotCollection.h" #include "RimViewWindow.h" #include "RimWellAllocationOverTimePlot.h" #include "RimWellAllocationPlot.h" @@ -58,6 +57,7 @@ #include "RimWellLogPlotCollection.h" #include "RimWellPltPlot.h" #include "RimWellRftPlot.h" +#include "VerticalFlowPerformance/RimVfpPlotCollection.h" #ifdef USE_QTCHARTS #include "RimEnsembleFractureStatisticsPlot.h" diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index d462447062..4210ed99f0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -92,7 +92,6 @@ #include "RimUserDefinedPolylinesAnnotation.h" #include "RimValveTemplate.h" #include "RimValveTemplateCollection.h" -#include "RimVfpPlotCollection.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" #include "RimViewWindow.h" @@ -100,6 +99,7 @@ #include "RimWellLogPlotCollection.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" +#include "VerticalFlowPerformance/RimVfpPlotCollection.h" #include "Tools/RiaVariableMapper.h" diff --git a/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp index c733bf1221..37f91cf370 100644 --- a/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp @@ -44,11 +44,11 @@ void RimPlotAxisTools::updateVisibleRangesFromPlotWidget( RimPlotAxisProperties* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotAxisTools::updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget, - RiuPlotAxis axis, - const RimPlotAxisProperties* const axisProperties, - const QString& axisTitle, - std::vector plotCurves ) +void RimPlotAxisTools::updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget, + RiuPlotAxis axis, + const RimPlotAxisProperties* const axisProperties, + const QString& axisTitle, + const std::vector& plotCurves ) { if ( !plotWidget || !axisProperties ) return; diff --git a/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h index 269bba909b..013283e738 100644 --- a/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h +++ b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h @@ -30,10 +30,10 @@ namespace RimPlotAxisTools { void updateVisibleRangesFromPlotWidget( RimPlotAxisProperties* axisProperties, RiuPlotAxis plotAxis, const RiuPlotWidget* const plotWidget ); -void updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget, - RiuPlotAxis plotAxis, - const RimPlotAxisProperties* const axisProperties, - const QString& axisTitle, - std::vector plotCurves ); +void updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget, + RiuPlotAxis plotAxis, + const RimPlotAxisProperties* const axisProperties, + const QString& axisTitle, + const std::vector& plotCurves ); }; // namespace RimPlotAxisTools diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake new file mode 100644 index 0000000000..b2d2b68a31 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake @@ -0,0 +1,21 @@ +set(SOURCE_GROUP_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.h + ${CMAKE_CURRENT_LIST_DIR}/RimVfpDeck.h + ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.h + ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.h +) + +set(SOURCE_GROUP_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/RimVfpDeck.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.cpp +) + +list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) +list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) + +source_group( + "VFP Plots" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} + ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake +) diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp new file mode 100644 index 0000000000..e8a0780892 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp @@ -0,0 +1,139 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimVfpDeck.h" + +#include "RiaOpmParserTools.h" + +#include "RimVfpPlotCollection.h" + +#include "cafPdmUiTreeOrdering.h" + +#include + +CAF_PDM_SOURCE_INIT( RimVfpDeck, "RimVfpDeck" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpDeck::RimVfpDeck() +{ + CAF_PDM_InitObject( "VFP Plot", ":/VfpPlot.svg" ); + + CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path" ); + CAF_PDM_InitFieldNoDefault( &m_vfpPlotCollection, "VfpPlotCollection", "Plot Collection" ); + m_vfpPlotCollection = new RimVfpPlotCollection(); + + setDeletable( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpDeck::setFileName( const QString& filename ) +{ + m_filePath = filename; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpDeck::loadDataAndUpdate() +{ + updateObjectName(); + + auto createRimVfpPlot = [&]() -> RimVfpPlot* + { + auto plot = new RimVfpPlot(); + plot->setFileName( m_filePath().path() ); + return plot; + }; + + std::vector currentPlots = m_vfpPlotCollection->plots(); + + auto [vfpProdTables, vfpInjTables] = RiaOpmParserTools::extractVfpTablesFromDataFile( m_filePath().path().toStdString() ); + for ( const auto& prodTable : vfpProdTables ) + { + RimVfpPlot* plot = m_vfpPlotCollection->plotForTableNumber( prodTable.getTableNum() ); + if ( !plot ) + { + plot = createRimVfpPlot(); + m_vfpPlotCollection->addPlot( plot ); + } + else + { + std::erase( currentPlots, plot ); + } + plot->setProductionTable( prodTable ); + plot->setDataIsImportedExternally( true ); + plot->setDeletable( false ); + plot->loadDataAndUpdate(); + } + + for ( const auto& injTable : vfpInjTables ) + { + RimVfpPlot* plot = m_vfpPlotCollection->plotForTableNumber( injTable.getTableNum() ); + if ( !plot ) + { + plot = createRimVfpPlot(); + m_vfpPlotCollection->addPlot( plot ); + } + else + { + std::erase( currentPlots, plot ); + } + plot->setInjectionTable( injTable ); + plot->setDataIsImportedExternally( true ); + plot->setDeletable( false ); + plot->loadDataAndUpdate(); + } + + for ( auto plotToDelete : currentPlots ) + { + m_vfpPlotCollection->removePlot( plotToDelete ); + delete plotToDelete; + } +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpDeck::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) +{ + for ( auto p : m_vfpPlotCollection->plots() ) + { + uiTreeOrdering.add( p ); + } + + uiTreeOrdering.skipRemainingChildren( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpDeck::updateObjectName() +{ + QString name = "VFP Plots"; + + QFileInfo fileInfo( m_filePath().path() ); + auto fileName = fileInfo.fileName(); + if ( !fileName.isEmpty() ) + { + name += " - " + fileName; + } + setName( name ); +} diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.h new file mode 100644 index 0000000000..fdc25c5293 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimNamedObject.h" + +#include "cafFilePath.h" + +class RimVfpPlotCollection; + +//-------------------------------------------------------------------------------------------------- +/// RimVfpDeck parses a deck file (*.DATA) containing VFP data and creates a collection of VFP plots. +//-------------------------------------------------------------------------------------------------- +class RimVfpDeck : public RimNamedObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimVfpDeck(); + + void setFileName( const QString& filename ); + void loadDataAndUpdate(); + +private: + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; + void updateObjectName(); + +private: + caf::PdmField m_filePath; + caf::PdmChildField m_vfpPlotCollection; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimVfpDefines.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.cpp similarity index 100% rename from ApplicationLibCode/ProjectDataModel/RimVfpDefines.cpp rename to ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.cpp diff --git a/ApplicationLibCode/ProjectDataModel/RimVfpDefines.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.h similarity index 100% rename from ApplicationLibCode/ProjectDataModel/RimVfpDefines.h rename to ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.h diff --git a/ApplicationLibCode/ProjectDataModel/RimVfpPlot.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp similarity index 77% rename from ApplicationLibCode/ProjectDataModel/RimVfpPlot.cpp rename to ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp index 71dbb86cd2..9bf1cce8d8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimVfpPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp @@ -18,23 +18,29 @@ #include "RimVfpPlot.h" -#include "RiaDefines.h" -#include "RiaOpmParserTools.h" -#include "RimVfpDefines.h" - #include "RiaColorTables.h" #include "RiaEclipseUnitTools.h" +#include "RiaOpmParserTools.h" + +#include "RimPlotAxisProperties.h" +#include "RimVfpDefines.h" +#include "Tools/RimPlotAxisTools.h" #include "RiuContextMenuLauncher.h" #include "RiuPlotCurve.h" #include "RiuPlotWidget.h" #include "RiuQwtPlotCurveDefines.h" +#include "RiuQwtPlotWheelZoomer.h" +#include "RiuQwtPlotWidget.h" + +#include "RiuQwtCurvePointTracker.h" #include "RiuQwtPlotWidget.h" +#include "RiuQwtPlotZoomer.h" -#include "RiuQwtSymbol.h" -#include "cafCmdFeatureMenuBuilder.h" #include "cafPdmUiComboBoxEditor.h" +#include "qwt_plot_panner.h" + #include #include @@ -137,8 +143,22 @@ RimVfpPlot::RimVfpPlot() CAF_PDM_InitField( &m_gasLiquidRatioIdx, "GasLiquidRatioIdx", 0, "Gas Liquid Ratio" ); m_gasLiquidRatioIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - m_showWindow = true; - m_showPlotLegends = true; + CAF_PDM_InitFieldNoDefault( &m_xAxisProperties, "xAxisProperties", "X Axis" ); + m_xAxisProperties = new RimPlotAxisProperties; + m_xAxisProperties->setNameAndAxis( "X-Axis", "X-Axis", RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); + m_xAxisProperties->setEnableTitleTextSettings( false ); + + CAF_PDM_InitFieldNoDefault( &m_yAxisProperties, "yAxisProperties", "Y Axis" ); + m_yAxisProperties = new RimPlotAxisProperties; + m_yAxisProperties->setNameAndAxis( "Y-Axis", "Y-Axis", RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); + m_yAxisProperties->setEnableTitleTextSettings( false ); + + connectAxisSignals( m_xAxisProperties() ); + connectAxisSignals( m_yAxisProperties() ); + + m_showWindow = true; + m_showPlotLegends = true; + m_dataIsImportedExternally = false; setAsPlotMdiWindow(); @@ -181,15 +201,17 @@ bool RimVfpPlot::isCurveHighlightSupported() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setAutoScaleXEnabled( bool /*enabled*/ ) +void RimVfpPlot::setAutoScaleXEnabled( bool enabled ) { + m_xAxisProperties->setAutoZoom( enabled ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setAutoScaleYEnabled( bool /*enabled*/ ) +void RimVfpPlot::setAutoScaleYEnabled( bool enabled ) { + m_yAxisProperties->setAutoZoom( enabled ); } //-------------------------------------------------------------------------------------------------- @@ -197,6 +219,13 @@ void RimVfpPlot::setAutoScaleYEnabled( bool /*enabled*/ ) //-------------------------------------------------------------------------------------------------- void RimVfpPlot::updateAxes() { + if ( !m_plotWidget ) return; + + QString title; + RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, RiuPlotAxis::defaultBottom(), m_xAxisProperties(), title, {} ); + RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, RiuPlotAxis::defaultLeft(), m_yAxisProperties(), title, {} ); + + m_plotWidget->scheduleReplot(); } //-------------------------------------------------------------------------------------------------- @@ -209,7 +238,7 @@ void RimVfpPlot::updateLegend() return; } - // Hide the legend when in multiplot mode, as the legend is handeled by the multi plot grid layout + // Hide the legend when in multiplot mode, as the legend is handled by the multi plot grid layout bool doShowLegend = false; if ( isMdiWindow() ) { @@ -350,6 +379,44 @@ QImage RimVfpPlot::snapshotWindowContent() //-------------------------------------------------------------------------------------------------- void RimVfpPlot::zoomAll() { + setAutoScaleXEnabled( true ); + setAutoScaleYEnabled( true ); + + updatePlotWidgetFromAxisRanges(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::setProductionTable( const Opm::VFPProdTable& table ) +{ + m_prodTable = std::make_unique( table ); + m_injectionTable.reset(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::setInjectionTable( const Opm::VFPInjTable& table ) +{ + m_prodTable.reset(); + m_injectionTable = std::make_unique( table ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::setDataIsImportedExternally( bool dataIsImportedExternally ) +{ + m_dataIsImportedExternally = dataIsImportedExternally; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimVfpPlot::tableNumber() const +{ + return m_tableNumber(); } //-------------------------------------------------------------------------------------------------- @@ -365,21 +432,35 @@ void RimVfpPlot::doRemoveFromCollection() RiuPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) { // It seems we risk being called multiple times - if ( m_plotWidget ) - { - return m_plotWidget; - } + if ( m_plotWidget ) return m_plotWidget; - { - RiuPlotWidget* plotWidget = new RiuQwtPlotWidget( this, mainWindowParent ); + auto qwtPlotWidget = new RiuQwtPlotWidget( this, mainWindowParent ); + auto qwtPlot = qwtPlotWidget->qwtPlot(); + new RiuQwtCurvePointTracker( qwtPlot, true, nullptr ); - // Remove event filter to disable unwanted highlighting on left click in plot. - plotWidget->removeEventFilter(); + // LeftButton for the zooming + auto plotZoomer = new RiuQwtPlotZoomer( qwtPlot->canvas() ); + plotZoomer->setTrackerMode( QwtPicker::AlwaysOff ); + plotZoomer->initMousePattern( 1 ); - new RiuContextMenuLauncher( plotWidget, { "RicShowPlotDataFeature" } ); + // MidButton for the panning + auto panner = new QwtPlotPanner( qwtPlot->canvas() ); + panner->setMouseButton( Qt::MiddleButton ); - m_plotWidget = plotWidget; - } + auto wheelZoomer = new RiuQwtPlotWheelZoomer( qwtPlot ); + + // Use lambda functions to connect signals to functions instead of slots + connect( wheelZoomer, &RiuQwtPlotWheelZoomer::zoomUpdated, [=]() { onPlotZoomed(); } ); + connect( plotZoomer, &RiuQwtPlotZoomer::zoomed, [=]() { onPlotZoomed(); } ); + connect( panner, &QwtPlotPanner::panned, [=]() { onPlotZoomed(); } ); + connect( qwtPlotWidget, &RiuQwtPlotWidget::plotZoomed, [=]() { onPlotZoomed(); } ); + + // Remove event filter to disable unwanted highlighting on left click in plot. + qwtPlotWidget->removeEventFilter(); + + new RiuContextMenuLauncher( qwtPlotWidget, { "RicShowPlotDataFeature" } ); + + m_plotWidget = qwtPlotWidget; updateLegend(); onLoadDataAndUpdate(); @@ -423,46 +504,63 @@ void RimVfpPlot::onLoadDataAndUpdate() updateLegend(); - QString filePath = m_filePath.v().path(); - if ( !filePath.isEmpty() ) - { - QFileInfo fi( filePath ); - QString wellName = fi.baseName(); + QString wellName; - // Try to read the file as an prod table first (most common) - const std::vector tables = RiaOpmParserTools::extractVfpProductionTables( filePath.toStdString() ); - if ( !tables.empty() ) - { - m_prodTable = std::make_unique( tables[0] ); - m_tableType = RimVfpDefines::TableType::PRODUCTION; - m_tableNumber = tables[0].getTableNum(); - m_referenceDepth = tables[0].getDatumDepth(); - m_flowingPhase = getFlowingPhaseType( tables[0] ); - m_flowingGasFraction = getFlowingGasFractionType( tables[0] ); - m_flowingWaterFraction = getFlowingWaterFractionType( tables[0] ); - populatePlotWidgetWithCurveData( m_plotWidget, tables[0], m_primaryVariable(), m_familyVariable() ); - } - else + if ( !m_dataIsImportedExternally ) + { + QString filePath = m_filePath.v().path(); + if ( !filePath.isEmpty() ) { - const std::vector tables = RiaOpmParserTools::extractVfpInjectionTables( filePath.toStdString() ); + QFileInfo fi( filePath ); + wellName = fi.baseName(); + + // Try to read the file as an prod table first (most common) + const std::vector tables = RiaOpmParserTools::extractVfpProductionTables( filePath.toStdString() ); if ( !tables.empty() ) { - m_injectionTable = std::make_unique( tables[0] ); - m_tableType = RimVfpDefines::TableType::INJECTION; - m_tableNumber = tables[0].getTableNum(); - m_referenceDepth = tables[0].getDatumDepth(); - m_flowingPhase = getFlowingPhaseType( tables[0] ); - populatePlotWidgetWithCurveData( m_plotWidget, tables[0] ); + setProductionTable( tables[0] ); + } + else + { + const std::vector tables = RiaOpmParserTools::extractVfpInjectionTables( filePath.toStdString() ); + if ( !tables.empty() ) + { + setInjectionTable( tables[0] ); + } } } + } - updatePlotTitle( - generatePlotTitle( wellName, m_tableNumber(), m_tableType(), m_interpolatedVariable(), m_primaryVariable(), m_familyVariable() ) ); + if ( m_prodTable ) + { + auto table = *m_prodTable; + m_tableType = RimVfpDefines::TableType::PRODUCTION; + m_tableNumber = table.getTableNum(); + m_referenceDepth = table.getDatumDepth(); + m_flowingPhase = getFlowingPhaseType( table ); + m_flowingGasFraction = getFlowingGasFractionType( table ); + m_flowingWaterFraction = getFlowingWaterFractionType( table ); + populatePlotWidgetWithCurveData( m_plotWidget, table, m_primaryVariable(), m_familyVariable() ); + } + else if ( m_injectionTable ) + { + auto table = *m_injectionTable; - m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true ); - m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true ); + m_tableType = RimVfpDefines::TableType::INJECTION; + m_tableNumber = table.getTableNum(); + m_referenceDepth = table.getDatumDepth(); + m_flowingPhase = getFlowingPhaseType( table ); + populatePlotWidgetWithCurveData( m_plotWidget, table ); } + updatePlotTitle( + generatePlotTitle( wellName, m_tableNumber(), m_tableType(), m_interpolatedVariable(), m_primaryVariable(), m_familyVariable() ) ); + + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true ); + + updatePlotWidgetFromAxisRanges(); + m_plotWidget->scheduleReplot(); } @@ -509,10 +607,10 @@ void RimVfpPlot::populatePlotData( const Opm::VFPInjTable& table double value = convertToDisplayUnit( thpValues[thp], RimVfpDefines::ProductionVariableType::THP ); QString unit = getDisplayUnit( RimVfpDefines::ProductionVariableType::THP ); - QString title = QString( "%1: %2 %3" ) + QString title = QString( "%1 [%2]: %3" ) .arg( caf::AppEnum::uiText( RimVfpDefines::ProductionVariableType::THP ) ) - .arg( value ) - .arg( unit ); + .arg( unit ) + .arg( value ); convertToDisplayUnit( yVals, RimVfpDefines::ProductionVariableType::THP ); convertToDisplayUnit( xVals, RimVfpDefines::ProductionVariableType::FLOW_RATE ); @@ -590,6 +688,69 @@ QString RimVfpPlot::axisTitle( RimVfpDefines::ProductionVariableType variableTyp return title; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::connectAxisSignals( RimPlotAxisProperties* axis ) +{ + axis->settingsChanged.connect( this, &RimVfpPlot::axisSettingsChanged ); + axis->logarithmicChanged.connect( this, &RimVfpPlot::axisLogarithmicChanged ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::axisSettingsChanged( const caf::SignalEmitter* emitter ) +{ + updateAxes(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic ) +{ + // Currently not supported +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::updatePlotWidgetFromAxisRanges() +{ + if ( m_plotWidget ) + { + updateAxes(); + + if ( auto qwtWidget = dynamic_cast( m_plotWidget.data() ) ) + { + if ( qwtWidget->qwtPlot() ) qwtWidget->qwtPlot()->updateAxes(); + } + + updateAxisRangesFromPlotWidget(); + m_plotWidget->scheduleReplot(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::updateAxisRangesFromPlotWidget() +{ + RimPlotAxisTools::updateVisibleRangesFromPlotWidget( m_xAxisProperties(), RiuPlotAxis::defaultBottom(), m_plotWidget ); + RimPlotAxisTools::updateVisibleRangesFromPlotWidget( m_yAxisProperties(), RiuPlotAxis::defaultLeft(), m_plotWidget ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::onPlotZoomed() +{ + setAutoScaleXEnabled( false ); + setAutoScaleYEnabled( false ); + updateAxisRangesFromPlotWidget(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -764,37 +925,35 @@ size_t RimVfpPlot::getVariableIndex( const Opm::VFPProdTable& table void RimVfpPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_filePath ); + m_filePath.uiCapability()->setUiReadOnly( m_dataIsImportedExternally ); - if ( !m_filePath.v().path().isEmpty() ) - { - uiOrdering.add( &m_tableType ); - uiOrdering.add( &m_tableNumber ); - uiOrdering.add( &m_referenceDepth ); - uiOrdering.add( &m_interpolatedVariable ); - uiOrdering.add( &m_flowingPhase ); + uiOrdering.add( &m_tableType ); + uiOrdering.add( &m_tableNumber ); + uiOrdering.add( &m_referenceDepth ); + uiOrdering.add( &m_interpolatedVariable ); + uiOrdering.add( &m_flowingPhase ); - if ( m_tableType == RimVfpDefines::TableType::PRODUCTION ) - { - uiOrdering.add( &m_flowingWaterFraction ); - uiOrdering.add( &m_flowingGasFraction ); - - uiOrdering.add( &m_primaryVariable ); - uiOrdering.add( &m_familyVariable ); - - caf::PdmUiOrdering* fixedVariablesGroup = uiOrdering.addNewGroup( "Fixed Variables" ); - fixedVariablesGroup->add( &m_flowRateIdx ); - fixedVariablesGroup->add( &m_thpIdx ); - fixedVariablesGroup->add( &m_articifialLiftQuantityIdx ); - fixedVariablesGroup->add( &m_waterCutIdx ); - fixedVariablesGroup->add( &m_gasLiquidRatioIdx ); - - // Disable the choices for variables as primary or family - setFixedVariableUiEditability( m_flowRateIdx, RimVfpDefines::ProductionVariableType::FLOW_RATE ); - setFixedVariableUiEditability( m_thpIdx, RimVfpDefines::ProductionVariableType::THP ); - setFixedVariableUiEditability( m_articifialLiftQuantityIdx, RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY ); - setFixedVariableUiEditability( m_waterCutIdx, RimVfpDefines::ProductionVariableType::WATER_CUT ); - setFixedVariableUiEditability( m_gasLiquidRatioIdx, RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO ); - } + if ( m_tableType == RimVfpDefines::TableType::PRODUCTION ) + { + uiOrdering.add( &m_flowingWaterFraction ); + uiOrdering.add( &m_flowingGasFraction ); + + uiOrdering.add( &m_primaryVariable ); + uiOrdering.add( &m_familyVariable ); + + caf::PdmUiOrdering* fixedVariablesGroup = uiOrdering.addNewGroup( "Fixed Variables" ); + fixedVariablesGroup->add( &m_flowRateIdx ); + fixedVariablesGroup->add( &m_thpIdx ); + fixedVariablesGroup->add( &m_articifialLiftQuantityIdx ); + fixedVariablesGroup->add( &m_waterCutIdx ); + fixedVariablesGroup->add( &m_gasLiquidRatioIdx ); + + // Disable the choices for variables as primary or family + setFixedVariableUiEditability( m_flowRateIdx, RimVfpDefines::ProductionVariableType::FLOW_RATE ); + setFixedVariableUiEditability( m_thpIdx, RimVfpDefines::ProductionVariableType::THP ); + setFixedVariableUiEditability( m_articifialLiftQuantityIdx, RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY ); + setFixedVariableUiEditability( m_waterCutIdx, RimVfpDefines::ProductionVariableType::WATER_CUT ); + setFixedVariableUiEditability( m_gasLiquidRatioIdx, RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO ); } uiOrdering.skipRemainingFields( true ); diff --git a/ApplicationLibCode/ProjectDataModel/RimVfpPlot.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h similarity index 91% rename from ApplicationLibCode/ProjectDataModel/RimVfpPlot.h rename to ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h index c9a634787f..71451ae6c3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimVfpPlot.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h @@ -22,7 +22,6 @@ #include "RimVfpDefines.h" #include "cafFilePath.h" -#include "cafPdmPtrField.h" #include @@ -31,6 +30,7 @@ class RiuPlotWidget; class VfpPlotData; +class RimPlotAxisProperties; //-------------------------------------------------------------------------------------------------- /// Vertical Flow Performance Plot @@ -65,6 +65,11 @@ class RimVfpPlot : public RimPlot QImage snapshotWindowContent() override; void zoomAll() override; + void setProductionTable( const Opm::VFPProdTable& table ); + void setInjectionTable( const Opm::VFPInjTable& table ); + void setDataIsImportedExternally( bool dataIsImportedExternally ); + int tableNumber() const; + private: // RimPlot implementations void doRemoveFromCollection(); @@ -137,6 +142,14 @@ class RimVfpPlot : public RimPlot static QString axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ); + void connectAxisSignals( RimPlotAxisProperties* axis ); + void axisSettingsChanged( const caf::SignalEmitter* emitter ); + void axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic ); + void updatePlotWidgetFromAxisRanges() override; + void updateAxisRangesFromPlotWidget() override; + + void onPlotZoomed(); + private: caf::PdmField m_plotTitle; caf::PdmField m_filePath; @@ -157,7 +170,12 @@ class RimVfpPlot : public RimPlot caf::PdmField m_waterCutIdx; caf::PdmField m_gasLiquidRatioIdx; + caf::PdmChildField m_yAxisProperties; + caf::PdmChildField m_xAxisProperties; + QPointer m_plotWidget; std::unique_ptr m_prodTable; std::unique_ptr m_injectionTable; + + bool m_dataIsImportedExternally; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp similarity index 61% rename from ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.cpp rename to ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp index 970fa95273..4831b23e7a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp @@ -27,7 +27,9 @@ #include "RimEclipseResultCase.h" #include "RimProject.h" -#include "RimVfpPlot.h" +#include "RimVfpDeck.h" + +#include "cafCmdFeatureMenuBuilder.h" CAF_PDM_SOURCE_INIT( RimVfpPlotCollection, "RimVfpPlotCollection" ); @@ -39,6 +41,7 @@ RimVfpPlotCollection::RimVfpPlotCollection() CAF_PDM_InitObject( "VFP Plots", ":/VfpPlotCollection.svg" ); CAF_PDM_InitFieldNoDefault( &m_vfpPlots, "VfpPlots", "Vertical Flow Performance Plots" ); + CAF_PDM_InitFieldNoDefault( &m_vfpDecks, "VfpDecks", "Vertical Flow Performance Decks" ); } //-------------------------------------------------------------------------------------------------- @@ -80,6 +83,22 @@ void RimVfpPlotCollection::deleteChildren() m_vfpPlots.deleteChildren(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpPlot* RimVfpPlotCollection::plotForTableNumber( int tableNumber ) const +{ + for ( auto plot : plots() ) + { + if ( plot->tableNumber() == tableNumber ) + { + return plot; + } + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -96,3 +115,50 @@ void RimVfpPlotCollection::removePlot( RimVfpPlot* vfpPlot ) m_vfpPlots.removeChild( vfpPlot ); updateAllRequiredEditors(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpDeck* RimVfpPlotCollection::addDeck( const QString& filename ) +{ + RimVfpDeck* deck = new RimVfpDeck(); + deck->setFileName( filename ); + m_vfpDecks.push_back( deck ); + + return deck; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlotCollection::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) +{ + for ( auto plot : plots() ) + { + plot->updateMdiWindowVisibility(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlotCollection::loadDataAndUpdateAllPlots() +{ + for ( auto plot : plots() ) + { + plot->loadDataAndUpdate(); + } + + for ( auto deck : m_vfpDecks.childrenByType() ) + { + deck->loadDataAndUpdate(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlotCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder << "RicNewVfpPlotFeature"; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h similarity index 78% rename from ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.h rename to ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h index b8dda7b337..916d974aa5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h @@ -23,6 +23,8 @@ #include "cafPdmChildArrayField.h" #include "cafPdmObject.h" +class RimVfpDeck; + //================================================================================================== /// /// @@ -38,11 +40,21 @@ class RimVfpPlotCollection : public caf::PdmObject, public RimTypedPlotCollectio void addPlot( RimVfpPlot* newPlot ) override; std::vector plots() const override; void deleteChildren(); + RimVfpPlot* plotForTableNumber( int tableNumber ) const; size_t plotCount() const final; void insertPlot( RimVfpPlot* vfpPlot, size_t index ) final; void removePlot( RimVfpPlot* vfpPlot ) final; + RimVfpDeck* addDeck( const QString& filename ); + +private: + void loadDataAndUpdateAllPlots() override; + void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) override; + + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; + private: caf::PdmChildArrayField m_vfpPlots; + caf::PdmChildArrayField m_vfpDecks; }; From 96481d81a8ea58ae8b5a756b4b997d1ee187c1cf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 4 May 2024 13:21:31 +0200 Subject: [PATCH 067/332] Add tool used to extract project file revisions from project file database * Add tool used to extract project file versions from database * Delete old records from backup to limit number of records to 50 --- .../Tools/RiaProjectBackupTools.cpp | 33 ++++- .../Application/Tools/RiaProjectBackupTools.h | 4 +- .../ProjectDataModel/RimProject.cpp | 5 +- CMakeLists.txt | 5 + .../.clang-format | 78 ++++++++++ .../CMakeLists.txt | 24 ++++ .../extract-projectfile-versions/main.cpp | 135 ++++++++++++++++++ 7 files changed, 279 insertions(+), 5 deletions(-) create mode 100644 ThirdParty/extract-projectfile-versions/.clang-format create mode 100644 ThirdParty/extract-projectfile-versions/CMakeLists.txt create mode 100644 ThirdParty/extract-projectfile-versions/main.cpp diff --git a/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp b/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp index 7ca26035f8..49844b8b57 100644 --- a/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp @@ -66,11 +66,40 @@ bool insertContent( const QString& content ) return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool deleteOldRecords( int maximumRecordCount ) +{ + QSqlQuery countQuery( "SELECT COUNT(*) FROM file_versions" ); + if ( !countQuery.exec() || !countQuery.next() ) + { + RiaLogging::error( "Error counting records: " + countQuery.lastError().text() ); + return false; + } + + int count = countQuery.value( 0 ).toInt(); + int recordsToDelete = count - maximumRecordCount; + if ( recordsToDelete <= 0 ) return true; + + QSqlQuery query; + query.prepare( "DELETE FROM file_versions WHERE id IN (SELECT id FROM file_versions ORDER BY timestamp ASC LIMIT :limit)" ); + query.bindValue( ":limit", recordsToDelete ); + + if ( !query.exec() ) + { + QString txt = "Error deleting old records:" + query.lastError().text(); + RiaLogging::error( txt ); + return false; + } + + return true; +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool appendTextToDatabase( const QString& databaseFilePath, const QString& content ) +bool appendTextToDatabase( const QString& databaseFilePath, int maximumRecordCount, const QString& content ) { const QString databaseType = "QSQLITE"; @@ -101,6 +130,8 @@ bool appendTextToDatabase( const QString& databaseFilePath, const QString& conte db.setDatabaseName( databaseFilePath ); if ( !createTableIfNeeded() ) return false; + if ( !deleteOldRecords( maximumRecordCount ) ) return false; + if ( !insertContent( content ) ) return false; return true; diff --git a/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.h b/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.h index a265702e12..658bb6b06b 100644 --- a/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.h +++ b/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.h @@ -25,5 +25,5 @@ //================================================================================================== namespace RiaProjectBackupTools { -bool appendTextToDatabase( const QString& databaseFilePath, const QString& content ); -} +bool appendTextToDatabase( const QString& databaseFilePath, int maximumRecordCount, const QString& content ); +} // namespace RiaProjectBackupTools diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 4210ed99f0..99ff1d34f5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -416,8 +416,9 @@ bool RimProject::writeProjectFile() if ( RiaPreferences::current()->storeBackupOfProjectFiles() ) { - QString backupFilename = fileName + "db"; - RiaProjectBackupTools::appendTextToDatabase( backupFilename, content ); + QString backupFilename = fileName + "db"; + const int maximumRecordCount = 50; + RiaProjectBackupTools::appendTextToDatabase( backupFilename, maximumRecordCount, content ); } distributePathsFromGlobalPathList(); diff --git a/CMakeLists.txt b/CMakeLists.txt index b0010b31b2..80323bde92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -989,6 +989,11 @@ else(OCTAVE_MKOCTFILE) ) endif(OCTAVE_MKOCTFILE) +add_subdirectory(ThirdParty/extract-projectfile-versions) +install(TARGETS extract-projectfile-versions + DESTINATION ${RESINSIGHT_INSTALL_FOLDER} +) + # ############################################################################## # Visual Studio : Create the ruleset file to be used by Static Code Analysis # https://stackoverflow.com/questions/75031903/how-to-enable-static-analysis-with-custom-ruleset-in-msvc-via-cmakelists-txt diff --git a/ThirdParty/extract-projectfile-versions/.clang-format b/ThirdParty/extract-projectfile-versions/.clang-format new file mode 100644 index 0000000000..241093fc3e --- /dev/null +++ b/ThirdParty/extract-projectfile-versions/.clang-format @@ -0,0 +1,78 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignEscapedNewlinesLeft: true +AlignOperands: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: true +AllowShortFunctionsOnASingleLine: InlineOnly +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackArguments: false +BinPackParameters: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Allman +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 140 +CommentPragmas: "^ IWYU pragma:" +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ForEachMacros: [foreach, Q_FOREACH, BOOST_FOREACH] +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|isl|json)/)' + Priority: 3 + - Regex: ".*" + Priority: 1 +IncludeIsMainRegex: "$" +IndentCaseLabels: true +IndentWidth: 4 +IndentWrappedFunctionNames: true +JavaScriptQuotes: Leave +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: "" +MacroBlockEnd: "" +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +PenaltyBreakAssignment: 13 +PenaltyBreakBeforeFirstCallParameter: 10000 +PenaltyBreakComment: 20 +PenaltyBreakFirstLessLess: 12 +PenaltyBreakString: 100 +PenaltyExcessCharacter: 5 +PenaltyReturnTypeOnItsOwnLine: 30 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: true +SpacesInSquareBrackets: false +Standard: c++20 +TabWidth: 4 +UseTab: Never diff --git a/ThirdParty/extract-projectfile-versions/CMakeLists.txt b/ThirdParty/extract-projectfile-versions/CMakeLists.txt new file mode 100644 index 0000000000..9c21b24629 --- /dev/null +++ b/ThirdParty/extract-projectfile-versions/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.5) +project(extract-projectfile-versions) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt5 COMPONENTS Core Sql REQUIRED) + +add_executable(extract-projectfile-versions main.cpp) + +target_link_libraries(extract-projectfile-versions Qt5::Core Qt5::Sql) + +if(MSVC) + add_custom_command( + TARGET extract-projectfile-versions + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ + $ + COMMAND_EXPAND_LISTS + ) +endif(MSVC) diff --git a/ThirdParty/extract-projectfile-versions/main.cpp b/ThirdParty/extract-projectfile-versions/main.cpp new file mode 100644 index 0000000000..88d5b56ed5 --- /dev/null +++ b/ThirdParty/extract-projectfile-versions/main.cpp @@ -0,0 +1,135 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> getAllContent() +{ + std::vector> content; + + QSqlQuery query; + + query.prepare( "SELECT timestamp, content FROM file_versions" ); + if ( !query.exec() ) + { + qDebug() << "Error retrieving content:" << query.lastError().text(); + return content; + } + + while ( query.next() ) + { + QDateTime timestamp = query.value( 0 ).toDateTime(); + QString projectContent = query.value( 1 ).toString(); + content.push_back( std::make_pair( timestamp, projectContent ) ); + } + + return content; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void extractVersionsToFolder( const QString& destinationFolder ) +{ + auto allContent = getAllContent(); + + for ( const auto& [timestamp, content] : allContent ) + { + const QString dateFormat = "yyyy-MM-dd_hh-mm-ss"; + QString filename = destinationFolder + "/" + timestamp.toString( dateFormat ) + ".rsp"; + QFile file( filename ); + if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) ) + { + qCritical() << "Error opening file for writing:" << filename; + return; + } + + QTextStream out( &file ); + out << content; + file.close(); + } +} + +int main( int argc, char* argv[] ) +{ + QCoreApplication app( argc, argv ); + QCoreApplication::setApplicationName( "extract-projectfile-versions" ); + QCoreApplication::setApplicationVersion( "1.0" ); + + QCommandLineParser parser; + parser.setApplicationDescription( + "extract-projectfile-versions is used to restore previous revisions of a ResInsight project from a project file database." ); + parser.addHelpOption(); + parser.addVersionOption(); + + parser.addPositionalArgument( "file", "ResInsight project file database (*.rspdb)" ); + parser.addPositionalArgument( "outputfolder", "Output folder all project files" ); + + parser.process( app ); + + const QStringList args = parser.positionalArguments(); + if ( args.size() != 2 ) + { + qCritical() << "Failed to detect two input arguments."; + parser.showHelp( 1 ); + return 1; + } + + QString databaseFilePath = args.front(); + if ( !QFile::exists( databaseFilePath ) ) + { + qCritical() << "Database file does not exist:" << databaseFilePath; + return 1; + } + + QString destinationDir = args[1]; + QDir dir; + if ( !dir.mkpath( destinationDir ) ) + { + qCritical() << "Not able to create destination folder : " << destinationDir; + return 1; + } + + const QString databaseType = "QSQLITE"; + + if ( !QSqlDatabase::isDriverAvailable( databaseType ) ) + { + qInfo() << "sqlite database is not available."; + return 1; + } + + // Try to open the SQLITE database + QSqlDatabase db = QSqlDatabase::database(); + if ( !db.isValid() || !db.open() ) + { + qInfo() << "Adding database"; + + // Add the SQLITE database, and it it required to do this once per session. The database will be available during the lifetime + // of the application, and can be accessed using QSqlDatabase::database() + db = QSqlDatabase::addDatabase( databaseType ); + } + + QFileInfo fileInfo( databaseFilePath ); + auto dbPath = fileInfo.absoluteFilePath(); + db.setDatabaseName( dbPath ); + + if ( !db.open() ) + { + QString txt = "Error opening database:" + db.lastError().text(); + qCritical() << txt; + return 1; + } + + extractVersionsToFolder( destinationDir ); + + return 1; +} From ae7f29c80fe7482d814cc489974b5839c9f1bd48 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 6 May 2024 09:48:00 +0200 Subject: [PATCH 068/332] #11418 Fix calculation between multiple cases --- .../RimSummaryCalculation.cpp | 34 ++++++++----------- .../ProjectDataModel/RimSummaryCalculation.h | 4 ++- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp index c83a240de3..08ba9fcf96 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp @@ -304,7 +304,9 @@ std::optional, std::vector>> auto vars = variables.value(); substituteVariables( vars, addr ); - return calculateResult( m_expression, vars, summaryCase ); + RimSummaryCase* summaryCaseForVariableSubstitution = m_distributeToAllCases ? summaryCase : nullptr; + + return calculateResult( m_expression, vars, summaryCaseForVariableSubstitution ); } //-------------------------------------------------------------------------------------------------- @@ -313,7 +315,7 @@ std::optional, std::vector>> std::optional, std::vector>> RimSummaryCalculation::calculateResult( const QString& expression, const std::vector& variables, - RimSummaryCase* summaryCase ) + RimSummaryCase* summaryCaseForSubstitution ) { QString leftHandSideVariableName = RimSummaryCalculation::findLeftHandSide( expression ); @@ -324,12 +326,13 @@ std::optional, std::vector>> { SummaryCalculationVariable v = variables[i]; - RiaSummaryCurveDefinition curveDef( summaryCase, v.summaryAddress, false ); + RimSummaryCase* summaryCaseForValues = v.summaryCase; + if ( summaryCaseForSubstitution ) summaryCaseForValues = summaryCaseForSubstitution; - std::vector curveValues = RiaSummaryCurveDefinition::resultValues( curveDef ); + RiaSummaryCurveDefinition curveDef( summaryCaseForValues, v.summaryAddress, false ); + std::vector curveValues = RiaSummaryCurveDefinition::resultValues( curveDef ); std::vector curveTimeSteps = RiaSummaryCurveDefinition::timeSteps( curveDef ); - if ( !curveTimeSteps.empty() && !curveValues.empty() ) { timeHistoryCurveMerger.addCurveData( curveTimeSteps, curveValues ); @@ -431,26 +434,19 @@ void RimSummaryCalculation::removeDependentObjects() //-------------------------------------------------------------------------------------------------- std::vector RimSummaryCalculation::allAddressesForSummaryCase( RimSummaryCase* summaryCase ) const { - if ( !m_distributeToAllCases ) + auto variables = getVariables(); + if ( variables && !variables.value().empty() ) { - for ( auto& v : m_variables ) + auto firstVariable = variables.value().front(); + + if ( !m_distributeToAllCases && ( firstVariable.summaryCase != summaryCase ) ) { - if ( auto variable = dynamic_cast( v.p() ) ) - { - if ( variable->summaryCase() != summaryCase ) - { - return {}; - } - } + // The calculation is only displayed in the summary case matching the first variable + return {}; } - } - auto variables = getVariables(); - if ( variables && !variables.value().empty() ) - { // The first variable is the substituable one. Use its category to // provide all available addresses. - auto firstVariable = variables.value().front(); if ( m_distributeToOtherItems ) { auto allResultAddresses = summaryCase->summaryReader()->allResultAddresses(); diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.h b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.h index 8f73d7ce96..dac018ca50 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.h +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.h @@ -76,7 +76,9 @@ class RimSummaryCalculation : public RimUserDefinedCalculation RimSummaryCalculationVariable* createVariable() override; static std::optional, std::vector>> - calculateResult( const QString& expression, const std::vector& variables, RimSummaryCase* summaryCase ); + calculateResult( const QString& expression, + const std::vector& variables, + RimSummaryCase* summaryCaseForSubstitution ); std::optional, std::vector>> calculateWithSubstitutions( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& addr ); From c685cff65481b967360acfdad41a38d88e1d7abb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 6 May 2024 10:07:53 +0200 Subject: [PATCH 069/332] Bump to 2024.03.4-dev.03 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 716c1427b9..8a08d31cac 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".02") +set(RESINSIGHT_DEV_VERSION ".03") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From b0e0bc5f146c3905833b52d88ca5ec16dbf56df6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 7 May 2024 07:50:13 +0200 Subject: [PATCH 070/332] Add more details to error messages during parsing of input files --- .../ProjectDataModel/RiaOpmParserTools.cpp | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp index 9d7c7a815b..a3e9ae0476 100644 --- a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp @@ -25,6 +25,7 @@ #include "cafPdmUiItem.h" #include "cafUtils.h" +#include "opm/common/utility/OpmInputError.hpp" #include "opm/input/eclipse/Deck/Deck.hpp" #include "opm/input/eclipse/Parser/ParseContext.hpp" #include "opm/input/eclipse/Parser/Parser.hpp" @@ -109,8 +110,20 @@ std::vector extractVfpInjectionTables( const std::string& file tables.push_back( table ); } } + catch ( Opm::OpmInputError& e ) + { + QString text = QString( "Error detected when parsing '%1'. Imported data might be missing or incomplete.\n%2" ) + .arg( QString::fromStdString( filename ) ) + .arg( QString::fromStdString( e.what() ) ); + + RiaLogging::warning( text ); + } catch ( ... ) { + QString text = + QString( "Error detected when parsing '%1'. Imported data might be missing or incomplete." ).arg( QString::fromStdString( filename ) ); + + RiaLogging::warning( text ); } return tables; @@ -140,8 +153,20 @@ std::vector extractVfpProductionTables( const std::string& fi tables.push_back( table ); } } + catch ( Opm::OpmInputError& e ) + { + QString text = QString( "Error detected when parsing '%1'. Imported data might be missing or incomplete.\n%2" ) + .arg( QString::fromStdString( filename ) ) + .arg( QString::fromStdString( e.what() ) ); + + RiaLogging::warning( text ); + } catch ( ... ) { + QString text = + QString( "Error detected when parsing '%1'. Imported data might be missing or incomplete." ).arg( QString::fromStdString( filename ) ); + + RiaLogging::warning( text ); } return tables; @@ -194,6 +219,14 @@ std::pair, std::vector> extract } } } + catch ( Opm::OpmInputError& e ) + { + QString text = QString( "Error detected when parsing '%1'. Imported data might be missing or incomplete.\n%2" ) + .arg( QString::fromStdString( dataDeckFilename ) ) + .arg( QString::fromStdString( e.what() ) ); + + RiaLogging::warning( text ); + } catch ( ... ) { QString text = QString( "Error detected when parsing '%1'. Imported data might be missing or incomplete." ) From aae5f55dc224b585bf62dbf7c5e13d504d471de2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 7 May 2024 08:46:54 +0200 Subject: [PATCH 071/332] Rename to "Import VFP Data" --- .../Commands/CMakeLists_files.cmake | 4 +-- ...eature.cpp => RicImportVfpDataFeature.cpp} | 29 ++++++++++++++----- ...lotFeature.h => RicImportVfpDataFeature.h} | 2 +- .../RimVfpPlotCollection.cpp | 6 +++- 4 files changed, 29 insertions(+), 12 deletions(-) rename ApplicationLibCode/Commands/{RicNewVfpPlotFeature.cpp => RicImportVfpDataFeature.cpp} (77%) rename ApplicationLibCode/Commands/{RicNewVfpPlotFeature.h => RicImportVfpDataFeature.h} (95%) diff --git a/ApplicationLibCode/Commands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/CMakeLists_files.cmake index b3ce72161b..1dc49cca3f 100644 --- a/ApplicationLibCode/Commands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/CMakeLists_files.cmake @@ -62,7 +62,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicStackSelectedCurvesFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicUnstackSelectedCurvesFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicThemeColorEditorFeature.h - ${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicImportVfpDataFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewCustomObjectiveFunctionFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewCustomObjectiveFunctionWeightFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewPressureTableItemFeature.h @@ -160,7 +160,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicStackSelectedCurvesFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicUnstackSelectedCurvesFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicThemeColorEditorFeature.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicImportVfpDataFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewCustomObjectiveFunctionFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewCustomObjectiveFunctionWeightFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewPressureTableItemFeature.cpp diff --git a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp b/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp similarity index 77% rename from ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp rename to ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp index 2e1d2e17d9..997de63cc0 100644 --- a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicNewVfpPlotFeature.h" +#include "RicImportVfpDataFeature.h" #include "RiaApplication.h" #include "RiaGuiApplication.h" @@ -36,12 +36,12 @@ #include #include -CAF_CMD_SOURCE_INIT( RicNewVfpPlotFeature, "RicNewVfpPlotFeature" ); +CAF_CMD_SOURCE_INIT( RicImportVfpDataFeature, "RicImportVfpDataFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicNewVfpPlotFeature::isCommandEnabled() const +bool RicImportVfpDataFeature::isCommandEnabled() const { auto plotColl = caf::firstAncestorOfTypeFromSelectedObject(); return ( plotColl != nullptr ); @@ -50,7 +50,7 @@ bool RicNewVfpPlotFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewVfpPlotFeature::onActionTriggered( bool isChecked ) +void RicImportVfpDataFeature::onActionTriggered( bool isChecked ) { RimVfpPlotCollection* vfpPlotColl = RimMainPlotCollection::current()->vfpPlotCollection(); if ( !vfpPlotColl ) return; @@ -60,8 +60,21 @@ void RicNewVfpPlotFeature::onActionTriggered( bool isChecked ) const QString vfpDataKey = "VFP_DATA"; QString defaultDir = app->lastUsedDialogDirectory( vfpDataKey ); - QStringList fileNames = - RiuFileDialogTools::getOpenFileNames( mpw, "Import VFP Files", defaultDir, "VFP Text Files (*.ecl *.vfp *.data);;All Files (*.*)" ); + + QString vfpTextFileFilter = "VFP Text Files (*.ecl *.vfp)"; + QString simulatorInputFilter = "Simulator Input Files (*.data)"; + QString allFilters = vfpTextFileFilter + ";;" + simulatorInputFilter + ";;" + "All Files (*.*)"; + + QString selectedFilter = simulatorInputFilter; + + QVariant userData = this->userData(); + if ( !userData.isNull() && userData.canConvert() ) + { + bool isVfpFiles = userData.toBool(); + if ( isVfpFiles ) selectedFilter = vfpTextFileFilter; + } + + QStringList fileNames = RiuFileDialogTools::getOpenFileNames( mpw, "Import VFP Files", defaultDir, allFilters, &selectedFilter ); if ( fileNames.isEmpty() ) return; @@ -116,8 +129,8 @@ void RicNewVfpPlotFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewVfpPlotFeature::setupActionLook( QAction* actionToSetup ) +void RicImportVfpDataFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "New VFP Plots" ); + actionToSetup->setText( "Import VFP Data" ); actionToSetup->setIcon( QIcon( ":/VfpPlot.svg" ) ); } diff --git a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h b/ApplicationLibCode/Commands/RicImportVfpDataFeature.h similarity index 95% rename from ApplicationLibCode/Commands/RicNewVfpPlotFeature.h rename to ApplicationLibCode/Commands/RicImportVfpDataFeature.h index 1b616a6337..801d8545f0 100644 --- a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h +++ b/ApplicationLibCode/Commands/RicImportVfpDataFeature.h @@ -23,7 +23,7 @@ //================================================================================================== /// //================================================================================================== -class RicNewVfpPlotFeature : public caf::CmdFeature +class RicImportVfpDataFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp index 4831b23e7a..05c78b96aa 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp @@ -160,5 +160,9 @@ void RimVfpPlotCollection::loadDataAndUpdateAllPlots() //-------------------------------------------------------------------------------------------------- void RimVfpPlotCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const { - menuBuilder << "RicNewVfpPlotFeature"; + // A variant with a true value is used to indicate that the VFP data is imported from a file + // This is used to distinguish between VFP data imported from a file and VFP data imported from a simulator + QVariant variant( QVariant::fromValue( true ) ); + menuBuilder.addCmdFeatureWithUserData( "RicImportVfpDataFeature", "Import VFP Files", variant ); + menuBuilder.addCmdFeature( "RicImportVfpDataFeature", "Import VFP from Simulator Files" ); } From 0ba11af5a414f0488f15c5245113d6d36a2c7e6b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 8 May 2024 07:06:12 +0200 Subject: [PATCH 072/332] Performance: Improve performance when adding a summary calculation Rebuild and update of the project tree for summary objects in Data Sources can be time consuming for large cases. Make sure the update of UI only happens when required. --- .../Summary/RimSummaryAddressCollection.cpp | 8 +++-- .../Summary/RimSummaryAddressCollection.h | 2 +- .../Summary/RimSummaryCase.cpp | 32 +++++++++++++++++-- .../Summary/RimSummaryCaseCollection.cpp | 2 +- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp index c27e0140a6..b35beca11e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp @@ -349,7 +349,7 @@ void RimSummaryAddressCollection::deleteChildren() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryAddressCollection::deleteCalculatedObjects() +int RimSummaryAddressCollection::deleteCalculatedAddresses() { std::vector toDelete; for ( const auto& a : m_adresses ) @@ -360,6 +360,8 @@ void RimSummaryAddressCollection::deleteCalculatedObjects() } } + int calculationAddressCount = static_cast( toDelete.size() ); + for ( auto a : toDelete ) { m_adresses.removeChild( a ); @@ -368,8 +370,10 @@ void RimSummaryAddressCollection::deleteCalculatedObjects() for ( auto& folder : m_subfolders ) { - folder->deleteCalculatedObjects(); + calculationAddressCount += folder->deleteCalculatedAddresses(); } + + return calculationAddressCount; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h index 9381c94813..274b923dda 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h @@ -66,7 +66,7 @@ class RimSummaryAddressCollection : public RimNamedObject void updateFolderStructure( const std::set& addresses, int caseId, int ensembleId = -1 ); void deleteChildren(); - void deleteCalculatedObjects(); + int deleteCalculatedAddresses(); bool isEmpty() const; bool isEnsemble() const; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp index 1ba6917fa4..c4a9deab55 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -397,14 +397,40 @@ void RimSummaryCase::onCalculationUpdated() // NB! Performance critical method if ( !m_showSubNodesInTree ) return; + if ( m_dataVectorFolders->isEmpty() ) + { + // Build the child nodes if they are not already built. This function will also create the + // calculated objects so we can do a early return. + refreshMetaData(); + + return; + } + // Delete all calculated address objects - m_dataVectorFolders->deleteCalculatedObjects(); + auto deletedCalculatedObjectCount = m_dataVectorFolders->deleteCalculatedAddresses(); + int calculatedAddressCount = 0; if ( auto reader = summaryReader() ) { auto addresses = reader->allResultAddresses(); - m_dataVectorFolders->updateFolderStructure( addresses, m_caseId ); + + std::set calculatedAddresses; + + for ( const auto& adr : addresses ) + { + if ( adr.isCalculated() ) + { + calculatedAddresses.insert( adr ); + } + } + + calculatedAddressCount = static_cast( calculatedAddresses.size() ); + + m_dataVectorFolders->updateFolderStructure( calculatedAddresses, m_caseId ); } - updateConnectedEditors(); + if ( deletedCalculatedObjectCount > 0 || calculatedAddressCount > 0 ) + { + updateConnectedEditors(); + } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 21fc2c4738..ea0dce891f 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -1162,7 +1162,7 @@ void RimSummaryCaseCollection::buildMetaData() //-------------------------------------------------------------------------------------------------- void RimSummaryCaseCollection::onCalculationUpdated() { - m_dataVectorFolders->deleteCalculatedObjects(); + m_dataVectorFolders->deleteCalculatedAddresses(); m_dataVectorFolders->updateFolderStructure( ensembleSummaryAddresses(), -1, m_ensembleId ); m_analyzer.reset(); From e98d839055969a2852595b722a3d340ec5acb68b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 7 May 2024 17:09:08 +0200 Subject: [PATCH 073/332] Bump version to dev.04 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 8a08d31cac..0dab48872d 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".03") +set(RESINSIGHT_DEV_VERSION ".04") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 2862de63a60219ca55e454b06952216fe2594df2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 8 May 2024 11:17:37 +0200 Subject: [PATCH 074/332] Add GRUPTREE and WELSPECS to avoid parser error --- .../ProjectDataModel/RiaOpmParserTools.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp index a3e9ae0476..36b08bac54 100644 --- a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp @@ -29,6 +29,7 @@ #include "opm/input/eclipse/Deck/Deck.hpp" #include "opm/input/eclipse/Parser/ParseContext.hpp" #include "opm/input/eclipse/Parser/Parser.hpp" +#include "opm/input/eclipse/Parser/ParserKeywords/G.hpp" #include "opm/input/eclipse/Parser/ParserKeywords/I.hpp" #include "opm/input/eclipse/Parser/ParserKeywords/P.hpp" #include "opm/input/eclipse/Parser/ParserKeywords/T.hpp" @@ -186,12 +187,15 @@ std::pair, std::vector> extract { Opm::Parser parser( false ); - // Required to include the TUNING keyword to avoid parsing error of a Norne DATA file containing the TUNING keyword - // The TUNING keyword is not required nor related to VFP data + // Required to include the some keywords not related or required for VFP data to avoid paring errors causing data to be skipped. + // TUNING caused error in a Norne model + // GRUPTREE, WELSPECS caused error in an unknown models std::vector parserKeywords = { Opm::ParserKeywords::VFPPROD(), Opm::ParserKeywords::VFPINJ(), Opm::ParserKeywords::INCLUDE(), - Opm::ParserKeywords::TUNING() }; + Opm::ParserKeywords::TUNING(), + Opm::ParserKeywords::GRUPTREE(), + Opm::ParserKeywords::WELSPECS() }; for ( const auto& kw : parserKeywords ) { parser.addParserKeyword( kw ); From 68e423f1b8ffa37ff317e1fbf85f30764616d5c1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 8 May 2024 15:06:28 +0200 Subject: [PATCH 075/332] #11430 Add trimming of header words to identify CSV as line based --- .../FileInterface/RifCsvUserDataParser.cpp | 4 +- .../UnitTests/ObservedDataParser-Test.cpp | 68 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp index c29812c736..0480a0306e 100644 --- a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp +++ b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp @@ -288,7 +288,9 @@ RifCsvUserDataParser::CsvLayout RifCsvUserDataParser::determineCsvLayout() { firstLine = dataStream->readLine(); if ( firstLine.isEmpty() ) continue; - headers = firstLine.split( ';' ); + + headers = RifFileParseTools::splitLineAndTrim( firstLine, ";" ); + if ( headers.size() < 3 || headers.size() > 5 ) continue; break; } diff --git a/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp b/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp index d1f5f055ab..f5afa8a9d3 100644 --- a/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp +++ b/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp @@ -442,6 +442,74 @@ DAYS;BARS;BARS;BARS ASSERT_EQ( column1->values.front(), 456.78 ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RifColumnBasedAsciiParserTest, LineBasedWithErrorCsv ) +{ + QString data = R"( +DATE ;VECTOR ;VALUE ;ERROR +2018-04-16 ;FOPT ;12.5 ;0.45 +2018-04-18 ;FOPT ;8.6 ;0.31 +2018-04-18 ;WOPT:BH-1 ;0.1 ;0.2 +)"; + + QTextStream out( &data ); + + RifCsvUserDataPastedTextParser parser = RifCsvUserDataPastedTextParser( data ); + parser.parse( {} ); + + auto tableData = parser.tableData(); + auto columnInfos = tableData.columnInfos(); + + ASSERT_EQ( columnInfos.size(), 4 ); + + // FOPT + ASSERT_EQ( columnInfos[0].values.size(), 2 ); + ASSERT_EQ( columnInfos[0].dateTimeValues.size(), 2 ); + + // FOPT_ERR + ASSERT_EQ( columnInfos[1].values.size(), 2 ); + ASSERT_EQ( columnInfos[1].dateTimeValues.size(), 2 ); + + // WOPT:BH-1 + ASSERT_EQ( columnInfos[2].values.size(), 1 ); + ASSERT_EQ( columnInfos[2].dateTimeValues.size(), 1 ); + + // WOPT:BH-1_ERR + ASSERT_EQ( columnInfos[3].values.size(), 1 ); + ASSERT_EQ( columnInfos[3].dateTimeValues.size(), 1 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RifColumnBasedAsciiParserTest, LineBasedCsv ) +{ + QString data = R"( +DATE ;VECTOR ;VALUE +2018-04-16 ;FOPT ;12.5 +2018-04-18 ;FOPT ;8.6 +2018-04-18 ;WOPT:BH-1 ;0.1 +)"; + + QTextStream out( &data ); + + RifCsvUserDataPastedTextParser parser = RifCsvUserDataPastedTextParser( data ); + parser.parse( {} ); + + auto tableData = parser.tableData(); + auto columnInfos = tableData.columnInfos(); + + ASSERT_EQ( columnInfos.size(), 2 ); + + ASSERT_EQ( columnInfos[0].values.size(), 2 ); + ASSERT_EQ( columnInfos[0].dateTimeValues.size(), 2 ); + + ASSERT_EQ( columnInfos[1].values.size(), 1 ); + ASSERT_EQ( columnInfos[1].dateTimeValues.size(), 1 ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- From 2ad6c0fff215933124ed89aeffbc1516050e5c67 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 10 May 2024 09:06:15 +0200 Subject: [PATCH 076/332] Set artifact retention-days to 5 The delete artifact action is no longer working, set retention-days to 5 --- .github/workflows/ResInsightWithCache.yml | 2 + .../ResInsightWithCacheManualPaths.yml | 207 ------------------ 2 files changed, 2 insertions(+), 207 deletions(-) delete mode 100644 .github/workflows/ResInsightWithCacheManualPaths.yml diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 13d30c5daa..6d6514d505 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -259,12 +259,14 @@ jobs: with: name: python-distribution path: GrpcInterface/Python/dist + retention-days: 5 - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: ResInsight-${{ matrix.config.name }} path: ${{ runner.workspace }}/ResInsight/cmakebuild/install + retention-days: 5 pypi-publish: name: Upload release to PyPI diff --git a/.github/workflows/ResInsightWithCacheManualPaths.yml b/.github/workflows/ResInsightWithCacheManualPaths.yml deleted file mode 100644 index 8008815cb7..0000000000 --- a/.github/workflows/ResInsightWithCacheManualPaths.yml +++ /dev/null @@ -1,207 +0,0 @@ -name: ResInsight Manual gRPC Paths - -on: - workflow_dispatch: - schedule: - # Once every night - - cron: "0 1 * * * " -env: - NINJA_VERSION: 1.9.0 - BUILD_TYPE: Release - BUILDCACHE_VERSION: 0.23.0 - BUILDCACHE_DIR: ${{ github.workspace }}/buildcache_dir - -jobs: - ResInsight-x64-buildcache: - runs-on: ${{ matrix.config.os }} - strategy: - fail-fast: false - matrix: - config: - - { - name: "Ubuntu 20.04", - os: ubuntu-20.04, - cc: "gcc", - cxx: "g++", - vcpkg-response-file: vcpkg_x64-linux.txt, - vcpkg-triplet: x64-linux, - cmake-toolchain: "ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake", - } - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: true - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.8" - - name: Display Python version - run: python -c "import sys; print(sys.version)" - - name: Download Ninja - uses: seanmiddleditch/gha-setup-ninja@master - with: - version: ${{ env.NINJA_VERSION }} - - name: Download buildcache - id: buildcache-download - shell: cmake -P {0} - run: | - if ("${{ runner.os }}" STREQUAL "Windows") - set(buildcache_suffix "win-msvc.zip") - elseif ("${{ runner.os }}" STREQUAL "Linux") - set(buildcache_suffix "linux.tar.gz") - endif() - - set(buildcache_version $ENV{BUILDCACHE_VERSION}) - set(buildcache_url "https://github.com/mbitsnbites/buildcache/releases/download/v${buildcache_version}/buildcache-${buildcache_suffix}") - file(DOWNLOAD "${buildcache_url}" ./buildcache.zip) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./buildcache.zip) - - if (NOT "${{ runner.os }}" STREQUAL "Windows") - execute_process( - COMMAND chmod +x buildcache/bin/buildcache - ) - endif() - - - name: Prepare cache timestamp - id: cache_timestamp_string - shell: cmake -P {0} - run: | - string(TIMESTAMP current_date "%Y-%m-%d" UTC) - message("::set-output name=timestamp::${current_date}") - - name: Cache Buildcache - id: cache-buildcache - uses: actions/cache@v2 - with: - path: ${{ env.BUILDCACHE_DIR }} - key: ${{ matrix.config.name }}-cache-v02-${{ steps.cache_timestamp_string.outputs.timestamp }} - - name: Create Folder for buildcache - run: New-Item ${{ env.BUILDCACHE_DIR }} -ItemType "directory" -Force - shell: pwsh - - name: Add buildcache to system path - run: echo "${{github.workspace}}/buildcache/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 - shell: pwsh - - - name: Cache Qt - id: cache-qt - uses: actions/cache@v2 - with: - path: ${{ github.workspace }}/Qt/ - key: ${{ matrix.config.os }}-QtCache-5-12-12 - - name: Install Qt - uses: jurplel/install-qt-action@v2 - with: - version: 5.12.12 - modules: qtscript qtcharts - dir: "${{ github.workspace }}/Qt/" - cached: ${{ steps.cache-qt.outputs.cache-hit }} - - name: Install Linux dependencies - if: "contains( matrix.config.os, 'ubuntu')" - run: sudo apt-get install libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev libhdf5-dev - - name: Get Python executable path - id: python-path - run: echo "::set-output name=PYTHON_EXECUTABLE::$(python -c 'import sys; import pathlib; print (pathlib.PurePath(sys.executable).as_posix())')" - - name: Print Python path - run: echo ${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} - - - name: Set vcpkg's response file path used as part of cache's key. - uses: lukka/set-shell-env@master - with: - VCPKGRESPONSEFILE: ${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }} - - name: Run vcpkg - uses: lukka/run-vcpkg@v5 - id: runvcpkg - with: - vcpkgArguments: "@${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}" - vcpkgDirectory: - "${{ github.workspace }}/ThirdParty/vcpkg" - # Ensure the cache key changes any time the content of the response file changes. - appendedCacheKey: ${{ hashFiles(env.VCPKGRESPONSEFILE) }} - - - name: Configure - shell: cmake -P {0} - run: | - set(ENV{CC} ${{ matrix.config.cc }}) - set(ENV{CXX} ${{ matrix.config.cxx }}) - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - execute_process( - COMMAND "${{ matrix.config.environment_script }}" && set - OUTPUT_FILE environment_script_output.txt - ) - file(STRINGS environment_script_output.txt output_lines) - foreach(line IN LISTS output_lines) - if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") - set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - endif() - endforeach() - endif() - set(path_separator ":") - if ("${{ runner.os }}" STREQUAL "Windows") - set(path_separator ";") - endif() - set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") - - execute_process( - COMMAND cmake - -S . - -B cmakebuild - -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} - -D CMAKE_INSTALL_PREFIX=cmakebuild/install - -D RESINSIGHT_ENABLE_UNITY_BUILD=true - -D RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true - -D RESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true - -D RESINSIGHT_ENABLE_GRPC=true - -D Eigen3_DIR=${{ github.workspace }}/ThirdParty/vcpkg/installed/x64-linux/share/eigen3 - -D Boost_INCLUDE_DIR=${{ github.workspace }}/ThirdParty/vcpkg/installed/x64-linux/include - -D RESINSIGHT_GRPC_INSTALL_PREFIX=${{ github.workspace }}/ThirdParty/vcpkg/installed/x64-linux - -D RESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} - -D RESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE=true - -D VCPKG_AUTO_INSTALL=false - -G Ninja - RESULT_VARIABLE result - ) - if (NOT result EQUAL 0) - message(FATAL_ERROR "Bad exit status") - endif() - - name: Build - shell: cmake -P {0} - run: | - set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - file(STRINGS environment_script_output.txt output_lines) - foreach(line IN LISTS output_lines) - if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") - set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - endif() - endforeach() - endif() - set(path_separator ":") - if ("${{ runner.os }}" STREQUAL "Windows") - set(path_separator ";") - endif() - execute_process( - COMMAND cmake --build cmakebuild --target install - RESULT_VARIABLE result - ) - if (NOT result EQUAL 0) - message(FATAL_ERROR "Bad exit status") - endif() - - - name: Stats for buildcache - run: ${{ github.workspace }}/buildcache/bin/buildcache -s - - - name: Run Unit Tests - shell: bash - run: | - cmakebuild/ApplicationExeCode/ResInsight --unittest - - name: Run pytest - env: - RESINSIGHT_EXECUTABLE: ${{ runner.workspace }}/ResInsight/cmakebuild/ApplicationExeCode/ResInsight - run: | - cd GrpcInterface/Python/rips - ${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} -m pytest --console - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: ResInsight-${{ matrix.config.name }} - path: ${{ runner.workspace }}/ResInsight/cmakebuild/install From b8391e6f92b6d63e05984ce8f4cd856969d43afb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 13 May 2024 08:34:27 +0200 Subject: [PATCH 077/332] Remove pure virtual from RimPlotCurve Make it possible to use RimPlotCurve directly. Remove depnendencies on special implementation in derived classes. --- ...icPasteAsciiDataToSummaryPlotFeatureUi.cpp | 2 + .../AnalysisPlots/RimPlotDataFilterItem.cpp | 1 + .../RimParameterResultCrossPlot.cpp | 1 + .../Flow/RimWellFlowRateCurve.cpp | 2 + .../ProjectDataModel/RimPlotCurve.cpp | 106 +++++++++--------- .../ProjectDataModel/RimPlotCurve.h | 25 +++-- .../Summary/RimSummaryAddress.cpp | 4 - .../Summary/RimSummaryAddress.h | 2 +- .../Summary/RimSummaryCurve.cpp | 59 ++++++++++ .../Summary/RimSummaryCurve.h | 2 + .../UserInterface/RiuGridCrossQwtPlot.cpp | 1 + .../RiuWellPathComponentPlotItem.cpp | 11 +- .../RiuWellPathComponentPlotItem.h | 8 +- 13 files changed, 135 insertions(+), 89 deletions(-) diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp index 1577c00446..066b77f7a7 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp @@ -21,6 +21,8 @@ #include "RiaTextStringTools.h" #include "RifCsvUserDataParser.h" +#include "RiuQwtSymbol.h" + #include "cafPdmUiItem.h" #include "cafPdmUiTextEditor.h" diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp index 612d97c63a..8ac9c6b181 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimPlotDataFilterItem.h" +#include "RiaCurveDataTools.h" #include "RiaResultNames.h" #include "RifSummaryReaderInterface.h" diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp index 43497377f4..7d3c8661cd 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp @@ -42,6 +42,7 @@ #include "RiuPlotCurve.h" #include "RiuPlotMainWindowTools.h" #include "RiuQwtPlotCurve.h" +#include "RiuQwtSymbol.h" #include "RiuSummaryQwtPlot.h" #include "RiuSummaryVectorSelectionDialog.h" diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp index 8450c689a5..b3f87e67f5 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp @@ -32,6 +32,8 @@ #include "qwt_plot.h" +#include + #include //================================================================================================== diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp index 52c4784268..2a87cd874e 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp @@ -23,32 +23,22 @@ #include "RiaGuiApplication.h" #include "RiaPreferences.h" -#include "RimEnsembleCurveSet.h" -#include "RimEnsembleCurveSetCollection.h" -#include "RimMultiPlot.h" #include "RimNameConfig.h" #include "RimPlotRectAnnotation.h" +#include "RimPlotWindow.h" #include "RimProject.h" -#include "RimSummaryCurve.h" -#include "RimSummaryCurveCollection.h" -#include "RimSummaryPlot.h" #include "RiuGuiTheme.h" #include "RiuPlotCurve.h" #include "RiuPlotCurveSymbol.h" -#include "RiuPlotMainWindowTools.h" #include "RiuPlotWidget.h" #include "cafAssert.h" #include "cafPdmUiColorEditor.h" -#include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiTreeAttributes.h" #include "cafPdmUiTreeSelectionEditor.h" -#include - -// NB! Special macro for pure virtual class -CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotCurve, "PlotCurve" ); +CAF_PDM_SOURCE_INIT( RimPlotCurve, "PlotCurve" ); //-------------------------------------------------------------------------------------------------- /// @@ -244,6 +234,14 @@ bool RimPlotCurve::isCurveNameTemplateSupported() const return !supportedCurveNameVariables().isEmpty(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimPlotCurve::createCurveAutoName() +{ + return "Default Curve Name"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -252,6 +250,24 @@ QStringList RimPlotCurve::supportedCurveNameVariables() const return {}; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::updateZoomInParentPlot() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::onLoadDataAndUpdate( bool updateParentPlot ) +{ + if ( updateParentPlot && m_parentPlot ) + { + m_parentPlot->scheduleReplot(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -549,17 +565,7 @@ bool RimPlotCurve::canCurveBeAttached() const return false; } - bool isVisibleInPossibleParent = true; - - { - auto summaryCurveCollection = firstAncestorOrThisOfType(); - if ( summaryCurveCollection ) isVisibleInPossibleParent = summaryCurveCollection->isCurvesVisible(); - - auto ensembleCurveSet = firstAncestorOrThisOfType(); - if ( ensembleCurveSet ) isVisibleInPossibleParent = ensembleCurveSet->isCurvesVisible(); - } - - return isVisibleInPossibleParent; + return true; } //-------------------------------------------------------------------------------------------------- @@ -893,38 +899,7 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() { if ( !m_plotCurve ) return; - auto ensembleCurveSet = firstAncestorOrThisOfType(); - if ( ensembleCurveSet ) - { - return; - } - - bool showLegendInPlot = m_showLegend(); - - auto summaryPlot = firstAncestorOrThisOfType(); - if ( summaryPlot ) - { - bool anyCalculated = false; - for ( const auto c : summaryPlot->summaryCurves() ) - { - if ( c->summaryAddressY().isCalculated() ) - { - // Never hide the legend for calculated curves, as the curve legend is used to - // show some essential auto generated data - anyCalculated = true; - } - } - - auto isMultiPlot = ( firstAncestorOrThisOfType() != nullptr ); - - if ( !anyCalculated && isMultiPlot && summaryPlot->ensembleCurveSetCollection()->curveSets().empty() && summaryPlot->curveCount() == 1 ) - { - // Disable display of legend if the summary plot has only one single curve - showLegendInPlot = false; - } - } - - m_plotCurve->setVisibleInLegend( showLegendInPlot ); + m_plotCurve->setVisibleInLegend( m_showLegend() ); } //-------------------------------------------------------------------------------------------------- @@ -1238,6 +1213,14 @@ void RimPlotCurve::deletePlotCurve() m_plotCurve = nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotCurve* RimPlotCurve::plotCurve() const +{ + return m_plotCurve; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1286,3 +1269,16 @@ void RimPlotCurve::onColorTagClicked( const SignalEmitter* emitter, size_t index m_curveAppearance->setColorWithFieldChanged( newColor ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" ); + RimPlotCurve::appearanceUiOrdering( *appearanceGroup ); + caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Curve Name" ); + nameGroup->add( &m_curveName ); + nameGroup->add( &m_showLegend ); + uiOrdering.skipRemainingFields( true ); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h index 79a96e9fe7..91fea83e54 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h @@ -24,7 +24,6 @@ #include "RiuPlotAxis.h" #include "RiuQwtPlotCurveDefines.h" -#include "RiuQwtSymbol.h" #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" @@ -34,7 +33,6 @@ #include "cafPdmPtrArrayField.h" #include -#include class RiuPlotCurve; class RiuPlotWidget; @@ -104,7 +102,7 @@ class RimPlotCurve : public caf::PdmObject virtual void updateCurveVisibility(); void updateLegendEntryVisibilityAndPlotLegend(); - void updateLegendEntryVisibilityNoPlotUpdate(); + virtual void updateLegendEntryVisibilityNoPlotUpdate(); virtual void replotParentPlot(); bool showInLegend() const; @@ -133,21 +131,22 @@ class RimPlotCurve : public caf::PdmObject void setParentPlotNoReplot( RiuPlotWidget* ); void setParentPlotAndReplot( RiuPlotWidget* ); - void attach( RiuPlotWidget* ); - void detach( bool deletePlotCurve = false ); - void reattach(); - bool isSameCurve( const RiuPlotCurve* plotCurve ) const; - void deletePlotCurve(); + void attach( RiuPlotWidget* ); + void detach( bool deletePlotCurve = false ); + void reattach(); + bool isSameCurve( const RiuPlotCurve* plotCurve ) const; + void deletePlotCurve(); + RiuPlotCurve* plotCurve() const; std::vector rectAnnotations() const; protected: - virtual QString createCurveAutoName() = 0; + virtual QString createCurveAutoName(); virtual QStringList supportedCurveNameVariables() const; - virtual void updateZoomInParentPlot() = 0; - virtual void onLoadDataAndUpdate( bool updateParentPlot ) = 0; + virtual void updateZoomInParentPlot(); + virtual void onLoadDataAndUpdate( bool updateParentPlot ); void initAfterRead() override; void updateCurvePresentation( bool updatePlotLegendAndTitle ); @@ -181,7 +180,7 @@ class RimPlotCurve : public caf::PdmObject void onCurveAppearanceChanged( const caf::SignalEmitter* emitter ); virtual void onFillColorChanged( const caf::SignalEmitter* emitter ); - bool canCurveBeAttached() const; + virtual bool canCurveBeAttached() const; virtual void clearErrorBars(); void checkAndApplyDefaultFillColor(); @@ -192,6 +191,8 @@ class RimPlotCurve : public caf::PdmObject void onColorTagClicked( const SignalEmitter* emitter, size_t index ); + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + private: bool isCurveNameTemplateSupported() const; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp index cefc8e4678..b8d67a5c4d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp @@ -20,10 +20,6 @@ #include "RiaSummaryDefines.h" -#include "RimProject.h" -#include "RimSummaryCalculation.h" -#include "RimSummaryCalculationCollection.h" - #include namespace caf diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h index 20088ee191..5974d77632 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h @@ -25,8 +25,8 @@ #include "cafPdmPtrField.h" #include "RiaDefines.h" + #include "RifEclipseSummaryAddressQMetaType.h" -#include "RimPlotCurve.h" #include "cafAppEnum.h" diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index dcac98d73d..25cd2539b5 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -1389,3 +1389,62 @@ void RimSummaryCurve::calculateCurveInterpolationFromAddress() void RimSummaryCurve::updateTimeAnnotations() { } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurve::updateLegendEntryVisibilityNoPlotUpdate() +{ + if ( !m_plotCurve ) return; + + auto ensembleCurveSet = firstAncestorOrThisOfType(); + if ( ensembleCurveSet ) + { + return; + } + + bool showLegendInPlot = m_showLegend(); + + auto summaryPlot = firstAncestorOrThisOfType(); + if ( summaryPlot ) + { + bool anyCalculated = false; + for ( const auto c : summaryPlot->summaryCurves() ) + { + if ( c->summaryAddressY().isCalculated() ) + { + // Never hide the legend for calculated curves, as the curve legend is used to + // show some essential auto generated data + anyCalculated = true; + } + } + + auto isMultiPlot = ( firstAncestorOrThisOfType() != nullptr ); + + if ( !anyCalculated && isMultiPlot && summaryPlot->ensembleCurveSetCollection()->curveSets().empty() && summaryPlot->curveCount() == 1 ) + { + // Disable display of legend if the summary plot has only one single curve + showLegendInPlot = false; + } + } + + m_plotCurve->setVisibleInLegend( showLegendInPlot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryCurve::canCurveBeAttached() const +{ + if ( !RimPlotCurve::canCurveBeAttached() ) return false; + + bool isVisibleInPossibleParent = true; + + auto summaryCurveCollection = firstAncestorOrThisOfType(); + if ( summaryCurveCollection ) isVisibleInPossibleParent = summaryCurveCollection->isCurvesVisible(); + + auto ensembleCurveSet = firstAncestorOrThisOfType(); + if ( ensembleCurveSet ) isVisibleInPossibleParent = ensembleCurveSet->isCurvesVisible(); + + return isVisibleInPossibleParent; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h index 50041a8f93..9e9dc33acd 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h @@ -106,6 +106,7 @@ class RimSummaryCurve : public RimStackablePlotCurve RiaDefines::PhaseType phaseType() const override; virtual bool isRegressionCurve() const; + void updateLegendEntryVisibilityNoPlotUpdate() override; protected: // RimPlotCurve overrides @@ -124,6 +125,7 @@ class RimSummaryCurve : public RimStackablePlotCurve virtual std::vector timeStepsX() const; virtual void updateTimeAnnotations(); + bool canCurveBeAttached() const override; // Overridden PDM methods void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp b/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp index f981e06f49..e3d993e8b4 100644 --- a/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp @@ -37,6 +37,7 @@ #include "RiuQwtPlotTools.h" #include "RiuQwtPlotWheelZoomer.h" #include "RiuQwtPlotZoomer.h" +#include "RiuQwtSymbol.h" #include "RiuWidgetDragger.h" #include "cafCmdFeatureMenuBuilder.h" diff --git a/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.cpp b/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.cpp index 18b2cb5af9..7a1f33cf52 100644 --- a/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.cpp +++ b/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.cpp @@ -23,29 +23,20 @@ #include "RiaPlotDefines.h" #include "RimDepthTrackPlot.h" -#include "RimFishbones.h" -#include "RimFracture.h" -#include "RimFractureTemplate.h" -#include "RimPerforationInterval.h" #include "RimWellLogPlot.h" -#include "RimWellLogTrack.h" #include "RimWellPath.h" #include "RimWellPathAttribute.h" #include "RimWellPathAttributeCollection.h" #include "RimWellPathValve.h" #include "RigWellPath.h" -#include "RiuPlotAxis.h" #include "RiuQwtPlotTools.h" +#include "RiuQwtSymbol.h" #include "qwt_plot.h" #include "qwt_plot_marker.h" -#include "qwt_plot_shapeitem.h" #include "qwt_text.h" -#include -#include - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.h b/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.h index b68d30e91e..8800c04367 100644 --- a/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.h +++ b/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.h @@ -21,19 +21,13 @@ #include "RiaDefines.h" #include "RiuQwtPlotItemGroup.h" -#include "RimPlotCurve.h" #include "RimWellLogPlot.h" -#include "RimWellPathAttribute.h" #include "RimWellPathComponentInterface.h" -#include "cafPdmBase.h" -#include "cafPdmObject.h" -#include "cafPdmPtrField.h" +#include "RiuPlotCurveSymbol.h" #include "cvfColor4.h" -#include "cvfObject.h" -#include #include class RigWellLogCurveData; From ff9b13163a316d585748f590a360e5032b715dd2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 13 May 2024 08:54:40 +0200 Subject: [PATCH 078/332] Add RimVfpTableData used to represent connection to file and data Extract data management from RimVfpPlot. Use pointer from RimVfpPlot to RimVfpTableData. --- .../Commands/CMakeLists_files.cmake | 2 + .../Commands/RicDeleteSubItemsFeature.cpp | 22 + .../Commands/RicImportVfpDataFeature.cpp | 54 +- .../Commands/RicImportVfpDataFeature.h | 1 - .../Commands/RicNewVfpPlotFeature.cpp | 59 ++ .../Commands/RicNewVfpPlotFeature.h | 33 + .../RicDeleteSubPlotFeature.cpp | 25 +- .../WellLogCommands/RicDeleteSubPlotFeature.h | 1 + .../ProjectDataModel/RiaOpmParserTools.cpp | 88 --- .../ProjectDataModel/RiaOpmParserTools.h | 2 - .../ProjectDataModel/RimOilField.cpp | 4 + .../ProjectDataModel/RimOilField.h | 2 + .../ProjectDataModel/RimProject.cpp | 6 + .../Summary/RimSummaryCurve.cpp | 11 +- .../CMakeLists_files.cmake | 4 + .../RimVfpDataCollection.cpp | 73 ++ .../RimVfpDataCollection.h | 46 ++ .../VerticalFlowPerformance/RimVfpDeck.cpp | 114 ++-- .../VerticalFlowPerformance/RimVfpDeck.h | 14 +- .../VerticalFlowPerformance/RimVfpPlot.cpp | 642 ++++++------------ .../VerticalFlowPerformance/RimVfpPlot.h | 87 +-- .../RimVfpPlotCollection.cpp | 86 ++- .../RimVfpPlotCollection.h | 11 +- .../RimVfpTableData.cpp | 126 ++++ .../VerticalFlowPerformance/RimVfpTableData.h | 55 ++ .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../ReservoirDataModel/RigVfpTables.cpp | 569 ++++++++++++++++ .../ReservoirDataModel/RigVfpTables.h | 157 +++++ 28 files changed, 1585 insertions(+), 711 deletions(-) create mode 100644 ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp create mode 100644 ApplicationLibCode/Commands/RicNewVfpPlotFeature.h create mode 100644 ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.h create mode 100644 ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.h create mode 100644 ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp create mode 100644 ApplicationLibCode/ReservoirDataModel/RigVfpTables.h diff --git a/ApplicationLibCode/Commands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/CMakeLists_files.cmake index 1dc49cca3f..9404013634 100644 --- a/ApplicationLibCode/Commands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/CMakeLists_files.cmake @@ -95,6 +95,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCalculationExpressionsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicImportWellLogCsvFileFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewViewForGridEnsembleFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -193,6 +194,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCalculationExpressionsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportWellLogCsvFileFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewViewForGridEnsembleFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.cpp ) if(RESINSIGHT_USE_QT_CHARTS) diff --git a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp index d0608ab62c..aa3dca2c0d 100644 --- a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp @@ -27,6 +27,7 @@ #include "RimWellPathFractureCollection.h" #include "cafPdmUiItem.h" +#include "cafPdmUiObjectHandle.h" #include "cafSelectionManager.h" #include @@ -115,6 +116,14 @@ bool RicDeleteSubItemsFeature::hasDeletableSubItems( caf::PdmUiItem* uiItem ) } } + { + auto collection = dynamic_cast( uiItem ); + if ( collection && collection->plotCount() > 0 ) + { + return true; + } + } + return false; } @@ -227,5 +236,18 @@ void RicDeleteSubItemsFeature::deleteSubItems( bool onlyDeleteUnchecked ) if ( proj ) proj->reloadCompletionTypeResultsInAllViews(); } } + + { + auto collection = dynamic_cast( item ); + if ( collection ) + { + collection->deleteAllPlots(); + + if ( auto objHandle = dynamic_cast( item ) ) + { + objHandle->updateConnectedEditors(); + } + } + } } } diff --git a/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp b/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp index 997de63cc0..06920c73bc 100644 --- a/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp @@ -23,6 +23,7 @@ #include "RimMainPlotCollection.h" +#include "VerticalFlowPerformance/RimVfpDataCollection.h" #include "VerticalFlowPerformance/RimVfpDeck.h" #include "VerticalFlowPerformance/RimVfpPlot.h" #include "VerticalFlowPerformance/RimVfpPlotCollection.h" @@ -38,15 +39,6 @@ CAF_CMD_SOURCE_INIT( RicImportVfpDataFeature, "RicImportVfpDataFeature" ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicImportVfpDataFeature::isCommandEnabled() const -{ - auto plotColl = caf::firstAncestorOfTypeFromSelectedObject(); - return ( plotColl != nullptr ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -83,47 +75,17 @@ void RicImportVfpDataFeature::onActionTriggered( bool isChecked ) std::vector vfpPlots; std::vector vfpDecks; - for ( const auto& fileName : fileNames ) - { - if ( fileName.contains( ".DATA" ) ) - { - auto vfpDeck = vfpPlotColl->addDeck( fileName ); - vfpDecks.push_back( vfpDeck ); - } - else - { - auto vfpPlot = new RimVfpPlot(); - vfpPlot->setFileName( fileName ); - vfpPlotColl->addPlot( vfpPlot ); - - vfpPlots.push_back( vfpPlot ); - } - } - - vfpPlotColl->updateConnectedEditors(); + auto vfpDataColl = RimVfpDataCollection::instance(); - for ( auto deck : vfpDecks ) - { - deck->loadDataAndUpdate(); - deck->updateConnectedEditors(); - } - - for ( auto plot : vfpPlots ) - { - plot->loadDataAndUpdate(); - } - - RiuPlotMainWindowTools::showPlotMainWindow(); - - if ( !vfpPlots.empty() ) + for ( const auto& fileName : fileNames ) { - RiuPlotMainWindowTools::onObjectAppended( vfpPlots.front() ); + auto vfpDataSource = vfpDataColl->appendTableDataObject( fileName ); + auto firstPlot = vfpPlotColl->createAndAppendPlots( vfpDataSource ); + vfpDataColl->updateAllRequiredEditors(); + RiuPlotMainWindowTools::onObjectAppended( firstPlot, firstPlot ); } - if ( !vfpDecks.empty() ) - { - RiuPlotMainWindowTools::onObjectAppended( vfpDecks.front() ); - } + vfpPlotColl->updateAllRequiredEditors(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicImportVfpDataFeature.h b/ApplicationLibCode/Commands/RicImportVfpDataFeature.h index 801d8545f0..e7af6a103b 100644 --- a/ApplicationLibCode/Commands/RicImportVfpDataFeature.h +++ b/ApplicationLibCode/Commands/RicImportVfpDataFeature.h @@ -28,7 +28,6 @@ class RicImportVfpDataFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; private: - bool isCommandEnabled() const override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; }; diff --git a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp new file mode 100644 index 0000000000..90a21871db --- /dev/null +++ b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RicNewVfpPlotFeature.h" + +#include "RimMainPlotCollection.h" + +#include "VerticalFlowPerformance/RimVfpDataCollection.h" +#include "VerticalFlowPerformance/RimVfpPlotCollection.h" +#include "VerticalFlowPerformance/RimVfpTableData.h" + +#include "cafSelectionManagerTools.h" + +#include "RiuPlotMainWindowTools.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewVfpPlotFeature, "RicNewVfpPlotFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewVfpPlotFeature::onActionTriggered( bool isChecked ) +{ + RimVfpPlotCollection* vfpPlotColl = RimMainPlotCollection::current()->vfpPlotCollection(); + if ( !vfpPlotColl ) return; + + auto selectedTableData = caf::selectedObjectsByTypeStrict(); + for ( auto tableData : selectedTableData ) + { + RimVfpPlot* firstPlot = vfpPlotColl->createAndAppendPlots( tableData ); + vfpPlotColl->updateConnectedEditors(); + RiuPlotMainWindowTools::onObjectAppended( firstPlot, firstPlot ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewVfpPlotFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Create VFP Plot" ); + actionToSetup->setIcon( QIcon( ":/VfpPlot.svg" ) ); +} diff --git a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h new file mode 100644 index 0000000000..300d859e15 --- /dev/null +++ b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicNewVfpPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp index adcc733e7f..1dfec8002a 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp @@ -44,10 +44,7 @@ bool RicDeleteSubPlotFeature::isCommandEnabled() const { if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return false; - std::vector selection; - getSelection( selection ); - - return ( !selection.empty() ); + return isAnyDeletablePlotSelected(); } //-------------------------------------------------------------------------------------------------- @@ -150,3 +147,23 @@ void RicDeleteSubPlotFeature::getSelection( std::vector& selection ) c caf::SelectionManager::instance()->objectsByType( &selection ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDeleteSubPlotFeature::isAnyDeletablePlotSelected() const +{ + std::vector selection; + getSelection( selection ); + + for ( RimPlot* plot : selection ) + { + if ( !plot ) continue; + + RimMultiPlot* multiPlot = plot->firstAncestorOrThisOfType(); + RimWellLogPlot* wellLogPlot = plot->firstAncestorOrThisOfType(); + if ( multiPlot || wellLogPlot ) return true; + } + + return false; +} diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h index 1a9ce940cb..6c75d58172 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h @@ -39,4 +39,5 @@ class RicDeleteSubPlotFeature : public caf::CmdFeature private: void getSelection( std::vector& selection ) const; + bool isAnyDeletablePlotSelected() const; }; diff --git a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp index 36b08bac54..e05f7e8ec0 100644 --- a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp @@ -85,94 +85,6 @@ Opm::VFPProdTable createProductionTable( const Opm::DeckKeyword& keyword ) return { keyword, gaslift_opt_active, unitSystem }; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector extractVfpInjectionTables( const std::string& filename ) -{ - std::vector tables; - - try - { - Opm::Parser parser( false ); - const ::Opm::ParserKeywords::VFPINJ kw1; - const ::Opm::ParserKeywords::VFPIDIMS kw2; - - parser.addParserKeyword( kw1 ); - parser.addParserKeyword( kw2 ); - - auto deck = parser.parseFile( filename ); - - std::string keyword = ::Opm::ParserKeywords::VFPINJ::keywordName; - auto keywordList = deck.getKeywordList( keyword ); - for ( auto kw : keywordList ) - { - auto table = createInjectionTable( *kw ); - tables.push_back( table ); - } - } - catch ( Opm::OpmInputError& e ) - { - QString text = QString( "Error detected when parsing '%1'. Imported data might be missing or incomplete.\n%2" ) - .arg( QString::fromStdString( filename ) ) - .arg( QString::fromStdString( e.what() ) ); - - RiaLogging::warning( text ); - } - catch ( ... ) - { - QString text = - QString( "Error detected when parsing '%1'. Imported data might be missing or incomplete." ).arg( QString::fromStdString( filename ) ); - - RiaLogging::warning( text ); - } - - return tables; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector extractVfpProductionTables( const std::string& filename ) -{ - std::vector tables; - - try - { - Opm::Parser parser( false ); - const ::Opm::ParserKeywords::VFPPROD kw1; - - parser.addParserKeyword( kw1 ); - - auto deck = parser.parseFile( filename ); - - std::string keyword = ::Opm::ParserKeywords::VFPPROD::keywordName; - auto keywordList = deck.getKeywordList( keyword ); - for ( auto kw : keywordList ) - { - auto table = createProductionTable( *kw ); - tables.push_back( table ); - } - } - catch ( Opm::OpmInputError& e ) - { - QString text = QString( "Error detected when parsing '%1'. Imported data might be missing or incomplete.\n%2" ) - .arg( QString::fromStdString( filename ) ) - .arg( QString::fromStdString( e.what() ) ); - - RiaLogging::warning( text ); - } - catch ( ... ) - { - QString text = - QString( "Error detected when parsing '%1'. Imported data might be missing or incomplete." ).arg( QString::fromStdString( filename ) ); - - RiaLogging::warning( text ); - } - - return tables; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.h b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.h index 0841fb579a..c1a75d4b49 100644 --- a/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.h +++ b/ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.h @@ -30,8 +30,6 @@ //-------------------------------------------------------------------------------------------------- namespace RiaOpmParserTools { -std::vector extractVfpInjectionTables( const std::string& filename ); -std::vector extractVfpProductionTables( const std::string& filename ); std::pair, std::vector> extractVfpTablesFromDataFile( const std::string& dataDeckFilename ); diff --git a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp index 0497cf065f..58355cdd4c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp @@ -38,6 +38,7 @@ #include "RimWellPathCollection.h" #include "Polygons/RimPolygonCollection.h" +#include "VerticalFlowPerformance/RimVfpDataCollection.h" CAF_PDM_SOURCE_INIT( RimOilField, "ResInsightOilField" ); //-------------------------------------------------------------------------------------------------- @@ -93,6 +94,9 @@ RimOilField::RimOilField() ensembleWellLogsCollection = new RimEnsembleWellLogsCollection(); polygonCollection = new RimPolygonCollection(); + CAF_PDM_InitFieldNoDefault( &vfpDataCollection, "VfpDataCollection", "VFP Data" ); + vfpDataCollection = new RimVfpDataCollection(); + m_fractureTemplateCollection_OBSOLETE = new RimFractureTemplateCollection; m_fractureTemplateCollection_OBSOLETE.xmlCapability()->setIOWritable( false ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimOilField.h b/ApplicationLibCode/ProjectDataModel/RimOilField.h index 246ad5ea0f..2974ea42c7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimOilField.h +++ b/ApplicationLibCode/ProjectDataModel/RimOilField.h @@ -44,6 +44,7 @@ class RimEnsembleWellLogsCollection; class RimPolygonCollection; class RimEclipseViewCollection; class RimEclipseContourMapViewCollection; +class RimVfpDataCollection; //================================================================================================== /// @@ -79,6 +80,7 @@ class RimOilField : public caf::PdmObject caf::PdmChildField ensembleWellLogsCollection; caf::PdmChildField polygonCollection; caf::PdmChildField eclipseContourMapCollection; + caf::PdmChildField vfpDataCollection; protected: void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 99ff1d34f5..c6dd1c33a6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -99,6 +99,8 @@ #include "RimWellLogPlotCollection.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" + +#include "VerticalFlowPerformance/RimVfpDataCollection.h" #include "VerticalFlowPerformance/RimVfpPlotCollection.h" #include "Tools/RiaVariableMapper.h" @@ -1458,6 +1460,10 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q { uiTreeOrdering.add( oilField->ensembleWellLogsCollection() ); } + if ( oilField->vfpDataCollection() ) + { + uiTreeOrdering.add( oilField->vfpDataCollection() ); + } } } else if ( uiConfigName == "PlotWindow.Scripts" || uiConfigName == "MainWindow.Scripts" ) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 25cd2539b5..7a63fbeefb 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -1396,17 +1396,10 @@ void RimSummaryCurve::updateTimeAnnotations() void RimSummaryCurve::updateLegendEntryVisibilityNoPlotUpdate() { if ( !m_plotCurve ) return; - - auto ensembleCurveSet = firstAncestorOrThisOfType(); - if ( ensembleCurveSet ) - { - return; - } + if ( !firstAncestorOrThisOfType() ) return; bool showLegendInPlot = m_showLegend(); - - auto summaryPlot = firstAncestorOrThisOfType(); - if ( summaryPlot ) + if ( auto summaryPlot = firstAncestorOrThisOfType() ) { bool anyCalculated = false; for ( const auto c : summaryPlot->summaryCurves() ) diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake index b2d2b68a31..b1fbee6cef 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake @@ -3,6 +3,8 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimVfpDeck.h ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimVfpTableData.h + ${CMAKE_CURRENT_LIST_DIR}/RimVfpDataCollection.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -10,6 +12,8 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimVfpTableData.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimVfpDataCollection.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.cpp new file mode 100644 index 0000000000..44fda4eb84 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.cpp @@ -0,0 +1,73 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimVfpDataCollection.h" + +#include "RimOilField.h" +#include "RimProject.h" +#include "RimVfpPlotCollection.h" +#include "RimVfpTableData.h" + +CAF_PDM_SOURCE_INIT( RimVfpDataCollection, "RimVfpDataCollection" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpDataCollection::RimVfpDataCollection() +{ + CAF_PDM_InitObject( "VFP Data", ":/VfpPlotCollection.svg" ); + + CAF_PDM_InitFieldNoDefault( &m_vfpTableData, "VfpPlots", "Vertical Flow Performance Data" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpDataCollection* RimVfpDataCollection::instance() +{ + return RimProject::current()->activeOilField()->vfpDataCollection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpTableData* RimVfpDataCollection::appendTableDataObject( const QString& fileName ) +{ + auto* vfpTableData = new RimVfpTableData(); + vfpTableData->setFileName( fileName ); + + m_vfpTableData.push_back( vfpTableData ); + + return vfpTableData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimVfpDataCollection::vfpTableData() const +{ + return m_vfpTableData.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpDataCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + RimVfpPlotCollection::addImportItems( menuBuilder ); +} diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.h new file mode 100644 index 0000000000..a5afebf70c --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "cafPdmChildArrayField.h" +#include "cafPdmObject.h" + +class RimVfpTableData; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimVfpDataCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimVfpDataCollection(); + + static RimVfpDataCollection* instance(); + + RimVfpTableData* appendTableDataObject( const QString& fileName ); + std::vector vfpTableData() const; + +private: + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; + +private: + caf::PdmChildArrayField m_vfpTableData; +}; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp index e8a0780892..3e9ce414d4 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp @@ -18,14 +18,14 @@ #include "RimVfpDeck.h" -#include "RiaOpmParserTools.h" +#include "RigVfpTables.h" +#include "RimVfpDataCollection.h" #include "RimVfpPlotCollection.h" +#include "RimVfpTableData.h" #include "cafPdmUiTreeOrdering.h" -#include - CAF_PDM_SOURCE_INIT( RimVfpDeck, "RimVfpDeck" ); //-------------------------------------------------------------------------------------------------- @@ -35,7 +35,7 @@ RimVfpDeck::RimVfpDeck() { CAF_PDM_InitObject( "VFP Plot", ":/VfpPlot.svg" ); - CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path" ); + CAF_PDM_InitFieldNoDefault( &m_vfpTableData, "VfpTableData", "VFP Data Source" ); CAF_PDM_InitFieldNoDefault( &m_vfpPlotCollection, "VfpPlotCollection", "Plot Collection" ); m_vfpPlotCollection = new RimVfpPlotCollection(); @@ -45,9 +45,9 @@ RimVfpDeck::RimVfpDeck() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpDeck::setFileName( const QString& filename ) +void RimVfpDeck::setDataSource( RimVfpTableData* tableData ) { - m_filePath = filename; + m_vfpTableData = tableData; } //-------------------------------------------------------------------------------------------------- @@ -57,50 +57,40 @@ void RimVfpDeck::loadDataAndUpdate() { updateObjectName(); - auto createRimVfpPlot = [&]() -> RimVfpPlot* - { - auto plot = new RimVfpPlot(); - plot->setFileName( m_filePath().path() ); - return plot; - }; - std::vector currentPlots = m_vfpPlotCollection->plots(); - auto [vfpProdTables, vfpInjTables] = RiaOpmParserTools::extractVfpTablesFromDataFile( m_filePath().path().toStdString() ); - for ( const auto& prodTable : vfpProdTables ) + if ( m_vfpTableData ) { - RimVfpPlot* plot = m_vfpPlotCollection->plotForTableNumber( prodTable.getTableNum() ); - if ( !plot ) - { - plot = createRimVfpPlot(); - m_vfpPlotCollection->addPlot( plot ); - } - else - { - std::erase( currentPlots, plot ); - } - plot->setProductionTable( prodTable ); - plot->setDataIsImportedExternally( true ); - plot->setDeletable( false ); - plot->loadDataAndUpdate(); - } + m_vfpTableData->ensureDataIsImported(); - for ( const auto& injTable : vfpInjTables ) - { - RimVfpPlot* plot = m_vfpPlotCollection->plotForTableNumber( injTable.getTableNum() ); - if ( !plot ) - { - plot = createRimVfpPlot(); - m_vfpPlotCollection->addPlot( plot ); - } - else + if ( m_vfpTableData->vfpTables() ) { - std::erase( currentPlots, plot ); + auto tables = m_vfpTableData->vfpTables(); + + auto allTableNumbers = tables->productionTableNumbers(); + auto injTableNumbers = tables->injectionTableNumbers(); + allTableNumbers.insert( allTableNumbers.end(), injTableNumbers.begin(), injTableNumbers.end() ); + + for ( const auto& number : allTableNumbers ) + { + RimVfpPlot* plot = m_vfpPlotCollection->plotForTableNumber( number ); + if ( !plot ) + { + plot = new RimVfpPlot(); + plot->setDataSource( m_vfpTableData ); + plot->setTableNumber( number ); + plot->initializeObject(); + + m_vfpPlotCollection->addPlot( plot ); + } + else + { + std::erase( currentPlots, plot ); + } + plot->setDeletable( false ); + plot->loadDataAndUpdate(); + } } - plot->setInjectionTable( injTable ); - plot->setDataIsImportedExternally( true ); - plot->setDeletable( false ); - plot->loadDataAndUpdate(); } for ( auto plotToDelete : currentPlots ) @@ -109,6 +99,15 @@ void RimVfpDeck::loadDataAndUpdate() delete plotToDelete; } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimVfpDeck::plots() const +{ + return m_vfpPlotCollection->plots(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -127,13 +126,30 @@ void RimVfpDeck::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q //-------------------------------------------------------------------------------------------------- void RimVfpDeck::updateObjectName() { - QString name = "VFP Plots"; + QString name = "VFP Deck"; - QFileInfo fileInfo( m_filePath().path() ); - auto fileName = fileInfo.fileName(); - if ( !fileName.isEmpty() ) + if ( m_vfpTableData ) { - name += " - " + fileName; + name = m_vfpTableData->name(); } + setName( name ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimVfpDeck::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + if ( fieldNeedingOptions == &m_vfpTableData ) + { + RimVfpDataCollection* vfpDataCollection = RimVfpDataCollection::instance(); + for ( auto table : vfpDataCollection->vfpTableData() ) + { + options.push_back( caf::PdmOptionItemInfo( table->name(), table ) ); + } + } + + return options; +} diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.h index fdc25c5293..d927f2c73a 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.h @@ -21,8 +21,11 @@ #include "RimNamedObject.h" #include "cafFilePath.h" +#include "cafPdmPtrField.h" class RimVfpPlotCollection; +class RimVfpTableData; +class RimVfpPlot; //-------------------------------------------------------------------------------------------------- /// RimVfpDeck parses a deck file (*.DATA) containing VFP data and creates a collection of VFP plots. @@ -34,14 +37,17 @@ class RimVfpDeck : public RimNamedObject public: RimVfpDeck(); - void setFileName( const QString& filename ); + void setDataSource( RimVfpTableData* tableData ); void loadDataAndUpdate(); + std::vector plots() const; + private: - void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; - void updateObjectName(); + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; + void updateObjectName(); + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: - caf::PdmField m_filePath; + caf::PdmPtrField m_vfpTableData; caf::PdmChildField m_vfpPlotCollection; }; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp index 9bf1cce8d8..d4868e0d63 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp @@ -19,22 +19,27 @@ #include "RimVfpPlot.h" #include "RiaColorTables.h" +#include "RiaColorTools.h" #include "RiaEclipseUnitTools.h" #include "RiaOpmParserTools.h" +#include "RigVfpTables.h" + #include "RimPlotAxisProperties.h" +#include "RimPlotCurve.h" +#include "RimProject.h" +#include "RimVfpDataCollection.h" #include "RimVfpDefines.h" +#include "RimVfpTableData.h" #include "Tools/RimPlotAxisTools.h" #include "RiuContextMenuLauncher.h" #include "RiuPlotCurve.h" #include "RiuPlotWidget.h" +#include "RiuQwtCurvePointTracker.h" #include "RiuQwtPlotCurveDefines.h" #include "RiuQwtPlotWheelZoomer.h" #include "RiuQwtPlotWidget.h" - -#include "RiuQwtCurvePointTracker.h" -#include "RiuQwtPlotWidget.h" #include "RiuQwtPlotZoomer.h" #include "cafPdmUiComboBoxEditor.h" @@ -51,39 +56,6 @@ // //================================================================================================== -class VfpPlotData -{ -public: - void setXAxisTitle( const QString& xAxisTitle ) { m_xAxisTitle = xAxisTitle; } - void setYAxisTitle( const QString& yAxisTitle ) { m_yAxisTitle = yAxisTitle; } - - const QString& xAxisTitle() const { return m_xAxisTitle; } - const QString& yAxisTitle() const { return m_yAxisTitle; } - - void appendCurve( const QString& curveTitle, const std::vector& xData, const std::vector& yData ) - { - m_curveTitles.push_back( curveTitle ); - m_xData.push_back( xData ); - m_yData.push_back( yData ); - } - - const QString& curveTitle( size_t idx ) const { return m_curveTitles[idx]; } - - size_t size() const { return m_xData.size(); } - - size_t curveSize( size_t idx ) const { return m_xData[idx].size(); } - - const std::vector& xData( size_t idx ) const { return m_xData[idx]; } - const std::vector& yData( size_t idx ) const { return m_yData[idx]; } - -private: - QString m_xAxisTitle; - QString m_yAxisTitle; - std::vector m_curveTitles; - std::vector> m_xData; - std::vector> m_yData; -}; - CAF_PDM_SOURCE_INIT( RimVfpPlot, "VfpPlot" ); //-------------------------------------------------------------------------------------------------- @@ -97,7 +69,10 @@ RimVfpPlot::RimVfpPlot() CAF_PDM_InitField( &m_plotTitle, "PlotTitle", QString( "VFP Plot" ), "Plot Title" ); m_plotTitle.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path" ); + CAF_PDM_InitFieldNoDefault( &m_filePath_OBSOLETE, "FilePath", "File Path" ); + m_filePath_OBSOLETE.xmlCapability()->setIOWritable( false ); + + CAF_PDM_InitFieldNoDefault( &m_vfpTableData, "VfpTableData", "VFP Data Source" ); caf::AppEnum defaultTableType = RimVfpDefines::TableType::INJECTION; CAF_PDM_InitField( &m_tableType, "TableType", defaultTableType, "Table Type" ); @@ -156,6 +131,8 @@ RimVfpPlot::RimVfpPlot() connectAxisSignals( m_xAxisProperties() ); connectAxisSignals( m_yAxisProperties() ); + CAF_PDM_InitFieldNoDefault( &m_plotCurves, "PlotCurves", "Curves" ); + m_showWindow = true; m_showPlotLegends = true; m_dataIsImportedExternally = false; @@ -163,6 +140,8 @@ RimVfpPlot::RimVfpPlot() setAsPlotMdiWindow(); setDeletable( true ); + + m_vfpTables = std::make_unique(); } //-------------------------------------------------------------------------------------------------- @@ -177,9 +156,43 @@ RimVfpPlot::~RimVfpPlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setFileName( const QString& filename ) +void RimVfpPlot::setDataSource( RimVfpTableData* vfpTableData ) +{ + m_vfpTableData = vfpTableData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::setTableNumber( int tableNumber ) +{ + m_tableNumber = tableNumber; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::initializeObject() { - m_filePath = filename; + if ( !vfpTables() ) return; + + auto tableNumber = m_tableNumber(); + + // Always use the available table number if only one table is available + auto prodTableNumbers = vfpTables()->productionTableNumbers(); + auto injTableNumbers = vfpTables()->injectionTableNumbers(); + + if ( prodTableNumbers.size() == 1 && injTableNumbers.empty() ) + { + tableNumber = prodTableNumbers.front(); + } + else if ( injTableNumbers.size() == 1 && prodTableNumbers.empty() ) + { + tableNumber = injTableNumbers.front(); + } + + auto table = vfpTables()->getTableInitialData( tableNumber ); + initializeFromInitData( table ); } //-------------------------------------------------------------------------------------------------- @@ -260,72 +273,35 @@ void RimVfpPlot::updateLegend() //-------------------------------------------------------------------------------------------------- QString RimVfpPlot::asciiDataForPlotExport() const { - QString filePath = m_filePath.v().path(); - if ( !filePath.isEmpty() ) - { - QFileInfo fi( filePath ); - QString wellName = fi.baseName(); + if ( !vfpTables() ) return {}; - VfpPlotData plotData; - if ( m_tableType() == RimVfpDefines::TableType::PRODUCTION ) - { - if ( m_prodTable ) - { - populatePlotData( *m_prodTable, m_primaryVariable(), m_familyVariable(), m_interpolatedVariable(), m_flowingPhase(), plotData ); - } - } - else - { - if ( m_injectionTable ) - { - populatePlotData( *m_injectionTable, m_interpolatedVariable(), m_flowingPhase(), plotData ); - } - } + auto tableText = vfpTables()->asciiDataForTable( m_tableNumber(), + m_primaryVariable(), + m_familyVariable(), + m_interpolatedVariable(), + m_flowingPhase(), + tableSelection() ); - QString plotTitle = - generatePlotTitle( wellName, m_tableNumber(), m_tableType(), m_interpolatedVariable(), m_primaryVariable(), m_familyVariable() ); - - QString dataText; + QString wellName; - if ( plotData.size() > 0 ) + if ( m_vfpTableData ) + { + wellName = m_vfpTableData->name(); + } + else + { + QString filePath = m_filePath_OBSOLETE.v().path(); + if ( !filePath.isEmpty() ) { - // The curves should have same dimensions - const size_t curveSize = plotData.curveSize( 0 ); - - // Generate the headers for the columns - // First column is the primary variable - QString columnTitleLine( plotData.xAxisTitle() ); - - // Then one column per "family" - for ( size_t s = 0; s < plotData.size(); s++ ) - { - columnTitleLine.append( QString( "\t%1" ).arg( plotData.curveTitle( s ) ) ); - } - columnTitleLine.append( "\n" ); - - dataText.append( columnTitleLine ); - - // Add the rows: one row per primary variable value - for ( size_t idx = 0; idx < curveSize; idx++ ) - { - QString line; - - // First item on each line is the primary variable - line.append( QString( "%1" ).arg( plotData.xData( 0 )[idx] ) ); - - for ( size_t s = 0; s < plotData.size(); s++ ) - { - line.append( QString( "\t%1" ).arg( plotData.yData( s )[idx] ) ); - } - dataText.append( line ); - dataText.append( "\n" ); - } + QFileInfo fi( filePath ); + QString wellName = fi.baseName(); } - - return QString( "%1\n\n%2" ).arg( plotTitle ).arg( dataText ); } - return {}; + QString plotTitle = + generatePlotTitle( wellName, m_tableNumber(), m_tableType(), m_interpolatedVariable(), m_primaryVariable(), m_familyVariable() ); + + return QString( "%1\n\n%2" ).arg( plotTitle ).arg( tableText ); } //-------------------------------------------------------------------------------------------------- @@ -333,6 +309,13 @@ QString RimVfpPlot::asciiDataForPlotExport() const //-------------------------------------------------------------------------------------------------- void RimVfpPlot::reattachAllCurves() { + for ( auto curve : m_plotCurves() ) + { + if ( curve->isChecked() ) + { + curve->setParentPlotNoReplot( m_plotWidget ); + } + } } //-------------------------------------------------------------------------------------------------- @@ -340,6 +323,10 @@ void RimVfpPlot::reattachAllCurves() //-------------------------------------------------------------------------------------------------- void RimVfpPlot::detachAllCurves() { + for ( auto curve : m_plotCurves() ) + { + curve->detach(); + } } //-------------------------------------------------------------------------------------------------- @@ -385,24 +372,6 @@ void RimVfpPlot::zoomAll() updatePlotWidgetFromAxisRanges(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setProductionTable( const Opm::VFPProdTable& table ) -{ - m_prodTable = std::make_unique( table ); - m_injectionTable.reset(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setInjectionTable( const Opm::VFPInjTable& table ) -{ - m_prodTable.reset(); - m_injectionTable = std::make_unique( table ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -422,8 +391,12 @@ int RimVfpPlot::tableNumber() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::doRemoveFromCollection() +void RimVfpPlot::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) { + detachAllCurves(); + reattachAllCurves(); + + m_plotWidget->scheduleReplot(); } //-------------------------------------------------------------------------------------------------- @@ -500,57 +473,22 @@ void RimVfpPlot::onLoadDataAndUpdate() return; } - m_plotWidget->detachItems( RiuPlotWidget::PlotItemType::CURVE ); - updateLegend(); QString wellName; - if ( !m_dataIsImportedExternally ) + if ( vfpTables() ) { - QString filePath = m_filePath.v().path(); - if ( !filePath.isEmpty() ) - { - QFileInfo fi( filePath ); - wellName = fi.baseName(); - - // Try to read the file as an prod table first (most common) - const std::vector tables = RiaOpmParserTools::extractVfpProductionTables( filePath.toStdString() ); - if ( !tables.empty() ) - { - setProductionTable( tables[0] ); - } - else - { - const std::vector tables = RiaOpmParserTools::extractVfpInjectionTables( filePath.toStdString() ); - if ( !tables.empty() ) - { - setInjectionTable( tables[0] ); - } - } - } - } + wellName = m_vfpTableData->baseFileName(); - if ( m_prodTable ) - { - auto table = *m_prodTable; - m_tableType = RimVfpDefines::TableType::PRODUCTION; - m_tableNumber = table.getTableNum(); - m_referenceDepth = table.getDatumDepth(); - m_flowingPhase = getFlowingPhaseType( table ); - m_flowingGasFraction = getFlowingGasFractionType( table ); - m_flowingWaterFraction = getFlowingWaterFractionType( table ); - populatePlotWidgetWithCurveData( m_plotWidget, table, m_primaryVariable(), m_familyVariable() ); - } - else if ( m_injectionTable ) - { - auto table = *m_injectionTable; + auto vfpPlotData = vfpTables()->populatePlotData( m_tableNumber(), + m_primaryVariable(), + m_familyVariable(), + m_interpolatedVariable(), + m_flowingPhase(), + tableSelection() ); - m_tableType = RimVfpDefines::TableType::INJECTION; - m_tableNumber = table.getTableNum(); - m_referenceDepth = table.getDatumDepth(); - m_flowingPhase = getFlowingPhaseType( table ); - populatePlotWidgetWithCurveData( m_plotWidget, table ); + populatePlotWidgetWithPlotData( m_plotWidget, vfpPlotData ); } updatePlotTitle( @@ -559,6 +497,8 @@ void RimVfpPlot::onLoadDataAndUpdate() m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true ); m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true ); + reattachAllCurves(); + updatePlotWidgetFromAxisRanges(); m_plotWidget->scheduleReplot(); @@ -567,103 +507,54 @@ void RimVfpPlot::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget, const Opm::VFPInjTable& table ) -{ - VfpPlotData plotData; - populatePlotData( table, m_interpolatedVariable(), m_flowingPhase(), plotData ); - populatePlotWidgetWithPlotData( plotWidget, plotData ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpPlot::populatePlotData( const Opm::VFPInjTable& table, - RimVfpDefines::InterpolatedVariableType interpolatedVariable, - RimVfpDefines::FlowingPhaseType flowingPhase, - VfpPlotData& plotData ) +void RimVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData ) { - QString xAxisTitle = axisTitle( RimVfpDefines::ProductionVariableType::FLOW_RATE, flowingPhase ); - plotData.setXAxisTitle( xAxisTitle ); - - QString yAxisTitle = QString( "%1 %2" ).arg( caf::AppEnum::uiText( interpolatedVariable ), - getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType::THP ) ); - plotData.setYAxisTitle( yAxisTitle ); - - std::vector thpValues = table.getTHPAxis(); + plotWidget->setAxisScale( RiuPlotAxis::defaultBottom(), 0, 1 ); + plotWidget->setAxisScale( RiuPlotAxis::defaultLeft(), 0, 1 ); + plotWidget->setAxisAutoScale( RiuPlotAxis::defaultBottom(), true ); + plotWidget->setAxisAutoScale( RiuPlotAxis::defaultLeft(), true ); + plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), plotData.xAxisTitle() ); + plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), plotData.yAxisTitle() ); - for ( size_t thp = 0; thp < thpValues.size(); thp++ ) + if ( m_plotCurves.size() != plotData.size() ) { - size_t numValues = table.getFloAxis().size(); - std::vector xVals = table.getFloAxis(); - std::vector yVals( numValues, 0.0 ); - for ( size_t y = 0; y < numValues; y++ ) + detachAllCurves(); + m_plotCurves.deleteChildren(); + + for ( auto idx = 0u; idx < plotData.size(); idx++ ) { - yVals[y] = table( thp, y ); - if ( interpolatedVariable == RimVfpDefines::InterpolatedVariableType::BHP_THP_DIFF ) - { - yVals[y] -= thpValues[thp]; - } - } + QColor qtClr = RiaColorTables::summaryCurveDefaultPaletteColors().cycledQColor( idx ); + + auto curve = new RimPlotCurve(); - double value = convertToDisplayUnit( thpValues[thp], RimVfpDefines::ProductionVariableType::THP ); - QString unit = getDisplayUnit( RimVfpDefines::ProductionVariableType::THP ); - QString title = QString( "%1 [%2]: %3" ) - .arg( caf::AppEnum::uiText( RimVfpDefines::ProductionVariableType::THP ) ) - .arg( unit ) - .arg( value ); + curve->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); + curve->setLineThickness( 2 ); + curve->setColor( RiaColorTools::fromQColorTo3f( qtClr ) ); + curve->setSymbol( RiuPlotCurveSymbol::SYMBOL_ELLIPSE ); + curve->setSymbolSize( 6 ); - convertToDisplayUnit( yVals, RimVfpDefines::ProductionVariableType::THP ); - convertToDisplayUnit( xVals, RimVfpDefines::ProductionVariableType::FLOW_RATE ); + m_plotCurves.push_back( curve ); + } - plotData.appendCurve( title, xVals, yVals ); + updateConnectedEditors(); } -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpPlot::populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget, - const Opm::VFPProdTable& table, - RimVfpDefines::ProductionVariableType primaryVariable, - RimVfpDefines::ProductionVariableType familyVariable ) -{ - VfpPlotData plotData; - populatePlotData( table, primaryVariable, familyVariable, m_interpolatedVariable(), m_flowingPhase(), plotData ); - populatePlotWidgetWithPlotData( plotWidget, plotData ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData ) -{ - plotWidget->detachItems( RiuPlotWidget::PlotItemType::CURVE ); - plotWidget->setAxisScale( RiuPlotAxis::defaultBottom(), 0, 1 ); - plotWidget->setAxisScale( RiuPlotAxis::defaultLeft(), 0, 1 ); - plotWidget->setAxisAutoScale( RiuPlotAxis::defaultBottom(), true ); - plotWidget->setAxisAutoScale( RiuPlotAxis::defaultLeft(), true ); - plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), plotData.xAxisTitle() ); - plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), plotData.yAxisTitle() ); + auto plotCurves = m_plotCurves.childrenByType(); for ( auto idx = 0u; idx < plotData.size(); idx++ ) { - QColor qtClr = RiaColorTables::summaryCurveDefaultPaletteColors().cycledQColor( idx ); - RiuPlotCurve* curve = m_plotWidget->createPlotCurve( nullptr, plotData.curveTitle( idx ) ); - - curve->setAppearance( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID, - RiuQwtPlotCurveDefines::CurveInterpolationEnum::INTERPOLATION_POINT_TO_POINT, - 2, - qtClr ); - - RiuPlotCurveSymbol* symbol = curve->createSymbol( RiuPlotCurveSymbol::PointSymbolEnum::SYMBOL_ELLIPSE ); - symbol->setColor( qtClr ); - symbol->setSize( 6, 6 ); - curve->setSymbol( symbol ); - - bool useLogarithmicScale = false; - curve->setSamplesFromXValuesAndYValues( plotData.xData( idx ), plotData.yData( idx ), useLogarithmicScale ); - curve->attachToPlot( plotWidget ); - curve->showInPlot(); + auto curve = plotCurves[idx]; + if ( !curve ) continue; + + curve->setCustomName( plotData.curveTitle( idx ) ); + curve->setParentPlotNoReplot( plotWidget ); + if ( curve->plotCurve() ) + { + bool useLogarithmicScale = false; + curve->plotCurve()->setSamplesFromXValuesAndYValues( plotData.xData( idx ), plotData.yData( idx ), useLogarithmicScale ); + } + curve->updateCurveAppearance(); + curve->appearanceChanged.connect( this, &RimVfpPlot::curveAppearanceChanged ); } } @@ -754,66 +645,41 @@ void RimVfpPlot::onPlotZoomed() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::populatePlotData( const Opm::VFPProdTable& table, - RimVfpDefines::ProductionVariableType primaryVariable, - RimVfpDefines::ProductionVariableType familyVariable, - RimVfpDefines::InterpolatedVariableType interpolatedVariable, - RimVfpDefines::FlowingPhaseType flowingPhase, - VfpPlotData& plotData ) const +void RimVfpPlot::curveAppearanceChanged( const caf::SignalEmitter* emitter ) { - QString xAxisTitle = axisTitle( primaryVariable, flowingPhase ); - plotData.setXAxisTitle( xAxisTitle ); + scheduleReplot(); +} - QString yAxisTitle = QString( "%1 %2" ).arg( caf::AppEnum::uiText( interpolatedVariable ), - getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType::THP ) ); - plotData.setYAxisTitle( yAxisTitle ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::initializeFromInitData( const VfpTableInitialData& table ) +{ + m_tableType = table.isProductionTable ? RimVfpDefines::TableType::PRODUCTION : RimVfpDefines::TableType::INJECTION; + m_tableNumber = table.tableNumber; + m_referenceDepth = table.datumDepth; + m_flowingPhase = table.flowingPhase; + m_flowingGasFraction = table.gasFraction; + m_flowingWaterFraction = table.waterFraction; +} - size_t numFamilyValues = getProductionTableData( table, familyVariable ).size(); - for ( size_t familyIdx = 0; familyIdx < numFamilyValues; familyIdx++ ) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigVfpTables* RimVfpPlot::vfpTables() const +{ + if ( m_vfpTableData ) { - std::vector primaryAxisValues = getProductionTableData( table, primaryVariable ); - std::vector familyVariableValues = getProductionTableData( table, familyVariable ); - std::vector thpValues = getProductionTableData( table, RimVfpDefines::ProductionVariableType::THP ); - - size_t numValues = primaryAxisValues.size(); - std::vector yVals( numValues, 0.0 ); - - for ( size_t y = 0; y < numValues; y++ ) - { - size_t wfr_idx = - getVariableIndex( table, RimVfpDefines::ProductionVariableType::WATER_CUT, primaryVariable, y, familyVariable, familyIdx ); - size_t gfr_idx = - getVariableIndex( table, RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO, primaryVariable, y, familyVariable, familyIdx ); - size_t alq_idx = getVariableIndex( table, - RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY, - primaryVariable, - y, - familyVariable, - familyIdx ); - size_t flo_idx = - getVariableIndex( table, RimVfpDefines::ProductionVariableType::FLOW_RATE, primaryVariable, y, familyVariable, familyIdx ); - size_t thp_idx = - getVariableIndex( table, RimVfpDefines::ProductionVariableType::THP, primaryVariable, y, familyVariable, familyIdx ); - - yVals[y] = table( thp_idx, wfr_idx, gfr_idx, alq_idx, flo_idx ); - if ( m_interpolatedVariable == RimVfpDefines::InterpolatedVariableType::BHP_THP_DIFF ) - { - yVals[y] -= thpValues[thp_idx]; - } - } - - double familyValue = convertToDisplayUnit( familyVariableValues[familyIdx], familyVariable ); - QString familyUnit = getDisplayUnit( familyVariable ); - QString familyTitle = QString( "%1: %2 %3" ) - .arg( caf::AppEnum::uiText( familyVariable ) ) - .arg( familyValue ) - .arg( familyUnit ); - - convertToDisplayUnit( yVals, RimVfpDefines::ProductionVariableType::THP ); - convertToDisplayUnit( primaryAxisValues, primaryVariable ); + m_vfpTableData->ensureDataIsImported(); + return m_vfpTableData->vfpTables(); + } - plotData.appendCurve( familyTitle, primaryAxisValues, yVals ); + if ( m_vfpTables ) + { + return m_vfpTables.get(); } + + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -868,64 +734,12 @@ QString RimVfpPlot::getDisplayUnit( RimVfpDefines::ProductionVariableType variab return ""; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimVfpPlot::getProductionTableData( const Opm::VFPProdTable& table, RimVfpDefines::ProductionVariableType variableType ) const -{ - std::vector xVals; - if ( variableType == RimVfpDefines::ProductionVariableType::WATER_CUT ) - { - xVals = table.getWFRAxis(); - } - else if ( variableType == RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO ) - { - xVals = table.getGFRAxis(); - } - else if ( variableType == RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY ) - { - xVals = table.getALQAxis(); - } - else if ( variableType == RimVfpDefines::ProductionVariableType::FLOW_RATE ) - { - xVals = table.getFloAxis(); - } - else if ( variableType == RimVfpDefines::ProductionVariableType::THP ) - { - xVals = table.getTHPAxis(); - } - - return xVals; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RimVfpPlot::getVariableIndex( const Opm::VFPProdTable& table, - RimVfpDefines::ProductionVariableType targetVariable, - RimVfpDefines::ProductionVariableType primaryVariable, - size_t primaryValue, - RimVfpDefines::ProductionVariableType familyVariable, - size_t familyValue ) const -{ - if ( targetVariable == primaryVariable ) return primaryValue; - if ( targetVariable == familyVariable ) return familyValue; - if ( targetVariable == RimVfpDefines::ProductionVariableType::WATER_CUT ) return m_waterCutIdx; - if ( targetVariable == RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO ) return m_gasLiquidRatioIdx; - if ( targetVariable == RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY ) return m_articifialLiftQuantityIdx; - if ( targetVariable == RimVfpDefines::ProductionVariableType::FLOW_RATE ) return m_flowRateIdx; - if ( targetVariable == RimVfpDefines::ProductionVariableType::THP ) return m_thpIdx; - - return getProductionTableData( table, targetVariable ).size() - 1; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimVfpPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - uiOrdering.add( &m_filePath ); - m_filePath.uiCapability()->setUiReadOnly( m_dataIsImportedExternally ); + uiOrdering.add( &m_vfpTableData ); uiOrdering.add( &m_tableType ); uiOrdering.add( &m_tableNumber ); @@ -999,79 +813,16 @@ QList RimVfpPlot::calculateValueOptions( const caf::PdmF calculateTableValueOptions( RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO, options ); } - return options; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimVfpDefines::FlowingPhaseType RimVfpPlot::getFlowingPhaseType( const Opm::VFPProdTable& table ) -{ - switch ( table.getFloType() ) - { - case Opm::VFPProdTable::FLO_TYPE::FLO_OIL: - return RimVfpDefines::FlowingPhaseType::OIL; - case Opm::VFPProdTable::FLO_TYPE::FLO_GAS: - return RimVfpDefines::FlowingPhaseType::GAS; - case Opm::VFPProdTable::FLO_TYPE::FLO_LIQ: - return RimVfpDefines::FlowingPhaseType::LIQUID; - default: - return RimVfpDefines::FlowingPhaseType::INVALID; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimVfpDefines::FlowingPhaseType RimVfpPlot::getFlowingPhaseType( const Opm::VFPInjTable& table ) -{ - switch ( table.getFloType() ) + else if ( fieldNeedingOptions == &m_vfpTableData ) { - case Opm::VFPInjTable::FLO_TYPE::FLO_OIL: - return RimVfpDefines::FlowingPhaseType::OIL; - case Opm::VFPInjTable::FLO_TYPE::FLO_GAS: - return RimVfpDefines::FlowingPhaseType::GAS; - case Opm::VFPInjTable::FLO_TYPE::FLO_WAT: - return RimVfpDefines::FlowingPhaseType::WATER; - default: - return RimVfpDefines::FlowingPhaseType::INVALID; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimVfpDefines::FlowingGasFractionType RimVfpPlot::getFlowingGasFractionType( const Opm::VFPProdTable& table ) -{ - switch ( table.getGFRType() ) - { - case Opm::VFPProdTable::GFR_TYPE::GFR_GOR: - return RimVfpDefines::FlowingGasFractionType::GOR; - case Opm::VFPProdTable::GFR_TYPE::GFR_GLR: - return RimVfpDefines::FlowingGasFractionType::GLR; - case Opm::VFPProdTable::GFR_TYPE::GFR_OGR: - return RimVfpDefines::FlowingGasFractionType::OGR; - default: - return RimVfpDefines::FlowingGasFractionType::INVALID; + RimVfpDataCollection* vfpDataCollection = RimVfpDataCollection::instance(); + for ( auto table : vfpDataCollection->vfpTableData() ) + { + options.push_back( caf::PdmOptionItemInfo( table->name(), table ) ); + } } -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimVfpDefines::FlowingWaterFractionType RimVfpPlot::getFlowingWaterFractionType( const Opm::VFPProdTable& table ) -{ - switch ( table.getWFRType() ) - { - case Opm::VFPProdTable::WFR_TYPE::WFR_WOR: - return RimVfpDefines::FlowingWaterFractionType::WOR; - case Opm::VFPProdTable::WFR_TYPE::WFR_WCT: - return RimVfpDefines::FlowingWaterFractionType::WCT; - case Opm::VFPProdTable::WFR_TYPE::WFR_WGR: - return RimVfpDefines::FlowingWaterFractionType::WGR; - default: - return RimVfpDefines::FlowingWaterFractionType::INVALID; - } + return options; } //-------------------------------------------------------------------------------------------------- @@ -1079,9 +830,9 @@ RimVfpDefines::FlowingWaterFractionType RimVfpPlot::getFlowingWaterFractionType( //-------------------------------------------------------------------------------------------------- void RimVfpPlot::calculateTableValueOptions( RimVfpDefines::ProductionVariableType variableType, QList& options ) { - if ( m_prodTable ) + if ( vfpTables() ) { - std::vector values = getProductionTableData( *m_prodTable, variableType ); + auto values = vfpTables()->getProductionTableData( m_tableNumber(), variableType ); for ( size_t i = 0; i < values.size(); i++ ) { @@ -1098,10 +849,32 @@ void RimVfpPlot::calculateTableValueOptions( RimVfpDefines::ProductionVariableTy void RimVfpPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { RimPlot::fieldChangedByUi( changedField, oldValue, newValue ); + loadDataAndUpdate(); updateLayout(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::initAfterRead() +{ + auto filePath = m_filePath_OBSOLETE.v().path(); + if ( filePath.isEmpty() ) return; + + QString fileName = RimProject::current()->updatedFilePathFromPathId( filePath ); + + auto vfpDataCollection = RimVfpDataCollection::instance(); + if ( vfpDataCollection ) + { + auto tableData = vfpDataCollection->appendTableDataObject( fileName ); + if ( tableData ) + { + setDataSource( tableData ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1143,3 +916,22 @@ caf::PdmFieldHandle* RimVfpPlot::userDescriptionField() { return &m_plotTitle; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::scheduleReplot() +{ + if ( m_plotWidget ) + { + m_plotWidget->scheduleReplot(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +VfpTableSelection RimVfpPlot::tableSelection() const +{ + return { m_flowRateIdx(), m_thpIdx(), m_articifialLiftQuantityIdx(), m_waterCutIdx(), m_gasLiquidRatioIdx() }; +} diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h index 71451ae6c3..7bf0192532 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h @@ -22,15 +22,24 @@ #include "RimVfpDefines.h" #include "cafFilePath.h" +#include "cafPdmPtrField.h" #include -#include "opm/input/eclipse/Schedule/VFPInjTable.hpp" -#include "opm/input/eclipse/Schedule/VFPProdTable.hpp" - class RiuPlotWidget; class VfpPlotData; class RimPlotAxisProperties; +class RigVfpTables; +class RimVfpTableData; + +struct VfpTableSelection; +struct VfpTableInitialData; + +namespace Opm +{ +class VFPInjTable; +class VFPProdTable; +} // namespace Opm //-------------------------------------------------------------------------------------------------- /// Vertical Flow Performance Plot @@ -43,7 +52,9 @@ class RimVfpPlot : public RimPlot RimVfpPlot(); ~RimVfpPlot() override; - void setFileName( const QString& filename ); + void setDataSource( RimVfpTableData* vfpTableData ); + void setTableNumber( int tableNumber ); + void initializeObject(); // RimPlot implementations RiuPlotWidget* plotWidget() override; @@ -65,43 +76,30 @@ class RimVfpPlot : public RimPlot QImage snapshotWindowContent() override; void zoomAll() override; - void setProductionTable( const Opm::VFPProdTable& table ); - void setInjectionTable( const Opm::VFPInjTable& table ); void setDataIsImportedExternally( bool dataIsImportedExternally ); int tableNumber() const; private: - // RimPlot implementations - void doRemoveFromCollection(); - - // RimViewWindow implementations + void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) override; void deleteViewWidget() override; void onLoadDataAndUpdate() override; - // PDM methods caf::PdmFieldHandle* userDescriptionField() override; -private: - RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; - - void populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget, const Opm::VFPInjTable& table ); - void populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget, - const Opm::VFPProdTable& table, - RimVfpDefines::ProductionVariableType primaryVariable, - RimVfpDefines::ProductionVariableType familyVariable ); - std::vector getProductionTableData( const Opm::VFPProdTable& table, RimVfpDefines::ProductionVariableType variableType ) const; - size_t getVariableIndex( const Opm::VFPProdTable& table, - RimVfpDefines::ProductionVariableType targetVariable, - RimVfpDefines::ProductionVariableType primaryVariable, - size_t primaryValue, - RimVfpDefines::ProductionVariableType familyVariable, - size_t familyValue ) const; + void scheduleReplot(); +private: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - + void initAfterRead() override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + VfpTableSelection tableSelection() const; + void initializeFromInitData( const VfpTableInitialData& table ); + const RigVfpTables* vfpTables() const; + + RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; + void calculateTableValueOptions( RimVfpDefines::ProductionVariableType variableType, QList& options ); void setFixedVariableUiEditability( caf::PdmField& field, RimVfpDefines::ProductionVariableType variableType ); @@ -114,30 +112,11 @@ class RimVfpPlot : public RimPlot RimVfpDefines::ProductionVariableType primaryVariable, RimVfpDefines::ProductionVariableType familyVariable ); - static double convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType ); - static void convertToDisplayUnit( std::vector& values, RimVfpDefines::ProductionVariableType variableType ); - + static double convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType ); + static void convertToDisplayUnit( std::vector& values, RimVfpDefines::ProductionVariableType variableType ); static QString getDisplayUnit( RimVfpDefines::ProductionVariableType variableType ); - static QString getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType variableType ); - static RimVfpDefines::FlowingPhaseType getFlowingPhaseType( const Opm::VFPProdTable& table ); - static RimVfpDefines::FlowingPhaseType getFlowingPhaseType( const Opm::VFPInjTable& table ); - static RimVfpDefines::FlowingWaterFractionType getFlowingWaterFractionType( const Opm::VFPProdTable& table ); - static RimVfpDefines::FlowingGasFractionType getFlowingGasFractionType( const Opm::VFPProdTable& table ); - - void populatePlotData( const Opm::VFPProdTable& table, - RimVfpDefines::ProductionVariableType primaryVariable, - RimVfpDefines::ProductionVariableType familyVariable, - RimVfpDefines::InterpolatedVariableType interpolatedVariable, - RimVfpDefines::FlowingPhaseType flowingPhase, - VfpPlotData& plotData ) const; - - static void populatePlotData( const Opm::VFPInjTable& table, - RimVfpDefines::InterpolatedVariableType interpolatedVariable, - RimVfpDefines::FlowingPhaseType flowingPhase, - VfpPlotData& plotData ); - void populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData ); static QString axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ); @@ -149,10 +128,11 @@ class RimVfpPlot : public RimPlot void updateAxisRangesFromPlotWidget() override; void onPlotZoomed(); + void curveAppearanceChanged( const caf::SignalEmitter* emitter ); private: caf::PdmField m_plotTitle; - caf::PdmField m_filePath; + caf::PdmPtrField m_vfpTableData; caf::PdmField m_tableNumber; caf::PdmField m_referenceDepth; caf::PdmField> m_flowingPhase; @@ -173,9 +153,12 @@ class RimVfpPlot : public RimPlot caf::PdmChildField m_yAxisProperties; caf::PdmChildField m_xAxisProperties; - QPointer m_plotWidget; - std::unique_ptr m_prodTable; - std::unique_ptr m_injectionTable; + caf::PdmChildArrayField m_plotCurves; + + QPointer m_plotWidget; + + std::unique_ptr m_vfpTables; + caf::PdmField m_filePath_OBSOLETE; bool m_dataIsImportedExternally; }; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp index 05c78b96aa..734cd655a5 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp @@ -18,16 +18,8 @@ #include "RimVfpPlotCollection.h" -#include "RiaApplication.h" - -#include "RigCaseCellResultsData.h" -#include "RigEclipseCaseData.h" -#include "RigEclipseResultAddress.h" -#include "RigEquil.h" - -#include "RimEclipseResultCase.h" -#include "RimProject.h" #include "RimVfpDeck.h" +#include "RimVfpTableData.h" #include "cafCmdFeatureMenuBuilder.h" @@ -47,8 +39,43 @@ RimVfpPlotCollection::RimVfpPlotCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimVfpPlotCollection::~RimVfpPlotCollection() +RimVfpPlot* RimVfpPlotCollection::createAndAppendPlots( RimVfpTableData* tableData ) { + if ( !tableData ) return nullptr; + + tableData->ensureDataIsImported(); + + if ( !tableData->vfpTables() ) return nullptr; + + RimVfpPlot* firstPlot = nullptr; + + if ( tableData->tableCount() > 1 ) + { + auto* deck = new RimVfpDeck(); + deck->setDataSource( tableData ); + addDeck( deck ); + deck->loadDataAndUpdate(); + deck->updateAllRequiredEditors(); + + auto plots = deck->plots(); + if ( !plots.empty() ) + { + firstPlot = plots.front(); + } + } + else + { + auto vfpPlot = new RimVfpPlot(); + vfpPlot->setDataSource( tableData ); + vfpPlot->initializeObject(); + + addPlot( vfpPlot ); + vfpPlot->loadDataAndUpdate(); + + firstPlot = vfpPlot; + } + + return firstPlot; } //-------------------------------------------------------------------------------------------------- @@ -75,14 +102,6 @@ std::vector RimVfpPlotCollection::plots() const return m_vfpPlots.childrenByType(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpPlotCollection::deleteChildren() -{ - m_vfpPlots.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -119,13 +138,30 @@ void RimVfpPlotCollection::removePlot( RimVfpPlot* vfpPlot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimVfpDeck* RimVfpPlotCollection::addDeck( const QString& filename ) +void RimVfpPlotCollection::addDeck( RimVfpDeck* deck ) { - RimVfpDeck* deck = new RimVfpDeck(); - deck->setFileName( filename ); m_vfpDecks.push_back( deck ); +} - return deck; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlotCollection::deleteAllPlots() +{ + m_vfpPlots.deleteChildren(); + m_vfpDecks.deleteChildren(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlotCollection::addImportItems( caf::CmdFeatureMenuBuilder& menuBuilder ) +{ + // A variant with a true value is used to indicate that the VFP data is imported from a file + // This is used to distinguish between VFP data imported from a file and VFP data imported from a simulator + QVariant variant( QVariant::fromValue( true ) ); + menuBuilder.addCmdFeatureWithUserData( "RicImportVfpDataFeature", "Import VFP Files", variant ); + menuBuilder.addCmdFeature( "RicImportVfpDataFeature", "Import VFP from Simulator Files" ); } //-------------------------------------------------------------------------------------------------- @@ -160,9 +196,5 @@ void RimVfpPlotCollection::loadDataAndUpdateAllPlots() //-------------------------------------------------------------------------------------------------- void RimVfpPlotCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const { - // A variant with a true value is used to indicate that the VFP data is imported from a file - // This is used to distinguish between VFP data imported from a file and VFP data imported from a simulator - QVariant variant( QVariant::fromValue( true ) ); - menuBuilder.addCmdFeatureWithUserData( "RicImportVfpDataFeature", "Import VFP Files", variant ); - menuBuilder.addCmdFeature( "RicImportVfpDataFeature", "Import VFP from Simulator Files" ); + addImportItems( menuBuilder ); } diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h index 916d974aa5..a489deccbd 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h @@ -35,18 +35,19 @@ class RimVfpPlotCollection : public caf::PdmObject, public RimTypedPlotCollectio public: RimVfpPlotCollection(); - ~RimVfpPlotCollection() override; + + RimVfpPlot* createAndAppendPlots( RimVfpTableData* tableData ); + RimVfpPlot* plotForTableNumber( int tableNumber ) const; void addPlot( RimVfpPlot* newPlot ) override; std::vector plots() const override; - void deleteChildren(); - RimVfpPlot* plotForTableNumber( int tableNumber ) const; size_t plotCount() const final; void insertPlot( RimVfpPlot* vfpPlot, size_t index ) final; void removePlot( RimVfpPlot* vfpPlot ) final; + void deleteAllPlots() override; - RimVfpDeck* addDeck( const QString& filename ); + static void addImportItems( caf::CmdFeatureMenuBuilder& menuBuilder ); private: void loadDataAndUpdateAllPlots() override; @@ -54,6 +55,8 @@ class RimVfpPlotCollection : public caf::PdmObject, public RimTypedPlotCollectio void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; + void addDeck( RimVfpDeck* deck ); + private: caf::PdmChildArrayField m_vfpPlots; caf::PdmChildArrayField m_vfpDecks; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp new file mode 100644 index 0000000000..39414adb27 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp @@ -0,0 +1,126 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimVfpTableData.h" + +#include "RiaOpmParserTools.h" + +#include "RigVfpTables.h" + +#include "cafCmdFeatureMenuBuilder.h" + +#include + +CAF_PDM_SOURCE_INIT( RimVfpTableData, "RimVfpTableData" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpTableData::RimVfpTableData() +{ + CAF_PDM_InitObject( "VFP Plot", ":/VfpPlot.svg" ); + + CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path" ); + + setDeletable( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpTableData::setFileName( const QString& filename ) +{ + m_filePath = filename; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimVfpTableData::baseFileName() +{ + QFileInfo fileInfo( m_filePath().path() ); + return fileInfo.baseName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpTableData::ensureDataIsImported() +{ + if ( m_vfpTables ) return; + + updateObjectName(); + + m_vfpTables = std::make_unique(); + + const auto [vfpProdTables, vfpInjTables] = RiaOpmParserTools::extractVfpTablesFromDataFile( m_filePath().path().toStdString() ); + for ( const auto& prod : vfpProdTables ) + { + m_vfpTables->addProductionTable( prod ); + } + + for ( const auto& inj : vfpInjTables ) + { + m_vfpTables->addInjectionTable( inj ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimVfpTableData::tableCount() const +{ + if ( m_vfpTables ) + { + return m_vfpTables->injectionTableNumbers().size() + m_vfpTables->productionTableNumbers().size(); + } + + return 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigVfpTables* RimVfpTableData::vfpTables() const +{ + return m_vfpTables.get(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpTableData::updateObjectName() +{ + QString name = "VFP Plots"; + + QFileInfo fileInfo( m_filePath().path() ); + auto fileName = fileInfo.fileName(); + if ( !fileName.isEmpty() ) + { + name = fileName; + } + setName( name ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpTableData::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder << "RicNewVfpPlotFeature"; +} diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.h new file mode 100644 index 0000000000..dd3abcb757 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.h @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimNamedObject.h" + +#include "cafFilePath.h" + +#include + +class RigVfpTables; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RimVfpTableData : public RimNamedObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimVfpTableData(); + + void setFileName( const QString& filename ); + QString baseFileName(); + void ensureDataIsImported(); + + size_t tableCount() const; + + const RigVfpTables* vfpTables() const; + +private: + void updateObjectName(); + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; + +private: + caf::PdmField m_filePath; + + std::unique_ptr m_vfpTables; +}; diff --git a/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake index f37b87b270..924cadcb6b 100644 --- a/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake @@ -98,6 +98,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RigWellResultBranch.h ${CMAKE_CURRENT_LIST_DIR}/RigWellResultFrame.h ${CMAKE_CURRENT_LIST_DIR}/RigReservoirBuilder.h + ${CMAKE_CURRENT_LIST_DIR}/RigVfpTables.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -194,6 +195,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RigWellResultFrame.cpp ${CMAKE_CURRENT_LIST_DIR}/RigDeclineCurveCalculator.cpp ${CMAKE_CURRENT_LIST_DIR}/RigReservoirBuilder.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigVfpTables.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp new file mode 100644 index 0000000000..b0e1fba717 --- /dev/null +++ b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp @@ -0,0 +1,569 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RigVfpTables.h" + +#include "RiaEclipseUnitTools.h" + +#include "cafAppEnum.h" + +#include "opm/input/eclipse/Schedule/VFPInjTable.hpp" +#include "opm/input/eclipse/Schedule/VFPProdTable.hpp" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +VfpPlotData RigVfpTables::populatePlotData( const Opm::VFPInjTable& table, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase ) +{ + VfpPlotData plotData; + + QString xAxisTitle = axisTitle( RimVfpDefines::ProductionVariableType::FLOW_RATE, flowingPhase ); + plotData.setXAxisTitle( xAxisTitle ); + + QString yAxisTitle = QString( "%1 %2" ).arg( caf::AppEnum::uiText( interpolatedVariable ), + getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType::THP ) ); + plotData.setYAxisTitle( yAxisTitle ); + + std::vector thpValues = table.getTHPAxis(); + + for ( size_t thp = 0; thp < thpValues.size(); thp++ ) + { + size_t numValues = table.getFloAxis().size(); + std::vector xVals = table.getFloAxis(); + std::vector yVals( numValues, 0.0 ); + for ( size_t y = 0; y < numValues; y++ ) + { + yVals[y] = table( thp, y ); + if ( interpolatedVariable == RimVfpDefines::InterpolatedVariableType::BHP_THP_DIFF ) + { + yVals[y] -= thpValues[thp]; + } + } + + double value = convertToDisplayUnit( thpValues[thp], RimVfpDefines::ProductionVariableType::THP ); + QString unit = getDisplayUnit( RimVfpDefines::ProductionVariableType::THP ); + QString title = QString( "%1 [%2]: %3" ) + .arg( caf::AppEnum::uiText( RimVfpDefines::ProductionVariableType::THP ) ) + .arg( unit ) + .arg( value ); + + convertToDisplayUnit( yVals, RimVfpDefines::ProductionVariableType::THP ); + convertToDisplayUnit( xVals, RimVfpDefines::ProductionVariableType::FLOW_RATE ); + + plotData.appendCurve( title, xVals, yVals ); + } + + return plotData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +VfpPlotData RigVfpTables::populatePlotData( const Opm::VFPProdTable& table, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase, + const VfpTableSelection& tableSelection ) +{ + VfpPlotData plotData; + + QString xAxisTitle = axisTitle( primaryVariable, flowingPhase ); + plotData.setXAxisTitle( xAxisTitle ); + + QString yAxisTitle = QString( "%1 %2" ).arg( caf::AppEnum::uiText( interpolatedVariable ), + getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType::THP ) ); + plotData.setYAxisTitle( yAxisTitle ); + + size_t numFamilyValues = getProductionTableData( table, familyVariable ).size(); + for ( size_t familyIdx = 0; familyIdx < numFamilyValues; familyIdx++ ) + { + std::vector primaryAxisValues = getProductionTableData( table, primaryVariable ); + std::vector familyVariableValues = getProductionTableData( table, familyVariable ); + std::vector thpValues = getProductionTableData( table, RimVfpDefines::ProductionVariableType::THP ); + + size_t numValues = primaryAxisValues.size(); + std::vector yVals( numValues, 0.0 ); + + for ( size_t y = 0; y < numValues; y++ ) + { + size_t wfr_idx = + getVariableIndex( table, RimVfpDefines::ProductionVariableType::WATER_CUT, primaryVariable, y, familyVariable, familyIdx, tableSelection ); + size_t gfr_idx = getVariableIndex( table, + RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO, + primaryVariable, + y, + familyVariable, + familyIdx, + tableSelection ); + size_t alq_idx = getVariableIndex( table, + RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY, + primaryVariable, + y, + familyVariable, + familyIdx, + tableSelection ); + size_t flo_idx = + getVariableIndex( table, RimVfpDefines::ProductionVariableType::FLOW_RATE, primaryVariable, y, familyVariable, familyIdx, tableSelection ); + size_t thp_idx = + getVariableIndex( table, RimVfpDefines::ProductionVariableType::THP, primaryVariable, y, familyVariable, familyIdx, tableSelection ); + + yVals[y] = table( thp_idx, wfr_idx, gfr_idx, alq_idx, flo_idx ); + if ( interpolatedVariable == RimVfpDefines::InterpolatedVariableType::BHP_THP_DIFF ) + { + yVals[y] -= thpValues[thp_idx]; + } + } + + double familyValue = convertToDisplayUnit( familyVariableValues[familyIdx], familyVariable ); + QString familyUnit = getDisplayUnit( familyVariable ); + QString familyTitle = QString( "%1: %2 %3" ) + .arg( caf::AppEnum::uiText( familyVariable ) ) + .arg( familyValue ) + .arg( familyUnit ); + + convertToDisplayUnit( yVals, RimVfpDefines::ProductionVariableType::THP ); + convertToDisplayUnit( primaryAxisValues, primaryVariable ); + + plotData.appendCurve( familyTitle, primaryAxisValues, yVals ); + } + + return plotData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +VfpPlotData RigVfpTables::populatePlotData( int tableIndex, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase, + const VfpTableSelection& tableSelection ) const +{ + auto prodTable = productionTable( tableIndex ); + if ( prodTable.has_value() ) + { + return populatePlotData( *prodTable, primaryVariable, familyVariable, interpolatedVariable, flowingPhase, tableSelection ); + }; + + auto injContainer = injectionTable( tableIndex ); + if ( injContainer.has_value() ) + { + return populatePlotData( *injContainer, interpolatedVariable, flowingPhase ); + }; + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigVfpTables::asciiDataForTable( int tableNumber, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase, + const VfpTableSelection& tableSelection ) const +{ + VfpPlotData plotData; + auto prodTable = productionTable( tableNumber ); + if ( prodTable.has_value() ) + { + plotData = populatePlotData( *prodTable, primaryVariable, familyVariable, interpolatedVariable, flowingPhase, tableSelection ); + } + else + { + auto injTable = injectionTable( tableNumber ); + if ( injTable.has_value() ) + { + plotData = populatePlotData( *injTable, interpolatedVariable, flowingPhase ); + } + } + + return textForPlotData( plotData ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigVfpTables::axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ) +{ + QString title; + + if ( flowingPhase == RimVfpDefines::FlowingPhaseType::GAS ) + { + title = "Gas "; + } + else + { + title = "Liquid "; + } + title += QString( "%1 %2" ).arg( caf::AppEnum::uiText( variableType ), + getDisplayUnitWithBracket( variableType ) ); + + return title; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigVfpTables::getDisplayUnit( RimVfpDefines::ProductionVariableType variableType ) +{ + if ( variableType == RimVfpDefines::ProductionVariableType::THP ) return "Bar"; + + if ( variableType == RimVfpDefines::ProductionVariableType::FLOW_RATE ) return "Sm3/day"; + + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigVfpTables::getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType variableType ) +{ + QString unit = getDisplayUnit( variableType ); + if ( !unit.isEmpty() ) return QString( "[%1]" ).arg( unit ); + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigVfpTables::convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType ) +{ + if ( variableType == RimVfpDefines::ProductionVariableType::THP ) + { + return RiaEclipseUnitTools::pascalToBar( value ); + } + + if ( variableType == RimVfpDefines::ProductionVariableType::FLOW_RATE ) + { + // Convert to m3/sec to m3/day + return value * static_cast( 24 * 60 * 60 ); + } + + return value; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigVfpTables::convertToDisplayUnit( std::vector& values, RimVfpDefines::ProductionVariableType variableType ) +{ + for ( double& value : values ) + value = convertToDisplayUnit( value, variableType ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigVfpTables::textForPlotData( const VfpPlotData& plotData ) +{ + QString dataText; + + if ( plotData.size() > 0 ) + { + // The curves should have same dimensions + const size_t curveSize = plotData.curveSize( 0 ); + + // Generate the headers for the columns + // First column is the primary variable + QString columnTitleLine( plotData.xAxisTitle() ); + + // Then one column per "family" + for ( size_t s = 0; s < plotData.size(); s++ ) + { + columnTitleLine.append( QString( "\t%1" ).arg( plotData.curveTitle( s ) ) ); + } + columnTitleLine.append( "\n" ); + + dataText.append( columnTitleLine ); + + // Add the rows: one row per primary variable value + for ( size_t idx = 0; idx < curveSize; idx++ ) + { + QString line; + + // First item on each line is the primary variable + line.append( QString( "%1" ).arg( plotData.xData( 0 )[idx] ) ); + + for ( size_t s = 0; s < plotData.size(); s++ ) + { + line.append( QString( "\t%1" ).arg( plotData.yData( s )[idx] ) ); + } + dataText.append( line ); + dataText.append( "\n" ); + } + } + + return dataText; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigVfpTables::getProductionTableData( const Opm::VFPProdTable& table, RimVfpDefines::ProductionVariableType variableType ) +{ + std::vector xVals; + if ( variableType == RimVfpDefines::ProductionVariableType::WATER_CUT ) + { + xVals = table.getWFRAxis(); + } + else if ( variableType == RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO ) + { + xVals = table.getGFRAxis(); + } + else if ( variableType == RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY ) + { + xVals = table.getALQAxis(); + } + else if ( variableType == RimVfpDefines::ProductionVariableType::FLOW_RATE ) + { + xVals = table.getFloAxis(); + } + else if ( variableType == RimVfpDefines::ProductionVariableType::THP ) + { + xVals = table.getTHPAxis(); + } + + return xVals; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigVfpTables::getProductionTableData( int tableIndex, RimVfpDefines::ProductionVariableType variableType ) const +{ + auto prodTable = productionTable( tableIndex ); + if ( prodTable.has_value() ) + { + return getProductionTableData( *prodTable, variableType ); + } + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigVfpTables::getVariableIndex( const Opm::VFPProdTable& table, + RimVfpDefines::ProductionVariableType targetVariable, + RimVfpDefines::ProductionVariableType primaryVariable, + size_t primaryValue, + RimVfpDefines::ProductionVariableType familyVariable, + size_t familyValue, + const VfpTableSelection& tableSelection ) +{ + if ( targetVariable == primaryVariable ) return primaryValue; + if ( targetVariable == familyVariable ) return familyValue; + if ( targetVariable == RimVfpDefines::ProductionVariableType::WATER_CUT ) return tableSelection.waterCutIdx; + if ( targetVariable == RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO ) return tableSelection.gasLiquidRatioIdx; + if ( targetVariable == RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY ) + return tableSelection.articifialLiftQuantityIdx; + if ( targetVariable == RimVfpDefines::ProductionVariableType::FLOW_RATE ) return tableSelection.flowRateIdx; + if ( targetVariable == RimVfpDefines::ProductionVariableType::THP ) return tableSelection.thpIdx; + + return getProductionTableData( table, targetVariable ).size() - 1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::optional RigVfpTables::injectionTable( int tableNumber ) const +{ + for ( const auto& table : m_injectionTables ) + { + if ( table.getTableNum() == tableNumber ) + { + return table; + } + } + + return std::nullopt; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::optional RigVfpTables::productionTable( int tableNumber ) const +{ + for ( const auto& table : m_productionTables ) + { + if ( table.getTableNum() == tableNumber ) + { + return table; + } + } + + return std::nullopt; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpDefines::FlowingPhaseType RigVfpTables::getFlowingPhaseType( const Opm::VFPProdTable& table ) +{ + switch ( table.getFloType() ) + { + case Opm::VFPProdTable::FLO_TYPE::FLO_OIL: + return RimVfpDefines::FlowingPhaseType::OIL; + case Opm::VFPProdTable::FLO_TYPE::FLO_GAS: + return RimVfpDefines::FlowingPhaseType::GAS; + case Opm::VFPProdTable::FLO_TYPE::FLO_LIQ: + return RimVfpDefines::FlowingPhaseType::LIQUID; + default: + return RimVfpDefines::FlowingPhaseType::INVALID; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpDefines::FlowingPhaseType RigVfpTables::getFlowingPhaseType( const Opm::VFPInjTable& table ) +{ + switch ( table.getFloType() ) + { + case Opm::VFPInjTable::FLO_TYPE::FLO_OIL: + return RimVfpDefines::FlowingPhaseType::OIL; + case Opm::VFPInjTable::FLO_TYPE::FLO_GAS: + return RimVfpDefines::FlowingPhaseType::GAS; + case Opm::VFPInjTable::FLO_TYPE::FLO_WAT: + return RimVfpDefines::FlowingPhaseType::WATER; + default: + return RimVfpDefines::FlowingPhaseType::INVALID; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpDefines::FlowingWaterFractionType RigVfpTables::getFlowingWaterFractionType( const Opm::VFPProdTable& table ) +{ + switch ( table.getWFRType() ) + { + case Opm::VFPProdTable::WFR_TYPE::WFR_WOR: + return RimVfpDefines::FlowingWaterFractionType::WOR; + case Opm::VFPProdTable::WFR_TYPE::WFR_WCT: + return RimVfpDefines::FlowingWaterFractionType::WCT; + case Opm::VFPProdTable::WFR_TYPE::WFR_WGR: + return RimVfpDefines::FlowingWaterFractionType::WGR; + default: + return RimVfpDefines::FlowingWaterFractionType::INVALID; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpDefines::FlowingGasFractionType RigVfpTables::getFlowingGasFractionType( const Opm::VFPProdTable& table ) +{ + switch ( table.getGFRType() ) + { + case Opm::VFPProdTable::GFR_TYPE::GFR_GOR: + return RimVfpDefines::FlowingGasFractionType::GOR; + case Opm::VFPProdTable::GFR_TYPE::GFR_GLR: + return RimVfpDefines::FlowingGasFractionType::GLR; + case Opm::VFPProdTable::GFR_TYPE::GFR_OGR: + return RimVfpDefines::FlowingGasFractionType::OGR; + default: + return RimVfpDefines::FlowingGasFractionType::INVALID; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigVfpTables::addInjectionTable( const Opm::VFPInjTable& table ) +{ + m_injectionTables.push_back( table ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigVfpTables::addProductionTable( const Opm::VFPProdTable& table ) +{ + m_productionTables.push_back( table ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigVfpTables::injectionTableNumbers() const +{ + std::vector tableNumbers; + + for ( const auto& table : m_injectionTables ) + { + tableNumbers.push_back( table.getTableNum() ); + } + + return tableNumbers; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigVfpTables::productionTableNumbers() const +{ + std::vector tableNumbers; + + for ( const auto& table : m_productionTables ) + { + tableNumbers.push_back( table.getTableNum() ); + } + + return tableNumbers; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +VfpTableInitialData RigVfpTables::getTableInitialData( int tableIndex ) const +{ + auto prodTable = productionTable( tableIndex ); + if ( prodTable.has_value() ) + { + VfpTableInitialData initialData; + initialData.isProductionTable = true; + initialData.tableNumber = prodTable->getTableNum(); + initialData.datumDepth = prodTable->getDatumDepth(); + initialData.flowingPhase = getFlowingPhaseType( *prodTable ); + initialData.waterFraction = getFlowingWaterFractionType( *prodTable ); + initialData.gasFraction = getFlowingGasFractionType( *prodTable ); + + return initialData; + } + + auto injTable = injectionTable( tableIndex ); + if ( injTable.has_value() ) + { + VfpTableInitialData initialData; + initialData.isProductionTable = false; + initialData.tableNumber = injTable->getTableNum(); + initialData.datumDepth = injTable->getDatumDepth(); + initialData.flowingPhase = getFlowingPhaseType( *injTable ); + return initialData; + } + + return {}; +} diff --git a/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h new file mode 100644 index 0000000000..a417ff4837 --- /dev/null +++ b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h @@ -0,0 +1,157 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "VerticalFlowPerformance/RimVfpDefines.h" + +#include + +#include +#include + +namespace Opm +{ +class VFPInjTable; +class VFPProdTable; +} // namespace Opm + +class VfpPlotData +{ +public: + void setXAxisTitle( const QString& xAxisTitle ) { m_xAxisTitle = xAxisTitle; } + void setYAxisTitle( const QString& yAxisTitle ) { m_yAxisTitle = yAxisTitle; } + + const QString& xAxisTitle() const { return m_xAxisTitle; } + const QString& yAxisTitle() const { return m_yAxisTitle; } + + void appendCurve( const QString& curveTitle, const std::vector& xData, const std::vector& yData ) + { + m_curveTitles.push_back( curveTitle ); + m_xData.push_back( xData ); + m_yData.push_back( yData ); + } + + const QString& curveTitle( size_t idx ) const { return m_curveTitles[idx]; } + + size_t size() const { return m_xData.size(); } + + size_t curveSize( size_t idx ) const { return m_xData[idx].size(); } + + const std::vector& xData( size_t idx ) const { return m_xData[idx]; } + const std::vector& yData( size_t idx ) const { return m_yData[idx]; } + +private: + QString m_xAxisTitle; + QString m_yAxisTitle; + std::vector m_curveTitles; + std::vector> m_xData; + std::vector> m_yData; +}; + +struct VfpTableSelection +{ + int flowRateIdx; + int thpIdx; + int articifialLiftQuantityIdx; + int waterCutIdx; + int gasLiquidRatioIdx; +}; + +struct VfpTableInitialData +{ + bool isProductionTable; + int tableNumber; + double datumDepth; + RimVfpDefines::FlowingPhaseType flowingPhase; + RimVfpDefines::FlowingWaterFractionType waterFraction; + RimVfpDefines::FlowingGasFractionType gasFraction; +}; + +//================================================================================================== +/// +//================================================================================================== +class RigVfpTables +{ +public: + void addInjectionTable( const Opm::VFPInjTable& table ); + void addProductionTable( const Opm::VFPProdTable& table ); + + std::vector injectionTableNumbers() const; + std::vector productionTableNumbers() const; + + VfpTableInitialData getTableInitialData( int tableIndex ) const; + + std::vector getProductionTableData( int tableIndex, RimVfpDefines::ProductionVariableType variableType ) const; + + VfpPlotData populatePlotData( int tableIndex, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase, + const VfpTableSelection& tableSelection ) const; + + QString asciiDataForTable( int tableNumber, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase, + const VfpTableSelection& tableSelection ) const; + +private: + static VfpPlotData populatePlotData( const Opm::VFPInjTable& table, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase ); + + static VfpPlotData populatePlotData( const Opm::VFPProdTable& table, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase, + const VfpTableSelection& tableSelection ); + + static QString axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ); + static QString getDisplayUnit( RimVfpDefines::ProductionVariableType variableType ); + static QString getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType variableType ); + + static double convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType ); + static void convertToDisplayUnit( std::vector& values, RimVfpDefines::ProductionVariableType variableType ); + + static QString textForPlotData( const VfpPlotData& plotData ); + + static std::vector getProductionTableData( const Opm::VFPProdTable& table, RimVfpDefines::ProductionVariableType variableType ); + static size_t getVariableIndex( const Opm::VFPProdTable& table, + RimVfpDefines::ProductionVariableType targetVariable, + RimVfpDefines::ProductionVariableType primaryVariable, + size_t primaryValue, + RimVfpDefines::ProductionVariableType familyVariable, + size_t familyValue, + const VfpTableSelection& tableSelection ); + + std::optional injectionTable( int tableNumber ) const; + std::optional productionTable( int tableNumber ) const; + + static RimVfpDefines::FlowingPhaseType getFlowingPhaseType( const Opm::VFPProdTable& table ); + static RimVfpDefines::FlowingPhaseType getFlowingPhaseType( const Opm::VFPInjTable& table ); + static RimVfpDefines::FlowingWaterFractionType getFlowingWaterFractionType( const Opm::VFPProdTable& table ); + static RimVfpDefines::FlowingGasFractionType getFlowingGasFractionType( const Opm::VFPProdTable& table ); + +private: + std::vector m_injectionTables; + std::vector m_productionTables; +}; From bbebdbba4c4d2e923a32ff6040906cde80a71f34 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 21 May 2024 14:51:20 +0200 Subject: [PATCH 079/332] Bump to Python 3.11 --- .github/workflows/ResInsightWithCache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 6d6514d505..af57454aa2 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -72,7 +72,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.11" - name: Display Python version run: python -c "import sys; print(sys.version)" From 11563666e6ff0aee6223d0da81185bcd720dbabf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 22 May 2024 09:43:12 +0200 Subject: [PATCH 080/332] #11358 Guard overwrite of already calculated statistics values Statistics can be computed in two ways, precise using all available cell values and fast based on a histogram. A flag indicates if the P10/P90 values are calculated. Check this flag before assigning values using the fast histogram method. --- .../RigStatisticsDataCache.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.cpp b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.cpp index 506fc60b49..1a4b991793 100644 --- a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.cpp +++ b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.cpp @@ -396,8 +396,13 @@ void RigStatisticsDataCache::computeHistogramStatisticsIfNeeded() m_statisticsCalculator->addDataToHistogramCalculator( histCalc ); - m_statsAllTimesteps.m_p10 = histCalc.calculatePercentil( 0.1, RigStatisticsMath::PercentileStyle::SWITCHED ); - m_statsAllTimesteps.m_p90 = histCalc.calculatePercentil( 0.9, RigStatisticsMath::PercentileStyle::SWITCHED ); + if ( !m_statsAllTimesteps.m_isp10p90Calculated ) + { + m_statsAllTimesteps.m_p10 = histCalc.calculatePercentil( 0.1, RigStatisticsMath::PercentileStyle::SWITCHED ); + m_statsAllTimesteps.m_p90 = histCalc.calculatePercentil( 0.9, RigStatisticsMath::PercentileStyle::SWITCHED ); + + m_statsAllTimesteps.m_isp10p90Calculated = true; + } } } @@ -416,8 +421,13 @@ void RigStatisticsDataCache::computeHistogramStatisticsIfNeeded( size_t timeStep m_statisticsCalculator->addDataToHistogramCalculator( timeStepIndex, histCalc ); - m_statsPrTs[timeStepIndex].m_p10 = histCalc.calculatePercentil( 0.1, RigStatisticsMath::PercentileStyle::SWITCHED ); - m_statsPrTs[timeStepIndex].m_p90 = histCalc.calculatePercentil( 0.9, RigStatisticsMath::PercentileStyle::SWITCHED ); + if ( !m_statsPrTs[timeStepIndex].m_isp10p90Calculated ) + { + m_statsPrTs[timeStepIndex].m_p10 = histCalc.calculatePercentil( 0.1, RigStatisticsMath::PercentileStyle::SWITCHED ); + m_statsPrTs[timeStepIndex].m_p90 = histCalc.calculatePercentil( 0.9, RigStatisticsMath::PercentileStyle::SWITCHED ); + + m_statsPrTs[timeStepIndex].m_isp10p90Calculated = true; + } } } From 809f5597923672a8fca1725231c39d2a0e053a0c Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 22 May 2024 11:14:12 +0200 Subject: [PATCH 081/332] Add test for reading Parquet files using Apache Arrow. --- ApplicationLibCode/UnitTests/CMakeLists.txt | 1 + .../UnitTests/RifParquetReader-Test.cpp | 52 ++++++++++++++++++ .../TestData/RifParquetReader/example.parquet | Bin 0 -> 1478 bytes CMakeLists.txt | 20 +++++++ vcpkg_x64-linux.txt | 1 + vcpkg_x64-osx.txt | 1 + vcpkg_x64-windows.txt | 1 + 7 files changed, 76 insertions(+) create mode 100644 ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp create mode 100644 ApplicationLibCode/UnitTests/TestData/RifParquetReader/example.parquet diff --git a/ApplicationLibCode/UnitTests/CMakeLists.txt b/ApplicationLibCode/UnitTests/CMakeLists.txt index d25c8bd5c9..ac7d8e0de6 100644 --- a/ApplicationLibCode/UnitTests/CMakeLists.txt +++ b/ApplicationLibCode/UnitTests/CMakeLists.txt @@ -102,6 +102,7 @@ set(SOURCE_UNITTEST_FILES ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationIO-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEmReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifParquetReader-Test.cpp ) if(RESINSIGHT_ENABLE_GRPC) diff --git a/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp b/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp new file mode 100644 index 0000000000..bcc0138287 --- /dev/null +++ b/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp @@ -0,0 +1,52 @@ +#include "gtest/gtest.h" + +#include "RiaTestDataDirectory.h" + +#include +#include +#include +#include +#include + +#include +#include + +TEST( RifParquetReaderTest, ReadValidFile ) +{ + QDir baseFolder( TEST_DATA_DIR ); + + QString filename( "RifParquetReader/example.parquet" ); + QString filePath = baseFolder.absoluteFilePath( filename ); + EXPECT_TRUE( QFile::exists( filePath ) ); + + arrow::MemoryPool* pool = arrow::default_memory_pool(); + + auto openResult = arrow::io::ReadableFile::Open( filePath.toStdString().c_str() ); + EXPECT_TRUE( openResult.ok() ); + + std::shared_ptr input = std::move( openResult ).ValueOrDie(); + + // Open Parquet file reader + std::unique_ptr arrow_reader; + EXPECT_TRUE( parquet::arrow::OpenFile( input, pool, &arrow_reader ).ok() ); + + // Read entire file as a single Arrow table + std::shared_ptr table; + EXPECT_TRUE( arrow_reader->ReadTable( &table ).ok() ); + + // Expect one column named "col1" + EXPECT_EQ( table->columns().size(), 1 ); + std::vector expectedNames = { "col1" }; + EXPECT_EQ( table->ColumnNames(), expectedNames ); + + // Expected the column to contain 100 int64 [0, 99] + auto columnData = table->column( 0 ); + int expectedSize = 100; + EXPECT_EQ( columnData->length(), expectedSize ); + for ( int i = 0; i < expectedSize; i++ ) + { + std::shared_ptr scalar = columnData->GetScalar( i ).ValueOrDie(); + std::shared_ptr intScalar = std::dynamic_pointer_cast( scalar ); + EXPECT_TRUE( scalar->Equals( arrow::Int64Scalar( i ) ) ); + } +} diff --git a/ApplicationLibCode/UnitTests/TestData/RifParquetReader/example.parquet b/ApplicationLibCode/UnitTests/TestData/RifParquetReader/example.parquet new file mode 100644 index 0000000000000000000000000000000000000000..96d4beda6c624bdbbc8ae99c75c7b66f6226fa58 GIT binary patch literal 1478 zcmcK4%Wo1v90%~(7AYzgd@Sy^YsE(qD^RGVR+QS|C4B>0TdURrB1jOB)u5Afy;eCf%H2Y*@SGc&vV=10Q*LNwwKRpPpq zU4vp-5Xla*5dvm)upX-5Ca8uDPy;u^EpRK;!fmh->YyHOhqaP+V!aEB&;WNs3Cgeu zHbVvOfh}+^G{SvwKRf^r!d7U4hoBiAhHdZ&v_LDg!FFhe4%h*Y!cORfUGNy}hR2}` zo`5Hz8}`6cuoqJ3fnMl?ei(qKVG#DgemDRJ;Sd~#BQONRFapoOvv3rigJW!AW=-PQfUQ!8jBNe^bhWg`*eMqFRwOwVP7y-%kw0{Fhypqn>@rg3!=BH#gO5 zmKx{p#NMX5TNdZ9c%F>gmhN4B_r27!yqNN}Js4iOpMIZyJ-ND+2|W9nU3-}Q@bmZW z_2qof(zH;1T=x^&ozZtjNm$E`k4+ zvS89MSx1l+NlPP Date: Mon, 26 Feb 2024 15:40:13 +0100 Subject: [PATCH 082/332] Rename SSIHUB to Osdu. --- ApplicationLibCode/Commands/CMakeLists.txt | 2 +- .../CMakeLists_files.cmake | 4 ++-- .../RicWellPathsImportOsduFeature.cpp} | 2 +- .../RicWellPathsImportOsduFeature.h} | 0 .../RimOilFieldEntry.cpp | 0 .../RimOilFieldEntry.h | 0 .../RimOilRegionEntry.cpp | 0 .../RimOilRegionEntry.h | 0 .../RimWellPathImport.cpp | 0 .../RimWellPathImport.h | 0 .../RimWellsEntry.cpp | 0 .../RimWellsEntry.h | 0 .../RiuWellImportWizard.cpp | 0 .../RiuWellImportWizard.h | 0 ApplicationLibCode/ProjectDataModel/RimProject.cpp | 2 +- 15 files changed, 5 insertions(+), 5 deletions(-) rename ApplicationLibCode/Commands/{SsiHubImportCommands => OsduImportCommands}/CMakeLists_files.cmake (88%) rename ApplicationLibCode/Commands/{SsiHubImportCommands/RicWellPathsImportSsihubFeature.cpp => OsduImportCommands/RicWellPathsImportOsduFeature.cpp} (99%) rename ApplicationLibCode/Commands/{SsiHubImportCommands/RicWellPathsImportSsihubFeature.h => OsduImportCommands/RicWellPathsImportOsduFeature.h} (100%) rename ApplicationLibCode/Commands/{SsiHubImportCommands => OsduImportCommands}/RimOilFieldEntry.cpp (100%) rename ApplicationLibCode/Commands/{SsiHubImportCommands => OsduImportCommands}/RimOilFieldEntry.h (100%) rename ApplicationLibCode/Commands/{SsiHubImportCommands => OsduImportCommands}/RimOilRegionEntry.cpp (100%) rename ApplicationLibCode/Commands/{SsiHubImportCommands => OsduImportCommands}/RimOilRegionEntry.h (100%) rename ApplicationLibCode/Commands/{SsiHubImportCommands => OsduImportCommands}/RimWellPathImport.cpp (100%) rename ApplicationLibCode/Commands/{SsiHubImportCommands => OsduImportCommands}/RimWellPathImport.h (100%) rename ApplicationLibCode/Commands/{SsiHubImportCommands => OsduImportCommands}/RimWellsEntry.cpp (100%) rename ApplicationLibCode/Commands/{SsiHubImportCommands => OsduImportCommands}/RimWellsEntry.h (100%) rename ApplicationLibCode/Commands/{SsiHubImportCommands => OsduImportCommands}/RiuWellImportWizard.cpp (100%) rename ApplicationLibCode/Commands/{SsiHubImportCommands => OsduImportCommands}/RiuWellImportWizard.h (100%) diff --git a/ApplicationLibCode/Commands/CMakeLists.txt b/ApplicationLibCode/Commands/CMakeLists.txt index 740ee78f12..f3cd9401e4 100644 --- a/ApplicationLibCode/Commands/CMakeLists.txt +++ b/ApplicationLibCode/Commands/CMakeLists.txt @@ -30,7 +30,7 @@ set(COMMAND_REFERENCED_CMAKE_FILES OctaveScriptCommands/CMakeLists_files.cmake OperationsUsingObjReferences/CMakeLists_files.cmake SummaryPlotCommands/CMakeLists_files.cmake - SsiHubImportCommands/CMakeLists_files.cmake + OsduImportCommands/CMakeLists_files.cmake StreamlineCommands/CMakeLists_files.cmake SurfaceCommands/CMakeLists_files.cmake SeismicCommands/CMakeLists_files.cmake diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake similarity index 88% rename from ApplicationLibCode/Commands/SsiHubImportCommands/CMakeLists_files.cmake rename to ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake index 965f2d80a2..e4c129fb5b 100644 --- a/ApplicationLibCode/Commands/SsiHubImportCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake @@ -1,5 +1,5 @@ set(SOURCE_GROUP_HEADER_FILES - ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportSsihubFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportOsduFeature.h ${CMAKE_CURRENT_LIST_DIR}/RimOilFieldEntry.h ${CMAKE_CURRENT_LIST_DIR}/RimOilRegionEntry.h ${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.h @@ -8,7 +8,7 @@ set(SOURCE_GROUP_HEADER_FILES ) set(SOURCE_GROUP_SOURCE_FILES - ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportSsihubFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportOsduFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RimOilFieldEntry.cpp ${CMAKE_CURRENT_LIST_DIR}/RimOilRegionEntry.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.cpp diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp similarity index 99% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.cpp rename to ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index 4f56806884..bf0c27b95e 100644 --- a/ApplicationLibCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -17,7 +17,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicWellPathsImportSsihubFeature.h" +#include "RicWellPathsImportOsduFeature.h" #include "RiaApplication.h" #include "RiaGuiApplication.h" diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.h b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.h similarity index 100% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.h rename to ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.h diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilFieldEntry.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.cpp similarity index 100% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RimOilFieldEntry.cpp rename to ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.cpp diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilFieldEntry.h b/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.h similarity index 100% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RimOilFieldEntry.h rename to ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.h diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilRegionEntry.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.cpp similarity index 100% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RimOilRegionEntry.cpp rename to ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.cpp diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilRegionEntry.h b/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.h similarity index 100% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RimOilRegionEntry.h rename to ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.h diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellPathImport.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp similarity index 100% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RimWellPathImport.cpp rename to ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellPathImport.h b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h similarity index 100% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RimWellPathImport.h rename to ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellsEntry.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.cpp similarity index 100% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RimWellsEntry.cpp rename to ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.cpp diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellsEntry.h b/ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.h similarity index 100% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RimWellsEntry.h rename to ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.h diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp similarity index 100% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.cpp rename to ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h similarity index 100% rename from ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.h rename to ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index c6dd1c33a6..a9ae2a490b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -112,7 +112,7 @@ #include "RimGridStatisticsPlotCollection.h" #endif -#include "SsiHubImportCommands/RimWellPathImport.h" +#include "OsduImportCommands/RimWellPathImport.h" #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" From d02dd2dfedd9882d28a5bf49359f8ac1de54af9d Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 4 Mar 2024 10:21:08 +0100 Subject: [PATCH 083/332] Add Qt network auth to github actions. --- .github/workflows/ResInsightWithCache.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index af57454aa2..ee9cd8bc02 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -175,6 +175,7 @@ jobs: version: 5.12.12 dir: "${{ github.workspace }}/Qt/" cache: true + modules: "qtnetworkauth" - name: Restore from cache and install vcpkg uses: lukka/run-vcpkg@v7 From 577ef1e15490dbb73e2a2725a1fcca775a3b8fa8 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 28 Feb 2024 08:10:52 +0100 Subject: [PATCH 084/332] Add support for well paths from OSDU. --- .../Application/CMakeLists_files.cmake | 5 + .../Application/RiaFileDownloader.cpp | 54 + .../Application/RiaFileDownloader.h | 16 + .../Application/RiaPreferences.cpp | 24 + .../Application/RiaPreferences.h | 7 + .../Application/RiaPreferencesOsdu.cpp | 84 ++ .../Application/RiaPreferencesOsdu.h | 48 + ApplicationLibCode/CMakeLists.txt | 2 + .../OsduImportCommands/CMakeLists_files.cmake | 7 +- .../OsduImportCommands/RiaOsduConnector.cpp | 652 ++++++++++ .../OsduImportCommands/RiaOsduConnector.h | 136 +++ .../RiaOsduOAuthHttpServerReplyHandler.cpp | 24 + .../RiaOsduOAuthHttpServerReplyHandler.h | 38 + .../RicWellPathsImportOsduFeature.cpp | 118 +- .../RicWellPathsImportOsduFeature.h | 2 +- .../OsduImportCommands/RimWellPathImport.cpp | 161 +-- .../OsduImportCommands/RimWellPathImport.h | 12 +- .../RiuWellImportWizard.cpp | 1047 +++-------------- .../OsduImportCommands/RiuWellImportWizard.h | 347 +++--- .../FileInterface/CMakeLists_files.cmake | 2 + .../FileInterface/RifOsduWellPathReader.cpp | 92 ++ .../FileInterface/RifOsduWellPathReader.h | 35 + .../RimContextCommandBuilder.cpp | 2 +- .../ProjectDataModel/RimProject.cpp | 3 - .../WellPath/CMakeLists_files.cmake | 2 + .../WellPath/RimOsduWellPath.cpp | 110 ++ .../WellPath/RimOsduWellPath.h | 50 + .../WellPath/RimWellPathCollection.cpp | 47 + .../WellPath/RimWellPathCollection.h | 3 + ApplicationLibCode/UnitTests/CMakeLists.txt | 1 + .../UnitTests/RifOsduWellPathReader-Test.cpp | 59 + .../UserInterface/RiuMenuBarBuildTools.cpp | 2 +- CMakeLists.txt | 3 +- 33 files changed, 1965 insertions(+), 1230 deletions(-) create mode 100644 ApplicationLibCode/Application/RiaFileDownloader.cpp create mode 100644 ApplicationLibCode/Application/RiaFileDownloader.h create mode 100644 ApplicationLibCode/Application/RiaPreferencesOsdu.cpp create mode 100644 ApplicationLibCode/Application/RiaPreferencesOsdu.h create mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp create mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h create mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.cpp create mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.h create mode 100644 ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp create mode 100644 ApplicationLibCode/FileInterface/RifOsduWellPathReader.h create mode 100644 ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h create mode 100644 ApplicationLibCode/UnitTests/RifOsduWellPathReader-Test.cpp diff --git a/ApplicationLibCode/Application/CMakeLists_files.cmake b/ApplicationLibCode/Application/CMakeLists_files.cmake index ed89dbc257..f8745d79ac 100644 --- a/ApplicationLibCode/Application/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/CMakeLists_files.cmake @@ -9,6 +9,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSummary.h ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGeoMech.h ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.h + ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.h ${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.h ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.h ${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.h @@ -35,6 +36,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.h + ${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -48,6 +50,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSummary.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGeoMech.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.cpp @@ -74,6 +77,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) @@ -87,6 +91,7 @@ set(QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.h ${CMAKE_CURRENT_LIST_DIR}/RiaPlotWindowRedrawScheduler.h ${CMAKE_CURRENT_LIST_DIR}/RiaScheduler.h + ${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h ) source_group( diff --git a/ApplicationLibCode/Application/RiaFileDownloader.cpp b/ApplicationLibCode/Application/RiaFileDownloader.cpp new file mode 100644 index 0000000000..8fbcd5b30a --- /dev/null +++ b/ApplicationLibCode/Application/RiaFileDownloader.cpp @@ -0,0 +1,54 @@ +#include "RiaFileDownloader.h" + +#include +#include +#include +#include +#include +#include + +#include "RiaLogging.h" + +RiaFileDownloader::RiaFileDownloader( QObject* parent ) + : QObject( parent ) +{ +} + +void RiaFileDownloader::downloadFile( const QUrl& url, const QString& filePath ) +{ + QNetworkAccessManager* manager = new QNetworkAccessManager( this ); + QNetworkRequest request( url ); + + RiaLogging::debug( "Downloading from: " + url.toString() ); + + QNetworkReply* reply = manager->get( request ); + + connect( reply, + &QNetworkReply::finished, + [=]() + { + if ( reply->error() ) + { + RiaLogging::error( "Download failed:" + reply->errorString() ); + emit done(); + } + else + { + QFile file( filePath ); + if ( file.open( QIODevice::WriteOnly ) ) + { + file.write( reply->readAll() ); + file.close(); + RiaLogging::info( "Download succeeded. File saved to " + filePath ); + emit done(); + } + else + { + RiaLogging::info( "Failed to save file to " + filePath ); + emit done(); + } + } + reply->deleteLater(); + manager->deleteLater(); + } ); +} diff --git a/ApplicationLibCode/Application/RiaFileDownloader.h b/ApplicationLibCode/Application/RiaFileDownloader.h new file mode 100644 index 0000000000..a29cfe423b --- /dev/null +++ b/ApplicationLibCode/Application/RiaFileDownloader.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include +#include + +class RiaFileDownloader : public QObject +{ + Q_OBJECT +public: + explicit RiaFileDownloader( QObject* parent = nullptr ); + + void downloadFile( const QUrl& url, const QString& filePath ); +signals: + void done(); +}; diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index 1f0269778f..eb2bbee2f1 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -279,6 +279,9 @@ RiaPreferences::RiaPreferences() CAF_PDM_InitFieldNoDefault( &m_systemPreferences, "systemPreferences", "systemPreferences" ); m_systemPreferences = new RiaPreferencesSystem; + + CAF_PDM_InitFieldNoDefault( &m_osduPreferences, "osduPreferences", "osduPreferences" ); + m_osduPreferences = new RiaPreferencesOsdu; } //-------------------------------------------------------------------------------------------------- @@ -487,6 +490,10 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& m_loggerTrapSignalAndFlush.uiCapability()->setUiReadOnly( !m_loggerFilename().first ); m_loggerFlushInterval.uiCapability()->setUiReadOnly( !m_loggerFilename().first ); } + else if ( uiConfigName == RiaPreferences::tabNameOsdu() ) + { + m_osduPreferences()->uiOrdering( uiConfigName, uiOrdering ); + } else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() ) { m_systemPreferences()->uiOrdering( uiConfigName, uiOrdering ); @@ -614,6 +621,14 @@ QString RiaPreferences::tabNameSystem() return "System"; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferences::tabNameOsdu() +{ + return "Osdu"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -654,6 +669,7 @@ QStringList RiaPreferences::tabNames() names << tabNameGeomech(); #endif names << tabNameImportExport(); + names << tabNameOsdu(); if ( RiaApplication::enableDevelopmentFeatures() ) { @@ -1018,6 +1034,14 @@ RiaPreferencesGeoMech* RiaPreferences::geoMechPreferences() const return m_geoMechPreferences(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesOsdu* RiaPreferences::osduPreferences() const +{ + return m_osduPreferences(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferences.h b/ApplicationLibCode/Application/RiaPreferences.h index 78f6d283c8..8f6d5e8b48 100644 --- a/ApplicationLibCode/Application/RiaPreferences.h +++ b/ApplicationLibCode/Application/RiaPreferences.h @@ -24,6 +24,7 @@ #include "RiaDateTimeDefines.h" #include "RiaDefines.h" #include "RiaFontCache.h" +#include "RiaPreferencesOsdu.h" #include "cafAppEnum.h" #include "cafPdmChildField.h" @@ -43,6 +44,7 @@ class RifReaderSettings; class RiaPreferencesSummary; class RiaPreferencesGeoMech; class RiaPreferencesSystem; +class RiaPreferencesOsdu; //-------------------------------------------------------------------------------------------------- /// @@ -125,6 +127,7 @@ class RiaPreferences : public caf::PdmObject RiaPreferencesGeoMech* geoMechPreferences() const; RiaPreferencesSummary* summaryPreferences() const; RiaPreferencesSystem* systemPreferences() const; + RiaPreferencesOsdu* osduPreferences() const; public: caf::PdmField enableGrpcServer; @@ -170,6 +173,7 @@ class RiaPreferences : public caf::PdmObject static QString tabNamePlotting(); static QString tabNameScripting(); static QString tabNameSystem(); + static QString tabNameOsdu(); static QString tabNameImportExport(); static double defaultMarginSize( QPageSize::PageSizeId pageSizeId ); @@ -230,6 +234,9 @@ class RiaPreferences : public caf::PdmObject // System settings caf::PdmChildField m_systemPreferences; + // Osdu settings + caf::PdmChildField m_osduPreferences; + // 3d view caf::PdmField> m_defaultMeshModeType; caf::PdmField> m_navigationPolicy; diff --git a/ApplicationLibCode/Application/RiaPreferencesOsdu.cpp b/ApplicationLibCode/Application/RiaPreferencesOsdu.cpp new file mode 100644 index 0000000000..941390f345 --- /dev/null +++ b/ApplicationLibCode/Application/RiaPreferencesOsdu.cpp @@ -0,0 +1,84 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RiaApplication.h" + +#include "RiaPreferences.h" +#include "RiaPreferencesOsdu.h" + +CAF_PDM_SOURCE_INIT( RiaPreferencesOsdu, "RiaPreferencesOsdu" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesOsdu::RiaPreferencesOsdu() +{ + CAF_PDM_InitFieldNoDefault( &m_server, "server", "Server" ); + CAF_PDM_InitFieldNoDefault( &m_dataPartitionId, "dataPartitionId", "Data Partition Id" ); + CAF_PDM_InitFieldNoDefault( &m_authority, "authority", "Authority" ); + CAF_PDM_InitFieldNoDefault( &m_scopes, "scopes", "Scopes" ); + CAF_PDM_InitFieldNoDefault( &m_clientId, "clientId", "Client Id" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesOsdu* RiaPreferencesOsdu::current() +{ + return RiaApplication::instance()->preferences()->osduPreferences(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesOsdu::server() const +{ + return m_server; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesOsdu::dataPartitionId() const +{ + return m_dataPartitionId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesOsdu::authority() const +{ + return m_authority; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesOsdu::scopes() const +{ + return m_scopes; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesOsdu::clientId() const +{ + return m_clientId; +} diff --git a/ApplicationLibCode/Application/RiaPreferencesOsdu.h b/ApplicationLibCode/Application/RiaPreferencesOsdu.h new file mode 100644 index 0000000000..6a0643b082 --- /dev/null +++ b/ApplicationLibCode/Application/RiaPreferencesOsdu.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "cafPdmField.h" +#include "cafPdmObject.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RiaPreferencesOsdu : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RiaPreferencesOsdu(); + + static RiaPreferencesOsdu* current(); + + QString server() const; + QString dataPartitionId() const; + QString authority() const; + QString scopes() const; + QString clientId() const; + +private: + caf::PdmField m_server; + caf::PdmField m_dataPartitionId; + caf::PdmField m_authority; + caf::PdmField m_scopes; + caf::PdmField m_clientId; +}; diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index 67ad84624b..01d647af09 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -32,6 +32,7 @@ if(Qt5Core_FOUND) Gui OpenGL Network + NetworkAuth Widgets Xml Concurrent @@ -44,6 +45,7 @@ if(Qt5Core_FOUND) Qt5::Core Qt5::Gui Qt5::Network + Qt5::NetworkAuth Qt5::OpenGL Qt5::Widgets Qt5::Xml diff --git a/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake index e4c129fb5b..af4c5c046d 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake @@ -5,6 +5,8 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.h ${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -14,14 +16,17 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) -list(APPEND COMMAND_QT_MOC_HEADERS +list(APPEND COMMAND_QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h ) source_group( diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp new file mode 100644 index 0000000000..5d30c250f0 --- /dev/null +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -0,0 +1,652 @@ +#include "RiaOsduConnector.h" +#include "RiaFileDownloader.h" +#include "RiaLogging.h" +#include "RiaOsduOAuthHttpServerReplyHandler.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaOsduConnector::RiaOsduConnector( QObject* parent, + const QString& server, + const QString& dataPartitionId, + const QString& authority, + const QString& scopes, + const QString& clientId ) + : QObject( parent ) + , m_server( server ) + , m_dataPartitionId( dataPartitionId ) + , m_authority( authority ) + , m_scopes( scopes ) + , m_clientId( clientId ) +{ + m_networkAccessManager = new QNetworkAccessManager( this ); + + m_osdu = new QOAuth2AuthorizationCodeFlow( this ); + + RiaLogging::debug( "SSL BUILD VERSION: " + QSslSocket::sslLibraryBuildVersionString() ); + RiaLogging::debug( "SSL VERSION STRING: " + QSslSocket::sslLibraryVersionString() ); + + int port = 35327; + + connect( m_osdu, + &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, + []( QUrl url ) + { + RiaLogging::info( "Authorize with url: " + url.toString() ); + QUrlQuery query( url ); + url.setQuery( query ); + QDesktopServices::openUrl( url ); + } ); + + QString authUrl = constructAuthUrl( m_authority ); + m_osdu->setAuthorizationUrl( QUrl( authUrl ) ); + + QString tokenUrl = constructTokenUrl( m_authority ); + m_osdu->setAccessTokenUrl( QUrl( tokenUrl ) ); + + // App key + m_osdu->setClientIdentifier( m_clientId ); + m_osdu->setScope( m_scopes ); + + auto replyHandler = new RiaOsduOAuthHttpServerReplyHandler( port, this ); + m_osdu->setReplyHandler( replyHandler ); + + connect( m_osdu, SIGNAL( granted() ), this, SLOT( accessGranted() ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::accessGranted() +{ + m_token = m_osdu->token(); + emit tokenReady( m_token ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestToken() +{ + RiaLogging::debug( "Requesting token." ); + m_osdu->grant(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaOsduConnector::~RiaOsduConnector() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestFieldsByName( const QString& token, const QString& fieldName ) +{ + requestFieldsByName( m_server, m_dataPartitionId, token, fieldName ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestFieldsByName( const QString& fieldName ) +{ + requestFieldsByName( m_token, fieldName ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestFieldsByName( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldName ) +{ + std::map params; + params["kind"] = FIELD_KIND; + params["limit"] = "10000"; + params["query"] = "data.FieldName:" + fieldName; + + auto reply = makeRequest( params, server, dataPartitionId, token ); + connect( reply, + &QNetworkReply::finished, + [this, reply]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + parseFields( reply ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestWellsByFieldId( const QString& fieldId ) +{ + requestWellsByFieldId( m_server, m_dataPartitionId, m_token, fieldId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestWellsByFieldId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldId ) +{ + std::map params; + params["kind"] = WELL_KIND; + params["limit"] = "10000"; + params["query"] = QString( "nested(data.GeoContexts, (FieldID:\"%1\"))" ).arg( fieldId ); + + auto reply = makeRequest( params, server, dataPartitionId, token ); + connect( reply, + &QNetworkReply::finished, + [this, reply, fieldId]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + parseWells( reply ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestWellboresByWellId( const QString& wellId ) +{ + requestWellboresByWellId( m_server, m_dataPartitionId, m_token, wellId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestWellboresByWellId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellId ) +{ + std::map params; + params["kind"] = WELLBORE_KIND; + params["limit"] = "10000"; + params["query"] = "data.WellID: \"" + wellId + "\""; + + auto reply = makeRequest( params, server, dataPartitionId, token ); + connect( reply, + &QNetworkReply::finished, + [this, reply, wellId]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + parseWellbores( reply, wellId ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& wellboreId ) +{ + requestWellboreTrajectoryByWellboreId( m_server, m_dataPartitionId, m_token, wellboreId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestFileDownloadByFileId( const QString& fileId ) +{ + requestFileDownloadByFileId( m_server, m_dataPartitionId, m_token, fileId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& server, + const QString& dataPartitionId, + const QString& token, + const QString& wellboreId ) +{ + std::map params; + params["kind"] = WELLBORE_TRAJECTORY_KIND; + params["limit"] = "10000"; + params["query"] = "data.WellboreID: \"" + wellboreId + "\""; + + auto reply = makeRequest( params, server, dataPartitionId, token ); + connect( reply, + &QNetworkReply::finished, + [this, reply, wellboreId]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + parseWellTrajectory( reply, wellboreId ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestFileDownloadByFileId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fileId ) +{ + RiaLogging::info( "Requesting download of file id: " + fileId ); + auto reply = makeDownloadRequest( server, dataPartitionId, fileId, token ); + connect( reply, + &QNetworkReply::finished, + [this, reply, fileId]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + saveFile( reply, fileId ); + } + else + { + RiaLogging::error( "File request for id " + fileId + " failed." + reply->errorString() ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +// +//-------------------------------------------------------------------------------------------------- +QString RiaOsduConnector::constructSearchUrl( const QString& server ) +{ + return server + "/api/search/v2/query"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaOsduConnector::constructDownloadUrl( const QString& server, const QString& fileId ) +{ + return server + "/api/file/v2/files/" + fileId + "/downloadURL"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaOsduConnector::constructAuthUrl( const QString& authority ) +{ + return authority + "/oauth2/v2.0/authorize"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaOsduConnector::constructTokenUrl( const QString& authority ) +{ + return authority + "/oauth2/v2.0/token"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QNetworkReply* RiaOsduConnector::makeRequest( const std::map& parameters, + const QString& server, + const QString& dataPartitionId, + const QString& token ) +{ + QNetworkRequest m_networkRequest; + m_networkRequest.setUrl( QUrl( constructSearchUrl( server ) ) ); + + addStandardHeader( m_networkRequest, token, dataPartitionId ); + + QJsonObject obj; + for ( auto [key, value] : parameters ) + { + obj.insert( key, value ); + } + + QJsonDocument doc( obj ); + QString strJson( doc.toJson( QJsonDocument::Compact ) ); + + auto reply = m_networkAccessManager->post( m_networkRequest, strJson.toUtf8() ); + return reply; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::parseFields( QNetworkReply* reply ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + if ( reply->error() == QNetworkReply::NoError ) + { + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + QJsonArray resultsArray = jsonObj["results"].toArray(); + + m_fields.clear(); + + foreach ( const QJsonValue& value, resultsArray ) + { + QJsonObject resultObj = value.toObject(); + + QString id = resultObj["id"].toString(); + QString kind = resultObj["kind"].toString(); + QString fieldName = resultObj["data"].toObject()["FieldName"].toString(); + m_fields.push_back( OsduField{ id, kind, fieldName } ); + } + + emit fieldsFinished(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::parseWells( QNetworkReply* reply ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + if ( reply->error() == QNetworkReply::NoError ) + { + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + QJsonArray resultsArray = jsonObj["results"].toArray(); + + RiaLogging::info( QString( "Found %1 wells." ).arg( +resultsArray.size() ) ); + + m_wells.clear(); + foreach ( const QJsonValue& value, resultsArray ) + { + QJsonObject resultObj = value.toObject(); + QString id = resultObj["id"].toString(); + QString kind = resultObj["kind"].toString(); + QString name = resultObj["data"].toObject()["FacilityName"].toString(); + m_wells.push_back( OsduWell{ id, kind, name } ); + } + + emit wellsFinished(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::parseWellbores( QNetworkReply* reply, const QString& wellId ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + if ( reply->error() == QNetworkReply::NoError ) + { + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + QJsonArray resultsArray = jsonObj["results"].toArray(); + + RiaLogging::info( QString( "Found %1 wellbores." ).arg( resultsArray.size() ) ); + + m_wellbores[wellId].clear(); + foreach ( const QJsonValue& value, resultsArray ) + { + QJsonObject resultObj = value.toObject(); + QString id = resultObj["id"].toString(); + QString kind = resultObj["kind"].toString(); + QString name = resultObj["data"].toObject()["FacilityName"].toString(); + m_wellbores[wellId].push_back( OsduWellbore{ id, kind, name, wellId } ); + } + + emit wellboresFinished( wellId ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::parseWellTrajectory( QNetworkReply* reply, const QString& wellboreId ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + if ( reply->error() == QNetworkReply::NoError ) + { + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + QJsonArray resultsArray = jsonObj["results"].toArray(); + m_wellboreTrajectories.clear(); + foreach ( const QJsonValue& value, resultsArray ) + { + QJsonObject resultObj = value.toObject(); + QJsonObject dataObj = resultObj["data"].toObject(); + QJsonArray dataSets = dataObj["Datasets"].toArray(); + if ( dataSets.size() == 1 ) + { + QString id = resultObj["id"].toString(); + QString kind = resultObj["kind"].toString(); + QString dataSetId = dataSets[0].toString(); + QString description = dataObj["Description"].toString(); + + m_wellboreTrajectories[wellboreId].push_back( OsduWellboreTrajectory{ id, kind, description, dataSetId, wellboreId } ); + } + else if ( dataSets.size() > 1 ) + { + RiaLogging::error( "Encountered dataset with more than on file: currently not supported." ); + } + } + + emit wellboreTrajectoryFinished( wellboreId ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::saveFile( QNetworkReply* reply, const QString& fileId ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + if ( reply->error() == QNetworkReply::NoError ) + { + QEventLoop loop; + + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + + QString signedUrl = jsonObj["SignedUrl"].toString(); + + RiaFileDownloader* downloader = new RiaFileDownloader; + QUrl url( signedUrl ); + QString filePath = "/tmp/" + generateRandomString( 30 ) + ".txt"; + + QString formattedJsonString = doc.toJson( QJsonDocument::Indented ); + + RiaLogging::info( QString( "File download: %1 => %2" ).arg( signedUrl ).arg( filePath ) ); + connect( this, SIGNAL( fileDownloadFinished( const QString&, const QString& ) ), &loop, SLOT( quit() ) ); + connect( downloader, + &RiaFileDownloader::done, + [this, fileId, filePath]() + { + RiaLogging::info( QString( "Download complete %1 => %2" ).arg( fileId ).arg( filePath ) ); + emit( fileDownloadFinished( fileId, filePath ) ); + } ); + RiaLogging::info( "Starting download" ); + downloader->downloadFile( url, filePath ); + + downloader->deleteLater(); + loop.exec(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& dataPartitionId ) +{ + networkRequest.setHeader( QNetworkRequest::ContentTypeHeader, "application/json" ); + networkRequest.setRawHeader( "Authorization", "Bearer " + token.toUtf8() ); + networkRequest.setRawHeader( QByteArray( "Data-Partition-Id" ), dataPartitionId.toUtf8() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QNetworkReply* + RiaOsduConnector::makeDownloadRequest( const QString& server, const QString& dataPartitionId, const QString& id, const QString& token ) +{ + QNetworkRequest m_networkRequest; + + QString url = constructDownloadUrl( server, id ); + + m_networkRequest.setUrl( QUrl( url ) ); + + addStandardHeader( m_networkRequest, token, dataPartitionId ); + + auto reply = m_networkAccessManager->get( m_networkRequest ); + return reply; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaOsduConnector::generateRandomString( int randomStringLength ) +{ + const QString possibleCharacters( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ); + QString randomString; + for ( int i = 0; i < randomStringLength; ++i ) + { + quint32 value = QRandomGenerator::global()->generate(); + int index = value % possibleCharacters.length(); + QChar nextChar = possibleCharacters.at( index ); + randomString.append( nextChar ); + } + return randomString; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaOsduConnector::server() const +{ + return m_server; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaOsduConnector::dataPartition() const +{ + return m_dataPartitionId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaOsduConnector::fields() const +{ + return m_fields; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaOsduConnector::wells() const +{ + return m_wells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaOsduConnector::wellbores( const QString& wellId ) const +{ + auto it = m_wellbores.find( wellId ); + if ( it != m_wellbores.end() ) + return it->second; + else + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaOsduConnector::wellIdForWellboreId( const QString& wellboreId ) const +{ + auto findWellIdForWellboreId = []( const std::vector& wellbores, const QString& wellboreId ) + { + auto it = std::find_if( wellbores.begin(), wellbores.end(), [wellboreId]( const OsduWellbore& w ) { return w.id == wellboreId; } ); + if ( it != wellbores.end() ) + return it->wellId; + else + return QString(); + }; + + for ( auto [wellId, wellbores] : m_wellbores ) + { + if ( auto res = findWellIdForWellboreId( wellbores, wellboreId ); !res.isEmpty() ) + { + return wellId; + } + } + + return QString(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaOsduConnector::wellboreTrajectories( const QString& wellboreId ) const +{ + auto it = m_wellboreTrajectories.find( wellboreId ); + if ( it != m_wellboreTrajectories.end() ) + return it->second; + else + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::fileDownloadComplete( const QString& fileId, const QString& filePath ) +{ + m_filePath = filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiaOsduConnector::requestFileContentsById( const QString& fileId ) +{ + if ( m_token.isEmpty() ) + { + // TODO: improve this.. + QEventLoop loop; + connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) ); + requestToken(); + loop.exec(); + } + + QEventLoop loop2; + connect( this, + SIGNAL( fileDownloadFinished( const QString&, const QString& ) ), + this, + SLOT( fileDownloadComplete( const QString&, const QString& ) ) ); + connect( this, SIGNAL( fileDownloadFinished( const QString&, const QString& ) ), &loop2, SLOT( quit() ) ); + requestFileDownloadByFileId( m_server, m_dataPartitionId, m_token, fileId ); + loop2.exec(); + + QFile dataFile( m_filePath ); + + if ( !dataFile.open( QFile::ReadOnly ) ) + { + return { "", "Unable to open file: " + m_filePath }; + } + + QTextStream stream( &dataFile ); + auto fileContent = stream.readAll(); + + return { fileContent, "" }; +} diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h new file mode 100644 index 0000000000..2271e398d2 --- /dev/null +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -0,0 +1,136 @@ +#pragma once + +#include + +#include +#include + +#include + +struct OsduField +{ + QString id; + QString kind; + QString name; +}; + +struct OsduWell +{ + QString id; + QString kind; + QString name; +}; + +struct OsduWellbore +{ + QString id; + QString kind; + QString name; + QString wellId; +}; + +struct OsduWellboreTrajectory +{ + QString id; + QString kind; + QString description; + QString dataSetId; + QString wellboreId; +}; + +//================================================================================================== +/// +//================================================================================================== +class RiaOsduConnector : public QObject +{ + Q_OBJECT +public: + RiaOsduConnector( QObject* parent, + const QString& server, + const QString& dataParitionId, + const QString& authority, + const QString& scopes, + const QString& clientId ); + ~RiaOsduConnector() override; + + void requestFieldsByName( const QString& token, const QString& fieldName ); + void requestFieldsByName( const QString& fieldName ); + void requestWellsByFieldId( const QString& fieldId ); + void requestWellboresByWellId( const QString& wellId ); + void requestWellboreTrajectoryByWellboreId( const QString& wellboreId ); + void requestFileDownloadByFileId( const QString& fileId ); + + std::pair requestFileContentsById( const QString& fileId ); + + QString wellIdForWellboreId( const QString& wellboreId ) const; + + QString server() const; + QString dataPartition() const; + + std::vector fields() const; + std::vector wells() const; + std::vector wellbores( const QString& wellId ) const; + std::vector wellboreTrajectories( const QString& wellboreId ) const; + +public slots: + void requestToken(); + void parseFields( QNetworkReply* reply ); + void parseWells( QNetworkReply* reply ); + void parseWellbores( QNetworkReply* reply, const QString& wellId ); + void parseWellTrajectory( QNetworkReply* reply, const QString& wellboreId ); + void saveFile( QNetworkReply* reply, const QString& fileId ); + void accessGranted(); + void fileDownloadComplete( const QString& fileId, const QString& filePath ); + +signals: + void fileDownloadFinished( const QString& fileId, const QString& filePath ); + void fieldsFinished(); + void wellsFinished(); + void wellboresFinished( const QString& wellId ); + void wellboreTrajectoryFinished( const QString& wellboreId ); + void tokenReady( const QString& token ); + +private: + void addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& dataPartitionId ); + + QNetworkReply* + makeRequest( const std::map& parameters, const QString& server, const QString& dataPartitionId, const QString& token ); + + QNetworkReply* makeDownloadRequest( const QString& server, const QString& dataPartitionId, const QString& id, const QString& token ); + + void requestFieldsByName( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldName ); + void requestWellsByFieldId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldId ); + void requestWellboresByWellId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellId ); + void requestWellboreTrajectoryByWellboreId( const QString& server, + const QString& dataPartitionId, + const QString& token, + const QString& wellboreId ); + void requestFileDownloadByFileId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fileId ); + + static QString generateRandomString( int length = 20 ); + static QString constructSearchUrl( const QString& server ); + static QString constructDownloadUrl( const QString& server, const QString& fileId ); + static QString constructAuthUrl( const QString& authority ); + static QString constructTokenUrl( const QString& authority ); + + QOAuth2AuthorizationCodeFlow* m_osdu; + QNetworkAccessManager* m_networkAccessManager; + + const QString m_server; + const QString m_dataPartitionId; + const QString m_authority; + const QString m_scopes; + const QString m_clientId; + + QString m_token; + std::vector m_fields; + std::vector m_wells; + std::map> m_wellbores; + std::map> m_wellboreTrajectories; + QString m_filePath; + + static inline const QString FIELD_KIND = "osdu:wks:master-data--Field:1.0.0"; + static inline const QString WELL_KIND = "osdu:wks:master-data--Well:1.2.0"; + static inline const QString WELLBORE_KIND = "osdu:wks:master-data--Wellbore:1.1.0"; + static inline const QString WELLBORE_TRAJECTORY_KIND = "osdu:wks:work-product-component--WellboreTrajectory:1.1.0"; +}; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.cpp new file mode 100644 index 0000000000..849ea56a78 --- /dev/null +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.cpp @@ -0,0 +1,24 @@ +#include "RiaOsduOAuthHttpServerReplyHandler.h" + +#include +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaOsduOAuthHttpServerReplyHandler::RiaOsduOAuthHttpServerReplyHandler( quint16 port, QObject* parent ) + : QOAuthHttpServerReplyHandler( port, parent ) + , m_port( port ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaOsduOAuthHttpServerReplyHandler::callback() const +{ + const QUrl url( QString::fromLatin1( "http://localhost:%1/" ).arg( m_port ) ); + return url.toString( QUrl::EncodeDelimiters ); +} diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.h new file mode 100644 index 0000000000..4aaedd6e90 --- /dev/null +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 +#include +#include + +//================================================================================================== +/// +//================================================================================================== +class RiaOsduOAuthHttpServerReplyHandler : public QOAuthHttpServerReplyHandler +{ + Q_OBJECT +public: + RiaOsduOAuthHttpServerReplyHandler( quint16 port, QObject* parent ); + + QString callback() const override; + +private: + quint16 m_port; +}; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index bf0c27b95e..0c864f709d 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -1,7 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2015- Statoil ASA -// Copyright (C) 2015- Ceetron Solutions AS +// Copyright (C) 2024- 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 @@ -21,63 +20,43 @@ #include "RiaApplication.h" #include "RiaGuiApplication.h" +#include "RiaLogging.h" +#include "RiaOsduConnector.h" #include "RiaPreferences.h" +#include "RiaPreferencesOsdu.h" + +#include "RigWellPath.h" #include "RimFileWellPath.h" +#include "RimOilField.h" +#include "RimOsduWellPath.h" #include "RimProject.h" #include "RimTools.h" +#include "RimWellPathCollection.h" #include "RimWellPathImport.h" #include "RiuMainWindow.h" #include "RiuWellImportWizard.h" +#include "cvfObject.h" + #include #include -#include -#include -CAF_CMD_SOURCE_INIT( RicWellPathsImportSsihubFeature, "RicWellPathsImportSsihubFeature" ); +CAF_CMD_SOURCE_INIT( RicWellPathsImportOsduFeature, "RicWellPathsImportOsduFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathsImportSsihubFeature::onActionTriggered( bool isChecked ) +void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) { RiaApplication* app = RiaApplication::instance(); if ( !app->project() ) return; - if ( !app->isProjectSavedToDisc() ) - { - RiaGuiApplication* guiApp = RiaGuiApplication::instance(); - if ( guiApp ) - { - QMessageBox msgBox( guiApp->mainWindow() ); - msgBox.setIcon( QMessageBox::Question ); - - QString questionText = QString( "Import of well paths will be stored as a part of a ResInsight project file. Please " - "save the project to file before importing well paths." ); - - msgBox.setText( questionText ); - msgBox.setInformativeText( "Do you want to save the project?" ); - msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No ); - - int ret = msgBox.exec(); - if ( ret == QMessageBox::Yes ) - { - guiApp->saveProject(); - } - } - - if ( !app->isProjectSavedToDisc() ) - { - return; - } - } - // Update the UTM bounding box from the reservoir app->project()->computeUtmAreaOfInterest(); - QString wellPathsFolderPath = RimFileWellPath::getCacheDirectoryPath(); + QString wellPathsFolderPath = QStandardPaths::writableLocation( QStandardPaths::CacheLocation ) + QString( "/wellpaths/" ); QDir::root().mkpath( wellPathsFolderPath ); if ( !app->project()->wellPathImport() ) return; @@ -86,35 +65,56 @@ void RicWellPathsImportSsihubFeature::onActionTriggered( bool isChecked ) QString copyOfOriginalObject = app->project()->wellPathImport()->writeObjectToXmlString(); if ( !app->preferences() ) return; - RiuWellImportWizard wellImportwizard( app->preferences()->ssihubAddress, - wellPathsFolderPath, - app->project()->wellPathImport(), - RiuMainWindow::instance() ); - // Get password/username from application cache - { -#ifdef _DEBUG - // Valid credentials for ssihubfake received in mail from Håkon - QString ssihubUsername = "admin"; - QString ssihubPassword = "resinsight"; -#else - QString ssihubUsername = app->cacheDataObject( "ssihub_username" ).toString(); - QString ssihubPassword; -#endif - wellImportwizard.setCredentials( ssihubUsername, ssihubPassword ); - } + RimProject* project = RimProject::current(); + if ( !project ) return; + + if ( project->oilFields.empty() ) return; + + RimOilField* oilField = project->activeOilField(); + if ( !oilField ) return; + + RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences(); + + const QString server = osduPreferences->server(); + const QString dataParitionId = osduPreferences->dataPartitionId(); + const QString authority = osduPreferences->authority(); + const QString scopes = osduPreferences->scopes(); + const QString clientId = osduPreferences->clientId(); + + RiaOsduConnector osduConnector( RiuMainWindow::instance(), server, dataParitionId, authority, scopes, clientId ); + + RiuWellImportWizard wellImportwizard( wellPathsFolderPath, &osduConnector, app->project()->wellPathImport(), RiuMainWindow::instance() ); if ( QDialog::Accepted == wellImportwizard.exec() ) { - QStringList wellPaths = wellImportwizard.absoluteFilePathsToWellPaths(); - if ( !wellPaths.empty() ) + std::vector importedWells = wellImportwizard.importedWells(); + for ( auto w : importedWells ) { - QStringList errorMessages; - app->addWellPathsToModel( wellPaths, &errorMessages ); - app->project()->scheduleCreateDisplayModelAndRedrawAllViews(); + auto wellPath = new RimOsduWellPath; + wellPath->setName( w.name ); + wellPath->setWellId( w.wellId ); + wellPath->setWellboreId( w.wellboreId ); + wellPath->setWellboreTrajectoryId( w.wellboreTrajectoryId ); + wellPath->setFileId( w.fileId ); + + oilField->wellPathCollection->addWellPath( wellPath ); + + auto [wellPathGeometry, errorMessage] = RimWellPathCollection::loadWellPathGeometryFromOsdu( &osduConnector, w.fileId ); + if ( wellPathGeometry.notNull() ) + { + wellPath->setWellPathGeometry( wellPathGeometry.p() ); + } + else + { + RiaLogging::error( "Importing OSDU well failed: " + errorMessage ); + } + + oilField->wellPathCollection->updateConnectedEditors(); } - app->setCacheDataObject( "ssihub_username", wellImportwizard.field( "username" ) ); + project->updateConnectedEditors(); + app->project()->scheduleCreateDisplayModelAndRedrawAllViews(); } else { @@ -125,8 +125,8 @@ void RicWellPathsImportSsihubFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathsImportSsihubFeature::setupActionLook( QAction* actionToSetup ) +void RicWellPathsImportOsduFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "Import Well Paths from &SSI-hub" ); + actionToSetup->setText( "Import Well Paths from &OSDU" ); actionToSetup->setIcon( QIcon( ":/WellCollection.png" ) ); } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.h b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.h index 2ffb5e84be..863d77f85a 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.h @@ -24,7 +24,7 @@ //================================================================================================== /// //================================================================================================== -class RicWellPathsImportSsihubFeature : public caf::CmdFeature +class RicWellPathsImportOsduFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp index 97d18bcb89..b384171f4f 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// Copyright (C) 2024 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 @@ -53,12 +53,6 @@ RimWellPathImport::RimWellPathImport() { CAF_PDM_InitObject( "RimWellPathImport" ); - CAF_PDM_InitField( &wellTypeSurvey, "WellTypeSurvey", true, "Survey" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &wellTypeSurvey ); - - CAF_PDM_InitField( &wellTypePlans, "WellTypePlans", true, "Plans" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &wellTypePlans ); - caf::AppEnum defaultUtmMode = UTM_FILTER_OFF; CAF_PDM_InitField( &utmFilterMode, "UtmMode", defaultUtmMode, "Utm Filter" ); @@ -67,95 +61,7 @@ RimWellPathImport::RimWellPathImport() CAF_PDM_InitField( &east, "UtmEast", 0.0, "East" ); CAF_PDM_InitField( &west, "UtmWest", 0.0, "West" ); - CAF_PDM_InitFieldNoDefault( ®ions, "Regions", "" ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathImport::updateRegions( const QStringList& regionStrings, const QStringList& fieldStrings, const QStringList& edmIds ) -{ - assert( regionStrings.size() == fieldStrings.size() && regionStrings.size() == edmIds.size() ); - - std::vector regionsToRemove; - - // Remove regions and fields not present in last request - for ( size_t regionIdx = 0; regionIdx < regions.size(); regionIdx++ ) - { - if ( !regionStrings.contains( regions[regionIdx]->name ) ) - { - regionsToRemove.push_back( regions[regionIdx] ); - } - else - { - std::vector fieldsToRemove; - - for ( size_t fIdx = 0; fIdx < regions[regionIdx]->fields.size(); fIdx++ ) - { - if ( !fieldStrings.contains( regions[regionIdx]->fields[fIdx]->name ) ) - { - fieldsToRemove.push_back( regions[regionIdx]->fields[fIdx] ); - } - } - - for ( size_t i = 0; i < fieldsToRemove.size(); i++ ) - { - regions[regionIdx]->fields.removeChild( fieldsToRemove[i] ); - - delete fieldsToRemove[i]; - } - } - } - - for ( size_t i = 0; i < regionsToRemove.size(); i++ ) - { - regions.removeChild( regionsToRemove[i] ); - - delete regionsToRemove[i]; - } - - for ( int i = 0; i < regionStrings.size(); i++ ) - { - RimOilRegionEntry* oilRegionEntry = nullptr; - RimOilFieldEntry* oilFieldEntry = nullptr; - - for ( size_t regionIdx = 0; regionIdx < regions.size(); regionIdx++ ) - { - if ( regions[regionIdx]->name == regionStrings[i] ) - { - oilRegionEntry = regions[regionIdx]; - - for ( size_t fIdx = 0; fIdx < regions[regionIdx]->fields.size(); fIdx++ ) - { - if ( regions[regionIdx]->fields[fIdx]->edmId == edmIds[i] ) - { - oilFieldEntry = regions[regionIdx]->fields[fIdx]; - } - } - } - } - - if ( !oilRegionEntry ) - { - oilRegionEntry = new RimOilRegionEntry; - oilRegionEntry->name = regionStrings[i]; - - regions.push_back( oilRegionEntry ); - } - - assert( oilRegionEntry ); - - if ( !oilFieldEntry ) - { - oilFieldEntry = new RimOilFieldEntry; - oilFieldEntry->name = fieldStrings[i]; - oilFieldEntry->edmId = edmIds[i]; - - oilRegionEntry->fields.push_back( oilFieldEntry ); - } - } - - updateFieldVisibility(); + CAF_PDM_InitFieldNoDefault( ®ions_OBSOLETE, "Regions", "" ); } //-------------------------------------------------------------------------------------------------- @@ -198,71 +104,10 @@ void RimWellPathImport::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathImport::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) -{ - caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast( attribute ); - if ( myAttr ) - { - QStringList colHeaders; - colHeaders << "Region"; - myAttr->columnHeaders = colHeaders; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathImport::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) -{ - // NOTE: If the default uiOrdering is used, the first checkbox is not possible to interact with using the mouse - // (only keyboard). This is a workaround to make the first checkbox work. - // - // Related issue, but with an opposite fix - // https://github.com/OPM/ResInsight/commit/51443d7aa33abebfaa179e645c729fde19a64666 - // - auto group = uiOrdering.addNewGroup( "Well Types" ); - group->add( &wellTypeSurvey ); - group->add( &wellTypePlans ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimWellPathImport::~RimWellPathImport() { - regions.deleteChildren(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathImport::updateFilePaths() -{ - QString wellPathsFolderPath = RimFileWellPath::getCacheDirectoryPath(); - - for ( size_t regionIdx = 0; regionIdx < regions.size(); regionIdx++ ) - { - for ( size_t fIdx = 0; fIdx < regions[regionIdx]->fields.size(); fIdx++ ) - { - RimOilFieldEntry* oilField = regions[regionIdx]->fields[fIdx]; - - QFileInfo fi( oilField->wellsFilePath ); - - QString newWellsFilePath = wellPathsFolderPath + "/" + fi.fileName(); - oilField->wellsFilePath = newWellsFilePath; - - for ( size_t wIdx = 0; wIdx < oilField->wells.size(); wIdx++ ) - { - RimWellPathEntry* rimWellPathEntry = oilField->wells[wIdx]; - - QFileInfo fiWell( rimWellPathEntry->wellPathFilePath ); - - QString newFilePath = wellPathsFolderPath + "/" + fiWell.fileName(); - rimWellPathEntry->wellPathFilePath = newFilePath; - } - } - } + regions_OBSOLETE.deleteChildren(); } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h index b75f313cc9..bb4ad472a9 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h @@ -41,25 +41,17 @@ class RimWellPathImport : public caf::PdmObject RimWellPathImport(); ~RimWellPathImport() override; - caf::PdmField wellTypeSurvey; - caf::PdmField wellTypePlans; - caf::PdmField> utmFilterMode; caf::PdmField north; caf::PdmField south; caf::PdmField east; caf::PdmField west; - caf::PdmChildArrayField regions; - - void updateRegions( const QStringList& regions, const QStringList& fields, const QStringList& edmIds ); - +protected: void initAfterRead() override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void updateFieldVisibility(); - void updateFilePaths(); + caf::PdmChildArrayField regions_OBSOLETE; }; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index 7a53b71afe..99cd2a395b 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -19,17 +19,11 @@ #include "RiuWellImportWizard.h" #include "RiaFeatureCommandContext.h" +#include "RiaOsduConnector.h" -#include "RifJsonEncodeDecode.h" - -#include "RimOilFieldEntry.h" -#include "RimOilRegionEntry.h" #include "RimWellPathImport.h" #include "cafCmdFeatureMenuBuilder.h" -#include "cafPdmDocument.h" -#include "cafPdmObject.h" -#include "cafPdmObjectGroup.h" #include "cafPdmUiListView.h" #include "cafPdmUiPropertyView.h" #include "cafPdmUiTreeAttributes.h" @@ -37,53 +31,37 @@ #include "cafPdmUiTreeViewEditor.h" #include "cafUtils.h" -#include +#include #include -#include -#include +#include #include #include #include - -CAF_PDM_XML_ABSTRACT_SOURCE_INIT( ObjectGroupWithHeaders, "ObjectGroupWithHeaders" ); // Do not use. Abstract class +#include +#include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuWellImportWizard::RiuWellImportWizard( const QString& webServiceAddress, - const QString& downloadFolder, +RiuWellImportWizard::RiuWellImportWizard( const QString& downloadFolder, + RiaOsduConnector* osduConnector, RimWellPathImport* wellPathImportObject, QWidget* parent /*= 0*/ ) : QWizard( parent ) { m_wellPathImportObject = wellPathImportObject; + m_osduConnector = osduConnector; m_destinationFolder = downloadFolder; - m_webServiceAddress = webServiceAddress; - m_myProgressDialog = nullptr; m_firstTimeRequestingAuthentication = true; - addPage( new AuthenticationPage( webServiceAddress, this ) ); - m_fieldSelectionPageId = addPage( new FieldSelectionPage( m_wellPathImportObject, this ) ); - m_wellSelectionPageId = addPage( new WellSelectionPage( m_wellPathImportObject, this ) ); - m_wellSummaryPageId = addPage( new WellSummaryPage( m_wellPathImportObject, this ) ); - - connect( this, SIGNAL( currentIdChanged( int ) ), SLOT( slotCurrentIdChanged( int ) ) ); - - connect( &m_networkAccessManager, - SIGNAL( authenticationRequired( QNetworkReply*, QAuthenticator* ) ), - this, - SLOT( slotAuthenticationRequired( QNetworkReply*, QAuthenticator* ) ) ); - -#if !defined( QT_NO_OPENSSL ) && !defined( CVF_OSX ) - connect( &m_networkAccessManager, - SIGNAL( sslErrors( QNetworkReply*, QList ) ), - this, - SLOT( sslErrors( QNetworkReply*, QList ) ) ); -#endif + addPage( new AuthenticationPage( m_osduConnector, this ) ); + addPage( new FieldSelectionPage( m_wellPathImportObject, m_osduConnector, this ) ); + addPage( new WellSelectionPage( m_wellPathImportObject, m_osduConnector, this ) ); + addPage( new WellSummaryPage( m_wellPathImportObject, m_osduConnector, this ) ); } //-------------------------------------------------------------------------------------------------- @@ -93,189 +71,13 @@ RiuWellImportWizard::~RiuWellImportWizard() { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiuWellImportWizard::jsonFieldsFilePath() -{ - return m_destinationFolder + "/fields.json"; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiuWellImportWizard::jsonWellsFilePath() -{ - return m_destinationFolder + "/wellpaths.json"; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RiuWellImportWizard::downloadFields() { - QString wellFileName = jsonWellsFilePath(); - if ( caf::Utils::fileExists( wellFileName ) ) - { - QFile::remove( wellFileName ); - } - - QString completeUrlText = m_webServiceAddress + "/resinsight/projects"; - QString destinationFileName = jsonFieldsFilePath(); - - m_currentDownloadState = DOWNLOAD_FIELDS; - issueHttpRequestToFile( completeUrlText, destinationFileName ); - - return; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::issueHttpRequestToFile( QString completeUrlText, QString destinationFileName ) -{ - setUrl( completeUrlText ); - m_file = new QFile( destinationFileName ); - if ( !m_file->open( QIODevice::WriteOnly ) ) - { - QMessageBox::information( this, - tr( "HTTP" ), - tr( "Unable to save the file %1: %2." ).arg( destinationFileName ).arg( m_file->errorString() ) ); - delete m_file; - m_file = nullptr; - return; - } - - // schedule the request - m_httpRequestAborted = false; - startRequest( m_url ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::cancelDownload() -{ - // m_statusLabel->setText(tr("Download canceled.")); - m_httpRequestAborted = true; - m_reply->abort(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::httpFinished() -{ - if ( m_httpRequestAborted ) - { - if ( m_file ) - { - m_file->close(); - m_file->remove(); - delete m_file; - m_file = nullptr; - } - m_reply->deleteLater(); - hideProgressDialog(); - return; - } - - m_file->flush(); - m_file->close(); - - QVariant redirectionTarget = m_reply->attribute( QNetworkRequest::RedirectionTargetAttribute ); - if ( m_reply->error() ) - { - m_file->remove(); - QMessageBox::information( this, tr( "HTTP" ), tr( "Download failed: %1." ).arg( m_reply->errorString() ) ); - } - else if ( !redirectionTarget.isNull() ) - { - QUrl newUrl = m_url.resolved( redirectionTarget.toUrl() ); - if ( QMessageBox::question( this, tr( "HTTP" ), tr( "Redirect to %1 ?" ).arg( newUrl.toString() ), QMessageBox::Yes | QMessageBox::No ) == - QMessageBox::Yes ) - { - m_url = newUrl; - m_reply->deleteLater(); - m_file->open( QIODevice::WriteOnly ); - m_file->resize( 0 ); - startRequest( m_url ); - return; - } - } - else - { - // m_statusLabel->setText(tr("Downloaded data to %1.").arg(m_destinationFolder)); - } - - if ( m_currentDownloadState == DOWNLOAD_WELL_PATH ) - { - QString singleWellPathFilePath = m_file->fileName(); - - QFile file( singleWellPathFilePath ); - if ( file.open( QFile::ReadOnly ) ) - { - QString singleWellPathContent = file.readAll(); - - // Strip leading and trailing [] - - if ( singleWellPathContent.indexOf( '{' ) > 0 ) - { - singleWellPathContent = singleWellPathContent.right( singleWellPathContent.size() - singleWellPathContent.indexOf( '{' ) ); - } - - if ( singleWellPathContent[singleWellPathContent.size() - 1] == ']' ) - { - singleWellPathContent = singleWellPathContent.left( singleWellPathContent.size() - 1 ); - } - - QString wellPathName = getValue( "name", singleWellPathContent ); - if ( !singleWellPathContent.isEmpty() && !wellPathName.isEmpty() ) - { - // Write out the content without leading/trailing [] - file.close(); - QFile::remove( singleWellPathFilePath ); - - if ( file.open( QFile::WriteOnly ) ) - { - QTextStream out( &file ); - out << singleWellPathContent; - } - } - - progressDialog()->setLabelText( QString( "Downloaded well path : %1" ).arg( wellPathName ) ); - } - - int newValue = progressDialog()->maximum() - m_wellRequestQueue.size(); - progressDialog()->setValue( newValue ); - } - - m_reply->deleteLater(); - m_reply = nullptr; - delete m_file; - m_file = nullptr; - - if ( m_currentDownloadState == DOWNLOAD_WELLS || m_currentDownloadState == DOWNLOAD_WELL_PATH ) - { - checkDownloadQueueAndIssueRequests(); - } - else if ( m_currentDownloadState == DOWNLOAD_FIELDS ) - { - updateFieldsModel(); - m_currentDownloadState = DOWNLOAD_UNDEFINED; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::httpReadyRead() -{ - // this slot gets called every time the QNetworkReply has new data. - // We read all of its new data and write it into the file. - // That way we use less RAM than when reading it at the finished() - // signal of the QNetworkReply - if ( m_file ) m_file->write( m_reply->readAll() ); + // TODO: filter by user input + m_osduConnector->requestFieldsByName( "AZERI" ); } //-------------------------------------------------------------------------------------------------- @@ -286,525 +88,226 @@ void RiuWellImportWizard::slotAuthenticationRequired( QNetworkReply* networkRepl { if ( m_firstTimeRequestingAuthentication ) { - // Use credentials from first wizard page - authenticator->setUser( field( "username" ).toString() ); - authenticator->setPassword( field( "password" ).toString() ); - m_firstTimeRequestingAuthentication = false; } else { QMessageBox::information( this, "Authentication failed", - "Failed to authenticate credentials. You will now be directed back to the first " - "wizard page." ); + "Failed to authenticate. You will now be directed back to the first wizard page." ); m_firstTimeRequestingAuthentication = true; restart(); } } -#if !defined( QT_NO_OPENSSL ) && !defined( CVF_OSX ) -void RiuWellImportWizard::sslErrors( QNetworkReply*, const QList& errors ) -{ - QString errorString; - foreach ( const QSslError& error, errors ) - { - if ( !errorString.isEmpty() ) errorString += ", "; - errorString += error.errorString(); - } - - if ( QMessageBox::warning( this, - tr( "HTTP" ), - tr( "One or more SSL errors has occurred: %1" ).arg( errorString ), - QMessageBox::Ignore | QMessageBox::Abort ) == QMessageBox::Ignore ) - { - m_reply->ignoreSslErrors(); - } -} -#endif - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::setUrl( const QString& httpAddress ) +void RiuWellImportWizard::downloadWells( const QString& fieldId ) { - m_url = httpAddress; + m_osduConnector->requestWellsByFieldId( fieldId ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::startRequest( QUrl url ) +void RiuWellImportWizard::downloadWellPaths( const QString& wellboreId ) { - auto request = QNetworkRequest( url ); - -#if !defined( QT_NO_OPENSSL ) && !defined( CVF_OSX ) - bool supportsSsl = QSslSocket::supportsSsl(); - if ( supportsSsl ) - { - QSslConfiguration config = QSslConfiguration::defaultConfiguration(); - config.setProtocol( QSsl::TlsV1_0 ); - request.setSslConfiguration( config ); - } -#endif - - m_reply = m_networkAccessManager.get( request ); - connect( m_reply, SIGNAL( finished() ), this, SLOT( httpFinished() ) ); - connect( m_reply, SIGNAL( readyRead() ), this, SLOT( httpReadyRead() ) ); -} - -//-------------------------------------------------------------------------------------------------- -/// Search for string, and find the associated value inside the next quoted string -// text content : "A" : "B" -// A search for key "A" returns B -//-------------------------------------------------------------------------------------------------- -QString RiuWellImportWizard::getValue( const QString& key, const QString& stringContent ) -{ - QString quotedKey = "\"" + key + "\""; - - int pos = stringContent.indexOf( quotedKey ); - if ( pos >= 0 ) - { - int valueStartPos = stringContent.indexOf( "\"", pos + quotedKey.size() ); - int valueEndPos = stringContent.indexOf( "\"", valueStartPos + 1 ); - - if ( valueStartPos >= 0 && valueEndPos > valueStartPos ) - { - return stringContent.mid( valueStartPos + 1, valueEndPos - valueStartPos - 1 ); - } - } - - return QString(); + m_osduConnector->requestWellboreTrajectoryByWellboreId( wellboreId ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QProgressDialog* RiuWellImportWizard::progressDialog() +void RiuWellImportWizard::resetAuthenticationCount() { - if ( !m_myProgressDialog ) - { - m_myProgressDialog = new QProgressDialog( this ); - } - - return m_myProgressDialog; + m_firstTimeRequestingAuthentication = true; + m_osduConnector->requestToken(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::hideProgressDialog() +void RiuWellImportWizard::setSelectedFieldId( const QString& fieldId ) { - if ( m_myProgressDialog ) - { - m_myProgressDialog->hide(); - - QCoreApplication::processEvents(); - } + m_selectedFieldId = fieldId; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::updateFieldsModel() +QString RiuWellImportWizard::selectedFieldId() const { - QString fileName = jsonFieldsFilePath(); - - if ( caf::Utils::fileExists( fileName ) ) - { - QStringList regions; - QStringList fields; - QStringList edmIds; - - QMap jsonMap = ResInsightInternalJson::JsonReader::decodeFile( fileName ); - QVariantList variantList = ResInsightInternalJson::JsonReader::getVariantList( jsonMap ); - for ( const auto& listItem : variantList ) - { - QMap fieldMap = listItem.toMap(); - - regions.push_back( fieldMap["region"].toString() ); - fields.push_back( fieldMap["name"].toString() ); - edmIds.push_back( fieldMap["edmId"].toString() ); - } - - m_wellPathImportObject->updateRegions( regions, fields, edmIds ); - - for ( size_t i = 0; i < m_wellPathImportObject->regions.size(); i++ ) - { - m_wellPathImportObject->regions[i]->updateState(); - } - - m_wellPathImportObject->updateConnectedEditors(); - } + return m_selectedFieldId; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::downloadWells() +void RiuWellImportWizard::setSelectedWellboreId( const QString& wellboreId ) { - for ( size_t rIdx = 0; rIdx < m_wellPathImportObject->regions.size(); rIdx++ ) - { - RimOilRegionEntry* oilRegion = m_wellPathImportObject->regions[rIdx]; - if ( oilRegion->selected ) - { - for ( size_t fIdx = 0; fIdx < oilRegion->fields.size(); fIdx++ ) - { - RimOilFieldEntry* oilField = oilRegion->fields[fIdx]; - if ( oilField->selected ) - { - DownloadEntity urlToFile; - - QString wellRequest; - if ( m_wellPathImportObject->utmFilterMode == RimWellPathImport::UTM_FILTER_OFF ) - { - wellRequest = QString( "/resinsight/projects/%1/wells" ).arg( oilField->edmId ); - } - else - { - wellRequest = QString( "/resinsight/projects/%1/" - "wellsInArea?north=%2&south=%3&east=%4&west=%5&utmzone=32N" ) - .arg( oilField->edmId ) - .arg( QString::number( m_wellPathImportObject->north, 'g', 10 ) ) - .arg( QString::number( m_wellPathImportObject->south, 'g', 10 ) ) - .arg( QString::number( m_wellPathImportObject->east, 'g', 10 ) ) - .arg( QString::number( m_wellPathImportObject->west, 'g', 10 ) ); - } - - urlToFile.requestUrl = m_webServiceAddress + wellRequest; - urlToFile.responseFilename = m_destinationFolder + QString( "/wells_%1.json" ).arg( oilField->edmId ); - - oilField->wellsFilePath = urlToFile.responseFilename; - - m_wellRequestQueue.push_back( urlToFile ); - } - } - } - } - - m_currentDownloadState = DOWNLOAD_WELLS; - checkDownloadQueueAndIssueRequests(); + m_selectedWellboreId = wellboreId; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::downloadWellPaths() +QString RiuWellImportWizard::selectedWellboreId() const { - WellSelectionPage* wellSelectionPage = dynamic_cast( page( m_wellSelectionPageId ) ); - std::vector downloadEntities; - wellSelectionPage->selectedWellPathEntries( downloadEntities, nullptr ); - - for ( size_t i = 0; i < downloadEntities.size(); i++ ) - { - m_wellRequestQueue.push_back( downloadEntities[i] ); - } - - m_currentDownloadState = DOWNLOAD_WELL_PATH; - - progressDialog()->setMaximum( m_wellRequestQueue.size() ); - progressDialog()->setValue( 0 ); - progressDialog()->show(); - - checkDownloadQueueAndIssueRequests(); + return m_selectedWellboreId; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::checkDownloadQueueAndIssueRequests() +std::vector RiuWellImportWizard::importedWells() const { - if ( !m_wellRequestQueue.empty() ) - { - DownloadEntity firstItem = m_wellRequestQueue[0]; - m_wellRequestQueue.pop_front(); - - QString completeUrlText = firstItem.requestUrl; - QString absoluteFilePath = firstItem.responseFilename; - - issueHttpRequestToFile( completeUrlText, absoluteFilePath ); - - return; - } - - if ( m_currentDownloadState == DOWNLOAD_WELLS ) - { - hideProgressDialog(); - - // Update UI with downloaded wells - - for ( size_t rIdx = 0; rIdx < m_wellPathImportObject->regions.size(); rIdx++ ) - { - RimOilRegionEntry* oilRegion = m_wellPathImportObject->regions[rIdx]; - if ( oilRegion->selected ) - { - for ( size_t fIdx = 0; fIdx < oilRegion->fields.size(); fIdx++ ) - { - RimOilFieldEntry* oilField = oilRegion->fields[fIdx]; - if ( oilField->selected ) - { - parseWellsResponse( oilField ); - } - } - } - } - - m_wellPathImportObject->updateConnectedEditors(); - } - else if ( m_currentDownloadState == DOWNLOAD_WELL_PATH ) - { - WellSummaryPage* wellSummaryPage = dynamic_cast( page( m_wellSummaryPageId ) ); - if ( wellSummaryPage ) - { - wellSummaryPage->updateSummaryPage(); - } - } - - m_currentDownloadState = DOWNLOAD_UNDEFINED; - - hideProgressDialog(); + return m_wellInfos; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::resetAuthenticationCount() +void RiuWellImportWizard::addWellInfo( RiuWellImportWizard::WellInfo wellInfo ) { - m_firstTimeRequestingAuthentication = true; + m_wellInfos.push_back( wellInfo ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RiuWellImportWizard::absoluteFilePathsToWellPaths() const +AuthenticationPage::AuthenticationPage( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) + : QWizardPage( parent ) + , m_accessOk( false ) { - QStringList filePaths; + setTitle( "OSDU - Login" ); - WellSelectionPage* wellSelectionPage = dynamic_cast( page( m_wellSelectionPageId ) ); - std::vector downloadEntities; - wellSelectionPage->selectedWellPathEntries( downloadEntities, nullptr ); + QVBoxLayout* layout = new QVBoxLayout; - for ( size_t i = 0; i < downloadEntities.size(); i++ ) - { - if ( caf::Utils::fileExists( downloadEntities[i].responseFilename ) ) - { - filePaths.push_back( downloadEntities[i].responseFilename ); - } - } + QLabel* label = new QLabel( "Checking OSDU connection..." ); + layout->addWidget( label ); - return filePaths; -} + QFormLayout* formLayout = new QFormLayout; + layout->addLayout( formLayout ); -//-------------------------------------------------------------------------------------------------- -/// Set wells hidden from the field selection page -/// TODO: This can be refactored when UIOrdering for objects is created -//-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::slotCurrentIdChanged( int currentId ) -{ - bool hideWells = true; - if ( currentId == m_wellSelectionPageId ) hideWells = false; + QLineEdit* serverLineEdit = new QLineEdit( osduConnector->server(), this ); + QLineEdit* partitionLineEdit = new QLineEdit( osduConnector->dataPartition(), this ); - for ( size_t rIdx = 0; rIdx < m_wellPathImportObject->regions.size(); rIdx++ ) - { - RimOilRegionEntry* oilRegion = m_wellPathImportObject->regions[rIdx]; - { - for ( size_t fIdx = 0; fIdx < oilRegion->fields.size(); fIdx++ ) - { - RimOilFieldEntry* oilField = oilRegion->fields[fIdx]; - oilField->wells.uiCapability()->setUiHidden( hideWells ); - } - } - } + formLayout->addRow( "Server:", serverLineEdit ); + formLayout->addRow( "Data Partition:", partitionLineEdit ); - // Update the editors to propagate the changes to UI - m_wellPathImportObject->updateConnectedEditors(); + setLayout( layout ); + + connect( osduConnector, SIGNAL( tokenReady( const QString& ) ), this, SLOT( accessOk() ) ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::parseWellsResponse( RimOilFieldEntry* oilFieldEntry ) +void AuthenticationPage::initializePage() { - QStringList surveyNames; - QStringList planNames; - - if ( caf::Utils::fileExists( oilFieldEntry->wellsFilePath ) ) - { - QMap jsonMap = ResInsightInternalJson::JsonReader::decodeFile( oilFieldEntry->wellsFilePath ); - QVariantList variantList = ResInsightInternalJson::JsonReader::getVariantList( jsonMap ); - for ( const auto& listItem : variantList ) - { - QMap rootMap = listItem.toMap(); - - if ( m_wellPathImportObject->wellTypeSurvey ) - { - QMap surveyMap = rootMap["survey"].toMap(); - QString name = surveyMap["name"].toString(); - - if ( !oilFieldEntry->find( name, RimWellPathEntry::WELL_SURVEY ) ) - { - QMap linksMap = surveyMap["links"].toMap(); - QString requestUrl = m_webServiceAddress + linksMap["entity"].toString(); - QString surveyType = surveyMap["surveyType"].toString(); - RimWellPathEntry* surveyWellPathEntry = - RimWellPathEntry::createWellPathEntry( name, surveyType, requestUrl, m_destinationFolder, RimWellPathEntry::WELL_SURVEY ); - oilFieldEntry->wells.push_back( surveyWellPathEntry ); - } - - surveyNames.push_back( name ); - } - - if ( m_wellPathImportObject->wellTypePlans ) - { - QList plansList = rootMap["plans"].toList(); - QListIterator planIt( plansList ); - while ( planIt.hasNext() ) - { - QMap planMap = planIt.next().toMap(); - QString name = planMap["name"].toString(); - - if ( !oilFieldEntry->find( name, RimWellPathEntry::WELL_PLAN ) ) - { - QMap linksMap = planMap["links"].toMap(); - QString requestUrl = m_webServiceAddress + linksMap["entity"].toString(); - QString surveyType = planMap["surveyType"].toString(); - RimWellPathEntry* surveyWellPathEntry = - RimWellPathEntry::createWellPathEntry( name, surveyType, requestUrl, m_destinationFolder, RimWellPathEntry::WELL_PLAN ); - oilFieldEntry->wells.push_back( surveyWellPathEntry ); - } - - planNames.push_back( name ); - } - } - } - } - - // Delete the well path entries in the model that are not part of the reply from the web service - std::vector wellsToRemove; - - for ( size_t i = 0; i < oilFieldEntry->wells.size(); i++ ) - { - RimWellPathEntry* wellPathEntry = oilFieldEntry->wells[i]; - if ( wellPathEntry->wellPathType == RimWellPathEntry::WELL_PLAN ) - { - if ( !planNames.contains( wellPathEntry->name ) ) - { - wellsToRemove.push_back( wellPathEntry ); - } - } - else - { - if ( !surveyNames.contains( wellPathEntry->name ) ) - { - wellsToRemove.push_back( wellPathEntry ); - } - } - } - - for ( size_t i = 0; i < wellsToRemove.size(); i++ ) - { - oilFieldEntry->wells.removeChild( wellsToRemove[i] ); - - delete wellsToRemove[i]; - } - - WellSelectionPage* wellSelectionPage = dynamic_cast( page( m_wellSelectionPageId ) ); - if ( wellSelectionPage ) wellSelectionPage->buildWellTreeView(); + RiuWellImportWizard* wiz = dynamic_cast( wizard() ); + wiz->resetAuthenticationCount(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::setCredentials( const QString& username, const QString& password ) +bool AuthenticationPage::isComplete() const { - // Set the initial value of the fields defined in the Authorization page - setField( "username", username ); - setField( "password", password ); + return m_accessOk; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RiuWellImportWizard::wellSelectionPageId() +void AuthenticationPage::accessOk() { - return m_wellSelectionPageId; + m_accessOk = true; + emit( completeChanged() ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -AuthenticationPage::AuthenticationPage( const QString& webServiceAddress, QWidget* parent /*= 0*/ ) - : QWizardPage( parent ) +FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) { - setTitle( "SSIHUB - Login" ); + setTitle( "Field Selection" ); QVBoxLayout* layout = new QVBoxLayout; + setLayout( layout ); - QLabel* label = new QLabel( "Please enter your login information for SSIHUB at : " + webServiceAddress ); + QLabel* label = new QLabel( "Select fields" ); layout->addWidget( label ); - QFormLayout* formLayout = new QFormLayout; - layout->addLayout( formLayout ); + m_tableView = new QTableView( this ); + m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows ); + m_osduFieldsModel = new OsduFieldTableModel; + m_tableView->setModel( m_osduFieldsModel ); + layout->addWidget( m_tableView ); + layout->setStretchFactor( m_tableView, 10 ); + + // Tree view + // caf::PdmUiTreeView* treeView = new caf::PdmUiTreeView( this ); + // treeView->setPdmItem( wellPathImport ); + // layout->addWidget( treeView ); + // layout->setStretchFactor( treeView, 10 ); - QLineEdit* usernameLineEdit = new QLineEdit( "", this ); - QLineEdit* passwordlLineEdit = new QLineEdit( "", this ); - passwordlLineEdit->setEchoMode( QLineEdit::Password ); + setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); - formLayout->addRow( "&Username:", usernameLineEdit ); - formLayout->addRow( "&Password:", passwordlLineEdit ); + m_osduConnector = osduConnector; + connect( m_osduConnector, SIGNAL( fieldsFinished() ), SLOT( fieldsFinished() ) ); - setLayout( layout ); + connect( m_tableView->selectionModel(), + SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), + SLOT( selectField( const QItemSelection&, const QItemSelection& ) ) ); - // Make variables accessible to other pages in wizard - // Use * at end of field name to indicate mandatory field - registerField( "username", usernameLineEdit ); - registerField( "password", passwordlLineEdit ); + connect( m_tableView->selectionModel(), + SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), + SIGNAL( completeChanged() ) ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void AuthenticationPage::initializePage() +void FieldSelectionPage::initializePage() { RiuWellImportWizard* wiz = dynamic_cast( wizard() ); - wiz->resetAuthenticationCount(); + wiz->downloadFields(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, QWidget* parent /*= 0*/ ) +void FieldSelectionPage::fieldsFinished() { - setTitle( "Field Selection" ); - - QVBoxLayout* layout = new QVBoxLayout; - setLayout( layout ); - - QLabel* label = new QLabel( "Select fields" ); - layout->addWidget( label ); - - // Tree view - caf::PdmUiTreeView* treeView = new caf::PdmUiTreeView( this ); - treeView->setPdmItem( wellPathImport ); - layout->addWidget( treeView ); - layout->setStretchFactor( treeView, 10 ); - - // Property view - m_propertyView = new caf::PdmUiPropertyView( this ); - layout->addWidget( m_propertyView ); - m_propertyView->showProperties( wellPathImport ); + std::vector fields = m_osduConnector->fields(); + m_osduFieldsModel->setOsduFields( fields ); +} - setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void FieldSelectionPage::selectField( const QItemSelection& newSelection, const QItemSelection& oldSelection ) +{ + if ( !newSelection.indexes().empty() ) + { + QModelIndex index = newSelection.indexes()[0]; + int column = 0; + QString fieldId = m_osduFieldsModel->data( index.siblingAtColumn( column ) ).toString(); + RiuWellImportWizard* wiz = dynamic_cast( wizard() ); + wiz->setSelectedFieldId( fieldId ); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void FieldSelectionPage::initializePage() +bool FieldSelectionPage::isComplete() const { - RiuWellImportWizard* wiz = dynamic_cast( wizard() ); - wiz->downloadFields(); + QItemSelectionModel* select = m_tableView->selectionModel(); + return select->selectedRows().size() == 1; } //-------------------------------------------------------------------------------------------------- @@ -812,13 +315,12 @@ void FieldSelectionPage::initializePage() //-------------------------------------------------------------------------------------------------- FieldSelectionPage::~FieldSelectionPage() { - m_propertyView->showProperties( nullptr ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -WellSelectionPage::WellSelectionPage( RimWellPathImport* wellPathImport, QWidget* parent /*= 0*/ ) +WellSelectionPage::WellSelectionPage( RimWellPathImport* wellPathImport, RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) { QVBoxLayout* layout = new QVBoxLayout; setLayout( layout ); @@ -826,21 +328,26 @@ WellSelectionPage::WellSelectionPage( RimWellPathImport* wellPathImport, QWidget QLabel* label = new QLabel( "Select wells" ); layout->addWidget( label ); - m_wellSelectionTreeView = new caf::PdmUiTreeView( this ); - m_wellSelectionTreeView->treeView()->setContextMenuPolicy( Qt::CustomContextMenu ); - m_wellSelectionTreeView->enableSelectionManagerUpdating( true ); - m_wellSelectionTreeView->treeView()->setSelectionMode( QAbstractItemView::ExtendedSelection ); + m_tableView = new QTableView( this ); + m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows ); + m_osduWellboresModel = new OsduWellboreTableModel; + m_tableView->setModel( m_osduWellboresModel ); + layout->addWidget( m_tableView ); + layout->setStretchFactor( m_tableView, 10 ); - connect( m_wellSelectionTreeView->treeView(), - SIGNAL( customContextMenuRequested( const QPoint& ) ), - SLOT( customMenuRequested( const QPoint& ) ) ); + m_wellPathImportObject = wellPathImport; - layout->addWidget( m_wellSelectionTreeView ); + m_osduConnector = osduConnector; + connect( m_osduConnector, SIGNAL( wellsFinished() ), SLOT( wellsFinished() ) ); + connect( m_osduConnector, SIGNAL( wellboresFinished( const QString& ) ), SLOT( wellboresFinished( const QString& ) ) ); - m_wellPathImportObject = wellPathImport; + connect( m_tableView->selectionModel(), + SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), + SLOT( selectWellbore( const QItemSelection&, const QItemSelection& ) ) ); - m_regionsWithVisibleWells = new ObjectGroupWithHeaders; - m_regionsWithVisibleWells->objects.uiCapability()->setUiHidden( true ); + connect( m_tableView->selectionModel(), + SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), + SIGNAL( completeChanged() ) ); } //-------------------------------------------------------------------------------------------------- @@ -851,211 +358,74 @@ void WellSelectionPage::initializePage() RiuWellImportWizard* wiz = dynamic_cast( wizard() ); if ( !wiz ) return; - wiz->downloadWells(); + QString fieldId = wiz->selectedFieldId(); + wiz->downloadWells( fieldId ); - setButtonText( QWizard::NextButton, "Download" ); + setButtonText( QWizard::NextButton, "Next" ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void WellSelectionPage::buildWellTreeView() +WellSelectionPage::~WellSelectionPage() { - for ( size_t rIdx = 0; rIdx < m_regionsWithVisibleWells->objects.size(); rIdx++ ) - { - caf::PdmObjectGroup* regGroup = dynamic_cast( m_regionsWithVisibleWells->objects[rIdx] ); - if ( !regGroup ) continue; - - for ( size_t fIdx = 0; fIdx < regGroup->objects.size(); fIdx++ ) - { - caf::PdmObjectGroup* fieldGroup = dynamic_cast( regGroup->objects[fIdx] ); - if ( !fieldGroup ) continue; - - // RimWellPathEntry objects are present here, they must be taken out out the container, but not deleted - // If fieldGroup->objects->deleteObjects is performed, the objects are deleted - fieldGroup->objects.clear(); - } - } - - // Delete all temporary pdm object groups - m_regionsWithVisibleWells->objects.deleteChildren(); - - for ( size_t rIdx = 0; rIdx < m_wellPathImportObject->regions.size(); rIdx++ ) - { - RimOilRegionEntry* oilRegion = m_wellPathImportObject->regions[rIdx]; - if ( oilRegion->selected ) - { - caf::PdmObjectCollection* regGroup = new caf::PdmObjectCollection; - regGroup->objects.uiCapability()->setUiHidden( true ); - - regGroup->setUiName( oilRegion->userDescriptionField()->uiCapability()->uiValue().toString() ); - - m_regionsWithVisibleWells->objects.push_back( regGroup ); - - for ( size_t fIdx = 0; fIdx < oilRegion->fields.size(); fIdx++ ) - { - RimOilFieldEntry* oilField = oilRegion->fields[fIdx]; - if ( oilField->selected ) - { - caf::PdmObjectCollection* fieldGroup = new caf::PdmObjectCollection; - fieldGroup->objects.uiCapability()->setUiHidden( true ); - - fieldGroup->setUiName( oilField->userDescriptionField()->uiCapability()->uiValue().toString() ); - - regGroup->objects.push_back( fieldGroup ); - - for ( size_t wIdx = 0; wIdx < oilField->wells.size(); wIdx++ ) - { - RimWellPathEntry* wellPathEntry = oilField->wells[wIdx]; - - // Create a copy of the PdmObject, as it is not supported to have multiple parents of any - // objects - QString objStr = wellPathEntry->writeObjectToXmlString(); - - RimWellPathEntry* wellPathCopy = new RimWellPathEntry; - wellPathCopy->readObjectFromXmlString( objStr, caf::PdmDefaultObjectFactory::instance() ); - wellPathCopy->selected = true; - - fieldGroup->objects.push_back( wellPathCopy ); - } - - sortObjectsByDescription( fieldGroup ); - } - } - } - } - - m_wellSelectionTreeView->setPdmItem( m_regionsWithVisibleWells ); - m_regionsWithVisibleWells->updateConnectedEditors(); - - m_wellSelectionTreeView->treeView()->expandAll(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -WellSelectionPage::~WellSelectionPage() +void WellSelectionPage::wellsFinished() { - if ( m_wellSelectionTreeView ) + std::vector wells = m_osduConnector->wells(); + for ( auto w : wells ) { - m_wellSelectionTreeView->setPdmItem( nullptr ); + m_osduConnector->requestWellboresByWellId( w.id ); } - delete m_regionsWithVisibleWells; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void WellSelectionPage::selectedWellPathEntries( std::vector& downloadEntities, caf::PdmObjectHandle* objHandle ) +void WellSelectionPage::wellboresFinished( const QString& wellId ) { - if ( objHandle == nullptr ) - { - objHandle = m_regionsWithVisibleWells; - } - - std::vector childFields = objHandle->fields(); - for ( size_t i = 0; i < childFields.size(); i++ ) - { - std::vector childObjects = childFields[i]->children(); - - for ( size_t j = 0; j < childObjects.size(); j++ ) - { - RimWellPathEntry* wellPathEntry = ( dynamic_cast( childObjects[j] ) ); - if ( wellPathEntry ) - { - if ( wellPathEntry->selected && wellPathEntry->isWellPathValid() ) - { - DownloadEntity urlToFile; - - urlToFile.name = wellPathEntry->name; - urlToFile.requestUrl = wellPathEntry->requestUrl; - urlToFile.responseFilename = wellPathEntry->wellPathFilePath; - - downloadEntities.push_back( urlToFile ); - } - } - else - { - selectedWellPathEntries( downloadEntities, childObjects[j] ); - } - } - } + std::vector wellbores = m_osduConnector->wellbores( wellId ); + if ( !wellbores.empty() ) m_osduWellboresModel->setOsduWellbores( wellId, wellbores ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void WellSelectionPage::customMenuRequested( const QPoint& pos ) +bool WellSelectionPage::isComplete() const { - QMenu menu; - - RiaFeatureCommandContextHelper helper( m_wellSelectionTreeView ); - - caf::CmdFeatureMenuBuilder menuBuilder; - - menuBuilder << "RicToggleItemsOnFeature"; - menuBuilder << "RicToggleItemsOffFeature"; - menuBuilder << "RicToggleItemsFeature"; - menuBuilder << "RicToggleItemsOnOthersOffFeature"; - - menuBuilder.appendToMenu( &menu ); - - // Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the - // viewport(). Since we might get this signal from different treeViews, we need to map the position accordingly. - QObject* senderObj = sender(); - QTreeView* treeView = dynamic_cast( senderObj ); - if ( treeView ) - { - QPoint globalPos = treeView->viewport()->mapToGlobal( pos ); - menu.exec( globalPos ); - } + QItemSelectionModel* select = m_tableView->selectionModel(); + return select->selectedRows().size() == 1; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool lessByDescription( const caf::PdmPointer& obj1, const caf::PdmPointer& obj2 ) +void WellSelectionPage::selectWellbore( const QItemSelection& newSelection, const QItemSelection& oldSelection ) { - caf::PdmUiFieldHandle* uiFieldHandle1 = nullptr; - caf::PdmUiFieldHandle* uiFieldHandle2 = nullptr; - - if ( obj1.notNull() && obj1->uiCapability() && obj1->uiCapability()->userDescriptionField() ) - { - uiFieldHandle1 = obj1->uiCapability()->userDescriptionField()->uiCapability(); - } - - if ( obj2.notNull() && obj2->uiCapability() && obj2->uiCapability()->userDescriptionField() ) + if ( !newSelection.indexes().empty() ) { - uiFieldHandle2 = obj2->uiCapability()->userDescriptionField()->uiCapability(); + QModelIndex index = newSelection.indexes()[0]; + int column = 0; + QString wellboreId = m_osduWellboresModel->data( index.siblingAtColumn( column ) ).toString(); + RiuWellImportWizard* wiz = dynamic_cast( wizard() ); + wiz->setSelectedWellboreId( wellboreId ); } - - if ( uiFieldHandle1 && uiFieldHandle2 ) - { - QString string1 = uiFieldHandle1->uiValue().toString(); - QString string2 = uiFieldHandle2->uiValue().toString(); - - return string1 < string2; - } - - return true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void WellSelectionPage::sortObjectsByDescription( caf::PdmObjectCollection* objects ) -{ - std::sort( objects->objects.begin(), objects->objects.end(), lessByDescription ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -WellSummaryPage::WellSummaryPage( RimWellPathImport* wellPathImport, QWidget* parent /*= 0*/ ) +WellSummaryPage::WellSummaryPage( RimWellPathImport* wellPathImport, RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) { m_wellPathImportObject = wellPathImport; m_wellPathImportObject->setUiHidden( true ); + m_osduConnector = osduConnector; + QVBoxLayout* layout = new QVBoxLayout; setLayout( layout ); @@ -1063,18 +433,10 @@ WellSummaryPage::WellSummaryPage( RimWellPathImport* wellPathImport, QWidget* pa m_textEdit->setReadOnly( true ); layout->addWidget( m_textEdit ); - QPushButton* button = new QPushButton( "Show/hide details", this ); - connect( button, SIGNAL( clicked() ), this, SLOT( slotShowDetails() ) ); - layout->addWidget( button ); - - m_listView = new caf::PdmUiListView( this ); - layout->setStretchFactor( m_listView, 10 ); - layout->addWidget( m_listView ); - m_listView->hide(); - - m_objectGroup = new caf::PdmObjectCollection; - setButtonText( QWizard::FinishButton, "Import" ); + + connect( m_osduConnector, SIGNAL( wellboreTrajectoryFinished( const QString& ) ), SLOT( wellboreTrajectoryFinished( const QString& ) ) ); + connect( m_osduConnector, SIGNAL( fileDownloadFinished( const QString& ) ), SLOT( fileDownloadFinished( const QString& ) ) ); } //-------------------------------------------------------------------------------------------------- @@ -1083,98 +445,59 @@ WellSummaryPage::WellSummaryPage( RimWellPathImport* wellPathImport, QWidget* pa void WellSummaryPage::initializePage() { RiuWellImportWizard* wiz = dynamic_cast( wizard() ); - wiz->downloadWellPaths(); + + QString wellboreId = wiz->selectedWellboreId(); + wiz->downloadWellPaths( wellboreId ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void WellSummaryPage::updateSummaryPage() +void WellSummaryPage::fileDownloadFinished( const QString& fileId, const QString& filePath ) { - m_objectGroup->objects.deleteChildren(); - m_textEdit->setText( "Summary of imported wells\n\n" ); - size_t wellPathCount = 0; - QString errorString; - - RiuWellImportWizard* wiz = dynamic_cast( wizard() ); - WellSelectionPage* wellSelectionPage = dynamic_cast( wiz->page( wiz->wellSelectionPageId() ) ); - std::vector downloadEntities; - wellSelectionPage->selectedWellPathEntries( downloadEntities, nullptr ); - - for ( size_t i = 0; i < downloadEntities.size(); i++ ) - { - if ( caf::Utils::fileExists( downloadEntities[i].responseFilename ) ) - { - wellPathCount++; - } - else - { - errorString += - QString( "Failed to get file '%1' from well '%2'\n" ).arg( downloadEntities[i].responseFilename ).arg( downloadEntities[i].name ); - } - - SummaryPageDownloadEntity* sumPageEntity = new SummaryPageDownloadEntity; - sumPageEntity->name = downloadEntities[i].name; - sumPageEntity->responseFilename = downloadEntities[i].responseFilename; - sumPageEntity->requestUrl = downloadEntities[i].requestUrl; - - m_objectGroup->objects().push_back( sumPageEntity ); - } - - m_textEdit->setText( QString( "Downloaded successfully %1 well paths.\nPlease push 'Import' button to import well " - "paths into ResInsight.\n\n" ) - .arg( wellPathCount ) ); - if ( !errorString.isEmpty() ) - { - m_textEdit->append( "Detected following errors during well path download. See details below." ); - m_textEdit->append( errorString ); - } - - m_listView->setPdmObject( m_objectGroup ); - m_objectGroup->updateConnectedEditors(); + m_textEdit->append( "FileId:" ); + m_textEdit->append( fileId ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void WellSummaryPage::slotShowDetails() +void WellSummaryPage::wellboreTrajectoryFinished( const QString& wellboreId ) { - if ( m_listView->isHidden() ) - { - m_listView->show(); - } - else - { - m_listView->hide(); - } -} + std::vector wellboreTrajectories = m_osduConnector->wellboreTrajectories( wellboreId ); + std::vector wells = m_osduConnector->wells(); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void ObjectGroupWithHeaders::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) -{ - caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast( attribute ); - if ( myAttr ) + auto findWellForWellId = []( const std::vector& wells, const QString& wellId ) -> std::optional { - QStringList colHeaders; - colHeaders << "Wells"; - myAttr->columnHeaders = colHeaders; - } -} + auto it = std::find_if( wells.begin(), wells.end(), [wellId]( const OsduWell& w ) { return w.id == wellId; } ); + if ( it != wells.end() ) + return std::optional( *it ); + else + return {}; + }; -CAF_PDM_SOURCE_INIT( SummaryPageDownloadEntity, "SummaryPageDownloadEntity" ); + RiuWellImportWizard* wiz = dynamic_cast( wizard() ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -SummaryPageDownloadEntity::SummaryPageDownloadEntity() -{ - CAF_PDM_InitObject( "SummaryPageDownloadEntity" ); + for ( auto w : wellboreTrajectories ) + { + // TODO: remove hack. A lot of the data set IDs in OSDU has trailing ":" which should not be + // there (i.e. the real id is without it). Chop them off to make more data sets work. + QString fileId = w.dataSetId; + if ( fileId.endsWith( ":" ) ) fileId.truncate( fileId.lastIndexOf( QChar( ':' ) ) ); + + QString wellId = m_osduConnector->wellIdForWellboreId( w.wellboreId ); + std::optional well = findWellForWellId( wells, wellId ); - CAF_PDM_InitFieldNoDefault( &name, "Name", "" ); - CAF_PDM_InitFieldNoDefault( &requestUrl, "RequestUrl", "" ); - CAF_PDM_InitFieldNoDefault( &responseFilename, "ResponseFilename", "" ); + if ( well.has_value() ) + { + QString wellboreTrajectoryId = w.id; + wiz->addWellInfo( { .name = well.value().name, + .wellId = well.value().id, + .wellboreId = w.wellboreId, + .wellboreTrajectoryId = wellboreTrajectoryId, + .fileId = fileId } ); + } + } } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index 16c841312f..deb3b4f33b 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -18,10 +18,6 @@ #pragma once -#include "cafPdmChildArrayField.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" - #include #include #include @@ -29,105 +25,232 @@ #include #include +#include "RiaOsduConnector.h" + class QFile; -class QProgressDialog; class QLabel; class QTextEdit; +class QTableView; class RimWellPathImport; -class RimOilFieldEntry; -class RimWellPathEntry; namespace caf { class PdmUiTreeView; class PdmUiListView; class PdmUiPropertyView; -class PdmObjectCollection; } // namespace caf -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class AuthenticationPage : public QWizardPage +class OsduFieldTableModel : public QAbstractTableModel { Q_OBJECT public: - AuthenticationPage( const QString& webServiceAddress, QWidget* parent = nullptr ); - - void initializePage() override; -}; + explicit OsduFieldTableModel( QObject* parent = nullptr ) + : QAbstractTableModel( parent ) + { + } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class FieldSelectionPage : public QWizardPage -{ - Q_OBJECT + int rowCount( const QModelIndex& parent = QModelIndex() ) const override + { + Q_UNUSED( parent ); + return static_cast( m_osduFields.size() ); + } -public: - FieldSelectionPage( RimWellPathImport* wellPathImport, QWidget* parent = nullptr ); - ~FieldSelectionPage() override; + int columnCount( const QModelIndex& parent = QModelIndex() ) const override + { + Q_UNUSED( parent ); + // Assuming you have three fields: id, kind, and name + return 3; + } - void initializePage() override; + QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override + { + if ( !index.isValid() ) return QVariant(); + + if ( index.row() >= static_cast( m_osduFields.size() ) || index.row() < 0 ) return QVariant(); + + if ( role == Qt::DisplayRole ) + { + const OsduField& field = m_osduFields.at( index.row() ); + switch ( index.column() ) + { + case 0: + return field.id; + case 1: + return field.kind; + case 2: + return field.name; + default: + return QVariant(); + } + } + + return QVariant(); + } + + QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override + { + if ( role != Qt::DisplayRole ) return QVariant(); + + if ( orientation == Qt::Horizontal ) + { + switch ( section ) + { + case 0: + return tr( "ID" ); + case 1: + return tr( "Kind" ); + case 2: + return tr( "Name" ); + default: + return QVariant(); + } + } + return QVariant(); + } + + void setOsduFields( const std::vector& osduFields ) + { + beginInsertRows( QModelIndex(), 0, static_cast( osduFields.size() ) ); + m_osduFields = osduFields; + endInsertRows(); + } private: - caf::PdmUiPropertyView* m_propertyView; + std::vector m_osduFields; }; -//-------------------------------------------------------------------------------------------------- -/// Container class used to define column headers -//-------------------------------------------------------------------------------------------------- -class ObjectGroupWithHeaders : public caf::PdmObject +class OsduWellboreTableModel : public QAbstractTableModel { - CAF_PDM_HEADER_INIT; + Q_OBJECT public: - ObjectGroupWithHeaders() + explicit OsduWellboreTableModel( QObject* parent = nullptr ) + : QAbstractTableModel( parent ) { - CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "" ); - - CAF_PDM_InitField( &m_isChecked, "IsChecked", true, "Active" ); - m_isChecked.uiCapability()->setUiHidden( true ); - }; + } - void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + int rowCount( const QModelIndex& parent = QModelIndex() ) const override + { + Q_UNUSED( parent ); + return static_cast( m_osduWellbores.size() ); + } -public: - caf::PdmChildArrayField objects; + int columnCount( const QModelIndex& parent = QModelIndex() ) const override + { + Q_UNUSED( parent ); + // Assuming you have three fields: id, kind, and name + return 3; + } -protected: - caf::PdmFieldHandle* objectToggleField() override { return &m_isChecked; } + QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override + { + if ( !index.isValid() ) return QVariant(); + + if ( index.row() >= static_cast( m_osduWellbores.size() ) || index.row() < 0 ) return QVariant(); + + if ( role == Qt::DisplayRole ) + { + const OsduWellbore& field = m_osduWellbores.at( index.row() ); + switch ( index.column() ) + { + case 0: + return field.id; + case 1: + return field.kind; + case 2: + return field.name; + default: + return QVariant(); + } + } + + return QVariant(); + } + + QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override + { + if ( role != Qt::DisplayRole ) return QVariant(); + + if ( orientation == Qt::Horizontal ) + { + switch ( section ) + { + case 0: + return tr( "ID" ); + case 1: + return tr( "Kind" ); + case 2: + return tr( "Name" ); + default: + return QVariant(); + } + } + return QVariant(); + } + + void setOsduWellbores( const QString& wellId, const std::vector& osduWellbores ) + { + m_map[wellId] = osduWellbores; + m_osduWellbores.clear(); + for ( auto [name, values] : m_map ) + { + for ( auto v : values ) + m_osduWellbores.push_back( v ); + } + + beginInsertRows( QModelIndex(), 0, static_cast( m_osduWellbores.size() ) ); + endInsertRows(); + } -protected: - caf::PdmField m_isChecked; +private: + std::vector m_osduWellbores; + std::map> m_map; }; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -class DownloadEntity +class AuthenticationPage : public QWizardPage { + Q_OBJECT + public: - QString name; - QString requestUrl; - QString responseFilename; + AuthenticationPage( RiaOsduConnector* osduConnector, QWidget* parent = nullptr ); + + void initializePage() override; + bool isComplete() const override; + +private slots: + void accessOk(); + +private: + bool m_accessOk; }; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -class SummaryPageDownloadEntity : public caf::PdmObject +class FieldSelectionPage : public QWizardPage { - CAF_PDM_HEADER_INIT; + Q_OBJECT public: - SummaryPageDownloadEntity(); + FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOsduConnector* m_osduConnector, QWidget* parent = nullptr ); + ~FieldSelectionPage() override; - caf::PdmField name; - caf::PdmField requestUrl; - caf::PdmField responseFilename; + void initializePage() override; + bool isComplete() const override; +private slots: + void fieldsFinished(); + void selectField( const QItemSelection& newSelection, const QItemSelection& oldSelection ); + +private: + // caf::PdmUiPropertyView* m_propertyView; + RiaOsduConnector* m_osduConnector; + QTableView* m_tableView; + OsduFieldTableModel* m_osduFieldsModel; }; //-------------------------------------------------------------------------------------------------- @@ -138,24 +261,22 @@ class WellSelectionPage : public QWizardPage Q_OBJECT public: - WellSelectionPage( RimWellPathImport* wellPathImport, QWidget* parent = nullptr ); + WellSelectionPage( RimWellPathImport* wellPathImport, RiaOsduConnector* m_osduConnector, QWidget* parent = nullptr ); ~WellSelectionPage() override; void initializePage() override; - void buildWellTreeView(); - - void selectedWellPathEntries( std::vector& downloadEntities, caf::PdmObjectHandle* objHandle ); - -private: - void sortObjectsByDescription( caf::PdmObjectCollection* objects ); + bool isComplete() const override; private slots: - void customMenuRequested( const QPoint& pos ); + void wellboresFinished( const QString& wellId ); + void wellsFinished(); + void selectWellbore( const QItemSelection& newSelection, const QItemSelection& oldSelection ); private: - ObjectGroupWithHeaders* m_regionsWithVisibleWells; RimWellPathImport* m_wellPathImportObject; - caf::PdmUiTreeView* m_wellSelectionTreeView; + RiaOsduConnector* m_osduConnector; + QTableView* m_tableView; + OsduWellboreTableModel* m_osduWellboresModel; }; //-------------------------------------------------------------------------------------------------- @@ -166,20 +287,18 @@ class WellSummaryPage : public QWizardPage Q_OBJECT public: - WellSummaryPage( RimWellPathImport* wellPathImport, QWidget* parent = nullptr ); + WellSummaryPage( RimWellPathImport* wellPathImport, RiaOsduConnector* osduConnector, QWidget* parent = nullptr ); void initializePage() override; - void updateSummaryPage(); - private slots: - void slotShowDetails(); + void wellboreTrajectoryFinished( const QString& wellId ); + void fileDownloadFinished( const QString& fileId, const QString& filePath ); private: - RimWellPathImport* m_wellPathImportObject; - QTextEdit* m_textEdit; - caf::PdmUiListView* m_listView; - caf::PdmObjectCollection* m_objectGroup; + RimWellPathImport* m_wellPathImportObject; + RiaOsduConnector* m_osduConnector; + QTextEdit* m_textEdit; }; //-------------------------------------------------------------------------------------------------- @@ -190,88 +309,50 @@ class RiuWellImportWizard : public QWizard Q_OBJECT public: - enum DownloadState + struct WellInfo { - DOWNLOAD_FIELDS, - DOWNLOAD_WELLS, - DOWNLOAD_WELL_PATH, - DOWNLOAD_UNDEFINED + QString name; + QString wellId; + QString wellboreId; + QString wellboreTrajectoryId; + QString fileId; }; -public: - RiuWellImportWizard( const QString& webServiceAddress, - const QString& downloadFolder, + RiuWellImportWizard( const QString& downloadFolder, + RiaOsduConnector* osduConnector, RimWellPathImport* wellPathImportObject, QWidget* parent = nullptr ); ~RiuWellImportWizard() override; - void setCredentials( const QString& username, const QString& password ); - QStringList absoluteFilePathsToWellPaths() const; - // Methods used from the wizard pages void resetAuthenticationCount(); -public slots: - void downloadWellPaths(); - void downloadWells(); - void downloadFields(); + void setSelectedFieldId( const QString& fieldId ); + QString selectedFieldId() const; + void setSelectedWellboreId( const QString& wellboreId ); + QString selectedWellboreId() const; - void checkDownloadQueueAndIssueRequests(); + void addWellInfo( RiuWellImportWizard::WellInfo wellInfo ); + std::vector importedWells() const; - void issueHttpRequestToFile( QString completeUrlText, QString destinationFileName ); - void cancelDownload(); - - void httpFinished(); - void httpReadyRead(); +public slots: + void downloadWellPaths( const QString& wellboreId ); + void downloadWells( const QString& fieldId ); + void downloadFields(); void slotAuthenticationRequired( QNetworkReply* networkReply, QAuthenticator* authenticator ); - int wellSelectionPageId(); - -#if !defined( QT_NO_OPENSSL ) && !defined( CVF_OSX ) - void sslErrors( QNetworkReply*, const QList& errors ); -#endif - -private slots: - void slotCurrentIdChanged( int currentId ); - private: - void startRequest( QUrl url ); - void setUrl( const QString& httpAddress ); + RiaOsduConnector* m_osduConnector; + QString m_selectedFieldId; + QString m_selectedWellboreId; - QString jsonFieldsFilePath(); - QString jsonWellsFilePath(); - - void updateFieldsModel(); - void parseWellsResponse( RimOilFieldEntry* oilFieldEntry ); - - QString getValue( const QString& key, const QString& stringContent ); - - QProgressDialog* progressDialog(); - void hideProgressDialog(); - -private: - QString m_webServiceAddress; QString m_destinationFolder; RimWellPathImport* m_wellPathImportObject; caf::PdmUiTreeView* m_pdmTreeView; - QProgressDialog* m_myProgressDialog; - - QUrl m_url; - QNetworkAccessManager m_networkAccessManager; - QNetworkReply* m_reply; - QFile* m_file; - bool m_httpRequestAborted; - bool m_firstTimeRequestingAuthentication; - QList m_wellRequestQueue; - - DownloadState m_currentDownloadState; - - int m_fieldSelectionPageId; - int m_wellSelectionPageId; - int m_wellSummaryPageId; + std::vector m_wellInfos; }; diff --git a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake index 8d2d0a8123..f44a0e80f4 100644 --- a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake @@ -96,6 +96,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationImporter.h ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationExporter.h ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader.h + ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellPathReader.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -191,6 +192,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationImporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationExporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellPathReader.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp new file mode 100644 index 0000000000..2ac47bb23d --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp @@ -0,0 +1,92 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RifOsduWellPathReader.h" + +#include "RiaTextStringTools.h" + +#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" + +#include "RifCsvUserDataParser.h" + +#include "RigWellPath.h" + +#include "cvfObject.h" +#include "cvfVector3.h" + +#include +#include + +std::pair, QString> RifOsduWellPathReader::parseCsv( const QString& content ) +{ + QString errorMessage; + RifCsvUserDataPastedTextParser parser( content, &errorMessage ); + + AsciiDataParseOptions parseOptions; + parseOptions.cellSeparator = ","; + parseOptions.decimalSeparator = "."; + + std::vector>> readValues; + + if ( parser.parse( parseOptions ) ) + { + for ( auto s : parser.tableData().columnInfos() ) + { + if ( s.dataType != Column::NUMERIC ) continue; + + QString columnName = QString::fromStdString( s.columnName() ); + bool isNumber = false; + auto value = columnName.toDouble( &isNumber ); + std::vector values = s.values; + if ( isNumber ) + { + values.insert( values.begin(), value ); + } + readValues.push_back( { columnName, values } ); + } + } + + const int MD_INDEX = 0; + const int TVD_INDEX = 1; + const int X_INDEX = 4; + const int Y_INDEX = 5; + + if ( readValues.size() == 10 ) + { + const size_t firstSize = readValues[MD_INDEX].second.size(); + if ( ( firstSize == readValues[TVD_INDEX].second.size() ) && ( firstSize == readValues[X_INDEX].second.size() ) && + ( firstSize == readValues[Y_INDEX].second.size() ) ) + { + std::vector wellPathPoints; + std::vector measuredDepths; + + for ( size_t i = 0; i < firstSize; i++ ) + { + cvf::Vec3d point( readValues[X_INDEX].second[i], readValues[Y_INDEX].second[i], -readValues[TVD_INDEX].second[i] ); + double md = readValues[MD_INDEX].second[i]; + + wellPathPoints.push_back( point ); + measuredDepths.push_back( md ); + } + + return { new RigWellPath( wellPathPoints, measuredDepths ), "" }; + } + } + + return { nullptr, "Oh no!" }; +} diff --git a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.h b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.h new file mode 100644 index 0000000000..a78859dd6f --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 + +#include "cvfObject.h" + +class RigWellPath; + +//================================================================================================== +// +// +//================================================================================================== +class RifOsduWellPathReader +{ +public: + static std::pair, QString> parseCsv( const QString& content ); +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 19dbea920c..8bc343eed3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -370,7 +370,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); menuBuilder.subMenuStart( "Import" ); menuBuilder << "RicWellPathsImportFileFeature"; - menuBuilder << "RicWellPathsImportSsihubFeature"; + menuBuilder << "RicWellPathsImportOsduFeature"; menuBuilder << "RicWellPathFormationsImportFileFeature"; menuBuilder << "RicWellLogsImportFileFeature"; menuBuilder << "RicReloadWellPathFormationNamesFeature"; diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index a9ae2a490b..18b1710b5c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -270,8 +270,6 @@ void RimProject::close() casesObsolete.deleteChildren(); caseGroupsObsolete.deleteChildren(); - wellPathImport->regions().deleteChildren(); - commandObjects.deleteChildren(); multiSnapshotDefinitions.deleteChildren(); @@ -512,7 +510,6 @@ void RimProject::setProjectFileNameAndUpdateDependencies( const QString& project filePath->setPath( newFilePath ); } - wellPathImport->updateFilePaths(); auto* wellPathColl = RimTools::wellPathCollection(); if ( wellPathColl ) { diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake index fd3d9472d2..ab55fcaf61 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake @@ -15,6 +15,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellIAModelBox.h ${CMAKE_CURRENT_LIST_DIR}/RimWellIAModelData.h ${CMAKE_CURRENT_LIST_DIR}/RimWellIADataAccess.h + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellPath.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -34,6 +35,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellIAModelBox.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellIAModelData.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellIADataAccess.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellPath.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp new file mode 100644 index 0000000000..7529828939 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp @@ -0,0 +1,110 @@ +#include "RimOsduWellPath.h" + +#include "cafPdmObjectScriptingCapability.h" + +CAF_PDM_SOURCE_INIT( RimOsduWellPath, "OsduWellPath" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimOsduWellPath::RimOsduWellPath() +{ + CAF_PDM_InitScriptableObjectWithNameAndComment( "Osdu Well Path", ":/Well.svg", "", "", "OsduWellPath", "Well Path Loaded From Osdu" ); + + CAF_PDM_InitFieldNoDefault( &m_wellId, "WellId", "Well Id" ); + m_wellId.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_wellboreId, "WellboreId", "Wellbore Id" ); + m_wellboreId.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_wellboreTrajectoryId, "WellboreTrajectoryId", "Wellbore Trajectory Id" ); + m_wellboreTrajectoryId.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_fileId, "FileId", "File Id" ); + m_fileId.uiCapability()->setUiReadOnly( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimOsduWellPath::~RimOsduWellPath() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellPath::setWellId( const QString& wellId ) +{ + m_wellId = wellId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimOsduWellPath::wellId() const +{ + return m_wellId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellPath::setWellboreId( const QString& wellboreId ) +{ + m_wellboreId = wellboreId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimOsduWellPath::wellboreId() const +{ + return m_wellboreId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellPath::setWellboreTrajectoryId( const QString& wellboreTrajectoryId ) +{ + m_wellboreTrajectoryId = wellboreTrajectoryId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimOsduWellPath::wellboreTrajectoryId() const +{ + return m_wellboreTrajectoryId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellPath::setFileId( const QString& fileId ) +{ + m_fileId = fileId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimOsduWellPath::fileId() const +{ + return m_fileId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + caf::PdmUiGroup* osduGroup = uiOrdering.addNewGroup( "OSDU" ); + osduGroup->add( &m_wellId ); + osduGroup->add( &m_wellboreId ); + osduGroup->add( &m_wellboreTrajectoryId ); + osduGroup->add( &m_fileId ); + + RimWellPath::defineUiOrdering( uiConfigName, uiOrdering ); +} diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h new file mode 100644 index 0000000000..a1968cf336 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h @@ -0,0 +1,50 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimWellPath.h" + +class RimOsduWellPath : public RimWellPath +{ + CAF_PDM_HEADER_INIT; + +public: + RimOsduWellPath(); + ~RimOsduWellPath() override; + + void setWellId( const QString& wellId ); + QString wellId() const; + + void setWellboreId( const QString& wellboreId ); + QString wellboreId() const; + + void setWellboreTrajectoryId( const QString& wellboreTrajectoryId ); + QString wellboreTrajectoryId() const; + + void setFileId( const QString& fileId ); + QString fileId() const; + +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + +private: + caf::PdmField m_wellId; + caf::PdmField m_wellboreId; + caf::PdmField m_wellboreTrajectoryId; + caf::PdmField m_fileId; +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index e258825897..7aa323c371 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -20,6 +20,7 @@ #include "RimWellPathCollection.h" +#include "OsduImportCommands/RiaOsduConnector.h" #include "RiaColorTables.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" @@ -27,6 +28,7 @@ #include "RiaTextStringTools.h" #include "RiaWellNameComparer.h" +#include "RifOsduWellPathReader.h" #include "RifWellPathFormationsImporter.h" #include "RifWellPathImporter.h" @@ -40,6 +42,7 @@ #include "RimFileWellPath.h" #include "RimModeledWellPath.h" #include "RimOilField.h" +#include "RimOsduWellPath.h" #include "RimPerforationCollection.h" #include "RimProject.h" #include "RimStimPlanModel.h" @@ -50,6 +53,8 @@ #include "RimWellPathCompletionSettings.h" #include "RimWellPathTieIn.h" +#include "RiuMainWindow.h" + #include "cafTreeNode.h" // TODO: Move to caf #include "Riu3DMainWindowTools.h" @@ -67,6 +72,7 @@ #include #include +#include namespace caf { @@ -149,6 +155,7 @@ void RimWellPathCollection::loadDataAndUpdate() auto* fWPath = dynamic_cast( wellPath ); auto* mWPath = dynamic_cast( wellPath ); + auto* oWPath = dynamic_cast( wellPath ); if ( fWPath ) { if ( !fWPath->filePath().isEmpty() ) @@ -164,6 +171,31 @@ void RimWellPathCollection::loadDataAndUpdate() { mWPath->createWellPathGeometry(); } + else if ( oWPath ) + { + RiaApplication* app = RiaApplication::instance(); + + RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences(); + + const QString server = osduPreferences->server(); + const QString dataParitionId = osduPreferences->dataPartitionId(); + const QString authority = osduPreferences->authority(); + const QString scopes = osduPreferences->scopes(); + const QString clientId = osduPreferences->clientId(); + + auto osduConnector = + std::make_unique( RiuMainWindow::instance(), server, dataParitionId, authority, scopes, clientId ); + + auto [wellPathGeometry, errorMessage] = loadWellPathGeometryFromOsdu( osduConnector.get(), oWPath->fileId() ); + if ( wellPathGeometry.notNull() ) + { + oWPath->setWellPathGeometry( wellPathGeometry.p() ); + } + else + { + RiaLogging::warning( errorMessage ); + } + } if ( wellPath ) { @@ -1013,3 +1045,18 @@ void RimWellPathCollection::onChildAdded( caf::PdmFieldHandle* containerForNewOb scheduleRedrawAffectedViews(); uiCapability()->updateConnectedEditors(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair, QString> RimWellPathCollection::loadWellPathGeometryFromOsdu( RiaOsduConnector* osduConnector, + const QString& fileId ) +{ + auto [fileContents, errorMessage] = osduConnector->requestFileContentsById( fileId ); + if ( !errorMessage.isEmpty() ) + { + return { nullptr, errorMessage }; + } + + return RifOsduWellPathReader::parseCsv( fileContents ); +} diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h index db57a69225..84e7d63035 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h @@ -38,6 +38,7 @@ #include +class RiaOsduConnector; class RifWellPathImporter; class RigWellPath; class RimFileWellPath; @@ -131,6 +132,8 @@ class RimWellPathCollection : public caf::PdmObject void onChildAdded( caf::PdmFieldHandle* containerForNewObject ) override; + static std::pair, QString> loadWellPathGeometryFromOsdu( RiaOsduConnector* osduConnector, const QString& fileId ); + protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationLibCode/UnitTests/CMakeLists.txt b/ApplicationLibCode/UnitTests/CMakeLists.txt index ac7d8e0de6..7a484008a5 100644 --- a/ApplicationLibCode/UnitTests/CMakeLists.txt +++ b/ApplicationLibCode/UnitTests/CMakeLists.txt @@ -103,6 +103,7 @@ set(SOURCE_UNITTEST_FILES ${CMAKE_CURRENT_LIST_DIR}/RimEmReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifParquetReader-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellPathReader-Test.cpp ) if(RESINSIGHT_ENABLE_GRPC) diff --git a/ApplicationLibCode/UnitTests/RifOsduWellPathReader-Test.cpp b/ApplicationLibCode/UnitTests/RifOsduWellPathReader-Test.cpp new file mode 100644 index 0000000000..d4e915371f --- /dev/null +++ b/ApplicationLibCode/UnitTests/RifOsduWellPathReader-Test.cpp @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "gtest/gtest.h" + +#include "RifOsduWellPathReader.h" + +#include "RigWellPath.h" + +#include "cvfObject.h" + +TEST( RifOsduWellPathReader, ParseCsv ) +{ + std::string fileContent = R"( +MD,TVD,AZIMUTH,INCLINATION,X,Y,GODLEG_SEVERITY,DX,DY,UWI,WELLBORE,CRS,EPSG_CODE +0.0,0.0,1e-10,0.0,68.8767382,33.1345775,0.0,0.0,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 +271.49,271.49,1e-10,0.0,68.8767382,33.1345775,0.0,0.0,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 +306.29,306.29,272.01823962,0.08968724,68.8767375,33.1345774,0.24,-0.06,-0.01,WELL NAME #1,WELL NAME #1,WGS84,4326 +336.29,336.29,274.30140794,0.15846019,68.8767368,33.1345775,0.22,-0.12,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 +366.29,366.29,278.8234303,0.09299958,68.8767359,33.1345775,0.23,-0.2,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 +396.29,396.29,272.75661039,0.10458399,68.8767352,33.1345775,0.11,-0.26,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 +426.56,426.29,268.84493373,0.12982945,68.8767347,33.1345775,0.24,-0.3,0.0,WELL NAME #1,WELL NAME #1,WGS84,4326 +456.29,456.29,247.08294017,0.24449049,68.8767336,33.1345774,0.58,-0.39,-0.01,WELL NAME #1,WELL NAME #1,WGS84,4326 +486.29,486.28,228.45433687,1.77934187,68.876729,33.1345746,1.0,-0.78,-0.33,WELL NAME #1,WELL NAME #1,WGS84,4326 +516.29,516.25,234.24032672,3.25969626,68.8767165,33.1345672,1.41,-1.85,-1.15,WELL NAME #1,WELL NAME #1,WGS84,4326 +546.29,546.17,235.37605057,5.34499442,68.8766954,33.1345561,3.39,-3.64,-2.39,WELL NAME #1,WELL NAME #1,WGS84,4326 +576.29,575.97,233.86086873,7.54998951,68.8766625,33.1345381,1.98,-6.44,-4.4,WELL NAME #1,WELL NAME #1,WGS84,4326 +)"; + + QString fileContentAsQString = QString::fromStdString( fileContent ); + + auto [wellPath, errorMessage] = RifOsduWellPathReader::parseCsv( fileContentAsQString ); + EXPECT_TRUE( wellPath.notNull() ); + + EXPECT_EQ( 12u, wellPath->wellPathPoints().size() ); + EXPECT_EQ( 12u, wellPath->measuredDepths().size() ); + + cvf::Vec3d point = wellPath->wellPathPoints()[6]; + EXPECT_DOUBLE_EQ( 68.8767347, point.x() ); + EXPECT_DOUBLE_EQ( 33.1345775, point.y() ); + EXPECT_DOUBLE_EQ( -426.29, point.z() ); + + EXPECT_DOUBLE_EQ( 426.56, wellPath->measuredDepths()[6] ); +} diff --git a/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp b/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp index 9e48e1a273..a658e219c9 100644 --- a/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp @@ -138,7 +138,7 @@ void RiuMenuBarBuildTools::addImportMenuWithActions( QObject* parent, QMenu* men importMenu->addSeparator(); QMenu* importWellMenu = importMenu->addMenu( QIcon( ":/Well.svg" ), "Well Data" ); importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathsImportFileFeature" ) ); - importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathsImportSsihubFeature" ) ); + importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathsImportOsduFeature" ) ); importWellMenu->addAction( cmdFeatureMgr->action( "RicWellLogsImportFileFeature" ) ); importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathFormationsImportFileFeature" ) ); importWellMenu->addAction( cmdFeatureMgr->action( "RicImportWellMeasurementsFeature" ) ); diff --git a/CMakeLists.txt b/CMakeLists.txt index f99c07e292..58c8c0ce24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -508,7 +508,8 @@ endif() set(RI_QT_MINIMUM_VERSION 5.12) find_package( - Qt5 ${RI_QT_MINIMUM_VERSION} COMPONENTS Core Gui OpenGL Network Widgets + Qt5 ${RI_QT_MINIMUM_VERSION} COMPONENTS Core Gui OpenGL Network NetworkAuth + Widgets ) # Open GL From 1b93347aeaf9e9b6798938ed68e6f1d1eb636467 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 16 May 2024 15:00:05 +0200 Subject: [PATCH 085/332] Fix unity build --- ApplicationLibCode/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index 01d647af09..f74cf8067b 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -418,6 +418,7 @@ set(UNITY_EXCLUDE_FILES # Exclude files including opm-common ProjectDataModel/RimVfpTableExtractor.cpp ProjectDataModel/RimVfpPlot.cpp + ProjectDataModel/RiaOpmParserTools.cpp ) if(RESINSIGHT_ENABLE_UNITY_BUILD) From 9858d09a33d6f4de3820ed696b4fa418f329a6f0 Mon Sep 17 00:00:00 2001 From: Jon Jenssen Date: Mon, 27 May 2024 14:41:24 +0200 Subject: [PATCH 086/332] Add support for overriding egrid reader type on command line. Override disables GUI in preferences. --- .../Application/RiaConsoleApplication.cpp | 7 ++++ ApplicationLibCode/Application/RiaDefines.h | 3 +- .../Application/RiaGuiApplication.cpp | 7 ++++ .../Application/RiaPreferences.cpp | 37 ++++++++++++++++++- .../Application/RiaPreferences.h | 3 ++ .../Application/Tools/RiaArgumentParser.cpp | 5 +++ 6 files changed, 60 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/Application/RiaConsoleApplication.cpp b/ApplicationLibCode/Application/RiaConsoleApplication.cpp index 97a4b8b88b..b0a3e65dc8 100644 --- a/ApplicationLibCode/Application/RiaConsoleApplication.cpp +++ b/ApplicationLibCode/Application/RiaConsoleApplication.cpp @@ -161,6 +161,13 @@ RiaApplication::ApplicationStatus RiaConsoleApplication::handleArguments( gsl::n setStartDir( cvfqt::Utils::toQString( o.value( 0 ) ) ); } + if ( cvf::Option o = progOpt->option( "egridReader" ) ) + { + CVF_ASSERT( o.valueCount() == 1 ); + std::string readerName = o.value( 0 ).toLower().toStdString(); + m_preferences->setGridModelReaderOverride( readerName ); + } + QString projectFileName; if ( progOpt->hasOption( "last" ) ) diff --git a/ApplicationLibCode/Application/RiaDefines.h b/ApplicationLibCode/Application/RiaDefines.h index f75a8c171f..95ae5705ea 100644 --- a/ApplicationLibCode/Application/RiaDefines.h +++ b/ApplicationLibCode/Application/RiaDefines.h @@ -173,7 +173,8 @@ enum class GridCaseAxis enum class GridModelReader { RESDATA, - OPM_COMMON + OPM_COMMON, + NOT_SET }; enum class ThemeEnum diff --git a/ApplicationLibCode/Application/RiaGuiApplication.cpp b/ApplicationLibCode/Application/RiaGuiApplication.cpp index 461e99ec54..8aee18445f 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.cpp +++ b/ApplicationLibCode/Application/RiaGuiApplication.cpp @@ -521,6 +521,13 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n setStartDir( cvfqt::Utils::toQString( o.value( 0 ) ) ); } + if ( cvf::Option o = progOpt->option( "egridReader" ) ) + { + CVF_ASSERT( o.valueCount() == 1 ); + std::string readerName = o.value( 0 ).toLower().toStdString(); + m_preferences->setGridModelReaderOverride( readerName ); + } + if ( cvf::Option o = progOpt->option( "size" ) ) { int width = o.safeValue( 0 ).toInt( -1 ); diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index eb2bbee2f1..9e6807d30d 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -23,6 +23,7 @@ #include "RiaApplication.h" #include "RiaColorTables.h" +#include "RiaLogging.h" #include "RiaPreferencesGeoMech.h" #include "RiaPreferencesSummary.h" #include "RiaPreferencesSystem.h" @@ -81,6 +82,7 @@ CAF_PDM_SOURCE_INIT( RiaPreferences, "RiaPreferences" ); /// //-------------------------------------------------------------------------------------------------- RiaPreferences::RiaPreferences() + : m_gridModelReaderOverride( RiaDefines::GridModelReader::NOT_SET ) { CAF_PDM_InitField( &m_navigationPolicy, "navigationPolicy", @@ -388,7 +390,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& } else if ( uiConfigName == RiaPreferences::tabNameGrid() ) { - uiOrdering.add( &m_gridModelReader ); + if ( m_gridModelReaderOverride == RiaDefines::GridModelReader::NOT_SET ) uiOrdering.add( &m_gridModelReader ); caf::PdmUiGroup* newCaseBehaviourGroup = uiOrdering.addNewGroup( "Behavior When Loading Data" ); newCaseBehaviourGroup->add( &autocomputeDepthRelatedProperties ); @@ -692,9 +694,42 @@ const RifReaderSettings* RiaPreferences::readerSettings() const //-------------------------------------------------------------------------------------------------- RiaDefines::GridModelReader RiaPreferences::gridModelReader() const { + if ( m_gridModelReaderOverride != RiaDefines::GridModelReader::NOT_SET ) + { + return m_gridModelReaderOverride; + } + return m_gridModelReader(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferences::setGridModelReaderOverride( const std::string& readerName ) +{ + RiaDefines::GridModelReader readerType = RiaDefines::GridModelReader::NOT_SET; + if ( readerName == "opm_common" ) + { + readerType = RiaDefines::GridModelReader::OPM_COMMON; + } + else if ( readerName == "resdata" ) + { + readerType = RiaDefines::GridModelReader::RESDATA; + } + else + { + RiaLogging::warning( QString::fromStdString( "Unknown EGRID reader type specified on command line: " + readerName ) ); + return; + } + + if ( readerType != RiaDefines::GridModelReader::NOT_SET ) + { + RiaLogging::info( QString::fromStdString( "Using EGRID reader: " + readerName ) ); + } + + m_gridModelReaderOverride = readerType; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferences.h b/ApplicationLibCode/Application/RiaPreferences.h index 8f6d5e8b48..5ecf7f78b3 100644 --- a/ApplicationLibCode/Application/RiaPreferences.h +++ b/ApplicationLibCode/Application/RiaPreferences.h @@ -39,6 +39,7 @@ #include #include +#include class RifReaderSettings; class RiaPreferencesSummary; @@ -71,6 +72,7 @@ class RiaPreferences : public caf::PdmObject const RifReaderSettings* readerSettings() const; RiaDefines::GridModelReader gridModelReader() const; + void setGridModelReaderOverride( const std::string& readerName ); bool useUndoRedo() const; @@ -180,6 +182,7 @@ class RiaPreferences : public caf::PdmObject private: caf::PdmField m_gridModelReader; + RiaDefines::GridModelReader m_gridModelReaderOverride; caf::PdmChildField m_readerSettings; caf::PdmField m_dateFormat; diff --git a/ApplicationLibCode/Application/Tools/RiaArgumentParser.cpp b/ApplicationLibCode/Application/Tools/RiaArgumentParser.cpp index ed231aea5b..600bdc77b6 100644 --- a/ApplicationLibCode/Application/Tools/RiaArgumentParser.cpp +++ b/ApplicationLibCode/Application/Tools/RiaArgumentParser.cpp @@ -135,6 +135,11 @@ bool RiaArgumentParser::parseArguments( cvf::ProgramOptions* progOpt ) progOpt->registerOption( "version", "", "Display the application version string" ); progOpt->registerOption( "openplotwindow", "", "Open the 2D plot window. By default, the 3D window is displayed." ); + progOpt->registerOption( "egridReader", + "", + "Select the reader type used to access EGRID files, valid values are RESDATA or OPM_COMMON", + cvf::ProgramOptions::SINGLE_VALUE ); + progOpt->setOptionPrefix( cvf::ProgramOptions::DOUBLE_DASH ); QStringList arguments = QCoreApplication::arguments(); From c1aba471f2e55a4dd3cd4d6e5d06cb05fcfbfb26 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 27 May 2024 12:09:47 +0200 Subject: [PATCH 087/332] Refactor: rename WellLogFileChannel to WellLogChannel. --- .../RicCreateDepthAdjustedLasFilesUi.cpp | 2 +- ApplicationLibCode/Commands/RicWellLogTools.cpp | 12 ++++++------ ApplicationLibCode/Commands/RicWellLogTools.h | 4 ++-- .../RicAddWellLogToPlotFeature.cpp | 12 ++++++------ .../RicAddWellLogToPlotFeature.h | 4 ++-- .../RicNewWellBoreStabilityPlotFeature.cpp | 2 +- .../RicNewWellLogFileCurveFeature.cpp | 2 +- .../ProjectDataModel/Flow/RimWellPlotTools.cpp | 14 +++++++------- .../ProjectDataModel/Flow/RimWellPlotTools.h | 8 ++++---- .../ProjectDataModel/Flow/RimWellPltPlot.cpp | 2 +- .../ProjectDataModel/Flow/RimWellPltPlot.h | 2 +- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 6 +++--- .../ProjectDataModel/Flow/RimWellRftPlot.h | 2 +- .../RimContextCommandBuilder.cpp | 6 +++--- .../WellLog/CMakeLists_files.cmake | 2 +- .../WellLog/Rim3dWellLogExtractionCurve.cpp | 2 +- .../WellLog/Rim3dWellLogFileCurve.cpp | 6 +++--- .../WellLog/RimEnsembleWellLogCurveSet.cpp | 4 ++-- ...LogFileChannel.cpp => RimWellLogChannel.cpp} | 8 ++++---- ...WellLogFileChannel.h => RimWellLogChannel.h} | 4 ++-- .../WellLog/RimWellLogCsvFile.cpp | 4 ++-- .../WellLog/RimWellLogExtractionCurve.cpp | 2 +- .../ProjectDataModel/WellLog/RimWellLogFile.cpp | 6 +++--- .../ProjectDataModel/WellLog/RimWellLogFile.h | 14 +++++++------- .../WellLog/RimWellLogLasFile.cpp | 4 ++-- .../WellLog/RimWellLogLasFile.h | 2 +- .../WellLog/RimWellLogLasFileCurve.cpp | 4 ++-- .../WellLog/RimWellLogLasFileCurve.h | 2 +- .../ProjectDataModel/WellPath/RimWellPath.cpp | 6 +++--- .../UserInterface/RiuDragDrop.cpp | 17 ++++++++--------- 30 files changed, 82 insertions(+), 83 deletions(-) rename ApplicationLibCode/ProjectDataModel/WellLog/{RimWellLogFileChannel.cpp => RimWellLogChannel.cpp} (87%) rename ApplicationLibCode/ProjectDataModel/WellLog/{RimWellLogFileChannel.h => RimWellLogChannel.h} (94%) diff --git a/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesUi.cpp index ad275a9233..dbf0ed3221 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesUi.cpp @@ -24,7 +24,7 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimTools.h" -#include "RimWellLogFileChannel.h" +#include "RimWellLogChannel.h" #include "RimWellLogLasFile.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" diff --git a/ApplicationLibCode/Commands/RicWellLogTools.cpp b/ApplicationLibCode/Commands/RicWellLogTools.cpp index bb90dcd940..9a8f412f0e 100644 --- a/ApplicationLibCode/Commands/RicWellLogTools.cpp +++ b/ApplicationLibCode/Commands/RicWellLogTools.cpp @@ -31,9 +31,9 @@ #include "RimSimWellInView.h" #include "RimSummaryCase.h" #include "RimWellLogCalculatedCurve.h" +#include "RimWellLogChannel.h" #include "RimWellLogCurveCommonDataSource.h" #include "RimWellLogExtractionCurve.h" -#include "RimWellLogFileChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogLasFileCurve.h" #include "RimWellLogRftCurve.h" @@ -136,21 +136,21 @@ bool RicWellLogTools::isWellPathOrSimWellSelectedInView() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellLogTools::addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack, const std::vector& wellLogFileChannels ) +void RicWellLogTools::addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack, const std::vector& wellLogChannels ) { - for ( size_t cIdx = 0; cIdx < wellLogFileChannels.size(); cIdx++ ) + for ( RimWellLogChannel* wellLogChannel : wellLogChannels ) { RimWellLogLasFileCurve* plotCurve = RicWellLogTools::addFileCurve( plotTrack ); - RimWellPath* wellPath = wellLogFileChannels[cIdx]->firstAncestorOrThisOfType(); - RimWellLogLasFile* wellLogFile = wellLogFileChannels[cIdx]->firstAncestorOrThisOfType(); + RimWellPath* wellPath = wellLogChannel->firstAncestorOrThisOfType(); + RimWellLogLasFile* wellLogFile = wellLogChannel->firstAncestorOrThisOfType(); if ( wellPath ) { if ( wellLogFile ) plotCurve->setWellLogFile( wellLogFile ); plotCurve->setWellPath( wellPath ); - plotCurve->setWellLogChannelName( wellLogFileChannels[cIdx]->name() ); + plotCurve->setWellLogChannelName( wellLogChannel->name() ); plotCurve->loadDataAndUpdate( true ); plotCurve->updateConnectedEditors(); } diff --git a/ApplicationLibCode/Commands/RicWellLogTools.h b/ApplicationLibCode/Commands/RicWellLogTools.h index 5648b9542b..563895e898 100644 --- a/ApplicationLibCode/Commands/RicWellLogTools.h +++ b/ApplicationLibCode/Commands/RicWellLogTools.h @@ -29,7 +29,7 @@ class RimSimWellInView; class Rim3dView; class Rim3dWellLogCurveCollection; class RimWellLogExtractionCurve; -class RimWellLogFileChannel; +class RimWellLogChannel; class RimWellLogLasFileCurve; class RimWellLogRftCurve; class RimWellLogTrack; @@ -50,7 +50,7 @@ class RicWellLogTools static bool hasRftData(); static bool hasRftDataForWell( const QString& wellName ); static bool isWellPathOrSimWellSelectedInView(); - static void addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack, const std::vector& wellLogFileChannels ); + static void addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack, const std::vector& wellLogFileChannels ); static RimWellPath* selectedWellPathWithLogFile(); static RimWellPath* findWellPathWithLogFileFromSelection(); static RimWellLogRftCurve* addRftCurve( RimWellLogTrack* plotTrack, const RimSimWellInView* simWell, bool showPlotWindow = true ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index 749f4d8f8a..d521a3bd70 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -24,7 +24,7 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" -#include "RimWellLogFileChannel.h" +#include "RimWellLogChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogLasFileCurve.h" #include "RimWellLogPlot.h" @@ -49,7 +49,7 @@ CAF_CMD_SOURCE_INIT( RicAddWellLogToPlotFeature, "RicAddWellLogToPlotFeature" ); //-------------------------------------------------------------------------------------------------- bool RicAddWellLogToPlotFeature::isCommandEnabled() const { - std::vector selection = selectedWellLogs(); + std::vector selection = selectedWellLogs(); return !selection.empty(); } @@ -58,7 +58,7 @@ bool RicAddWellLogToPlotFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicAddWellLogToPlotFeature::onActionTriggered( bool isChecked ) { - std::vector selection = selectedWellLogs(); + std::vector selection = selectedWellLogs(); if ( selection.empty() ) return; RimWellLogPlot* plot = RicNewWellLogPlotFeatureImpl::createWellLogPlot(); @@ -71,7 +71,7 @@ void RicAddWellLogToPlotFeature::onActionTriggered( bool isChecked ) for ( size_t wlIdx = 0; wlIdx < selection.size(); wlIdx++ ) { - RimWellLogFileChannel* wellLog = selection[wlIdx]; + RimWellLogChannel* wellLog = selection[wlIdx]; auto wellPath = wellLog->firstAncestorOrThisOfType(); auto wellLogFile = wellLog->firstAncestorOrThisOfType(); @@ -116,9 +116,9 @@ void RicAddWellLogToPlotFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicAddWellLogToPlotFeature::selectedWellLogs() +std::vector RicAddWellLogToPlotFeature::selectedWellLogs() { - std::vector selection; + std::vector selection; caf::SelectionManager::instance()->objectsByType( &selection ); return selection; } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.h index 9ae431c45f..6ff2e1abd4 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.h @@ -26,7 +26,7 @@ class RimMainPlotCollection; class RimWellLogPlotCollection; class RimWellLogPlot; -class RimWellLogFileChannel; +class RimWellLogChannel; //================================================================================================== /// @@ -41,5 +41,5 @@ class RicAddWellLogToPlotFeature : public caf::CmdFeature void setupActionLook( QAction* actionToSetup ) override; private: - static std::vector selectedWellLogs(); + static std::vector selectedWellLogs(); }; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index 25bb643b7c..3b9430c64f 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -35,8 +35,8 @@ #include "RimProject.h" #include "RimTools.h" #include "RimWellBoreStabilityPlot.h" +#include "RimWellLogChannel.h" #include "RimWellLogExtractionCurve.h" -#include "RimWellLogFileChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogLasFileCurve.h" #include "RimWellLogPlotCollection.h" diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp index 5097767a2d..e63b1150db 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp @@ -24,7 +24,7 @@ #include "RicWellLogTools.h" #include "RimTools.h" -#include "RimWellLogFileChannel.h" +#include "RimWellLogChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogLasFileCurve.h" #include "RimWellLogTrack.h" diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 33d7e93f06..179bfe7a14 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -37,8 +37,8 @@ #include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" +#include "RimWellLogChannel.h" #include "RimWellLogExtractionCurve.h" -#include "RimWellLogFileChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogLasFileCurve.h" #include "RimWellLogRftCurve.h" @@ -80,7 +80,7 @@ class StaticFieldsInitializer //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasPressureData( const RimWellLogFile* wellLogFile ) { - for ( RimWellLogFileChannel* const wellLogChannel : wellLogFile->wellLogChannels() ) + for ( RimWellLogChannel* const wellLogChannel : wellLogFile->wellLogChannels() ) { if ( isPressureChannel( wellLogChannel ) ) return true; } @@ -125,7 +125,7 @@ std::pair RimWellPlotTools::pressureResultData //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::isPressureChannel( RimWellLogFileChannel* channel ) +bool RimWellPlotTools::isPressureChannel( RimWellLogChannel* channel ) { for ( const auto& pressureDataName : PRESSURE_DATA_NAMES ) { @@ -146,7 +146,7 @@ bool RimWellPlotTools::hasPressureData( RimEclipseResultCase* gridCase ) //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasFlowData( const RimWellLogFile* wellLogFile ) { - for ( RimWellLogFileChannel* const wellLogChannel : wellLogFile->wellLogChannels() ) + for ( RimWellLogChannel* const wellLogChannel : wellLogFile->wellLogChannels() ) { if ( isFlowChannel( wellLogChannel ) ) return true; } @@ -182,7 +182,7 @@ bool RimWellPlotTools::hasAssociatedWellPath( const QString& wellName ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::isFlowChannel( RimWellLogFileChannel* channel ) +bool RimWellPlotTools::isFlowChannel( RimWellLogChannel* channel ) { return tryMatchChannelName( FLOW_DATA_NAMES, channel->name() ); } @@ -297,11 +297,11 @@ std::vector RimWellPlotTools::wellLogFilesContainingPressure( c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellLogFileChannel* RimWellPlotTools::getPressureChannelFromWellFile( const RimWellLogFile* wellLogFile ) +RimWellLogChannel* RimWellPlotTools::getPressureChannelFromWellFile( const RimWellLogFile* wellLogFile ) { if ( wellLogFile != nullptr ) { - for ( RimWellLogFileChannel* const channel : wellLogFile->wellLogChannels() ) + for ( RimWellLogChannel* const channel : wellLogFile->wellLogChannels() ) { if ( isPressureChannel( channel ) ) { diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h index 046cad5f8e..47bca4f5b6 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h @@ -36,7 +36,7 @@ class RimEclipseResultCase; class RimObservedFmuRftData; class RimSummaryCaseCollection; class RimWellLogCurve; -class RimWellLogFileChannel; +class RimWellLogChannel; class RimWellLogPlot; class RimWellPath; class RimPressureDepthData; @@ -87,7 +87,7 @@ class RimWellPlotTools static void addTimeStepsToMap( std::map>& destMap, const std::map>& timeStepsToAdd ); static std::vector wellLogFilesContainingPressure( const QString& wellPathNameOrSimWellName ); - static RimWellLogFileChannel* getPressureChannelFromWellFile( const RimWellLogFile* wellLogFile ); + static RimWellLogChannel* getPressureChannelFromWellFile( const RimWellLogFile* wellLogFile ); static RimWellPath* wellPathFromWellLogFile( const RimWellLogFile* wellLogFile ); static std::map> timeStepsMapFromGridCase( RimEclipseCase* gridCase ); static RiaRftPltCurveDefinition curveDefFromCurve( const RimWellLogCurve* curve ); @@ -147,11 +147,11 @@ class RimWellPlotTools static std::set FLOW_DATA_NAMES; static bool hasPressureData( const RimWellLogFile* wellLogFile ); - static bool isPressureChannel( RimWellLogFileChannel* channel ); + static bool isPressureChannel( RimWellLogChannel* channel ); static bool hasPressureData( RimEclipseResultCase* gridCase ); static bool hasPressureData( RimWellPath* wellPath ); static bool hasFlowData( RimEclipseResultCase* gridCase ); - static bool isFlowChannel( RimWellLogFileChannel* channel ); + static bool isFlowChannel( RimWellLogChannel* channel ); static bool tryMatchChannelName( const std::set& channelNames, const QString& channelNameToMatch ); static std::set findMatchingOrAdjacentTimeSteps( const std::set& baseTimeLine, const std::set& availableTimeSteps ); diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index 37ba161f5f..a3cdd2e9d2 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -47,9 +47,9 @@ #include "RimProject.h" #include "RimSummaryCurveAppearanceCalculator.h" #include "RimWellFlowRateCurve.h" +#include "RimWellLogChannel.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogFile.h" -#include "RimWellLogFileChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogLasFileCurve.h" #include "RimWellLogPlot.h" diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h index 14c3be4af4..5764394a9e 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h @@ -38,7 +38,7 @@ class RimEclipseCase; class RimEclipseResultCase; class RimWellLogCurve; -class RimWellLogFileChannel; +class RimWellLogChannel; class RimWellPath; class RiuWellPltPlot; class RimWellLogTrack; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 03f64193e9..7631f6c744 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -46,8 +46,8 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimTools.h" +#include "RimWellLogChannel.h" #include "RimWellLogExtractionCurve.h" -#include "RimWellLogFileChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogLasFileCurve.h" #include "RimWellLogPlot.h" @@ -687,8 +687,8 @@ void RimWellRftPlot::updateCurvesInPlot( const std::setaddCurve( curve ); curve->setWellPath( wellPath ); diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h index 6cbb040255..6fc08f2293 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h @@ -44,7 +44,7 @@ class RimEclipseCase; class RimEclipseResultCase; class RimRegularLegendConfig; class RimWellLogCurve; -class RimWellLogFileChannel; +class RimWellLogChannel; class RimWellPath; class RimWellPathCollection; class RiuWellRftPlot; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 8bc343eed3..9b7ac20320 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -154,8 +154,8 @@ #include "RimVirtualPerforationResults.h" #include "RimWellAllocationPlot.h" #include "RimWellIASettings.h" +#include "RimWellLogChannel.h" #include "RimWellLogCurve.h" -#include "RimWellLogFileChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" @@ -838,7 +838,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicShowSummaryCurveCalculatorFeature"; } } - else if ( dynamic_cast( firstUiItem ) ) + else if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicAddWellLogToPlotFeature"; } @@ -1240,7 +1240,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); } - if ( dynamic_cast( firstUiItem ) ) + if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicAddWellLogToPlotFeature"; } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake index f3030b156c..a09f017929 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake @@ -42,7 +42,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCsvFile.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileUtil.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileChannel.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimWellLogChannel.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogLasFileCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogRftCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogWbsCurve.cpp diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp index 8bbf4755e3..e8747eb43b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp @@ -40,9 +40,9 @@ #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" #include "RimTools.h" +#include "RimWellLogChannel.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogExtractionCurveNameConfig.h" -#include "RimWellLogFileChannel.h" #include "RimWellLogLasFile.h" #include "RimWellPath.h" diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp index 78673e7dd7..9adcedd4ad 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp @@ -20,7 +20,7 @@ #include "RigWellLogLasFile.h" -#include "RimWellLogFileChannel.h" +#include "RimWellLogChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogLasFileCurveNameConfig.h" #include "RimWellPath.h" @@ -72,7 +72,7 @@ void Rim3dWellLogFileCurve::setDefaultFileCurveDataInfo() if ( m_wellLogFile ) { - std::vector fileLogs = m_wellLogFile->wellLogChannels(); + std::vector fileLogs = m_wellLogFile->wellLogChannels(); if ( !fileLogs.empty() ) { @@ -204,7 +204,7 @@ QList Rim3dWellLogFileCurve::calculateValueOptions( cons { if ( m_wellLogFile ) { - std::vector fileLogs = m_wellLogFile->wellLogChannels(); + std::vector fileLogs = m_wellLogFile->wellLogChannels(); for ( size_t i = 0; i < fileLogs.size(); i++ ) { diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp index 38f891bd31..3bb967afa8 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp @@ -38,8 +38,8 @@ #include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" +#include "RimWellLogChannel.h" #include "RimWellLogCurve.h" -#include "RimWellLogFileChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogLasFileCurve.h" #include "RimWellLogPlot.h" @@ -567,7 +567,7 @@ QList RimEnsembleWellLogCurveSet::calculateValueOptions( std::set wellLogChannelNames; for ( auto wellLogFile : m_ensembleWellLogs->wellLogFiles() ) { - std::vector fileLogs = wellLogFile->wellLogChannels(); + std::vector fileLogs = wellLogFile->wellLogChannels(); for ( size_t i = 0; i < fileLogs.size(); i++ ) { QString wellLogChannelName = fileLogs[i]->name(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileChannel.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp similarity index 87% rename from ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileChannel.cpp rename to ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp index 6371138944..adf8be5b33 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileChannel.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp @@ -17,18 +17,18 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimWellLogFileChannel.h" +#include "RimWellLogChannel.h" #include "RiaFieldHandleTools.h" #include -CAF_PDM_SOURCE_INIT( RimWellLogFileChannel, "WellLogFileChannel" ); +CAF_PDM_SOURCE_INIT( RimWellLogChannel, "WellLogFileChannel" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellLogFileChannel::RimWellLogFileChannel() +RimWellLogChannel::RimWellLogChannel() { CAF_PDM_InitObject( "Well Log File Channel" ); @@ -39,7 +39,7 @@ RimWellLogFileChannel::RimWellLogFileChannel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogFileChannel::setName( const QString& name ) +void RimWellLogChannel::setName( const QString& name ) { m_name = name; } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileChannel.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.h similarity index 94% rename from ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileChannel.h rename to ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.h index f55875c96e..104a45d626 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileChannel.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.h @@ -28,12 +28,12 @@ class QString; /// /// //================================================================================================== -class RimWellLogFileChannel : public caf::PdmObject +class RimWellLogChannel : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimWellLogFileChannel(); + RimWellLogChannel(); void setName( const QString& name ); QString name() const { return m_name; } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp index cc71b7b498..3de9f37a4e 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp @@ -25,7 +25,7 @@ #include "RimFileWellPath.h" #include "RimTools.h" -#include "RimWellLogFileChannel.h" +#include "RimWellLogChannel.h" #include #include @@ -91,7 +91,7 @@ bool RimWellLogCsvFile::readFile( QString* errorMessage ) QStringList wellLogNames = m_wellLogDataFile->wellLogChannelNames(); for ( int logIdx = 0; logIdx < wellLogNames.size(); logIdx++ ) { - RimWellLogFileChannel* wellLog = new RimWellLogFileChannel(); + RimWellLogChannel* wellLog = new RimWellLogChannel(); wellLog->setName( wellLogNames[logIdx] ); m_wellLogChannelNames.push_back( wellLog ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp index 67d6bb34c5..a6e65d7221 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp @@ -51,9 +51,9 @@ #include "RimMainPlotCollection.h" #include "RimTools.h" #include "RimWellBoreStabilityPlot.h" +#include "RimWellLogChannel.h" #include "RimWellLogCurve.h" #include "RimWellLogCurveCommonDataSource.h" -#include "RimWellLogFileChannel.h" #include "RimWellLogFileUtil.h" #include "RimWellLogLasFile.h" #include "RimWellLogPlot.h" diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp index c863c37bce..198a2741d3 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp @@ -20,7 +20,7 @@ #include "RimFileWellPath.h" #include "RimTools.h" -#include "RimWellLogFileChannel.h" +#include "RimWellLogChannel.h" #include "RiaFieldHandleTools.h" #include "RiaQDateTimeTools.h" @@ -79,9 +79,9 @@ QString RimWellLogFile::fileName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellLogFile::wellLogChannels() const +std::vector RimWellLogFile::wellLogChannels() const { - std::vector channels; + std::vector channels; for ( const auto& channel : m_wellLogChannelNames ) { channels.push_back( channel ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h index 399cf23367..8dec8e083c 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h @@ -25,7 +25,7 @@ #include #include -class RimWellLogFileChannel; +class RimWellLogChannel; class RimWellPath; class RigWellLogFile; @@ -42,9 +42,9 @@ class RimWellLogFile : public caf::PdmObject RimWellLogFile(); ~RimWellLogFile() override; - virtual void setFileName( const QString& fileName ); - virtual QString fileName() const; - virtual std::vector wellLogChannels() const; + virtual void setFileName( const QString& fileName ); + virtual QString fileName() const; + virtual std::vector wellLogChannels() const; virtual QString wellName() const = 0; virtual QString name() const = 0; @@ -62,7 +62,7 @@ class RimWellLogFile : public caf::PdmObject void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - caf::PdmChildArrayField m_wellLogChannelNames; - caf::PdmField m_fileName; - caf::PdmField m_date; + caf::PdmChildArrayField m_wellLogChannelNames; + caf::PdmField m_fileName; + caf::PdmField m_date; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp index 45ccea42ee..72632f3223 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp @@ -30,7 +30,7 @@ #include "RimFileWellPath.h" #include "RimTools.h" -#include "RimWellLogFileChannel.h" +#include "RimWellLogChannel.h" #include "RimWellPathCollection.h" #include "RimWellPlotTools.h" @@ -155,7 +155,7 @@ bool RimWellLogLasFile::readFile( QString* errorMessage ) QStringList wellLogNames = m_wellLogDataFile->wellLogChannelNames(); for ( int logIdx = 0; logIdx < wellLogNames.size(); logIdx++ ) { - RimWellLogFileChannel* wellLog = new RimWellLogFileChannel(); + RimWellLogChannel* wellLog = new RimWellLogChannel(); wellLog->setName( wellLogNames[logIdx] ); m_wellLogChannelNames.push_back( wellLog ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h index cc34eb4499..64c746b3b0 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h @@ -29,7 +29,7 @@ #include -class RimWellLogFileChannel; +class RimWellLogChannel; class RimWellPath; class QString; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp index 4f857a210e..203543d3d0 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp @@ -30,7 +30,7 @@ #include "RimProject.h" #include "RimTools.h" -#include "RimWellLogFileChannel.h" +#include "RimWellLogChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" @@ -382,7 +382,7 @@ QList RimWellLogLasFileCurve::calculateValueOptions( con { if ( m_wellLogFile ) { - std::vector fileLogs = m_wellLogFile->wellLogChannels(); + std::vector fileLogs = m_wellLogFile->wellLogChannels(); for ( size_t i = 0; i < fileLogs.size(); i++ ) { diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.h index 12c8bca896..a1ab607ef2 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.h @@ -27,7 +27,7 @@ #include class RimWellPath; -class RimWellLogFileChannel; +class RimWellLogChannel; class RimWellLogFile; class RigWellLogIndexDepthOffset; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp index 19afdd1bcf..3a99298198 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp @@ -43,7 +43,7 @@ #include "RimStimPlanModelCollection.h" #include "RimTools.h" #include "RimWellIASettingsCollection.h" -#include "RimWellLogFileChannel.h" +#include "RimWellLogChannel.h" #include "RimWellLogLasFile.h" #include "RimWellLogPlotCollection.h" #include "RimWellPathAttributeCollection.h" @@ -588,8 +588,8 @@ RimWellLogFile* RimWellPath::firstWellLogFileMatchingChannelName( const QString& std::vector allWellLogFiles = wellLogFiles(); for ( RimWellLogFile* logFile : allWellLogFiles ) { - std::vector channels = logFile->wellLogChannels(); - for ( RimWellLogFileChannel* channel : channels ) + std::vector channels = logFile->wellLogChannels(); + for ( RimWellLogChannel* channel : channels ) { if ( channel->name() == channelName ) { diff --git a/ApplicationLibCode/UserInterface/RiuDragDrop.cpp b/ApplicationLibCode/UserInterface/RiuDragDrop.cpp index ead07b0190..81aea9b534 100644 --- a/ApplicationLibCode/UserInterface/RiuDragDrop.cpp +++ b/ApplicationLibCode/UserInterface/RiuDragDrop.cpp @@ -41,8 +41,8 @@ #include "RimSurface.h" #include "RimSurfaceCollection.h" #include "RimWellAllocationPlot.h" +#include "RimWellLogChannel.h" #include "RimWellLogCurve.h" -#include "RimWellLogFileChannel.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" @@ -216,7 +216,7 @@ Qt::DropActions RiuDragDrop::supportedDropActions() const { return Qt::CopyAction | Qt::MoveAction; } - else if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) + else if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) { return Qt::CopyAction; } @@ -247,7 +247,7 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const } if ( dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || - dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || + dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) ) { itemflags |= Qt::ItemIsDragEnabled; @@ -342,14 +342,14 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const { if ( dynamic_cast( uiItem ) ) { - if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) + if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) { itemflags |= Qt::ItemIsDropEnabled; } } else if ( dynamic_cast( uiItem ) ) { - if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) + if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) { itemflags |= Qt::ItemIsDropEnabled; } @@ -523,13 +523,12 @@ bool RiuDragDrop::handleWellLogPlotTrackDrop( Qt::DropAction action, RimWellLogTrack* trackTarget, int insertAtPosition ) { - std::vector wellLogFileChannels = - RiuTypedPdmObjects::typedObjectsFromGroup( draggedObjects ); - if ( !wellLogFileChannels.empty() ) + std::vector wellLogChannels = RiuTypedPdmObjects::typedObjectsFromGroup( draggedObjects ); + if ( !wellLogChannels.empty() ) { if ( action == Qt::CopyAction ) { - RicWellLogTools::addWellLogChannelsToPlotTrack( trackTarget, wellLogFileChannels ); + RicWellLogTools::addWellLogChannelsToPlotTrack( trackTarget, wellLogChannels ); return true; } } From 11128073f7acf52d93cb41de90bb2598f7cb8f28 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 27 May 2024 13:32:40 +0200 Subject: [PATCH 088/332] Refactor: Use NamedObject for WellLogChannel. --- .../WellLog/RimWellLogChannel.cpp | 13 +------------ .../ProjectDataModel/WellLog/RimWellLogChannel.h | 15 ++------------- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp index adf8be5b33..adf99714c9 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp @@ -21,8 +21,6 @@ #include "RiaFieldHandleTools.h" -#include - CAF_PDM_SOURCE_INIT( RimWellLogChannel, "WellLogFileChannel" ); //-------------------------------------------------------------------------------------------------- @@ -32,14 +30,5 @@ RimWellLogChannel::RimWellLogChannel() { CAF_PDM_InitObject( "Well Log File Channel" ); - CAF_PDM_InitFieldNoDefault( &m_name, "Name", "" ); - RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_name ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellLogChannel::setName( const QString& name ) -{ - m_name = name; + RiaFieldHandleTools::disableWriteAndSetFieldHidden( nameField() ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.h index 104a45d626..ee49b1b597 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.h @@ -19,27 +19,16 @@ #pragma once -#include "cafPdmField.h" -#include "cafPdmObject.h" - -class QString; +#include "RimNamedObject.h" //================================================================================================== /// /// //================================================================================================== -class RimWellLogChannel : public caf::PdmObject +class RimWellLogChannel : public RimNamedObject { CAF_PDM_HEADER_INIT; public: RimWellLogChannel(); - - void setName( const QString& name ); - QString name() const { return m_name; } - - caf::PdmFieldHandle* userDescriptionField() override { return &m_name; } - -private: - caf::PdmField m_name; }; From 6e1289507f3a571d12559bab4fe038a1333c3c10 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 27 May 2024 14:00:40 +0200 Subject: [PATCH 089/332] Refactor: Rename WellLogFile to WellLogData. --- .../ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp | 4 ++-- .../ProjectDataModel/WellLog/RimWellLogFile.h | 4 ++-- .../WellLog/RimWellLogLasFileCurve.cpp | 4 ++-- .../CMakeLists_filesNotToUnitTest.cmake | 4 ++-- .../ReservoirDataModel/RigWellLogCsvFile.cpp | 2 +- .../ReservoirDataModel/RigWellLogCsvFile.h | 4 ++-- .../{RigWellLogFile.cpp => RigWellLogData.cpp} | 10 +++++----- .../{RigWellLogFile.h => RigWellLogData.h} | 6 +++--- .../ReservoirDataModel/RigWellLogLasFile.cpp | 2 +- .../ReservoirDataModel/RigWellLogLasFile.h | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-) rename ApplicationLibCode/ReservoirDataModel/{RigWellLogFile.cpp => RigWellLogData.cpp} (92%) rename ApplicationLibCode/ReservoirDataModel/{RigWellLogFile.h => RigWellLogData.h} (95%) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp index 9adcedd4ad..0f8b2164bc 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp @@ -91,7 +91,7 @@ void Rim3dWellLogFileCurve::curveValuesAndMds( std::vector* values, std: if ( m_wellLogFile ) { - RigWellLogFile* wellLogFile = m_wellLogFile->wellLogFileData(); + RigWellLogData* wellLogFile = m_wellLogFile->wellLogFileData(); if ( wellLogFile ) { *values = wellLogFile->values( m_wellLogChannelName ); @@ -137,7 +137,7 @@ QString Rim3dWellLogFileCurve::createAutoName() const channelNameAvailable = true; } - RigWellLogFile* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogFileData() : nullptr; + RigWellLogData* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogFileData() : nullptr; if ( wellLogFile ) { diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h index 8dec8e083c..3a5f21f946 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h @@ -28,7 +28,7 @@ class RimWellLogChannel; class RimWellPath; -class RigWellLogFile; +class RigWellLogData; //================================================================================================== /// @@ -49,7 +49,7 @@ class RimWellLogFile : public caf::PdmObject virtual QString wellName() const = 0; virtual QString name() const = 0; virtual bool readFile( QString* errorMessage ) = 0; - virtual RigWellLogFile* wellLogFileData() = 0; + virtual RigWellLogData* wellLogFileData() = 0; virtual QDateTime date() const; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp index 203543d3d0..b96569b292 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp @@ -85,7 +85,7 @@ void RimWellLogLasFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) if ( m_wellPath && m_wellLogFile ) { - RigWellLogFile* wellLogFile = m_wellLogFile->wellLogFileData(); + RigWellLogData* wellLogFile = m_wellLogFile->wellLogFileData(); if ( wellLogFile ) { std::vector values = wellLogFile->values( m_wellLogChannelName ); @@ -457,7 +457,7 @@ QString RimWellLogLasFileCurve::createCurveAutoName() channelNameAvailable = true; } - RigWellLogFile* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogFileData() : nullptr; + RigWellLogData* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogFileData() : nullptr; if ( wellLogFile ) { diff --git a/ApplicationLibCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake b/ApplicationLibCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake index a004e95cd4..8863056320 100644 --- a/ApplicationLibCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake +++ b/ApplicationLibCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake @@ -4,7 +4,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseCellMapperTools.h ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseRangeFilterMapper.h ${CMAKE_CURRENT_LIST_DIR}/RigSimulationWellCenterLineCalculator.h - ${CMAKE_CURRENT_LIST_DIR}/RigWellLogFile.h + ${CMAKE_CURRENT_LIST_DIR}/RigWellLogData.h ${CMAKE_CURRENT_LIST_DIR}/RigWellLogLasFile.h ${CMAKE_CURRENT_LIST_DIR}/RigWellLogCsvFile.h ${CMAKE_CURRENT_LIST_DIR}/RigReservoirGridTools.h @@ -16,7 +16,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseCellMapperTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseRangeFilterMapper.cpp ${CMAKE_CURRENT_LIST_DIR}/RigSimulationWellCenterLineCalculator.cpp - ${CMAKE_CURRENT_LIST_DIR}/RigWellLogFile.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigWellLogData.cpp ${CMAKE_CURRENT_LIST_DIR}/RigWellLogLasFile.cpp ${CMAKE_CURRENT_LIST_DIR}/RigWellLogCsvFile.cpp ${CMAKE_CURRENT_LIST_DIR}/RigReservoirGridTools.cpp diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp index f6f0283304..d8eba720b3 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp @@ -40,7 +40,7 @@ /// //-------------------------------------------------------------------------------------------------- RigWellLogCsvFile::RigWellLogCsvFile() - : RigWellLogFile() + : RigWellLogData() { } diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h index aa25027fb8..21fda23aa4 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h @@ -18,7 +18,7 @@ #pragma once -#include "RigWellLogFile.h" +#include "RigWellLogData.h" #include "RiaDefines.h" @@ -32,7 +32,7 @@ class RigWellPath; //================================================================================================== /// //================================================================================================== -class RigWellLogCsvFile : public RigWellLogFile +class RigWellLogCsvFile : public RigWellLogData { public: RigWellLogCsvFile(); diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogFile.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellLogData.cpp similarity index 92% rename from ApplicationLibCode/ReservoirDataModel/RigWellLogFile.cpp rename to ApplicationLibCode/ReservoirDataModel/RigWellLogData.cpp index 50f720d8ae..b0fd6e0c31 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogFile.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogData.cpp @@ -17,12 +17,12 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RigWellLogFile.h" +#include "RigWellLogData.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigWellLogFile::RigWellLogFile() +RigWellLogData::RigWellLogData() : cvf::Object() { } @@ -30,14 +30,14 @@ RigWellLogFile::RigWellLogFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigWellLogFile::~RigWellLogFile() +RigWellLogData::~RigWellLogData() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaDefines::DepthUnitType RigWellLogFile::depthUnit() const +RiaDefines::DepthUnitType RigWellLogData::depthUnit() const { RiaDefines::DepthUnitType unitType = RiaDefines::DepthUnitType::UNIT_METER; @@ -52,7 +52,7 @@ RiaDefines::DepthUnitType RigWellLogFile::depthUnit() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RigWellLogFile::convertedWellLogChannelUnitString( const QString& wellLogChannelName, RiaDefines::DepthUnitType displayDepthUnit ) const +QString RigWellLogData::convertedWellLogChannelUnitString( const QString& wellLogChannelName, RiaDefines::DepthUnitType displayDepthUnit ) const { QString unit = wellLogChannelUnitString( wellLogChannelName ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogFile.h b/ApplicationLibCode/ReservoirDataModel/RigWellLogData.h similarity index 95% rename from ApplicationLibCode/ReservoirDataModel/RigWellLogFile.h rename to ApplicationLibCode/ReservoirDataModel/RigWellLogData.h index ed91a3f5f5..edbc80a2f9 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogFile.h +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogData.h @@ -31,11 +31,11 @@ class RimWellLogCurve; //================================================================================================== /// //================================================================================================== -class RigWellLogFile : public cvf::Object +class RigWellLogData : public cvf::Object { public: - RigWellLogFile(); - ~RigWellLogFile() override; + RigWellLogData(); + ~RigWellLogData() override; virtual QStringList wellLogChannelNames() const = 0; diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogLasFile.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellLogLasFile.cpp index 661ea3110f..454d8c67d1 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogLasFile.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogLasFile.cpp @@ -38,7 +38,7 @@ /// //-------------------------------------------------------------------------------------------------- RigWellLogLasFile::RigWellLogLasFile() - : RigWellLogFile() + : RigWellLogData() { m_wellLogFile = nullptr; } diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogLasFile.h b/ApplicationLibCode/ReservoirDataModel/RigWellLogLasFile.h index 1be8f381ff..9d0d363437 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogLasFile.h +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogLasFile.h @@ -19,7 +19,7 @@ #pragma once -#include "RigWellLogFile.h" +#include "RigWellLogData.h" #include "RiaDefines.h" @@ -36,7 +36,7 @@ class RimWellLogCurve; //================================================================================================== /// //================================================================================================== -class RigWellLogLasFile : public RigWellLogFile +class RigWellLogLasFile : public RigWellLogData { public: RigWellLogLasFile(); From 74ba0c8b8c0c2711c33cb46888ccf75e6cc75ec1 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 27 May 2024 14:48:28 +0200 Subject: [PATCH 090/332] Refactor: Rename method name. --- .../RicCreateDepthAdjustedLasFilesImpl.cpp | 2 +- .../WellLogCommands/RicAddWellLogToPlotFeature.cpp | 2 +- .../FileInterface/RifDataSourceForRftPlt.cpp | 4 ++-- .../ProjectDataModel/Flow/RimWellPltPlot.cpp | 12 ++++++------ .../WellLog/Rim3dWellLogFileCurve.cpp | 4 ++-- .../WellLog/RimEnsembleWellLogCurveSet.cpp | 4 ++-- .../WellLog/RimEnsembleWellLogStatistics.cpp | 6 +++--- .../ProjectDataModel/WellLog/RimWellLogCsvFile.cpp | 4 ++-- .../ProjectDataModel/WellLog/RimWellLogCsvFile.h | 2 +- .../ProjectDataModel/WellLog/RimWellLogFile.h | 2 +- .../ProjectDataModel/WellLog/RimWellLogLasFile.cpp | 2 +- .../ProjectDataModel/WellLog/RimWellLogLasFile.h | 2 +- .../WellLog/RimWellLogLasFileCurve.cpp | 8 ++++---- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesImpl.cpp b/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesImpl.cpp index 5850acc945..dd9be2acf7 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesImpl.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesImpl.cpp @@ -123,7 +123,7 @@ void RicCreateDepthAdjustedLasFilesImpl::createDestinationWellsLasFiles( RimCase { if ( !selectedCase || !sourceWell || !soureWellLogFile || destinationWells.empty() ) return; - auto* sourceWellLogData = soureWellLogFile->wellLogFileData(); + auto* sourceWellLogData = soureWellLogFile->wellLogData(); const auto defaultPropertyMap = createDefaultPropertyMap( selectedResultProperties, sourceWellLogData ); // NOTE: map createIndexKDepthDataMapFromCase is created using well extractor, while sourceWellLogData depth diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index d521a3bd70..58715e86de 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -83,7 +83,7 @@ void RicAddWellLogToPlotFeature::onActionTriggered( bool isChecked ) plotTrack->addCurve( curve ); - RigWellLogLasFile* wellLogDataFile = wellLogFile->wellLogFileData(); + RigWellLogLasFile* wellLogDataFile = wellLogFile->wellLogData(); CVF_ASSERT( wellLogDataFile ); if ( wlIdx == 0 ) diff --git a/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp b/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp index 2a3e8451f9..6b26aa729b 100644 --- a/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp +++ b/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp @@ -146,9 +146,9 @@ std::vector RifDataSourceForRftPlt::availableUnit systems.push_back( m_eclCase->eclipseCaseData()->unitsType() ); } - if ( m_wellLogFile && m_wellLogFile->wellLogFileData() ) + if ( m_wellLogFile && m_wellLogFile->wellLogData() ) { - auto eclipseUnit = RiaDefines::fromDepthUnit( m_wellLogFile->wellLogFileData()->depthUnit() ); + auto eclipseUnit = RiaDefines::fromDepthUnit( m_wellLogFile->wellLogData()->depthUnit() ); systems.push_back( eclipseUnit ); } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index a3cdd2e9d2..e7588ff0db 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -590,7 +590,7 @@ void RimWellPltPlot::syncCurvesFromUiSelection() } else if ( sourceDef.sourceType() == RifDataSourceForRftPlt::SourceType::OBSERVED_LAS_FILE ) { - if ( sourceDef.wellLogFile() && sourceDef.wellLogFile()->wellLogFileData() ) + if ( sourceDef.wellLogFile() && sourceDef.wellLogFile()->wellLogData() ) { RimWellLogLasFile::WellFlowCondition flowCondition = sourceDef.wellLogFile()->wellFlowRateCondition(); @@ -599,9 +599,9 @@ void RimWellPltPlot::syncCurvesFromUiSelection() { using ChannelValNameIdxTuple = std::tuple; - RigWellLogLasFile* wellLogFileData = sourceDef.wellLogFile()->wellLogFileData(); + RigWellLogLasFile* wellLogData = sourceDef.wellLogFile()->wellLogData(); - QStringList channelNames = wellLogFileData->wellLogChannelNames(); + QStringList channelNames = wellLogData->wellLogChannelNames(); std::multiset sortedChannels; std::vector> channelData; @@ -610,16 +610,16 @@ void RimWellPltPlot::syncCurvesFromUiSelection() for ( int chIdx = 0; chIdx < channelNames.size(); ++chIdx ) { QString channelName = channelNames[chIdx]; - channelData[chIdx] = wellLogFileData->values( channelName ); + channelData[chIdx] = wellLogData->values( channelName ); if ( !channelData[chIdx].empty() ) { sortedChannels.insert( ChannelValNameIdxTuple( -fabs( channelData[chIdx].front() ), channelName, chIdx ) ); } } - std::vector depthValues = wellLogFileData->depthValues(); + std::vector depthValues = wellLogData->depthValues(); - RiaDefines::EclipseUnitSystem unitSystem = RiaDefines::fromDepthUnit( wellLogFileData->depthUnit() ); + RiaDefines::EclipseUnitSystem unitSystem = RiaDefines::fromDepthUnit( wellLogData->depthUnit() ); for ( const ChannelValNameIdxTuple& channelInfo : sortedChannels ) { diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp index 0f8b2164bc..804b7b497f 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp @@ -91,7 +91,7 @@ void Rim3dWellLogFileCurve::curveValuesAndMds( std::vector* values, std: if ( m_wellLogFile ) { - RigWellLogData* wellLogFile = m_wellLogFile->wellLogFileData(); + RigWellLogData* wellLogFile = m_wellLogFile->wellLogData(); if ( wellLogFile ) { *values = wellLogFile->values( m_wellLogChannelName ); @@ -137,7 +137,7 @@ QString Rim3dWellLogFileCurve::createAutoName() const channelNameAvailable = true; } - RigWellLogData* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogFileData() : nullptr; + RigWellLogData* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogData() : nullptr; if ( wellLogFile ) { diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp index 3bb967afa8..75bbffd6b2 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp @@ -774,7 +774,7 @@ void RimEnsembleWellLogCurveSet::updateEnsembleCurves( const std::vectorreadFile( &errorMessage ) ) { - RigWellLogLasFile* wellLogDataFile = wellLogFile->wellLogFileData(); + RigWellLogLasFile* wellLogDataFile = wellLogFile->wellLogData(); CVF_ASSERT( wellLogDataFile ); if ( isFirst ) @@ -1264,7 +1264,7 @@ bool RimEnsembleWellLogCurveSet::hasPropertyInFile( const QString& property ) co QString errorMessage; if ( !wellLogFile->readFile( &errorMessage ) ) return false; - RigWellLogLasFile* wellLogDataFile = wellLogFile->wellLogFileData(); + RigWellLogLasFile* wellLogDataFile = wellLogFile->wellLogData(); CVF_ASSERT( wellLogDataFile ); std::vector values = wellLogDataFile->values( RiaResultNames::indexKResultName() ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatistics.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatistics.cpp index 337816398f..34a98a2a5f 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatistics.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatistics.cpp @@ -95,7 +95,7 @@ void RimEnsembleWellLogStatistics::calculate( const std::vectorreadFile( &errorMessage ) ) { - RigWellLogLasFile* fileData = wellLogFile->wellLogFileData(); + RigWellLogLasFile* fileData = wellLogFile->wellLogData(); RiaDefines::DepthUnitType depthUnitInFile = fileData->depthUnit(); if ( m_depthUnit != RiaDefines::DepthUnitType::UNIT_NONE && m_depthUnit != depthUnitInFile ) { @@ -197,7 +197,7 @@ void RimEnsembleWellLogStatistics::calculateByKLayer( const std::vectorreadFile( &errorMessage ) ) { - RigWellLogLasFile* fileData = wellLogFile->wellLogFileData(); + RigWellLogLasFile* fileData = wellLogFile->wellLogData(); std::vector kIndexValues = fileData->values( RiaResultNames::indexKResultName() ); std::vector values = fileData->values( wellLogChannelName ); @@ -300,7 +300,7 @@ std::shared_ptr QString errorMessage; if ( wellLogFile->readFile( &errorMessage ) ) { - RigWellLogLasFile* fileData = wellLogFile->wellLogFileData(); + RigWellLogLasFile* fileData = wellLogFile->wellLogData(); std::vector depths = fileData->depthValues(); std::vector tvdDepths = fileData->tvdMslValues(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp index 3de9f37a4e..d6324d3a5a 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp @@ -117,7 +117,7 @@ std::vector> RimWellLogCsvFile::findMdAndChannelValues std::vector wellLogFiles = wellPath.descendantsIncludingThisOfType(); for ( RimWellLogCsvFile* wellLogFile : wellLogFiles ) { - RigWellLogCsvFile* fileData = wellLogFile->wellLogFileData(); + RigWellLogCsvFile* fileData = wellLogFile->wellLogData(); if ( fileData ) { std::vector channelValues = fileData->values( channelName ); @@ -144,7 +144,7 @@ std::vector> RimWellLogCsvFile::findMdAndChannelValues //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigWellLogCsvFile* RimWellLogCsvFile::wellLogFileData() +RigWellLogCsvFile* RimWellLogCsvFile::wellLogData() { return m_wellLogDataFile.p(); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.h index c67a0b4058..f93a66ce0b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.h @@ -49,7 +49,7 @@ class RimWellLogCsvFile : public RimWellLogFile QString wellName() const override; - RigWellLogCsvFile* wellLogFileData() override; + RigWellLogCsvFile* wellLogData() override; std::vector> findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString = nullptr ) override; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h index 3a5f21f946..44b7b57127 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h @@ -49,7 +49,7 @@ class RimWellLogFile : public caf::PdmObject virtual QString wellName() const = 0; virtual QString name() const = 0; virtual bool readFile( QString* errorMessage ) = 0; - virtual RigWellLogData* wellLogFileData() = 0; + virtual RigWellLogData* wellLogData() = 0; virtual QDateTime date() const; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp index 72632f3223..6704c26082 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp @@ -198,7 +198,7 @@ std::vector> RimWellLogLasFile::findMdAndChannelValues std::vector wellLogFiles = wellPath.descendantsIncludingThisOfType(); for ( RimWellLogLasFile* wellLogFile : wellLogFiles ) { - RigWellLogLasFile* fileData = wellLogFile->wellLogFileData(); + RigWellLogLasFile* fileData = wellLogFile->wellLogData(); std::vector channelValues = fileData->values( channelName ); if ( !channelValues.empty() ) { diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h index 64c746b3b0..d6702b32ff 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h @@ -54,7 +54,7 @@ class RimWellLogLasFile : public RimWellLogFile QString wellName() const override; - RigWellLogLasFile* wellLogFileData() override { return m_wellLogDataFile.p(); } + RigWellLogLasFile* wellLogData() override { return m_wellLogDataFile.p(); } bool hasFlowData() const; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp index b96569b292..4723c8d768 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp @@ -85,7 +85,7 @@ void RimWellLogLasFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) if ( m_wellPath && m_wellLogFile ) { - RigWellLogData* wellLogFile = m_wellLogFile->wellLogFileData(); + RigWellLogData* wellLogFile = m_wellLogFile->wellLogData(); if ( wellLogFile ) { std::vector values = wellLogFile->values( m_wellLogChannelName ); @@ -457,7 +457,7 @@ QString RimWellLogLasFileCurve::createCurveAutoName() channelNameAvailable = true; } - RigWellLogData* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogFileData() : nullptr; + RigWellLogData* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogData() : nullptr; if ( wellLogFile ) { @@ -498,9 +498,9 @@ QString RimWellLogLasFileCurve::wellLogChannelUiName() const //-------------------------------------------------------------------------------------------------- QString RimWellLogLasFileCurve::wellLogChannelUnits() const { - if ( m_wellLogFile && m_wellLogFile->wellLogFileData() ) + if ( m_wellLogFile && m_wellLogFile->wellLogData() ) { - return m_wellLogFile->wellLogFileData()->wellLogChannelUnitString( m_wellLogChannelName ); + return m_wellLogFile->wellLogData()->wellLogChannelUnitString( m_wellLogChannelName ); } return RiaWellLogUnitTools::noUnitString(); } From 6144c1f3a68489787d7aa336c49d1575d661a699 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 27 May 2024 15:31:01 +0200 Subject: [PATCH 091/332] Add Well Log root object. --- .../WellLog/CMakeLists_files.cmake | 2 + .../ProjectDataModel/WellLog/RimWellLog.cpp | 88 +++++++++++++++++++ .../ProjectDataModel/WellLog/RimWellLog.h | 63 +++++++++++++ .../WellLog/RimWellLogFile.cpp | 53 +---------- .../ProjectDataModel/WellLog/RimWellLogFile.h | 29 ++---- 5 files changed, 162 insertions(+), 73 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake index a09f017929..803132e0ec 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake @@ -20,6 +20,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogLasFile.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCsvFile.h + ${CMAKE_CURRENT_LIST_DIR}/RimWellLog.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileUtil.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogChannel.h @@ -40,6 +41,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogLasFile.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCsvFile.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimWellLog.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileUtil.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogChannel.cpp diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp new file mode 100644 index 0000000000..8340a6371a --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp @@ -0,0 +1,88 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimWellLog.h" + +#include "RimFileWellPath.h" +#include "RimTools.h" +#include "RimWellLogChannel.h" + +#include "RiaFieldHandleTools.h" +#include "RiaQDateTimeTools.h" + +#include "cafPdmUiDateEditor.h" + +#include + +CAF_PDM_ABSTRACT_SOURCE_INIT( RimWellLog, "WellLog" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QDateTime RimWellLog::DEFAULT_DATE_TIME = RiaQDateTimeTools::createUtcDateTime( QDate( 1900, 1, 1 ) ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLog::RimWellLog() +{ + CAF_PDM_InitObject( "Well File Info", ":/LasFile16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_date, "Date", "Date" ); + + CAF_PDM_InitFieldNoDefault( &m_wellLogChannelNames, "WellLogFileChannels", "" ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_wellLogChannelNames ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellLog::wellLogChannels() const +{ + return m_wellLogChannelNames.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QDateTime RimWellLog::date() const +{ + return m_date; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLog::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + if ( changedField == &m_date ) + { + // Due to a possible bug in QDateEdit/PdmUiDateEditor, convert m_date to a QDateTime having UTC timespec + m_date = RiaQDateTimeTools::createUtcDateTime( m_date().date(), m_date().time() ); + } +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLog::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( caf::PdmUiDateEditorAttribute* attrib = dynamic_cast( attribute ) ) + { + attrib->dateFormat = RiaQDateTimeTools::dateFormatString(); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h new file mode 100644 index 0000000000..0a899326a6 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include +#include + +class RimWellLogChannel; +class RimWellPath; + +class RigWellLogData; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLog : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellLog(); + + virtual std::vector wellLogChannels() const; + + virtual QString wellName() const = 0; + virtual QString name() const = 0; + virtual RigWellLogData* wellLogData() = 0; + + virtual QDateTime date() const; + + virtual std::vector> + findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString = nullptr ) = 0; + + const static QDateTime DEFAULT_DATE_TIME; + +protected: + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + + caf::PdmChildArrayField m_wellLogChannelNames; + caf::PdmField m_date; +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp index 198a2741d3..6c0435711d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp @@ -18,24 +18,10 @@ #include "RimWellLogFile.h" -#include "RimFileWellPath.h" -#include "RimTools.h" -#include "RimWellLogChannel.h" - -#include "RiaFieldHandleTools.h" -#include "RiaQDateTimeTools.h" - -#include "cafPdmUiDateEditor.h" - #include CAF_PDM_ABSTRACT_SOURCE_INIT( RimWellLogFile, "WellLogFileInterface" ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const QDateTime RimWellLogFile::DEFAULT_DATE_TIME = RiaQDateTimeTools::createUtcDateTime( QDate( 1900, 1, 1 ) ); - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -45,11 +31,6 @@ RimWellLogFile::RimWellLogFile() CAF_PDM_InitFieldNoDefault( &m_fileName, "FileName", "Filename" ); m_fileName.uiCapability()->setUiReadOnly( true ); - - CAF_PDM_InitFieldNoDefault( &m_date, "Date", "Date" ); - - CAF_PDM_InitFieldNoDefault( &m_wellLogChannelNames, "WellLogFileChannels", "" ); - RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_wellLogChannelNames ); } //-------------------------------------------------------------------------------------------------- @@ -57,7 +38,6 @@ RimWellLogFile::RimWellLogFile() //-------------------------------------------------------------------------------------------------- RimWellLogFile::~RimWellLogFile() { - m_wellLogChannelNames.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -76,45 +56,18 @@ QString RimWellLogFile::fileName() const return m_fileName().path(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimWellLogFile::wellLogChannels() const -{ - std::vector channels; - for ( const auto& channel : m_wellLogChannelNames ) - { - channels.push_back( channel ); - } - return channels; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QDateTime RimWellLogFile::date() const -{ - return m_date; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellLogFile::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { - if ( changedField == &m_date ) - { - // Due to a possible bug in QDateEdit/PdmUiDateEditor, convert m_date to a QDateTime having UTC timespec - m_date = RiaQDateTimeTools::createUtcDateTime( m_date().date(), m_date().time() ); - } + RimWellLog::fieldChangedByUi( changedField, oldValue, newValue ); } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellLogFile::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { - if ( caf::PdmUiDateEditorAttribute* attrib = dynamic_cast( attribute ) ) - { - attrib->dateFormat = RiaQDateTimeTools::dateFormatString(); - } + RimWellLog::defineEditorAttribute( field, uiConfigName, attribute ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h index 44b7b57127..7cb19f1a06 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h @@ -22,19 +22,15 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -#include #include -class RimWellLogChannel; -class RimWellPath; - -class RigWellLogData; +#include "RimWellLog.h" //================================================================================================== /// /// //================================================================================================== -class RimWellLogFile : public caf::PdmObject +class RimWellLogFile : public RimWellLog { CAF_PDM_HEADER_INIT; @@ -42,27 +38,14 @@ class RimWellLogFile : public caf::PdmObject RimWellLogFile(); ~RimWellLogFile() override; - virtual void setFileName( const QString& fileName ); - virtual QString fileName() const; - virtual std::vector wellLogChannels() const; - - virtual QString wellName() const = 0; - virtual QString name() const = 0; - virtual bool readFile( QString* errorMessage ) = 0; - virtual RigWellLogData* wellLogData() = 0; - - virtual QDateTime date() const; - - virtual std::vector> - findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString = nullptr ) = 0; + virtual void setFileName( const QString& fileName ); + virtual QString fileName() const; - const static QDateTime DEFAULT_DATE_TIME; + virtual bool readFile( QString* errorMessage ) = 0; protected: void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - caf::PdmChildArrayField m_wellLogChannelNames; - caf::PdmField m_fileName; - caf::PdmField m_date; + caf::PdmField m_fileName; }; From c79f7939b4e62a08c503267d475ef4ee7d7d5999 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 27 May 2024 15:46:21 +0200 Subject: [PATCH 092/332] Refactor: move method implementation to cpp file. --- .../WellLog/RimWellLogLasFile.cpp | 32 +++++++++++++++++++ .../WellLog/RimWellLogLasFile.h | 8 ++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp index 6704c26082..2bd2d8adbe 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp @@ -256,3 +256,35 @@ bool RimWellLogLasFile::isDateValid( const QDateTime dateTime ) { return dateTime.isValid() && dateTime != DEFAULT_DATE_TIME; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimWellLogLasFile::userDescriptionField() +{ + return &m_name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimWellLogLasFile::name() const +{ + return m_name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellLogLasFile* RimWellLogLasFile::wellLogData() +{ + return m_wellLogDataFile.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogLasFile::WellFlowCondition RimWellLogLasFile::wellFlowRateCondition() const +{ + return m_wellFlowCondition(); +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h index d6702b32ff..1c679033e5 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h @@ -48,13 +48,13 @@ class RimWellLogLasFile : public RimWellLogFile static RimWellLogLasFile* readWellLogFile( const QString& logFilePath, QString* errorMessage ); - QString name() const override { return m_name; } + QString name() const override; bool readFile( QString* errorMessage ) override; QString wellName() const override; - RigWellLogLasFile* wellLogData() override { return m_wellLogDataFile.p(); } + RigWellLogLasFile* wellLogData() override; bool hasFlowData() const; @@ -64,7 +64,7 @@ class RimWellLogLasFile : public RimWellLogFile WELL_FLOW_COND_STANDARD }; - RimWellLogLasFile::WellFlowCondition wellFlowRateCondition() const { return m_wellFlowCondition(); } + RimWellLogLasFile::WellFlowCondition wellFlowRateCondition() const; std::vector> findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString = nullptr ) override; @@ -73,7 +73,7 @@ class RimWellLogLasFile : public RimWellLogFile void setupBeforeSave() override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - caf::PdmFieldHandle* userDescriptionField() override { return &m_name; } + caf::PdmFieldHandle* userDescriptionField() override; static bool isDateValid( const QDateTime dateTime ); From d1d3ee129f13e01e761389e06e7b371279facaf5 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 27 May 2024 19:13:54 +0200 Subject: [PATCH 093/332] Refactor: Extract parser options from RicPasteAsciiDataToSummaryPlotFeatureUi --- .../RicPasteAsciiDataToSummaryPlotFeature.cpp | 2 +- ...icPasteAsciiDataToSummaryPlotFeatureUi.cpp | 4 +- .../RicPasteAsciiDataToSummaryPlotFeatureUi.h | 44 ++----------- .../FileInterface/CMakeLists_files.cmake | 1 + .../FileInterface/RifAsciiDataParseOptions.h | 65 +++++++++++++++++++ .../FileInterface/RifCsvUserData.cpp | 2 +- .../FileInterface/RifCsvUserData.h | 5 +- .../FileInterface/RifCsvUserDataParser.cpp | 15 ++--- .../FileInterface/RifCsvUserDataParser.h | 14 ++-- .../FileInterface/RifOsduWellPathReader.cpp | 4 +- .../FileInterface/RifPolygonReader.cpp | 4 +- .../FileInterface/RifReaderObservedData.cpp | 4 +- .../RifRevealCsvSectionSummaryReader.cpp | 4 +- .../RifStimPlanCsvSummaryReader.cpp | 4 +- .../Summary/RimCsvUserData.cpp | 2 + .../ProjectDataModel/Summary/RimCsvUserData.h | 3 +- .../ReservoirDataModel/RigWellLogCsvFile.cpp | 4 +- .../UnitTests/ObservedDataParser-Test.cpp | 16 +++-- 18 files changed, 114 insertions(+), 83 deletions(-) create mode 100644 ApplicationLibCode/FileInterface/RifAsciiDataParseOptions.h diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp index c9d2b4d12b..d00f21b663 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp @@ -153,7 +153,7 @@ std::vector RicPasteAsciiDataToSummaryPlotFeature::parseCurv const RicPasteAsciiDataToSummaryPlotFeatureUi& settings ) { std::vector curves; - const AsciiDataParseOptions& parseOptions = settings.parseOptions(); + const RifAsciiDataParseOptions& parseOptions = settings.parseOptions(); RifCsvUserDataPastedTextParser parser = RifCsvUserDataPastedTextParser( data ); if ( !parser.parse( parseOptions ) ) diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp index 066b77f7a7..e5a52f187d 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp @@ -233,9 +233,9 @@ RicPasteAsciiDataToSummaryPlotFeatureUi::UiMode RicPasteAsciiDataToSummaryPlotFe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const AsciiDataParseOptions RicPasteAsciiDataToSummaryPlotFeatureUi::parseOptions() const +const RifAsciiDataParseOptions RicPasteAsciiDataToSummaryPlotFeatureUi::parseOptions() const { - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.assumeNumericDataColumns = true; parseOptions.plotTitle = m_plotTitle(); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h index 2f6543135e..761465dafd 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h @@ -20,6 +20,7 @@ #include "RimPlotCurve.h" +#include "RifAsciiDataParseOptions.h" #include "RifCsvUserDataParser.h" #include "RifEclipseSummaryAddressDefines.h" @@ -32,43 +33,6 @@ #include -//================================================================================================== -/// -//================================================================================================== -class AsciiDataParseOptions -{ -public: - AsciiDataParseOptions() - : useCustomDateTimeFormat( false ) - , assumeNumericDataColumns( false ) - , curveSymbolSkipDistance( 0.0f ) - , defaultCategory( RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_INVALID ) - { - } - - QString plotTitle; - QString curvePrefix; - QString decimalSeparator; - QLocale locale; - - bool useCustomDateTimeFormat; - QString dateFormat; - QString timeFormat; - QString fallbackDateTimeFormat; - QString dateTimeFormat; - QString cellSeparator; - QString timeSeriesColumnName; - - QDateTime startDateTime; - bool assumeNumericDataColumns; - - RifEclipseSummaryAddressDefines::SummaryCategory defaultCategory; - - RiuQwtPlotCurveDefines::LineStyleEnum curveLineStyle; - RiuPlotCurveSymbol::PointSymbolEnum curveSymbol; - float curveSymbolSkipDistance; -}; - //================================================================================================== /// //================================================================================================== @@ -132,9 +96,9 @@ class RicPasteAsciiDataToSummaryPlotFeatureUi : public caf::PdmObject void setUiModeImport( const QString& fileName ); void setUiModePasteText( const QString& text ); - UiMode uiModeImport() const; - const AsciiDataParseOptions parseOptions() const; - void setCreateNewPlot(); + UiMode uiModeImport() const; + const RifAsciiDataParseOptions parseOptions() const; + void setCreateNewPlot(); QString contextString() const; diff --git a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake index f44a0e80f4..01a2390406 100644 --- a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake @@ -97,6 +97,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationExporter.h ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader.h ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellPathReader.h + ${CMAKE_CURRENT_LIST_DIR}/RifAsciiDataParseOptions.h ) set(SOURCE_GROUP_SOURCE_FILES diff --git a/ApplicationLibCode/FileInterface/RifAsciiDataParseOptions.h b/ApplicationLibCode/FileInterface/RifAsciiDataParseOptions.h new file mode 100644 index 0000000000..824be3c394 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifAsciiDataParseOptions.h @@ -0,0 +1,65 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RiuPlotCurveSymbol.h" +#include "RiuQwtPlotCurveDefines.h" + +#include "RifEclipseSummaryAddressDefines.h" + +#include +#include +#include + +//================================================================================================== +/// +//================================================================================================== +class RifAsciiDataParseOptions +{ +public: + RifAsciiDataParseOptions() + : useCustomDateTimeFormat( false ) + , assumeNumericDataColumns( false ) + , curveSymbolSkipDistance( 0.0f ) + , defaultCategory( RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_INVALID ) + { + } + + QString plotTitle; + QString curvePrefix; + QString decimalSeparator; + QLocale locale; + + bool useCustomDateTimeFormat; + QString dateFormat; + QString timeFormat; + QString fallbackDateTimeFormat; + QString dateTimeFormat; + QString cellSeparator; + QString timeSeriesColumnName; + + QDateTime startDateTime; + bool assumeNumericDataColumns; + + RifEclipseSummaryAddressDefines::SummaryCategory defaultCategory; + + RiuQwtPlotCurveDefines::LineStyleEnum curveLineStyle; + RiuPlotCurveSymbol::PointSymbolEnum curveSymbol; + float curveSymbolSkipDistance; +}; diff --git a/ApplicationLibCode/FileInterface/RifCsvUserData.cpp b/ApplicationLibCode/FileInterface/RifCsvUserData.cpp index aaff80fefb..3559a23682 100644 --- a/ApplicationLibCode/FileInterface/RifCsvUserData.cpp +++ b/ApplicationLibCode/FileInterface/RifCsvUserData.cpp @@ -49,7 +49,7 @@ RifCsvUserData::~RifCsvUserData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifCsvUserData::parse( const QString& fileName, const AsciiDataParseOptions& parseOptions, QString* errorText ) +bool RifCsvUserData::parse( const QString& fileName, const RifAsciiDataParseOptions& parseOptions, QString* errorText ) { m_allResultAddresses.clear(); m_mapFromAddressToResultIndex.clear(); diff --git a/ApplicationLibCode/FileInterface/RifCsvUserData.h b/ApplicationLibCode/FileInterface/RifCsvUserData.h index 3ed9afab53..46ff448cd2 100644 --- a/ApplicationLibCode/FileInterface/RifCsvUserData.h +++ b/ApplicationLibCode/FileInterface/RifCsvUserData.h @@ -20,8 +20,6 @@ #include "RifSummaryReaderInterface.h" -#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" - #include #include #include @@ -30,6 +28,7 @@ class QString; class RifCsvUserDataParser; class RifEclipseSummaryAddress; +class RifAsciiDataParseOptions; class TableData; //================================================================================================== @@ -42,7 +41,7 @@ class RifCsvUserData : public RifSummaryReaderInterface RifCsvUserData(); ~RifCsvUserData() override; - bool parse( const QString& fileName, const AsciiDataParseOptions& parseOptions, QString* errorText = nullptr ); + bool parse( const QString& fileName, const RifAsciiDataParseOptions& parseOptions, QString* errorText = nullptr ); std::vector timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override; diff --git a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp index 0480a0306e..dcea1a840d 100644 --- a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp +++ b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp @@ -18,6 +18,7 @@ #include "RifCsvUserDataParser.h" +#include "RifAsciiDataParseOptions.h" #include "RifEclipseSummaryAddress.h" #include "RifEclipseUserDataKeywordTools.h" #include "RifEclipseUserDataParserTools.h" @@ -29,8 +30,6 @@ #include "RiaStdStringTools.h" #include "RiaTextStringTools.h" -#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" - #include "caf.h" #include "cvfAssert.h" @@ -85,7 +84,7 @@ RifCsvUserDataParser::~RifCsvUserDataParser() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifCsvUserDataParser::parse( const AsciiDataParseOptions& parseOptions, +bool RifCsvUserDataParser::parse( const RifAsciiDataParseOptions& parseOptions, const std::map& nameMapping, const std::map>& unitMapping ) { @@ -152,7 +151,7 @@ std::vector RifCsvUserDataParser::parseLineBasedHeader( QStringList headerC //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifCsvUserDataParser::parseColumnInfo( const AsciiDataParseOptions& parseOptions ) +bool RifCsvUserDataParser::parseColumnInfo( const RifAsciiDataParseOptions& parseOptions ) { QTextStream* dataStream = openDataStream(); std::vector columnInfoList; @@ -169,7 +168,7 @@ bool RifCsvUserDataParser::parseColumnInfo( const AsciiDataParseOptions& parseOp //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RifCsvUserDataParser::previewText( int lineCount, const AsciiDataParseOptions& parseOptions ) +QString RifCsvUserDataParser::previewText( int lineCount, const RifAsciiDataParseOptions& parseOptions ) { QTextStream* stream = openDataStream(); @@ -230,7 +229,7 @@ QString RifCsvUserDataParser::previewText( int lineCount, const AsciiDataParseOp //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RifCsvUserDataParser::timeColumnPreviewData( int lineCount, const AsciiDataParseOptions& parseOptions ) +QStringList RifCsvUserDataParser::timeColumnPreviewData( int lineCount, const RifAsciiDataParseOptions& parseOptions ) { QStringList timeStrings; @@ -307,7 +306,7 @@ RifCsvUserDataParser::CsvLayout RifCsvUserDataParser::determineCsvLayout() /// //-------------------------------------------------------------------------------------------------- bool RifCsvUserDataParser::parseColumnInfo( QTextStream* dataStream, - const AsciiDataParseOptions& parseOptions, + const RifAsciiDataParseOptions& parseOptions, std::vector* columnInfoList, const std::map& nameMapping, const std::map>& unitMapping ) @@ -465,7 +464,7 @@ bool RifCsvUserDataParser::parseColumnInfo( QTextStream* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifCsvUserDataParser::parseColumnBasedData( const AsciiDataParseOptions& parseOptions, +bool RifCsvUserDataParser::parseColumnBasedData( const RifAsciiDataParseOptions& parseOptions, const std::map& nameMapping, const std::map>& unitMapping ) { diff --git a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.h b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.h index ad72314141..f59da377b9 100644 --- a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.h +++ b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.h @@ -31,7 +31,7 @@ #include class Column; -class AsciiDataParseOptions; +class RifAsciiDataParseOptions; //================================================================================================== /// @@ -49,7 +49,7 @@ class RifCsvUserDataParser RifCsvUserDataParser( QString* errorText = nullptr ); virtual ~RifCsvUserDataParser(); - bool parse( const AsciiDataParseOptions& parseOptions, + bool parse( const RifAsciiDataParseOptions& parseOptions, const std::map& nameMapping = {}, const std::map>& unitMapping = {} ); const TableData& tableData() const; @@ -57,9 +57,9 @@ class RifCsvUserDataParser const Column* columnInfo( size_t columnIndex ) const; const Column* dateTimeColumn() const; - bool parseColumnInfo( const AsciiDataParseOptions& parseOptions ); - QString previewText( int lineCount, const AsciiDataParseOptions& parseOptions ); - QStringList timeColumnPreviewData( int lineCount, const AsciiDataParseOptions& parseOptions ); + bool parseColumnInfo( const RifAsciiDataParseOptions& parseOptions ); + QString previewText( int lineCount, const RifAsciiDataParseOptions& parseOptions ); + QStringList timeColumnPreviewData( int lineCount, const RifAsciiDataParseOptions& parseOptions ); CsvLayout determineCsvLayout(); @@ -76,11 +76,11 @@ class RifCsvUserDataParser std::vector parseLineBasedHeader( QStringList headerCols ); bool parseColumnInfo( QTextStream* dataStream, - const AsciiDataParseOptions& parseOptions, + const RifAsciiDataParseOptions& parseOptions, std::vector* columnInfoList, const std::map& nameMapping = {}, const std::map>& unitMapping = {} ); - bool parseColumnBasedData( const AsciiDataParseOptions& parseOptions, + bool parseColumnBasedData( const RifAsciiDataParseOptions& parseOptions, const std::map& nameMapping = {}, const std::map>& unitMapping = {} ); bool parseLineBasedData(); diff --git a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp index 2ac47bb23d..74fcc7b53b 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp +++ b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp @@ -20,7 +20,7 @@ #include "RiaTextStringTools.h" -#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" +#include "RifAsciiDataParseOptions.h" #include "RifCsvUserDataParser.h" @@ -37,7 +37,7 @@ std::pair, QString> RifOsduWellPathReader::parseCsv( const QString errorMessage; RifCsvUserDataPastedTextParser parser( content, &errorMessage ); - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.cellSeparator = ","; parseOptions.decimalSeparator = "."; diff --git a/ApplicationLibCode/FileInterface/RifPolygonReader.cpp b/ApplicationLibCode/FileInterface/RifPolygonReader.cpp index 2bfbd34e3c..5b1a652e5d 100644 --- a/ApplicationLibCode/FileInterface/RifPolygonReader.cpp +++ b/ApplicationLibCode/FileInterface/RifPolygonReader.cpp @@ -20,7 +20,7 @@ #include "RiaTextStringTools.h" -#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" +#include "RifAsciiDataParseOptions.h" #include "RifCsvUserDataParser.h" @@ -133,7 +133,7 @@ std::vector>> RifPolygonReader::parseText { RifCsvUserDataPastedTextParser parser( content, errorMessage ); - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.cellSeparator = ","; parseOptions.decimalSeparator = "."; diff --git a/ApplicationLibCode/FileInterface/RifReaderObservedData.cpp b/ApplicationLibCode/FileInterface/RifReaderObservedData.cpp index e069cb19e9..1c87784566 100644 --- a/ApplicationLibCode/FileInterface/RifReaderObservedData.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderObservedData.cpp @@ -23,7 +23,7 @@ #include "RifCsvUserDataParser.h" #include "RifEclipseSummaryAddress.h" -#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" +#include "RifAsciiDataParseOptions.h" #include #include @@ -49,7 +49,7 @@ bool RifReaderObservedData::open( const QString& const QString& identifierName, RifEclipseSummaryAddressDefines::SummaryCategory summaryCategory ) { - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.dateFormat = "yyyy-MM-dd"; parseOptions.cellSeparator = "\t"; parseOptions.locale = caf::norwegianLocale(); diff --git a/ApplicationLibCode/FileInterface/RifRevealCsvSectionSummaryReader.cpp b/ApplicationLibCode/FileInterface/RifRevealCsvSectionSummaryReader.cpp index 6c3393d59f..aead5bff80 100644 --- a/ApplicationLibCode/FileInterface/RifRevealCsvSectionSummaryReader.cpp +++ b/ApplicationLibCode/FileInterface/RifRevealCsvSectionSummaryReader.cpp @@ -27,7 +27,7 @@ #include "RifEclipseUserDataKeywordTools.h" #include "RifEclipseUserDataParserTools.h" -#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" +#include "RifAsciiDataParseOptions.h" #include "cafUtils.h" @@ -59,7 +59,7 @@ bool RifRevealCsvSectionSummaryReader::parse( const QString& m_allResultAddresses.clear(); m_mapFromAddressToResultIndex.clear(); - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.useCustomDateTimeFormat = true; parseOptions.dateTimeFormat = "dd.MM.yyyy hh:mm:ss"; parseOptions.fallbackDateTimeFormat = "dd.MM.yyyy"; diff --git a/ApplicationLibCode/FileInterface/RifStimPlanCsvSummaryReader.cpp b/ApplicationLibCode/FileInterface/RifStimPlanCsvSummaryReader.cpp index ea898bb4f6..c16989036f 100644 --- a/ApplicationLibCode/FileInterface/RifStimPlanCsvSummaryReader.cpp +++ b/ApplicationLibCode/FileInterface/RifStimPlanCsvSummaryReader.cpp @@ -26,7 +26,7 @@ #include "RifEclipseUserDataKeywordTools.h" #include "RifEclipseUserDataParserTools.h" -#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" +#include "RifAsciiDataParseOptions.h" #include "cafUtils.h" @@ -68,7 +68,7 @@ std::pair RifStimPlanCsvSummaryReader::parse( const QString& file // Split files on strange header line (starts with ",Date"). QString fileContents = in.readAll(); - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.useCustomDateTimeFormat = true; parseOptions.dateTimeFormat = "m.zzz"; parseOptions.cellSeparator = ","; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.cpp index 4d5eb1a447..354d9cfacc 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.cpp @@ -27,6 +27,8 @@ #include "RifSummaryReaderInterface.h" #include "RifSummaryReaderMultipleFiles.h" +#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" + #include "RimCalculatedSummaryCurveReader.h" #include "RimProject.h" #include "RimSummaryCalculationCollection.h" diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.h b/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.h index b94e34e698..1255b91ab5 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.h @@ -20,8 +20,6 @@ #include "RimObservedSummaryData.h" -#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" - #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -30,6 +28,7 @@ class RifSummaryReaderInterface; class RifCalculatedSummaryCurveReader; class RifMultipleSummaryReaders; +class RicPasteAsciiDataToSummaryPlotFeatureUi; //================================================================================================== // diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp index d8eba720b3..ed8efd6aee 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp @@ -23,7 +23,7 @@ #include "RigWellLogCurveData.h" #include "RigWellPathGeometryTools.h" -#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" +#include "RifAsciiDataParseOptions.h" #include "RiaLogging.h" #include "RiaStringEncodingTools.h" @@ -63,7 +63,7 @@ bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QS RifCsvUserDataFileParser parser( fileName, errorMessage ); - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.useCustomDateTimeFormat = true; parseOptions.dateTimeFormat = "dd.MM.yyyy hh:mm:ss"; parseOptions.fallbackDateTimeFormat = "dd.MM.yyyy"; diff --git a/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp b/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp index f5afa8a9d3..a9ade93783 100644 --- a/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp +++ b/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp @@ -1,6 +1,8 @@ #include "gtest/gtest.h" #include "RiaQDateTimeTools.h" + +#include "RifAsciiDataParseOptions.h" #include "RifColumnBasedUserData.h" #include "RifColumnBasedUserDataParser.h" #include "RifCsvUserDataParser.h" @@ -21,7 +23,7 @@ //-------------------------------------------------------------------------------------------------- TEST( RifColumnBasedAsciiParserTest, TestDateFormatYyyymmddWithDash ) { - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.dateFormat = "yyyy-MM-dd"; parseOptions.cellSeparator = "\t"; parseOptions.locale = caf::norwegianLocale(); @@ -78,7 +80,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDateFormatYyyymmddWithDash ) //-------------------------------------------------------------------------------------------------- TEST( RifColumnBasedAsciiParserTest, TestDateFormatYymmddWithDot ) { - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.dateFormat = "yy.MM.dd"; parseOptions.cellSeparator = "\t"; parseOptions.locale = caf::norwegianLocale(); @@ -133,7 +135,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDateFormatYymmddWithDot ) //-------------------------------------------------------------------------------------------------- TEST( RifColumnBasedAsciiParserTest, TestDateFormatDdmmyyWithDot ) { - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.dateFormat = "dd.MM.yy"; parseOptions.cellSeparator = "\t"; parseOptions.locale = caf::norwegianLocale(); @@ -187,7 +189,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDateFormatDdmmyyWithDot ) //-------------------------------------------------------------------------------------------------- TEST( RifColumnBasedAsciiParserTest, TestDecimalLocaleNorwegian ) { - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.dateFormat = "yy.MM.dd"; parseOptions.cellSeparator = "\t"; parseOptions.decimalSeparator = ","; @@ -255,7 +257,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDecimalLocaleNorwegian ) //-------------------------------------------------------------------------------------------------- TEST( RifColumnBasedAsciiParserTest, TestDecimalLocaleC ) { - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.dateFormat = "yy.MM.dd"; parseOptions.cellSeparator = "\t"; parseOptions.locale = QLocale::c(); @@ -339,7 +341,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDecimalLocaleC ) //-------------------------------------------------------------------------------------------------- TEST( RifColumnBasedAsciiParserTest, TestCellSeparatorComma ) { - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.dateFormat = "yy.MM.dd"; parseOptions.cellSeparator = ","; parseOptions.locale = QLocale::c(); @@ -406,7 +408,7 @@ TEST( RifColumnBasedAsciiParserTest, TestCellSeparatorComma ) //-------------------------------------------------------------------------------------------------- TEST( RifColumnBasedAsciiParserTest, ThreeLinesHeader ) { - AsciiDataParseOptions parseOptions; + RifAsciiDataParseOptions parseOptions; parseOptions.dateFormat = "dd.MM.yyyy"; parseOptions.cellSeparator = ";"; parseOptions.locale = QLocale::c(); From c7fbb5374c0d8ea7742b3e6e7485e421fd129001 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 28 May 2024 11:22:57 +0200 Subject: [PATCH 094/332] #11437 Propagate detected date format to line based parsing Add try/catch to avoid crash Remove flag to avoid eternal loop --- .../Commands/RicImportObservedDataFeature.cpp | 48 +++++------ .../FileInterface/RifCsvUserDataParser.cpp | 86 ++++++++++--------- .../FileInterface/RifCsvUserDataParser.h | 2 +- 3 files changed, 68 insertions(+), 68 deletions(-) diff --git a/ApplicationLibCode/Commands/RicImportObservedDataFeature.cpp b/ApplicationLibCode/Commands/RicImportObservedDataFeature.cpp index d770ca5bc5..4118607d6f 100644 --- a/ApplicationLibCode/Commands/RicImportObservedDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportObservedDataFeature.cpp @@ -60,36 +60,28 @@ void RicImportObservedDataFeature::selectObservedDataFileInDialog() for ( const QString& fileName : fileNames ) { - bool retryImport = false; + QString errorText; - do + if ( fileName.endsWith( ".rsm", Qt::CaseInsensitive ) ) { - QString errorText; - - if ( fileName.endsWith( ".rsm", Qt::CaseInsensitive ) ) - { - observedData = observedDataCollection->createAndAddRsmObservedSummaryDataFromFile( fileName, &errorText ); - retryImport = false; - } - else if ( fileName.endsWith( ".txt", Qt::CaseInsensitive ) || fileName.endsWith( ".csv", Qt::CaseInsensitive ) ) - { - bool useSavedFieldValuesInDialog = retryImport; - observedData = - observedDataCollection->createAndAddCvsObservedSummaryDataFromFile( fileName, useSavedFieldValuesInDialog, &errorText ); - retryImport = !errorText.isEmpty(); - } - else - { - errorText = "Not able to import file. Make sure '*.rsm' is used as extension if data is in RMS format " - "or '*.txt' or '*.csv' if data is in CSV format."; - retryImport = false; - } - - if ( !errorText.isEmpty() ) - { - RiaLogging::errorInMessageBox( nullptr, "Errors detected during import", errorText ); - } - } while ( retryImport ); + observedData = observedDataCollection->createAndAddRsmObservedSummaryDataFromFile( fileName, &errorText ); + } + else if ( fileName.endsWith( ".txt", Qt::CaseInsensitive ) || fileName.endsWith( ".csv", Qt::CaseInsensitive ) ) + { + bool useSavedFieldValuesInDialog = false; + observedData = + observedDataCollection->createAndAddCvsObservedSummaryDataFromFile( fileName, useSavedFieldValuesInDialog, &errorText ); + } + else + { + errorText = "Not able to import file. Make sure '*.rsm' is used as extension if data is in RMS format " + "or '*.txt' or '*.csv' if data is in CSV format."; + } + + if ( !errorText.isEmpty() ) + { + RiaLogging::errorInMessageBox( nullptr, "Errors detected during import", errorText ); + } } RiuPlotMainWindowTools::showPlotMainWindow(); diff --git a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp index dcea1a840d..14277573fe 100644 --- a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp +++ b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp @@ -88,7 +88,7 @@ bool RifCsvUserDataParser::parse( const RifAsciiDataParseOptions& const std::map& nameMapping, const std::map>& unitMapping ) { - if ( determineCsvLayout() == LineBased ) return parseLineBasedData(); + if ( determineCsvLayout() == LineBased ) return parseLineBasedData( parseOptions ); return parseColumnBasedData( parseOptions, nameMapping, unitMapping ); } @@ -617,7 +617,7 @@ bool RifCsvUserDataParser::parseColumnBasedData( const RifAsciiDataParseOptions& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifCsvUserDataParser::parseLineBasedData() +bool RifCsvUserDataParser::parseLineBasedData( const RifAsciiDataParseOptions& parseOptions ) { QTextStream* dataStream = openDataStream(); if ( !dataStream ) @@ -682,54 +682,62 @@ bool RifCsvUserDataParser::parseLineBasedData() } } - // DATE - QDateTime dateTime; + try { - auto dateText = dataItems[colIndexes[(size_t)CsvLineBasedColumnType::DATE]].toStdString(); - - dateTime = tryParseDateTime( dateText, ISO_DATE_FORMAT ); - if ( !dateTime.isValid() ) + // DATE + QDateTime dateTime; { - // Try to match date and time - dateTime = tryParseDateTime( dateText, QString( ISO_DATE_FORMAT ) + " " + TIME_FORMAT ); + auto dateText = dataItems[colIndexes[(size_t)CsvLineBasedColumnType::DATE]].toStdString(); + + const auto formats = { parseOptions.dateFormat, QString( ISO_DATE_FORMAT ), QString( ISO_DATE_FORMAT ) + " " + TIME_FORMAT }; + for ( const auto& format : formats ) + { + dateTime = tryParseDateTime( dateText, format ); + if ( dateTime.isValid() ) break; + } + + if ( !dateTime.isValid() ) + { + if ( m_errorText ) + m_errorText->append( + QString( "CSV import: Failed to parse date time value in line %1" ).arg( QString::number( lineCount ) ) ); + throw 0; + } } - if ( !dateTime.isValid() ) + // VALUE { - if ( m_errorText ) - m_errorText->append( - QString( "CSV import: Failed to parse date time value in line %1" ).arg( QString::number( lineCount ) ) ); - throw 0; - } - } + bool parseOk = true; + double value = QLocale::c().toDouble( dataItems[colIndexes[(size_t)CsvLineBasedColumnType::VALUE]], &parseOk ); - // VALUE - { - bool parseOk = true; - double value = QLocale::c().toDouble( dataItems[colIndexes[(size_t)CsvLineBasedColumnType::VALUE]], &parseOk ); + if ( !parseOk ) + { + if ( m_errorText ) + m_errorText->append( + QString( "CSV import: Failed to parse numeric value in line %1\n" ).arg( QString::number( lineCount ) ) ); + throw 0; + } - if ( !parseOk ) - { - if ( m_errorText ) - m_errorText->append( - QString( "CSV import: Failed to parse numeric value in line %1\n" ).arg( QString::number( lineCount ) ) ); - throw 0; + auto& samples = addressesAndData[addr]; + samples.push_back( std::make_pair( dateTime.toSecsSinceEpoch(), value ) ); } - auto& samples = addressesAndData[addr]; - samples.push_back( std::make_pair( dateTime.toSecsSinceEpoch(), value ) ); - } - - // ERROR VALUE - if ( expectErrorValue ) - { - bool parseOk = true; - double value = QLocale::c().toDouble( dataItems[colIndexes[(size_t)CsvLineBasedColumnType::ERROR_VALUE]], &parseOk ); + // ERROR VALUE + if ( expectErrorValue ) + { + bool parseOk = true; + double value = QLocale::c().toDouble( dataItems[colIndexes[(size_t)CsvLineBasedColumnType::ERROR_VALUE]], &parseOk ); - if ( !parseOk ) value = DOUBLE_INF; + if ( !parseOk ) value = DOUBLE_INF; - auto& samples = addressesAndData[errAddr]; - samples.push_back( std::make_pair( dateTime.toSecsSinceEpoch(), value ) ); + auto& samples = addressesAndData[errAddr]; + samples.push_back( std::make_pair( dateTime.toSecsSinceEpoch(), value ) ); + } + } + catch ( ... ) + { + closeDataStream(); + return false; } } } diff --git a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.h b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.h index f59da377b9..fdbdb84013 100644 --- a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.h +++ b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.h @@ -83,7 +83,7 @@ class RifCsvUserDataParser bool parseColumnBasedData( const RifAsciiDataParseOptions& parseOptions, const std::map& nameMapping = {}, const std::map>& unitMapping = {} ); - bool parseLineBasedData(); + bool parseLineBasedData( const RifAsciiDataParseOptions& parseOptions ); static QDateTime tryParseDateTime( const std::string& colData, const QString& format ); private: From 2fb54ac1ecbfa721b745b96677a613514d85b6c9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 29 May 2024 08:18:42 +0200 Subject: [PATCH 095/332] Add qtnetworkauth to clang-tidy workflow --- .github/workflows/clang-tidy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index c9b0a35b59..f417dc72ba 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -46,10 +46,10 @@ jobs: uses: jurplel/install-qt-action@v3 with: version: 5.12.12 - modules: qtscript dir: "${{ github.workspace }}/Qt/" cache: true - + modules: "qtnetworkauth" + - name: Run vcpkg uses: lukka/run-vcpkg@v7 id: runvcpkg From 1d57b9032b81ab7f10d85b3654243d6e945a021e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 29 May 2024 12:55:45 +0200 Subject: [PATCH 096/332] Custom vfp plot (#11450) * AppFwk: When clearing a tree selection, make sure all values are cleared * Fix deprecated implicit lambda * Add support for using the closest value in addition to exact match * Add table data source object and add plot with multiple data sources Delete the temporary RimVfpDeck class Add RimVfpTable to represent a table in a data source Add plot able to show data from multiple tables * AppFwk: Make it possible to call resolveReferences multiple times Use case: Vfp tables are stored in files. Multiple tables can be present in one file. Pdm table objects are created after resolve references is done as part of parsing file. When the Pdm object are created, resolveReferences can be called once more. * Call resolveReferencesRecursively() after RimVfpTable objects are created --- .../Application/RiaApplication.cpp | 7 + .../Application/RiaFileDownloader.cpp | 2 +- .../Commands/CMakeLists_files.cmake | 2 + .../Commands/RicDeleteSubItemsFeature.cpp | 150 +-- .../Commands/RicImportVfpDataFeature.cpp | 4 - .../Commands/RicNewCustomVfpPlotFeature.cpp | 66 ++ .../Commands/RicNewCustomVfpPlotFeature.h | 33 + .../Commands/RicNewVfpPlotFeature.cpp | 22 +- .../Commands/RicNewVfpPlotFeature.h | 5 + .../CMakeLists_files.cmake | 6 +- .../RimCustomVfpPlot.cpp | 1013 +++++++++++++++++ .../RimCustomVfpPlot.h | 172 +++ .../RimVfpDataCollection.cpp | 46 +- .../RimVfpDataCollection.h | 10 +- .../VerticalFlowPerformance/RimVfpDeck.cpp | 155 --- .../VerticalFlowPerformance/RimVfpDefines.cpp | 16 + .../VerticalFlowPerformance/RimVfpDefines.h | 13 + .../VerticalFlowPerformance/RimVfpPlot.cpp | 55 +- .../VerticalFlowPerformance/RimVfpPlot.h | 14 +- .../RimVfpPlotCollection.cpp | 69 +- .../RimVfpPlotCollection.h | 13 +- .../VerticalFlowPerformance/RimVfpTable.cpp | 146 +++ .../{RimVfpDeck.h => RimVfpTable.h} | 33 +- .../RimVfpTableData.cpp | 27 + .../VerticalFlowPerformance/RimVfpTableData.h | 6 +- .../ReservoirDataModel/RigVfpTables.cpp | 291 +++++ .../ReservoirDataModel/RigVfpTables.h | 40 + ApplicationLibCode/UnitTests/CMakeLists.txt | 1 + .../UnitTests/RigVfpTables-Test.cpp | 83 ++ .../cafPdmCore/cafPdmPtrField.h | 6 +- .../cafPdmCore/cafPdmPtrField.inl | 1 - .../cafInternalPdmXmlFieldCapability.h | 4 - .../cafInternalPdmXmlFieldCapability.inl | 8 +- .../cafPdmAdvancedTemplateTest.cpp | 4 + .../cafPdmUiTreeSelectionEditor.cpp | 15 +- .../cafPdmUiTreeSelectionEditor.h | 4 +- .../cafPdmUiTreeSelectionQModel.cpp | 8 + .../cafPdmUiTreeSelectionQModel.h | 1 + 38 files changed, 2191 insertions(+), 360 deletions(-) create mode 100644 ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.cpp create mode 100644 ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.h create mode 100644 ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h delete mode 100644 ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTable.cpp rename ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/{RimVfpDeck.h => RimVfpTable.h} (58%) create mode 100644 ApplicationLibCode/UnitTests/RigVfpTables-Test.cpp diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 8e68e20e7b..b0fcc129a9 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -92,6 +92,8 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPathFracture.h" +#include "VerticalFlowPerformance/RimVfpDataCollection.h" +#include "VerticalFlowPerformance/RimVfpPlotCollection.h" #include "Riu3DMainWindowTools.h" #include "RiuGuiTheme.h" @@ -539,6 +541,7 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct // Initialize well paths oilField->wellPathCollection->loadDataAndUpdate(); oilField->ensembleWellLogsCollection->loadDataAndUpdate(); + oilField->vfpDataCollection->loadDataAndUpdate(); // Initialize seismic data auto& seisDataColl = oilField->seismicDataCollection(); @@ -553,6 +556,10 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct { RimMainPlotCollection* mainPlotColl = RimMainPlotCollection::current(); mainPlotColl->ensureDefaultFlowPlotsAreCreated(); + + // RimVfpTable are not presisted in the project file, and are created in vfpDataCollection->loadDataAndUpdate(). Existing VFP + // plots will have references to RimVfpTables. Call resolveReferencesRecursively() to update the references to RimVfpTable objects. + mainPlotColl->vfpPlotCollection()->resolveReferencesRecursively(); } for ( RimOilField* oilField : m_project->oilFields ) diff --git a/ApplicationLibCode/Application/RiaFileDownloader.cpp b/ApplicationLibCode/Application/RiaFileDownloader.cpp index 8fbcd5b30a..ed67eda849 100644 --- a/ApplicationLibCode/Application/RiaFileDownloader.cpp +++ b/ApplicationLibCode/Application/RiaFileDownloader.cpp @@ -25,7 +25,7 @@ void RiaFileDownloader::downloadFile( const QUrl& url, const QString& filePath ) connect( reply, &QNetworkReply::finished, - [=]() + [=, this]() { if ( reply->error() ) { diff --git a/ApplicationLibCode/Commands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/CMakeLists_files.cmake index 9404013634..e6baeea686 100644 --- a/ApplicationLibCode/Commands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/CMakeLists_files.cmake @@ -96,6 +96,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicImportWellLogCsvFileFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewViewForGridEnsembleFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewCustomVfpPlotFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -195,6 +196,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicImportWellLogCsvFileFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewViewForGridEnsembleFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewCustomVfpPlotFeature.cpp ) if(RESINSIGHT_USE_QT_CHARTS) diff --git a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp index aa3dca2c0d..85ee5c69f3 100644 --- a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp @@ -26,6 +26,8 @@ #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" +#include "VerticalFlowPerformance/RimVfpDataCollection.h" + #include "cafPdmUiItem.h" #include "cafPdmUiObjectHandle.h" #include "cafSelectionManager.h" @@ -124,6 +126,11 @@ bool RicDeleteSubItemsFeature::hasDeletableSubItems( caf::PdmUiItem* uiItem ) } } + if ( dynamic_cast( uiItem ) ) + { + return true; + } + return false; } @@ -141,112 +148,107 @@ void RicDeleteSubItemsFeature::deleteSubItems( bool onlyDeleteUnchecked ) { if ( !RicDeleteSubItemsFeature::hasDeletableSubItems( item ) ) continue; + if ( auto multiPlot = dynamic_cast( item ) ) { - auto multiPlot = dynamic_cast( item ); - if ( multiPlot ) + if ( onlyDeleteUnchecked ) { - if ( onlyDeleteUnchecked ) - { - auto plots = multiPlot->plots(); - for ( auto plot : plots ) - { - if ( plot->showWindow() ) continue; - multiPlot->removePlotNoUpdate( plot ); - delete plot; - } - } - else + auto plots = multiPlot->plots(); + for ( auto plot : plots ) { - multiPlot->deleteAllPlots(); + if ( plot->showWindow() ) continue; + multiPlot->removePlotNoUpdate( plot ); + delete plot; } - - multiPlot->updateConnectedEditors(); } + else + { + multiPlot->deleteAllPlots(); + } + + multiPlot->updateConnectedEditors(); } + if ( auto collection = dynamic_cast( item ) ) { - auto collection = dynamic_cast( item ); - if ( collection ) + if ( onlyDeleteUnchecked ) { - if ( onlyDeleteUnchecked ) + auto plots = collection->multiPlots(); + for ( auto plot : plots ) { - auto plots = collection->multiPlots(); - for ( auto plot : plots ) - { - if ( plot->showWindow() ) continue; - collection->removePlotNoUpdate( plot ); - delete plot; - } + if ( plot->showWindow() ) continue; + collection->removePlotNoUpdate( plot ); + delete plot; } - else - { - collection->deleteAllPlots(); - } - - collection->updateConnectedEditors(); } + else + { + collection->deleteAllPlots(); + } + + collection->updateConnectedEditors(); } + if ( auto collection = dynamic_cast( item ) ) { - auto collection = dynamic_cast( item ); - if ( collection ) + if ( onlyDeleteUnchecked ) { - if ( onlyDeleteUnchecked ) - { - auto paths = collection->allWellPaths(); - for ( auto path : paths ) - { - if ( path->showWellPath() ) continue; - collection->removeWellPath( path ); - delete path; - } - } - else + auto paths = collection->allWellPaths(); + for ( auto path : paths ) { - collection->deleteAllWellPaths(); + if ( path->showWellPath() ) continue; + collection->removeWellPath( path ); + delete path; } - - collection->updateConnectedEditors(); - collection->scheduleRedrawAffectedViews(); } + else + { + collection->deleteAllWellPaths(); + } + + collection->updateConnectedEditors(); + collection->scheduleRedrawAffectedViews(); } + if ( auto collection = dynamic_cast( item ) ) { - auto collection = dynamic_cast( item ); - if ( collection ) + if ( onlyDeleteUnchecked ) { - if ( onlyDeleteUnchecked ) - { - auto items = collection->allFractures(); - for ( auto item : items ) - { - if ( item->isChecked() ) continue; - collection->removeFracture( item ); - delete item; - } - } - else + auto items = collection->allFractures(); + for ( auto item : items ) { - collection->deleteFractures(); + if ( item->isChecked() ) continue; + collection->removeFracture( item ); + delete item; } + } + else + { + collection->deleteFractures(); + } - collection->updateConnectedEditors(); + collection->updateConnectedEditors(); - RimProject* proj = RimProject::current(); - if ( proj ) proj->reloadCompletionTypeResultsInAllViews(); - } + RimProject* proj = RimProject::current(); + if ( proj ) proj->reloadCompletionTypeResultsInAllViews(); } + if ( auto collection = dynamic_cast( item ) ) { - auto collection = dynamic_cast( item ); - if ( collection ) + collection->deleteAllPlots(); + + if ( auto objHandle = dynamic_cast( item ) ) { - collection->deleteAllPlots(); + objHandle->updateConnectedEditors(); + } + } - if ( auto objHandle = dynamic_cast( item ) ) - { - objHandle->updateConnectedEditors(); - } + if ( auto collection = dynamic_cast( item ) ) + { + collection->deleteAllData(); + + if ( auto objHandle = dynamic_cast( item ) ) + { + objHandle->updateConnectedEditors(); } } } diff --git a/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp b/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp index 06920c73bc..972cf6cc0d 100644 --- a/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp @@ -24,7 +24,6 @@ #include "RimMainPlotCollection.h" #include "VerticalFlowPerformance/RimVfpDataCollection.h" -#include "VerticalFlowPerformance/RimVfpDeck.h" #include "VerticalFlowPerformance/RimVfpPlot.h" #include "VerticalFlowPerformance/RimVfpPlotCollection.h" @@ -72,9 +71,6 @@ void RicImportVfpDataFeature::onActionTriggered( bool isChecked ) app->setLastUsedDialogDirectory( vfpDataKey, QFileInfo( fileNames.last() ).absolutePath() ); - std::vector vfpPlots; - std::vector vfpDecks; - auto vfpDataColl = RimVfpDataCollection::instance(); for ( const auto& fileName : fileNames ) diff --git a/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.cpp b/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.cpp new file mode 100644 index 0000000000..5421890f08 --- /dev/null +++ b/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.cpp @@ -0,0 +1,66 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RicNewCustomVfpPlotFeature.h" + +#include "RicNewVfpPlotFeature.h" + +#include "RimMainPlotCollection.h" + +#include "VerticalFlowPerformance/RimCustomVfpPlot.h" +#include "VerticalFlowPerformance/RimVfpDataCollection.h" +#include "VerticalFlowPerformance/RimVfpPlotCollection.h" +#include "VerticalFlowPerformance/RimVfpTable.h" +#include "VerticalFlowPerformance/RimVfpTableData.h" + +#include "cafSelectionManagerTools.h" + +#include "RiuPlotMainWindowTools.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewCustomVfpPlotFeature, "RicNewCustomVfpPlotFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewCustomVfpPlotFeature::onActionTriggered( bool isChecked ) +{ + RimVfpPlotCollection* vfpPlotColl = RimMainPlotCollection::current()->vfpPlotCollection(); + if ( !vfpPlotColl ) return; + + auto selectedTables = RicNewVfpPlotFeature::selectedTables(); + if ( selectedTables.empty() ) return; + + auto mainDataSource = selectedTables.front(); + std::vector additionalDataSources; + std::copy( selectedTables.begin() + 1, selectedTables.end(), std::back_inserter( additionalDataSources ) ); + + auto firstPlot = vfpPlotColl->createAndAppendPlots( mainDataSource, additionalDataSources ); + vfpPlotColl->updateConnectedEditors(); + RiuPlotMainWindowTools::onObjectAppended( firstPlot, firstPlot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewCustomVfpPlotFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Create Custom VFP Plot" ); + actionToSetup->setIcon( QIcon( ":/VfpPlot.svg" ) ); +} diff --git a/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.h b/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.h new file mode 100644 index 0000000000..f3f99517e6 --- /dev/null +++ b/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicNewCustomVfpPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp index 90a21871db..a908d1b0c9 100644 --- a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp @@ -22,6 +22,7 @@ #include "VerticalFlowPerformance/RimVfpDataCollection.h" #include "VerticalFlowPerformance/RimVfpPlotCollection.h" +#include "VerticalFlowPerformance/RimVfpTable.h" #include "VerticalFlowPerformance/RimVfpTableData.h" #include "cafSelectionManagerTools.h" @@ -32,6 +33,22 @@ CAF_CMD_SOURCE_INIT( RicNewVfpPlotFeature, "RicNewVfpPlotFeature" ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicNewVfpPlotFeature::selectedTables() +{ + auto tables = caf::selectedObjectsByTypeStrict(); + auto selectedTableData = caf::selectedObjectsByTypeStrict(); + for ( auto tableData : selectedTableData ) + { + auto tableDataSources = tableData->tableDataSources(); + tables.insert( tables.end(), tableDataSources.begin(), tableDataSources.end() ); + } + + return tables; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -40,10 +57,9 @@ void RicNewVfpPlotFeature::onActionTriggered( bool isChecked ) RimVfpPlotCollection* vfpPlotColl = RimMainPlotCollection::current()->vfpPlotCollection(); if ( !vfpPlotColl ) return; - auto selectedTableData = caf::selectedObjectsByTypeStrict(); - for ( auto tableData : selectedTableData ) + for ( auto table : selectedTables() ) { - RimVfpPlot* firstPlot = vfpPlotColl->createAndAppendPlots( tableData ); + RimVfpPlot* firstPlot = vfpPlotColl->createAndAppendPlots( table ); vfpPlotColl->updateConnectedEditors(); RiuPlotMainWindowTools::onObjectAppended( firstPlot, firstPlot ); } diff --git a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h index 300d859e15..9a9cb8dcf2 100644 --- a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h +++ b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h @@ -20,6 +20,8 @@ #include "cafCmdFeature.h" +class RimVfpTable; + //================================================================================================== /// //================================================================================================== @@ -27,6 +29,9 @@ class RicNewVfpPlotFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + static std::vector selectedTables(); + private: void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake index b1fbee6cef..5db1f2a700 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake @@ -1,18 +1,20 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.h - ${CMAKE_CURRENT_LIST_DIR}/RimVfpDeck.h ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.h + ${CMAKE_CURRENT_LIST_DIR}/RimCustomVfpPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimVfpTableData.h + ${CMAKE_CURRENT_LIST_DIR}/RimVfpTable.h ${CMAKE_CURRENT_LIST_DIR}/RimVfpDataCollection.h ) set(SOURCE_GROUP_SOURCE_FILES - ${CMAKE_CURRENT_LIST_DIR}/RimVfpDeck.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimCustomVfpPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVfpTableData.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimVfpTable.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVfpDataCollection.cpp ) diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp new file mode 100644 index 0000000000..a1879b976a --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp @@ -0,0 +1,1013 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimCustomVfpPlot.h" + +#include "RiaColorTables.h" +#include "RiaColorTools.h" +#include "RiaEclipseUnitTools.h" + +#include "RigVfpTables.h" + +#include "RimPlotAxisProperties.h" +#include "RimPlotCurve.h" +#include "RimVfpDataCollection.h" +#include "RimVfpDefines.h" +#include "RimVfpTable.h" +#include "RimVfpTableData.h" +#include "Tools/RimPlotAxisTools.h" + +#include "RiuContextMenuLauncher.h" +#include "RiuPlotCurve.h" +#include "RiuPlotCurveInfoTextProvider.h" +#include "RiuPlotWidget.h" +#include "RiuQwtCurvePointTracker.h" +#include "RiuQwtPlotCurveDefines.h" +#include "RiuQwtPlotWheelZoomer.h" +#include "RiuQwtPlotWidget.h" +#include "RiuQwtPlotZoomer.h" + +#include "cafPdmUiComboBoxEditor.h" +#include "cafPdmUiTreeSelectionEditor.h" + +#include "qwt_plot_panner.h" + +//================================================================================================== +// +// +// +//================================================================================================== + +CAF_PDM_SOURCE_INIT( RimCustomVfpPlot, "RimCustomVfpPlot" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCustomVfpPlot::RimCustomVfpPlot() +{ + // TODO: add icon + CAF_PDM_InitObject( "VFP Plot", ":/VfpPlot.svg" ); + + CAF_PDM_InitField( &m_plotTitle, "PlotTitle", QString( "VFP Plot" ), "Plot Title" ); + m_plotTitle.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_mainDataSource, "MainDataSouce", "Main VFP Data Source" ); + + CAF_PDM_InitFieldNoDefault( &m_additionalDataSources, "AdditionalDataSources", "Additional Data Sources" ); + m_additionalDataSources.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_curveOptionFiltering, "CurveOptionFiltering", "Curve Option Filtering" ); + CAF_PDM_InitFieldNoDefault( &m_curveMatchingType, "CurveMatchingType", "Curve Matching Type" ); + + caf::AppEnum defaultTableType = RimVfpDefines::TableType::INJECTION; + CAF_PDM_InitField( &m_tableType, "TableType", defaultTableType, "Table Type" ); + m_tableType.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitField( &m_tableNumber, "TableNumber", -1, "Table Number" ); + m_tableNumber.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitField( &m_referenceDepth, "ReferenceDepth", 0.0, "Reference Depth" ); + m_referenceDepth.uiCapability()->setUiReadOnly( true ); + + caf::AppEnum defaultFlowingPhase = RimVfpDefines::FlowingPhaseType::WATER; + CAF_PDM_InitField( &m_flowingPhase, "FlowingPhase", defaultFlowingPhase, "Flowing Phase" ); + m_flowingPhase.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_flowingWaterFraction, "FlowingWaterFraction", "Flowing Water Fraction" ); + m_flowingWaterFraction.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_flowingGasFraction, "FlowingGasFraction", "Flowing Gas Fraction" ); + m_flowingGasFraction.uiCapability()->setUiReadOnly( true ); + + caf::AppEnum defaultInterpolatedVariable = RimVfpDefines::InterpolatedVariableType::BHP; + CAF_PDM_InitField( &m_interpolatedVariable, "InterpolatedVariable", defaultInterpolatedVariable, "Interpolated Variable" ); + + caf::AppEnum defaultPrimaryVariable = RimVfpDefines::ProductionVariableType::FLOW_RATE; + CAF_PDM_InitField( &m_primaryVariable, "PrimaryVariable", defaultPrimaryVariable, "Primary Variable" ); + + caf::AppEnum defaultFamilyVariable = RimVfpDefines::ProductionVariableType::THP; + CAF_PDM_InitField( &m_familyVariable, "FamilyVariable", defaultFamilyVariable, "Family Variable" ); + + CAF_PDM_InitField( &m_flowRateIdx, "LiquidFlowRateIdx", { 0 }, "Flow Rate" ); + m_flowRateIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_thpIdx, "THPIdx", { 0 }, "THP" ); + m_thpIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_articifialLiftQuantityIdx, "ArtificialLiftQuantityIdx", { 0 }, "Artificial Lift Quantity" ); + m_articifialLiftQuantityIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_waterCutIdx, "WaterCutIdx", { 0 }, "Water Cut" ); + m_waterCutIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_gasLiquidRatioIdx, "GasLiquidRatioIdx", { 0 }, "Gas Liquid Ratio" ); + m_gasLiquidRatioIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_familyValues, "FamilyValues", { 0 }, "Family Values" ); + m_familyValues.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_xAxisProperties, "xAxisProperties", "X Axis" ); + m_xAxisProperties = new RimPlotAxisProperties; + m_xAxisProperties->setNameAndAxis( "X-Axis", "X-Axis", RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); + m_xAxisProperties->setEnableTitleTextSettings( false ); + + CAF_PDM_InitFieldNoDefault( &m_yAxisProperties, "yAxisProperties", "Y Axis" ); + m_yAxisProperties = new RimPlotAxisProperties; + m_yAxisProperties->setNameAndAxis( "Y-Axis", "Y-Axis", RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); + m_yAxisProperties->setEnableTitleTextSettings( false ); + + connectAxisSignals( m_xAxisProperties() ); + connectAxisSignals( m_yAxisProperties() ); + + CAF_PDM_InitFieldNoDefault( &m_plotCurves, "PlotCurves", "Curves" ); + m_plotCurves.uiCapability()->setUiTreeChildrenHidden( true ); + + m_showWindow = true; + m_showPlotLegends = true; + + setAsPlotMdiWindow(); + + setDeletable( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCustomVfpPlot::~RimCustomVfpPlot() +{ + removeMdiWindowFromMdiArea(); + deleteViewWidget(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::selectDataSource( RimVfpTable* mainDataSource, const std::vector& vfpTableData ) +{ + m_mainDataSource = mainDataSource; + + m_additionalDataSources.setValue( vfpTableData ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::setTableNumber( int tableNumber ) +{ + m_tableNumber = tableNumber; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::initializeObject() +{ + if ( !m_mainDataSource || !m_mainDataSource->dataSource() || !m_mainDataSource->dataSource()->vfpTables() ) return; + + auto vfpTables = m_mainDataSource->dataSource()->vfpTables(); + auto tableNumber = m_mainDataSource->tableNumber(); + + auto table = vfpTables->getTableInitialData( tableNumber ); + initializeFromInitData( table ); + + auto values = vfpTables->getProductionTableData( m_tableNumber(), m_familyVariable() ); + m_familyValues = values; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotWidget* RimCustomVfpPlot::plotWidget() +{ + return m_plotWidget; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimCustomVfpPlot::isCurveHighlightSupported() const +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::setAutoScaleXEnabled( bool enabled ) +{ + m_xAxisProperties->setAutoZoom( enabled ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::setAutoScaleYEnabled( bool enabled ) +{ + m_yAxisProperties->setAutoZoom( enabled ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::updateAxes() +{ + if ( !m_plotWidget ) return; + + QString title; + RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, RiuPlotAxis::defaultBottom(), m_xAxisProperties(), title, {} ); + RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, RiuPlotAxis::defaultLeft(), m_yAxisProperties(), title, {} ); + + m_plotWidget->scheduleReplot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::updateLegend() +{ + if ( !m_plotWidget ) + { + return; + } + + // Hide the legend when in multiplot mode, as the legend is handled by the multi plot grid layout + bool doShowLegend = false; + if ( isMdiWindow() ) + { + doShowLegend = m_showPlotLegends; + } + + if ( doShowLegend ) + { + m_plotWidget->insertLegend( RiuPlotWidget::Legend::BOTTOM ); + } + else + { + m_plotWidget->clearLegend(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCustomVfpPlot::asciiDataForPlotExport() const +{ + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::reattachAllCurves() +{ + for ( auto curve : m_plotCurves() ) + { + if ( curve->isChecked() ) + { + curve->setParentPlotNoReplot( m_plotWidget ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::detachAllCurves() +{ + for ( auto curve : m_plotCurves() ) + { + curve->detach(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCustomVfpPlot::description() const +{ + return uiName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCustomVfpPlot::infoForCurve( RimPlotCurve* plotCurve ) const +{ + std::vector tables = m_additionalDataSources.ptrReferencedObjectsByType(); + tables.push_back( m_mainDataSource ); + + auto index = m_plotCurves.indexOf( plotCurve ); + + size_t curveCount = 0; + for ( size_t i = 0; i < m_plotData.size(); i++ ) + { + curveCount += m_plotData[i].size(); + if ( index < curveCount ) + { + auto tableIndex = i; + + auto table = tables[tableIndex]; + QString info = QString( "Table: %1" ).arg( table->tableNumber() ); + + auto curveIndex = index - ( curveCount - m_plotData[i].size() ); + auto selection = tableSelection( table ); + if ( curveIndex < selection.familyValues.size() ) + { + auto displayValue = convertToDisplayUnit( selection.familyValues[curveIndex], m_familyVariable() ); + auto unitText = getDisplayUnit( m_familyVariable() ); + auto variableName = m_familyVariable().uiText(); + + info += QString( " - %1 %2 %3 " ).arg( variableName ).arg( displayValue ).arg( unitText ); + } + + return info; + } + } + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* RimCustomVfpPlot::viewWidget() +{ + return m_plotWidget; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QImage RimCustomVfpPlot::snapshotWindowContent() +{ + QImage image; + + if ( m_plotWidget ) + { + QPixmap pix = m_plotWidget->grab(); + image = pix.toImage(); + } + + return image; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::zoomAll() +{ + setAutoScaleXEnabled( true ); + setAutoScaleYEnabled( true ); + + updatePlotWidgetFromAxisRanges(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) +{ + detachAllCurves(); + reattachAllCurves(); + + m_plotWidget->scheduleReplot(); +} + +//================================================================================================== +// +// +// +//================================================================================================== +class RimVfpCurveInfoTextProvider : public RiuPlotCurveInfoTextProvider +{ +public: + QString curveInfoText( RiuPlotCurve* curve ) const override { return infoForCurve( curve ); }; + + QString additionalText( RiuPlotCurve* curve, int sampleIndex ) const override { return {}; } + +private: + QString infoForCurve( RiuPlotCurve* riuCurve ) const + { + if ( auto rimcurve = riuCurve->ownerRimCurve() ) + { + if ( auto owner = rimcurve->firstAncestorOfType() ) + { + return owner->infoForCurve( rimcurve ); + } + } + + return {}; + }; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotWidget* RimCustomVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) +{ + // It seems we risk being called multiple times + if ( m_plotWidget ) return m_plotWidget; + + auto qwtPlotWidget = new RiuQwtPlotWidget( this, mainWindowParent ); + auto qwtPlot = qwtPlotWidget->qwtPlot(); + new RiuQwtCurvePointTracker( qwtPlot, true, curveTextProvider() ); + + // LeftButton for the zooming + auto plotZoomer = new RiuQwtPlotZoomer( qwtPlot->canvas() ); + plotZoomer->setTrackerMode( QwtPicker::AlwaysOff ); + plotZoomer->initMousePattern( 1 ); + + // MidButton for the panning + auto panner = new QwtPlotPanner( qwtPlot->canvas() ); + panner->setMouseButton( Qt::MiddleButton ); + + auto wheelZoomer = new RiuQwtPlotWheelZoomer( qwtPlot ); + + // Use lambda functions to connect signals to functions instead of slots + connect( wheelZoomer, &RiuQwtPlotWheelZoomer::zoomUpdated, [=, this]() { onPlotZoomed(); } ); + connect( plotZoomer, &RiuQwtPlotZoomer::zoomed, [=, this]() { onPlotZoomed(); } ); + connect( panner, &QwtPlotPanner::panned, [=, this]() { onPlotZoomed(); } ); + connect( qwtPlotWidget, &RiuQwtPlotWidget::plotZoomed, [=, this]() { onPlotZoomed(); } ); + + // Remove event filter to disable unwanted highlighting on left click in plot. + qwtPlotWidget->removeEventFilter(); + + new RiuContextMenuLauncher( qwtPlotWidget, { "RicShowPlotDataFeature" } ); + + m_plotWidget = qwtPlotWidget; + + updateLegend(); + onLoadDataAndUpdate(); + + return m_plotWidget; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::deleteViewWidget() +{ + if ( m_plotWidget ) + { + m_plotWidget->setParent( nullptr ); + delete m_plotWidget; + m_plotWidget = nullptr; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::onLoadDataAndUpdate() +{ + if ( isMdiWindow() ) + { + updateMdiWindowVisibility(); + } + else + { + updateParentLayout(); + } + + if ( !m_plotWidget ) + { + return; + } + + updateLegend(); + + detachAllCurves(); + m_plotCurves.deleteChildren(); + + int colorIndex = 0; + + std::vector tables = m_additionalDataSources.ptrReferencedObjectsByType(); + tables.push_back( m_mainDataSource ); + + m_plotData.clear(); + + for ( const auto& table : tables ) + { + if ( !table ) continue; + + int tableIndex = table->tableNumber(); + auto vfpTables = table->dataSource()->vfpTables(); + + auto vfpPlotData = vfpTables->populatePlotData( tableIndex, + m_primaryVariable(), + m_familyVariable(), + m_interpolatedVariable(), + m_flowingPhase(), + tableSelection( table ) ); + + m_plotData.push_back( vfpPlotData ); + + QColor curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledQColor( colorIndex++ ); + + populatePlotWidgetWithPlotData( m_plotWidget, vfpPlotData, curveColor ); + } + + updatePlotTitle( + generatePlotTitle( "Custom", m_tableNumber(), m_tableType(), m_interpolatedVariable(), m_primaryVariable(), m_familyVariable() ) ); + + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true ); + + reattachAllCurves(); + + updatePlotWidgetFromAxisRanges(); + + m_plotWidget->scheduleReplot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData, const QColor& color ) +{ + plotWidget->setAxisScale( RiuPlotAxis::defaultBottom(), 0, 1 ); + plotWidget->setAxisScale( RiuPlotAxis::defaultLeft(), 0, 1 ); + plotWidget->setAxisAutoScale( RiuPlotAxis::defaultBottom(), true ); + plotWidget->setAxisAutoScale( RiuPlotAxis::defaultLeft(), true ); + plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), plotData.xAxisTitle() ); + plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), plotData.yAxisTitle() ); + + for ( auto idx = 0u; idx < plotData.size(); idx++ ) + { + auto curve = new RimPlotCurve(); + + curve->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); + curve->setLineThickness( 2 ); + curve->setColor( RiaColorTools::fromQColorTo3f( color ) ); + curve->setSymbol( RiuPlotCurveSymbol::SYMBOL_ELLIPSE ); + curve->setSymbolSize( 6 ); + + curve->setCustomName( plotData.curveTitle( idx ) ); + curve->setParentPlotNoReplot( plotWidget ); + if ( curve->plotCurve() ) + { + bool useLogarithmicScale = false; + curve->plotCurve()->setSamplesFromXValuesAndYValues( plotData.xData( idx ), plotData.yData( idx ), useLogarithmicScale ); + } + curve->updateCurveAppearance(); + curve->appearanceChanged.connect( this, &RimCustomVfpPlot::curveAppearanceChanged ); + + m_plotCurves.push_back( curve ); + } + + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCustomVfpPlot::axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ) +{ + QString title; + + if ( flowingPhase == RimVfpDefines::FlowingPhaseType::GAS ) + { + title = "Gas "; + } + else + { + title = "Liquid "; + } + title += QString( "%1 %2" ).arg( caf::AppEnum::uiText( variableType ), + getDisplayUnitWithBracket( variableType ) ); + + return title; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::connectAxisSignals( RimPlotAxisProperties* axis ) +{ + axis->settingsChanged.connect( this, &RimCustomVfpPlot::axisSettingsChanged ); + axis->logarithmicChanged.connect( this, &RimCustomVfpPlot::axisLogarithmicChanged ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::axisSettingsChanged( const caf::SignalEmitter* emitter ) +{ + updateAxes(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic ) +{ + // Currently not supported +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::updatePlotWidgetFromAxisRanges() +{ + if ( m_plotWidget ) + { + updateAxes(); + + if ( auto qwtWidget = dynamic_cast( m_plotWidget.data() ) ) + { + if ( qwtWidget->qwtPlot() ) qwtWidget->qwtPlot()->updateAxes(); + } + + updateAxisRangesFromPlotWidget(); + m_plotWidget->scheduleReplot(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::updateAxisRangesFromPlotWidget() +{ + RimPlotAxisTools::updateVisibleRangesFromPlotWidget( m_xAxisProperties(), RiuPlotAxis::defaultBottom(), m_plotWidget ); + RimPlotAxisTools::updateVisibleRangesFromPlotWidget( m_yAxisProperties(), RiuPlotAxis::defaultLeft(), m_plotWidget ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::onPlotZoomed() +{ + setAutoScaleXEnabled( false ); + setAutoScaleYEnabled( false ); + updateAxisRangesFromPlotWidget(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::curveAppearanceChanged( const caf::SignalEmitter* emitter ) +{ + scheduleReplot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCustomVfpPlot::availableValues( RimVfpDefines::ProductionVariableType variableType ) const +{ + if ( !m_mainDataSource || !m_mainDataSource->dataSource() || !m_mainDataSource->dataSource()->vfpTables() ) return {}; + + auto values = m_mainDataSource->dataSource()->vfpTables()->getProductionTableData( m_tableNumber(), variableType ); + + if ( m_curveOptionFiltering() == RimVfpDefines::CurveOptionValuesType::UNION_OF_SELECTED_TABLES ) + { + std::vector tables = m_additionalDataSources.ptrReferencedObjectsByType(); + for ( const auto& table : tables ) + { + if ( !table ) continue; + + auto additionalValues = table->dataSource()->vfpTables()->getProductionTableData( table->tableNumber(), variableType ); + values.insert( values.end(), additionalValues.begin(), additionalValues.end() ); + } + + std::sort( values.begin(), values.end() ); + values.erase( std::unique( values.begin(), values.end() ), values.end() ); + } + + return values; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotCurveInfoTextProvider* RimCustomVfpPlot::curveTextProvider() +{ + static auto textProvider = RimVfpCurveInfoTextProvider(); + return &textProvider; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::initializeFromInitData( const VfpTableInitialData& table ) +{ + m_tableType = table.isProductionTable ? RimVfpDefines::TableType::PRODUCTION : RimVfpDefines::TableType::INJECTION; + m_tableNumber = table.tableNumber; + m_referenceDepth = table.datumDepth; + m_flowingPhase = table.flowingPhase; + m_flowingGasFraction = table.gasFraction; + m_flowingWaterFraction = table.waterFraction; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimCustomVfpPlot::convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType ) +{ + if ( variableType == RimVfpDefines::ProductionVariableType::THP ) + { + return RiaEclipseUnitTools::pascalToBar( value ); + } + + if ( variableType == RimVfpDefines::ProductionVariableType::FLOW_RATE ) + { + // Convert to m3/sec to m3/day + return value * static_cast( 24 * 60 * 60 ); + } + + return value; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::convertToDisplayUnit( std::vector& values, RimVfpDefines::ProductionVariableType variableType ) +{ + for ( double& value : values ) + value = convertToDisplayUnit( value, variableType ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCustomVfpPlot::getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType variableType ) +{ + QString unit = getDisplayUnit( variableType ); + if ( !unit.isEmpty() ) return QString( "[%1]" ).arg( unit ); + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCustomVfpPlot::getDisplayUnit( RimVfpDefines::ProductionVariableType variableType ) + +{ + if ( variableType == RimVfpDefines::ProductionVariableType::THP ) return "Bar"; + + if ( variableType == RimVfpDefines::ProductionVariableType::FLOW_RATE ) return "Sm3/day"; + + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_mainDataSource ); + uiOrdering.add( &m_additionalDataSources ); + + uiOrdering.add( &m_curveMatchingType ); + uiOrdering.add( &m_curveOptionFiltering ); + + uiOrdering.add( &m_tableType ); + uiOrdering.add( &m_tableNumber ); + uiOrdering.add( &m_referenceDepth ); + uiOrdering.add( &m_interpolatedVariable ); + uiOrdering.add( &m_flowingPhase ); + + if ( m_tableType == RimVfpDefines::TableType::PRODUCTION ) + { + uiOrdering.add( &m_flowingWaterFraction ); + uiOrdering.add( &m_flowingGasFraction ); + + uiOrdering.add( &m_primaryVariable ); + uiOrdering.add( &m_familyVariable ); + + caf::PdmUiOrdering* fixedVariablesGroup = uiOrdering.addNewGroup( "Fixed Variables" ); + fixedVariablesGroup->add( &m_flowRateIdx ); + fixedVariablesGroup->add( &m_thpIdx ); + fixedVariablesGroup->add( &m_articifialLiftQuantityIdx ); + fixedVariablesGroup->add( &m_waterCutIdx ); + fixedVariablesGroup->add( &m_gasLiquidRatioIdx ); + + fixedVariablesGroup->add( &m_familyValues ); + + // Disable the choices for variables as primary or family + setFixedVariableUiEditability( m_flowRateIdx, RimVfpDefines::ProductionVariableType::FLOW_RATE ); + setFixedVariableUiEditability( m_thpIdx, RimVfpDefines::ProductionVariableType::THP ); + setFixedVariableUiEditability( m_articifialLiftQuantityIdx, RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY ); + setFixedVariableUiEditability( m_waterCutIdx, RimVfpDefines::ProductionVariableType::WATER_CUT ); + setFixedVariableUiEditability( m_gasLiquidRatioIdx, RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO ); + } + + uiOrdering.skipRemainingFields( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::setFixedVariableUiEditability( caf::PdmFieldHandle& field, RimVfpDefines::ProductionVariableType variableType ) +{ + field.uiCapability()->setUiReadOnly( variableType == m_primaryVariable.v() ); + field.uiCapability()->setUiHidden( variableType == m_familyVariable.v() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimCustomVfpPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options = RimPlot::calculateValueOptions( fieldNeedingOptions ); + + if ( fieldNeedingOptions == &m_flowRateIdx ) + { + calculateTableValueOptions( RimVfpDefines::ProductionVariableType::FLOW_RATE, options ); + } + + else if ( fieldNeedingOptions == &m_thpIdx ) + { + calculateTableValueOptions( RimVfpDefines::ProductionVariableType::THP, options ); + } + + else if ( fieldNeedingOptions == &m_articifialLiftQuantityIdx ) + { + calculateTableValueOptions( RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY, options ); + } + + else if ( fieldNeedingOptions == &m_waterCutIdx ) + { + calculateTableValueOptions( RimVfpDefines::ProductionVariableType::WATER_CUT, options ); + } + + else if ( fieldNeedingOptions == &m_gasLiquidRatioIdx ) + { + calculateTableValueOptions( RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO, options ); + } + + else if ( fieldNeedingOptions == &m_familyValues ) + { + calculateTableValueOptions( m_familyVariable(), options ); + } + + else if ( fieldNeedingOptions == &m_additionalDataSources ) + { + RimVfpDataCollection* vfpDataCollection = RimVfpDataCollection::instance(); + for ( auto table : vfpDataCollection->vfpTableData() ) + { + // Exclude main table data object + if ( table == m_mainDataSource ) continue; + + options.push_back( caf::PdmOptionItemInfo( table->name(), table ) ); + } + } + + else if ( fieldNeedingOptions == &m_mainDataSource ) + { + RimVfpDataCollection* vfpDataCollection = RimVfpDataCollection::instance(); + for ( auto table : vfpDataCollection->vfpTableData() ) + { + options.push_back( caf::PdmOptionItemInfo( table->name(), table ) ); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::calculateTableValueOptions( RimVfpDefines::ProductionVariableType variableType, QList& options ) +{ + auto values = availableValues( variableType ); + + for ( size_t i = 0; i < values.size(); i++ ) + { + options.push_back( + caf::PdmOptionItemInfo( QString( "%1 %2" ).arg( convertToDisplayUnit( values[i], variableType ) ).arg( getDisplayUnit( variableType ) ), + values[i] ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + RimPlot::fieldChangedByUi( changedField, oldValue, newValue ); + + if ( changedField == &m_mainDataSource ) + { + initializeObject(); + } + + if ( changedField == &m_familyVariable || changedField == &m_curveOptionFiltering ) + { + m_familyValues.v() = availableValues( m_familyVariable() ); + } + + loadDataAndUpdate(); + updateLayout(); + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::initAfterRead() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::updatePlotTitle( const QString& plotTitle ) +{ + m_plotTitle = plotTitle; + + updateMdiWindowTitle(); + + if ( m_plotWidget ) + { + m_plotWidget->setPlotTitle( plotTitle ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCustomVfpPlot::generatePlotTitle( const QString& wellName, + int tableNumber, + RimVfpDefines::TableType tableType, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable ) +{ + QString tableTypeText = caf::AppEnum::uiText( tableType ); + QString interpolatedVariableText = caf::AppEnum::uiText( interpolatedVariable ); + QString primaryVariableText = caf::AppEnum::uiText( primaryVariable ); + QString plotTitleStr = + QString( "VFP: %1 (%2) #%3 - %4 x %5" ).arg( wellName ).arg( tableTypeText ).arg( tableNumber ).arg( interpolatedVariableText ).arg( primaryVariableText ); + + return plotTitleStr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimCustomVfpPlot::userDescriptionField() +{ + return &m_plotTitle; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::scheduleReplot() +{ + if ( m_plotWidget ) + { + m_plotWidget->scheduleReplot(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +VfpValueSelection RimCustomVfpPlot::tableSelection( RimVfpTable* table ) const +{ + VfpValueSelection selection; + + selection.articifialLiftQuantityValue = m_articifialLiftQuantityIdx(); + selection.flowRateValue = m_flowRateIdx(); + selection.gasLiquidRatioValue = m_gasLiquidRatioIdx(); + selection.thpValue = m_thpIdx(); + selection.waterCutValue = m_waterCutIdx(); + + if ( m_curveMatchingType() == RimVfpDefines::CurveMatchingType::EXACT ) + { + selection.familyValues = m_familyValues(); + } + else if ( m_curveMatchingType() == RimVfpDefines::CurveMatchingType::CLOSEST_MATCH_FAMILY ) + { + auto familyValues = m_familyValues(); + if ( table && table->dataSource() && table->dataSource()->vfpTables() ) + { + auto valuesToMatch = table->dataSource()->vfpTables()->getProductionTableData( table->tableNumber(), m_familyVariable() ); + auto indices = RigVfpTables::uniqueClosestIndices( familyValues, valuesToMatch ); + for ( const auto& i : indices ) + { + selection.familyValues.push_back( valuesToMatch[i] ); + } + } + } + + return selection; +} diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h new file mode 100644 index 0000000000..2797eaceaf --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h @@ -0,0 +1,172 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimPlot.h" +#include "RimVfpDefines.h" + +#include "cafPdmPtrArrayField.h" +#include "cafPdmPtrField.h" + +#include + +class RiuPlotWidget; +class VfpPlotData; +class RimPlotAxisProperties; +class RigVfpTables; +class RimVfpTableData; +class RimVfpTable; +class RiuPlotCurveInfoTextProvider; + +struct VfpValueSelection; +struct VfpTableInitialData; + +namespace Opm +{ +class VFPInjTable; +class VFPProdTable; +} // namespace Opm + +//-------------------------------------------------------------------------------------------------- +/// Vertical Flow Performance Plot +//-------------------------------------------------------------------------------------------------- +class RimCustomVfpPlot : public RimPlot +{ + CAF_PDM_HEADER_INIT; + +public: + RimCustomVfpPlot(); + ~RimCustomVfpPlot() override; + + void selectDataSource( RimVfpTable* mainDataSource, const std::vector& vfpTableData ); + void setTableNumber( int tableNumber ); + void initializeObject(); + + // RimPlot implementations + RiuPlotWidget* plotWidget() override; + bool isCurveHighlightSupported() const override; + + void setAutoScaleXEnabled( bool enabled ) override; + void setAutoScaleYEnabled( bool enabled ) override; + void updateAxes() override; + void updateLegend() override; + QString asciiDataForPlotExport() const override; + void reattachAllCurves() override; + void detachAllCurves() override; + + // RimPlotWindow implementations + QString description() const override; + QString infoForCurve( RimPlotCurve* plotCurve ) const; + + // RimViewWindow implementations + QWidget* viewWidget() override; + QImage snapshotWindowContent() override; + void zoomAll() override; + +private: + void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) override; + void deleteViewWidget() override; + void onLoadDataAndUpdate() override; + + caf::PdmFieldHandle* userDescriptionField() override; + + void scheduleReplot(); + +private: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void initAfterRead() override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + + VfpValueSelection tableSelection( RimVfpTable* table ) const; + void initializeFromInitData( const VfpTableInitialData& table ); + + RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; + + void calculateTableValueOptions( RimVfpDefines::ProductionVariableType variableType, QList& options ); + + void setFixedVariableUiEditability( caf::PdmFieldHandle& field, RimVfpDefines::ProductionVariableType variableType ); + + void updatePlotTitle( const QString& plotTitle ); + static QString generatePlotTitle( const QString& wellName, + int tableNumber, + RimVfpDefines::TableType tableType, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable ); + + static double convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType ); + static void convertToDisplayUnit( std::vector& values, RimVfpDefines::ProductionVariableType variableType ); + static QString getDisplayUnit( RimVfpDefines::ProductionVariableType variableType ); + static QString getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType variableType ); + + void populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData, const QColor& color ); + + static QString axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ); + + void connectAxisSignals( RimPlotAxisProperties* axis ); + void axisSettingsChanged( const caf::SignalEmitter* emitter ); + void axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic ); + void updatePlotWidgetFromAxisRanges() override; + void updateAxisRangesFromPlotWidget() override; + + void onPlotZoomed(); + void curveAppearanceChanged( const caf::SignalEmitter* emitter ); + + std::vector availableValues( RimVfpDefines::ProductionVariableType variableType ) const; + + static RiuPlotCurveInfoTextProvider* curveTextProvider(); + +private: + caf::PdmField m_plotTitle; + + caf::PdmPtrField m_mainDataSource; + caf::PdmPtrArrayField m_additionalDataSources; + + caf::PdmField> m_curveMatchingType; + caf::PdmField> m_curveOptionFiltering; + + caf::PdmField m_tableNumber; + caf::PdmField m_referenceDepth; + caf::PdmField> m_flowingPhase; + caf::PdmField> m_flowingWaterFraction; + caf::PdmField> m_flowingGasFraction; + + caf::PdmField> m_tableType; + caf::PdmField> m_interpolatedVariable; + caf::PdmField> m_primaryVariable; + caf::PdmField> m_familyVariable; + + caf::PdmField m_flowRateIdx; + caf::PdmField m_thpIdx; + caf::PdmField m_articifialLiftQuantityIdx; + caf::PdmField m_waterCutIdx; + caf::PdmField m_gasLiquidRatioIdx; + + caf::PdmField> m_familyValues; + + caf::PdmChildField m_yAxisProperties; + caf::PdmChildField m_xAxisProperties; + + caf::PdmChildArrayField m_plotCurves; + + std::vector m_plotData; + + QPointer m_plotWidget; +}; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.cpp index 44fda4eb84..2253808928 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.cpp @@ -46,22 +46,58 @@ RimVfpDataCollection* RimVfpDataCollection::instance() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimVfpTableData* RimVfpDataCollection::appendTableDataObject( const QString& fileName ) +RimVfpTable* RimVfpDataCollection::appendTableDataObject( const QString& fileName ) { auto* vfpTableData = new RimVfpTableData(); vfpTableData->setFileName( fileName ); - m_vfpTableData.push_back( vfpTableData ); - return vfpTableData; + vfpTableData->ensureDataIsImported(); + auto dataSources = vfpTableData->tableDataSources(); + + if ( !dataSources.empty() ) + { + return dataSources.front(); + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimVfpDataCollection::vfpTableData() const +{ + std::vector tableDataSources; + + for ( auto vfpTableData : m_vfpTableData.childrenByType() ) + { + for ( auto table : vfpTableData->tableDataSources() ) + { + tableDataSources.push_back( table ); + } + } + + return tableDataSources; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpDataCollection::loadDataAndUpdate() +{ + for ( auto vfpTableData : m_vfpTableData.childrenByType() ) + { + vfpTableData->ensureDataIsImported(); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimVfpDataCollection::vfpTableData() const +void RimVfpDataCollection::deleteAllData() { - return m_vfpTableData.childrenByType(); + m_vfpTableData.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.h index a5afebf70c..2fa71bfdba 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDataCollection.h @@ -20,6 +20,7 @@ #include "cafPdmChildArrayField.h" #include "cafPdmObject.h" +class RimVfpTable; class RimVfpTableData; //================================================================================================== @@ -35,8 +36,13 @@ class RimVfpDataCollection : public caf::PdmObject static RimVfpDataCollection* instance(); - RimVfpTableData* appendTableDataObject( const QString& fileName ); - std::vector vfpTableData() const; + RimVfpTable* appendTableDataObject( const QString& fileName ); + + std::vector vfpTableData() const; + + void loadDataAndUpdate(); + + void deleteAllData(); private: void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp deleted file mode 100644 index 3e9ce414d4..0000000000 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.cpp +++ /dev/null @@ -1,155 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2024 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 "RimVfpDeck.h" - -#include "RigVfpTables.h" - -#include "RimVfpDataCollection.h" -#include "RimVfpPlotCollection.h" -#include "RimVfpTableData.h" - -#include "cafPdmUiTreeOrdering.h" - -CAF_PDM_SOURCE_INIT( RimVfpDeck, "RimVfpDeck" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimVfpDeck::RimVfpDeck() -{ - CAF_PDM_InitObject( "VFP Plot", ":/VfpPlot.svg" ); - - CAF_PDM_InitFieldNoDefault( &m_vfpTableData, "VfpTableData", "VFP Data Source" ); - CAF_PDM_InitFieldNoDefault( &m_vfpPlotCollection, "VfpPlotCollection", "Plot Collection" ); - m_vfpPlotCollection = new RimVfpPlotCollection(); - - setDeletable( true ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpDeck::setDataSource( RimVfpTableData* tableData ) -{ - m_vfpTableData = tableData; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpDeck::loadDataAndUpdate() -{ - updateObjectName(); - - std::vector currentPlots = m_vfpPlotCollection->plots(); - - if ( m_vfpTableData ) - { - m_vfpTableData->ensureDataIsImported(); - - if ( m_vfpTableData->vfpTables() ) - { - auto tables = m_vfpTableData->vfpTables(); - - auto allTableNumbers = tables->productionTableNumbers(); - auto injTableNumbers = tables->injectionTableNumbers(); - allTableNumbers.insert( allTableNumbers.end(), injTableNumbers.begin(), injTableNumbers.end() ); - - for ( const auto& number : allTableNumbers ) - { - RimVfpPlot* plot = m_vfpPlotCollection->plotForTableNumber( number ); - if ( !plot ) - { - plot = new RimVfpPlot(); - plot->setDataSource( m_vfpTableData ); - plot->setTableNumber( number ); - plot->initializeObject(); - - m_vfpPlotCollection->addPlot( plot ); - } - else - { - std::erase( currentPlots, plot ); - } - plot->setDeletable( false ); - plot->loadDataAndUpdate(); - } - } - } - - for ( auto plotToDelete : currentPlots ) - { - m_vfpPlotCollection->removePlot( plotToDelete ); - delete plotToDelete; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimVfpDeck::plots() const -{ - return m_vfpPlotCollection->plots(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpDeck::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) -{ - for ( auto p : m_vfpPlotCollection->plots() ) - { - uiTreeOrdering.add( p ); - } - - uiTreeOrdering.skipRemainingChildren( true ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpDeck::updateObjectName() -{ - QString name = "VFP Deck"; - - if ( m_vfpTableData ) - { - name = m_vfpTableData->name(); - } - - setName( name ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList RimVfpDeck::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) -{ - QList options; - if ( fieldNeedingOptions == &m_vfpTableData ) - { - RimVfpDataCollection* vfpDataCollection = RimVfpDataCollection::instance(); - for ( auto table : vfpDataCollection->vfpTableData() ) - { - options.push_back( caf::PdmOptionItemInfo( table->name(), table ) ); - } - } - - return options; -} diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.cpp index 35b3d255e1..2814469f64 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.cpp @@ -79,4 +79,20 @@ void caf::AppEnum::setUp() addItem( RimVfpDefines::FlowingGasFractionType::INVALID, "INVALID", "Invalid" ); setDefault( RimVfpDefines::FlowingGasFractionType::INVALID ); } + +template <> +void caf::AppEnum::setUp() +{ + addItem( RimVfpDefines::CurveMatchingType::EXACT, "EXACT", "Exact" ); + addItem( RimVfpDefines::CurveMatchingType::CLOSEST_MATCH_FAMILY, "CLOSEST_MATCH_FAMILY", "Family Closest Match" ); + setDefault( RimVfpDefines::CurveMatchingType::EXACT ); +} + +template <> +void caf::AppEnum::setUp() +{ + addItem( RimVfpDefines::CurveOptionValuesType::MAIN_TABLE, "MAIN_TABLE", "Values from Main Table" ); + addItem( RimVfpDefines::CurveOptionValuesType::UNION_OF_SELECTED_TABLES, "UNION_OF_SELECTED_TABLES", "Union of Selected Table Values" ); + setDefault( RimVfpDefines::CurveOptionValuesType::MAIN_TABLE ); +} } // namespace caf diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.h index 39a9913c37..fe76cf40bc 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.h @@ -65,4 +65,17 @@ enum class FlowingGasFractionType OGR, INVALID }; + +enum class CurveMatchingType +{ + EXACT, + CLOSEST_MATCH_FAMILY, +}; + +enum class CurveOptionValuesType +{ + MAIN_TABLE, + UNION_OF_SELECTED_TABLES, +}; + }; // namespace RimVfpDefines diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp index d4868e0d63..0335a7ec41 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp @@ -30,6 +30,7 @@ #include "RimProject.h" #include "RimVfpDataCollection.h" #include "RimVfpDefines.h" +#include "RimVfpTable.h" #include "RimVfpTableData.h" #include "Tools/RimPlotAxisTools.h" @@ -72,7 +73,7 @@ RimVfpPlot::RimVfpPlot() CAF_PDM_InitFieldNoDefault( &m_filePath_OBSOLETE, "FilePath", "File Path" ); m_filePath_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_vfpTableData, "VfpTableData", "VFP Data Source" ); + CAF_PDM_InitFieldNoDefault( &m_vfpTable, "VfpTableData", "VFP Data Source" ); caf::AppEnum defaultTableType = RimVfpDefines::TableType::INJECTION; CAF_PDM_InitField( &m_tableType, "TableType", defaultTableType, "Table Type" ); @@ -140,8 +141,6 @@ RimVfpPlot::RimVfpPlot() setAsPlotMdiWindow(); setDeletable( true ); - - m_vfpTables = std::make_unique(); } //-------------------------------------------------------------------------------------------------- @@ -156,9 +155,9 @@ RimVfpPlot::~RimVfpPlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setDataSource( RimVfpTableData* vfpTableData ) +void RimVfpPlot::setDataSource( RimVfpTable* vfpTableData ) { - m_vfpTableData = vfpTableData; + m_vfpTable = vfpTableData; } //-------------------------------------------------------------------------------------------------- @@ -176,7 +175,7 @@ void RimVfpPlot::initializeObject() { if ( !vfpTables() ) return; - auto tableNumber = m_tableNumber(); + auto tableNumber = m_vfpTable->tableNumber(); // Always use the available table number if only one table is available auto prodTableNumbers = vfpTables()->productionTableNumbers(); @@ -284,9 +283,9 @@ QString RimVfpPlot::asciiDataForPlotExport() const QString wellName; - if ( m_vfpTableData ) + if ( m_vfpTable ) { - wellName = m_vfpTableData->name(); + wellName = m_vfpTable->name(); } else { @@ -423,10 +422,10 @@ RiuPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) auto wheelZoomer = new RiuQwtPlotWheelZoomer( qwtPlot ); // Use lambda functions to connect signals to functions instead of slots - connect( wheelZoomer, &RiuQwtPlotWheelZoomer::zoomUpdated, [=]() { onPlotZoomed(); } ); - connect( plotZoomer, &RiuQwtPlotZoomer::zoomed, [=]() { onPlotZoomed(); } ); - connect( panner, &QwtPlotPanner::panned, [=]() { onPlotZoomed(); } ); - connect( qwtPlotWidget, &RiuQwtPlotWidget::plotZoomed, [=]() { onPlotZoomed(); } ); + connect( wheelZoomer, &RiuQwtPlotWheelZoomer::zoomUpdated, [=, this]() { onPlotZoomed(); } ); + connect( plotZoomer, &RiuQwtPlotZoomer::zoomed, [=, this]() { onPlotZoomed(); } ); + connect( panner, &QwtPlotPanner::panned, [=, this]() { onPlotZoomed(); } ); + connect( qwtPlotWidget, &RiuQwtPlotWidget::plotZoomed, [=, this]() { onPlotZoomed(); } ); // Remove event filter to disable unwanted highlighting on left click in plot. qwtPlotWidget->removeEventFilter(); @@ -479,7 +478,7 @@ void RimVfpPlot::onLoadDataAndUpdate() if ( vfpTables() ) { - wellName = m_vfpTableData->baseFileName(); + wellName = vfpTableData()->baseFileName(); auto vfpPlotData = vfpTables()->populatePlotData( m_tableNumber(), m_primaryVariable(), @@ -666,17 +665,22 @@ void RimVfpPlot::initializeFromInitData( const VfpTableInitialData& table ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigVfpTables* RimVfpPlot::vfpTables() const +RimVfpTableData* RimVfpPlot::vfpTableData() const { - if ( m_vfpTableData ) - { - m_vfpTableData->ensureDataIsImported(); - return m_vfpTableData->vfpTables(); - } + if ( m_vfpTable ) return m_vfpTable->dataSource(); - if ( m_vfpTables ) + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigVfpTables* RimVfpPlot::vfpTables() const +{ + if ( vfpTableData() ) { - return m_vfpTables.get(); + vfpTableData()->ensureDataIsImported(); + return vfpTableData()->vfpTables(); } return nullptr; @@ -739,7 +743,7 @@ QString RimVfpPlot::getDisplayUnit( RimVfpDefines::ProductionVariableType variab //-------------------------------------------------------------------------------------------------- void RimVfpPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - uiOrdering.add( &m_vfpTableData ); + uiOrdering.add( &m_vfpTable ); uiOrdering.add( &m_tableType ); uiOrdering.add( &m_tableNumber ); @@ -813,7 +817,7 @@ QList RimVfpPlot::calculateValueOptions( const caf::PdmF calculateTableValueOptions( RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO, options ); } - else if ( fieldNeedingOptions == &m_vfpTableData ) + else if ( fieldNeedingOptions == &m_vfpTable ) { RimVfpDataCollection* vfpDataCollection = RimVfpDataCollection::instance(); for ( auto table : vfpDataCollection->vfpTableData() ) @@ -850,6 +854,11 @@ void RimVfpPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, cons { RimPlot::fieldChangedByUi( changedField, oldValue, newValue ); + if ( changedField == &m_vfpTable ) + { + initializeObject(); + } + loadDataAndUpdate(); updateLayout(); } diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h index 7bf0192532..96c325910f 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h @@ -30,6 +30,7 @@ class RiuPlotWidget; class VfpPlotData; class RimPlotAxisProperties; class RigVfpTables; +class RimVfpTable; class RimVfpTableData; struct VfpTableSelection; @@ -52,7 +53,7 @@ class RimVfpPlot : public RimPlot RimVfpPlot(); ~RimVfpPlot() override; - void setDataSource( RimVfpTableData* vfpTableData ); + void setDataSource( RimVfpTable* vfpTableData ); void setTableNumber( int tableNumber ); void initializeObject(); @@ -94,8 +95,10 @@ class RimVfpPlot : public RimPlot void initAfterRead() override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; - VfpTableSelection tableSelection() const; - void initializeFromInitData( const VfpTableInitialData& table ); + VfpTableSelection tableSelection() const; + void initializeFromInitData( const VfpTableInitialData& table ); + + RimVfpTableData* vfpTableData() const; const RigVfpTables* vfpTables() const; RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; @@ -132,7 +135,7 @@ class RimVfpPlot : public RimPlot private: caf::PdmField m_plotTitle; - caf::PdmPtrField m_vfpTableData; + caf::PdmPtrField m_vfpTable; caf::PdmField m_tableNumber; caf::PdmField m_referenceDepth; caf::PdmField> m_flowingPhase; @@ -157,8 +160,7 @@ class RimVfpPlot : public RimPlot QPointer m_plotWidget; - std::unique_ptr m_vfpTables; - caf::PdmField m_filePath_OBSOLETE; + caf::PdmField m_filePath_OBSOLETE; bool m_dataIsImportedExternally; }; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp index 734cd655a5..0aff309d53 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp @@ -18,8 +18,8 @@ #include "RimVfpPlotCollection.h" -#include "RimVfpDeck.h" -#include "RimVfpTableData.h" +#include "RimCustomVfpPlot.h" +#include "RimVfpTable.h" #include "cafCmdFeatureMenuBuilder.h" @@ -33,51 +33,48 @@ RimVfpPlotCollection::RimVfpPlotCollection() CAF_PDM_InitObject( "VFP Plots", ":/VfpPlotCollection.svg" ); CAF_PDM_InitFieldNoDefault( &m_vfpPlots, "VfpPlots", "Vertical Flow Performance Plots" ); - CAF_PDM_InitFieldNoDefault( &m_vfpDecks, "VfpDecks", "Vertical Flow Performance Decks" ); + CAF_PDM_InitFieldNoDefault( &m_customVfpPlots, "CustomVfpPlots", "Vertical Flow Performance Plots" ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimVfpPlot* RimVfpPlotCollection::createAndAppendPlots( RimVfpTableData* tableData ) +RimVfpPlot* RimVfpPlotCollection::createAndAppendPlots( RimVfpTable* tableData ) { if ( !tableData ) return nullptr; tableData->ensureDataIsImported(); - if ( !tableData->vfpTables() ) return nullptr; - RimVfpPlot* firstPlot = nullptr; - if ( tableData->tableCount() > 1 ) - { - auto* deck = new RimVfpDeck(); - deck->setDataSource( tableData ); - addDeck( deck ); - deck->loadDataAndUpdate(); - deck->updateAllRequiredEditors(); - - auto plots = deck->plots(); - if ( !plots.empty() ) - { - firstPlot = plots.front(); - } - } - else - { - auto vfpPlot = new RimVfpPlot(); - vfpPlot->setDataSource( tableData ); - vfpPlot->initializeObject(); + auto vfpPlot = new RimVfpPlot(); + vfpPlot->setDataSource( tableData ); + vfpPlot->initializeObject(); - addPlot( vfpPlot ); - vfpPlot->loadDataAndUpdate(); + addPlot( vfpPlot ); + vfpPlot->loadDataAndUpdate(); - firstPlot = vfpPlot; - } + firstPlot = vfpPlot; return firstPlot; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCustomVfpPlot* RimVfpPlotCollection::createAndAppendPlots( RimVfpTable* mainDataSource, std::vector tableData ) +{ + auto vfpPlot = new RimCustomVfpPlot(); + vfpPlot->selectDataSource( mainDataSource, tableData ); + vfpPlot->initializeObject(); + + m_customVfpPlots.push_back( vfpPlot ); + + vfpPlot->loadDataAndUpdate(); + + return vfpPlot; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -135,21 +132,13 @@ void RimVfpPlotCollection::removePlot( RimVfpPlot* vfpPlot ) updateAllRequiredEditors(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpPlotCollection::addDeck( RimVfpDeck* deck ) -{ - m_vfpDecks.push_back( deck ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimVfpPlotCollection::deleteAllPlots() { m_vfpPlots.deleteChildren(); - m_vfpDecks.deleteChildren(); + m_customVfpPlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -185,9 +174,9 @@ void RimVfpPlotCollection::loadDataAndUpdateAllPlots() plot->loadDataAndUpdate(); } - for ( auto deck : m_vfpDecks.childrenByType() ) + for ( auto customPlot : m_customVfpPlots.childrenByType() ) { - deck->loadDataAndUpdate(); + customPlot->loadDataAndUpdate(); } } diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h index a489deccbd..2ab646552b 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h @@ -23,7 +23,7 @@ #include "cafPdmChildArrayField.h" #include "cafPdmObject.h" -class RimVfpDeck; +class RimCustomVfpPlot; //================================================================================================== /// @@ -36,8 +36,9 @@ class RimVfpPlotCollection : public caf::PdmObject, public RimTypedPlotCollectio public: RimVfpPlotCollection(); - RimVfpPlot* createAndAppendPlots( RimVfpTableData* tableData ); - RimVfpPlot* plotForTableNumber( int tableNumber ) const; + RimVfpPlot* createAndAppendPlots( RimVfpTable* tableData ); + RimVfpPlot* plotForTableNumber( int tableNumber ) const; + RimCustomVfpPlot* createAndAppendPlots( RimVfpTable* mainDataSource, std::vector tableData ); void addPlot( RimVfpPlot* newPlot ) override; std::vector plots() const override; @@ -55,9 +56,7 @@ class RimVfpPlotCollection : public caf::PdmObject, public RimTypedPlotCollectio void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; - void addDeck( RimVfpDeck* deck ); - private: - caf::PdmChildArrayField m_vfpPlots; - caf::PdmChildArrayField m_vfpDecks; + caf::PdmChildArrayField m_vfpPlots; + caf::PdmChildArrayField m_customVfpPlots; }; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTable.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTable.cpp new file mode 100644 index 0000000000..0cefc9c8e7 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTable.cpp @@ -0,0 +1,146 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimVfpTable.h" + +#include "cafCmdFeatureMenuBuilder.h" + +CAF_PDM_SOURCE_INIT( RimVfpTable, "RimVfpTable" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpTable::RimVfpTable() +{ + CAF_PDM_InitObject( "VFP Table", ":/VfpPlot.svg" ); + + CAF_PDM_InitFieldNoDefault( &m_dataSource, "DataSource", "Data Source" ); + CAF_PDM_InitFieldNoDefault( &m_tableNumber, "TableNumber", "Table Number" ); + CAF_PDM_InitFieldNoDefault( &m_tableType, "TableType", "Table Type" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpTable::setDataSource( RimVfpTableData* dataSource ) +{ + m_dataSource = dataSource; + + updateObjectName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpTable::setTableNumber( int tableNumber ) +{ + m_tableNumber = tableNumber; + + updateObjectName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpTable::setTableType( RimVfpDefines::TableType tableType ) +{ + m_tableType = tableType; + + updateObjectName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpTable::ensureDataIsImported() +{ + if ( m_dataSource ) + { + m_dataSource->ensureDataIsImported(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpTableData* RimVfpTable::dataSource() const +{ + return m_dataSource; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimVfpTable::tableNumber() const +{ + return m_tableNumber; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpDefines::TableType RimVfpTable::tableType() const +{ + return m_tableType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpTable::updateObjectName() +{ + if ( m_dataSource ) + { + QString name; + + if ( m_tableNumber >= 0 ) + { + if ( !name.isEmpty() ) name += " - "; + name += QString( "Table %1" ).arg( m_tableNumber ); + } + + if ( m_tableType() == RimVfpDefines::TableType::INJECTION ) + { + if ( !name.isEmpty() ) name += " - "; + name += QString( "INJ" ); + } + else + { + if ( !name.isEmpty() ) name += " - "; + name += QString( "PROD" ); + } + + if ( !name.isEmpty() ) name += " - "; + name += m_dataSource->name(); + + setName( name ); + } + else + { + setName( "VFP Table" ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpTable::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder << "RicNewVfpPlotFeature"; + menuBuilder << "RicNewCustomVfpPlotFeature"; +} diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTable.h similarity index 58% rename from ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.h rename to ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTable.h index d927f2c73a..c034ad034e 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDeck.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTable.h @@ -20,34 +20,39 @@ #include "RimNamedObject.h" -#include "cafFilePath.h" +#include "RimVfpDefines.h" +#include "RimVfpTableData.h" + #include "cafPdmPtrField.h" -class RimVfpPlotCollection; class RimVfpTableData; -class RimVfpPlot; //-------------------------------------------------------------------------------------------------- -/// RimVfpDeck parses a deck file (*.DATA) containing VFP data and creates a collection of VFP plots. +/// //-------------------------------------------------------------------------------------------------- -class RimVfpDeck : public RimNamedObject +class RimVfpTable : public RimNamedObject { CAF_PDM_HEADER_INIT; public: - RimVfpDeck(); + RimVfpTable(); + + RimVfpTableData* dataSource() const; + int tableNumber() const; + RimVfpDefines::TableType tableType() const; - void setDataSource( RimVfpTableData* tableData ); - void loadDataAndUpdate(); + void setDataSource( RimVfpTableData* dataSource ); + void setTableNumber( int tableNumber ); + void setTableType( RimVfpDefines::TableType tableType ); - std::vector plots() const; + void ensureDataIsImported(); private: - void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; - void updateObjectName(); - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + void updateObjectName(); + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; private: - caf::PdmPtrField m_vfpTableData; - caf::PdmChildField m_vfpPlotCollection; + caf::PdmPtrField m_dataSource; + caf::PdmField m_tableNumber; + caf::PdmField> m_tableType; }; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp index 39414adb27..d2161e3f85 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp @@ -22,6 +22,8 @@ #include "RigVfpTables.h" +#include "RimVfpTable.h" + #include "cafCmdFeatureMenuBuilder.h" #include @@ -36,6 +38,8 @@ RimVfpTableData::RimVfpTableData() CAF_PDM_InitObject( "VFP Plot", ":/VfpPlot.svg" ); CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path" ); + CAF_PDM_InitFieldNoDefault( &m_tables, "Tables", "Tables" ); + m_tables.xmlCapability()->disableIO(); setDeletable( true ); } @@ -66,20 +70,42 @@ void RimVfpTableData::ensureDataIsImported() updateObjectName(); + m_tables.deleteChildren(); + m_vfpTables = std::make_unique(); const auto [vfpProdTables, vfpInjTables] = RiaOpmParserTools::extractVfpTablesFromDataFile( m_filePath().path().toStdString() ); for ( const auto& prod : vfpProdTables ) { m_vfpTables->addProductionTable( prod ); + + auto table = new RimVfpTable; + table->setDataSource( this ); + table->setTableNumber( prod.getTableNum() ); + table->setTableType( RimVfpDefines::TableType::PRODUCTION ); + m_tables.push_back( table ); } for ( const auto& inj : vfpInjTables ) { m_vfpTables->addInjectionTable( inj ); + + auto table = new RimVfpTable; + table->setDataSource( this ); + table->setTableNumber( inj.getTableNum() ); + table->setTableType( RimVfpDefines::TableType::INJECTION ); + m_tables.push_back( table ); } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimVfpTableData::tableDataSources() const +{ + return m_tables.childrenByType(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -123,4 +149,5 @@ void RimVfpTableData::updateObjectName() void RimVfpTableData::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const { menuBuilder << "RicNewVfpPlotFeature"; + menuBuilder << "RicNewCustomVfpPlotFeature"; } diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.h index dd3abcb757..724fa822c3 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.h @@ -25,6 +25,7 @@ #include class RigVfpTables; +class RimVfpTable; //-------------------------------------------------------------------------------------------------- /// @@ -40,6 +41,8 @@ class RimVfpTableData : public RimNamedObject QString baseFileName(); void ensureDataIsImported(); + std::vector tableDataSources() const; + size_t tableCount() const; const RigVfpTables* vfpTables() const; @@ -49,7 +52,8 @@ class RimVfpTableData : public RimNamedObject void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; private: - caf::PdmField m_filePath; + caf::PdmField m_filePath; + caf::PdmChildArrayField m_tables; std::unique_ptr m_vfpTables; }; diff --git a/ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp index b0e1fba717..a6844108fc 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp @@ -173,6 +173,130 @@ VfpPlotData RigVfpTables::populatePlotData( int return {}; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +VfpPlotData RigVfpTables::populatePlotData( int tableIndex, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase, + const VfpValueSelection& valueSelection ) const +{ + auto prodTable = productionTable( tableIndex ); + if ( prodTable.has_value() ) + { + return populatePlotData( *prodTable, primaryVariable, familyVariable, interpolatedVariable, flowingPhase, valueSelection ); + } + + auto injContainer = injectionTable( tableIndex ); + if ( injContainer.has_value() ) + { + return populatePlotData( *injContainer, interpolatedVariable, flowingPhase ); + } + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +VfpPlotData RigVfpTables::populatePlotData( const Opm::VFPProdTable& table, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase, + const VfpValueSelection& valueSelection ) +{ + VfpPlotData plotData; + + QString xAxisTitle = axisTitle( primaryVariable, flowingPhase ); + plotData.setXAxisTitle( xAxisTitle ); + + QString yAxisTitle = QString( "%1 %2" ).arg( caf::AppEnum::uiText( interpolatedVariable ), + getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType::THP ) ); + plotData.setYAxisTitle( yAxisTitle ); + + std::vector familyFilterValues = valueSelection.familyValues; + + size_t numFamilyValues = getProductionTableData( table, familyVariable ).size(); + for ( size_t familyIdx = 0; familyIdx < numFamilyValues; familyIdx++ ) + { + std::vector primaryAxisValues = getProductionTableData( table, primaryVariable ); + std::vector familyVariableValues = getProductionTableData( table, familyVariable ); + std::vector thpValues = getProductionTableData( table, RimVfpDefines::ProductionVariableType::THP ); + + // Skip if the family value is not in the filter + auto currentFamilyValue = familyVariableValues[familyIdx]; + auto it = std::find( familyFilterValues.begin(), familyFilterValues.end(), currentFamilyValue ); + if ( it == familyFilterValues.end() ) continue; + + size_t numValues = primaryAxisValues.size(); + std::vector yVals( numValues, 0.0 ); + + for ( size_t y = 0; y < numValues; y++ ) + { + auto currentPrimaryValue = primaryAxisValues[y]; + + size_t wfr_idx = getVariableIndexForValue( table, + RimVfpDefines::ProductionVariableType::WATER_CUT, + primaryVariable, + currentPrimaryValue, + familyVariable, + currentFamilyValue, + valueSelection ); + size_t gfr_idx = getVariableIndexForValue( table, + RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO, + primaryVariable, + currentPrimaryValue, + familyVariable, + currentFamilyValue, + valueSelection ); + size_t alq_idx = getVariableIndexForValue( table, + RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY, + primaryVariable, + currentPrimaryValue, + familyVariable, + currentFamilyValue, + valueSelection ); + size_t flo_idx = getVariableIndexForValue( table, + RimVfpDefines::ProductionVariableType::FLOW_RATE, + primaryVariable, + currentPrimaryValue, + familyVariable, + currentFamilyValue, + valueSelection ); + size_t thp_idx = getVariableIndexForValue( table, + RimVfpDefines::ProductionVariableType::THP, + primaryVariable, + currentPrimaryValue, + familyVariable, + currentFamilyValue, + valueSelection ); + + yVals[y] = table( thp_idx, wfr_idx, gfr_idx, alq_idx, flo_idx ); + if ( interpolatedVariable == RimVfpDefines::InterpolatedVariableType::BHP_THP_DIFF ) + { + yVals[y] -= thpValues[thp_idx]; + } + } + + double familyValue = convertToDisplayUnit( currentFamilyValue, familyVariable ); + QString familyUnit = getDisplayUnit( familyVariable ); + QString familyTitle = QString( "%1: %2 %3" ) + .arg( caf::AppEnum::uiText( familyVariable ) ) + .arg( familyValue ) + .arg( familyUnit ); + + convertToDisplayUnit( yVals, RimVfpDefines::ProductionVariableType::THP ); + convertToDisplayUnit( primaryAxisValues, primaryVariable ); + + plotData.appendCurve( familyTitle, primaryAxisValues, yVals ); + } + + return plotData; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -201,6 +325,89 @@ QString RigVfpTables::asciiDataForTable( int return textForPlotData( plotData ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigVfpTables::findClosestIndices( const std::vector& sourceValues, const std::vector& valuesToMatch ) +{ + std::vector result( sourceValues.size(), -1 ); + + // Returns the indices of the closest values in valuesToMatch for each value in sourceValues. + for ( size_t i = 0; i < sourceValues.size(); ++i ) + { + double minDistance = std::numeric_limits::max(); + int closestIndex = -1; + + for ( size_t j = 0; j < valuesToMatch.size(); ++j ) + { + double distance = std::abs( sourceValues[i] - valuesToMatch[j] ); + if ( distance < minDistance ) + { + minDistance = distance; + closestIndex = static_cast( j ); + } + } + + if ( closestIndex < static_cast( valuesToMatch.size() ) ) + { + result[i] = closestIndex; + } + } + + return result; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigVfpTables::uniqueClosestIndices( const std::vector& sourceValues, const std::vector& valuesToMatch ) +{ + // Find the closest value in valuesForMatch for each value in sourceValues + std::vector distances( sourceValues.size(), std::numeric_limits::max() ); + + auto closestIndices = findClosestIndices( sourceValues, valuesToMatch ); + + for ( size_t i = 0; i < sourceValues.size(); i++ ) + { + if ( closestIndices[i] >= 0 ) + { + distances[i] = std::abs( sourceValues[i] - valuesToMatch[closestIndices[i]] ); + } + } + + while ( std::any_of( distances.begin(), distances.end(), []( double val ) { return val != std::numeric_limits::max(); } ) ) + { + // find the index of the smallest value in minDistance + auto minDistanceIt = std::min_element( distances.begin(), distances.end() ); + if ( minDistanceIt == distances.end() ) + { + break; + } + + auto minDistanceIndex = std::distance( distances.begin(), minDistanceIt ); + auto matchingIndex = closestIndices[minDistanceIndex]; + + if ( matchingIndex > -1 ) + { + // Remove all references to the matching index + for ( size_t i = 0; i < sourceValues.size(); i++ ) + { + if ( i == static_cast( minDistanceIndex ) ) + { + distances[i] = std::numeric_limits::max(); + } + else if ( closestIndices[i] == matchingIndex ) + { + distances[i] = std::numeric_limits::max(); + closestIndices[i] = -1; + } + } + } + } + + return closestIndices; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -385,6 +592,90 @@ size_t RigVfpTables::getVariableIndex( const Opm::VFPProdTable& tab return getProductionTableData( table, targetVariable ).size() - 1; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigVfpTables::getVariableIndexForValue( const Opm::VFPProdTable& table, + RimVfpDefines::ProductionVariableType targetVariable, + RimVfpDefines::ProductionVariableType primaryVariable, + double primaryValue, + RimVfpDefines::ProductionVariableType familyVariable, + double familyValue, + const VfpValueSelection& valueSelection ) +{ + auto findClosestIndex = []( const std::vector& values, const double value ) + { + auto it = std::lower_bound( values.begin(), values.end(), value ); + if ( it == values.begin() ) + { + return (size_t)0; + } + if ( it == values.end() ) + { + return values.size() - 1; + } + if ( *it == value ) + { + return (size_t)std::distance( values.begin(), it ); + } + + auto prev = it - 1; + if ( std::abs( *prev - value ) < std::abs( *it - value ) ) + { + return (size_t)std::distance( values.begin(), prev ); + } + + return (size_t)std::distance( values.begin(), it ); + }; + + if ( targetVariable == primaryVariable ) + { + const auto values = getProductionTableData( table, targetVariable ); + return findClosestIndex( values, primaryValue ); + } + + if ( targetVariable == familyVariable ) + { + const auto values = getProductionTableData( table, targetVariable ); + return findClosestIndex( values, familyValue ); + } + + auto findClosestIndexForVariable = + [&]( RimVfpDefines::ProductionVariableType targetVariable, const double selectedValue, const Opm::VFPProdTable& table ) + { + const auto values = getProductionTableData( table, targetVariable ); + return findClosestIndex( values, selectedValue ); + }; + + switch ( targetVariable ) + { + case RimVfpDefines::ProductionVariableType::WATER_CUT: + { + return findClosestIndexForVariable( targetVariable, valueSelection.waterCutValue, table ); + } + case RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO: + { + return findClosestIndexForVariable( targetVariable, valueSelection.gasLiquidRatioValue, table ); + } + case RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY: + { + return findClosestIndexForVariable( targetVariable, valueSelection.articifialLiftQuantityValue, table ); + } + case RimVfpDefines::ProductionVariableType::FLOW_RATE: + { + return findClosestIndexForVariable( targetVariable, valueSelection.flowRateValue, table ); + } + case RimVfpDefines::ProductionVariableType::THP: + { + return findClosestIndexForVariable( targetVariable, valueSelection.thpValue, table ); + } + default: + break; + } + + return 0; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h index a417ff4837..1d8b7ab390 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h +++ b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h @@ -73,6 +73,17 @@ struct VfpTableSelection int gasLiquidRatioIdx; }; +struct VfpValueSelection +{ + double flowRateValue; + double thpValue; + double articifialLiftQuantityValue; + double waterCutValue; + double gasLiquidRatioValue; + + std::vector familyValues; +}; + struct VfpTableInitialData { bool isProductionTable; @@ -106,6 +117,13 @@ class RigVfpTables RimVfpDefines::FlowingPhaseType flowingPhase, const VfpTableSelection& tableSelection ) const; + VfpPlotData populatePlotData( int tableIndex, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase, + const VfpValueSelection& valueSelection ) const; + QString asciiDataForTable( int tableNumber, RimVfpDefines::ProductionVariableType primaryVariable, RimVfpDefines::ProductionVariableType familyVariable, @@ -113,6 +131,10 @@ class RigVfpTables RimVfpDefines::FlowingPhaseType flowingPhase, const VfpTableSelection& tableSelection ) const; + // Returns the indices of the closest values in valuesToMatch for each value in sourceValues. Returned index value -1 indicates no + // match. A index value is only returned once. + static std::vector uniqueClosestIndices( const std::vector& sourceValues, const std::vector& valuesToMatch ); + private: static VfpPlotData populatePlotData( const Opm::VFPInjTable& table, RimVfpDefines::InterpolatedVariableType interpolatedVariable, @@ -125,6 +147,13 @@ class RigVfpTables RimVfpDefines::FlowingPhaseType flowingPhase, const VfpTableSelection& tableSelection ); + static VfpPlotData populatePlotData( const Opm::VFPProdTable& table, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::FlowingPhaseType flowingPhase, + const VfpValueSelection& valueSelection ); + static QString axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ); static QString getDisplayUnit( RimVfpDefines::ProductionVariableType variableType ); static QString getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType variableType ); @@ -143,6 +172,14 @@ class RigVfpTables size_t familyValue, const VfpTableSelection& tableSelection ); + static size_t getVariableIndexForValue( const Opm::VFPProdTable& table, + RimVfpDefines::ProductionVariableType targetVariable, + RimVfpDefines::ProductionVariableType primaryVariable, + double primaryValue, + RimVfpDefines::ProductionVariableType familyVariable, + double familyValue, + const VfpValueSelection& valueSelection ); + std::optional injectionTable( int tableNumber ) const; std::optional productionTable( int tableNumber ) const; @@ -151,6 +188,9 @@ class RigVfpTables static RimVfpDefines::FlowingWaterFractionType getFlowingWaterFractionType( const Opm::VFPProdTable& table ); static RimVfpDefines::FlowingGasFractionType getFlowingGasFractionType( const Opm::VFPProdTable& table ); + // Returns the indices of the closest values in valuesToMatch for each value in sourceValues. Returned index value -1 indicates no match. + static std::vector findClosestIndices( const std::vector& sourceValues, const std::vector& valuesToMatch ); + private: std::vector m_injectionTables; std::vector m_productionTables; diff --git a/ApplicationLibCode/UnitTests/CMakeLists.txt b/ApplicationLibCode/UnitTests/CMakeLists.txt index 7a484008a5..c6cb4e19be 100644 --- a/ApplicationLibCode/UnitTests/CMakeLists.txt +++ b/ApplicationLibCode/UnitTests/CMakeLists.txt @@ -104,6 +104,7 @@ set(SOURCE_UNITTEST_FILES ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifParquetReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellPathReader-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigVfpTables-Test.cpp ) if(RESINSIGHT_ENABLE_GRPC) diff --git a/ApplicationLibCode/UnitTests/RigVfpTables-Test.cpp b/ApplicationLibCode/UnitTests/RigVfpTables-Test.cpp new file mode 100644 index 0000000000..778c32f3ef --- /dev/null +++ b/ApplicationLibCode/UnitTests/RigVfpTables-Test.cpp @@ -0,0 +1,83 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "gtest/gtest.h" + +#include "RigVfpTables.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RigVfpTables, MatchingValues ) +{ + std::vector sourceValues = { 1.0, 2.0, 3.0, 4.0, 5.0 }; + std::vector valuesForMatch = { 1.0, 2.0, 3.0, 4.0, 5.0 }; + std::vector closestIndices = RigVfpTables::uniqueClosestIndices( sourceValues, valuesForMatch ); + for ( int i = 0; i < sourceValues.size(); i++ ) + { + EXPECT_EQ( i, closestIndices[i] ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RigVfpTables, MoreDestinationValues ) +{ + std::vector sourceValues = { 1.0, 2.0, 3.0, 4.0, 5.0 }; + std::vector valuesForMatch = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; + std::vector closestIndices = RigVfpTables::uniqueClosestIndices( sourceValues, valuesForMatch ); + for ( int i = 0; i < sourceValues.size(); i++ ) + { + EXPECT_EQ( i, closestIndices[i] ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RigVfpTables, MatchInBetweenValues ) +{ + std::vector sourceValues = { 1.0, 2.0, 3.0, 4.0, 5.0 }; + std::vector valuesForMatch = { 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0 }; + std::vector closestIndices = RigVfpTables::uniqueClosestIndices( sourceValues, valuesForMatch ); + + EXPECT_EQ( 5, (int)closestIndices.size() ); + + EXPECT_EQ( 0, closestIndices[0] ); + EXPECT_EQ( 2, closestIndices[1] ); + EXPECT_EQ( 3, closestIndices[2] ); + EXPECT_EQ( 4, closestIndices[3] ); + EXPECT_EQ( 5, closestIndices[4] ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RigVfpTables, SingleValue ) +{ + std::vector sourceValues = { 1.0, 2.0, 3.0 }; + std::vector valuesForMatch = { 2.1 }; + std::vector closestIndices = RigVfpTables::uniqueClosestIndices( sourceValues, valuesForMatch ); + + EXPECT_EQ( 3, (int)closestIndices.size() ); + + EXPECT_EQ( -1, closestIndices[0] ); + EXPECT_EQ( 0, closestIndices[1] ); + EXPECT_EQ( -1, closestIndices[2] ); +} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrField.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrField.h index 061338715b..2bd170c37f 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrField.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrField.h @@ -39,10 +39,7 @@ class PdmPtrField : public PdmValueField public: typedef PdmPointer FieldDataType; - PdmPtrField() - : m_isResolved( false ) - { - } + PdmPtrField() {} explicit PdmPtrField( const DataTypePtr& fieldValue ); ~PdmPtrField() override; @@ -81,7 +78,6 @@ class PdmPtrField : public PdmValueField // Resolving QString m_referenceString; - bool m_isResolved; }; } // End of namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrField.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrField.inl index ca5d78b0f1..2f54ba5736 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrField.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrField.inl @@ -29,7 +29,6 @@ void caf::PdmPtrField::setFromQVariant( const QVariant& variant ) template caf::PdmPtrField::PdmPtrField( const DataTypePtr& fieldValue ) { - m_isResolved = true; m_fieldValue = fieldValue; if ( m_fieldValue != NULL ) m_fieldValue->addReferencingPtrField( this ); } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.h index 0b66092345..f86517665c 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.h @@ -54,7 +54,6 @@ class PdmFieldXmlCap> : public PdmXmlFieldHandle { m_field = field; m_dataTypeName = DataType::classKeywordStatic(); - m_isResolved = false; m_referenceString = ""; } @@ -70,7 +69,6 @@ class PdmFieldXmlCap> : public PdmXmlFieldHandle // Resolving QString m_referenceString; - bool m_isResolved; }; template @@ -87,7 +85,6 @@ class PdmFieldXmlCap> : public PdmXmlFieldHandle { m_field = field; m_dataTypeName = DataType::classKeywordStatic(); - m_isResolved = false; m_referenceString = ""; } @@ -103,7 +100,6 @@ class PdmFieldXmlCap> : public PdmXmlFieldHandle // Resolving QString m_referenceString; - bool m_isResolved; }; template diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl index 7027f4a642..ee1c486a4d 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl @@ -90,7 +90,6 @@ void caf::PdmFieldXmlCap>::readFieldData( QXmlStream // // and then we need a traversal of the object hierarchy to resolve all references before initAfterRead. - m_isResolved = false; m_referenceString = dataString; m_field->setRawPtr( NULL ); } @@ -117,12 +116,11 @@ void caf::PdmFieldXmlCap>::writeFieldData( QXmlStrea template bool caf::PdmFieldXmlCap>::resolveReferences() { - if ( m_isResolved ) return true; + if ( m_field->m_fieldValue.rawPtr() != nullptr ) return true; if ( m_referenceString.isEmpty() ) return true; PdmObjectHandle* objHandle = PdmReferenceHelper::objectFromFieldReference( this->fieldHandle(), m_referenceString ); m_field->setRawPtr( objHandle ); - m_isResolved = true; return objHandle != nullptr; } @@ -163,7 +161,6 @@ void caf::PdmFieldXmlCap>::readFieldData( QXmlS // It must be done when we know that the complete hierarchy is read and created, // and then we need a traversal of the object hierarchy to resolve all references before initAfterRead. - m_isResolved = false; m_referenceString = dataString; m_field->clearWithoutDelete(); } @@ -193,7 +190,6 @@ void caf::PdmFieldXmlCap>::writeFieldData( QXml template bool caf::PdmFieldXmlCap>::resolveReferences() { - if ( m_isResolved ) return true; if ( m_referenceString.isEmpty() ) return true; m_field->clearWithoutDelete(); @@ -211,8 +207,6 @@ bool caf::PdmFieldXmlCap>::resolveReferences() m_field->m_pointers.back().setRawPtr( objHandle ); } - m_isResolved = true; - return foundValidObjectFromString; } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp index b41d07ba89..10821807a2 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp @@ -197,7 +197,11 @@ TEST( AdvancedObjectTest, FieldWrite ) a->readObjectFromXmlString( serializedString, caf::PdmDefaultObjectFactory::instance() ); a->xmlCapability()->resolveReferencesRecursively(); + ASSERT_TRUE( a->m_pointerToItem() == container->m_items[1] ); + // Set pointer to null. The reference string is still valid, and the resolving will restore the pointer. + a->m_pointerToItem = nullptr; + a->xmlCapability()->resolveReferencesRecursively(); ASSERT_TRUE( a->m_pointerToItem() == container->m_items[1] ); } } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp index 8f64b77103..8c361eb6c2 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp @@ -551,11 +551,18 @@ void PdmUiTreeSelectionEditor::slotToggleAll() { if ( m_toggleAllCheckBox->isChecked() ) { - checkAllItems(); + checkAllItemsMatchingFilter(); return; } - unCheckAllItems(); + if ( m_textFilterLineEdit->text().isEmpty() ) + { + m_model->unselectAllItems(); + } + else + { + unCheckAllItemsMatchingFilter(); + } // Apply integer filtering if the model contains only integers if ( hasOnlyIntegers( m_model ) ) @@ -788,7 +795,7 @@ void PdmUiTreeSelectionEditor::currentChanged( const QModelIndex& current ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiTreeSelectionEditor::checkAllItems() +void PdmUiTreeSelectionEditor::checkAllItemsMatchingFilter() { QModelIndexList indices = allVisibleSourceModelIndices(); @@ -798,7 +805,7 @@ void PdmUiTreeSelectionEditor::checkAllItems() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiTreeSelectionEditor::unCheckAllItems() +void PdmUiTreeSelectionEditor::unCheckAllItemsMatchingFilter() { QModelIndexList indices = allVisibleSourceModelIndices(); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h index 206411ecd5..06abb8d84a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h @@ -127,8 +127,8 @@ private slots: void setCheckedStateOfSelected( bool checked ); void setCheckedStateForSubItemsOfSelected( bool checked ); - void checkAllItems(); - void unCheckAllItems(); + void checkAllItemsMatchingFilter(); + void unCheckAllItemsMatchingFilter(); void setCheckedStateForIntegerItemsMatchingFilter(); QModelIndexList allVisibleSourceModelIndices() const; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp index 5963d05a25..236a68c09f 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp @@ -173,6 +173,14 @@ void caf::PdmUiTreeSelectionQModel::invertCheckedStateForItems( const QModelInde PdmUiCommandSystemProxy::instance()->setUiValueToField( m_uiFieldHandle->uiField(), fieldValueSelection ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::PdmUiTreeSelectionQModel::unselectAllItems() +{ + PdmUiCommandSystemProxy::instance()->setUiValueToField( m_uiFieldHandle->uiField(), {} ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h index f7da22b1c9..3def9b3b76 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h @@ -63,6 +63,7 @@ class PdmUiTreeSelectionQModel : public QAbstractItemModel void setCheckedStateForItems( const QModelIndexList& indices, bool checked ); void invertCheckedStateForItems( const QModelIndexList& indices ); + void unselectAllItems(); void enableSingleSelectionMode( bool enable ); From 4f5a0d8bdf11064baa99a4a6f29e890954819f9b Mon Sep 17 00:00:00 2001 From: magnesj <1793152+magnesj@users.noreply.github.com> Date: Thu, 30 May 2024 02:02:09 +0000 Subject: [PATCH 097/332] Fixes by clang-tidy --- ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp index 85ee5c69f3..25869712e0 100644 --- a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp @@ -126,12 +126,7 @@ bool RicDeleteSubItemsFeature::hasDeletableSubItems( caf::PdmUiItem* uiItem ) } } - if ( dynamic_cast( uiItem ) ) - { - return true; - } - - return false; + return dynamic_cast( uiItem ) != nullptr; } //-------------------------------------------------------------------------------------------------- From 1e07b239d1d9f58904ae0f0cc64c8fdcbec54be3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 31 May 2024 08:56:29 +0200 Subject: [PATCH 098/332] Simplify configuration and use of vcpkg * Simplify configuration and use of vcpkg * Use 22.04 * Set and use BUILD_TYPE = Release * Use -DVCPKG_BUILD_TYPE=release --- .github/workflows/ResInsightWithCache.yml | 91 ++++++------- ApplicationLibCode/CMakeLists.txt | 7 - CMakeLists.txt | 16 --- GrpcInterface/CMakeLists.txt | 4 - cmake/AutoVcpkg.cmake | 148 ---------------------- cmake/vcpkg-bootstrap.cmake | 27 ---- vcpkg-configuration.json | 14 ++ vcpkg.json | 9 ++ vcpkg_x64-linux.txt | 7 - vcpkg_x64-osx.txt | 7 - vcpkg_x64-windows.txt | 7 - 11 files changed, 62 insertions(+), 275 deletions(-) delete mode 100644 cmake/AutoVcpkg.cmake delete mode 100644 cmake/vcpkg-bootstrap.cmake create mode 100644 vcpkg-configuration.json create mode 100644 vcpkg.json delete mode 100644 vcpkg_x64-linux.txt delete mode 100644 vcpkg_x64-osx.txt delete mode 100644 vcpkg_x64-windows.txt diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index ee9cd8bc02..ad15e227b9 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -12,6 +12,7 @@ env: BUILDCACHE_VERSION: 0.27.6 BUILDCACHE_DIR: ${{ github.workspace }}/buildcache_dir BUILDCACHE_ACCURACY: SLOPPY + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" concurrency: group: build-${{ github.event.pull_request.number || github.ref }} @@ -23,45 +24,43 @@ jobs: strategy: fail-fast: false matrix: + build_type: [Release] config: - { name: "Windows Latest MSVC", os: windows-2022, cc: "cl", cxx: "cl", - vcpkg-response-file: vcpkg_x64-windows.txt, - vcpkg-triplet: x64-windows, build-python-module: true, execute-unit-tests: true, execute-pytests: true, unity-build: true, publish-to-pypi: false, + vcpkg-bootstrap: bootstrap-vcpkg.bat, } - { - name: "Ubuntu 20.04 gcc", - os: ubuntu-20.04, + name: "Ubuntu 22.04 gcc", + os: ubuntu-22.04, cc: "gcc", cxx: "g++", - vcpkg-response-file: vcpkg_x64-linux.txt, - vcpkg-triplet: x64-linux, build-python-module: true, execute-unit-tests: true, execute-pytests: true, unity-build: false, publish-to-pypi: true, + vcpkg-bootstrap: bootstrap-vcpkg.sh, } - { name: "Ubuntu 22.04 clang-16", os: ubuntu-22.04, cc: "clang-16", cxx: "clang++-16", - vcpkg-response-file: vcpkg_x64-linux.txt, - vcpkg-triplet: x64-linux, build-python-module: true, execute-unit-tests: true, execute-pytests: false, unity-build: false, publish-to-pypi: false, + vcpkg-bootstrap: bootstrap-vcpkg.sh, } steps: - name: Checkout @@ -177,55 +176,43 @@ jobs: cache: true modules: "qtnetworkauth" - - name: Restore from cache and install vcpkg - uses: lukka/run-vcpkg@v7 - id: runvcpkg + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 with: - vcpkgArguments: "@${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}" - vcpkgDirectory: - "${{ github.workspace }}/ThirdParty/vcpkg" - appendedCacheKey: ${{ matrix.config.os }}-${{ matrix.config.cxx }}-cache-key-v2 + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - - name: Configure - shell: cmake -P {0} + - name: vcpkg bootstrap run: | - set(ENV{CC} ${{ matrix.config.cc }}) - set(ENV{CXX} ${{ matrix.config.cxx }}) - - execute_process( - COMMAND cmake - -S . - -B cmakebuild - -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} - -D CMAKE_INSTALL_PREFIX=cmakebuild/install - -D RESINSIGHT_QT5_BUNDLE_LIBRARIES=true - -D RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true - -D RESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true - -D RESINSIGHT_ENABLE_PRECOMPILED_HEADERS=false - -D RESINSIGHT_ENABLE_UNITY_BUILD=${{ matrix.config.unity-build }} - -D RESINSIGHT_ENABLE_GRPC=${{ matrix.config.build-python-module }} - -D RESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} - -D RESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE=true - -D RESINSIGHT_ENABLE_HDF5=false - -D RESINSIGHT_BUILD_LIBS_FROM_SOURCE=false - -D CMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake - -G Ninja - RESULT_VARIABLE result - ) - if (NOT result EQUAL 0) - message(FATAL_ERROR "Bad exit status") - endif() + ThirdParty/vcpkg/${{ matrix.config.vcpkg-bootstrap }} + + - name: Configure + shell: bash + env: + CC: ${{ matrix.config.cc }} + CXX: ${{ matrix.config.cxx }} + run: > + cmake -S . -B cmakebuild + -DVCPKG_BUILD_TYPE=release + -DCMAKE_INSTALL_PREFIX=cmakebuild/install + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DRESINSIGHT_QT5_BUNDLE_LIBRARIES=true + -DRESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true + -DRESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true + -DRESINSIGHT_ENABLE_PRECOMPILED_HEADERS=false + -DRESINSIGHT_ENABLE_UNITY_BUILD=${{ matrix.config.unity-build }} + -DRESINSIGHT_ENABLE_GRPC=${{ matrix.config.build-python-module }} + -DRESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} + -DRESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE=true + -DRESINSIGHT_ENABLE_HDF5=false + -DRESINSIGHT_BUILD_LIBS_FROM_SOURCE=false + -DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake + -G Ninja + - name: Build - shell: cmake -P {0} run: | - set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") - execute_process( - COMMAND cmake --build cmakebuild --target install - RESULT_VARIABLE result - ) - if (NOT result EQUAL 0) - message(FATAL_ERROR "Bad exit status") - endif() + cmake --build cmakebuild --target install - name: Stats for buildcache run: ${{ github.workspace }}/buildcache/bin/buildcache -s diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index f74cf8067b..ceebb33ab9 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -81,13 +81,6 @@ if(MSVC) add_definitions(-D_USE_MATH_DEFINES) endif() -# ############################################################################## -# Eigen -# ############################################################################## -if(RESINSIGHT_VCPKG_AUTO_INSTALL) - vcpkg_install(eigen3) -endif() - find_package(Eigen3 REQUIRED) # ############################################################################## diff --git a/CMakeLists.txt b/CMakeLists.txt index 58c8c0ce24..2e44d52a41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,16 +38,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") option(RESINSIGHT_BUNDLE_TESTMODELS "Copy TestModels into the installation" OFF) mark_as_advanced(RESINSIGHT_BUNDLE_TESTMODELS) -option(RESINSIGHT_VCPKG_AUTO_INSTALL - "Automatically download build pre-requisites with VCPKG" OFF -) -mark_as_advanced(RESINSIGHT_VCPKG_AUTO_INSTALL) - -if(RESINSIGHT_VCPKG_AUTO_INSTALL) - include(AutoVcpkg) - set(AUTO_VCPKG_ROOT "${CMAKE_SOURCE_DIR}/ThirdParty/vcpkg") -endif() - set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -436,12 +426,6 @@ endif() # MSVC # Opm # ############################################################################## -if(RESINSIGHT_VCPKG_AUTO_INSTALL) - vcpkg_install(boost-filesystem) - vcpkg_install(boost-spirit) - include(${CMAKE_TOOLCHAIN_FILE}) -endif() - add_subdirectory(ThirdParty/custom-opm-flowdiagnostics) add_subdirectory(ThirdParty/custom-opm-flowdiag-app) diff --git a/GrpcInterface/CMakeLists.txt b/GrpcInterface/CMakeLists.txt index 3747acc6e5..6b296dd382 100644 --- a/GrpcInterface/CMakeLists.txt +++ b/GrpcInterface/CMakeLists.txt @@ -3,10 +3,6 @@ project(GrpcInterface) message(STATUS "GRPC enabled") add_definitions(-DENABLE_GRPC) -if(RESINSIGHT_VCPKG_AUTO_INSTALL) - vcpkg_install(grpc) -endif() - set(CMAKE_UNITY_BUILD false) set(RESINSIGHT_GRPC_PYTHON_EXECUTABLE "" diff --git a/cmake/AutoVcpkg.cmake b/cmake/AutoVcpkg.cmake deleted file mode 100644 index 75ae0d0117..0000000000 --- a/cmake/AutoVcpkg.cmake +++ /dev/null @@ -1,148 +0,0 @@ -# ~~~ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ~~~ - -# -# -# AUTO_VCPKG_GIT_TAG - which vcpkg tag to clone if building ourselves -# -# AUTO_VCPKG_ROOT - root where `vcpkg` is (or should be installed) -# NOTE: it should be fullpath to the place otherwise it will be relative to CMAKE_SOURCE_DIR -# - -set(AUTO_VCPKG_GIT_REPOSITORY "https://github.com/Microsoft/vcpkg.git") -if (DEFINED AUTO_VCPKG_GIT_TAG) - set(USE_AUTO_VCPKG_GIT_TAG "GIT_TAG ${AUTO_VCPKG_GIT_TAG}") -endif () - -function (vcpkg_setroot) - if (DEFINED AUTO_VCPKG_ROOT) - return() - endif () - set(AUTO_VCPKG_ROOT "${CMAKE_BINARY_DIR}/vcpkg" CACHE STRING "") - set(ENV{VCPKG_ROOT} "${AUTO_VCPKG_ROOT}") - message(STATUS "AutoVcpkg: using vcpkg root ${AUTO_VCPKG_ROOT}") -endfunction() - -function (vcpkg_download) - vcpkg_setroot() - set(vcpkg_download_contents [===[ -cmake_minimum_required(VERSION 3.5) -project(vcpkg-download) - -include(ExternalProject) -ExternalProject_Add(vcpkg - GIT_REPOSITORY @AUTO_VCPKG_GIT_REPOSITORY@ - @USE_AUTO_VCPKG_GIT_TAG@ - GIT_SHALLOW ON - SOURCE_DIR @AUTO_VCPKG_ROOT@ - PATCH_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_INSTALL ON) - ]===]) - get_filename_component(AUTO_VCPKG_ROOT_FULL ${AUTO_VCPKG_ROOT} ABSOLUTE) - string(REPLACE "@AUTO_VCPKG_GIT_REPOSITORY@" "${AUTO_VCPKG_GIT_REPOSITORY}" vcpkg_download_contents "${vcpkg_download_contents}") - string(REPLACE "@USE_AUTO_VCPKG_GIT_TAG@" "${USE_AUTO_VCPKG_GIT_TAG}" vcpkg_download_contents "${vcpkg_download_contents}") - string(REPLACE "@AUTO_VCPKG_ROOT@" "${AUTO_VCPKG_ROOT_FULL}" vcpkg_download_contents "${vcpkg_download_contents}") - if(CCACHE_BIN) - set(CMAKE_COMPILER_WRAPPER "-DCMAKE_CXX_COMPILER_LAUNCHER=${CCACHE_BIN} -DCMAKE_C_COMPILER_LAUNCHER=${CCACHE_BIN}") - endif() - file(WRITE "${CMAKE_BINARY_DIR}/vcpkg-download/CMakeLists.txt" "${vcpkg_download_contents}") - execute_process(COMMAND "${CMAKE_COMMAND}" - "-H${CMAKE_BINARY_DIR}/vcpkg-download" - "-B${CMAKE_BINARY_DIR}/vcpkg-download" - ${CMAKE_COMPILER_WRAPPER} - ${USE_AUTO_VCPKG_TRIPLET}) - execute_process(COMMAND "${CMAKE_COMMAND}" - "--build" "${CMAKE_BINARY_DIR}/vcpkg-download") -endfunction () - -function (vcpkg_bootstrap) - find_program(AUTO_VCPKG_EXECUTABLE - vcpkg PATHS ${AUTO_VCPKG_ROOT}) - if (NOT AUTO_VCPKG_EXECUTABLE) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/cmake/vcpkg-bootstrap.cmake" "${AUTO_VCPKG_ROOT}") - execute_process(COMMAND ${CMAKE_COMMAND} -P "${AUTO_VCPKG_ROOT}/vcpkg-bootstrap.cmake" - WORKING_DIRECTORY ${AUTO_VCPKG_ROOT}) - endif () -endfunction () - -function (vcpkg_configure AUTO_VCPKG_BOOTSTRAP_SKIP) - if (AUTO_VCPKG_EXECUTABLE AND DEFINED AUTO_VCPKG_ROOT) - set(CMAKE_TOOLCHAIN_FILE - "${AUTO_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") - return() - endif () - - message(STATUS "AutoVcpkg: searching for vcpkg in ${AUTO_VCPKG_ROOT}") - find_program(AUTO_VCPKG_EXECUTABLE - vcpkg vcpkg.exe PATHS ${AUTO_VCPKG_ROOT}) - if (NOT AUTO_VCPKG_EXECUTABLE) - message(STATUS "AutoVcpkg: vcpkg not found, bootstrapping a new installation") - if (NOT AUTO_VCPKG_BOOTSTRAP_SKIP) - vcpkg_download() - vcpkg_bootstrap() - endif () - # Validate now we have something - find_program(AUTO_VCPKG_EXECUTABLE - vcpkg vcpkg.exe PATHS ${AUTO_VCPKG_ROOT}) - if (NOT AUTO_VCPKG_EXECUTABLE) - message(FATAL_ERROR "AutoVcpkg: Cannot find vcpkg executable") - endif () - endif () - mark_as_advanced(AUTO_VCPKG_ROOT) - mark_as_advanced(AUTO_VCPKG_EXECUTABLE) - set(CMAKE_TOOLCHAIN_FILE - "${AUTO_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") -endfunction () - -function (vcpkg_install) - cmake_parse_arguments(_vcpkg_install "" "TRIPLET" "" ${ARGN}) - if (NOT ARGN) - message(STATUS "AutoVcpkg: vcpkg_install() called with no packages to install") - return() - endif () - - set(packages ${ARGN}) - if (NOT _vcpkg_install_TRIPLET) - if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Windows)") - if (NOT "${CMAKE_GENERATOR}" MATCHES "(Win32|IA32|x86)") - set(_vcpkg_install_TRIPLET "x64-windows") - else () - set(_vcpkg_install_TRIPLET "x86-windows") - endif () - #set(USE_AUTO_VCPKG_TRIPLET "-DVCPKG_TARGET_TRIPLET=${_vcpkg_install_TRIPLET}") - #set(VCPKG_TARGET_TRIPLET ${_vcpkg_install_TRIPLET}) - list(TRANSFORM packages APPEND ":${_vcpkg_install_TRIPLET}") - endif () - endif () - string(CONCAT join ${packages}) - string(TOLOWER "${AUTO_VCPKG_GIT_TAG}:${packages}" packages_cache) - message(STATUS "AutoVcpkg: vcpkg packages: ${packages}") - - vcpkg_setroot() - if (NOT EXISTS "${AUTO_VCPKG_ROOT}/vcpkg" OR NOT EXISTS "${AUTO_VCPKG_ROOT}/.vcpkg-root") - vcpkg_configure(off) - else () - vcpkg_configure(on) # skip bootstrap - endif () - - message(STATUS "AutoVcpkg: vcpkg_install() called to install: ${join}") - execute_process (COMMAND "${AUTO_VCPKG_EXECUTABLE}" "install" ${packages}) -endfunction () \ No newline at end of file diff --git a/cmake/vcpkg-bootstrap.cmake b/cmake/vcpkg-bootstrap.cmake deleted file mode 100644 index 0656735fff..0000000000 --- a/cmake/vcpkg-bootstrap.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# ~~~ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ~~~ - -find_program(VCPKG_EXECUTABLE - vcpkg PATHS "${CMAKE_CURRENT_LIST_DIR}") -if (NOT VCPKG_EXECUTABLE) - if (WIN32) - execute_process(COMMAND "${CMAKE_CURRENT_LIST_DIR}/bootstrap-vcpkg.bat" -disableMetrics - WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}") - else () - execute_process(COMMAND "${CMAKE_CURRENT_LIST_DIR}/bootstrap-vcpkg.sh" -disableMetrics - WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}") - endif () -endif () \ No newline at end of file diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000000..7b797ccaa1 --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,14 @@ +{ + "default-registry": { + "kind": "git", + "baseline": "a42af01b72c28a8e1d7b48107b33e4f286a55ef6", + "repository": "https://github.com/microsoft/vcpkg" + }, + "registries": [ + { + "kind": "artifact", + "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", + "name": "microsoft" + } + ] +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000000..abe2eb3446 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,9 @@ +{ + "dependencies": [ + "arrow", + "boost-filesystem", + "boost-spirit", + "eigen3", + "grpc" + ] +} diff --git a/vcpkg_x64-linux.txt b/vcpkg_x64-linux.txt deleted file mode 100644 index 57e54939ff..0000000000 --- a/vcpkg_x64-linux.txt +++ /dev/null @@ -1,7 +0,0 @@ -grpc -boost-filesystem -boost-spirit -eigen3 -arrow ---triplet -x64-linux diff --git a/vcpkg_x64-osx.txt b/vcpkg_x64-osx.txt deleted file mode 100644 index fbaa9aaabf..0000000000 --- a/vcpkg_x64-osx.txt +++ /dev/null @@ -1,7 +0,0 @@ -grpc -boost-filesystem -boost-spirit -eigen3 -arrow ---triplet -x64-osx diff --git a/vcpkg_x64-windows.txt b/vcpkg_x64-windows.txt deleted file mode 100644 index fc191ee234..0000000000 --- a/vcpkg_x64-windows.txt +++ /dev/null @@ -1,7 +0,0 @@ -grpc -boost-filesystem -boost-spirit -eigen3 -arrow ---triplet -x64-windows From 3f535e5b62b80dde6e9db1590417797f05041f54 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 1 Jun 2024 14:40:20 +0200 Subject: [PATCH 099/332] Add bundling of QtNetworkAuth --- ApplicationExeCode/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationExeCode/CMakeLists.txt b/ApplicationExeCode/CMakeLists.txt index 6a7f38f147..8b9f4a5955 100644 --- a/ApplicationExeCode/CMakeLists.txt +++ b/ApplicationExeCode/CMakeLists.txt @@ -28,6 +28,7 @@ if(Qt5Core_FOUND) Gui OpenGL Network + NetworkAuth Widgets Xml Concurrent @@ -40,6 +41,7 @@ if(Qt5Core_FOUND) Qt5::Core Qt5::Gui Qt5::Network + Qt5::NetworkAuth Qt5::OpenGL Qt5::Widgets Qt5::Xml From 1c899df06341318a7a2bab32980ebe601716cf9d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 3 Jun 2024 07:46:58 +0200 Subject: [PATCH 100/332] Octave: Change default port number and add custom port number to Preferences --- .../Application/RiaApplication.cpp | 15 +++++++++- .../Application/RiaPreferences.cpp | 28 +++++++++++++++++-- .../Application/RiaPreferences.h | 13 +++++++-- .../SocketInterface/RiaSocketServer.cpp | 13 +++++++-- .../SocketInterface/RiaSocketServerDefines.h | 12 ++++++++ OctavePlugin/riGetActiveCellCenters.cpp | 2 +- OctavePlugin/riGetActiveCellCorners.cpp | 2 +- OctavePlugin/riGetActiveCellInfo.cpp | 2 +- OctavePlugin/riGetActiveCellProperty.cpp | 2 +- OctavePlugin/riGetCaseGroups.cpp | 2 +- OctavePlugin/riGetCases.cpp | 2 +- OctavePlugin/riGetCellCenters.cpp | 2 +- OctavePlugin/riGetCellCorners.cpp | 2 +- OctavePlugin/riGetCoarseningInfo.cpp | 2 +- OctavePlugin/riGetCurrentCase.cpp | 2 +- OctavePlugin/riGetDynamicNNCValues.cpp | 2 +- OctavePlugin/riGetGridDimensions.cpp | 2 +- OctavePlugin/riGetGridProperty.cpp | 2 +- .../riGetGridPropertyForSelectedCells.cpp | 2 +- OctavePlugin/riGetMainGridDimensions.cpp | 4 +-- OctavePlugin/riGetNNCConnections.cpp | 2 +- OctavePlugin/riGetNNCPropertyNames.cpp | 2 +- OctavePlugin/riGetPropertyNames.cpp | 2 +- OctavePlugin/riGetSelectedCases.cpp | 2 +- OctavePlugin/riGetSelectedCells.cpp | 2 +- OctavePlugin/riGetStaticNNCValues.cpp | 2 +- OctavePlugin/riGetTimeStepDates.cpp | 2 +- OctavePlugin/riGetTimeStepDays.cpp | 2 +- OctavePlugin/riGetWellCells.cpp | 2 +- OctavePlugin/riGetWellNames.cpp | 2 +- OctavePlugin/riGetWellStatus.cpp | 2 +- OctavePlugin/riSetActiveCellProperty.cpp | 2 +- OctavePlugin/riSetGridProperty.cpp | 2 +- OctavePlugin/riSetNNCProperty.cpp | 2 +- OctavePlugin/riSettings.h | 11 ++++++++ 35 files changed, 113 insertions(+), 39 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index b0fcc129a9..f40f2ae5c6 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -1076,7 +1076,7 @@ QStringList RiaApplication::octaveArguments() const arguments.append( "--path" ); arguments << QApplication::applicationDirPath(); - if ( !m_preferences->octaveShowHeaderInfoWhenExecutingScripts ) + if ( !m_preferences->octaveShowHeaderInfoWhenExecutingScripts() ) { // -q // Don't print the usual greeting and version message at startup. @@ -1119,6 +1119,19 @@ QProcessEnvironment RiaApplication::octaveProcessEnvironment() const penv.insert( "LD_LIBRARY_PATH", ldPath ); #endif + // Set the environment variable for the port number used by Octave plugins + // The plugins can access the port number using riOctavePlugin::portNumber() + // If the port number is not set in preferences, the plugins will use the default port number + const QString key = QString::fromStdString( riOctavePlugin::portNumberKey() ); + if ( !m_preferences->octavePortNumber().isEmpty() ) + { + penv.insert( key, m_preferences->octavePortNumber() ); + } + else + { + penv.remove( key ); + } + return penv; } diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index 9e6807d30d..6174a0d9df 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -118,11 +118,14 @@ RiaPreferences::RiaPreferences() m_octaveExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_octaveExecutable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitField( &octaveShowHeaderInfoWhenExecutingScripts, + CAF_PDM_InitField( &m_octaveShowHeaderInfoWhenExecutingScripts, "octaveShowHeaderInfoWhenExecutingScripts", false, "Show Text Header When Executing Scripts" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &octaveShowHeaderInfoWhenExecutingScripts ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_octaveShowHeaderInfoWhenExecutingScripts ); + + CAF_PDM_InitFieldNoDefault( &m_octavePortNumber, "octavePortNumber", "Octave Port Number" ); + m_octavePortNumber.uiCapability()->setUiEditorTypeName( caf::PdmUiCheckBoxAndTextEditor::uiEditorTypeName() ); CAF_PDM_InitField( &m_pythonExecutable, "pythonExecutable", QString( "python" ), "Python Executable Location" ); m_pythonExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); @@ -449,7 +452,8 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& { caf::PdmUiGroup* octaveGroup = uiOrdering.addNewGroup( "Octave" ); octaveGroup->add( &m_octaveExecutable ); - octaveGroup->add( &octaveShowHeaderInfoWhenExecutingScripts ); + octaveGroup->add( &m_octaveShowHeaderInfoWhenExecutingScripts ); + octaveGroup->add( &m_octavePortNumber ); #ifdef ENABLE_GRPC caf::PdmUiGroup* pythonGroup = uiOrdering.addNewGroup( "Python" ); @@ -1008,6 +1012,24 @@ QString RiaPreferences::octaveExecutable() const return m_octaveExecutable().trimmed(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferences::octaveShowHeaderInfoWhenExecutingScripts() const +{ + return m_octaveShowHeaderInfoWhenExecutingScripts(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferences::octavePortNumber() const +{ + if ( m_octavePortNumber().first ) return m_octavePortNumber().second; + + return {}; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferences.h b/ApplicationLibCode/Application/RiaPreferences.h index 5ecf7f78b3..2ff2e814a0 100644 --- a/ApplicationLibCode/Application/RiaPreferences.h +++ b/ApplicationLibCode/Application/RiaPreferences.h @@ -119,7 +119,11 @@ class RiaPreferences : public caf::PdmObject // Script paths QString pythonExecutable() const; + + // Octave QString octaveExecutable() const; + bool octaveShowHeaderInfoWhenExecutingScripts() const; + QString octavePortNumber() const; QString loggerFilename() const; int loggerFlushInterval() const; @@ -137,7 +141,6 @@ class RiaPreferences : public caf::PdmObject caf::PdmField scriptDirectories; caf::PdmField scriptEditorExecutable; - caf::PdmField octaveShowHeaderInfoWhenExecutingScripts; caf::PdmField showPythonDebugInfo; caf::PdmField ssihubAddress; @@ -211,8 +214,12 @@ class RiaPreferences : public caf::PdmObject caf::PdmField m_gridCalculationExpressionFolder; caf::PdmField m_summaryCalculationExpressionFolder; - // Script paths - caf::PdmField m_octaveExecutable; + // Octave + caf::PdmField m_octaveExecutable; + caf::PdmField m_octaveShowHeaderInfoWhenExecutingScripts; + caf::PdmField> m_octavePortNumber; + + // Python caf::PdmField m_pythonExecutable; // Logging diff --git a/ApplicationLibCode/SocketInterface/RiaSocketServer.cpp b/ApplicationLibCode/SocketInterface/RiaSocketServer.cpp index 56d5a76584..c137a9043a 100644 --- a/ApplicationLibCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationLibCode/SocketInterface/RiaSocketServer.cpp @@ -56,15 +56,24 @@ RiaSocketServer::RiaSocketServer( QObject* parent ) m_nextPendingConnectionTimer->setInterval( 100 ); m_nextPendingConnectionTimer->setSingleShot( true ); - if ( !m_tcpServer->listen( QHostAddress::LocalHost, 40001 ) ) + int portNumber = riOctavePlugin::defaultPortNumber; + if ( !RiaPreferences::current()->octavePortNumber().isEmpty() ) { - QString txt = "Disabled communication with Octave due to another ResInsight process running."; + portNumber = RiaPreferences::current()->octavePortNumber().toInt(); + } + + if ( !m_tcpServer->listen( QHostAddress::LocalHost, portNumber ) ) + { + QString txt = QString( "Not able to communicate with Octave plugins. Failed to use port number : %1" ).arg( portNumber ); RiaLogging::warning( txt ); return; } + QString txt = QString( "Octave is using port: %1" ).arg( portNumber ); + RiaLogging::info( txt ); + connect( m_nextPendingConnectionTimer, SIGNAL( timeout() ), this, SLOT( slotNewClientConnection() ) ); connect( m_tcpServer, SIGNAL( newConnection() ), this, SLOT( slotNewClientConnection() ) ); } diff --git a/ApplicationLibCode/SocketInterface/RiaSocketServerDefines.h b/ApplicationLibCode/SocketInterface/RiaSocketServerDefines.h index 0a5a1e997f..e46b264ffe 100644 --- a/ApplicationLibCode/SocketInterface/RiaSocketServerDefines.h +++ b/ApplicationLibCode/SocketInterface/RiaSocketServerDefines.h @@ -16,9 +16,21 @@ // ///////////////////////////////////////////////////////////////////////////////// +#pragma once + #include namespace riOctavePlugin { const int qtDataStreamVersion = QDataStream::Qt_4_0; + +// https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers +// Use a port number in the dynamic/private range (49152-65535) +const int defaultPortNumber = 52025; + +inline const std::string portNumberKey() +{ + return "RESINSIGHT_OCTAVE_PORT_NUMBER"; } + +} // namespace riOctavePlugin diff --git a/OctavePlugin/riGetActiveCellCenters.cpp b/OctavePlugin/riGetActiveCellCenters.cpp index 300cf68d5a..1ef594a30a 100644 --- a/OctavePlugin/riGetActiveCellCenters.cpp +++ b/OctavePlugin/riGetActiveCellCenters.cpp @@ -143,7 +143,7 @@ DEFUN_DLD (riGetActiveCellCenters, args, nargout, } NDArray cellCenterValues; - getActiveCellCenters(cellCenterValues, "127.0.0.1", 40001, caseId, porosityModel.c_str()); + getActiveCellCenters(cellCenterValues, "127.0.0.1", riOctavePlugin::portNumber(), caseId, porosityModel.c_str()); return octave_value(cellCenterValues); } diff --git a/OctavePlugin/riGetActiveCellCorners.cpp b/OctavePlugin/riGetActiveCellCorners.cpp index 1c7ba597da..91e7d2df92 100644 --- a/OctavePlugin/riGetActiveCellCorners.cpp +++ b/OctavePlugin/riGetActiveCellCorners.cpp @@ -143,7 +143,7 @@ DEFUN_DLD (riGetActiveCellCorners, args, nargout, } NDArray cellCornerValues; - getActiveCellCorners(cellCornerValues, "127.0.0.1", 40001, caseId, porosityModel.c_str()); + getActiveCellCorners(cellCornerValues, "127.0.0.1", riOctavePlugin::portNumber(), caseId, porosityModel.c_str()); return octave_value(cellCornerValues); } diff --git a/OctavePlugin/riGetActiveCellInfo.cpp b/OctavePlugin/riGetActiveCellInfo.cpp index 9b8e07744d..ef472d8162 100644 --- a/OctavePlugin/riGetActiveCellInfo.cpp +++ b/OctavePlugin/riGetActiveCellInfo.cpp @@ -158,7 +158,7 @@ DEFUN_DLD (riGetActiveCellInfo, args, nargout, } } - getActiveCellInfo(propertyFrames, "127.0.0.1", 40001, caseId, porosityModel); + getActiveCellInfo(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, porosityModel); return octave_value(propertyFrames); } diff --git a/OctavePlugin/riGetActiveCellProperty.cpp b/OctavePlugin/riGetActiveCellProperty.cpp index 088ab3890f..abdf2a8609 100644 --- a/OctavePlugin/riGetActiveCellProperty.cpp +++ b/OctavePlugin/riGetActiveCellProperty.cpp @@ -193,7 +193,7 @@ DEFUN_DLD (riGetActiveCellProperty, args, nargout, return octave_value_list (); } - getActiveCellProperty(propertyFrames, "127.0.0.1", 40001, caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str()); + getActiveCellProperty(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str()); return octave_value(propertyFrames); } diff --git a/OctavePlugin/riGetCaseGroups.cpp b/OctavePlugin/riGetCaseGroups.cpp index c78cb9c9b1..a3234ef0a6 100644 --- a/OctavePlugin/riGetCaseGroups.cpp +++ b/OctavePlugin/riGetCaseGroups.cpp @@ -103,7 +103,7 @@ DEFUN_DLD (riGetCaseGroups, args, nargout, { std::vector groupNames; std::vector groupIds; - getCaseGroups(groupNames, groupIds, "127.0.0.1", 40001); + getCaseGroups(groupNames, groupIds, "127.0.0.1", riOctavePlugin::portNumber()); size_t groupCount = groupNames.size(); diff --git a/OctavePlugin/riGetCases.cpp b/OctavePlugin/riGetCases.cpp index a3500e0287..7a52dcf932 100644 --- a/OctavePlugin/riGetCases.cpp +++ b/OctavePlugin/riGetCases.cpp @@ -115,7 +115,7 @@ DEFUN_DLD (riGetCases, args, nargout, caseGroupId = argCaseId; } - getCases(caseIds, caseNames, caseTypes, caseGroupIds, caseGroupId, "127.0.0.1", 40001); + getCases(caseIds, caseNames, caseTypes, caseGroupIds, caseGroupId, "127.0.0.1", riOctavePlugin::portNumber()); size_t caseCount = caseIds.size(); diff --git a/OctavePlugin/riGetCellCenters.cpp b/OctavePlugin/riGetCellCenters.cpp index c4807c5b7b..7aa957485c 100644 --- a/OctavePlugin/riGetCellCenters.cpp +++ b/OctavePlugin/riGetCellCenters.cpp @@ -126,7 +126,7 @@ DEFUN_DLD (riGetCellCenters, args, nargout, gridIndex = args(1).uint_value(); } - getCellCenters(cellCenterValues, "127.0.0.1", 40001, caseId, gridIndex); + getCellCenters(cellCenterValues, "127.0.0.1", riOctavePlugin::portNumber(), caseId, gridIndex); return octave_value(cellCenterValues); } diff --git a/OctavePlugin/riGetCellCorners.cpp b/OctavePlugin/riGetCellCorners.cpp index 782a18a468..3fb010bfb6 100644 --- a/OctavePlugin/riGetCellCorners.cpp +++ b/OctavePlugin/riGetCellCorners.cpp @@ -128,7 +128,7 @@ DEFUN_DLD (riGetCellCorners, args, nargout, gridIndex = args(1).uint_value(); } - getCellCorners(cellCornerValues, "127.0.0.1", 40001, caseId, gridIndex); + getCellCorners(cellCornerValues, "127.0.0.1", riOctavePlugin::portNumber(), caseId, gridIndex); return octave_value(cellCornerValues); } diff --git a/OctavePlugin/riGetCoarseningInfo.cpp b/OctavePlugin/riGetCoarseningInfo.cpp index ed415ff420..d68992c5e1 100644 --- a/OctavePlugin/riGetCoarseningInfo.cpp +++ b/OctavePlugin/riGetCoarseningInfo.cpp @@ -115,7 +115,7 @@ DEFUN_DLD (riGetCoarseningInfo, args, nargout, } int32NDArray coarseningInfo; - getCoarseningInfo(coarseningInfo, "127.0.0.1", 40001, caseId); + getCoarseningInfo(coarseningInfo, "127.0.0.1", riOctavePlugin::portNumber(), caseId); return octave_value(coarseningInfo); } diff --git a/OctavePlugin/riGetCurrentCase.cpp b/OctavePlugin/riGetCurrentCase.cpp index d5bfd2590e..3a90e43dc5 100644 --- a/OctavePlugin/riGetCurrentCase.cpp +++ b/OctavePlugin/riGetCurrentCase.cpp @@ -93,7 +93,7 @@ DEFUN_DLD (riGetCurrentCase, args, nargout, QString caseType; qint64 caseGroupId = -1; - getCurrentCase(caseId, caseName, caseType, caseGroupId, "127.0.0.1", 40001); + getCurrentCase(caseId, caseName, caseType, caseGroupId, "127.0.0.1", riOctavePlugin::portNumber()); octave_map fieldMap; diff --git a/OctavePlugin/riGetDynamicNNCValues.cpp b/OctavePlugin/riGetDynamicNNCValues.cpp index ce8473e44e..3700de2f11 100644 --- a/OctavePlugin/riGetDynamicNNCValues.cpp +++ b/OctavePlugin/riGetDynamicNNCValues.cpp @@ -155,7 +155,7 @@ DEFUN_DLD (riGetDynamicNNCValues, args, nargout, if (argIndices[1] >= 0) propertyName = args(argIndices[1]).char_matrix_value().row_as_string(0); if (argIndices[2] >= 0) requestedTimeSteps = args(argIndices[2]).int32_array_value(); - getDynamicNNCValues(propertyFrames, "127.0.0.1", 40001, caseId, propertyName.c_str(), requestedTimeSteps); + getDynamicNNCValues(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str(), requestedTimeSteps); return octave_value(propertyFrames); } diff --git a/OctavePlugin/riGetGridDimensions.cpp b/OctavePlugin/riGetGridDimensions.cpp index 7478b859e8..1e89cbc8ae 100644 --- a/OctavePlugin/riGetGridDimensions.cpp +++ b/OctavePlugin/riGetGridDimensions.cpp @@ -119,7 +119,7 @@ DEFUN_DLD (riGetGridDimensions, args, nargout, } int32NDArray gridDimensions; - getGridDimensions(gridDimensions, "127.0.0.1", 40001, caseId); + getGridDimensions(gridDimensions, "127.0.0.1", riOctavePlugin::portNumber(), caseId); return octave_value(gridDimensions); } diff --git a/OctavePlugin/riGetGridProperty.cpp b/OctavePlugin/riGetGridProperty.cpp index 1507317445..8ddd5572a0 100644 --- a/OctavePlugin/riGetGridProperty.cpp +++ b/OctavePlugin/riGetGridProperty.cpp @@ -211,7 +211,7 @@ DEFUN_DLD (riGetGridProperty, args, nargout, return octave_value_list (); } - getGridProperty(propertyFrames, "127.0.0.1", 40001, caseId, gridIdx, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str()); + getGridProperty(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, gridIdx, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str()); return octave_value(propertyFrames); } diff --git a/OctavePlugin/riGetGridPropertyForSelectedCells.cpp b/OctavePlugin/riGetGridPropertyForSelectedCells.cpp index 8cd71a5774..17f8dddd08 100644 --- a/OctavePlugin/riGetGridPropertyForSelectedCells.cpp +++ b/OctavePlugin/riGetGridPropertyForSelectedCells.cpp @@ -193,7 +193,7 @@ DEFUN_DLD (riGetGridPropertyForSelectedCells, args, nargout, return octave_value_list (); } - getGridPropertyForSelectedCells(propertyFrames, "127.0.0.1", 40001, caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str()); + getGridPropertyForSelectedCells(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str()); return octave_value(propertyFrames); } diff --git a/OctavePlugin/riGetMainGridDimensions.cpp b/OctavePlugin/riGetMainGridDimensions.cpp index af009cfd91..385f89fe62 100644 --- a/OctavePlugin/riGetMainGridDimensions.cpp +++ b/OctavePlugin/riGetMainGridDimensions.cpp @@ -101,9 +101,9 @@ DEFUN_DLD (riGetMainGridDimensions, args, nargout, int32NDArray propertyFrames; if (nargin > 0) - getMainGridDimensions(propertyFrames, "127.0.0.1", 40001, args(0).char_matrix_value().row_as_string(0).c_str()); + getMainGridDimensions(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), args(0).char_matrix_value().row_as_string(0).c_str()); else - getMainGridDimensions(propertyFrames, "127.0.0.1", 40001, ""); + getMainGridDimensions(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), ""); return octave_value(propertyFrames); } diff --git a/OctavePlugin/riGetNNCConnections.cpp b/OctavePlugin/riGetNNCConnections.cpp index 6595047863..7260c1d5c8 100644 --- a/OctavePlugin/riGetNNCConnections.cpp +++ b/OctavePlugin/riGetNNCConnections.cpp @@ -122,7 +122,7 @@ DEFUN_DLD(riGetNNCConnections, args, nargout, } } - getNNCConnections(connections, "127.0.0.1", 40001, caseId); + getNNCConnections(connections, "127.0.0.1", riOctavePlugin::portNumber(), caseId); Cell cellValuesGridIndex(connections.size(), 2); Cell cellValuesI(connections.size(), 2); diff --git a/OctavePlugin/riGetNNCPropertyNames.cpp b/OctavePlugin/riGetNNCPropertyNames.cpp index ba9140d0b9..84ca1f9806 100644 --- a/OctavePlugin/riGetNNCPropertyNames.cpp +++ b/OctavePlugin/riGetNNCPropertyNames.cpp @@ -115,7 +115,7 @@ DEFUN_DLD (riGetNNCPropertyNames, args, nargout, std::vector propertyNames; std::vector propertyTypes; - getNNCPropertyNames(propertyNames, propertyTypes, "127.0.0.1", 40001, argCaseId); + getNNCPropertyNames(propertyNames, propertyTypes, "127.0.0.1", riOctavePlugin::portNumber(), argCaseId); size_t caseCount = propertyNames.size(); diff --git a/OctavePlugin/riGetPropertyNames.cpp b/OctavePlugin/riGetPropertyNames.cpp index b870448d81..6cd313e3d8 100644 --- a/OctavePlugin/riGetPropertyNames.cpp +++ b/OctavePlugin/riGetPropertyNames.cpp @@ -135,7 +135,7 @@ DEFUN_DLD (riGetPropertyNames, args, nargout, std::vector propertyNames; std::vector propertyTypes; - getPropertyNames(propertyNames, propertyTypes, "127.0.0.1", 40001, argCaseId, porosityModel); + getPropertyNames(propertyNames, propertyTypes, "127.0.0.1", riOctavePlugin::portNumber(), argCaseId, porosityModel); size_t caseCount = propertyNames.size(); diff --git a/OctavePlugin/riGetSelectedCases.cpp b/OctavePlugin/riGetSelectedCases.cpp index 7d65e50ed1..077144d3a9 100644 --- a/OctavePlugin/riGetSelectedCases.cpp +++ b/OctavePlugin/riGetSelectedCases.cpp @@ -105,7 +105,7 @@ DEFUN_DLD (riGetSelectedCases, args, nargout, std::vector caseTypes; std::vector caseGroupIds; - getSelectedCases(caseIds, caseNames, caseTypes, caseGroupIds, "127.0.0.1", 40001); + getSelectedCases(caseIds, caseNames, caseTypes, caseGroupIds, "127.0.0.1", riOctavePlugin::portNumber()); size_t caseCount = caseIds.size(); diff --git a/OctavePlugin/riGetSelectedCells.cpp b/OctavePlugin/riGetSelectedCells.cpp index 157549ac5e..16e263e726 100644 --- a/OctavePlugin/riGetSelectedCells.cpp +++ b/OctavePlugin/riGetSelectedCells.cpp @@ -125,7 +125,7 @@ DEFUN_DLD (riGetSelectedCells, args, nargout, int32NDArray propertyFrames; - getSelectedCells(propertyFrames, "127.0.0.1", 40001, caseId); + getSelectedCells(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId); return octave_value(propertyFrames); } diff --git a/OctavePlugin/riGetStaticNNCValues.cpp b/OctavePlugin/riGetStaticNNCValues.cpp index 0610f6a4de..e3646fcf0c 100644 --- a/OctavePlugin/riGetStaticNNCValues.cpp +++ b/OctavePlugin/riGetStaticNNCValues.cpp @@ -128,7 +128,7 @@ DEFUN_DLD (riGetStaticNNCValues, args, nargout, if (argIndices[0] >= 0) caseId = args(argIndices[0]).int_value(); if (argIndices[1] >= 0) propertyName = args(argIndices[1]).char_matrix_value().row_as_string(0); - getStaticNNCValues(propertyValues, "127.0.0.1", 40001, caseId, propertyName.c_str()); + getStaticNNCValues(propertyValues, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str()); dim_vector dv(2, 1); dv(0) = propertyValues.size(); diff --git a/OctavePlugin/riGetTimeStepDates.cpp b/OctavePlugin/riGetTimeStepDates.cpp index 9be5748448..27a116ba65 100644 --- a/OctavePlugin/riGetTimeStepDates.cpp +++ b/OctavePlugin/riGetTimeStepDates.cpp @@ -140,7 +140,7 @@ DEFUN_DLD (riGetTimeStepDates, args, nargout, std::vector minuteValues; std::vector secondValues; - getTimeStepDates(yearValues, monthValues, dayValues, hourValues, minuteValues, secondValues, caseId, "127.0.0.1", 40001); + getTimeStepDates(yearValues, monthValues, dayValues, hourValues, minuteValues, secondValues, caseId, "127.0.0.1", riOctavePlugin::portNumber()); size_t timeStepDateCount = yearValues.size(); diff --git a/OctavePlugin/riGetTimeStepDays.cpp b/OctavePlugin/riGetTimeStepDays.cpp index 62f5cf13f3..c563be2d3e 100644 --- a/OctavePlugin/riGetTimeStepDays.cpp +++ b/OctavePlugin/riGetTimeStepDays.cpp @@ -108,7 +108,7 @@ DEFUN_DLD (riGetTimeStepDays, args, nargout, std::vector decimalDays; - getTimeStepDates(decimalDays, caseId, "127.0.0.1", 40001); + getTimeStepDates(decimalDays, caseId, "127.0.0.1", riOctavePlugin::portNumber()); dim_vector dv(2, 1); dv(0) = decimalDays.size(); diff --git a/OctavePlugin/riGetWellCells.cpp b/OctavePlugin/riGetWellCells.cpp index b967636ba0..fb206b5aec 100644 --- a/OctavePlugin/riGetWellCells.cpp +++ b/OctavePlugin/riGetWellCells.cpp @@ -209,7 +209,7 @@ DEFUN_DLD (riGetWellCells, args, nargout, cellStatuses, branchIds, segmentIds, - "127.0.0.1", 40001, + "127.0.0.1", riOctavePlugin::portNumber(), caseId, QString::fromStdString(wellName), requestedTimeStep); size_t cellCount = cellIs.size(); diff --git a/OctavePlugin/riGetWellNames.cpp b/OctavePlugin/riGetWellNames.cpp index 4bbd17733b..d6d825fee5 100644 --- a/OctavePlugin/riGetWellNames.cpp +++ b/OctavePlugin/riGetWellNames.cpp @@ -106,7 +106,7 @@ DEFUN_DLD (riGetWellNames, args, nargout, std::vector wellNames; - getWellNames(wellNames, "127.0.0.1", 40001, argCaseId); + getWellNames(wellNames, "127.0.0.1", riOctavePlugin::portNumber(), argCaseId); size_t caseCount = wellNames.size(); diff --git a/OctavePlugin/riGetWellStatus.cpp b/OctavePlugin/riGetWellStatus.cpp index 318e9b9d80..dcc9c43f27 100644 --- a/OctavePlugin/riGetWellStatus.cpp +++ b/OctavePlugin/riGetWellStatus.cpp @@ -170,7 +170,7 @@ DEFUN_DLD (riGetWellStatus, args, nargout, std::vector wellType; std::vector wellStatus; - getWellStatus(wellType, wellStatus, "127.0.0.1", 40001, caseId, QString::fromStdString(wellName), requestedTimeSteps); + getWellStatus(wellType, wellStatus, "127.0.0.1", riOctavePlugin::portNumber(), caseId, QString::fromStdString(wellName), requestedTimeSteps); size_t caseCount = wellType.size(); diff --git a/OctavePlugin/riSetActiveCellProperty.cpp b/OctavePlugin/riSetActiveCellProperty.cpp index 91edf8f9cd..ca12495424 100644 --- a/OctavePlugin/riSetActiveCellProperty.cpp +++ b/OctavePlugin/riSetActiveCellProperty.cpp @@ -219,7 +219,7 @@ DEFUN_DLD (riSetActiveCellProperty, args, nargout, return octave_value_list (); } - setEclipseProperty(propertyFrames, "127.0.0.1", 40001, caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str()); + setEclipseProperty(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str()); return octave_value_list (); } diff --git a/OctavePlugin/riSetGridProperty.cpp b/OctavePlugin/riSetGridProperty.cpp index 9a77e17173..e38456d10d 100644 --- a/OctavePlugin/riSetGridProperty.cpp +++ b/OctavePlugin/riSetGridProperty.cpp @@ -258,7 +258,7 @@ DEFUN_DLD (riSetGridProperty, args, nargout, return octave_value_list (); } - setEclipseProperty(propertyFrames, "127.0.0.1", 40001, caseId, gridIndex, propertyName.c_str(), timeStepIndices, porosityModel.c_str()); + setEclipseProperty(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, gridIndex, propertyName.c_str(), timeStepIndices, porosityModel.c_str()); return octave_value_list (); } diff --git a/OctavePlugin/riSetNNCProperty.cpp b/OctavePlugin/riSetNNCProperty.cpp index f58e7f56e6..d52b2e13c2 100644 --- a/OctavePlugin/riSetNNCProperty.cpp +++ b/OctavePlugin/riSetNNCProperty.cpp @@ -186,7 +186,7 @@ DEFUN_DLD (riSetNNCProperty, args, nargout, } } - setNNCProperty(propertyFrames, "127.0.0.1", 40001, caseId, propertyName.c_str(), requestedTimeSteps); + setNNCProperty(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str(), requestedTimeSteps); return octave_value_list (); } diff --git a/OctavePlugin/riSettings.h b/OctavePlugin/riSettings.h index a7badf6941..a10e41f869 100644 --- a/OctavePlugin/riSettings.h +++ b/OctavePlugin/riSettings.h @@ -76,5 +76,16 @@ namespace riOctavePlugin #endif } + int portNumber() + { + QString portStr = getenv(riOctavePlugin::portNumberKey().data()); + if (!portStr.isEmpty()) + { + return portStr.toInt(); + } + + return riOctavePlugin::defaultPortNumber; + } + } From b050cac1d26e3f1deb2e135ad1e09cc77b07cb0c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 4 Jun 2024 07:42:50 +0200 Subject: [PATCH 101/332] Make it possible to build Octave plugins independent to main build The building of Octave plugins within main ResInsight build on RHEL8 cause the build to use gcc-12, and gcc-12 is extremely slow when building opm-common. Adjust the CMake configuration so it is possible to build the Octave plugins as an independent build job. The plugin binaries can then be uploaded to an external server. The main ResInsight build can download the binaries and include them in the install package for ResInsight. Use the flag RESINSIGHT_USE_EXTERNAL_OCTAVE_PLUGINS to download external Octave plugin binaries. --- .github/workflows/cmake-format.yml | 4 + CMakeLists.txt | 31 +- Octave/CMakeLists.txt | 33 +++ Octave/OctavePlugin/CMakeLists.txt | 278 ++++++++++++++++++ .../MinGWBuildConfigurationForOctave.txt | 0 .../NNCOctaveInterfaceSpecification.txt | 0 .../OctaveScripts/InputPropTest.m | 0 .../OctavePlugin}/OctaveScripts/LGRSOIL.m | 0 .../OctavePlugin}/OctaveScripts/SatNum.m | 0 .../OctavePlugin}/OctaveScripts/SoilAverage.m | 0 .../OctaveScripts/SoilTimeDiff.m | 0 .../OctavePlugin}/OctaveScripts/kaverage.m | 0 .../OctavePlugin}/OctaveScripts/kslice.m | 0 ...ResInsightOctaveInterfaceSpecification.txt | 0 .../OctavePlugin}/riGetActiveCellCenters.cpp | 0 .../OctavePlugin}/riGetActiveCellCorners.cpp | 0 .../OctavePlugin}/riGetActiveCellInfo.cpp | 0 .../OctavePlugin}/riGetActiveCellProperty.cpp | 0 .../OctavePlugin}/riGetCaseGroups.cpp | 0 .../OctavePlugin}/riGetCases.cpp | 0 .../OctavePlugin}/riGetCellCenters.cpp | 0 .../OctavePlugin}/riGetCellCorners.cpp | 0 .../OctavePlugin}/riGetCoarseningInfo.cpp | 0 .../OctavePlugin}/riGetCurrentCase.cpp | 0 .../OctavePlugin}/riGetDynamicNNCValues.cpp | 0 .../OctavePlugin}/riGetGridDimensions.cpp | 0 .../OctavePlugin}/riGetGridProperty.cpp | 0 .../riGetGridPropertyForSelectedCells.cpp | 0 .../OctavePlugin}/riGetMainGridDimensions.cpp | 0 .../OctavePlugin}/riGetNNCConnections.cpp | 0 .../OctavePlugin}/riGetNNCPropertyNames.cpp | 0 .../OctavePlugin}/riGetPropertyNames.cpp | 0 .../OctavePlugin}/riGetSelectedCases.cpp | 0 .../OctavePlugin}/riGetSelectedCells.cpp | 0 .../OctavePlugin}/riGetStaticNNCValues.cpp | 0 .../OctavePlugin}/riGetTimeStepDates.cpp | 0 .../OctavePlugin}/riGetTimeStepDays.cpp | 0 .../OctavePlugin}/riGetWellCells.cpp | 0 .../OctavePlugin}/riGetWellNames.cpp | 0 .../OctavePlugin}/riGetWellStatus.cpp | 0 .../OctavePlugin}/riSetActiveCellProperty.cpp | 0 .../OctavePlugin}/riSetGridProperty.cpp | 0 .../OctavePlugin}/riSetNNCProperty.cpp | 0 .../OctavePlugin}/riSettings.h | 2 +- Octave/cmake/FindOctave.cmake | 205 +++++++++++++ Octave/cmake/cmake-format.py | 20 ++ OctavePlugin/CMakeLists.txt | 262 ----------------- 47 files changed, 565 insertions(+), 270 deletions(-) create mode 100644 Octave/CMakeLists.txt create mode 100644 Octave/OctavePlugin/CMakeLists.txt rename {OctavePlugin => Octave/OctavePlugin}/MinGWBuildConfigurationForOctave.txt (100%) rename {OctavePlugin => Octave/OctavePlugin}/NNCOctaveInterfaceSpecification.txt (100%) rename {OctavePlugin => Octave/OctavePlugin}/OctaveScripts/InputPropTest.m (100%) rename {OctavePlugin => Octave/OctavePlugin}/OctaveScripts/LGRSOIL.m (100%) rename {OctavePlugin => Octave/OctavePlugin}/OctaveScripts/SatNum.m (100%) rename {OctavePlugin => Octave/OctavePlugin}/OctaveScripts/SoilAverage.m (100%) rename {OctavePlugin => Octave/OctavePlugin}/OctaveScripts/SoilTimeDiff.m (100%) rename {OctavePlugin => Octave/OctavePlugin}/OctaveScripts/kaverage.m (100%) rename {OctavePlugin => Octave/OctavePlugin}/OctaveScripts/kslice.m (100%) rename {OctavePlugin => Octave/OctavePlugin}/ResInsightOctaveInterfaceSpecification.txt (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetActiveCellCenters.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetActiveCellCorners.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetActiveCellInfo.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetActiveCellProperty.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetCaseGroups.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetCases.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetCellCenters.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetCellCorners.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetCoarseningInfo.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetCurrentCase.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetDynamicNNCValues.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetGridDimensions.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetGridProperty.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetGridPropertyForSelectedCells.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetMainGridDimensions.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetNNCConnections.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetNNCPropertyNames.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetPropertyNames.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetSelectedCases.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetSelectedCells.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetStaticNNCValues.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetTimeStepDates.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetTimeStepDays.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetWellCells.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetWellNames.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riGetWellStatus.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riSetActiveCellProperty.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riSetGridProperty.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riSetNNCProperty.cpp (100%) rename {OctavePlugin => Octave/OctavePlugin}/riSettings.h (97%) create mode 100644 Octave/cmake/FindOctave.cmake create mode 100644 Octave/cmake/cmake-format.py delete mode 100644 OctavePlugin/CMakeLists.txt diff --git a/.github/workflows/cmake-format.yml b/.github/workflows/cmake-format.yml index c6db7afa8e..eb6b5ec436 100644 --- a/.github/workflows/cmake-format.yml +++ b/.github/workflows/cmake-format.yml @@ -23,6 +23,10 @@ jobs: find -name CMake*.txt | xargs ~/.local/bin/cmake-format -c ${{ github.workspace }}/cmake/cmake-format.py -i cd .. + cd Octave + find -name CMake*.txt | xargs ~/.local/bin/cmake-format -c ${{ github.workspace }}/cmake/cmake-format.py -i + cd .. + cd Fwk/AppFwk find -name CMake*.txt | xargs ~/.local/bin/cmake-format -c ${{ github.workspace }}/cmake/cmake-format.py -i cd .. diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e44d52a41..e941b2c0e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -984,15 +984,32 @@ if(RESINSIGHT_ENABLE_GRPC) endif() add_subdirectory(ApplicationExeCode) -if(OCTAVE_MKOCTFILE) - message(STATUS "Adding OctavePlugin library") +option(RESINSIGHT_USE_EXTERNAL_OCTAVE_PLUGINS "Use external Octave plugins" OFF) +if(RESINSIGHT_USE_EXTERNAL_OCTAVE_PLUGINS) + FetchContent_Declare( + external-octave_plugins + URL https://github.com/CeetronSolutions/resinsight-dependencies/releases/latest/download/OctavePlugins-0.1.1-Linux.tar.gz + ) - add_subdirectory(OctavePlugin) -else(OCTAVE_MKOCTFILE) - message( - STATUS "Could not find OCTAVE_MKOCTFILE, skipping OctavePlugin library" + FetchContent_Populate(external-octave_plugins) + + file(GLOB FILE_AND_SYMLINKS ${external-octave_plugins_SOURCE_DIR}/*.oct) + install( + FILES ${FILE_AND_SYMLINKS} + DESTINATION ${RESINSIGHT_INSTALL_FOLDER} + OPTIONAL ) -endif(OCTAVE_MKOCTFILE) +else(RESINSIGHT_USE_EXTERNAL_OCTAVE_PLUGINS) + if(OCTAVE_MKOCTFILE) + message(STATUS "Adding OctavePlugin library") + + add_subdirectory(Octave/OctavePlugin) + else(OCTAVE_MKOCTFILE) + message( + STATUS "Could not find OCTAVE_MKOCTFILE, skipping OctavePlugin library" + ) + endif(OCTAVE_MKOCTFILE) +endif(RESINSIGHT_USE_EXTERNAL_OCTAVE_PLUGINS) add_subdirectory(ThirdParty/extract-projectfile-versions) install(TARGETS extract-projectfile-versions diff --git a/Octave/CMakeLists.txt b/Octave/CMakeLists.txt new file mode 100644 index 0000000000..48f509f694 --- /dev/null +++ b/Octave/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.15) + +project(OctavePlugins) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +find_package(Octave) + +if(CEE_USE_QT6) + find_package( + Qt6 + COMPONENTS + REQUIRED Core Gui OpenGL Widgets Network + ) + set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::OpenGL Qt6::Widgets Qt6::Network) + qt_standard_project_setup() +else() + find_package( + Qt5 + COMPONENTS + REQUIRED Core Gui OpenGL Widgets Network + ) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets Qt5::Network) +endif() + +add_subdirectory(OctavePlugin) + +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(CPACK_GENERATOR TGZ) +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(CPACK_GENERATOR ZIP) +endif() + +include(CPack) diff --git a/Octave/OctavePlugin/CMakeLists.txt b/Octave/OctavePlugin/CMakeLists.txt new file mode 100644 index 0000000000..99beb51cea --- /dev/null +++ b/Octave/OctavePlugin/CMakeLists.txt @@ -0,0 +1,278 @@ +# Some of the functionality in this CMakeLists.txt might be easier to maintain +# if we use a CMake macro to find configuration info for Octave This file is +# currently (2.8.12) not part of default CMake installation See +# http://www.cmake.org/Wiki/CMakeUserFindOctave + +set(CPP_SOURCES + riGetActiveCellProperty.cpp + riSetActiveCellProperty.cpp + riGetActiveCellInfo.cpp + riGetMainGridDimensions.cpp + riGetNNCConnections.cpp + riGetNNCPropertyNames.cpp + riGetCurrentCase.cpp + riGetCaseGroups.cpp + riGetDynamicNNCValues.cpp + riGetStaticNNCValues.cpp + riGetSelectedCases.cpp + riGetSelectedCells.cpp + riGetCases.cpp + riGetTimeStepDates.cpp + riGetTimeStepDays.cpp + riGetGridDimensions.cpp + riGetCoarseningInfo.cpp + riGetCellCenters.cpp + riGetActiveCellCenters.cpp + riGetCellCorners.cpp + riGetActiveCellCorners.cpp + riGetGridProperty.cpp + riSetGridProperty.cpp + riGetGridPropertyForSelectedCells.cpp + riGetPropertyNames.cpp + riGetWellNames.cpp + riGetWellStatus.cpp + riGetWellCells.cpp + riSetNNCProperty.cpp +) + +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + # since the compiler passes the option to the linker, double quoting is + # necessary + set(RPATH_COMMAND "-Wl,-rpath,'\\$$ORIGIN'") +endif() + +# recreate the magic that CMake does for MacOS X frameworks in the include list +# when we call mkoctfile as a custom command +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(QT_INCLUDES) + set(QT_FRAMEWORKS) + # QT_INCLUDE_DIR contains two items; the first is the directory containing + # header files, the second is the framework. This setup is specially processed + # in include_directories (); CMake will add -F before the frameworks. We will + # have to replicate that setup here when we want to pass it directly to a + # command see + foreach(item IN ITEMS ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} + ${QT_INCLUDE_DIR} + ) + if("${item}" MATCHES ".framework$") + get_filename_component(frmwrk_path ${item} PATH) + get_filename_component(frmwrk_name ${item} NAME_WE) + # mkoctfile doesn't support arbitrary compiler command, so we must wrap in + # -Wl, to pass to the linker + list(APPEND QT_FRAMEWORKS "-Wl,-F${frmwrk_path}") + list(APPEND QT_FRAMEWORKS "-Wl,-framework,${frmwrk_name}") + else() + list(APPEND QT_INCLUDES "-I${item}") + endif() + endforeach(item) + if(QT_INCLUDES) + list(REMOVE_DUPLICATES QT_INCLUDES) + endif() + if(QT_FRAMEWORKS) + list(REMOVE_DUPLICATES QT_FRAMEWORKS) + endif() +endif() + +message(STATUS "Compiling Octave plugins using : ${OCTAVE_MKOCTFILE}") + +if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + option(RESINSIGHT_OCTAVE_PLUGIN_QT + "Compile Octave plugin using Qt located insided Octave root folder" ON + ) +endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + +if(RESINSIGHT_OCTAVE_PLUGIN_QT) + + message( + STATUS + "Compiling Octave plugins using custom Qt located at ${OCTAVE_ROOT_DIR}" + ) + + if(EXISTS ${OCTAVE_ROOT_DIR}/qt5) + set(OCTAVE_QT_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/qt5/include) + set(OCTAVE_QT_QTCORE_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/qt5/include/QtCore) + set(OCTAVE_QT_QTNETWORK_INCLUDE_DIR + ${OCTAVE_ROOT_DIR}/qt5/include/QtNetwork + ) + set(OCTAVE_QT_LIBRARY_DIR ${OCTAVE_ROOT_DIR}/qt5/lib) + set(OCTAVE_QT_QTCORE_LIB Qt5Core) + set(OCTAVE_QT_QTNETWORK_LIB Qt5Network) + else() + set(OCTAVE_QT_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include) + set(OCTAVE_QT_QTCORE_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include/QtCore) + set(OCTAVE_QT_QTNETWORK_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include/QtNetwork) + set(OCTAVE_QT_LIBRARY_DIR ${OCTAVE_ROOT_DIR}/lib) + set(OCTAVE_QT_QTCORE_LIB QtCore4) + set(OCTAVE_QT_QTNETWORK_LIB QtNetwork4) + endif(EXISTS ${OCTAVE_ROOT_DIR}/qt5) + +else() + + if(Qt5Core_FOUND) + message(STATUS "Compiling Octave plugins using system Qt5") + + set(OCTAVE_QT_QTCORE_INCLUDE_DIR ${Qt5Core_INCLUDE_DIRS}) + set(OCTAVE_QT_QTNETWORK_INCLUDE_DIR ${Qt5Network_INCLUDE_DIRS}) + set(OCTAVE_QT_LIBRARY_DIR ${QT_LIBRARY_DIR}) + set(OCTAVE_QT_QTCORE_LIB Qt5Core) + set(OCTAVE_QT_QTNETWORK_LIB Qt5Network) + + endif(Qt5Core_FOUND) + +endif(RESINSIGHT_OCTAVE_PLUGIN_QT) + +list(APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_INCLUDE_DIR}) +list(APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_QTCORE_INCLUDE_DIR}) +list(APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_QTNETWORK_INCLUDE_DIR}) + +# Add socket interface source code folder +list(APPEND MKOCTFILE_INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/../../ApplicationLibCode/SocketInterface +) + +list(REMOVE_DUPLICATES MKOCTFILE_INCLUDE_DIRS) +foreach(item ${MKOCTFILE_INCLUDE_DIRS}) + list(APPEND MKOCTFILE_INCLUDE_TEMP -I${item}) +endforeach(item) + +string(REPLACE ";" " " MKOCTFILE_INCLUDE_TEMP "${MKOCTFILE_INCLUDE_TEMP}") + +# Use special command to avoid double quoting in add_custom_command() +separate_arguments( + MKOCTFILE_INCLUDE_COMMAND_STRING WINDOWS_COMMAND "${MKOCTFILE_INCLUDE_TEMP}" +) + +# Clear the list of binary oct files to be produced +set(OCTAVE_BINARY_OCT_FILES) + +if(OCTAVE_MKOCTFILE) + foreach(srcFileName IN LISTS CPP_SOURCES) + + if(NOT IS_ABSOLUTE "${srcFileName}") + set(srcFileName "${CMAKE_CURRENT_SOURCE_DIR}/${srcFileName}") + endif() + + get_filename_component(baseFilename "${srcFileName}" NAME_WE) + + set(octFileName "${CMAKE_CURRENT_BINARY_DIR}/${baseFilename}.oct") + + if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + add_custom_command( + OUTPUT "${octFileName}" + COMMAND set "OCTAVE_HOME=${OCTAVE_ROOT_DIR}" + COMMAND set "PATH=%OCTAVE_HOME%\\bin;%PATH%" + COMMAND + ${OCTAVE_MKOCTFILE} ${MKOCTFILE_INCLUDE_COMMAND_STRING} + ${RPATH_COMMAND} -L${OCTAVE_QT_LIBRARY_DIR} -l${OCTAVE_QT_QTCORE_LIB} + -l${OCTAVE_QT_QTNETWORK_LIB} -o "${octFileName}" "${srcFileName}" + DEPENDS "${srcFileName}" + COMMENT "===> Generating ${octFileName}" + ) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + add_custom_command( + OUTPUT "${octFileName}" + COMMAND + ${OCTAVE_MKOCTFILE} ${QT_INCLUDES} ${QT_FRAMEWORKS} + -I${ResInsight_SOURCE_DIR}/ApplicationLibCode/SocketInterface + ${RPATH_COMMAND} -L${QT_LIBRARY_DIR} -Wl,-framework,QtCore + -Wl,-framework,QtNetwork -o "${octFileName}" "${srcFileName}" + DEPENDS "${srcFileName}" + COMMENT "===> Generating ${octFileName}" + ) + else() + add_custom_command( + OUTPUT "${octFileName}" + COMMAND + OCTAVE_HOME=${OCTAVE_ROOT_DIR} ${OCTAVE_MKOCTFILE} + ${MKOCTFILE_INCLUDE_COMMAND_STRING} ${RPATH_COMMAND} + -L${OCTAVE_QT_LIBRARY_DIR} -l${OCTAVE_QT_QTCORE_LIB} + -l${OCTAVE_QT_QTNETWORK_LIB} -o "${octFileName}" "${srcFileName}" + DEPENDS "${srcFileName}" + COMMENT "===> Generating ${octFileName}" + ) + endif() + + list(APPEND OCTAVE_BINARY_OCT_FILES "${octFileName}") + + endforeach() + + # Create depencedy string represeting the full path to all generated oct-files + foreach(item ${CPP_SOURCES}) + string(REPLACE ".cpp" ".oct" item ${item}) + list(APPEND DEPENDENCY_STRING ${CMAKE_CURRENT_BINARY_DIR}/${item}) + endforeach(item) + + # message("DEPENDENCY_STRING : ${DEPENDENCY_STRING}") + + add_custom_target( + octave_plugins ALL + DEPENDS ${DEPENDENCY_STRING} + SOURCES ${CPP_SOURCES} riSettings.h + ) + + # Copy Octave generated *.oct files to application folder, will make it + # possible to use Octave functions directly from the location of the + # ResInsight binaries + if(TARGET ResInsight) + message( + STATUS + "Target ResInsight exists, add copy of Octave plugins to ApplicationExeCode folder" + ) + + # Make ResInsight dependant on Octave, makes it easiser to debug Octave + # functionality by compiling ResInsight + add_dependencies(ResInsight octave_plugins) + + foreach(oct_bin ${OCTAVE_BINARY_OCT_FILES}) + get_filename_component(Filename "${oct_bin}" NAME) + + if(MSVC) + add_custom_command( + TARGET octave_plugins + POST_BUILD + COMMAND + ${CMAKE_COMMAND} -E copy_if_different "${oct_bin}" + "${CMAKE_CURRENT_BINARY_DIR}/../../ApplicationExeCode/$/${Filename}" + ) + else() + add_custom_command( + TARGET octave_plugins + POST_BUILD + COMMAND + ${CMAKE_COMMAND} -E copy_if_different "${oct_bin}" + "${CMAKE_CURRENT_BINARY_DIR}/../../ApplicationExeCode/${Filename}" + ) + endif(MSVC) + endforeach(oct_bin) + + if(RESINSIGHT_PRIVATE_INSTALL) + install(FILES ${OCTAVE_BINARY_OCT_FILES} + DESTINATION ${RESINSIGHT_INSTALL_FOLDER} + ) + else(RESINSIGHT_PRIVATE_INSTALL) + # probe for site location of .oct files + if(NOT OCTAVE_SITE_OCT_DIR) + find_program( + OCTAVE_CONFIG_COMMAND octave-config + DOC "Path to Octave component and library information retrieval" + ) + exec_program( + ${OCTAVE_CONFIG_COMMAND} ARGS + --oct-site-dir + OUTPUT_VARIABLE OCTAVE_SITE_OCT_DIR + ) + set(OCTAVE_SITE_OCT_DIR + "${OCTAVE_SITE_OCT_DIR}" + CACHE LOCATION "Octave plugin directory" + ) + endif(NOT OCTAVE_SITE_OCT_DIR) + + install(FILES ${OCTAVE_BINARY_OCT_FILES} + DESTINATION ${OCTAVE_SITE_OCT_DIR} + ) + endif(RESINSIGHT_PRIVATE_INSTALL) + else() + install(FILES ${OCTAVE_BINARY_OCT_FILES} DESTINATION .) + endif(TARGET ResInsight) + +endif(OCTAVE_MKOCTFILE) diff --git a/OctavePlugin/MinGWBuildConfigurationForOctave.txt b/Octave/OctavePlugin/MinGWBuildConfigurationForOctave.txt similarity index 100% rename from OctavePlugin/MinGWBuildConfigurationForOctave.txt rename to Octave/OctavePlugin/MinGWBuildConfigurationForOctave.txt diff --git a/OctavePlugin/NNCOctaveInterfaceSpecification.txt b/Octave/OctavePlugin/NNCOctaveInterfaceSpecification.txt similarity index 100% rename from OctavePlugin/NNCOctaveInterfaceSpecification.txt rename to Octave/OctavePlugin/NNCOctaveInterfaceSpecification.txt diff --git a/OctavePlugin/OctaveScripts/InputPropTest.m b/Octave/OctavePlugin/OctaveScripts/InputPropTest.m similarity index 100% rename from OctavePlugin/OctaveScripts/InputPropTest.m rename to Octave/OctavePlugin/OctaveScripts/InputPropTest.m diff --git a/OctavePlugin/OctaveScripts/LGRSOIL.m b/Octave/OctavePlugin/OctaveScripts/LGRSOIL.m similarity index 100% rename from OctavePlugin/OctaveScripts/LGRSOIL.m rename to Octave/OctavePlugin/OctaveScripts/LGRSOIL.m diff --git a/OctavePlugin/OctaveScripts/SatNum.m b/Octave/OctavePlugin/OctaveScripts/SatNum.m similarity index 100% rename from OctavePlugin/OctaveScripts/SatNum.m rename to Octave/OctavePlugin/OctaveScripts/SatNum.m diff --git a/OctavePlugin/OctaveScripts/SoilAverage.m b/Octave/OctavePlugin/OctaveScripts/SoilAverage.m similarity index 100% rename from OctavePlugin/OctaveScripts/SoilAverage.m rename to Octave/OctavePlugin/OctaveScripts/SoilAverage.m diff --git a/OctavePlugin/OctaveScripts/SoilTimeDiff.m b/Octave/OctavePlugin/OctaveScripts/SoilTimeDiff.m similarity index 100% rename from OctavePlugin/OctaveScripts/SoilTimeDiff.m rename to Octave/OctavePlugin/OctaveScripts/SoilTimeDiff.m diff --git a/OctavePlugin/OctaveScripts/kaverage.m b/Octave/OctavePlugin/OctaveScripts/kaverage.m similarity index 100% rename from OctavePlugin/OctaveScripts/kaverage.m rename to Octave/OctavePlugin/OctaveScripts/kaverage.m diff --git a/OctavePlugin/OctaveScripts/kslice.m b/Octave/OctavePlugin/OctaveScripts/kslice.m similarity index 100% rename from OctavePlugin/OctaveScripts/kslice.m rename to Octave/OctavePlugin/OctaveScripts/kslice.m diff --git a/OctavePlugin/ResInsightOctaveInterfaceSpecification.txt b/Octave/OctavePlugin/ResInsightOctaveInterfaceSpecification.txt similarity index 100% rename from OctavePlugin/ResInsightOctaveInterfaceSpecification.txt rename to Octave/OctavePlugin/ResInsightOctaveInterfaceSpecification.txt diff --git a/OctavePlugin/riGetActiveCellCenters.cpp b/Octave/OctavePlugin/riGetActiveCellCenters.cpp similarity index 100% rename from OctavePlugin/riGetActiveCellCenters.cpp rename to Octave/OctavePlugin/riGetActiveCellCenters.cpp diff --git a/OctavePlugin/riGetActiveCellCorners.cpp b/Octave/OctavePlugin/riGetActiveCellCorners.cpp similarity index 100% rename from OctavePlugin/riGetActiveCellCorners.cpp rename to Octave/OctavePlugin/riGetActiveCellCorners.cpp diff --git a/OctavePlugin/riGetActiveCellInfo.cpp b/Octave/OctavePlugin/riGetActiveCellInfo.cpp similarity index 100% rename from OctavePlugin/riGetActiveCellInfo.cpp rename to Octave/OctavePlugin/riGetActiveCellInfo.cpp diff --git a/OctavePlugin/riGetActiveCellProperty.cpp b/Octave/OctavePlugin/riGetActiveCellProperty.cpp similarity index 100% rename from OctavePlugin/riGetActiveCellProperty.cpp rename to Octave/OctavePlugin/riGetActiveCellProperty.cpp diff --git a/OctavePlugin/riGetCaseGroups.cpp b/Octave/OctavePlugin/riGetCaseGroups.cpp similarity index 100% rename from OctavePlugin/riGetCaseGroups.cpp rename to Octave/OctavePlugin/riGetCaseGroups.cpp diff --git a/OctavePlugin/riGetCases.cpp b/Octave/OctavePlugin/riGetCases.cpp similarity index 100% rename from OctavePlugin/riGetCases.cpp rename to Octave/OctavePlugin/riGetCases.cpp diff --git a/OctavePlugin/riGetCellCenters.cpp b/Octave/OctavePlugin/riGetCellCenters.cpp similarity index 100% rename from OctavePlugin/riGetCellCenters.cpp rename to Octave/OctavePlugin/riGetCellCenters.cpp diff --git a/OctavePlugin/riGetCellCorners.cpp b/Octave/OctavePlugin/riGetCellCorners.cpp similarity index 100% rename from OctavePlugin/riGetCellCorners.cpp rename to Octave/OctavePlugin/riGetCellCorners.cpp diff --git a/OctavePlugin/riGetCoarseningInfo.cpp b/Octave/OctavePlugin/riGetCoarseningInfo.cpp similarity index 100% rename from OctavePlugin/riGetCoarseningInfo.cpp rename to Octave/OctavePlugin/riGetCoarseningInfo.cpp diff --git a/OctavePlugin/riGetCurrentCase.cpp b/Octave/OctavePlugin/riGetCurrentCase.cpp similarity index 100% rename from OctavePlugin/riGetCurrentCase.cpp rename to Octave/OctavePlugin/riGetCurrentCase.cpp diff --git a/OctavePlugin/riGetDynamicNNCValues.cpp b/Octave/OctavePlugin/riGetDynamicNNCValues.cpp similarity index 100% rename from OctavePlugin/riGetDynamicNNCValues.cpp rename to Octave/OctavePlugin/riGetDynamicNNCValues.cpp diff --git a/OctavePlugin/riGetGridDimensions.cpp b/Octave/OctavePlugin/riGetGridDimensions.cpp similarity index 100% rename from OctavePlugin/riGetGridDimensions.cpp rename to Octave/OctavePlugin/riGetGridDimensions.cpp diff --git a/OctavePlugin/riGetGridProperty.cpp b/Octave/OctavePlugin/riGetGridProperty.cpp similarity index 100% rename from OctavePlugin/riGetGridProperty.cpp rename to Octave/OctavePlugin/riGetGridProperty.cpp diff --git a/OctavePlugin/riGetGridPropertyForSelectedCells.cpp b/Octave/OctavePlugin/riGetGridPropertyForSelectedCells.cpp similarity index 100% rename from OctavePlugin/riGetGridPropertyForSelectedCells.cpp rename to Octave/OctavePlugin/riGetGridPropertyForSelectedCells.cpp diff --git a/OctavePlugin/riGetMainGridDimensions.cpp b/Octave/OctavePlugin/riGetMainGridDimensions.cpp similarity index 100% rename from OctavePlugin/riGetMainGridDimensions.cpp rename to Octave/OctavePlugin/riGetMainGridDimensions.cpp diff --git a/OctavePlugin/riGetNNCConnections.cpp b/Octave/OctavePlugin/riGetNNCConnections.cpp similarity index 100% rename from OctavePlugin/riGetNNCConnections.cpp rename to Octave/OctavePlugin/riGetNNCConnections.cpp diff --git a/OctavePlugin/riGetNNCPropertyNames.cpp b/Octave/OctavePlugin/riGetNNCPropertyNames.cpp similarity index 100% rename from OctavePlugin/riGetNNCPropertyNames.cpp rename to Octave/OctavePlugin/riGetNNCPropertyNames.cpp diff --git a/OctavePlugin/riGetPropertyNames.cpp b/Octave/OctavePlugin/riGetPropertyNames.cpp similarity index 100% rename from OctavePlugin/riGetPropertyNames.cpp rename to Octave/OctavePlugin/riGetPropertyNames.cpp diff --git a/OctavePlugin/riGetSelectedCases.cpp b/Octave/OctavePlugin/riGetSelectedCases.cpp similarity index 100% rename from OctavePlugin/riGetSelectedCases.cpp rename to Octave/OctavePlugin/riGetSelectedCases.cpp diff --git a/OctavePlugin/riGetSelectedCells.cpp b/Octave/OctavePlugin/riGetSelectedCells.cpp similarity index 100% rename from OctavePlugin/riGetSelectedCells.cpp rename to Octave/OctavePlugin/riGetSelectedCells.cpp diff --git a/OctavePlugin/riGetStaticNNCValues.cpp b/Octave/OctavePlugin/riGetStaticNNCValues.cpp similarity index 100% rename from OctavePlugin/riGetStaticNNCValues.cpp rename to Octave/OctavePlugin/riGetStaticNNCValues.cpp diff --git a/OctavePlugin/riGetTimeStepDates.cpp b/Octave/OctavePlugin/riGetTimeStepDates.cpp similarity index 100% rename from OctavePlugin/riGetTimeStepDates.cpp rename to Octave/OctavePlugin/riGetTimeStepDates.cpp diff --git a/OctavePlugin/riGetTimeStepDays.cpp b/Octave/OctavePlugin/riGetTimeStepDays.cpp similarity index 100% rename from OctavePlugin/riGetTimeStepDays.cpp rename to Octave/OctavePlugin/riGetTimeStepDays.cpp diff --git a/OctavePlugin/riGetWellCells.cpp b/Octave/OctavePlugin/riGetWellCells.cpp similarity index 100% rename from OctavePlugin/riGetWellCells.cpp rename to Octave/OctavePlugin/riGetWellCells.cpp diff --git a/OctavePlugin/riGetWellNames.cpp b/Octave/OctavePlugin/riGetWellNames.cpp similarity index 100% rename from OctavePlugin/riGetWellNames.cpp rename to Octave/OctavePlugin/riGetWellNames.cpp diff --git a/OctavePlugin/riGetWellStatus.cpp b/Octave/OctavePlugin/riGetWellStatus.cpp similarity index 100% rename from OctavePlugin/riGetWellStatus.cpp rename to Octave/OctavePlugin/riGetWellStatus.cpp diff --git a/OctavePlugin/riSetActiveCellProperty.cpp b/Octave/OctavePlugin/riSetActiveCellProperty.cpp similarity index 100% rename from OctavePlugin/riSetActiveCellProperty.cpp rename to Octave/OctavePlugin/riSetActiveCellProperty.cpp diff --git a/OctavePlugin/riSetGridProperty.cpp b/Octave/OctavePlugin/riSetGridProperty.cpp similarity index 100% rename from OctavePlugin/riSetGridProperty.cpp rename to Octave/OctavePlugin/riSetGridProperty.cpp diff --git a/OctavePlugin/riSetNNCProperty.cpp b/Octave/OctavePlugin/riSetNNCProperty.cpp similarity index 100% rename from OctavePlugin/riSetNNCProperty.cpp rename to Octave/OctavePlugin/riSetNNCProperty.cpp diff --git a/OctavePlugin/riSettings.h b/Octave/OctavePlugin/riSettings.h similarity index 97% rename from OctavePlugin/riSettings.h rename to Octave/OctavePlugin/riSettings.h index a10e41f869..aaf019bf2c 100644 --- a/OctavePlugin/riSettings.h +++ b/Octave/OctavePlugin/riSettings.h @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "../ApplicationLibCode/SocketInterface/RiaSocketServerDefines.h" +#include "../../ApplicationLibCode/SocketInterface/RiaSocketServerDefines.h" namespace riOctavePlugin { diff --git a/Octave/cmake/FindOctave.cmake b/Octave/cmake/FindOctave.cmake new file mode 100644 index 0000000000..a616b58e35 --- /dev/null +++ b/Octave/cmake/FindOctave.cmake @@ -0,0 +1,205 @@ +# - Find Octave +# GNU Octave is a high-level interpreted language, primarily intended for numerical computations. +# available at http://www.gnu.org/software/octave/ +# +# This module defines: +# OCTAVE_EXECUTABLE - octave interpreter +# OCTAVE_INCLUDE_DIRS - include path for mex.h, mexproto.h +# OCTAVE_LIBRARIES - required libraries: octinterp, octave, cruft +# OCTAVE_OCTINTERP_LIBRARY - path to the library octinterp +# OCTAVE_OCTAVE_LIBRARY - path to the library octave +# OCTAVE_CRUFT_LIBRARY - path to the library cruft +# OCTAVE_VERSION_STRING - octave version string +# OCTAVE_MAJOR_VERSION - major version +# OCTAVE_MINOR_VERSION - minor version +# OCTAVE_PATCH_VERSION - patch version +# OCTAVE_OCT_FILE_DIR - object files that will be dynamically loaded +# OCTAVE_OCT_LIB_DIR - oct libraries +# OCTAVE_ROOT_DIR - octave prefix +# OCTAVE_M_SITE_DIR - .m files site dir +# OCTAVE_OCT_SITE_DIR - .oct files site dir +# +# The macro octave_add_oct allows to create compiled modules. +# octave_add_oct (target_name +# [SOURCES] source1 [source2 ...] +# [LINK_LIBRARIES lib1 [lib2 ...]] +# [EXTENSION ext] +#) +# +# To install it, you can the use the variable OCTAVE_OCT_FILE_DIR as follow: +# file (RELATIVE_PATH PKG_OCTAVE_OCT_SITE_DIR ${OCTAVE_ROOT_DIR} ${OCTAVE_OCT_SITE_DIR}) +# install ( +# TARGETS target_name +# DESTINATION ${PKG_OCTAVE_OCT_SITE_DIR} +#) + + +#============================================================================= +# Copyright 2013, Julien Schueller +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# The views and conclusions contained in the software and documentation are those +# of the authors and should not be interpreted as representing official policies, +# either expressed or implied, of the FreeBSD Project. +#============================================================================= + +find_program(OCTAVE_CONFIG_EXECUTABLE + NAMES octave-config + ) + + +if (OCTAVE_CONFIG_EXECUTABLE) + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTAVE_HOME + OUTPUT_VARIABLE OCTAVE_ROOT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} --m-site-dir + OUTPUT_VARIABLE OCTAVE_M_SITE_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} --oct-site-dir + OUTPUT_VARIABLE OCTAVE_OCT_SITE_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p BINDIR + OUTPUT_VARIABLE OCTAVE_BIN_PATHS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTINCLUDEDIR + OUTPUT_VARIABLE OCTAVE_INCLUDE_PATHS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTLIBDIR + OUTPUT_VARIABLE OCTAVE_LIBRARIES_PATHS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTFILEDIR + OUTPUT_VARIABLE OCTAVE_OCT_FILE_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTLIBDIR + OUTPUT_VARIABLE OCTAVE_OCT_LIB_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -v + OUTPUT_VARIABLE OCTAVE_VERSION_STRING + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (OCTAVE_VERSION_STRING) + string (REGEX REPLACE "([0-9]+)\\..*" "\\1" OCTAVE_MAJOR_VERSION ${OCTAVE_VERSION_STRING}) + string (REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" OCTAVE_MINOR_VERSION ${OCTAVE_VERSION_STRING}) + string (REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OCTAVE_PATCH_VERSION ${OCTAVE_VERSION_STRING}) + endif () +endif () + + +find_program(OCTAVE_EXECUTABLE + HINTS ${OCTAVE_BIN_PATHS} + NAMES octave + ) + +find_program(OCTAVE_MKOCTFILE + HINTS ${OCTAVE_BIN_PATHS} + NAMES mkoctfile + ) + +find_library(OCTAVE_OCTINTERP_LIBRARY + NAMES octinterp liboctinterp + HINTS ${OCTAVE_LIBRARIES_PATHS} + ) +find_library(OCTAVE_OCTAVE_LIBRARY + NAMES octave liboctave + HINTS ${OCTAVE_LIBRARIES_PATHS} + ) +find_library(OCTAVE_CRUFT_LIBRARY + NAMES cruft libcruft + HINTS ${OCTAVE_LIBRARIES_PATHS} + ) + +set (OCTAVE_LIBRARIES ${OCTAVE_OCTINTERP_LIBRARY}) +list (APPEND OCTAVE_LIBRARIES ${OCTAVE_OCTAVE_LIBRARY}) +if (OCTAVE_CRUFT_LIBRARY) + list (APPEND OCTAVE_LIBRARIES ${OCTAVE_CRUFT_LIBRARY}) +endif () + +find_path (OCTAVE_INCLUDE_DIR + NAMES octave/oct.h + PATHS "${OCTAVE_INCLUDE_PATHS}/.." + ) + +set (OCTAVE_INCLUDE_DIRS ${OCTAVE_INCLUDE_DIR} ${OCTAVE_INCLUDE_DIR}/octave) + + +macro (octave_add_oct FUNCTIONNAME) + set (_CMD SOURCES) + set (_SOURCES) + set (_LINK_LIBRARIES) + set (_EXTENSION) + set (_OCT_EXTENSION oct) + foreach (_ARG ${ARGN}) + if (${_ARG} MATCHES SOURCES) + set (_CMD SOURCES) + elseif (${_ARG} MATCHES LINK_LIBRARIES) + set (_CMD LINK_LIBRARIES) + elseif (${_ARG} MATCHES EXTENSION) + set (_CMD EXTENSION) + else () + if (${_CMD} MATCHES SOURCES) + list (APPEND _SOURCES "${_ARG}") + elseif (${_CMD} MATCHES LINK_LIBRARIES) + list (APPEND _LINK_LIBRARIES "${_ARG}") + elseif (${_CMD} MATCHES EXTENSION) + set (_OCT_EXTENSION ${_ARG}) + endif () + endif () + endforeach () + add_library (${FUNCTIONNAME} SHARED ${_SOURCES}) + target_link_libraries (${FUNCTIONNAME} ${OCTAVE_LIBRARIES} ${_LINK_LIBRARIES}) + set_target_properties (${FUNCTIONNAME} PROPERTIES + PREFIX "" + SUFFIX ".${_OCT_EXTENSION}" +) +endmacro () + + +# handle REQUIRED and QUIET options +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args (Octave REQUIRED_VARS OCTAVE_EXECUTABLE OCTAVE_ROOT_DIR OCTAVE_INCLUDE_DIRS OCTAVE_LIBRARIES VERSION_VAR OCTAVE_VERSION_STRING) + + +mark_as_advanced ( + OCTAVE_OCT_FILE_DIR + OCTAVE_OCT_LIB_DIR + OCTAVE_OCTINTERP_LIBRARY + OCTAVE_OCTAVE_LIBRARY + OCTAVE_CRUFT_LIBRARY + OCTAVE_LIBRARIES + OCTAVE_INCLUDE_DIR + OCTAVE_INCLUDE_DIRS + OCTAVE_ROOT_DIR + OCTAVE_VERSION_STRING + OCTAVE_MAJOR_VERSION + OCTAVE_MINOR_VERSION + OCTAVE_PATCH_VERSION +) + + diff --git a/Octave/cmake/cmake-format.py b/Octave/cmake/cmake-format.py new file mode 100644 index 0000000000..3dde4ae4ac --- /dev/null +++ b/Octave/cmake/cmake-format.py @@ -0,0 +1,20 @@ +# ----------------------------- +# Options effecting formatting. +# See: https://github.com/cheshirekow/cmake_format +# ----------------------------- +with section("format"): + # How wide to allow formatted cmake files + line_width = 80 + + # How many spaces to tab for indent + tab_size = 2 + + # If true, separate flow control names from their parentheses with a space + separate_ctrl_name_with_space = False + + # If true, separate function names from parentheses with a space + separate_fn_name_with_space = False + + # If a statement is wrapped to more than one line, than dangle the closing + # parenthesis on its own line. + dangle_parens = True diff --git a/OctavePlugin/CMakeLists.txt b/OctavePlugin/CMakeLists.txt deleted file mode 100644 index 950862c362..0000000000 --- a/OctavePlugin/CMakeLists.txt +++ /dev/null @@ -1,262 +0,0 @@ - -# Some of the functionality in this CMakeLists.txt might be easier to maintain if we use a CMake macro to find configuration info for Octave -# This file is currently (2.8.12) not part of default CMake installation -# See http://www.cmake.org/Wiki/CMakeUserFindOctave - -set(CPP_SOURCES - riGetActiveCellProperty.cpp - riSetActiveCellProperty.cpp - riGetActiveCellInfo.cpp - riGetMainGridDimensions.cpp - riGetNNCConnections.cpp - riGetNNCPropertyNames.cpp - riGetCurrentCase.cpp - riGetCaseGroups.cpp - riGetDynamicNNCValues.cpp - riGetStaticNNCValues.cpp - riGetSelectedCases.cpp - riGetSelectedCells.cpp - riGetCases.cpp - riGetTimeStepDates.cpp - riGetTimeStepDays.cpp - riGetGridDimensions.cpp - riGetCoarseningInfo.cpp - riGetCellCenters.cpp - riGetActiveCellCenters.cpp - riGetCellCorners.cpp - riGetActiveCellCorners.cpp - riGetGridProperty.cpp - riSetGridProperty.cpp - riGetGridPropertyForSelectedCells.cpp - riGetPropertyNames.cpp - riGetWellNames.cpp - riGetWellStatus.cpp - riGetWellCells.cpp - riSetNNCProperty.cpp -) - -if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - # since the compiler passes the option to the linker, double quoting is necessary - set (RPATH_COMMAND "-Wl,-rpath,'\\$$ORIGIN'") -endif() - -# recreate the magic that CMake does for MacOS X frameworks in the -# include list when we call mkoctfile as a custom command -if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set (QT_INCLUDES) - set (QT_FRAMEWORKS) - # QT_INCLUDE_DIR contains two items; the first is the directory - # containing header files, the second is the framework. This - # setup is specially processed in include_directories (); CMake - # will add -F before the frameworks. We will have to replicate - # that setup here when we want to pass it directly to a command - # see - foreach (item IN ITEMS ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_INCLUDE_DIR}) - if ("${item}" MATCHES ".framework$") - get_filename_component (frmwrk_path ${item} PATH) - get_filename_component (frmwrk_name ${item} NAME_WE) - # mkoctfile doesn't support arbitrary compiler command, - # so we must wrap in -Wl, to pass to the linker - list (APPEND QT_FRAMEWORKS "-Wl,-F${frmwrk_path}") - list (APPEND QT_FRAMEWORKS "-Wl,-framework,${frmwrk_name}") - else () - list (APPEND QT_INCLUDES "-I${item}") - endif () - endforeach (item) - if (QT_INCLUDES) - list (REMOVE_DUPLICATES QT_INCLUDES) - endif () - if (QT_FRAMEWORKS) - list (REMOVE_DUPLICATES QT_FRAMEWORKS) - endif () -endif () - -message (STATUS "Compiling Octave plugins using : ${OCTAVE_MKOCTFILE}") - -if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - option(RESINSIGHT_OCTAVE_PLUGIN_QT "Compile Octave plugin using Qt located insided Octave root folder" ON) -endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - -if(RESINSIGHT_OCTAVE_PLUGIN_QT) - - message(STATUS "Compiling Octave plugins using custom Qt located at ${OCTAVE_ROOT_DIR}") - - if (EXISTS ${OCTAVE_ROOT_DIR}/qt5) - SET(OCTAVE_QT_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/qt5/include) - SET(OCTAVE_QT_QTCORE_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/qt5/include/QtCore) - SET(OCTAVE_QT_QTNETWORK_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/qt5/include/QtNetwork) - SET(OCTAVE_QT_LIBRARY_DIR ${OCTAVE_ROOT_DIR}/qt5/lib) - SET(OCTAVE_QT_QTCORE_LIB Qt5Core) - SET(OCTAVE_QT_QTNETWORK_LIB Qt5Network) - else () - SET(OCTAVE_QT_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include) - SET(OCTAVE_QT_QTCORE_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include/QtCore) - SET(OCTAVE_QT_QTNETWORK_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include/QtNetwork) - SET(OCTAVE_QT_LIBRARY_DIR ${OCTAVE_ROOT_DIR}/lib) - SET(OCTAVE_QT_QTCORE_LIB QtCore4) - SET(OCTAVE_QT_QTNETWORK_LIB QtNetwork4) - endif(EXISTS ${OCTAVE_ROOT_DIR}/qt5) - -else() - - if (Qt5Core_FOUND) - message(STATUS "Compiling Octave plugins using system Qt5") - - SET(OCTAVE_QT_QTCORE_INCLUDE_DIR ${Qt5Core_INCLUDE_DIRS}) - SET(OCTAVE_QT_QTNETWORK_INCLUDE_DIR ${Qt5Network_INCLUDE_DIRS}) - SET(OCTAVE_QT_LIBRARY_DIR ${QT_LIBRARY_DIR}) - SET(OCTAVE_QT_QTCORE_LIB Qt5Core) - SET(OCTAVE_QT_QTNETWORK_LIB Qt5Network) - - endif(Qt5Core_FOUND) - -endif(RESINSIGHT_OCTAVE_PLUGIN_QT) - -list (APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_INCLUDE_DIR}) -list (APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_QTCORE_INCLUDE_DIR}) -list (APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_QTNETWORK_INCLUDE_DIR}) - - -# Add socket interface source code folder -list (APPEND MKOCTFILE_INCLUDE_DIRS ${ResInsight_SOURCE_DIR}/ApplicationLibCode/SocketInterface) - -list (REMOVE_DUPLICATES MKOCTFILE_INCLUDE_DIRS) -foreach (item ${MKOCTFILE_INCLUDE_DIRS}) - list (APPEND MKOCTFILE_INCLUDE_TEMP -I${item}) -endforeach (item) - -string( REPLACE ";" " " MKOCTFILE_INCLUDE_TEMP "${MKOCTFILE_INCLUDE_TEMP}" ) - -# Use special command to avoid double quoting in add_custom_command() -separate_arguments(MKOCTFILE_INCLUDE_COMMAND_STRING WINDOWS_COMMAND "${MKOCTFILE_INCLUDE_TEMP}") - - -# Clear the list of binary oct files to be produced -set(OCTAVE_BINARY_OCT_FILES) - -if (OCTAVE_MKOCTFILE) - foreach(srcFileName IN LISTS CPP_SOURCES) - - if(NOT IS_ABSOLUTE "${srcFileName}") - set(srcFileName "${CMAKE_CURRENT_SOURCE_DIR}/${srcFileName}") - endif() - - get_filename_component(baseFilename "${srcFileName}" NAME_WE) - - set(octFileName "${CMAKE_CURRENT_BINARY_DIR}/${baseFilename}.oct") - - if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_custom_command( - OUTPUT "${octFileName}" - COMMAND set "OCTAVE_HOME=${OCTAVE_ROOT_DIR}" - COMMAND set "PATH=%OCTAVE_HOME%\\bin;%PATH%" - COMMAND ${OCTAVE_MKOCTFILE} - ${MKOCTFILE_INCLUDE_COMMAND_STRING} - ${RPATH_COMMAND} - -L${OCTAVE_QT_LIBRARY_DIR} - -l${OCTAVE_QT_QTCORE_LIB} - -l${OCTAVE_QT_QTNETWORK_LIB} - -o "${octFileName}" "${srcFileName}" - DEPENDS "${srcFileName}" - COMMENT "===> Generating ${octFileName}" - ) - elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - add_custom_command( - OUTPUT "${octFileName}" - COMMAND ${OCTAVE_MKOCTFILE} - ${QT_INCLUDES} - ${QT_FRAMEWORKS} - -I${ResInsight_SOURCE_DIR}/ApplicationLibCode/SocketInterface - ${RPATH_COMMAND} - -L${QT_LIBRARY_DIR} -Wl,-framework,QtCore -Wl,-framework,QtNetwork - -o "${octFileName}" - "${srcFileName}" - DEPENDS "${srcFileName}" - COMMENT "===> Generating ${octFileName}" - ) - else() - add_custom_command( - OUTPUT "${octFileName}" - COMMAND OCTAVE_HOME=${OCTAVE_ROOT_DIR} - ${OCTAVE_MKOCTFILE} - ${MKOCTFILE_INCLUDE_COMMAND_STRING} - ${RPATH_COMMAND} - -L${OCTAVE_QT_LIBRARY_DIR} - -l${OCTAVE_QT_QTCORE_LIB} - -l${OCTAVE_QT_QTNETWORK_LIB} - -o "${octFileName}" "${srcFileName}" - DEPENDS "${srcFileName}" - COMMENT "===> Generating ${octFileName}" - ) - endif() - - list(APPEND OCTAVE_BINARY_OCT_FILES "${octFileName}") - - endforeach() - -# Create depencedy string represeting the full path to all generated oct-files -foreach (item ${CPP_SOURCES}) - string( REPLACE ".cpp" ".oct" item ${item}) - list (APPEND DEPENDENCY_STRING ${CMAKE_CURRENT_BINARY_DIR}/${item}) -endforeach (item) - -#message("DEPENDENCY_STRING : ${DEPENDENCY_STRING}") - -add_custom_target(octave_plugins ALL DEPENDS - ${DEPENDENCY_STRING} - SOURCES - ${CPP_SOURCES} - riSettings.h - ) - - # Copy Octave generated *.oct files to application folder, will make it possible to use Octave functions - # directly from the location of the ResInsight binaries - if (true) - foreach (oct_bin ${OCTAVE_BINARY_OCT_FILES}) - - get_filename_component(Filename "${oct_bin}" NAME) - - if(MSVC) - add_custom_command(TARGET octave_plugins POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${oct_bin}" - "${CMAKE_CURRENT_BINARY_DIR}/../ApplicationExeCode/$/${Filename}" - ) - else() - add_custom_command(TARGET octave_plugins POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${oct_bin}" - "${CMAKE_CURRENT_BINARY_DIR}/../ApplicationExeCode/${Filename}" - ) - endif() - endforeach( oct_bin ) - endif() - - # Make ResInsight dependant on Octave, makes it easiser to debug Octave functionality by compiling ResInsight - add_dependencies(ResInsight octave_plugins) - - - if (RESINSIGHT_PRIVATE_INSTALL) - install(FILES ${OCTAVE_BINARY_OCT_FILES} DESTINATION ${RESINSIGHT_INSTALL_FOLDER}) - else (RESINSIGHT_PRIVATE_INSTALL) - # probe for site location of .oct files - if (NOT OCTAVE_SITE_OCT_DIR) - find_program (OCTAVE_CONFIG_COMMAND - octave-config - DOC "Path to Octave component and library information retrieval" - ) - exec_program (${OCTAVE_CONFIG_COMMAND} - ARGS --oct-site-dir - OUTPUT_VARIABLE OCTAVE_SITE_OCT_DIR - ) - set (OCTAVE_SITE_OCT_DIR "${OCTAVE_SITE_OCT_DIR}" CACHE LOCATION "Octave plugin directory") - endif (NOT OCTAVE_SITE_OCT_DIR) - - install (FILES ${OCTAVE_BINARY_OCT_FILES} - DESTINATION ${OCTAVE_SITE_OCT_DIR} - ) - endif (RESINSIGHT_PRIVATE_INSTALL) - -endif (OCTAVE_MKOCTFILE) - - From 3b5621a6aa5e6b0e2d0a368d62c4f583eb73c4d4 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 3 Jun 2024 19:49:07 +0200 Subject: [PATCH 102/332] Messages Display: show left part of long log lines. --- ApplicationLibCode/UserInterface/RiuMessagePanel.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/ApplicationLibCode/UserInterface/RiuMessagePanel.cpp b/ApplicationLibCode/UserInterface/RiuMessagePanel.cpp index a4fb4dd7e3..1b48f3e384 100644 --- a/ApplicationLibCode/UserInterface/RiuMessagePanel.cpp +++ b/ApplicationLibCode/UserInterface/RiuMessagePanel.cpp @@ -79,9 +79,6 @@ void RiuMessagePanel::addMessage( RILogLevel messageLevel, const QString& msg ) m_textEdit->setCurrentCharFormat( form ); m_textEdit->appendPlainText( msg ); - m_textEdit->moveCursor( QTextCursor::End ); - m_textEdit->ensureCursorVisible(); - if ( !RiaRegressionTestRunner::instance()->isRunningRegressionTests() ) { if ( messageLevel == RILogLevel::RI_LL_ERROR || messageLevel == RILogLevel::RI_LL_WARNING ) From 27339a91fadd908ad62cc177adb96058abf3e37f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 4 Jun 2024 15:07:23 +0200 Subject: [PATCH 103/332] Guard nullpointer crash --- .../Intersections/RimIntersectionCollection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp index 81d138bd53..8781b96c4f 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp @@ -537,7 +537,7 @@ void RimIntersectionCollection::defineEditorAttribute( const caf::PdmFieldHandle { RimEclipseView* eclView = eclipseView(); - if ( eclView ) + if ( eclView && eclView->mainGrid() ) { const cvf::BoundingBox bb = eclView->mainGrid()->boundingBox(); From a952fbce7e604d2771dce2c2e727514c6f991a00 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 5 Jun 2024 10:59:04 +0200 Subject: [PATCH 104/332] Move function to RiaProjectFileTools Rename to RiaProjectFileTools --- .../Application/Tools/CMakeLists_files.cmake | 4 +- ...rsionTools.cpp => RiaProjectFileTools.cpp} | 60 +++++++++---------- ...leVersionTools.h => RiaProjectFileTools.h} | 40 ++++++++++++- .../ProjectDataModel/RimProject.cpp | 6 +- .../ProjectDataModel/RimProject.h | 42 ------------- ApplicationLibCode/UnitTests/CMakeLists.txt | 2 +- ...-Test.cpp => RiaProjectFileTools-Test.cpp} | 16 ++--- 7 files changed, 81 insertions(+), 89 deletions(-) rename ApplicationLibCode/Application/Tools/{RiaProjectFileVersionTools.cpp => RiaProjectFileTools.cpp} (56%) rename ApplicationLibCode/Application/Tools/{RiaProjectFileVersionTools.h => RiaProjectFileTools.h} (61%) rename ApplicationLibCode/UnitTests/{RiaProjectFileVersionTools-Test.cpp => RiaProjectFileTools-Test.cpp} (84%) diff --git a/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake b/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake index ceb110c3a9..94101bebfe 100644 --- a/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake @@ -18,7 +18,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaInterpolationTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryAddressAnalyzer.h ${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.h - ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.h + ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.h @@ -77,7 +77,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaInterpolationTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryAddressAnalyzer.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.cpp - ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.cpp diff --git a/ApplicationLibCode/Application/Tools/RiaProjectFileVersionTools.cpp b/ApplicationLibCode/Application/Tools/RiaProjectFileTools.cpp similarity index 56% rename from ApplicationLibCode/Application/Tools/RiaProjectFileVersionTools.cpp rename to ApplicationLibCode/Application/Tools/RiaProjectFileTools.cpp index 8741e46817..962d8b1ba9 100644 --- a/ApplicationLibCode/Application/Tools/RiaProjectFileVersionTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaProjectFileTools.cpp @@ -16,51 +16,47 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RiaProjectFileVersionTools.h" +#include "RiaProjectFileTools.h" #include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiaProjectFileVersionTools::isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& projectFileVersion ) +bool RiaProjectFileTools::isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& projectFileVersion ) { int candidateMajorVersion = 0; int candidateMinorVersion = 0; int candidatePatchNumber = -1; int candidateDevelopmentId = -1; - RiaProjectFileVersionTools::decodeVersionString( candidateProjectFileVersion, - &candidateMajorVersion, - &candidateMinorVersion, - &candidatePatchNumber, - &candidateDevelopmentId ); + RiaProjectFileTools::decodeVersionString( candidateProjectFileVersion, + &candidateMajorVersion, + &candidateMinorVersion, + &candidatePatchNumber, + &candidateDevelopmentId ); int majorVersion = 0; int minorVersion = 0; int patchNumber = -1; int developmentId = -1; - RiaProjectFileVersionTools::decodeVersionString( projectFileVersion, &majorVersion, &minorVersion, &patchNumber, &developmentId ); + RiaProjectFileTools::decodeVersionString( projectFileVersion, &majorVersion, &minorVersion, &patchNumber, &developmentId ); - return RiaProjectFileVersionTools::isCandidateNewerThanOther( candidateMajorVersion, - candidateMinorVersion, - candidatePatchNumber, - candidateDevelopmentId, - majorVersion, - minorVersion, - patchNumber, - developmentId ); + return RiaProjectFileTools::isCandidateNewerThanOther( candidateMajorVersion, + candidateMinorVersion, + candidatePatchNumber, + candidateDevelopmentId, + majorVersion, + minorVersion, + patchNumber, + developmentId ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaProjectFileVersionTools::decodeVersionString( const QString& projectFileVersion, - int* majorVersion, - int* minorVersion, - int* patch, - int* developmentId ) +void RiaProjectFileTools::decodeVersionString( const QString& projectFileVersion, int* majorVersion, int* minorVersion, int* patch, int* developmentId ) { if ( projectFileVersion.isEmpty() ) return; @@ -79,7 +75,7 @@ void RiaProjectFileVersionTools::decodeVersionString( const QString& projectFile if ( subStrings.size() > 2 ) { QString candidate = subStrings[2]; - QString candidateDigitsOnly = RiaProjectFileVersionTools::stringOfDigits( candidate ); + QString candidateDigitsOnly = RiaProjectFileTools::stringOfDigits( candidate ); *patch = candidateDigitsOnly.toInt(); } @@ -87,7 +83,7 @@ void RiaProjectFileVersionTools::decodeVersionString( const QString& projectFile if ( subStrings.size() > 3 ) { QString candidate = subStrings.back(); - QString candidateDigitsOnly = RiaProjectFileVersionTools::stringOfDigits( candidate ); + QString candidateDigitsOnly = RiaProjectFileTools::stringOfDigits( candidate ); *developmentId = candidateDigitsOnly.toInt(); } @@ -96,14 +92,14 @@ void RiaProjectFileVersionTools::decodeVersionString( const QString& projectFile //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiaProjectFileVersionTools::isCandidateNewerThanOther( int candidateMajorVersion, - int candidateMinorVersion, - int candidatePatchNumber, - int candidateDevelopmentId, - int otherMajorVersion, - int otherMinorVersion, - int otherPatchNumber, - int otherDevelopmentId ) +bool RiaProjectFileTools::isCandidateNewerThanOther( int candidateMajorVersion, + int candidateMinorVersion, + int candidatePatchNumber, + int candidateDevelopmentId, + int otherMajorVersion, + int otherMinorVersion, + int otherPatchNumber, + int otherDevelopmentId ) { if ( candidateMajorVersion != otherMajorVersion ) { @@ -137,7 +133,7 @@ bool RiaProjectFileVersionTools::isCandidateNewerThanOther( int candidateMajorVe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaProjectFileVersionTools::stringOfDigits( const QString& string ) +QString RiaProjectFileTools::stringOfDigits( const QString& string ) { QString digitsOnly; diff --git a/ApplicationLibCode/Application/Tools/RiaProjectFileVersionTools.h b/ApplicationLibCode/Application/Tools/RiaProjectFileTools.h similarity index 61% rename from ApplicationLibCode/Application/Tools/RiaProjectFileVersionTools.h rename to ApplicationLibCode/Application/Tools/RiaProjectFileTools.h index d473d25f46..b65199a3be 100644 --- a/ApplicationLibCode/Application/Tools/RiaProjectFileVersionTools.h +++ b/ApplicationLibCode/Application/Tools/RiaProjectFileTools.h @@ -18,12 +18,17 @@ #pragma once +#include "cafPdmField.h" +#include "cafPdmObjectHandle.h" + #include +#include + //================================================================================================== // //================================================================================================== -class RiaProjectFileVersionTools +class RiaProjectFileTools { public: static bool isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& otherProjectFileVersion ); @@ -31,6 +36,39 @@ class RiaProjectFileVersionTools // Public to be able to unit test function, not intended to be used static void decodeVersionString( const QString& projectFileVersion, int* majorVersion, int* minorVersion, int* patch, int* developmentId ); + template + static void fieldContentsByType( const caf::PdmObjectHandle* object, std::vector& fieldContents ) + { + if ( !object ) return; + + std::vector allFieldsInObject = object->fields(); + + std::vector children; + + for ( const auto& field : allFieldsInObject ) + { + caf::PdmField* typedField = dynamic_cast*>( field ); + if ( typedField ) fieldContents.push_back( &typedField->v() ); + + caf::PdmField>* typedFieldInVector = dynamic_cast>*>( field ); + if ( typedFieldInVector ) + { + for ( T& typedFieldFromVector : typedFieldInVector->v() ) + { + fieldContents.push_back( &typedFieldFromVector ); + } + } + + auto other = field->children(); + children.insert( children.end(), other.begin(), other.end() ); + } + + for ( const auto& child : children ) + { + fieldContentsByType( child, fieldContents ); + } + } + private: static bool isCandidateNewerThanOther( int candidateMajorVersion, int candidateMinorVersion, diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 18b1710b5c..5b6605f265 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -26,7 +26,7 @@ #include "RiaGuiApplication.h" #include "RiaPreferences.h" #include "RiaProjectBackupTools.h" -#include "RiaProjectFileVersionTools.h" +#include "RiaProjectFileTools.h" #include "RiaTextStringTools.h" #include "RiaVersionInfo.h" @@ -479,7 +479,7 @@ bool RimProject::isProjectFileVersionEqualOrOlderThan( const QString& otherProje { QString candidateProjectFileVersion = projectFileVersionString(); - return !RiaProjectFileVersionTools::isCandidateVersionNewerThanOther( candidateProjectFileVersion, otherProjectFileVersion ); + return !RiaProjectFileTools::isCandidateVersionNewerThanOther( candidateProjectFileVersion, otherProjectFileVersion ); } //-------------------------------------------------------------------------------------------------- @@ -1336,7 +1336,7 @@ RimPlotTemplateFolderItem* RimProject::rootPlotTemplateItem() const std::vector RimProject::allFilePaths() const { std::vector filePaths; - fieldContentsByType( this, filePaths ); + RiaProjectFileTools::fieldContentsByType( this, filePaths ); return filePaths; } diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.h b/ApplicationLibCode/ProjectDataModel/RimProject.h index 0809df9649..97d69a8311 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.h +++ b/ApplicationLibCode/ProjectDataModel/RimProject.h @@ -204,9 +204,6 @@ class RimProject : public caf::PdmDocument void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; private: - template - static void fieldContentsByType( const caf::PdmObjectHandle* object, std::vector& fieldContents ); - void transferPathsToGlobalPathList(); void distributePathsFromGlobalPathList(); @@ -239,42 +236,3 @@ class RimProject : public caf::PdmDocument caf::PdmChildArrayField casesObsolete; // obsolete caf::PdmChildArrayField caseGroupsObsolete; // obsolete }; - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -template -void RimProject::fieldContentsByType( const caf::PdmObjectHandle* object, std::vector& fieldContents ) -{ - if ( !object ) return; - - std::vector allFieldsInObject = object->fields(); - - std::vector children; - - for ( const auto& field : allFieldsInObject ) - { - auto xmlFieldCapability = field->xmlCapability(); - if ( xmlFieldCapability && !xmlFieldCapability->isIOWritable() ) continue; - - caf::PdmField* typedField = dynamic_cast*>( field ); - if ( typedField ) fieldContents.push_back( &typedField->v() ); - - caf::PdmField>* typedFieldInVector = dynamic_cast>*>( field ); - if ( typedFieldInVector ) - { - for ( T& typedFieldFromVector : typedFieldInVector->v() ) - { - fieldContents.push_back( &typedFieldFromVector ); - } - } - - auto other = field->children(); - children.insert( children.end(), other.begin(), other.end() ); - } - - for ( const auto& child : children ) - { - fieldContentsByType( child, fieldContents ); - } -} diff --git a/ApplicationLibCode/UnitTests/CMakeLists.txt b/ApplicationLibCode/UnitTests/CMakeLists.txt index c6cb4e19be..8a276f4732 100644 --- a/ApplicationLibCode/UnitTests/CMakeLists.txt +++ b/ApplicationLibCode/UnitTests/CMakeLists.txt @@ -34,7 +34,7 @@ set(SOURCE_UNITTEST_FILES ${CMAKE_CURRENT_LIST_DIR}/FixedWidthDataParser-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RigTimeCurveHistoryMerger-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/ListKeywordsForObjectsAndFields-Test.cpp - ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileTools-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimRelocatePath-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp diff --git a/ApplicationLibCode/UnitTests/RiaProjectFileVersionTools-Test.cpp b/ApplicationLibCode/UnitTests/RiaProjectFileTools-Test.cpp similarity index 84% rename from ApplicationLibCode/UnitTests/RiaProjectFileVersionTools-Test.cpp rename to ApplicationLibCode/UnitTests/RiaProjectFileTools-Test.cpp index bfecd864cf..83a9932d69 100644 --- a/ApplicationLibCode/UnitTests/RiaProjectFileVersionTools-Test.cpp +++ b/ApplicationLibCode/UnitTests/RiaProjectFileTools-Test.cpp @@ -1,10 +1,10 @@ #include "gtest/gtest.h" -#include "RiaProjectFileVersionTools.h" +#include "RiaProjectFileTools.h" #include -TEST( RiaProjectFileVersionTools, DecodeProjectVersionString ) +TEST( RiaProjectFileTools, DecodeProjectVersionString ) { { int majorVersion = -1; @@ -13,7 +13,7 @@ TEST( RiaProjectFileVersionTools, DecodeProjectVersionString ) int developmentId = -1; QString projectFileVersionString = "2017.05.1"; - RiaProjectFileVersionTools::decodeVersionString( projectFileVersionString, &majorVersion, &minorVersion, &patchNumber, &developmentId ); + RiaProjectFileTools::decodeVersionString( projectFileVersionString, &majorVersion, &minorVersion, &patchNumber, &developmentId ); EXPECT_EQ( 2017, majorVersion ); EXPECT_EQ( 5, minorVersion ); @@ -28,7 +28,7 @@ TEST( RiaProjectFileVersionTools, DecodeProjectVersionString ) int developmentId = -1; QString projectFileVersionString = ""; - RiaProjectFileVersionTools::decodeVersionString( projectFileVersionString, &majorVersion, &minorVersion, &patchNumber, &developmentId ); + RiaProjectFileTools::decodeVersionString( projectFileVersionString, &majorVersion, &minorVersion, &patchNumber, &developmentId ); EXPECT_EQ( -1, majorVersion ); EXPECT_EQ( -1, minorVersion ); @@ -43,7 +43,7 @@ TEST( RiaProjectFileVersionTools, DecodeProjectVersionString ) int developmentId = -1; QString projectFileVersionString = "2017.05.2-dev.23"; - RiaProjectFileVersionTools::decodeVersionString( projectFileVersionString, &majorVersion, &minorVersion, &patchNumber, &developmentId ); + RiaProjectFileTools::decodeVersionString( projectFileVersionString, &majorVersion, &minorVersion, &patchNumber, &developmentId ); EXPECT_EQ( 2017, majorVersion ); EXPECT_EQ( 5, minorVersion ); @@ -58,7 +58,7 @@ TEST( RiaProjectFileVersionTools, DecodeProjectVersionString ) int developmentId = -1; QString projectFileVersionString = "2017.05.2-dev.long.text..23"; - RiaProjectFileVersionTools::decodeVersionString( projectFileVersionString, &majorVersion, &minorVersion, &patchNumber, &developmentId ); + RiaProjectFileTools::decodeVersionString( projectFileVersionString, &majorVersion, &minorVersion, &patchNumber, &developmentId ); EXPECT_EQ( 2017, majorVersion ); EXPECT_EQ( 5, minorVersion ); @@ -67,7 +67,7 @@ TEST( RiaProjectFileVersionTools, DecodeProjectVersionString ) } } -TEST( RiaProjectFileVersionTools, OrderKnownVersionStrings ) +TEST( RiaProjectFileTools, OrderKnownVersionStrings ) { QStringList versionStrings; { @@ -141,7 +141,7 @@ TEST( RiaProjectFileVersionTools, OrderKnownVersionStrings ) QStringList sortedVersionList = versionStrings; { - std::sort( sortedVersionList.begin(), sortedVersionList.end(), RiaProjectFileVersionTools::isCandidateVersionNewerThanOther ); + std::sort( sortedVersionList.begin(), sortedVersionList.end(), RiaProjectFileTools::isCandidateVersionNewerThanOther ); } /* From beccd2454ed1296530b75b6eeb7a75418fa370fd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 5 Jun 2024 09:32:44 +0200 Subject: [PATCH 105/332] Move updatedFilePathFromPathId() to private File paths are now updated in initAfterRead() --- .../Annotations/RimAnnotationCollection.cpp | 3 +-- ApplicationLibCode/ProjectDataModel/RimProject.h | 6 +++--- .../ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp index 2ef1ab58fc..008d27940a 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp @@ -111,8 +111,7 @@ void RimAnnotationCollection::initAfterRead() RimPolygonFile* newPoly = new RimPolygonFile(); newPoly->setName( oldPoly->uiName() ); - QString fileName = RimProject::current()->updatedFilePathFromPathId( oldPoly->fileName() ); - newPoly->setFileName( fileName ); + newPoly->setFileName( oldPoly->fileName() ); polycoll->addPolygonFile( newPoly ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.h b/ApplicationLibCode/ProjectDataModel/RimProject.h index 97d69a8311..97fdc0ef7d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.h +++ b/ApplicationLibCode/ProjectDataModel/RimProject.h @@ -194,7 +194,6 @@ class RimProject : public caf::PdmDocument RimPlotTemplateFolderItem* rootPlotTemplateItem() const; std::vector allFilePaths() const; - QString updatedFilePathFromPathId( QString filePath, RiaVariableMapper* pathListMapper = nullptr ) const; protected: void beforeInitAfterRead() override; @@ -204,8 +203,9 @@ class RimProject : public caf::PdmDocument void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; private: - void transferPathsToGlobalPathList(); - void distributePathsFromGlobalPathList(); + void transferPathsToGlobalPathList(); + void distributePathsFromGlobalPathList(); + QString updatedFilePathFromPathId( QString filePath, RiaVariableMapper* pathListMapper = nullptr ) const; private: caf::PdmChildField m_mainPlotCollection; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp index 0335a7ec41..47652efd4c 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp @@ -871,12 +871,10 @@ void RimVfpPlot::initAfterRead() auto filePath = m_filePath_OBSOLETE.v().path(); if ( filePath.isEmpty() ) return; - QString fileName = RimProject::current()->updatedFilePathFromPathId( filePath ); - auto vfpDataCollection = RimVfpDataCollection::instance(); if ( vfpDataCollection ) { - auto tableData = vfpDataCollection->appendTableDataObject( fileName ); + auto tableData = vfpDataCollection->appendTableDataObject( filePath ); if ( tableData ) { setDataSource( tableData ); From 41d5e498d78f18b355d418068fdc8997fdde85fe Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 5 Jun 2024 11:00:55 +0200 Subject: [PATCH 106/332] Simplify PdmDocument class and move fileName to private Remove resolveReferencesRecursively() and initAfterReadRecursively() from PdmDocument::readFile(). These functions will be called in RiaApplication::loadProject after the file paths modifications are done. This will ensure that file paths can be used in initAfterRead() functions. --- .../Application/RiaApplication.cpp | 10 ++++- .../RicExportSelectedWellPathsFeature.cpp | 2 +- .../ProjectDataModel/RimProject.cpp | 13 ++++--- .../ProjectDataModel/RimProject.h | 3 +- .../UnitTests/RimRelocatePath-Test.cpp | 2 +- .../cafProjectDataModel/cafPdmDocument.cpp | 37 ++++++++++--------- .../cafProjectDataModel/cafPdmDocument.h | 15 ++++---- .../cafPdmBasicTest.cpp | 24 +++++++----- .../cafTestApplication/MainWindow.cpp | 8 ++-- 9 files changed, 66 insertions(+), 48 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index f40f2ae5c6..3cf5c02397 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -461,8 +461,9 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct return false; } - m_project->fileName = fullPathProjectFileName; + m_project->setFileName( fullPathProjectFileName ); m_project->readFile(); + m_project->updatesAfterProjectFileIsRead(); // Apply any modifications to the loaded project before we go ahead and load actual data if ( projectModifier ) @@ -493,6 +494,11 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct return true; } + // At this point, all the file paths variables are replaced and all file paths updated to the new location. This will enable use of file + // paths in initAfterRead(). + m_project->resolveReferencesRecursively(); + m_project->initAfterReadRecursively(); + // Migrate all RimGridCases to RimFileSummaryCase RimGridSummaryCase_obsolete::convertGridCasesToSummaryFileCases( m_project.get() ); @@ -802,7 +808,7 @@ bool RiaApplication::saveProjectAs( const QString& fileName, gsl::not_nullfileName = RiaFilePathTools::toInternalSeparator( fileName ); + m_project->setFileName( RiaFilePathTools::toInternalSeparator( fileName ) ); onProjectBeingSaved(); diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp index 6cd44b54af..9c692e92fc 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp @@ -113,7 +113,7 @@ void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream( QTextStre if ( writeProjectInfo ) { - formatter.comment( "Project: " + RimProject::current()->fileName ); + formatter.comment( "Project: " + RimProject::current()->fileName() ); stream << "\n"; } diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 5b6605f265..bac06037db 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -283,7 +283,7 @@ void RimProject::close() delete viewLinkerCollection->viewLinker(); viewLinkerCollection->viewLinker = nullptr; - fileName = ""; + setFileName( "" ); m_globalPathList = ""; @@ -303,7 +303,7 @@ void RimProject::close() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::beforeInitAfterRead() +void RimProject::updatesAfterProjectFileIsRead() { distributePathsFromGlobalPathList(); @@ -408,7 +408,7 @@ bool RimProject::writeProjectFile() { transferPathsToGlobalPathList(); - QFile xmlFile( fileName ); + QFile xmlFile( fileName() ); if ( !xmlFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false; QString content = documentAsString(); @@ -416,7 +416,7 @@ bool RimProject::writeProjectFile() if ( RiaPreferences::current()->storeBackupOfProjectFiles() ) { - QString backupFilename = fileName + "db"; + QString backupFilename = fileName() + "db"; const int maximumRecordCount = 50; RiaProjectBackupTools::appendTextToDatabase( backupFilename, maximumRecordCount, content ); } @@ -488,9 +488,10 @@ bool RimProject::isProjectFileVersionEqualOrOlderThan( const QString& otherProje void RimProject::setProjectFileNameAndUpdateDependencies( const QString& projectFileName ) { // Extract the filename of the project file when it was saved - QString oldProjectFileName = fileName; + QString oldProjectFileName = fileName(); + // Replace with the new actual filename - fileName = projectFileName; + setFileName( projectFileName ); QFileInfo fileInfo( projectFileName ); QString newProjectPath = fileInfo.path(); diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.h b/ApplicationLibCode/ProjectDataModel/RimProject.h index 97fdc0ef7d..6c4641c481 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.h +++ b/ApplicationLibCode/ProjectDataModel/RimProject.h @@ -195,8 +195,9 @@ class RimProject : public caf::PdmDocument std::vector allFilePaths() const; + void updatesAfterProjectFileIsRead(); + protected: - void beforeInitAfterRead() override; void initAfterRead() override; void setupBeforeSave() override; diff --git a/ApplicationLibCode/UnitTests/RimRelocatePath-Test.cpp b/ApplicationLibCode/UnitTests/RimRelocatePath-Test.cpp index 36a152638a..1ca4fa22c5 100644 --- a/ApplicationLibCode/UnitTests/RimRelocatePath-Test.cpp +++ b/ApplicationLibCode/UnitTests/RimRelocatePath-Test.cpp @@ -59,7 +59,7 @@ TEST( RimRelocatePathTest, findPathsInProjectFile ) RimProject project; - project.fileName = fileName; + project.setFileName( fileName ); project.readFile(); std::vector filePaths; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp index 8fe5ecadc8..3dd6db57f1 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp @@ -48,7 +48,23 @@ CAF_PDM_SOURCE_INIT( PdmDocument, "PdmDocument" ); //-------------------------------------------------------------------------------------------------- PdmDocument::PdmDocument() { - CAF_PDM_InitFieldNoDefault( &fileName, "DocumentFileName", "File Name" ); + CAF_PDM_InitFieldNoDefault( &m_fileName, "DocumentFileName", "File Name" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString PdmDocument::fileName() const +{ + return m_fileName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmDocument::setFileName( const QString& fileName ) +{ + m_fileName = fileName; } //-------------------------------------------------------------------------------------------------- @@ -56,7 +72,7 @@ PdmDocument::PdmDocument() //-------------------------------------------------------------------------------------------------- void PdmDocument::readFile() { - QFile xmlFile( fileName ); + QFile xmlFile( m_fileName ); if ( !xmlFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) return; readFile( &xmlFile ); @@ -76,19 +92,11 @@ void PdmDocument::readFile( QIODevice* xmlFile ) { if ( !matchesClassKeyword( xmlStream.name().toString() ) ) { - // Error: This is not a Ceetron Pdm based xml document return; } readFields( xmlStream, PdmDefaultObjectFactory::instance(), false ); } } - - // Ask all objects to initialize and set up internal data structures and pointers - // after everything is read from file - - resolveReferencesRecursively(); - beforeInitAfterRead(); - initAfterReadRecursively(); } //-------------------------------------------------------------------------------------------------- @@ -96,7 +104,7 @@ void PdmDocument::readFile( QIODevice* xmlFile ) //-------------------------------------------------------------------------------------------------- bool PdmDocument::writeFile() { - QFile xmlFile( fileName ); + QFile xmlFile( m_fileName ); if ( !xmlFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false; writeFile( &xmlFile ); @@ -161,13 +169,6 @@ void PdmDocument::updateUiIconStateRecursively( PdmObjectHandle* object ) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void PdmDocument::beforeInitAfterRead() -{ -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h index 6451c43c20..a072a8c266 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h @@ -54,23 +54,24 @@ class PdmDocument : public PdmObject public: PdmDocument(); - PdmField fileName; + QString fileName() const; + void setFileName( const QString& fileName ); void readFile(); bool writeFile(); - QString documentAsString(); - - void readFile( QIODevice* device ); - void writeFile( QIODevice* device ); - static void updateUiIconStateRecursively( PdmObjectHandle* root ); protected: - virtual void beforeInitAfterRead(); + QString documentAsString(); private: void writeDocumentToXmlStream( QXmlStreamWriter& xmlStream ); + void readFile( QIODevice* device ); + void writeFile( QIODevice* device ); + +private: + PdmField m_fileName; }; } // End of namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp index d128f321af..1e4b245750 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp @@ -476,6 +476,9 @@ TEST( BaseTest, ReadWrite ) { QString xmlDocumentContentWithErrors; + QString fileName = "PdmTestFil.xml"; + QString fileNameCopy = "PdmTestFil_copy.xml"; + { MyPdmDocument xmlDoc; @@ -524,7 +527,7 @@ TEST( BaseTest, ReadWrite ) xmlDoc.objects.push_back( id2 ); // Write file - xmlDoc.fileName = "PdmTestFil.xml"; + xmlDoc.setFileName( fileName ); xmlDoc.writeFile(); caf::PdmObjectGroup pog; @@ -557,9 +560,14 @@ TEST( BaseTest, ReadWrite ) MyPdmDocument xmlDoc; // Read file - xmlDoc.fileName = "PdmTestFil.xml"; + xmlDoc.setFileName( fileName ); xmlDoc.readFile(); + QFile f( fileNameCopy ); + f.remove(); + + std::rename( fileName.toStdString().data(), fileNameCopy.toStdString().data() ); + caf::PdmObjectGroup pog; for ( size_t i = 0; i < xmlDoc.objects.size(); i++ ) { @@ -578,16 +586,14 @@ TEST( BaseTest, ReadWrite ) EXPECT_EQ( QString( "ÆØÅ Test text end" ), ihDObjs[0]->m_textField() ); // Write file - QFile xmlFile( "PdmTestFil2.xml" ); - xmlFile.open( QIODevice::WriteOnly | QIODevice::Text ); - xmlDoc.writeFile( &xmlFile ); - xmlFile.close(); + xmlDoc.setFileName( fileName ); + xmlDoc.writeFile(); } // Check that the files are identical { - QFile f1( "PdmTestFil.xml" ); - QFile f2( "PdmTestFil2.xml" ); + QFile f1( fileName ); + QFile f2( fileNameCopy ); f1.open( QIODevice::ReadOnly | QIODevice::Text ); f2.open( QIODevice::ReadOnly | QIODevice::Text ); QByteArray ba1 = f1.readAll(); @@ -677,7 +683,7 @@ TEST( BaseTest, ReadWrite ) // Read the document containing errors MyPdmDocument xmlErrorDoc; - xmlErrorDoc.fileName = "PdmTestFilWithError.xml"; + xmlErrorDoc.setFileName( "PdmTestFilWithError.xml" ); xmlErrorDoc.readFile(); caf::PdmObjectGroup pog; diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp index 3e0bdee720..c9ea6c4de7 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp @@ -1612,9 +1612,11 @@ void MainWindow::slotLoadProject() setPdmRoot( nullptr ); releaseTestData(); - m_testRoot = new DemoPdmObjectGroup; - m_testRoot->fileName = fileName; + m_testRoot = new DemoPdmObjectGroup; + m_testRoot->setFileName( fileName ); m_testRoot->readFile(); + m_testRoot->resolveReferencesRecursively(); + m_testRoot->initAfterReadRecursively(); setPdmRoot( m_testRoot ); } @@ -1631,7 +1633,7 @@ void MainWindow::slotSaveProject() "Project Files (*.proj);;All files(*.*)" ); if ( !fileName.isEmpty() ) { - m_testRoot->fileName = fileName; + m_testRoot->setFileName( fileName ); m_testRoot->writeFile(); } } From a6fe630e5f5ba82a836ea0df6c0051795c97318a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 6 Jun 2024 10:47:01 +0200 Subject: [PATCH 107/332] Temporary LGR: Make sure the view is updated based on new LGRs A missing update caused the regression test TestCase_Create_Lgr_For_Completions to fail due to missing visibility of temporary LGRs. --- .../Commands/RicCreateTemporaryLgrFeature.cpp | 29 ++++++------------- .../ProjectDataModel/RimGridView.h | 17 ++++++----- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp b/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp index f85f08aeca..b8ddfe58c2 100644 --- a/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp @@ -19,53 +19,34 @@ #include "RicCreateTemporaryLgrFeature.h" #include "RiaCellDividingTools.h" -#include "RiaCompletionTypeCalculationScheduler.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" -#include "CompletionExportCommands/RicWellPathExportCompletionDataFeature.h" #include "ExportCommands/RicExportLgrFeature.h" #include "ExportCommands/RicExportLgrUi.h" #include "RicDeleteTemporaryLgrsFeature.h" -#include "RifTextDataTableFormatter.h" - #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" #include "RigCell.h" -#include "RigCellGeometryTools.h" #include "RigEclipseCaseData.h" #include "RigMainGrid.h" -#include "RigResultAccessor.h" -#include "RigResultAccessorFactory.h" -#include "RigVirtualPerforationTransmissibilities.h" -#include "RimDialogData.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" +#include "RimGridCollection.h" #include "RimMainPlotCollection.h" #include "RimWellLogPlotCollection.h" #include "RimWellPath.h" -#include "RimWellPathCollection.h" #include "RimWellPathCompletions.h" -#include "Riu3dSelectionManager.h" -#include "RiuPlotMainWindow.h" - #include #include -#include -#include -#include -#include -#include #include #include #include -#include -#include #include CAF_CMD_SOURCE_INIT( RicCreateTemporaryLgrFeature, "RicCreateTemporaryLgrFeature" ); @@ -124,6 +105,14 @@ void RicCreateTemporaryLgrFeature::updateViews( RimEclipseCase* eclipseCase ) RimMainPlotCollection::current()->deleteAllCachedData(); computeCachedData( eclipseCase ); + for ( auto view : eclipseCase->reservoirViews() ) + { + if ( view && view->gridCollection() ) + { + view->gridCollection()->syncFromMainEclipseGrid(); + } + } + RimMainPlotCollection::current()->wellLogPlotCollection()->loadDataAndUpdateAllPlots(); if ( guiApp ) eclipseCase->createDisplayModelAndUpdateAllViews(); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.h b/ApplicationLibCode/ProjectDataModel/RimGridView.h index e7132010c8..d7b45d5e54 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.h +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.h @@ -72,15 +72,16 @@ class RimGridView : public Rim3dView void updateWellMeasurements(); void updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) override; -protected: - virtual void updateViewFollowingCellFilterUpdates(); - void onClearReservoirCellVisibilitiesIfNecessary() override; - virtual void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStep ) = 0; - void selectOverlayInfoConfig() override; RimGridCollection* gridCollection() const; - void clearReservoirCellVisibilities(); - void addRequiredUiTreeObjects( caf::PdmUiTreeOrdering& uiTreeOrdering ); - void appendPolygonPartsToModel( caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); + +protected: + virtual void updateViewFollowingCellFilterUpdates(); + void onClearReservoirCellVisibilitiesIfNecessary() override; + virtual void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStep ) = 0; + void selectOverlayInfoConfig() override; + void clearReservoirCellVisibilities(); + void addRequiredUiTreeObjects( caf::PdmUiTreeOrdering& uiTreeOrdering ); + void appendPolygonPartsToModel( caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void initAfterRead() override; From f7dccd814900eaa633ee0c863cf222aeef1b6351 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 6 Jun 2024 13:35:27 +0200 Subject: [PATCH 108/332] #11482 Show mesh lines by default for faults in contour maps Add settings used to control the visibility of fault mesh --- .../Commands/RicNewContourMapViewFeature.cpp | 2 ++ .../RimEclipseContourMapView.cpp | 32 +++++++++++++++++-- .../RimEclipseContourMapView.h | 15 ++++++--- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp index cc9fdeb11c..9c70677cac 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp @@ -156,6 +156,7 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked ) oilField->eclipseContourMapCollection()->updateConnectedEditors(); Riu3DMainWindowTools::setExpanded( eclipseContourMap ); + Riu3DMainWindowTools::selectAsCurrentItem( eclipseContourMap ); } else if ( geoMechContourMap ) { @@ -171,6 +172,7 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked ) geoMechContourMap->createDisplayModelAndRedraw(); geoMechContourMap->zoomAll(); Riu3DMainWindowTools::setExpanded( geoMechContourMap ); + Riu3DMainWindowTools::selectAsCurrentItem( geoMechContourMap ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp index 87f8239bef..b7d9ea0050 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp @@ -67,6 +67,12 @@ RimEclipseContourMapView::RimEclipseContourMapView() CAF_PDM_InitField( &m_showAxisLines, "ShowAxisLines", true, "Show Axis Lines" ); CAF_PDM_InitField( &m_showScaleLegend, "ShowScaleLegend", true, "Show Scale Legend" ); + CAF_PDM_InitFieldNoDefault( &m_showFaultLines, "ShowFaultLines", "Show Fault Lines" ); + m_showFaultLines.registerGetMethod( this, &RimEclipseContourMapView::isFaultLinesVisible ); + m_showFaultLines.registerSetMethod( this, &RimEclipseContourMapView::setFaultLinesVisible ); + + meshMode = RiaDefines::MeshModeType::FAULTS_MESH; + setFaultVisParameters(); setDefaultCustomName(); @@ -169,7 +175,6 @@ void RimEclipseContourMapView::initAfterRead() disablePerspectiveProjectionField(); setShowGridBox( false ); - meshMode.setValue( RiaDefines::MeshModeType::NO_MESH ); surfaceMode.setValue( FAULTS ); setFaultVisParameters(); scheduleCreateDisplayModelAndRedraw(); @@ -207,13 +212,14 @@ void RimEclipseContourMapView::onCreateDisplayModel() //-------------------------------------------------------------------------------------------------- void RimEclipseContourMapView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { + uiOrdering.add( &m_eclipseCase ); + caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup( "Viewer" ); viewGroup->add( userDescriptionField() ); viewGroup->add( backgroundColorField() ); viewGroup->add( &m_showAxisLines ); viewGroup->add( &m_showScaleLegend ); - - uiOrdering.add( &m_eclipseCase ); + viewGroup->add( &m_showFaultLines ); caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Contour Map Name" ); nameConfig()->uiOrdering( uiConfigName, *nameGroup ); @@ -492,6 +498,10 @@ void RimEclipseContourMapView::fieldChangedByUi( const caf::PdmFieldHandle* chan onUpdateLegends(); scheduleCreateDisplayModelAndRedraw(); } + else if ( changedField == &m_showFaultLines ) + { + scheduleCreateDisplayModelAndRedraw(); + } } //-------------------------------------------------------------------------------------------------- @@ -602,3 +612,19 @@ void RimEclipseContourMapView::zoomAll() RimEclipseView::zoomAll(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseContourMapView::isFaultLinesVisible() const +{ + return meshMode() == RiaDefines::MeshModeType::FAULTS_MESH; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseContourMapView::setFaultLinesVisible( const bool& visible ) +{ + meshMode.setValue( visible ? RiaDefines::MeshModeType::FAULTS_MESH : RiaDefines::MeshModeType::NO_MESH ); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.h b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.h index 3e78d295ca..bd8528317e 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.h @@ -19,7 +19,8 @@ #pragma once #include "RimEclipseView.h" -#include "RimNameConfig.h" + +#include "cafPdmProxyValueField.h" enum class RimLegendConfigChangeType; class RimEclipseContourMapProjection; @@ -78,12 +79,18 @@ class RimEclipseContourMapView : public RimEclipseView void onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType ); +private: + bool isFaultLinesVisible() const; + void setFaultLinesVisible( const bool& visible ); + private: cvf::ref m_contourMapProjectionPartMgr; caf::PdmChildField m_contourMapProjection; - caf::PdmField m_showAxisLines; - caf::PdmField m_showScaleLegend; - cvf::Vec3d m_cameraPositionLastUpdate; + + caf::PdmProxyValueField m_showFaultLines; + caf::PdmField m_showAxisLines; + caf::PdmField m_showScaleLegend; + cvf::Vec3d m_cameraPositionLastUpdate; const static cvf::Mat4d sm_defaultViewMatrix; }; From ea17b1ec0781646d687bfa13201dd34023118123 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 6 Jun 2024 14:55:35 +0200 Subject: [PATCH 109/332] #11482 Add fault mesh line thickness option --- .../Faults/RivFaultPartMgr.cpp | 2 ++ .../Faults/RimFaultInViewCollection.cpp | 31 ++++++++++++++++--- .../Faults/RimFaultInViewCollection.h | 5 +-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/ApplicationLibCode/ModelVisualization/Faults/RivFaultPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Faults/RivFaultPartMgr.cpp index 2e418bfde1..235adfdade 100644 --- a/ApplicationLibCode/ModelVisualization/Faults/RivFaultPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Faults/RivFaultPartMgr.cpp @@ -516,6 +516,8 @@ void RivFaultPartMgr::updatePartEffect() cvf::ref eff; caf::MeshEffectGenerator faultEffGen( prefs->defaultFaultGridLineColors() ); + faultEffGen.setLineWidth( m_rimFaultCollection->meshLineThickness() ); + eff = faultEffGen.generateCachedEffect(); if ( m_nativeFaultGridLines.notNull() ) diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp index 79a75e944b..d203a33482 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp @@ -20,15 +20,12 @@ #include "RimFaultInViewCollection.h" #include "RiaColorTables.h" -#include "RiaDefines.h" #include "RiaPreferences.h" #include "RiaResultNames.h" #include "RigMainGrid.h" -#include "RimEclipseCase.h" #include "RimEclipseFaultColors.h" -#include "RimEclipseInputCase.h" #include "RimEclipseView.h" #include "RimFaultInView.h" #include "RimIntersectionCollection.h" @@ -38,8 +35,8 @@ #include "cafAppEnum.h" #include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfMat4d.h" #include "cafPdmUiCheckBoxEditor.h" +#include "cafPdmUiLineEditor.h" #include "cafPdmUiTreeOrdering.h" namespace caf @@ -73,6 +70,7 @@ RimFaultInViewCollection::RimFaultInViewCollection() caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showOppositeFaultFaces ); CAF_PDM_InitField( &m_applyCellFilters, "ApplyCellFilters", true, "Use Cell Filters for Faults" ); + CAF_PDM_InitField( &m_meshLineThickness, "MeshLineThickness", 2, "Mesh Line Thickness [1..10]" ); CAF_PDM_InitField( &m_onlyShowWithNeighbor, "OnlyShowWithDefNeighbor", false, "Show Only Faces with Juxtaposition" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_onlyShowWithNeighbor ); @@ -184,6 +182,14 @@ bool RimFaultInViewCollection::hideNNCsWhenNoResultIsAvailable() const return m_hideNNCsWhenNoResultIsAvailable(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFaultInViewCollection::meshLineThickness() const +{ + return m_meshLineThickness(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -205,7 +211,7 @@ void RimFaultInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* chan if ( &m_showFaultFaces == changedField || &m_showOppositeFaultFaces == changedField || &m_showFaultCollection == changedField || &m_showFaultLabel == changedField || &m_applyCellFilters == changedField || &m_faultLabelColor == changedField || &m_onlyShowWithNeighbor == changedField || &m_faultResult == changedField || &m_showNNCs == changedField || - &m_hideNNCsWhenNoResultIsAvailable == changedField ) + &m_hideNNCsWhenNoResultIsAvailable == changedField || changedField == &m_meshLineThickness ) { parentView()->scheduleCreateDisplayModelAndRedraw(); parentView()->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); @@ -225,6 +231,20 @@ caf::PdmFieldHandle* RimFaultInViewCollection::objectToggleField() return &m_showFaultCollection; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultInViewCollection::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_meshLineThickness ) + { + if ( auto* lineEditorAttr = dynamic_cast( attribute ) ) + { + lineEditorAttr->validator = new QIntValidator( 1, 10, nullptr ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -371,6 +391,7 @@ void RimFaultInViewCollection::defineUiOrdering( QString uiConfigName, caf::PdmU { caf::PdmUiGroup* general = uiOrdering.addNewGroup( "General" ); general->add( &m_applyCellFilters ); + general->add( &m_meshLineThickness ); caf::PdmUiGroup* labs = uiOrdering.addNewGroup( "Fault Labels" ); labs->add( &m_showFaultLabel ); diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h index 1a2856d482..374d37fc32 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h @@ -21,10 +21,8 @@ #include "cafAppEnum.h" #include "cafPdmChildArrayField.h" -#include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" -#include "cafPdmPointer.h" // Include to make Pdm work for cvf::Color #include "cafPdmFieldCvfColor.h" @@ -67,6 +65,7 @@ class RimFaultInViewCollection : public caf::PdmObject bool showOppositeFaultFaces() const; bool showNNCs() const; bool hideNNCsWhenNoResultIsAvailable() const; + int meshLineThickness() const; void setFaultResult( caf::AppEnum resultType ); void setShouldApplyCellFiltersToFaults( bool bEnabled ); @@ -86,6 +85,7 @@ class RimFaultInViewCollection : public caf::PdmObject private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; caf::PdmFieldHandle* objectToggleField() override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; @@ -103,6 +103,7 @@ class RimFaultInViewCollection : public caf::PdmObject caf::PdmField m_showFaultCollection; caf::PdmField m_showNNCs; caf::PdmField m_hideNNCsWhenNoResultIsAvailable; + caf::PdmField m_meshLineThickness; caf::PdmField> m_faultResult; From 431c8f5a27cb9c1396a996fb96ccb7d1d1d5abf7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 9 Jun 2024 11:02:25 +0200 Subject: [PATCH 110/332] Build release only for vcpkg packages --- .github/workflows/ResInsightWithCache.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index ad15e227b9..91416c8a0f 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -37,6 +37,7 @@ jobs: unity-build: true, publish-to-pypi: false, vcpkg-bootstrap: bootstrap-vcpkg.bat, + vcpkg-triplet: x64-windows-release, } - { name: "Ubuntu 22.04 gcc", @@ -49,6 +50,7 @@ jobs: unity-build: false, publish-to-pypi: true, vcpkg-bootstrap: bootstrap-vcpkg.sh, + vcpkg-triplet: x64-linux-release, } - { name: "Ubuntu 22.04 clang-16", @@ -61,6 +63,7 @@ jobs: unity-build: false, publish-to-pypi: false, vcpkg-bootstrap: bootstrap-vcpkg.sh, + vcpkg-triplet: x64-linux-release, } steps: - name: Checkout @@ -195,6 +198,7 @@ jobs: run: > cmake -S . -B cmakebuild -DVCPKG_BUILD_TYPE=release + -DVCPKG_TARGET_TRIPLET=${{ matrix.config.vcpkg-triplet }} -DCMAKE_INSTALL_PREFIX=cmakebuild/install -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DRESINSIGHT_QT5_BUNDLE_LIBRARIES=true From 742bb5f0d26909c5e9cab459315f9419a9d9716d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 10 Jun 2024 11:42:16 +0200 Subject: [PATCH 111/332] #11485 Disable Python and unit test to fix build on GitHub Recent changes on GitHub is breaking the build. Temporarily disable Python and unit tests as a workaround. https://github.com/actions/runner-images/issues/10004 --- .github/workflows/ResInsightWithCache.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 91416c8a0f..968c2c4129 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -31,9 +31,9 @@ jobs: os: windows-2022, cc: "cl", cxx: "cl", - build-python-module: true, - execute-unit-tests: true, - execute-pytests: true, + build-python-module: false, + execute-unit-tests: false, + execute-pytests: false, unity-build: true, publish-to-pypi: false, vcpkg-bootstrap: bootstrap-vcpkg.bat, From 015f248dd9df9c1b573f34284941b1fc4f743776 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 11 Jun 2024 13:36:04 +0200 Subject: [PATCH 112/332] Show properties for selected object in main project tree There can be several project trees in a project. Ensure that the selected object in the main project tree is displayed in the property editor. --- .../UserInterface/RiuMainWindow.cpp | 19 +++++++++++++++++++ .../UserInterface/RiuPlotMainWindow.cpp | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp index 9c99e50029..12ecc081e8 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp @@ -254,6 +254,25 @@ void RiuMainWindow::initializeGuiNewProjectLoaded() activeSubWindow->showMaximized(); } } + + // Find the project tree and reselect items to trigger the selectionChanged signal. This will make sure that the property view is + // updated based on the selection in the main project tree. + if ( auto dockWidget = RiuDockWidgetTools::findDockWidget( dockManager(), RiuDockWidgetTools::mainWindowProjectTreeName() ) ) + { + if ( auto tree = dynamic_cast( dockWidget->widget() ) ) + { + std::vector uiItems; + tree->selectedUiItems( uiItems ); + + std::vector constSelectedItems; + for ( auto item : uiItems ) + { + constSelectedItems.push_back( item ); + } + + tree->selectItems( constSelectedItems ); + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp index 191e99e855..db0f58a2f6 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp @@ -218,6 +218,25 @@ void RiuPlotMainWindow::initializeGuiNewProjectLoaded() } refreshToolbars(); + + // Find the project tree and reselect items to trigger the selectionChanged signal. This will make sure that the property view is + // updated based on the selection in the main project tree. + if ( auto dockWidget = RiuDockWidgetTools::findDockWidget( dockManager(), RiuDockWidgetTools::plotMainWindowPlotsTreeName() ) ) + { + if ( auto tree = dynamic_cast( dockWidget->widget() ) ) + { + std::vector uiItems; + tree->selectedUiItems( uiItems ); + + std::vector constSelectedItems; + for ( auto item : uiItems ) + { + constSelectedItems.push_back( item ); + } + + tree->selectItems( constSelectedItems ); + } + } } //-------------------------------------------------------------------------------------------------- From 13532b0fe4d972bc50498b13ece952f3105050cd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 11 Jun 2024 11:47:01 +0200 Subject: [PATCH 113/332] Add partial specialization for float and double In PdmFieldWriter::writeFieldData, the numeric values are converted to string with a selected precision. isEqual() is used when comparing values for field editors in PdmFieldUiCap::valueOptions() --- .../cafInternalPdmValueFieldSpecializations.h | 42 +++++++++++++++++++ .../cafPdmXmlNumberTest.cpp | 36 ++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h index ad472c2cae..aa67a1c01c 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h @@ -195,4 +195,46 @@ class PdmValueFieldSpecialization } }; +//================================================================================================== +/// Partial specialization for float +//================================================================================================== +template <> +class PdmValueFieldSpecialization +{ +public: + static QVariant convert( const float& value ) { return QVariant::fromValue( value ); } + + static void setFromVariant( const QVariant& variantValue, float& value ) { value = variantValue.value(); } + + static bool isEqual( const QVariant& variantValue, const QVariant& variantValue2 ) + { + // See PdmFieldWriter::writeFieldData for the precision used when writing float values + // This function is used when comparing values for field editors in PdmFieldUiCap::valueOptions() + + const float epsilon = 1e-6f; + return qAbs( variantValue.value() - variantValue2.value() ) < epsilon; + } +}; + +//================================================================================================== +/// Partial specialization for double +//================================================================================================== +template <> +class PdmValueFieldSpecialization +{ +public: + static QVariant convert( const double& value ) { return QVariant::fromValue( value ); } + + static void setFromVariant( const QVariant& variantValue, double& value ) { value = variantValue.value(); } + + static bool isEqual( const QVariant& variantValue, const QVariant& variantValue2 ) + { + // See PdmFieldWriter::writeFieldData for the precision used when writing double values + // This function is used when comparing values for field editors in PdmFieldUiCap::valueOptions() + + const double epsilon = 1e-8; + return qAbs( variantValue.value() - variantValue2.value() ) < epsilon; + } +}; + } // End of namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp index eb76680e29..9bd602010a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp @@ -110,3 +110,39 @@ TEST( SerializeNumbers, SimpleObjectWithFloatValues ) EXPECT_TRUE( diffB < epsilon ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( SerializeNumbers, TestPresicion ) +{ + double valueB = 0.1234567890123456789; + + QString objectAsText; + + { + SimpleObjectWithNumbers obj1; + + obj1.m_valueB = valueB; + + objectAsText = obj1.writeObjectToXmlString(); + } + + SimpleObjectWithNumbers obj1; + obj1.readObjectFromXmlString( objectAsText, caf::PdmDefaultObjectFactory::instance() ); + + // Test the precision of the value serialized to text + // See PdmFieldWriter::writeFieldData for the precision used when writing float values + + { + const double epsilon = 1e-15; + auto diff = fabs( obj1.m_valueB - valueB ); + EXPECT_FALSE( diff > epsilon ); + } + + { + const double epsilon = 1e-16; + auto diff = fabs( obj1.m_valueB - valueB ); + EXPECT_TRUE( diff > epsilon ); + } +} From fe63231db9d2363eca58da122990c2ccedc706f3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 12 Jun 2024 07:52:37 +0200 Subject: [PATCH 114/332] Add support for multiple curve sets in one VFP plot - support selection of multiple values for multiple producer variables - use one color for curves in a curve set representing a VFP curve collection - use symbols to indicate individual family values for curves - show all required values to identify curves as curve legend text and curve mouse hover text - make sure all available settings of axis property object is applied to the plot axis - support display of all curve data using "Show Plot Data" --- .../RicShowPlotDataFeature.cpp | 3 +- .../RimPlotAxisProperties.cpp | 14 + .../ProjectDataModel/RimPlotAxisProperties.h | 2 + .../Summary/RimSummaryPlotAxisFormatter.cpp | 86 +-- .../Tools/RimPlotAxisTools.cpp | 121 +++- .../ProjectDataModel/Tools/RimPlotAxisTools.h | 3 + .../RimCustomVfpPlot.cpp | 674 ++++++++++++++---- .../RimCustomVfpPlot.h | 79 +- .../VerticalFlowPerformance/RimVfpDefines.cpp | 2 +- .../RimVfpPlotCollection.cpp | 1 + .../ReservoirDataModel/RigVfpTables.cpp | 6 +- .../ReservoirDataModel/RigVfpTables.h | 2 +- 12 files changed, 727 insertions(+), 266 deletions(-) diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp index fa142c7b25..a837ab7e22 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp @@ -37,6 +37,7 @@ #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" +#include "VerticalFlowPerformance/RimCustomVfpPlot.h" #include "VerticalFlowPerformance/RimVfpPlot.h" #include "RiuPlotMainWindow.h" @@ -193,7 +194,7 @@ bool RicShowPlotDataFeature::isCommandEnabled() const for ( auto plot : selection ) { if ( dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || - dynamic_cast( plot ) || dynamic_cast( plot ) || + dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) ) diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp index 25060d3655..93833a2fda 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp @@ -107,6 +107,20 @@ RimPlotAxisProperties::RimPlotAxisProperties() updateOptionSensitivity(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::configureForBasicUse() +{ + setEnableTitleTextSettings( false ); + + m_isLogarithmicScaleEnabled.uiCapability()->setUiHidden( true ); + m_isAxisInverted.uiCapability()->setUiHidden( true ); + m_showNumbers.uiCapability()->setUiHidden( true ); + m_majorTickmarkCount.uiCapability()->setUiHidden( true ); + m_plotAxis.uiCapability()->setUiHidden( true ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h index bfde0844d8..21ab776fc0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h @@ -64,6 +64,8 @@ class RimPlotAxisProperties : public RimPlotAxisPropertiesInterface public: RimPlotAxisProperties(); + void configureForBasicUse(); + void setAlwaysRequired( bool enable ); void setEnableTitleTextSettings( bool enable ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp index aa1a1de7c6..3ad7f60911 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp @@ -29,73 +29,16 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "Tools/RimPlotAxisTools.h" #include "RiuQtChartsPlotWidget.h" -#include "RiuQwtPlotTools.h" #include "RiuSummaryQuantityNameInfoProvider.h" #include "RiuSummaryQwtPlot.h" -#include "qwt_date_scale_engine.h" -#include "qwt_plot.h" -#include "qwt_plot_curve.h" -#include "qwt_scale_draw.h" -#include "qwt_text.h" - #include #include #include -//-------------------------------------------------------------------------------------------------- -// e format as [-]9.9e[+|-]999 -// E format as[-]9.9E[+| -]999 -// f format as[-]9.9 -// g use e or f format, whichever is the most concise -// G use E or f format, whichever is the most concise - -//-------------------------------------------------------------------------------------------------- -class SummaryScaleDraw : public QwtScaleDraw -{ -public: - SummaryScaleDraw( double scaleFactor, - int numberOfDecimals, - RimPlotAxisProperties::NumberFormatType numberFormat = RimPlotAxisProperties::NUMBER_FORMAT_AUTO ) - { - m_scaleFactor = scaleFactor; - m_numberOfDecimals = numberOfDecimals; - m_numberFormat = numberFormat; - } - - QwtText label( double value ) const override - { - if ( qFuzzyCompare( scaledValue( value ) + 1.0, 1.0 ) ) value = 0.0; - - return QString::number( scaledValue( value ), numberFormat(), m_numberOfDecimals ); - } - -private: - char numberFormat() const - { - switch ( m_numberFormat ) - { - case RimPlotAxisProperties::NUMBER_FORMAT_AUTO: - return 'g'; - case RimPlotAxisProperties::NUMBER_FORMAT_DECIMAL: - return 'f'; - case RimPlotAxisProperties::NUMBER_FORMAT_SCIENTIFIC: - return 'e'; - default: - return 'g'; - } - } - - double scaledValue( double value ) const { return value / m_scaleFactor; } - -private: - double m_scaleFactor; - int m_numberOfDecimals; - RimPlotAxisProperties::NumberFormatType m_numberFormat; -}; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -139,24 +82,7 @@ void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuPlotWidget* plot plotWidget->setAxisTitleEnabled( axis, true ); } - auto qwtPlotWidget = dynamic_cast( plotWidget ); - if ( qwtPlotWidget ) - { - auto qwtAxisId = qwtPlotWidget->toQwtPlotAxis( axis ); - - if ( m_axisProperties->numberFormat() == RimPlotAxisProperties::NUMBER_FORMAT_AUTO && m_axisProperties->scaleFactor() == 1.0 ) - { - // Default to Qwt's own scale draw to avoid changing too much for default values - qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId, new QwtScaleDraw ); - } - else - { - qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId, - new SummaryScaleDraw( m_axisProperties->scaleFactor(), - m_axisProperties->decimalCount(), - m_axisProperties->numberFormat() ) ); - } - } + RimPlotAxisTools::applyAxisScaleDraw( plotWidget, axis, m_axisProperties ); #ifdef USE_QTCHARTS auto qtChartsPlotWidget = dynamic_cast( plotWidget ); @@ -307,13 +233,7 @@ QString RimSummaryPlotAxisFormatter::autoAxisTitle() const } QString assembledYAxisText; - QString scaleFactorText = ""; - - if ( m_axisProperties->scaleFactor() != 1.0 ) - { - int exponent = std::log10( m_axisProperties->scaleFactor() ); - scaleFactorText = QString( " x 10%1 " ).arg( QString::number( exponent ) ); - } + QString scaleFactorText = RimPlotAxisTools::scaleFactorText( m_axisProperties ); for ( const auto& unitIt : unitToQuantityNameMap ) { diff --git a/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp index 37f91cf370..3d21295c39 100644 --- a/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.cpp @@ -17,19 +17,80 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimPlotAxisTools.h" + #include "RimPlotAxisLogRangeCalculator.h" #include "RimPlotAxisProperties.h" #include "RimPlotCurve.h" +#include "RimSummaryPlotAxisFormatter.h" #include "RiuPlotAxis.h" #include "RiuPlotWidget.h" +#include "RiuQwtPlotWidget.h" + +#include "qwt_plot.h" +#include "qwt_scale_draw.h" +#include "qwt_text.h" + +#include + +namespace RimPlotAxisTools +{ + +//-------------------------------------------------------------------------------------------------- +// e format as [-]9.9e[+|-]999 +// E format as[-]9.9E[+| -]999 +// f format as[-]9.9 +// g use e or f format, whichever is the most concise +// G use E or f format, whichever is the most concise + +//-------------------------------------------------------------------------------------------------- +class SummaryScaleDraw : public QwtScaleDraw +{ +public: + SummaryScaleDraw( double scaleFactor, + int numberOfDecimals, + RimPlotAxisProperties::NumberFormatType numberFormat = RimPlotAxisProperties::NUMBER_FORMAT_AUTO ) + { + m_scaleFactor = scaleFactor; + m_numberOfDecimals = numberOfDecimals; + m_numberFormat = numberFormat; + } + + QwtText label( double value ) const override + { + if ( qFuzzyCompare( scaledValue( value ) + 1.0, 1.0 ) ) value = 0.0; + + return QString::number( scaledValue( value ), numberFormat(), m_numberOfDecimals ); + } + +private: + char numberFormat() const + { + switch ( m_numberFormat ) + { + case RimPlotAxisProperties::NUMBER_FORMAT_AUTO: + return 'g'; + case RimPlotAxisProperties::NUMBER_FORMAT_DECIMAL: + return 'f'; + case RimPlotAxisProperties::NUMBER_FORMAT_SCIENTIFIC: + return 'e'; + default: + return 'g'; + } + } + + double scaledValue( double value ) const { return value / m_scaleFactor; } + +private: + double m_scaleFactor; + int m_numberOfDecimals; + RimPlotAxisProperties::NumberFormatType m_numberFormat; +}; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotAxisTools::updateVisibleRangesFromPlotWidget( RimPlotAxisProperties* axisProperties, - RiuPlotAxis plotAxis, - const RiuPlotWidget* const plotWidget ) +void updateVisibleRangesFromPlotWidget( RimPlotAxisProperties* axisProperties, RiuPlotAxis plotAxis, const RiuPlotWidget* const plotWidget ) { if ( !plotWidget || !axisProperties ) return; @@ -44,11 +105,11 @@ void RimPlotAxisTools::updateVisibleRangesFromPlotWidget( RimPlotAxisProperties* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotAxisTools::updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget, - RiuPlotAxis axis, - const RimPlotAxisProperties* const axisProperties, - const QString& axisTitle, - const std::vector& plotCurves ) +void updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget, + RiuPlotAxis axis, + const RimPlotAxisProperties* const axisProperties, + const QString& axisTitle, + const std::vector& plotCurves ) { if ( !plotWidget || !axisProperties ) return; @@ -64,10 +125,12 @@ void RimPlotAxisTools::updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget->setAxisFontsAndAlignment( axis, axisProperties->titleFontSize(), axisProperties->valuesFontSize(), false, alignment ); if ( !axisTitle.isEmpty() ) { - plotWidget->setAxisTitleText( axis, axisTitle ); + plotWidget->setAxisTitleText( axis, axisTitle + RimPlotAxisTools::scaleFactorText( axisProperties ) ); } plotWidget->setAxisTitleEnabled( axis, true ); + applyAxisScaleDraw( plotWidget, axis, axisProperties ); + if ( axisProperties->isLogarithmicScaleEnabled() ) { bool isLogScale = plotWidget->axisScaleType( axis ) == RiuPlotWidget::AxisScaleType::LOGARITHMIC; @@ -123,3 +186,43 @@ void RimPlotAxisTools::updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget->enableAxis( axis, false ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void applyAxisScaleDraw( RiuPlotWidget* plotWidget, RiuPlotAxis axis, const RimPlotAxisProperties* const axisProperties ) +{ + if ( auto qwtPlotWidget = dynamic_cast( plotWidget ) ) + { + auto qwtAxisId = qwtPlotWidget->toQwtPlotAxis( axis ); + + if ( axisProperties->numberFormat() == RimPlotAxisProperties::NUMBER_FORMAT_AUTO && axisProperties->scaleFactor() == 1.0 ) + { + // Default to Qwt's own scale draw to avoid changing too much for default values + qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId, new QwtScaleDraw ); + } + else + { + qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId, + new SummaryScaleDraw( axisProperties->scaleFactor(), + axisProperties->decimalCount(), + axisProperties->numberFormat() ) ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString scaleFactorText( const RimPlotAxisProperties* const axisProperties ) +{ + if ( axisProperties->scaleFactor() != 1.0 ) + { + int exponent = std::log10( axisProperties->scaleFactor() ); + return QString( " x 10%1 " ).arg( QString::number( exponent ) ); + } + + return {}; +} + +} // namespace RimPlotAxisTools diff --git a/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h index 013283e738..227712b5ee 100644 --- a/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h +++ b/ApplicationLibCode/ProjectDataModel/Tools/RimPlotAxisTools.h @@ -36,4 +36,7 @@ void updatePlotWidgetFromAxisProperties( RiuPlotWidget* const QString& axisTitle, const std::vector& plotCurves ); +void applyAxisScaleDraw( RiuPlotWidget* plotWidget, RiuPlotAxis axis, const RimPlotAxisProperties* const axisProperties ); +QString scaleFactorText( const RimPlotAxisProperties* const axisProperties ); + }; // namespace RimPlotAxisTools diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp index a1879b976a..7a096476ba 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp @@ -21,6 +21,9 @@ #include "RiaColorTables.h" #include "RiaColorTools.h" #include "RiaEclipseUnitTools.h" +#include "RiaPreferences.h" + +#include "RifCsvDataTableFormatter.h" #include "RigVfpTables.h" @@ -71,7 +74,7 @@ RimCustomVfpPlot::RimCustomVfpPlot() CAF_PDM_InitFieldNoDefault( &m_additionalDataSources, "AdditionalDataSources", "Additional Data Sources" ); m_additionalDataSources.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_curveOptionFiltering, "CurveOptionFiltering", "Curve Option Filtering" ); + CAF_PDM_InitFieldNoDefault( &m_curveValueOptions, "CurveValueOptions", "Curve Value Options" ); CAF_PDM_InitFieldNoDefault( &m_curveMatchingType, "CurveMatchingType", "Curve Matching Type" ); caf::AppEnum defaultTableType = RimVfpDefines::TableType::INJECTION; @@ -103,33 +106,35 @@ RimCustomVfpPlot::RimCustomVfpPlot() caf::AppEnum defaultFamilyVariable = RimVfpDefines::ProductionVariableType::THP; CAF_PDM_InitField( &m_familyVariable, "FamilyVariable", defaultFamilyVariable, "Family Variable" ); - CAF_PDM_InitField( &m_flowRateIdx, "LiquidFlowRateIdx", { 0 }, "Flow Rate" ); - m_flowRateIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - - CAF_PDM_InitField( &m_thpIdx, "THPIdx", { 0 }, "THP" ); - m_thpIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + CAF_PDM_InitFieldNoDefault( &m_flowRate, "LiquidFlowRate", "Flow Rate" ); + m_flowRate.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_articifialLiftQuantityIdx, "ArtificialLiftQuantityIdx", { 0 }, "Artificial Lift Quantity" ); - m_articifialLiftQuantityIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + CAF_PDM_InitFieldNoDefault( &m_thp, "THP", "THP" ); + m_thp.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_waterCutIdx, "WaterCutIdx", { 0 }, "Water Cut" ); - m_waterCutIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + CAF_PDM_InitFieldNoDefault( &m_artificialLiftQuantity, "ArtificialLiftQuantity", "Artificial Lift Quantity" ); + m_artificialLiftQuantity.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_gasLiquidRatioIdx, "GasLiquidRatioIdx", { 0 }, "Gas Liquid Ratio" ); - m_gasLiquidRatioIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + CAF_PDM_InitFieldNoDefault( &m_waterCut, "WaterCut", "Water Cut" ); + m_waterCut.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_familyValues, "FamilyValues", { 0 }, "Family Values" ); - m_familyValues.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + CAF_PDM_InitFieldNoDefault( &m_gasLiquidRatio, "GasLiquidRatio", "Gas Liquid Ratio" ); + m_gasLiquidRatio.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); CAF_PDM_InitFieldNoDefault( &m_xAxisProperties, "xAxisProperties", "X Axis" ); m_xAxisProperties = new RimPlotAxisProperties; m_xAxisProperties->setNameAndAxis( "X-Axis", "X-Axis", RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); - m_xAxisProperties->setEnableTitleTextSettings( false ); + m_xAxisProperties->configureForBasicUse(); CAF_PDM_InitFieldNoDefault( &m_yAxisProperties, "yAxisProperties", "Y Axis" ); m_yAxisProperties = new RimPlotAxisProperties; m_yAxisProperties->setNameAndAxis( "Y-Axis", "Y-Axis", RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); - m_yAxisProperties->setEnableTitleTextSettings( false ); + m_yAxisProperties->configureForBasicUse(); + + CAF_PDM_InitField( &m_curveThickness, "CurveThickness", 2, "Line Thickness" ); + m_curveThickness.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_curveSymbolSize, "CurveSymbolSize", 10, "Symbol Size" ); connectAxisSignals( m_xAxisProperties() ); connectAxisSignals( m_yAxisProperties() ); @@ -184,9 +189,29 @@ void RimCustomVfpPlot::initializeObject() auto table = vfpTables->getTableInitialData( tableNumber ); initializeFromInitData( table ); +} - auto values = vfpTables->getProductionTableData( m_tableNumber(), m_familyVariable() ); - m_familyValues = values; +//-------------------------------------------------------------------------------------------------- +/// +void RimCustomVfpPlot::initializeSelection() +{ + std::map>*> typeAndField = + { { RimVfpDefines::ProductionVariableType::FLOW_RATE, &m_flowRate }, + { RimVfpDefines::ProductionVariableType::THP, &m_thp }, + { RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY, &m_artificialLiftQuantity }, + { RimVfpDefines::ProductionVariableType::WATER_CUT, &m_waterCut }, + { RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO, &m_gasLiquidRatio } }; + + for ( const auto& [variableType, field] : typeAndField ) + { + auto values = availableValues( variableType ); + if ( m_familyVariable() == variableType ) + field->v() = values; + else if ( !values.empty() ) + field->v() = { values.front() }; + else + field->v() = {}; + } } //-------------------------------------------------------------------------------------------------- @@ -228,9 +253,8 @@ void RimCustomVfpPlot::updateAxes() { if ( !m_plotWidget ) return; - QString title; - RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, RiuPlotAxis::defaultBottom(), m_xAxisProperties(), title, {} ); - RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, RiuPlotAxis::defaultLeft(), m_yAxisProperties(), title, {} ); + RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, RiuPlotAxis::defaultBottom(), m_xAxisProperties(), m_xAxisTitle, {} ); + RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, RiuPlotAxis::defaultLeft(), m_yAxisProperties(), m_yAxisTitle, {} ); m_plotWidget->scheduleReplot(); } @@ -267,7 +291,47 @@ void RimCustomVfpPlot::updateLegend() //-------------------------------------------------------------------------------------------------- QString RimCustomVfpPlot::asciiDataForPlotExport() const { - return {}; + QString asciiData; + + size_t plotCurveIdx = 0; + + for ( const auto& curveData : m_plotData ) + { + for ( size_t curveIdx = 0; curveIdx < curveData.size(); curveIdx++ ) + { + asciiData += curveData.curveTitle( curveIdx ); + + if ( !m_additionalDataSources.empty() && plotCurveIdx < m_plotCurveMetaData.size() ) + { + auto plotCurveData = m_plotCurveMetaData[plotCurveIdx]; + asciiData += QString( " (Table: %1)" ).arg( plotCurveData.tableNumber ); + } + + asciiData += "\n"; + + QTextStream stream( &asciiData ); + RifCsvDataTableFormatter formatter( stream, RiaPreferences::current()->csvTextExportFieldSeparator ); + + std::vector header; + const int precision = 2; + header.emplace_back( curveData.xAxisTitle(), RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) ); + header.emplace_back( curveData.yAxisTitle(), RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) ); + formatter.header( header ); + + for ( size_t i = 0; i < curveData.xData( curveIdx ).size(); i++ ) + { + formatter.add( curveData.xData( curveIdx )[i] ); + formatter.add( curveData.yData( curveIdx )[i] ); + formatter.rowCompleted(); + } + formatter.tableCompleted(); + + plotCurveIdx++; + } + asciiData += "\n"; + } + + return asciiData; } //-------------------------------------------------------------------------------------------------- @@ -275,7 +339,7 @@ QString RimCustomVfpPlot::asciiDataForPlotExport() const //-------------------------------------------------------------------------------------------------- void RimCustomVfpPlot::reattachAllCurves() { - for ( auto curve : m_plotCurves() ) + for ( const auto& curve : m_plotCurves() ) { if ( curve->isChecked() ) { @@ -289,7 +353,7 @@ void RimCustomVfpPlot::reattachAllCurves() //-------------------------------------------------------------------------------------------------- void RimCustomVfpPlot::detachAllCurves() { - for ( auto curve : m_plotCurves() ) + for ( const auto& curve : m_plotCurves() ) { curve->detach(); } @@ -308,35 +372,43 @@ QString RimCustomVfpPlot::description() const //-------------------------------------------------------------------------------------------------- QString RimCustomVfpPlot::infoForCurve( RimPlotCurve* plotCurve ) const { - std::vector tables = m_additionalDataSources.ptrReferencedObjectsByType(); - tables.push_back( m_mainDataSource ); - - auto index = m_plotCurves.indexOf( plotCurve ); + auto plotCurveIdx = m_plotCurves.indexOf( plotCurve ); - size_t curveCount = 0; - for ( size_t i = 0; i < m_plotData.size(); i++ ) + if ( plotCurveIdx < m_plotCurveMetaData.size() ) { - curveCount += m_plotData[i].size(); - if ( index < curveCount ) - { - auto tableIndex = i; - - auto table = tables[tableIndex]; - QString info = QString( "Table: %1" ).arg( table->tableNumber() ); - - auto curveIndex = index - ( curveCount - m_plotData[i].size() ); - auto selection = tableSelection( table ); - if ( curveIndex < selection.familyValues.size() ) - { - auto displayValue = convertToDisplayUnit( selection.familyValues[curveIndex], m_familyVariable() ); - auto unitText = getDisplayUnit( m_familyVariable() ); - auto variableName = m_familyVariable().uiText(); - - info += QString( " - %1 %2 %3 " ).arg( variableName ).arg( displayValue ).arg( unitText ); - } - - return info; - } + auto values = m_plotCurveMetaData[plotCurveIdx]; + QString info = QString( "Table: %1\n" ).arg( values.tableNumber ); + info += values.curveName; + + if ( m_familyVariable() != RimVfpDefines::ProductionVariableType::WATER_CUT && m_waterCut().size() > 1 ) + info += QString( "\nWC: %1 %2" ) + .arg( convertToDisplayUnit( values.waterCutValue, RimVfpDefines::ProductionVariableType::WATER_CUT ) ) + .arg( getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType::WATER_CUT ) ); + + if ( m_familyVariable() != RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO && m_gasLiquidRatio().size() > 1 ) + info += QString( "\nGLR: %1 %2" ) + .arg( convertToDisplayUnit( values.gasLiquidRatioValue, RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO ) ) + .arg( getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO ) ); + + if ( m_familyVariable() != RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY && m_artificialLiftQuantity().size() > 1 ) + info += QString( "\nLift: %1 %2" ) + .arg( convertToDisplayUnit( values.artificialLiftQuantityValue, + RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY ) ) + .arg( getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY ) ); + + if ( m_familyVariable() != RimVfpDefines::ProductionVariableType::THP && m_thp().size() > 1 ) + info += QString( "\nTPH: %1 %2" ) + .arg( convertToDisplayUnit( values.thpValue, RimVfpDefines::ProductionVariableType::THP ) ) + .arg( getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType::THP ) ); + + if ( m_familyVariable() != RimVfpDefines::ProductionVariableType::FLOW_RATE && m_flowRate().size() > 1 ) + info += QString( "\nRate: %1 %2" ) + .arg( convertToDisplayUnit( values.flowRateValue, RimVfpDefines::ProductionVariableType::FLOW_RATE ) ) + .arg( getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType::FLOW_RATE ) ); + + info += "\n"; + + return info; } return {}; @@ -470,6 +542,27 @@ void RimCustomVfpPlot::deleteViewWidget() } } +//-------------------------------------------------------------------------------------------------- +/// Create all possible combinations of the vectors passed in. +//-------------------------------------------------------------------------------------------------- +void generateCombinations( const std::vector>& vectors, + std::vector& currentCombination, + std::vector>& allCombinations, + size_t depth ) +{ + if ( depth == vectors.size() ) + { + allCombinations.push_back( currentCombination ); + return; + } + + for ( const auto& value : vectors[depth] ) + { + currentCombination[depth] = value; + generateCombinations( vectors, currentCombination, allCombinations, depth + 1 ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -500,26 +593,86 @@ void RimCustomVfpPlot::onLoadDataAndUpdate() tables.push_back( m_mainDataSource ); m_plotData.clear(); + m_plotCurveMetaData.clear(); for ( const auto& table : tables ) { if ( !table ) continue; - int tableIndex = table->tableNumber(); - auto vfpTables = table->dataSource()->vfpTables(); - - auto vfpPlotData = vfpTables->populatePlotData( tableIndex, - m_primaryVariable(), - m_familyVariable(), - m_interpolatedVariable(), - m_flowingPhase(), - tableSelection( table ) ); - - m_plotData.push_back( vfpPlotData ); - - QColor curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledQColor( colorIndex++ ); + int tableNumber = table->tableNumber(); + auto vfpTables = table->dataSource()->vfpTables(); - populatePlotWidgetWithPlotData( m_plotWidget, vfpPlotData, curveColor ); + if ( table->tableType() == RimVfpDefines::TableType::INJECTION ) + { + auto vfpPlotData = vfpTables->populatePlotData( tableNumber, + m_primaryVariable(), + m_familyVariable(), + m_interpolatedVariable(), + m_flowingPhase(), + VfpTableSelection() ); + + m_plotData.push_back( vfpPlotData ); + + QColor curveColor = curveColors().cycledQColor( colorIndex ); + + auto symbols = curveSymbols(); + auto symbol = symbols[colorIndex % symbols.size()]; + + bool multipleCurveSets = tables.size() > 1; + CurveNameContent curveNameContent; + curveNameContent.defaultName = true; + populatePlotWidgetWithPlotData( m_plotWidget, + vfpPlotData, + VfpValueSelection(), + tableNumber, + curveColor, + symbol, + multipleCurveSets, + curveNameContent ); + colorIndex++; + } + else + { + auto valueSelections = computeValueSelectionCombinations(); + for ( auto& valueSelection : valueSelections ) + { + valueSelection.familyValues = familyValuesForTable( table ); + + auto vfpPlotData = vfpTables->populatePlotData( tableNumber, + m_primaryVariable(), + m_familyVariable(), + m_interpolatedVariable(), + m_flowingPhase(), + valueSelection ); + + m_plotData.push_back( vfpPlotData ); + + QColor curveColor = curveColors().cycledQColor( colorIndex ); + + auto symbols = curveSymbols(); + auto symbol = symbols[colorIndex % symbols.size()]; + + bool multipleCurveSets = ( tables.size() > 1 || ( valueSelections.size() > 1 ) ); + + CurveNameContent curveNameContent; + if ( tables.size() > 1 ) curveNameContent.tableNumber = true; + if ( m_flowRate().size() > 1 ) curveNameContent.flowRate = true; + if ( m_thp().size() > 1 ) curveNameContent.thp = true; + if ( m_artificialLiftQuantity().size() > 1 ) curveNameContent.artificialLiftQuantity = true; + if ( m_waterCut().size() > 1 ) curveNameContent.waterCut = true; + if ( m_gasLiquidRatio().size() > 1 ) curveNameContent.gasLiquidRatio = true; + + populatePlotWidgetWithPlotData( m_plotWidget, + vfpPlotData, + valueSelection, + tableNumber, + curveColor, + symbol, + multipleCurveSets, + curveNameContent ); + colorIndex++; + } + } } updatePlotTitle( @@ -538,36 +691,108 @@ void RimCustomVfpPlot::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCustomVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData, const QColor& color ) +void RimCustomVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, + const VfpPlotData& plotData, + const VfpValueSelection& valueSelection, + int tableNumber, + const QColor& color, + RiuPlotCurveSymbol::PointSymbolEnum curveSymbol, + bool multipleCurveSets, + const CurveNameContent& curveNameContent ) { + if ( !plotWidget ) return; + plotWidget->setAxisScale( RiuPlotAxis::defaultBottom(), 0, 1 ); plotWidget->setAxisScale( RiuPlotAxis::defaultLeft(), 0, 1 ); plotWidget->setAxisAutoScale( RiuPlotAxis::defaultBottom(), true ); plotWidget->setAxisAutoScale( RiuPlotAxis::defaultLeft(), true ); - plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), plotData.xAxisTitle() ); - plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), plotData.yAxisTitle() ); - for ( auto idx = 0u; idx < plotData.size(); idx++ ) + m_xAxisTitle = plotData.xAxisTitle(); + m_yAxisTitle = plotData.yAxisTitle(); + + auto formatCurveNamePart = + [&]( RimVfpDefines::ProductionVariableType variableType, double familyValue, double selectionValue, const QString& namePart ) -> QString + { + double value = ( variableType == m_familyVariable() ) ? familyValue : selectionValue; + double displayValue = convertToDisplayUnit( value, variableType ); + return QString( " %1:%2" ).arg( namePart ).arg( displayValue ); + }; + + for ( auto curveIndex = 0u; curveIndex < plotData.size(); curveIndex++ ) { auto curve = new RimPlotCurve(); curve->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); - curve->setLineThickness( 2 ); - curve->setColor( RiaColorTools::fromQColorTo3f( color ) ); - curve->setSymbol( RiuPlotCurveSymbol::SYMBOL_ELLIPSE ); - curve->setSymbolSize( 6 ); + curve->setLineThickness( m_curveThickness() ); + + if ( multipleCurveSets ) + { + // Use the incoming color for all curves, and cycle the symbols + curve->setColor( RiaColorTools::fromQColorTo3f( color ) ); + auto symbols = curveSymbols(); + auto customSymbol = symbols[curveIndex % symbols.size()]; + curve->setSymbol( customSymbol ); + } + else + { + // Use the incoming symbol for all curves, and cycle the colors + auto customColor = curveColors().cycledQColor( curveIndex ); + curve->setColor( RiaColorTools::fromQColorTo3f( customColor ) ); + curve->setSymbol( curveSymbol ); + } + curve->setSymbolSize( m_curveSymbolSize() ); + + QString curveName; + if ( curveNameContent.defaultName ) curveName = plotData.curveTitle( curveIndex ); + if ( curveNameContent.tableNumber ) curveName += QString( " Table:%1" ).arg( tableNumber ); + + auto familyValue = ( curveIndex < valueSelection.familyValues.size() ) ? valueSelection.familyValues[curveIndex] : 0.0; - curve->setCustomName( plotData.curveTitle( idx ) ); + using pvt = RimVfpDefines::ProductionVariableType; + + if ( curveNameContent.thp || m_familyVariable() == pvt::THP ) + { + curveName += formatCurveNamePart( pvt::THP, familyValue, valueSelection.thpValue, "THP" ); + } + if ( curveNameContent.gasLiquidRatio || m_familyVariable() == pvt::GAS_LIQUID_RATIO ) + { + curveName += formatCurveNamePart( pvt::GAS_LIQUID_RATIO, familyValue, valueSelection.gasLiquidRatioValue, "GLR" ); + } + if ( curveNameContent.waterCut || m_familyVariable() == pvt::WATER_CUT ) + { + curveName += formatCurveNamePart( pvt::WATER_CUT, familyValue, valueSelection.waterCutValue, "WC" ); + } + if ( curveNameContent.artificialLiftQuantity || m_familyVariable() == pvt::ARTIFICIAL_LIFT_QUANTITY ) + { + curveName += formatCurveNamePart( pvt::ARTIFICIAL_LIFT_QUANTITY, familyValue, valueSelection.artificialLiftQuantityValue, "Lift" ); + } + if ( curveNameContent.flowRate || m_familyVariable() == pvt::FLOW_RATE ) + { + curveName += formatCurveNamePart( pvt::FLOW_RATE, familyValue, valueSelection.flowRateValue, "Rate" ); + } + + curve->setCustomName( curveName.trimmed() ); curve->setParentPlotNoReplot( plotWidget ); if ( curve->plotCurve() ) { bool useLogarithmicScale = false; - curve->plotCurve()->setSamplesFromXValuesAndYValues( plotData.xData( idx ), plotData.yData( idx ), useLogarithmicScale ); + curve->plotCurve()->setSamplesFromXValuesAndYValues( plotData.xData( curveIndex ), plotData.yData( curveIndex ), useLogarithmicScale ); } curve->updateCurveAppearance(); curve->appearanceChanged.connect( this, &RimCustomVfpPlot::curveAppearanceChanged ); m_plotCurves.push_back( curve ); + + PlotCurveData plotCurveData; + plotCurveData.curveName = plotData.curveTitle( curveIndex ); + plotCurveData.tableNumber = tableNumber; + plotCurveData.flowRateValue = valueSelection.flowRateValue; + plotCurveData.thpValue = valueSelection.thpValue; + plotCurveData.artificialLiftQuantityValue = valueSelection.artificialLiftQuantityValue; + plotCurveData.waterCutValue = valueSelection.waterCutValue; + plotCurveData.gasLiquidRatioValue = valueSelection.gasLiquidRatioValue; + + m_plotCurveMetaData.emplace_back( plotCurveData ); } updateConnectedEditors(); @@ -674,7 +899,7 @@ std::vector RimCustomVfpPlot::availableValues( RimVfpDefines::Production auto values = m_mainDataSource->dataSource()->vfpTables()->getProductionTableData( m_tableNumber(), variableType ); - if ( m_curveOptionFiltering() == RimVfpDefines::CurveOptionValuesType::UNION_OF_SELECTED_TABLES ) + if ( m_curveValueOptions() == RimVfpDefines::CurveOptionValuesType::UNION_OF_SELECTED_TABLES ) { std::vector tables = m_additionalDataSources.ptrReferencedObjectsByType(); for ( const auto& table : tables ) @@ -701,6 +926,107 @@ RiuPlotCurveInfoTextProvider* RimCustomVfpPlot::curveTextProvider() return &textProvider; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCustomVfpPlot::nonFamilyProductionVariables() const +{ + std::vector variables; + + auto allVariables = { RimVfpDefines::ProductionVariableType::FLOW_RATE, + RimVfpDefines::ProductionVariableType::THP, + RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY, + RimVfpDefines::ProductionVariableType::WATER_CUT, + RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO }; + + for ( const auto& variable : allVariables ) + { + if ( variable != m_familyVariable() ) + { + variables.push_back( variable ); + } + } + return variables; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCustomVfpPlot::computeValueSelectionCombinations() const +{ + auto populateValueSelection = []( VfpValueSelection& selection, RimVfpDefines::ProductionVariableType variableType, double value ) + { + switch ( variableType ) + { + case RimVfpDefines::ProductionVariableType::FLOW_RATE: + selection.flowRateValue = value; + break; + case RimVfpDefines::ProductionVariableType::THP: + selection.thpValue = value; + break; + case RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY: + selection.artificialLiftQuantityValue = value; + break; + case RimVfpDefines::ProductionVariableType::WATER_CUT: + selection.waterCutValue = value; + break; + case RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO: + selection.gasLiquidRatioValue = value; + break; + } + }; + + auto availableVariables = nonFamilyProductionVariables(); + + std::vector> variableVectors; + for ( auto variableType : availableVariables ) + { + variableVectors.push_back( valuesForProductionType( variableType ) ); + } + + std::vector> allCombinations; + std::vector currentCombination( variableVectors.size() ); + generateCombinations( variableVectors, currentCombination, allCombinations, 0 ); + + std::vector valueSelections; + for ( const auto& combination : allCombinations ) + { + VfpValueSelection selection; + for ( size_t i = 0; i < availableVariables.size(); ++i ) + { + populateValueSelection( selection, availableVariables[i], combination[i] ); + } + + valueSelections.push_back( selection ); + } + + return valueSelections; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCustomVfpPlot::curveSymbols() +{ + return { + RiuPlotCurveSymbol::SYMBOL_ELLIPSE, + RiuPlotCurveSymbol::SYMBOL_CROSS, + RiuPlotCurveSymbol::SYMBOL_DIAMOND, + RiuPlotCurveSymbol::SYMBOL_XCROSS, + RiuPlotCurveSymbol::SYMBOL_LEFT_TRIANGLE, + RiuPlotCurveSymbol::SYMBOL_STAR1, + RiuPlotCurveSymbol::SYMBOL_RIGHT_TRIANGLE, + }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::ColorTable RimCustomVfpPlot::curveColors() +{ + return RiaColorTables::summaryCurveDefaultPaletteColors().inverted(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -772,54 +1098,59 @@ QString RimCustomVfpPlot::getDisplayUnit( RimVfpDefines::ProductionVariableType void RimCustomVfpPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_mainDataSource ); - uiOrdering.add( &m_additionalDataSources ); - uiOrdering.add( &m_curveMatchingType ); - uiOrdering.add( &m_curveOptionFiltering ); - - uiOrdering.add( &m_tableType ); - uiOrdering.add( &m_tableNumber ); - uiOrdering.add( &m_referenceDepth ); - uiOrdering.add( &m_interpolatedVariable ); - uiOrdering.add( &m_flowingPhase ); + { + auto group = uiOrdering.addNewGroup( "Configuration" ); + group->add( &m_curveMatchingType ); + group->add( &m_curveValueOptions ); + group->add( &m_interpolatedVariable ); + if ( m_tableType == RimVfpDefines::TableType::PRODUCTION ) + { + group->add( &m_primaryVariable ); + group->add( &m_familyVariable ); + } + } - if ( m_tableType == RimVfpDefines::TableType::PRODUCTION ) { - uiOrdering.add( &m_flowingWaterFraction ); - uiOrdering.add( &m_flowingGasFraction ); + auto group = uiOrdering.addNewGroup( "Table Details" ); + group->add( &m_tableType ); + group->add( &m_tableNumber ); + group->add( &m_referenceDepth ); + group->add( &m_flowingPhase ); - uiOrdering.add( &m_primaryVariable ); - uiOrdering.add( &m_familyVariable ); + if ( m_tableType == RimVfpDefines::TableType::PRODUCTION ) + { + group->add( &m_flowingWaterFraction ); + group->add( &m_flowingGasFraction ); + } + } - caf::PdmUiOrdering* fixedVariablesGroup = uiOrdering.addNewGroup( "Fixed Variables" ); - fixedVariablesGroup->add( &m_flowRateIdx ); - fixedVariablesGroup->add( &m_thpIdx ); - fixedVariablesGroup->add( &m_articifialLiftQuantityIdx ); - fixedVariablesGroup->add( &m_waterCutIdx ); - fixedVariablesGroup->add( &m_gasLiquidRatioIdx ); + { + auto group = uiOrdering.addNewGroup( "Additional Tables" ); + group->setCollapsedByDefault(); + group->add( &m_additionalDataSources ); + } - fixedVariablesGroup->add( &m_familyValues ); + if ( m_tableType == RimVfpDefines::TableType::PRODUCTION ) + { + auto selectionDetailsGroup = uiOrdering.addNewGroup( "Selection Details" ); + selectionDetailsGroup->setCollapsedByDefault(); + selectionDetailsGroup->add( &m_flowRate ); + selectionDetailsGroup->add( &m_thp ); + selectionDetailsGroup->add( &m_artificialLiftQuantity ); + selectionDetailsGroup->add( &m_waterCut ); + selectionDetailsGroup->add( &m_gasLiquidRatio ); + } - // Disable the choices for variables as primary or family - setFixedVariableUiEditability( m_flowRateIdx, RimVfpDefines::ProductionVariableType::FLOW_RATE ); - setFixedVariableUiEditability( m_thpIdx, RimVfpDefines::ProductionVariableType::THP ); - setFixedVariableUiEditability( m_articifialLiftQuantityIdx, RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY ); - setFixedVariableUiEditability( m_waterCutIdx, RimVfpDefines::ProductionVariableType::WATER_CUT ); - setFixedVariableUiEditability( m_gasLiquidRatioIdx, RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO ); + { + auto group = uiOrdering.addNewGroup( "Appearance" ); + group->add( &m_curveThickness ); + group->add( &m_curveSymbolSize ); } uiOrdering.skipRemainingFields( true ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCustomVfpPlot::setFixedVariableUiEditability( caf::PdmFieldHandle& field, RimVfpDefines::ProductionVariableType variableType ) -{ - field.uiCapability()->setUiReadOnly( variableType == m_primaryVariable.v() ); - field.uiCapability()->setUiHidden( variableType == m_familyVariable.v() ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -827,36 +1158,31 @@ QList RimCustomVfpPlot::calculateValueOptions( const caf { QList options = RimPlot::calculateValueOptions( fieldNeedingOptions ); - if ( fieldNeedingOptions == &m_flowRateIdx ) + if ( fieldNeedingOptions == &m_flowRate ) { calculateTableValueOptions( RimVfpDefines::ProductionVariableType::FLOW_RATE, options ); } - else if ( fieldNeedingOptions == &m_thpIdx ) + else if ( fieldNeedingOptions == &m_thp ) { calculateTableValueOptions( RimVfpDefines::ProductionVariableType::THP, options ); } - else if ( fieldNeedingOptions == &m_articifialLiftQuantityIdx ) + else if ( fieldNeedingOptions == &m_artificialLiftQuantity ) { calculateTableValueOptions( RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY, options ); } - else if ( fieldNeedingOptions == &m_waterCutIdx ) + else if ( fieldNeedingOptions == &m_waterCut ) { calculateTableValueOptions( RimVfpDefines::ProductionVariableType::WATER_CUT, options ); } - else if ( fieldNeedingOptions == &m_gasLiquidRatioIdx ) + else if ( fieldNeedingOptions == &m_gasLiquidRatio ) { calculateTableValueOptions( RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO, options ); } - else if ( fieldNeedingOptions == &m_familyValues ) - { - calculateTableValueOptions( m_familyVariable(), options ); - } - else if ( fieldNeedingOptions == &m_additionalDataSources ) { RimVfpDataCollection* vfpDataCollection = RimVfpDataCollection::instance(); @@ -878,9 +1204,60 @@ QList RimCustomVfpPlot::calculateValueOptions( const caf } } + else if ( fieldNeedingOptions == &m_curveThickness ) + { + for ( size_t i = 0; i < 10; i++ ) + { + options.push_back( caf::PdmOptionItemInfo( QString::number( i + 1 ), QVariant::fromValue( i + 1 ) ) ); + } + } + return options; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( auto attrib = dynamic_cast( attribute ) ) + { + attrib->showTextFilter = false; + } + + if ( field == &m_mainDataSource ) + { + if ( auto* myAttr = dynamic_cast( attribute ) ) + { + myAttr->showPreviousAndNextButtons = true; + myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" ); + myAttr->previousIcon = QIcon( ":/ComboBoxUp.svg" ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCustomVfpPlot::valuesForProductionType( RimVfpDefines::ProductionVariableType variableType ) const +{ + switch ( variableType ) + { + case RimVfpDefines::ProductionVariableType::FLOW_RATE: + return m_flowRate(); + case RimVfpDefines::ProductionVariableType::THP: + return m_thp(); + case RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY: + return m_artificialLiftQuantity(); + case RimVfpDefines::ProductionVariableType::WATER_CUT: + return m_waterCut(); + case RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO: + return m_gasLiquidRatio(); + } + + return {}; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -888,11 +1265,11 @@ void RimCustomVfpPlot::calculateTableValueOptions( RimVfpDefines::ProductionVari { auto values = availableValues( variableType ); - for ( size_t i = 0; i < values.size(); i++ ) + for ( double value : values ) { options.push_back( - caf::PdmOptionItemInfo( QString( "%1 %2" ).arg( convertToDisplayUnit( values[i], variableType ) ).arg( getDisplayUnit( variableType ) ), - values[i] ) ); + caf::PdmOptionItemInfo( QString( "%1 %2" ).arg( convertToDisplayUnit( value, variableType ) ).arg( getDisplayUnit( variableType ) ), + value ) ); } } @@ -906,11 +1283,14 @@ void RimCustomVfpPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField if ( changedField == &m_mainDataSource ) { initializeObject(); + initializeSelection(); + zoomAll(); } - if ( changedField == &m_familyVariable || changedField == &m_curveOptionFiltering ) + if ( changedField == &m_additionalDataSources || changedField == &m_curveMatchingType || changedField == &m_curveValueOptions || + changedField == &m_primaryVariable || changedField == &m_familyVariable ) { - m_familyValues.v() = availableValues( m_familyVariable() ); + initializeSelection(); } loadDataAndUpdate(); @@ -918,13 +1298,6 @@ void RimCustomVfpPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField updateConnectedEditors(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCustomVfpPlot::initAfterRead() -{ -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -981,33 +1354,30 @@ void RimCustomVfpPlot::scheduleReplot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -VfpValueSelection RimCustomVfpPlot::tableSelection( RimVfpTable* table ) const +std::vector RimCustomVfpPlot::familyValuesForTable( RimVfpTable* table ) const { - VfpValueSelection selection; + if ( !table || !m_mainDataSource || !m_mainDataSource->dataSource() || !m_mainDataSource->dataSource()->vfpTables() ) return {}; - selection.articifialLiftQuantityValue = m_articifialLiftQuantityIdx(); - selection.flowRateValue = m_flowRateIdx(); - selection.gasLiquidRatioValue = m_gasLiquidRatioIdx(); - selection.thpValue = m_thpIdx(); - selection.waterCutValue = m_waterCutIdx(); + std::vector mainTableFamilyValues = valuesForProductionType( m_familyVariable() ); if ( m_curveMatchingType() == RimVfpDefines::CurveMatchingType::EXACT ) { - selection.familyValues = m_familyValues(); + return mainTableFamilyValues; } - else if ( m_curveMatchingType() == RimVfpDefines::CurveMatchingType::CLOSEST_MATCH_FAMILY ) + + if ( m_curveMatchingType() == RimVfpDefines::CurveMatchingType::CLOSEST_MATCH_FAMILY ) { - auto familyValues = m_familyValues(); - if ( table && table->dataSource() && table->dataSource()->vfpTables() ) + auto valuesToMatch = table->dataSource()->vfpTables()->getProductionTableData( table->tableNumber(), m_familyVariable() ); + auto indices = RigVfpTables::uniqueClosestIndices( mainTableFamilyValues, valuesToMatch ); + + std::vector values; + for ( const auto& i : indices ) { - auto valuesToMatch = table->dataSource()->vfpTables()->getProductionTableData( table->tableNumber(), m_familyVariable() ); - auto indices = RigVfpTables::uniqueClosestIndices( familyValues, valuesToMatch ); - for ( const auto& i : indices ) - { - selection.familyValues.push_back( valuesToMatch[i] ); - } + values.push_back( valuesToMatch[i] ); } + + return values; } - return selection; + return {}; } diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h index 2797eaceaf..cefc9fd15e 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h @@ -21,6 +21,8 @@ #include "RimPlot.h" #include "RimVfpDefines.h" +#include "RiuPlotCurveSymbol.h" + #include "cafPdmPtrArrayField.h" #include "cafPdmPtrField.h" @@ -43,6 +45,11 @@ class VFPInjTable; class VFPProdTable; } // namespace Opm +namespace caf +{ +class ColorTable; +} + //-------------------------------------------------------------------------------------------------- /// Vertical Flow Performance Plot //-------------------------------------------------------------------------------------------------- @@ -57,6 +64,7 @@ class RimCustomVfpPlot : public RimPlot void selectDataSource( RimVfpTable* mainDataSource, const std::vector& vfpTableData ); void setTableNumber( int tableNumber ); void initializeObject(); + void initializeSelection(); // RimPlot implementations RiuPlotWidget* plotWidget() override; @@ -88,21 +96,19 @@ class RimCustomVfpPlot : public RimPlot void scheduleReplot(); -private: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - void initAfterRead() override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - VfpValueSelection tableSelection( RimVfpTable* table ) const; - void initializeFromInitData( const VfpTableInitialData& table ); + std::vector valuesForProductionType( RimVfpDefines::ProductionVariableType variableType ) const; + std::vector familyValuesForTable( RimVfpTable* table ) const; + void initializeFromInitData( const VfpTableInitialData& table ); RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; void calculateTableValueOptions( RimVfpDefines::ProductionVariableType variableType, QList& options ); - void setFixedVariableUiEditability( caf::PdmFieldHandle& field, RimVfpDefines::ProductionVariableType variableType ); - void updatePlotTitle( const QString& plotTitle ); static QString generatePlotTitle( const QString& wellName, int tableNumber, @@ -116,7 +122,25 @@ class RimCustomVfpPlot : public RimPlot static QString getDisplayUnit( RimVfpDefines::ProductionVariableType variableType ); static QString getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType variableType ); - void populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData, const QColor& color ); + struct CurveNameContent + { + bool defaultName = false; + bool tableNumber = false; + bool flowRate = false; + bool thp = false; + bool artificialLiftQuantity = false; + bool waterCut = false; + bool gasLiquidRatio = false; + }; + + void populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, + const VfpPlotData& plotData, + const VfpValueSelection& valueSelection, + int tableNumber, + const QColor& color, + RiuPlotCurveSymbol::PointSymbolEnum curveSymbol, + bool multipleCurveSets, + const CurveNameContent& curveNameContent ); static QString axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ); @@ -133,6 +157,24 @@ class RimCustomVfpPlot : public RimPlot static RiuPlotCurveInfoTextProvider* curveTextProvider(); + std::vector nonFamilyProductionVariables() const; + std::vector computeValueSelectionCombinations() const; + + struct PlotCurveData + { + QString curveName; + int tableNumber; + double flowRateValue; + double thpValue; + double artificialLiftQuantityValue; + double waterCutValue; + double gasLiquidRatioValue; + }; + + static std::vector curveSymbols(); + + static const caf::ColorTable curveColors(); + private: caf::PdmField m_plotTitle; @@ -140,7 +182,7 @@ class RimCustomVfpPlot : public RimPlot caf::PdmPtrArrayField m_additionalDataSources; caf::PdmField> m_curveMatchingType; - caf::PdmField> m_curveOptionFiltering; + caf::PdmField> m_curveValueOptions; caf::PdmField m_tableNumber; caf::PdmField m_referenceDepth; @@ -153,20 +195,25 @@ class RimCustomVfpPlot : public RimPlot caf::PdmField> m_primaryVariable; caf::PdmField> m_familyVariable; - caf::PdmField m_flowRateIdx; - caf::PdmField m_thpIdx; - caf::PdmField m_articifialLiftQuantityIdx; - caf::PdmField m_waterCutIdx; - caf::PdmField m_gasLiquidRatioIdx; - - caf::PdmField> m_familyValues; + caf::PdmField> m_flowRate; + caf::PdmField> m_thp; + caf::PdmField> m_artificialLiftQuantity; + caf::PdmField> m_waterCut; + caf::PdmField> m_gasLiquidRatio; caf::PdmChildField m_yAxisProperties; caf::PdmChildField m_xAxisProperties; caf::PdmChildArrayField m_plotCurves; - std::vector m_plotData; + caf::PdmField m_curveSymbolSize; + caf::PdmField m_curveThickness; + + std::vector m_plotData; + std::vector m_plotCurveMetaData; + + QString m_xAxisTitle; + QString m_yAxisTitle; QPointer m_plotWidget; }; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.cpp index 2814469f64..4329c31556 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpDefines.cpp @@ -85,7 +85,7 @@ void caf::AppEnum::setUp() { addItem( RimVfpDefines::CurveMatchingType::EXACT, "EXACT", "Exact" ); addItem( RimVfpDefines::CurveMatchingType::CLOSEST_MATCH_FAMILY, "CLOSEST_MATCH_FAMILY", "Family Closest Match" ); - setDefault( RimVfpDefines::CurveMatchingType::EXACT ); + setDefault( RimVfpDefines::CurveMatchingType::CLOSEST_MATCH_FAMILY ); } template <> diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp index 0aff309d53..8ac3b072c0 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp @@ -67,6 +67,7 @@ RimCustomVfpPlot* RimVfpPlotCollection::createAndAppendPlots( RimVfpTable* mainD auto vfpPlot = new RimCustomVfpPlot(); vfpPlot->selectDataSource( mainDataSource, tableData ); vfpPlot->initializeObject(); + vfpPlot->initializeSelection(); m_customVfpPlots.push_back( vfpPlot ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp index a6844108fc..cd917639f1 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.cpp @@ -659,7 +659,7 @@ size_t RigVfpTables::getVariableIndexForValue( const Opm::VFPProdTable& } case RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY: { - return findClosestIndexForVariable( targetVariable, valueSelection.articifialLiftQuantityValue, table ); + return findClosestIndexForVariable( targetVariable, valueSelection.artificialLiftQuantityValue, table ); } case RimVfpDefines::ProductionVariableType::FLOW_RATE: { @@ -834,7 +834,7 @@ VfpTableInitialData RigVfpTables::getTableInitialData( int tableIndex ) const auto prodTable = productionTable( tableIndex ); if ( prodTable.has_value() ) { - VfpTableInitialData initialData; + VfpTableInitialData initialData{}; initialData.isProductionTable = true; initialData.tableNumber = prodTable->getTableNum(); initialData.datumDepth = prodTable->getDatumDepth(); @@ -848,7 +848,7 @@ VfpTableInitialData RigVfpTables::getTableInitialData( int tableIndex ) const auto injTable = injectionTable( tableIndex ); if ( injTable.has_value() ) { - VfpTableInitialData initialData; + VfpTableInitialData initialData{}; initialData.isProductionTable = false; initialData.tableNumber = injTable->getTableNum(); initialData.datumDepth = injTable->getDatumDepth(); diff --git a/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h index 1d8b7ab390..8caa1dd8ea 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h +++ b/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h @@ -77,7 +77,7 @@ struct VfpValueSelection { double flowRateValue; double thpValue; - double articifialLiftQuantityValue; + double artificialLiftQuantityValue; double waterCutValue; double gasLiquidRatioValue; From 7f4f8732e1fe038a9909eacd41d943d9e8b4355f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 12 Jun 2024 10:12:26 +0200 Subject: [PATCH 115/332] Revert "#11485 Disable Python and unit test to fix build on GitHub" This reverts commit 742bb5f0d26909c5e9cab459315f9419a9d9716d. --- .github/workflows/ResInsightWithCache.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 968c2c4129..91416c8a0f 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -31,9 +31,9 @@ jobs: os: windows-2022, cc: "cl", cxx: "cl", - build-python-module: false, - execute-unit-tests: false, - execute-pytests: false, + build-python-module: true, + execute-unit-tests: true, + execute-pytests: true, unity-build: true, publish-to-pypi: false, vcpkg-bootstrap: bootstrap-vcpkg.bat, From 7efefbb93aacfeaf0089cd428913929b4a77d6c7 Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Thu, 13 Jun 2024 17:12:17 +0200 Subject: [PATCH 116/332] Update openzgy to latest version --- ThirdParty/openzgy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdParty/openzgy b/ThirdParty/openzgy index 194068f4dc..4132d2d031 160000 --- a/ThirdParty/openzgy +++ b/ThirdParty/openzgy @@ -1 +1 @@ -Subproject commit 194068f4dca443a782b81d35533a89877e25a7e4 +Subproject commit 4132d2d0315a6347ba8a416bc1725505a2d3d8e8 From a0ebb6e496b4f46006e8559671192bf29bf26391 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 14 Jun 2024 17:18:28 +0200 Subject: [PATCH 117/332] Add copyObject to PdmObjectHandle New syntax to copy an object auto curveCopy = curve->copyObject(); Previous deprecated syntax RimColorLegend* customLegend = dynamic_cast( standardLegend->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); --- .../RicEditPreferencesFeature.cpp | 4 +- .../RicCopyStandardLegendFeature.cpp | 4 +- ...pyIntersectionsToAllViewsInCaseFeature.cpp | 6 +-- .../RicAdvancedSnapshotExportFeature.cpp | 3 +- ...ddStoredFlowCharacteristicsPlotFeature.cpp | 3 +- .../RicAddStoredWellAllocationPlotFeature.cpp | 4 +- ...licateTemplateInOtherUnitSystemFeature.cpp | 3 +- .../RicPasteEllipseFractureFeature.cpp | 4 +- .../RicPasteStimPlanFractureFeature.cpp | 4 +- .../RicPasteGridCrossPlotDataSetFeature.cpp | 4 +- .../RicPasteCellFiltersFeature.cpp | 4 +- .../RicPasteEclipseViewsFeature.cpp | 3 +- .../RicPasteGeoMechViewsFeature.cpp | 5 +-- .../RicPasteIntersectionsFeature.cpp | 12 ++--- .../RicNewSummaryPlotFromCurveFeature.cpp | 3 +- .../RicSummaryPlotBuilder.cpp | 6 +-- .../RicCreateSummaryCaseCollectionFeature.cpp | 3 +- .../Commands/RicNewContourMapViewFeature.cpp | 8 +--- .../RicDuplicateSummaryTableFeature.cpp | 3 +- .../RicPasteAsciiDataCurveFeature.cpp | 3 +- .../RicPasteEnsembleCurveSetFeature.cpp | 3 +- .../RicPasteSummaryCurveFeature.cpp | 5 +-- .../RicPasteTimeHistoryCurveFeature.cpp | 3 +- .../RicSummaryPlotEditorUi.cpp | 6 +-- .../RicCreateRftPlotsFeature.cpp | 3 +- .../RicPasteWellLogCurveFeature.cpp | 3 +- .../RicPasteWellLogPlotFeature.cpp | 3 +- .../RicPasteWellLogTrackFeature.cpp | 3 +- .../RicCreateMultipleWellPathLaterals.cpp | 6 +-- .../RicPasteModeledWellPathFeature.cpp | 6 +-- .../RimUserDefinedPolylinesAnnotation.cpp | 3 +- .../RimFractureTemplateCollection.cpp | 8 ++-- .../GeoMech/RimGeoMechCase.cpp | 6 +-- .../ProjectDataModel/RimEclipseCase.cpp | 3 +- .../RimUserDefinedCalculationCollection.cpp | 3 +- .../Summary/RimEnsembleCurveSet.cpp | 3 +- .../Summary/RimSummaryMultiPlotCollection.cpp | 3 +- .../Surfaces/RimEnsembleStatisticsSurface.cpp | 4 +- .../Surfaces/RimFileSurface.cpp | 4 +- .../Surfaces/RimGridCaseSurface.cpp | 2 +- .../WellPath/RimWellPathGeometryDef.cpp | 3 +- .../cafPdmCore/cafPdmObjectHandle.cpp | 16 +++++++ .../cafPdmCore/cafPdmObjectHandle.h | 45 +++++++++++++------ .../cafProjectDataModel/cafPdmObject.cpp | 10 +++++ Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h | 3 ++ .../cafPdmBasicTest.cpp | 11 +++++ 46 files changed, 126 insertions(+), 131 deletions(-) diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp index 0b41b4def7..6a8345f472 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp @@ -103,9 +103,7 @@ void RicEditPreferencesFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- std::unique_ptr RicEditPreferencesFeature::clonePreferences( const RiaPreferences* preferences ) { - caf::PdmObjectHandle* pdmClone = preferences->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ); - - return std::unique_ptr( dynamic_cast( pdmClone ) ); + return std::unique_ptr( preferences->copyObject() ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ColorLegendCommands/RicCopyStandardLegendFeature.cpp b/ApplicationLibCode/Commands/ColorLegendCommands/RicCopyStandardLegendFeature.cpp index aaf880fdf7..995e8325a3 100644 --- a/ApplicationLibCode/Commands/ColorLegendCommands/RicCopyStandardLegendFeature.cpp +++ b/ApplicationLibCode/Commands/ColorLegendCommands/RicCopyStandardLegendFeature.cpp @@ -49,9 +49,7 @@ void RicCopyStandardLegendFeature::onActionTriggered( bool isChecked ) if ( standardLegend ) { // perform deep copy of standard legend object via XML - RimColorLegend* customLegend = dynamic_cast( - standardLegend->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto customLegend = standardLegend->copyObject(); customLegend->setColorLegendName( "Copy of " + standardLegend->colorLegendName() ); RimColorLegendCollection* colorLegendCollection = RimProject::current()->colorLegendCollection; diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp index 372d01bc64..ee0412fcb3 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp @@ -119,8 +119,7 @@ void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionsToOtherViews( { RimIntersectionCollection* destCollection = currGridView->intersectionCollection(); - RimExtrudedCurveIntersection* copy = dynamic_cast( - intersection->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto copy = intersection->copyObject(); CVF_ASSERT( copy ); destCollection->appendIntersectionAndUpdate( copy, false ); @@ -150,8 +149,7 @@ void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionBoxesToOtherVi { RimIntersectionCollection* destCollection = currGridView->intersectionCollection(); - RimBoxIntersection* copy = dynamic_cast( - intersectionBox->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto copy = intersectionBox->copyObject(); CVF_ASSERT( copy ); destCollection->appendIntersectionBoxAndUpdate( copy ); diff --git a/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp index f0951bac66..8c8484815e 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp @@ -157,8 +157,7 @@ void RicAdvancedSnapshotExportFeature::exportMultipleSnapshots( const QString& f RimGeoMechView* sourceGeoMechView = dynamic_cast( sourceView ); if ( geomCase && sourceGeoMechView ) { - RimGeoMechView* copyOfGeoMechView = dynamic_cast( - sourceGeoMechView->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto copyOfGeoMechView = sourceGeoMechView->copyObject(); CVF_ASSERT( copyOfGeoMechView ); geomCase->geoMechViews().push_back( copyOfGeoMechView ); diff --git a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp index 3d9d0aea24..1a123191cd 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp @@ -63,8 +63,7 @@ void RicAddStoredFlowCharacteristicsPlotFeature::onActionTriggered( bool isCheck RimFlowCharacteristicsPlot* sourceObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); - RimFlowCharacteristicsPlot* flowCharacteristicsPlot = - dynamic_cast( sourceObject->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto flowCharacteristicsPlot = sourceObject->copyObject(); CVF_ASSERT( flowCharacteristicsPlot ); flowPlotColl->addFlowCharacteristicsPlotToStoredPlots( flowCharacteristicsPlot ); diff --git a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp index 9e2f4b0395..9fb03b5f07 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp @@ -62,9 +62,7 @@ void RicAddStoredWellAllocationPlotFeature::onActionTriggered( bool isChecked ) { RimWellAllocationPlot* sourceObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); - RimWellAllocationPlot* wellAllocationPlot = - dynamic_cast( sourceObject->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto wellAllocationPlot = sourceObject->copyObject(); CVF_ASSERT( wellAllocationPlot ); flowPlotColl->addWellAllocPlotToStoredPlots( wellAllocationPlot ); diff --git a/ApplicationLibCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp index e79d3fdc8a..e7d5365665 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp @@ -54,8 +54,7 @@ void RicCreateDuplicateTemplateInOtherUnitSystemFeature::onActionTriggered( bool RimFractureTemplate* fractureTemplate = caf::firstAncestorOfTypeFromSelectedObject(); if ( !fractureTemplate ) return; - auto copyOfTemplate = dynamic_cast( - fractureTemplate->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto copyOfTemplate = fractureTemplate->copyObject(); RimFractureTemplateCollection* fractureTemplateCollection = caf::firstAncestorOfTypeFromSelectedObject(); fractureTemplateCollection->addFractureTemplate( copyOfTemplate ); diff --git a/ApplicationLibCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp index a9d6bc747a..27cdb5d666 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp @@ -74,9 +74,7 @@ void RicPasteEllipseFractureFeature::onActionTriggered( bool isChecked ) for ( const auto& source : typedObjects ) { - auto templ = dynamic_cast( - source->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto templ = source->copyObject(); fractureTemplateColl->addFractureTemplate( templ ); RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate( templ ); diff --git a/ApplicationLibCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp index a81d724a27..742a2733f9 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp @@ -74,9 +74,7 @@ void RicPasteStimPlanFractureFeature::onActionTriggered( bool isChecked ) for ( const auto& source : typedObjects ) { - auto copyOfStimPlanTemplate = dynamic_cast( - source->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto copyOfStimPlanTemplate = source->copyObject(); fractureTemplateColl->addFractureTemplate( copyOfStimPlanTemplate ); RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate( copyOfStimPlanTemplate ); diff --git a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicPasteGridCrossPlotDataSetFeature.cpp b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicPasteGridCrossPlotDataSetFeature.cpp index 3ad9e354a8..76a883014a 100644 --- a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicPasteGridCrossPlotDataSetFeature.cpp +++ b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicPasteGridCrossPlotDataSetFeature.cpp @@ -59,9 +59,7 @@ void RicPasteGridCrossPlotDataSetFeature::onActionTriggered( bool isChecked ) for ( RimGridCrossPlotDataSet* dataSet : gridCrossPlotDataSetsOnClipboard() ) { - RimGridCrossPlotDataSet* newDataSet = dynamic_cast( - dataSet->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto newDataSet = dataSet->copyObject(); crossPlot->addDataSet( newDataSet ); newDataSet->resolveReferencesRecursively(); newDataSet->initAfterReadRecursively(); diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp index d2b68bd085..03bfa26645 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp @@ -67,9 +67,7 @@ void RicPasteCellFiltersFeature::onActionTriggered( bool isChecked ) for ( auto obj : objectGroup.objects ) { - auto duplicatedObject = - dynamic_cast( obj->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto duplicatedObject = obj->copyObject(); if ( duplicatedObject ) { cellFilterCollection->addFilterAndNotifyChanges( duplicatedObject, eclipseCase ); diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp index cde76028af..660141b4b0 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp @@ -86,8 +86,7 @@ void RicPasteEclipseViewsFeature::onActionTriggered( bool isChecked ) // Add cases to case group for ( const auto& eclipseView : eclipseViews ) { - auto* rimReservoirView = - dynamic_cast( eclipseView->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto* rimReservoirView = eclipseView->copyObject(); CVF_ASSERT( rimReservoirView ); QString nameOfCopy = QString( "Copy of " ) + rimReservoirView->name(); diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp index 6d305b1870..2a469aa8bb 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp @@ -80,9 +80,8 @@ void RicPasteGeoMechViewsFeature::onActionTriggered( bool isChecked ) // Add cases to case group for ( size_t i = 0; i < geomViews.size(); i++ ) { - RimGeoMechView* rimReservoirView = - dynamic_cast( geomViews[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - QString nameOfCopy = QString( "Copy of " ) + rimReservoirView->name(); + auto rimReservoirView = geomViews[i]->copyObject(); + QString nameOfCopy = QString( "Copy of " ) + rimReservoirView->name(); rimReservoirView->setName( nameOfCopy ); geomCase->geoMechViews().push_back( rimReservoirView ); diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.cpp index 416a17e8ad..0636e85498 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.cpp @@ -78,10 +78,8 @@ void RicPasteIntersectionsFeature::onActionTriggered( bool isChecked ) for ( size_t i = 0; i < intersectionObjects.size(); i++ ) { - RimExtrudedCurveIntersection* intersection = dynamic_cast( - intersectionObjects[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - - QString nameOfCopy = QString( "Copy of " ) + intersection->name(); + auto intersection = intersectionObjects[i]->copyObject(); + QString nameOfCopy = QString( "Copy of " ) + intersection->name(); intersection->setName( nameOfCopy ); if ( i == intersectionObjects.size() - 1 ) @@ -99,10 +97,8 @@ void RicPasteIntersectionsFeature::onActionTriggered( bool isChecked ) for ( size_t i = 0; i < intersectionBoxObjects.size(); i++ ) { - RimBoxIntersection* intersectionBox = dynamic_cast( - intersectionBoxObjects[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - - QString nameOfCopy = QString( "Copy of " ) + intersectionBox->name(); + RimBoxIntersection* intersectionBox = intersectionBoxObjects[i]->copyObject(); + QString nameOfCopy = QString( "Copy of " ) + intersectionBox->name(); intersectionBox->setName( nameOfCopy ); if ( i == intersectionBoxObjects.size() - 1 ) diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromCurveFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromCurveFeature.cpp index 4a6fc4833d..012e9d274f 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromCurveFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromCurveFeature.cpp @@ -38,8 +38,7 @@ void RicNewSummaryPlotFromCurveFeature::onActionTriggered( bool isChecked ) { RimSummaryCurve* curve = static_cast( userData.value() ); - auto curveCopy = dynamic_cast( curve->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto curveCopy = curve->copyObject(); curveCopy->setShowInLegend( true ); RimSummaryPlot* plot = RicSummaryPlotBuilder::createPlot( { curveCopy } ); diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp index d527fa154d..b4a8fb6141 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp @@ -278,8 +278,7 @@ std::vector RicSummaryPlotBuilder::duplicatePlots( const std::vector( plot->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto copy = plot->copyObject(); { // TODO: Workaround for fixing the PdmPointer in RimEclipseResultDefinition // caf::PdmPointer m_eclipseCase; @@ -308,8 +307,7 @@ std::vector RicSummaryPlotBuilder::duplicateSummaryPlots( const for ( auto plot : sourcePlots ) { - auto copy = dynamic_cast( plot->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto copy = plot->copyObject(); if ( copy ) { plots.push_back( copy ); diff --git a/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp b/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp index c47bbe3015..0486ffee06 100644 --- a/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp @@ -87,8 +87,7 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered( bool isChecked ) for ( const auto sumCase : selection ) { - auto copy = dynamic_cast( sumCase->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto copy = sumCase->copyObject(); duplicates.push_back( copy ); } diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp index 9c70677cac..8db4c901e2 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp @@ -210,10 +210,8 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFromExistingContourMap( RimEclipseCase* eclipseCase, RimEclipseContourMapView* existingContourMap ) { - RimEclipseContourMapView* contourMap = dynamic_cast( - existingContourMap->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto contourMap = existingContourMap->copyObject(); CVF_ASSERT( contourMap ); - contourMap->setEclipseCase( eclipseCase ); auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" ); @@ -358,10 +356,8 @@ RimGeoMechContourMapView* RicNewContourMapViewFeature::createGeoMechContourMapFromExistingContourMap( RimGeoMechCase* geoMechCase, RimGeoMechContourMapView* existingContourMap ) { - RimGeoMechContourMapView* contourMap = dynamic_cast( - existingContourMap->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto contourMap = existingContourMap->copyObject(); CVF_ASSERT( contourMap ); - contourMap->setGeoMechCase( geoMechCase ); auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryTableFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryTableFeature.cpp index 96d2a3e335..3e0418cd36 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryTableFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryTableFeature.cpp @@ -63,8 +63,7 @@ void RicDuplicateSummaryTableFeature::copyTableAndAddToCollection( RimSummaryTab RimSummaryTableCollection* summaryTableColl = RimMainPlotCollection::current()->summaryTableCollection(); if ( !summaryTableColl ) return; - RimSummaryTable* newSummaryTable = - dynamic_cast( sourceTable->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto newSummaryTable = sourceTable->copyObject(); CVF_ASSERT( newSummaryTable ); // Add table to collection diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataCurveFeature.cpp index e460992f88..f1444210ca 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataCurveFeature.cpp @@ -64,8 +64,7 @@ void RicPasteAsciiDataCurveFeature::onActionTriggered( bool isChecked ) for ( size_t i = 0; i < sourceObjects.size(); i++ ) { - RimAsciiDataCurve* newObject = dynamic_cast( - sourceObjects[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto newObject = sourceObjects[i]->copyObject(); CVF_ASSERT( newObject ); summaryPlot->addAsciiDataCruve( newObject ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp index f3b7efd1b4..07c68a21a0 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp @@ -45,8 +45,7 @@ RimEnsembleCurveSet* RicPasteEnsembleCurveSetFeature::copyCurveSetAndAddToCollec { CVF_ASSERT( curveSetCollection ); - RimEnsembleCurveSet* newCurveSet = dynamic_cast( - sourceCurveSet->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto newCurveSet = sourceCurveSet->copyObject(); CVF_ASSERT( newCurveSet ); curveSetCollection->addCurveSet( newCurveSet ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp index 19c751952b..474abf2353 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp @@ -45,10 +45,7 @@ RimSummaryCurve* RicPasteSummaryCurveFeature::copyCurveAndAddToPlot( RimSummaryC { RimSummaryPlot* summaryPlot = caf::firstAncestorOfTypeFromSelectedObject(); - RimSummaryCurve* newCurve = - dynamic_cast( sourceCurve->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - CVF_ASSERT( newCurve ); - + auto newCurve = sourceCurve->copyObject(); summaryPlot->addCurveAndUpdate( newCurve ); // Resolve references after object has been inserted into the project data model diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteTimeHistoryCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteTimeHistoryCurveFeature.cpp index 2b2a3bc73e..fdc48c2818 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteTimeHistoryCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteTimeHistoryCurveFeature.cpp @@ -72,8 +72,7 @@ void RicPasteTimeHistoryCurveFeature::onActionTriggered( bool isChecked ) for ( size_t i = 0; i < sourceObjects.size(); i++ ) { - RimGridTimeHistoryCurve* newObject = dynamic_cast( - sourceObjects[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto newObject = sourceObjects[i]->copyObject(); CVF_ASSERT( newObject ); summaryPlot->addGridTimeHistoryCurve( newObject ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp index 5392e14473..4fd1b0a712 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp @@ -705,8 +705,7 @@ void RicSummaryPlotEditorUi::updateTargetPlot() //-------------------------------------------------------------------------------------------------- void RicSummaryPlotEditorUi::copyCurveAndAddToPlot( const RimSummaryCurve* curve, RimSummaryPlot* plot, bool forceVisible ) { - auto curveCopy = - dynamic_cast( curve->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto curveCopy = curve->copyObject(); CVF_ASSERT( curveCopy ); if ( forceVisible ) @@ -728,8 +727,7 @@ void RicSummaryPlotEditorUi::copyCurveAndAddToPlot( const RimSummaryCurve* curve //-------------------------------------------------------------------------------------------------- void RicSummaryPlotEditorUi::copyEnsembleCurveAndAddToCurveSet( const RimSummaryCurve* curve, RimEnsembleCurveSet* curveSet, bool forceVisible ) { - RimSummaryCurve* curveCopy = - dynamic_cast( curve->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto curveCopy = curve->copyObject(); CVF_ASSERT( curveCopy ); if ( forceVisible ) diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp index 274daa40f4..19e4bf81a1 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp @@ -102,8 +102,7 @@ void RicCreateRftPlotsFeature::appendRftPlotForWell( const QString& wellName, Ri // Create a RFT plot based on wellName, and reuse the data source selection in sourcePlot - auto rftPlot = - dynamic_cast( sourcePlot->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto rftPlot = sourcePlot->copyObject(); if ( !rftPlot ) return; rftPlot->setSimWellOrWellPathName( wellName ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp index 081dc09e5a..c81b329491 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp @@ -105,8 +105,7 @@ void RicPasteWellLogCurveFeature::onActionTriggered( bool isChecked ) auto* rftCurve = dynamic_cast( sourceObject.p() ); if ( fileCurve || measurementCurve || extractionCurve || rftCurve ) { - auto* newObject = dynamic_cast( - sourceObject->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto* newObject = sourceObject->copyObject(); CVF_ASSERT( newObject ); wellLogTrack->addCurve( newObject ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.cpp index fd30d93988..1304dcfa98 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.cpp @@ -72,8 +72,7 @@ void RicPasteWellLogPlotFeature::onActionTriggered( bool isChecked ) RimWellLogPlot* fileCurve = sourceObjects[i]; if ( fileCurve ) { - RimWellLogPlot* newObject = dynamic_cast( - fileCurve->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto newObject = fileCurve->copyObject(); CVF_ASSERT( newObject ); wellLogPlotCollection->addWellLogPlot( newObject ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.cpp index 822253f595..9da0965df7 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.cpp @@ -73,8 +73,7 @@ void RicPasteWellLogTrackFeature::onActionTriggered( bool isChecked ) RimWellLogTrack* fileCurve = sourceObjects[i]; if ( fileCurve ) { - RimWellLogTrack* newObject = dynamic_cast( - fileCurve->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto newObject = fileCurve->copyObject(); CVF_ASSERT( newObject ); wellLogPlot->addPlot( newObject ); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLaterals.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLaterals.cpp index f8fb5fb2f8..5fcff88dfa 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLaterals.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLaterals.cpp @@ -146,10 +146,8 @@ void RicCreateMultipleWellPathLaterals::slotAppendFractures() { for ( auto measuredDepth : m_ui->locationConfig()->locations() ) { - RimModeledWellPath* newModeledWellPath = dynamic_cast( - sourceLateral->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - - auto nameOfNewWell = RicNewWellPathLateralAtDepthFeature::updateNameOfParentAndFindNameOfSideStep( parentWellPath ); + auto newModeledWellPath = sourceLateral->copyObject(); + auto nameOfNewWell = RicNewWellPathLateralAtDepthFeature::updateNameOfParentAndFindNameOfSideStep( parentWellPath ); newModeledWellPath->setName( nameOfNewWell ); newModeledWellPath->wellPathTieIn()->setTieInMeasuredDepth( measuredDepth ); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp index 2d6b935970..519609f6bd 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicPasteModeledWellPathFeature.cpp @@ -148,10 +148,8 @@ RimModeledWellPath* RicPasteModeledWellPathFeature::duplicateAndInitializeWellPa auto wpc = RimTools::wellPathCollection(); - auto* destinationWellPath = dynamic_cast( - sourceWellPath->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - - QString name = sourceWellPath->name() + "(copy)"; + auto* destinationWellPath = sourceWellPath->copyObject(); + QString name = sourceWellPath->name() + "(copy)"; destinationWellPath->setName( name ); wpc->addWellPath( destinationWellPath ); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp index d86ab4b699..2cc5018458 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp @@ -121,8 +121,7 @@ void RimUserDefinedPolylinesAnnotation::appendTarget( const cvf::Vec3d& defaultP } else { - target = dynamic_cast( - targets.back()->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + target = targets.back()->copyObject(); } if ( target ) diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 17cbcd59a2..9a1b4c8605 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -221,11 +221,9 @@ void RimFractureTemplateCollection::createAndAssignTemplateCopyForNonMatchingUni { if ( !templateWithMatchingUnit ) { - templateWithMatchingUnit = dynamic_cast( - fractureTemplate->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - - auto currentUnit = fractureTemplate->fractureTemplateUnit(); - auto neededUnit = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN; + templateWithMatchingUnit = fractureTemplate->copyObject(); + auto currentUnit = fractureTemplate->fractureTemplateUnit(); + auto neededUnit = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN; if ( currentUnit == RiaDefines::EclipseUnitSystem::UNITS_METRIC ) { neededUnit = RiaDefines::EclipseUnitSystem::UNITS_FIELD; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp index ee72f023b1..8800ce7ec4 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp @@ -247,8 +247,7 @@ RimGeoMechView* RimGeoMechCase::createAndAddReservoirView() //-------------------------------------------------------------------------------------------------- RimGeoMechView* RimGeoMechCase::createCopyAndAddView( const RimGeoMechView* sourceView ) { - RimGeoMechView* rimGeoMechView = - dynamic_cast( sourceView->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto rimGeoMechView = sourceView->copyObject(); CVF_ASSERT( rimGeoMechView ); rimGeoMechView->setGeoMechCase( this ); @@ -268,8 +267,7 @@ RimGeoMechCase* RimGeoMechCase::createCopy( const QString& newInputFileName ) { RimProject* project = RimProject::current(); - RimGeoMechCase* copycase = - dynamic_cast( xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto copycase = copyObject(); CVF_ASSERT( copycase ); QFileInfo filenameInfo( newInputFileName ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index a95f60104a..6bc9ab4709 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -329,8 +329,7 @@ RimEclipseView* RimEclipseCase::createCopyAndAddView( const RimEclipseView* sour { CVF_ASSERT( sourceView ); - RimEclipseView* rimEclipseView = - dynamic_cast( sourceView->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto rimEclipseView = sourceView->copyObject(); CVF_ASSERT( rimEclipseView ); rimEclipseView->setEclipseCase( this ); diff --git a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp index b8572c84b1..d3f33d222b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp @@ -65,8 +65,7 @@ RimUserDefinedCalculation* RimUserDefinedCalculationCollection::addCalculation( //-------------------------------------------------------------------------------------------------- RimUserDefinedCalculation* RimUserDefinedCalculationCollection::addCalculationCopy( const RimUserDefinedCalculation* sourceCalculation ) { - RimUserDefinedCalculation* calcCopy = dynamic_cast( - sourceCalculation->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto calcCopy = sourceCalculation->copyObject(); CVF_ASSERT( calcCopy ); std::set calcNames; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 76d5b59f02..c2ec618fb7 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -2282,8 +2282,7 @@ void RimEnsembleCurveSet::updateStatisticsCurves() //-------------------------------------------------------------------------------------------------- RimEnsembleCurveSet* RimEnsembleCurveSet::clone() const { - RimEnsembleCurveSet* copy = - dynamic_cast( xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto copy = copyObject(); copy->setSummaryCaseCollection( m_yValuesSummaryCaseCollection() ); // Update summary case references diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp index a53964e00d..039413268e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp @@ -159,8 +159,7 @@ void RimSummaryMultiPlotCollection::duplicatePlot( RimSummaryMultiPlot* plotToDu { if ( !plotToDuplicate ) return; - auto plotCopy = dynamic_cast( plotToDuplicate->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto plotCopy = plotToDuplicate->copyObject(); addSummaryMultiPlot( plotCopy ); plotCopy->resolveReferencesRecursively(); diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleStatisticsSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleStatisticsSurface.cpp index ee0ed054e2..71f4ef4360 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleStatisticsSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleStatisticsSurface.cpp @@ -86,9 +86,7 @@ bool RimEnsembleStatisticsSurface::onLoadData() //-------------------------------------------------------------------------------------------------- RimSurface* RimEnsembleStatisticsSurface::createCopy() { - auto* newSurface = - dynamic_cast( xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto newSurface = copyObject(); if ( !newSurface->onLoadData() ) { delete newSurface; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp index 80808175be..81e6c9a30a 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp @@ -81,9 +81,7 @@ bool RimFileSurface::onLoadData() //-------------------------------------------------------------------------------------------------- RimSurface* RimFileSurface::createCopy() { - RimFileSurface* newSurface = - dynamic_cast( xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - + auto newSurface = copyObject(); if ( !newSurface->onLoadData() ) { delete newSurface; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.cpp index 1e0275d960..032091cb3c 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.cpp @@ -89,7 +89,7 @@ bool RimGridCaseSurface::onLoadData() //-------------------------------------------------------------------------------------------------- RimSurface* RimGridCaseSurface::createCopy() { - auto* newSurface = dynamic_cast( xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto* newSurface = copyObject(); newSurface->setCase( m_case.value() ); // TODO: case seems to get lost in the xml copy, investigate later if ( !newSurface->onLoadData() ) diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp index f6bd5bda93..fc0d2b2c92 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp @@ -427,8 +427,7 @@ RimWellPathTarget* RimWellPathGeometryDef::appendTarget() } else { - wellPathTarget = dynamic_cast( - targets.back()->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + wellPathTarget = targets.back()->copyObject(); } if ( wellPathTarget ) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp index b7faa527dd..b0f6216623 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp @@ -167,6 +167,14 @@ void PdmObjectHandle::prepareForDelete() m_pointersReferencingMe.clear(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmObjectHandle::addCapability( PdmObjectCapability* capability, bool takeOwnership ) +{ + m_capabilities.push_back( std::make_pair( capability, takeOwnership ) ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -181,6 +189,14 @@ void PdmObjectHandle::addField( PdmFieldHandle* field, const QString& keyword ) m_fields.push_back( field ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmObjectHandle* PdmObjectHandle::doCopyObject() const +{ + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.h index 5ab98c79a1..2695cd9752 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.h @@ -31,6 +31,10 @@ class PdmObjectHandle : public SignalObserver, public SignalEmitter static QString classKeywordStatic(); // For PdmXmlFieldCap to be able to handle fields of PdmObjectHandle directly static std::vector classKeywordAliases(); + // Function template to call the virtual copy function + template + [[nodiscard]] T* copyObject() const; + /// The registered fields contained in this PdmObject. [[nodiscard]] std::vector fields() const; [[nodiscard]] PdmFieldHandle* findField( const QString& keyword ) const; @@ -84,21 +88,10 @@ class PdmObjectHandle : public SignalObserver, public SignalEmitter void prepareForDelete(); // Object capabilities - void addCapability( PdmObjectCapability* capability, bool takeOwnership ) - { - m_capabilities.push_back( std::make_pair( capability, takeOwnership ) ); - } + void addCapability( PdmObjectCapability* capability, bool takeOwnership ); template - CapabilityType* capability() const - { - for ( size_t i = 0; i < m_capabilities.size(); ++i ) - { - CapabilityType* capability = dynamic_cast( m_capabilities[i].first ); - if ( capability ) return capability; - } - return nullptr; - } + CapabilityType* capability() const; PdmUiObjectHandle* uiCapability() const; // Implementation is in cafPdmUiObjectHandle.cpp PdmXmlObjectHandle* xmlCapability() const; // Implementation is in cafPdmXmlObjectHandle.cpp @@ -118,6 +111,9 @@ class PdmObjectHandle : public SignalObserver, public SignalEmitter protected: void addField( PdmFieldHandle* field, const QString& keyword ); + // Virtual method used to copy objects. The implementation is in PdmObject + [[nodiscard]] virtual PdmObjectHandle* doCopyObject() const; + private: PDM_DISABLE_COPY_AND_ASSIGN( PdmObjectHandle ); @@ -173,6 +169,16 @@ class PdmObjectHandle : public SignalObserver, public SignalEmitter namespace caf { + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +[[nodiscard]] T* PdmObjectHandle::copyObject() const +{ + return dynamic_cast( doCopyObject() ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -338,4 +344,17 @@ template return objectsOfType; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +CapabilityType* PdmObjectHandle::capability() const +{ + for ( auto capability : m_capabilities ) + { + if ( auto capabilityType = dynamic_cast( capability.first ) ) return capabilityType; + } + return nullptr; +} + } // End of namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp index 968ff651ad..b389b8098e 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp @@ -17,6 +17,16 @@ caf::PdmObject::PdmObject() CAF_PDM_InitObject( "Base PDM Object", "", "", "The Abstract Base Class for the Project Data Model" ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmObjectHandle* PdmObject::doCopyObject() const +{ + if ( !xmlCapability() ) return nullptr; + + return xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h index 4f4c8fb71c..7b49ebbb23 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h @@ -186,6 +186,9 @@ class PdmObject : public PdmObjectHandle, public PdmXmlObjectHandle, public PdmU /// Gets all children matching class keyword. Not recursive. void childrenFromClassKeyword( const QString& classKeyword, std::vector& children ) const; + +protected: + PdmObjectHandle* doCopyObject() const override; }; } // End of namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp index 1e4b245750..ea19bdfc4d 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp @@ -991,3 +991,14 @@ TEST( BaseTest, PdmReferenceHelper ) EXPECT_TRUE( fromRef == &( ihd1->m_simpleObjectsField ) ); } } + +TEST( BaseTest, CopyObject ) +{ + const double testValue = 123.345; + + auto ihd1 = std::make_unique(); + ihd1->m_doubleMember = testValue; + + auto objectCopy = std::unique_ptr( ihd1->copyObject() ); + EXPECT_EQ( testValue, objectCopy->m_doubleMember ); +} From 0477371e0d0bfc177f5a7f7d93d4786f8376a7ca Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 29 May 2024 10:57:59 +0200 Subject: [PATCH 118/332] Refactor: use new base class WellLog where possible. --- .../RicImportWellLogCsvFileFeature.cpp | 2 +- .../Commands/RicWellLogTools.cpp | 8 +- ApplicationLibCode/Commands/RicWellLogTools.h | 4 +- .../RicAdd3dWellLogFileCurveFeature.cpp | 4 +- .../RicMoveWellLogFilesFeature.cpp | 4 +- .../RicNewWellLogFileCurveFeature.cpp | 4 +- .../RicWellLogFileCloseFeature.cpp | 2 +- .../ProjectDataModel/WellPath/RimWellPath.cpp | 89 ++++++++++++------- .../ProjectDataModel/WellPath/RimWellPath.h | 13 +-- .../WellPath/RimWellPathCollection.cpp | 4 +- 10 files changed, 82 insertions(+), 52 deletions(-) diff --git a/ApplicationLibCode/Commands/RicImportWellLogCsvFileFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogCsvFileFeature.cpp index 18b963e8e0..92897e15cd 100644 --- a/ApplicationLibCode/Commands/RicImportWellLogCsvFileFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportWellLogCsvFileFeature.cpp @@ -74,7 +74,7 @@ void RicImportWellLogCsvFileFeature::onActionTriggered( bool isChecked ) QString errorMessage; if ( !wellLogCsvFile->readFile( &errorMessage ) ) { - wellPath->deleteWellLogFile( wellLogCsvFile ); + wellPath->deleteWellLog( wellLogCsvFile ); QString displayMessage = "Errors opening the CSV file: \n" + errorMessage; RiaLogging::errorInMessageBox( Riu3DMainWindowTools::mainWindowWidget(), "File open error", displayMessage ); return; diff --git a/ApplicationLibCode/Commands/RicWellLogTools.cpp b/ApplicationLibCode/Commands/RicWellLogTools.cpp index 9a8f412f0e..055d3b54d8 100644 --- a/ApplicationLibCode/Commands/RicWellLogTools.cpp +++ b/ApplicationLibCode/Commands/RicWellLogTools.cpp @@ -160,14 +160,14 @@ void RicWellLogTools::addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellPath* RicWellLogTools::selectedWellPathWithLogFile() +RimWellPath* RicWellLogTools::selectedWellPathWithLog() { std::vector selection; caf::SelectionManager::instance()->objectsByType( &selection ); if ( !selection.empty() ) { RimWellPath* wellPath = selection[0]; - if ( !wellPath->wellLogFiles().empty() ) + if ( !wellPath->wellLogs().empty() ) { return wellPath; } @@ -179,10 +179,10 @@ RimWellPath* RicWellLogTools::selectedWellPathWithLogFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellPath* RicWellLogTools::findWellPathWithLogFileFromSelection() +RimWellPath* RicWellLogTools::findWellPathWithLogFromSelection() { RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType(); - if ( wellPath && !wellPath->wellLogFiles().empty() ) + if ( wellPath && !wellPath->wellLogs().empty() ) { return wellPath; } diff --git a/ApplicationLibCode/Commands/RicWellLogTools.h b/ApplicationLibCode/Commands/RicWellLogTools.h index 563895e898..5d32c04d51 100644 --- a/ApplicationLibCode/Commands/RicWellLogTools.h +++ b/ApplicationLibCode/Commands/RicWellLogTools.h @@ -51,8 +51,8 @@ class RicWellLogTools static bool hasRftDataForWell( const QString& wellName ); static bool isWellPathOrSimWellSelectedInView(); static void addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack, const std::vector& wellLogFileChannels ); - static RimWellPath* selectedWellPathWithLogFile(); - static RimWellPath* findWellPathWithLogFileFromSelection(); + static RimWellPath* selectedWellPathWithLog(); + static RimWellPath* findWellPathWithLogFromSelection(); static RimWellLogRftCurve* addRftCurve( RimWellLogTrack* plotTrack, const RimSimWellInView* simWell, bool showPlotWindow = true ); static RimWellLogLasFileCurve* addFileCurve( RimWellLogTrack* plotTrack, bool showPlotWindow = true ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp index b43a5d3511..3df6c45002 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp @@ -38,7 +38,7 @@ bool RicAdd3dWellLogFileCurveFeature::isCommandEnabled() const std::vector cases = RimProject::current()->allGridCases(); if ( cases.empty() ) return false; - return ( RicWellLogTools::findWellPathWithLogFileFromSelection() != nullptr ); + return ( RicWellLogTools::findWellPathWithLogFromSelection() != nullptr ); } //-------------------------------------------------------------------------------------------------- @@ -46,7 +46,7 @@ bool RicAdd3dWellLogFileCurveFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicAdd3dWellLogFileCurveFeature::onActionTriggered( bool isChecked ) { - RimWellPath* selectedWellPath = RicWellLogTools::findWellPathWithLogFileFromSelection(); + RimWellPath* selectedWellPath = RicWellLogTools::findWellPathWithLogFromSelection(); if ( !selectedWellPath ) return; Rim3dWellLogFileCurve* rim3dWellLogFileCurve = new Rim3dWellLogFileCurve(); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.cpp index b3beafa003..18d3b3162d 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.cpp @@ -61,8 +61,8 @@ void RicMoveWellLogFilesFeature::onActionTriggered( bool isChecked ) if ( !destWellPath || !wellLogFile || !sourceWellPath ) return; - sourceWellPath->detachWellLogFile( wellLogFile ); - destWellPath->addWellLogFile( wellLogFile ); + sourceWellPath->detachWellLog( wellLogFile ); + destWellPath->addWellLog( wellLogFile ); sourceWellPath->updateConnectedEditors(); destWellPath->updateConnectedEditors(); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp index e63b1150db..f702eb9fe5 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp @@ -48,7 +48,7 @@ bool RicNewWellLogFileCurveFeature::isCommandEnabled() const { if ( RicWellLogPlotCurveFeatureImpl::parentWellRftPlot() ) return false; return ( caf::SelectionManager::instance()->selectedItemAncestorOfType() != nullptr && wellLogFilesAvailable() ) || - RicWellLogTools::selectedWellPathWithLogFile() != nullptr; + RicWellLogTools::selectedWellPathWithLog() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -63,7 +63,7 @@ void RicNewWellLogFileCurveFeature::onActionTriggered( bool isChecked ) } else { - RimWellPath* wellPath = RicWellLogTools::selectedWellPathWithLogFile(); + RimWellPath* wellPath = RicWellLogTools::selectedWellPathWithLog(); if ( wellPath ) { RimWellLogTrack* newWellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack(); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.cpp index daf5eab195..d691baa830 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.cpp @@ -59,7 +59,7 @@ void RicWellLogFileCloseFeature::onActionTriggered( bool isChecked ) if ( parentWellPath ) { std::set referringPlots = referringWellLogPlots( wellLogFile ); - parentWellPath->deleteWellLogFile( wellLogFile ); + parentWellPath->deleteWellLog( wellLogFile ); for ( RimViewWindow* plot : referringPlots ) { diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp index 3a99298198..7209487437 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp @@ -131,7 +131,7 @@ RimWellPath::RimWellPath() CAF_PDM_InitScriptableFieldNoDefault( &m_completionSettings, "CompletionSettings", "Completion Settings" ); m_completionSettings = new RimWellPathCompletionSettings; - CAF_PDM_InitFieldNoDefault( &m_wellLogFiles, "WellLogFiles", "Well Log Files" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogs, "WellLogFiles", "Well Logs" ); CAF_PDM_InitFieldNoDefault( &m_3dWellLogCurves, "CollectionOf3dWellLogCurves", "3D Track" ); m_3dWellLogCurves = new Rim3dWellLogCurveCollection; @@ -161,9 +161,9 @@ RimWellPath::RimWellPath() //-------------------------------------------------------------------------------------------------- RimWellPath::~RimWellPath() { - for ( const auto& file : m_wellLogFiles() ) + for ( const auto& wellLog : m_wellLogs() ) { - delete file; + delete wellLog; } RimWellLogPlotCollection* plotCollection = RimMainPlotCollection::current()->wellLogPlotCollection(); @@ -577,7 +577,24 @@ void RimWellPath::setNameNoUpdateOfExportName( const QString& name ) //-------------------------------------------------------------------------------------------------- std::vector RimWellPath::wellLogFiles() const { - return std::vector( m_wellLogFiles.begin(), m_wellLogFiles.end() ); + std::vector wellLogFiles; + for ( RimWellLog* wellLog : m_wellLogs ) + { + if ( auto wellLogFile = dynamic_cast( wellLog ) ) + { + wellLogFiles.push_back( wellLogFile ); + } + } + + return wellLogFiles; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellPath::wellLogs() const +{ + return m_wellLogs.childrenByType(); } //-------------------------------------------------------------------------------------------------- @@ -585,11 +602,9 @@ std::vector RimWellPath::wellLogFiles() const //-------------------------------------------------------------------------------------------------- RimWellLogFile* RimWellPath::firstWellLogFileMatchingChannelName( const QString& channelName ) const { - std::vector allWellLogFiles = wellLogFiles(); - for ( RimWellLogFile* logFile : allWellLogFiles ) + for ( RimWellLogFile* logFile : wellLogFiles() ) { - std::vector channels = logFile->wellLogChannels(); - for ( RimWellLogChannel* channel : channels ) + for ( RimWellLogChannel* channel : logFile->wellLogChannels() ) { if ( channel->name() == channelName ) { @@ -597,6 +612,7 @@ RimWellLogFile* RimWellPath::firstWellLogFileMatchingChannelName( const QString& } } } + return nullptr; } @@ -745,7 +761,7 @@ void RimWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& ui //-------------------------------------------------------------------------------------------------- void RimWellPath::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) { - uiTreeOrdering.add( &m_wellLogFiles ); + uiTreeOrdering.add( &m_wellLogs ); if ( m_wellIASettingsCollection()->isEnabled() && m_wellIASettingsCollection()->hasSettings() ) { @@ -892,47 +908,58 @@ double RimWellPath::datumElevation() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPath::addWellLogFile( RimWellLogFile* logFileInfo ) +void RimWellPath::addWellLog( RimWellLog* wellLog ) { - // Prevent the same file from being loaded more than once - auto itr = std::find_if( m_wellLogFiles.begin(), - m_wellLogFiles.end(), - [&]( const RimWellLogFile* file ) - { return QString::compare( file->fileName(), logFileInfo->fileName(), Qt::CaseInsensitive ) == 0; } ); - - // Todo: Verify well name to ensure all well log files having the same well name - - if ( itr == m_wellLogFiles.end() ) + if ( RimWellLogFile* wellLogFile = dynamic_cast( wellLog ) ) { - m_wellLogFiles.push_back( logFileInfo ); - - if ( m_wellLogFiles.size() == 1 && name().isEmpty() ) + // Prevent the same file from being loaded more than once + auto itr = + std::find_if( m_wellLogs.begin(), + m_wellLogs.end(), + [&]( const RimWellLog* existingWellLog ) + { + auto existingWellLogFile = dynamic_cast( existingWellLog ); + return existingWellLogFile && + QString::compare( existingWellLogFile->fileName(), wellLogFile->fileName(), Qt::CaseInsensitive ) == 0; + } ); + + // Todo: Verify well name to ensure all well log files having the same well name + if ( itr == m_wellLogs.end() ) { - setName( m_wellLogFiles[0]->wellName() ); + m_wellLogs.push_back( wellLog ); + + if ( m_wellLogs.size() == 1 && name().isEmpty() ) + { + setName( m_wellLogs[0]->wellName() ); + } } } + else + { + m_wellLogs.push_back( osduWellLog ); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPath::deleteWellLogFile( RimWellLogFile* logFileInfo ) +void RimWellPath::deleteWellLog( RimWellLog* wellLog ) { - detachWellLogFile( logFileInfo ); - delete logFileInfo; + detachWellLog( wellLog ); + delete wellLog; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPath::detachWellLogFile( RimWellLogFile* logFileInfo ) +void RimWellPath::detachWellLog( RimWellLog* wellLog ) { - auto pdmObject = dynamic_cast( logFileInfo ); - for ( size_t i = 0; i < m_wellLogFiles.size(); i++ ) + auto pdmObject = dynamic_cast( wellLog ); + for ( size_t i = 0; i < m_wellLogs.size(); i++ ) { - if ( m_wellLogFiles[i] == pdmObject ) + if ( m_wellLogs[i] == pdmObject ) { - m_wellLogFiles.removeChild( pdmObject ); + m_wellLogs.removeChild( pdmObject ); break; } } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.h index 8bf83163cf..f43f789576 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.h @@ -62,6 +62,7 @@ class RimWellPathTieIn; class RimMswCompletionParameters; class RimWellIASettingsCollection; class RimWellLogFile; +class RimWellLog; //================================================================================================== /// @@ -105,11 +106,13 @@ class RimWellPath : public caf::PdmObject, public RimWellPathComponentInterface double uniqueStartMD() const; double uniqueEndMD() const; - void addWellLogFile( RimWellLogFile* logFileInfo ); - void deleteWellLogFile( RimWellLogFile* logFileInfo ); - void detachWellLogFile( RimWellLogFile* logFileInfo ); + void addWellLog( RimWellLog* wellLog ); + void deleteWellLog( RimWellLog* wellLog ); + void detachWellLog( RimWellLog* wellLog ); std::vector wellLogFiles() const; - RimWellLogFile* firstWellLogFileMatchingChannelName( const QString& channelName ) const; + std::vector wellLogs() const; + + RimWellLogFile* firstWellLogFileMatchingChannelName( const QString& channelName ) const; void setFormationsGeometry( cvf::ref wellPathFormations ); bool readWellPathFormationsFile( QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter ); @@ -210,7 +213,7 @@ class RimWellPath : public caf::PdmObject, public RimWellPathComponentInterface caf::PdmField m_wellPathRadiusScaleFactor; caf::PdmField m_wellPathColor; - caf::PdmChildArrayField m_wellLogFiles; + caf::PdmChildArrayField m_wellLogs; caf::PdmChildField m_3dWellLogCurves; caf::PdmChildField m_completionSettings; caf::PdmChildField m_completions; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 7aa323c371..fea4d8a17a 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -405,7 +405,7 @@ std::vector RimWellPathCollection::addWellLogs( const QStrin addWellPath( wellPath ); } - wellPath->addWellLogFile( logFileInfo ); + wellPath->addWellLog( logFileInfo ); logFileInfos.push_back( logFileInfo ); } } @@ -421,7 +421,7 @@ std::vector RimWellPathCollection::addWellLogs( const QStrin //-------------------------------------------------------------------------------------------------- void RimWellPathCollection::addWellLog( RimWellLogFile* wellLogFile, RimWellPath* wellPath ) { - wellPath->addWellLogFile( wellLogFile ); + wellPath->addWellLog( wellLogFile ); sortWellsByName(); updateAllRequiredEditors(); } From 5be47b3d2c684729440c9fea1e3979f6b30dc071 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 29 May 2024 15:05:47 +0200 Subject: [PATCH 119/332] Refactor: Use more generic base class. --- ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp | 4 ++-- ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 179bfe7a14..f8aaf2e540 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -144,9 +144,9 @@ bool RimWellPlotTools::hasPressureData( RimEclipseResultCase* gridCase ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::hasFlowData( const RimWellLogFile* wellLogFile ) +bool RimWellPlotTools::hasFlowData( const RimWellLog* wellLog ) { - for ( RimWellLogChannel* const wellLogChannel : wellLogFile->wellLogChannels() ) + for ( RimWellLogChannel* const wellLogChannel : wellLog->wellLogChannels() ) { if ( isFlowChannel( wellLogChannel ) ) return true; } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h index 47bca4f5b6..ced86c8550 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h @@ -93,7 +93,7 @@ class RimWellPlotTools static RiaRftPltCurveDefinition curveDefFromCurve( const RimWellLogCurve* curve ); // others - static bool hasFlowData( const RimWellLogFile* wellLogFile ); + static bool hasFlowData( const RimWellLog* wellLog ); static bool hasAssociatedWellPath( const QString& wellName ); // Both From 23d716754e5d6052fc0ddda350034c46ffe35acb Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 27 May 2024 11:24:00 +0200 Subject: [PATCH 120/332] Add action for downloading and parsing well log from OSDU Wellbore DDMS. --- .../Commands/CMakeLists_files.cmake | 1 + .../OsduImportCommands/RiaOsduConnector.cpp | 116 +++++++++--- .../OsduImportCommands/RiaOsduConnector.h | 22 ++- .../Commands/RicImportWellLogOsduFeature.cpp | 103 ++++++++++ .../Commands/RicImportWellLogOsduFeature.h | 34 ++++ .../FileInterface/CMakeLists_files.cmake | 3 + .../RifByteArrayArrowRandomAccessFile.cpp | 107 +++++++++++ .../RifByteArrayArrowRandomAccessFile.h | 61 ++++++ .../FileInterface/RifOsduWellLogReader.cpp | 105 +++++++++++ .../FileInterface/RifOsduWellLogReader.h | 36 ++++ .../RimContextCommandBuilder.cpp | 9 +- .../RimContextCommandBuilder.h | 2 +- .../WellLog/CMakeLists_files.cmake | 1 + .../WellLog/RimOsduWellLog.cpp | 176 ++++++++++++++++++ .../ProjectDataModel/WellLog/RimOsduWellLog.h | 74 ++++++++ .../WellPath/RimWellPathCollection.cpp | 61 ++++-- .../WellPath/RimWellPathCollection.h | 7 +- .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../ReservoirDataModel/RigOsduWellLogData.cpp | 152 +++++++++++++++ .../ReservoirDataModel/RigOsduWellLogData.h | 68 +++++++ 20 files changed, 1094 insertions(+), 46 deletions(-) create mode 100644 ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp create mode 100644 ApplicationLibCode/Commands/RicImportWellLogOsduFeature.h create mode 100644 ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.cpp create mode 100644 ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h create mode 100644 ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp create mode 100644 ApplicationLibCode/FileInterface/RifOsduWellLogReader.h create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h create mode 100644 ApplicationLibCode/ReservoirDataModel/RigOsduWellLogData.cpp create mode 100644 ApplicationLibCode/ReservoirDataModel/RigOsduWellLogData.h diff --git a/ApplicationLibCode/Commands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/CMakeLists_files.cmake index e6baeea686..e81cff0b60 100644 --- a/ApplicationLibCode/Commands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/CMakeLists_files.cmake @@ -194,6 +194,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicExportSummaryCalculationExpressionsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCalculationExpressionsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportWellLogCsvFileFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicImportWellLogOsduFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewViewForGridEnsembleFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewCustomVfpPlotFeature.cpp diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index 5d30c250f0..51bd9c211d 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -120,7 +120,7 @@ void RiaOsduConnector::requestFieldsByName( const QString& server, const QString params["limit"] = "10000"; params["query"] = "data.FieldName:" + fieldName; - auto reply = makeRequest( params, server, dataPartitionId, token ); + auto reply = makeSearchRequest( params, server, dataPartitionId, token ); connect( reply, &QNetworkReply::finished, [this, reply]() @@ -150,7 +150,7 @@ void RiaOsduConnector::requestWellsByFieldId( const QString& server, const QStri params["limit"] = "10000"; params["query"] = QString( "nested(data.GeoContexts, (FieldID:\"%1\"))" ).arg( fieldId ); - auto reply = makeRequest( params, server, dataPartitionId, token ); + auto reply = makeSearchRequest( params, server, dataPartitionId, token ); connect( reply, &QNetworkReply::finished, [this, reply, fieldId]() @@ -180,7 +180,7 @@ void RiaOsduConnector::requestWellboresByWellId( const QString& server, const QS params["limit"] = "10000"; params["query"] = "data.WellID: \"" + wellId + "\""; - auto reply = makeRequest( params, server, dataPartitionId, token ); + auto reply = makeSearchRequest( params, server, dataPartitionId, token ); connect( reply, &QNetworkReply::finished, [this, reply, wellId]() @@ -221,7 +221,7 @@ void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& ser params["limit"] = "10000"; params["query"] = "data.WellboreID: \"" + wellboreId + "\""; - auto reply = makeRequest( params, server, dataPartitionId, token ); + auto reply = makeSearchRequest( params, server, dataPartitionId, token ); connect( reply, &QNetworkReply::finished, [this, reply, wellboreId]() @@ -239,7 +239,9 @@ void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& ser void RiaOsduConnector::requestFileDownloadByFileId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fileId ) { RiaLogging::info( "Requesting download of file id: " + fileId ); - auto reply = makeDownloadRequest( server, dataPartitionId, fileId, token ); + QString url = constructFileDownloadUrl( server, fileId ); + + auto reply = makeDownloadRequest( url, dataPartitionId, token, CONTENT_TYPE_JSON ); connect( reply, &QNetworkReply::finished, [this, reply, fileId]() @@ -266,7 +268,7 @@ QString RiaOsduConnector::constructSearchUrl( const QString& server ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaOsduConnector::constructDownloadUrl( const QString& server, const QString& fileId ) +QString RiaOsduConnector::constructFileDownloadUrl( const QString& server, const QString& fileId ) { return server + "/api/file/v2/files/" + fileId + "/downloadURL"; } @@ -290,15 +292,23 @@ QString RiaOsduConnector::constructTokenUrl( const QString& authority ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QNetworkReply* RiaOsduConnector::makeRequest( const std::map& parameters, - const QString& server, - const QString& dataPartitionId, - const QString& token ) +QString RiaOsduConnector::constructWellLogDownloadUrl( const QString& server, const QString& wellLogId ) +{ + return server + "/api/os-wellbore-ddms/ddms/v3/welllogs/" + wellLogId + "/data"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QNetworkReply* RiaOsduConnector::makeSearchRequest( const std::map& parameters, + const QString& server, + const QString& dataPartitionId, + const QString& token ) { QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( constructSearchUrl( server ) ) ); - addStandardHeader( m_networkRequest, token, dataPartitionId ); + addStandardHeader( m_networkRequest, token, dataPartitionId, CONTENT_TYPE_JSON ); QJsonObject obj; for ( auto [key, value] : parameters ) @@ -484,9 +494,12 @@ void RiaOsduConnector::saveFile( QNetworkReply* reply, const QString& fileId ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& dataPartitionId ) +void RiaOsduConnector::addStandardHeader( QNetworkRequest& networkRequest, + const QString& token, + const QString& dataPartitionId, + const QString& contentType ) { - networkRequest.setHeader( QNetworkRequest::ContentTypeHeader, "application/json" ); + networkRequest.setHeader( QNetworkRequest::ContentTypeHeader, contentType ); networkRequest.setRawHeader( "Authorization", "Bearer " + token.toUtf8() ); networkRequest.setRawHeader( QByteArray( "Data-Partition-Id" ), dataPartitionId.toUtf8() ); } @@ -495,17 +508,14 @@ void RiaOsduConnector::addStandardHeader( QNetworkRequest& networkRequest, const /// //-------------------------------------------------------------------------------------------------- QNetworkReply* - RiaOsduConnector::makeDownloadRequest( const QString& server, const QString& dataPartitionId, const QString& id, const QString& token ) + RiaOsduConnector::makeDownloadRequest( const QString& url, const QString& dataPartitionId, const QString& token, const QString& contentType ) { - QNetworkRequest m_networkRequest; - - QString url = constructDownloadUrl( server, id ); + QNetworkRequest networkRequest; + networkRequest.setUrl( QUrl( url ) ); - m_networkRequest.setUrl( QUrl( url ) ); + addStandardHeader( networkRequest, token, dataPartitionId, contentType ); - addStandardHeader( m_networkRequest, token, dataPartitionId ); - - auto reply = m_networkAccessManager->get( m_networkRequest ); + auto reply = m_networkAccessManager->get( networkRequest ); return reply; } @@ -635,6 +645,7 @@ std::pair RiaOsduConnector::requestFileContentsById( const QSt this, SLOT( fileDownloadComplete( const QString&, const QString& ) ) ); connect( this, SIGNAL( fileDownloadFinished( const QString&, const QString& ) ), &loop2, SLOT( quit() ) ); + requestFileDownloadByFileId( m_server, m_dataPartitionId, m_token, fileId ); loop2.exec(); @@ -650,3 +661,66 @@ std::pair RiaOsduConnector::requestFileContentsById( const QSt return { fileContent, "" }; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiaOsduConnector::requestWellLogParquetDataById( const QString& wellLogId ) +{ + if ( m_token.isEmpty() ) + { + // TODO: improve this.. + QEventLoop loop; + connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) ); + requestToken(); + loop.exec(); + } + + QEventLoop loop2; + connect( this, + SIGNAL( wellLogDownloadFinished( const QByteArray&, const QString& ) ), + this, + SLOT( wellLogDownloadComplete( const QByteArray&, const QString& ) ) ); + connect( this, SIGNAL( wellLogDownloadFinished( const QByteArray&, const QString& ) ), &loop2, SLOT( quit() ) ); + + QString url = constructWellLogDownloadUrl( m_server, wellLogId ); + RiaLogging::debug( "Well log URL: " + url ); + + requestWellLog( url, m_dataPartitionId, m_token ); + loop2.exec(); + + return { m_wellLogContents, "" }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestWellLog( const QString& url, const QString& dataPartitionId, const QString& token ) +{ + RiaLogging::info( "Requesting download of well log from: " + url ); + + auto reply = makeDownloadRequest( url, dataPartitionId, token, CONTENT_TYPE_PARQUET ); + connect( reply, + &QNetworkReply::finished, + [this, reply, url]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + QByteArray contents = reply->readAll(); + RiaLogging::info( QString( "Download succeeded: %1 bytes." ).arg( contents.length() ) ); + emit wellLogDownloadFinished( contents, "" ); + } + else + { + RiaLogging::error( "Download failed: " + url + " failed." + reply->errorString() ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::wellLogDownloadComplete( const QByteArray& contents, const QString& url ) +{ + m_wellLogContents = contents; +} diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h index 2271e398d2..0cc800a4c9 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -59,9 +59,12 @@ class RiaOsduConnector : public QObject void requestWellboresByWellId( const QString& wellId ); void requestWellboreTrajectoryByWellboreId( const QString& wellboreId ); void requestFileDownloadByFileId( const QString& fileId ); + void requestWellLog( const QString& url, const QString& dataPartitionId, const QString& token ); std::pair requestFileContentsById( const QString& fileId ); + std::pair requestWellLogParquetDataById( const QString& wellLogId ); + QString wellIdForWellboreId( const QString& wellboreId ) const; QString server() const; @@ -81,9 +84,11 @@ public slots: void saveFile( QNetworkReply* reply, const QString& fileId ); void accessGranted(); void fileDownloadComplete( const QString& fileId, const QString& filePath ); + void wellLogDownloadComplete( const QByteArray&, const QString& url ); signals: void fileDownloadFinished( const QString& fileId, const QString& filePath ); + void wellLogDownloadFinished( const QByteArray& contents, const QString& url ); void fieldsFinished(); void wellsFinished(); void wellboresFinished( const QString& wellId ); @@ -91,12 +96,14 @@ public slots: void tokenReady( const QString& token ); private: - void addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& dataPartitionId ); + void addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& dataPartitionId, const QString& contentType ); - QNetworkReply* - makeRequest( const std::map& parameters, const QString& server, const QString& dataPartitionId, const QString& token ); + QNetworkReply* makeSearchRequest( const std::map& parameters, + const QString& server, + const QString& dataPartitionId, + const QString& token ); - QNetworkReply* makeDownloadRequest( const QString& server, const QString& dataPartitionId, const QString& id, const QString& token ); + QNetworkReply* makeDownloadRequest( const QString& url, const QString& dataPartitionId, const QString& token, const QString& contentType ); void requestFieldsByName( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldName ); void requestWellsByFieldId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldId ); @@ -109,9 +116,10 @@ public slots: static QString generateRandomString( int length = 20 ); static QString constructSearchUrl( const QString& server ); - static QString constructDownloadUrl( const QString& server, const QString& fileId ); + static QString constructFileDownloadUrl( const QString& server, const QString& fileId ); static QString constructAuthUrl( const QString& authority ); static QString constructTokenUrl( const QString& authority ); + static QString constructWellLogDownloadUrl( const QString& server, const QString& wellLogId ); QOAuth2AuthorizationCodeFlow* m_osdu; QNetworkAccessManager* m_networkAccessManager; @@ -128,9 +136,13 @@ public slots: std::map> m_wellbores; std::map> m_wellboreTrajectories; QString m_filePath; + QByteArray m_wellLogContents; static inline const QString FIELD_KIND = "osdu:wks:master-data--Field:1.0.0"; static inline const QString WELL_KIND = "osdu:wks:master-data--Well:1.2.0"; static inline const QString WELLBORE_KIND = "osdu:wks:master-data--Wellbore:1.1.0"; static inline const QString WELLBORE_TRAJECTORY_KIND = "osdu:wks:work-product-component--WellboreTrajectory:1.1.0"; + + static inline const QString CONTENT_TYPE_JSON = "application/json"; + static inline const QString CONTENT_TYPE_PARQUET = "application/x-parquet"; }; diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp new file mode 100644 index 0000000000..8f9f283cc5 --- /dev/null +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RicImportWellLogOsduFeature.h" + +#include "RiaGuiApplication.h" +#include "RiaLogging.h" + +#include "RimOilField.h" +#include "RimOsduWellLog.h" +#include "RimOsduWellPath.h" +#include "RimProject.h" +#include "RimWellPathCollection.h" + +#include "RiuMainWindow.h" + +#include "OsduImportCommands/RiaOsduConnector.h" +#include "RiaLogging.h" +#include "RiaPreferences.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicImportWellLogOsduFeature, "RicImportWellLogOsduFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportWellLogOsduFeature::isCommandEnabled() const +{ + return caf::SelectionManager::instance()->selectedItemOfType() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked ) +{ + auto makeOsduConnector = []( auto app ) + { + RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences(); + const QString server = osduPreferences->server(); + const QString dataPartitionId = osduPreferences->dataPartitionId(); + const QString authority = osduPreferences->authority(); + const QString scopes = osduPreferences->scopes(); + const QString clientId = osduPreferences->clientId(); + return std::make_unique( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId ); + }; + + if ( auto wellPath = caf::SelectionManager::instance()->selectedItemOfType() ) + { + RiaGuiApplication* app = RiaGuiApplication::instance(); + + RimOilField* oilField = RimProject::current()->activeOilField(); + if ( oilField == nullptr ) return; + + if ( !oilField->wellPathCollection ) oilField->wellPathCollection = std::make_unique(); + + RimOsduWellLog* osduWellLog = new RimOsduWellLog; + // TODO: get from OSDU... + osduWellLog->setWellLogId( "npequinor-dev:work-product-component--WellLog:aeb5bd8b1de14138afe9f23cacbc7fe7" ); + oilField->wellPathCollection->addWellLog( osduWellLog, wellPath ); + + auto osduConnector = makeOsduConnector( app ); + + auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector.get(), osduWellLog->wellLogId() ); + if ( wellLogData.notNull() ) + { + osduWellLog->setWellLogData( wellLogData.p() ); + } + else + { + RiaLogging::error( "Importing OSDU well log failed: " + errorMessage ); + } + + osduWellLog->updateConnectedEditors(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportWellLogOsduFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setIcon( QIcon( ":/LasFile16x16.png" ) ); + actionToSetup->setText( "Import Well Log From OSDU" ); +} diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.h b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.h new file mode 100644 index 0000000000..d9a9b33ef7 --- /dev/null +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicImportWellLogOsduFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() const override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake index 01a2390406..1ddbe67fa3 100644 --- a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake @@ -98,6 +98,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader.h ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellPathReader.h ${CMAKE_CURRENT_LIST_DIR}/RifAsciiDataParseOptions.h + ${CMAKE_CURRENT_LIST_DIR}/RifByteArrayArrowRandomAccessFile.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -194,6 +195,8 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationExporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellPathReader.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellLogReader.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifByteArrayArrowRandomAccessFile.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.cpp b/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.cpp new file mode 100644 index 0000000000..3f73e4c51b --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.cpp @@ -0,0 +1,107 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RifByteArrayArrowRandomAccessFile.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifByteArrayArrowRandomAccessFile::RifByteArrayArrowRandomAccessFile( const QByteArray& data ) + : m_data( data ) + , m_position( 0 ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +arrow::Result RifByteArrayArrowRandomAccessFile::ReadAt( int64_t position, int64_t nbytes, void* out ) +{ + if ( nbytes > 0 ) + { + memcpy( out, m_data.data() + position, static_cast( nbytes ) ); + m_position += nbytes; + } + return nbytes; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +arrow::Result> RifByteArrayArrowRandomAccessFile::ReadAt( int64_t position, int64_t nbytes ) +{ + return std::make_shared( (const uint8_t*)m_data.data() + position, nbytes ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +arrow::Result RifByteArrayArrowRandomAccessFile::Read( int64_t nbytes, void* out ) +{ + return ReadAt( m_position, nbytes, out ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +arrow::Result> RifByteArrayArrowRandomAccessFile::Read( int64_t nbytes ) +{ + return ReadAt( m_position, nbytes ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +arrow::Result RifByteArrayArrowRandomAccessFile::GetSize() +{ + return m_data.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +arrow::Result RifByteArrayArrowRandomAccessFile::Tell() const +{ + return m_position; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +arrow::Status RifByteArrayArrowRandomAccessFile::Seek( int64_t position ) +{ + m_position = position; + return arrow::Status::OK(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +arrow::Status RifByteArrayArrowRandomAccessFile::Close() +{ + m_closed = true; + return arrow::Status::OK(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifByteArrayArrowRandomAccessFile::closed() const +{ + return m_closed; +} diff --git a/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h b/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h new file mode 100644 index 0000000000..ac9cce504f --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h @@ -0,0 +1,61 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 +#include +#include +#include +#include + +#include + +#include + +//================================================================================================== +/// +//================================================================================================== +class RifByteArrayArrowRandomAccessFile : public arrow::io::RandomAccessFile +{ +public: + RifByteArrayArrowRandomAccessFile( const QByteArray& data ); + + arrow::Result ReadAt( int64_t position, int64_t nbytes, void* out ) override; + + arrow::Result> ReadAt( int64_t position, int64_t nbytes ) override; + + arrow::Result Read( int64_t nbytes, void* out ) override; + + arrow::Result> Read( int64_t nbytes ) override; + + arrow::Result GetSize() override; + + arrow::Result Tell() const override; + + arrow::Status Seek( int64_t position ) override; + + arrow::Status Close() override; + + bool closed() const override; + +private: + const QByteArray& m_data; + bool m_closed; + int64_t m_position; +}; diff --git a/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp new file mode 100644 index 0000000000..f23e730d99 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp @@ -0,0 +1,105 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RifOsduWellLogReader.h" + +#include "RifByteArrayArrowRandomAccessFile.h" + +#include "cafAssert.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair, QString> RifOsduWellLogReader::readWellLogData( const QByteArray& contents ) +{ + // Function to convert an entire column to std::vector + auto convertColumnToVector = []( const std::shared_ptr& column ) -> std::vector + { + auto convertChunkToVector = []( const std::shared_ptr& array ) -> std::vector + { + std::vector result; + + auto double_array = std::static_pointer_cast( array ); + result.resize( double_array->length() ); + for ( int64_t i = 0; i < double_array->length(); ++i ) + { + result[i] = double_array->Value( i ); + } + + return result; + }; + + CAF_ASSERT( column->type()->id() == arrow::Type::DOUBLE ); + + std::vector result; + + // Iterate over each chunk in the column + for ( int i = 0; i < column->num_chunks(); ++i ) + { + std::shared_ptr chunk = column->chunk( i ); + std::vector chunk_vector = convertChunkToVector( chunk ); + result.insert( result.end(), chunk_vector.begin(), chunk_vector.end() ); + } + + return result; + }; + + arrow::MemoryPool* pool = arrow::default_memory_pool(); + + std::shared_ptr input = std::make_shared( contents ); + + // Open Parquet file reader + std::unique_ptr arrow_reader; + if ( !parquet::arrow::OpenFile( input, pool, &arrow_reader ).ok() ) + { + return { nullptr, "Unable to read parquet data." }; + } + + // Read entire file as a single Arrow table + std::shared_ptr table; + if ( !arrow_reader->ReadTable( &table ).ok() ) + { + return { nullptr, "Unable to read parquet table." }; + } + + auto logData = cvf::make_ref(); + for ( std::string columnName : table->ColumnNames() ) + { + std::shared_ptr column = table->GetColumnByName( columnName ); + + if ( column->type()->id() == arrow::Type::DOUBLE ) + { + std::vector columnVector = convertColumnToVector( column ); + logData->setValues( QString::fromStdString( columnName ), columnVector ); + } + } + + logData->finalizeData(); + + return { logData, "" }; +} diff --git a/ApplicationLibCode/FileInterface/RifOsduWellLogReader.h b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.h new file mode 100644 index 0000000000..2246a9cf58 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RigOsduWellLogData.h" + +#include "cvfObject.h" + +#include +#include + +//================================================================================================== +// +// +//================================================================================================== +class RifOsduWellLogReader +{ +public: + static std::pair, QString> readWellLogData( const QByteArray& contents ); +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 9b7ac20320..2953a58d55 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -102,6 +102,7 @@ #include "RimMultiPlot.h" #include "RimMultiPlotCollection.h" #include "RimObservedSummaryData.h" +#include "RimOsduWellPath.h" #include "RimParameterResultCrossPlot.h" #include "RimPerforationCollection.h" #include "RimPerforationInterval.h" @@ -409,7 +410,9 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() appendCreateCompletions( menuBuilder ); menuBuilder.addSeparator(); - appendImportMenu( menuBuilder ); + bool addSeparatorBeforeMenu = false; + bool addOsduImportMenuItem = dynamic_cast( firstUiItem ) != nullptr; + appendImportMenu( menuBuilder, addSeparatorBeforeMenu, addOsduImportMenuItem ); menuBuilder.addSeparator(); appendExportCompletions( menuBuilder ); menuBuilder.addSeparator(); @@ -1498,7 +1501,7 @@ void RimContextCommandBuilder::appendScriptItems( caf::CmdFeatureMenuBuilder& me //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RimContextCommandBuilder::appendImportMenu( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu ) +int RimContextCommandBuilder::appendImportMenu( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu, bool addOsduImportMenuItem ) { QStringList candidates; candidates << "RicWellPathsImportFileFeature"; @@ -1507,6 +1510,8 @@ int RimContextCommandBuilder::appendImportMenu( caf::CmdFeatureMenuBuilder& menu candidates << "RicImportWellLogCsvFileFeature"; candidates << "RicReloadWellPathFormationNamesFeature"; + if ( addOsduImportMenuItem ) candidates << "RicImportWellLogOsduFeature"; + return appendSubMenuWithCommands( menuBuilder, candidates, "Import", QIcon(), addSeparatorBeforeMenu ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.h b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.h index 894400a06f..aef887348a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.h +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.h @@ -51,7 +51,7 @@ class RimContextCommandBuilder static void appendScriptItems( caf::CmdFeatureMenuBuilder& menuBuilder, RimScriptCollection* scriptCollection ); static void appendPlotTemplateItems( caf::CmdFeatureMenuBuilder& menuBuilder, RimPlotTemplateFolderItem* plotTemplateRoot ); - static int appendImportMenu( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false ); + static int appendImportMenu( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false, bool addOsduMenuItem = false ); static int appendCreateCompletions( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false ); static int appendExportCompletions( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false ); static int appendExportWellPaths( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake index 803132e0ec..e0fa17dc2d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake @@ -41,6 +41,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogLasFile.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCsvFile.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLog.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLog.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileUtil.cpp diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp new file mode 100644 index 0000000000..82e911cbb0 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp @@ -0,0 +1,176 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimOsduWellLog.h" + +#include "RiaGuiApplication.h" +#include "RiaLogging.h" + +#include "RiaDateStringParser.h" +#include "RiaFieldHandleTools.h" +#include "RiaQDateTimeTools.h" + +#include "RimFileWellPath.h" +#include "RimTools.h" +#include "RimWellLogChannel.h" +#include "RimWellPathCollection.h" +#include "RimWellPlotTools.h" + +#include "Riu3DMainWindowTools.h" + +#include +#include +#include + +CAF_PDM_SOURCE_INIT( RimOsduWellLog, "OsduWellLog" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimOsduWellLog::RimOsduWellLog() +{ + CAF_PDM_InitObject( "OSDU Well Log", ":/LasFile16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_name, "Name", "" ); + m_name.uiCapability()->setUiReadOnly( true ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_name ); + + m_date.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_wellLogId, "WellLogId", "Well Log Id" ); + m_wellLogId.uiCapability()->setUiReadOnly( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimOsduWellLog::~RimOsduWellLog() +{ + m_wellLogChannelNames.deleteChildren(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimOsduWellLog::wellName() const +{ + return m_wellName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimOsduWellLog::hasFlowData() const +{ + return RimWellPlotTools::hasFlowData( this ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> + RimOsduWellLog::findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString ) +{ + std::vector wellLogFiles = wellPath.descendantsIncludingThisOfType(); + for ( RimOsduWellLog* wellLogFile : wellLogFiles ) + { + RigOsduWellLogData* fileData = wellLogFile->wellLogData(); + std::vector channelValues = fileData->values( channelName ); + if ( !channelValues.empty() ) + { + if ( unitString ) + { + *unitString = fileData->wellLogChannelUnitString( channelName ); + } + std::vector depthValues = fileData->depthValues(); + CVF_ASSERT( depthValues.size() == channelValues.size() ); + std::vector> depthValuePairs; + for ( size_t i = 0; i < depthValues.size(); ++i ) + { + depthValuePairs.push_back( std::make_pair( depthValues[i], channelValues[i] ) ); + } + return depthValuePairs; + } + } + return std::vector>(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimOsduWellLog::isDateValid( const QDateTime dateTime ) +{ + return dateTime.isValid() && dateTime != DEFAULT_DATE_TIME; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimOsduWellLog::userDescriptionField() +{ + return &m_name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimOsduWellLog::name() const +{ + return m_name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigOsduWellLogData* RimOsduWellLog::wellLogData() +{ + return m_wellLogData.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLog::setWellLogData( RigOsduWellLogData* wellLogData ) +{ + m_wellLogData = wellLogData; + + m_wellLogChannelNames.deleteChildren(); + + for ( const QString& wellLogName : wellLogData->wellLogChannelNames() ) + { + RimWellLogChannel* wellLog = new RimWellLogChannel(); + wellLog->setName( wellLogName ); + m_wellLogChannelNames.push_back( wellLog ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLog::setWellLogId( const QString& wellLogId ) +{ + m_wellLogId = wellLogId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimOsduWellLog::wellLogId() const +{ + return m_wellLogId; +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h new file mode 100644 index 0000000000..fcba219e5e --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h @@ -0,0 +1,74 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimWellLog.h" + +#include "RigOsduWellLogData.h" + +#include "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmProxyValueField.h" + +#include + +class RimWellLogChannel; +class RimWellPath; + +class QString; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimOsduWellLog : public RimWellLog +{ + CAF_PDM_HEADER_INIT; + +public: + RimOsduWellLog(); + ~RimOsduWellLog() override; + + QString name() const override; + + QString wellName() const override; + + RigOsduWellLogData* wellLogData() override; + void setWellLogData( RigOsduWellLogData* wellLogData ); + + void setWellLogId( const QString& wellLogId ); + QString wellLogId() const; + + bool hasFlowData() const; + + std::vector> + findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString = nullptr ) override; + +private: + caf::PdmFieldHandle* userDescriptionField() override; + + static bool isDateValid( const QDateTime dateTime ); + +private: + cvf::ref m_wellLogData; + caf::PdmField m_wellName; + caf::PdmField m_name; + caf::PdmField m_wellLogId; +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index fea4d8a17a..698e3d9783 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -28,12 +28,14 @@ #include "RiaTextStringTools.h" #include "RiaWellNameComparer.h" +#include "RifOsduWellLogReader.h" #include "RifOsduWellPathReader.h" #include "RifWellPathFormationsImporter.h" #include "RifWellPathImporter.h" #include "RigEclipseCaseData.h" #include "RigMainGrid.h" +#include "RigOsduWellLogData.h" #include "RigWellPath.h" #include "RimEclipseCase.h" @@ -42,6 +44,7 @@ #include "RimFileWellPath.h" #include "RimModeledWellPath.h" #include "RimOilField.h" +#include "RimOsduWellLog.h" #include "RimOsduWellPath.h" #include "RimPerforationCollection.h" #include "RimProject.h" @@ -147,6 +150,17 @@ void RimWellPathCollection::loadDataAndUpdate() { caf::ProgressInfo progress( m_wellPaths.size(), "Reading well paths from file" ); + auto makeOsduConnector = []( auto app ) + { + RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences(); + const QString server = osduPreferences->server(); + const QString dataPartitionId = osduPreferences->dataPartitionId(); + const QString authority = osduPreferences->authority(); + const QString scopes = osduPreferences->scopes(); + const QString clientId = osduPreferences->clientId(); + return std::make_unique( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId ); + }; + readWellPathFormationFiles(); for ( RimWellPath* wellPath : allWellPaths() ) @@ -173,18 +187,8 @@ void RimWellPathCollection::loadDataAndUpdate() } else if ( oWPath ) { - RiaApplication* app = RiaApplication::instance(); - - RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences(); - - const QString server = osduPreferences->server(); - const QString dataParitionId = osduPreferences->dataPartitionId(); - const QString authority = osduPreferences->authority(); - const QString scopes = osduPreferences->scopes(); - const QString clientId = osduPreferences->clientId(); - - auto osduConnector = - std::make_unique( RiuMainWindow::instance(), server, dataParitionId, authority, scopes, clientId ); + RiaApplication* app = RiaApplication::instance(); + auto osduConnector = makeOsduConnector( app ); auto [wellPathGeometry, errorMessage] = loadWellPathGeometryFromOsdu( osduConnector.get(), oWPath->fileId() ); if ( wellPathGeometry.notNull() ) @@ -199,9 +203,9 @@ void RimWellPathCollection::loadDataAndUpdate() if ( wellPath ) { - for ( RimWellLogFile* const wellLogFile : wellPath->wellLogFiles() ) + for ( RimWellLog* wellLog : wellPath->wellLogs() ) { - if ( wellLogFile ) + if ( RimWellLogFile* wellLogFile = dynamic_cast( wellLog ) ) { QString errorMessage; if ( !wellLogFile->readFile( &errorMessage ) ) @@ -209,6 +213,16 @@ void RimWellPathCollection::loadDataAndUpdate() RiaLogging::warning( errorMessage ); } } + else if ( RimOsduWellLog* osduWellLog = dynamic_cast( wellLog ) ) + { + RiaApplication* app = RiaApplication::instance(); + auto osduConnector = makeOsduConnector( app ); + auto [wellLogData, errorMessage] = loadWellLogFromOsdu( osduConnector.get(), osduWellLog->wellLogId() ); + if ( wellLogData.notNull() ) + { + osduWellLog->setWellLogData( wellLogData.p() ); + } + } } RimStimPlanModelCollection* stimPlanModelCollection = wellPath->stimPlanModelCollection(); @@ -419,9 +433,9 @@ std::vector RimWellPathCollection::addWellLogs( const QStrin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPathCollection::addWellLog( RimWellLogFile* wellLogFile, RimWellPath* wellPath ) +void RimWellPathCollection::addWellLog( RimWellLog* wellLog, RimWellPath* wellPath ) { - wellPath->addWellLog( wellLogFile ); + wellPath->addWellLog( wellLog ); sortWellsByName(); updateAllRequiredEditors(); } @@ -1060,3 +1074,18 @@ std::pair, QString> RimWellPathCollection::loadWellPathGeo return RifOsduWellPathReader::parseCsv( fileContents ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair, QString> RimWellPathCollection::loadWellLogFromOsdu( RiaOsduConnector* osduConnector, + const QString& wellLogId ) +{ + auto [fileContents, errorMessage] = osduConnector->requestWellLogParquetDataById( wellLogId ); + if ( !errorMessage.isEmpty() ) + { + return { nullptr, errorMessage }; + } + + return RifOsduWellLogReader::readWellLogData( fileContents ); +} diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h index 84e7d63035..d4ca69fe4b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h @@ -22,6 +22,7 @@ #include "RiaDefines.h" +#include "RigOsduWellLogData.h" #include "cafAppEnum.h" #include "cafPdmChildArrayField.h" #include "cafPdmField.h" @@ -41,6 +42,7 @@ class RiaOsduConnector; class RifWellPathImporter; class RigWellPath; +class RigOsduWellLogData; class RimFileWellPath; class RimEclipseView; class RimProject; @@ -49,6 +51,7 @@ class RimWellLogFile; class RimWellPath; class RifWellPathFormationsImporter; class RimWellMeasurementCollection; +class RimWellLog; class cafTreeNode; class QString; @@ -118,7 +121,7 @@ class RimWellPathCollection : public caf::PdmObject std::vector addWellLogs( const QStringList& filePaths, QStringList* errorMessages ); void addWellPathFormations( const QStringList& filePaths ); - void addWellLog( RimWellLogFile* wellLogFile, RimWellPath* wellPath ); + void addWellLog( RimWellLog* wellLog, RimWellPath* wellPath ); void scheduleRedrawAffectedViews(); @@ -134,6 +137,8 @@ class RimWellPathCollection : public caf::PdmObject static std::pair, QString> loadWellPathGeometryFromOsdu( RiaOsduConnector* osduConnector, const QString& fileId ); + static std::pair, QString> loadWellLogFromOsdu( RiaOsduConnector* osduConnector, const QString& wellLogId ); + protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake index 924cadcb6b..f42b255323 100644 --- a/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake @@ -99,6 +99,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RigWellResultFrame.h ${CMAKE_CURRENT_LIST_DIR}/RigReservoirBuilder.h ${CMAKE_CURRENT_LIST_DIR}/RigVfpTables.h + ${CMAKE_CURRENT_LIST_DIR}/RigOsduWellLogData.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -196,6 +197,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RigDeclineCurveCalculator.cpp ${CMAKE_CURRENT_LIST_DIR}/RigReservoirBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/RigVfpTables.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigOsduWellLogData.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ReservoirDataModel/RigOsduWellLogData.cpp b/ApplicationLibCode/ReservoirDataModel/RigOsduWellLogData.cpp new file mode 100644 index 0000000000..4a576fbbf7 --- /dev/null +++ b/ApplicationLibCode/ReservoirDataModel/RigOsduWellLogData.cpp @@ -0,0 +1,152 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RigOsduWellLogData.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigOsduWellLogData::RigOsduWellLogData() + : RigWellLogData() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigOsduWellLogData::~RigOsduWellLogData() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RigOsduWellLogData::wellLogChannelNames() const +{ + QStringList channelNames; + for ( const auto& channelPair : m_values ) + { + channelNames << channelPair.first; + } + + return channelNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigOsduWellLogData::depthValues() const +{ + return values( m_depthLogName ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigOsduWellLogData::tvdMslValues() const +{ + return values( m_tvdMslLogName ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigOsduWellLogData::tvdRkbValues() const +{ + // Not supported + return std::vector(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigOsduWellLogData::setValues( const QString& name, const std::vector& values ) +{ + m_values[name] = values; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigOsduWellLogData::values( const QString& name ) const +{ + if ( auto it = m_values.find( name ); it != m_values.end() ) return it->second; + return std::vector(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigOsduWellLogData::hasTvdMslChannel() const +{ + return !m_tvdMslLogName.isEmpty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigOsduWellLogData::hasTvdRkbChannel() const +{ + return !m_tvdRkbLogName.isEmpty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigOsduWellLogData::depthUnitString() const +{ + return wellLogChannelUnitString( m_tvdMslLogName ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigOsduWellLogData::wellLogChannelUnitString( const QString& wellLogChannelName ) const +{ + auto unit = m_units.find( wellLogChannelName ); + if ( unit != m_units.end() ) + return unit->second; + else + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigOsduWellLogData::getMissingValue() const +{ + return std::numeric_limits::infinity(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigOsduWellLogData::finalizeData() +{ + for ( auto [columnName, values] : m_values ) + { + if ( columnName.toUpper() == "TVDMSL" || columnName.toUpper().contains( "TVD" ) ) + { + m_tvdMslLogName = columnName; + } + else if ( columnName.toUpper() == "DEPTH" ) + { + m_depthLogName = "DEPTH"; + } + } +} diff --git a/ApplicationLibCode/ReservoirDataModel/RigOsduWellLogData.h b/ApplicationLibCode/ReservoirDataModel/RigOsduWellLogData.h new file mode 100644 index 0000000000..150b387dc4 --- /dev/null +++ b/ApplicationLibCode/ReservoirDataModel/RigOsduWellLogData.h @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RigWellLogData.h" + +#include "RiaDefines.h" + +#include + +#include +#include + +class RimWellLogCurve; + +//================================================================================================== +/// +//================================================================================================== +class RigOsduWellLogData : public RigWellLogData +{ +public: + RigOsduWellLogData(); + ~RigOsduWellLogData() override; + + QStringList wellLogChannelNames() const override; + + std::vector depthValues() const override; + std::vector tvdMslValues() const override; + std::vector tvdRkbValues() const override; + + void setValues( const QString& name, const std::vector& values ); + std::vector values( const QString& name ) const override; + + QString wellLogChannelUnitString( const QString& wellLogChannelName ) const override; + + bool hasTvdMslChannel() const override; + bool hasTvdRkbChannel() const override; + + double getMissingValue() const override; + + void finalizeData(); + +private: + QString depthUnitString() const override; + + QString m_depthLogName; + QString m_tvdMslLogName; + QString m_tvdRkbLogName; + + std::map> m_values; + std::map m_units; +}; From 10ad053c30da73c00a288bd84753aaff61d369dd Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 3 Jun 2024 19:42:08 +0200 Subject: [PATCH 121/332] Osdu Well Log: make it possible to add Osdu well logs to plot. --- .../Commands/RicImportWellLogOsduFeature.cpp | 34 ++++++---- .../Commands/RicWellLogTools.cpp | 2 +- .../RicAddWellLogToPlotFeature.cpp | 24 +++---- .../RicNewWellLogFileCurveFeature.cpp | 2 +- .../Flow/RimWellPlotTools.cpp | 11 ++-- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 2 +- .../WellLog/RimEnsembleWellLogCurveSet.cpp | 5 +- .../WellLog/RimOsduWellLog.cpp | 9 ++- .../ProjectDataModel/WellLog/RimOsduWellLog.h | 1 + .../RimWellLogCurveCommonDataSource.cpp | 3 +- .../WellLog/RimWellLogLasFileCurve.cpp | 66 ++++++++++--------- .../WellLog/RimWellLogLasFileCurve.h | 13 ++-- .../WellPath/RimOsduWellPath.cpp | 6 ++ .../ProjectDataModel/WellPath/RimWellPath.cpp | 4 +- 14 files changed, 104 insertions(+), 78 deletions(-) diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp index 8f9f283cc5..827c7a47ee 100644 --- a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp @@ -72,24 +72,30 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked ) if ( !oilField->wellPathCollection ) oilField->wellPathCollection = std::make_unique(); - RimOsduWellLog* osduWellLog = new RimOsduWellLog; // TODO: get from OSDU... - osduWellLog->setWellLogId( "npequinor-dev:work-product-component--WellLog:aeb5bd8b1de14138afe9f23cacbc7fe7" ); - oilField->wellPathCollection->addWellLog( osduWellLog, wellPath ); + std::vector wellLogIds = { "npequinor-dev:work-product-component--WellLog:aeb5bd8b1de14138afe9f23cacbc7fe7" }; - auto osduConnector = makeOsduConnector( app ); - - auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector.get(), osduWellLog->wellLogId() ); - if ( wellLogData.notNull() ) - { - osduWellLog->setWellLogData( wellLogData.p() ); - } - else + for ( QString wellLogId : wellLogIds ) { - RiaLogging::error( "Importing OSDU well log failed: " + errorMessage ); + RimOsduWellLog* osduWellLog = new RimOsduWellLog; + osduWellLog->setName( wellLogId ); + osduWellLog->setWellLogId( wellLogId ); + oilField->wellPathCollection->addWellLog( osduWellLog, wellPath ); + + auto osduConnector = makeOsduConnector( app ); + + auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector.get(), osduWellLog->wellLogId() ); + if ( wellLogData.notNull() ) + { + osduWellLog->setWellLogData( wellLogData.p() ); + } + else + { + RiaLogging::error( "Importing OSDU well log failed: " + errorMessage ); + } + + osduWellLog->updateConnectedEditors(); } - - osduWellLog->updateConnectedEditors(); } } diff --git a/ApplicationLibCode/Commands/RicWellLogTools.cpp b/ApplicationLibCode/Commands/RicWellLogTools.cpp index 055d3b54d8..28585e0611 100644 --- a/ApplicationLibCode/Commands/RicWellLogTools.cpp +++ b/ApplicationLibCode/Commands/RicWellLogTools.cpp @@ -147,7 +147,7 @@ void RicWellLogTools::addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack, if ( wellPath ) { - if ( wellLogFile ) plotCurve->setWellLogFile( wellLogFile ); + if ( wellLogFile ) plotCurve->setWellLog( wellLogFile ); plotCurve->setWellPath( wellPath ); plotCurve->setWellLogChannelName( wellLogChannel->name() ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index 58715e86de..67efb6ec3c 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -69,13 +69,12 @@ void RicAddWellLogToPlotFeature::onActionTriggered( bool isChecked ) plot->loadDataAndUpdate(); - for ( size_t wlIdx = 0; wlIdx < selection.size(); wlIdx++ ) + bool isFirst = true; + for ( RimWellLogChannel* wellLogChannel : selection ) { - RimWellLogChannel* wellLog = selection[wlIdx]; - - auto wellPath = wellLog->firstAncestorOrThisOfType(); - auto wellLogFile = wellLog->firstAncestorOrThisOfType(); - if ( wellLogFile ) + auto wellPath = wellLogChannel->firstAncestorOrThisOfType(); + auto wellLog = wellLogChannel->firstAncestorOrThisOfType(); + if ( wellLog ) { RimWellLogLasFileCurve* curve = new RimWellLogLasFileCurve; cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plotTrack->curveCount() ); @@ -83,18 +82,19 @@ void RicAddWellLogToPlotFeature::onActionTriggered( bool isChecked ) plotTrack->addCurve( curve ); - RigWellLogLasFile* wellLogDataFile = wellLogFile->wellLogData(); - CVF_ASSERT( wellLogDataFile ); + RigWellLogData* wellLogData = wellLog->wellLogData(); + CVF_ASSERT( wellLogData ); - if ( wlIdx == 0 ) + if ( isFirst ) { // Initialize plot with depth unit from the first log file - plot->setDepthUnit( wellLogDataFile->depthUnit() ); + plot->setDepthUnit( wellLogData->depthUnit() ); + isFirst = false; } curve->setWellPath( wellPath ); - curve->setWellLogChannelName( wellLog->name() ); - curve->setWellLogFile( wellLogFile ); + curve->setWellLogChannelName( wellLogChannel->name() ); + curve->setWellLog( wellLog ); curve->loadDataAndUpdate( true ); } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp index f702eb9fe5..cb542a5811 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp @@ -72,7 +72,7 @@ void RicNewWellLogFileCurveFeature::onActionTriggered( bool isChecked ) if ( wellPath->wellLogFiles().size() == 1 ) { - plotCurve->setWellLogFile( wellPath->wellLogFiles().front() ); + plotCurve->setWellLog( wellPath->wellLogFiles().front() ); } plotCurve->updateConnectedEditors(); } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index f8aaf2e540..992c75894c 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -676,17 +676,16 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve( const RimWellLogCu } else if ( wellLogFileCurve != nullptr ) { - RimWellLogFile* const wellLogFile = wellLogFileCurve->wellLogFile(); + RimWellLog* const wellLog = wellLogFileCurve->wellLog(); - if ( wellLogFile != nullptr ) + if ( wellLog != nullptr ) { - const QDateTime date = wellLogFile->date(); - + const QDateTime date = wellLog->date(); if ( date.isValid() ) { - if ( auto wellLogLasFile = dynamic_cast( wellLogFile ) ) + if ( auto wellLogLasFile = dynamic_cast( wellLog ) ) { - return RiaRftPltCurveDefinition( RifDataSourceForRftPlt( wellLogLasFile ), wellLogFile->wellName(), date ); + return RiaRftPltCurveDefinition( RifDataSourceForRftPlt( wellLogLasFile ), wellLog->wellName(), date ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 7631f6c744..7dd9d4d7b1 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -692,7 +692,7 @@ void RimWellRftPlot::updateCurvesInPlot( const std::setaddCurve( curve ); curve->setWellPath( wellPath ); - curve->setWellLogFile( wellLogFile ); + curve->setWellLog( wellLogFile ); curve->setWellLogChannelName( pressureChannel->name() ); curve->setZOrder( 2 ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp index 75bbffd6b2..ece94e43ab 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp @@ -645,7 +645,8 @@ RimSummaryCase* RimEnsembleWellLogCurveSet::findMatchingSummaryCase( RimWellLogL std::vector sumCases = summaryCaseCollection->allSummaryCases(); for ( auto sumCase : sumCases ) { - if ( isSameRealization( sumCase, wellLogCurve->wellLogFile() ) ) + RimWellLogFile* wellLogFile = dynamic_cast( wellLogCurve->wellLog() ); + if ( wellLogFile && isSameRealization( sumCase, wellLogFile ) ) { return sumCase; } @@ -794,7 +795,7 @@ void RimEnsembleWellLogCurveSet::updateEnsembleCurves( const std::vectorsetWellPath( wellPath ); curve->setWellLogChannelName( wellLogChannelName ); - curve->setWellLogFile( wellLogFile ); + curve->setWellLog( wellLogFile ); curve->setSymbol( m_curveAppearance->symbol() ); curve->setSymbolSize( m_curveAppearance->symbolSize() ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp index 82e911cbb0..6aa942cfae 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp @@ -48,7 +48,6 @@ RimOsduWellLog::RimOsduWellLog() CAF_PDM_InitFieldNoDefault( &m_name, "Name", "" ); m_name.uiCapability()->setUiReadOnly( true ); - RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_name ); m_date.uiCapability()->setUiReadOnly( true ); @@ -126,6 +125,14 @@ caf::PdmFieldHandle* RimOsduWellLog::userDescriptionField() return &m_name; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLog::setName( const QString& name ) +{ + m_name = name; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h index fcba219e5e..1051acf40a 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h @@ -46,6 +46,7 @@ class RimOsduWellLog : public RimWellLog RimOsduWellLog(); ~RimOsduWellLog() override; + void setName( const QString& name ); QString name() const override; QString wellName() const override; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp index 8cfc90978c..84d557d059 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp @@ -34,6 +34,7 @@ #include "RimTools.h" #include "RimWellFlowRateCurve.h" #include "RimWellLogExtractionCurve.h" +#include "RimWellLogFile.h" #include "RimWellLogLasFileCurve.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" @@ -528,7 +529,7 @@ void RimWellLogCurveCommonDataSource::applyDataSourceChanges( const std::vector< if ( !fileCurve->wellLogChannelUiName().isEmpty() ) { RimWellLogFile* logFile = wellPathToApply()->firstWellLogFileMatchingChannelName( fileCurve->wellLogChannelUiName() ); - fileCurve->setWellLogFile( logFile ); + fileCurve->setWellLog( logFile ); auto parentPlot = fileCurve->firstAncestorOrThisOfTypeAsserted(); plots.insert( parentPlot ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp index 4723c8d768..6e1b0bc621 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp @@ -60,7 +60,7 @@ RimWellLogLasFileCurve::RimWellLogLasFileCurve() CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "CurveWellLogChannel", "Well Log Channel" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogFile, "WellLogFile", "Well Log File" ); + CAF_PDM_InitFieldNoDefault( &m_wellLog, "WellLogFile", "Well Log File" ); m_wellPath = nullptr; } @@ -83,9 +83,9 @@ void RimWellLogLasFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) { auto wellLogPlot = firstAncestorOrThisOfTypeAsserted(); - if ( m_wellPath && m_wellLogFile ) + if ( m_wellPath && m_wellLog ) { - RigWellLogData* wellLogFile = m_wellLogFile->wellLogData(); + RigWellLogData* wellLogFile = m_wellLog->wellLogData(); if ( wellLogFile ) { std::vector values = wellLogFile->values( m_wellLogChannelName ); @@ -287,9 +287,9 @@ void RimWellLogLasFileCurve::setWellLogChannelName( const QString& name ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogLasFileCurve::setWellLogFile( RimWellLogFile* wellLogFile ) +void RimWellLogLasFileCurve::setWellLog( RimWellLog* wellLogFile ) { - m_wellLogFile = wellLogFile; + m_wellLog = wellLogFile; } //-------------------------------------------------------------------------------------------------- @@ -315,7 +315,7 @@ void RimWellLogLasFileCurve::fieldChangedByUi( const caf::PdmFieldHandle* change { loadDataAndUpdate( true ); } - else if ( changedField == &m_wellLogFile ) + else if ( changedField == &m_wellLog ) { loadDataAndUpdate( true ); } @@ -331,7 +331,7 @@ void RimWellLogLasFileCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiO caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Curve Data" ); curveDataGroup->add( &m_wellPath ); - curveDataGroup->add( &m_wellLogFile ); + curveDataGroup->add( &m_wellLog ); curveDataGroup->add( &m_wellLogChannelName ); RimStackablePlotCurve::defaultUiOrdering( uiOrdering ); @@ -362,8 +362,8 @@ QList RimWellLogLasFileCurve::calculateValueOptions( con { for ( auto wellPath : wellPathColl->allWellPaths() ) { - // Only include well paths coming from a well log file - if ( !wellPath->wellLogFiles().empty() ) + // Only include well paths coming with a well log + if ( !wellPath->wellLogs().empty() ) { options.push_back( caf::PdmOptionItemInfo( wellPath->name(), wellPath ) ); } @@ -378,17 +378,12 @@ QList RimWellLogLasFileCurve::calculateValueOptions( con if ( fieldNeedingOptions == &m_wellLogChannelName ) { - if ( m_wellPath() ) + if ( m_wellPath() && m_wellLog() ) { - if ( m_wellLogFile ) + for ( RimWellLogChannel* wellLogChannel : m_wellLog->wellLogChannels() ) { - std::vector fileLogs = m_wellLogFile->wellLogChannels(); - - for ( size_t i = 0; i < fileLogs.size(); i++ ) - { - QString wellLogChannelName = fileLogs[i]->name(); - options.push_back( caf::PdmOptionItemInfo( wellLogChannelName, wellLogChannelName ) ); - } + QString wellLogChannelName = wellLogChannel->name(); + options.push_back( caf::PdmOptionItemInfo( wellLogChannelName, wellLogChannelName ) ); } } @@ -398,14 +393,21 @@ QList RimWellLogLasFileCurve::calculateValueOptions( con } } - if ( fieldNeedingOptions == &m_wellLogFile ) + if ( fieldNeedingOptions == &m_wellLog ) { - if ( m_wellPath() && !m_wellPath->wellLogFiles().empty() ) + if ( m_wellPath() && !m_wellPath->wellLogs().empty() ) { - for ( RimWellLogFile* const wellLogFile : m_wellPath->wellLogFiles() ) + for ( RimWellLog* const wellLog : m_wellPath->wellLogs() ) { - QFileInfo fileInfo( wellLogFile->fileName() ); - options.push_back( caf::PdmOptionItemInfo( fileInfo.baseName(), wellLogFile ) ); + if ( RimWellLogFile* wellLogFile = dynamic_cast( wellLog ) ) + { + QFileInfo fileInfo( wellLogFile->fileName() ); + options.push_back( caf::PdmOptionItemInfo( fileInfo.baseName(), wellLog ) ); + } + else + { + options.push_back( caf::PdmOptionItemInfo( wellLog->name(), wellLog ) ); + } } } } @@ -424,7 +426,7 @@ void RimWellLogLasFileCurve::initAfterRead() if ( m_wellPath->wellLogFiles().size() == 1 ) { - m_wellLogFile = dynamic_cast( m_wellPath->wellLogFiles().front() ); + m_wellLog = dynamic_cast( m_wellPath->wellLogFiles().front() ); } } @@ -457,14 +459,14 @@ QString RimWellLogLasFileCurve::createCurveAutoName() channelNameAvailable = true; } - RigWellLogData* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogData() : nullptr; + RigWellLogData* wellLogData = m_wellLog ? m_wellLog->wellLogData() : nullptr; - if ( wellLogFile ) + if ( wellLogData ) { if ( channelNameAvailable ) { auto wellLogPlot = firstAncestorOrThisOfTypeAsserted(); - QString unitName = wellLogFile->convertedWellLogChannelUnitString( m_wellLogChannelName, wellLogPlot->depthUnit() ); + QString unitName = wellLogData->convertedWellLogChannelUnitString( m_wellLogChannelName, wellLogPlot->depthUnit() ); if ( !unitName.isEmpty() ) { @@ -472,7 +474,7 @@ QString RimWellLogLasFileCurve::createCurveAutoName() } } - QString date = m_wellLogFile->date().toString( RiaQDateTimeTools::dateFormatString() ); + QString date = m_wellLog->date().toString( RiaQDateTimeTools::dateFormatString() ); if ( !date.isEmpty() ) { name.push_back( date ); @@ -498,9 +500,9 @@ QString RimWellLogLasFileCurve::wellLogChannelUiName() const //-------------------------------------------------------------------------------------------------- QString RimWellLogLasFileCurve::wellLogChannelUnits() const { - if ( m_wellLogFile && m_wellLogFile->wellLogData() ) + if ( m_wellLog && m_wellLog->wellLogData() ) { - return m_wellLogFile->wellLogData()->wellLogChannelUnitString( m_wellLogChannelName ); + return m_wellLog->wellLogData()->wellLogChannelUnitString( m_wellLogChannelName ); } return RiaWellLogUnitTools::noUnitString(); } @@ -508,9 +510,9 @@ QString RimWellLogLasFileCurve::wellLogChannelUnits() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellLogFile* RimWellLogLasFileCurve::wellLogFile() const +RimWellLog* RimWellLogLasFileCurve::wellLog() const { - return m_wellLogFile(); + return m_wellLog(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.h index a1ab607ef2..aefa289f2b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.h @@ -30,6 +30,7 @@ class RimWellPath; class RimWellLogChannel; class RimWellLogFile; class RigWellLogIndexDepthOffset; +class RimWellLog; //================================================================================================== /// @@ -46,7 +47,7 @@ class RimWellLogLasFileCurve : public RimWellLogCurve void setWellPath( RimWellPath* wellPath ); RimWellPath* wellPath() const; void setWellLogChannelName( const QString& name ); - void setWellLogFile( RimWellLogFile* wellLogFile ); + void setWellLog( RimWellLog* wellLog ); void setIndexDepthOffsets( std::shared_ptr depthOffsets ); // Overrides from RimWellLogPlotCurve @@ -54,7 +55,7 @@ class RimWellLogLasFileCurve : public RimWellLogCurve QString wellLogChannelUiName() const override; QString wellLogChannelUnits() const override; - RimWellLogFile* wellLogFile() const; + RimWellLog* wellLog() const; protected: // Overrides from RimWellLogPlotCurve @@ -75,10 +76,10 @@ class RimWellLogLasFileCurve : public RimWellLogCurve const std::vector& kIndexValues ) const; protected: - caf::PdmPtrField m_wellPath; - caf::PdmPtrField m_wellLogFile; - caf::PdmField m_wellLogChannelName; - caf::PdmField m_wellLogChannnelUnit; + caf::PdmPtrField m_wellPath; + caf::PdmPtrField m_wellLog; + caf::PdmField m_wellLogChannelName; + caf::PdmField m_wellLogChannnelUnit; std::shared_ptr m_indexDepthOffsets; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp index 7529828939..1f5e6bf415 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp @@ -22,6 +22,12 @@ RimOsduWellPath::RimOsduWellPath() CAF_PDM_InitFieldNoDefault( &m_fileId, "FileId", "File Id" ); m_fileId.uiCapability()->setUiReadOnly( true ); + + // Required, as these settings are set in RimWellPath() + m_name.uiCapability()->setUiReadOnly( false ); + m_name.uiCapability()->setUiHidden( false ); + m_name.xmlCapability()->setIOReadable( true ); + m_name.xmlCapability()->setIOWritable( true ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp index 7209487437..4cb1edb3c4 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp @@ -25,6 +25,7 @@ #include "RiaSimWellBranchTools.h" #include "RiaWellNameComparer.h" +#include "RicImportWellLogOsduFeature.h" #include "RicfCommandObject.h" #include "RifWellPathFormationsImporter.h" @@ -38,6 +39,7 @@ #include "RimFishbonesCollection.h" #include "RimMainPlotCollection.h" #include "RimMswCompletionParameters.h" +#include "RimOsduWellLog.h" #include "RimPerforationCollection.h" #include "RimProject.h" #include "RimStimPlanModelCollection.h" @@ -934,7 +936,7 @@ void RimWellPath::addWellLog( RimWellLog* wellLog ) } } } - else + else if ( RimOsduWellLog* osduWellLog = dynamic_cast( wellLog ) ) { m_wellLogs.push_back( osduWellLog ); } From 35a2623a36d45b86b8589a6e99f7d326cc6b2699 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 3 Jun 2024 19:55:30 +0200 Subject: [PATCH 122/332] Arrow: remove unused header file. --- .../FileInterface/RifByteArrayArrowRandomAccessFile.h | 1 - ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp | 1 - ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp | 1 - 3 files changed, 3 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h b/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h index ac9cce504f..9f65a27f7e 100644 --- a/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h +++ b/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include diff --git a/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp index f23e730d99..70a6e033b3 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp +++ b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp b/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp index bcc0138287..f1d97f7c8b 100644 --- a/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include From dd6c41b84ed1b4c8bdc93d93bfd4975ba6c61d1a Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 7 Jun 2024 12:41:54 +0200 Subject: [PATCH 123/332] Osdu: Allow any version of well kinds. --- .../Commands/OsduImportCommands/RiaOsduConnector.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h index 0cc800a4c9..31be1bdf46 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -139,9 +139,9 @@ public slots: QByteArray m_wellLogContents; static inline const QString FIELD_KIND = "osdu:wks:master-data--Field:1.0.0"; - static inline const QString WELL_KIND = "osdu:wks:master-data--Well:1.2.0"; - static inline const QString WELLBORE_KIND = "osdu:wks:master-data--Wellbore:1.1.0"; - static inline const QString WELLBORE_TRAJECTORY_KIND = "osdu:wks:work-product-component--WellboreTrajectory:1.1.0"; + static inline const QString WELL_KIND = "osdu:wks:master-data--Well:1.*.*"; + static inline const QString WELLBORE_KIND = "osdu:wks:master-data--Wellbore:1.*.*"; + static inline const QString WELLBORE_TRAJECTORY_KIND = "osdu:wks:work-product-component--WellboreTrajectory:1.*.*"; static inline const QString CONTENT_TYPE_JSON = "application/json"; static inline const QString CONTENT_TYPE_PARQUET = "application/x-parquet"; From 8854abe48236bf721947bbda89776a023749288a Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 7 Jun 2024 15:57:51 +0200 Subject: [PATCH 124/332] Osdu: get well paths from ddms instead of Osdu Storage api. --- .../Application/RiaApplication.cpp | 20 ++ .../Application/RiaApplication.h | 4 + .../OsduImportCommands/RiaOsduConnector.cpp | 217 ++++++++---------- .../OsduImportCommands/RiaOsduConnector.h | 51 ++-- .../RicWellPathsImportOsduFeature.cpp | 16 +- .../RiuWellImportWizard.cpp | 22 +- .../OsduImportCommands/RiuWellImportWizard.h | 2 - .../Commands/RicImportWellLogOsduFeature.cpp | 25 +- .../FileInterface/RifOsduWellPathReader.cpp | 110 ++++++++- .../FileInterface/RifOsduWellPathReader.h | 1 + .../WellPath/RimWellPathCollection.cpp | 30 +-- 11 files changed, 286 insertions(+), 212 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 3cf5c02397..aeae3a2659 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaApplication.h" +#include "OsduImportCommands/RiaOsduConnector.h" #include "RiaArgumentParser.h" #include "RiaBaseDefs.h" #include "RiaFilePathTools.h" @@ -97,6 +98,7 @@ #include "Riu3DMainWindowTools.h" #include "RiuGuiTheme.h" +#include "RiuMainWindow.h" #include "RiuViewer.h" #include "RiuViewerCommands.h" @@ -170,6 +172,7 @@ RiaApplication::RiaApplication() setLastUsedDialogDirectory( "MULTICASEIMPORT", "/" ); m_commandRouter = std::make_unique(); + m_osduConnector = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -1690,3 +1693,20 @@ bool RiaApplication::generateCode( const QString& fileName, gsl::not_nullosduPreferences(); + const QString server = osduPreferences->server(); + const QString dataPartitionId = osduPreferences->dataPartitionId(); + const QString authority = osduPreferences->authority(); + const QString scopes = osduPreferences->scopes(); + const QString clientId = osduPreferences->clientId(); + m_osduConnector = new RiaOsduConnector( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId ); + return m_osduConnector; +} diff --git a/ApplicationLibCode/Application/RiaApplication.h b/ApplicationLibCode/Application/RiaApplication.h index 5496295dbf..b0ea7facd0 100644 --- a/ApplicationLibCode/Application/RiaApplication.h +++ b/ApplicationLibCode/Application/RiaApplication.h @@ -68,6 +68,7 @@ class RiuMainWindowBase; class RiuPlotMainWindow; class RiuRecentFileActionProvider; class RiaArgumentParser; +class RiaOsduConnector; namespace caf { @@ -200,6 +201,8 @@ class RiaApplication virtual void addToRecentFiles( const QString& fileName ) {} virtual void showFormattedTextInMessageBoxOrConsole( const QString& errMsg ) = 0; + RiaOsduConnector* makeOsduConnector(); + protected: // Protected implementation specific overrides virtual void invokeProcessEvents( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents ) = 0; @@ -255,4 +258,5 @@ class RiaApplication private: static RiaApplication* s_riaApplication; + RiaOsduConnector* m_osduConnector; }; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index 51bd9c211d..faade6fec1 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -195,29 +195,36 @@ void RiaOsduConnector::requestWellboresByWellId( const QString& server, const QS //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& wellboreId ) +std::vector RiaOsduConnector::requestWellLogsByWellboreIdBlocking( const QString& wellboreId ) { - requestWellboreTrajectoryByWellboreId( m_server, m_dataPartitionId, m_token, wellboreId ); + QString token = requestTokenBlocking(); + + QEventLoop loop; + connect( this, SIGNAL( wellLogsFinished( const QString& ) ), &loop, SLOT( quit() ) ); + requestWellLogsByWellboreId( m_server, m_dataPartitionId, token, wellboreId ); + loop.exec(); + + return m_wellLogs[wellboreId]; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::requestFileDownloadByFileId( const QString& fileId ) +void RiaOsduConnector::requestWellLogsByWellboreId( const QString& wellboreId ) { - requestFileDownloadByFileId( m_server, m_dataPartitionId, m_token, fileId ); + requestWellLogsByWellboreId( m_server, m_dataPartitionId, m_token, wellboreId ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& server, - const QString& dataPartitionId, - const QString& token, - const QString& wellboreId ) +void RiaOsduConnector::requestWellLogsByWellboreId( const QString& server, + const QString& dataPartitionId, + const QString& token, + const QString& wellboreId ) { std::map params; - params["kind"] = WELLBORE_TRAJECTORY_KIND; + params["kind"] = WELL_LOG_KIND; params["limit"] = "10000"; params["query"] = "data.WellboreID: \"" + wellboreId + "\""; @@ -228,7 +235,7 @@ void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& ser { if ( reply->error() == QNetworkReply::NoError ) { - parseWellTrajectory( reply, wellboreId ); + parseWellLogs( reply, wellboreId ); } } ); } @@ -236,23 +243,32 @@ void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& ser //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::requestFileDownloadByFileId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fileId ) +void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& wellboreId ) +{ + requestWellboreTrajectoryByWellboreId( m_server, m_dataPartitionId, m_token, wellboreId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& server, + const QString& dataPartitionId, + const QString& token, + const QString& wellboreId ) { - RiaLogging::info( "Requesting download of file id: " + fileId ); - QString url = constructFileDownloadUrl( server, fileId ); + std::map params; + params["kind"] = WELLBORE_TRAJECTORY_KIND; + params["limit"] = "10000"; + params["query"] = "data.WellboreID: \"" + wellboreId + "\""; - auto reply = makeDownloadRequest( url, dataPartitionId, token, CONTENT_TYPE_JSON ); + auto reply = makeSearchRequest( params, server, dataPartitionId, token ); connect( reply, &QNetworkReply::finished, - [this, reply, fileId]() + [this, reply, wellboreId]() { if ( reply->error() == QNetworkReply::NoError ) { - saveFile( reply, fileId ); - } - else - { - RiaLogging::error( "File request for id " + fileId + " failed." + reply->errorString() ); + parseWellTrajectory( reply, wellboreId ); } } ); } @@ -297,6 +313,14 @@ QString RiaOsduConnector::constructWellLogDownloadUrl( const QString& server, co return server + "/api/os-wellbore-ddms/ddms/v3/welllogs/" + wellLogId + "/data"; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaOsduConnector::constructWellboreTrajectoriesDownloadUrl( const QString& server, const QString& wellboreTrajectoryId ) +{ + return server + "/api/os-wellbore-ddms/ddms/v3/wellboretrajectories/" + wellboreTrajectoryId + "/data"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -430,21 +454,10 @@ void RiaOsduConnector::parseWellTrajectory( QNetworkReply* reply, const QString& foreach ( const QJsonValue& value, resultsArray ) { QJsonObject resultObj = value.toObject(); - QJsonObject dataObj = resultObj["data"].toObject(); - QJsonArray dataSets = dataObj["Datasets"].toArray(); - if ( dataSets.size() == 1 ) - { - QString id = resultObj["id"].toString(); - QString kind = resultObj["kind"].toString(); - QString dataSetId = dataSets[0].toString(); - QString description = dataObj["Description"].toString(); - - m_wellboreTrajectories[wellboreId].push_back( OsduWellboreTrajectory{ id, kind, description, dataSetId, wellboreId } ); - } - else if ( dataSets.size() > 1 ) - { - RiaLogging::error( "Encountered dataset with more than on file: currently not supported." ); - } + QString id = resultObj["id"].toString(); + QString kind = resultObj["kind"].toString(); + + m_wellboreTrajectories[wellboreId].push_back( OsduWellboreTrajectory{ id, kind, wellboreId } ); } emit wellboreTrajectoryFinished( wellboreId ); @@ -454,40 +467,27 @@ void RiaOsduConnector::parseWellTrajectory( QNetworkReply* reply, const QString& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::saveFile( QNetworkReply* reply, const QString& fileId ) +void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellboreId ) { QByteArray result = reply->readAll(); reply->deleteLater(); if ( reply->error() == QNetworkReply::NoError ) { - QEventLoop loop; - - QJsonDocument doc = QJsonDocument::fromJson( result ); - QJsonObject jsonObj = doc.object(); - - QString signedUrl = jsonObj["SignedUrl"].toString(); - - RiaFileDownloader* downloader = new RiaFileDownloader; - QUrl url( signedUrl ); - QString filePath = "/tmp/" + generateRandomString( 30 ) + ".txt"; - - QString formattedJsonString = doc.toJson( QJsonDocument::Indented ); + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + QJsonArray resultsArray = jsonObj["results"].toArray(); + m_wellLogs.clear(); + foreach ( const QJsonValue& value, resultsArray ) + { + QJsonObject resultObj = value.toObject(); + QString id = resultObj["id"].toString(); + QString kind = resultObj["kind"].toString(); - RiaLogging::info( QString( "File download: %1 => %2" ).arg( signedUrl ).arg( filePath ) ); - connect( this, SIGNAL( fileDownloadFinished( const QString&, const QString& ) ), &loop, SLOT( quit() ) ); - connect( downloader, - &RiaFileDownloader::done, - [this, fileId, filePath]() - { - RiaLogging::info( QString( "Download complete %1 => %2" ).arg( fileId ).arg( filePath ) ); - emit( fileDownloadFinished( fileId, filePath ) ); - } ); - RiaLogging::info( "Starting download" ); - downloader->downloadFile( url, filePath ); + m_wellLogs[wellboreId].push_back( OsduWellLog{ id, kind, wellboreId } ); + } - downloader->deleteLater(); - loop.exec(); + emit wellLogsFinished( wellboreId ); } } @@ -620,84 +620,49 @@ std::vector RiaOsduConnector::wellboreTrajectories( cons //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::fileDownloadComplete( const QString& fileId, const QString& filePath ) +std::pair RiaOsduConnector::requestWellboreTrajectoryParquetDataById( const QString& wellboreTrajectoryId ) { - m_filePath = filePath; + QString url = constructWellboreTrajectoriesDownloadUrl( m_server, wellboreTrajectoryId ); + RiaLogging::debug( "Wellbore trajectory URL: " + url ); + return requestParquetDataByUrl( url ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair RiaOsduConnector::requestFileContentsById( const QString& fileId ) +std::pair RiaOsduConnector::requestWellLogParquetDataById( const QString& wellLogId ) { - if ( m_token.isEmpty() ) - { - // TODO: improve this.. - QEventLoop loop; - connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) ); - requestToken(); - loop.exec(); - } - - QEventLoop loop2; - connect( this, - SIGNAL( fileDownloadFinished( const QString&, const QString& ) ), - this, - SLOT( fileDownloadComplete( const QString&, const QString& ) ) ); - connect( this, SIGNAL( fileDownloadFinished( const QString&, const QString& ) ), &loop2, SLOT( quit() ) ); - - requestFileDownloadByFileId( m_server, m_dataPartitionId, m_token, fileId ); - loop2.exec(); - - QFile dataFile( m_filePath ); - - if ( !dataFile.open( QFile::ReadOnly ) ) - { - return { "", "Unable to open file: " + m_filePath }; - } - - QTextStream stream( &dataFile ); - auto fileContent = stream.readAll(); - - return { fileContent, "" }; + QString url = constructWellLogDownloadUrl( m_server, wellLogId ); + RiaLogging::debug( "Well log URL: " + url ); + return requestParquetDataByUrl( url ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair RiaOsduConnector::requestWellLogParquetDataById( const QString& wellLogId ) +std::pair RiaOsduConnector::requestParquetDataByUrl( const QString& url ) { - if ( m_token.isEmpty() ) - { - // TODO: improve this.. - QEventLoop loop; - connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) ); - requestToken(); - loop.exec(); - } + QString token = requestTokenBlocking(); - QEventLoop loop2; + QEventLoop loop; connect( this, - SIGNAL( wellLogDownloadFinished( const QByteArray&, const QString& ) ), + SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ), this, - SLOT( wellLogDownloadComplete( const QByteArray&, const QString& ) ) ); - connect( this, SIGNAL( wellLogDownloadFinished( const QByteArray&, const QString& ) ), &loop2, SLOT( quit() ) ); - - QString url = constructWellLogDownloadUrl( m_server, wellLogId ); - RiaLogging::debug( "Well log URL: " + url ); + SLOT( parquetDownloadComplete( const QByteArray&, const QString& ) ) ); + connect( this, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ), &loop, SLOT( quit() ) ); - requestWellLog( url, m_dataPartitionId, m_token ); - loop2.exec(); + requestParquetData( url, m_dataPartitionId, token ); + loop.exec(); - return { m_wellLogContents, "" }; + return { m_parquetData, "" }; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::requestWellLog( const QString& url, const QString& dataPartitionId, const QString& token ) +void RiaOsduConnector::requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token ) { - RiaLogging::info( "Requesting download of well log from: " + url ); + RiaLogging::info( "Requesting download of parquet from: " + url ); auto reply = makeDownloadRequest( url, dataPartitionId, token, CONTENT_TYPE_PARQUET ); connect( reply, @@ -708,7 +673,7 @@ void RiaOsduConnector::requestWellLog( const QString& url, const QString& dataPa { QByteArray contents = reply->readAll(); RiaLogging::info( QString( "Download succeeded: %1 bytes." ).arg( contents.length() ) ); - emit wellLogDownloadFinished( contents, "" ); + emit parquetDownloadFinished( contents, "" ); } else { @@ -720,7 +685,23 @@ void RiaOsduConnector::requestWellLog( const QString& url, const QString& dataPa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::wellLogDownloadComplete( const QByteArray& contents, const QString& url ) +void RiaOsduConnector::parquetDownloadComplete( const QByteArray& contents, const QString& url ) { - m_wellLogContents = contents; + m_parquetData = contents; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaOsduConnector::requestTokenBlocking() +{ + if ( m_token.isEmpty() ) + { + QEventLoop loop; + connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) ); + requestToken(); + loop.exec(); + } + + return m_token; } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h index 31be1bdf46..7d242807b3 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -33,8 +33,13 @@ struct OsduWellboreTrajectory { QString id; QString kind; - QString description; - QString dataSetId; + QString wellboreId; +}; + +struct OsduWellLog +{ + QString id; + QString kind; QString wellboreId; }; @@ -53,17 +58,16 @@ class RiaOsduConnector : public QObject const QString& clientId ); ~RiaOsduConnector() override; - void requestFieldsByName( const QString& token, const QString& fieldName ); - void requestFieldsByName( const QString& fieldName ); - void requestWellsByFieldId( const QString& fieldId ); - void requestWellboresByWellId( const QString& wellId ); - void requestWellboreTrajectoryByWellboreId( const QString& wellboreId ); - void requestFileDownloadByFileId( const QString& fileId ); - void requestWellLog( const QString& url, const QString& dataPartitionId, const QString& token ); - - std::pair requestFileContentsById( const QString& fileId ); + void requestFieldsByName( const QString& token, const QString& fieldName ); + void requestFieldsByName( const QString& fieldName ); + void requestWellsByFieldId( const QString& fieldId ); + void requestWellboresByWellId( const QString& wellId ); + void requestWellboreTrajectoryByWellboreId( const QString& wellboreId ); + void requestWellLogsByWellboreId( const QString& wellboreId ); + std::vector requestWellLogsByWellboreIdBlocking( const QString& wellboreId ); std::pair requestWellLogParquetDataById( const QString& wellLogId ); + std::pair requestWellboreTrajectoryParquetDataById( const QString& wellboreTrajectoryId ); QString wellIdForWellboreId( const QString& wellboreId ) const; @@ -74,6 +78,7 @@ class RiaOsduConnector : public QObject std::vector wells() const; std::vector wellbores( const QString& wellId ) const; std::vector wellboreTrajectories( const QString& wellboreId ) const; + std::vector wellLogs( const QString& wellboreId ) const; public slots: void requestToken(); @@ -81,21 +86,23 @@ public slots: void parseWells( QNetworkReply* reply ); void parseWellbores( QNetworkReply* reply, const QString& wellId ); void parseWellTrajectory( QNetworkReply* reply, const QString& wellboreId ); - void saveFile( QNetworkReply* reply, const QString& fileId ); + void parseWellLogs( QNetworkReply* reply, const QString& wellboreId ); + void accessGranted(); - void fileDownloadComplete( const QString& fileId, const QString& filePath ); - void wellLogDownloadComplete( const QByteArray&, const QString& url ); + void parquetDownloadComplete( const QByteArray&, const QString& url ); signals: - void fileDownloadFinished( const QString& fileId, const QString& filePath ); - void wellLogDownloadFinished( const QByteArray& contents, const QString& url ); + void parquetDownloadFinished( const QByteArray& contents, const QString& url ); void fieldsFinished(); void wellsFinished(); void wellboresFinished( const QString& wellId ); void wellboreTrajectoryFinished( const QString& wellboreId ); + void wellLogsFinished( const QString& wellboreId ); void tokenReady( const QString& token ); private: + void requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token ); + void addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& dataPartitionId, const QString& contentType ); QNetworkReply* makeSearchRequest( const std::map& parameters, @@ -112,7 +119,7 @@ public slots: const QString& dataPartitionId, const QString& token, const QString& wellboreId ); - void requestFileDownloadByFileId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fileId ); + void requestWellLogsByWellboreId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellboreId ); static QString generateRandomString( int length = 20 ); static QString constructSearchUrl( const QString& server ); @@ -120,6 +127,11 @@ public slots: static QString constructAuthUrl( const QString& authority ); static QString constructTokenUrl( const QString& authority ); static QString constructWellLogDownloadUrl( const QString& server, const QString& wellLogId ); + static QString constructWellboreTrajectoriesDownloadUrl( const QString& server, const QString& wellboreTrajectoryId ); + + std::pair requestParquetDataByUrl( const QString& url ); + + QString requestTokenBlocking(); QOAuth2AuthorizationCodeFlow* m_osdu; QNetworkAccessManager* m_networkAccessManager; @@ -135,13 +147,14 @@ public slots: std::vector m_wells; std::map> m_wellbores; std::map> m_wellboreTrajectories; - QString m_filePath; - QByteArray m_wellLogContents; + std::map> m_wellLogs; + QByteArray m_parquetData; static inline const QString FIELD_KIND = "osdu:wks:master-data--Field:1.0.0"; static inline const QString WELL_KIND = "osdu:wks:master-data--Well:1.*.*"; static inline const QString WELLBORE_KIND = "osdu:wks:master-data--Wellbore:1.*.*"; static inline const QString WELLBORE_TRAJECTORY_KIND = "osdu:wks:work-product-component--WellboreTrajectory:1.*.*"; + static inline const QString WELL_LOG_KIND = "osdu:wks:work-product-component--WellLog:1.*.*"; static inline const QString CONTENT_TYPE_JSON = "application/json"; static inline const QString CONTENT_TYPE_PARQUET = "application/x-parquet"; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index 0c864f709d..7da62c2454 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -74,17 +74,9 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) RimOilField* oilField = project->activeOilField(); if ( !oilField ) return; - RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences(); + RiaOsduConnector* osduConnector = app->makeOsduConnector(); - const QString server = osduPreferences->server(); - const QString dataParitionId = osduPreferences->dataPartitionId(); - const QString authority = osduPreferences->authority(); - const QString scopes = osduPreferences->scopes(); - const QString clientId = osduPreferences->clientId(); - - RiaOsduConnector osduConnector( RiuMainWindow::instance(), server, dataParitionId, authority, scopes, clientId ); - - RiuWellImportWizard wellImportwizard( wellPathsFolderPath, &osduConnector, app->project()->wellPathImport(), RiuMainWindow::instance() ); + RiuWellImportWizard wellImportwizard( wellPathsFolderPath, osduConnector, app->project()->wellPathImport(), RiuMainWindow::instance() ); if ( QDialog::Accepted == wellImportwizard.exec() ) { @@ -96,11 +88,11 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) wellPath->setWellId( w.wellId ); wellPath->setWellboreId( w.wellboreId ); wellPath->setWellboreTrajectoryId( w.wellboreTrajectoryId ); - wellPath->setFileId( w.fileId ); oilField->wellPathCollection->addWellPath( wellPath ); - auto [wellPathGeometry, errorMessage] = RimWellPathCollection::loadWellPathGeometryFromOsdu( &osduConnector, w.fileId ); + auto [wellPathGeometry, errorMessage] = + RimWellPathCollection::loadWellPathGeometryFromOsdu( osduConnector, w.wellboreTrajectoryId ); if ( wellPathGeometry.notNull() ) { wellPath->setWellPathGeometry( wellPathGeometry.p() ); diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index 99cd2a395b..bbac7ec813 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -77,7 +77,7 @@ RiuWellImportWizard::~RiuWellImportWizard() void RiuWellImportWizard::downloadFields() { // TODO: filter by user input - m_osduConnector->requestFieldsByName( "AZERI" ); + m_osduConnector->requestFieldsByName( "CASTBERG" ); } //-------------------------------------------------------------------------------------------------- @@ -436,7 +436,6 @@ WellSummaryPage::WellSummaryPage( RimWellPathImport* wellPathImport, RiaOsduConn setButtonText( QWizard::FinishButton, "Import" ); connect( m_osduConnector, SIGNAL( wellboreTrajectoryFinished( const QString& ) ), SLOT( wellboreTrajectoryFinished( const QString& ) ) ); - connect( m_osduConnector, SIGNAL( fileDownloadFinished( const QString& ) ), SLOT( fileDownloadFinished( const QString& ) ) ); } //-------------------------------------------------------------------------------------------------- @@ -450,17 +449,6 @@ void WellSummaryPage::initializePage() wiz->downloadWellPaths( wellboreId ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void WellSummaryPage::fileDownloadFinished( const QString& fileId, const QString& filePath ) -{ - m_textEdit->setText( "Summary of imported wells\n\n" ); - - m_textEdit->append( "FileId:" ); - m_textEdit->append( fileId ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -482,11 +470,6 @@ void WellSummaryPage::wellboreTrajectoryFinished( const QString& wellboreId ) for ( auto w : wellboreTrajectories ) { - // TODO: remove hack. A lot of the data set IDs in OSDU has trailing ":" which should not be - // there (i.e. the real id is without it). Chop them off to make more data sets work. - QString fileId = w.dataSetId; - if ( fileId.endsWith( ":" ) ) fileId.truncate( fileId.lastIndexOf( QChar( ':' ) ) ); - QString wellId = m_osduConnector->wellIdForWellboreId( w.wellboreId ); std::optional well = findWellForWellId( wells, wellId ); @@ -496,8 +479,7 @@ void WellSummaryPage::wellboreTrajectoryFinished( const QString& wellboreId ) wiz->addWellInfo( { .name = well.value().name, .wellId = well.value().id, .wellboreId = w.wellboreId, - .wellboreTrajectoryId = wellboreTrajectoryId, - .fileId = fileId } ); + .wellboreTrajectoryId = wellboreTrajectoryId } ); } } } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index deb3b4f33b..4707f1de19 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -293,7 +293,6 @@ class WellSummaryPage : public QWizardPage private slots: void wellboreTrajectoryFinished( const QString& wellId ); - void fileDownloadFinished( const QString& fileId, const QString& filePath ); private: RimWellPathImport* m_wellPathImportObject; @@ -315,7 +314,6 @@ class RiuWellImportWizard : public QWizard QString wellId; QString wellboreId; QString wellboreTrajectoryId; - QString fileId; }; RiuWellImportWizard( const QString& downloadFolder, diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp index 827c7a47ee..38c484c127 100644 --- a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp @@ -52,17 +52,6 @@ bool RicImportWellLogOsduFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked ) { - auto makeOsduConnector = []( auto app ) - { - RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences(); - const QString server = osduPreferences->server(); - const QString dataPartitionId = osduPreferences->dataPartitionId(); - const QString authority = osduPreferences->authority(); - const QString scopes = osduPreferences->scopes(); - const QString clientId = osduPreferences->clientId(); - return std::make_unique( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId ); - }; - if ( auto wellPath = caf::SelectionManager::instance()->selectedItemOfType() ) { RiaGuiApplication* app = RiaGuiApplication::instance(); @@ -72,19 +61,17 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked ) if ( !oilField->wellPathCollection ) oilField->wellPathCollection = std::make_unique(); - // TODO: get from OSDU... - std::vector wellLogIds = { "npequinor-dev:work-product-component--WellLog:aeb5bd8b1de14138afe9f23cacbc7fe7" }; + auto osduConnector = app->makeOsduConnector(); + std::vector wellLogs = osduConnector->requestWellLogsByWellboreIdBlocking( wellPath->wellboreId() ); - for ( QString wellLogId : wellLogIds ) + for ( OsduWellLog wellLog : wellLogs ) { RimOsduWellLog* osduWellLog = new RimOsduWellLog; - osduWellLog->setName( wellLogId ); - osduWellLog->setWellLogId( wellLogId ); + osduWellLog->setName( wellLog.id ); + osduWellLog->setWellLogId( wellLog.id ); oilField->wellPathCollection->addWellLog( osduWellLog, wellPath ); - auto osduConnector = makeOsduConnector( app ); - - auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector.get(), osduWellLog->wellLogId() ); + auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector, osduWellLog->wellLogId() ); if ( wellLogData.notNull() ) { osduWellLog->setWellLogData( wellLogData.p() ); diff --git a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp index 74fcc7b53b..7965767c44 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp +++ b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp @@ -18,10 +18,18 @@ #include "RifOsduWellPathReader.h" +#include +#include +#include +#include +#include +#include + +#include "RiaLogging.h" #include "RiaTextStringTools.h" #include "RifAsciiDataParseOptions.h" - +#include "RifByteArrayArrowRandomAccessFile.h" #include "RifCsvUserDataParser.h" #include "RigWellPath.h" @@ -32,6 +40,9 @@ #include #include +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- std::pair, QString> RifOsduWellPathReader::parseCsv( const QString& content ) { QString errorMessage; @@ -90,3 +101,100 @@ std::pair, QString> RifOsduWellPathReader::parseCsv( const return { nullptr, "Oh no!" }; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair, QString> RifOsduWellPathReader::readWellPathData( const QByteArray& content ) +{ + // Function to convert an entire column to std::vector + auto convertColumnToVector = []( const std::shared_ptr& column ) -> std::vector + { + auto convertChunkToVector = []( const std::shared_ptr& array ) -> std::vector + { + std::vector result; + + auto double_array = std::static_pointer_cast( array ); + result.resize( double_array->length() ); + for ( int64_t i = 0; i < double_array->length(); ++i ) + { + result[i] = double_array->Value( i ); + } + + return result; + }; + + CAF_ASSERT( column->type()->id() == arrow::Type::DOUBLE ); + + std::vector result; + + // Iterate over each chunk in the column + for ( int i = 0; i < column->num_chunks(); ++i ) + { + std::shared_ptr chunk = column->chunk( i ); + std::vector chunk_vector = convertChunkToVector( chunk ); + result.insert( result.end(), chunk_vector.begin(), chunk_vector.end() ); + } + + return result; + }; + + arrow::MemoryPool* pool = arrow::default_memory_pool(); + + std::shared_ptr input = std::make_shared( content ); + + // Open Parquet file reader + std::unique_ptr arrow_reader; + if ( !parquet::arrow::OpenFile( input, pool, &arrow_reader ).ok() ) + { + return { nullptr, "Unable to read parquet data." }; + } + + // Read entire file as a single Arrow table + std::shared_ptr table; + if ( !arrow_reader->ReadTable( &table ).ok() ) + { + return { nullptr, "Unable to read parquet table." }; + } + + const std::string MD = "MD"; + const std::string TVD = "TVD"; + const std::string X = "X"; + const std::string Y = "Y"; + + std::vector columnNames = { MD, TVD, X, Y }; + + std::map> readValues; + + for ( std::string columnName : columnNames ) + { + std::shared_ptr column = table->GetColumnByName( columnName ); + + if ( column->type()->id() == arrow::Type::DOUBLE ) + { + std::vector columnVector = convertColumnToVector( column ); + RiaLogging::debug( QString( "Column name: %1. Size: %2" ).arg( QString::fromStdString( columnName ) ).arg( columnVector.size() ) ); + readValues[columnName] = columnVector; + } + } + + const size_t firstSize = readValues[MD].size(); + if ( ( firstSize == readValues[TVD].size() ) && ( firstSize == readValues[X].size() ) && ( firstSize == readValues[Y].size() ) ) + { + std::vector wellPathPoints; + std::vector measuredDepths; + + for ( size_t i = 0; i < firstSize; i++ ) + { + cvf::Vec3d point( readValues[X][i], readValues[Y][i], -readValues[TVD][i] ); + double md = readValues[MD][i]; + + wellPathPoints.push_back( point ); + measuredDepths.push_back( md ); + } + + return { cvf::make_ref( wellPathPoints, measuredDepths ), "" }; + } + + return { nullptr, "" }; +} diff --git a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.h b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.h index a78859dd6f..ffb52f83e0 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.h +++ b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.h @@ -32,4 +32,5 @@ class RifOsduWellPathReader { public: static std::pair, QString> parseCsv( const QString& content ); + static std::pair, QString> readWellPathData( const QByteArray& content ); }; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 698e3d9783..84d6f8497b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -150,19 +150,10 @@ void RimWellPathCollection::loadDataAndUpdate() { caf::ProgressInfo progress( m_wellPaths.size(), "Reading well paths from file" ); - auto makeOsduConnector = []( auto app ) - { - RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences(); - const QString server = osduPreferences->server(); - const QString dataPartitionId = osduPreferences->dataPartitionId(); - const QString authority = osduPreferences->authority(); - const QString scopes = osduPreferences->scopes(); - const QString clientId = osduPreferences->clientId(); - return std::make_unique( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId ); - }; - readWellPathFormationFiles(); + RiaApplication* app = RiaApplication::instance(); + for ( RimWellPath* wellPath : allWellPaths() ) { progress.setProgressDescription( QString( "Reading file %1" ).arg( wellPath->name() ) ); @@ -187,10 +178,8 @@ void RimWellPathCollection::loadDataAndUpdate() } else if ( oWPath ) { - RiaApplication* app = RiaApplication::instance(); - auto osduConnector = makeOsduConnector( app ); - - auto [wellPathGeometry, errorMessage] = loadWellPathGeometryFromOsdu( osduConnector.get(), oWPath->fileId() ); + RiaOsduConnector* osduConnector = app->makeOsduConnector(); + auto [wellPathGeometry, errorMessage] = loadWellPathGeometryFromOsdu( osduConnector, oWPath->wellboreTrajectoryId() ); if ( wellPathGeometry.notNull() ) { oWPath->setWellPathGeometry( wellPathGeometry.p() ); @@ -215,9 +204,8 @@ void RimWellPathCollection::loadDataAndUpdate() } else if ( RimOsduWellLog* osduWellLog = dynamic_cast( wellLog ) ) { - RiaApplication* app = RiaApplication::instance(); - auto osduConnector = makeOsduConnector( app ); - auto [wellLogData, errorMessage] = loadWellLogFromOsdu( osduConnector.get(), osduWellLog->wellLogId() ); + RiaOsduConnector* osduConnector = app->makeOsduConnector(); + auto [wellLogData, errorMessage] = loadWellLogFromOsdu( osduConnector, osduWellLog->wellLogId() ); if ( wellLogData.notNull() ) { osduWellLog->setWellLogData( wellLogData.p() ); @@ -1064,15 +1052,15 @@ void RimWellPathCollection::onChildAdded( caf::PdmFieldHandle* containerForNewOb /// //-------------------------------------------------------------------------------------------------- std::pair, QString> RimWellPathCollection::loadWellPathGeometryFromOsdu( RiaOsduConnector* osduConnector, - const QString& fileId ) + const QString& wellboreTrajectoryId ) { - auto [fileContents, errorMessage] = osduConnector->requestFileContentsById( fileId ); + auto [fileContents, errorMessage] = osduConnector->requestWellboreTrajectoryParquetDataById( wellboreTrajectoryId ); if ( !errorMessage.isEmpty() ) { return { nullptr, errorMessage }; } - return RifOsduWellPathReader::parseCsv( fileContents ); + return RifOsduWellPathReader::readWellPathData( fileContents ); } //-------------------------------------------------------------------------------------------------- From c5da22223b9fa2525d9657a728905970e943fa0e Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 10 Jun 2024 13:23:13 +0200 Subject: [PATCH 125/332] Osdu wellpath import: improve error handling. --- .../OsduImportCommands/RiaOsduConnector.cpp | 4 +++- .../RicWellPathsImportOsduFeature.cpp | 16 ++++++++-------- .../Commands/RicImportWellLogOsduFeature.cpp | 15 +++++++-------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index faade6fec1..1722469a37 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -677,7 +677,9 @@ void RiaOsduConnector::requestParquetData( const QString& url, const QString& da } else { - RiaLogging::error( "Download failed: " + url + " failed." + reply->errorString() ); + QString errorMessage = "Download failed: " + url + " failed." + reply->errorString(); + RiaLogging::error( errorMessage ); + emit parquetDownloadFinished( QByteArray(), errorMessage ); } } ); } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index 7da62c2454..8b4cbbf1ce 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -83,18 +83,18 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) std::vector importedWells = wellImportwizard.importedWells(); for ( auto w : importedWells ) { - auto wellPath = new RimOsduWellPath; - wellPath->setName( w.name ); - wellPath->setWellId( w.wellId ); - wellPath->setWellboreId( w.wellboreId ); - wellPath->setWellboreTrajectoryId( w.wellboreTrajectoryId ); - - oilField->wellPathCollection->addWellPath( wellPath ); - auto [wellPathGeometry, errorMessage] = RimWellPathCollection::loadWellPathGeometryFromOsdu( osduConnector, w.wellboreTrajectoryId ); if ( wellPathGeometry.notNull() ) { + auto wellPath = new RimOsduWellPath; + wellPath->setName( w.name ); + wellPath->setWellId( w.wellId ); + wellPath->setWellboreId( w.wellboreId ); + wellPath->setWellboreTrajectoryId( w.wellboreTrajectoryId ); + + oilField->wellPathCollection->addWellPath( wellPath ); + wellPath->setWellPathGeometry( wellPathGeometry.p() ); } else diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp index 38c484c127..9f34260a49 100644 --- a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp @@ -66,22 +66,21 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked ) for ( OsduWellLog wellLog : wellLogs ) { - RimOsduWellLog* osduWellLog = new RimOsduWellLog; - osduWellLog->setName( wellLog.id ); - osduWellLog->setWellLogId( wellLog.id ); - oilField->wellPathCollection->addWellLog( osduWellLog, wellPath ); - - auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector, osduWellLog->wellLogId() ); + auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector, wellLog.id ); if ( wellLogData.notNull() ) { + RimOsduWellLog* osduWellLog = new RimOsduWellLog; + osduWellLog->setName( wellLog.id ); + osduWellLog->setWellLogId( wellLog.id ); + oilField->wellPathCollection->addWellLog( osduWellLog, wellPath ); + osduWellLog->setWellLogData( wellLogData.p() ); + osduWellLog->updateConnectedEditors(); } else { RiaLogging::error( "Importing OSDU well log failed: " + errorMessage ); } - - osduWellLog->updateConnectedEditors(); } } } From ea2bf3887f3b29626de76e3bd1e8d0863ef1b09d Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 10 Jun 2024 18:24:01 +0200 Subject: [PATCH 126/332] Osdu: exclude arrow files from unity build --- ApplicationLibCode/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index ceebb33ab9..2d476be4d7 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -412,6 +412,9 @@ set(UNITY_EXCLUDE_FILES ProjectDataModel/RimVfpTableExtractor.cpp ProjectDataModel/RimVfpPlot.cpp ProjectDataModel/RiaOpmParserTools.cpp + FileInterface/RifOsduWellPathReader.cpp + FileInterface/RifOsduWellLogReader.cpp + FileInterface/RifByteArrayArrowRandomAccessFile.cpp ) if(RESINSIGHT_ENABLE_UNITY_BUILD) From 61f59e72f66ea3ed83306e8eaad6dfd29bde5252 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 12 Jun 2024 10:32:04 +0200 Subject: [PATCH 127/332] Osdu Well Paths: add search field. --- .../RiuWellImportWizard.cpp | 32 ++++++++++++++++--- .../OsduImportCommands/RiuWellImportWizard.h | 10 ++++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index bbac7ec813..63e3632c46 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -74,10 +74,10 @@ RiuWellImportWizard::~RiuWellImportWizard() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::downloadFields() +void RiuWellImportWizard::downloadFields( const QString& fieldName ) { // TODO: filter by user input - m_osduConnector->requestFieldsByName( "CASTBERG" ); + m_osduConnector->requestFieldsByName( fieldName ); } //-------------------------------------------------------------------------------------------------- @@ -238,6 +238,16 @@ FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOs QVBoxLayout* layout = new QVBoxLayout; setLayout( layout ); + QHBoxLayout* searchLayout = new QHBoxLayout; + m_searchTextEdit = new QLineEdit( this ); + searchLayout->addWidget( m_searchTextEdit ); + + m_searchButton = new QPushButton( "Search", this ); + m_searchButton->setEnabled( false ); + searchLayout->addWidget( m_searchButton ); + + layout->addLayout( searchLayout ); + QLabel* label = new QLabel( "Select fields" ); layout->addWidget( label ); @@ -259,6 +269,10 @@ FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOs m_osduConnector = osduConnector; connect( m_osduConnector, SIGNAL( fieldsFinished() ), SLOT( fieldsFinished() ) ); + connect( m_searchTextEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSearchTextChanged( const QString& ) ) ); + + connect( m_searchButton, SIGNAL( clicked() ), this, SLOT( searchForFields() ) ); + connect( m_tableView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), SLOT( selectField( const QItemSelection&, const QItemSelection& ) ) ); @@ -271,10 +285,20 @@ FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOs //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void FieldSelectionPage::initializePage() +void FieldSelectionPage::onSearchTextChanged( const QString& text ) +{ + m_searchButton->setEnabled( text.length() >= MINIMUM_CHARACTERS_FOR_SEARCH ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void FieldSelectionPage::searchForFields() { RiuWellImportWizard* wiz = dynamic_cast( wizard() ); - wiz->downloadFields(); + + QString text = m_searchTextEdit->text(); + if ( text.length() >= MINIMUM_CHARACTERS_FOR_SEARCH ) wiz->downloadFields( text ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index 4707f1de19..d6d2ff306d 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include #include @@ -245,9 +246,14 @@ class FieldSelectionPage : public QWizardPage private slots: void fieldsFinished(); void selectField( const QItemSelection& newSelection, const QItemSelection& oldSelection ); + void onSearchTextChanged( const QString& ); + void searchForFields(); private: - // caf::PdmUiPropertyView* m_propertyView; + static const int MINIMUM_CHARACTERS_FOR_SEARCH = 3; + + QLineEdit* m_searchTextEdit; + QPushButton* m_searchButton; RiaOsduConnector* m_osduConnector; QTableView* m_tableView; OsduFieldTableModel* m_osduFieldsModel; @@ -336,7 +342,7 @@ class RiuWellImportWizard : public QWizard public slots: void downloadWellPaths( const QString& wellboreId ); void downloadWells( const QString& fieldId ); - void downloadFields(); + void downloadFields( const QString& fieldName ); void slotAuthenticationRequired( QNetworkReply* networkReply, QAuthenticator* authenticator ); From 1dce5373085b03c86bd5c9a7cca5e0735a6cdfad Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 12 Jun 2024 11:18:06 +0200 Subject: [PATCH 128/332] Osdu: skip auth when token is available. --- .../Commands/OsduImportCommands/RiaOsduConnector.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index 1722469a37..396ac54337 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -83,8 +83,16 @@ void RiaOsduConnector::accessGranted() //-------------------------------------------------------------------------------------------------- void RiaOsduConnector::requestToken() { - RiaLogging::debug( "Requesting token." ); - m_osdu->grant(); + if ( m_token.isEmpty() ) + { + RiaLogging::debug( "Requesting token." ); + m_osdu->grant(); + } + else + { + RiaLogging::debug( "Has token: skipping token request." ); + emit accessGranted(); + } } //-------------------------------------------------------------------------------------------------- From 88d88992d624ad73fdec8257dc5bbddf3989ff00 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 12 Jun 2024 11:18:44 +0200 Subject: [PATCH 129/332] Janitor: Remove unused method. --- .../OsduImportCommands/RiaOsduConnector.cpp | 17 ----------------- .../OsduImportCommands/RiaOsduConnector.h | 1 - 2 files changed, 18 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index 396ac54337..18a031a686 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -527,23 +527,6 @@ QNetworkReply* return reply; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaOsduConnector::generateRandomString( int randomStringLength ) -{ - const QString possibleCharacters( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ); - QString randomString; - for ( int i = 0; i < randomStringLength; ++i ) - { - quint32 value = QRandomGenerator::global()->generate(); - int index = value % possibleCharacters.length(); - QChar nextChar = possibleCharacters.at( index ); - randomString.append( nextChar ); - } - return randomString; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h index 7d242807b3..3e23027d22 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -121,7 +121,6 @@ public slots: const QString& wellboreId ); void requestWellLogsByWellboreId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellboreId ); - static QString generateRandomString( int length = 20 ); static QString constructSearchUrl( const QString& server ); static QString constructFileDownloadUrl( const QString& server, const QString& fileId ); static QString constructAuthUrl( const QString& authority ); From e77ecb7f7f9a1b9beb036cb74a4209b94355dc75 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 12 Jun 2024 11:32:37 +0200 Subject: [PATCH 130/332] Janitor: remove unused field. --- .../WellPath/RimOsduWellPath.cpp | 20 ------------------- .../WellPath/RimOsduWellPath.h | 4 ---- 2 files changed, 24 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp index 1f5e6bf415..cb16b7c949 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp @@ -20,9 +20,6 @@ RimOsduWellPath::RimOsduWellPath() CAF_PDM_InitFieldNoDefault( &m_wellboreTrajectoryId, "WellboreTrajectoryId", "Wellbore Trajectory Id" ); m_wellboreTrajectoryId.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_fileId, "FileId", "File Id" ); - m_fileId.uiCapability()->setUiReadOnly( true ); - // Required, as these settings are set in RimWellPath() m_name.uiCapability()->setUiReadOnly( false ); m_name.uiCapability()->setUiHidden( false ); @@ -85,22 +82,6 @@ QString RimOsduWellPath::wellboreTrajectoryId() const return m_wellboreTrajectoryId; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimOsduWellPath::setFileId( const QString& fileId ) -{ - m_fileId = fileId; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimOsduWellPath::fileId() const -{ - return m_fileId; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -110,7 +91,6 @@ void RimOsduWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering osduGroup->add( &m_wellId ); osduGroup->add( &m_wellboreId ); osduGroup->add( &m_wellboreTrajectoryId ); - osduGroup->add( &m_fileId ); RimWellPath::defineUiOrdering( uiConfigName, uiOrdering ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h index a1968cf336..362ab3bcb5 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h @@ -36,9 +36,6 @@ class RimOsduWellPath : public RimWellPath void setWellboreTrajectoryId( const QString& wellboreTrajectoryId ); QString wellboreTrajectoryId() const; - void setFileId( const QString& fileId ); - QString fileId() const; - protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; @@ -46,5 +43,4 @@ class RimOsduWellPath : public RimWellPath caf::PdmField m_wellId; caf::PdmField m_wellboreId; caf::PdmField m_wellboreTrajectoryId; - caf::PdmField m_fileId; }; From 3e8a8af857205369d25600ee88858cb38d7f89d0 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 12 Jun 2024 11:33:58 +0200 Subject: [PATCH 131/332] Osdu Wizard: make server and data partition id read-only. --- .../Commands/OsduImportCommands/RiuWellImportWizard.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index 63e3632c46..1fef3eabaa 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -191,8 +191,10 @@ AuthenticationPage::AuthenticationPage( RiaOsduConnector* osduConnector, QWidget QFormLayout* formLayout = new QFormLayout; layout->addLayout( formLayout ); - QLineEdit* serverLineEdit = new QLineEdit( osduConnector->server(), this ); + QLineEdit* serverLineEdit = new QLineEdit( osduConnector->server(), this ); + serverLineEdit->setReadOnly( true ); QLineEdit* partitionLineEdit = new QLineEdit( osduConnector->dataPartition(), this ); + partitionLineEdit->setReadOnly( true ); formLayout->addRow( "Server:", serverLineEdit ); formLayout->addRow( "Data Partition:", partitionLineEdit ); From 2d76775ff6c15a53e27dffd6361767a6910255d7 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 14 Jun 2024 12:12:33 +0200 Subject: [PATCH 132/332] Osdu Import: improve table layout. --- .../Commands/OsduImportCommands/RiuWellImportWizard.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index 1fef3eabaa..d75b635328 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -255,6 +255,10 @@ FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOs m_tableView = new QTableView( this ); m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows ); + QHeaderView* header = m_tableView->horizontalHeader(); + header->setSectionResizeMode( QHeaderView::Interactive ); + header->setStretchLastSection( true ); + m_osduFieldsModel = new OsduFieldTableModel; m_tableView->setModel( m_osduFieldsModel ); layout->addWidget( m_tableView ); @@ -356,6 +360,10 @@ WellSelectionPage::WellSelectionPage( RimWellPathImport* wellPathImport, RiaOsdu m_tableView = new QTableView( this ); m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows ); + QHeaderView* header = m_tableView->horizontalHeader(); + header->setSectionResizeMode( QHeaderView::Interactive ); + header->setStretchLastSection( true ); + m_osduWellboresModel = new OsduWellboreTableModel; m_tableView->setModel( m_osduWellboresModel ); layout->addWidget( m_tableView ); From a6323471e781ee79643f49679d3ad08eedce7166 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 14 Jun 2024 12:16:05 +0200 Subject: [PATCH 133/332] Osdu import: update connection label. --- .../OsduImportCommands/RiuWellImportWizard.cpp | 5 +++-- .../Commands/OsduImportCommands/RiuWellImportWizard.h | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index d75b635328..a2752a5de6 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -185,8 +185,8 @@ AuthenticationPage::AuthenticationPage( RiaOsduConnector* osduConnector, QWidget QVBoxLayout* layout = new QVBoxLayout; - QLabel* label = new QLabel( "Checking OSDU connection..." ); - layout->addWidget( label ); + m_connectionLabel = new QLabel( "Checking OSDU connection. You might need to login." ); + layout->addWidget( m_connectionLabel ); QFormLayout* formLayout = new QFormLayout; layout->addLayout( formLayout ); @@ -226,6 +226,7 @@ bool AuthenticationPage::isComplete() const //-------------------------------------------------------------------------------------------------- void AuthenticationPage::accessOk() { + m_connectionLabel->setText( "Connection to OSDU: OK." ); m_accessOk = true; emit( completeChanged() ); } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index d6d2ff306d..2dd3a44aac 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -113,9 +113,9 @@ class OsduFieldTableModel : public QAbstractTableModel void setOsduFields( const std::vector& osduFields ) { - beginInsertRows( QModelIndex(), 0, static_cast( osduFields.size() ) ); + beginResetModel(); m_osduFields = osduFields; - endInsertRows(); + endResetModel(); } private: @@ -193,6 +193,7 @@ class OsduWellboreTableModel : public QAbstractTableModel void setOsduWellbores( const QString& wellId, const std::vector& osduWellbores ) { + beginResetModel(); m_map[wellId] = osduWellbores; m_osduWellbores.clear(); for ( auto [name, values] : m_map ) @@ -201,8 +202,7 @@ class OsduWellboreTableModel : public QAbstractTableModel m_osduWellbores.push_back( v ); } - beginInsertRows( QModelIndex(), 0, static_cast( m_osduWellbores.size() ) ); - endInsertRows(); + endResetModel(); } private: @@ -227,7 +227,8 @@ private slots: void accessOk(); private: - bool m_accessOk; + QLabel* m_connectionLabel; + bool m_accessOk; }; //-------------------------------------------------------------------------------------------------- From db96589e0f31ebcc9ee3dc98236c18b5e6097def Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 14 Jun 2024 12:24:25 +0200 Subject: [PATCH 134/332] Osdu import: avoid data race condition on well data. --- .../OsduImportCommands/RiaOsduConnector.cpp | 102 +++++++++++------- .../OsduImportCommands/RiaOsduConnector.h | 1 + 2 files changed, 62 insertions(+), 41 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index 18a031a686..1447d30831 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -369,16 +369,19 @@ void RiaOsduConnector::parseFields( QNetworkReply* reply ) QJsonObject jsonObj = doc.object(); QJsonArray resultsArray = jsonObj["results"].toArray(); - m_fields.clear(); - - foreach ( const QJsonValue& value, resultsArray ) { - QJsonObject resultObj = value.toObject(); - - QString id = resultObj["id"].toString(); - QString kind = resultObj["kind"].toString(); - QString fieldName = resultObj["data"].toObject()["FieldName"].toString(); - m_fields.push_back( OsduField{ id, kind, fieldName } ); + QMutexLocker lock( &m_mutex ); + m_fields.clear(); + + foreach ( const QJsonValue& value, resultsArray ) + { + QJsonObject resultObj = value.toObject(); + + QString id = resultObj["id"].toString(); + QString kind = resultObj["kind"].toString(); + QString fieldName = resultObj["data"].toObject()["FieldName"].toString(); + m_fields.push_back( OsduField{ id, kind, fieldName } ); + } } emit fieldsFinished(); @@ -399,16 +402,17 @@ void RiaOsduConnector::parseWells( QNetworkReply* reply ) QJsonObject jsonObj = doc.object(); QJsonArray resultsArray = jsonObj["results"].toArray(); - RiaLogging::info( QString( "Found %1 wells." ).arg( +resultsArray.size() ) ); - - m_wells.clear(); - foreach ( const QJsonValue& value, resultsArray ) { - QJsonObject resultObj = value.toObject(); - QString id = resultObj["id"].toString(); - QString kind = resultObj["kind"].toString(); - QString name = resultObj["data"].toObject()["FacilityName"].toString(); - m_wells.push_back( OsduWell{ id, kind, name } ); + QMutexLocker lock( &m_mutex ); + m_wells.clear(); + foreach ( const QJsonValue& value, resultsArray ) + { + QJsonObject resultObj = value.toObject(); + QString id = resultObj["id"].toString(); + QString kind = resultObj["kind"].toString(); + QString name = resultObj["data"].toObject()["FacilityName"].toString(); + m_wells.push_back( OsduWell{ id, kind, name } ); + } } emit wellsFinished(); @@ -429,16 +433,17 @@ void RiaOsduConnector::parseWellbores( QNetworkReply* reply, const QString& well QJsonObject jsonObj = doc.object(); QJsonArray resultsArray = jsonObj["results"].toArray(); - RiaLogging::info( QString( "Found %1 wellbores." ).arg( resultsArray.size() ) ); - - m_wellbores[wellId].clear(); - foreach ( const QJsonValue& value, resultsArray ) { - QJsonObject resultObj = value.toObject(); - QString id = resultObj["id"].toString(); - QString kind = resultObj["kind"].toString(); - QString name = resultObj["data"].toObject()["FacilityName"].toString(); - m_wellbores[wellId].push_back( OsduWellbore{ id, kind, name, wellId } ); + QMutexLocker lock( &m_mutex ); + m_wellbores[wellId].clear(); + foreach ( const QJsonValue& value, resultsArray ) + { + QJsonObject resultObj = value.toObject(); + QString id = resultObj["id"].toString(); + QString kind = resultObj["kind"].toString(); + QString name = resultObj["data"].toObject()["FacilityName"].toString(); + m_wellbores[wellId].push_back( OsduWellbore{ id, kind, name, wellId } ); + } } emit wellboresFinished( wellId ); @@ -458,14 +463,18 @@ void RiaOsduConnector::parseWellTrajectory( QNetworkReply* reply, const QString& QJsonDocument doc = QJsonDocument::fromJson( result ); QJsonObject jsonObj = doc.object(); QJsonArray resultsArray = jsonObj["results"].toArray(); - m_wellboreTrajectories.clear(); - foreach ( const QJsonValue& value, resultsArray ) - { - QJsonObject resultObj = value.toObject(); - QString id = resultObj["id"].toString(); - QString kind = resultObj["kind"].toString(); - m_wellboreTrajectories[wellboreId].push_back( OsduWellboreTrajectory{ id, kind, wellboreId } ); + { + QMutexLocker lock( &m_mutex ); + m_wellboreTrajectories.clear(); + foreach ( const QJsonValue& value, resultsArray ) + { + QJsonObject resultObj = value.toObject(); + QString id = resultObj["id"].toString(); + QString kind = resultObj["kind"].toString(); + + m_wellboreTrajectories[wellboreId].push_back( OsduWellboreTrajectory{ id, kind, wellboreId } ); + } } emit wellboreTrajectoryFinished( wellboreId ); @@ -485,14 +494,18 @@ void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellb QJsonDocument doc = QJsonDocument::fromJson( result ); QJsonObject jsonObj = doc.object(); QJsonArray resultsArray = jsonObj["results"].toArray(); - m_wellLogs.clear(); - foreach ( const QJsonValue& value, resultsArray ) - { - QJsonObject resultObj = value.toObject(); - QString id = resultObj["id"].toString(); - QString kind = resultObj["kind"].toString(); - m_wellLogs[wellboreId].push_back( OsduWellLog{ id, kind, wellboreId } ); + { + QMutexLocker lock( &m_mutex ); + m_wellLogs.clear(); + foreach ( const QJsonValue& value, resultsArray ) + { + QJsonObject resultObj = value.toObject(); + QString id = resultObj["id"].toString(); + QString kind = resultObj["kind"].toString(); + + m_wellLogs[wellboreId].push_back( OsduWellLog{ id, kind, wellboreId } ); + } } emit wellLogsFinished( wellboreId ); @@ -548,6 +561,7 @@ QString RiaOsduConnector::dataPartition() const //-------------------------------------------------------------------------------------------------- std::vector RiaOsduConnector::fields() const { + QMutexLocker lock( &m_mutex ); return m_fields; } @@ -556,6 +570,7 @@ std::vector RiaOsduConnector::fields() const //-------------------------------------------------------------------------------------------------- std::vector RiaOsduConnector::wells() const { + QMutexLocker lock( &m_mutex ); return m_wells; } @@ -564,6 +579,8 @@ std::vector RiaOsduConnector::wells() const //-------------------------------------------------------------------------------------------------- std::vector RiaOsduConnector::wellbores( const QString& wellId ) const { + QMutexLocker lock( &m_mutex ); + auto it = m_wellbores.find( wellId ); if ( it != m_wellbores.end() ) return it->second; @@ -585,6 +602,7 @@ QString RiaOsduConnector::wellIdForWellboreId( const QString& wellboreId ) const return QString(); }; + QMutexLocker lock( &m_mutex ); for ( auto [wellId, wellbores] : m_wellbores ) { if ( auto res = findWellIdForWellboreId( wellbores, wellboreId ); !res.isEmpty() ) @@ -601,6 +619,8 @@ QString RiaOsduConnector::wellIdForWellboreId( const QString& wellboreId ) const //-------------------------------------------------------------------------------------------------- std::vector RiaOsduConnector::wellboreTrajectories( const QString& wellboreId ) const { + QMutexLocker lock( &m_mutex ); + auto it = m_wellboreTrajectories.find( wellboreId ); if ( it != m_wellboreTrajectories.end() ) return it->second; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h index 3e23027d22..ba869d7b7b 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -141,6 +141,7 @@ public slots: const QString m_scopes; const QString m_clientId; + mutable QMutex m_mutex; QString m_token; std::vector m_fields; std::vector m_wells; From a85fd12989b6afb92a74990e3ed954c2d987dcc0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 14 Jun 2024 14:14:08 +0200 Subject: [PATCH 135/332] Add arrow/util/cancel.h to PCH builds Qt has special treatment of the word 'signals', and the function RegisterCancellingSignalHandler(const std::vector& signals) causes compiler issues using PCH --- ApplicationLibCode/pch.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ApplicationLibCode/pch.h b/ApplicationLibCode/pch.h index e1f0453cd5..0d49a38975 100644 --- a/ApplicationLibCode/pch.h +++ b/ApplicationLibCode/pch.h @@ -16,6 +16,11 @@ // ///////////////////////////////////////////////////////////////////////////////// +// NOTE: This file must be included before any other Qt header files, as the keyword 'signals' is used as a parameter name in +// RegisterCancellingSignalHandler(const std::vector& signals); +// Qt has special treatment of 'signals', and causes compiler issues using PCH +#include + #include "cvfObject.h" #include "cvfVector3.h" From 44ca21636a533f9a023093171056705b8cc66ff2 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 14 Jun 2024 15:16:05 +0200 Subject: [PATCH 136/332] Osdu: extract constants to separate namespace. --- .../Application/CMakeLists_files.cmake | 2 + .../Application/RiaOsduDefines.cpp | 75 +++++++++++++++++++ .../Application/RiaOsduDefines.h | 32 ++++++++ .../OsduImportCommands/RiaOsduConnector.cpp | 15 ++-- .../OsduImportCommands/RiaOsduConnector.h | 9 --- 5 files changed, 117 insertions(+), 16 deletions(-) create mode 100644 ApplicationLibCode/Application/RiaOsduDefines.cpp create mode 100644 ApplicationLibCode/Application/RiaOsduDefines.h diff --git a/ApplicationLibCode/Application/CMakeLists_files.cmake b/ApplicationLibCode/Application/CMakeLists_files.cmake index f8745d79ac..c6952c80a2 100644 --- a/ApplicationLibCode/Application/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/CMakeLists_files.cmake @@ -34,6 +34,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaSeismicDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.h ${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h @@ -75,6 +76,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSeismicDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.cpp diff --git a/ApplicationLibCode/Application/RiaOsduDefines.cpp b/ApplicationLibCode/Application/RiaOsduDefines.cpp new file mode 100644 index 0000000000..2c14f207f9 --- /dev/null +++ b/ApplicationLibCode/Application/RiaOsduDefines.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RiaOsduDefines.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::osduFieldKind() +{ + return "osdu:wks:master-data--Field:1.0.0"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::osduWellKind() +{ + return "osdu:wks:master-data--Well:1.*.*"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::osduWellboreKind() +{ + return "osdu:wks:master-data--Wellbore:1.*.*"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::osduWellboreTrajectoryKind() +{ + return "osdu:wks:work-product-component--WellboreTrajectory:1.*.*"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::osduWellLogKind() +{ + return "osdu:wks:work-product-component--WellLog:1.*.*"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::contentTypeJson() +{ + return "application/json"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::contentTypeParquet() +{ + return "application/x-parquet"; +} diff --git a/ApplicationLibCode/Application/RiaOsduDefines.h b/ApplicationLibCode/Application/RiaOsduDefines.h new file mode 100644 index 0000000000..6168386e1a --- /dev/null +++ b/ApplicationLibCode/Application/RiaOsduDefines.h @@ -0,0 +1,32 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 + +namespace RiaDefines +{ +QString osduFieldKind(); +QString osduWellKind(); +QString osduWellboreKind(); +QString osduWellboreTrajectoryKind(); +QString osduWellLogKind(); +QString contentTypeJson(); +QString contentTypeParquet(); +}; // namespace RiaDefines diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index 1447d30831..9030451a4a 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -1,6 +1,7 @@ #include "RiaOsduConnector.h" #include "RiaFileDownloader.h" #include "RiaLogging.h" +#include "RiaOsduDefines.h" #include "RiaOsduOAuthHttpServerReplyHandler.h" #include @@ -124,7 +125,7 @@ void RiaOsduConnector::requestFieldsByName( const QString& fieldName ) void RiaOsduConnector::requestFieldsByName( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldName ) { std::map params; - params["kind"] = FIELD_KIND; + params["kind"] = RiaDefines::osduFieldKind(); params["limit"] = "10000"; params["query"] = "data.FieldName:" + fieldName; @@ -154,7 +155,7 @@ void RiaOsduConnector::requestWellsByFieldId( const QString& fieldId ) void RiaOsduConnector::requestWellsByFieldId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldId ) { std::map params; - params["kind"] = WELL_KIND; + params["kind"] = RiaDefines::osduWellKind(); params["limit"] = "10000"; params["query"] = QString( "nested(data.GeoContexts, (FieldID:\"%1\"))" ).arg( fieldId ); @@ -184,7 +185,7 @@ void RiaOsduConnector::requestWellboresByWellId( const QString& wellId ) void RiaOsduConnector::requestWellboresByWellId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellId ) { std::map params; - params["kind"] = WELLBORE_KIND; + params["kind"] = RiaDefines::osduWellboreKind(); params["limit"] = "10000"; params["query"] = "data.WellID: \"" + wellId + "\""; @@ -232,7 +233,7 @@ void RiaOsduConnector::requestWellLogsByWellboreId( const QString& server, const QString& wellboreId ) { std::map params; - params["kind"] = WELL_LOG_KIND; + params["kind"] = RiaDefines::osduWellLogKind(); params["limit"] = "10000"; params["query"] = "data.WellboreID: \"" + wellboreId + "\""; @@ -265,7 +266,7 @@ void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& ser const QString& wellboreId ) { std::map params; - params["kind"] = WELLBORE_TRAJECTORY_KIND; + params["kind"] = RiaDefines::osduWellboreTrajectoryKind(); params["limit"] = "10000"; params["query"] = "data.WellboreID: \"" + wellboreId + "\""; @@ -340,7 +341,7 @@ QNetworkReply* RiaOsduConnector::makeSearchRequest( const std::map> m_wellboreTrajectories; std::map> m_wellLogs; QByteArray m_parquetData; - - static inline const QString FIELD_KIND = "osdu:wks:master-data--Field:1.0.0"; - static inline const QString WELL_KIND = "osdu:wks:master-data--Well:1.*.*"; - static inline const QString WELLBORE_KIND = "osdu:wks:master-data--Wellbore:1.*.*"; - static inline const QString WELLBORE_TRAJECTORY_KIND = "osdu:wks:work-product-component--WellboreTrajectory:1.*.*"; - static inline const QString WELL_LOG_KIND = "osdu:wks:work-product-component--WellLog:1.*.*"; - - static inline const QString CONTENT_TYPE_JSON = "application/json"; - static inline const QString CONTENT_TYPE_PARQUET = "application/x-parquet"; }; From 7125670d8c645c7668362bf458ee9bb7e540d948 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 14 Jun 2024 15:18:12 +0200 Subject: [PATCH 137/332] Review fixes. --- ApplicationLibCode/Application/RiaApplication.h | 4 ++-- .../Commands/OsduImportCommands/RiuWellImportWizard.cpp | 6 ------ .../Commands/OsduImportCommands/RiuWellImportWizard.h | 1 - .../ProjectDataModel/WellLog/RimOsduWellLog.cpp | 7 ++----- .../ProjectDataModel/WellPath/RimWellPath.cpp | 5 +---- 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.h b/ApplicationLibCode/Application/RiaApplication.h index b0ea7facd0..b98be5cd3e 100644 --- a/ApplicationLibCode/Application/RiaApplication.h +++ b/ApplicationLibCode/Application/RiaApplication.h @@ -257,6 +257,6 @@ class RiaApplication bool m_runningWorkerProcess; private: - static RiaApplication* s_riaApplication; - RiaOsduConnector* m_osduConnector; + static RiaApplication* s_riaApplication; + QPointer m_osduConnector; }; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index a2752a5de6..e30f28ff33 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -265,12 +265,6 @@ FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOs layout->addWidget( m_tableView ); layout->setStretchFactor( m_tableView, 10 ); - // Tree view - // caf::PdmUiTreeView* treeView = new caf::PdmUiTreeView( this ); - // treeView->setPdmItem( wellPathImport ); - // layout->addWidget( treeView ); - // layout->setStretchFactor( treeView, 10 ); - setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); m_osduConnector = osduConnector; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index 2dd3a44aac..b465ae7f01 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -242,7 +242,6 @@ class FieldSelectionPage : public QWizardPage FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOsduConnector* m_osduConnector, QWidget* parent = nullptr ); ~FieldSelectionPage() override; - void initializePage() override; bool isComplete() const override; private slots: void fieldsFinished(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp index 6aa942cfae..e2738a0c70 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp @@ -18,11 +18,10 @@ #include "RimOsduWellLog.h" -#include "RiaGuiApplication.h" -#include "RiaLogging.h" - #include "RiaDateStringParser.h" #include "RiaFieldHandleTools.h" +#include "RiaGuiApplication.h" +#include "RiaLogging.h" #include "RiaQDateTimeTools.h" #include "RimFileWellPath.h" @@ -33,9 +32,7 @@ #include "Riu3DMainWindowTools.h" -#include #include -#include CAF_PDM_SOURCE_INIT( RimOsduWellLog, "OsduWellLog" ); diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp index 4cb1edb3c4..eebe7d8d17 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp @@ -163,10 +163,7 @@ RimWellPath::RimWellPath() //-------------------------------------------------------------------------------------------------- RimWellPath::~RimWellPath() { - for ( const auto& wellLog : m_wellLogs() ) - { - delete wellLog; - } + m_wellLogs.deleteChildren(); RimWellLogPlotCollection* plotCollection = RimMainPlotCollection::current()->wellLogPlotCollection(); if ( plotCollection ) From 71929a234af9c68827f206bac9e7ffd540da77df Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 14 Jun 2024 15:33:53 +0200 Subject: [PATCH 138/332] Refactor: Extract arrow tools. --- .../FileInterface/CMakeLists_files.cmake | 2 + .../FileInterface/RifArrowTools.cpp | 63 +++++++++++++++++++ .../FileInterface/RifArrowTools.h | 34 ++++++++++ .../FileInterface/RifOsduWellLogReader.cpp | 36 +---------- .../FileInterface/RifOsduWellPathReader.cpp | 35 +---------- 5 files changed, 104 insertions(+), 66 deletions(-) create mode 100644 ApplicationLibCode/FileInterface/RifArrowTools.cpp create mode 100644 ApplicationLibCode/FileInterface/RifArrowTools.h diff --git a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake index 1ddbe67fa3..71155c2019 100644 --- a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake @@ -99,6 +99,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellPathReader.h ${CMAKE_CURRENT_LIST_DIR}/RifAsciiDataParseOptions.h ${CMAKE_CURRENT_LIST_DIR}/RifByteArrayArrowRandomAccessFile.h + ${CMAKE_CURRENT_LIST_DIR}/RifArrowTools.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -197,6 +198,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellPathReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellLogReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifByteArrayArrowRandomAccessFile.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifArrowTools.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/FileInterface/RifArrowTools.cpp b/ApplicationLibCode/FileInterface/RifArrowTools.cpp new file mode 100644 index 0000000000..3b459fcf16 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifArrowTools.cpp @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RifArrowTools.h" + +#include "cafAssert.h" + +#include + +// #include +// #include +// #include +// #include +// #include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifArrowTools::convertChunkedArrayToStdVector( const std::shared_ptr& column ) +{ + auto convertChunkToVector = []( const std::shared_ptr& array ) -> std::vector + { + std::vector result; + + auto double_array = std::static_pointer_cast( array ); + result.resize( double_array->length() ); + for ( int64_t i = 0; i < double_array->length(); ++i ) + { + result[i] = double_array->Value( i ); + } + + return result; + }; + + CAF_ASSERT( column->type()->id() == arrow::Type::DOUBLE ); + + std::vector result; + + // Iterate over each chunk in the column + for ( int i = 0; i < column->num_chunks(); ++i ) + { + std::shared_ptr chunk = column->chunk( i ); + std::vector chunk_vector = convertChunkToVector( chunk ); + result.insert( result.end(), chunk_vector.begin(), chunk_vector.end() ); + } + + return result; +}; diff --git a/ApplicationLibCode/FileInterface/RifArrowTools.h b/ApplicationLibCode/FileInterface/RifArrowTools.h new file mode 100644 index 0000000000..a671675834 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifArrowTools.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 + +#include +#include + +//================================================================================================== +// +// +//================================================================================================== +class RifArrowTools +{ +public: + static std::vector convertChunkedArrayToStdVector( const std::shared_ptr& column ); +}; diff --git a/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp index 70a6e033b3..52d6218b2a 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp +++ b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp @@ -25,6 +25,8 @@ #include #include +#include "RifArrowTools.h" + #include #include #include @@ -36,38 +38,6 @@ //-------------------------------------------------------------------------------------------------- std::pair, QString> RifOsduWellLogReader::readWellLogData( const QByteArray& contents ) { - // Function to convert an entire column to std::vector - auto convertColumnToVector = []( const std::shared_ptr& column ) -> std::vector - { - auto convertChunkToVector = []( const std::shared_ptr& array ) -> std::vector - { - std::vector result; - - auto double_array = std::static_pointer_cast( array ); - result.resize( double_array->length() ); - for ( int64_t i = 0; i < double_array->length(); ++i ) - { - result[i] = double_array->Value( i ); - } - - return result; - }; - - CAF_ASSERT( column->type()->id() == arrow::Type::DOUBLE ); - - std::vector result; - - // Iterate over each chunk in the column - for ( int i = 0; i < column->num_chunks(); ++i ) - { - std::shared_ptr chunk = column->chunk( i ); - std::vector chunk_vector = convertChunkToVector( chunk ); - result.insert( result.end(), chunk_vector.begin(), chunk_vector.end() ); - } - - return result; - }; - arrow::MemoryPool* pool = arrow::default_memory_pool(); std::shared_ptr input = std::make_shared( contents ); @@ -93,7 +63,7 @@ std::pair, QString> RifOsduWellLogReader::readWellL if ( column->type()->id() == arrow::Type::DOUBLE ) { - std::vector columnVector = convertColumnToVector( column ); + std::vector columnVector = RifArrowTools::convertChunkedArrayToStdVector( column ); logData->setValues( QString::fromStdString( columnName ), columnVector ); } } diff --git a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp index 7965767c44..d1000e246c 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp +++ b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp @@ -28,6 +28,7 @@ #include "RiaLogging.h" #include "RiaTextStringTools.h" +#include "RifArrowTools.h" #include "RifAsciiDataParseOptions.h" #include "RifByteArrayArrowRandomAccessFile.h" #include "RifCsvUserDataParser.h" @@ -107,38 +108,6 @@ std::pair, QString> RifOsduWellPathReader::parseCsv( const //-------------------------------------------------------------------------------------------------- std::pair, QString> RifOsduWellPathReader::readWellPathData( const QByteArray& content ) { - // Function to convert an entire column to std::vector - auto convertColumnToVector = []( const std::shared_ptr& column ) -> std::vector - { - auto convertChunkToVector = []( const std::shared_ptr& array ) -> std::vector - { - std::vector result; - - auto double_array = std::static_pointer_cast( array ); - result.resize( double_array->length() ); - for ( int64_t i = 0; i < double_array->length(); ++i ) - { - result[i] = double_array->Value( i ); - } - - return result; - }; - - CAF_ASSERT( column->type()->id() == arrow::Type::DOUBLE ); - - std::vector result; - - // Iterate over each chunk in the column - for ( int i = 0; i < column->num_chunks(); ++i ) - { - std::shared_ptr chunk = column->chunk( i ); - std::vector chunk_vector = convertChunkToVector( chunk ); - result.insert( result.end(), chunk_vector.begin(), chunk_vector.end() ); - } - - return result; - }; - arrow::MemoryPool* pool = arrow::default_memory_pool(); std::shared_ptr input = std::make_shared( content ); @@ -172,7 +141,7 @@ std::pair, QString> RifOsduWellPathReader::readWellPathDat if ( column->type()->id() == arrow::Type::DOUBLE ) { - std::vector columnVector = convertColumnToVector( column ); + std::vector columnVector = RifArrowTools::convertChunkedArrayToStdVector( column ); RiaLogging::debug( QString( "Column name: %1. Size: %2" ).arg( QString::fromStdString( columnName ) ).arg( columnVector.size() ) ); readValues[columnName] = columnVector; } From 2a8c69bc4966fc07ea27a7f2f5e829e56ffb046d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 17 Jun 2024 13:02:02 +0200 Subject: [PATCH 139/332] Install arrow and parquet DLLs --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e941b2c0e2..57c1ee4278 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -690,6 +690,7 @@ if(MSVC) endforeach(HDF5_DLL_NAME) endif() + else() # Linux @@ -1016,6 +1017,14 @@ install(TARGETS extract-projectfile-versions DESTINATION ${RESINSIGHT_INSTALL_FOLDER} ) +if (TARGET Arrow::arrow_shared) + install(IMPORTED_RUNTIME_ARTIFACTS Arrow::arrow_shared RUNTIME DESTINATION ${RESINSIGHT_INSTALL_FOLDER}) +endif() + +if (TARGET Parquet::parquet_shared) + install(IMPORTED_RUNTIME_ARTIFACTS Parquet::parquet_shared RUNTIME DESTINATION ${RESINSIGHT_INSTALL_FOLDER}) +endif() + # ############################################################################## # Visual Studio : Create the ruleset file to be used by Static Code Analysis # https://stackoverflow.com/questions/75031903/how-to-enable-static-analysis-with-custom-ruleset-in-msvc-via-cmakelists-txt From 7d50b5162eb43c39a51a20336a2c8b249e433bf3 Mon Sep 17 00:00:00 2001 From: magnesj <1793152+magnesj@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:02:41 +0000 Subject: [PATCH 140/332] Fixes by cmake-format --- CMakeLists.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57c1ee4278..3d874f5e68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -690,7 +690,6 @@ if(MSVC) endforeach(HDF5_DLL_NAME) endif() - else() # Linux @@ -1017,12 +1016,16 @@ install(TARGETS extract-projectfile-versions DESTINATION ${RESINSIGHT_INSTALL_FOLDER} ) -if (TARGET Arrow::arrow_shared) - install(IMPORTED_RUNTIME_ARTIFACTS Arrow::arrow_shared RUNTIME DESTINATION ${RESINSIGHT_INSTALL_FOLDER}) +if(TARGET Arrow::arrow_shared) + install(IMPORTED_RUNTIME_ARTIFACTS Arrow::arrow_shared RUNTIME DESTINATION + ${RESINSIGHT_INSTALL_FOLDER} + ) endif() -if (TARGET Parquet::parquet_shared) - install(IMPORTED_RUNTIME_ARTIFACTS Parquet::parquet_shared RUNTIME DESTINATION ${RESINSIGHT_INSTALL_FOLDER}) +if(TARGET Parquet::parquet_shared) + install(IMPORTED_RUNTIME_ARTIFACTS Parquet::parquet_shared RUNTIME + DESTINATION ${RESINSIGHT_INSTALL_FOLDER} + ) endif() # ############################################################################## From a862f4eca02c14295f05d117a72733a929843909 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 17 Jun 2024 18:33:28 +0200 Subject: [PATCH 141/332] Use cmake to find and install runtime dependencies --- CMakeLists.txt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d874f5e68..d2eace58f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1016,17 +1016,16 @@ install(TARGETS extract-projectfile-versions DESTINATION ${RESINSIGHT_INSTALL_FOLDER} ) -if(TARGET Arrow::arrow_shared) - install(IMPORTED_RUNTIME_ARTIFACTS Arrow::arrow_shared RUNTIME DESTINATION - ${RESINSIGHT_INSTALL_FOLDER} - ) -endif() - -if(TARGET Parquet::parquet_shared) - install(IMPORTED_RUNTIME_ARTIFACTS Parquet::parquet_shared RUNTIME - DESTINATION ${RESINSIGHT_INSTALL_FOLDER} +if(MSVC) + # Install all the DLLs needed for the executable. System dependencies are not + # included + install( + TARGETS ResInsight + DESTINATION ${RESINSIGHT_INSTALL_FOLDER} + RUNTIME_DEPENDENCIES PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" + POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" ) -endif() +endif(MSVC) # ############################################################################## # Visual Studio : Create the ruleset file to be used by Static Code Analysis From 33466f5d842971807690d916b447585da8889ab5 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 17 Jun 2024 22:21:32 +0200 Subject: [PATCH 142/332] 11498 osdu well multiselect (#11505) * #11498 OSDU well path multi-select. * Janitor: modernize foreach loops --- .../OsduImportCommands/RiaOsduConnector.cpp | 38 +++++-- .../OsduImportCommands/RiaOsduConnector.h | 6 +- .../RicWellPathsImportOsduFeature.cpp | 6 + .../RiuWellImportWizard.cpp | 105 ++++++++++++++---- .../OsduImportCommands/RiuWellImportWizard.h | 21 ++-- 5 files changed, 136 insertions(+), 40 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index 9030451a4a..a4c2d4c89d 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -103,6 +103,20 @@ RiaOsduConnector::~RiaOsduConnector() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::clearCachedData() +{ + QMutexLocker lock( &m_mutex ); + m_fields.clear(); + m_wells.clear(); + m_wellbores.clear(); + m_wellboreTrajectories.clear(); + m_wellLogs.clear(); + m_parquetData.clear(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -374,7 +388,7 @@ void RiaOsduConnector::parseFields( QNetworkReply* reply ) QMutexLocker lock( &m_mutex ); m_fields.clear(); - foreach ( const QJsonValue& value, resultsArray ) + for ( const QJsonValue& value : resultsArray ) { QJsonObject resultObj = value.toObject(); @@ -406,7 +420,7 @@ void RiaOsduConnector::parseWells( QNetworkReply* reply ) { QMutexLocker lock( &m_mutex ); m_wells.clear(); - foreach ( const QJsonValue& value, resultsArray ) + for ( const QJsonValue& value : resultsArray ) { QJsonObject resultObj = value.toObject(); QString id = resultObj["id"].toString(); @@ -437,7 +451,7 @@ void RiaOsduConnector::parseWellbores( QNetworkReply* reply, const QString& well { QMutexLocker lock( &m_mutex ); m_wellbores[wellId].clear(); - foreach ( const QJsonValue& value, resultsArray ) + for ( const QJsonValue& value : resultsArray ) { QJsonObject resultObj = value.toObject(); QString id = resultObj["id"].toString(); @@ -449,6 +463,10 @@ void RiaOsduConnector::parseWellbores( QNetworkReply* reply, const QString& well emit wellboresFinished( wellId ); } + else + { + RiaLogging::error( "Failed to download well with id " + wellId + ": " + reply->errorString() ); + } } //-------------------------------------------------------------------------------------------------- @@ -467,8 +485,8 @@ void RiaOsduConnector::parseWellTrajectory( QNetworkReply* reply, const QString& { QMutexLocker lock( &m_mutex ); - m_wellboreTrajectories.clear(); - foreach ( const QJsonValue& value, resultsArray ) + m_wellboreTrajectories[wellboreId].clear(); + for ( const QJsonValue& value : resultsArray ) { QJsonObject resultObj = value.toObject(); QString id = resultObj["id"].toString(); @@ -478,7 +496,11 @@ void RiaOsduConnector::parseWellTrajectory( QNetworkReply* reply, const QString& } } - emit wellboreTrajectoryFinished( wellboreId ); + emit wellboreTrajectoryFinished( wellboreId, resultsArray.size(), "" ); + } + else + { + emit wellboreTrajectoryFinished( wellboreId, 0, "Failed to download: " + reply->errorString() ); } } @@ -498,8 +520,8 @@ void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellb { QMutexLocker lock( &m_mutex ); - m_wellLogs.clear(); - foreach ( const QJsonValue& value, resultsArray ) + m_wellLogs[wellboreId].clear(); + for ( const QJsonValue& value : resultsArray ) { QJsonObject resultObj = value.toObject(); QString id = resultObj["id"].toString(); diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h index 1846160ffe..98a19de628 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -58,7 +58,6 @@ class RiaOsduConnector : public QObject const QString& clientId ); ~RiaOsduConnector() override; - void requestFieldsByName( const QString& token, const QString& fieldName ); void requestFieldsByName( const QString& fieldName ); void requestWellsByFieldId( const QString& fieldId ); void requestWellboresByWellId( const QString& wellId ); @@ -71,6 +70,8 @@ class RiaOsduConnector : public QObject QString wellIdForWellboreId( const QString& wellboreId ) const; + void clearCachedData(); + QString server() const; QString dataPartition() const; @@ -96,7 +97,7 @@ public slots: void fieldsFinished(); void wellsFinished(); void wellboresFinished( const QString& wellId ); - void wellboreTrajectoryFinished( const QString& wellboreId ); + void wellboreTrajectoryFinished( const QString& wellboreId, int numTrajectories, const QString& errorMessage ); void wellLogsFinished( const QString& wellboreId ); void tokenReady( const QString& token ); @@ -112,6 +113,7 @@ public slots: QNetworkReply* makeDownloadRequest( const QString& url, const QString& dataPartitionId, const QString& token, const QString& contentType ); + void requestFieldsByName( const QString& token, const QString& fieldName ); void requestFieldsByName( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldName ); void requestWellsByFieldId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldId ); void requestWellboresByWellId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellId ); diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index 8b4cbbf1ce..88bec7c83a 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -38,6 +38,8 @@ #include "RiuMainWindow.h" #include "RiuWellImportWizard.h" +#include "cafProgressInfo.h" + #include "cvfObject.h" #include @@ -81,8 +83,12 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) if ( QDialog::Accepted == wellImportwizard.exec() ) { std::vector importedWells = wellImportwizard.importedWells(); + + caf::ProgressInfo progress( importedWells.size(), "Importing wells from OSDU" ); for ( auto w : importedWells ) { + auto task = progress.task( QString( "Importing well: %1" ).arg( w.name ) ); + auto [wellPathGeometry, errorMessage] = RimWellPathCollection::loadWellPathGeometryFromOsdu( osduConnector, w.wellboreTrajectoryId ); if ( wellPathGeometry.notNull() ) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index e30f28ff33..794900b3ef 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -106,6 +106,7 @@ void RiuWellImportWizard::slotAuthenticationRequired( QNetworkReply* networkRepl //-------------------------------------------------------------------------------------------------- void RiuWellImportWizard::downloadWells( const QString& fieldId ) { + m_osduConnector->clearCachedData(); m_osduConnector->requestWellsByFieldId( fieldId ); } @@ -145,17 +146,17 @@ QString RiuWellImportWizard::selectedFieldId() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::setSelectedWellboreId( const QString& wellboreId ) +void RiuWellImportWizard::setSelectedWellboreIds( const std::vector& wellboreIds ) { - m_selectedWellboreId = wellboreId; + m_selectedWellboreIds = wellboreIds; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiuWellImportWizard::selectedWellboreId() const +std::vector RiuWellImportWizard::selectedWellboreIds() const { - return m_selectedWellboreId; + return m_selectedWellboreIds; } //-------------------------------------------------------------------------------------------------- @@ -355,6 +356,7 @@ WellSelectionPage::WellSelectionPage( RimWellPathImport* wellPathImport, RiaOsdu m_tableView = new QTableView( this ); m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows ); + m_tableView->setSelectionMode( QAbstractItemView::MultiSelection ); QHeaderView* header = m_tableView->horizontalHeader(); header->setSectionResizeMode( QHeaderView::Interactive ); header->setStretchLastSection( true ); @@ -427,7 +429,7 @@ void WellSelectionPage::wellboresFinished( const QString& wellId ) bool WellSelectionPage::isComplete() const { QItemSelectionModel* select = m_tableView->selectionModel(); - return select->selectedRows().size() == 1; + return !select->selectedRows().empty(); } //-------------------------------------------------------------------------------------------------- @@ -437,11 +439,21 @@ void WellSelectionPage::selectWellbore( const QItemSelection& newSelection, cons { if ( !newSelection.indexes().empty() ) { - QModelIndex index = newSelection.indexes()[0]; - int column = 0; - QString wellboreId = m_osduWellboresModel->data( index.siblingAtColumn( column ) ).toString(); - RiuWellImportWizard* wiz = dynamic_cast( wizard() ); - wiz->setSelectedWellboreId( wellboreId ); + std::vector wellboreIds; + QModelIndexList selection = m_tableView->selectionModel()->selectedRows(); + for ( QModelIndex index : selection ) + { + int idColumn = 0; + + if ( index.column() == idColumn ) + { + QString wellboreId = m_osduWellboresModel->data( index.siblingAtColumn( idColumn ) ).toString(); + wellboreIds.push_back( wellboreId ); + } + } + + RiuWellImportWizard* wiz = dynamic_cast( wizard() ); + wiz->setSelectedWellboreIds( wellboreIds ); } } @@ -464,7 +476,9 @@ WellSummaryPage::WellSummaryPage( RimWellPathImport* wellPathImport, RiaOsduConn setButtonText( QWizard::FinishButton, "Import" ); - connect( m_osduConnector, SIGNAL( wellboreTrajectoryFinished( const QString& ) ), SLOT( wellboreTrajectoryFinished( const QString& ) ) ); + connect( m_osduConnector, + SIGNAL( wellboreTrajectoryFinished( const QString&, int, const QString& ) ), + SLOT( wellboreTrajectoryFinished( const QString&, int, const QString& ) ) ); } //-------------------------------------------------------------------------------------------------- @@ -474,18 +488,36 @@ void WellSummaryPage::initializePage() { RiuWellImportWizard* wiz = dynamic_cast( wizard() ); - QString wellboreId = wiz->selectedWellboreId(); - wiz->downloadWellPaths( wellboreId ); + QMutexLocker lock( &m_mutex ); + m_pendingWellboreIds.clear(); + for ( const QString& wellboreId : wiz->selectedWellboreIds() ) + { + m_pendingWellboreIds.insert( wellboreId ); + } + + for ( const QString& wellboreId : wiz->selectedWellboreIds() ) + { + wiz->downloadWellPaths( wellboreId ); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void WellSummaryPage::wellboreTrajectoryFinished( const QString& wellboreId ) +void WellSummaryPage::wellboreTrajectoryFinished( const QString& wellboreId, int numTrajectories, const QString& errorMessage ) { std::vector wellboreTrajectories = m_osduConnector->wellboreTrajectories( wellboreId ); std::vector wells = m_osduConnector->wells(); + auto findWellboreById = []( const std::vector& wellbores, const QString& wellboreId ) -> std::optional + { + auto it = std::find_if( wellbores.begin(), wellbores.end(), [wellboreId]( const OsduWellbore& w ) { return w.id == wellboreId; } ); + if ( it != wellbores.end() ) + return std::optional( *it ); + else + return {}; + }; + auto findWellForWellId = []( const std::vector& wells, const QString& wellId ) -> std::optional { auto it = std::find_if( wells.begin(), wells.end(), [wellId]( const OsduWell& w ) { return w.id == wellId; } ); @@ -497,18 +529,47 @@ void WellSummaryPage::wellboreTrajectoryFinished( const QString& wellboreId ) RiuWellImportWizard* wiz = dynamic_cast( wizard() ); - for ( auto w : wellboreTrajectories ) { - QString wellId = m_osduConnector->wellIdForWellboreId( w.wellboreId ); + QMutexLocker lock( &m_mutex ); + + QString wellId = m_osduConnector->wellIdForWellboreId( wellboreId ); std::optional well = findWellForWellId( wells, wellId ); - if ( well.has_value() ) + std::vector wellbores = m_osduConnector->wellbores( wellId ); + std::optional wellbore = findWellboreById( wellbores, wellboreId ); + + if ( well.has_value() && wellbore.has_value() ) { - QString wellboreTrajectoryId = w.id; - wiz->addWellInfo( { .name = well.value().name, - .wellId = well.value().id, - .wellboreId = w.wellboreId, - .wellboreTrajectoryId = wellboreTrajectoryId } ); + if ( !errorMessage.isEmpty() ) + { + m_textEdit->append( QString( "Wellbore '%1' download failed: %2." ).arg( wellbore.value().name ).arg( errorMessage ) ); + } + else if ( numTrajectories == 0 ) + { + m_textEdit->append( QString( "Wellbore '%1': No trajectory found." ).arg( wellbore.value().name ) ); + } + + for ( auto w : wellboreTrajectories ) + { + QString wellboreTrajectoryId = w.id; + wiz->addWellInfo( { .name = wellbore.value().name, + .wellId = well.value().id, + .wellboreId = w.wellboreId, + .wellboreTrajectoryId = wellboreTrajectoryId } ); + } } + + m_pendingWellboreIds.erase( wellboreId ); } + + emit( completeChanged() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool WellSummaryPage::isComplete() const +{ + QMutexLocker lock( &m_mutex ); + return m_pendingWellboreIds.empty(); } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index b465ae7f01..c3adeae7cb 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -28,6 +28,8 @@ #include "RiaOsduConnector.h" +#include + class QFile; class QLabel; class QTextEdit; @@ -296,14 +298,17 @@ class WellSummaryPage : public QWizardPage WellSummaryPage( RimWellPathImport* wellPathImport, RiaOsduConnector* osduConnector, QWidget* parent = nullptr ); void initializePage() override; + bool isComplete() const override; private slots: - void wellboreTrajectoryFinished( const QString& wellId ); + void wellboreTrajectoryFinished( const QString& wellboreId, int numTrajectories, const QString& errorMessage ); private: RimWellPathImport* m_wellPathImportObject; RiaOsduConnector* m_osduConnector; QTextEdit* m_textEdit; + std::set m_pendingWellboreIds; + mutable QMutex m_mutex; }; //-------------------------------------------------------------------------------------------------- @@ -331,10 +336,10 @@ class RiuWellImportWizard : public QWizard // Methods used from the wizard pages void resetAuthenticationCount(); - void setSelectedFieldId( const QString& fieldId ); - QString selectedFieldId() const; - void setSelectedWellboreId( const QString& wellboreId ); - QString selectedWellboreId() const; + void setSelectedFieldId( const QString& fieldId ); + QString selectedFieldId() const; + void setSelectedWellboreIds( const std::vector& wellboreIds ); + std::vector selectedWellboreIds() const; void addWellInfo( RiuWellImportWizard::WellInfo wellInfo ); std::vector importedWells() const; @@ -347,9 +352,9 @@ public slots: void slotAuthenticationRequired( QNetworkReply* networkReply, QAuthenticator* authenticator ); private: - RiaOsduConnector* m_osduConnector; - QString m_selectedFieldId; - QString m_selectedWellboreId; + RiaOsduConnector* m_osduConnector; + QString m_selectedFieldId; + std::vector m_selectedWellboreIds; QString m_destinationFolder; From 81eca2c89395003fcb3353d2752c3d479489ef95 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 17 Jun 2024 14:15:31 +0200 Subject: [PATCH 143/332] #11497 3D Well Log: show 3d well logs for OSDU log too. --- .../WellLog/Rim3dWellLogFileCurve.cpp | 58 ++++++++----------- .../WellLog/Rim3dWellLogFileCurve.h | 3 +- 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp index 804b7b497f..0b9257c08d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp @@ -45,7 +45,7 @@ Rim3dWellLogFileCurve::Rim3dWellLogFileCurve() CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "CurveWellLogChannel", "Well Log Channel" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogFile, "WellLogFile", "Well Log File" ); + CAF_PDM_InitFieldNoDefault( &m_wellLog, "WellLogFile", "Well Log" ); CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "" ); m_nameConfig = new RimWellLogLasFileCurveNameConfig(); @@ -65,18 +65,17 @@ void Rim3dWellLogFileCurve::setDefaultFileCurveDataInfo() { auto wellPath = firstAncestorOrThisOfType(); - if ( wellPath && !wellPath->wellLogFiles().empty() ) + if ( wellPath && !wellPath->wellLogs().empty() ) { - m_wellLogFile = wellPath->wellLogFiles()[0]; + m_wellLog = wellPath->wellLogs()[0]; } - if ( m_wellLogFile ) + if ( m_wellLog ) { - std::vector fileLogs = m_wellLogFile->wellLogChannels(); - - if ( !fileLogs.empty() ) + std::vector wellLogChannels = m_wellLog->wellLogChannels(); + if ( !wellLogChannels.empty() ) { - m_wellLogChannelName = fileLogs[0]->name(); + m_wellLogChannelName = wellLogChannels[0]->name(); } } } @@ -89,13 +88,13 @@ void Rim3dWellLogFileCurve::curveValuesAndMds( std::vector* values, std: CAF_ASSERT( values != nullptr ); CAF_ASSERT( measuredDepthValues != nullptr ); - if ( m_wellLogFile ) + if ( m_wellLog ) { - RigWellLogData* wellLogFile = m_wellLogFile->wellLogData(); - if ( wellLogFile ) + RigWellLogData* wellLogData = m_wellLog->wellLogData(); + if ( wellLogData ) { - *values = wellLogFile->values( m_wellLogChannelName ); - *measuredDepthValues = wellLogFile->depthValues(); + *values = wellLogData->values( m_wellLogChannelName ); + *measuredDepthValues = wellLogData->depthValues(); } } } @@ -137,9 +136,8 @@ QString Rim3dWellLogFileCurve::createAutoName() const channelNameAvailable = true; } - RigWellLogData* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogData() : nullptr; - - if ( wellLogFile ) + RigWellLogData* wellLogData = m_wellLog ? m_wellLog->wellLogData() : nullptr; + if ( wellLogData ) { if ( channelNameAvailable ) { @@ -155,7 +153,7 @@ QString Rim3dWellLogFileCurve::createAutoName() const } */ } - QString date = m_wellLogFile->date().toString( RiaQDateTimeTools::dateFormatString() ); + QString date = m_wellLog->date().toString( RiaQDateTimeTools::dateFormatString() ); if ( !date.isEmpty() ) { name.push_back( date ); @@ -181,7 +179,7 @@ caf::PdmFieldHandle* Rim3dWellLogFileCurve::userDescriptionField() //-------------------------------------------------------------------------------------------------- void Rim3dWellLogFileCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { - if ( changedField == &m_wellLogFile || changedField == &m_wellLogChannelName ) + if ( changedField == &m_wellLog || changedField == &m_wellLogChannelName ) { resetMinMaxValues(); updateConnectedEditors(); @@ -194,21 +192,16 @@ void Rim3dWellLogFileCurve::fieldChangedByUi( const caf::PdmFieldHandle* changed //-------------------------------------------------------------------------------------------------- QList Rim3dWellLogFileCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options; - - options = Rim3dWellLogCurve::calculateValueOptions( fieldNeedingOptions ); - + QList options = Rim3dWellLogCurve::calculateValueOptions( fieldNeedingOptions ); if ( !options.empty() ) return options; if ( fieldNeedingOptions == &m_wellLogChannelName ) { - if ( m_wellLogFile ) + if ( m_wellLog ) { - std::vector fileLogs = m_wellLogFile->wellLogChannels(); - - for ( size_t i = 0; i < fileLogs.size(); i++ ) + for ( RimWellLogChannel* wellLogChannel : m_wellLog->wellLogChannels() ) { - QString wellLogChannelName = fileLogs[i]->name(); + QString wellLogChannelName = wellLogChannel->name(); options.push_back( caf::PdmOptionItemInfo( wellLogChannelName, wellLogChannelName ) ); } } @@ -219,16 +212,15 @@ QList Rim3dWellLogFileCurve::calculateValueOptions( cons } } - if ( fieldNeedingOptions == &m_wellLogFile ) + if ( fieldNeedingOptions == &m_wellLog ) { auto wellPath = firstAncestorOrThisOfType(); - if ( wellPath && !wellPath->wellLogFiles().empty() ) + if ( wellPath ) { - for ( RimWellLogFile* const wellLogFile : wellPath->wellLogFiles() ) + for ( RimWellLog* const wellLog : wellPath->wellLogs() ) { - QFileInfo fileInfo( wellLogFile->fileName() ); - options.push_back( caf::PdmOptionItemInfo( fileInfo.baseName(), wellLogFile ) ); + options.push_back( caf::PdmOptionItemInfo( wellLog->name(), wellLog ) ); } } } @@ -242,7 +234,7 @@ QList Rim3dWellLogFileCurve::calculateValueOptions( cons void Rim3dWellLogFileCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Curve Data" ); - curveDataGroup->add( &m_wellLogFile ); + curveDataGroup->add( &m_wellLog ); curveDataGroup->add( &m_wellLogChannelName ); Rim3dWellLogCurve::configurationUiOrdering( uiOrdering ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.h index e4adbb1be6..4eac9f7eff 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.h @@ -24,6 +24,7 @@ #include "cafPdmField.h" #include "cafPdmPtrField.h" +class RimWellLog; class RimWellLogFile; class RimWellLogLasFileCurveNameConfig; @@ -55,7 +56,7 @@ class Rim3dWellLogFileCurve : public Rim3dWellLogCurve void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; private: - caf::PdmPtrField m_wellLogFile; + caf::PdmPtrField m_wellLog; caf::PdmField m_wellLogChannelName; caf::PdmChildField m_nameConfig; }; From 80f269715b2e1ae53ceddea8a9f5ea04e28eb865 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 17 Jun 2024 14:37:57 +0200 Subject: [PATCH 144/332] Refactor: register keyword aliases for WellLogFile. --- .../ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp | 3 ++- .../ProjectDataModel/WellLog/RimOsduWellLog.cpp | 6 +++--- .../ProjectDataModel/WellLog/RimWellLog.cpp | 8 +++++--- ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h | 2 +- .../ProjectDataModel/WellLog/RimWellLogChannel.cpp | 4 ++-- .../ProjectDataModel/WellLog/RimWellLogCsvFile.cpp | 6 +++--- .../ProjectDataModel/WellLog/RimWellLogLasFile.cpp | 6 +++--- .../ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp | 3 ++- .../ProjectDataModel/WellPath/RimWellPath.cpp | 3 ++- 9 files changed, 23 insertions(+), 18 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp index 0b9257c08d..b82819472c 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp @@ -45,7 +45,8 @@ Rim3dWellLogFileCurve::Rim3dWellLogFileCurve() CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "CurveWellLogChannel", "Well Log Channel" ); - CAF_PDM_InitFieldNoDefault( &m_wellLog, "WellLogFile", "Well Log" ); + CAF_PDM_InitFieldNoDefault( &m_wellLog, "WellLog", "Well Log" ); + m_wellLog.registerKeywordAlias( "WellLogFile" ); CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "" ); m_nameConfig = new RimWellLogLasFileCurveNameConfig(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp index e2738a0c70..feb3b5f44d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp @@ -57,7 +57,7 @@ RimOsduWellLog::RimOsduWellLog() //-------------------------------------------------------------------------------------------------- RimOsduWellLog::~RimOsduWellLog() { - m_wellLogChannelNames.deleteChildren(); + m_wellLogChannels.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -153,13 +153,13 @@ void RimOsduWellLog::setWellLogData( RigOsduWellLogData* wellLogData ) { m_wellLogData = wellLogData; - m_wellLogChannelNames.deleteChildren(); + m_wellLogChannels.deleteChildren(); for ( const QString& wellLogName : wellLogData->wellLogChannelNames() ) { RimWellLogChannel* wellLog = new RimWellLogChannel(); wellLog->setName( wellLogName ); - m_wellLogChannelNames.push_back( wellLog ); + m_wellLogChannels.push_back( wellLog ); } } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp index 8340a6371a..82b4d75aab 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp @@ -45,8 +45,10 @@ RimWellLog::RimWellLog() CAF_PDM_InitFieldNoDefault( &m_date, "Date", "Date" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogChannelNames, "WellLogFileChannels", "" ); - RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_wellLogChannelNames ); + CAF_PDM_InitFieldNoDefault( &m_wellLogChannels, "WellLogChannels", "" ); + m_wellLogChannels.registerKeywordAlias( "WellLogFileChannels" ); + + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_wellLogChannels ); } //-------------------------------------------------------------------------------------------------- @@ -54,7 +56,7 @@ RimWellLog::RimWellLog() //-------------------------------------------------------------------------------------------------- std::vector RimWellLog::wellLogChannels() const { - return m_wellLogChannelNames.childrenByType(); + return m_wellLogChannels.childrenByType(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h index 0a899326a6..50e570d744 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h @@ -58,6 +58,6 @@ class RimWellLog : public caf::PdmObject void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - caf::PdmChildArrayField m_wellLogChannelNames; + caf::PdmChildArrayField m_wellLogChannels; caf::PdmField m_date; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp index adf99714c9..05c1cf357e 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp @@ -21,14 +21,14 @@ #include "RiaFieldHandleTools.h" -CAF_PDM_SOURCE_INIT( RimWellLogChannel, "WellLogFileChannel" ); +CAF_PDM_SOURCE_INIT( RimWellLogChannel, "WellLogChannel", "WellLogFileChannel" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimWellLogChannel::RimWellLogChannel() { - CAF_PDM_InitObject( "Well Log File Channel" ); + CAF_PDM_InitObject( "Well Log Channel" ); RiaFieldHandleTools::disableWriteAndSetFieldHidden( nameField() ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp index d6324d3a5a..384bedd19c 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp @@ -56,7 +56,7 @@ RimWellLogCsvFile::RimWellLogCsvFile() //-------------------------------------------------------------------------------------------------- RimWellLogCsvFile::~RimWellLogCsvFile() { - m_wellLogChannelNames.deleteChildren(); + m_wellLogChannels.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -86,14 +86,14 @@ bool RimWellLogCsvFile::readFile( QString* errorMessage ) return false; } - m_wellLogChannelNames.deleteChildren(); + m_wellLogChannels.deleteChildren(); QStringList wellLogNames = m_wellLogDataFile->wellLogChannelNames(); for ( int logIdx = 0; logIdx < wellLogNames.size(); logIdx++ ) { RimWellLogChannel* wellLog = new RimWellLogChannel(); wellLog->setName( wellLogNames[logIdx] ); - m_wellLogChannelNames.push_back( wellLog ); + m_wellLogChannels.push_back( wellLog ); } return true; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp index 2bd2d8adbe..28655c2b37 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp @@ -87,7 +87,7 @@ RimWellLogLasFile::RimWellLogLasFile() //-------------------------------------------------------------------------------------------------- RimWellLogLasFile::~RimWellLogLasFile() { - m_wellLogChannelNames.deleteChildren(); + m_wellLogChannels.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -150,14 +150,14 @@ bool RimWellLogLasFile::readFile( QString* errorMessage ) m_date = DEFAULT_DATE_TIME; } - m_wellLogChannelNames.deleteChildren(); + m_wellLogChannels.deleteChildren(); QStringList wellLogNames = m_wellLogDataFile->wellLogChannelNames(); for ( int logIdx = 0; logIdx < wellLogNames.size(); logIdx++ ) { RimWellLogChannel* wellLog = new RimWellLogChannel(); wellLog->setName( wellLogNames[logIdx] ); - m_wellLogChannelNames.push_back( wellLog ); + m_wellLogChannels.push_back( wellLog ); } auto wellPath = firstAncestorOrThisOfType(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp index 6e1b0bc621..e421336445 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp @@ -60,7 +60,8 @@ RimWellLogLasFileCurve::RimWellLogLasFileCurve() CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "CurveWellLogChannel", "Well Log Channel" ); - CAF_PDM_InitFieldNoDefault( &m_wellLog, "WellLogFile", "Well Log File" ); + CAF_PDM_InitFieldNoDefault( &m_wellLog, "WellLog", "Well Log" ); + m_wellLog.registerKeywordAlias( "WellLogFile" ); m_wellPath = nullptr; } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp index eebe7d8d17..339d974dee 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp @@ -133,7 +133,8 @@ RimWellPath::RimWellPath() CAF_PDM_InitScriptableFieldNoDefault( &m_completionSettings, "CompletionSettings", "Completion Settings" ); m_completionSettings = new RimWellPathCompletionSettings; - CAF_PDM_InitFieldNoDefault( &m_wellLogs, "WellLogFiles", "Well Logs" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogs, "WellLogs", "Well Logs" ); + m_wellLogs.registerKeywordAlias( "WellLogFiles" ); CAF_PDM_InitFieldNoDefault( &m_3dWellLogCurves, "CollectionOf3dWellLogCurves", "3D Track" ); m_3dWellLogCurves = new Rim3dWellLogCurveCollection; From acb76061eedfecbf0273cc953b5e8e0f03be4087 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Tue, 18 Jun 2024 09:27:34 +0200 Subject: [PATCH 145/332] #11496 OSDU well path import: add sorting and filter of wells. --- .../RiuWellImportWizard.cpp | 28 +++++++++++- .../OsduImportCommands/RiuWellImportWizard.h | 45 +++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index 794900b3ef..14604fb167 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -263,6 +263,10 @@ FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOs m_osduFieldsModel = new OsduFieldTableModel; m_tableView->setModel( m_osduFieldsModel ); + m_tableView->setSortingEnabled( true ); + int nameColumn = 2; + m_tableView->sortByColumn( nameColumn, Qt::AscendingOrder ); + layout->addWidget( m_tableView ); layout->setStretchFactor( m_tableView, 10 ); @@ -354,18 +358,38 @@ WellSelectionPage::WellSelectionPage( RimWellPathImport* wellPathImport, RiaOsdu QLabel* label = new QLabel( "Select wells" ); layout->addWidget( label ); + QHBoxLayout* filterLayout = new QHBoxLayout; + filterLayout->addWidget( new QLabel( "Filter:", this ) ); + QLineEdit* filterLineEdit = new QLineEdit( this ); + filterLayout->addWidget( filterLineEdit ); + + layout->addLayout( filterLayout ); + m_tableView = new QTableView( this ); m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows ); m_tableView->setSelectionMode( QAbstractItemView::MultiSelection ); + m_tableView->setSortingEnabled( true ); + int nameColumn = 2; + m_tableView->sortByColumn( nameColumn, Qt::AscendingOrder ); + QHeaderView* header = m_tableView->horizontalHeader(); header->setSectionResizeMode( QHeaderView::Interactive ); header->setStretchLastSection( true ); m_osduWellboresModel = new OsduWellboreTableModel; - m_tableView->setModel( m_osduWellboresModel ); layout->addWidget( m_tableView ); layout->setStretchFactor( m_tableView, 10 ); + m_proxyModel = new QSortFilterProxyModel( this ); + m_proxyModel->setSourceModel( m_osduWellboresModel ); + m_proxyModel->setFilterKeyColumn( nameColumn ); + m_proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive ); + + m_tableView->setModel( m_proxyModel ); + m_tableView->setSortingEnabled( true ); + + QObject::connect( filterLineEdit, &QLineEdit::textChanged, m_proxyModel, &QSortFilterProxyModel::setFilterWildcard ); + m_wellPathImportObject = wellPathImport; m_osduConnector = osduConnector; @@ -447,7 +471,7 @@ void WellSelectionPage::selectWellbore( const QItemSelection& newSelection, cons if ( index.column() == idColumn ) { - QString wellboreId = m_osduWellboresModel->data( index.siblingAtColumn( idColumn ) ).toString(); + QString wellboreId = m_proxyModel->data( index.siblingAtColumn( idColumn ) ).toString(); wellboreIds.push_back( wellboreId ); } } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index c3adeae7cb..449bd5e840 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -120,6 +120,28 @@ class OsduFieldTableModel : public QAbstractTableModel endResetModel(); } + void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override + { + std::sort( m_osduFields.begin(), + m_osduFields.end(), + [column, order]( const OsduField& a, const OsduField& b ) + { + switch ( column ) + { + case 0: + return ( order == Qt::AscendingOrder ) ? a.id < b.id : a.id > b.id; + case 1: + return ( order == Qt::AscendingOrder ) ? a.kind < b.kind : a.kind > b.kind; + case 2: + return ( order == Qt::AscendingOrder ) ? a.name < b.name : a.name > b.name; + default: + return false; + } + } ); + emit dataChanged( index( 0, 0 ), index( rowCount() - 1, columnCount() - 1 ) ); + emit layoutChanged(); + } + private: std::vector m_osduFields; }; @@ -207,6 +229,28 @@ class OsduWellboreTableModel : public QAbstractTableModel endResetModel(); } + void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override + { + std::sort( m_osduWellbores.begin(), + m_osduWellbores.end(), + [column, order]( const OsduWellbore& a, const OsduWellbore& b ) + { + switch ( column ) + { + case 0: + return ( order == Qt::AscendingOrder ) ? a.id < b.id : a.id > b.id; + case 1: + return ( order == Qt::AscendingOrder ) ? a.kind < b.kind : a.kind > b.kind; + case 2: + return ( order == Qt::AscendingOrder ) ? a.name < b.name : a.name > b.name; + default: + return false; + } + } ); + emit dataChanged( index( 0, 0 ), index( rowCount() - 1, columnCount() - 1 ) ); + emit layoutChanged(); + } + private: std::vector m_osduWellbores; std::map> m_map; @@ -285,6 +329,7 @@ private slots: RiaOsduConnector* m_osduConnector; QTableView* m_tableView; OsduWellboreTableModel* m_osduWellboresModel; + QSortFilterProxyModel* m_proxyModel; }; //-------------------------------------------------------------------------------------------------- From 82dea49ac61bbc45e5c41a5b5b75a03b4597a494 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 18 Jun 2024 11:10:15 +0200 Subject: [PATCH 146/332] Add color legend to show curve set colors --- .../Application/Tools/RiaColorTables.cpp | 19 ++ .../Application/Tools/RiaColorTables.h | 1 + .../ProjectDataModel/RimColorLegend.cpp | 4 + .../ProjectDataModel/RimColorLegend.h | 3 + .../RimCustomVfpPlot.cpp | 269 +++++++++++++----- .../RimCustomVfpPlot.h | 30 +- 6 files changed, 239 insertions(+), 87 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/RiaColorTables.cpp b/ApplicationLibCode/Application/Tools/RiaColorTables.cpp index 8eff4780bf..b55c0a0df5 100644 --- a/ApplicationLibCode/Application/Tools/RiaColorTables.cpp +++ b/ApplicationLibCode/Application/Tools/RiaColorTables.cpp @@ -549,6 +549,25 @@ const caf::ColorTable& RiaColorTables::heatMapPaletteColors() return colorTable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::ColorTable& RiaColorTables::curveSetPaletteColors() +{ + static std::vector colors{ + cvf::Color3ub( 255, 131, 140 ), // Old pink + cvf::Color3ub( 210, 176, 112 ), // Light Brown + cvf::Color3ub( 140, 171, 238 ), // Light gray blue + cvf::Color3ub( 130, 255, 120 ), // Light green + cvf::Color3ub( 255, 64, 236 ), // Magenta + cvf::Color3ub( 101, 132, 96 ), // Dark green + }; + + static caf::ColorTable colorTable = caf::ColorTable( colors ); + + return colorTable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaColorTables.h b/ApplicationLibCode/Application/Tools/RiaColorTables.h index 297e6fa519..3574b8ae0f 100644 --- a/ApplicationLibCode/Application/Tools/RiaColorTables.h +++ b/ApplicationLibCode/Application/Tools/RiaColorTables.h @@ -63,6 +63,7 @@ class RiaColorTables static const caf::ColorTable& waterAndRockPaletteColors(); static const caf::ColorTable& correlationPaletteColors(); static const caf::ColorTable& heatMapPaletteColors(); + static const caf::ColorTable& curveSetPaletteColors(); static cvf::Color3f undefinedCellColor(); diff --git a/ApplicationLibCode/ProjectDataModel/RimColorLegend.cpp b/ApplicationLibCode/ProjectDataModel/RimColorLegend.cpp index 637ccf11d2..ef70f855c5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimColorLegend.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimColorLegend.cpp @@ -34,6 +34,7 @@ CAF_PDM_SOURCE_INIT( RimColorLegend, "ColorLegend" ); /// //-------------------------------------------------------------------------------------------------- RimColorLegend::RimColorLegend() + : changed( this ) { CAF_PDM_InitScriptableObject( "ColorLegend", ":/Legend.png" ); @@ -120,6 +121,7 @@ caf::PdmFieldHandle* RimColorLegend::userDescriptionField() //-------------------------------------------------------------------------------------------------- void RimColorLegend::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { + changed.send(); } //-------------------------------------------------------------------------------------------------- @@ -181,6 +183,8 @@ caf::IconProvider RimColorLegend::paletteIconProvider() const //-------------------------------------------------------------------------------------------------- void RimColorLegend::onColorLegendItemHasChanged() { + changed.send(); + updateConnectedEditors(); std::vector referringObjects = objectsWithReferringPtrFields(); diff --git a/ApplicationLibCode/ProjectDataModel/RimColorLegend.h b/ApplicationLibCode/ProjectDataModel/RimColorLegend.h index 49c34d2ce0..24939a0235 100644 --- a/ApplicationLibCode/ProjectDataModel/RimColorLegend.h +++ b/ApplicationLibCode/ProjectDataModel/RimColorLegend.h @@ -43,6 +43,9 @@ class RimColorLegend : public caf::PdmObject RimColorLegend(); ~RimColorLegend() override; +public: + caf::Signal<> changed; + public: void setColorLegendName( const QString& colorLegendName ); QString colorLegendName(); diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp index 7a096476ba..7a862a57df 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp @@ -27,15 +27,20 @@ #include "RigVfpTables.h" +#include "RimColorLegend.h" +#include "RimColorLegendItem.h" #include "RimPlotAxisProperties.h" #include "RimPlotCurve.h" +#include "RimRegularLegendConfig.h" #include "RimVfpDataCollection.h" #include "RimVfpDefines.h" #include "RimVfpTable.h" #include "RimVfpTableData.h" #include "Tools/RimPlotAxisTools.h" +#include "RiuAbstractLegendFrame.h" #include "RiuContextMenuLauncher.h" +#include "RiuDraggableOverlayFrame.h" #include "RiuPlotCurve.h" #include "RiuPlotCurveInfoTextProvider.h" #include "RiuPlotWidget.h" @@ -45,6 +50,7 @@ #include "RiuQwtPlotWidget.h" #include "RiuQwtPlotZoomer.h" +#include "cafColorTable.h" #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiTreeSelectionEditor.h" @@ -71,8 +77,8 @@ RimCustomVfpPlot::RimCustomVfpPlot() CAF_PDM_InitFieldNoDefault( &m_mainDataSource, "MainDataSouce", "Main VFP Data Source" ); - CAF_PDM_InitFieldNoDefault( &m_additionalDataSources, "AdditionalDataSources", "Additional Data Sources" ); - m_additionalDataSources.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + CAF_PDM_InitFieldNoDefault( &m_comparisonTables, "ComparisonTables", "Comparison Tables" ); + m_comparisonTables.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); CAF_PDM_InitFieldNoDefault( &m_curveValueOptions, "CurveValueOptions", "Curve Value Options" ); CAF_PDM_InitFieldNoDefault( &m_curveMatchingType, "CurveMatchingType", "Curve Matching Type" ); @@ -142,6 +148,17 @@ RimCustomVfpPlot::RimCustomVfpPlot() CAF_PDM_InitFieldNoDefault( &m_plotCurves, "PlotCurves", "Curves" ); m_plotCurves.uiCapability()->setUiTreeChildrenHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_colorLegend, "ColorLegend", "" ); + m_colorLegend = new RimColorLegend(); + m_colorLegend->setColorLegendName( "Curve Colors" ); + m_colorLegend->changed.connect( this, &RimCustomVfpPlot::legendColorsChanged ); + + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "" ); + m_legendConfig = new RimRegularLegendConfig(); + m_legendConfig->setMappingMode( RimRegularLegendConfig::MappingType::CATEGORY_INTEGER ); + m_legendConfig->setColorLegend( m_colorLegend ); + m_legendConfig->uiCapability()->setUiTreeHidden( true ); + m_showWindow = true; m_showPlotLegends = true; @@ -166,7 +183,7 @@ void RimCustomVfpPlot::selectDataSource( RimVfpTable* mainDataSource, const std: { m_mainDataSource = mainDataSource; - m_additionalDataSources.setValue( vfpTableData ); + m_comparisonTables.setValue( vfpTableData ); } //-------------------------------------------------------------------------------------------------- @@ -214,6 +231,27 @@ void RimCustomVfpPlot::initializeSelection() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::createDefaultColors() +{ + auto colors = RiaColorTables::curveSetPaletteColors(); + + int colorIndex = 1; + for ( auto color : colors.color3fArray() ) + { + auto* colorLegendItem = new RimColorLegendItem; + colorLegendItem->setValues( QString( "Color %1" ).arg( colorIndex ), colorIndex, color ); + + m_colorLegend->appendColorLegendItem( colorLegendItem ); + + colorIndex++; + } + + m_legendConfig->setColorLegend( m_colorLegend ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -301,7 +339,7 @@ QString RimCustomVfpPlot::asciiDataForPlotExport() const { asciiData += curveData.curveTitle( curveIdx ); - if ( !m_additionalDataSources.empty() && plotCurveIdx < m_plotCurveMetaData.size() ) + if ( !m_comparisonTables.empty() && plotCurveIdx < m_plotCurveMetaData.size() ) { auto plotCurveData = m_plotCurveMetaData[plotCurveIdx]; asciiData += QString( " (Table: %1)" ).arg( plotCurveData.tableNumber ); @@ -589,12 +627,17 @@ void RimCustomVfpPlot::onLoadDataAndUpdate() int colorIndex = 0; - std::vector tables = m_additionalDataSources.ptrReferencedObjectsByType(); + std::vector tables; tables.push_back( m_mainDataSource ); + auto comparisonTables = m_comparisonTables.ptrReferencedObjectsByType(); + std::copy( comparisonTables.begin(), comparisonTables.end(), std::back_inserter( tables ) ); m_plotData.clear(); m_plotCurveMetaData.clear(); + size_t curveSetCount = 0; + CurveNameContent curveNameContent; + for ( const auto& table : tables ) { if ( !table ) continue; @@ -615,25 +658,24 @@ void RimCustomVfpPlot::onLoadDataAndUpdate() QColor curveColor = curveColors().cycledQColor( colorIndex ); - auto symbols = curveSymbols(); - auto symbol = symbols[colorIndex % symbols.size()]; - - bool multipleCurveSets = tables.size() > 1; - CurveNameContent curveNameContent; curveNameContent.defaultName = true; - populatePlotWidgetWithPlotData( m_plotWidget, - vfpPlotData, - VfpValueSelection(), - tableNumber, - curveColor, - symbol, - multipleCurveSets, - curveNameContent ); + populatePlotWidgetWithPlotData( m_plotWidget, vfpPlotData, VfpValueSelection(), tableNumber, curveColor, curveNameContent ); colorIndex++; + + curveSetCount += 1; } else { auto valueSelections = computeValueSelectionCombinations(); + curveSetCount += valueSelections.size(); + + if ( tables.size() > 1 ) curveNameContent.tableNumber = true; + if ( m_flowRate().size() > 1 ) curveNameContent.flowRate = true; + if ( m_thp().size() > 1 ) curveNameContent.thp = true; + if ( m_artificialLiftQuantity().size() > 1 ) curveNameContent.artificialLiftQuantity = true; + if ( m_waterCut().size() > 1 ) curveNameContent.waterCut = true; + if ( m_gasLiquidRatio().size() > 1 ) curveNameContent.gasLiquidRatio = true; + for ( auto& valueSelection : valueSelections ) { valueSelection.familyValues = familyValuesForTable( table ); @@ -649,34 +691,16 @@ void RimCustomVfpPlot::onLoadDataAndUpdate() QColor curveColor = curveColors().cycledQColor( colorIndex ); - auto symbols = curveSymbols(); - auto symbol = symbols[colorIndex % symbols.size()]; - - bool multipleCurveSets = ( tables.size() > 1 || ( valueSelections.size() > 1 ) ); - - CurveNameContent curveNameContent; - if ( tables.size() > 1 ) curveNameContent.tableNumber = true; - if ( m_flowRate().size() > 1 ) curveNameContent.flowRate = true; - if ( m_thp().size() > 1 ) curveNameContent.thp = true; - if ( m_artificialLiftQuantity().size() > 1 ) curveNameContent.artificialLiftQuantity = true; - if ( m_waterCut().size() > 1 ) curveNameContent.waterCut = true; - if ( m_gasLiquidRatio().size() > 1 ) curveNameContent.gasLiquidRatio = true; - - populatePlotWidgetWithPlotData( m_plotWidget, - vfpPlotData, - valueSelection, - tableNumber, - curveColor, - symbol, - multipleCurveSets, - curveNameContent ); + populatePlotWidgetWithPlotData( m_plotWidget, vfpPlotData, valueSelection, tableNumber, curveColor, curveNameContent ); colorIndex++; } } } updatePlotTitle( - generatePlotTitle( "Custom", m_tableNumber(), m_tableType(), m_interpolatedVariable(), m_primaryVariable(), m_familyVariable() ) ); + generatePlotTitle( "", m_tableNumber(), m_tableType(), m_interpolatedVariable(), m_primaryVariable(), m_familyVariable() ) ); + + updateLegendWidget( curveSetCount, curveNameContent ); m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true ); m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true ); @@ -691,14 +715,87 @@ void RimCustomVfpPlot::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCustomVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, - const VfpPlotData& plotData, - const VfpValueSelection& valueSelection, - int tableNumber, - const QColor& color, - RiuPlotCurveSymbol::PointSymbolEnum curveSymbol, - bool multipleCurveSets, - const CurveNameContent& curveNameContent ) +void RimCustomVfpPlot::updateLegendWidget( size_t curveSetCount, CurveNameContent& curveNameContent ) +{ + if ( !m_plotWidget ) return; + + if ( !m_legendOverlayFrame ) + { + m_legendOverlayFrame = new RiuDraggableOverlayFrame( m_plotWidget->getParentForOverlay(), m_plotWidget->overlayMargins() ); + } + + if ( curveSetCount > 1 ) + { + size_t plotCurveIdx = 0; + std::vector> categories; + for ( size_t i = 0; i < curveSetCount; i++ ) + { + auto color = curveColors().cycledColor3f( i ); + + auto formatNamePart = [&]( RimVfpDefines::ProductionVariableType variableType, double selectionValue, const QString& namePart ) -> QString + { + double displayValue = convertToDisplayUnit( selectionValue, variableType ); + return QString( " %1:%2" ).arg( namePart ).arg( displayValue ); + }; + + if ( plotCurveIdx < m_plotCurveMetaData.size() ) + { + auto plotData = m_plotCurveMetaData[plotCurveIdx]; + + QString curveSetName; + if ( curveNameContent.tableNumber ) curveSetName += QString( " Table:%1" ).arg( plotData.tableNumber ); + + using pvt = RimVfpDefines::ProductionVariableType; + + if ( curveNameContent.thp && m_familyVariable() != pvt::THP ) + { + curveSetName += formatNamePart( pvt::THP, plotData.thpValue, "THP" ); + } + if ( curveNameContent.gasLiquidRatio && m_familyVariable() != pvt::GAS_LIQUID_RATIO ) + { + curveSetName += formatNamePart( pvt::GAS_LIQUID_RATIO, plotData.gasLiquidRatioValue, "GLR" ); + } + if ( curveNameContent.waterCut && m_familyVariable() != pvt::WATER_CUT ) + { + curveSetName += formatNamePart( pvt::WATER_CUT, plotData.waterCutValue, "WC" ); + } + if ( curveNameContent.artificialLiftQuantity && m_familyVariable() != pvt::ARTIFICIAL_LIFT_QUANTITY ) + { + curveSetName += formatNamePart( pvt::ARTIFICIAL_LIFT_QUANTITY, plotData.artificialLiftQuantityValue, "Lift" ); + } + if ( curveNameContent.flowRate && m_familyVariable() != pvt::FLOW_RATE ) + { + curveSetName += formatNamePart( pvt::FLOW_RATE, plotData.flowRateValue, "Rate" ); + } + + categories.push_back( std::make_tuple( curveSetName, static_cast( i ), cvf::Color3ub( color ) ) ); + } + + plotCurveIdx += m_plotData[i].size(); + } + + // Reverse the categories to make the first curve the topmost in the legend + std::reverse( categories.begin(), categories.end() ); + m_legendConfig->setCategoryItems( categories ); + + m_legendOverlayFrame->setContentFrame( m_legendConfig->makeLegendFrame() ); + m_plotWidget->addOverlayFrame( m_legendOverlayFrame ); + } + else + { + m_plotWidget->removeOverlayFrame( m_legendOverlayFrame ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, + const VfpPlotData& plotData, + const VfpValueSelection& valueSelection, + int tableNumber, + const QColor& color, + const CurveNameContent& curveNameContent ) { if ( !plotWidget ) return; @@ -725,48 +822,37 @@ void RimCustomVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* curve->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); curve->setLineThickness( m_curveThickness() ); - if ( multipleCurveSets ) - { - // Use the incoming color for all curves, and cycle the symbols - curve->setColor( RiaColorTools::fromQColorTo3f( color ) ); - auto symbols = curveSymbols(); - auto customSymbol = symbols[curveIndex % symbols.size()]; - curve->setSymbol( customSymbol ); - } - else - { - // Use the incoming symbol for all curves, and cycle the colors - auto customColor = curveColors().cycledQColor( curveIndex ); - curve->setColor( RiaColorTools::fromQColorTo3f( customColor ) ); - curve->setSymbol( curveSymbol ); - } + // Use the incoming color for all curves, and cycle the symbols + curve->setColor( RiaColorTools::fromQColorTo3f( color ) ); + auto symbols = curveSymbols(); + auto customSymbol = symbols[curveIndex % symbols.size()]; + curve->setSymbol( customSymbol ); curve->setSymbolSize( m_curveSymbolSize() ); QString curveName; if ( curveNameContent.defaultName ) curveName = plotData.curveTitle( curveIndex ); - if ( curveNameContent.tableNumber ) curveName += QString( " Table:%1" ).arg( tableNumber ); auto familyValue = ( curveIndex < valueSelection.familyValues.size() ) ? valueSelection.familyValues[curveIndex] : 0.0; using pvt = RimVfpDefines::ProductionVariableType; - if ( curveNameContent.thp || m_familyVariable() == pvt::THP ) + if ( m_familyVariable() == pvt::THP ) { curveName += formatCurveNamePart( pvt::THP, familyValue, valueSelection.thpValue, "THP" ); } - if ( curveNameContent.gasLiquidRatio || m_familyVariable() == pvt::GAS_LIQUID_RATIO ) + if ( m_familyVariable() == pvt::GAS_LIQUID_RATIO ) { curveName += formatCurveNamePart( pvt::GAS_LIQUID_RATIO, familyValue, valueSelection.gasLiquidRatioValue, "GLR" ); } - if ( curveNameContent.waterCut || m_familyVariable() == pvt::WATER_CUT ) + if ( m_familyVariable() == pvt::WATER_CUT ) { curveName += formatCurveNamePart( pvt::WATER_CUT, familyValue, valueSelection.waterCutValue, "WC" ); } - if ( curveNameContent.artificialLiftQuantity || m_familyVariable() == pvt::ARTIFICIAL_LIFT_QUANTITY ) + if ( m_familyVariable() == pvt::ARTIFICIAL_LIFT_QUANTITY ) { curveName += formatCurveNamePart( pvt::ARTIFICIAL_LIFT_QUANTITY, familyValue, valueSelection.artificialLiftQuantityValue, "Lift" ); } - if ( curveNameContent.flowRate || m_familyVariable() == pvt::FLOW_RATE ) + if ( m_familyVariable() == pvt::FLOW_RATE ) { curveName += formatCurveNamePart( pvt::FLOW_RATE, familyValue, valueSelection.flowRateValue, "Rate" ); } @@ -901,7 +987,7 @@ std::vector RimCustomVfpPlot::availableValues( RimVfpDefines::Production if ( m_curveValueOptions() == RimVfpDefines::CurveOptionValuesType::UNION_OF_SELECTED_TABLES ) { - std::vector tables = m_additionalDataSources.ptrReferencedObjectsByType(); + std::vector tables = m_comparisonTables.ptrReferencedObjectsByType(); for ( const auto& table : tables ) { if ( !table ) continue; @@ -1022,9 +1108,23 @@ std::vector RimCustomVfpPlot::curveSymbols( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const caf::ColorTable RimCustomVfpPlot::curveColors() +caf::ColorTable RimCustomVfpPlot::curveColors() const +{ + if ( m_colorLegend->colorArray().size() == 0 ) + { + return RiaColorTables::summaryCurveDefaultPaletteColors().inverted(); + } + + caf::ColorTable colors( m_colorLegend->colorArray() ); + return colors; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::legendColorsChanged( const caf::SignalEmitter* emitter ) { - return RiaColorTables::summaryCurveDefaultPaletteColors().inverted(); + onLoadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- @@ -1126,20 +1226,33 @@ void RimCustomVfpPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin } { - auto group = uiOrdering.addNewGroup( "Additional Tables" ); + auto group = uiOrdering.addNewGroup( "Comparison Tables" ); group->setCollapsedByDefault(); - group->add( &m_additionalDataSources ); + group->add( &m_comparisonTables ); } if ( m_tableType == RimVfpDefines::TableType::PRODUCTION ) { auto selectionDetailsGroup = uiOrdering.addNewGroup( "Selection Details" ); selectionDetailsGroup->setCollapsedByDefault(); + selectionDetailsGroup->add( &m_flowRate ); + m_flowRate.uiCapability()->setUiHidden( m_primaryVariable() == RimVfpDefines::ProductionVariableType::FLOW_RATE ); + selectionDetailsGroup->add( &m_thp ); - selectionDetailsGroup->add( &m_artificialLiftQuantity ); + m_thp.uiCapability()->setUiHidden( m_primaryVariable() == RimVfpDefines::ProductionVariableType::THP ); + selectionDetailsGroup->add( &m_waterCut ); + m_waterCut.uiCapability()->setUiHidden( m_primaryVariable() == RimVfpDefines::ProductionVariableType::WATER_CUT ); + selectionDetailsGroup->add( &m_gasLiquidRatio ); + m_gasLiquidRatio.uiCapability()->setUiHidden( m_primaryVariable() == RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO ); + + selectionDetailsGroup->add( &m_artificialLiftQuantity ); + auto options = calculateValueOptions( &m_artificialLiftQuantity ); + bool hideArtificialLiftQuantity = ( m_primaryVariable() == RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY ) || + ( options.size() < 2 ); + m_artificialLiftQuantity.uiCapability()->setUiHidden( hideArtificialLiftQuantity ); } { @@ -1183,7 +1296,7 @@ QList RimCustomVfpPlot::calculateValueOptions( const caf calculateTableValueOptions( RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO, options ); } - else if ( fieldNeedingOptions == &m_additionalDataSources ) + else if ( fieldNeedingOptions == &m_comparisonTables ) { RimVfpDataCollection* vfpDataCollection = RimVfpDataCollection::instance(); for ( auto table : vfpDataCollection->vfpTableData() ) @@ -1191,6 +1304,8 @@ QList RimCustomVfpPlot::calculateValueOptions( const caf // Exclude main table data object if ( table == m_mainDataSource ) continue; + if ( table->tableType() != m_tableType() ) continue; + options.push_back( caf::PdmOptionItemInfo( table->name(), table ) ); } } @@ -1287,7 +1402,7 @@ void RimCustomVfpPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField zoomAll(); } - if ( changedField == &m_additionalDataSources || changedField == &m_curveMatchingType || changedField == &m_curveValueOptions || + if ( changedField == &m_comparisonTables || changedField == &m_curveMatchingType || changedField == &m_curveValueOptions || changedField == &m_primaryVariable || changedField == &m_familyVariable ) { initializeSelection(); diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h index cefc9fd15e..521b5449f4 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h @@ -19,6 +19,7 @@ #pragma once #include "RimPlot.h" + #include "RimVfpDefines.h" #include "RiuPlotCurveSymbol.h" @@ -35,6 +36,9 @@ class RigVfpTables; class RimVfpTableData; class RimVfpTable; class RiuPlotCurveInfoTextProvider; +class RimRegularLegendConfig; +class RiuDraggableOverlayFrame; +class RimColorLegend; struct VfpValueSelection; struct VfpTableInitialData; @@ -65,6 +69,7 @@ class RimCustomVfpPlot : public RimPlot void setTableNumber( int tableNumber ); void initializeObject(); void initializeSelection(); + void createDefaultColors(); // RimPlot implementations RiuPlotWidget* plotWidget() override; @@ -133,14 +138,14 @@ class RimCustomVfpPlot : public RimPlot bool gasLiquidRatio = false; }; - void populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, - const VfpPlotData& plotData, - const VfpValueSelection& valueSelection, - int tableNumber, - const QColor& color, - RiuPlotCurveSymbol::PointSymbolEnum curveSymbol, - bool multipleCurveSets, - const CurveNameContent& curveNameContent ); + void populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, + const VfpPlotData& plotData, + const VfpValueSelection& valueSelection, + int tableNumber, + const QColor& color, + const CurveNameContent& curveNameContent ); + + void updateLegendWidget( size_t curveSetCount, CurveNameContent& curveNameContent ); static QString axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ); @@ -173,13 +178,14 @@ class RimCustomVfpPlot : public RimPlot static std::vector curveSymbols(); - static const caf::ColorTable curveColors(); + caf::ColorTable curveColors() const; + void legendColorsChanged( const caf::SignalEmitter* emitter ); private: caf::PdmField m_plotTitle; caf::PdmPtrField m_mainDataSource; - caf::PdmPtrArrayField m_additionalDataSources; + caf::PdmPtrArrayField m_comparisonTables; caf::PdmField> m_curveMatchingType; caf::PdmField> m_curveValueOptions; @@ -206,6 +212,10 @@ class RimCustomVfpPlot : public RimPlot caf::PdmChildArrayField m_plotCurves; + caf::PdmChildField m_legendConfig; + QPointer m_legendOverlayFrame; + caf::PdmChildField m_colorLegend; + caf::PdmField m_curveSymbolSize; caf::PdmField m_curveThickness; From ccda815bde957909737f396bff5212660b51fe86 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 18 Jun 2024 09:28:16 +0200 Subject: [PATCH 147/332] Mark single table VFP plot as obsolete Remove features to create obsoleted plot. Remove plot creation functions. Rename to RimVfpPlot_deprecated --- .../RicShowPlotDataFeature.cpp | 3 +- .../Commands/CMakeLists_files.cmake | 2 - .../Commands/RicImportVfpDataFeature.cpp | 4 +- .../Commands/RicNewCustomVfpPlotFeature.cpp | 22 +++- .../Commands/RicNewCustomVfpPlotFeature.h | 4 + .../Commands/RicNewVfpPlotFeature.cpp | 75 ----------- .../Commands/RicNewVfpPlotFeature.h | 38 ------ .../CMakeLists_files.cmake | 4 +- .../RimVfpPlotCollection.cpp | 62 ++------- .../RimVfpPlotCollection.h | 26 ++-- ...mVfpPlot.cpp => RimVfpPlot_deprecated.cpp} | 123 +++++++++--------- .../{RimVfpPlot.h => RimVfpPlot_deprecated.h} | 11 +- .../VerticalFlowPerformance/RimVfpTable.cpp | 1 - .../RimVfpTableData.cpp | 1 - 14 files changed, 122 insertions(+), 254 deletions(-) delete mode 100644 ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp delete mode 100644 ApplicationLibCode/Commands/RicNewVfpPlotFeature.h rename ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/{RimVfpPlot.cpp => RimVfpPlot_deprecated.cpp} (86%) rename ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/{RimVfpPlot.h => RimVfpPlot_deprecated.h} (96%) diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp index a837ab7e22..7aee55ec6d 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp @@ -38,7 +38,6 @@ #include "RimWellLogTrack.h" #include "VerticalFlowPerformance/RimCustomVfpPlot.h" -#include "VerticalFlowPerformance/RimVfpPlot.h" #include "RiuPlotMainWindow.h" #include "RiuTextDialog.h" @@ -194,7 +193,7 @@ bool RicShowPlotDataFeature::isCommandEnabled() const for ( auto plot : selection ) { if ( dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || - dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || + dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) || dynamic_cast( plot ) ) diff --git a/ApplicationLibCode/Commands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/CMakeLists_files.cmake index e81cff0b60..3adb164c67 100644 --- a/ApplicationLibCode/Commands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/CMakeLists_files.cmake @@ -95,7 +95,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCalculationExpressionsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicImportWellLogCsvFileFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewViewForGridEnsembleFeature.h - ${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewCustomVfpPlotFeature.h ) @@ -196,7 +195,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicImportWellLogCsvFileFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportWellLogOsduFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewViewForGridEnsembleFeature.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewCustomVfpPlotFeature.cpp ) diff --git a/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp b/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp index 972cf6cc0d..9fe1586d4e 100644 --- a/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp @@ -23,8 +23,8 @@ #include "RimMainPlotCollection.h" +#include "VerticalFlowPerformance/RimCustomVfpPlot.h" #include "VerticalFlowPerformance/RimVfpDataCollection.h" -#include "VerticalFlowPerformance/RimVfpPlot.h" #include "VerticalFlowPerformance/RimVfpPlotCollection.h" #include "RiuFileDialogTools.h" @@ -76,7 +76,7 @@ void RicImportVfpDataFeature::onActionTriggered( bool isChecked ) for ( const auto& fileName : fileNames ) { auto vfpDataSource = vfpDataColl->appendTableDataObject( fileName ); - auto firstPlot = vfpPlotColl->createAndAppendPlots( vfpDataSource ); + auto firstPlot = vfpPlotColl->createAndAppendPlots( vfpDataSource, {} ); vfpDataColl->updateAllRequiredEditors(); RiuPlotMainWindowTools::onObjectAppended( firstPlot, firstPlot ); } diff --git a/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.cpp b/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.cpp index 5421890f08..e607f72118 100644 --- a/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.cpp @@ -18,8 +18,6 @@ #include "RicNewCustomVfpPlotFeature.h" -#include "RicNewVfpPlotFeature.h" - #include "RimMainPlotCollection.h" #include "VerticalFlowPerformance/RimCustomVfpPlot.h" @@ -44,7 +42,7 @@ void RicNewCustomVfpPlotFeature::onActionTriggered( bool isChecked ) RimVfpPlotCollection* vfpPlotColl = RimMainPlotCollection::current()->vfpPlotCollection(); if ( !vfpPlotColl ) return; - auto selectedTables = RicNewVfpPlotFeature::selectedTables(); + auto selectedTables = RicNewCustomVfpPlotFeature::selectedTables(); if ( selectedTables.empty() ) return; auto mainDataSource = selectedTables.front(); @@ -61,6 +59,22 @@ void RicNewCustomVfpPlotFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicNewCustomVfpPlotFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "Create Custom VFP Plot" ); + actionToSetup->setText( "Create VFP Plot" ); actionToSetup->setIcon( QIcon( ":/VfpPlot.svg" ) ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicNewCustomVfpPlotFeature::selectedTables() +{ + auto tables = caf::selectedObjectsByTypeStrict(); + auto selectedTableData = caf::selectedObjectsByTypeStrict(); + for ( auto tableData : selectedTableData ) + { + auto tableDataSources = tableData->tableDataSources(); + tables.insert( tables.end(), tableDataSources.begin(), tableDataSources.end() ); + } + + return tables; +} diff --git a/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.h b/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.h index f3f99517e6..1c2c51abfc 100644 --- a/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.h +++ b/ApplicationLibCode/Commands/RicNewCustomVfpPlotFeature.h @@ -20,6 +20,8 @@ #include "cafCmdFeature.h" +class RimVfpTable; + //================================================================================================== /// //================================================================================================== @@ -30,4 +32,6 @@ class RicNewCustomVfpPlotFeature : public caf::CmdFeature private: void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; + + static std::vector selectedTables(); }; diff --git a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp deleted file mode 100644 index a908d1b0c9..0000000000 --- a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp +++ /dev/null @@ -1,75 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2024 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 "RicNewVfpPlotFeature.h" - -#include "RimMainPlotCollection.h" - -#include "VerticalFlowPerformance/RimVfpDataCollection.h" -#include "VerticalFlowPerformance/RimVfpPlotCollection.h" -#include "VerticalFlowPerformance/RimVfpTable.h" -#include "VerticalFlowPerformance/RimVfpTableData.h" - -#include "cafSelectionManagerTools.h" - -#include "RiuPlotMainWindowTools.h" - -#include - -CAF_CMD_SOURCE_INIT( RicNewVfpPlotFeature, "RicNewVfpPlotFeature" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicNewVfpPlotFeature::selectedTables() -{ - auto tables = caf::selectedObjectsByTypeStrict(); - auto selectedTableData = caf::selectedObjectsByTypeStrict(); - for ( auto tableData : selectedTableData ) - { - auto tableDataSources = tableData->tableDataSources(); - tables.insert( tables.end(), tableDataSources.begin(), tableDataSources.end() ); - } - - return tables; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicNewVfpPlotFeature::onActionTriggered( bool isChecked ) -{ - RimVfpPlotCollection* vfpPlotColl = RimMainPlotCollection::current()->vfpPlotCollection(); - if ( !vfpPlotColl ) return; - - for ( auto table : selectedTables() ) - { - RimVfpPlot* firstPlot = vfpPlotColl->createAndAppendPlots( table ); - vfpPlotColl->updateConnectedEditors(); - RiuPlotMainWindowTools::onObjectAppended( firstPlot, firstPlot ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicNewVfpPlotFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setText( "Create VFP Plot" ); - actionToSetup->setIcon( QIcon( ":/VfpPlot.svg" ) ); -} diff --git a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h deleted file mode 100644 index 9a9cb8dcf2..0000000000 --- a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.h +++ /dev/null @@ -1,38 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2024 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 "cafCmdFeature.h" - -class RimVfpTable; - -//================================================================================================== -/// -//================================================================================================== -class RicNewVfpPlotFeature : public caf::CmdFeature -{ - CAF_CMD_HEADER_INIT; - -public: - static std::vector selectedTables(); - -private: - void onActionTriggered( bool isChecked ) override; - void setupActionLook( QAction* actionToSetup ) override; -}; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake index 5db1f2a700..8a36f69a0e 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake @@ -1,6 +1,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.h - ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.h + ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot_deprecated.h ${CMAKE_CURRENT_LIST_DIR}/RimCustomVfpPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimVfpTableData.h @@ -10,7 +10,7 @@ set(SOURCE_GROUP_HEADER_FILES set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot_deprecated.cpp ${CMAKE_CURRENT_LIST_DIR}/RimCustomVfpPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVfpTableData.cpp diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp index 8ac3b072c0..5ca78c1fcc 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.cpp @@ -32,33 +32,10 @@ RimVfpPlotCollection::RimVfpPlotCollection() { CAF_PDM_InitObject( "VFP Plots", ":/VfpPlotCollection.svg" ); - CAF_PDM_InitFieldNoDefault( &m_vfpPlots, "VfpPlots", "Vertical Flow Performance Plots" ); + CAF_PDM_InitFieldNoDefault( &m_vfpPlots_deprecated, "VfpPlots", "Vertical Flow Performance Plots" ); CAF_PDM_InitFieldNoDefault( &m_customVfpPlots, "CustomVfpPlots", "Vertical Flow Performance Plots" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimVfpPlot* RimVfpPlotCollection::createAndAppendPlots( RimVfpTable* tableData ) -{ - if ( !tableData ) return nullptr; - - tableData->ensureDataIsImported(); - - RimVfpPlot* firstPlot = nullptr; - - auto vfpPlot = new RimVfpPlot(); - vfpPlot->setDataSource( tableData ); - vfpPlot->initializeObject(); - - addPlot( vfpPlot ); - vfpPlot->loadDataAndUpdate(); - - firstPlot = vfpPlot; - - return firstPlot; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -68,6 +45,7 @@ RimCustomVfpPlot* RimVfpPlotCollection::createAndAppendPlots( RimVfpTable* mainD vfpPlot->selectDataSource( mainDataSource, tableData ); vfpPlot->initializeObject(); vfpPlot->initializeSelection(); + vfpPlot->createDefaultColors(); m_customVfpPlots.push_back( vfpPlot ); @@ -79,41 +57,25 @@ RimCustomVfpPlot* RimVfpPlotCollection::createAndAppendPlots( RimVfpTable* mainD //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlotCollection::addPlot( RimVfpPlot* newPlot ) -{ - m_vfpPlots.push_back( newPlot ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpPlotCollection::insertPlot( RimVfpPlot* vfpPlot, size_t index ) +void RimVfpPlotCollection::addPlot( RimVfpPlot_deprecated* newPlot ) { - m_vfpPlots.insert( index, vfpPlot ); + m_vfpPlots_deprecated.push_back( newPlot ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimVfpPlotCollection::plots() const +void RimVfpPlotCollection::insertPlot( RimVfpPlot_deprecated* vfpPlot, size_t index ) { - return m_vfpPlots.childrenByType(); + m_vfpPlots_deprecated.insert( index, vfpPlot ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimVfpPlot* RimVfpPlotCollection::plotForTableNumber( int tableNumber ) const +std::vector RimVfpPlotCollection::plots() const { - for ( auto plot : plots() ) - { - if ( plot->tableNumber() == tableNumber ) - { - return plot; - } - } - - return nullptr; + return m_vfpPlots_deprecated.childrenByType(); } //-------------------------------------------------------------------------------------------------- @@ -121,15 +83,15 @@ RimVfpPlot* RimVfpPlotCollection::plotForTableNumber( int tableNumber ) const //-------------------------------------------------------------------------------------------------- size_t RimVfpPlotCollection::plotCount() const { - return m_vfpPlots.size(); + return m_vfpPlots_deprecated.size() + m_customVfpPlots.size(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlotCollection::removePlot( RimVfpPlot* vfpPlot ) +void RimVfpPlotCollection::removePlot( RimVfpPlot_deprecated* vfpPlot ) { - m_vfpPlots.removeChild( vfpPlot ); + m_vfpPlots_deprecated.removeChild( vfpPlot ); updateAllRequiredEditors(); } @@ -138,7 +100,7 @@ void RimVfpPlotCollection::removePlot( RimVfpPlot* vfpPlot ) //-------------------------------------------------------------------------------------------------- void RimVfpPlotCollection::deleteAllPlots() { - m_vfpPlots.deleteChildren(); + m_vfpPlots_deprecated.deleteChildren(); m_customVfpPlots.deleteChildren(); } diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h index 2ab646552b..df8293127d 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlotCollection.h @@ -18,7 +18,7 @@ #pragma once #include "RimAbstractPlotCollection.h" -#include "RimVfpPlot.h" +#include "RimVfpPlot_deprecated.h" #include "cafPdmChildArrayField.h" #include "cafPdmObject.h" @@ -29,34 +29,36 @@ class RimCustomVfpPlot; /// /// //================================================================================================== -class RimVfpPlotCollection : public caf::PdmObject, public RimTypedPlotCollection +class RimVfpPlotCollection : public caf::PdmObject, public RimTypedPlotCollection { CAF_PDM_HEADER_INIT; public: RimVfpPlotCollection(); - RimVfpPlot* createAndAppendPlots( RimVfpTable* tableData ); - RimVfpPlot* plotForTableNumber( int tableNumber ) const; RimCustomVfpPlot* createAndAppendPlots( RimVfpTable* mainDataSource, std::vector tableData ); - void addPlot( RimVfpPlot* newPlot ) override; - std::vector plots() const override; + static void addImportItems( caf::CmdFeatureMenuBuilder& menuBuilder ); + +private: + void addPlot( RimVfpPlot_deprecated* newPlot ) override; + std::vector plots() const override; size_t plotCount() const final; - void insertPlot( RimVfpPlot* vfpPlot, size_t index ) final; - void removePlot( RimVfpPlot* vfpPlot ) final; + void insertPlot( RimVfpPlot_deprecated* vfpPlot, size_t index ) final; + void removePlot( RimVfpPlot_deprecated* vfpPlot ) final; void deleteAllPlots() override; - static void addImportItems( caf::CmdFeatureMenuBuilder& menuBuilder ); - -private: void loadDataAndUpdateAllPlots() override; void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) override; void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; private: - caf::PdmChildArrayField m_vfpPlots; caf::PdmChildArrayField m_customVfpPlots; + + // To be removed in a future release. + // RimVfpPlotCollection can derive from RimTypedPlotCollection + // Consider renaming RimCustomVfpPlot to RimVfpPlot + caf::PdmChildArrayField m_vfpPlots_deprecated; }; diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot_deprecated.cpp similarity index 86% rename from ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp rename to ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot_deprecated.cpp index 47652efd4c..c023eac228 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot_deprecated.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimVfpPlot.h" +#include "RimVfpPlot_deprecated.h" #include "RiaColorTables.h" #include "RiaColorTools.h" @@ -57,12 +57,12 @@ // //================================================================================================== -CAF_PDM_SOURCE_INIT( RimVfpPlot, "VfpPlot" ); +CAF_PDM_SOURCE_INIT( RimVfpPlot_deprecated, "VfpPlot" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimVfpPlot::RimVfpPlot() +RimVfpPlot_deprecated::RimVfpPlot_deprecated() { // TODO: add icon CAF_PDM_InitObject( "VFP Plot", ":/VfpPlot.svg" ); @@ -146,7 +146,7 @@ RimVfpPlot::RimVfpPlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimVfpPlot::~RimVfpPlot() +RimVfpPlot_deprecated::~RimVfpPlot_deprecated() { removeMdiWindowFromMdiArea(); deleteViewWidget(); @@ -155,7 +155,7 @@ RimVfpPlot::~RimVfpPlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setDataSource( RimVfpTable* vfpTableData ) +void RimVfpPlot_deprecated::setDataSource( RimVfpTable* vfpTableData ) { m_vfpTable = vfpTableData; } @@ -163,7 +163,7 @@ void RimVfpPlot::setDataSource( RimVfpTable* vfpTableData ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setTableNumber( int tableNumber ) +void RimVfpPlot_deprecated::setTableNumber( int tableNumber ) { m_tableNumber = tableNumber; } @@ -171,7 +171,7 @@ void RimVfpPlot::setTableNumber( int tableNumber ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::initializeObject() +void RimVfpPlot_deprecated::initializeObject() { if ( !vfpTables() ) return; @@ -197,7 +197,7 @@ void RimVfpPlot::initializeObject() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuPlotWidget* RimVfpPlot::plotWidget() +RiuPlotWidget* RimVfpPlot_deprecated::plotWidget() { return m_plotWidget; } @@ -205,7 +205,7 @@ RiuPlotWidget* RimVfpPlot::plotWidget() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimVfpPlot::isCurveHighlightSupported() const +bool RimVfpPlot_deprecated::isCurveHighlightSupported() const { return true; } @@ -213,7 +213,7 @@ bool RimVfpPlot::isCurveHighlightSupported() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setAutoScaleXEnabled( bool enabled ) +void RimVfpPlot_deprecated::setAutoScaleXEnabled( bool enabled ) { m_xAxisProperties->setAutoZoom( enabled ); } @@ -221,7 +221,7 @@ void RimVfpPlot::setAutoScaleXEnabled( bool enabled ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setAutoScaleYEnabled( bool enabled ) +void RimVfpPlot_deprecated::setAutoScaleYEnabled( bool enabled ) { m_yAxisProperties->setAutoZoom( enabled ); } @@ -229,7 +229,7 @@ void RimVfpPlot::setAutoScaleYEnabled( bool enabled ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::updateAxes() +void RimVfpPlot_deprecated::updateAxes() { if ( !m_plotWidget ) return; @@ -243,7 +243,7 @@ void RimVfpPlot::updateAxes() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::updateLegend() +void RimVfpPlot_deprecated::updateLegend() { if ( !m_plotWidget ) { @@ -270,7 +270,7 @@ void RimVfpPlot::updateLegend() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimVfpPlot::asciiDataForPlotExport() const +QString RimVfpPlot_deprecated::asciiDataForPlotExport() const { if ( !vfpTables() ) return {}; @@ -306,7 +306,7 @@ QString RimVfpPlot::asciiDataForPlotExport() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::reattachAllCurves() +void RimVfpPlot_deprecated::reattachAllCurves() { for ( auto curve : m_plotCurves() ) { @@ -320,7 +320,7 @@ void RimVfpPlot::reattachAllCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::detachAllCurves() +void RimVfpPlot_deprecated::detachAllCurves() { for ( auto curve : m_plotCurves() ) { @@ -331,7 +331,7 @@ void RimVfpPlot::detachAllCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimVfpPlot::description() const +QString RimVfpPlot_deprecated::description() const { return uiName(); } @@ -339,7 +339,7 @@ QString RimVfpPlot::description() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QWidget* RimVfpPlot::viewWidget() +QWidget* RimVfpPlot_deprecated::viewWidget() { return m_plotWidget; } @@ -347,7 +347,7 @@ QWidget* RimVfpPlot::viewWidget() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QImage RimVfpPlot::snapshotWindowContent() +QImage RimVfpPlot_deprecated::snapshotWindowContent() { QImage image; @@ -363,7 +363,7 @@ QImage RimVfpPlot::snapshotWindowContent() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::zoomAll() +void RimVfpPlot_deprecated::zoomAll() { setAutoScaleXEnabled( true ); setAutoScaleYEnabled( true ); @@ -374,7 +374,7 @@ void RimVfpPlot::zoomAll() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setDataIsImportedExternally( bool dataIsImportedExternally ) +void RimVfpPlot_deprecated::setDataIsImportedExternally( bool dataIsImportedExternally ) { m_dataIsImportedExternally = dataIsImportedExternally; } @@ -382,7 +382,7 @@ void RimVfpPlot::setDataIsImportedExternally( bool dataIsImportedExternally ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RimVfpPlot::tableNumber() const +int RimVfpPlot_deprecated::tableNumber() const { return m_tableNumber(); } @@ -390,7 +390,7 @@ int RimVfpPlot::tableNumber() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) +void RimVfpPlot_deprecated::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) { detachAllCurves(); reattachAllCurves(); @@ -401,7 +401,7 @@ void RimVfpPlot::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, s //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) +RiuPlotWidget* RimVfpPlot_deprecated::doCreatePlotViewWidget( QWidget* mainWindowParent ) { // It seems we risk being called multiple times if ( m_plotWidget ) return m_plotWidget; @@ -443,7 +443,7 @@ RiuPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::deleteViewWidget() +void RimVfpPlot_deprecated::deleteViewWidget() { if ( m_plotWidget ) { @@ -456,7 +456,7 @@ void RimVfpPlot::deleteViewWidget() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::onLoadDataAndUpdate() +void RimVfpPlot_deprecated::onLoadDataAndUpdate() { if ( isMdiWindow() ) { @@ -506,7 +506,7 @@ void RimVfpPlot::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData ) +void RimVfpPlot_deprecated::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData ) { plotWidget->setAxisScale( RiuPlotAxis::defaultBottom(), 0, 1 ); plotWidget->setAxisScale( RiuPlotAxis::defaultLeft(), 0, 1 ); @@ -553,14 +553,14 @@ void RimVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, cons curve->plotCurve()->setSamplesFromXValuesAndYValues( plotData.xData( idx ), plotData.yData( idx ), useLogarithmicScale ); } curve->updateCurveAppearance(); - curve->appearanceChanged.connect( this, &RimVfpPlot::curveAppearanceChanged ); + curve->appearanceChanged.connect( this, &RimVfpPlot_deprecated::curveAppearanceChanged ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimVfpPlot::axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ) +QString RimVfpPlot_deprecated::axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ) { QString title; @@ -581,16 +581,16 @@ QString RimVfpPlot::axisTitle( RimVfpDefines::ProductionVariableType variableTyp //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::connectAxisSignals( RimPlotAxisProperties* axis ) +void RimVfpPlot_deprecated::connectAxisSignals( RimPlotAxisProperties* axis ) { - axis->settingsChanged.connect( this, &RimVfpPlot::axisSettingsChanged ); - axis->logarithmicChanged.connect( this, &RimVfpPlot::axisLogarithmicChanged ); + axis->settingsChanged.connect( this, &RimVfpPlot_deprecated::axisSettingsChanged ); + axis->logarithmicChanged.connect( this, &RimVfpPlot_deprecated::axisLogarithmicChanged ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::axisSettingsChanged( const caf::SignalEmitter* emitter ) +void RimVfpPlot_deprecated::axisSettingsChanged( const caf::SignalEmitter* emitter ) { updateAxes(); } @@ -598,7 +598,7 @@ void RimVfpPlot::axisSettingsChanged( const caf::SignalEmitter* emitter ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic ) +void RimVfpPlot_deprecated::axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic ) { // Currently not supported } @@ -606,7 +606,7 @@ void RimVfpPlot::axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::updatePlotWidgetFromAxisRanges() +void RimVfpPlot_deprecated::updatePlotWidgetFromAxisRanges() { if ( m_plotWidget ) { @@ -625,7 +625,7 @@ void RimVfpPlot::updatePlotWidgetFromAxisRanges() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::updateAxisRangesFromPlotWidget() +void RimVfpPlot_deprecated::updateAxisRangesFromPlotWidget() { RimPlotAxisTools::updateVisibleRangesFromPlotWidget( m_xAxisProperties(), RiuPlotAxis::defaultBottom(), m_plotWidget ); RimPlotAxisTools::updateVisibleRangesFromPlotWidget( m_yAxisProperties(), RiuPlotAxis::defaultLeft(), m_plotWidget ); @@ -634,7 +634,7 @@ void RimVfpPlot::updateAxisRangesFromPlotWidget() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::onPlotZoomed() +void RimVfpPlot_deprecated::onPlotZoomed() { setAutoScaleXEnabled( false ); setAutoScaleYEnabled( false ); @@ -644,7 +644,7 @@ void RimVfpPlot::onPlotZoomed() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::curveAppearanceChanged( const caf::SignalEmitter* emitter ) +void RimVfpPlot_deprecated::curveAppearanceChanged( const caf::SignalEmitter* emitter ) { scheduleReplot(); } @@ -652,7 +652,7 @@ void RimVfpPlot::curveAppearanceChanged( const caf::SignalEmitter* emitter ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::initializeFromInitData( const VfpTableInitialData& table ) +void RimVfpPlot_deprecated::initializeFromInitData( const VfpTableInitialData& table ) { m_tableType = table.isProductionTable ? RimVfpDefines::TableType::PRODUCTION : RimVfpDefines::TableType::INJECTION; m_tableNumber = table.tableNumber; @@ -665,7 +665,7 @@ void RimVfpPlot::initializeFromInitData( const VfpTableInitialData& table ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimVfpTableData* RimVfpPlot::vfpTableData() const +RimVfpTableData* RimVfpPlot_deprecated::vfpTableData() const { if ( m_vfpTable ) return m_vfpTable->dataSource(); @@ -675,7 +675,7 @@ RimVfpTableData* RimVfpPlot::vfpTableData() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigVfpTables* RimVfpPlot::vfpTables() const +const RigVfpTables* RimVfpPlot_deprecated::vfpTables() const { if ( vfpTableData() ) { @@ -689,7 +689,7 @@ const RigVfpTables* RimVfpPlot::vfpTables() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimVfpPlot::convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType ) +double RimVfpPlot_deprecated::convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType ) { if ( variableType == RimVfpDefines::ProductionVariableType::THP ) { @@ -708,7 +708,7 @@ double RimVfpPlot::convertToDisplayUnit( double value, RimVfpDefines::Production //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::convertToDisplayUnit( std::vector& values, RimVfpDefines::ProductionVariableType variableType ) +void RimVfpPlot_deprecated::convertToDisplayUnit( std::vector& values, RimVfpDefines::ProductionVariableType variableType ) { for ( double& value : values ) value = convertToDisplayUnit( value, variableType ); @@ -717,7 +717,7 @@ void RimVfpPlot::convertToDisplayUnit( std::vector& values, RimVfpDefine //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimVfpPlot::getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType variableType ) +QString RimVfpPlot_deprecated::getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType variableType ) { QString unit = getDisplayUnit( variableType ); if ( !unit.isEmpty() ) return QString( "[%1]" ).arg( unit ); @@ -728,7 +728,7 @@ QString RimVfpPlot::getDisplayUnitWithBracket( RimVfpDefines::ProductionVariable //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimVfpPlot::getDisplayUnit( RimVfpDefines::ProductionVariableType variableType ) +QString RimVfpPlot_deprecated::getDisplayUnit( RimVfpDefines::ProductionVariableType variableType ) { if ( variableType == RimVfpDefines::ProductionVariableType::THP ) return "Bar"; @@ -741,7 +741,7 @@ QString RimVfpPlot::getDisplayUnit( RimVfpDefines::ProductionVariableType variab //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +void RimVfpPlot_deprecated::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_vfpTable ); @@ -780,7 +780,7 @@ void RimVfpPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiO //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::setFixedVariableUiEditability( caf::PdmField& field, RimVfpDefines::ProductionVariableType variableType ) +void RimVfpPlot_deprecated::setFixedVariableUiEditability( caf::PdmField& field, RimVfpDefines::ProductionVariableType variableType ) { field.uiCapability()->setUiReadOnly( variableType == m_primaryVariable.v() || variableType == m_familyVariable.v() ); } @@ -788,7 +788,7 @@ void RimVfpPlot::setFixedVariableUiEditability( caf::PdmField& field, RimVf //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimVfpPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +QList RimVfpPlot_deprecated::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options = RimPlot::calculateValueOptions( fieldNeedingOptions ); @@ -832,7 +832,8 @@ QList RimVfpPlot::calculateValueOptions( const caf::PdmF //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::calculateTableValueOptions( RimVfpDefines::ProductionVariableType variableType, QList& options ) +void RimVfpPlot_deprecated::calculateTableValueOptions( RimVfpDefines::ProductionVariableType variableType, + QList& options ) { if ( vfpTables() ) { @@ -850,7 +851,7 @@ void RimVfpPlot::calculateTableValueOptions( RimVfpDefines::ProductionVariableTy //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +void RimVfpPlot_deprecated::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { RimPlot::fieldChangedByUi( changedField, oldValue, newValue ); @@ -866,7 +867,7 @@ void RimVfpPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, cons //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::initAfterRead() +void RimVfpPlot_deprecated::initAfterRead() { auto filePath = m_filePath_OBSOLETE.v().path(); if ( filePath.isEmpty() ) return; @@ -885,7 +886,7 @@ void RimVfpPlot::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::updatePlotTitle( const QString& plotTitle ) +void RimVfpPlot_deprecated::updatePlotTitle( const QString& plotTitle ) { m_plotTitle = plotTitle; @@ -900,12 +901,12 @@ void RimVfpPlot::updatePlotTitle( const QString& plotTitle ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimVfpPlot::generatePlotTitle( const QString& wellName, - int tableNumber, - RimVfpDefines::TableType tableType, - RimVfpDefines::InterpolatedVariableType interpolatedVariable, - RimVfpDefines::ProductionVariableType primaryVariable, - RimVfpDefines::ProductionVariableType familyVariable ) +QString RimVfpPlot_deprecated::generatePlotTitle( const QString& wellName, + int tableNumber, + RimVfpDefines::TableType tableType, + RimVfpDefines::InterpolatedVariableType interpolatedVariable, + RimVfpDefines::ProductionVariableType primaryVariable, + RimVfpDefines::ProductionVariableType familyVariable ) { QString tableTypeText = caf::AppEnum::uiText( tableType ); QString interpolatedVariableText = caf::AppEnum::uiText( interpolatedVariable ); @@ -919,7 +920,7 @@ QString RimVfpPlot::generatePlotTitle( const QString& w //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimVfpPlot::userDescriptionField() +caf::PdmFieldHandle* RimVfpPlot_deprecated::userDescriptionField() { return &m_plotTitle; } @@ -927,7 +928,7 @@ caf::PdmFieldHandle* RimVfpPlot::userDescriptionField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::scheduleReplot() +void RimVfpPlot_deprecated::scheduleReplot() { if ( m_plotWidget ) { @@ -938,7 +939,7 @@ void RimVfpPlot::scheduleReplot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -VfpTableSelection RimVfpPlot::tableSelection() const +VfpTableSelection RimVfpPlot_deprecated::tableSelection() const { return { m_flowRateIdx(), m_thpIdx(), m_articifialLiftQuantityIdx(), m_waterCutIdx(), m_gasLiquidRatioIdx() }; } diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot_deprecated.h similarity index 96% rename from ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h rename to ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot_deprecated.h index 96c325910f..5f3a4f513e 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpPlot_deprecated.h @@ -43,16 +43,19 @@ class VFPProdTable; } // namespace Opm //-------------------------------------------------------------------------------------------------- -/// Vertical Flow Performance Plot +/// DEPRECATED: Vertical Flow Performance Plot +/// This class is deprecated and will be removed in a future release. +/// Use RimCustomVfpPlot instead. //-------------------------------------------------------------------------------------------------- -class RimVfpPlot : public RimPlot +class RimVfpPlot_deprecated : public RimPlot { CAF_PDM_HEADER_INIT; public: - RimVfpPlot(); - ~RimVfpPlot() override; + RimVfpPlot_deprecated(); + ~RimVfpPlot_deprecated() override; +private: void setDataSource( RimVfpTable* vfpTableData ); void setTableNumber( int tableNumber ); void initializeObject(); diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTable.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTable.cpp index 0cefc9c8e7..5fbbc5ca1a 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTable.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTable.cpp @@ -141,6 +141,5 @@ void RimVfpTable::updateObjectName() //-------------------------------------------------------------------------------------------------- void RimVfpTable::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const { - menuBuilder << "RicNewVfpPlotFeature"; menuBuilder << "RicNewCustomVfpPlotFeature"; } diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp index d2161e3f85..edbf8b71a1 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimVfpTableData.cpp @@ -148,6 +148,5 @@ void RimVfpTableData::updateObjectName() //-------------------------------------------------------------------------------------------------- void RimVfpTableData::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const { - menuBuilder << "RicNewVfpPlotFeature"; menuBuilder << "RicNewCustomVfpPlotFeature"; } From 4365b0dfb9a603b410f81320d915211eca480a6a Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Tue, 18 Jun 2024 13:03:48 +0200 Subject: [PATCH 148/332] Grid import using opm-common improvements (#11438) * Update opm-common EGRID reader to support LGRs, NNCs, dual porosity, unit system info and time step filters * Rearrange well reading code into separate class * Update resdata library to not require an ecl_grid when reading well information. Only lgr names are needed, allows reused by opm_common reader --- .../Application/Tools/RiaQDateTimeTools.cpp | 6 +- .../Application/Tools/RiaQDateTimeTools.h | 2 +- .../FileInterface/CMakeLists_files.cmake | 9 +- .../RifEclipseOutputFileTools.cpp | 154 +- .../FileInterface/RifEclipseOutputFileTools.h | 40 +- ...ccess.cpp => RifEclipseReportKeywords.cpp} | 30 +- .../FileInterface/RifEclipseReportKeywords.h | 91 ++ .../RifEclipseRestartDataAccess.h | 77 +- .../RifEclipseRestartFilesetAccess.cpp | 2 +- .../RifEclipseRestartFilesetAccess.h | 2 +- .../RifEclipseUnifiedRestartFileAccess.cpp | 2 +- .../RifEclipseUnifiedRestartFileAccess.h | 2 +- ...ridTools.cpp => RifOpmRadialGridTools.cpp} | 278 +--- ...OpmGridTools.h => RifOpmRadialGridTools.h} | 26 +- .../FileInterface/RifReaderEclipseOutput.cpp | 1362 ++--------------- .../FileInterface/RifReaderEclipseOutput.h | 30 +- .../FileInterface/RifReaderEclipseWell.cpp | 1006 ++++++++++++ .../FileInterface/RifReaderEclipseWell.h | 78 + .../FileInterface/RifReaderInterface.cpp | 4 +- .../FileInterface/RifReaderInterface.h | 2 +- .../FileInterface/RifReaderOpmCommon.cpp | 847 +++++++--- .../FileInterface/RifReaderOpmCommon.h | 51 +- .../Flow/RimFlowCharacteristicsPlot.cpp | 11 +- .../ProjectDataModel/RimEclipseResultCase.cpp | 83 +- .../ProjectDataModel/RimEclipseResultCase.h | 1 + .../RigFlowDiagSolverInterface.cpp | 5 + .../ReservoirDataModel/RigMainGrid.cpp | 15 + .../ReservoirDataModel/RigMainGrid.h | 1 + .../ReservoirDataModel/RigSimWellData.cpp | 4 +- ThirdParty/Ert/lib/ecl/well_info.cpp | 187 +-- ThirdParty/Ert/lib/ecl/well_state.cpp | 760 ++++----- .../lib/include/ert/ecl_well/well_info.hpp | 40 +- .../lib/include/ert/ecl_well/well_state.hpp | 98 +- ThirdParty/custom-opm-common/opm-common | 2 +- 34 files changed, 2851 insertions(+), 2457 deletions(-) rename ApplicationLibCode/FileInterface/{RifEclipseRestartDataAccess.cpp => RifEclipseReportKeywords.cpp} (62%) create mode 100644 ApplicationLibCode/FileInterface/RifEclipseReportKeywords.h rename ApplicationLibCode/FileInterface/{RifOpmGridTools.cpp => RifOpmRadialGridTools.cpp} (55%) rename ApplicationLibCode/FileInterface/{RifOpmGridTools.h => RifOpmRadialGridTools.h} (67%) create mode 100644 ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp create mode 100644 ApplicationLibCode/FileInterface/RifReaderEclipseWell.h diff --git a/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp b/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp index 344a52ac20..f9bb01ef86 100644 --- a/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp @@ -201,12 +201,12 @@ QDateTime RiaQDateTimeTools::subtractPeriod( const QDateTime& dt, RiaDefines::Da //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QDateTime RiaQDateTimeTools::createDateTime( const QDate& date ) +QDateTime RiaQDateTimeTools::createDateTime( const QDate& date, Qt::TimeSpec timeSpec /*= Qt::LocalTime*/ ) { #if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 ) - return date.startOfDay(); + return date.startOfDay( timeSpec ); #else - return QDateTime( date, QTime( 0, 0 ) ); + return QDateTime( date, QTime( 0, 0 ), timeSpec ); #endif } diff --git a/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.h b/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.h index 334abbeb93..9f8647f462 100644 --- a/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.h +++ b/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.h @@ -58,7 +58,7 @@ class RiaQDateTimeTools static QDateTime addPeriod( const QDateTime& dt, RiaDefines::DateTimePeriod period ); static QDateTime subtractPeriod( const QDateTime& dt, RiaDefines::DateTimePeriod period ); - static QDateTime createDateTime( const QDate& date ); + static QDateTime createDateTime( const QDate& date, Qt::TimeSpec timeSpec = Qt::LocalTime ); static QDateTime epoch(); diff --git a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake index 71155c2019..b70fb67ef0 100644 --- a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake @@ -10,6 +10,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RifPerforationIntervalReader.h ${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseInput.h ${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseOutput.h + ${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseWell.h ${CMAKE_CURRENT_LIST_DIR}/RifSummaryReaderInterface.h ${CMAKE_CURRENT_LIST_DIR}/RifEclipseUserDataParserTools.h ${CMAKE_CURRENT_LIST_DIR}/RifColumnBasedUserDataParser.h @@ -79,12 +80,13 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RifSeismicReader.h ${CMAKE_CURRENT_LIST_DIR}/RifSeismicZGYReader.h ${CMAKE_CURRENT_LIST_DIR}/RifOpenVDSReader.h - ${CMAKE_CURRENT_LIST_DIR}/RifOpmGridTools.h + ${CMAKE_CURRENT_LIST_DIR}/RifOpmRadialGridTools.h ${CMAKE_CURRENT_LIST_DIR}/RifCsvSummaryReader.h ${CMAKE_CURRENT_LIST_DIR}/RifRevealSummaryCsvReader.h ${CMAKE_CURRENT_LIST_DIR}/RifRevealCsvSectionSummaryReader.h ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanCsvSummaryReader.h ${CMAKE_CURRENT_LIST_DIR}/RifReaderOpmCommon.h + ${CMAKE_CURRENT_LIST_DIR}/RifEclipseReportKeywords.h ${CMAKE_CURRENT_LIST_DIR}/RifInpExportTools.h ${CMAKE_CURRENT_LIST_DIR}/RifFaultReactivationModelExporter.h ${CMAKE_CURRENT_LIST_DIR}/RifThermalToStimPlanFractureXmlOutput.h @@ -107,13 +109,13 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputFileTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RifRoffFileTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RifEclipseOutputFileTools.cpp - ${CMAKE_CURRENT_LIST_DIR}/RifEclipseRestartDataAccess.cpp ${CMAKE_CURRENT_LIST_DIR}/RifEclipseRestartFilesetAccess.cpp ${CMAKE_CURRENT_LIST_DIR}/RifEclipseUnifiedRestartFileAccess.cpp ${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RifPerforationIntervalReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseInput.cpp ${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseOutput.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseWell.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSummaryReaderInterface.cpp ${CMAKE_CURRENT_LIST_DIR}/RifEclipseUserDataParserTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RifColumnBasedUserDataParser.cpp @@ -180,9 +182,10 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RifSeismicReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSeismicZGYReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifOpenVDSReader.cpp - ${CMAKE_CURRENT_LIST_DIR}/RifOpmGridTools.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifOpmRadialGridTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RifCsvSummaryReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifRevealCsvSummaryReader.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifEclipseReportKeywords.cpp ${CMAKE_CURRENT_LIST_DIR}/RifRevealCsvSectionSummaryReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanCsvSummaryReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifReaderOpmCommon.cpp diff --git a/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp index 84e175f1b9..fe49ffb81d 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -23,6 +23,7 @@ #include "RiaQDateTimeTools.h" #include "RiaStringEncodingTools.h" +#include "RifEclipseReportKeywords.h" #include "RifEclipseRestartFilesetAccess.h" #include "RifEclipseUnifiedRestartFileAccess.h" @@ -67,7 +68,7 @@ RifEclipseOutputFileTools::~RifEclipseOutputFileTools() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifEclipseOutputFileTools::keywordValueCounts( const std::vector& ecl_files ) +std::vector RifEclipseOutputFileTools::keywordValueCounts( const std::vector& ecl_files ) { auto reportstepMetaData = RifEclipseOutputFileTools::createReportStepsMetaData( ecl_files ); return reportstepMetaData.keywordValueCounts(); @@ -76,10 +77,11 @@ std::vector RifEclipseOutputFileTools::keywordValueCounts( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifEclipseOutputFileTools::createResultEntries( const std::vector& fileKeywordInfo, - const std::vector& timeStepInfo, - RiaDefines::ResultCatType resultCategory, - RigEclipseCaseData* eclipseCaseData ) +void RifEclipseOutputFileTools::createResultEntries( const std::vector& fileKeywordInfo, + const std::vector& timeStepInfo, + RiaDefines::ResultCatType resultCategory, + RigEclipseCaseData* eclipseCaseData, + size_t totalTimeSteps ) { if ( !eclipseCaseData ) return; @@ -91,12 +93,17 @@ void RifEclipseOutputFileTools::createResultEntries( const std::vectoractiveCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ), eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ), RiaDefines::PorosityModelType::MATRIX_MODEL, - timeStepInfo.size() ); + totalTimeSteps ); + + if ( resultCategory == RiaDefines::ResultCatType::STATIC_NATIVE ) + { + validKeywords.push_back( RifEclipseKeywordValueCount( "ACTNUM", 0, RifEclipseKeywordValueCount::KeywordDataType::INTEGER ) ); + } for ( const auto& keywordData : validKeywords ) { RigEclipseResultAddress resAddr( resultCategory, - RifKeywordValueCount::mapType( keywordData.dataType() ), + RifEclipseKeywordValueCount::mapType( keywordData.dataType() ), QString::fromStdString( keywordData.keyword() ) ); matrixModelResults->createResultEntry( resAddr, false ); matrixModelResults->setTimeStepInfos( resAddr, timeStepInfo ); @@ -108,12 +115,17 @@ void RifEclipseOutputFileTools::createResultEntries( const std::vectoractiveCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ), eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ), RiaDefines::PorosityModelType::FRACTURE_MODEL, - timeStepInfo.size() ); + totalTimeSteps ); + + if ( resultCategory == RiaDefines::ResultCatType::STATIC_NATIVE ) + { + validKeywords.push_back( RifEclipseKeywordValueCount( "ACTNUM", 0, RifEclipseKeywordValueCount::KeywordDataType::INTEGER ) ); + } for ( const auto& keywordData : validKeywords ) { RigEclipseResultAddress resAddr( resultCategory, - RifKeywordValueCount::mapType( keywordData.dataType() ), + RifEclipseKeywordValueCount::mapType( keywordData.dataType() ), QString::fromStdString( keywordData.keyword() ) ); fractureModelResults->createResultEntry( resAddr, false ); fractureModelResults->setTimeStepInfos( resAddr, timeStepInfo ); @@ -124,7 +136,7 @@ void RifEclipseOutputFileTools::createResultEntries( const std::vector& ecl_files ) +RifEclipseReportKeywords RifEclipseOutputFileTools::createReportStepsMetaData( const std::vector& ecl_files ) { - RifRestartReportKeywords reportSteps; + RifEclipseReportKeywords reportSteps; for ( auto ecl_file : ecl_files ) { @@ -753,18 +765,18 @@ RifRestartReportKeywords RifEclipseOutputFileTools::createReportStepsMetaData( c continue; } - RifKeywordValueCount::KeywordDataType dataType = RifKeywordValueCount::KeywordDataType::UNKNOWN; + auto dataType = RifEclipseKeywordValueCount::KeywordDataType::UNKNOWN; if ( dataTypeEnumOnFile == ECL_DOUBLE_TYPE ) { - dataType = RifKeywordValueCount::KeywordDataType::DOUBLE; + dataType = RifEclipseKeywordValueCount::KeywordDataType::DOUBLE; } else if ( dataTypeEnumOnFile == ECL_FLOAT_TYPE ) { - dataType = RifKeywordValueCount::KeywordDataType::FLOAT; + dataType = RifEclipseKeywordValueCount::KeywordDataType::FLOAT; } else if ( dataTypeEnumOnFile == ECL_INT_TYPE ) { - dataType = RifKeywordValueCount::KeywordDataType::INTEGER; + dataType = RifEclipseKeywordValueCount::KeywordDataType::INTEGER; } int itemCount = ecl_file_iget_named_size( ecl_file, kw, iOcc ); @@ -786,12 +798,12 @@ RifRestartReportKeywords RifEclipseOutputFileTools::createReportStepsMetaData( c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector - RifEclipseOutputFileTools::validKeywordsForPorosityModel( const std::vector& keywordItemCounts, - const RigActiveCellInfo* matrixActiveCellInfo, - const RigActiveCellInfo* fractureActiveCellInfo, - RiaDefines::PorosityModelType porosityModel, - size_t timeStepCount ) +std::vector + RifEclipseOutputFileTools::validKeywordsForPorosityModel( const std::vector& keywordItemCounts, + const RigActiveCellInfo* matrixActiveCellInfo, + const RigActiveCellInfo* fractureActiveCellInfo, + RiaDefines::PorosityModelType porosityModel, + size_t timeStepCount ) { if ( !matrixActiveCellInfo ) return {}; @@ -800,7 +812,7 @@ std::vector return {}; } - std::vector keywordsWithCorrectNumberOfDataItems; + std::vector keywordsWithCorrectNumberOfDataItems; for ( const auto& keywordValueCount : keywordItemCounts ) { @@ -809,39 +821,39 @@ std::vector bool validKeyword = false; - size_t timeStepsAllCellsRest = valueCount % matrixActiveCellInfo->reservoirCellCount(); - if ( timeStepsAllCellsRest == 0 && valueCount <= timeStepCount * matrixActiveCellInfo->reservoirCellCount() ) + auto matrixActiveCellCount = matrixActiveCellInfo->reservoirActiveCellCount(); + auto fractureActiveCellCount = fractureActiveCellInfo->reservoirActiveCellCount(); + + size_t timeStepsAllCellsRest = valueCount % matrixActiveCellCount; + if ( timeStepsAllCellsRest == 0 && valueCount <= timeStepCount * matrixActiveCellCount ) { // Found result for all cells for N time steps, usually a static dataset for one time step validKeyword = true; } else { - size_t timeStepsMatrixRest = valueCount % matrixActiveCellInfo->reservoirActiveCellCount(); + size_t timeStepsMatrixRest = valueCount % matrixActiveCellCount; size_t timeStepsFractureRest = 0; - if ( fractureActiveCellInfo->reservoirActiveCellCount() > 0 ) + if ( fractureActiveCellCount > 0 ) { - timeStepsFractureRest = valueCount % fractureActiveCellInfo->reservoirActiveCellCount(); + timeStepsFractureRest = valueCount % fractureActiveCellCount; } - size_t sumFractureMatrixActiveCellCount = matrixActiveCellInfo->reservoirActiveCellCount() + - fractureActiveCellInfo->reservoirActiveCellCount(); - size_t timeStepsMatrixAndFractureRest = valueCount % sumFractureMatrixActiveCellCount; + size_t sumFractureMatrixActiveCellCount = matrixActiveCellCount + fractureActiveCellCount; + size_t timeStepsMatrixAndFractureRest = valueCount % sumFractureMatrixActiveCellCount; if ( porosityModel == RiaDefines::PorosityModelType::MATRIX_MODEL && timeStepsMatrixRest == 0 ) { - if ( valueCount <= - timeStepCount * std::max( matrixActiveCellInfo->reservoirActiveCellCount(), sumFractureMatrixActiveCellCount ) ) + if ( valueCount <= timeStepCount * std::max( matrixActiveCellCount, sumFractureMatrixActiveCellCount ) ) { validKeyword = true; } } - else if ( porosityModel == RiaDefines::PorosityModelType::FRACTURE_MODEL && - fractureActiveCellInfo->reservoirActiveCellCount() > 0 && timeStepsFractureRest == 0 ) + else if ( porosityModel == RiaDefines::PorosityModelType::FRACTURE_MODEL && fractureActiveCellCount > 0 && + timeStepsFractureRest == 0 ) { - if ( valueCount <= - timeStepCount * std::max( fractureActiveCellInfo->reservoirActiveCellCount(), sumFractureMatrixActiveCellCount ) ) + if ( valueCount <= timeStepCount * std::max( fractureActiveCellCount, sumFractureMatrixActiveCellCount ) ) { validKeyword = true; } @@ -855,13 +867,23 @@ std::vector } } + // is this a result with a value for all cells? + if ( !validKeyword ) + { + if ( valueCount > 0 && ( porosityModel == RiaDefines::PorosityModelType::MATRIX_MODEL ) && + ( valueCount % matrixActiveCellInfo->reservoirCellCount() == 0 ) ) + { + validKeyword = true; + } + } + // Check for INIT values that has only values for main grid active cells if ( !validKeyword ) { if ( timeStepCount == 1 ) { - size_t mainGridMatrixActiveCellCount = matrixActiveCellInfo->gridActiveCellCounts( 0 ); - size_t mainGridFractureActiveCellCount = fractureActiveCellInfo->gridActiveCellCounts( 0 ); + size_t mainGridMatrixActiveCellCount = matrixActiveCellInfo->reservoirActiveCellCount(); + size_t mainGridFractureActiveCellCount = fractureActiveCellInfo->reservoirActiveCellCount(); if ( valueCount == mainGridMatrixActiveCellCount || valueCount == mainGridFractureActiveCellCount || valueCount == mainGridMatrixActiveCellCount + mainGridFractureActiveCellCount ) @@ -879,3 +901,57 @@ std::vector return keywordsWithCorrectNumberOfDataItems; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseOutputFileTools::extractResultValuesBasedOnPorosityModel( RigEclipseCaseData* eclipseCaseData, + RiaDefines::PorosityModelType matrixOrFracture, + std::vector* destinationResultValues, + const std::vector& sourceResultValues ) +{ + if ( sourceResultValues.empty() ) return; + + RigActiveCellInfo* fracActCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); + + if ( matrixOrFracture == RiaDefines::PorosityModelType::MATRIX_MODEL && fracActCellInfo->reservoirActiveCellCount() == 0 ) + { + destinationResultValues->insert( destinationResultValues->end(), sourceResultValues.begin(), sourceResultValues.end() ); + } + else + { + RigActiveCellInfo* actCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + + size_t sourceStartPosition = 0; + + for ( size_t i = 0; i < eclipseCaseData->mainGrid()->gridCount(); i++ ) + { + if ( eclipseCaseData->mainGrid()->gridByIndex( i )->isTempGrid() ) continue; + + size_t matrixActiveCellCount = actCellInfo->gridActiveCellCounts( i ); + size_t fractureActiveCellCount = fracActCellInfo->gridActiveCellCounts( i ); + + if ( matrixOrFracture == RiaDefines::PorosityModelType::MATRIX_MODEL ) + { + destinationResultValues->insert( destinationResultValues->end(), + sourceResultValues.begin() + sourceStartPosition, + sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount ); + } + else + { + if ( ( matrixActiveCellCount + fractureActiveCellCount ) > sourceResultValues.size() ) + { + // Special handling of the situation where we only have data for one fracture mode + matrixActiveCellCount = 0; + } + + destinationResultValues->insert( destinationResultValues->end(), + sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount, + sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount + + fractureActiveCellCount ); + } + + sourceStartPosition += ( matrixActiveCellCount + fractureActiveCellCount ); + } + } +} diff --git a/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.h b/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.h index 7301ed2420..38181b1e09 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.h +++ b/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.h @@ -20,8 +20,13 @@ #pragma once -#include "RifEclipseRestartDataAccess.h" +#include "RifEclipseReportKeywords.h" +#include "RiaDefines.h" +#include "RiaPorosityModel.h" + +#include "ert/ecl/ecl_file_view.h" +#include "ert/ecl/ecl_grid.h" #include "ert/ecl/ecl_util.h" #include "cvfObject.h" @@ -37,6 +42,8 @@ using ecl_file_type = struct ecl_file_struct; class RifEclipseRestartDataAccess; class RigEclipseTimeStepInfo; class RigActiveCellInfo; +class RigEclipseCaseData; + class QByteArray; //================================================================================================== @@ -50,12 +57,13 @@ class RifEclipseOutputFileTools RifEclipseOutputFileTools(); virtual ~RifEclipseOutputFileTools(); - static std::vector keywordValueCounts( const std::vector& ecl_files ); + static std::vector keywordValueCounts( const std::vector& ecl_files ); - static void createResultEntries( const std::vector& fileKeywordInfo, - const std::vector& timeStepInfo, - RiaDefines::ResultCatType resultCategory, - RigEclipseCaseData* eclipseCaseData ); + static void createResultEntries( const std::vector& fileKeywordInfo, + const std::vector& timeStepInfo, + RiaDefines::ResultCatType resultCategory, + RigEclipseCaseData* eclipseCaseData, + size_t totalTimeSteps ); static bool keywordData( const ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector* values ); static bool keywordData( const ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector* values ); @@ -94,11 +102,19 @@ class RifEclipseOutputFileTools static bool assignActiveCellData( std::vector>& actnumValuesPerGrid, RigEclipseCaseData* eclipseCaseData ); + static std::vector + validKeywordsForPorosityModel( const std::vector& keywordItemCounts, + const RigActiveCellInfo* activeCellInfo, + const RigActiveCellInfo* fractureActiveCellInfo, + RiaDefines::PorosityModelType matrixOrFracture, + size_t timeStepCount ); + + static void extractResultValuesBasedOnPorosityModel( RigEclipseCaseData* eclipseCaseData, + RiaDefines::PorosityModelType matrixOrFracture, + std::vector* values, + const std::vector& fileValues ); + private: - static RifRestartReportKeywords createReportStepsMetaData( const std::vector& ecl_files ); - static std::vector validKeywordsForPorosityModel( const std::vector& keywordItemCounts, - const RigActiveCellInfo* activeCellInfo, - const RigActiveCellInfo* fractureActiveCellInfo, - RiaDefines::PorosityModelType matrixOrFracture, - size_t timeStepCount ); + static void getDayMonthYear( const ecl_kw_type* intehead_kw, int* day, int* month, int* year ); + static RifEclipseReportKeywords createReportStepsMetaData( const std::vector& ecl_files ); }; diff --git a/ApplicationLibCode/FileInterface/RifEclipseRestartDataAccess.cpp b/ApplicationLibCode/FileInterface/RifEclipseReportKeywords.cpp similarity index 62% rename from ApplicationLibCode/FileInterface/RifEclipseRestartDataAccess.cpp rename to ApplicationLibCode/FileInterface/RifEclipseReportKeywords.cpp index 4ba7ff912c..14ee9f1a82 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseRestartDataAccess.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseReportKeywords.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// Copyright (C) 2024 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 @@ -16,32 +16,20 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RifEclipseRestartDataAccess.h" - -//-------------------------------------------------------------------------------------------------- -/// Constructor -//-------------------------------------------------------------------------------------------------- -RifEclipseRestartDataAccess::RifEclipseRestartDataAccess() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// Destructor -//-------------------------------------------------------------------------------------------------- -RifEclipseRestartDataAccess::~RifEclipseRestartDataAccess() -{ -} +#include "RifEclipseReportKeywords.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifRestartReportKeywords::appendKeywordCount( const std::string& keyword, size_t valueCount, RifKeywordValueCount::KeywordDataType dataType ) +void RifEclipseReportKeywords::appendKeywordCount( const std::string& keyword, + size_t valueCount, + RifEclipseKeywordValueCount::KeywordDataType dataType ) { auto it = m_keywordValueCounts.find( keyword ); if ( it == m_keywordValueCounts.end() ) { - m_keywordValueCounts[keyword] = RifKeywordValueCount( keyword, valueCount, dataType ); + m_keywordValueCounts[keyword] = RifEclipseKeywordValueCount( keyword, valueCount, dataType ); } else { @@ -52,7 +40,7 @@ void RifRestartReportKeywords::appendKeywordCount( const std::string& keyword, s //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifRestartReportKeywords::appendKeywordCount( const RifRestartReportKeywords& other ) +void RifEclipseReportKeywords::appendKeywordCount( const RifEclipseReportKeywords& other ) { for ( const auto& [keyword, keywordInfo] : other.m_keywordValueCounts ) { @@ -63,9 +51,9 @@ void RifRestartReportKeywords::appendKeywordCount( const RifRestartReportKeyword //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifRestartReportKeywords::keywordValueCounts() const +std::vector RifEclipseReportKeywords::keywordValueCounts() const { - std::vector tmp; + std::vector tmp; for ( const auto& [keyword, info] : m_keywordValueCounts ) { tmp.push_back( info ); diff --git a/ApplicationLibCode/FileInterface/RifEclipseReportKeywords.h b/ApplicationLibCode/FileInterface/RifEclipseReportKeywords.h new file mode 100644 index 0000000000..617ea17386 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifEclipseReportKeywords.h @@ -0,0 +1,91 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RiaDefines.h" + +#include +#include + +class RifEclipseKeywordValueCount +{ +public: + enum class KeywordDataType + { + UNKNOWN, + FLOAT, + DOUBLE, + INTEGER, + }; + +public: + RifEclipseKeywordValueCount( const std::string& keyword, size_t itemCount, KeywordDataType dataType ) + : m_keyword( keyword ) + , m_valueCount( itemCount ) + , m_dataType( dataType ) + { + } + + RifEclipseKeywordValueCount() + : m_valueCount( 0 ) + , m_dataType( KeywordDataType::UNKNOWN ) + { + } + + void addValueCount( size_t valueCount ) { m_valueCount += valueCount; } + + std::string keyword() const { return m_keyword; } + size_t valueCount() const { return m_valueCount; } + KeywordDataType dataType() const { return m_dataType; } + + static RiaDefines::ResultDataType mapType( RifEclipseKeywordValueCount::KeywordDataType dataType ) + { + switch ( dataType ) + { + case RifEclipseKeywordValueCount::KeywordDataType::FLOAT: + return RiaDefines::ResultDataType::FLOAT; + case RifEclipseKeywordValueCount::KeywordDataType::DOUBLE: + return RiaDefines::ResultDataType::DOUBLE; + case RifEclipseKeywordValueCount::KeywordDataType::INTEGER: + return RiaDefines::ResultDataType::INTEGER; + } + + return RiaDefines::ResultDataType::UNKNOWN; + } + +private: + std::string m_keyword; + size_t m_valueCount; + KeywordDataType m_dataType; +}; + +//================================================================================================== +// +//================================================================================================== +class RifEclipseReportKeywords +{ +public: + void appendKeywordCount( const RifEclipseReportKeywords& other ); + void appendKeywordCount( const std::string& keyword, size_t valueCount, RifEclipseKeywordValueCount::KeywordDataType dataType ); + + std::vector keywordValueCounts() const; + +private: + std::map m_keywordValueCounts; +}; diff --git a/ApplicationLibCode/FileInterface/RifEclipseRestartDataAccess.h b/ApplicationLibCode/FileInterface/RifEclipseRestartDataAccess.h index 2c7395970d..791821d75f 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseRestartDataAccess.h +++ b/ApplicationLibCode/FileInterface/RifEclipseRestartDataAccess.h @@ -29,78 +29,9 @@ #include "ert/ecl_well/well_info.hpp" +#include "RifEclipseReportKeywords.h" #include "RifReaderInterface.h" -//================================================================================================== -// -//================================================================================================== -class RifKeywordValueCount -{ -public: - enum class KeywordDataType - { - UNKNOWN, - FLOAT, - DOUBLE, - INTEGER, - }; - -public: - RifKeywordValueCount( const std::string& keyword, size_t itemCount, KeywordDataType dataType ) - : m_keyword( keyword ) - , m_valueCount( itemCount ) - , m_dataType( dataType ) - { - } - - RifKeywordValueCount() - : m_valueCount( 0 ) - , m_dataType( KeywordDataType::UNKNOWN ) - { - } - - void addValueCount( size_t valueCount ) { m_valueCount += valueCount; } - - std::string keyword() const { return m_keyword; } - size_t valueCount() const { return m_valueCount; } - KeywordDataType dataType() const { return m_dataType; } - - static RiaDefines::ResultDataType mapType( RifKeywordValueCount::KeywordDataType dataType ) - { - switch ( dataType ) - { - case RifKeywordValueCount::KeywordDataType::FLOAT: - return RiaDefines::ResultDataType::FLOAT; - case RifKeywordValueCount::KeywordDataType::DOUBLE: - return RiaDefines::ResultDataType::DOUBLE; - case RifKeywordValueCount::KeywordDataType::INTEGER: - return RiaDefines::ResultDataType::INTEGER; - } - - return RiaDefines::ResultDataType::UNKNOWN; - } - -private: - std::string m_keyword; - size_t m_valueCount; - KeywordDataType m_dataType; -}; - -//================================================================================================== -// -//================================================================================================== -class RifRestartReportKeywords -{ -public: - void appendKeywordCount( const RifRestartReportKeywords& other ); - void appendKeywordCount( const std::string& keyword, size_t valueCount, RifKeywordValueCount::KeywordDataType dataType ); - - std::vector keywordValueCounts() const; - -private: - std::map m_keywordValueCounts; -}; - //================================================================================================== // // Abstract class for results access @@ -109,8 +40,8 @@ class RifRestartReportKeywords class RifEclipseRestartDataAccess : public cvf::Object { public: - RifEclipseRestartDataAccess(); - ~RifEclipseRestartDataAccess() override; + RifEclipseRestartDataAccess(){}; + ~RifEclipseRestartDataAccess() override{}; virtual bool open() = 0; virtual void setRestartFiles( const QStringList& fileSet ) = 0; @@ -121,7 +52,7 @@ class RifEclipseRestartDataAccess : public cvf::Object virtual void timeSteps( std::vector* timeSteps, std::vector* daysSinceSimulationStart ) = 0; virtual std::vector reportNumbers() = 0; - virtual std::vector keywordValueCounts() = 0; + virtual std::vector keywordValueCounts() = 0; virtual bool results( const QString& resultName, size_t timeStep, size_t gridCount, std::vector* values ) = 0; virtual bool dynamicNNCResults( const ecl_grid_type* grid, diff --git a/ApplicationLibCode/FileInterface/RifEclipseRestartFilesetAccess.cpp b/ApplicationLibCode/FileInterface/RifEclipseRestartFilesetAccess.cpp index 23355bfdc5..5794de7c4f 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseRestartFilesetAccess.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseRestartFilesetAccess.cpp @@ -158,7 +158,7 @@ void RifEclipseRestartFilesetAccess::timeSteps( std::vector* timeStep //-------------------------------------------------------------------------------------------------- /// Get list of result names //-------------------------------------------------------------------------------------------------- -std::vector RifEclipseRestartFilesetAccess::keywordValueCounts() +std::vector RifEclipseRestartFilesetAccess::keywordValueCounts() { CVF_ASSERT( timeStepCount() > 0 ); diff --git a/ApplicationLibCode/FileInterface/RifEclipseRestartFilesetAccess.h b/ApplicationLibCode/FileInterface/RifEclipseRestartFilesetAccess.h index 931b366e30..6ec2c54159 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseRestartFilesetAccess.h +++ b/ApplicationLibCode/FileInterface/RifEclipseRestartFilesetAccess.h @@ -46,7 +46,7 @@ class RifEclipseRestartFilesetAccess : public RifEclipseRestartDataAccess void timeSteps( std::vector* timeSteps, std::vector* daysSinceSimulationStart ) override; std::vector reportNumbers() override; - std::vector keywordValueCounts() override; + std::vector keywordValueCounts() override; bool results( const QString& resultName, size_t timeStep, size_t gridCount, std::vector* values ) override; bool dynamicNNCResults( const ecl_grid_type* grid, diff --git a/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp b/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp index a62874f114..da983b20c5 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp @@ -214,7 +214,7 @@ void RifEclipseUnifiedRestartFileAccess::timeSteps( std::vector* time //-------------------------------------------------------------------------------------------------- /// Get list of result names //-------------------------------------------------------------------------------------------------- -std::vector RifEclipseUnifiedRestartFileAccess::keywordValueCounts() +std::vector RifEclipseUnifiedRestartFileAccess::keywordValueCounts() { if ( openFile() ) { diff --git a/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h b/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h index fd2183cb68..8c666d5543 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h +++ b/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h @@ -47,7 +47,7 @@ class RifEclipseUnifiedRestartFileAccess : public RifEclipseRestartDataAccess void timeSteps( std::vector* timeSteps, std::vector* daysSinceSimulationStart ) override; std::vector reportNumbers() override; - std::vector keywordValueCounts() override; + std::vector keywordValueCounts() override; bool results( const QString& resultName, size_t timeStep, size_t gridCount, std::vector* values ) override; bool dynamicNNCResults( const ecl_grid_type* grid, diff --git a/ApplicationLibCode/FileInterface/RifOpmGridTools.cpp b/ApplicationLibCode/FileInterface/RifOpmRadialGridTools.cpp similarity index 55% rename from ApplicationLibCode/FileInterface/RifOpmGridTools.cpp rename to ApplicationLibCode/FileInterface/RifOpmRadialGridTools.cpp index 56183d2212..58d80ae807 100644 --- a/ApplicationLibCode/FileInterface/RifOpmGridTools.cpp +++ b/ApplicationLibCode/FileInterface/RifOpmRadialGridTools.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RifOpmGridTools.h" +#include "RifOpmRadialGridTools.h" #include "RiaLogging.h" #include "RiaWeightedMeanCalculator.h" @@ -37,7 +37,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifOpmGridTools::importCoordinatesForRadialGrid( const std::string& gridFilePath, RigMainGrid* riMainGrid ) +void RifOpmRadialGridTools::importCoordinatesForRadialGrid( const std::string& gridFilePath, RigMainGrid* riMainGrid ) { CAF_ASSERT( riMainGrid ); @@ -73,7 +73,7 @@ void RifOpmGridTools::importCoordinatesForRadialGrid( const std::string& gridFil if ( opmMainGrid.is_radial() ) { - transferCoordinates( opmMainGrid, opmMainGrid, riMainGrid, riMainGrid ); + transferCoordinatesRadial( opmMainGrid, opmMainGrid, riMainGrid, riMainGrid ); } auto lgrNames = opmMainGrid.list_of_lgrs(); @@ -88,7 +88,7 @@ void RifOpmGridTools::importCoordinatesForRadialGrid( const std::string& gridFil auto riLgrGrid = riMainGrid->gridByIndex( i ); if ( riLgrGrid->gridName() == lgrName ) { - transferCoordinates( opmMainGrid, opmLgrGrid, riMainGrid, riLgrGrid ); + transferCoordinatesRadial( opmMainGrid, opmLgrGrid, riMainGrid, riLgrGrid ); } } } @@ -101,87 +101,6 @@ void RifOpmGridTools::importCoordinatesForRadialGrid( const std::string& gridFil } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RifOpmGridTools::cellCount( const std::string& gridFilePath ) -{ - Opm::EclIO::EGrid opmGrid( gridFilePath ); - - return opmGrid.totalNumberOfCells(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RifOpmGridTools::importGrid( const std::string& gridFilePath, RigMainGrid* mainGrid, RigEclipseCaseData* caseData ) -{ - Opm::EclIO::EGrid opmGrid( gridFilePath ); - - auto dims = opmGrid.dimension(); - mainGrid->setGridPointDimensions( cvf::Vec3st( dims[0] + 1, dims[1] + 1, dims[2] + 1 ) ); - - RigCell defaultCell; - defaultCell.setHostGrid( mainGrid ); - auto cellCount = opmGrid.totalNumberOfCells(); - mainGrid->globalCellArray().resize( cellCount, defaultCell ); - mainGrid->nodes().resize( 8 * cellCount ); - - transferCoordinatesCartesian( opmGrid, opmGrid, mainGrid, mainGrid, caseData ); - - auto opmMapAxes = opmGrid.get_mapaxes(); - if ( opmMapAxes.size() == 6 ) - { - std::array mapAxes; - for ( size_t i = 0; i < opmMapAxes.size(); ++i ) - { - mapAxes[i] = opmMapAxes[i]; - } - - // Set the map axes transformation matrix on the main grid - mainGrid->setMapAxes( mapAxes ); - mainGrid->setUseMapAxes( true ); - - auto transform = mainGrid->mapAxisTransform(); - - // Invert the transformation matrix to convert from file coordinates to domain coordinates - transform.invert(); - -#pragma omp parallel for - for ( long i = 0; i < static_cast( mainGrid->nodes().size() ); i++ ) - { - auto& n = mainGrid->nodes()[i]; - n.transformPoint( transform ); - } - } - - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector> RifOpmGridTools::activeCellsFromActnumKeyword( Opm::EclIO::EGrid& grid ) -{ - auto arrayNames = grid.arrayNames(); - int actnumArrayIndex = -1; - - for ( size_t i = 0; i < arrayNames.size(); i++ ) - { - if ( arrayNames[i] == "ACTNUM" ) - { - actnumArrayIndex = static_cast( i ); - break; - } - } - - if ( actnumArrayIndex < 0 ) return {}; - - auto actnumMainGrid = grid.get( actnumArrayIndex ); - - return { actnumMainGrid }; -} - //-------------------------------------------------------------------------------------------------- // // A radial grid is defined by a center point and a set of cylindrical coordinates. The coordinates at the @@ -213,7 +132,10 @@ std::vector> RifOpmGridTools::activeCellsFromActnumKeyword( Opm // 3. Find the closest point on this pillar, and use this point as the adjusted coordinate for the node // //-------------------------------------------------------------------------------------------------- -void RifOpmGridTools::transferCoordinates( Opm::EclIO::EGrid& opmMainGrid, Opm::EclIO::EGrid& opmGrid, RigMainGrid* riMainGrid, RigGridBase* riGrid ) +void RifOpmRadialGridTools::transferCoordinatesRadial( Opm::EclIO::EGrid& opmMainGrid, + Opm::EclIO::EGrid& opmGrid, + RigMainGrid* riMainGrid, + RigGridBase* riGrid ) { size_t cellCount = opmGrid.totalNumberOfCells(); if ( cellCount != riGrid->cellCount() ) return; @@ -266,153 +188,102 @@ void RifOpmGridTools::transferCoordinates( Opm::EclIO::EGrid& opmMainGrid, Opm:: // First grid dimension is radius, check if cell has are at the outer-most slice if ( !hostCellGlobalIndices.empty() && ( gridDimension[0] - 1 == ijkCell[0] ) ) { - std::array cellRadius{}; - std::array cellTheta{}; - std::array cellZ{}; - opmGrid.getRadialCellCorners( ijkCell, cellRadius, cellTheta, cellZ ); - - double maxRadius = *std::max_element( cellRadius.begin(), cellRadius.end() ); - - // Check if the radius is at the outer surface of the radial grid - // Adjust the outer nodes to match the corner pillars of the host cell - const double epsilon = 0.15; - if ( fabs( maxRadius - cellRadius[opmNodeIndex] ) < epsilon * cellRadius[opmNodeIndex] ) - { - const auto hostCellIndex = hostCellGlobalIndices[opmCellIndex]; - - double closestPillarDistance = std::numeric_limits::max(); - int closestPillarIndex = -1; - - const auto cylinderCoordX = opmX[opmNodeIndex] + xCenterCoordOpm; - const auto cylinderCoordY = opmY[opmNodeIndex] + yCenterCoordOpm; - const auto cylinderCoordZ = opmZ[opmNodeIndex]; + auto hostCellIndex = hostCellGlobalIndices[opmCellIndex]; - const cvf::Vec3d coordinateOnCylinder = cvf::Vec3d( cylinderCoordX, cylinderCoordY, cylinderCoordZ ); - - const auto candidates = computeSnapToCoordinates( opmMainGrid, opmGrid, hostCellIndex, opmCellIndex ); - for ( int pillarIndex = 0; pillarIndex < static_cast( candidates.size() ); pillarIndex++ ) - { - for ( const auto& c : candidates[pillarIndex] ) - { - double distance = coordinateOnCylinder.pointDistance( c ); - if ( distance < closestPillarDistance ) - { - closestPillarDistance = distance; - closestPillarIndex = pillarIndex; - } - } - } - - if ( closestPillarDistance < std::numeric_limits::max() ) - { - const auto& pillarCordinates = candidates[closestPillarIndex]; - - int layerCount = static_cast( pillarCordinates.size() / 2 ); - int layerIndexInMainGridCell = ijkCell[2] % layerCount; - int localNodeIndex = opmNodeIndex % 8; - - cvf::Vec3d closestPillarCoord; - if ( localNodeIndex < 4 ) - { - // Top of cell - int pillarCoordIndex = layerIndexInMainGridCell * 2; - closestPillarCoord = pillarCordinates[pillarCoordIndex]; - } - else - { - // Bottom of cell - int pillarCoordIndex = layerIndexInMainGridCell * 2 + 1; - closestPillarCoord = pillarCordinates[pillarCoordIndex]; - } - - riNode.x() = closestPillarCoord.x(); - riNode.y() = closestPillarCoord.y(); - riNode.z() = -closestPillarCoord.z(); - } - } + lockToHostPillars( riNode, opmMainGrid, opmGrid, ijkCell, hostCellIndex, opmCellIndex, opmNodeIndex, xCenterCoordOpm, yCenterCoordOpm ); } } } } //-------------------------------------------------------------------------------------------------- -/// +// //-------------------------------------------------------------------------------------------------- -void RifOpmGridTools::transferCoordinatesCartesian( Opm::EclIO::EGrid& opmMainGrid, - Opm::EclIO::EGrid& opmGrid, - RigMainGrid* riMainGrid, - RigGridBase* riGrid, - RigEclipseCaseData* caseData ) +void RifOpmRadialGridTools::lockToHostPillars( cvf::Vec3d& riNode, + Opm::EclIO::EGrid& opmMainGrid, + Opm::EclIO::EGrid& opmGrid, + std::array& ijkCell, + int hostCellIndex, + int opmCellIndex, + size_t opmNodeIndex, + double xCenterCoordOpm, + double yCenterCoordOpm ) { - // Prefix OPM structures with _opm_and ResInsight structures with _ri_ + std::array cellRadius{}; + std::array cellTheta{}; + std::array cellZ{}; + opmGrid.getRadialCellCorners( ijkCell, cellRadius, cellTheta, cellZ ); - auto& riNodes = riMainGrid->nodes(); + double maxRadius = *std::max_element( cellRadius.begin(), cellRadius.end() ); - opmGrid.loadData(); - opmGrid.load_grid_data(); - - auto riActiveCells = caseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); - auto riActiveCellsFrac = caseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); - riActiveCellsFrac->setGridCount( 1 ); - riActiveCellsFrac->setGridActiveCellCounts( 0, 0 ); - - riActiveCells->setReservoirCellCount( riMainGrid->cellCount() ); - - // same mapping as resdata - const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 }; - -#pragma omp parallel for - for ( int opmCellIndex = 0; opmCellIndex < static_cast( riMainGrid->cellCount() ); opmCellIndex++ ) + // Check if the radius is at the outer surface of the radial grid + // Adjust the outer nodes to match the corner pillars of the host cell + const double epsilon = 0.15; + if ( fabs( maxRadius - cellRadius[opmNodeIndex] ) < epsilon * cellRadius[opmNodeIndex] ) { - auto opmIJK = opmGrid.ijk_from_global_index( opmCellIndex ); - - auto riReservoirIndex = riGrid->cellIndexFromIJK( opmIJK[0], opmIJK[1], opmIJK[2] ); - RigCell& cell = riMainGrid->globalCellArray()[riReservoirIndex]; - cell.setGridLocalCellIndex( riReservoirIndex ); - std::array opmX{}; std::array opmY{}; std::array opmZ{}; + opmGrid.getCellCorners( opmCellIndex, opmX, opmY, opmZ ); - // Each cell has 8 nodes, use reservoir cell index and multiply to find first node index for cell - auto riNodeStartIndex = riReservoirIndex * 8; + double closestPillarDistance = std::numeric_limits::max(); + int closestPillarIndex = -1; - for ( size_t opmNodeIndex = 0; opmNodeIndex < 8; opmNodeIndex++ ) - { - auto riCornerIndex = cellMappingECLRi[opmNodeIndex]; - size_t riNodeIndex = riNodeStartIndex + riCornerIndex; + const auto cylinderCoordX = opmX[opmNodeIndex] + xCenterCoordOpm; + const auto cylinderCoordY = opmY[opmNodeIndex] + yCenterCoordOpm; + const auto cylinderCoordZ = opmZ[opmNodeIndex]; - auto& riNode = riNodes[riNodeIndex]; - riNode.x() = opmX[opmNodeIndex]; - riNode.y() = opmY[opmNodeIndex]; - riNode.z() = -opmZ[opmNodeIndex]; + const cvf::Vec3d coordinateOnCylinder = cvf::Vec3d( cylinderCoordX, cylinderCoordY, cylinderCoordZ ); - cell.cornerIndices()[riCornerIndex] = riNodeIndex; + const auto candidates = computeSnapToCoordinates( opmMainGrid, opmGrid, hostCellIndex, opmCellIndex ); + for ( int pillarIndex = 0; pillarIndex < static_cast( candidates.size() ); pillarIndex++ ) + { + for ( const auto& c : candidates[pillarIndex] ) + { + double distance = coordinateOnCylinder.pointDistance( c ); + if ( distance < closestPillarDistance ) + { + closestPillarDistance = distance; + closestPillarIndex = pillarIndex; + } + } } - if ( riActiveCells ) + if ( closestPillarDistance < std::numeric_limits::max() ) { - auto activeIndex = opmGrid.active_index( opmIJK[0], opmIJK[1], opmIJK[2] ); - if ( activeIndex > -1 ) + const auto& pillarCordinates = candidates[closestPillarIndex]; + + int layerCount = static_cast( pillarCordinates.size() / 2 ); + int layerIndexInMainGridCell = ijkCell[2] % layerCount; + int localNodeIndex = opmNodeIndex % 8; + + cvf::Vec3d closestPillarCoord; + if ( localNodeIndex < 4 ) + { + // Top of cell + int pillarCoordIndex = layerIndexInMainGridCell * 2; + closestPillarCoord = pillarCordinates[pillarCoordIndex]; + } + else { - riActiveCells->setCellResultIndex( riReservoirIndex, activeIndex ); + // Bottom of cell + int pillarCoordIndex = layerIndexInMainGridCell * 2 + 1; + closestPillarCoord = pillarCordinates[pillarCoordIndex]; } + + riNode.x() = closestPillarCoord.x(); + riNode.y() = closestPillarCoord.y(); + riNode.z() = -closestPillarCoord.z(); } } - - riActiveCells->setGridCount( 1 ); - riActiveCells->setGridActiveCellCounts( 0, opmGrid.activeCells() ); - riActiveCells->computeDerivedData(); - - riMainGrid->initAllSubGridsParentGridPointer(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::map> - RifOpmGridTools::computeXyCenterForTopOfCells( Opm::EclIO::EGrid& opmMainGrid, Opm::EclIO::EGrid& opmGrid, RigGridBase* riGrid ) + RifOpmRadialGridTools::computeXyCenterForTopOfCells( Opm::EclIO::EGrid& opmMainGrid, Opm::EclIO::EGrid& opmGrid, RigGridBase* riGrid ) { if ( !riGrid || riGrid->isMainGrid() ) return {}; @@ -420,7 +291,6 @@ std::map> if ( cellCount != riGrid->cellCount() ) return {}; // Read out the corner coordinates from the EGRID file using radial coordinates. - // Prefix OPM structures with _opm_and ResInsight structures with _ri_ // Compute the center of the LGR radial grid cells for each K layer std::map> radialGridCenterTopLayerOpm; @@ -471,8 +341,10 @@ std::map> //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector> - RifOpmGridTools::computeSnapToCoordinates( Opm::EclIO::EGrid& opmMainGrid, Opm::EclIO::EGrid& opmGrid, int mainGridCellIndex, int lgrCellIndex ) +std::vector> RifOpmRadialGridTools::computeSnapToCoordinates( Opm::EclIO::EGrid& opmMainGrid, + Opm::EclIO::EGrid& opmGrid, + int mainGridCellIndex, + int lgrCellIndex ) { auto hostCellIndices = opmGrid.hostCellsGlobalIndex(); auto lgrIjk = opmGrid.ijk_from_global_index( lgrCellIndex ); diff --git a/ApplicationLibCode/FileInterface/RifOpmGridTools.h b/ApplicationLibCode/FileInterface/RifOpmRadialGridTools.h similarity index 67% rename from ApplicationLibCode/FileInterface/RifOpmGridTools.h rename to ApplicationLibCode/FileInterface/RifOpmRadialGridTools.h index 50df2896b3..c46016c70a 100644 --- a/ApplicationLibCode/FileInterface/RifOpmGridTools.h +++ b/ApplicationLibCode/FileInterface/RifOpmRadialGridTools.h @@ -39,28 +39,28 @@ class RigEclipseCaseData; //================================================================================================== /// //================================================================================================== -class RifOpmGridTools +class RifOpmRadialGridTools { public: // If the grid is radial, the coordinates are imported and adjusted to fit the host cells static void importCoordinatesForRadialGrid( const std::string& gridFilePath, RigMainGrid* mainGrid ); - static size_t cellCount( const std::string& gridFilePath ); - static bool importGrid( const std::string& gridFilePath, RigMainGrid* mainGrid, RigEclipseCaseData* caseData ); - - static std::vector> activeCellsFromActnumKeyword( Opm::EclIO::EGrid& grid ); - -private: - static void transferCoordinates( Opm::EclIO::EGrid& opmMainGrid, Opm::EclIO::EGrid& opmGrid, RigMainGrid* riMainGrid, RigGridBase* riGrid ); - static void transferCoordinatesCartesian( Opm::EclIO::EGrid& opmMainGrid, - Opm::EclIO::EGrid& opmGrid, - RigMainGrid* riMainGrid, - RigGridBase* riGrid, - RigEclipseCaseData* caseData ); + static void + transferCoordinatesRadial( Opm::EclIO::EGrid& opmMainGrid, Opm::EclIO::EGrid& opmGrid, RigMainGrid* riMainGrid, RigGridBase* riGrid ); static std::map> computeXyCenterForTopOfCells( Opm::EclIO::EGrid& opmMainGrid, Opm::EclIO::EGrid& opmGrid, RigGridBase* riGrid ); static std::vector> computeSnapToCoordinates( Opm::EclIO::EGrid& opmMainGrid, Opm::EclIO::EGrid& opmGrid, int mainGridCellIndex, int lgrCellIndex ); + + static void lockToHostPillars( cvf::Vec3d& riNode, + Opm::EclIO::EGrid& opmMainGrid, + Opm::EclIO::EGrid& opmGrid, + std::array& ijkCell, + int hostCellIndex, + int opmCellIndex, + size_t opmNodeIndex, + double xCenterCoordOpm, + double yCenterCoordOpm ); }; diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp index 78621b4e02..1ecab114bd 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp @@ -28,8 +28,10 @@ #include "RifActiveCellsReader.h" #include "RifEclipseInputFileTools.h" #include "RifEclipseOutputFileTools.h" +#include "RifEclipseRestartDataAccess.h" #include "RifHdf5ReaderInterface.h" -#include "RifOpmGridTools.h" +#include "RifOpmRadialGridTools.h" +#include "RifReaderEclipseWell.h" #include "RifReaderSettings.h" #ifdef USE_HDF5 @@ -114,17 +116,47 @@ static const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 }; -//************************************************************************************************** -// Static functions -//************************************************************************************************** - -bool transferGridCellData( RigMainGrid* mainGrid, - RigActiveCellInfo* activeCellInfo, - RigActiveCellInfo* fractureActiveCellInfo, - RigGridBase* localGrid, - const ecl_grid_type* localEclGrid, - size_t matrixActiveStartIndex, - size_t fractureActiveStartIndex ) +//-------------------------------------------------------------------------------------------------- +/// Constructor +//-------------------------------------------------------------------------------------------------- +RifReaderEclipseOutput::RifReaderEclipseOutput() +{ + m_fileName.clear(); + m_filesWithSameBaseName.clear(); + + m_eclipseCaseData = nullptr; + + m_ecl_init_file = nullptr; + m_dynamicResultsAccess = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// Destructor +//-------------------------------------------------------------------------------------------------- +RifReaderEclipseOutput::~RifReaderEclipseOutput() +{ + if ( m_ecl_init_file ) + { + ecl_file_close( m_ecl_init_file ); + } + m_ecl_init_file = nullptr; + + if ( m_dynamicResultsAccess.notNull() ) + { + m_dynamicResultsAccess->close(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderEclipseOutput::transferGridCellData( RigMainGrid* mainGrid, + RigActiveCellInfo* activeCellInfo, + RigActiveCellInfo* fractureActiveCellInfo, + RigGridBase* localGrid, + const ecl_grid_type* localEclGrid, + size_t matrixActiveStartIndex, + size_t fractureActiveStartIndex ) { CVF_ASSERT( activeCellInfo && fractureActiveCellInfo ); @@ -148,7 +180,6 @@ bool transferGridCellData( RigMainGrid* mainGrid, cell.setGridLocalCellIndex( gridLocalCellIndex ); // Active cell index - int matrixActiveIndex = ecl_grid_get_active_index1( localEclGrid, gridLocalCellIndex ); if ( matrixActiveIndex != -1 ) { @@ -162,7 +193,6 @@ bool transferGridCellData( RigMainGrid* mainGrid, } // Parent cell index - int parentCellIndex = ecl_grid_get_parent_cell1( localEclGrid, gridLocalCellIndex ); if ( parentCellIndex == -1 ) { @@ -202,43 +232,6 @@ bool transferGridCellData( RigMainGrid* mainGrid, return true; } -//================================================================================================== -// -// Class RigReaderInterfaceECL -// -//================================================================================================== - -//-------------------------------------------------------------------------------------------------- -/// Constructor -//-------------------------------------------------------------------------------------------------- -RifReaderEclipseOutput::RifReaderEclipseOutput() -{ - m_fileName.clear(); - m_filesWithSameBaseName.clear(); - - m_eclipseCase = nullptr; - - m_ecl_init_file = nullptr; - m_dynamicResultsAccess = nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// Destructor -//-------------------------------------------------------------------------------------------------- -RifReaderEclipseOutput::~RifReaderEclipseOutput() -{ - if ( m_ecl_init_file ) - { - ecl_file_close( m_ecl_init_file ); - } - m_ecl_init_file = nullptr; - - if ( m_dynamicResultsAccess.notNull() ) - { - m_dynamicResultsAccess->close(); - } -} - //-------------------------------------------------------------------------------------------------- /// Read geometry from file given by name into given reservoir object //-------------------------------------------------------------------------------------------------- @@ -359,9 +352,9 @@ bool RifReaderEclipseOutput::transferGeometry( const ecl_grid_type* mainEclGrid, //-------------------------------------------------------------------------------------------------- /// Open file and read geometry into given reservoir object //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* eclipseCase ) +bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* eclipseCaseData ) { - CVF_ASSERT( eclipseCase ); + CVF_ASSERT( eclipseCaseData ); caf::ProgressInfo progress( 100, "Reading Grid" ); if ( !RifEclipseOutputFileTools::isValidEclipseFileName( fileName ) ) @@ -403,9 +396,9 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* { auto task = progress.task( "Transferring grid geometry", 10 ); - if ( !transferGeometry( mainEclGrid, eclipseCase ) ) return false; + if ( !transferGeometry( mainEclGrid, eclipseCaseData ) ) return false; - RifOpmGridTools::importCoordinatesForRadialGrid( fileName.toStdString(), eclipseCase->mainGrid() ); + RifOpmRadialGridTools::importCoordinatesForRadialGrid( fileName.toStdString(), eclipseCaseData->mainGrid() ); } { @@ -417,12 +410,12 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* importFaults( fileSet, &faults ); - RigMainGrid* mainGrid = eclipseCase->mainGrid(); + RigMainGrid* mainGrid = eclipseCaseData->mainGrid(); mainGrid->setFaults( faults ); } } - m_eclipseCase = eclipseCase; + m_eclipseCaseData = eclipseCaseData; { auto task = progress.task( "Reading Results Meta data", 25 ); @@ -434,7 +427,7 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* if ( isNNCsEnabled() ) { caf::ProgressInfo nncProgress( 10, "" ); - RigMainGrid* mainGrid = eclipseCase->mainGrid(); + RigMainGrid* mainGrid = eclipseCaseData->mainGrid(); { auto subNncTask = nncProgress.task( "Reading static NNC data" ); @@ -442,13 +435,13 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* } // This test should probably be improved to test more directly for presence of NNC data - if ( m_eclipseCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->hasFlowDiagUsableFluxes() ) + if ( m_eclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->hasFlowDiagUsableFluxes() ) { auto subNncTask = nncProgress.task( "Reading dynamic NNC data" ); transferDynamicNNCData( mainEclGrid, mainGrid ); } - RigActiveCellInfo* activeCellInfo = m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + RigActiveCellInfo* activeCellInfo = m_eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); bool includeInactiveCells = includeInactiveCellsInFaultGeometry(); mainGrid->nncData()->setSourceDataForProcessing( mainGrid, activeCellInfo, includeInactiveCells ); @@ -457,9 +450,28 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* { auto task = progress.task( "Handling well information", 10 ); - if ( !isSkipWellData() ) + if ( loadWellDataEnabled() ) { - readWellCells( mainEclGrid, isImportOfCompleteMswDataEnabled() ); + std::vector filteredTimeSteps; + std::vector filteredTimeStepInfos = createFilteredTimeStepInfos(); + for ( auto a : filteredTimeStepInfos ) + { + filteredTimeSteps.push_back( a.m_date ); + } + + std::vector gridNames; + gridNames.push_back( "global" ); + for ( int i = 0; i < ecl_grid_get_num_lgr( mainEclGrid ); i++ ) + { + const char* gridName = ecl_grid_iget_lgr_name( mainEclGrid, i ); + gridNames.push_back( gridName ); + } + + RifReaderEclipseWell::readWellCells( m_dynamicResultsAccess.p(), + m_eclipseCaseData, + filteredTimeSteps, + gridNames, + isImportOfCompleteMswDataEnabled() ); } else { @@ -480,9 +492,9 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* //-------------------------------------------------------------------------------------------------- void RifReaderEclipseOutput::setHdf5FileName( const QString& fileName ) { - CVF_ASSERT( m_eclipseCase ); + CVF_ASSERT( m_eclipseCaseData ); - RigCaseCellResultsData* matrixModelResults = m_eclipseCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL ); + RigCaseCellResultsData* matrixModelResults = m_eclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL ); CVF_ASSERT( matrixModelResults ); if ( fileName.isEmpty() ) @@ -731,7 +743,7 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData( const QString& // Keep the set of files of interest m_filesWithSameBaseName = fileSet; - m_eclipseCase = eclipseCase; + m_eclipseCaseData = eclipseCase; m_fileName = fileName; if ( !readActiveCellInfo() ) @@ -750,12 +762,11 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData( const QString& //-------------------------------------------------------------------------------------------------- /// -/// See also RigStatistics::computeActiveCellUnion() //-------------------------------------------------------------------------------------------------- bool RifReaderEclipseOutput::readActiveCellInfo() { - CVF_ASSERT( m_eclipseCase ); - CVF_ASSERT( m_eclipseCase->mainGrid() ); + CVF_ASSERT( m_eclipseCaseData ); + CVF_ASSERT( m_eclipseCaseData->mainGrid() ); std::vector> actnumValuesPerGrid; @@ -767,8 +778,8 @@ bool RifReaderEclipseOutput::readActiveCellInfo() ecl_file_type* ecl_file = ecl_file_open( RiaStringEncodingTools::toNativeEncoded( initFileName ).data(), ECL_FILE_CLOSE_STREAM ); if ( ecl_file ) { - bool isDualPorosity = m_eclipseCase->mainGrid()->isDualPorosity(); - int cellCountMainGrid = static_cast( m_eclipseCase->mainGrid()->cellCount() ); + bool isDualPorosity = m_eclipseCaseData->mainGrid()->isDualPorosity(); + int cellCountMainGrid = static_cast( m_eclipseCaseData->mainGrid()->cellCount() ); actnumValuesPerGrid = RifActiveCellsReader::activeCellsFromPorvKeyword( ecl_file, isDualPorosity, cellCountMainGrid ); ecl_file_close( ecl_file ); } @@ -790,7 +801,7 @@ bool RifReaderEclipseOutput::readActiveCellInfo() } } - return RifEclipseOutputFileTools::assignActiveCellData( actnumValuesPerGrid, m_eclipseCase ); + return RifEclipseOutputFileTools::assignActiveCellData( actnumValuesPerGrid, m_eclipseCaseData ); } //-------------------------------------------------------------------------------------------------- @@ -798,63 +809,31 @@ bool RifReaderEclipseOutput::readActiveCellInfo() //-------------------------------------------------------------------------------------------------- void RifReaderEclipseOutput::buildMetaData( ecl_grid_type* grid ) { - CVF_ASSERT( m_eclipseCase ); + CVF_ASSERT( m_eclipseCaseData ); CVF_ASSERT( !m_filesWithSameBaseName.empty() ); caf::ProgressInfo progInfo( m_filesWithSameBaseName.size() + 3, "" ); progInfo.setNextProgressIncrement( m_filesWithSameBaseName.size() ); - RigCaseCellResultsData* matrixModelResults = m_eclipseCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL ); - RigCaseCellResultsData* fractureModelResults = m_eclipseCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL ); - std::vector timeStepInfos; // Create access object for dynamic results ensureDynamicResultAccessIsPresent(); if ( m_dynamicResultsAccess.notNull() ) { - m_dynamicResultsAccess->open(); - progInfo.incrementProgress(); - timeStepInfos = createFilteredTimeStepInfos(); - - auto keywordValueCounts = m_dynamicResultsAccess->keywordValueCounts(); - - { - auto validKeywords = validKeywordsForPorosityModel( keywordValueCounts, - m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ), - m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ), - RiaDefines::PorosityModelType::MATRIX_MODEL, - m_dynamicResultsAccess->timeStepCount() ); - - for ( const auto& keywordData : validKeywords ) - { - RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - RifKeywordValueCount::mapType( keywordData.dataType() ), - QString::fromStdString( keywordData.keyword() ) ); - matrixModelResults->createResultEntry( resAddr, false ); - matrixModelResults->setTimeStepInfos( resAddr, timeStepInfos ); - } - } + m_dynamicResultsAccess->open(); - { - auto validKeywords = validKeywordsForPorosityModel( keywordValueCounts, - m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ), - m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ), - RiaDefines::PorosityModelType::FRACTURE_MODEL, - m_dynamicResultsAccess->timeStepCount() ); + timeStepInfos = createFilteredTimeStepInfos(); + auto keywordInfo = m_dynamicResultsAccess->keywordValueCounts(); - for ( const auto& keywordData : validKeywords ) - { - RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - RifKeywordValueCount::mapType( keywordData.dataType() ), - QString::fromStdString( keywordData.keyword() ) ); - fractureModelResults->createResultEntry( resAddr, false ); - fractureModelResults->setTimeStepInfos( resAddr, timeStepInfos ); - } - } + RifEclipseOutputFileTools::createResultEntries( keywordInfo, + timeStepInfos, + RiaDefines::ResultCatType::DYNAMIC_NATIVE, + m_eclipseCaseData, + m_dynamicResultsAccess->timeStepCount() ); } progInfo.incrementProgress(); @@ -891,7 +870,7 @@ void RifReaderEclipseOutput::buildMetaData( ecl_grid_type* grid ) { unitsType = RiaDefines::EclipseUnitSystem::UNITS_LAB; } - m_eclipseCase->setUnitsType( unitsType ); + m_eclipseCaseData->setUnitsType( unitsType ); } progInfo.incrementProgress(); @@ -909,42 +888,11 @@ void RifReaderEclipseOutput::buildMetaData( ecl_grid_type* grid ) staticTimeStepInfo.push_back( timeStepInfos.front() ); } - { - auto validKeywords = validKeywordsForPorosityModel( keywordInfo, - m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ), - m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ), - RiaDefines::PorosityModelType::MATRIX_MODEL, - 1 ); - - validKeywords.push_back( RifKeywordValueCount( "ACTNUM", 0, RifKeywordValueCount::KeywordDataType::INTEGER ) ); - - for ( const auto& keywordData : validKeywords ) - { - RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::STATIC_NATIVE, - RifKeywordValueCount::mapType( keywordData.dataType() ), - QString::fromStdString( keywordData.keyword() ) ); - matrixModelResults->createResultEntry( resAddr, false ); - matrixModelResults->setTimeStepInfos( resAddr, staticTimeStepInfo ); - } - } - - { - auto validKeywords = validKeywordsForPorosityModel( keywordInfo, - m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ), - m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ), - RiaDefines::PorosityModelType::FRACTURE_MODEL, - 1 ); - validKeywords.push_back( RifKeywordValueCount( "ACTNUM", 0, RifKeywordValueCount::KeywordDataType::INTEGER ) ); - - for ( const auto& keywordData : validKeywords ) - { - RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::STATIC_NATIVE, - RifKeywordValueCount::mapType( keywordData.dataType() ), - QString::fromStdString( keywordData.keyword() ) ); - fractureModelResults->createResultEntry( resAddr, false ); - fractureModelResults->setTimeStepInfos( resAddr, staticTimeStepInfo ); - } - } + RifEclipseOutputFileTools::createResultEntries( keywordInfo, + staticTimeStepInfo, + RiaDefines::ResultCatType::STATIC_NATIVE, + m_eclipseCaseData, + 1 ); } } @@ -968,7 +916,7 @@ bool RifReaderEclipseOutput::staticResult( const QString& result, RiaDefines::Po if ( result.compare( "ACTNUM", Qt::CaseInsensitive ) == 0 ) { - RigActiveCellInfo* activeCellInfo = m_eclipseCase->activeCellInfo( matrixOrFracture ); + RigActiveCellInfo* activeCellInfo = m_eclipseCaseData->activeCellInfo( matrixOrFracture ); values->resize( activeCellInfo->reservoirActiveCellCount(), 1.0 ); return true; @@ -989,7 +937,7 @@ bool RifReaderEclipseOutput::staticResult( const QString& result, RiaDefines::Po fileValues.insert( fileValues.end(), partValues.begin(), partValues.end() ); } - extractResultValuesBasedOnPorosityModel( matrixOrFracture, values, fileValues ); + RifEclipseOutputFileTools::extractResultValuesBasedOnPorosityModel( m_eclipseCaseData, matrixOrFracture, values, fileValues ); } return true; @@ -1004,14 +952,14 @@ void RifReaderEclipseOutput::sourSimRlResult( const QString& result, size_t step if ( !m_hdfReaderInterface ) return; - if ( m_eclipseCase->mainGrid()->gridCount() == 0 ) + if ( m_eclipseCaseData->mainGrid()->gridCount() == 0 ) { RiaLogging::error( "No grids available" ); return; } - RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + RigActiveCellInfo* fracActCellInfo = m_eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); size_t activeCellCount = fracActCellInfo->gridActiveCellCounts( 0 ); size_t fileIndex = timeStepIndexOnFile( stepIndex ); @@ -1056,1048 +1004,17 @@ bool RifReaderEclipseOutput::dynamicResult( const QString& result size_t indexOnFile = timeStepIndexOnFile( stepIndex ); std::vector fileValues; - if ( !m_dynamicResultsAccess->results( result, indexOnFile, m_eclipseCase->mainGrid()->gridCountOnFile(), &fileValues ) ) + if ( !m_dynamicResultsAccess->results( result, indexOnFile, m_eclipseCaseData->mainGrid()->gridCountOnFile(), &fileValues ) ) { return false; } - extractResultValuesBasedOnPorosityModel( matrixOrFracture, values, fileValues ); + RifEclipseOutputFileTools::extractResultValuesBasedOnPorosityModel( m_eclipseCaseData, matrixOrFracture, values, fileValues ); } return true; } -//-------------------------------------------------------------------------------------------------- -/// Helper struct to store info on how a well-to-grid connection contributes to the position of -/// well segments without any connections. -//-------------------------------------------------------------------------------------------------- -struct SegmentPositionContribution -{ - SegmentPositionContribution( int connectionSegmentId, - cvf::Vec3d connectionPosition, - double lengthFromConnection, - bool isInsolating, - int segmentIdUnder, - int segmentIdAbove, - bool isFromAbove ) - : m_connectionSegmentId( connectionSegmentId ) - , m_lengthFromConnection( lengthFromConnection ) - , m_isInsolating( isInsolating ) - , m_connectionPosition( connectionPosition ) - , m_segmentIdUnder( segmentIdUnder ) - , m_segmentIdAbove( segmentIdAbove ) - , m_isFromAbove( isFromAbove ) - { - } - - int m_connectionSegmentId; - double m_lengthFromConnection; - bool m_isInsolating; - cvf::Vec3d m_connectionPosition; - int m_segmentIdUnder; - int m_segmentIdAbove; - bool m_isFromAbove; -}; - -size_t localGridCellIndexFromErtConnection( const RigGridBase* grid, const well_conn_type* ert_connection, const char* wellNameForErrorMsgs ) -{ - CVF_ASSERT( ert_connection ); - CVF_ASSERT( grid ); - - int cellI = well_conn_get_i( ert_connection ); - int cellJ = well_conn_get_j( ert_connection ); - int cellK = well_conn_get_k( ert_connection ); - - // If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1 - // Adjust K so index is always in valid grid region - if ( cellK >= static_cast( grid->cellCountK() ) ) - { - cellK -= static_cast( grid->cellCountK() ); - } - - // See description for keyword ICON at page 54/55 of Rile Formats Reference Manual 2010.2 - /* - Integer completion data array - ICON(NICONZ,NCWMAX,NWELLS) with dimensions - defined by INTEHEAD. The following items are required for each completion in each well: - Item 1 - Well connection index ICON(1,IC,IWELL) = IC (set to -IC if connection is not in current LGR) - Item 2 - I-coordinate (<= 0 if not in this LGR) - Item 3 - J-coordinate (<= 0 if not in this LGR) - Item 4 - K-coordinate (<= 0 if not in this LGR) - Item 6 - Connection status > 0 open, <= 0 shut - Item 14 - Penetration direction (1=x, 2=y, 3=z, 4=fractured in x-direction, 5=fractured in y-direction) - If undefined or zero, assume Z - Item 15 - Segment number containing connection (for multi-segment wells, =0 for ordinary wells) - Undefined items in this array may be set to zero. - */ - - // The K value might also be -1. It is not yet known why, or what it is supposed to mean, - // but for now we will interpret as 0. - // TODO: Ask Joakim Haave regarding this. - if ( cellK < 0 ) - { - // cvf::Trace::show("Well Connection for grid " + cvf::String(grid->gridName()) + "\n - Detected negative K - // value (K=" + cvf::String(cellK) + ") for well : " + cvf::String(wellName) + " K clamped to 0"); - - cellK = 0; - } - - // Introduced based on discussion with H�kon H�gst�l 08.09.2016 - if ( cellK >= static_cast( grid->cellCountK() ) ) - { - int maxCellK = static_cast( grid->cellCountK() ); - if ( wellNameForErrorMsgs ) - { - cvf::Trace::show( "Well Connection for grid " + cvf::String( grid->gridName() ) + - "\n - Ignored connection with invalid K value (K=" + cvf::String( cellK ) + - ", max K = " + cvf::String( maxCellK ) + ") for well : " + cvf::String( wellNameForErrorMsgs ) ); - } - return cvf::UNDEFINED_SIZE_T; - } - - return grid->cellIndexFromIJK( cellI, cellJ, cellK ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint( const RigGridBase* grid, - const well_conn_type* ert_connection, - const well_segment_type* segment, - const char* wellName ) -{ - CVF_ASSERT( ert_connection ); - CVF_ASSERT( grid ); - - size_t gridCellIndex = localGridCellIndexFromErtConnection( grid, ert_connection, wellName ); - - bool isCellOpen = well_conn_open( ert_connection ); - double volumeRate = well_conn_get_volume_rate( ert_connection ); - double oilRate = well_conn_get_oil_rate( ert_connection ); - double gasRate = well_conn_get_gas_rate( ert_connection ); - double waterRate = well_conn_get_water_rate( ert_connection ); - double connectionFactor = well_conn_get_connection_factor( ert_connection ); - - RigWellResultPoint resultPoint; - - if ( gridCellIndex != cvf::UNDEFINED_SIZE_T ) - { - int branchId = -1, segmentId = -1, outletBranchId = -1, outletSegmentId = -1; - - if ( segment ) - { - branchId = well_segment_get_branch_id( segment ); - segmentId = well_segment_get_id( segment ); - - auto outletSegment = well_segment_get_outlet( segment ); - if ( outletSegment ) - { - outletBranchId = well_segment_get_branch_id( outletSegment ); - outletSegmentId = well_segment_get_id( outletSegment ); - } - } - - resultPoint.setGridIndex( grid->gridIndex() ); - resultPoint.setGridCellIndex( gridCellIndex ); - - resultPoint.setIsOpen( isCellOpen ); - - resultPoint.setSegmentData( branchId, segmentId ); - resultPoint.setOutletSegmentData( outletBranchId, outletSegmentId ); - - const double adjustedGasRate = RiaEclipseUnitTools::convertSurfaceGasFlowRateToOilEquivalents( m_eclipseCase->unitsType(), gasRate ); - resultPoint.setFlowData( volumeRate, oilRate, adjustedGasRate, waterRate ); - - resultPoint.setConnectionFactor( connectionFactor ); - - auto ijkOneBased = grid->ijkFromCellIndexOneBased( gridCellIndex ); - if ( ijkOneBased ) - { - resultPoint.setIjk( *ijkOneBased ); - } - } - - return resultPoint; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigWellResultPoint - RifReaderEclipseOutput::createWellResultPoint( const RigGridBase* grid, const well_conn_type* ert_connection, const char* wellName ) -{ - return createWellResultPoint( grid, ert_connection, nullptr, wellName ); -} - -//-------------------------------------------------------------------------------------------------- -/// Inverse distance interpolation of the supplied points and distance weights for -/// the contributing points which are closest above, and closest below -//-------------------------------------------------------------------------------------------------- -cvf::Vec3d interpolate3DPosition( const std::vector& positions ) -{ - std::vector filteredPositions; - filteredPositions.reserve( positions.size() ); - - double minDistFromContribAbove = HUGE_VAL; - double minDistFromContribBelow = HUGE_VAL; - std::vector contrFromAbove; - std::vector contrFromBelow; - - for ( size_t i = 0; i < positions.size(); i++ ) - { - if ( positions[i].m_connectionPosition != cvf::Vec3d::UNDEFINED ) - { - if ( positions[i].m_isFromAbove && positions[i].m_lengthFromConnection < minDistFromContribAbove ) - { - if ( !contrFromAbove.empty() ) - contrFromAbove[0] = positions[i]; - else - contrFromAbove.push_back( positions[i] ); - - minDistFromContribAbove = positions[i].m_lengthFromConnection; - } - - if ( !positions[i].m_isFromAbove && positions[i].m_lengthFromConnection < minDistFromContribBelow ) - { - if ( !contrFromBelow.empty() ) - contrFromBelow[0] = positions[i]; - else - contrFromBelow.push_back( positions[i] ); - - minDistFromContribBelow = positions[i].m_lengthFromConnection; - } - } - } - - filteredPositions = contrFromAbove; - filteredPositions.insert( filteredPositions.end(), contrFromBelow.begin(), contrFromBelow.end() ); - - std::vector nominators( filteredPositions.size(), 0.0 ); - - double denominator = 0.0; - cvf::Vec3d interpolatedValue = cvf::Vec3d::ZERO; - - for ( size_t i = 0; i < filteredPositions.size(); i++ ) - { -#if 0 // Pure average test - nominators[i] = 1.0; -#else - double distance = filteredPositions[i].m_lengthFromConnection; - - if ( distance < 1e-6 ) - { - return filteredPositions[i].m_connectionPosition; - } - else if ( distance < 1.0 ) - { - // distance = 1.0; - } - - distance = 1.0 / distance; - nominators[i] = distance; - denominator += distance; - -#endif - } -#if 0 // Pure average test - denominator = positions.size(); // Pure average test -#endif - for ( size_t i = 0; i < filteredPositions.size(); i++ ) - { - interpolatedValue += ( nominators[i] / denominator ) * filteredPositions[i].m_connectionPosition; - } - - return interpolatedValue; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void propagatePosContribDownwards( std::map>& segmentIdToPositionContrib, - const well_segment_collection_type* allErtSegments, - int ertSegmentId, - std::vector posContrib ) -{ - std::map>::iterator posContribIt; - posContribIt = segmentIdToPositionContrib.find( ertSegmentId ); - - if ( posContribIt != segmentIdToPositionContrib.end() ) - { - // Create a set of the segments below this, that has to be followed. - - std::set segmentIdsBelow; - for ( size_t i = 0; i < posContribIt->second.size(); ++i ) - { - segmentIdsBelow.insert( posContribIt->second[i].m_segmentIdUnder ); - } - - // Get the segment length to add to the contributions - - well_segment_type* segment = well_segment_collection_get( allErtSegments, posContribIt->first ); - double sementLength = well_segment_get_length( segment ); - - // If we do not have the contribution represented, add it, and accumulate the length - // If it is already present, do not touch - for ( size_t i = 0; i < posContrib.size(); ++i ) - { - bool foundContribution = false; - for ( size_t j = 0; j < posContribIt->second.size(); ++j ) - { - if ( posContribIt->second[j].m_connectionSegmentId == posContrib[i].m_connectionSegmentId ) - { - foundContribution = true; - break; - } - } - - if ( !foundContribution ) - { - posContrib[i].m_lengthFromConnection += sementLength; - posContrib[i].m_isFromAbove = true; - posContribIt->second.push_back( posContrib[i] ); - } - posContrib[i].m_segmentIdAbove = ertSegmentId; - } - - for ( std::set::iterator it = segmentIdsBelow.begin(); it != segmentIdsBelow.end(); ++it ) - { - propagatePosContribDownwards( segmentIdToPositionContrib, allErtSegments, ( *it ), posContrib ); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// Helper class to determine whether a well connection is present in a sub cell -// for a specific well. Connections must be tested from innermost lgr to outermost since -// it accumulates the outer cells having subcell connections as it goes. -//-------------------------------------------------------------------------------------------------- -class WellResultPointHasSubCellConnectionCalculator -{ -public: - explicit WellResultPointHasSubCellConnectionCalculator( const RigMainGrid* mainGrid, well_state_type* ert_well_state ) - : m_mainGrid( mainGrid ) - { - int lastGridNr = static_cast( m_mainGrid->gridCountOnFile() ) - 1; - - for ( int gridNr = lastGridNr; gridNr >= 0; --gridNr ) - { - const well_conn_type* ert_wellhead = well_state_iget_wellhead( ert_well_state, static_cast( gridNr ) ); - if ( ert_wellhead ) - { - size_t localGridCellidx = localGridCellIndexFromErtConnection( m_mainGrid->gridByIndex( gridNr ), ert_wellhead, nullptr ); - insertTheParentCells( gridNr, localGridCellidx ); - } - - std::string gridname = gridNr == 0 ? ECL_GRID_GLOBAL_GRID : m_mainGrid->gridByIndex( gridNr )->gridName(); - const well_conn_collection_type* connections = well_state_get_grid_connections( ert_well_state, gridname.data() ); - - if ( connections ) - { - int connectionCount = well_conn_collection_get_size( connections ); - if ( connectionCount ) - { - for ( int connIdx = 0; connIdx < connectionCount; connIdx++ ) - { - well_conn_type* ert_connection = well_conn_collection_iget( connections, connIdx ); - - size_t localGridCellidx = - localGridCellIndexFromErtConnection( m_mainGrid->gridByIndex( gridNr ), ert_connection, nullptr ); - insertTheParentCells( gridNr, localGridCellidx ); - } - } - } - } - } - - bool hasSubCellConnection( const RigWellResultPoint& wellResultPoint ) - { - if ( !wellResultPoint.isCell() ) return false; - - size_t gridIndex = wellResultPoint.gridIndex(); - size_t gridCellIndex = wellResultPoint.cellIndex(); - - size_t reservoirCellIdx = m_mainGrid->reservoirCellIndexByGridAndGridLocalCellIndex( gridIndex, gridCellIndex ); - - return m_gridCellsWithSubCellWellConnections.count( reservoirCellIdx ) != 0; - } - -private: - void insertTheParentCells( size_t gridIndex, size_t gridCellIndex ) - { - if ( gridCellIndex == cvf::UNDEFINED_SIZE_T ) return; - - // Traverse parent gridcells, and add them to the map - - while ( gridIndex > 0 ) // is lgr - { - const RigCell& connectionCell = m_mainGrid->cellByGridAndGridLocalCellIdx( gridIndex, gridCellIndex ); - RigGridBase* hostGrid = connectionCell.hostGrid(); - - RigLocalGrid* lgrHost = static_cast( hostGrid ); - gridIndex = lgrHost->parentGrid()->gridIndex(); - gridCellIndex = connectionCell.parentCellIndex(); - - size_t parentReservoirCellIdx = m_mainGrid->reservoirCellIndexByGridAndGridLocalCellIndex( gridIndex, gridCellIndex ); - m_gridCellsWithSubCellWellConnections.insert( parentReservoirCellIdx ); - } - } - - std::set m_gridCellsWithSubCellWellConnections; - const RigMainGrid* m_mainGrid; -}; - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bool importCompleteMswData ) -{ - CVF_ASSERT( m_eclipseCase ); - - if ( m_dynamicResultsAccess.isNull() ) return; - - well_info_type* ert_well_info = well_info_alloc( mainEclGrid ); - if ( !ert_well_info ) return; - - m_dynamicResultsAccess->readWellData( ert_well_info, importCompleteMswData ); - - std::vector daysSinceSimulationStart; - std::vector timeSteps; - m_dynamicResultsAccess->timeSteps( &timeSteps, &daysSinceSimulationStart ); - std::vector reportNumbers = m_dynamicResultsAccess->reportNumbers(); - - bool sameCount = false; - if ( timeSteps.size() == reportNumbers.size() ) - { - sameCount = true; - } - - std::vector grids; - m_eclipseCase->allGrids( &grids ); - - cvf::Collection wells; - caf::ProgressInfo progress( well_info_get_num_wells( ert_well_info ), "" ); - - int wellIdx; - for ( wellIdx = 0; wellIdx < well_info_get_num_wells( ert_well_info ); wellIdx++ ) - { - const char* wellName = well_info_iget_well_name( ert_well_info, wellIdx ); - CVF_ASSERT( wellName ); - - cvf::ref simWellData = new RigSimWellData; - simWellData->m_wellName = wellName; - - well_ts_type* ert_well_time_series = well_info_get_ts( ert_well_info, wellName ); - int timeStepCount = well_ts_get_size( ert_well_time_series ); - - simWellData->m_wellCellsTimeSteps.resize( timeStepCount ); - - int timeIdx; - for ( timeIdx = 0; timeIdx < timeStepCount; timeIdx++ ) - { - well_state_type* ert_well_state = well_ts_iget_state( ert_well_time_series, timeIdx ); - - RigWellResultFrame& wellResFrame = simWellData->m_wellCellsTimeSteps[timeIdx]; - - // Build timestamp for well - bool haveFoundTimeStamp = false; - - if ( sameCount ) - { - int reportNr = well_state_get_report_nr( ert_well_state ); - - for ( size_t i = 0; i < reportNumbers.size(); i++ ) - { - if ( reportNumbers[i] == reportNr ) - { - wellResFrame.setTimestamp( timeSteps[i] ); - haveFoundTimeStamp = true; - } - } - } - - if ( !haveFoundTimeStamp ) - { - // This fallback will not work for timesteps before 1970. - - // Also see RifEclipseOutputFileAccess::timeStepsText for accessing time_t structures - time_t stepTime = well_state_get_sim_time( ert_well_state ); - wellResFrame.setTimestamp( QDateTime::fromSecsSinceEpoch( stepTime ) ); - } - - // Production type - well_type_enum ert_well_type = well_state_get_type( ert_well_state ); - if ( ert_well_type == ECL_WELL_PRODUCER ) - { - wellResFrame.setProductionType( RiaDefines::WellProductionType::PRODUCER ); - } - else if ( ert_well_type == ECL_WELL_WATER_INJECTOR ) - { - wellResFrame.setProductionType( RiaDefines::WellProductionType::WATER_INJECTOR ); - } - else if ( ert_well_type == ECL_WELL_GAS_INJECTOR ) - { - wellResFrame.setProductionType( RiaDefines::WellProductionType::GAS_INJECTOR ); - } - else if ( ert_well_type == ECL_WELL_OIL_INJECTOR ) - { - wellResFrame.setProductionType( RiaDefines::WellProductionType::OIL_INJECTOR ); - } - else - { - wellResFrame.setProductionType( RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE ); - } - - wellResFrame.setIsOpen( well_state_is_open( ert_well_state ) ); - - if ( importCompleteMswData && well_state_is_MSW( ert_well_state ) ) - { - simWellData->setMultiSegmentWell( true ); - - // how do we handle LGR-s ? - // 1. Create separate visual branches for each Grid, with its own wellhead - // 2. Always use the connections to the grid with the highest number (innermost LGR). - // 3. Handle both and switch between them according to visual settings of grid visualization - // Will there ever exist connections to different grids for the same segment ? - // We have currently selected 2. - - // Set the wellhead - - int lastGridNr = static_cast( grids.size() ) - 1; - for ( int gridNr = lastGridNr; gridNr >= 0; --gridNr ) - { - // If several grids have a wellhead definition for this well, we use the last one. - // (Possibly the innermost LGR) - - const well_conn_type* ert_wellhead = well_state_iget_wellhead( ert_well_state, static_cast( gridNr ) ); - if ( ert_wellhead ) - { - auto wellHead = createWellResultPoint( grids[gridNr], ert_wellhead, wellName ); - - // HACK: Ert returns open as "this is equally wrong as closed for well heads". - // Well heads are not open jfr mail communication with HHGS and JH Statoil 07.01.2016 - wellHead.setIsOpen( false ); - wellResFrame.setWellHead( wellHead ); - break; - } - } - - well_branch_collection_type* branches = well_state_get_branches( ert_well_state ); - int branchCount = well_branch_collection_get_size( branches ); - std::map> segmentIdToPositionContrib; - std::vector upperSegmentIdsOfUnpositionedSegementGroup; - - // Create copy of well result branches for modification - std::vector wellResultBranches = wellResFrame.wellResultBranches(); - wellResultBranches.resize( branchCount ); - - // For each branch, go from bottom segment upwards and transfer their connections to WellResultpoints. - // If they have no connections, create a resultpoint representing their bottom position, which will - // receive an actual position at a later stage. - // I addition, distribute contributions for calculating segment bottom positions from bottom and up. - - for ( int bIdx = 0; bIdx < well_branch_collection_get_size( branches ); bIdx++ ) - { - RigWellResultBranch& wellResultBranch = wellResultBranches[bIdx]; - - const well_segment_type* segment = well_branch_collection_iget_start_segment( branches, bIdx ); - - int branchId = well_segment_get_branch_id( segment ); - wellResultBranch.setErtBranchId( branchId ); - - // Data for segment position calculation - int lastConnectionSegmentId = -1; - cvf::Vec3d lastConnectionPos = cvf::Vec3d::UNDEFINED; - cvf::Vec3d lastConnectionCellCorner = cvf::Vec3d::UNDEFINED; - double lastConnectionCellSize = 0; - double accLengthFromLastConnection = 0; - int segmentIdBelow = -1; - bool segmentBelowHasConnections = false; - - while ( segment && branchId == well_segment_get_branch_id( segment ) ) - { - // Loop backwards, making us select the connection in the innermost lgr as the truth - bool segmentHasConnections = false; - - for ( int gridNr = lastGridNr; gridNr >= 0; --gridNr ) - { - std::string gridName = ertGridName( gridNr ); - - // If this segment has connections in any grid, transfer the innermost ones - - if ( well_segment_has_grid_connections( segment, gridName.data() ) ) - { - const well_conn_collection_type* connections = well_segment_get_connections( segment, gridName.data() ); - int connectionCount = well_conn_collection_get_size( connections ); - - // Loop backwards to put the deepest connections first in the array. (The segments are - // also traversed deep to shallow) - for ( int connIdx = connectionCount - 1; connIdx >= 0; connIdx-- ) - { - well_conn_type* ert_connection = well_conn_collection_iget( connections, connIdx ); - wellResultBranch.addBranchResultPoint( - createWellResultPoint( grids[gridNr], ert_connection, segment, wellName ) ); - } - - segmentHasConnections = true; - - // Prepare data for segment position calculation - - well_conn_type* ert_connection = well_conn_collection_iget( connections, 0 ); - RigWellResultPoint point = createWellResultPoint( grids[gridNr], ert_connection, segment, wellName ); - lastConnectionPos = grids[gridNr]->cell( point.cellIndex() ).center(); - cvf::Vec3d cellVxes[8]; - grids[gridNr]->cellCornerVertices( point.cellIndex(), cellVxes ); - lastConnectionCellCorner = cellVxes[0]; - lastConnectionCellSize = ( lastConnectionPos - cellVxes[0] ).length(); - - lastConnectionSegmentId = well_segment_get_id( segment ); - accLengthFromLastConnection = well_segment_get_length( segment ) / ( connectionCount + 1 ); - if ( !segmentBelowHasConnections ) upperSegmentIdsOfUnpositionedSegementGroup.push_back( segmentIdBelow ); - - break; // Stop looping over grids - } - } - - // If the segment did not have connections at all, we need to create a resultpoint representing - // the bottom of the segment and store it as an unpositioned segment - - if ( !segmentHasConnections ) - { - RigWellResultPoint data; - data.setSegmentData( branchId, well_segment_get_id( segment ) ); - - wellResultBranch.addBranchResultPoint( data ); - - // Store data for segment position calculation - bool isAnInsolationContribution = accLengthFromLastConnection < lastConnectionCellSize; - - segmentIdToPositionContrib[well_segment_get_id( segment )].push_back( - SegmentPositionContribution( lastConnectionSegmentId, - lastConnectionPos, - accLengthFromLastConnection, - isAnInsolationContribution, - segmentIdBelow, - -1, - false ) ); - accLengthFromLastConnection += well_segment_get_length( segment ); - } - - segmentIdBelow = well_segment_get_id( segment ); - segmentBelowHasConnections = segmentHasConnections; - - if ( well_segment_get_outlet_id( segment ) == -1 ) - { - segment = nullptr; - } - else - { - segment = well_segment_get_outlet( segment ); - } - } - - // Add resultpoint representing the outlet segment (bottom), if not the branch ends at the wellhead. - - const well_segment_type* outletSegment = segment; - - if ( outletSegment ) - { - bool outletSegmentHasConnections = false; - - for ( int gridNr = lastGridNr; gridNr >= 0; --gridNr ) - { - std::string gridName = ertGridName( gridNr ); - - // If this segment has connections in any grid, use the deepest innermost one - - if ( well_segment_has_grid_connections( outletSegment, gridName.data() ) ) - { - const well_conn_collection_type* connections = well_segment_get_connections( outletSegment, gridName.data() ); - int connectionCount = well_conn_collection_get_size( connections ); - - // Select the deepest connection - well_conn_type* ert_connection = well_conn_collection_iget( connections, connectionCount - 1 ); - - auto resultPoint = createWellResultPoint( grids[gridNr], ert_connection, outletSegment, wellName ); - // This result point is only supposed to be used to indicate connection to a parent well - // Clear all flow in this result point - resultPoint.clearAllFlow(); - - wellResultBranch.addBranchResultPoint( resultPoint ); - - outletSegmentHasConnections = true; - break; // Stop looping over grids - } - } - - if ( !outletSegmentHasConnections ) - { - // Store the result point - - RigWellResultPoint data; - data.setSegmentData( well_segment_get_branch_id( outletSegment ), well_segment_get_id( outletSegment ) ); - wellResultBranch.addBranchResultPoint( data ); - - // Store data for segment position calculation, - // and propagate it upwards until we meet a segment with connections - - bool isAnInsolationContribution = accLengthFromLastConnection < lastConnectionCellSize; - - cvf::Vec3d lastConnectionPosWOffset = lastConnectionPos; - if ( isAnInsolationContribution ) - lastConnectionPosWOffset += 0.4 * ( lastConnectionCellCorner - lastConnectionPos ); - - segmentIdToPositionContrib[well_segment_get_id( outletSegment )].push_back( - SegmentPositionContribution( lastConnectionSegmentId, - lastConnectionPosWOffset, - accLengthFromLastConnection, - isAnInsolationContribution, - segmentIdBelow, - -1, - false ) ); - - /// Loop further to add this position contribution until a segment with connections is found - - accLengthFromLastConnection += well_segment_get_length( outletSegment ); - segmentIdBelow = well_segment_get_id( outletSegment ); - - const well_segment_type* aboveOutletSegment = nullptr; - - if ( well_segment_get_outlet_id( outletSegment ) == -1 ) - { - aboveOutletSegment = nullptr; - } - else - { - aboveOutletSegment = well_segment_get_outlet( outletSegment ); - } - - while ( aboveOutletSegment ) - { - // Loop backwards, just because we do that the other places - bool segmentHasConnections = false; - - for ( int gridNr = lastGridNr; gridNr >= 0; --gridNr ) - { - std::string gridName = ertGridName( gridNr ); - - // If this segment has connections in any grid, stop traversal - - if ( well_segment_has_grid_connections( aboveOutletSegment, gridName.data() ) ) - { - segmentHasConnections = true; - break; - } - } - - if ( !segmentHasConnections ) - { - segmentIdToPositionContrib[well_segment_get_id( aboveOutletSegment )].push_back( - SegmentPositionContribution( lastConnectionSegmentId, - lastConnectionPos, - accLengthFromLastConnection, - isAnInsolationContribution, - segmentIdBelow, - -1, - false ) ); - accLengthFromLastConnection += well_segment_get_length( aboveOutletSegment ); - } - else - { - break; // We have found a segment with connections. We do not need to propagate - // position contributions further - } - - segmentIdBelow = well_segment_get_id( aboveOutletSegment ); - - if ( well_segment_get_outlet_id( aboveOutletSegment ) == -1 ) - { - aboveOutletSegment = nullptr; - } - else - { - aboveOutletSegment = well_segment_get_outlet( aboveOutletSegment ); - } - } - } - } - else - { - // Add wellhead as result point Nope. Not Yet, but it is a good idea. - // The centerline calculations would be a bit simpler, I think. - } - - // Reverse the order of the result points in this branch, making the deepest come last - auto branchResultPoints = wellResultBranch.branchResultPoints(); - std::reverse( branchResultPoints.begin(), branchResultPoints.end() ); - wellResultBranch.setBranchResultPoints( branchResultPoints ); - } // End of the branch loop - - // Set modified copy back to frame - wellResFrame.setWellResultBranches( wellResultBranches ); - - // Propagate position contributions from connections above unpositioned segments downwards - - well_segment_collection_type* allErtSegments = well_state_get_segments( ert_well_state ); - - bool isWellHead = true; - for ( const auto& wellResultBranch : wellResFrame.wellResultBranches() ) - { - bool previousResultPointWasCell = isWellHead; - - // Go downwards until we find a none-cell result point just after a cell result point - // When we do, start propagating - - for ( size_t rpIdx = 0; rpIdx < wellResultBranch.branchResultPoints().size(); ++rpIdx ) - { - const RigWellResultPoint resPoint = wellResultBranch.branchResultPoints()[rpIdx]; - if ( resPoint.isCell() ) - { - previousResultPointWasCell = true; - } - else - { - if ( previousResultPointWasCell ) - { - RigWellResultPoint prevResPoint; - if ( isWellHead && rpIdx == 0 ) - { - prevResPoint = wellResFrame.wellHead(); - } - else - { - prevResPoint = wellResultBranch.branchResultPoints()[rpIdx - 1]; - } - - cvf::Vec3d lastConnectionPos = grids[prevResPoint.gridIndex()]->cell( prevResPoint.cellIndex() ).center(); - - SegmentPositionContribution - posContrib( prevResPoint.segmentId(), lastConnectionPos, 0.0, false, -1, prevResPoint.segmentId(), true ); - - int ertSegmentId = resPoint.segmentId(); - - std::map>::iterator posContribIt; - posContribIt = segmentIdToPositionContrib.find( ertSegmentId ); - CVF_ASSERT( posContribIt != segmentIdToPositionContrib.end() ); - - std::vector posContributions = posContribIt->second; - for ( size_t i = 0; i < posContributions.size(); ++i ) - { - posContributions[i].m_segmentIdAbove = prevResPoint.segmentId(); - } - posContributions.push_back( posContrib ); - - propagatePosContribDownwards( segmentIdToPositionContrib, allErtSegments, ertSegmentId, posContributions ); - } - - previousResultPointWasCell = false; - } - } - - isWellHead = false; - } - - // Calculate the bottom position of all the unpositioned segments - // Then do the calculation based on the refined contributions - - std::map>::iterator posContribIt = segmentIdToPositionContrib.begin(); - std::map bottomPositions; - while ( posContribIt != segmentIdToPositionContrib.end() ) - { - bottomPositions[posContribIt->first] = interpolate3DPosition( posContribIt->second ); - ++posContribIt; - } - - // Copy content and distribute the positions to the result points stored in the wellResultBranch.branchResultPoints() - // set updated copy back to frame - - std::vector newWellResultBranches = wellResFrame.wellResultBranches(); - for ( auto& wellResultBranch : newWellResultBranches ) - { - RigWellResultBranch& newWellResultBranch = wellResultBranch; - for ( auto& resultPoint : newWellResultBranch.branchResultPoints() ) - { - if ( !resultPoint.isCell() ) - { - resultPoint.setBottomPosition( bottomPositions[resultPoint.segmentId()] ); - } - } - } - wellResFrame.setWellResultBranches( newWellResultBranches ); - } // End of the MSW section - else - { - // Code handling None-MSW Wells ... Normal wells that is. - - WellResultPointHasSubCellConnectionCalculator subCellConnCalc( m_eclipseCase->mainGrid(), ert_well_state ); - int lastGridNr = static_cast( grids.size() ) - 1; - for ( int gridNr = 0; gridNr <= lastGridNr; ++gridNr ) - { - const well_conn_type* ert_wellhead = well_state_iget_wellhead( ert_well_state, static_cast( gridNr ) ); - if ( ert_wellhead ) - { - RigWellResultPoint wellHeadRp = createWellResultPoint( grids[gridNr], ert_wellhead, wellName ); - // HACK: Ert returns open as "this is equally wrong as closed for well heads". - // Well heads are not open jfr mail communication with HHGS and JH Statoil 07.01.2016 - wellHeadRp.setIsOpen( false ); - - if ( !subCellConnCalc.hasSubCellConnection( wellHeadRp ) ) wellResFrame.setWellHead( wellHeadRp ); - } - - const well_conn_collection_type* connections = - well_state_get_grid_connections( ert_well_state, ertGridName( gridNr ).data() ); - - // Import all well result cells for all connections - if ( connections ) - { - int connectionCount = well_conn_collection_get_size( connections ); - if ( connectionCount ) - { - RigWellResultBranch wellResultBranch; - wellResultBranch.setErtBranchId( 0 ); // Normal wells have only one branch - - std::vector branchResultPoints = wellResultBranch.branchResultPoints(); - const size_t existingCellCount = branchResultPoints.size(); - branchResultPoints.resize( existingCellCount + connectionCount ); - - for ( int connIdx = 0; connIdx < connectionCount; connIdx++ ) - { - well_conn_type* ert_connection = well_conn_collection_iget( connections, connIdx ); - RigWellResultPoint wellRp = createWellResultPoint( grids[gridNr], ert_connection, wellName ); - - if ( !subCellConnCalc.hasSubCellConnection( wellRp ) ) - { - branchResultPoints[existingCellCount + connIdx] = wellRp; - } - } - wellResultBranch.setBranchResultPoints( branchResultPoints ); - wellResFrame.addWellResultBranch( wellResultBranch ); - } - } - } - } - } - - std::vector filteredTimeSteps; - { - std::vector filteredTimeStepInfos = createFilteredTimeStepInfos(); - for ( auto a : filteredTimeStepInfos ) - { - filteredTimeSteps.push_back( a.m_date ); - } - } - - simWellData->computeMappingFromResultTimeIndicesToWellTimeIndices( filteredTimeSteps ); - - wells.push_back( simWellData.p() ); - - progress.incrementProgress(); - } - - well_info_free( ert_well_info ); - - m_eclipseCase->setSimWellData( wells ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector - RifReaderEclipseOutput::validKeywordsForPorosityModel( const std::vector& keywordItemCounts, - const RigActiveCellInfo* matrixActiveCellInfo, - const RigActiveCellInfo* fractureActiveCellInfo, - RiaDefines::PorosityModelType porosityModel, - size_t timeStepCount ) -{ - CVF_ASSERT( matrixActiveCellInfo ); - - if ( porosityModel == RiaDefines::PorosityModelType::FRACTURE_MODEL ) - { - if ( fractureActiveCellInfo->reservoirActiveCellCount() == 0 ) - { - return {}; - } - } - - std::vector keywordsWithCorrectNumberOfDataItems; - - for ( const auto& keywordValueCount : keywordItemCounts ) - { - QString keyword = QString::fromStdString( keywordValueCount.keyword() ); - size_t valueCount = keywordValueCount.valueCount(); - - bool validKeyword = false; - - size_t timeStepsAllCellsRest = valueCount % matrixActiveCellInfo->reservoirCellCount(); - if ( timeStepsAllCellsRest == 0 && valueCount <= timeStepCount * matrixActiveCellInfo->reservoirCellCount() ) - { - // Found result for all cells for N time steps, usually a static dataset for one time step - validKeyword = true; - } - else - { - size_t timeStepsMatrixRest = valueCount % matrixActiveCellInfo->reservoirActiveCellCount(); - - size_t timeStepsFractureRest = 0; - if ( fractureActiveCellInfo->reservoirActiveCellCount() > 0 ) - { - timeStepsFractureRest = valueCount % fractureActiveCellInfo->reservoirActiveCellCount(); - } - - size_t sumFractureMatrixActiveCellCount = matrixActiveCellInfo->reservoirActiveCellCount() + - fractureActiveCellInfo->reservoirActiveCellCount(); - size_t timeStepsMatrixAndFractureRest = valueCount % sumFractureMatrixActiveCellCount; - - if ( porosityModel == RiaDefines::PorosityModelType::MATRIX_MODEL && timeStepsMatrixRest == 0 ) - { - if ( valueCount <= - timeStepCount * std::max( matrixActiveCellInfo->reservoirActiveCellCount(), sumFractureMatrixActiveCellCount ) ) - { - validKeyword = true; - } - } - else if ( porosityModel == RiaDefines::PorosityModelType::FRACTURE_MODEL && - fractureActiveCellInfo->reservoirActiveCellCount() > 0 && timeStepsFractureRest == 0 ) - { - if ( valueCount <= - timeStepCount * std::max( fractureActiveCellInfo->reservoirActiveCellCount(), sumFractureMatrixActiveCellCount ) ) - { - validKeyword = true; - } - } - else if ( timeStepsMatrixAndFractureRest == 0 ) - { - if ( valueCount <= timeStepCount * sumFractureMatrixActiveCellCount ) - { - validKeyword = true; - } - } - } - - // Check for INIT values that has only values for main grid active cells - if ( !validKeyword ) - { - if ( timeStepCount == 1 ) - { - size_t mainGridMatrixActiveCellCount = matrixActiveCellInfo->gridActiveCellCounts( 0 ); - size_t mainGridFractureActiveCellCount = fractureActiveCellInfo->gridActiveCellCounts( 0 ); - - if ( valueCount == mainGridMatrixActiveCellCount || valueCount == mainGridFractureActiveCellCount || - valueCount == mainGridMatrixActiveCellCount + mainGridFractureActiveCellCount ) - { - validKeyword = true; - } - } - } - - if ( validKeyword ) - { - keywordsWithCorrectNumberOfDataItems.push_back( keywordValueCount ); - } - } - - return keywordsWithCorrectNumberOfDataItems; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2198,59 +1115,6 @@ void RifReaderEclipseOutput::updateFromGridCount( size_t gridCount ) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel( RiaDefines::PorosityModelType matrixOrFracture, - std::vector* destinationResultValues, - const std::vector& sourceResultValues ) -{ - if ( sourceResultValues.empty() ) return; - - RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); - - if ( matrixOrFracture == RiaDefines::PorosityModelType::MATRIX_MODEL && fracActCellInfo->reservoirActiveCellCount() == 0 ) - { - destinationResultValues->insert( destinationResultValues->end(), sourceResultValues.begin(), sourceResultValues.end() ); - } - else - { - RigActiveCellInfo* actCellInfo = m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); - - size_t sourceStartPosition = 0; - - for ( size_t i = 0; i < m_eclipseCase->mainGrid()->gridCount(); i++ ) - { - if ( m_eclipseCase->mainGrid()->gridByIndex( i )->isTempGrid() ) continue; - - size_t matrixActiveCellCount = actCellInfo->gridActiveCellCounts( i ); - size_t fractureActiveCellCount = fracActCellInfo->gridActiveCellCounts( i ); - - if ( matrixOrFracture == RiaDefines::PorosityModelType::MATRIX_MODEL ) - { - destinationResultValues->insert( destinationResultValues->end(), - sourceResultValues.begin() + sourceStartPosition, - sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount ); - } - else - { - if ( ( matrixActiveCellCount + fractureActiveCellCount ) > sourceResultValues.size() ) - { - // Special handling of the situation where we only have data for one fracture mode - matrixActiveCellCount = 0; - } - - destinationResultValues->insert( destinationResultValues->end(), - sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount, - sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount + - fractureActiveCellCount ); - } - - sourceStartPosition += ( matrixActiveCellCount + fractureActiveCellCount ); - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2304,23 +1168,3 @@ std::set RifReaderEclipseOutput::availablePhases() const return std::set(); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::string RifReaderEclipseOutput::ertGridName( size_t gridNr ) -{ - std::string gridName; - if ( gridNr == 0 ) - { - gridName = ECL_GRID_GLOBAL_GRID; - } - else - { - CVF_ASSERT( m_eclipseCase ); - CVF_ASSERT( m_eclipseCase->gridCount() > gridNr ); - gridName = m_eclipseCase->grid( gridNr )->gridName(); - } - - return gridName; -} diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h index 39d976de4b..2b57a74231 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h @@ -36,7 +36,7 @@ class RigEclipseTimeStepInfo; class RigGridBase; class RigMainGrid; class QDateTime; -class RifKeywordValueCount; +class RifEclipseKeywordValueCount; struct RigWellResultPoint; @@ -91,43 +91,33 @@ class RifReaderEclipseOutput : public RifReaderInterface private: bool readActiveCellInfo(); - void buildMetaData( ecl_grid_type* grid ); - void readWellCells( const ecl_grid_type* mainEclGrid, bool importCompleteMswData ); - std::string ertGridName( size_t gridNr ); - RigWellResultPoint createWellResultPoint( const RigGridBase* grid, const well_conn_type* ert_connection, const char* wellName ); - - RigWellResultPoint createWellResultPoint( const RigGridBase* grid, - const well_conn_type* ert_connection, - const well_segment_type* segment, - const char* wellName ); + void buildMetaData( ecl_grid_type* grid ); void openInitFile(); - void extractResultValuesBasedOnPorosityModel( RiaDefines::PorosityModelType matrixOrFracture, - std::vector* values, - const std::vector& fileValues ); void transferStaticNNCData( const ecl_grid_type* mainEclGrid, ecl_file_type* init_file, RigMainGrid* mainGrid ); void transferDynamicNNCData( const ecl_grid_type* mainEclGrid, RigMainGrid* mainGrid ); void ensureDynamicResultAccessIsPresent(); - static std::vector validKeywordsForPorosityModel( const std::vector& keywordItemCounts, - const RigActiveCellInfo* activeCellInfo, - const RigActiveCellInfo* fractureActiveCellInfo, - RiaDefines::PorosityModelType matrixOrFracture, - size_t timeStepCount ); - std::vector createFilteredTimeStepInfos(); static bool isEclipseAndSoursimTimeStepsEqual( const QDateTime& eclipseDateTime, const QDateTime& sourSimDateTime ); + static bool transferGridCellData( RigMainGrid* mainGrid, + RigActiveCellInfo* activeCellInfo, + RigActiveCellInfo* fractureActiveCellInfo, + RigGridBase* localGrid, + const ecl_grid_type* localEclGrid, + size_t matrixActiveStartIndex, + size_t fractureActiveStartIndex ); private: QString m_fileName; // Name of file used to start accessing Eclipse output files QStringList m_filesWithSameBaseName; // Set of files in filename's path with same base name as filename - RigEclipseCaseData* m_eclipseCase; + RigEclipseCaseData* m_eclipseCaseData; ecl_file_type* m_ecl_init_file; // File access to static results mutable cvf::ref m_dynamicResultsAccess; // File access to dynamic results diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp new file mode 100644 index 0000000000..aee64e1e36 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp @@ -0,0 +1,1006 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RifReaderEclipseWell.h" + +#include "RiaEclipseUnitTools.h" + +#include "RifEclipseRestartDataAccess.h" + +#include "RigEclipseCaseData.h" +#include "RigEclipseResultInfo.h" +#include "RigGridBase.h" +#include "RigMainGrid.h" +#include "RigSimWellData.h" +#include "RigWellResultFrame.h" +#include "RigWellResultPoint.h" + +#include "cafProgressInfo.h" + +#include "cvfTrace.h" + +#include "ert/ecl_well/well_conn.h" +#include "ert/ecl_well/well_info.h" +#include "ert/ecl_well/well_segment.h" +#include "ert/ecl_well/well_segment_collection.h" +#include "ert/ecl_well/well_state.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// Helper struct to store info on how a well-to-grid connection contributes to the position of +/// well segments without any connections. +//-------------------------------------------------------------------------------------------------- +struct SegmentPositionContribution +{ + SegmentPositionContribution( int connectionSegmentId, + cvf::Vec3d connectionPosition, + double lengthFromConnection, + bool isInsolating, + int segmentIdUnder, + int segmentIdAbove, + bool isFromAbove ) + : m_connectionSegmentId( connectionSegmentId ) + , m_lengthFromConnection( lengthFromConnection ) + , m_isInsolating( isInsolating ) + , m_connectionPosition( connectionPosition ) + , m_segmentIdUnder( segmentIdUnder ) + , m_segmentIdAbove( segmentIdAbove ) + , m_isFromAbove( isFromAbove ) + { + } + + int m_connectionSegmentId; + double m_lengthFromConnection; + bool m_isInsolating; + cvf::Vec3d m_connectionPosition; + int m_segmentIdUnder; + int m_segmentIdAbove; + bool m_isFromAbove; +}; + +size_t RifReaderEclipseWell::localGridCellIndexFromErtConnection( const RigGridBase* grid, + const well_conn_type* ert_connection, + const char* wellNameForErrorMsgs ) +{ + CVF_ASSERT( ert_connection ); + CVF_ASSERT( grid ); + + int cellI = well_conn_get_i( ert_connection ); + int cellJ = well_conn_get_j( ert_connection ); + int cellK = well_conn_get_k( ert_connection ); + + // If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1 + // Adjust K so index is always in valid grid region + if ( cellK >= static_cast( grid->cellCountK() ) ) + { + cellK -= static_cast( grid->cellCountK() ); + } + + // See description for keyword ICON at page 54/55 of Rile Formats Reference Manual 2010.2 + /* + Integer completion data array + ICON(NICONZ,NCWMAX,NWELLS) with dimensions + defined by INTEHEAD. The following items are required for each completion in each well: + Item 1 - Well connection index ICON(1,IC,IWELL) = IC (set to -IC if connection is not in current LGR) + Item 2 - I-coordinate (<= 0 if not in this LGR) + Item 3 - J-coordinate (<= 0 if not in this LGR) + Item 4 - K-coordinate (<= 0 if not in this LGR) + Item 6 - Connection status > 0 open, <= 0 shut + Item 14 - Penetration direction (1=x, 2=y, 3=z, 4=fractured in x-direction, 5=fractured in y-direction) + If undefined or zero, assume Z + Item 15 - Segment number containing connection (for multi-segment wells, =0 for ordinary wells) + Undefined items in this array may be set to zero. + */ + + // The K value might also be -1. It is not yet known why, or what it is supposed to mean, + // but for now we will interpret as 0. + // TODO: Ask Joakim Haave regarding this. + if ( cellK < 0 ) + { + // cvf::Trace::show("Well Connection for grid " + cvf::String(grid->gridName()) + "\n - Detected negative K + // value (K=" + cvf::String(cellK) + ") for well : " + cvf::String(wellName) + " K clamped to 0"); + + cellK = 0; + } + + // Introduced based on discussion with H�kon H�gst�l 08.09.2016 + if ( cellK >= static_cast( grid->cellCountK() ) ) + { + int maxCellK = static_cast( grid->cellCountK() ); + if ( wellNameForErrorMsgs ) + { + cvf::Trace::show( "Well Connection for grid " + cvf::String( grid->gridName() ) + + "\n - Ignored connection with invalid K value (K=" + cvf::String( cellK ) + + ", max K = " + cvf::String( maxCellK ) + ") for well : " + cvf::String( wellNameForErrorMsgs ) ); + } + return cvf::UNDEFINED_SIZE_T; + } + + return grid->cellIndexFromIJK( cellI, cellJ, cellK ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellResultPoint RifReaderEclipseWell::createWellResultPoint( const RigEclipseCaseData* eCaseData, + const RigGridBase* grid, + const well_conn_type* ert_connection, + const well_segment_type* segment, + const char* wellName ) +{ + CVF_ASSERT( ert_connection ); + CVF_ASSERT( grid ); + + size_t gridCellIndex = localGridCellIndexFromErtConnection( grid, ert_connection, wellName ); + + bool isCellOpen = well_conn_open( ert_connection ); + double volumeRate = well_conn_get_volume_rate( ert_connection ); + double oilRate = well_conn_get_oil_rate( ert_connection ); + double gasRate = well_conn_get_gas_rate( ert_connection ); + double waterRate = well_conn_get_water_rate( ert_connection ); + double connectionFactor = well_conn_get_connection_factor( ert_connection ); + + RigWellResultPoint resultPoint; + + if ( gridCellIndex != cvf::UNDEFINED_SIZE_T ) + { + int branchId = -1, segmentId = -1, outletBranchId = -1, outletSegmentId = -1; + + if ( segment ) + { + branchId = well_segment_get_branch_id( segment ); + segmentId = well_segment_get_id( segment ); + + auto outletSegment = well_segment_get_outlet( segment ); + if ( outletSegment ) + { + outletBranchId = well_segment_get_branch_id( outletSegment ); + outletSegmentId = well_segment_get_id( outletSegment ); + } + } + + resultPoint.setGridIndex( grid->gridIndex() ); + resultPoint.setGridCellIndex( gridCellIndex ); + + resultPoint.setIsOpen( isCellOpen ); + + resultPoint.setSegmentData( branchId, segmentId ); + resultPoint.setOutletSegmentData( outletBranchId, outletSegmentId ); + + const double adjustedGasRate = RiaEclipseUnitTools::convertSurfaceGasFlowRateToOilEquivalents( eCaseData->unitsType(), gasRate ); + resultPoint.setFlowData( volumeRate, oilRate, adjustedGasRate, waterRate ); + + resultPoint.setConnectionFactor( connectionFactor ); + + auto ijkOneBased = grid->ijkFromCellIndexOneBased( gridCellIndex ); + if ( ijkOneBased ) + { + resultPoint.setIjk( *ijkOneBased ); + } + } + + return resultPoint; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellResultPoint RifReaderEclipseWell::createWellResultPoint( const RigEclipseCaseData* eCaseData, + const RigGridBase* grid, + const well_conn_type* ert_connection, + const char* wellName ) +{ + return createWellResultPoint( eCaseData, grid, ert_connection, nullptr, wellName ); +} + +//-------------------------------------------------------------------------------------------------- +/// Inverse distance interpolation of the supplied points and distance weights for +/// the contributing points which are closest above, and closest below +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RifReaderEclipseWell::interpolate3DPosition( const std::vector& positions ) +{ + std::vector filteredPositions; + filteredPositions.reserve( positions.size() ); + + double minDistFromContribAbove = HUGE_VAL; + double minDistFromContribBelow = HUGE_VAL; + std::vector contrFromAbove; + std::vector contrFromBelow; + + for ( size_t i = 0; i < positions.size(); i++ ) + { + if ( positions[i].m_connectionPosition != cvf::Vec3d::UNDEFINED ) + { + if ( positions[i].m_isFromAbove && positions[i].m_lengthFromConnection < minDistFromContribAbove ) + { + if ( !contrFromAbove.empty() ) + contrFromAbove[0] = positions[i]; + else + contrFromAbove.push_back( positions[i] ); + + minDistFromContribAbove = positions[i].m_lengthFromConnection; + } + + if ( !positions[i].m_isFromAbove && positions[i].m_lengthFromConnection < minDistFromContribBelow ) + { + if ( !contrFromBelow.empty() ) + contrFromBelow[0] = positions[i]; + else + contrFromBelow.push_back( positions[i] ); + + minDistFromContribBelow = positions[i].m_lengthFromConnection; + } + } + } + + filteredPositions = contrFromAbove; + filteredPositions.insert( filteredPositions.end(), contrFromBelow.begin(), contrFromBelow.end() ); + + std::vector nominators( filteredPositions.size(), 0.0 ); + + double denominator = 0.0; + cvf::Vec3d interpolatedValue = cvf::Vec3d::ZERO; + + for ( size_t i = 0; i < filteredPositions.size(); i++ ) + { +#if 0 // Pure average test + nominators[i] = 1.0; +#else + double distance = filteredPositions[i].m_lengthFromConnection; + + if ( distance < 1e-6 ) + { + return filteredPositions[i].m_connectionPosition; + } + else if ( distance < 1.0 ) + { + // distance = 1.0; + } + + distance = 1.0 / distance; + nominators[i] = distance; + denominator += distance; + +#endif + } +#if 0 // Pure average test + denominator = positions.size(); // Pure average test +#endif + for ( size_t i = 0; i < filteredPositions.size(); i++ ) + { + interpolatedValue += ( nominators[i] / denominator ) * filteredPositions[i].m_connectionPosition; + } + + return interpolatedValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderEclipseWell::propagatePosContribDownwards( std::map>& segmentIdToPositionContrib, + const well_segment_collection_type* allErtSegments, + int ertSegmentId, + std::vector posContrib ) +{ + std::map>::iterator posContribIt; + posContribIt = segmentIdToPositionContrib.find( ertSegmentId ); + + if ( posContribIt != segmentIdToPositionContrib.end() ) + { + // Create a set of the segments below this, that has to be followed. + + std::set segmentIdsBelow; + for ( size_t i = 0; i < posContribIt->second.size(); ++i ) + { + segmentIdsBelow.insert( posContribIt->second[i].m_segmentIdUnder ); + } + + // Get the segment length to add to the contributions + + well_segment_type* segment = well_segment_collection_get( allErtSegments, posContribIt->first ); + double sementLength = well_segment_get_length( segment ); + + // If we do not have the contribution represented, add it, and accumulate the length + // If it is already present, do not touch + for ( size_t i = 0; i < posContrib.size(); ++i ) + { + bool foundContribution = false; + for ( size_t j = 0; j < posContribIt->second.size(); ++j ) + { + if ( posContribIt->second[j].m_connectionSegmentId == posContrib[i].m_connectionSegmentId ) + { + foundContribution = true; + break; + } + } + + if ( !foundContribution ) + { + posContrib[i].m_lengthFromConnection += sementLength; + posContrib[i].m_isFromAbove = true; + posContribIt->second.push_back( posContrib[i] ); + } + posContrib[i].m_segmentIdAbove = ertSegmentId; + } + + for ( std::set::iterator it = segmentIdsBelow.begin(); it != segmentIdsBelow.end(); ++it ) + { + propagatePosContribDownwards( segmentIdToPositionContrib, allErtSegments, ( *it ), posContrib ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// Helper class to determine whether a well connection is present in a sub cell +// for a specific well. Connections must be tested from innermost lgr to outermost since +// it accumulates the outer cells having subcell connections as it goes. +//-------------------------------------------------------------------------------------------------- +class WellResultPointHasSubCellConnectionCalculator +{ +public: + explicit WellResultPointHasSubCellConnectionCalculator( const RigMainGrid* mainGrid, well_state_type* ert_well_state ) + : m_mainGrid( mainGrid ) + { + int lastGridNr = static_cast( m_mainGrid->gridCountOnFile() ) - 1; + + for ( int gridNr = lastGridNr; gridNr >= 0; --gridNr ) + { + const well_conn_type* ert_wellhead = well_state_iget_wellhead( ert_well_state, static_cast( gridNr ) ); + if ( ert_wellhead ) + { + size_t localGridCellidx = + RifReaderEclipseWell::localGridCellIndexFromErtConnection( m_mainGrid->gridByIndex( gridNr ), ert_wellhead, nullptr ); + insertTheParentCells( gridNr, localGridCellidx ); + } + + std::string gridname = gridNr == 0 ? ECL_GRID_GLOBAL_GRID : m_mainGrid->gridByIndex( gridNr )->gridName(); + const well_conn_collection_type* connections = well_state_get_grid_connections( ert_well_state, gridname.data() ); + + if ( connections ) + { + int connectionCount = well_conn_collection_get_size( connections ); + if ( connectionCount ) + { + for ( int connIdx = 0; connIdx < connectionCount; connIdx++ ) + { + well_conn_type* ert_connection = well_conn_collection_iget( connections, connIdx ); + + size_t localGridCellidx = RifReaderEclipseWell::localGridCellIndexFromErtConnection( m_mainGrid->gridByIndex( gridNr ), + ert_connection, + nullptr ); + insertTheParentCells( gridNr, localGridCellidx ); + } + } + } + } + } + + bool hasSubCellConnection( const RigWellResultPoint& wellResultPoint ) + { + if ( !wellResultPoint.isCell() ) return false; + + size_t gridIndex = wellResultPoint.gridIndex(); + size_t gridCellIndex = wellResultPoint.cellIndex(); + + size_t reservoirCellIdx = m_mainGrid->reservoirCellIndexByGridAndGridLocalCellIndex( gridIndex, gridCellIndex ); + + return m_gridCellsWithSubCellWellConnections.count( reservoirCellIdx ) != 0; + } + +private: + void insertTheParentCells( size_t gridIndex, size_t gridCellIndex ) + { + if ( gridCellIndex == cvf::UNDEFINED_SIZE_T ) return; + + // Traverse parent gridcells, and add them to the map + + while ( gridIndex > 0 ) // is lgr + { + const RigCell& connectionCell = m_mainGrid->cellByGridAndGridLocalCellIdx( gridIndex, gridCellIndex ); + RigGridBase* hostGrid = connectionCell.hostGrid(); + + RigLocalGrid* lgrHost = static_cast( hostGrid ); + gridIndex = lgrHost->parentGrid()->gridIndex(); + gridCellIndex = connectionCell.parentCellIndex(); + + size_t parentReservoirCellIdx = m_mainGrid->reservoirCellIndexByGridAndGridLocalCellIndex( gridIndex, gridCellIndex ); + m_gridCellsWithSubCellWellConnections.insert( parentReservoirCellIdx ); + } + } + + std::set m_gridCellsWithSubCellWellConnections; + const RigMainGrid* m_mainGrid; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderEclipseWell::readWellCells( RifEclipseRestartDataAccess* restartDataAccess, + RigEclipseCaseData* eclipseCaseData, + std::vector filteredTimeSteps, + std::vector gridNames, + bool importCompleteMswData ) +{ + CVF_ASSERT( eclipseCaseData ); + + if ( restartDataAccess == nullptr ) return; + + well_info_type* ert_well_info = well_info_alloc( gridNames ); + if ( !ert_well_info ) return; + + restartDataAccess->readWellData( ert_well_info, importCompleteMswData ); + + std::vector daysSinceSimulationStart; + std::vector timeSteps; + restartDataAccess->timeSteps( &timeSteps, &daysSinceSimulationStart ); + std::vector reportNumbers = restartDataAccess->reportNumbers(); + + bool sameCount = false; + if ( timeSteps.size() == reportNumbers.size() ) + { + sameCount = true; + } + + std::vector grids; + eclipseCaseData->allGrids( &grids ); + + cvf::Collection wells; + caf::ProgressInfo progress( well_info_get_num_wells( ert_well_info ), "" ); + + int wellIdx; + for ( wellIdx = 0; wellIdx < well_info_get_num_wells( ert_well_info ); wellIdx++ ) + { + const char* wellName = well_info_iget_well_name( ert_well_info, wellIdx ); + CVF_ASSERT( wellName ); + + cvf::ref simWellData = new RigSimWellData; + simWellData->m_wellName = wellName; + + well_ts_type* ert_well_time_series = well_info_get_ts( ert_well_info, wellName ); + int timeStepCount = well_ts_get_size( ert_well_time_series ); + + simWellData->m_wellCellsTimeSteps.resize( timeStepCount ); + + int timeIdx; + for ( timeIdx = 0; timeIdx < timeStepCount; timeIdx++ ) + { + well_state_type* ert_well_state = well_ts_iget_state( ert_well_time_series, timeIdx ); + + RigWellResultFrame& wellResFrame = simWellData->m_wellCellsTimeSteps[timeIdx]; + + // Build timestamp for well + bool haveFoundTimeStamp = false; + + if ( sameCount ) + { + int reportNr = well_state_get_report_nr( ert_well_state ); + + for ( size_t i = 0; i < reportNumbers.size(); i++ ) + { + if ( reportNumbers[i] == reportNr ) + { + wellResFrame.setTimestamp( timeSteps[i] ); + haveFoundTimeStamp = true; + } + } + } + + if ( !haveFoundTimeStamp ) + { + // This fallback will not work for timesteps before 1970. + + // Also see RifEclipseOutputFileAccess::timeStepsText for accessing time_t structures + time_t stepTime = well_state_get_sim_time( ert_well_state ); + wellResFrame.setTimestamp( QDateTime::fromSecsSinceEpoch( stepTime, Qt::UTC ) ); + } + + // Production type + well_type_enum ert_well_type = well_state_get_type( ert_well_state ); + if ( ert_well_type == ECL_WELL_PRODUCER ) + { + wellResFrame.setProductionType( RiaDefines::WellProductionType::PRODUCER ); + } + else if ( ert_well_type == ECL_WELL_WATER_INJECTOR ) + { + wellResFrame.setProductionType( RiaDefines::WellProductionType::WATER_INJECTOR ); + } + else if ( ert_well_type == ECL_WELL_GAS_INJECTOR ) + { + wellResFrame.setProductionType( RiaDefines::WellProductionType::GAS_INJECTOR ); + } + else if ( ert_well_type == ECL_WELL_OIL_INJECTOR ) + { + wellResFrame.setProductionType( RiaDefines::WellProductionType::OIL_INJECTOR ); + } + else + { + wellResFrame.setProductionType( RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE ); + } + + wellResFrame.setIsOpen( well_state_is_open( ert_well_state ) ); + + if ( importCompleteMswData && well_state_is_MSW( ert_well_state ) ) + { + simWellData->setMultiSegmentWell( true ); + + // how do we handle LGR-s ? + // 1. Create separate visual branches for each Grid, with its own wellhead + // 2. Always use the connections to the grid with the highest number (innermost LGR). + // 3. Handle both and switch between them according to visual settings of grid visualization + // Will there ever exist connections to different grids for the same segment ? + // We have currently selected 2. + + // Set the wellhead + + int lastGridNr = static_cast( grids.size() ) - 1; + for ( int gridNr = lastGridNr; gridNr >= 0; --gridNr ) + { + // If several grids have a wellhead definition for this well, we use the last one. + // (Possibly the innermost LGR) + + const well_conn_type* ert_wellhead = well_state_iget_wellhead( ert_well_state, static_cast( gridNr ) ); + if ( ert_wellhead ) + { + auto wellHead = RifReaderEclipseWell::createWellResultPoint( eclipseCaseData, grids[gridNr], ert_wellhead, wellName ); + + // HACK: Ert returns open as "this is equally wrong as closed for well heads". + // Well heads are not open jfr mail communication with HHGS and JH Statoil 07.01.2016 + wellHead.setIsOpen( false ); + wellResFrame.setWellHead( wellHead ); + break; + } + } + + well_branch_collection_type* branches = well_state_get_branches( ert_well_state ); + int branchCount = well_branch_collection_get_size( branches ); + std::map> segmentIdToPositionContrib; + std::vector upperSegmentIdsOfUnpositionedSegementGroup; + + // Create copy of well result branches for modification + std::vector wellResultBranches = wellResFrame.wellResultBranches(); + wellResultBranches.resize( branchCount ); + + // For each branch, go from bottom segment upwards and transfer their connections to WellResultpoints. + // If they have no connections, create a resultpoint representing their bottom position, which will + // receive an actual position at a later stage. + // I addition, distribute contributions for calculating segment bottom positions from bottom and up. + + for ( int bIdx = 0; bIdx < well_branch_collection_get_size( branches ); bIdx++ ) + { + RigWellResultBranch& wellResultBranch = wellResultBranches[bIdx]; + + const well_segment_type* segment = well_branch_collection_iget_start_segment( branches, bIdx ); + + int branchId = well_segment_get_branch_id( segment ); + wellResultBranch.setErtBranchId( branchId ); + + // Data for segment position calculation + int lastConnectionSegmentId = -1; + cvf::Vec3d lastConnectionPos = cvf::Vec3d::UNDEFINED; + cvf::Vec3d lastConnectionCellCorner = cvf::Vec3d::UNDEFINED; + double lastConnectionCellSize = 0; + double accLengthFromLastConnection = 0; + int segmentIdBelow = -1; + bool segmentBelowHasConnections = false; + + while ( segment && branchId == well_segment_get_branch_id( segment ) ) + { + // Loop backwards, making us select the connection in the innermost lgr as the truth + bool segmentHasConnections = false; + + for ( int gridNr = lastGridNr; gridNr >= 0; --gridNr ) + { + std::string gridName = ertGridName( eclipseCaseData, gridNr ); + + // If this segment has connections in any grid, transfer the innermost ones + + if ( well_segment_has_grid_connections( segment, gridName.data() ) ) + { + const well_conn_collection_type* connections = well_segment_get_connections( segment, gridName.data() ); + int connectionCount = well_conn_collection_get_size( connections ); + + // Loop backwards to put the deepest connections first in the array. (The segments are + // also traversed deep to shallow) + for ( int connIdx = connectionCount - 1; connIdx >= 0; connIdx-- ) + { + well_conn_type* ert_connection = well_conn_collection_iget( connections, connIdx ); + wellResultBranch.addBranchResultPoint( RifReaderEclipseWell::createWellResultPoint( eclipseCaseData, + grids[gridNr], + ert_connection, + segment, + wellName ) ); + } + + segmentHasConnections = true; + + // Prepare data for segment position calculation + + well_conn_type* ert_connection = well_conn_collection_iget( connections, 0 ); + RigWellResultPoint point = + RifReaderEclipseWell::createWellResultPoint( eclipseCaseData, grids[gridNr], ert_connection, segment, wellName ); + lastConnectionPos = grids[gridNr]->cell( point.cellIndex() ).center(); + cvf::Vec3d cellVxes[8]; + grids[gridNr]->cellCornerVertices( point.cellIndex(), cellVxes ); + lastConnectionCellCorner = cellVxes[0]; + lastConnectionCellSize = ( lastConnectionPos - cellVxes[0] ).length(); + + lastConnectionSegmentId = well_segment_get_id( segment ); + accLengthFromLastConnection = well_segment_get_length( segment ) / ( connectionCount + 1 ); + if ( !segmentBelowHasConnections ) upperSegmentIdsOfUnpositionedSegementGroup.push_back( segmentIdBelow ); + + break; // Stop looping over grids + } + } + + // If the segment did not have connections at all, we need to create a resultpoint representing + // the bottom of the segment and store it as an unpositioned segment + + if ( !segmentHasConnections ) + { + RigWellResultPoint data; + data.setSegmentData( branchId, well_segment_get_id( segment ) ); + + wellResultBranch.addBranchResultPoint( data ); + + // Store data for segment position calculation + bool isAnInsolationContribution = accLengthFromLastConnection < lastConnectionCellSize; + + segmentIdToPositionContrib[well_segment_get_id( segment )].push_back( + SegmentPositionContribution( lastConnectionSegmentId, + lastConnectionPos, + accLengthFromLastConnection, + isAnInsolationContribution, + segmentIdBelow, + -1, + false ) ); + accLengthFromLastConnection += well_segment_get_length( segment ); + } + + segmentIdBelow = well_segment_get_id( segment ); + segmentBelowHasConnections = segmentHasConnections; + + if ( well_segment_get_outlet_id( segment ) == -1 ) + { + segment = nullptr; + } + else + { + segment = well_segment_get_outlet( segment ); + } + } + + // Add resultpoint representing the outlet segment (bottom), if not the branch ends at the wellhead. + + const well_segment_type* outletSegment = segment; + + if ( outletSegment ) + { + bool outletSegmentHasConnections = false; + + for ( int gridNr = lastGridNr; gridNr >= 0; --gridNr ) + { + std::string gridName = ertGridName( eclipseCaseData, gridNr ); + + // If this segment has connections in any grid, use the deepest innermost one + + if ( well_segment_has_grid_connections( outletSegment, gridName.data() ) ) + { + const well_conn_collection_type* connections = well_segment_get_connections( outletSegment, gridName.data() ); + int connectionCount = well_conn_collection_get_size( connections ); + + // Select the deepest connection + well_conn_type* ert_connection = well_conn_collection_iget( connections, connectionCount - 1 ); + + auto resultPoint = RifReaderEclipseWell::createWellResultPoint( eclipseCaseData, + grids[gridNr], + ert_connection, + outletSegment, + wellName ); + // This result point is only supposed to be used to indicate connection to a parent well + // Clear all flow in this result point + resultPoint.clearAllFlow(); + + wellResultBranch.addBranchResultPoint( resultPoint ); + + outletSegmentHasConnections = true; + break; // Stop looping over grids + } + } + + if ( !outletSegmentHasConnections ) + { + // Store the result point + + RigWellResultPoint data; + data.setSegmentData( well_segment_get_branch_id( outletSegment ), well_segment_get_id( outletSegment ) ); + wellResultBranch.addBranchResultPoint( data ); + + // Store data for segment position calculation, + // and propagate it upwards until we meet a segment with connections + + bool isAnInsolationContribution = accLengthFromLastConnection < lastConnectionCellSize; + + cvf::Vec3d lastConnectionPosWOffset = lastConnectionPos; + if ( isAnInsolationContribution ) + lastConnectionPosWOffset += 0.4 * ( lastConnectionCellCorner - lastConnectionPos ); + + segmentIdToPositionContrib[well_segment_get_id( outletSegment )].push_back( + SegmentPositionContribution( lastConnectionSegmentId, + lastConnectionPosWOffset, + accLengthFromLastConnection, + isAnInsolationContribution, + segmentIdBelow, + -1, + false ) ); + + /// Loop further to add this position contribution until a segment with connections is found + + accLengthFromLastConnection += well_segment_get_length( outletSegment ); + segmentIdBelow = well_segment_get_id( outletSegment ); + + const well_segment_type* aboveOutletSegment = nullptr; + + if ( well_segment_get_outlet_id( outletSegment ) == -1 ) + { + aboveOutletSegment = nullptr; + } + else + { + aboveOutletSegment = well_segment_get_outlet( outletSegment ); + } + + while ( aboveOutletSegment ) + { + // Loop backwards, just because we do that the other places + bool segmentHasConnections = false; + + for ( int gridNr = lastGridNr; gridNr >= 0; --gridNr ) + { + std::string gridName = ertGridName( eclipseCaseData, gridNr ); + + // If this segment has connections in any grid, stop traversal + + if ( well_segment_has_grid_connections( aboveOutletSegment, gridName.data() ) ) + { + segmentHasConnections = true; + break; + } + } + + if ( !segmentHasConnections ) + { + segmentIdToPositionContrib[well_segment_get_id( aboveOutletSegment )].push_back( + SegmentPositionContribution( lastConnectionSegmentId, + lastConnectionPos, + accLengthFromLastConnection, + isAnInsolationContribution, + segmentIdBelow, + -1, + false ) ); + accLengthFromLastConnection += well_segment_get_length( aboveOutletSegment ); + } + else + { + break; // We have found a segment with connections. We do not need to propagate + // position contributions further + } + + segmentIdBelow = well_segment_get_id( aboveOutletSegment ); + + if ( well_segment_get_outlet_id( aboveOutletSegment ) == -1 ) + { + aboveOutletSegment = nullptr; + } + else + { + aboveOutletSegment = well_segment_get_outlet( aboveOutletSegment ); + } + } + } + } + else + { + // Add wellhead as result point Nope. Not Yet, but it is a good idea. + // The centerline calculations would be a bit simpler, I think. + } + + // Reverse the order of the result points in this branch, making the deepest come last + auto branchResultPoints = wellResultBranch.branchResultPoints(); + std::reverse( branchResultPoints.begin(), branchResultPoints.end() ); + wellResultBranch.setBranchResultPoints( branchResultPoints ); + } // End of the branch loop + + // Set modified copy back to frame + wellResFrame.setWellResultBranches( wellResultBranches ); + + // Propagate position contributions from connections above unpositioned segments downwards + + well_segment_collection_type* allErtSegments = well_state_get_segments( ert_well_state ); + + bool isWellHead = true; + for ( const auto& wellResultBranch : wellResFrame.wellResultBranches() ) + { + bool previousResultPointWasCell = isWellHead; + + // Go downwards until we find a none-cell result point just after a cell result point + // When we do, start propagating + + for ( size_t rpIdx = 0; rpIdx < wellResultBranch.branchResultPoints().size(); ++rpIdx ) + { + const RigWellResultPoint resPoint = wellResultBranch.branchResultPoints()[rpIdx]; + if ( resPoint.isCell() ) + { + previousResultPointWasCell = true; + } + else + { + if ( previousResultPointWasCell ) + { + RigWellResultPoint prevResPoint; + if ( isWellHead && rpIdx == 0 ) + { + prevResPoint = wellResFrame.wellHead(); + } + else + { + prevResPoint = wellResultBranch.branchResultPoints()[rpIdx - 1]; + } + + cvf::Vec3d lastConnectionPos = grids[prevResPoint.gridIndex()]->cell( prevResPoint.cellIndex() ).center(); + + SegmentPositionContribution + posContrib( prevResPoint.segmentId(), lastConnectionPos, 0.0, false, -1, prevResPoint.segmentId(), true ); + + int ertSegmentId = resPoint.segmentId(); + + std::map>::iterator posContribIt; + posContribIt = segmentIdToPositionContrib.find( ertSegmentId ); + CVF_ASSERT( posContribIt != segmentIdToPositionContrib.end() ); + + std::vector posContributions = posContribIt->second; + for ( size_t i = 0; i < posContributions.size(); ++i ) + { + posContributions[i].m_segmentIdAbove = prevResPoint.segmentId(); + } + posContributions.push_back( posContrib ); + + propagatePosContribDownwards( segmentIdToPositionContrib, allErtSegments, ertSegmentId, posContributions ); + } + + previousResultPointWasCell = false; + } + } + + isWellHead = false; + } + + // Calculate the bottom position of all the unpositioned segments + // Then do the calculation based on the refined contributions + + std::map>::iterator posContribIt = segmentIdToPositionContrib.begin(); + std::map bottomPositions; + while ( posContribIt != segmentIdToPositionContrib.end() ) + { + bottomPositions[posContribIt->first] = interpolate3DPosition( posContribIt->second ); + ++posContribIt; + } + + // Copy content and distribute the positions to the result points stored in the wellResultBranch.branchResultPoints() + // set updated copy back to frame + + std::vector newWellResultBranches = wellResFrame.wellResultBranches(); + for ( auto& wellResultBranch : newWellResultBranches ) + { + RigWellResultBranch& newWellResultBranch = wellResultBranch; + for ( auto& resultPoint : newWellResultBranch.branchResultPoints() ) + { + if ( !resultPoint.isCell() ) + { + resultPoint.setBottomPosition( bottomPositions[resultPoint.segmentId()] ); + } + } + } + wellResFrame.setWellResultBranches( newWellResultBranches ); + } // End of the MSW section + else + { + // Code handling None-MSW Wells ... Normal wells that is. + + WellResultPointHasSubCellConnectionCalculator subCellConnCalc( eclipseCaseData->mainGrid(), ert_well_state ); + int lastGridNr = static_cast( grids.size() ) - 1; + for ( int gridNr = 0; gridNr <= lastGridNr; ++gridNr ) + { + const well_conn_type* ert_wellhead = well_state_iget_wellhead( ert_well_state, static_cast( gridNr ) ); + if ( ert_wellhead ) + { + RigWellResultPoint wellHeadRp = + RifReaderEclipseWell::createWellResultPoint( eclipseCaseData, grids[gridNr], ert_wellhead, wellName ); + // HACK: Ert returns open as "this is equally wrong as closed for well heads". + // Well heads are not open jfr mail communication with HHGS and JH Statoil 07.01.2016 + wellHeadRp.setIsOpen( false ); + + if ( !subCellConnCalc.hasSubCellConnection( wellHeadRp ) ) wellResFrame.setWellHead( wellHeadRp ); + } + + const well_conn_collection_type* connections = + well_state_get_grid_connections( ert_well_state, ertGridName( eclipseCaseData, gridNr ).data() ); + + // Import all well result cells for all connections + if ( connections ) + { + int connectionCount = well_conn_collection_get_size( connections ); + if ( connectionCount ) + { + RigWellResultBranch wellResultBranch; + wellResultBranch.setErtBranchId( 0 ); // Normal wells have only one branch + + std::vector branchResultPoints = wellResultBranch.branchResultPoints(); + const size_t existingCellCount = branchResultPoints.size(); + branchResultPoints.resize( existingCellCount + connectionCount ); + + for ( int connIdx = 0; connIdx < connectionCount; connIdx++ ) + { + well_conn_type* ert_connection = well_conn_collection_iget( connections, connIdx ); + RigWellResultPoint wellRp = + RifReaderEclipseWell::createWellResultPoint( eclipseCaseData, grids[gridNr], ert_connection, wellName ); + + if ( !subCellConnCalc.hasSubCellConnection( wellRp ) ) + { + branchResultPoints[existingCellCount + connIdx] = wellRp; + } + } + wellResultBranch.setBranchResultPoints( branchResultPoints ); + wellResFrame.addWellResultBranch( wellResultBranch ); + } + } + } + } + } + + simWellData->computeMappingFromResultTimeIndicesToWellTimeIndices( filteredTimeSteps ); + + wells.push_back( simWellData.p() ); + + progress.incrementProgress(); + } + + well_info_free( ert_well_info ); + + eclipseCaseData->setSimWellData( wells ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RifReaderEclipseWell::ertGridName( const RigEclipseCaseData* eCaseData, size_t gridNr ) +{ + std::string gridName; + if ( gridNr == 0 ) + { + gridName = ECL_GRID_GLOBAL_GRID; + } + else + { + CVF_ASSERT( eCaseData ); + CVF_ASSERT( eCaseData->gridCount() > gridNr ); + gridName = eCaseData->grid( gridNr )->gridName(); + } + + return gridName; +} diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseWell.h b/ApplicationLibCode/FileInterface/RifReaderEclipseWell.h new file mode 100644 index 0000000000..214746f7e4 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseWell.h @@ -0,0 +1,78 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 +#include + +#include "cvfVector3.h" +#include + +class RifEclipseRestartDataAccess; +class RigGridBase; +class RigEclipseCaseData; + +struct RigWellResultPoint; +struct SegmentPositionContribution; + +// NOLINTBEGIN(modernize-use-using) +typedef struct well_conn_struct well_conn_type; +typedef struct well_segment_struct well_segment_type; +typedef struct well_segment_collection_struct well_segment_collection_type; +// NOLINTEND(modernize-use-using) + +//================================================================================================== +// +// +// +//================================================================================================== +class RifReaderEclipseWell +{ +private: + RifReaderEclipseWell(){}; + +public: + static void readWellCells( RifEclipseRestartDataAccess* restartDataAccess, + RigEclipseCaseData* eclipseCaseData, + std::vector filteredTimeSteps, + std::vector gridNames, + bool importCompleteMswData ); + + static size_t + localGridCellIndexFromErtConnection( const RigGridBase* grid, const well_conn_type* ert_connection, const char* wellNameForErrorMsgs ); + +private: + static RigWellResultPoint createWellResultPoint( const RigEclipseCaseData* eCaseData, + const RigGridBase* grid, + const well_conn_type* ert_connection, + const char* wellName ); + static RigWellResultPoint createWellResultPoint( const RigEclipseCaseData* eCaseData, + const RigGridBase* grid, + const well_conn_type* ert_connection, + const well_segment_type* segment, + const char* wellName ); + + static cvf::Vec3d interpolate3DPosition( const std::vector& positions ); + static void propagatePosContribDownwards( std::map>& segmentIdToPositionContrib, + const well_segment_collection_type* allErtSegments, + int ertSegmentId, + std::vector posContrib ); + + static std::string ertGridName( const RigEclipseCaseData* eCaseData, size_t gridNr ); +}; diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp index 341f172dbb..6fb8becd86 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp @@ -51,9 +51,9 @@ bool RifReaderInterface::isNNCsEnabled() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderInterface::isSkipWellData() +bool RifReaderInterface::loadWellDataEnabled() { - return readerSettings()->skipWellData; + return !readerSettings()->skipWellData; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.h b/ApplicationLibCode/FileInterface/RifReaderInterface.h index 7619b392e3..f97039dd91 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.h +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.h @@ -56,7 +56,7 @@ class RifReaderInterface : public cvf::Object bool isImportOfCompleteMswDataEnabled(); bool isNNCsEnabled(); bool includeInactiveCellsInFaultGeometry(); - bool isSkipWellData(); + bool loadWellDataEnabled(); const QString faultIncludeFileAbsolutePathPrefix(); virtual bool open( const QString& fileName, RigEclipseCaseData* eclipseCase ) = 0; diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp index 2d92279529..56c7c26700 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp @@ -21,32 +21,31 @@ #include "RiaEclipseFileNameTools.h" #include "RiaLogging.h" #include "RiaQDateTimeTools.h" +#include "RiaStdStringTools.h" #include "RifEclipseOutputFileTools.h" -#include "RifOpmGridTools.h" +#include "RifEclipseReportKeywords.h" +#include "RifEclipseUnifiedRestartFileAccess.h" +#include "RifOpmRadialGridTools.h" +#include "RifReaderEclipseWell.h" +#include "RigActiveCellInfo.h" +#include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" #include "RigEclipseResultInfo.h" #include "RigMainGrid.h" +#include "RigNNCData.h" #include "RigSimWellData.h" #include "RigWellResultFrame.h" #include "cafProgressInfo.h" -#include "opm/input/eclipse/Deck/Deck.hpp" -#include "opm/input/eclipse/EclipseState/Runspec.hpp" -#include "opm/input/eclipse/Parser/Parser.hpp" -#include "opm/input/eclipse/Schedule/Well/Connection.hpp" -#include "opm/input/eclipse/Schedule/Well/Well.hpp" +#include "opm/io/eclipse/EGrid.hpp" #include "opm/io/eclipse/EInit.hpp" #include "opm/io/eclipse/ERst.hpp" -#include "opm/io/eclipse/RestartFileView.hpp" -#include "opm/io/eclipse/rst/state.hpp" -#include "opm/output/eclipse/VectorItems/group.hpp" #include "opm/output/eclipse/VectorItems/intehead.hpp" -#include "opm/output/eclipse/VectorItems/well.hpp" -#include +#include using namespace Opm; @@ -54,6 +53,8 @@ using namespace Opm; /// //-------------------------------------------------------------------------------------------------- RifReaderOpmCommon::RifReaderOpmCommon() + : m_eclipseCaseData( nullptr ) + , m_gridUnit( -1 ) { } @@ -67,7 +68,7 @@ RifReaderOpmCommon::~RifReaderOpmCommon() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* eclipseCase ) +bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* eclipseCaseData ) { caf::ProgressInfo progress( 100, "Reading Grid" ); @@ -77,8 +78,9 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli try { m_gridFileName = fileName.toStdString(); + locateInitAndRestartFiles( fileName ); - if ( !RifOpmGridTools::importGrid( m_gridFileName, eclipseCase->mainGrid(), eclipseCase ) ) + if ( !importGrid( eclipseCaseData->mainGrid(), eclipseCaseData ) ) { RiaLogging::error( "Failed to open grid file " + fileName ); @@ -94,14 +96,35 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli importFaults( fileSet, &faults ); - RigMainGrid* mainGrid = eclipseCase->mainGrid(); + RigMainGrid* mainGrid = eclipseCaseData->mainGrid(); mainGrid->setFaults( faults ); } } + m_eclipseCaseData = eclipseCaseData; + + { + auto task = progress.task( "Reading Results Meta data", 25 ); + buildMetaData( eclipseCaseData, progress ); + } + + auto task = progress.task( "Handling NCC Result data", 25 ); + if ( isNNCsEnabled() ) { - auto task = progress.task( "Reading Results Meta data", 50 ); - buildMetaData( eclipseCase ); + caf::ProgressInfo nncProgress( 10, "" ); + RigMainGrid* mainGrid = eclipseCaseData->mainGrid(); + + // This test should probably be improved to test more directly for presence of NNC data + if ( eclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->hasFlowDiagUsableFluxes() ) + { + auto subNncTask = nncProgress.task( "Reading dynamic NNC data" ); + transferDynamicNNCData( mainGrid ); + } + + RigActiveCellInfo* activeCellInfo = m_eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + + bool includeInactiveCells = includeInactiveCellsInFaultGeometry(); + mainGrid->nncData()->setSourceDataForProcessing( mainGrid, activeCellInfo, includeInactiveCells ); } return true; @@ -115,6 +138,343 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderOpmCommon::importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* eclipseCaseData ) +{ + Opm::EclIO::EGrid opmGrid( m_gridFileName ); + + RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); + + const auto& dims = opmGrid.dimension(); + mainGrid->setGridPointDimensions( cvf::Vec3st( dims[0] + 1, dims[1] + 1, dims[2] + 1 ) ); + mainGrid->setGridName( "Main grid" ); + mainGrid->setDualPorosity( opmGrid.porosity_mode() > 0 ); + + // assign grid unit, if found (1 = Metric, 2 = Field, 3 = Lab) + auto gridUnitStr = RiaStdStringTools::toUpper( opmGrid.grid_unit() ); + if ( gridUnitStr.starts_with( 'M' ) ) + m_gridUnit = 1; + else if ( gridUnitStr.starts_with( 'F' ) ) + m_gridUnit = 2; + else if ( gridUnitStr.starts_with( 'C' ) ) + m_gridUnit = 3; + + auto totalCellCount = opmGrid.totalNumberOfCells(); + auto globalMatrixActiveSize = opmGrid.activeCells(); + auto globalFractureActiveSize = opmGrid.activeFracCells(); + + const auto& lgr_names = opmGrid.list_of_lgrs(); + m_gridNames.clear(); + m_gridNames.push_back( "global" ); + m_gridNames.insert( m_gridNames.end(), lgr_names.begin(), lgr_names.end() ); + const auto& lgr_parent_names = opmGrid.list_of_lgr_parents(); + const int numLGRs = (int)lgr_names.size(); + + std::vector lgrGrids; + + for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ ) + { + lgrGrids.emplace_back( Opm::EclIO::EGrid( m_gridFileName, lgr_names[lgrIdx] ) ); + RigLocalGrid* localGrid = new RigLocalGrid( mainGrid ); + + const auto& lgrDims = lgrGrids[lgrIdx].dimension(); + localGrid->setGridPointDimensions( cvf::Vec3st( lgrDims[0] + 1, lgrDims[1] + 1, lgrDims[2] + 1 ) ); + + localGrid->setGridId( lgrIdx + 1 ); + localGrid->setGridName( lgr_names[lgrIdx] ); + mainGrid->addLocalGrid( localGrid ); + + localGrid->setIndexToStartOfCells( totalCellCount ); + + totalCellCount += lgrGrids[lgrIdx].totalNumberOfCells(); + } + + activeCellInfo->setReservoirCellCount( totalCellCount ); + fractureActiveCellInfo->setReservoirCellCount( totalCellCount ); + + mainGrid->globalCellArray().reserve( (size_t)totalCellCount ); + mainGrid->nodes().reserve( (size_t)totalCellCount * 8 ); + + caf::ProgressInfo progInfo( 4 + numLGRs, "" ); + + { + auto task = progInfo.task( "Loading Main Grid Data", 3 ); + transferGeometry( opmGrid, opmGrid, mainGrid, mainGrid, eclipseCaseData, 0, 0 ); + } + + activeCellInfo->setGridCount( 1 + numLGRs ); + fractureActiveCellInfo->setGridCount( 1 + numLGRs ); + + activeCellInfo->setGridActiveCellCounts( 0, globalMatrixActiveSize ); + fractureActiveCellInfo->setGridActiveCellCounts( 0, globalFractureActiveSize ); + + bool hasParentInfo = ( lgr_parent_names.size() >= (size_t)numLGRs ); + + for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ ) + { + auto task = progInfo.task( "LGR number " + QString::number( lgrIdx + 1 ), 1 ); + + RigGridBase* parentGrid = hasParentInfo ? mainGrid->gridByName( lgr_parent_names[lgrIdx] ) : mainGrid; + + RigLocalGrid* localGrid = static_cast( mainGrid->gridById( lgrIdx + 1 ) ); + localGrid->setParentGrid( parentGrid ); + + transferGeometry( opmGrid, lgrGrids[lgrIdx], mainGrid, localGrid, eclipseCaseData, globalMatrixActiveSize, globalFractureActiveSize ); + + int matrixActiveCellCount = lgrGrids[lgrIdx].activeCells(); + globalMatrixActiveSize += matrixActiveCellCount; + activeCellInfo->setGridActiveCellCounts( lgrIdx + 1, matrixActiveCellCount ); + + int fractureActiveCellCount = lgrGrids[lgrIdx].activeFracCells(); + globalFractureActiveSize += fractureActiveCellCount; + fractureActiveCellInfo->setGridActiveCellCounts( lgrIdx + 1, fractureActiveCellCount ); + } + + mainGrid->initAllSubGridsParentGridPointer(); + activeCellInfo->computeDerivedData(); + fractureActiveCellInfo->computeDerivedData(); + + if ( isNNCsEnabled() ) + { + auto task = progInfo.task( "Handling NNC data", 1 ); + transferStaticNNCData( opmGrid, lgrGrids, mainGrid ); + } + + auto opmMapAxes = opmGrid.get_mapaxes(); + if ( opmMapAxes.size() == 6 ) + { + std::array mapAxes; + for ( size_t i = 0; i < opmMapAxes.size(); ++i ) + { + mapAxes[i] = opmMapAxes[i]; + } + + // Set the map axes transformation matrix on the main grid + mainGrid->setMapAxes( mapAxes ); + mainGrid->setUseMapAxes( true ); + + auto transform = mainGrid->mapAxisTransform(); + + // Invert the transformation matrix to convert from file coordinates to domain coordinates + transform.invert(); + +#pragma omp parallel for + for ( long i = 0; i < static_cast( mainGrid->nodes().size() ); i++ ) + { + auto& n = mainGrid->nodes()[i]; + n.transformPoint( transform ); + } + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmCommon::transferStaticNNCData( Opm::EclIO::EGrid& opmMainGrid, std::vector& lgrGrids, RigMainGrid* mainGrid ) +{ + opmMainGrid.load_nnc_data(); + for ( auto& lgr : lgrGrids ) + { + lgr.load_nnc_data(); + } + + auto connections = opmMainGrid.nnc_connections( 0 ); + + for ( int i = 0; i < (int)lgrGrids.size(); i++ ) + { + auto conn = lgrGrids[i].nnc_connections( i + 1 ); + connections.insert( connections.end(), conn.begin(), conn.end() ); + } + + if ( connections.size() > 0 ) + { + // Transform to our own data structures + RigConnectionContainer nncConnections; + std::vector transmissibilityValues; + + for ( auto& c : connections ) + { + RigGridBase* grid1 = mainGrid->gridByIndex( c.grid1_Id ); + RigGridBase* grid2 = mainGrid->gridByIndex( c.grid2_Id ); + + RigConnection nncConnection( grid1->reservoirCellIndex( c.grid1_CellIdx - 1 ), grid2->reservoirCellIndex( c.grid2_CellIdx - 1 ) ); + + nncConnections.push_back( nncConnection ); + + transmissibilityValues.push_back( c.transValue ); + } + + mainGrid->nncData()->setEclipseConnections( nncConnections ); + mainGrid->nncData()->makeScalarResultAndSetValues( RiaDefines::propertyNameCombTrans(), transmissibilityValues ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmCommon::transferDynamicNNCData( RigMainGrid* mainGrid ) +{ + if ( !m_restartFile ) return; + + const size_t timeStepCount = m_restartFile->numberOfReportSteps(); + + std::vector>& waterFluxData = + mainGrid->nncData()->makeDynamicConnectionScalarResult( RiaDefines::propertyNameFluxWat(), timeStepCount ); + std::vector>& oilFluxData = + mainGrid->nncData()->makeDynamicConnectionScalarResult( RiaDefines::propertyNameFluxOil(), timeStepCount ); + std::vector>& gasFluxData = + mainGrid->nncData()->makeDynamicConnectionScalarResult( RiaDefines::propertyNameFluxGas(), timeStepCount ); + + for ( size_t timeStep = 0; timeStep < timeStepCount; ++timeStep ) + { + dynamicResult( "FLRWATN+", RiaDefines::PorosityModelType::MATRIX_MODEL, timeStep, &waterFluxData[timeStep] ); + dynamicResult( "FLRGASN+", RiaDefines::PorosityModelType::MATRIX_MODEL, timeStep, &gasFluxData[timeStep] ); + dynamicResult( "FLROILN+", RiaDefines::PorosityModelType::MATRIX_MODEL, timeStep, &oilFluxData[timeStep] ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmCommon::transferGeometry( Opm::EclIO::EGrid& opmMainGrid, + Opm::EclIO::EGrid& opmGrid, + RigMainGrid* mainGrid, + RigGridBase* localGrid, + RigEclipseCaseData* eclipseCaseData, + size_t matrixActiveStartIndex, + size_t fractureActiveStartIndex ) +{ + int cellCount = opmGrid.totalNumberOfCells(); + size_t cellStartIndex = mainGrid->globalCellArray().size(); + size_t nodeStartIndex = mainGrid->nodes().size(); + + RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); + + RigCell defaultCell; + defaultCell.setHostGrid( localGrid ); + mainGrid->globalCellArray().resize( cellStartIndex + cellCount, defaultCell ); + + mainGrid->nodes().resize( nodeStartIndex + cellCount * 8, cvf::Vec3d( 0, 0, 0 ) ); + + auto& riNodes = mainGrid->nodes(); + + opmGrid.loadData(); + opmGrid.load_grid_data(); + + const bool isRadialGrid = opmGrid.is_radial(); + + const auto& gridDimension = opmGrid.dimension(); + const auto& hostCellGlobalIndices = opmGrid.hostCellsGlobalIndex(); + + // Compute the center of the LGR radial grid cells for each K layer + auto radialGridCenterTopLayerOpm = isRadialGrid ? RifOpmRadialGridTools::computeXyCenterForTopOfCells( opmMainGrid, opmGrid, localGrid ) + : std::map>(); + + // use same mapping as resdata + const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 }; + +#pragma omp parallel for + for ( int opmCellIndex = 0; opmCellIndex < static_cast( localGrid->cellCount() ); opmCellIndex++ ) + { + auto opmIJK = opmGrid.ijk_from_global_index( opmCellIndex ); + + double xCenterCoordOpm = 0.0; + double yCenterCoordOpm = 0.0; + + if ( isRadialGrid && radialGridCenterTopLayerOpm.contains( opmIJK[2] ) ) + { + const auto& [xCenter, yCenter] = radialGridCenterTopLayerOpm[opmIJK[2]]; + xCenterCoordOpm = xCenter; + yCenterCoordOpm = yCenter; + } + + auto riReservoirIndex = localGrid->cellIndexFromIJK( opmIJK[0], opmIJK[1], opmIJK[2] ); + RigCell& cell = mainGrid->globalCellArray()[cellStartIndex + riReservoirIndex]; + cell.setGridLocalCellIndex( riReservoirIndex ); + + // active cell index + int matrixActiveIndex = opmGrid.active_index( opmIJK[0], opmIJK[1], opmIJK[2] ); + if ( matrixActiveIndex != -1 ) + { + activeCellInfo->setCellResultIndex( cellStartIndex + opmCellIndex, matrixActiveStartIndex + matrixActiveIndex ); + } + + int fractureActiveIndex = opmGrid.active_frac_index( opmIJK[0], opmIJK[1], opmIJK[2] ); + if ( fractureActiveIndex != -1 ) + { + fractureActiveCellInfo->setCellResultIndex( cellStartIndex + opmCellIndex, fractureActiveStartIndex + fractureActiveIndex ); + } + + // parent cell index + if ( ( hostCellGlobalIndices.size() > (size_t)opmCellIndex ) && hostCellGlobalIndices[opmCellIndex] >= 0 ) + { + cell.setParentCellIndex( hostCellGlobalIndices[opmCellIndex] ); + } + else + { + cell.setParentCellIndex( cvf::UNDEFINED_SIZE_T ); + } + + // corner coordinates + std::array opmX{}; + std::array opmY{}; + std::array opmZ{}; + opmGrid.getCellCorners( opmCellIndex, opmX, opmY, opmZ ); + + // Each cell has 8 nodes, use reservoir cell index and multiply to find first node index for cell + auto riNodeStartIndex = nodeStartIndex + riReservoirIndex * 8; + + for ( size_t opmNodeIndex = 0; opmNodeIndex < 8; opmNodeIndex++ ) + { + auto riCornerIndex = cellMappingECLRi[opmNodeIndex]; + size_t riNodeIndex = riNodeStartIndex + riCornerIndex; + + auto& riNode = riNodes[riNodeIndex]; + riNode.x() = opmX[opmNodeIndex] + xCenterCoordOpm; + riNode.y() = opmY[opmNodeIndex] + yCenterCoordOpm; + riNode.z() = -opmZ[opmNodeIndex]; + + cell.cornerIndices()[riCornerIndex] = riNodeIndex; + + // First grid dimension is radius, check if cell are at the outer-most slice + if ( isRadialGrid && !hostCellGlobalIndices.empty() && ( gridDimension[0] - 1 == opmIJK[0] ) ) + { + auto hostCellIndex = hostCellGlobalIndices[opmCellIndex]; + + RifOpmRadialGridTools::lockToHostPillars( riNode, + opmMainGrid, + opmGrid, + opmIJK, + hostCellIndex, + opmCellIndex, + opmNodeIndex, + xCenterCoordOpm, + yCenterCoordOpm ); + } + } + + cell.setInvalid( cell.isLongPyramidCell() ); + } + + // subgrid pointers + RigLocalGrid* realLocalGrid = dynamic_cast( localGrid ); + RigGridBase* parentGrid = realLocalGrid != nullptr ? realLocalGrid->parentGrid() : nullptr; + + if ( parentGrid != nullptr ) + { + for ( auto localCellInGlobalIdx : hostCellGlobalIndices ) + { + parentGrid->cell( localCellInGlobalIdx ).setSubGrid( realLocalGrid ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -126,33 +486,41 @@ bool RifReaderOpmCommon::staticResult( const QString& result, RiaDefines::Porosi { auto resultName = result.toStdString(); - auto resultEntries = m_initFile->getList(); + std::vector combinedFileValues; + + const auto& resultEntries = m_initFile->getList(); for ( const auto& entry : resultEntries ) { const auto& [keyword, kwType, size] = entry; if ( keyword == resultName ) { - if ( kwType == EclIO::eclArrType::REAL ) - { - auto fileValues = m_initFile->getInitData( resultName ); - values->insert( values->end(), fileValues.begin(), fileValues.end() ); - } - else if ( kwType == EclIO::eclArrType::DOUB ) - { - auto fileValues = m_initFile->getInitData( resultName ); - values->insert( values->end(), fileValues.begin(), fileValues.end() ); - } - else if ( kwType == EclIO::eclArrType::INTE ) + for ( auto& gridName : m_gridNames ) { - auto fileValues = m_initFile->getInitData( resultName ); - values->insert( values->end(), fileValues.begin(), fileValues.end() ); + if ( kwType == EclIO::eclArrType::REAL ) + { + const auto& fileValues = m_initFile->getInitData( resultName, gridName ); + combinedFileValues.insert( combinedFileValues.end(), fileValues.begin(), fileValues.end() ); + } + else if ( kwType == EclIO::eclArrType::DOUB ) + { + const auto& fileValues = m_initFile->getInitData( resultName, gridName ); + combinedFileValues.insert( combinedFileValues.end(), fileValues.begin(), fileValues.end() ); + } + else if ( kwType == EclIO::eclArrType::INTE ) + { + const auto& fileValues = m_initFile->getInitData( resultName, gridName ); + combinedFileValues.insert( combinedFileValues.end(), fileValues.begin(), fileValues.end() ); + } } + break; } } // Always clear data after reading to avoid memory use m_initFile->clearData(); + RifEclipseOutputFileTools::extractResultValuesBasedOnPorosityModel( m_eclipseCaseData, matrixOrFracture, values, combinedFileValues ); + return true; } catch ( std::exception& e ) @@ -178,8 +546,12 @@ bool RifReaderOpmCommon::dynamicResult( const QString& result, { auto resultName = result.toStdString(); - auto stepNumbers = m_restartFile->listOfReportStepNumbers(); - auto stepNumber = stepNumbers[stepIndex]; + size_t indexOnFile = timeStepIndexOnFile( stepIndex ); + + const auto& stepNumbers = m_restartFile->listOfReportStepNumbers(); + auto stepNumber = stepNumbers[indexOnFile]; + + std::vector combinedFileValues; auto resultEntries = m_restartFile->getList(); for ( const auto& entry : resultEntries ) @@ -187,27 +559,54 @@ bool RifReaderOpmCommon::dynamicResult( const QString& result, const auto& [keyword, kwType, size] = entry; if ( keyword == resultName ) { - if ( kwType == EclIO::eclArrType::DOUB ) - { - auto fileValues = m_restartFile->getRestartData( resultName, stepNumber ); - values->insert( values->end(), fileValues.begin(), fileValues.end() ); - } - if ( kwType == EclIO::eclArrType::REAL ) - { - auto fileValues = m_restartFile->getRestartData( resultName, stepNumber ); - values->insert( values->end(), fileValues.begin(), fileValues.end() ); - } - else if ( kwType == EclIO::eclArrType::INTE ) + for ( auto& gridName : m_gridNames ) { - auto fileValues = m_restartFile->getRestartData( resultName, stepNumber ); - values->insert( values->end(), fileValues.begin(), fileValues.end() ); + if ( gridName == "global" ) // main grid, need to use separate method due to inner workings in opm_common + { + if ( kwType == EclIO::eclArrType::DOUB ) + { + const auto& fileValues = m_restartFile->getRestartData( resultName, stepNumber ); + combinedFileValues.insert( combinedFileValues.end(), fileValues.begin(), fileValues.end() ); + } + if ( kwType == EclIO::eclArrType::REAL ) + { + const auto& fileValues = m_restartFile->getRestartData( resultName, stepNumber ); + combinedFileValues.insert( combinedFileValues.end(), fileValues.begin(), fileValues.end() ); + } + else if ( kwType == EclIO::eclArrType::INTE ) + { + const auto& fileValues = m_restartFile->getRestartData( resultName, stepNumber ); + combinedFileValues.insert( combinedFileValues.end(), fileValues.begin(), fileValues.end() ); + } + } + else + { + if ( kwType == EclIO::eclArrType::DOUB ) + { + const auto& fileValues = m_restartFile->getRestartData( resultName, stepNumber, gridName ); + combinedFileValues.insert( combinedFileValues.end(), fileValues.begin(), fileValues.end() ); + } + if ( kwType == EclIO::eclArrType::REAL ) + { + const auto& fileValues = m_restartFile->getRestartData( resultName, stepNumber, gridName ); + combinedFileValues.insert( combinedFileValues.end(), fileValues.begin(), fileValues.end() ); + } + else if ( kwType == EclIO::eclArrType::INTE ) + { + const auto& fileValues = m_restartFile->getRestartData( resultName, stepNumber, gridName ); + combinedFileValues.insert( combinedFileValues.end(), fileValues.begin(), fileValues.end() ); + } + } } + break; } } // Always clear data after reading to avoid memory use m_restartFile->clearData(); + RifEclipseOutputFileTools::extractResultValuesBasedOnPorosityModel( m_eclipseCaseData, matrixOrFracture, values, combinedFileValues ); + return true; } catch ( std::exception& e ) @@ -222,36 +621,36 @@ bool RifReaderOpmCommon::dynamicResult( const QString& result, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector createKeywordInfo( std::vector entries ) +static std::vector createKeywordInfo( std::vector entries ) { - std::vector fileKeywordInfo; + RifEclipseReportKeywords keywordsReport; for ( const auto& entry : entries ) { const auto& [keyword, kwType, size] = entry; - RifKeywordValueCount::KeywordDataType dataType = RifKeywordValueCount::KeywordDataType::UNKNOWN; + RifEclipseKeywordValueCount::KeywordDataType dataType = RifEclipseKeywordValueCount::KeywordDataType::UNKNOWN; if ( kwType == EclIO::eclArrType::INTE ) - dataType = RifKeywordValueCount::KeywordDataType::INTEGER; + dataType = RifEclipseKeywordValueCount::KeywordDataType::INTEGER; else if ( kwType == EclIO::eclArrType::REAL ) - dataType = RifKeywordValueCount::KeywordDataType::FLOAT; + dataType = RifEclipseKeywordValueCount::KeywordDataType::FLOAT; else if ( kwType == EclIO::eclArrType::DOUB ) - dataType = RifKeywordValueCount::KeywordDataType::DOUBLE; + dataType = RifEclipseKeywordValueCount::KeywordDataType::DOUBLE; - if ( dataType != RifKeywordValueCount::KeywordDataType::UNKNOWN ) + if ( dataType != RifEclipseKeywordValueCount::KeywordDataType::UNKNOWN ) { - fileKeywordInfo.emplace_back( RifKeywordValueCount( keyword, static_cast( size ), dataType ) ); + keywordsReport.appendKeywordCount( keyword, static_cast( size ), dataType ); } } - return fileKeywordInfo; + return keywordsReport.keywordValueCounts(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifReaderOpmCommon::buildMetaData( RigEclipseCaseData* eclipseCase ) +void RifReaderOpmCommon::locateInitAndRestartFiles( QString gridFileName ) { auto getFileNameForType = []( RiaEclipseFileNameTools::EclipseFileType fileType, const QString& candidate ) -> std::string { @@ -260,233 +659,233 @@ void RifReaderOpmCommon::buildMetaData( RigEclipseCaseData* eclipseCase ) return {}; }; - std::string initFileName; - std::string restartFileName; - - QStringList fileSet; - RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName( QString::fromStdString( m_gridFileName ), &fileSet ); - for ( const auto& s : fileSet ) - { - auto initCandidate = getFileNameForType( RiaEclipseFileNameTools::EclipseFileType::ECLIPSE_INIT, s ); - auto restartCandidate = getFileNameForType( RiaEclipseFileNameTools::EclipseFileType::ECLIPSE_UNRST, s ); - - if ( !initCandidate.empty() ) initFileName = initCandidate; - if ( !restartCandidate.empty() ) restartFileName = restartCandidate; - } - - RigEclipseTimeStepInfo firstTimeStepInfo{ QDateTime(), 0, 0.0 }; - if ( !restartFileName.empty() ) + if ( m_initFileName.empty() || m_restartFileName.empty() ) { - m_restartFile = std::make_shared( restartFileName ); - - std::vector entries; - for ( auto reportNumber : m_restartFile->listOfReportStepNumbers() ) + QStringList fileSet; + RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName( gridFileName, &fileSet ); + for ( const auto& s : fileSet ) { - auto reportEntries = m_restartFile->listOfRstArrays( reportNumber ); - entries.insert( entries.end(), reportEntries.begin(), reportEntries.end() ); - } + auto initCandidate = getFileNameForType( RiaEclipseFileNameTools::EclipseFileType::ECLIPSE_INIT, s ); + auto restartCandidate = getFileNameForType( RiaEclipseFileNameTools::EclipseFileType::ECLIPSE_UNRST, s ); - auto timeStepsFromFile = readTimeSteps( m_restartFile ); - - std::vector timeStepInfos; - std::vector dateTimes; - for ( const auto& timeStep : timeStepsFromFile ) - { - QDate date( timeStep.year, timeStep.month, timeStep.day ); - QDateTime dateTime = RiaQDateTimeTools::createDateTime( date ); - dateTimes.push_back( dateTime ); - timeStepInfos.emplace_back( dateTime, timeStep.sequenceNumber, timeStep.simulationTimeFromStart ); + if ( !initCandidate.empty() ) m_initFileName = initCandidate; + if ( !restartCandidate.empty() ) m_restartFileName = restartCandidate; } - m_timeSteps = dateTimes; + } +} - auto last = std::unique( entries.begin(), entries.end() ); - entries.erase( last, entries.end() ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmCommon::setupInitAndRestartAccess() +{ + if ( ( m_initFile == nullptr ) && !m_initFileName.empty() ) + { + m_initFile = std::make_unique( m_initFileName ); + } - std::vector keywordInfo = createKeywordInfo( entries ); + if ( ( m_restartFile == nullptr ) && !m_restartFileName.empty() ) + { + m_restartFile = std::make_unique( m_restartFileName ); + } +} - RifEclipseOutputFileTools::createResultEntries( keywordInfo, timeStepInfos, RiaDefines::ResultCatType::DYNAMIC_NATIVE, eclipseCase ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifReaderOpmCommon::createFilteredTimeStepInfos() +{ + std::vector timeStepInfos; - firstTimeStepInfo = timeStepInfos.front(); + if ( m_restartFile == nullptr ) return timeStepInfos; - readWellCells( m_restartFile, eclipseCase, m_timeSteps ); - } + auto timeStepsOnFile = readTimeSteps(); - if ( !initFileName.empty() ) + for ( size_t i = 0; i < timeStepsOnFile.size(); i++ ) { - m_initFile = std::make_unique( initFileName ); - - auto entries = m_initFile->list_arrays(); - std::vector keywordInfo = createKeywordInfo( entries ); + if ( isTimeStepIncludedByFilter( i ) ) + { + QDate date( timeStepsOnFile[i].year, timeStepsOnFile[i].month, timeStepsOnFile[i].day ); + auto datetime = RiaQDateTimeTools::createDateTime( date, Qt::TimeSpec::UTC ); - RifEclipseOutputFileTools::createResultEntries( keywordInfo, { firstTimeStepInfo }, RiaDefines::ResultCatType::STATIC_NATIVE, eclipseCase ); + timeStepInfos.push_back( + RigEclipseTimeStepInfo( datetime, timeStepsOnFile[i].sequenceNumber, timeStepsOnFile[i].simulationTimeFromStart ) ); + } } + + return timeStepInfos; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifReaderOpmCommon::readWellCells( std::shared_ptr restartFile, - RigEclipseCaseData* eclipseCase, - const std::vector& timeSteps ) +void RifReaderOpmCommon::buildMetaData( RigEclipseCaseData* eclipseCaseData, caf::ProgressInfo& progress ) { - // It is required to create a deck as the input parameter to runspec. The default() initialization of the runspec keyword does not - // initialize the object as expected. + setupInitAndRestartAccess(); - Deck deck; - Runspec runspec( deck ); - Parser parser( false ); + std::vector timeSteps; + std::vector filteredTimeStepInfos; - cvf::Collection wells; - - try + RigEclipseTimeStepInfo firstTimeStepInfo{ QDateTime(), 0, 0.0 }; + if ( m_restartFile != nullptr ) { - if ( restartFile->numberOfReportSteps() != timeSteps.size() ) + std::vector entries; + for ( auto reportNumber : m_restartFile->listOfReportStepNumbers() ) { - RiaLogging::error( "Number of time steps is not matching number of report steps" ); - return; - } + auto stepEntries = m_restartFile->listOfRstArrays( reportNumber ); - auto getWellStateAndNames = [&]() -> std::pair, std::set> - { - std::vector states; - std::set wellNames; + std::set> keyNames; - for ( auto seqNumber : restartFile->listOfReportStepNumbers() ) + for ( auto& [keyName, resType, nValues] : stepEntries ) { - auto fileView = std::make_shared( restartFile, seqNumber ); + keyNames.insert( { keyName, resType } ); + } - auto state = RestartIO::RstState::load( fileView, runspec, parser ); - states.emplace_back( state ); + for ( auto& [keyName, resType] : keyNames ) + { + auto dataSize = m_restartFile->dataSize( keyName, reportNumber ); - for ( const auto& w : state.wells ) - { - wellNames.insert( w.name ); - } + entries.emplace_back( keyName, resType, dataSize ); } + } - return std::make_pair( states, wellNames ); - }; + auto last = std::unique( entries.begin(), entries.end() ); + entries.erase( last, entries.end() ); - auto [states, wellNames] = getWellStateAndNames(); + std::vector keywordInfo = createKeywordInfo( entries ); - for ( const auto& wellName : wellNames ) - { - cvf::ref simWellData = new RigSimWellData; - simWellData->setWellName( QString::fromStdString( wellName ) ); - simWellData->m_wellCellsTimeSteps.resize( timeSteps.size() ); + filteredTimeStepInfos = createFilteredTimeStepInfos(); - for ( size_t timeIdx = 0; timeIdx < timeSteps.size(); ++timeIdx ) - { - auto state = states[timeIdx]; + RifEclipseOutputFileTools::createResultEntries( keywordInfo, + filteredTimeStepInfos, + RiaDefines::ResultCatType::DYNAMIC_NATIVE, + eclipseCaseData, + m_restartFile->numberOfReportSteps() ); - auto it = std::find_if( state.wells.begin(), - state.wells.end(), - [&wellName]( const RestartIO::RstWell& well ) { return well.name == wellName; } ); - if ( it == state.wells.end() ) continue; + if ( filteredTimeStepInfos.size() > 0 ) firstTimeStepInfo = filteredTimeStepInfos.front(); + } - RestartIO::RstWell rstWell = *it; + if ( m_initFile != nullptr ) + { + // entries from main grid + auto entries = m_initFile->list_arrays(); + // add lgr entries, too + auto nGrids = m_gridNames.size(); + for ( size_t i = 1; i < nGrids; i++ ) + { + auto gridEntries = m_initFile->list_arrays( m_gridNames[i] ); + entries.insert( entries.end(), gridEntries.begin(), gridEntries.end() ); + } - RigWellResultFrame& wellResFrame = simWellData->m_wellCellsTimeSteps[timeIdx]; - wellResFrame.setTimestamp( timeSteps[timeIdx] ); + std::vector keywordInfo = createKeywordInfo( entries ); - auto wellType = [&rstWell]() -> RiaDefines::WellProductionType - { - if ( rstWell.wtype.producer() ) return RiaDefines::WellProductionType::PRODUCER; + RifEclipseOutputFileTools::createResultEntries( keywordInfo, + { firstTimeStepInfo }, + RiaDefines::ResultCatType::STATIC_NATIVE, + eclipseCaseData, + 1 ); + } - if ( rstWell.wtype.injector_type() == InjectorType::WATER ) return RiaDefines::WellProductionType::WATER_INJECTOR; - if ( rstWell.wtype.injector_type() == InjectorType::GAS ) return RiaDefines::WellProductionType::GAS_INJECTOR; - if ( rstWell.wtype.injector_type() == InjectorType::OIL ) return RiaDefines::WellProductionType::OIL_INJECTOR; + // Unit system + { + // Default units type is METRIC, look in restart file, then init file and then grid file until we find something + RiaDefines::EclipseUnitSystem unitsType = RiaDefines::EclipseUnitSystem::UNITS_METRIC; + int unitsTypeValue = -1; - return RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE; - }; + if ( m_restartFile != nullptr ) + { + if ( m_restartFile->hasArray( "INTEHEAD", 0 ) ) + { + const auto& intHeader = m_restartFile->getRestartData( "INTEHEAD", 0 ); - wellResFrame.setProductionType( wellType() ); + if ( intHeader.size() > 2 ) unitsTypeValue = intHeader[2]; + } + } - wellResFrame.setIsOpen( rstWell.well_status == RestartIO::Helpers::VectorItems::IWell::Value::Status::Open ); + if ( unitsTypeValue < 0 ) + { + if ( m_initFile != nullptr ) + { + const auto& intHeader = m_initFile->getInitData( "INTEHEAD" ); + if ( intHeader.size() > 2 ) unitsTypeValue = intHeader[2]; + } + } - // Well head - RigWellResultPoint wellHead; - wellHead.setGridIndex( 0 ); - auto cellIndex = eclipseCase->mainGrid()->cellIndexFromIJK( rstWell.ij[0], rstWell.ij[1], 0 ); - wellHead.setGridCellIndex( cellIndex ); + if ( unitsTypeValue < 0 ) + { + unitsTypeValue = m_gridUnit; + } - wellResFrame.setWellHead( wellHead ); + if ( unitsTypeValue == 2 ) + { + unitsType = RiaDefines::EclipseUnitSystem::UNITS_FIELD; + } + else if ( unitsTypeValue == 3 ) + { + unitsType = RiaDefines::EclipseUnitSystem::UNITS_LAB; + } + m_eclipseCaseData->setUnitsType( unitsType ); + } - // Grid cells - if ( !rstWell.connections.empty() ) - { - RigWellResultBranch wellResultBranch; - wellResultBranch.setErtBranchId( 0 ); // Normal wells have only one branch + auto task = progress.task( "Handling well information", 10 ); + if ( loadWellDataEnabled() && !m_restartFileName.empty() ) + { + auto restartAccess = std::make_unique(); + restartAccess->setRestartFiles( QStringList( QString::fromStdString( m_restartFileName ) ) ); + restartAccess->open(); - std::vector branchResultPoints = wellResultBranch.branchResultPoints(); - const size_t existingCellCount = branchResultPoints.size(); - branchResultPoints.reserve( existingCellCount + rstWell.connections.size() ); + std::vector filteredTimeSteps; + for ( auto& a : filteredTimeStepInfos ) + { + filteredTimeSteps.push_back( a.m_date ); + } - for ( const auto& conn : rstWell.connections ) - { - RigWellResultPoint wellResPoint; - wellResPoint.setGridIndex( 0 ); - auto cellIndex = eclipseCase->mainGrid()->cellIndexFromIJK( conn.ijk[0], conn.ijk[1], conn.ijk[2] ); - wellResPoint.setGridCellIndex( cellIndex ); - - wellResPoint.setIsOpen( conn.state == Connection::State::OPEN ); - - // All units for a Connection is given in SI units - // Convert back to the original units - // See RestartIO::RstConnection::RstConnection - auto us = state.unit_system; - wellResPoint.setFlowData( us.from_si( UnitSystem::measure::rate, conn.resv_rate ), - us.from_si( UnitSystem::measure::liquid_surface_rate, conn.oil_rate ), - us.from_si( UnitSystem::measure::gas_surface_rate, conn.gas_rate ), - us.from_si( UnitSystem::measure::liquid_surface_rate, conn.water_rate ) ); - wellResPoint.setConnectionFactor( us.from_si( UnitSystem::measure::transmissibility, conn.cf ) ); - - branchResultPoints.push_back( wellResPoint ); - } - wellResultBranch.setBranchResultPoints( branchResultPoints ); - wellResFrame.addWellResultBranch( wellResultBranch ); - } - } + RifReaderEclipseWell::readWellCells( restartAccess.get(), + eclipseCaseData, + filteredTimeSteps, + m_gridNames, + isImportOfCompleteMswDataEnabled() ); - simWellData->computeMappingFromResultTimeIndicesToWellTimeIndices( timeSteps ); - wells.push_back( simWellData.p() ); - } + restartAccess->close(); } - catch ( std::exception& e ) + else { - std::cout << "Exception: " << e.what() << std::endl; + RiaLogging::info( "Skipping import of simulation well data" ); } - - eclipseCase->setSimWellData( wells ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifReaderOpmCommon::readTimeSteps( std::shared_ptr restartFile ) +std::vector RifReaderOpmCommon::readTimeSteps() { + setupInitAndRestartAccess(); + std::vector reportTimeData; + + if ( m_restartFile == nullptr ) return reportTimeData; + try { namespace VI = Opm::RestartIO::Helpers::VectorItems; - for ( auto seqNum : restartFile->listOfReportStepNumbers() ) + for ( auto seqNum : m_restartFile->listOfReportStepNumbers() ) { const std::string inteheadString = "INTEHEAD"; const std::string doubheadString = "DOUBHEAD"; - if ( restartFile->hasArray( inteheadString, seqNum ) ) + if ( m_restartFile->hasArray( inteheadString, seqNum ) ) { - auto intehead = restartFile->getRestartData( inteheadString, seqNum ); - auto year = intehead[VI::intehead::YEAR]; - auto month = intehead[VI::intehead::MONTH]; - auto day = intehead[VI::intehead::DAY]; + const auto& intehead = m_restartFile->getRestartData( inteheadString, seqNum ); + auto year = intehead[VI::intehead::YEAR]; + auto month = intehead[VI::intehead::MONTH]; + auto day = intehead[VI::intehead::DAY]; double daySinceSimStart = 0.0; - if ( restartFile->hasArray( doubheadString, seqNum ) ) + if ( m_restartFile->hasArray( doubheadString, seqNum ) ) { - auto doubhead = restartFile->getRestartData( doubheadString, seqNum ); + const auto& doubhead = m_restartFile->getRestartData( doubheadString, seqNum ); if ( !doubhead.empty() ) { // Read out the simulation time from start from DOUBHEAD. There is no enum defined to access this value. @@ -508,3 +907,27 @@ std::vector RifReaderOpmCommon::readTimeSteps( return reportTimeData; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifReaderOpmCommon::timeStepsOnFile( QString gridFileName ) +{ + locateInitAndRestartFiles( gridFileName ); + setupInitAndRestartAccess(); + + if ( m_restartFile == nullptr ) return {}; + + auto timeStepsFromFile = readTimeSteps(); + + std::vector dateTimes; + + for ( const auto& timeStep : timeStepsFromFile ) + { + QDate date( timeStep.year, timeStep.month, timeStep.day ); + QDateTime dateTime = RiaQDateTimeTools::createDateTime( date, Qt::UTC ); + dateTimes.push_back( dateTime ); + } + + return dateTimes; +} diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h index 457d69d12f..003b511ca2 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h @@ -21,13 +21,26 @@ #include "RifReaderInterface.h" #include +#include +#include namespace Opm::EclIO { class EInit; class ERst; +class EGrid; } // namespace Opm::EclIO +class RigMainGrid; +class RigGridBase; +class RigEclipseCaseData; +class RigEclipseTimeStepInfo; + +namespace caf +{ +class ProgressInfo; +} + //================================================================================================== // // @@ -38,13 +51,31 @@ class RifReaderOpmCommon : public RifReaderInterface RifReaderOpmCommon(); ~RifReaderOpmCommon() override; - bool open( const QString& fileName, RigEclipseCaseData* eclipseCase ) override; + bool open( const QString& fileName, RigEclipseCaseData* caseData ) override; bool staticResult( const QString& result, RiaDefines::PorosityModelType matrixOrFracture, std::vector* values ) override; bool dynamicResult( const QString& result, RiaDefines::PorosityModelType matrixOrFracture, size_t stepIndex, std::vector* values ) override; + std::vector timeStepsOnFile( QString gridFileName ); + private: - void buildMetaData( RigEclipseCaseData* eclipseCase ); + void buildMetaData( RigEclipseCaseData* caseData, caf::ProgressInfo& progress ); + bool importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* caseData ); + void transferGeometry( Opm::EclIO::EGrid& opmMainGrid, + Opm::EclIO::EGrid& opmGrid, + RigMainGrid* riMainGrid, + RigGridBase* riGrid, + RigEclipseCaseData* caseData, + size_t matrixActiveStartIndex, + size_t fractureActiveStartIndex ); + + void transferStaticNNCData( Opm::EclIO::EGrid& opmMainGrid, std::vector& lgrGrids, RigMainGrid* mainGrid ); + void transferDynamicNNCData( RigMainGrid* mainGrid ); + + void locateInitAndRestartFiles( QString gridFileName ); + void setupInitAndRestartAccess(); + + std::vector createFilteredTimeStepInfos(); struct TimeDataFile { @@ -55,16 +86,18 @@ class RifReaderOpmCommon : public RifReaderInterface double simulationTimeFromStart; }; - static std::vector readTimeSteps( std::shared_ptr restartFile ); - static void readWellCells( std::shared_ptr restartFile, - RigEclipseCaseData* eclipseCase, - const std::vector& timeSteps ); + std::vector readTimeSteps(); private: std::string m_gridFileName; + std::string m_initFileName; + std::string m_restartFileName; + int m_gridUnit; + + RigEclipseCaseData* m_eclipseCaseData; - std::shared_ptr m_restartFile; - std::shared_ptr m_initFile; + std::unique_ptr m_restartFile; + std::unique_ptr m_initFile; - std::vector m_timeSteps; + std::vector m_gridNames; }; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp index a22bed1f95..859ce29561 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp @@ -819,14 +819,17 @@ QString RimFlowCharacteristicsPlot::curveDataAsText() const auto storageCapacityValues = a->second.m_storageCapFlowCapCurve.first; auto flowCapacityValues = a->second.m_storageCapFlowCapCurve.second; + if ( storageCapacityValues.size() < 2 || flowCapacityValues.size() < 2 ) + { + continue; + } + bool extrapolate = false; std::vector flowCapacitySamplingValues; for ( const auto storageCapacity : storageCapacitySamplingValues ) { - { - double flowCapacity = interpolate( storageCapacityValues, flowCapacityValues, storageCapacity, extrapolate ); - flowCapacitySamplingValues.push_back( flowCapacity ); - } + double flowCapacity = interpolate( storageCapacityValues, flowCapacityValues, storageCapacity, extrapolate ); + flowCapacitySamplingValues.push_back( flowCapacity ); } auto dimensionLessTimeValues = a->second.m_dimensionlessTimeSweepEfficiencyCurve.first; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp index c9da240294..f5d3cf90f9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -30,6 +30,7 @@ #include "RicfCommandObject.h" #include "RifEclipseOutputFileTools.h" +#include "RifEclipseRestartDataAccess.h" #include "RifInputPropertyLoader.h" #include "RifReaderEclipseOutput.h" #include "RifReaderEclipseRft.h" @@ -109,6 +110,28 @@ bool RimEclipseResultCase::openEclipseGridFile() return importGridAndResultMetaData( false ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseResultCase::showTimeStepFilterGUI() +{ + caf::PdmUiPropertyViewDialog propertyDialog( nullptr, m_timeStepFilter, "Time Step Filter", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel ); + propertyDialog.resize( QSize( 400, 400 ) ); + + // Push arrow cursor onto the cursor stack so it takes over from the wait cursor. + QApplication::setOverrideCursor( QCursor( Qt::ArrowCursor ) ); + // Show GUI to select time steps + int dialogReturnValue = propertyDialog.exec(); + // Pop arrow cursor off the cursor stack so that the previous (wait) cursor takes over. + QApplication::restoreOverrideCursor(); + + if ( dialogReturnValue != QDialog::Accepted ) return false; + + m_timeStepFilter->updateFilteredTimeStepsFromUi(); + + return true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -137,56 +160,48 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter return false; } - auto defaultReader = RiaPreferences::current()->gridModelReader(); + auto readerType = RiaPreferences::current()->gridModelReader(); + + // opmcommon reader only reads EGRID + if ( !gridFileName().toLower().endsWith( ".egrid" ) ) + { + readerType = RiaDefines::GridModelReader::RESDATA; + } - if ( defaultReader == RiaDefines::GridModelReader::RESDATA ) + if ( readerType == RiaDefines::GridModelReader::RESDATA ) { auto readerEclipseOutput = new RifReaderEclipseOutput(); cvf::ref restartDataAccess = RifEclipseOutputFileTools::createDynamicResultAccess( gridFileName() ); - { - std::vector timeSteps; - std::vector daysSinceSimulationStart; + std::vector timeSteps; + std::vector daysSinceSimulationStart; - if ( restartDataAccess.notNull() ) - { - restartDataAccess->timeSteps( &timeSteps, &daysSinceSimulationStart ); - } - m_timeStepFilter->setTimeStepsFromFile( timeSteps ); - } - - if ( showTimeStepFilter ) + if ( restartDataAccess.notNull() ) { - caf::PdmUiPropertyViewDialog propertyDialog( nullptr, - m_timeStepFilter, - "Time Step Filter", - "", - QDialogButtonBox::Ok | QDialogButtonBox::Cancel ); - propertyDialog.resize( QSize( 400, 400 ) ); - - // Push arrow cursor onto the cursor stack so it takes over from the wait cursor. - QApplication::setOverrideCursor( QCursor( Qt::ArrowCursor ) ); - // Show GUI to select time steps - int dialogReturnValue = propertyDialog.exec(); - // Pop arrow cursor off the cursor stack so that the previous (wait) cursor takes over. - QApplication::restoreOverrideCursor(); - - if ( dialogReturnValue != QDialog::Accepted ) - { - return false; - } - m_timeStepFilter->updateFilteredTimeStepsFromUi(); + restartDataAccess->timeSteps( &timeSteps, &daysSinceSimulationStart ); } + m_timeStepFilter->setTimeStepsFromFile( timeSteps ); readerEclipseOutput->setFileDataAccess( restartDataAccess.p() ); - readerEclipseOutput->setTimeStepFilter( m_timeStepFilter->filteredTimeSteps() ); readerInterface = readerEclipseOutput; } else { - readerInterface = new RifReaderOpmCommon; + auto readerOpmCommon = new RifReaderOpmCommon(); + + std::vector timeSteps = readerOpmCommon->timeStepsOnFile( gridFileName() ); + m_timeStepFilter->setTimeStepsFromFile( timeSteps ); + + readerInterface = readerOpmCommon; + } + + if ( showTimeStepFilter ) + { + if ( !showTimeStepFilterGUI() ) return false; + + readerInterface->setTimeStepFilter( m_timeStepFilter->filteredTimeSteps() ); } readerInterface->setFilenamesWithFaults( filesContainingFaults() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h index a39edec3f2..ab0473a85d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h @@ -84,6 +84,7 @@ class RimEclipseResultCase : public RimEclipseCase private: void loadAndUpdateSourSimData(); void ensureRftDataIsImported(); + bool showTimeStepFilterGUI(); cvf::ref createMockModel( QString modelName ); void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp b/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp index 81486314e9..a246f0f78e 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp @@ -625,6 +625,11 @@ RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame return result; } + if ( m_opmFlowDiagStaticData.isNull() ) + { + return result; + } + std::vector poreVolume; for ( size_t cellIndex : selected_cell_indices ) { diff --git a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp index 71fab84de7..62a351de75 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp @@ -312,6 +312,21 @@ const RigGridBase* RigMainGrid::gridByIndex( size_t localGridIndex ) const return m_localGrids[localGridIndex - 1].p(); } +//-------------------------------------------------------------------------------------------------- +/// Returns the grid with the given name. Main Grid itself could be retreived by using name "" +//-------------------------------------------------------------------------------------------------- +RigGridBase* RigMainGrid::gridByName( const std::string& name ) +{ + if ( name.empty() ) return this; + + for ( auto& grid : m_localGrids ) + { + if ( grid->gridName() == name ) return grid.p(); + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h index 536a2a2d12..d0a851dad4 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h @@ -63,6 +63,7 @@ class RigMainGrid : public RigGridBase RigGridBase* gridByIndex( size_t localGridIndex ); const RigGridBase* gridByIndex( size_t localGridIndex ) const; RigGridBase* gridById( int localGridId ); + RigGridBase* gridByName( const std::string& name ); size_t totalTemporaryGridCellCount() const; diff --git a/ApplicationLibCode/ReservoirDataModel/RigSimWellData.cpp b/ApplicationLibCode/ReservoirDataModel/RigSimWellData.cpp index e9e02ec6a0..8b69a17ce9 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigSimWellData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigSimWellData.cpp @@ -65,8 +65,8 @@ void RigSimWellData::computeMappingFromResultTimeIndicesToWellTimeIndices( const wellTimeStepIndex++; } - if ( wellTimeStepIndex < m_wellCellsTimeSteps.size() && - m_wellCellsTimeSteps[wellTimeStepIndex].timestamp() == simulationTimeSteps[resultTimeStepIndex] ) + if ( ( wellTimeStepIndex < m_wellCellsTimeSteps.size() ) && + ( m_wellCellsTimeSteps[wellTimeStepIndex].timestamp() == simulationTimeSteps[resultTimeStepIndex] ) ) { m_resultTimeStepIndexToWellTimeStepIndex[resultTimeStepIndex] = wellTimeStepIndex; } diff --git a/ThirdParty/Ert/lib/ecl/well_info.cpp b/ThirdParty/Ert/lib/ecl/well_info.cpp index 94f6692dd7..01a412c168 100644 --- a/ThirdParty/Ert/lib/ecl/well_info.cpp +++ b/ThirdParty/Ert/lib/ecl/well_info.cpp @@ -182,9 +182,9 @@ struct well_info_struct { - std::map wells; /* std::map of well_ts_type instances; indexed by well name. */ - std::vector well_names; /* A list of all the well names. */ - const ecl_grid_type * grid; + std::map wells; /* std::map of well_ts_type instances; indexed by well name. */ + std::vector well_names; /* A list of all the well names. */ + std::vector grid_names; /* A list of all grid names, main grid is at index 0, lgrs at 1 and above, if any */ }; @@ -193,39 +193,39 @@ struct well_info_struct { it to resolve lgr names. */ -well_info_type * well_info_alloc( const ecl_grid_type * grid) { - well_info_type * well_info = new well_info_type(); - well_info->grid = grid; - return well_info; +well_info_type* well_info_alloc(const std::vector grid_names) { + well_info_type* well_info = new well_info_type(); + well_info->grid_names = grid_names; + return well_info; } -bool well_info_has_well( well_info_type * well_info , const char * well_name ) { - const auto it = well_info->wells.find(well_name); - if (it == well_info->wells.end()) - return false; - return true; +bool well_info_has_well(well_info_type* well_info, const char* well_name) { + const auto it = well_info->wells.find(well_name); + if (it == well_info->wells.end()) + return false; + return true; } -well_ts_type * well_info_get_ts( const well_info_type * well_info , const char *well_name) { - return well_info->wells.at( well_name ); +well_ts_type* well_info_get_ts(const well_info_type* well_info, const char* well_name) { + return well_info->wells.at(well_name); } -static void well_info_add_new_ts( well_info_type * well_info , const char * well_name) { - well_ts_type * well_ts = well_ts_alloc( well_name ) ; - well_info->wells[well_name] = well_ts; - well_info->well_names.push_back( well_name ); +static void well_info_add_new_ts(well_info_type* well_info, const char* well_name) { + well_ts_type* well_ts = well_ts_alloc(well_name); + well_info->wells[well_name] = well_ts; + well_info->well_names.push_back(well_name); } -static void well_info_add_state( well_info_type * well_info , well_state_type * well_state) { - const char * well_name = well_state_get_name( well_state ); - if (!well_info_has_well( well_info , well_name)) - well_info_add_new_ts( well_info , well_name ); +static void well_info_add_state(well_info_type* well_info, well_state_type* well_state) { + const char* well_name = well_state_get_name(well_state); + if (!well_info_has_well(well_info, well_name)) + well_info_add_new_ts(well_info, well_name); - { - well_ts_type * well_ts = well_info_get_ts( well_info , well_name ); - well_ts_add_well( well_ts , well_state ); - } + { + well_ts_type* well_ts = well_info_get_ts(well_info, well_name); + well_ts_add_well(well_ts, well_state); + } } @@ -278,23 +278,23 @@ static void well_info_add_state( well_info_type * well_info , well_state_type * */ -void well_info_add_wells2( well_info_type * well_info , ecl_file_view_type * rst_view , int report_nr, bool load_segment_information) { - bool close_stream = ecl_file_view_drop_flag( rst_view , ECL_FILE_CLOSE_STREAM ); - ecl_rsthead_type * global_header = ecl_rsthead_alloc( rst_view , report_nr ); - int well_nr; - for (well_nr = 0; well_nr < global_header->nwells; well_nr++) { - well_state_type * well_state = well_state_alloc_from_file2( rst_view , well_info->grid , report_nr , well_nr , load_segment_information ); - if (well_state != NULL) - well_info_add_state( well_info , well_state ); - } - ecl_rsthead_free( global_header ); - if (close_stream) - ecl_file_view_add_flag(rst_view, ECL_FILE_CLOSE_STREAM); +void well_info_add_wells2(well_info_type* well_info, ecl_file_view_type* rst_view, int report_nr, bool load_segment_information) { + bool close_stream = ecl_file_view_drop_flag(rst_view, ECL_FILE_CLOSE_STREAM); + ecl_rsthead_type* global_header = ecl_rsthead_alloc(rst_view, report_nr); + int well_nr; + for (well_nr = 0; well_nr < global_header->nwells; well_nr++) { + well_state_type* well_state = well_state_alloc_from_file2(rst_view, well_info->grid_names, report_nr, well_nr, load_segment_information); + if (well_state != NULL) + well_info_add_state(well_info, well_state); + } + ecl_rsthead_free(global_header); + if (close_stream) + ecl_file_view_add_flag(rst_view, ECL_FILE_CLOSE_STREAM); } -void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file , int report_nr, bool load_segment_information) { - well_info_add_wells2( well_info , ecl_file_get_active_view( rst_file ) , report_nr , load_segment_information ); +void well_info_add_wells(well_info_type* well_info, ecl_file_type* rst_file, int report_nr, bool load_segment_information) { + well_info_add_wells2(well_info, ecl_file_get_active_view(rst_file), report_nr, load_segment_information); } /** @@ -303,25 +303,25 @@ void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file not have the SEQNUM keyword. */ -void well_info_add_UNRST_wells2( well_info_type * well_info , ecl_file_view_type * rst_view, bool load_segment_information) { - int num_blocks = ecl_file_view_get_num_named_kw( rst_view , SEQNUM_KW ); - int block_nr; - for (block_nr = 0; block_nr < num_blocks; block_nr++) { +void well_info_add_UNRST_wells2(well_info_type* well_info, ecl_file_view_type* rst_view, bool load_segment_information) { + int num_blocks = ecl_file_view_get_num_named_kw(rst_view, SEQNUM_KW); + int block_nr; + for (block_nr = 0; block_nr < num_blocks; block_nr++) { - ecl_file_view_type * step_view = ecl_file_view_add_restart_view(rst_view, block_nr , -1 , -1 , -1 ); - const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( step_view , SEQNUM_KW , 0); - int report_nr = ecl_kw_iget_int( seqnum_kw , 0 ); + ecl_file_view_type* step_view = ecl_file_view_add_restart_view(rst_view, block_nr, -1, -1, -1); + const ecl_kw_type* seqnum_kw = ecl_file_view_iget_named_kw(step_view, SEQNUM_KW, 0); + int report_nr = ecl_kw_iget_int(seqnum_kw, 0); - ecl_file_transaction_type * t = ecl_file_view_start_transaction(rst_view); - well_info_add_wells2( well_info , step_view , report_nr , load_segment_information ); - ecl_file_view_end_transaction(rst_view, t); - } + ecl_file_transaction_type* t = ecl_file_view_start_transaction(rst_view); + well_info_add_wells2(well_info, step_view, report_nr, load_segment_information); + ecl_file_view_end_transaction(rst_view, t); + } } -void well_info_add_UNRST_wells( well_info_type * well_info , ecl_file_type * rst_file, bool load_segment_information) { - well_info_add_UNRST_wells2( well_info , ecl_file_get_global_view( rst_file ) , load_segment_information); +void well_info_add_UNRST_wells(well_info_type* well_info, ecl_file_type* rst_file, bool load_segment_information) { + well_info_add_UNRST_wells2(well_info, ecl_file_get_global_view(rst_file), load_segment_information); } @@ -331,71 +331,72 @@ void well_info_add_UNRST_wells( well_info_type * well_info , ecl_file_type * rst have crash and burn. */ -void well_info_load_rstfile( well_info_type * well_info , const char * filename, bool load_segment_information) { - ecl_file_type * ecl_file = ecl_file_open( filename , 0); - well_info_load_rst_eclfile(well_info, ecl_file, load_segment_information); - ecl_file_close( ecl_file ); +void well_info_load_rstfile(well_info_type* well_info, const char* filename, bool load_segment_information) { + ecl_file_type* ecl_file = ecl_file_open(filename, 0); + well_info_load_rst_eclfile(well_info, ecl_file, load_segment_information); + ecl_file_close(ecl_file); } -void well_info_load_rst_eclfile( well_info_type * well_info , ecl_file_type * ecl_file, bool load_segment_information) { - int report_nr; - const char* filename = ecl_file_get_src_file(ecl_file); - ecl_file_enum file_type = ecl_util_get_file_type( filename , NULL , &report_nr); - if ((file_type == ECL_RESTART_FILE) || (file_type == ECL_UNIFIED_RESTART_FILE)) - { - if (file_type == ECL_RESTART_FILE) - well_info_add_wells( well_info , ecl_file , report_nr , load_segment_information ); - else - well_info_add_UNRST_wells( well_info , ecl_file , load_segment_information ); +void well_info_load_rst_eclfile(well_info_type* well_info, ecl_file_type* ecl_file, bool load_segment_information) { + int report_nr; + const char* filename = ecl_file_get_src_file(ecl_file); + ecl_file_enum file_type = ecl_util_get_file_type(filename, NULL, &report_nr); + if ((file_type == ECL_RESTART_FILE) || (file_type == ECL_UNIFIED_RESTART_FILE)) + { + if (file_type == ECL_RESTART_FILE) + well_info_add_wells(well_info, ecl_file, report_nr, load_segment_information); + else + well_info_add_UNRST_wells(well_info, ecl_file, load_segment_information); - } else - util_abort("%s: invalid file type: %s - must be a restart file\n", __func__ , filename); + } + else + util_abort("%s: invalid file type: %s - must be a restart file\n", __func__, filename); } -void well_info_free( well_info_type * well_info ) { - for (const auto& pair : well_info->wells) - well_ts_free(pair.second); +void well_info_free(well_info_type* well_info) { + for (const auto& pair : well_info->wells) + well_ts_free(pair.second); - delete well_info; + delete well_info; } -int well_info_get_well_size( const well_info_type * well_info , const char * well_name ) { - well_ts_type * well_ts = well_info_get_ts( well_info , well_name ); - return well_ts_get_size( well_ts ); +int well_info_get_well_size(const well_info_type* well_info, const char* well_name) { + well_ts_type* well_ts = well_info_get_ts(well_info, well_name); + return well_ts_get_size(well_ts); } /*****************************************************************/ -well_state_type * well_info_get_state_from_time( const well_info_type * well_info , const char * well_name , time_t sim_time) { - well_ts_type * well_ts = well_info_get_ts( well_info , well_name ); - return well_ts_get_state_from_sim_time( well_ts , sim_time ); +well_state_type* well_info_get_state_from_time(const well_info_type* well_info, const char* well_name, time_t sim_time) { + well_ts_type* well_ts = well_info_get_ts(well_info, well_name); + return well_ts_get_state_from_sim_time(well_ts, sim_time); } -well_state_type * well_info_get_state_from_report( const well_info_type * well_info , const char * well_name , int report_step ) { - well_ts_type * well_ts = well_info_get_ts( well_info , well_name ); - return well_ts_get_state_from_report( well_ts , report_step); +well_state_type* well_info_get_state_from_report(const well_info_type* well_info, const char* well_name, int report_step) { + well_ts_type* well_ts = well_info_get_ts(well_info, well_name); + return well_ts_get_state_from_report(well_ts, report_step); } -well_state_type * well_info_iget_state( const well_info_type * well_info , const char * well_name , int time_index) { - well_ts_type * well_ts = well_info_get_ts( well_info , well_name ); - return well_ts_iget_state( well_ts , time_index); +well_state_type* well_info_iget_state(const well_info_type* well_info, const char* well_name, int time_index) { + well_ts_type* well_ts = well_info_get_ts(well_info, well_name); + return well_ts_iget_state(well_ts, time_index); } -well_state_type * well_info_iiget_state( const well_info_type * well_info , int well_index , int time_index) { - const std::string& well_name = well_info->well_names[well_index]; - return well_info_iget_state( well_info , well_name.c_str() , time_index ); +well_state_type* well_info_iiget_state(const well_info_type* well_info, int well_index, int time_index) { + const std::string& well_name = well_info->well_names[well_index]; + return well_info_iget_state(well_info, well_name.c_str(), time_index); } /*****************************************************************/ -int well_info_get_num_wells( const well_info_type * well_info ) { - return well_info->well_names.size(); +int well_info_get_num_wells(const well_info_type* well_info) { + return well_info->well_names.size(); } -const char * well_info_iget_well_name( const well_info_type * well_info, int well_index) { - const std::string& well_name = well_info->well_names[well_index]; - return well_name.c_str(); +const char* well_info_iget_well_name(const well_info_type* well_info, int well_index) { + const std::string& well_name = well_info->well_names[well_index]; + return well_name.c_str(); } diff --git a/ThirdParty/Ert/lib/ecl/well_state.cpp b/ThirdParty/Ert/lib/ecl/well_state.cpp index 19e033b987..64671264c6 100644 --- a/ThirdParty/Ert/lib/ecl/well_state.cpp +++ b/ThirdParty/Ert/lib/ecl/well_state.cpp @@ -167,158 +167,158 @@ coupledte implementation these objects are modelled as such: #define WELL_STATE_TYPE_ID 613307832 struct well_state_struct { - UTIL_TYPE_ID_DECLARATION; - std::string name; - time_t valid_from_time; - int valid_from_report; - int global_well_nr; - bool open; - well_type_enum type; - bool is_MSW_well; - double oil_rate; - double gas_rate; - double water_rate; - double volume_rate; - ert_ecl_unit_enum unit_system; - - std::map connections; // hash - well_segment_collection_type * segments; - well_branch_collection_type * branches; - - /*****************************************************************/ - - std::vector index_wellhead; // An well_conn_type instance representing the wellhead - indexed by grid_nr. - std::map name_wellhead; // An well_conn_type instance representing the wellhead - indexed by lgr_name. + UTIL_TYPE_ID_DECLARATION; + std::string name; + time_t valid_from_time; + int valid_from_report; + int global_well_nr; + bool open; + well_type_enum type; + bool is_MSW_well; + double oil_rate; + double gas_rate; + double water_rate; + double volume_rate; + ert_ecl_unit_enum unit_system; + + std::map connections; // hash + well_segment_collection_type* segments; + well_branch_collection_type* branches; + + /*****************************************************************/ + + std::vector index_wellhead; // An well_conn_type instance representing the wellhead - indexed by grid_nr. + std::map name_wellhead; // An well_conn_type instance representing the wellhead - indexed by lgr_name. }; -UTIL_IS_INSTANCE_FUNCTION( well_state , WELL_STATE_TYPE_ID) +UTIL_IS_INSTANCE_FUNCTION(well_state, WELL_STATE_TYPE_ID) -well_state_type * well_state_alloc(const char * well_name , int global_well_nr , bool open, well_type_enum type , int report_nr, time_t valid_from) { - well_state_type * well_state = new well_state_type(); - UTIL_TYPE_ID_INIT( well_state , WELL_STATE_TYPE_ID ); +well_state_type* well_state_alloc(const char* well_name, int global_well_nr, bool open, well_type_enum type, int report_nr, time_t valid_from) { + well_state_type* well_state = new well_state_type(); + UTIL_TYPE_ID_INIT(well_state, WELL_STATE_TYPE_ID); - well_state->name = well_name; - well_state->valid_from_time = valid_from; - well_state->valid_from_report = report_nr; - well_state->open = open; - well_state->type = type; - well_state->global_well_nr = global_well_nr; - well_state->segments = well_segment_collection_alloc(); - well_state->branches = well_branch_collection_alloc(); - well_state->is_MSW_well = false; - well_state->oil_rate = 0; - well_state->gas_rate = 0; - well_state->water_rate = 0; - well_state->volume_rate = 0; - well_state->unit_system = ECL_METRIC_UNITS; + well_state->name = well_name; + well_state->valid_from_time = valid_from; + well_state->valid_from_report = report_nr; + well_state->open = open; + well_state->type = type; + well_state->global_well_nr = global_well_nr; + well_state->segments = well_segment_collection_alloc(); + well_state->branches = well_branch_collection_alloc(); + well_state->is_MSW_well = false; + well_state->oil_rate = 0; + well_state->gas_rate = 0; + well_state->water_rate = 0; + well_state->volume_rate = 0; + well_state->unit_system = ECL_METRIC_UNITS; - /* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */ - if ((type == ECL_WELL_ZERO) && open) - util_abort("%s: Invalid type value for open wells.\n",__func__ ); - return well_state; + /* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */ + if ((type == ECL_WELL_ZERO) && open) + util_abort("%s: Invalid type value for open wells.\n", __func__); + return well_state; } -double well_state_get_oil_rate( const well_state_type * well_state ) { - return well_state->oil_rate; +double well_state_get_oil_rate(const well_state_type* well_state) { + return well_state->oil_rate; } -double well_state_get_gas_rate( const well_state_type * well_state ) { - return well_state->gas_rate; +double well_state_get_gas_rate(const well_state_type* well_state) { + return well_state->gas_rate; } -double well_state_get_water_rate( const well_state_type * well_state) { - return well_state->water_rate; +double well_state_get_water_rate(const well_state_type* well_state) { + return well_state->water_rate; } -double well_state_get_volume_rate( const well_state_type * well_state) { - return well_state->volume_rate; +double well_state_get_volume_rate(const well_state_type* well_state) { + return well_state->volume_rate; } -double well_state_get_oil_rate_si( const well_state_type * well_state ) { - double conversion_factor = 1; +double well_state_get_oil_rate_si(const well_state_type* well_state) { + double conversion_factor = 1; - if (well_state->unit_system == ECL_METRIC_UNITS) - conversion_factor = 1.0 / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_FIELD_UNITS) - conversion_factor = ECL_UNITS_VOLUME_BARREL / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_LAB_UNITS) - conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR; + if (well_state->unit_system == ECL_METRIC_UNITS) + conversion_factor = 1.0 / ECL_UNITS_TIME_DAY; + else if (well_state->unit_system == ECL_FIELD_UNITS) + conversion_factor = ECL_UNITS_VOLUME_BARREL / ECL_UNITS_TIME_DAY; + else if (well_state->unit_system == ECL_LAB_UNITS) + conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR; - return well_state->oil_rate * conversion_factor; + return well_state->oil_rate * conversion_factor; } -double well_state_get_gas_rate_si( const well_state_type * well_state ) { - double conversion_factor = 1; +double well_state_get_gas_rate_si(const well_state_type* well_state) { + double conversion_factor = 1; - if (well_state->unit_system == ECL_METRIC_UNITS) - conversion_factor = 1.0 / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_FIELD_UNITS) - conversion_factor = ECL_UNITS_VOLUME_GAS_FIELD / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_LAB_UNITS) - conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR; + if (well_state->unit_system == ECL_METRIC_UNITS) + conversion_factor = 1.0 / ECL_UNITS_TIME_DAY; + else if (well_state->unit_system == ECL_FIELD_UNITS) + conversion_factor = ECL_UNITS_VOLUME_GAS_FIELD / ECL_UNITS_TIME_DAY; + else if (well_state->unit_system == ECL_LAB_UNITS) + conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR; - return well_state->gas_rate * conversion_factor; + return well_state->gas_rate * conversion_factor; } -double well_state_get_water_rate_si( const well_state_type * well_state) { - double conversion_factor = 1; +double well_state_get_water_rate_si(const well_state_type* well_state) { + double conversion_factor = 1; - if (well_state->unit_system == ECL_METRIC_UNITS) - conversion_factor = 1.0 / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_FIELD_UNITS) - conversion_factor = ECL_UNITS_VOLUME_BARREL / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_LAB_UNITS) - conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR; + if (well_state->unit_system == ECL_METRIC_UNITS) + conversion_factor = 1.0 / ECL_UNITS_TIME_DAY; + else if (well_state->unit_system == ECL_FIELD_UNITS) + conversion_factor = ECL_UNITS_VOLUME_BARREL / ECL_UNITS_TIME_DAY; + else if (well_state->unit_system == ECL_LAB_UNITS) + conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR; - return well_state->water_rate * conversion_factor; + return well_state->water_rate * conversion_factor; } -double well_state_get_volume_rate_si( const well_state_type * well_state) { - return well_state->volume_rate; +double well_state_get_volume_rate_si(const well_state_type* well_state) { + return well_state->volume_rate; } -void well_state_add_wellhead( well_state_type * well_state , const ecl_rsthead_type * header , const ecl_kw_type * iwel_kw , int well_nr , const char * grid_name , int grid_nr) { - well_conn_type * wellhead = well_conn_alloc_wellhead( iwel_kw , header , well_nr ); +void well_state_add_wellhead(well_state_type* well_state, const ecl_rsthead_type* header, const ecl_kw_type* iwel_kw, int well_nr, const char* grid_name, int grid_nr) { + well_conn_type* wellhead = well_conn_alloc_wellhead(iwel_kw, header, well_nr); - if (wellhead != NULL) { - if (grid_nr >= static_cast(well_state->index_wellhead.size())) - well_state->index_wellhead.resize(grid_nr+1, NULL); - well_state->index_wellhead[grid_nr] = wellhead; - well_state->name_wellhead[grid_name] = wellhead; - } + if (wellhead != NULL) { + if (grid_nr >= static_cast(well_state->index_wellhead.size())) + well_state->index_wellhead.resize(grid_nr + 1, NULL); + well_state->index_wellhead[grid_nr] = wellhead; + well_state->name_wellhead[grid_name] = wellhead; + } } -static bool well_state_add_rates( well_state_type * well_state , - ecl_file_view_type * rst_view , - int well_nr) { +static bool well_state_add_rates(well_state_type* well_state, + ecl_file_view_type* rst_view, + int well_nr) { - bool has_xwel_kw = ecl_file_view_has_kw(rst_view, XWEL_KW); - if (has_xwel_kw) { - const ecl_kw_type *xwel_kw = ecl_file_view_iget_named_kw(rst_view, XWEL_KW, 0); - ecl_rsthead_type *header = ecl_rsthead_alloc(rst_view, -1); - int offset = header->nxwelz * well_nr; + bool has_xwel_kw = ecl_file_view_has_kw(rst_view, XWEL_KW); + if (has_xwel_kw) { + const ecl_kw_type* xwel_kw = ecl_file_view_iget_named_kw(rst_view, XWEL_KW, 0); + ecl_rsthead_type* header = ecl_rsthead_alloc(rst_view, -1); + int offset = header->nxwelz * well_nr; - well_state->unit_system = header->unit_system; - well_state->oil_rate = ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_ORAT_ITEM); - well_state->gas_rate = ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_GRAT_ITEM); - well_state->water_rate = ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_WRAT_ITEM); - well_state->volume_rate = ecl_kw_iget_double(xwel_kw, offset + XWEL_RESV_ITEM); + well_state->unit_system = header->unit_system; + well_state->oil_rate = ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_ORAT_ITEM); + well_state->gas_rate = ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_GRAT_ITEM); + well_state->water_rate = ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_WRAT_ITEM); + well_state->volume_rate = ecl_kw_iget_double(xwel_kw, offset + XWEL_RESV_ITEM); - ecl_rsthead_free(header); - } - return has_xwel_kw; + ecl_rsthead_free(header); + } + return has_xwel_kw; } @@ -332,69 +332,69 @@ static bool well_state_add_rates( well_state_type * well_state , all. */ -static int well_state_get_lgr_well_nr( const well_state_type * well_state , const ecl_file_view_type * file_view) { - int well_nr = -1; - - if (ecl_file_view_has_kw( file_view , ZWEL_KW)) { - ecl_rsthead_type * header = ecl_rsthead_alloc( file_view , -1); - const ecl_kw_type * zwel_kw = ecl_file_view_iget_named_kw( file_view , ZWEL_KW , 0 ); - int num_wells = header->nwells; - well_nr = 0; - while (true) { - bool found = false; - { - char * lgr_well_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( zwel_kw , well_nr * header->nzwelz) ); - - if ( well_state->name == lgr_well_name) - found = true; - else - well_nr++; - - free( lgr_well_name ); - } - - if (found) - break; - else if (well_nr == num_wells) { - // The well is not in this LGR at all. - well_nr = -1; - break; - } +static int well_state_get_lgr_well_nr(const well_state_type* well_state, const ecl_file_view_type* file_view) { + int well_nr = -1; + + if (ecl_file_view_has_kw(file_view, ZWEL_KW)) { + ecl_rsthead_type* header = ecl_rsthead_alloc(file_view, -1); + const ecl_kw_type* zwel_kw = ecl_file_view_iget_named_kw(file_view, ZWEL_KW, 0); + int num_wells = header->nwells; + well_nr = 0; + while (true) { + bool found = false; + { + char* lgr_well_name = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr(zwel_kw, well_nr * header->nzwelz)); + + if (well_state->name == lgr_well_name) + found = true; + else + well_nr++; + + free(lgr_well_name); + } + + if (found) + break; + else if (well_nr == num_wells) { + // The well is not in this LGR at all. + well_nr = -1; + break; + } + } + ecl_rsthead_free(header); } - ecl_rsthead_free( header ); - } - return well_nr; + return well_nr; } well_type_enum well_state_translate_ecl_type_int(int int_type) { - well_type_enum type = ECL_WELL_ZERO; + well_type_enum type = ECL_WELL_ZERO; - switch (int_type) { - /* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */ - case(IWEL_UNDOCUMENTED_ZERO): - type = ECL_WELL_ZERO; - break; - case(IWEL_PRODUCER): - type = ECL_WELL_PRODUCER; - break; - case(IWEL_OIL_INJECTOR): - type = ECL_WELL_OIL_INJECTOR; - break; - case(IWEL_GAS_INJECTOR): - type = ECL_WELL_GAS_INJECTOR; - break; - case(IWEL_WATER_INJECTOR): - type = ECL_WELL_WATER_INJECTOR; - break; - default: - // See https://github.com/OPM/ResInsight/issues/10493 - // util_abort("%s: Invalid type value %d\n",__func__ , int_type); - break; - } - return type; + switch (int_type) { + /* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */ + case(IWEL_UNDOCUMENTED_ZERO): + type = ECL_WELL_ZERO; + break; + case(IWEL_PRODUCER): + type = ECL_WELL_PRODUCER; + break; + case(IWEL_OIL_INJECTOR): + type = ECL_WELL_OIL_INJECTOR; + break; + case(IWEL_GAS_INJECTOR): + type = ECL_WELL_GAS_INJECTOR; + break; + case(IWEL_WATER_INJECTOR): + type = ECL_WELL_WATER_INJECTOR; + break; + default: + // See https://github.com/OPM/ResInsight/issues/10493 + // util_abort("%s: Invalid type value %d\n",__func__ , int_type); + break; + } + return type; } @@ -404,215 +404,215 @@ well_type_enum well_state_translate_ecl_type_int(int int_type) { to one LGR block with the ecl_file_subselect_block() function. */ -static void well_state_add_connections__( well_state_type * well_state , - const ecl_file_view_type * rst_view , - const char * grid_name , - int grid_nr, - int well_nr ) { +static void well_state_add_connections__(well_state_type* well_state, + const ecl_file_view_type* rst_view, + const char* grid_name, + int grid_nr, + int well_nr) { - ecl_rsthead_type * header = ecl_rsthead_alloc( rst_view , -1); - const ecl_kw_type * iwel_kw = ecl_file_view_iget_named_kw( rst_view , IWEL_KW , 0); + ecl_rsthead_type* header = ecl_rsthead_alloc(rst_view, -1); + const ecl_kw_type* iwel_kw = ecl_file_view_iget_named_kw(rst_view, IWEL_KW, 0); - well_state_add_wellhead( well_state , header , iwel_kw , well_nr , grid_name , grid_nr ); + well_state_add_wellhead(well_state, header, iwel_kw, well_nr, grid_name, grid_nr); - if (ecl_file_view_has_kw(rst_view, ICON_KW)) { - const ecl_kw_type * icon_kw = ecl_file_view_iget_named_kw( rst_view , ICON_KW , 0); - if (!well_state_has_grid_connections( well_state , grid_name )) - well_state->connections[grid_name] = well_conn_collection_alloc(); + if (ecl_file_view_has_kw(rst_view, ICON_KW)) { + const ecl_kw_type* icon_kw = ecl_file_view_iget_named_kw(rst_view, ICON_KW, 0); + if (!well_state_has_grid_connections(well_state, grid_name)) + well_state->connections[grid_name] = well_conn_collection_alloc(); - { - ecl_kw_type * scon_kw = NULL; - if (ecl_file_view_has_kw( rst_view , SCON_KW)) - scon_kw = ecl_file_view_iget_named_kw( rst_view , SCON_KW , 0); + { + ecl_kw_type* scon_kw = NULL; + if (ecl_file_view_has_kw(rst_view, SCON_KW)) + scon_kw = ecl_file_view_iget_named_kw(rst_view, SCON_KW, 0); - ecl_kw_type * xcon_kw = NULL; - if (ecl_file_view_has_kw( rst_view , XCON_KW)) { - xcon_kw = ecl_file_view_iget_named_kw(rst_view, XCON_KW, 0); - } + ecl_kw_type* xcon_kw = NULL; + if (ecl_file_view_has_kw(rst_view, XCON_KW)) { + xcon_kw = ecl_file_view_iget_named_kw(rst_view, XCON_KW, 0); + } - well_conn_collection_type * wellcc = well_state->connections[grid_name]; - well_conn_collection_load_from_kw( wellcc , iwel_kw , icon_kw , scon_kw, xcon_kw , well_nr , header ); + well_conn_collection_type* wellcc = well_state->connections[grid_name]; + well_conn_collection_load_from_kw(wellcc, iwel_kw, icon_kw, scon_kw, xcon_kw, well_nr, header); + } } - } - ecl_rsthead_free( header ); -} - - -static void well_state_add_global_connections( well_state_type * well_state , - const ecl_file_view_type * rst_view , - int well_nr ) { - well_state_add_connections__( well_state , rst_view , ECL_GRID_GLOBAL_GRID , 0 , well_nr ); -} - -static void well_state_add_LGR_connections(well_state_type * well_state, - const ecl_grid_type * grid, - ecl_file_view_type * file_view) { - // Go through all the LGRs and add connections; both in the bulk - // grid and as wellhead. - - int num_lgr = ecl_grid_get_num_lgr( grid ); - for (int lgr_index = 0; lgr_index < num_lgr; lgr_index++) { - ecl_file_view_type * lgr_view = ecl_file_view_add_blockview(file_view , LGR_KW , lgr_index); - /* - Even though the grid has LGR information the restart file is not required - to have corresponding LGR information. This has for a long time been - unchecked, and there might be bugs lurking based on the incorrect - assumption that if the grid has LGR information then the corresponding LGR - information can also be found in the restart file. - */ - if (lgr_view) { - const char * grid_name = ecl_grid_iget_lgr_name( grid , lgr_index ); - int well_nr = well_state_get_lgr_well_nr( well_state , lgr_view ); - if (well_nr >= 0) - well_state_add_connections__( well_state , lgr_view , grid_name , lgr_index + 1, well_nr ); + ecl_rsthead_free(header); +} + + +static void well_state_add_global_connections(well_state_type* well_state, + const ecl_file_view_type* rst_view, + int well_nr) { + well_state_add_connections__(well_state, rst_view, ECL_GRID_GLOBAL_GRID, 0, well_nr); +} + +static void well_state_add_LGR_connections(well_state_type* well_state, + std::vector grid_names, + ecl_file_view_type* file_view) { + // Go through all the LGRs and add connections; both in the bulk + // grid and as wellhead. + + int num_lgr = (int)(grid_names.size() - 1); + for (int lgr_index = 0; lgr_index < num_lgr; lgr_index++) { + ecl_file_view_type* lgr_view = ecl_file_view_add_blockview(file_view, LGR_KW, lgr_index); + /* + Even though the grid has LGR information the restart file is not required + to have corresponding LGR information. This has for a long time been + unchecked, and there might be bugs lurking based on the incorrect + assumption that if the grid has LGR information then the corresponding LGR + information can also be found in the restart file. + */ + if (lgr_view) { + int well_nr = well_state_get_lgr_well_nr(well_state, lgr_view); + if (well_nr >= 0) + well_state_add_connections__(well_state, lgr_view, grid_names[lgr_index + 1].c_str(), lgr_index + 1, well_nr); + } } - } } -void well_state_add_connections( well_state_type * well_state , - const ecl_grid_type * grid , - ecl_file_type * rst_file , // Either an open .Xnnnn file or UNRST file restricted to one report step - int well_nr) { +void well_state_add_connections(well_state_type* well_state, + std::vector grid_names, + ecl_file_type* rst_file, // Either an open .Xnnnn file or UNRST file restricted to one report step + int well_nr) { - well_state_add_connections2(well_state , grid , ecl_file_get_active_view( rst_file ) , well_nr ); + well_state_add_connections2(well_state, grid_names, ecl_file_get_active_view(rst_file), well_nr); } -void well_state_add_connections2( well_state_type * well_state , - const ecl_grid_type * grid , - ecl_file_view_type * rst_view , - int well_nr) { +void well_state_add_connections2(well_state_type* well_state, + std::vector grid_names, + ecl_file_view_type* rst_view, + int well_nr) { - well_state_add_global_connections( well_state , rst_view , well_nr ); - well_state_add_LGR_connections( well_state , grid , rst_view); + well_state_add_global_connections(well_state, rst_view, well_nr); + well_state_add_LGR_connections(well_state, grid_names, rst_view); } -bool well_state_add_MSW( well_state_type * well_state , - ecl_file_type * rst_file , - int well_nr, - bool load_segment_information) { +bool well_state_add_MSW(well_state_type* well_state, + ecl_file_type* rst_file, + int well_nr, + bool load_segment_information) { - return well_state_add_MSW2( well_state , ecl_file_get_active_view(rst_file) , well_nr , load_segment_information ); + return well_state_add_MSW2(well_state, ecl_file_get_active_view(rst_file), well_nr, load_segment_information); } -bool well_state_add_MSW2( well_state_type * well_state , - ecl_file_view_type * rst_view , - int well_nr, - bool load_segment_information) { +bool well_state_add_MSW2(well_state_type* well_state, + ecl_file_view_type* rst_view, + int well_nr, + bool load_segment_information) { - if (ecl_file_view_has_kw( rst_view , ISEG_KW)) { - ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_view , -1); - const ecl_kw_type * iwel_kw = ecl_file_view_iget_named_kw( rst_view , IWEL_KW , 0); - const ecl_kw_type * iseg_kw = ecl_file_view_iget_named_kw( rst_view , ISEG_KW , 0); - well_rseg_loader_type * rseg_loader = NULL; + if (ecl_file_view_has_kw(rst_view, ISEG_KW)) { + ecl_rsthead_type* rst_head = ecl_rsthead_alloc(rst_view, -1); + const ecl_kw_type* iwel_kw = ecl_file_view_iget_named_kw(rst_view, IWEL_KW, 0); + const ecl_kw_type* iseg_kw = ecl_file_view_iget_named_kw(rst_view, ISEG_KW, 0); + well_rseg_loader_type* rseg_loader = NULL; - int segment_count; + int segment_count; - if (ecl_file_view_has_kw( rst_view , RSEG_KW )) { - if (load_segment_information) - rseg_loader = well_rseg_loader_alloc(rst_view); + if (ecl_file_view_has_kw(rst_view, RSEG_KW)) { + if (load_segment_information) + rseg_loader = well_rseg_loader_alloc(rst_view); - segment_count = well_segment_collection_load_from_kw( well_state->segments , - well_nr , - iwel_kw , - iseg_kw , - rseg_loader , - rst_head, - load_segment_information , - &well_state->is_MSW_well); + segment_count = well_segment_collection_load_from_kw(well_state->segments, + well_nr, + iwel_kw, + iseg_kw, + rseg_loader, + rst_head, + load_segment_information, + &well_state->is_MSW_well); - if (segment_count > 0) { + if (segment_count > 0) { - auto it = well_state->connections.begin(); - while (it != well_state->connections.end()) { - well_segment_collection_add_connections( well_state->segments , it->first.c_str() , it->second ); - it++; - } + auto it = well_state->connections.begin(); + while (it != well_state->connections.end()) { + well_segment_collection_add_connections(well_state->segments, it->first.c_str(), it->second); + it++; + } - well_segment_collection_link( well_state->segments ); - well_segment_collection_add_branches( well_state->segments , well_state->branches ); - } - ecl_rsthead_free( rst_head ); + well_segment_collection_link(well_state->segments); + well_segment_collection_add_branches(well_state->segments, well_state->branches); + } + ecl_rsthead_free(rst_head); - if (rseg_loader != NULL) { - well_rseg_loader_free(rseg_loader); - } + if (rseg_loader != NULL) { + well_rseg_loader_free(rseg_loader); + } - return true; + return true; + } } - } - return false; + return false; } -bool well_state_is_MSW( const well_state_type * well_state) { - return well_state->is_MSW_well; +bool well_state_is_MSW(const well_state_type* well_state) { + return well_state->is_MSW_well; } -bool well_state_has_segment_data(const well_state_type * well_state){ - if (well_segment_collection_get_size( well_state->segments ) > 0) - return true; +bool well_state_has_segment_data(const well_state_type* well_state) { + if (well_segment_collection_get_size(well_state->segments) > 0) + return true; else - return false; -} - -well_state_type * well_state_alloc_from_file( ecl_file_type * ecl_file , const ecl_grid_type * grid , int report_nr , int global_well_nr ,bool load_segment_information) { - return well_state_alloc_from_file2( ecl_file_get_active_view( ecl_file ) , grid , report_nr , global_well_nr , load_segment_information); -} - -well_state_type * well_state_alloc_from_file2( ecl_file_view_type * file_view , const ecl_grid_type * grid , int report_nr , int global_well_nr ,bool load_segment_information) { - if (ecl_file_view_has_kw( file_view , IWEL_KW)) { - well_state_type * well_state = NULL; - ecl_rsthead_type * global_header = ecl_rsthead_alloc( file_view , -1); - const ecl_kw_type * global_iwel_kw = ecl_file_view_iget_named_kw( file_view , IWEL_KW , 0); - const ecl_kw_type * global_zwel_kw = ecl_file_view_iget_named_kw( file_view , ZWEL_KW , 0); - - const int iwel_offset = global_header->niwelz * global_well_nr; - { - char * name; - bool open; - well_type_enum type = ECL_WELL_ZERO; - { - int int_state = ecl_kw_iget_int( global_iwel_kw , iwel_offset + IWEL_STATUS_INDEX ); - if (int_state > 0) - open = true; - else - open = false; - } - - { - int int_type = ecl_kw_iget_int( global_iwel_kw , iwel_offset + IWEL_TYPE_INDEX); - type = well_state_translate_ecl_type_int( int_type ); - } - - { - const int zwel_offset = global_header->nzwelz * global_well_nr; - name = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr( global_zwel_kw , zwel_offset )); // Hardwired max 8 characters in Well Name - } - - well_state = well_state_alloc(name , global_well_nr , open , type , report_nr , global_header->sim_time); - free( name ); - - well_state_add_connections2( well_state , grid , file_view , global_well_nr); - if (ecl_file_view_has_kw( file_view , ISEG_KW)) - well_state_add_MSW2( well_state , file_view , global_well_nr , load_segment_information); - - well_state_add_rates(well_state, file_view, global_well_nr); + return false; +} + +well_state_type* well_state_alloc_from_file(ecl_file_type* ecl_file, std::vector grid_names, int report_nr, int global_well_nr, bool load_segment_information) { + return well_state_alloc_from_file2(ecl_file_get_active_view(ecl_file), grid_names, report_nr, global_well_nr, load_segment_information); +} + +well_state_type* well_state_alloc_from_file2(ecl_file_view_type* file_view, std::vector grid_names, int report_nr, int global_well_nr, bool load_segment_information) { + if (ecl_file_view_has_kw(file_view, IWEL_KW)) { + well_state_type* well_state = NULL; + ecl_rsthead_type* global_header = ecl_rsthead_alloc(file_view, -1); + const ecl_kw_type* global_iwel_kw = ecl_file_view_iget_named_kw(file_view, IWEL_KW, 0); + const ecl_kw_type* global_zwel_kw = ecl_file_view_iget_named_kw(file_view, ZWEL_KW, 0); + + const int iwel_offset = global_header->niwelz * global_well_nr; + { + char* name; + bool open; + well_type_enum type = ECL_WELL_ZERO; + { + int int_state = ecl_kw_iget_int(global_iwel_kw, iwel_offset + IWEL_STATUS_INDEX); + if (int_state > 0) + open = true; + else + open = false; + } + + { + int int_type = ecl_kw_iget_int(global_iwel_kw, iwel_offset + IWEL_TYPE_INDEX); + type = well_state_translate_ecl_type_int(int_type); + } + + { + const int zwel_offset = global_header->nzwelz * global_well_nr; + name = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr(global_zwel_kw, zwel_offset)); // Hardwired max 8 characters in Well Name + } + + well_state = well_state_alloc(name, global_well_nr, open, type, report_nr, global_header->sim_time); + free(name); + + well_state_add_connections2(well_state, grid_names, file_view, global_well_nr); + if (ecl_file_view_has_kw(file_view, ISEG_KW)) + well_state_add_MSW2(well_state, file_view, global_well_nr, load_segment_information); + + well_state_add_rates(well_state, file_view, global_well_nr); + } + ecl_rsthead_free(global_header); + return well_state; } - ecl_rsthead_free( global_header ); - return well_state; - } else - /* This seems a bit weird - have come over E300 restart files without the IWEL keyword. */ - return NULL; + else + /* This seems a bit weird - have come over E300 restart files without the IWEL keyword. */ + return NULL; } @@ -621,115 +621,115 @@ well_state_type * well_state_alloc_from_file2( ecl_file_view_type * file_view , -void well_state_free( well_state_type * well ) { +void well_state_free(well_state_type* well) { - for (size_t i = 0; i < well->index_wellhead.size(); i++) { - if (well->index_wellhead[i]) - well_conn_free(well->index_wellhead[i]); - } + for (size_t i = 0; i < well->index_wellhead.size(); i++) { + if (well->index_wellhead[i]) + well_conn_free(well->index_wellhead[i]); + } - for (auto& pair : well->connections) - well_conn_collection_free(pair.second); + for (auto& pair : well->connections) + well_conn_collection_free(pair.second); - well_segment_collection_free( well->segments ); - well_branch_collection_free( well->branches ); + well_segment_collection_free(well->segments); + well_branch_collection_free(well->branches); - delete well; + delete well; } /*****************************************************************/ -int well_state_get_report_nr( const well_state_type * well_state ) { - return well_state->valid_from_report; +int well_state_get_report_nr(const well_state_type* well_state) { + return well_state->valid_from_report; } -time_t well_state_get_sim_time( const well_state_type * well_state ) { - return well_state->valid_from_time; +time_t well_state_get_sim_time(const well_state_type* well_state) { + return well_state->valid_from_time; } /** Will return NULL if no wellhead in this grid. */ -const well_conn_type * well_state_iget_wellhead( const well_state_type * well_state , int grid_nr) { - if (grid_nr < static_cast(well_state->index_wellhead.size())) - return well_state->index_wellhead[grid_nr]; - else - return NULL; +const well_conn_type* well_state_iget_wellhead(const well_state_type* well_state, int grid_nr) { + if (grid_nr < static_cast(well_state->index_wellhead.size())) + return well_state->index_wellhead[grid_nr]; + else + return NULL; } -bool well_state_has_named_well_conn( const well_state_type * well_state , const char * grid_name ) { - const auto it = well_state->name_wellhead.find( grid_name ); - if (it == well_state->name_wellhead.end()) - return false; - return true; +bool well_state_has_named_well_conn(const well_state_type* well_state, const char* grid_name) { + const auto it = well_state->name_wellhead.find(grid_name); + if (it == well_state->name_wellhead.end()) + return false; + return true; } -const well_conn_type * well_state_get_wellhead( const well_state_type * well_state , const char * grid_name) { - const auto it = well_state->name_wellhead.find( grid_name ); - if (it != well_state->name_wellhead.end()) - return it->second; - return NULL; +const well_conn_type* well_state_get_wellhead(const well_state_type* well_state, const char* grid_name) { + const auto it = well_state->name_wellhead.find(grid_name); + if (it != well_state->name_wellhead.end()) + return it->second; + return NULL; } -const well_conn_type * well_state_get_global_wellhead( const well_state_type * well_state ) { - return well_state_get_wellhead( well_state, ECL_GRID_GLOBAL_GRID ); +const well_conn_type* well_state_get_global_wellhead(const well_state_type* well_state) { + return well_state_get_wellhead(well_state, ECL_GRID_GLOBAL_GRID); } -well_type_enum well_state_get_type( const well_state_type * well_state){ - return well_state->type; +well_type_enum well_state_get_type(const well_state_type* well_state) { + return well_state->type; } -bool well_state_is_open( const well_state_type * well_state ) { - return well_state->open; +bool well_state_is_open(const well_state_type* well_state) { + return well_state->open; } -int well_state_get_well_nr( const well_state_type * well_state ) { - return well_state->global_well_nr; +int well_state_get_well_nr(const well_state_type* well_state) { + return well_state->global_well_nr; } -const char * well_state_get_name( const well_state_type * well_state ) { - return well_state->name.c_str(); +const char* well_state_get_name(const well_state_type* well_state) { + return well_state->name.c_str(); } /*****************************************************************/ -const well_conn_collection_type * well_state_get_grid_connections( const well_state_type * well_state , const char * grid_name) { - if (well_state_has_grid_connections(well_state, grid_name) ) - return well_state->connections.at(grid_name); - else - return NULL; +const well_conn_collection_type* well_state_get_grid_connections(const well_state_type* well_state, const char* grid_name) { + if (well_state_has_grid_connections(well_state, grid_name)) + return well_state->connections.at(grid_name); + else + return NULL; } -const well_conn_collection_type * well_state_get_global_connections( const well_state_type * well_state ) { - return well_state_get_grid_connections( well_state , ECL_GRID_GLOBAL_GRID ); +const well_conn_collection_type* well_state_get_global_connections(const well_state_type* well_state) { + return well_state_get_grid_connections(well_state, ECL_GRID_GLOBAL_GRID); } -bool well_state_has_grid_connections( const well_state_type * well_state , const char * grid_name) { +bool well_state_has_grid_connections(const well_state_type* well_state, const char* grid_name) { - const auto it = well_state->connections.find(grid_name); - if (it == well_state->connections.end()) - return false; - return true; + const auto it = well_state->connections.find(grid_name); + if (it == well_state->connections.end()) + return false; + return true; } -bool well_state_has_global_connections( const well_state_type * well_state ) { - return well_state_has_grid_connections( well_state , ECL_GRID_GLOBAL_GRID ); +bool well_state_has_global_connections(const well_state_type* well_state) { + return well_state_has_grid_connections(well_state, ECL_GRID_GLOBAL_GRID); } -well_segment_collection_type * well_state_get_segments( const well_state_type * well_state ) { - return well_state->segments; +well_segment_collection_type* well_state_get_segments(const well_state_type* well_state) { + return well_state->segments; } -well_branch_collection_type * well_state_get_branches( const well_state_type * well_state ) { - return well_state->branches; +well_branch_collection_type* well_state_get_branches(const well_state_type* well_state) { + return well_state->branches; } diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp index b3474c0db5..2f861d9c68 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp @@ -30,26 +30,26 @@ extern "C" { #endif - typedef struct well_info_struct well_info_type; - - well_info_type * well_info_alloc(const ecl_grid_type * grid); - void well_info_add_UNRST_wells2( well_info_type * well_info , ecl_file_view_type * rst_view, bool load_segment_information); - void well_info_add_UNRST_wells( well_info_type * well_info , ecl_file_type * rst_file, bool load_segment_information); - void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file , int report_nr , bool load_segment_information); - void well_info_add_wells2( well_info_type * well_info , ecl_file_view_type * rst_view , int report_nr, bool load_segment_information); - void well_info_load_rstfile( well_info_type * well_info , const char * filename, bool load_segment_information); - void well_info_load_rst_eclfile( well_info_type * well_info , ecl_file_type * rst_file , bool load_segment_information); - void well_info_free( well_info_type * well_info ); - - well_ts_type * well_info_get_ts( const well_info_type * well_info , const char *well_name); - int well_info_get_num_wells( const well_info_type * well_info ); - const char * well_info_iget_well_name( const well_info_type * well_info, int well_index); - bool well_info_has_well( well_info_type * well_info , const char * well_name ); - - well_state_type * well_info_get_state_from_time( const well_info_type * well_info , const char * well_name , time_t sim_time); - well_state_type * well_info_get_state_from_report( const well_info_type * well_info , const char * well_name , int report_step ); - well_state_type * well_info_iget_state( const well_info_type * well_info , const char * well_name , int time_index); - well_state_type * well_info_iiget_state( const well_info_type * well_info , int well_index , int time_index); + typedef struct well_info_struct well_info_type; + + well_info_type* well_info_alloc(std::vector grid_names); + void well_info_add_UNRST_wells2(well_info_type* well_info, ecl_file_view_type* rst_view, bool load_segment_information); + void well_info_add_UNRST_wells(well_info_type* well_info, ecl_file_type* rst_file, bool load_segment_information); + void well_info_add_wells(well_info_type* well_info, ecl_file_type* rst_file, int report_nr, bool load_segment_information); + void well_info_add_wells2(well_info_type* well_info, ecl_file_view_type* rst_view, int report_nr, bool load_segment_information); + void well_info_load_rstfile(well_info_type* well_info, const char* filename, bool load_segment_information); + void well_info_load_rst_eclfile(well_info_type* well_info, ecl_file_type* rst_file, bool load_segment_information); + void well_info_free(well_info_type* well_info); + + well_ts_type* well_info_get_ts(const well_info_type* well_info, const char* well_name); + int well_info_get_num_wells(const well_info_type* well_info); + const char* well_info_iget_well_name(const well_info_type* well_info, int well_index); + bool well_info_has_well(well_info_type* well_info, const char* well_name); + + well_state_type* well_info_get_state_from_time(const well_info_type* well_info, const char* well_name, time_t sim_time); + well_state_type* well_info_get_state_from_report(const well_info_type* well_info, const char* well_name, int report_step); + well_state_type* well_info_iget_state(const well_info_type* well_info, const char* well_name, int time_index); + well_state_type* well_info_iiget_state(const well_info_type* well_info, int well_index, int time_index); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp index b6151b9aae..1731c1cfd3 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp @@ -22,6 +22,8 @@ #include +#include +#include #include #include @@ -38,72 +40,72 @@ extern "C" { #define GLOBAL_GRID_NAME "GLOBAL" // The name assigned to the global grid for name based lookup. - typedef struct well_state_struct well_state_type; + typedef struct well_state_struct well_state_type; - well_state_type * well_state_alloc(const char * well_name , int global_well_nr , bool open, well_type_enum type , int report_nr, time_t valid_from); - well_state_type * well_state_alloc_from_file( ecl_file_type * ecl_file , const ecl_grid_type * grid , int report_step , int well_nr , bool load_segment_information); - well_state_type * well_state_alloc_from_file2( ecl_file_view_type * file_view , const ecl_grid_type * grid , int report_nr , int global_well_nr ,bool load_segment_information); + well_state_type* well_state_alloc(const char* well_name, int global_well_nr, bool open, well_type_enum type, int report_nr, time_t valid_from); + well_state_type* well_state_alloc_from_file(ecl_file_type* ecl_file, std::vector grid_names, int report_step, int well_nr, bool load_segment_information); + well_state_type* well_state_alloc_from_file2(ecl_file_view_type* file_view, std::vector grid_names, int report_nr, int global_well_nr, bool load_segment_information); - void well_state_add_connections2( well_state_type * well_state , - const ecl_grid_type * grid , - ecl_file_view_type * rst_view , - int well_nr); + void well_state_add_connections2(well_state_type* well_state, + std::vector grid_names, + ecl_file_view_type* rst_view, + int well_nr); - void well_state_add_connections( well_state_type * well_state , - const ecl_grid_type * grid , - ecl_file_type * rst_file , - int well_nr); + void well_state_add_connections(well_state_type* well_state, + std::vector grid_names, + ecl_file_type* rst_file, + int well_nr); - bool well_state_add_MSW( well_state_type * well_state , - ecl_file_type * rst_file , - int well_nr, - bool load_segment_information); + bool well_state_add_MSW(well_state_type* well_state, + ecl_file_type* rst_file, + int well_nr, + bool load_segment_information); - bool well_state_add_MSW2( well_state_type * well_state , - ecl_file_view_type * rst_view, - int well_nr, - bool load_segment_information); + bool well_state_add_MSW2(well_state_type* well_state, + ecl_file_view_type* rst_view, + int well_nr, + bool load_segment_information); - bool well_state_is_MSW( const well_state_type * well_state); + bool well_state_is_MSW(const well_state_type* well_state); - bool well_state_has_segment_data(const well_state_type * well_state); + bool well_state_has_segment_data(const well_state_type* well_state); - well_segment_collection_type * well_state_get_segments( const well_state_type * well_state ); - well_branch_collection_type * well_state_get_branches( const well_state_type * well_state ); + well_segment_collection_type* well_state_get_segments(const well_state_type* well_state); + well_branch_collection_type* well_state_get_branches(const well_state_type* well_state); - void well_state_free( well_state_type * well ); - const char * well_state_get_name( const well_state_type * well ); - int well_state_get_report_nr( const well_state_type * well_state ); - time_t well_state_get_sim_time( const well_state_type * well_state ); - well_type_enum well_state_get_type( const well_state_type * well_state); - bool well_state_is_open( const well_state_type * well_state ); - int well_state_get_well_nr( const well_state_type * well_state ); + void well_state_free(well_state_type* well); + const char* well_state_get_name(const well_state_type* well); + int well_state_get_report_nr(const well_state_type* well_state); + time_t well_state_get_sim_time(const well_state_type* well_state); + well_type_enum well_state_get_type(const well_state_type* well_state); + bool well_state_is_open(const well_state_type* well_state); + int well_state_get_well_nr(const well_state_type* well_state); - const well_conn_type * well_state_get_global_wellhead( const well_state_type * well_state ); - const well_conn_type * well_state_iget_wellhead( const well_state_type * well_state , int grid_nr); - const well_conn_type * well_state_get_wellhead( const well_state_type * well_state , const char * grid_name); + const well_conn_type* well_state_get_global_wellhead(const well_state_type* well_state); + const well_conn_type* well_state_iget_wellhead(const well_state_type* well_state, int grid_nr); + const well_conn_type* well_state_get_wellhead(const well_state_type* well_state, const char* grid_name); - well_type_enum well_state_translate_ecl_type_int(int int_type); + well_type_enum well_state_translate_ecl_type_int(int int_type); - const well_conn_collection_type * well_state_get_grid_connections( const well_state_type * well_state , const char * grid_name); - const well_conn_collection_type * well_state_get_global_connections( const well_state_type * well_state ); - bool well_state_has_grid_connections( const well_state_type * well_state , const char * grid_name); - bool well_state_has_global_connections( const well_state_type * well_state ); + const well_conn_collection_type* well_state_get_grid_connections(const well_state_type* well_state, const char* grid_name); + const well_conn_collection_type* well_state_get_global_connections(const well_state_type* well_state); + bool well_state_has_grid_connections(const well_state_type* well_state, const char* grid_name); + bool well_state_has_global_connections(const well_state_type* well_state); - double well_state_get_oil_rate( const well_state_type * well_state ); - double well_state_get_gas_rate( const well_state_type * well_state ); - double well_state_get_water_rate( const well_state_type * well_state); - double well_state_get_volume_rate( const well_state_type * well_state); - double well_state_get_water_rate_si( const well_state_type * well_state); - double well_state_get_oil_rate_si( const well_state_type * well_state ); - double well_state_get_volume_rate_si( const well_state_type * well_state); - double well_state_get_gas_rate_si( const well_state_type * well_state ); + double well_state_get_oil_rate(const well_state_type* well_state); + double well_state_get_gas_rate(const well_state_type* well_state); + double well_state_get_water_rate(const well_state_type* well_state); + double well_state_get_volume_rate(const well_state_type* well_state); + double well_state_get_water_rate_si(const well_state_type* well_state); + double well_state_get_oil_rate_si(const well_state_type* well_state); + double well_state_get_volume_rate_si(const well_state_type* well_state); + double well_state_get_gas_rate_si(const well_state_type* well_state); - UTIL_IS_INSTANCE_HEADER( well_state ); + UTIL_IS_INSTANCE_HEADER(well_state); #ifdef __cplusplus } diff --git a/ThirdParty/custom-opm-common/opm-common b/ThirdParty/custom-opm-common/opm-common index a76421efff..ddbf77d554 160000 --- a/ThirdParty/custom-opm-common/opm-common +++ b/ThirdParty/custom-opm-common/opm-common @@ -1 +1 @@ -Subproject commit a76421efffb45ae42831a5a5a8cc7e2bddbf5b8e +Subproject commit ddbf77d5541eef7073d56991158aa63985309379 From d0a870bb38fb46783639e649af6eb4b6a5afe942 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Tue, 18 Jun 2024 14:25:14 +0200 Subject: [PATCH 149/332] #11514 OSDU: parse and add datum elevation to well paths. --- .../OsduImportCommands/RiaOsduConnector.cpp | 26 ++++++++++++++++++- .../OsduImportCommands/RiaOsduConnector.h | 1 + .../RicWellPathsImportOsduFeature.cpp | 3 ++- .../RiuWellImportWizard.cpp | 3 ++- .../OsduImportCommands/RiuWellImportWizard.h | 1 + .../FileInterface/RifOsduWellPathReader.cpp | 8 +++--- .../FileInterface/RifOsduWellPathReader.h | 2 +- .../WellPath/RimOsduWellPath.cpp | 21 +++++++++++++++ .../WellPath/RimOsduWellPath.h | 4 +++ .../WellPath/RimWellPathCollection.cpp | 10 ++++--- .../WellPath/RimWellPathCollection.h | 3 ++- 11 files changed, 70 insertions(+), 12 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index a4c2d4c89d..8c1dcfc92a 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -19,6 +19,8 @@ #include #include +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -457,7 +459,29 @@ void RiaOsduConnector::parseWellbores( QNetworkReply* reply, const QString& well QString id = resultObj["id"].toString(); QString kind = resultObj["kind"].toString(); QString name = resultObj["data"].toObject()["FacilityName"].toString(); - m_wellbores[wellId].push_back( OsduWellbore{ id, kind, name, wellId } ); + + // Extract datum elevation. The DefaultVerticalMeasurementID is probably the datum elevation needed. + // Default to 0.0 if nothing is found, but finding nothing is suspicious. + double datumElevation = std::numeric_limits::infinity(); + QString defaultVerticalMeasurementId = resultObj["data"].toObject()["DefaultVerticalMeasurementID"].toString(); + QJsonArray verticalMeasurementsArray = resultObj["data"].toObject()["VerticalMeasurements"].toArray(); + for ( const QJsonValue& vma : verticalMeasurementsArray ) + { + QString verticalMeasurementId = vma["VerticalMeasurementID"].toString(); + if ( verticalMeasurementId == defaultVerticalMeasurementId ) + { + double verticalMeasurement = vma["VerticalMeasurement"].toDouble( 0.0 ); + datumElevation = verticalMeasurement; + } + } + + if ( std::isinf( datumElevation ) ) + { + RiaLogging::warning( QString( "Missing datum elevation for well bore '%1'. Id: %2" ).arg( name ).arg( id ) ); + datumElevation = 0.0; + } + + m_wellbores[wellId].push_back( OsduWellbore{ id, kind, name, wellId, datumElevation } ); } } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h index 98a19de628..b474416f2e 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -27,6 +27,7 @@ struct OsduWellbore QString kind; QString name; QString wellId; + double datumElevation; }; struct OsduWellboreTrajectory diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index 88bec7c83a..d0209b9b26 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -90,7 +90,7 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) auto task = progress.task( QString( "Importing well: %1" ).arg( w.name ) ); auto [wellPathGeometry, errorMessage] = - RimWellPathCollection::loadWellPathGeometryFromOsdu( osduConnector, w.wellboreTrajectoryId ); + RimWellPathCollection::loadWellPathGeometryFromOsdu( osduConnector, w.wellboreTrajectoryId, w.datumElevation ); if ( wellPathGeometry.notNull() ) { auto wellPath = new RimOsduWellPath; @@ -98,6 +98,7 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) wellPath->setWellId( w.wellId ); wellPath->setWellboreId( w.wellboreId ); wellPath->setWellboreTrajectoryId( w.wellboreTrajectoryId ); + wellPath->setDatumElevationFromOsdu( w.datumElevation ); oilField->wellPathCollection->addWellPath( wellPath ); diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index 14604fb167..d34f5c245b 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -579,7 +579,8 @@ void WellSummaryPage::wellboreTrajectoryFinished( const QString& wellboreId, int wiz->addWellInfo( { .name = wellbore.value().name, .wellId = well.value().id, .wellboreId = w.wellboreId, - .wellboreTrajectoryId = wellboreTrajectoryId } ); + .wellboreTrajectoryId = wellboreTrajectoryId, + .datumElevation = wellbore.value().datumElevation } ); } } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index 449bd5e840..4e27c87723 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -370,6 +370,7 @@ class RiuWellImportWizard : public QWizard QString wellId; QString wellboreId; QString wellboreTrajectoryId; + double datumElevation; }; RiuWellImportWizard( const QString& downloadFolder, diff --git a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp index d1000e246c..04838836eb 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp +++ b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp @@ -106,7 +106,7 @@ std::pair, QString> RifOsduWellPathReader::parseCsv( const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair, QString> RifOsduWellPathReader::readWellPathData( const QByteArray& content ) +std::pair, QString> RifOsduWellPathReader::readWellPathData( const QByteArray& content, double datumElevation ) { arrow::MemoryPool* pool = arrow::default_memory_pool(); @@ -155,14 +155,16 @@ std::pair, QString> RifOsduWellPathReader::readWellPathDat for ( size_t i = 0; i < firstSize; i++ ) { - cvf::Vec3d point( readValues[X][i], readValues[Y][i], -readValues[TVD][i] ); + cvf::Vec3d point( readValues[X][i], readValues[Y][i], -readValues[TVD][i] + datumElevation ); double md = readValues[MD][i]; wellPathPoints.push_back( point ); measuredDepths.push_back( md ); } - return { cvf::make_ref( wellPathPoints, measuredDepths ), "" }; + auto wellPath = cvf::make_ref( wellPathPoints, measuredDepths ); + wellPath->setDatumElevation( datumElevation ); + return { wellPath, "" }; } return { nullptr, "" }; diff --git a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.h b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.h index ffb52f83e0..768cfa4876 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.h +++ b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.h @@ -32,5 +32,5 @@ class RifOsduWellPathReader { public: static std::pair, QString> parseCsv( const QString& content ); - static std::pair, QString> readWellPathData( const QByteArray& content ); + static std::pair, QString> readWellPathData( const QByteArray& content, double datumElevation ); }; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp index cb16b7c949..2543a18a92 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.cpp @@ -1,5 +1,6 @@ #include "RimOsduWellPath.h" +#include "cafPdmObject.h" #include "cafPdmObjectScriptingCapability.h" CAF_PDM_SOURCE_INIT( RimOsduWellPath, "OsduWellPath" ); @@ -20,6 +21,9 @@ RimOsduWellPath::RimOsduWellPath() CAF_PDM_InitFieldNoDefault( &m_wellboreTrajectoryId, "WellboreTrajectoryId", "Wellbore Trajectory Id" ); m_wellboreTrajectoryId.uiCapability()->setUiReadOnly( true ); + CAF_PDM_InitField( &m_datumElevationFromOsdu, "DatumElevationFromOsdu", 0.0, "Datum Elevation From OSDU" ); + m_datumElevationFromOsdu.uiCapability()->setUiReadOnly( true ); + // Required, as these settings are set in RimWellPath() m_name.uiCapability()->setUiReadOnly( false ); m_name.uiCapability()->setUiHidden( false ); @@ -82,6 +86,22 @@ QString RimOsduWellPath::wellboreTrajectoryId() const return m_wellboreTrajectoryId; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellPath::setDatumElevationFromOsdu( double datumElevation ) +{ + m_datumElevationFromOsdu = datumElevation; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimOsduWellPath::datumElevationFromOsdu() const +{ + return m_datumElevationFromOsdu; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -91,6 +111,7 @@ void RimOsduWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering osduGroup->add( &m_wellId ); osduGroup->add( &m_wellboreId ); osduGroup->add( &m_wellboreTrajectoryId ); + osduGroup->add( &m_datumElevationFromOsdu ); RimWellPath::defineUiOrdering( uiConfigName, uiOrdering ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h index 362ab3bcb5..72d1628803 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPath.h @@ -36,6 +36,9 @@ class RimOsduWellPath : public RimWellPath void setWellboreTrajectoryId( const QString& wellboreTrajectoryId ); QString wellboreTrajectoryId() const; + void setDatumElevationFromOsdu( double datumElevationFromOsdu ); + double datumElevationFromOsdu() const; + protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; @@ -43,4 +46,5 @@ class RimOsduWellPath : public RimWellPath caf::PdmField m_wellId; caf::PdmField m_wellboreId; caf::PdmField m_wellboreTrajectoryId; + caf::PdmField m_datumElevationFromOsdu; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 84d6f8497b..9d52f24cda 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -178,8 +178,9 @@ void RimWellPathCollection::loadDataAndUpdate() } else if ( oWPath ) { - RiaOsduConnector* osduConnector = app->makeOsduConnector(); - auto [wellPathGeometry, errorMessage] = loadWellPathGeometryFromOsdu( osduConnector, oWPath->wellboreTrajectoryId() ); + RiaOsduConnector* osduConnector = app->makeOsduConnector(); + auto [wellPathGeometry, errorMessage] = + loadWellPathGeometryFromOsdu( osduConnector, oWPath->wellboreTrajectoryId(), oWPath->datumElevationFromOsdu() ); if ( wellPathGeometry.notNull() ) { oWPath->setWellPathGeometry( wellPathGeometry.p() ); @@ -1052,7 +1053,8 @@ void RimWellPathCollection::onChildAdded( caf::PdmFieldHandle* containerForNewOb /// //-------------------------------------------------------------------------------------------------- std::pair, QString> RimWellPathCollection::loadWellPathGeometryFromOsdu( RiaOsduConnector* osduConnector, - const QString& wellboreTrajectoryId ) + const QString& wellboreTrajectoryId, + double datumElevation ) { auto [fileContents, errorMessage] = osduConnector->requestWellboreTrajectoryParquetDataById( wellboreTrajectoryId ); if ( !errorMessage.isEmpty() ) @@ -1060,7 +1062,7 @@ std::pair, QString> RimWellPathCollection::loadWellPathGeo return { nullptr, errorMessage }; } - return RifOsduWellPathReader::readWellPathData( fileContents ); + return RifOsduWellPathReader::readWellPathData( fileContents, datumElevation ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h index d4ca69fe4b..966725626d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h @@ -135,7 +135,8 @@ class RimWellPathCollection : public caf::PdmObject void onChildAdded( caf::PdmFieldHandle* containerForNewObject ) override; - static std::pair, QString> loadWellPathGeometryFromOsdu( RiaOsduConnector* osduConnector, const QString& fileId ); + static std::pair, QString> + loadWellPathGeometryFromOsdu( RiaOsduConnector* osduConnector, const QString& wellTrajectoryId, double datumElevation ); static std::pair, QString> loadWellLogFromOsdu( RiaOsduConnector* osduConnector, const QString& wellLogId ); From 0d48c7d5b7c6e007a752b88881be07b1aae50a5f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 18 Jun 2024 10:37:47 +0200 Subject: [PATCH 150/332] #11515 Show Eclipse data source on top in Property Editor --- ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 6fd8898b77..9618024d72 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -1899,11 +1899,11 @@ const std::vector& RimEclipseView::visibleGridParts() const //-------------------------------------------------------------------------------------------------- void RimEclipseView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - Rim3dView::defineUiOrdering( uiConfigName, uiOrdering ); - // Only show case option when not under a case in the project tree. if ( !firstAncestorOrThisOfType() ) uiOrdering.add( &m_eclipseCase ); + Rim3dView::defineUiOrdering( uiConfigName, uiOrdering ); + caf::PdmUiGroup* cellGroup = uiOrdering.addNewGroup( "Cell Visibility" ); cellGroup->add( &m_showInactiveCells ); cellGroup->add( &m_showInvalidCells ); From 2724f80e8e40c1fe6b5cf85cfaee93a750a1f2e2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 18 Jun 2024 11:34:51 +0200 Subject: [PATCH 151/332] #11516 Disable selection of cell result from intersection view Selection of the cell result in the 3D view causes changes in active view and is very confusing for the user. Use "Activate Result in Project Tree" from right-click menu in the intersection view. --- .../Rim2dIntersectionView.cpp | 27 +---------- .../ProjectDataModel/Rim2dIntersectionView.h | 3 -- .../UserInterface/RiuViewerCommands.cpp | 45 +++++++++---------- 3 files changed, 22 insertions(+), 53 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp index f2952ac03b..b89a90414b 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -404,26 +404,9 @@ bool Rim2dIntersectionView::showDefiningPoints() const //-------------------------------------------------------------------------------------------------- std::vector Rim2dIntersectionView::legendConfigs() const { - std::vector legendsIn3dView; - // Return empty list, as the intersection view has a copy of the legend items. Picking and selection of the // corresponding item is handeled by handleOverlayItemPicked() - return legendsIn3dView; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool Rim2dIntersectionView::handleOverlayItemPicked( const cvf::OverlayItem* pickedOverlayItem ) const -{ - if ( m_legendObjectToSelect ) - { - if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->selectAsCurrentItem( m_legendObjectToSelect ); - - return true; - } - - return false; + return {}; } //-------------------------------------------------------------------------------------------------- @@ -662,8 +645,6 @@ void Rim2dIntersectionView::onUpdateDisplayModelForCurrentTimeStep() //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionView::onUpdateLegends() { - m_legendObjectToSelect = nullptr; - if ( !nativeOrOverrideViewer() || !m_intersection ) return; nativeOrOverrideViewer()->removeAllColorLegends(); @@ -724,15 +705,11 @@ void Rim2dIntersectionView::onUpdateLegends() { m_ternaryLegendConfig()->setTitle( "Cell Result:\n" ); legend = m_ternaryLegendConfig()->titledOverlayFrame(); - - m_legendObjectToSelect = ternaryLegendConfig; } else { eclResDef->updateLegendTitle( m_legendConfig, "Cell Result:\n" ); legend = m_legendConfig()->titledOverlayFrame(); - - m_legendObjectToSelect = regularLegendConfig; } } @@ -740,8 +717,6 @@ void Rim2dIntersectionView::onUpdateLegends() { geomResDef->updateLegendTextAndRanges( m_legendConfig(), "Cell Result:\n", m_currentTimeStep() ); legend = m_legendConfig()->titledOverlayFrame(); - - m_legendObjectToSelect = regularLegendConfig; } if ( legend ) diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h index 1613e55e03..a9a83af986 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h @@ -72,7 +72,6 @@ class Rim2dIntersectionView : public Rim3dView bool showDefiningPoints() const; std::vector legendConfigs() const override; - bool handleOverlayItemPicked( const cvf::OverlayItem* pickedOverlayItem ) const; protected: void onUpdateLegends() override; @@ -118,7 +117,5 @@ class Rim2dIntersectionView : public Rim3dView caf::PdmField m_showDefiningPoints; caf::PdmField m_showAxisLines; - caf::PdmPointer m_legendObjectToSelect; - const static cvf::Mat4d sm_defaultViewMatrix; }; diff --git a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp index 1fb9b04446..d83182c029 100644 --- a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp @@ -1188,6 +1188,11 @@ void RiuViewerCommands::ijkFromCellIndex( Rim3dView* mainOrComparisonView, size_ //-------------------------------------------------------------------------------------------------- bool RiuViewerCommands::handleOverlayItemPicking( int winPosX, int winPosY ) { + if ( dynamic_cast( m_reservoirView.p() ) ) + { + return false; + } + cvf::OverlayItem* pickedOverlayItem = m_viewer->overlayItem( winPosX, winPosY ); if ( !pickedOverlayItem ) { @@ -1196,36 +1201,28 @@ bool RiuViewerCommands::handleOverlayItemPicking( int winPosX, int winPosY ) if ( pickedOverlayItem ) { - auto intersectionView = dynamic_cast( m_reservoirView.p() ); - if ( intersectionView && intersectionView->handleOverlayItemPicked( pickedOverlayItem ) ) + std::vector legendConfigs = m_reservoirView->legendConfigs(); + if ( m_reservoirView->activeComparisonView() ) { - return true; + std::vector compViewLegendConfigs = m_reservoirView->activeComparisonView()->legendConfigs(); + legendConfigs.insert( legendConfigs.end(), compViewLegendConfigs.begin(), compViewLegendConfigs.end() ); } - else - { - std::vector legendConfigs = m_reservoirView->legendConfigs(); - if ( m_reservoirView->activeComparisonView() ) - { - std::vector compViewLegendConfigs = m_reservoirView->activeComparisonView()->legendConfigs(); - legendConfigs.insert( legendConfigs.end(), compViewLegendConfigs.begin(), compViewLegendConfigs.end() ); - } - for ( const auto& legendConfig : legendConfigs ) + for ( const auto& legendConfig : legendConfigs ) + { + if ( legendConfig && legendConfig->titledOverlayFrame() == pickedOverlayItem ) { - if ( legendConfig && legendConfig->titledOverlayFrame() == pickedOverlayItem ) + auto seisInterface = legendConfig->firstAncestorOfType(); + if ( seisInterface != nullptr ) { - auto seisInterface = legendConfig->firstAncestorOfType(); - if ( seisInterface != nullptr ) - { - RiuMainWindow::instance()->selectAsCurrentItem( seisInterface ); - } - else - { - RiuMainWindow::instance()->selectAsCurrentItem( legendConfig ); - } - - return true; + RiuMainWindow::instance()->selectAsCurrentItem( seisInterface ); } + else + { + RiuMainWindow::instance()->selectAsCurrentItem( legendConfig ); + } + + return true; } } } From 33646b33f5086072b264d6c928e79010ecf342cf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 18 Jun 2024 18:01:46 +0200 Subject: [PATCH 152/332] #11522 Convert to plain text when pasting from clipboard --- Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp | 14 ++++++++++++++ Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h | 1 + 2 files changed, 15 insertions(+) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp index d87f427d1a..52d065c87a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -92,6 +93,19 @@ void TextEdit::focusOutEvent( QFocusEvent* e ) emit editingFinished(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void TextEdit::insertFromMimeData( const QMimeData* source ) +{ + if ( !source ) return; + + // Insert as plain text and do not try to interpret HTML. https://github.com/OPM/ResInsight/issues/11522 + + auto text = source->text(); + insertPlainText( text ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h index e68caf2526..570d79e4d3 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h @@ -100,6 +100,7 @@ class TextEdit : public QTextEdit protected: void focusOutEvent( QFocusEvent* e ) override; + void insertFromMimeData( const QMimeData* source ) override; signals: void editingFinished(); From 812097cc3dbc9d971b02d26a25d88329e0591523 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 18 Jun 2024 10:43:48 +0200 Subject: [PATCH 153/332] Bump to dev.05 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 0dab48872d..15637d3131 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".04") +set(RESINSIGHT_DEV_VERSION ".05") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 9a2be684a2813938f1b6ab685ce297a65e8a16cc Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Thu, 20 Jun 2024 07:16:02 +0200 Subject: [PATCH 154/332] Fix building when you have both WINDOWS and POSIX mkdir detected. (#11523) * Fix building when you have both WINDOWS and POSIX mkdir detected. --- ThirdParty/Ert/lib/util/util.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ThirdParty/Ert/lib/util/util.c b/ThirdParty/Ert/lib/util/util.c index 5923dd5ba3..af625d76fe 100644 --- a/ThirdParty/Ert/lib/util/util.c +++ b/ThirdParty/Ert/lib/util/util.c @@ -4620,12 +4620,10 @@ bool util_is_abs_path(const char * path) { } static int util_mkdir( const char * path ) { -#ifdef HAVE_POSIX_MKDIR - return mkdir( path , UTIL_DEFAULT_MKDIR_MODE ); -#endif - -#ifdef HAVE_WINDOWS_MKDIR - return _mkdir( path ); +#if defined(HAVE_WINDOWS_MKDIR) + return _mkdir(path); +#elif defined(HAVE_POSIX_MKDIR) + return mkdir( path , UTIL_DEFAULT_MKDIR_MODE ); #endif } From b697ba764cfbc872e1fec35b8235fd7bbc63fb80 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:27:55 +0200 Subject: [PATCH 155/332] Support dual poro init files, too (#11524) --- ThirdParty/custom-opm-common/opm-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdParty/custom-opm-common/opm-common b/ThirdParty/custom-opm-common/opm-common index ddbf77d554..354375b8ae 160000 --- a/ThirdParty/custom-opm-common/opm-common +++ b/ThirdParty/custom-opm-common/opm-common @@ -1 +1 @@ -Subproject commit ddbf77d5541eef7073d56991158aa63985309379 +Subproject commit 354375b8ae55fad91efa64a298de4e0871defd19 From c7b1fdc134fe0d1527ba8600dbccd7b6b016a9c2 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 24 Jun 2024 10:26:55 +0200 Subject: [PATCH 156/332] Osdu: Add more logging. --- .../OsduImportCommands/RiaOsduConnector.cpp | 33 ++++++++++++++++++- .../OsduImportCommands/RiaOsduConnector.h | 4 +++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index 8c1dcfc92a..c9dc9e4c1c 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -50,7 +50,7 @@ RiaOsduConnector::RiaOsduConnector( QObject* parent, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, []( QUrl url ) { - RiaLogging::info( "Authorize with url: " + url.toString() ); + RiaLogging::debug( "Authorize with url: " + url.toString() ); QUrlQuery query( url ); url.setQuery( query ); QDesktopServices::openUrl( url ); @@ -68,8 +68,18 @@ RiaOsduConnector::RiaOsduConnector( QObject* parent, auto replyHandler = new RiaOsduOAuthHttpServerReplyHandler( port, this ); m_osdu->setReplyHandler( replyHandler ); + RiaLogging::debug( "Osdu server callback: " + replyHandler->callback() ); connect( m_osdu, SIGNAL( granted() ), this, SLOT( accessGranted() ) ); + connect( m_osdu, + SIGNAL( error( const QString&, const QString&, const QUrl& ) ), + this, + SLOT( errorReceived( const QString&, const QString&, const QUrl& ) ) ); + + connect( m_osdu, + SIGNAL( authorizationCallbackReceived( const QVariantMap& ) ), + this, + SLOT( authorizationCallbackReceived( const QVariantMap& ) ) ); } //-------------------------------------------------------------------------------------------------- @@ -77,10 +87,31 @@ RiaOsduConnector::RiaOsduConnector( QObject* parent, //-------------------------------------------------------------------------------------------------- void RiaOsduConnector::accessGranted() { + RiaLogging::debug( "Access granted." ); m_token = m_osdu->token(); emit tokenReady( m_token ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri ) +{ + RiaLogging::debug( "OSDU Error Received: " + error + ". Description: " + errorDescription ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::authorizationCallbackReceived( const QVariantMap& data ) +{ + RiaLogging::debug( "Authorization callback received:" ); + for ( const auto& [key, value] : data.toStdMap() ) + { + RiaLogging::debug( " Key: " + key + " Value: " + value.toString() ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h index b474416f2e..32a0f44c1d 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -102,6 +102,10 @@ public slots: void wellLogsFinished( const QString& wellboreId ); void tokenReady( const QString& token ); +private slots: + void errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri ); + void authorizationCallbackReceived( const QVariantMap& data ); + private: void requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token ); From 09efbb8439dcbbbd67a785ec7aa5e5830697c78e Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 24 Jun 2024 10:28:05 +0200 Subject: [PATCH 157/332] Bump to dev.06 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 15637d3131..27277032bb 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".05") +set(RESINSIGHT_DEV_VERSION ".06") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 16215585be3eae596533d89300a1553496e02d97 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 24 Jun 2024 14:20:54 +0200 Subject: [PATCH 158/332] Refactoring to prepare for renaming of RimSummaryCaseCollection Move functions into RimSummaryEnsembleTools Use enum class instead of plain enum --- .../RicCreateRftPlotsFeature.cpp | 4 +- .../RimAbstractCorrelationPlot.cpp | 3 +- .../RimCorrelationPlotCollection.cpp | 4 +- .../Flow/RimWellPlotTools.cpp | 288 +++++++-------- .../ProjectDataModel/Flow/RimWellPlotTools.h | 168 ++++----- .../ProjectDataModel/Flow/RimWellPltPlot.cpp | 56 +-- .../ProjectDataModel/Flow/RimWellPltPlot.h | 7 +- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 11 +- .../Summary/CMakeLists_files.cmake | 2 + .../Summary/RimSummaryCaseCollection.cpp | 328 +----------------- .../Summary/RimSummaryCaseCollection.h | 15 +- .../Summary/RimSummaryEnsembleTools.cpp | 325 +++++++++++++++++ .../Summary/RimSummaryEnsembleTools.h | 40 +++ .../RimSummaryCaseCollection-Test.cpp | 6 +- 14 files changed, 645 insertions(+), 612 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsembleTools.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsembleTools.h diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp index 19e4bf81a1..41e729f3d8 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp @@ -28,9 +28,9 @@ #include "RimRftPlotCollection.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsembleTools.h" #include "RimWellLogPlotNameConfig.h" #include "RimWellLogTrack.h" -#include "RimWellPlotTools.h" #include "RimWellRftPlot.h" #include "RiuPlotMainWindowTools.h" @@ -58,7 +58,7 @@ void RicCreateRftPlotsFeature::onActionTriggered( bool isChecked ) auto dataSource = sourcePlot->dataSource(); if ( auto summaryCollection = std::get_if( &dataSource ) ) { - wellsWithRftData = ( *summaryCollection )->wellsWithRftData(); + wellsWithRftData = RimSummaryEnsembleTools::wellsWithRftData( ( *summaryCollection )->allSummaryCases() ); } else if ( auto summaryCase = std::get_if( &dataSource ) ) { diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp index fbea61f87b..f657e90da0 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp @@ -32,6 +32,7 @@ #include "RimSummaryAddress.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsembleTools.h" #include "RiuContextMenuLauncher.h" #include "RiuPlotMainWindowTools.h" @@ -465,7 +466,7 @@ std::set RimAbstractCorrelationPlot::ensembleParameters() for ( RimSummaryCaseCollection* ensemble : analyserOfSelectedCurveDefs->m_ensembles ) { - std::vector parameters = ensemble->alphabeticEnsembleParameters(); + std::vector parameters = RimSummaryEnsembleTools::alphabeticEnsembleParameters( ensemble->allSummaryCases() ); ensembleParms.insert( parameters.begin(), parameters.end() ); } return ensembleParms; diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp index 6408faac80..9f31a77c5a 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp @@ -26,6 +26,7 @@ #include "RimParameterResultCrossPlot.h" #include "RimProject.h" #include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsembleTools.h" CAF_PDM_SOURCE_INIT( RimCorrelationPlotCollection, "CorrelationPlotCollection" ); @@ -247,7 +248,8 @@ void RimCorrelationPlotCollection::applyFirstEnsembleFieldAddressesToPlot( RimAb auto crossPlot = dynamic_cast( plot ); if ( crossPlot ) { - crossPlot->setEnsembleParameter( ensembles.front()->alphabeticEnsembleParameters().front().name ); + crossPlot->setEnsembleParameter( + RimSummaryEnsembleTools::alphabeticEnsembleParameters( ensembles.front()->allSummaryCases() ).front().name ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 992c75894c..1943183b6a 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -19,9 +19,6 @@ #include "RimWellPlotTools.h" #include "RiaQDateTimeTools.h" -#include "RiaWellNameComparer.h" - -#include "RifReaderEclipseRft.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" @@ -37,6 +34,7 @@ #include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsembleTools.h" #include "RimWellLogChannel.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogLasFile.h" @@ -47,17 +45,42 @@ #include +namespace RimWellPlotTools +{ + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::set RimWellPlotTools::PRESSURE_DATA_NAMES = { "PRESSURE", "PRES_FORM" }; +const std::set PRESSURE_DATA_NAMES = { "PRESSURE", "PRES_FORM" }; -const std::set RimWellPlotTools::OIL_CHANNEL_NAMES = { "QOZT", "QOIL", "^.*\\D_QOIL" }; -const std::set RimWellPlotTools::GAS_CHANNEL_NAMES = { "QGZT", "QGAS", "^.*\\D_QGAS" }; -const std::set RimWellPlotTools::WATER_CHANNEL_NAMES = { "QWZT", "QWAT", "^.*\\D_QWAT" }; -const std::set RimWellPlotTools::TOTAL_CHANNEL_NAMES = { "QTZT", "QTOT", "^.*\\D_QTOT" }; +const std::set OIL_CHANNEL_NAMES = { "QOZT", "QOIL", "^.*\\D_QOIL" }; +const std::set GAS_CHANNEL_NAMES = { "QGZT", "QGAS", "^.*\\D_QGAS" }; +const std::set WATER_CHANNEL_NAMES = { "QWZT", "QWAT", "^.*\\D_QWAT" }; +const std::set TOTAL_CHANNEL_NAMES = { "QTZT", "QTOT", "^.*\\D_QTOT" }; -std::set RimWellPlotTools::FLOW_DATA_NAMES = {}; +std::set FLOW_DATA_NAMES = {}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool tryMatchChannelName( const std::set& channelNames, const QString& channelNameToMatch ) +{ + auto itr = std::find_if( channelNames.begin(), + channelNames.end(), + [&]( const QString& channelName ) + { + if ( channelName.startsWith( '^' ) ) + { + std::regex pattern( channelName.toStdString() ); + return std::regex_match( channelNameToMatch.toStdString(), pattern ); + } + else + { + return (bool)channelName.contains( channelNameToMatch, Qt::CaseInsensitive ); + } + } ); + return itr != channelNames.end(); +} //-------------------------------------------------------------------------------------------------- /// @@ -68,17 +91,29 @@ class StaticFieldsInitializer StaticFieldsInitializer() { // Init static list - RimWellPlotTools::FLOW_DATA_NAMES.insert( RimWellPlotTools::OIL_CHANNEL_NAMES.begin(), RimWellPlotTools::OIL_CHANNEL_NAMES.end() ); - RimWellPlotTools::FLOW_DATA_NAMES.insert( RimWellPlotTools::GAS_CHANNEL_NAMES.begin(), RimWellPlotTools::GAS_CHANNEL_NAMES.end() ); - RimWellPlotTools::FLOW_DATA_NAMES.insert( RimWellPlotTools::WATER_CHANNEL_NAMES.begin(), RimWellPlotTools::WATER_CHANNEL_NAMES.end() ); - RimWellPlotTools::FLOW_DATA_NAMES.insert( RimWellPlotTools::TOTAL_CHANNEL_NAMES.begin(), RimWellPlotTools::TOTAL_CHANNEL_NAMES.end() ); + FLOW_DATA_NAMES.insert( OIL_CHANNEL_NAMES.begin(), OIL_CHANNEL_NAMES.end() ); + FLOW_DATA_NAMES.insert( GAS_CHANNEL_NAMES.begin(), GAS_CHANNEL_NAMES.end() ); + FLOW_DATA_NAMES.insert( WATER_CHANNEL_NAMES.begin(), WATER_CHANNEL_NAMES.end() ); + FLOW_DATA_NAMES.insert( TOTAL_CHANNEL_NAMES.begin(), TOTAL_CHANNEL_NAMES.end() ); } } staticFieldsInitializer; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::hasPressureData( const RimWellLogFile* wellLogFile ) +bool isPressureChannel( RimWellLogChannel* channel ) +{ + for ( const auto& pressureDataName : PRESSURE_DATA_NAMES ) + { + if ( QString::compare( channel->name(), pressureDataName, Qt::CaseInsensitive ) == 0 ) return true; + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool hasPressureData( const RimWellLogFile* wellLogFile ) { for ( RimWellLogChannel* const wellLogChannel : wellLogFile->wellLogChannels() ) { @@ -90,7 +125,7 @@ bool RimWellPlotTools::hasPressureData( const RimWellLogFile* wellLogFile ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::hasPressureData( RimWellPath* wellPath ) +bool hasPressureData( RimWellPath* wellPath ) { for ( RimWellLogFile* const wellLogFile : wellPath->wellLogFiles() ) { @@ -105,7 +140,7 @@ bool RimWellPlotTools::hasPressureData( RimWellPath* wellPath ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair RimWellPlotTools::pressureResultDataInfo( const RigEclipseCaseData* eclipseCaseData ) +std::pair pressureResultDataInfo( const RigEclipseCaseData* eclipseCaseData ) { if ( eclipseCaseData != nullptr ) { @@ -125,26 +160,23 @@ std::pair RimWellPlotTools::pressureResultData //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::isPressureChannel( RimWellLogChannel* channel ) +bool hasPressureData( RimEclipseResultCase* gridCase ) { - for ( const auto& pressureDataName : PRESSURE_DATA_NAMES ) - { - if ( QString::compare( channel->name(), pressureDataName, Qt::CaseInsensitive ) == 0 ) return true; - } - return false; + return pressureResultDataInfo( gridCase->eclipseCaseData() ).first.isValid(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::hasPressureData( RimEclipseResultCase* gridCase ) +bool isFlowChannel( RimWellLogChannel* channel ) { - return pressureResultDataInfo( gridCase->eclipseCaseData() ).first.isValid(); + return tryMatchChannelName( FLOW_DATA_NAMES, channel->name() ); } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::hasFlowData( const RimWellLog* wellLog ) +bool hasFlowData( const RimWellLog* wellLog ) { for ( RimWellLogChannel* const wellLogChannel : wellLog->wellLogChannels() ) { @@ -156,7 +188,7 @@ bool RimWellPlotTools::hasFlowData( const RimWellLog* wellLog ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::hasFlowData( const RimWellPath* wellPath ) +bool hasFlowData( const RimWellPath* wellPath ) { for ( RimWellLogFile* const wellLogFile : wellPath->wellLogFiles() ) { @@ -171,7 +203,7 @@ bool RimWellPlotTools::hasFlowData( const RimWellPath* wellPath ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::hasAssociatedWellPath( const QString& wellName ) +bool hasAssociatedWellPath( const QString& wellName ) { RimProject* proj = RimProject::current(); RimWellPath* wellPath = proj->wellPathByName( wellName ); @@ -182,15 +214,7 @@ bool RimWellPlotTools::hasAssociatedWellPath( const QString& wellName ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::isFlowChannel( RimWellLogChannel* channel ) -{ - return tryMatchChannelName( FLOW_DATA_NAMES, channel->name() ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::isOilFlowChannel( const QString& channelName ) +bool isOilFlowChannel( const QString& channelName ) { return tryMatchChannelName( OIL_CHANNEL_NAMES, channelName ); } @@ -198,7 +222,7 @@ bool RimWellPlotTools::isOilFlowChannel( const QString& channelName ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::isGasFlowChannel( const QString& channelName ) +bool isGasFlowChannel( const QString& channelName ) { return tryMatchChannelName( GAS_CHANNEL_NAMES, channelName ); } @@ -206,7 +230,7 @@ bool RimWellPlotTools::isGasFlowChannel( const QString& channelName ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::isWaterFlowChannel( const QString& channelName ) +bool isWaterFlowChannel( const QString& channelName ) { return tryMatchChannelName( WATER_CHANNEL_NAMES, channelName ); } @@ -214,7 +238,7 @@ bool RimWellPlotTools::isWaterFlowChannel( const QString& channelName ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::isTotalFlowChannel( const QString& channelName ) +bool isTotalFlowChannel( const QString& channelName ) { return tryMatchChannelName( TOTAL_CHANNEL_NAMES, channelName ); } @@ -222,7 +246,7 @@ bool RimWellPlotTools::isTotalFlowChannel( const QString& channelName ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::hasFlowData( RimEclipseResultCase* gridCase ) +bool hasFlowData( RimEclipseResultCase* gridCase ) { const RigEclipseCaseData* const eclipseCaseData = gridCase->eclipseCaseData(); @@ -240,20 +264,20 @@ bool RimWellPlotTools::hasFlowData( RimEclipseResultCase* gridCase ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -FlowPhase RimWellPlotTools::flowPhaseFromChannelName( const QString& channelName ) +FlowPhase flowPhaseFromChannelName( const QString& channelName ) { - if ( tryMatchChannelName( OIL_CHANNEL_NAMES, channelName ) ) return FLOW_PHASE_OIL; - if ( tryMatchChannelName( GAS_CHANNEL_NAMES, channelName ) ) return FLOW_PHASE_GAS; - if ( tryMatchChannelName( WATER_CHANNEL_NAMES, channelName ) ) return FLOW_PHASE_WATER; - if ( tryMatchChannelName( TOTAL_CHANNEL_NAMES, channelName ) ) return FLOW_PHASE_TOTAL; - return FLOW_PHASE_NONE; + if ( tryMatchChannelName( OIL_CHANNEL_NAMES, channelName ) ) return FlowPhase::FLOW_PHASE_OIL; + if ( tryMatchChannelName( GAS_CHANNEL_NAMES, channelName ) ) return FlowPhase::FLOW_PHASE_GAS; + if ( tryMatchChannelName( WATER_CHANNEL_NAMES, channelName ) ) return FlowPhase::FLOW_PHASE_WATER; + if ( tryMatchChannelName( TOTAL_CHANNEL_NAMES, channelName ) ) return FlowPhase::FLOW_PHASE_TOTAL; + return FlowPhase::FLOW_PHASE_NONE; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPlotTools::addTimeStepsToMap( std::map>& destMap, - const std::map>& timeStepsToAdd ) +void addTimeStepsToMap( std::map>& destMap, + const std::map>& timeStepsToAdd ) { for ( const auto& timeStepPair : timeStepsToAdd ) { @@ -268,7 +292,7 @@ void RimWellPlotTools::addTimeStepsToMap( std::map RimWellPlotTools::wellLogFilesContainingPressure( const QString& wellPathNameOrSimWellName ) +std::vector wellLogFilesContainingPressure( const QString& wellPathNameOrSimWellName ) { std::vector wellLogFiles; const RimProject* const project = RimProject::current(); @@ -297,7 +321,7 @@ std::vector RimWellPlotTools::wellLogFilesContainingPressure( c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellLogChannel* RimWellPlotTools::getPressureChannelFromWellFile( const RimWellLogFile* wellLogFile ) +RimWellLogChannel* getPressureChannelFromWellFile( const RimWellLogFile* wellLogFile ) { if ( wellLogFile != nullptr ) { @@ -315,7 +339,7 @@ RimWellLogChannel* RimWellPlotTools::getPressureChannelFromWellFile( const RimWe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPlotTools::wellLogFilesContainingFlow( const QString& wellPathName ) +std::vector wellLogFilesContainingFlow( const QString& wellPathName ) { std::vector wellLogFiles; const RimProject* const project = RimProject::current(); @@ -342,7 +366,7 @@ std::vector RimWellPlotTools::wellLogFilesContainingFlow( const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellPath* RimWellPlotTools::wellPathFromWellLogFile( const RimWellLogFile* wellLogFile ) +RimWellPath* wellPathFromWellLogFile( const RimWellLogFile* wellLogFile ) { RimProject* const project = RimProject::current(); for ( const auto& oilField : project->oilFields ) @@ -365,7 +389,7 @@ RimWellPath* RimWellPlotTools::wellPathFromWellLogFile( const RimWellLogFile* we //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPlotTools::gridCasesForWell( const QString& simWellName ) +std::vector gridCasesForWell( const QString& simWellName ) { std::vector cases; const RimProject* project = RimProject::current(); @@ -387,7 +411,7 @@ std::vector RimWellPlotTools::gridCasesForWell( const QSt //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPlotTools::rftCasesForWell( const QString& simWellName ) +std::vector rftCasesForWell( const QString& simWellName ) { std::vector cases; const RimProject* project = RimProject::current(); @@ -407,7 +431,25 @@ std::vector RimWellPlotTools::rftCasesForWell( const QStr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPlotTools::rftEnsemblesForWell( const QString& simWellName ) +std::set rftTimeStepsForWell( const std::vector& summaryCases, const QString& wellName ) +{ + std::set allTimeSteps; + for ( RimSummaryCase* summaryCase : summaryCases ) + { + RifReaderRftInterface* reader = summaryCase->rftReader(); + if ( reader ) + { + std::set timeStep = reader->availableTimeSteps( wellName ); + allTimeSteps.insert( timeStep.begin(), timeStep.end() ); + } + } + return allTimeSteps; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector rftEnsemblesForWell( const QString& simWellName ) { const RimProject* project = RimProject::current(); @@ -417,7 +459,8 @@ std::vector RimWellPlotTools::rftEnsemblesForWell( co for ( RimSummaryCaseCollection* summaryCaseColl : allSummaryCaseCollections ) { - if ( summaryCaseColl && summaryCaseColl->isEnsemble() && !summaryCaseColl->rftTimeStepsForWell( simWellName ).empty() ) + if ( summaryCaseColl && summaryCaseColl->isEnsemble() && + !rftTimeStepsForWell( summaryCaseColl->allSummaryCases(), simWellName ).empty() ) { rftEnsembles.push_back( summaryCaseColl ); } @@ -428,7 +471,7 @@ std::vector RimWellPlotTools::rftEnsemblesForWell( co //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPlotTools::rftEnsembles() +std::vector rftEnsembles() { const RimProject* project = RimProject::current(); @@ -438,7 +481,8 @@ std::vector RimWellPlotTools::rftEnsembles() for ( RimSummaryCaseCollection* summaryCaseColl : allSummaryCaseCollections ) { - if ( summaryCaseColl && summaryCaseColl->isEnsemble() && !summaryCaseColl->wellsWithRftData().empty() ) + if ( summaryCaseColl && summaryCaseColl->isEnsemble() && + !RimSummaryEnsembleTools::wellsWithRftData( summaryCaseColl->allSummaryCases() ).empty() ) { rftEnsembles.push_back( summaryCaseColl ); } @@ -449,7 +493,7 @@ std::vector RimWellPlotTools::rftEnsembles() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPlotTools::observedFmuRftDataForWell( const QString& simWellName ) +std::vector observedFmuRftDataForWell( const QString& simWellName ) { std::vector observedDataForWell; std::vector allObservedData = observedFmuRftData(); @@ -466,7 +510,7 @@ std::vector RimWellPlotTools::observedFmuRftDataForWell( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPlotTools::observedFmuRftData() +std::vector observedFmuRftData() { const RimProject* project = RimProject::current(); RimObservedDataCollection* observedDataCollection = project->activeOilField() ? project->activeOilField()->observedDataCollection() @@ -482,7 +526,7 @@ std::vector RimWellPlotTools::observedFmuRftData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPlotTools::pressureDepthDataForWell( const QString& simWellName ) +std::vector pressureDepthDataForWell( const QString& simWellName ) { std::vector observedDataForWell; std::vector allObservedData = pressureDepthData(); @@ -499,7 +543,7 @@ std::vector RimWellPlotTools::pressureDepthDataForWell( c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPlotTools::pressureDepthData() +std::vector pressureDepthData() { const RimProject* project = RimProject::current(); RimObservedDataCollection* observedDataCollection = project->activeOilField() ? project->activeOilField()->observedDataCollection() @@ -515,7 +559,7 @@ std::vector RimWellPlotTools::pressureDepthData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::map> RimWellPlotTools::timeStepsMapFromGridCase( RimEclipseCase* gridCase ) +std::map> timeStepsMapFromGridCase( RimEclipseCase* gridCase ) { const RigEclipseCaseData* const eclipseCaseData = gridCase->eclipseCaseData(); std::pair resultDataInfo = pressureResultDataInfo( eclipseCaseData ); @@ -539,8 +583,7 @@ std::map> RimWellPlotTools::timeStep //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimWellPlotTools::findMatchingOrAdjacentTimeSteps( const std::set& baseTimeLine, - const std::set& availableTimeSteps ) +std::set findMatchingOrAdjacentTimeSteps( const std::set& baseTimeLine, const std::set& availableTimeSteps ) { std::set resultTimeSteps; for ( const QDateTime& baseTimeStep : baseTimeLine ) @@ -572,7 +615,7 @@ std::set RimWellPlotTools::findMatchingOrAdjacentTimeSteps( const std //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimWellPlotTools::availableSimWellTimesteps( RimEclipseCase* eclCase, const QString& simWellName, bool addFirstReportTimestep ) +std::set availableSimWellTimesteps( RimEclipseCase* eclCase, const QString& simWellName, bool addFirstReportTimestep ) { if ( !eclCase || !eclCase->eclipseCaseData() ) return {}; @@ -600,7 +643,7 @@ std::set RimWellPlotTools::availableSimWellTimesteps( RimEclipseCase* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifReaderRftInterface* RimWellPlotTools::rftReaderInterface( RimEclipseCase* eclipseCase ) +RifReaderRftInterface* rftReaderInterface( RimEclipseCase* eclipseCase ) { auto eclResCase = dynamic_cast( eclipseCase ); @@ -612,7 +655,7 @@ RifReaderRftInterface* RimWellPlotTools::rftReaderInterface( RimEclipseCase* ecl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve( const RimWellLogCurve* curve ) +RiaRftPltCurveDefinition curveDefFromCurve( const RimWellLogCurve* curve ) { const RimWellLogRftCurve* rftCurve = dynamic_cast( curve ); const RimWellLogExtractionCurve* gridCurve = dynamic_cast( curve ); @@ -696,7 +739,7 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve( const RimWellLogCu //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellPath* RimWellPlotTools::wellPathByWellPathNameOrSimWellName( const QString& wellPathNameOrSimwellName ) +RimWellPath* wellPathByWellPathNameOrSimWellName( const QString& wellPathNameOrSimwellName ) { RimProject* proj = RimProject::current(); RimWellPath* wellPath = proj->wellPathByName( wellPathNameOrSimwellName ); @@ -707,12 +750,12 @@ RimWellPath* RimWellPlotTools::wellPathByWellPathNameOrSimWellName( const QStrin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPlotTools::wellPathsContainingFlow() +std::vector wellPathsContainingFlow() { std::vector wellPaths; for ( RimWellPath* wellPath : RimProject::current()->allWellPaths() ) { - if ( wellPath->wellPathGeometry() || RimWellPlotTools::hasFlowData( wellPath ) ) wellPaths.push_back( wellPath ); + if ( wellPath->wellPathGeometry() || hasFlowData( wellPath ) ) wellPaths.push_back( wellPath ); } return wellPaths; @@ -721,7 +764,7 @@ std::vector RimWellPlotTools::wellPathsContainingFlow() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellPlotTools::simWellName( const QString& wellPathNameOrSimWellName ) +QString simWellName( const QString& wellPathNameOrSimWellName ) { RimWellPath* wellPath = wellPathByWellPathNameOrSimWellName( wellPathNameOrSimWellName ); return wellPath != nullptr ? wellPath->associatedSimulationWellName() : wellPathNameOrSimWellName; @@ -730,34 +773,11 @@ QString RimWellPlotTools::simWellName( const QString& wellPathNameOrSimWellName //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellPlotTools::tryMatchChannelName( const std::set& channelNames, const QString& channelNameToMatch ) -{ - auto itr = std::find_if( channelNames.begin(), - channelNames.end(), - [&]( const QString& channelName ) - { - if ( channelName.startsWith( '^' ) ) - { - std::regex pattern( channelName.toStdString() ); - return std::regex_match( channelNameToMatch.toStdString(), pattern ); - } - else - { - return (bool)channelName.contains( channelNameToMatch, Qt::CaseInsensitive ); - } - } ); - return itr != channelNames.end(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::set - RimWellPlotTools::curveDefsFromTimesteps( const QString& wellPathNameOrSimWellName, - const std::vector& selectedTimeSteps, - bool firstSimWellTimeStepIsValid, - const std::vector& selectedSourcesExpanded, - const std::set& interestingRFTResults ) +std::set curveDefsFromTimesteps( const QString& wellPathNameOrSimWellName, + const std::vector& selectedTimeSteps, + bool firstSimWellTimeStepIsValid, + const std::vector& selectedSourcesExpanded, + const std::set& interestingRFTResults ) { std::set curveDefs; @@ -781,8 +801,7 @@ std::set } else if ( addr.sourceType() == RifDataSourceForRftPlt::SourceType::GRID_MODEL_CELL_DATA && addr.eclCase() ) { - std::set timeSteps = - RimWellPlotTools::availableSimWellTimesteps( addr.eclCase(), simWellName, firstSimWellTimeStepIsValid ); + std::set timeSteps = availableSimWellTimesteps( addr.eclCase(), simWellName, firstSimWellTimeStepIsValid ); for ( const QDateTime& time : timeSteps ) { @@ -852,7 +871,7 @@ std::set // Add statistics curves if ( addr.sourceType() == RifDataSourceForRftPlt::SourceType::ENSEMBLE_RFT ) { - std::set statTimeSteps = addr.ensemble()->rftTimeStepsForWell( wellPathNameOrSimWellName ); + std::set statTimeSteps = rftTimeStepsForWell( addr.ensemble()->allSummaryCases(), wellPathNameOrSimWellName ); for ( const QDateTime& time : statTimeSteps ) { if ( selectedTimeStepSet.count( time ) ) @@ -885,19 +904,19 @@ std::set //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellPlotTools::flowPlotAxisTitle( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ) +QString flowPlotAxisTitle( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ) { QString axisTitle; if ( condition == RimWellLogLasFile::WELL_FLOW_COND_RESERVOIR ) { - QString unitText = RimWellPlotTools::flowUnitText( condition, unitSystem ); + QString unitText = flowUnitText( condition, unitSystem ); axisTitle = "Reservoir Flow Rate " + unitText; } else { - QString unitText = RimWellPlotTools::flowUnitText( condition, unitSystem ); + QString unitText = flowUnitText( condition, unitSystem ); axisTitle = "Surface Flow Rate " + unitText; } @@ -933,7 +952,7 @@ QString flowConditionReservoirUnitText( RiaDefines::EclipseUnitSystem unitSystem //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellPlotTools::flowUnitText( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ) +QString flowUnitText( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ) { QString unitText; @@ -965,19 +984,19 @@ QString RimWellPlotTools::flowUnitText( RimWellLogLasFile::WellFlowCondition con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellPlotTools::flowVolumePlotAxisTitle( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ) +QString flowVolumePlotAxisTitle( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ) { QString axisTitle; if ( condition == RimWellLogLasFile::WELL_FLOW_COND_RESERVOIR ) { - QString unitText = RimWellPlotTools::flowVolumeUnitText( condition, unitSystem ); + QString unitText = flowVolumeUnitText( condition, unitSystem ); axisTitle = "Reservoir Flow Volume " + unitText; } else { - QString unitText = RimWellPlotTools::flowVolumeUnitText( condition, unitSystem ); + QString unitText = flowVolumeUnitText( condition, unitSystem ); axisTitle = "Surface Flow Volume " + unitText; } @@ -1013,7 +1032,7 @@ QString flowVolumeConditionReservoirUnitText( RiaDefines::EclipseUnitSystem unit //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellPlotTools::flowVolumeUnitText( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ) +QString flowVolumeUnitText( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ) { QString unitText; @@ -1045,9 +1064,7 @@ QString RimWellPlotTools::flowVolumeUnitText( RimWellLogLasFile::WellFlowConditi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellPlotTools::curveUnitText( RimWellLogLasFile::WellFlowCondition condition, - RiaDefines::EclipseUnitSystem unitSystem, - FlowPhase flowPhase ) +QString curveUnitText( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem, FlowPhase flowPhase ) { QString unitText; @@ -1062,11 +1079,11 @@ QString RimWellPlotTools::curveUnitText( RimWellLogLasFile::WellFlowCondition co case RiaDefines::EclipseUnitSystem::UNITS_METRIC: switch ( flowPhase ) { - case FLOW_PHASE_GAS: + case FlowPhase::FLOW_PHASE_GAS: unitText = "[kSm3/day]"; break; - case FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit - case FLOW_PHASE_OIL: + case FlowPhase::FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit + case FlowPhase::FLOW_PHASE_OIL: unitText = "[Sm3/day]"; break; default: @@ -1078,11 +1095,11 @@ QString RimWellPlotTools::curveUnitText( RimWellLogLasFile::WellFlowCondition co case RiaDefines::EclipseUnitSystem::UNITS_FIELD: switch ( flowPhase ) { - case FLOW_PHASE_GAS: + case FlowPhase::FLOW_PHASE_GAS: unitText = "[BOE/day]"; break; - case FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit - case FLOW_PHASE_OIL: + case FlowPhase::FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit + case FlowPhase::FLOW_PHASE_OIL: unitText = "[BBL/day]"; break; default: @@ -1105,9 +1122,9 @@ QString RimWellPlotTools::curveUnitText( RimWellLogLasFile::WellFlowCondition co /// //-------------------------------------------------------------------------------------------------- std::map> - RimWellPlotTools::calculateRelevantTimeStepsFromCases( const QString& wellPathNameOrSimWellName, - const std::vector& selSources, - const std::set& interestingRFTResults ) + calculateRelevantTimeStepsFromCases( const QString& wellPathNameOrSimWellName, + const std::vector& selSources, + const std::set& interestingRFTResults ) { bool addFirstTimestep = ( interestingRFTResults.count( RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ) == 1 ); @@ -1208,8 +1225,7 @@ std::map> { if ( source.sourceType() == RifDataSourceForRftPlt::SourceType::GRID_MODEL_CELL_DATA && source.eclCase() ) { - std::set wellTimeSteps = - RimWellPlotTools::availableSimWellTimesteps( source.eclCase(), simWellName, addFirstTimestep ); + std::set wellTimeSteps = availableSimWellTimesteps( source.eclCase(), simWellName, addFirstTimestep ); for ( const QDateTime& date : wellTimeSteps ) { @@ -1246,7 +1262,7 @@ std::map> { if ( source.sourceType() == RifDataSourceForRftPlt::SourceType::ENSEMBLE_RFT && source.ensemble() ) { - std::set wellTimeSteps = source.ensemble()->rftTimeStepsForWell( wellPathNameOrSimWellName ); + std::set wellTimeSteps = rftTimeStepsForWell( source.ensemble()->allSummaryCases(), wellPathNameOrSimWellName ); for ( const QDateTime& date : wellTimeSteps ) { @@ -1302,12 +1318,10 @@ std::map> for ( const auto& dateSourceSetPair : ensembleTimeStepsWithSources ) ensembleRftTimeSteps.insert( dateSourceSetPair.first ); - std::set filteredRftTimeSteps = RimWellPlotTools::findMatchingOrAdjacentTimeSteps( baseTimeSteps, rftTimeSteps ); - std::set filteredGridTimeSteps = RimWellPlotTools::findMatchingOrAdjacentTimeSteps( baseTimeSteps, gridTimeSteps ); - std::set filteredEnsembleRftTimeSteps = - RimWellPlotTools::findMatchingOrAdjacentTimeSteps( baseTimeSteps, ensembleRftTimeSteps ); - std::set filteredSummaryRftTimeSteps = - RimWellPlotTools::findMatchingOrAdjacentTimeSteps( baseTimeSteps, summaryRftTimeSteps ); + std::set filteredRftTimeSteps = findMatchingOrAdjacentTimeSteps( baseTimeSteps, rftTimeSteps ); + std::set filteredGridTimeSteps = findMatchingOrAdjacentTimeSteps( baseTimeSteps, gridTimeSteps ); + std::set filteredEnsembleRftTimeSteps = findMatchingOrAdjacentTimeSteps( baseTimeSteps, ensembleRftTimeSteps ); + std::set filteredSummaryRftTimeSteps = findMatchingOrAdjacentTimeSteps( baseTimeSteps, summaryRftTimeSteps ); if ( addFirstTimestep && !gridTimeSteps.empty() ) { @@ -1364,10 +1378,10 @@ std::map> //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPlotTools::calculateValueOptionsForTimeSteps( const QString& wellPathNameOrSimWellName, - const std::vector& selSources, - const std::set& interestingRFTResults, - QList& options ) +void calculateValueOptionsForTimeSteps( const QString& wellPathNameOrSimWellName, + const std::vector& selSources, + const std::set& interestingRFTResults, + QList& options ) { auto timestepsToShowWithSources = calculateRelevantTimeStepsFromCases( wellPathNameOrSimWellName, selSources, interestingRFTResults ); @@ -1424,3 +1438,5 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps( const QString& options.push_back( caf::PdmOptionItemInfo( optionText, timeStepPair.first ) ); } } + +} // namespace RimWellPlotTools diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h index ced86c8550..f6f4f8d9f7 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h @@ -21,13 +21,10 @@ #include "RiaDefines.h" #include "RiaRftPltCurveDefinition.h" -#include "RifDataSourceForRftPltQMetaType.h" #include "RifEclipseRftAddress.h" #include "RimWellLogLasFile.h" -#include - #include #include @@ -45,15 +42,15 @@ class RigEclipseCaseData; class RigEclipseResultAddress; class RifReaderRftInterface; -//================================================================================================== -/// -//================================================================================================== -enum FlowType +namespace RimWellPlotTools +{ + +enum class FlowType { FLOW_TYPE_PHASE_SPLIT, FLOW_TYPE_TOTAL }; -enum FlowPhase +enum class FlowPhase { FLOW_PHASE_NONE, FLOW_PHASE_OIL, @@ -62,100 +59,61 @@ enum FlowPhase FLOW_PHASE_TOTAL }; -//================================================================================================== -/// -//================================================================================================== -class RimWellPlotTools -{ -public: - // PLT Only - static bool isOilFlowChannel( const QString& channelName ); - static bool isGasFlowChannel( const QString& channelName ); - static bool isWaterFlowChannel( const QString& channelName ); - static bool isTotalFlowChannel( const QString& channelName ); - static FlowPhase flowPhaseFromChannelName( const QString& channelName ); - - static std::vector wellLogFilesContainingFlow( const QString& wellName ); - static RimWellPath* wellPathByWellPathNameOrSimWellName( const QString& wellPathNameOrSimwellName ); - static std::vector wellPathsContainingFlow(); - - // RFT Only -private: - static std::pair pressureResultDataInfo( const RigEclipseCaseData* eclipseCaseData ); - -public: - static void addTimeStepsToMap( std::map>& destMap, - const std::map>& timeStepsToAdd ); - static std::vector wellLogFilesContainingPressure( const QString& wellPathNameOrSimWellName ); - static RimWellLogChannel* getPressureChannelFromWellFile( const RimWellLogFile* wellLogFile ); - static RimWellPath* wellPathFromWellLogFile( const RimWellLogFile* wellLogFile ); - static std::map> timeStepsMapFromGridCase( RimEclipseCase* gridCase ); - static RiaRftPltCurveDefinition curveDefFromCurve( const RimWellLogCurve* curve ); - - // others - static bool hasFlowData( const RimWellLog* wellLog ); - static bool hasAssociatedWellPath( const QString& wellName ); - - // Both - static std::vector gridCasesForWell( const QString& simWellName ); - static std::vector rftCasesForWell( const QString& simWellName ); - static std::vector rftEnsemblesForWell( const QString& simWellName ); - static std::vector rftEnsembles(); - static std::vector observedFmuRftDataForWell( const QString& simWellName ); - static std::vector observedFmuRftData(); - static QString simWellName( const QString& wellPathNameOrSimWellName ); - - static std::map> - calculateRelevantTimeStepsFromCases( const QString& wellPathNameOrSimWellName, - const std::vector& selSources, - const std::set& interestingRFTResults ); - - static void calculateValueOptionsForTimeSteps( const QString& wellPathNameOrSimWellName, - const std::vector& selSources, - const std::set& interestingRFTResults, - QList& options ); - - static std::set - curveDefsFromTimesteps( const QString& wellPathNameOrSimWellName, - const std::vector& selectedTimeStepVector, - bool firstReportTimeStepIsValid, - const std::vector& selectedSourcesExpanded, - const std::set& interestingRFTResults ); - - static QString flowPlotAxisTitle( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ); - static QString flowUnitText( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ); - static QString flowVolumePlotAxisTitle( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ); - static QString flowVolumeUnitText( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ); - - static QString - curveUnitText( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem, FlowPhase flowPhase ); - - static bool hasFlowData( const RimWellPath* wellPath ); - - static std::vector pressureDepthData(); - static std::vector pressureDepthDataForWell( const QString& simWellName ); - -private: - friend class StaticFieldsInitializer; - static const std::set PRESSURE_DATA_NAMES; - - static const std::set OIL_CHANNEL_NAMES; - static const std::set GAS_CHANNEL_NAMES; - static const std::set WATER_CHANNEL_NAMES; - static const std::set TOTAL_CHANNEL_NAMES; - - static std::set FLOW_DATA_NAMES; - - static bool hasPressureData( const RimWellLogFile* wellLogFile ); - static bool isPressureChannel( RimWellLogChannel* channel ); - static bool hasPressureData( RimEclipseResultCase* gridCase ); - static bool hasPressureData( RimWellPath* wellPath ); - static bool hasFlowData( RimEclipseResultCase* gridCase ); - static bool isFlowChannel( RimWellLogChannel* channel ); - static bool tryMatchChannelName( const std::set& channelNames, const QString& channelNameToMatch ); - static std::set findMatchingOrAdjacentTimeSteps( const std::set& baseTimeLine, - const std::set& availableTimeSteps ); - static std::set availableSimWellTimesteps( RimEclipseCase* eclCase, const QString& simWellName, bool addFirstReportTimeStep ); - - static RifReaderRftInterface* rftReaderInterface( RimEclipseCase* eclipseCase ); -}; +bool isOilFlowChannel( const QString& channelName ); +bool isGasFlowChannel( const QString& channelName ); +bool isWaterFlowChannel( const QString& channelName ); +bool isTotalFlowChannel( const QString& channelName ); +FlowPhase flowPhaseFromChannelName( const QString& channelName ); + +std::vector wellLogFilesContainingFlow( const QString& wellName ); +RimWellPath* wellPathByWellPathNameOrSimWellName( const QString& wellPathNameOrSimwellName ); +std::vector wellPathsContainingFlow(); + +void addTimeStepsToMap( std::map>& destMap, + const std::map>& timeStepsToAdd ); +std::vector wellLogFilesContainingPressure( const QString& wellPathNameOrSimWellName ); +RimWellLogChannel* getPressureChannelFromWellFile( const RimWellLogFile* wellLogFile ); +RimWellPath* wellPathFromWellLogFile( const RimWellLogFile* wellLogFile ); +std::map> timeStepsMapFromGridCase( RimEclipseCase* gridCase ); +RiaRftPltCurveDefinition curveDefFromCurve( const RimWellLogCurve* curve ); + +bool hasFlowData( const RimWellLog* wellLog ); +bool hasAssociatedWellPath( const QString& wellName ); + +std::vector gridCasesForWell( const QString& simWellName ); +std::vector rftCasesForWell( const QString& simWellName ); +std::vector rftEnsemblesForWell( const QString& simWellName ); +std::vector rftEnsembles(); +std::vector observedFmuRftDataForWell( const QString& simWellName ); +std::vector observedFmuRftData(); +QString simWellName( const QString& wellPathNameOrSimWellName ); + +std::map> + calculateRelevantTimeStepsFromCases( const QString& wellPathNameOrSimWellName, + const std::vector& selSources, + const std::set& interestingRFTResults ); + +void calculateValueOptionsForTimeSteps( const QString& wellPathNameOrSimWellName, + const std::vector& selSources, + const std::set& interestingRFTResults, + QList& options ); + +std::set curveDefsFromTimesteps( const QString& wellPathNameOrSimWellName, + const std::vector& selectedTimeStepVector, + bool firstReportTimeStepIsValid, + const std::vector& selectedSourcesExpanded, + const std::set& interestingRFTResults ); + +QString flowPlotAxisTitle( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ); +QString flowUnitText( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ); +QString flowVolumePlotAxisTitle( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ); +QString flowVolumeUnitText( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem ); + +QString curveUnitText( RimWellLogLasFile::WellFlowCondition condition, RiaDefines::EclipseUnitSystem unitSystem, FlowPhase flowPhase ); + +bool hasFlowData( const RimWellPath* wellPath ); + +std::vector pressureDepthData(); +std::vector pressureDepthDataForWell( const QString& simWellName ); + +}; // namespace RimWellPlotTools diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index e7588ff0db..81aba6b70e 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -74,20 +74,20 @@ CAF_PDM_SOURCE_INIT( RimWellPltPlot, "WellPltPlot" ); namespace caf { template <> -void caf::AppEnum::setUp() +void caf::AppEnum::setUp() { - addItem( FLOW_TYPE_PHASE_SPLIT, "PHASE_SPLIT", "Phase Split" ); - addItem( FLOW_TYPE_TOTAL, "TOTAL", "Total Flow" ); - setDefault( FLOW_TYPE_PHASE_SPLIT ); + addItem( RimWellPlotTools::FlowType::FLOW_TYPE_PHASE_SPLIT, "PHASE_SPLIT", "Phase Split" ); + addItem( RimWellPlotTools::FlowType::FLOW_TYPE_TOTAL, "TOTAL", "Total Flow" ); + setDefault( RimWellPlotTools::FlowType::FLOW_TYPE_PHASE_SPLIT ); } template <> -void caf::AppEnum::setUp() +void caf::AppEnum::setUp() { - addItem( FLOW_PHASE_OIL, "PHASE_OIL", "Oil" ); - addItem( FLOW_PHASE_GAS, "PHASE_GAS", "Gas" ); - addItem( FLOW_PHASE_WATER, "PHASE_WATER", "Water" ); - addItem( FLOW_PHASE_TOTAL, "PHASE_TOTAL", "Total" ); + addItem( RimWellPlotTools::FlowPhase::FLOW_PHASE_OIL, "PHASE_OIL", "Oil" ); + addItem( RimWellPlotTools::FlowPhase::FLOW_PHASE_GAS, "PHASE_GAS", "Gas" ); + addItem( RimWellPlotTools::FlowPhase::FLOW_PHASE_WATER, "PHASE_WATER", "Water" ); + addItem( RimWellPlotTools::FlowPhase::FLOW_PHASE_TOTAL, "PHASE_TOTAL", "Total" ); } } // namespace caf @@ -127,7 +127,9 @@ RimWellPltPlot::RimWellPltPlot() CAF_PDM_InitFieldNoDefault( &m_phases, "Phases", "Phases" ); m_phases.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - m_phases = std::vector>( { FLOW_PHASE_OIL, FLOW_PHASE_GAS, FLOW_PHASE_WATER } ); + m_phases = std::vector>( { RimWellPlotTools::FlowPhase::FLOW_PHASE_OIL, + RimWellPlotTools::FlowPhase::FLOW_PHASE_GAS, + RimWellPlotTools::FlowPhase::FLOW_PHASE_WATER } ); m_phases.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_nameConfig->setCustomName( "PLT Plot" ); @@ -484,7 +486,7 @@ void RimWellPltPlot::syncCurvesFromUiSelection() // Add curves for ( const RiaRftPltCurveDefinition& curveDefToAdd : curveDefs ) { - std::set selectedPhases = std::set( m_phases().begin(), m_phases().end() ); + std::set selectedPhases = std::set( m_phases().begin(), m_phases().end() ); RifDataSourceForRftPlt sourceDef = curveDefToAdd.address(); QDateTime timeStep = curveDefToAdd.timeStep(); @@ -522,7 +524,7 @@ void RimWellPltPlot::syncCurvesFromUiSelection() { if ( !resultPointCalc->pipeBranchCLCoords().empty() ) { - if ( selectedPhases.count( FLOW_PHASE_TOTAL ) && m_useReservoirConditionCurves() && + if ( selectedPhases.count( RimWellPlotTools::FlowPhase::FLOW_PHASE_TOTAL ) && m_useReservoirConditionCurves() && sourceDef.sourceType() == RifDataSourceForRftPlt::SourceType::GRID_MODEL_CELL_DATA ) { RigAccWellFlowCalculator wfTotalAccumulator( resultPointCalc->pipeBranchCLCoords(), @@ -561,17 +563,17 @@ void RimWellPltPlot::syncCurvesFromUiSelection() : tracerName == RIG_FLOW_WATER_NAME ? cvf::Color3f::BLUE : cvf::Color3f::DARK_GRAY; - if ( ( tracerName == RIG_FLOW_OIL_NAME && selectedPhases.count( FLOW_PHASE_OIL ) ) || - ( tracerName == RIG_FLOW_GAS_NAME && selectedPhases.count( FLOW_PHASE_GAS ) ) || - ( tracerName == RIG_FLOW_WATER_NAME && selectedPhases.count( FLOW_PHASE_WATER ) ) ) + if ( ( tracerName == RIG_FLOW_OIL_NAME && selectedPhases.count( RimWellPlotTools::FlowPhase::FLOW_PHASE_OIL ) ) || + ( tracerName == RIG_FLOW_GAS_NAME && selectedPhases.count( RimWellPlotTools::FlowPhase::FLOW_PHASE_GAS ) ) || + ( tracerName == RIG_FLOW_WATER_NAME && selectedPhases.count( RimWellPlotTools::FlowPhase::FLOW_PHASE_WATER ) ) ) { - FlowPhase flowPhase = FLOW_PHASE_NONE; + RimWellPlotTools::FlowPhase flowPhase = RimWellPlotTools::FlowPhase::FLOW_PHASE_NONE; if ( tracerName == RIG_FLOW_OIL_NAME ) - flowPhase = FLOW_PHASE_OIL; + flowPhase = RimWellPlotTools::FlowPhase::FLOW_PHASE_OIL; else if ( tracerName == RIG_FLOW_GAS_NAME ) - flowPhase = FLOW_PHASE_GAS; + flowPhase = RimWellPlotTools::FlowPhase::FLOW_PHASE_GAS; else if ( tracerName == RIG_FLOW_WATER_NAME ) - flowPhase = FLOW_PHASE_WATER; + flowPhase = RimWellPlotTools::FlowPhase::FLOW_PHASE_WATER; QString curveUnitText = RimWellPlotTools::curveUnitText( RimWellLogLasFile::WELL_FLOW_COND_STANDARD, unitSet, flowPhase ); @@ -631,13 +633,13 @@ void RimWellPltPlot::syncCurvesFromUiSelection() : RimWellPlotTools::isWaterFlowChannel( channelName ) ? cvf::Color3f::BLUE : cvf::Color3f::DARK_GRAY; - FlowPhase flowPhase = FLOW_PHASE_NONE; + RimWellPlotTools::FlowPhase flowPhase = RimWellPlotTools::FlowPhase::FLOW_PHASE_NONE; if ( RimWellPlotTools::isOilFlowChannel( channelName ) ) - flowPhase = FLOW_PHASE_OIL; + flowPhase = RimWellPlotTools::FlowPhase::FLOW_PHASE_OIL; else if ( RimWellPlotTools::isGasFlowChannel( channelName ) ) - flowPhase = FLOW_PHASE_GAS; + flowPhase = RimWellPlotTools::FlowPhase::FLOW_PHASE_GAS; else if ( RimWellPlotTools::isWaterFlowChannel( channelName ) ) - flowPhase = FLOW_PHASE_WATER; + flowPhase = RimWellPlotTools::FlowPhase::FLOW_PHASE_WATER; QString curveUnitText = RimWellPlotTools::curveUnitText( flowCondition, unitSystem, flowPhase ); addStackedCurve( curveName + ", " + channelName + " " + curveUnitText, @@ -801,10 +803,10 @@ QList RimWellPltPlot::calculateValueOptions( const caf:: if ( fieldNeedingOptions == &m_phases ) { - options.push_back( caf::PdmOptionItemInfo( "Oil", FLOW_PHASE_OIL ) ); - options.push_back( caf::PdmOptionItemInfo( "Gas", FLOW_PHASE_GAS ) ); - options.push_back( caf::PdmOptionItemInfo( "Water", FLOW_PHASE_WATER ) ); - options.push_back( caf::PdmOptionItemInfo( "Total", FLOW_PHASE_TOTAL ) ); + options.push_back( caf::PdmOptionItemInfo( "Oil", RimWellPlotTools::FlowPhase::FLOW_PHASE_OIL ) ); + options.push_back( caf::PdmOptionItemInfo( "Gas", RimWellPlotTools::FlowPhase::FLOW_PHASE_GAS ) ); + options.push_back( caf::PdmOptionItemInfo( "Water", RimWellPlotTools::FlowPhase::FLOW_PHASE_WATER ) ); + options.push_back( caf::PdmOptionItemInfo( "Total", RimWellPlotTools::FlowPhase::FLOW_PHASE_TOTAL ) ); } return options; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h index 5764394a9e..251acabb58 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h @@ -118,9 +118,10 @@ class RimWellPltPlot : public RimWellLogPlot caf::PdmChildField m_wellLogPlot_OBSOLETE; - caf::PdmField m_useStandardConditionCurves; - caf::PdmField m_useReservoirConditionCurves; - caf::PdmField>> m_phases; + caf::PdmField m_useStandardConditionCurves; + caf::PdmField m_useReservoirConditionCurves; + + caf::PdmField>> m_phases; bool m_doInitAfterLoad; bool m_isOnLoad; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 7dd9d4d7b1..d2b78676d3 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -20,7 +20,6 @@ #include "RiaColorTables.h" #include "RiaColorTools.h" -#include "RiaDateStringParser.h" #include "RiaPlotDefines.h" #include "RiaSimWellBranchTools.h" #include "RiaSummaryTools.h" @@ -29,22 +28,18 @@ #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" -#include "RigSimWellData.h" -#include "RigWellPath.h" #include "RimEclipseCase.h" -#include "RimEclipseCaseCollection.h" #include "RimEclipseResultCase.h" -#include "RimEclipseResultDefinition.h" #include "RimEnsembleCurveSetColorManager.h" #include "RimObservedFmuRftData.h" -#include "RimOilField.h" #include "RimPressureDepthData.h" #include "RimProject.h" #include "RimRegularLegendConfig.h" #include "RimReloadCaseTools.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsembleTools.h" #include "RimTools.h" #include "RimWellLogChannel.h" #include "RimWellLogExtractionCurve.h" @@ -57,11 +52,9 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPlotTools.h" -#include "RimWellPltPlot.h" #include "RimWellRftEnsembleCurveSet.h" #include "RiuAbstractLegendFrame.h" -#include "RiuAbstractOverlayContentFrame.h" #include "RiuDraggableOverlayFrame.h" #include "RiuQwtPlotCurveDefines.h" #include "RiuQwtPlotWidget.h" @@ -1161,7 +1154,7 @@ std::map RimWellRftPlot::findWellSources() { for ( RimSummaryCaseCollection* summaryCaseColl : rftEnsembles ) { - std::set wellsWithRftData = summaryCaseColl->wellsWithRftData(); + std::set wellsWithRftData = RimSummaryEnsembleTools::wellsWithRftData( summaryCaseColl->allSummaryCases() ); for ( const QString& wellName : wellsWithRftData ) { wellNames[wellName].push_back( "Ensemble" ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake index 9d6f352605..fbcf8fb25c 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake @@ -54,6 +54,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSummaryRegressionAnalysisCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddressSelector.h ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCrossPlotStatisticsCase.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryEnsembleTools.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -112,6 +113,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSummaryRegressionAnalysisCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddressSelector.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCrossPlotStatisticsCase.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryEnsembleTools.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index ea0dce891f..e53fa8085f 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -24,7 +24,6 @@ #include "RiaStatisticsTools.h" #include "RiaSummaryAddressAnalyzer.h" -#include "RifReaderRftInterface.h" #include "RifSummaryReaderInterface.h" #include "RimDerivedEnsembleCaseCollection.h" @@ -32,6 +31,7 @@ #include "RimProject.h" #include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" +#include "RimSummaryEnsembleTools.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" @@ -43,56 +43,6 @@ CAF_PDM_SOURCE_INIT( RimSummaryCaseCollection, "SummaryCaseSubCollection" ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::sortByBinnedVariation( std::vector& parameterVector ) -{ - double minStdDev = std::numeric_limits::infinity(); - double maxStdDev = 0.0; - for ( const auto& paramPair : parameterVector ) - { - double stdDev = paramPair.normalizedStdDeviation(); - if ( stdDev != 0.0 ) - { - minStdDev = std::min( minStdDev, stdDev ); - maxStdDev = std::max( maxStdDev, stdDev ); - } - } - if ( ( maxStdDev - minStdDev ) <= 0.0 ) - { - return; - } - - double delta = ( maxStdDev - minStdDev ) / (float)( RigEnsembleParameter::NR_OF_VARIATION_BINS ); - - std::vector bins; - bins.push_back( 0.0 ); - for ( int i = 0; i < RigEnsembleParameter::NR_OF_VARIATION_BINS - 1; ++i ) - { - bins.push_back( minStdDev + ( i + 1 ) * delta ); - } - - for ( RigEnsembleParameter& nameParamPair : parameterVector ) - { - int binNumber = -1; - for ( double bin : bins ) - { - if ( nameParamPair.normalizedStdDeviation() > bin ) - { - binNumber++; - } - } - nameParamPair.variationBin = binNumber; - } - - // Sort by variation bin (highest first) but keep name as sorting parameter when parameters have the same variation - // index - std::stable_sort( parameterVector.begin(), - parameterVector.end(), - []( const RigEnsembleParameter& lhs, const RigEnsembleParameter& rhs ) { return lhs.variationBin > rhs.variationBin; } ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -360,42 +310,6 @@ std::set RimSummaryCaseCollection::ensembleTimeSteps() const return allTimeSteps; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::set RimSummaryCaseCollection::wellsWithRftData() const -{ - std::set allWellNames; - for ( RimSummaryCase* summaryCase : m_cases ) - { - RifReaderRftInterface* reader = summaryCase->rftReader(); - if ( reader ) - { - std::set wellNames = reader->wellNames(); - allWellNames.insert( wellNames.begin(), wellNames.end() ); - } - } - return allWellNames; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::set RimSummaryCaseCollection::rftTimeStepsForWell( const QString& wellName ) const -{ - std::set allTimeSteps; - for ( RimSummaryCase* summaryCase : m_cases ) - { - RifReaderRftInterface* reader = summaryCase->rftReader(); - if ( reader ) - { - std::set timeStep = reader->availableTimeSteps( wellName ); - allTimeSteps.insert( timeStep.begin(), timeStep.end() ); - } - } - return allTimeSteps; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -403,45 +317,24 @@ std::vector RimSummaryCaseCollection::variationSortedEnsem { if ( m_cachedSortedEnsembleParameters.empty() ) { - std::set paramSet; - for ( RimSummaryCase* rimCase : allSummaryCases() ) - { - if ( rimCase->caseRealizationParameters() != nullptr ) - { - auto ps = rimCase->caseRealizationParameters()->parameters(); - for ( const auto& p : ps ) - { - paramSet.insert( p.first ); - } - } - } - - m_cachedSortedEnsembleParameters.reserve( paramSet.size() ); - for ( const QString& parameterName : paramSet ) - { - auto ensembleParameter = createEnsembleParameter( parameterName ); - m_cachedSortedEnsembleParameters.push_back( ensembleParameter ); - } - RimSummaryCaseCollection::sortByBinnedVariation( m_cachedSortedEnsembleParameters ); + m_cachedSortedEnsembleParameters = RimSummaryEnsembleTools::createVariationSortedEnsembleParameters( allSummaryCases() ); } if ( !excludeNoVariation ) { return m_cachedSortedEnsembleParameters; } - else + + const double epsilon = 1e-9; + std::vector parametersWithVariation; + for ( const auto& p : m_cachedSortedEnsembleParameters ) { - const double epsilon = 1e-9; - std::vector parametersWithVariation; - for ( const auto& p : m_cachedSortedEnsembleParameters ) + if ( std::abs( p.normalizedStdDeviation() ) > epsilon ) { - if ( std::abs( p.normalizedStdDeviation() ) > epsilon ) - { - parametersWithVariation.push_back( p ); - } + parametersWithVariation.push_back( p ); } - return parametersWithVariation; } + return parametersWithVariation; } //-------------------------------------------------------------------------------------------------- @@ -595,144 +488,19 @@ std::vector> return correlationsForChosenTimeSteps[0]; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCaseCollection::alphabeticEnsembleParameters() const -{ - std::set paramSet; - for ( RimSummaryCase* rimCase : allSummaryCases() ) - { - if ( rimCase->caseRealizationParameters() != nullptr ) - { - auto ps = rimCase->caseRealizationParameters()->parameters(); - for ( auto p : ps ) - { - paramSet.insert( p.first ); - } - } - } - - std::vector sortedEnsembleParameters; - sortedEnsembleParameters.reserve( paramSet.size() ); - for ( const QString& parameterName : paramSet ) - { - sortedEnsembleParameters.push_back( createEnsembleParameter( parameterName ) ); - } - return sortedEnsembleParameters; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigEnsembleParameter RimSummaryCaseCollection::ensembleParameter( const QString& paramName ) const { - if ( !isEnsemble() || paramName.isEmpty() ) return RigEnsembleParameter(); - - const std::vector& ensembleParams = variationSortedEnsembleParameters(); + if ( !isEnsemble() || paramName.isEmpty() ) return {}; - for ( const RigEnsembleParameter& ensParam : ensembleParams ) + for ( const RigEnsembleParameter& ensParam : variationSortedEnsembleParameters() ) { if ( ensParam.name == paramName ) return ensParam; } - return RigEnsembleParameter(); -} - -RigEnsembleParameter RimSummaryCaseCollection::createEnsembleParameter( const QString& paramName ) const -{ - RigEnsembleParameter eParam; - eParam.name = paramName; - - size_t numericValuesCount = 0; - size_t textValuesCount = 0; - - auto summaryCases = allSummaryCases(); - // Make sure the values list exactly matches the case count - // And use an invalid value (infinity) for invalid cases. - eParam.values.resize( summaryCases.size(), std::numeric_limits::infinity() ); - - // Prepare case realization params, and check types - for ( size_t caseIdx = 0; caseIdx < summaryCases.size(); ++caseIdx ) - { - auto rimCase = summaryCases[caseIdx]; - - auto crp = rimCase->caseRealizationParameters(); - if ( !crp ) continue; - - auto value = crp->parameterValue( paramName ); - if ( !value.isValid() ) continue; - - if ( value.isNumeric() ) - { - double numVal = value.numericValue(); - eParam.values[caseIdx] = QVariant( numVal ); - if ( numVal < eParam.minValue ) eParam.minValue = numVal; - if ( numVal > eParam.maxValue ) eParam.maxValue = numVal; - numericValuesCount++; - } - else if ( value.isText() ) - { - eParam.values[caseIdx] = QVariant( value.textValue() ); - textValuesCount++; - } - } - - if ( numericValuesCount && !textValuesCount ) - { - eParam.type = RigEnsembleParameter::TYPE_NUMERIC; - } - else if ( textValuesCount && !numericValuesCount ) - { - eParam.type = RigEnsembleParameter::TYPE_TEXT; - } - if ( numericValuesCount && textValuesCount ) - { - // A mix of types have been added to parameter values - if ( numericValuesCount > textValuesCount ) - { - // Use numeric type - for ( auto& val : eParam.values ) - { - if ( val.type() == QVariant::String ) - { - val.setValue( std::numeric_limits::infinity() ); - } - } - eParam.type = RigEnsembleParameter::TYPE_NUMERIC; - } - else - { - // Use text type - for ( auto& val : eParam.values ) - { - if ( val.type() == QVariant::Double ) - { - val.setValue( QString::number( val.value() ) ); - } - } - eParam.type = RigEnsembleParameter::TYPE_TEXT; - eParam.minValue = std::numeric_limits::infinity(); - eParam.maxValue = -std::numeric_limits::infinity(); - } - } - - if ( eParam.isText() ) - { - // Remove duplicate texts - std::set valueSet; - for ( const auto& val : eParam.values ) - { - valueSet.insert( val.toString() ); - } - eParam.values.clear(); - for ( const auto& val : valueSet ) - { - eParam.values.push_back( QVariant( val ) ); - } - } - - return eParam; + return {}; } //-------------------------------------------------------------------------------------------------- @@ -740,72 +508,7 @@ RigEnsembleParameter RimSummaryCaseCollection::createEnsembleParameter( const QS //-------------------------------------------------------------------------------------------------- void RimSummaryCaseCollection::calculateEnsembleParametersIntersectionHash() { - clearEnsembleParametersHashes(); - - // Find ensemble parameters intersection - std::set paramNames; - auto sumCases = allSummaryCases(); - - for ( size_t i = 0; i < sumCases.size(); i++ ) - { - auto crp = sumCases[i]->caseRealizationParameters(); - if ( !crp ) continue; - - auto caseParamNames = crp->parameterNames(); - - if ( i == 0 ) - paramNames = caseParamNames; - else - { - std::set newIntersection; - std::set_intersection( paramNames.begin(), - paramNames.end(), - caseParamNames.begin(), - caseParamNames.end(), - std::inserter( newIntersection, newIntersection.end() ) ); - - if ( paramNames.size() != newIntersection.size() ) paramNames = newIntersection; - } - } - - for ( auto sumCase : sumCases ) - { - auto crp = sumCase->caseRealizationParameters(); - if ( crp ) crp->calculateParametersHash( paramNames ); - } - - // Find common addess count - for ( const auto sumCase : sumCases ) - { - const auto reader = sumCase->summaryReader(); - if ( !reader ) continue; - auto currAddrCount = reader->allResultAddresses().size(); - - if ( m_commonAddressCount == 0 ) - { - m_commonAddressCount = currAddrCount; - } - else - { - if ( currAddrCount != m_commonAddressCount ) - { - m_commonAddressCount = 0; - break; - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::clearEnsembleParametersHashes() -{ - for ( auto sumCase : allSummaryCases() ) - { - auto crp = sumCase->caseRealizationParameters(); - if ( crp ) crp->clearParametersHash(); - } + m_commonAddressCount = RimSummaryEnsembleTools::calculateEnsembleParametersIntersectionHash( allSummaryCases() ); } //-------------------------------------------------------------------------------------------------- @@ -997,8 +700,9 @@ std::pair RimSummaryCaseCollection::minMax( const RifEclipseSumm //-------------------------------------------------------------------------------------------------- QString RimSummaryCaseCollection::nameAndItemCount() const { - size_t itemCount = m_cases.size(); - if ( itemCount > 20 ) + size_t itemCount = m_cases.size(); + const size_t itemCountThreshold = 20; + if ( itemCount > itemCountThreshold ) { return QString( "%1 (%2)" ).arg( m_name() ).arg( itemCount ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index b2798c954e..02ce930e10 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -69,11 +69,9 @@ class RimSummaryCaseCollection : public caf::PdmObject virtual std::set ensembleSummaryAddresses() const; virtual std::set ensembleTimeSteps() const; - std::set wellsWithRftData() const; - std::set rftTimeStepsForWell( const QString& wellName ) const; - void setEnsembleId( int ensembleId ); - int ensembleId() const; - bool hasEnsembleParameters() const; + void setEnsembleId( int ensembleId ); + int ensembleId() const; + bool hasEnsembleParameters() const; std::vector variationSortedEnsembleParameters( bool excludeNoVariation = false ) const; std::vector> correlationSortedEnsembleParameters( const RifEclipseSummaryAddress& address ) const; @@ -87,11 +85,8 @@ class RimSummaryCaseCollection : public caf::PdmObject std::vector> parameterCorrelationsAllTimeSteps( const RifEclipseSummaryAddress& address, const std::vector& selectedParameters = {} ) const; - std::vector alphabeticEnsembleParameters() const; - RigEnsembleParameter ensembleParameter( const QString& paramName ) const; void calculateEnsembleParametersIntersectionHash(); - void clearEnsembleParametersHashes(); void loadDataAndUpdate(); @@ -111,10 +106,6 @@ class RimSummaryCaseCollection : public caf::PdmObject std::pair minMax( const RifEclipseSummaryAddress& address ); private: - RigEnsembleParameter createEnsembleParameter( const QString& paramName ) const; - static void sortByBinnedVariation( std::vector& parameterVector ); - friend class RimSummaryCaseCollection_TESTER; - caf::PdmFieldHandle* userDescriptionField() override; QString nameAndItemCount() const; void updateIcon(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsembleTools.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsembleTools.cpp new file mode 100644 index 0000000000..79aa1734fa --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsembleTools.cpp @@ -0,0 +1,325 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimSummaryEnsembleTools.h" + +#include "RifReaderRftInterface.h" +#include "RifSummaryReaderInterface.h" + +#include "RigEnsembleParameter.h" + +#include "RimSummaryCase.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RimSummaryEnsembleTools::wellsWithRftData( const std::vector& summaryCases ) +{ + std::set allWellNames; + for ( auto summaryCase : summaryCases ) + { + if ( auto reader = summaryCase->rftReader() ) + { + std::set wellNames = reader->wellNames(); + allWellNames.insert( wellNames.begin(), wellNames.end() ); + } + } + return allWellNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigEnsembleParameter RimSummaryEnsembleTools::createEnsembleParameter( const std::vector& summaryCases, + const QString& paramName ) +{ + RigEnsembleParameter eParam; + eParam.name = paramName; + + size_t numericValuesCount = 0; + size_t textValuesCount = 0; + + // Make sure the values list exactly matches the case count + // And use an invalid value (infinity) for invalid cases. + eParam.values.resize( summaryCases.size(), std::numeric_limits::infinity() ); + + // Prepare case realization params, and check types + for ( size_t caseIdx = 0; caseIdx < summaryCases.size(); ++caseIdx ) + { + auto rimCase = summaryCases[caseIdx]; + + auto crp = rimCase->caseRealizationParameters(); + if ( !crp ) continue; + + auto value = crp->parameterValue( paramName ); + if ( !value.isValid() ) continue; + + if ( value.isNumeric() ) + { + double numVal = value.numericValue(); + eParam.values[caseIdx] = QVariant( numVal ); + if ( numVal < eParam.minValue ) eParam.minValue = numVal; + if ( numVal > eParam.maxValue ) eParam.maxValue = numVal; + numericValuesCount++; + } + else if ( value.isText() ) + { + eParam.values[caseIdx] = QVariant( value.textValue() ); + textValuesCount++; + } + } + + if ( numericValuesCount && !textValuesCount ) + { + eParam.type = RigEnsembleParameter::TYPE_NUMERIC; + } + else if ( textValuesCount && !numericValuesCount ) + { + eParam.type = RigEnsembleParameter::TYPE_TEXT; + } + if ( numericValuesCount && textValuesCount ) + { + // A mix of types have been added to parameter values + if ( numericValuesCount > textValuesCount ) + { + // Use numeric type + for ( auto& val : eParam.values ) + { + if ( val.type() == QVariant::String ) + { + val.setValue( std::numeric_limits::infinity() ); + } + } + eParam.type = RigEnsembleParameter::TYPE_NUMERIC; + } + else + { + // Use text type + for ( auto& val : eParam.values ) + { + if ( val.type() == QVariant::Double ) + { + val.setValue( QString::number( val.value() ) ); + } + } + eParam.type = RigEnsembleParameter::TYPE_TEXT; + eParam.minValue = std::numeric_limits::infinity(); + eParam.maxValue = -std::numeric_limits::infinity(); + } + } + + if ( eParam.isText() ) + { + // Remove duplicate texts + std::set valueSet; + for ( const auto& val : eParam.values ) + { + valueSet.insert( val.toString() ); + } + eParam.values.clear(); + for ( const auto& val : valueSet ) + { + eParam.values.push_back( QVariant( val ) ); + } + } + + return eParam; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleTools::sortByBinnedVariation( std::vector& parameterVector ) +{ + double minStdDev = std::numeric_limits::infinity(); + double maxStdDev = 0.0; + for ( const auto& paramPair : parameterVector ) + { + double stdDev = paramPair.normalizedStdDeviation(); + if ( stdDev != 0.0 ) + { + minStdDev = std::min( minStdDev, stdDev ); + maxStdDev = std::max( maxStdDev, stdDev ); + } + } + if ( ( maxStdDev - minStdDev ) <= 0.0 ) + { + return; + } + + double delta = ( maxStdDev - minStdDev ) / (float)( RigEnsembleParameter::NR_OF_VARIATION_BINS ); + + std::vector bins; + bins.push_back( 0.0 ); + for ( int i = 0; i < RigEnsembleParameter::NR_OF_VARIATION_BINS - 1; ++i ) + { + bins.push_back( minStdDev + ( i + 1 ) * delta ); + } + + for ( RigEnsembleParameter& nameParamPair : parameterVector ) + { + int binNumber = -1; + for ( double bin : bins ) + { + if ( nameParamPair.normalizedStdDeviation() > bin ) + { + binNumber++; + } + } + nameParamPair.variationBin = binNumber; + } + + // Sort by variation bin (highest first) but keep name as sorting parameter when parameters have the same variation + // index + std::stable_sort( parameterVector.begin(), + parameterVector.end(), + []( const RigEnsembleParameter& lhs, const RigEnsembleParameter& rhs ) { return lhs.variationBin > rhs.variationBin; } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryEnsembleTools::alphabeticEnsembleParameters( const std::vector& summaryCases ) +{ + std::set paramSet; + for ( RimSummaryCase* rimCase : summaryCases ) + { + if ( rimCase->caseRealizationParameters() != nullptr ) + { + auto ps = rimCase->caseRealizationParameters()->parameters(); + for ( auto p : ps ) + { + paramSet.insert( p.first ); + } + } + } + + std::vector sortedEnsembleParameters; + sortedEnsembleParameters.reserve( paramSet.size() ); + for ( const QString& parameterName : paramSet ) + { + sortedEnsembleParameters.push_back( RimSummaryEnsembleTools::createEnsembleParameter( summaryCases, parameterName ) ); + } + return sortedEnsembleParameters; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + RimSummaryEnsembleTools::createVariationSortedEnsembleParameters( const std::vector& summaryCases ) +{ + std::set paramSet; + for ( RimSummaryCase* rimCase : summaryCases ) + { + if ( rimCase->caseRealizationParameters() != nullptr ) + { + auto ps = rimCase->caseRealizationParameters()->parameters(); + for ( const auto& p : ps ) + { + paramSet.insert( p.first ); + } + } + } + std::vector parameters; + parameters.reserve( paramSet.size() ); + for ( const QString& parameterName : paramSet ) + { + auto ensembleParameter = RimSummaryEnsembleTools::createEnsembleParameter( summaryCases, parameterName ); + parameters.push_back( ensembleParameter ); + } + RimSummaryEnsembleTools::sortByBinnedVariation( parameters ); + + return parameters; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void clearEnsembleParametersHashes( const std::vector& summaryCases ) +{ + for ( auto sumCase : summaryCases ) + { + auto crp = sumCase->caseRealizationParameters(); + if ( crp ) crp->clearParametersHash(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimSummaryEnsembleTools::calculateEnsembleParametersIntersectionHash( const std::vector& summaryCases ) +{ + clearEnsembleParametersHashes( summaryCases ); + + // Find ensemble parameters intersection + std::set paramNames; + + for ( size_t i = 0; i < summaryCases.size(); i++ ) + { + auto crp = summaryCases[i]->caseRealizationParameters(); + if ( !crp ) continue; + + auto caseParamNames = crp->parameterNames(); + + if ( i == 0 ) + paramNames = caseParamNames; + else + { + std::set newIntersection; + std::set_intersection( paramNames.begin(), + paramNames.end(), + caseParamNames.begin(), + caseParamNames.end(), + std::inserter( newIntersection, newIntersection.end() ) ); + + if ( paramNames.size() != newIntersection.size() ) paramNames = newIntersection; + } + } + + for ( auto sumCase : summaryCases ) + { + auto crp = sumCase->caseRealizationParameters(); + if ( crp ) crp->calculateParametersHash( paramNames ); + } + + size_t commonAddressCount = 0; + + // Find common addess count + for ( const auto sumCase : summaryCases ) + { + const auto reader = sumCase->summaryReader(); + if ( !reader ) continue; + auto currAddrCount = reader->allResultAddresses().size(); + + if ( commonAddressCount == 0 ) + { + commonAddressCount = currAddrCount; + } + else + { + if ( currAddrCount != commonAddressCount ) + { + commonAddressCount = 0; + break; + } + } + } + + return commonAddressCount; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsembleTools.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsembleTools.h new file mode 100644 index 0000000000..9439ad74a4 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsembleTools.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 + +#include +#include + +class RimSummaryCase; +class RigEnsembleParameter; + +namespace RimSummaryEnsembleTools +{ +std::set wellsWithRftData( const std::vector& summaryCases ); + +RigEnsembleParameter createEnsembleParameter( const std::vector& summaryCases, const QString& paramName ); +void sortByBinnedVariation( std::vector& parameterVector ); +std::vector alphabeticEnsembleParameters( const std::vector& summaryCases ); +std::vector createVariationSortedEnsembleParameters( const std::vector& summaryCases ); + +size_t calculateEnsembleParametersIntersectionHash( const std::vector& summaryCases ); + +} // namespace RimSummaryEnsembleTools diff --git a/ApplicationLibCode/UnitTests/RimSummaryCaseCollection-Test.cpp b/ApplicationLibCode/UnitTests/RimSummaryCaseCollection-Test.cpp index 798c6f164a..84943ba3d9 100644 --- a/ApplicationLibCode/UnitTests/RimSummaryCaseCollection-Test.cpp +++ b/ApplicationLibCode/UnitTests/RimSummaryCaseCollection-Test.cpp @@ -1,12 +1,10 @@ #include "gtest/gtest.h" #include "RigEnsembleParameter.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsembleTools.h" #include -#include - class RimSummaryCaseCollection_TESTER { public: @@ -74,7 +72,7 @@ void RimSummaryCaseCollection_TESTER::test1() } size_t previousSize = parameters.size(); - RimSummaryCaseCollection::sortByBinnedVariation( parameters ); + RimSummaryEnsembleTools::sortByBinnedVariation( parameters ); size_t currentSize = parameters.size(); EXPECT_EQ( previousSize, currentSize ); From a45de57541af8018ce91dc7a6a94cda7043243c5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 24 Jun 2024 14:39:00 +0200 Subject: [PATCH 159/332] Include precombiled version of OpenSsl 1.1.1 on Windows --- CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2eace58f4..04261c8a93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1027,6 +1027,36 @@ if(MSVC) ) endif(MSVC) +# ############################################################################## +# Add OpenSSL 1.1.1 libraries The OpenSSL libraries are needed for the +# NetworkAuth module in Qt 5 Installed by adding openssl-windows in vcpkg.json +# Required to use fully specified path to the dlls, as it is not trivial to find +# the path. OpenSSL 3 is installed and used by other modules +# ############################################################################## + +if(MSVC) + FetchContent_Declare( + openssl_1_1_1 + URL https://github.com/CeetronSolutions/resinsight-dependencies/releases/download/2024.05/openssl_1_1_1.zip + ) + FetchContent_Populate(openssl_1_1_1) + + set(FILE_PATH_LIBCRYPTO_1_1 + "${openssl_1_1_1_SOURCE_DIR}/libcrypto-1_1-x64.dll" + ) + set(FILE_PATH_LIBOPENSSL_1_1 "${openssl_1_1_1_SOURCE_DIR}/libssl-1_1-x64.dll") + + message(STATUS "FILE_PATH_LIBCRYPTO_1_1: ${FILE_PATH_LIBCRYPTO_1_1}") + message(STATUS "FILE_PATH_LIBOPENSSL_1_1: ${FILE_PATH_LIBOPENSSL_1_1}") + + install( + FILES ${FILE_PATH_LIBCRYPTO_1_1} ${FILE_PATH_LIBOPENSSL_1_1} + DESTINATION ${RESINSIGHT_INSTALL_FOLDER} + OPTIONAL + ) + +endif() # MSVC + # ############################################################################## # Visual Studio : Create the ruleset file to be used by Static Code Analysis # https://stackoverflow.com/questions/75031903/how-to-enable-static-analysis-with-custom-ruleset-in-msvc-via-cmakelists-txt From 0974ee7f36ef86ed90ac54af38b32fa0b71c4167 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 26 Jun 2024 12:33:18 +0200 Subject: [PATCH 160/332] Osdu: add more error logging. --- .../OsduImportCommands/RiaOsduConnector.cpp | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index c9dc9e4c1c..54bfc48027 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -44,6 +44,13 @@ RiaOsduConnector::RiaOsduConnector( QObject* parent, RiaLogging::debug( "SSL BUILD VERSION: " + QSslSocket::sslLibraryBuildVersionString() ); RiaLogging::debug( "SSL VERSION STRING: " + QSslSocket::sslLibraryVersionString() ); + RiaLogging::debug( "OSDU config:" ); + RiaLogging::debug( " server: '" + server + "'" ); + RiaLogging::debug( " data partition id: '" + dataPartitionId + "'" ); + RiaLogging::debug( " authority: '" + authority + "'" ); + RiaLogging::debug( " scopes: '" + scopes + "'" ); + RiaLogging::debug( " client id: '" + clientId + "'" ); + int port = 35327; connect( m_osdu, @@ -179,12 +186,18 @@ void RiaOsduConnector::requestFieldsByName( const QString& server, const QString auto reply = makeSearchRequest( params, server, dataPartitionId, token ); connect( reply, &QNetworkReply::finished, - [this, reply]() + [this, reply, fieldName]() { if ( reply->error() == QNetworkReply::NoError ) { parseFields( reply ); } + else + { + QString errorMessage = + QString( "Download failed for fields by name (%1). Error: %2" ).arg( fieldName ).arg( reply->errorString() ); + RiaLogging::error( errorMessage ); + } } ); } @@ -215,6 +228,12 @@ void RiaOsduConnector::requestWellsByFieldId( const QString& server, const QStri { parseWells( reply ); } + else + { + QString errorMessage = + QString( "Request failed for wells for field (%1). Error: %2" ).arg( fieldId ).arg( reply->errorString() ); + RiaLogging::error( errorMessage ); + } } ); } @@ -245,6 +264,12 @@ void RiaOsduConnector::requestWellboresByWellId( const QString& server, const QS { parseWellbores( reply, wellId ); } + else + { + QString errorMessage = + QString( "Request failed for wellbores for well (%1). Error: %2" ).arg( wellId ).arg( reply->errorString() ); + RiaLogging::error( errorMessage ); + } } ); } @@ -293,6 +318,12 @@ void RiaOsduConnector::requestWellLogsByWellboreId( const QString& server, { parseWellLogs( reply, wellboreId ); } + else + { + QString errorMessage = + QString( "Request failed for well logs by wellbore (%1). Error: %2" ).arg( wellboreId ).arg( reply->errorString() ); + RiaLogging::error( errorMessage ); + } } ); } @@ -326,6 +357,12 @@ void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& ser { parseWellTrajectory( reply, wellboreId ); } + else + { + QString errorMessage = + QString( "Request failed for well trajectory by wellbore (%1). Error: %2" ).arg( wellboreId ).arg( reply->errorString() ); + RiaLogging::error( errorMessage ); + } } ); } @@ -430,6 +467,8 @@ void RiaOsduConnector::parseFields( QNetworkReply* reply ) QString fieldName = resultObj["data"].toObject()["FieldName"].toString(); m_fields.push_back( OsduField{ id, kind, fieldName } ); } + + RiaLogging::debug( QString( "Found %1 fields." ).arg( m_fields.size() ) ); } emit fieldsFinished(); @@ -766,7 +805,7 @@ void RiaOsduConnector::requestParquetData( const QString& url, const QString& da } else { - QString errorMessage = "Download failed: " + url + " failed." + reply->errorString(); + QString errorMessage = "Request failed: " + url + " failed." + reply->errorString(); RiaLogging::error( errorMessage ); emit parquetDownloadFinished( QByteArray(), errorMessage ); } From 9d2f915877d703bbedbfcac7aa81ae41ad39aa87 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 26 Jun 2024 12:36:11 +0200 Subject: [PATCH 161/332] Bump to dev.07. --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 27277032bb..3e926095fe 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".06") +set(RESINSIGHT_DEV_VERSION ".07") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 2f5f83b959e22e6b60065696c088ce7ff8719a10 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:44:41 +0200 Subject: [PATCH 162/332] opm_common reader updates (#11535) * Read NNC info from init file, if needed * Read active cell information before geometry --- .../FileInterface/RifReaderOpmCommon.cpp | 225 ++++++++++++++---- .../FileInterface/RifReaderOpmCommon.h | 23 +- ThirdParty/custom-opm-common/opm-common | 2 +- 3 files changed, 205 insertions(+), 45 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp index 56c7c26700..ed5c23dc1c 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp @@ -143,6 +143,8 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli //-------------------------------------------------------------------------------------------------- bool RifReaderOpmCommon::importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* eclipseCaseData ) { + caf::ProgressInfo progInfo( 5, "Importing Eclipse Grid" ); + Opm::EclIO::EGrid opmGrid( m_gridFileName ); RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); @@ -198,48 +200,72 @@ bool RifReaderOpmCommon::importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* mainGrid->globalCellArray().reserve( (size_t)totalCellCount ); mainGrid->nodes().reserve( (size_t)totalCellCount * 8 ); - caf::ProgressInfo progInfo( 4 + numLGRs, "" ); + activeCellInfo->setGridCount( 1 + numLGRs ); + fractureActiveCellInfo->setGridCount( 1 + numLGRs ); { - auto task = progInfo.task( "Loading Main Grid Data", 3 ); - transferGeometry( opmGrid, opmGrid, mainGrid, mainGrid, eclipseCaseData, 0, 0 ); - } + auto task = progInfo.task( "Getting Active Cell Information", 1 ); - activeCellInfo->setGridCount( 1 + numLGRs ); - fractureActiveCellInfo->setGridCount( 1 + numLGRs ); + for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ ) + { + globalMatrixActiveSize += lgrGrids[lgrIdx].activeCells(); + globalFractureActiveSize += lgrGrids[lgrIdx].activeFracCells(); + } + + // in case init file and grid file disagrees with number of active cells, read extra porv information from init file to correct this + if ( !verifyActiveCellInfo( globalMatrixActiveSize, globalFractureActiveSize ) ) + { + updateActiveCellInfo( eclipseCaseData, opmGrid, lgrGrids, mainGrid ); + } + + globalMatrixActiveSize = opmGrid.activeCells(); + globalFractureActiveSize = opmGrid.activeFracCells(); + + activeCellInfo->setGridActiveCellCounts( 0, globalMatrixActiveSize ); + fractureActiveCellInfo->setGridActiveCellCounts( 0, globalFractureActiveSize ); + + transferActiveCells( opmGrid, 0, eclipseCaseData, 0, 0 ); + size_t cellCount = opmGrid.totalNumberOfCells(); + + for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ ) + { + auto& lgrGrid = lgrGrids[lgrIdx]; + transferActiveCells( lgrGrid, cellCount, eclipseCaseData, globalMatrixActiveSize, globalFractureActiveSize ); + cellCount += lgrGrid.totalNumberOfCells(); + globalMatrixActiveSize += lgrGrid.activeCells(); + globalFractureActiveSize += lgrGrid.activeFracCells(); + activeCellInfo->setGridActiveCellCounts( lgrIdx + 1, lgrGrid.activeCells() ); + fractureActiveCellInfo->setGridActiveCellCounts( lgrIdx + 1, lgrGrid.activeFracCells() ); + } + + activeCellInfo->computeDerivedData(); + fractureActiveCellInfo->computeDerivedData(); + } - activeCellInfo->setGridActiveCellCounts( 0, globalMatrixActiveSize ); - fractureActiveCellInfo->setGridActiveCellCounts( 0, globalFractureActiveSize ); + { + auto task = progInfo.task( "Loading Main Grid Geometry", 1 ); + transferGeometry( opmGrid, opmGrid, mainGrid, mainGrid, eclipseCaseData ); + } bool hasParentInfo = ( lgr_parent_names.size() >= (size_t)numLGRs ); + auto task = progInfo.task( "Loading LGR Grid Geometry ", 1 ); + for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ ) { - auto task = progInfo.task( "LGR number " + QString::number( lgrIdx + 1 ), 1 ); - RigGridBase* parentGrid = hasParentInfo ? mainGrid->gridByName( lgr_parent_names[lgrIdx] ) : mainGrid; RigLocalGrid* localGrid = static_cast( mainGrid->gridById( lgrIdx + 1 ) ); localGrid->setParentGrid( parentGrid ); - transferGeometry( opmGrid, lgrGrids[lgrIdx], mainGrid, localGrid, eclipseCaseData, globalMatrixActiveSize, globalFractureActiveSize ); - - int matrixActiveCellCount = lgrGrids[lgrIdx].activeCells(); - globalMatrixActiveSize += matrixActiveCellCount; - activeCellInfo->setGridActiveCellCounts( lgrIdx + 1, matrixActiveCellCount ); - - int fractureActiveCellCount = lgrGrids[lgrIdx].activeFracCells(); - globalFractureActiveSize += fractureActiveCellCount; - fractureActiveCellInfo->setGridActiveCellCounts( lgrIdx + 1, fractureActiveCellCount ); + transferGeometry( opmGrid, lgrGrids[lgrIdx], mainGrid, localGrid, eclipseCaseData ); } mainGrid->initAllSubGridsParentGridPointer(); - activeCellInfo->computeDerivedData(); - fractureActiveCellInfo->computeDerivedData(); if ( isNNCsEnabled() ) { - auto task = progInfo.task( "Handling NNC data", 1 ); + auto task = progInfo.task( "Loading NNC data", 1 ); transferStaticNNCData( opmGrid, lgrGrids, mainGrid ); } @@ -338,6 +364,41 @@ void RifReaderOpmCommon::transferDynamicNNCData( RigMainGrid* mainGrid ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmCommon::transferActiveCells( Opm::EclIO::EGrid& opmGrid, + size_t cellStartIndex, + RigEclipseCaseData* eclipseCaseData, + size_t matrixActiveStartIndex, + size_t fractureActiveStartIndex ) +{ + const int cellCount = opmGrid.totalNumberOfCells(); + + RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); + + const auto& active_indexes = opmGrid.active_indexes(); + const auto& active_frac_indexes = opmGrid.active_frac_indexes(); + +#pragma omp parallel for + for ( int opmCellIndex = 0; opmCellIndex < (int)cellCount; opmCellIndex++ ) + { + // active cell index + int matrixActiveIndex = active_indexes[opmCellIndex]; + if ( matrixActiveIndex != -1 ) + { + activeCellInfo->setCellResultIndex( cellStartIndex + opmCellIndex, matrixActiveStartIndex + matrixActiveIndex ); + } + + int fractureActiveIndex = active_frac_indexes[opmCellIndex]; + if ( fractureActiveIndex != -1 ) + { + fractureActiveCellInfo->setCellResultIndex( cellStartIndex + opmCellIndex, fractureActiveStartIndex + fractureActiveIndex ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -345,17 +406,12 @@ void RifReaderOpmCommon::transferGeometry( Opm::EclIO::EGrid& opmMainGrid, Opm::EclIO::EGrid& opmGrid, RigMainGrid* mainGrid, RigGridBase* localGrid, - RigEclipseCaseData* eclipseCaseData, - size_t matrixActiveStartIndex, - size_t fractureActiveStartIndex ) + RigEclipseCaseData* eclipseCaseData ) { int cellCount = opmGrid.totalNumberOfCells(); size_t cellStartIndex = mainGrid->globalCellArray().size(); size_t nodeStartIndex = mainGrid->nodes().size(); - RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); - RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); - RigCell defaultCell; defaultCell.setHostGrid( localGrid ); mainGrid->globalCellArray().resize( cellStartIndex + cellCount, defaultCell ); @@ -398,19 +454,6 @@ void RifReaderOpmCommon::transferGeometry( Opm::EclIO::EGrid& opmMainGrid, RigCell& cell = mainGrid->globalCellArray()[cellStartIndex + riReservoirIndex]; cell.setGridLocalCellIndex( riReservoirIndex ); - // active cell index - int matrixActiveIndex = opmGrid.active_index( opmIJK[0], opmIJK[1], opmIJK[2] ); - if ( matrixActiveIndex != -1 ) - { - activeCellInfo->setCellResultIndex( cellStartIndex + opmCellIndex, matrixActiveStartIndex + matrixActiveIndex ); - } - - int fractureActiveIndex = opmGrid.active_frac_index( opmIJK[0], opmIJK[1], opmIJK[2] ); - if ( fractureActiveIndex != -1 ) - { - fractureActiveCellInfo->setCellResultIndex( cellStartIndex + opmCellIndex, fractureActiveStartIndex + fractureActiveIndex ); - } - // parent cell index if ( ( hostCellGlobalIndices.size() > (size_t)opmCellIndex ) && hostCellGlobalIndices[opmCellIndex] >= 0 ) { @@ -931,3 +974,103 @@ std::vector RifReaderOpmCommon::timeStepsOnFile( QString gridFileName return dateTimes; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderOpmCommon::verifyActiveCellInfo( int activeSizeMat, int activeSizeFrac ) +{ + if ( m_initFile == nullptr ) return true; + + int activeCells = 0; + + for ( const auto& name : m_gridNames ) + { + activeCells += m_initFile->activeCells( name ); + } + + return activeCells == ( activeSizeFrac + activeSizeMat ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RifReaderOpmCommon::readActiveCellInfoFromPorv( RigEclipseCaseData* eclipseCaseData, bool isDualPorosity ) +{ + if ( m_initFile == nullptr ) return {}; + + std::vector> activeCellsAllGrids; + + bool divideCellCountByTwo = isDualPorosity; + + const int nGrids = (int)m_gridNames.size(); + + for ( int gridIdx = 0; gridIdx < nGrids; gridIdx++ ) + { + auto porvValues = m_initFile->getInitData( "PORV", m_gridNames[gridIdx] ); + + int activeCellCount = (int)porvValues.size(); + if ( divideCellCountByTwo ) + { + activeCellCount /= 2; + } + + std::vector activeCellsOneGrid; + activeCellsOneGrid.resize( activeCellCount, 0 ); + + for ( int poreValueIndex = 0; poreValueIndex < static_cast( porvValues.size() ); poreValueIndex++ ) + { + int indexToCell = poreValueIndex; + if ( indexToCell >= activeCellCount ) + { + indexToCell = poreValueIndex - activeCellCount; + } + + if ( porvValues[poreValueIndex] > 0.0f ) + { + if ( isDualPorosity ) + { + if ( poreValueIndex < activeCellCount ) + { + activeCellsOneGrid[indexToCell] += (int)ActiveType::ACTIVE_MATRIX_VALUE; + } + else + { + activeCellsOneGrid[indexToCell] += (int)ActiveType::ACTIVE_FRACTURE_VALUE; + } + } + else + { + activeCellsOneGrid[indexToCell] += (int)ActiveType::ACTIVE_MATRIX_VALUE; + } + } + } + + activeCellsAllGrids.push_back( activeCellsOneGrid ); + } + + return activeCellsAllGrids; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmCommon::updateActiveCellInfo( RigEclipseCaseData* eclipseCaseData, + Opm::EclIO::EGrid& opmGrid, + std::vector& lgrGrids, + RigMainGrid* mainGrid ) +{ + auto activeCellInfoPerGrid = readActiveCellInfoFromPorv( eclipseCaseData, opmGrid.porosity_mode() > 0 ); + + int nInfos = (int)activeCellInfoPerGrid.size(); + if ( nInfos > 0 ) + { + int gridIdx = 0; + opmGrid.set_active_cells( activeCellInfoPerGrid[gridIdx++] ); + + for ( auto& lgr : lgrGrids ) + { + if ( gridIdx < nInfos ) lgr.set_active_cells( activeCellInfoPerGrid[gridIdx++] ); + } + } +} diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h index 003b511ca2..2400a3c15e 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h @@ -65,9 +65,13 @@ class RifReaderOpmCommon : public RifReaderInterface Opm::EclIO::EGrid& opmGrid, RigMainGrid* riMainGrid, RigGridBase* riGrid, - RigEclipseCaseData* caseData, - size_t matrixActiveStartIndex, - size_t fractureActiveStartIndex ); + RigEclipseCaseData* caseData ); + + void transferActiveCells( Opm::EclIO::EGrid& opmGrid, + size_t cellStartIndex, + RigEclipseCaseData* eclipseCaseData, + size_t matrixActiveStartIndex, + size_t fractureActiveStartIndex ); void transferStaticNNCData( Opm::EclIO::EGrid& opmMainGrid, std::vector& lgrGrids, RigMainGrid* mainGrid ); void transferDynamicNNCData( RigMainGrid* mainGrid ); @@ -77,6 +81,13 @@ class RifReaderOpmCommon : public RifReaderInterface std::vector createFilteredTimeStepInfos(); + bool verifyActiveCellInfo( int activeSizeMat, int activeSizeFrac ); + std::vector> readActiveCellInfoFromPorv( RigEclipseCaseData* eclipseCaseData, bool isDualPorosity ); + void updateActiveCellInfo( RigEclipseCaseData* eclipseCaseData, + Opm::EclIO::EGrid& opmGrid, + std::vector& lgrGrids, + RigMainGrid* mainGrid ); + struct TimeDataFile { int sequenceNumber; @@ -89,6 +100,12 @@ class RifReaderOpmCommon : public RifReaderInterface std::vector readTimeSteps(); private: + enum class ActiveType + { + ACTIVE_MATRIX_VALUE = 1, + ACTIVE_FRACTURE_VALUE = 2 + }; + std::string m_gridFileName; std::string m_initFileName; std::string m_restartFileName; diff --git a/ThirdParty/custom-opm-common/opm-common b/ThirdParty/custom-opm-common/opm-common index 354375b8ae..ea6dba538b 160000 --- a/ThirdParty/custom-opm-common/opm-common +++ b/ThirdParty/custom-opm-common/opm-common @@ -1 +1 @@ -Subproject commit 354375b8ae55fad91efa64a298de4e0871defd19 +Subproject commit ea6dba538bfb0498eb1ec6ad51a853b99e446a5b From e0b84ae36a6a39f26d52f93453d08beee95ad957 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 1 Jul 2024 11:33:40 +0200 Subject: [PATCH 163/332] #11536 Add library to support strong typing of objects --- ApplicationLibCode/Adm/LicenseInformation.txt | 30 +++++++++++++++++++ CMakeLists.txt | 6 ++++ vcpkg.json | 3 +- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/Adm/LicenseInformation.txt b/ApplicationLibCode/Adm/LicenseInformation.txt index f89389d990..daa41226ba 100644 --- a/ApplicationLibCode/Adm/LicenseInformation.txt +++ b/ApplicationLibCode/Adm/LicenseInformation.txt @@ -715,3 +715,33 @@ THE SOFTWARE. -- NOTE: Third party dependency used by this software -- This software depends on the fmt lib (MIT License), and users must comply to its license: https://raw.githubusercontent.com/fmtlib/fmt/master/LICENSE + +=============================================================================== + Notice for type-lite +=============================================================================== + +https://github.com/martinmoene/type-lite/blob/master/LICENSE.txt + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 04261c8a93..b7389ca2b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -641,6 +641,12 @@ else() list(APPEND THIRD_PARTY_LIBRARIES Parquet::parquet_static) endif() +# ############################################################################## +# nonstd::type-lite +# ############################################################################## +find_package(type-lite CONFIG REQUIRED) +list(APPEND THIRD_PARTY_LIBRARIES nonstd::type-lite) + # ############################################################################## # Thirdparty libraries are put in ThirdParty solution folder # ############################################################################## diff --git a/vcpkg.json b/vcpkg.json index abe2eb3446..13c9ad3d43 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -4,6 +4,7 @@ "boost-filesystem", "boost-spirit", "eigen3", - "grpc" + "grpc", + "type-lite" ] } From 58b3f0b928206434daafd95ce379961cefc26b3a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 1 Jul 2024 12:34:47 +0200 Subject: [PATCH 164/332] Fix compiler issue when importing arrow The arrow library has a function parameter called signals that causes trouble when compiled using Qt. Add undef signals to avoid this issue. --- ApplicationLibCode/FileInterface/RifArrowTools.cpp | 6 ------ ApplicationLibCode/FileInterface/RifArrowTools.h | 2 ++ .../FileInterface/RifByteArrayArrowRandomAccessFile.h | 2 ++ ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp | 2 ++ ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp | 2 ++ ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp | 2 ++ ApplicationLibCode/pch.h | 5 ----- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifArrowTools.cpp b/ApplicationLibCode/FileInterface/RifArrowTools.cpp index 3b459fcf16..a75d6cefa9 100644 --- a/ApplicationLibCode/FileInterface/RifArrowTools.cpp +++ b/ApplicationLibCode/FileInterface/RifArrowTools.cpp @@ -22,12 +22,6 @@ #include -// #include -// #include -// #include -// #include -// #include - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifArrowTools.h b/ApplicationLibCode/FileInterface/RifArrowTools.h index a671675834..aba2ed4042 100644 --- a/ApplicationLibCode/FileInterface/RifArrowTools.h +++ b/ApplicationLibCode/FileInterface/RifArrowTools.h @@ -18,7 +18,9 @@ #pragma once +#undef signals #include +#define signals Q_SIGNALS #include #include diff --git a/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h b/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h index 9f65a27f7e..4b7ae66286 100644 --- a/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h +++ b/ApplicationLibCode/FileInterface/RifByteArrayArrowRandomAccessFile.h @@ -18,10 +18,12 @@ #pragma once +#undef signals #include #include #include #include +#define signals Q_SIGNALS #include diff --git a/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp index 52d6218b2a..2442efbc3f 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp +++ b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp @@ -27,11 +27,13 @@ #include "RifArrowTools.h" +#undef signals #include #include #include #include #include +#define signals Q_SIGNALS //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp index 04838836eb..d9a85681bb 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp +++ b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp @@ -18,12 +18,14 @@ #include "RifOsduWellPathReader.h" +#undef signals #include #include #include #include #include #include +#define signals Q_SIGNALS #include "RiaLogging.h" #include "RiaTextStringTools.h" diff --git a/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp b/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp index f1d97f7c8b..b3341153eb 100644 --- a/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp @@ -2,10 +2,12 @@ #include "RiaTestDataDirectory.h" +#undef signals #include #include #include #include +#define signals Q_SIGNALS #include #include diff --git a/ApplicationLibCode/pch.h b/ApplicationLibCode/pch.h index 0d49a38975..e1f0453cd5 100644 --- a/ApplicationLibCode/pch.h +++ b/ApplicationLibCode/pch.h @@ -16,11 +16,6 @@ // ///////////////////////////////////////////////////////////////////////////////// -// NOTE: This file must be included before any other Qt header files, as the keyword 'signals' is used as a parameter name in -// RegisterCancellingSignalHandler(const std::vector& signals); -// Qt has special treatment of 'signals', and causes compiler issues using PCH -#include - #include "cvfObject.h" #include "cvfVector3.h" From f2d79da8beb072130537704f502b19bc61bc8697 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 1 Jul 2024 14:00:41 +0200 Subject: [PATCH 165/332] Use template to convert arrow::ChunkedArray --- .../FileInterface/RifArrowTools.cpp | 88 ++++++++++++++----- .../FileInterface/RifArrowTools.h | 43 ++++++++- .../FileInterface/RifOsduWellLogReader.cpp | 2 +- .../FileInterface/RifOsduWellPathReader.cpp | 2 +- .../UnitTests/RifParquetReader-Test.cpp | 59 +++++++++++++ 5 files changed, 167 insertions(+), 27 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifArrowTools.cpp b/ApplicationLibCode/FileInterface/RifArrowTools.cpp index a75d6cefa9..c127ce7872 100644 --- a/ApplicationLibCode/FileInterface/RifArrowTools.cpp +++ b/ApplicationLibCode/FileInterface/RifArrowTools.cpp @@ -18,40 +18,86 @@ #include "RifArrowTools.h" -#include "cafAssert.h" +#include "RifByteArrayArrowRandomAccessFile.h" +#include "RifCsvDataTableFormatter.h" #include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifArrowTools::convertChunkedArrayToStdVector( const std::shared_ptr& column ) +QString RifArrowTools::readFirstRowsOfTable( const QByteArray& contents ) { - auto convertChunkToVector = []( const std::shared_ptr& array ) -> std::vector + arrow::MemoryPool* pool = arrow::default_memory_pool(); + + std::shared_ptr input = std::make_shared( contents ); + + // Open Parquet file reader + std::unique_ptr arrow_reader; + if ( !parquet::arrow::OpenFile( input, pool, &arrow_reader ).ok() ) { - std::vector result; + return {}; + } - auto double_array = std::static_pointer_cast( array ); - result.resize( double_array->length() ); - for ( int64_t i = 0; i < double_array->length(); ++i ) - { - result[i] = double_array->Value( i ); - } + // Read entire file as a single Arrow table + std::shared_ptr table; + if ( !arrow_reader->ReadTable( &table ).ok() ) + { + return {}; + } - return result; - }; + QString tableText; + QTextStream stream( &tableText ); + RifCsvDataTableFormatter formatter( stream, ";" ); - CAF_ASSERT( column->type()->id() == arrow::Type::DOUBLE ); + std::vector header; + for ( std::string columnName : table->ColumnNames() ) + { + header.push_back( RifTextDataTableColumn( QString::fromStdString( columnName ) ) ); + } - std::vector result; + formatter.header( header ); - // Iterate over each chunk in the column - for ( int i = 0; i < column->num_chunks(); ++i ) + std::vector> columnVectors; + + for ( std::string columnName : table->ColumnNames() ) { - std::shared_ptr chunk = column->chunk( i ); - std::vector chunk_vector = convertChunkToVector( chunk ); - result.insert( result.end(), chunk_vector.begin(), chunk_vector.end() ); + std::shared_ptr column = table->GetColumnByName( columnName ); + + auto columnType = column->type()->id(); + + if ( columnType == arrow::Type::DOUBLE ) + { + std::vector columnVector = RifArrowTools::chunkedArrayToVector( column ); + columnVectors.push_back( columnVector ); + } + else if ( columnType == arrow::Type::FLOAT ) + { + auto columnVector = RifArrowTools::chunkedArrayToVector( column ); + columnVectors.push_back( columnVector ); + } + else if ( columnType == arrow::Type::TIMESTAMP ) + { + auto columnVector = RifArrowTools::chunkedArrayToVector( column ); + columnVectors.push_back( columnVector ); + } + } + + if ( columnVectors.empty() ) + { + return {}; } - return result; -}; + for ( int i = 0; i < std::min( 20, int( columnVectors[0].size() ) ); i++ ) + { + for ( int j = 0; j < int( columnVectors.size() ); j++ ) + { + formatter.add( columnVectors[j][i] ); + } + formatter.rowCompleted(); + } + + formatter.tableCompleted(); + + return tableText; +} diff --git a/ApplicationLibCode/FileInterface/RifArrowTools.h b/ApplicationLibCode/FileInterface/RifArrowTools.h index aba2ed4042..6778d26cbc 100644 --- a/ApplicationLibCode/FileInterface/RifArrowTools.h +++ b/ApplicationLibCode/FileInterface/RifArrowTools.h @@ -22,15 +22,50 @@ #include #define signals Q_SIGNALS +#include #include #include +#include +#include + //================================================================================================== // // //================================================================================================== -class RifArrowTools +namespace RifArrowTools +{ + +// Template class used to handle most of the basic types. Conversiont to std::string requuires a specialization using chunk->GetString(j). +template +std::vector chunkedArrayToVector( const std::shared_ptr& chunkedArray ) { -public: - static std::vector convertChunkedArrayToStdVector( const std::shared_ptr& column ); -}; + static_assert( std::is_base_of::value, "ArrowArrayType must be derived from arrow::Array" ); + + std::vector result; + for ( int i = 0; i < chunkedArray->num_chunks(); ++i ) + { + auto chunk = std::static_pointer_cast( chunkedArray->chunk( i ) ); + + // Use auto here instead of CType to allow conversion between different types + // Use raw_values() to get the raw data pointer for best performance + const auto* data = chunk->raw_values(); + + for ( int j = 0; j < chunk->length(); ++j ) + { + if ( !chunk->IsNull( j ) ) + { + result.push_back( data[j] ); + } + else + { + result.push_back( std::numeric_limits::quiet_NaN() ); + } + } + } + + return result; +} + +QString readFirstRowsOfTable( const QByteArray& contents ); +}; // namespace RifArrowTools diff --git a/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp index 2442efbc3f..31c98527bf 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp +++ b/ApplicationLibCode/FileInterface/RifOsduWellLogReader.cpp @@ -65,7 +65,7 @@ std::pair, QString> RifOsduWellLogReader::readWellL if ( column->type()->id() == arrow::Type::DOUBLE ) { - std::vector columnVector = RifArrowTools::convertChunkedArrayToStdVector( column ); + std::vector columnVector = RifArrowTools::chunkedArrayToVector( column ); logData->setValues( QString::fromStdString( columnName ), columnVector ); } } diff --git a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp index d9a85681bb..69f2edb0b4 100644 --- a/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp +++ b/ApplicationLibCode/FileInterface/RifOsduWellPathReader.cpp @@ -143,7 +143,7 @@ std::pair, QString> RifOsduWellPathReader::readWellPathDat if ( column->type()->id() == arrow::Type::DOUBLE ) { - std::vector columnVector = RifArrowTools::convertChunkedArrayToStdVector( column ); + std::vector columnVector = RifArrowTools::chunkedArrayToVector( column ); RiaLogging::debug( QString( "Column name: %1. Size: %2" ).arg( QString::fromStdString( columnName ) ).arg( columnVector.size() ) ); readValues[columnName] = columnVector; } diff --git a/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp b/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp index b3341153eb..0a88dee51c 100644 --- a/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp @@ -2,7 +2,10 @@ #include "RiaTestDataDirectory.h" +#include "RifArrowTools.h" + #undef signals +#include #include #include #include @@ -51,3 +54,59 @@ TEST( RifParquetReaderTest, ReadValidFile ) EXPECT_TRUE( scalar->Equals( arrow::Int64Scalar( i ) ) ); } } + +TEST( RifParquetReaderTest, ConvertIntChunkedArrays ) +{ + arrow::Status status; + + arrow::Int32Builder int_builder; + status = int_builder.Append( 1 ); + status = int_builder.Append( 2 ); + status = int_builder.Append( 3 ); + + std::shared_ptr int_array; + status = int_builder.Finish( &int_array ); + + auto int_chunked_array = std::make_shared( int_array ); + + { + auto columnVector = RifArrowTools::chunkedArrayToVector( int_chunked_array ); + EXPECT_EQ( columnVector.size(), 3 ); + } + { + auto columnVector = RifArrowTools::chunkedArrayToVector( int_chunked_array ); + EXPECT_EQ( columnVector.size(), 3 ); + } +} + +TEST( RifParquetReaderTest, ConvertFloatChunkedArrays ) +{ + arrow::Status status; + + // Create an Arrow double array + std::vector values = { 1.0, 2.0, 3.0, 4.0 }; + std::shared_ptr array; + arrow::DoubleBuilder builder; + status = builder.AppendValues( values ); + status = builder.Finish( &array ); + + // Create a chunked array from the Arrow array + std::shared_ptr chunkedArray = std::make_shared( array ); + + // Call the function under test + auto resultVector = RifArrowTools::chunkedArrayToVector( chunkedArray ); + + // Assert that the returned vector contains the expected values + ASSERT_EQ( resultVector.size(), values.size() ); + for ( size_t i = 0; i < values.size(); ++i ) + { + EXPECT_DOUBLE_EQ( resultVector[i], values[i] ); + } + + auto floatVector = RifArrowTools::chunkedArrayToVector( chunkedArray ); + ASSERT_EQ( floatVector.size(), values.size() ); + for ( size_t i = 0; i < values.size(); ++i ) + { + EXPECT_DOUBLE_EQ( floatVector[i], values[i] ); + } +} From 899fdba5db996e771b51cdb38db63cbd92655015 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Wed, 3 Jul 2024 12:44:16 +0200 Subject: [PATCH 166/332] ODB 2020 and 2024 support (#11544) * Support picking up and using odb 2020 or 2024 libraries from internal build server. --- CMakeLists.txt | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7389ca2b9..4600813045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,28 +124,46 @@ set(RESINSIGHT_ODB_API_DIR "Optional path to the ABAQUS ODB API from Simulia. Needed for support of geomechanical models" ) -if(MSVC) - option(RESINSIGHT_DONWLOAD_ODB_FROM_SERVER - "Download ODB library from inhouse build server" OFF - ) - mark_as_advanced(FORCE RESINSIGHT_DONWLOAD_ODB_FROM_SERVER) +option(RESINSIGHT_DOWNLOAD_ODB_FROM_SERVER + "Download ODB library from private repository" OFF +) +mark_as_advanced(FORCE RESINSIGHT_DOWNLOAD_ODB_FROM_SERVER) +set(RESINSIGHT_ODB_VERSION + "2020" + CACHE STRING "Abaqus API version to use, 2020 or 2024" +) +mark_as_advanced(FORCE RESINSIGHT_ODB_VERSION) + +if(RESINSIGHT_DOWNLOAD_ODB_FROM_SERVER) - if(RESINSIGHT_DONWLOAD_ODB_FROM_SERVER) + if(MSVC) FetchContent_Declare( odb-library-from-server - URL http://10.10.0.26:8080/job/resinsight-dependencies/ws/odb-api-2020.zip + URL http://10.10.0.26:8080/job/resinsight-dependencies/ws/${RESINSIGHT_ODB_VERSION}/odb_api_win64.zip + ) + else() + FetchContent_Declare( + odb-library-from-server + URL http://10.10.0.26:8080/job/resinsight-dependencies/ws/${RESINSIGHT_ODB_VERSION}/odb_api_linux.zip ) - - FetchContent_Populate(odb-library-from-server) - - set(RESINSIGHT_ODB_API_DIR ${odb-library-from-server_SOURCE_DIR}) endif() + + FetchContent_Populate(odb-library-from-server) + set(RESINSIGHT_ODB_API_DIR ${odb-library-from-server_SOURCE_DIR}) endif() if(NOT ${RESINSIGHT_ODB_API_DIR} EQUAL "") add_definitions(-DUSE_ODB_API) set(RESINSIGHT_USE_ODB_API 1) - message(STATUS "Using ODB-Api from : ${RESINSIGHT_ODB_API_DIR}") + message( + STATUS + "Using ODB-Api ${RESINSIGHT_ODB_VERSION} from : ${RESINSIGHT_ODB_API_DIR}" + ) + if(MSVC) + add_definitions(-D_WINDOWS_SOURCE) + else() + add_definitions(-D_LINUX_SOURCE) + endif() endif() # ############################################################################## From 868e9916bc1ee03ab68c4abeeae0838aa6b1239a Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:38:41 +0200 Subject: [PATCH 167/332] Grid preferences update (#11547) * Refactor RifReaderSettings and grid preferences tab --- .../Application/CMakeLists_files.cmake | 2 + .../Application/RiaConsoleApplication.cpp | 3 +- .../Application/RiaGuiApplication.cpp | 3 +- .../Application/RiaPreferences.cpp | 89 +----- .../Application/RiaPreferences.h | 18 +- .../Application/RiaPreferencesGrid.cpp | 300 ++++++++++++++++++ .../Application/RiaPreferencesGrid.h | 78 +++++ .../Tools/RiaImportEclipseCaseTools.cpp | 55 ++-- .../Tools/RiaImportEclipseCaseTools.h | 25 +- .../CommandFileInterface/RicfLoadCase.cpp | 7 +- .../RicImportEclipseCaseFeature.cpp | 7 +- .../RicCreateEnsembleWellLogFeature.cpp | 5 +- .../Commands/RicImportGeneralDataFeature.cpp | 28 +- .../Commands/RicImportGeneralDataFeature.h | 19 +- .../Commands/RicNewContourMapViewFeature.cpp | 4 +- .../FileInterface/CMakeLists_files.cmake | 1 - .../RifEclipseUnifiedRestartFileAccess.cpp | 9 +- .../FileInterface/RifReaderEclipseOutput.cpp | 1 - .../FileInterface/RifReaderInterface.cpp | 57 ++-- .../FileInterface/RifReaderInterface.h | 24 +- .../FileInterface/RifReaderSettings.cpp | 110 ------- .../FileInterface/RifReaderSettings.h | 33 +- .../ProjectDataModel/RimEclipseCase.cpp | 22 +- .../ProjectDataModel/RimEclipseCase.h | 16 +- .../RimEclipseCaseCollection.cpp | 3 - .../ProjectDataModel/RimEclipseInputCase.cpp | 7 +- .../ProjectDataModel/RimEclipseResultCase.cpp | 7 +- .../ProjectDataModel/RimEmCase.cpp | 4 +- .../ProjectDataModel/RimReloadCaseTools.cpp | 6 +- .../ProjectDataModel/RimRoffCase.cpp | 4 +- .../RigCaseCellResultsData.cpp | 6 +- .../UnitTests/RifReaderEclipseOutput-Test.cpp | 1 - 32 files changed, 566 insertions(+), 388 deletions(-) create mode 100644 ApplicationLibCode/Application/RiaPreferencesGrid.cpp create mode 100644 ApplicationLibCode/Application/RiaPreferencesGrid.h delete mode 100644 ApplicationLibCode/FileInterface/RifReaderSettings.cpp diff --git a/ApplicationLibCode/Application/CMakeLists_files.cmake b/ApplicationLibCode/Application/CMakeLists_files.cmake index c6952c80a2..55bb5fa2e1 100644 --- a/ApplicationLibCode/Application/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/CMakeLists_files.cmake @@ -8,6 +8,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaPreferences.h ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSummary.h ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGeoMech.h + ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGrid.h ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.h ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.h ${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.h @@ -50,6 +51,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaPreferences.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSummary.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGeoMech.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGrid.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.cpp diff --git a/ApplicationLibCode/Application/RiaConsoleApplication.cpp b/ApplicationLibCode/Application/RiaConsoleApplication.cpp index b0a3e65dc8..eb5ff1b85c 100644 --- a/ApplicationLibCode/Application/RiaConsoleApplication.cpp +++ b/ApplicationLibCode/Application/RiaConsoleApplication.cpp @@ -20,6 +20,7 @@ #include "RiaArgumentParser.h" #include "RiaLogging.h" #include "RiaPreferences.h" +#include "RiaPreferencesGrid.h" #include "RiaProjectModifier.h" #include "RiaSocketServer.h" #include "RiaVersionInfo.h" @@ -165,7 +166,7 @@ RiaApplication::ApplicationStatus RiaConsoleApplication::handleArguments( gsl::n { CVF_ASSERT( o.valueCount() == 1 ); std::string readerName = o.value( 0 ).toLower().toStdString(); - m_preferences->setGridModelReaderOverride( readerName ); + m_preferences->gridPreferences()->setGridModelReaderOverride( readerName ); } QString projectFileName; diff --git a/ApplicationLibCode/Application/RiaGuiApplication.cpp b/ApplicationLibCode/Application/RiaGuiApplication.cpp index 8aee18445f..8fee5f12cd 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.cpp +++ b/ApplicationLibCode/Application/RiaGuiApplication.cpp @@ -30,6 +30,7 @@ #include "RiaLogging.h" #include "RiaPlotWindowRedrawScheduler.h" #include "RiaPreferences.h" +#include "RiaPreferencesGrid.h" #include "RiaPreferencesSystem.h" #include "RiaProjectModifier.h" #include "RiaRegressionTestRunner.h" @@ -525,7 +526,7 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n { CVF_ASSERT( o.valueCount() == 1 ); std::string readerName = o.value( 0 ).toLower().toStdString(); - m_preferences->setGridModelReaderOverride( readerName ); + m_preferences->gridPreferences()->setGridModelReaderOverride( readerName ); } if ( cvf::Option o = progOpt->option( "size" ) ) diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index 6174a0d9df..ba163931a0 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -25,12 +25,12 @@ #include "RiaColorTables.h" #include "RiaLogging.h" #include "RiaPreferencesGeoMech.h" +#include "RiaPreferencesGrid.h" #include "RiaPreferencesSummary.h" #include "RiaPreferencesSystem.h" #include "RiaQDateTimeTools.h" #include "RiaValidRegExpValidator.h" -#include "RifReaderSettings.h" #include "RiuGuiTheme.h" #include "cafPdmFieldCvfColor.h" @@ -82,7 +82,6 @@ CAF_PDM_SOURCE_INIT( RiaPreferences, "RiaPreferences" ); /// //-------------------------------------------------------------------------------------------------- RiaPreferences::RiaPreferences() - : m_gridModelReaderOverride( RiaDefines::GridModelReader::NOT_SET ) { CAF_PDM_InitField( &m_navigationPolicy, "navigationPolicy", @@ -194,18 +193,6 @@ RiaPreferences::RiaPreferences() CAF_PDM_InitFieldNoDefault( &lastUsedProjectFileName, "lastUsedProjectFileName", "Last Used Project File" ); lastUsedProjectFileName.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &autocomputeDepthRelatedProperties, - "autocomputeDepth", - true, - "Compute DEPTH Related Properties", - "", - "DEPTH, DX, DY, DZ, TOP, BOTTOM", - "" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &autocomputeDepthRelatedProperties ); - - CAF_PDM_InitField( &loadAndShowSoil, "loadAndShowSoil", true, "Load and Show SOIL" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &loadAndShowSoil ); - CAF_PDM_InitField( &holoLensDisableCertificateVerification, "holoLensDisableCertificateVerification", false, @@ -214,10 +201,6 @@ RiaPreferences::RiaPreferences() CAF_PDM_InitField( &csvTextExportFieldSeparator, "csvTextExportFieldSeparator", QString( "," ), "CSV Text Export Field Separator" ); - CAF_PDM_InitFieldNoDefault( &m_gridModelReader, "gridModelReader", "Grid Model Reader" ); - - CAF_PDM_InitFieldNoDefault( &m_readerSettings, "readerSettings", "Reader Settings" ); - m_readerSettings = new RifReaderSettings; CAF_PDM_InitFieldNoDefault( &m_dateFormat, "dateFormat", "Date Format" ); m_dateFormat.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); m_dateFormat = RiaQDateTimeTools::supportedDateFormats().front(); @@ -279,6 +262,9 @@ RiaPreferences::RiaPreferences() CAF_PDM_InitFieldNoDefault( &m_summaryPreferences, "summaryPreferences", "summaryPreferences" ); m_summaryPreferences = new RiaPreferencesSummary; + CAF_PDM_InitFieldNoDefault( &m_gridPreferences, "gridPreferences", "gridPreferences" ); + m_gridPreferences = new RiaPreferencesGrid(); + CAF_PDM_InitFieldNoDefault( &m_geoMechPreferences, "geoMechPreferences", "geoMechPreferences" ); m_geoMechPreferences = new RiaPreferencesGeoMech; @@ -294,7 +280,6 @@ RiaPreferences::RiaPreferences() //-------------------------------------------------------------------------------------------------- RiaPreferences::~RiaPreferences() { - delete m_readerSettings; } //-------------------------------------------------------------------------------------------------- @@ -310,7 +295,6 @@ RiaPreferences* RiaPreferences::current() //-------------------------------------------------------------------------------------------------- void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { - m_readerSettings->defineEditorAttribute( field, uiConfigName, attribute ); m_summaryPreferences->defineEditorAttribute( field, uiConfigName, attribute ); { @@ -393,13 +377,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& } else if ( uiConfigName == RiaPreferences::tabNameGrid() ) { - if ( m_gridModelReaderOverride == RiaDefines::GridModelReader::NOT_SET ) uiOrdering.add( &m_gridModelReader ); - - caf::PdmUiGroup* newCaseBehaviourGroup = uiOrdering.addNewGroup( "Behavior When Loading Data" ); - newCaseBehaviourGroup->add( &autocomputeDepthRelatedProperties ); - newCaseBehaviourGroup->add( &loadAndShowSoil ); - - m_readerSettings->uiOrdering( uiConfigName, *newCaseBehaviourGroup ); + m_gridPreferences()->appendItems( uiOrdering ); } else if ( uiConfigName == RiaPreferences::tabNameSummary() ) { @@ -685,55 +663,6 @@ QStringList RiaPreferences::tabNames() return names; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const RifReaderSettings* RiaPreferences::readerSettings() const -{ - return m_readerSettings; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RiaDefines::GridModelReader RiaPreferences::gridModelReader() const -{ - if ( m_gridModelReaderOverride != RiaDefines::GridModelReader::NOT_SET ) - { - return m_gridModelReaderOverride; - } - - return m_gridModelReader(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaPreferences::setGridModelReaderOverride( const std::string& readerName ) -{ - RiaDefines::GridModelReader readerType = RiaDefines::GridModelReader::NOT_SET; - if ( readerName == "opm_common" ) - { - readerType = RiaDefines::GridModelReader::OPM_COMMON; - } - else if ( readerName == "resdata" ) - { - readerType = RiaDefines::GridModelReader::RESDATA; - } - else - { - RiaLogging::warning( QString::fromStdString( "Unknown EGRID reader type specified on command line: " + readerName ) ); - return; - } - - if ( readerType != RiaDefines::GridModelReader::NOT_SET ) - { - RiaLogging::info( QString::fromStdString( "Using EGRID reader: " + readerName ) ); - } - - m_gridModelReaderOverride = readerType; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1106,3 +1035,11 @@ bool RiaPreferences::enableFaultsByDefault() const { return m_enableFaultsByDefault; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesGrid* RiaPreferences::gridPreferences() const +{ + return m_gridPreferences(); +} diff --git a/ApplicationLibCode/Application/RiaPreferences.h b/ApplicationLibCode/Application/RiaPreferences.h index 2ff2e814a0..89d8964805 100644 --- a/ApplicationLibCode/Application/RiaPreferences.h +++ b/ApplicationLibCode/Application/RiaPreferences.h @@ -41,11 +41,11 @@ #include #include -class RifReaderSettings; class RiaPreferencesSummary; class RiaPreferencesGeoMech; class RiaPreferencesSystem; class RiaPreferencesOsdu; +class RiaPreferencesGrid; //-------------------------------------------------------------------------------------------------- /// @@ -58,7 +58,6 @@ class RiaPreferences : public caf::PdmObject using FontSizeEnum = RiaFontCache::FontSizeEnum; using PageSizeEnum = caf::AppEnum; using PageOrientationEnum = caf::AppEnum; - using GridModelEnum = caf::AppEnum; bool enableFaultsByDefault() const; @@ -70,10 +69,6 @@ class RiaPreferences : public caf::PdmObject QStringList tabNames(); - const RifReaderSettings* readerSettings() const; - RiaDefines::GridModelReader gridModelReader() const; - void setGridModelReaderOverride( const std::string& readerName ); - bool useUndoRedo() const; const QString& dateFormat() const; @@ -134,6 +129,7 @@ class RiaPreferences : public caf::PdmObject RiaPreferencesSummary* summaryPreferences() const; RiaPreferencesSystem* systemPreferences() const; RiaPreferencesOsdu* osduPreferences() const; + RiaPreferencesGrid* gridPreferences() const; public: caf::PdmField enableGrpcServer; @@ -157,9 +153,6 @@ class RiaPreferences : public caf::PdmObject caf::PdmField lastUsedProjectFileName; - caf::PdmField autocomputeDepthRelatedProperties; - caf::PdmField loadAndShowSoil; - caf::PdmField holoLensDisableCertificateVerification; caf::PdmField csvTextExportFieldSeparator; @@ -184,10 +177,6 @@ class RiaPreferences : public caf::PdmObject static double defaultMarginSize( QPageSize::PageSizeId pageSizeId ); private: - caf::PdmField m_gridModelReader; - RiaDefines::GridModelReader m_gridModelReaderOverride; - caf::PdmChildField m_readerSettings; - caf::PdmField m_dateFormat; caf::PdmField m_timeFormat; @@ -235,6 +224,9 @@ class RiaPreferences : public caf::PdmObject // Well Path Import caf::PdmField m_multiLateralWellPattern; + // Grid import + caf::PdmChildField m_gridPreferences; + // GeoMech things caf::PdmChildField m_geoMechPreferences; diff --git a/ApplicationLibCode/Application/RiaPreferencesGrid.cpp b/ApplicationLibCode/Application/RiaPreferencesGrid.cpp new file mode 100644 index 0000000000..151401e58c --- /dev/null +++ b/ApplicationLibCode/Application/RiaPreferencesGrid.cpp @@ -0,0 +1,300 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 - 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 "RiaPreferencesGrid.h" + +#include "RiaApplication.h" +#include "RiaLogging.h" +#include "RiaPreferences.h" + +#include "cafPdmUiCheckBoxEditor.h" + +CAF_PDM_SOURCE_INIT( RiaPreferencesGrid, "RifReaderSettings" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesGrid::RiaPreferencesGrid() + : m_gridModelReaderOverride( RiaDefines::GridModelReader::NOT_SET ) +{ + CAF_PDM_InitObject( "RiaPreferencesGrid" ); + + CAF_PDM_InitFieldNoDefault( &m_gridModelReader, "gridModelReader", "Model Reader" ); + m_gridModelReader = RiaDefines::GridModelReader::RESDATA; + + CAF_PDM_InitField( &m_importFaults, "importFaults", true, "Import Faults" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_importFaults ); + + CAF_PDM_InitField( &m_importNNCs, "importSimulationNNCs", true, "Import NNCs" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_importNNCs ); + + CAF_PDM_InitField( &m_includeInactiveCellsInFaultGeometry, + "includeInactiveCellsInFaultGeometry", + false, + "Include Inactive Cells in Fault Geometry" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_includeInactiveCellsInFaultGeometry ); + + CAF_PDM_InitField( &m_importAdvancedMswData, "importAdvancedMswData", true, "Import Advanced MSW Data" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_importAdvancedMswData ); + + CAF_PDM_InitField( &m_useResultIndexFile, + "useResultIndexFile", + false, + "Use Result Index File", + "", + "After import of a result file, store index data in an index file in the same folder as the " + "result file.\n" + "Import of result data if a result index file is present, will reduce file parsing " + "significantly.", + "" ); + + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useResultIndexFile ); + + CAF_PDM_InitField( &m_skipWellData, "skipWellData", false, "Skip Import of Simulation Well Data" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_skipWellData ); + + CAF_PDM_InitField( &m_includeFileAbsolutePathPrefix, + "includeFileAbsolutePathPrefix", + QString(), + "Include File Absolute Path Prefix", + "", + "Path used to prefix absolute UNIX paths in include statements on Windows, used when searching " + "for FAULTS and EQUIL", + "" ); + + CAF_PDM_InitField( &m_autoComputeDepthRelatedProperties, + "autocomputeDepth", + true, + "Compute DEPTH Related Properties", + "", + "DEPTH, DX, DY, DZ, TOP, BOTTOM", + "" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_autoComputeDepthRelatedProperties ); + + CAF_PDM_InitField( &m_loadAndShowSoil, "loadAndShowSoil", true, "Load and Show SOIL" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_loadAndShowSoil ); + + CAF_PDM_InitField( &m_onlyLoadActiveCells, "onlyLoadActiveCells", false, "Only Load Active Cell Geometry" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_onlyLoadActiveCells ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesGrid* RiaPreferencesGrid::current() +{ + return RiaApplication::instance()->preferences()->gridPreferences(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesGrid::appendItems( caf::PdmUiOrdering& uiOrdering ) +{ + auto newCBGroup = uiOrdering.addNewGroup( "Behavior When Loading Data" ); + newCBGroup->add( &m_autoComputeDepthRelatedProperties ); + newCBGroup->add( &m_loadAndShowSoil ); + + auto faultGrp = uiOrdering.addNewGroup( "Fault Import" ); + + faultGrp->add( &m_importFaults ); + faultGrp->add( &m_includeInactiveCellsInFaultGeometry ); +#ifdef WIN32 + faultGrp->add( &m_includeFileAbsolutePathPrefix ); +#endif + faultGrp->add( &m_importNNCs ); + + auto wellGrp = uiOrdering.addNewGroup( "Well Import" ); + + wellGrp->add( &m_skipWellData ); + wellGrp->add( &m_importAdvancedMswData ); + + if ( m_gridModelReaderOverride == RiaDefines::GridModelReader::NOT_SET ) + { + auto egridGrp = uiOrdering.addNewGroup( "EGRID Settings" ); + egridGrp->add( &m_gridModelReader ); + } + + auto resdataGrp = uiOrdering.addNewGroup( "ResData Reader Settings" ); + resdataGrp->add( &m_useResultIndexFile ); + + auto opmcGrp = uiOrdering.addNewGroup( "OPM Common Reader Settings" ); + opmcGrp->add( &m_onlyLoadActiveCells ); + + const bool setFaultImportSettingsReadOnly = !importFaults(); + + m_includeInactiveCellsInFaultGeometry.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly ); + m_includeFileAbsolutePathPrefix.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly ); + m_importNNCs.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderSettings RiaPreferencesGrid::gridOnlyReaderSettings() +{ + RifReaderSettings rs{ + // Disable as much as possible + false, // import faults + false, // import NNCs + false, // includeInactiveCellsInFaultGeometry + false, // importAdvancedMswData + false, // useResultIndexFile + true, // skipWellData + false, // import summary data + "" // include prefix + }; + return rs; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderSettings RiaPreferencesGrid::readerSettings() +{ + RifReaderSettings rs{ m_importFaults, + m_importNNCs, + m_includeInactiveCellsInFaultGeometry, + m_importAdvancedMswData, + m_useResultIndexFile, + m_skipWellData, + true, // import summary data + m_includeFileAbsolutePathPrefix }; + return rs; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesGrid::importFaults() const +{ + return m_importFaults; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesGrid::importNNCs() const +{ + return m_importNNCs; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesGrid::includeInactiveCellsInFaultGeometry() const +{ + return m_includeInactiveCellsInFaultGeometry; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesGrid::importAdvancedMswData() const +{ + return m_importAdvancedMswData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesGrid::includeFileAbsolutePathPrefix() const +{ + return m_includeFileAbsolutePathPrefix; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesGrid::useResultIndexFile() const +{ + return m_useResultIndexFile; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesGrid::skipWellData() const +{ + return m_skipWellData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesGrid::loadAndShowSoil() const +{ + return m_loadAndShowSoil; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesGrid::autoComputeDepthRelatedProperties() const +{ + return m_autoComputeDepthRelatedProperties; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesGrid::onlyLoadActiveCells() const +{ + return m_onlyLoadActiveCells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaDefines::GridModelReader RiaPreferencesGrid::gridModelReader() const +{ + if ( m_gridModelReaderOverride != RiaDefines::GridModelReader::NOT_SET ) + { + return m_gridModelReaderOverride; + } + + return m_gridModelReader(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesGrid::setGridModelReaderOverride( const std::string& readerName ) +{ + RiaDefines::GridModelReader readerType = RiaDefines::GridModelReader::NOT_SET; + if ( readerName == "opm_common" ) + { + readerType = RiaDefines::GridModelReader::OPM_COMMON; + } + else if ( readerName == "resdata" ) + { + readerType = RiaDefines::GridModelReader::RESDATA; + } + else + { + RiaLogging::warning( QString::fromStdString( "Unknown EGRID reader type specified on command line: " + readerName ) ); + return; + } + + if ( readerType != RiaDefines::GridModelReader::NOT_SET ) + { + RiaLogging::info( QString::fromStdString( "Using EGRID reader: " + readerName ) ); + } + + m_gridModelReaderOverride = readerType; +} diff --git a/ApplicationLibCode/Application/RiaPreferencesGrid.h b/ApplicationLibCode/Application/RiaPreferencesGrid.h new file mode 100644 index 0000000000..9c2d4ec63a --- /dev/null +++ b/ApplicationLibCode/Application/RiaPreferencesGrid.h @@ -0,0 +1,78 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// Copyright (C) Ceetron Solutions AS +// +// 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 "cafPdmField.h" +#include "cafPdmObject.h" + +#include "RiaDefines.h" + +#include "RifReaderSettings.h" + +#include + +//================================================================================================== +/// +/// +//================================================================================================== +class RiaPreferencesGrid : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + + using GridModelEnum = caf::AppEnum; + +public: + RiaPreferencesGrid(); + + static RiaPreferencesGrid* current(); + static RifReaderSettings gridOnlyReaderSettings(); + RifReaderSettings readerSettings(); + + bool importFaults() const; + bool importNNCs() const; + bool includeInactiveCellsInFaultGeometry() const; + bool importAdvancedMswData() const; + QString includeFileAbsolutePathPrefix() const; + bool useResultIndexFile() const; + bool skipWellData() const; + bool loadAndShowSoil() const; + bool autoComputeDepthRelatedProperties() const; + bool onlyLoadActiveCells() const; + + RiaDefines::GridModelReader gridModelReader() const; + void setGridModelReaderOverride( const std::string& readerName ); + + void appendItems( caf::PdmUiOrdering& uiOrdering ); + +private: + caf::PdmField m_gridModelReader; + RiaDefines::GridModelReader m_gridModelReaderOverride; + + caf::PdmField m_importFaults; + caf::PdmField m_importNNCs; + caf::PdmField m_includeInactiveCellsInFaultGeometry; + caf::PdmField m_importAdvancedMswData; + caf::PdmField m_includeFileAbsolutePathPrefix; + caf::PdmField m_useResultIndexFile; + caf::PdmField m_skipWellData; + caf::PdmField m_autoComputeDepthRelatedProperties; + caf::PdmField m_loadAndShowSoil; + caf::PdmField m_onlyLoadActiveCells; +}; diff --git a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp index 1bd15d442f..1f53a5db39 100644 --- a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -26,6 +26,7 @@ #include "RiaGuiApplication.h" #include "RiaLogging.h" +#include "RiaPreferencesGrid.h" #include "RifEclipseSummaryTools.h" #include "RifReaderSettings.h" @@ -68,11 +69,20 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& fileNames, - bool createView, - FileCaseIdMap* openedFilesOut, - bool noDialog, - std::shared_ptr readerSettings ) +bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& fileNames, bool createView, FileCaseIdMap* openedFilesOut, bool noDialog ) +{ + RifReaderSettings rs = RiaPreferencesGrid::current()->readerSettings(); + return openEclipseCasesFromFile( fileNames, createView, openedFilesOut, noDialog, rs ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& fileNames, + bool createView, + FileCaseIdMap* openedFilesOut, + bool noDialog, + RifReaderSettings& readerSettings ) { RimProject* project = RimProject::current(); if ( !project ) return false; @@ -100,16 +110,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& RimMainPlotCollection::current()->ensureDefaultFlowPlotsAreCreated(); } - // The default value for summary case import is true, but we use the state from RifReaderSettings if defined - // - // TODO: - // Refactor RifReaderSettings, separate the data structure sent to reader from the data structure in - // preferences. See RifReaderSettings::createGridOnlyReaderSettings() for the only use of importSummaryData flag - // - bool importSummaryCases = true; - if ( readerSettings ) importSummaryCases = readerSettings->importSummaryData; - - if ( importSummaryCases && !summaryFileInfos.empty() ) + if ( readerSettings.importSummaryData && !summaryFileInfos.empty() ) { RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; @@ -228,7 +229,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RiaImportEclipseCaseTools::openEclipseCaseFromFile( const QString& fileName, bool createView, std::shared_ptr readerSettings ) +int RiaImportEclipseCaseTools::openEclipseCaseFromFile( const QString& fileName, bool createView, RifReaderSettings& readerSettings ) { if ( !caf::Utils::fileExists( fileName ) ) return -1; @@ -243,9 +244,10 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilter( const QString { if ( !caf::Utils::fileExists( fileName ) ) return false; - bool showTimeStepFilter = true; - bool createView = true; - return RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( fileName, showTimeStepFilter, createView, nullptr ) >= 0; + bool showTimeStepFilter = true; + bool createView = true; + RifReaderSettings rs = RiaPreferencesGrid::current()->readerSettings(); + return RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( fileName, showTimeStepFilter, createView, rs ) >= 0; } //-------------------------------------------------------------------------------------------------- @@ -318,18 +320,19 @@ std::vector RiaImportEclipseCaseTools::openEclipseInputCasesFromFileNames( //-------------------------------------------------------------------------------------------------- bool RiaImportEclipseCaseTools::openMockModel( const QString& name ) { - bool showTimeStepFilter = false; - bool createView = true; - return RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( name, showTimeStepFilter, createView, nullptr ); + bool showTimeStepFilter = false; + bool createView = true; + RifReaderSettings rs = RiaPreferencesGrid::current()->readerSettings(); + return RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( name, showTimeStepFilter, createView, rs ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( const QString& fileName, - bool showTimeStepFilter, - bool createView, - std::shared_ptr readerSettings ) +int RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( const QString& fileName, + bool showTimeStepFilter, + bool createView, + RifReaderSettings& readerSettings ) { RimProject* project = RimProject::current(); if ( !project ) return -1; diff --git a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h index ec6be06c67..e3a52837f1 100644 --- a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h +++ b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h @@ -20,6 +20,8 @@ #include +#include "RifReaderSettings.h" + #include #include #include @@ -29,7 +31,6 @@ class QString; class RimIdenticalGridCaseGroup; class RimRoffCase; -class RifReaderSettings; //================================================================================================== /// @@ -40,11 +41,13 @@ class RiaImportEclipseCaseTools using CaseFileNameAndId = std::pair; using FileCaseIdMap = std::map; - static bool openEclipseCasesFromFile( const QStringList& fileNames, - bool createView, - FileCaseIdMap* openedFilesOut, - bool noDialog, - std::shared_ptr readerSettings = nullptr ); + static bool openEclipseCasesFromFile( const QStringList& fileNames, bool createView, FileCaseIdMap* openedFilesOut, bool noDialog ); + + static bool openEclipseCasesFromFile( const QStringList& fileNames, + bool createView, + FileCaseIdMap* openedFilesOut, + bool noDialog, + RifReaderSettings& readerSettings ); static bool openEclipseCaseShowTimeStepFilter( const QString& fileName ); @@ -55,7 +58,7 @@ class RiaImportEclipseCaseTools static bool addEclipseCases( const QStringList& fileNames, RimIdenticalGridCaseGroup** resultingCaseGroup = nullptr ); - static int openEclipseCaseFromFile( const QString& fileName, bool createView, std::shared_ptr readerSettings = nullptr ); + static int openEclipseCaseFromFile( const QString& fileName, bool createView, RifReaderSettings& readerSettings ); static std::vector openRoffCasesFromFileNames( const QStringList& fileNames, bool createDefaultView ); static RimRoffCase* openRoffCaseFromFileName( const QString& fileName, bool createDefaultView ); @@ -63,8 +66,8 @@ class RiaImportEclipseCaseTools static bool openEmFilesFromFileNames( const QStringList& fileNames, bool createDefaultView, std::vector& createdCaseIds ); private: - static int openEclipseCaseShowTimeStepFilterImpl( const QString& fileName, - bool showTimeStepFilter, - bool createView, - std::shared_ptr readerSettings ); + static int openEclipseCaseShowTimeStepFilterImpl( const QString& fileName, + bool showTimeStepFilter, + bool createView, + RifReaderSettings& readerSettings ); }; diff --git a/ApplicationLibCode/CommandFileInterface/RicfLoadCase.cpp b/ApplicationLibCode/CommandFileInterface/RicfLoadCase.cpp index dd42b79ea2..9107cba8da 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfLoadCase.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfLoadCase.cpp @@ -21,9 +21,12 @@ #include "RiaApplication.h" #include "RiaLogging.h" +#include "RiaPreferencesGrid.h" + #include "RicImportGeneralDataFeature.h" #include "RifReaderSettings.h" + #include "cafPdmFieldScriptingCapability.h" #include @@ -65,8 +68,8 @@ caf::PdmScriptResponse RicfLoadCase::execute() absolutePath = startDir.absoluteFilePath( m_path ); } - std::shared_ptr readerSettings; - if ( m_gridOnly ) readerSettings = RifReaderSettings::createGridOnlyReaderSettings(); + RifReaderSettings readerSettings = m_gridOnly ? RiaPreferencesGrid::current()->gridOnlyReaderSettings() + : RiaPreferencesGrid::current()->readerSettings(); bool createPlot = false; bool createView = false; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp index 4133ef4320..8d85dcaaf0 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp @@ -20,6 +20,7 @@ #include "RicImportEclipseCaseFeature.h" #include "RiaApplication.h" +#include "RiaPreferencesGrid.h" #include "RimEclipseCaseCollection.h" @@ -51,9 +52,9 @@ void RicImportEclipseCaseFeature::onActionTriggered( bool isChecked ) defaultDir = QFileInfo( fileNames.last() ).absolutePath(); app->setLastUsedDialogDirectory( "BINARY_GRID", defaultDir ); - bool createDefaultView = true; - std::vector caseIds; - std::shared_ptr readerSettings; + bool createDefaultView = true; + std::vector caseIds; + RifReaderSettings readerSettings = RiaPreferencesGrid::current()->readerSettings(); openEclipseCaseFromFileNames( fileNames, createDefaultView, caseIds, readerSettings ); for ( const auto& f : fileNames ) diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp index 9d99f6f8a4..d75eccdb7e 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp @@ -22,6 +22,7 @@ #include "RiaColorTables.h" #include "RiaImportEclipseCaseTools.h" #include "RiaLogging.h" +#include "RiaPreferencesGrid.h" #include "ExportCommands/RicExportToLasFileFeature.h" #include "RicCloseCaseFeature.h" @@ -280,8 +281,8 @@ RimEclipseCase* RicCreateEnsembleWellLogFeature::loadEclipseCase( const QString& bool createView = false; bool createPlot = false; - std::shared_ptr readerSettings = RifReaderSettings::createGridOnlyReaderSettings(); - auto openResult = + RifReaderSettings readerSettings = RiaPreferencesGrid::current()->gridOnlyReaderSettings(); + auto openResult = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList( { absolutePath } ), createPlot, createView, readerSettings ); if ( !openResult.createdCaseIds.empty() ) diff --git a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp index 822ca97660..f585c004d1 100644 --- a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp @@ -22,6 +22,7 @@ #include "RiaEclipseFileNameTools.h" #include "RiaImportEclipseCaseTools.h" #include "RiaLogging.h" +#include "RiaPreferencesGrid.h" #include "RicImportSummaryCasesFeature.h" @@ -47,10 +48,19 @@ CAF_CMD_SOURCE_INIT( RicImportGeneralDataFeature, "RicImportGeneralDataFeature" /// //-------------------------------------------------------------------------------------------------- RicImportGeneralDataFeature::OpenCaseResults - RicImportGeneralDataFeature::openEclipseFilesFromFileNames( const QStringList& fileNames, - bool doCreateDefaultPlot, - bool createDefaultView, - std::shared_ptr readerSettings ) + RicImportGeneralDataFeature::openEclipseFilesFromFileNames( const QStringList& fileNames, bool doCreateDefaultPlot, bool createDefaultView ) +{ + RifReaderSettings rs = RiaPreferencesGrid::current()->readerSettings(); + return openEclipseFilesFromFileNames( fileNames, doCreateDefaultPlot, createDefaultView, rs ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicImportGeneralDataFeature::OpenCaseResults RicImportGeneralDataFeature::openEclipseFilesFromFileNames( const QStringList& fileNames, + bool doCreateDefaultPlot, + bool createDefaultView, + RifReaderSettings& readerSettings ) { CVF_ASSERT( !fileNames.empty() ); @@ -303,7 +313,7 @@ void RicImportGeneralDataFeature::openFileDialog( ImportFileType fileTypes ) RiaApplication::instance()->setLastUsedDialogDirectory( defaultDirectoryLabel( ImportFileType::ANY_ECLIPSE_FILE ), fileNames.front() ); } - if ( !openEclipseFilesFromFileNames( fileNames, true, true, nullptr ) ) + if ( !openEclipseFilesFromFileNames( fileNames, true, true ) ) { RiaLogging::error( QString( "Failed to open file names: %1" ).arg( fileNames.join( ", " ) ) ); } @@ -319,10 +329,10 @@ void RicImportGeneralDataFeature::openFileDialog( ImportFileType fileTypes ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicImportGeneralDataFeature::openEclipseCaseFromFileNames( const QStringList& fileNames, - bool createDefaultView, - std::vector& createdCaseIds, - std::shared_ptr readerSettings ) +bool RicImportGeneralDataFeature::openEclipseCaseFromFileNames( const QStringList& fileNames, + bool createDefaultView, + std::vector& createdCaseIds, + RifReaderSettings& readerSettings ) { bool noDialog = false; RiaImportEclipseCaseTools::FileCaseIdMap newCaseFiles; diff --git a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.h b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.h index c8298e5e36..34a3932b69 100644 --- a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.h +++ b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.h @@ -27,7 +27,7 @@ #include #include -class RifReaderSettings; +#include "RifReaderSettings.h" //================================================================================================== /// @@ -52,10 +52,11 @@ class RicImportGeneralDataFeature : public caf::CmdFeature } }; - static OpenCaseResults openEclipseFilesFromFileNames( const QStringList& fileNames, - bool doCreateDefaultPlot, - bool createDefaultView, - std::shared_ptr readerSettings = nullptr ); + static OpenCaseResults openEclipseFilesFromFileNames( const QStringList& fileNames, bool doCreateDefaultPlot, bool createDefaultView ); + static OpenCaseResults openEclipseFilesFromFileNames( const QStringList& fileNames, + bool doCreateDefaultPlot, + bool createDefaultView, + RifReaderSettings& readerSettings ); static QStringList fileNamesFromCaseNames( const QStringList& caseNames ); static QStringList getEclipseFileNamesWithDialog( RiaDefines::ImportFileType fileTypes ); @@ -69,10 +70,10 @@ class RicImportGeneralDataFeature : public caf::CmdFeature static void openFileDialog( RiaDefines::ImportFileType fileTypes ); - static bool openEclipseCaseFromFileNames( const QStringList& fileNames, - bool createDefaultView, - std::vector& createdCaseIds, - std::shared_ptr readerSettings ); + static bool openEclipseCaseFromFileNames( const QStringList& fileNames, + bool createDefaultView, + std::vector& createdCaseIds, + RifReaderSettings& readerSettings ); static bool openSummaryCaseFromFileNames( const QStringList& fileNames, bool doCreateDefaultPlot = true ); diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp index 8db4c901e2..7d71506328 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp @@ -50,7 +50,7 @@ #include "RiaColorTools.h" #include "RiaLogging.h" -#include "RiaPreferences.h" +#include "RiaPreferencesGrid.h" #include "cafPdmDocument.h" #include "cafSelectionManager.h" @@ -438,7 +438,7 @@ void RicNewContourMapViewFeature::assignDefaultResultAndLegend( RimEclipseContou { contourMap->cellResult()->setResultType( RiaDefines::ResultCatType::DYNAMIC_NATIVE ); - if ( RiaPreferences::current()->loadAndShowSoil ) + if ( RiaPreferencesGrid::current()->loadAndShowSoil() ) { contourMap->cellResult()->setResultVariable( "SOIL" ); } diff --git a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake index b70fb67ef0..89777e2723 100644 --- a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake @@ -128,7 +128,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RifJsonEncodeDecode.cpp ${CMAKE_CURRENT_LIST_DIR}/RifReaderInterface.cpp ${CMAKE_CURRENT_LIST_DIR}/RifReaderMockModel.cpp - ${CMAKE_CURRENT_LIST_DIR}/RifReaderSettings.cpp ${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryAddress.cpp ${CMAKE_CURRENT_LIST_DIR}/RifEclipseRftAddress.cpp ${CMAKE_CURRENT_LIST_DIR}/RifWellPathImporter.cpp diff --git a/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp b/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp index da983b20c5..81a7fd9322 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp @@ -21,11 +21,10 @@ #include "RifEclipseUnifiedRestartFileAccess.h" #include "RiaLogging.h" -#include "RiaPreferences.h" +#include "RiaPreferencesGrid.h" #include "RiaStringEncodingTools.h" #include "RifEclipseOutputFileTools.h" -#include "RifReaderSettings.h" #include "ert/ecl/ecl_file.h" #include "ert/ecl/ecl_kw_magic.h" @@ -135,10 +134,8 @@ bool RifEclipseUnifiedRestartFileAccess::openFile() //-------------------------------------------------------------------------------------------------- bool RifEclipseUnifiedRestartFileAccess::useResultIndexFile() const { - RiaPreferences* prefs = RiaPreferences::current(); - const RifReaderSettings* readerSettings = prefs->readerSettings(); - - return readerSettings->useResultIndexFile(); + RiaPreferencesGrid* prefs = RiaPreferencesGrid::current(); + return prefs->useResultIndexFile(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp index 1ecab114bd..17c842596d 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp @@ -32,7 +32,6 @@ #include "RifHdf5ReaderInterface.h" #include "RifOpmRadialGridTools.h" #include "RifReaderEclipseWell.h" -#include "RifReaderSettings.h" #ifdef USE_HDF5 #include "RifHdf5Reader.h" diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp index 6fb8becd86..05ddf0983a 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp @@ -19,57 +19,65 @@ #include "RifReaderInterface.h" -#include "RiaPreferences.h" +#include "RiaPreferencesGrid.h" #include "RifEclipseInputFileTools.h" -#include "RifReaderSettings.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderInterface::isFaultImportEnabled() +RifReaderInterface::RifReaderInterface() { - return readerSettings()->importFaults; + RiaPreferencesGrid* prefs = RiaPreferencesGrid::current(); + m_readerSettings = prefs->readerSettings(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderInterface::isImportOfCompleteMswDataEnabled() +bool RifReaderInterface::isFaultImportEnabled() const { - return readerSettings()->importAdvancedMswData; + return m_readerSettings.importFaults; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderInterface::isNNCsEnabled() +bool RifReaderInterface::isImportOfCompleteMswDataEnabled() const { - return readerSettings()->importNNCs; + return m_readerSettings.importAdvancedMswData; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderInterface::loadWellDataEnabled() +bool RifReaderInterface::isNNCsEnabled() const { - return !readerSettings()->skipWellData; + return m_readerSettings.importNNCs; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderInterface::includeInactiveCellsInFaultGeometry() +bool RifReaderInterface::loadWellDataEnabled() const { - return readerSettings()->includeInactiveCellsInFaultGeometry(); + return !m_readerSettings.skipWellData; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const QString RifReaderInterface::faultIncludeFileAbsolutePathPrefix() +bool RifReaderInterface::includeInactiveCellsInFaultGeometry() const { - return readerSettings()->includeFileAbsolutePathPrefix; + return m_readerSettings.includeInactiveCellsInFaultGeometry; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString RifReaderInterface::faultIncludeFileAbsolutePathPrefix() const +{ + return m_readerSettings.includeFileAbsolutePathPrefix; } //-------------------------------------------------------------------------------------------------- @@ -122,26 +130,7 @@ size_t RifReaderInterface::timeStepIndexOnFile( size_t timeStepIndex ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RifReaderSettings* RifReaderInterface::readerSettings() const -{ - if ( m_readerSettings ) - { - return m_readerSettings.get(); - } - else - { - RiaPreferences* prefs = RiaPreferences::current(); - - CVF_ASSERT( prefs->readerSettings() ); - - return prefs->readerSettings(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifReaderInterface::setReaderSettings( std::shared_ptr readerSettings ) +void RifReaderInterface::setReaderSettings( RifReaderSettings readerSettings ) { m_readerSettings = readerSettings; } diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.h b/ApplicationLibCode/FileInterface/RifReaderInterface.h index f97039dd91..0da770f2c4 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.h +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.h @@ -23,6 +23,8 @@ #include "RiaDefines.h" #include "RiaPorosityModel.h" +#include "RifReaderSettings.h" + #include "cvfCollection.h" #include "cvfObject.h" @@ -36,7 +38,6 @@ #include class RigEclipseCaseData; -class RifReaderSettings; class RigFault; //================================================================================================== @@ -47,17 +48,17 @@ class RigFault; class RifReaderInterface : public cvf::Object { public: - RifReaderInterface() {} + RifReaderInterface(); ~RifReaderInterface() override {} - void setReaderSettings( std::shared_ptr readerSettings ); + bool isFaultImportEnabled() const; + bool isImportOfCompleteMswDataEnabled() const; + bool isNNCsEnabled() const; + bool includeInactiveCellsInFaultGeometry() const; + bool loadWellDataEnabled() const; + const QString faultIncludeFileAbsolutePathPrefix() const; - bool isFaultImportEnabled(); - bool isImportOfCompleteMswDataEnabled(); - bool isNNCsEnabled(); - bool includeInactiveCellsInFaultGeometry(); - bool loadWellDataEnabled(); - const QString faultIncludeFileAbsolutePathPrefix(); + void setReaderSettings( RifReaderSettings readerSettings ); virtual bool open( const QString& fileName, RigEclipseCaseData* eclipseCase ) = 0; @@ -81,13 +82,10 @@ class RifReaderInterface : public cvf::Object size_t timeStepIndexOnFile( size_t timeStepIndex ) const; void importFaults( const QStringList& fileSet, cvf::Collection* faults ); -private: - const RifReaderSettings* readerSettings() const; - private: std::vector m_filenamesWithFaults; std::vector m_fileTimeStepIndices; - std::shared_ptr m_readerSettings; + RifReaderSettings m_readerSettings; }; diff --git a/ApplicationLibCode/FileInterface/RifReaderSettings.cpp b/ApplicationLibCode/FileInterface/RifReaderSettings.cpp deleted file mode 100644 index 15d04f1a30..0000000000 --- a/ApplicationLibCode/FileInterface/RifReaderSettings.cpp +++ /dev/null @@ -1,110 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Statoil ASA -// Copyright (C) Ceetron Solutions AS -// -// 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 "RifReaderSettings.h" - -#include "cafPdmUiCheckBoxEditor.h" - -CAF_PDM_SOURCE_INIT( RifReaderSettings, "RifReaderSettings" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RifReaderSettings::RifReaderSettings() -{ - CAF_PDM_InitObject( "RifReaderSettings" ); - - CAF_PDM_InitField( &importFaults, "importFaults", true, "Import Faults" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &importFaults ); - - CAF_PDM_InitField( &importNNCs, "importSimulationNNCs", true, "Import NNCs" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &importNNCs ); - - CAF_PDM_InitField( &includeInactiveCellsInFaultGeometry, "includeInactiveCellsInFaultGeometry", false, "Include Inactive Cells" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &includeInactiveCellsInFaultGeometry ); - - CAF_PDM_InitField( &importAdvancedMswData, "importAdvancedMswData", true, "Import Advanced MSW Data" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &importAdvancedMswData ); - - CAF_PDM_InitField( &useResultIndexFile, - "useResultIndexFile", - false, - "Use Result Index File", - "", - "After import of a result file, store index data in an index file in the same folder as the " - "result file.\n" - "Import of result data if a result index file is present, will reduce file parsing " - "significantly.", - "" ); - - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &useResultIndexFile ); - - CAF_PDM_InitField( &skipWellData, "skipWellData", false, "Skip Import of Simulation Well Data" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &skipWellData ); - - CAF_PDM_InitField( &includeFileAbsolutePathPrefix, - "includeFileAbsolutePathPrefix", - QString(), - "Include File Absolute Path Prefix", - "", - "Path used to prefix absolute UNIX paths in include statements on Windows, used when searching " - "for FAULTS and EQUIL", - "" ); - - CAF_PDM_InitField( &importSummaryData, "importSummaryData", true, "Import summary data" ); - importSummaryData.uiCapability()->setUiHidden( true ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifReaderSettings::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) -{ - uiOrdering.add( &importFaults ); - uiOrdering.add( &includeInactiveCellsInFaultGeometry ); -#ifdef WIN32 - uiOrdering.add( &includeFileAbsolutePathPrefix ); -#endif - uiOrdering.add( &importNNCs ); - uiOrdering.add( &importAdvancedMswData ); - uiOrdering.add( &useResultIndexFile ); - uiOrdering.add( &skipWellData ); - - bool setFaultImportSettingsReadOnly = !importFaults(); - - includeInactiveCellsInFaultGeometry.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly ); - includeFileAbsolutePathPrefix.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly ); - importNNCs.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::shared_ptr RifReaderSettings::createGridOnlyReaderSettings() -{ - std::shared_ptr readerSettings = std::make_shared(); - // Disable as much as possible - readerSettings->importNNCs = false; - readerSettings->importFaults = false; - readerSettings->skipWellData = true; - readerSettings->includeInactiveCellsInFaultGeometry = false; - readerSettings->importAdvancedMswData = false; - readerSettings->importSummaryData = false; - return readerSettings; -} diff --git a/ApplicationLibCode/FileInterface/RifReaderSettings.h b/ApplicationLibCode/FileInterface/RifReaderSettings.h index 3beeb2bf41..8041974822 100644 --- a/ApplicationLibCode/FileInterface/RifReaderSettings.h +++ b/ApplicationLibCode/FileInterface/RifReaderSettings.h @@ -19,33 +19,20 @@ #pragma once -#include "cafPdmField.h" -#include "cafPdmObject.h" +#include //================================================================================================== /// /// //================================================================================================== -class RifReaderSettings : public caf::PdmObject +struct RifReaderSettings { - CAF_PDM_HEADER_INIT; - - friend class RiaPreferences; - -public: - RifReaderSettings(); - - caf::PdmField importFaults; - caf::PdmField importNNCs; - caf::PdmField includeInactiveCellsInFaultGeometry; - caf::PdmField importAdvancedMswData; - caf::PdmField includeFileAbsolutePathPrefix; - caf::PdmField useResultIndexFile; - caf::PdmField skipWellData; - caf::PdmField importSummaryData; - - static std::shared_ptr createGridOnlyReaderSettings(); - -private: - void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + bool importFaults; + bool importNNCs; + bool includeInactiveCellsInFaultGeometry; + bool importAdvancedMswData; + bool useResultIndexFile; + bool skipWellData; + bool importSummaryData; + QString includeFileAbsolutePathPrefix; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index 6bc9ab4709..845e4f8e19 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -25,14 +25,13 @@ #include "RiaDefines.h" #include "RiaFieldHandleTools.h" #include "RiaLogging.h" -#include "RiaPreferences.h" +#include "RiaPreferencesGrid.h" #include "RiaQDateTimeTools.h" #include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h" #include "RicfCommandObject.h" #include "RifInputPropertyLoader.h" -#include "RifReaderSettings.h" #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" @@ -129,6 +128,8 @@ RimEclipseCase::RimEclipseCase() m_fractureModelResults.uiCapability()->setUiTreeChildrenHidden( true ); setReservoirData( nullptr ); + + m_readerSettings = RiaPreferencesGrid::current()->readerSettings(); } //-------------------------------------------------------------------------------------------------- @@ -184,15 +185,6 @@ void RimEclipseCase::ensureDeckIsParsedForEquilData() { if ( m_rigEclipseCase.notNull() ) { - QString includeFileAbsolutePathPrefix; - { - RiaPreferences* prefs = RiaPreferences::current(); - if ( prefs->readerSettings() ) - { - includeFileAbsolutePathPrefix = prefs->readerSettings()->includeFileAbsolutePathPrefix(); - } - } - QString dataDeckFile; { QFileInfo fi( gridFileName() ); @@ -200,7 +192,7 @@ void RimEclipseCase::ensureDeckIsParsedForEquilData() dataDeckFile = caf::Utils::constructFullFileName( fi.absolutePath(), fi.baseName(), ".DATA" ); } - m_rigEclipseCase->ensureDeckIsParsedForEquilData( dataDeckFile, includeFileAbsolutePathPrefix ); + m_rigEclipseCase->ensureDeckIsParsedForEquilData( dataDeckFile, m_readerSettings.includeFileAbsolutePathPrefix ); } } @@ -730,9 +722,7 @@ void RimEclipseCase::ensureFaultDataIsComputed() RigEclipseCaseData* rigEclipseCase = eclipseCaseData(); if ( rigEclipseCase ) { - bool computeFaults = ( m_readerSettings && m_readerSettings->importFaults() ) || - ( !m_readerSettings && RiaPreferences::current()->readerSettings()->importFaults() ); - if ( computeFaults ) + if ( m_readerSettings.importFaults ) { RigActiveCellInfo* actCellInfo = rigEclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); rigEclipseCase->mainGrid()->calculateFaults( actCellInfo ); @@ -1179,7 +1169,7 @@ bool RimEclipseCase::importAsciiInputProperties( const QStringList& fileNames ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseCase::setReaderSettings( std::shared_ptr readerSettings ) +void RimEclipseCase::setReaderSettings( RifReaderSettings& readerSettings ) { m_readerSettings = readerSettings; } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h index a623643622..a1897c729f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h @@ -25,6 +25,8 @@ #include "RiaDefines.h" #include "RimCase.h" +#include "RifReaderSettings.h" + #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmField.h" @@ -51,7 +53,6 @@ class RimEclipseView; class RimIdenticalGridCaseGroup; class RimReservoirCellResultsStorage; class RimEclipseResultAddressCollection; -class RifReaderSettings; class RimEclipseViewCollection; //================================================================================================== @@ -126,7 +127,7 @@ class RimEclipseCase : public RimCase void createDisplayModelAndUpdateAllViews(); void computeActiveCellsBoundingBox(); - void setReaderSettings( std::shared_ptr readerSettings ); + void setReaderSettings( RifReaderSettings& readerSettings ); void updateResultAddressCollection(); @@ -139,11 +140,10 @@ class RimEclipseCase : public RimCase // Internal methods protected: - void computeCachedData(); - void setReservoirData( RigEclipseCaseData* eclipseCase ); - std::vector additionalFiles() const; - RimEclipseViewCollection* globalViewCollection() const; - RimEclipseContourMapViewCollection* contourMapViewCollection() const; + void computeCachedData(); + void setReservoirData( RigEclipseCaseData* eclipseCase ); + std::vector additionalFiles() const; + RimEclipseViewCollection* globalViewCollection() const; void addViewsFromViewCollection( std::vector& views, const RimEclipseViewCollection* viewColl ) const; private: @@ -158,7 +158,7 @@ class RimEclipseCase : public RimCase caf::PdmField m_flipYAxis; caf::PdmChildField m_inputPropertyCollection; - std::shared_ptr m_readerSettings; + RifReaderSettings m_readerSettings; private: caf::PdmField m_releaseResultMemory; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp index d46966ca09..99405784ab 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp @@ -21,9 +21,6 @@ #include "RimEclipseCaseCollection.h" #include "RiaApplication.h" -#include "RiaPreferences.h" - -#include "RifReaderSettings.h" #include "RigEclipseCaseData.h" #include "RigGridManager.h" diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.cpp index 345485560e..0f8cacceae 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.cpp @@ -23,14 +23,13 @@ #include "RiaDefines.h" #include "RiaFieldHandleTools.h" #include "RiaLogging.h" -#include "RiaPreferences.h" +#include "RiaPreferencesGrid.h" #include "RifEclipseInputFileTools.h" #include "RifInputPropertyLoader.h" #include "RifReaderEclipseInput.h" #include "RifReaderInterface.h" #include "RifReaderMockModel.h" -#include "RifReaderSettings.h" #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" @@ -107,7 +106,7 @@ bool RimEclipseInputCase::openDataFileSet( const QStringList& fileNames ) setReservoirData( new RigEclipseCaseData( this ) ); } - bool importFaults = RiaPreferences::current()->readerSettings()->importFaults(); + bool importFaults = RiaPreferencesGrid::current()->importFaults(); std::vector allErrorMessages; @@ -225,7 +224,7 @@ bool RimEclipseInputCase::openEclipseGridFile() computeCachedData(); } - if ( RiaPreferences::current()->autocomputeDepthRelatedProperties ) + if ( RiaPreferencesGrid::current()->autoComputeDepthRelatedProperties() ) { results( RiaDefines::PorosityModelType::MATRIX_MODEL )->computeDepthRelatedResults(); results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->computeDepthRelatedResults(); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp index f5d3cf90f9..2ad964e321 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -23,7 +23,7 @@ #include "RiaApplication.h" #include "RiaFieldHandleTools.h" #include "RiaLogging.h" -#include "RiaPreferences.h" +#include "RiaPreferencesGrid.h" #include "RiaRegressionTestRunner.h" #include "RiaResultNames.h" @@ -37,7 +37,6 @@ #include "RifReaderMockModel.h" #include "RifReaderOpmCommon.h" #include "RifReaderOpmRft.h" -#include "RifReaderSettings.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" @@ -160,7 +159,7 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter return false; } - auto readerType = RiaPreferences::current()->gridModelReader(); + auto readerType = RiaPreferencesGrid::current()->gridModelReader(); // opmcommon reader only reads EGRID if ( !gridFileName().toLower().endsWith( ".egrid" ) ) @@ -248,7 +247,7 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter outReader->setHdf5FileName( m_sourSimFileName().path() ); } - if ( RiaPreferences::current()->autocomputeDepthRelatedProperties ) + if ( RiaPreferencesGrid::current()->autoComputeDepthRelatedProperties() ) { results( RiaDefines::PorosityModelType::MATRIX_MODEL )->computeDepthRelatedResults(); results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->computeDepthRelatedResults(); diff --git a/ApplicationLibCode/ProjectDataModel/RimEmCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEmCase.cpp index 4d6bd87d97..4cc3c4fff7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEmCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEmCase.cpp @@ -20,7 +20,7 @@ #include "RiaDefines.h" #include "RiaLogging.h" -#include "RiaPreferences.h" +#include "RiaPreferencesGrid.h" #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" @@ -95,7 +95,7 @@ bool RimEmCase::openEclipseGridFile() results( RiaDefines::PorosityModelType::MATRIX_MODEL )->createPlaceholderResultEntries(); - if ( RiaPreferences::current()->autocomputeDepthRelatedProperties ) + if ( RiaPreferencesGrid::current()->autoComputeDepthRelatedProperties() ) { results( RiaDefines::PorosityModelType::MATRIX_MODEL )->computeDepthRelatedResults(); results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->computeDepthRelatedResults(); diff --git a/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp b/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp index 102b488bf8..d06bdd22b1 100644 --- a/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp @@ -22,6 +22,7 @@ #include "RiaFractureDefines.h" #include "RiaImportEclipseCaseTools.h" #include "RiaLogging.h" +#include "RiaPreferencesGrid.h" #include "RiaSummaryTools.h" #include "ApplicationCommands/RicShowMainWindowFeature.h" @@ -213,8 +214,9 @@ bool RimReloadCaseTools::openOrImportGridModelFromSummaryCase( const RimSummaryC if ( QFileInfo::exists( candidateGridFileName ) ) { - bool createView = true; - auto id = RiaImportEclipseCaseTools::openEclipseCaseFromFile( candidateGridFileName, createView ); + bool createView = true; + RifReaderSettings rs = RiaPreferencesGrid::current()->readerSettings(); + auto id = RiaImportEclipseCaseTools::openEclipseCaseFromFile( candidateGridFileName, createView, rs ); if ( id > -1 ) { RiaLogging::info( QString( "Imported %1" ).arg( candidateGridFileName ) ); diff --git a/ApplicationLibCode/ProjectDataModel/RimRoffCase.cpp b/ApplicationLibCode/ProjectDataModel/RimRoffCase.cpp index f7fafa1c30..e78365c6dd 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRoffCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimRoffCase.cpp @@ -20,7 +20,7 @@ #include "RiaDefines.h" #include "RiaLogging.h" -#include "RiaPreferences.h" +#include "RiaPreferencesGrid.h" #include "RifInputPropertyLoader.h" #include "RifRoffFileTools.h" @@ -94,7 +94,7 @@ bool RimRoffCase::openEclipseGridFile() results( RiaDefines::PorosityModelType::MATRIX_MODEL )->createPlaceholderResultEntries(); - if ( RiaPreferences::current()->autocomputeDepthRelatedProperties ) + if ( RiaPreferencesGrid::current()->autoComputeDepthRelatedProperties() ) { results( RiaDefines::PorosityModelType::MATRIX_MODEL )->computeDepthRelatedResults(); results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->computeDepthRelatedResults(); diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 6d04dcbd23..0c4f2fe446 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -24,7 +24,7 @@ #include "RiaDefines.h" #include "RiaEclipseUnitTools.h" #include "RiaLogging.h" -#include "RiaPreferences.h" +#include "RiaPreferencesGrid.h" #include "RiaResultNames.h" #include "RifReaderEclipseOutput.h" @@ -795,8 +795,8 @@ RigEclipseResultAddress RigCaseCellResultsData::defaultResult() const if ( maxTimeStepCount() > 0 ) { - auto prefs = RiaPreferences::current(); - if ( prefs->loadAndShowSoil ) return RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ); + auto prefs = RiaPreferencesGrid::current(); + if ( prefs->loadAndShowSoil() ) return RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ); auto dynamicResult = std::find_if( allResults.begin(), allResults.end(), diff --git a/ApplicationLibCode/UnitTests/RifReaderEclipseOutput-Test.cpp b/ApplicationLibCode/UnitTests/RifReaderEclipseOutput-Test.cpp index 6872e045ae..bf6e0f2a59 100644 --- a/ApplicationLibCode/UnitTests/RifReaderEclipseOutput-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifReaderEclipseOutput-Test.cpp @@ -30,7 +30,6 @@ #include "RifEclipseOutputFileTools.h" #include "RifEclipseUnifiedRestartFileAccess.h" #include "RifReaderEclipseOutput.h" -#include "RifReaderSettings.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" #include "RimEclipseResultCase.h" From ffc1687cc750010573da821476de14fef993dfba Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Jul 2024 09:31:16 +0200 Subject: [PATCH 168/332] Add Sumo connector and related cloud tools * Add cloud data icon * Add Sumo connector and related helper tools * Reorganize preferences and remove ssihub * Use timeout defined for Sumo --- ApplicationExeCode/CMakeLists.txt | 7 +- ApplicationExeCode/Resources/ResInsight.qrc | 1 + .../Resources/cloud-and-server.svg | 2 + .../Application/CMakeLists_files.cmake | 2 + .../Application/RiaApplication.cpp | 26 + .../Application/RiaApplication.h | 3 + .../Application/RiaPreferences.cpp | 49 +- .../Application/RiaPreferences.h | 6 +- .../Application/RiaPreferencesSumo.cpp | 75 ++ .../Application/RiaPreferencesSumo.h | 46 + .../Tools/Cloud/CMakeLists_files.cmake | 17 + .../Tools/Cloud/RiaConnectorTools.cpp | 80 ++ .../Tools/Cloud/RiaConnectorTools.h | 31 + .../Tools/Cloud/RiaSumoConnector.cpp | 1110 +++++++++++++++++ .../Tools/Cloud/RiaSumoConnector.h | 182 +++ .../Tools/Cloud/RiaSumoDefines.cpp | 38 + .../Application/Tools/Cloud/RiaSumoDefines.h | 32 + .../Application/Tools/RiaSummaryTools.cpp | 20 + .../Application/Tools/RiaSummaryTools.h | 1 + ApplicationLibCode/CMakeLists.txt | 2 + .../CMakeLists_files.cmake | 6 +- .../RicEditPreferencesFeature.cpp | 1 - .../RicSumoDataFeature.cpp | 288 +++++ .../ApplicationCommands/RicSumoDataFeature.h | 85 ++ .../UserInterface/RiuMainWindow.cpp | 1 + .../RiuPropertyViewTabWidget.cpp | 2 +- 26 files changed, 2077 insertions(+), 36 deletions(-) create mode 100644 ApplicationExeCode/Resources/cloud-and-server.svg create mode 100644 ApplicationLibCode/Application/RiaPreferencesSumo.cpp create mode 100644 ApplicationLibCode/Application/RiaPreferencesSumo.h create mode 100644 ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake create mode 100644 ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp create mode 100644 ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.h create mode 100644 ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp create mode 100644 ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h create mode 100644 ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp create mode 100644 ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.h create mode 100644 ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.cpp create mode 100644 ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.h diff --git a/ApplicationExeCode/CMakeLists.txt b/ApplicationExeCode/CMakeLists.txt index 8b9f4a5955..28ba766559 100644 --- a/ApplicationExeCode/CMakeLists.txt +++ b/ApplicationExeCode/CMakeLists.txt @@ -302,12 +302,7 @@ set(UNITY_EXCLUDE_FILES # forever is used as variable name, and this symbol is defined by Qt and # used in precompiled headers ${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc - qrc_cafAnimControl.cpp - qrc_ResInsight.cpp - qrc_cafCommandFeatures.cpp - # Exclude files including opm-common - ProjectDataModel/RimVfpTableExtractor.cpp - ProjectDataModel/RimVfpPlot.cpp + qrc_cafAnimControl.cpp qrc_ResInsight.cpp qrc_cafCommandFeatures.cpp ) if(RESINSIGHT_ENABLE_UNITY_BUILD) diff --git a/ApplicationExeCode/Resources/ResInsight.qrc b/ApplicationExeCode/Resources/ResInsight.qrc index 7c2e9a61bd..cb62facd2e 100644 --- a/ApplicationExeCode/Resources/ResInsight.qrc +++ b/ApplicationExeCode/Resources/ResInsight.qrc @@ -287,6 +287,7 @@ regression-curve.svg padlock.svg warning.svg + cloud-and-server.svg fs_CellFace.glsl diff --git a/ApplicationExeCode/Resources/cloud-and-server.svg b/ApplicationExeCode/Resources/cloud-and-server.svg new file mode 100644 index 0000000000..67c6a4f24a --- /dev/null +++ b/ApplicationExeCode/Resources/cloud-and-server.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ApplicationLibCode/Application/CMakeLists_files.cmake b/ApplicationLibCode/Application/CMakeLists_files.cmake index 55bb5fa2e1..8dc2c7f0aa 100644 --- a/ApplicationLibCode/Application/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/CMakeLists_files.cmake @@ -11,6 +11,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGrid.h ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.h ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.h + ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSumo.h ${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.h ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.h ${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.h @@ -54,6 +55,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGrid.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSumo.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.cpp diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index aeae3a2659..70a26aaf0a 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -17,7 +17,10 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaApplication.h" +#include "Cloud/RiaSumoConnector.h" +#include "Cloud/RiaSumoDefines.h" #include "OsduImportCommands/RiaOsduConnector.h" + #include "RiaArgumentParser.h" #include "RiaBaseDefs.h" #include "RiaFilePathTools.h" @@ -26,6 +29,7 @@ #include "RiaImportEclipseCaseTools.h" #include "RiaLogging.h" #include "RiaPreferences.h" +#include "RiaPreferencesSumo.h" #include "RiaPreferencesSystem.h" #include "RiaProjectModifier.h" #include "RiaSocketServer.h" @@ -1710,3 +1714,25 @@ RiaOsduConnector* RiaApplication::makeOsduConnector() m_osduConnector = new RiaOsduConnector( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId ); return m_osduConnector; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaSumoConnector* RiaApplication::makeSumoConnector() +{ + if ( !m_sumoConnector ) + { + auto sumoPrefs = preferences()->sumoPreferences(); + const QString server = sumoPrefs->server(); + const QString authority = sumoPrefs->authority(); + const QString scopes = sumoPrefs->scopes(); + const QString clientId = sumoPrefs->clientId(); + + m_sumoConnector = new RiaSumoConnector( RiuMainWindow::instance(), server, authority, scopes, clientId ); + + m_sumoConnector->setTokenDataFilePath( RiaSumoDefines::tokenPath() ); + m_sumoConnector->importTokenFromFile(); + } + + return m_sumoConnector; +} diff --git a/ApplicationLibCode/Application/RiaApplication.h b/ApplicationLibCode/Application/RiaApplication.h index b98be5cd3e..c9e45cb537 100644 --- a/ApplicationLibCode/Application/RiaApplication.h +++ b/ApplicationLibCode/Application/RiaApplication.h @@ -69,6 +69,7 @@ class RiuPlotMainWindow; class RiuRecentFileActionProvider; class RiaArgumentParser; class RiaOsduConnector; +class RiaSumoConnector; namespace caf { @@ -202,6 +203,7 @@ class RiaApplication virtual void showFormattedTextInMessageBoxOrConsole( const QString& errMsg ) = 0; RiaOsduConnector* makeOsduConnector(); + RiaSumoConnector* makeSumoConnector(); protected: // Protected implementation specific overrides @@ -259,4 +261,5 @@ class RiaApplication private: static RiaApplication* s_riaApplication; QPointer m_osduConnector; + QPointer m_sumoConnector; }; diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index ba163931a0..131551e6f1 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -27,6 +27,7 @@ #include "RiaPreferencesGeoMech.h" #include "RiaPreferencesGrid.h" #include "RiaPreferencesSummary.h" +#include "RiaPreferencesSumo.h" #include "RiaPreferencesSystem.h" #include "RiaQDateTimeTools.h" #include "RiaValidRegExpValidator.h" @@ -146,9 +147,6 @@ RiaPreferences::RiaPreferences() CAF_PDM_InitField( &m_storeBackupOfProjectFile, "storeBackupOfProjectFile", true, "Store Backup of Project Files" ); - CAF_PDM_InitField( &ssihubAddress, "ssihubAddress", QString( "http://" ), "SSIHUB Address" ); - ssihubAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitFieldNoDefault( &m_defaultMeshModeType, "defaultMeshModeType", "Show Grid Lines" ); CAF_PDM_InitField( &defaultGridLineColors, "defaultGridLineColors", RiaColorTables::defaultGridLineColor(), "Mesh Color" ); CAF_PDM_InitField( &defaultFaultGridLineColors, @@ -273,6 +271,9 @@ RiaPreferences::RiaPreferences() CAF_PDM_InitFieldNoDefault( &m_osduPreferences, "osduPreferences", "osduPreferences" ); m_osduPreferences = new RiaPreferencesOsdu; + + CAF_PDM_InitFieldNoDefault( &m_sumoPreferences, "sumoPreferences", "sumoPreferences" ); + m_sumoPreferences = new RiaPreferencesSumo; } //-------------------------------------------------------------------------------------------------- @@ -370,8 +371,15 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& viewsGroup->add( &m_showInfoBox ); viewsGroup->add( &m_showGridBox, { .newRow = false, .totalColumnSpan = 1 } ); + caf::PdmUiGroup* loggingGroup = uiOrdering.addNewGroup( "Logging and Backup" ); + loggingGroup->add( &m_storeBackupOfProjectFile ); + loggingGroup->add( &m_loggerFilename ); + loggingGroup->add( &m_loggerFlushInterval ); + loggingGroup->add( &m_loggerTrapSignalAndFlush ); + m_loggerTrapSignalAndFlush.uiCapability()->setUiReadOnly( !m_loggerFilename().first ); + m_loggerFlushInterval.uiCapability()->setUiReadOnly( !m_loggerFilename().first ); + caf::PdmUiGroup* otherGroup = uiOrdering.addNewGroup( "Other" ); - otherGroup->add( &ssihubAddress ); otherGroup->add( &holoLensDisableCertificateVerification ); otherGroup->add( &m_useUndoRedo ); } @@ -466,17 +474,11 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& otherGroup->add( &m_gridCalculationExpressionFolder ); otherGroup->add( &m_summaryCalculationExpressionFolder ); - caf::PdmUiGroup* loggingGroup = uiOrdering.addNewGroup( "Logging and Backup" ); - loggingGroup->add( &m_storeBackupOfProjectFile ); - loggingGroup->add( &m_loggerFilename ); - loggingGroup->add( &m_loggerFlushInterval ); - loggingGroup->add( &m_loggerTrapSignalAndFlush ); - m_loggerTrapSignalAndFlush.uiCapability()->setUiReadOnly( !m_loggerFilename().first ); - m_loggerFlushInterval.uiCapability()->setUiReadOnly( !m_loggerFilename().first ); - } - else if ( uiConfigName == RiaPreferences::tabNameOsdu() ) - { - m_osduPreferences()->uiOrdering( uiConfigName, uiOrdering ); + caf::PdmUiGroup* osduGroup = uiOrdering.addNewGroup( "OSDU" ); + m_osduPreferences()->uiOrdering( uiConfigName, *osduGroup ); + + caf::PdmUiGroup* sumoGroup = uiOrdering.addNewGroup( "SUMO" ); + m_sumoPreferences()->uiOrdering( uiConfigName, *sumoGroup ); } else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() ) { @@ -605,14 +607,6 @@ QString RiaPreferences::tabNameSystem() return "System"; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaPreferences::tabNameOsdu() -{ - return "Osdu"; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -653,7 +647,6 @@ QStringList RiaPreferences::tabNames() names << tabNameGeomech(); #endif names << tabNameImportExport(); - names << tabNameOsdu(); if ( RiaApplication::enableDevelopmentFeatures() ) { @@ -1028,6 +1021,14 @@ RiaPreferencesOsdu* RiaPreferences::osduPreferences() const return m_osduPreferences(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesSumo* RiaPreferences::sumoPreferences() const +{ + return m_sumoPreferences(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferences.h b/ApplicationLibCode/Application/RiaPreferences.h index 89d8964805..c56cccf38c 100644 --- a/ApplicationLibCode/Application/RiaPreferences.h +++ b/ApplicationLibCode/Application/RiaPreferences.h @@ -46,6 +46,7 @@ class RiaPreferencesGeoMech; class RiaPreferencesSystem; class RiaPreferencesOsdu; class RiaPreferencesGrid; +class RiaPreferencesSumo; //-------------------------------------------------------------------------------------------------- /// @@ -129,6 +130,7 @@ class RiaPreferences : public caf::PdmObject RiaPreferencesSummary* summaryPreferences() const; RiaPreferencesSystem* systemPreferences() const; RiaPreferencesOsdu* osduPreferences() const; + RiaPreferencesSumo* sumoPreferences() const; RiaPreferencesGrid* gridPreferences() const; public: @@ -139,8 +141,6 @@ class RiaPreferences : public caf::PdmObject caf::PdmField scriptEditorExecutable; caf::PdmField showPythonDebugInfo; - caf::PdmField ssihubAddress; - caf::PdmField defaultGridLineColors; caf::PdmField defaultFaultGridLineColors; caf::PdmField defaultViewerBackgroundColor; @@ -171,7 +171,6 @@ class RiaPreferences : public caf::PdmObject static QString tabNamePlotting(); static QString tabNameScripting(); static QString tabNameSystem(); - static QString tabNameOsdu(); static QString tabNameImportExport(); static double defaultMarginSize( QPageSize::PageSizeId pageSizeId ); @@ -238,6 +237,7 @@ class RiaPreferences : public caf::PdmObject // Osdu settings caf::PdmChildField m_osduPreferences; + caf::PdmChildField m_sumoPreferences; // 3d view caf::PdmField> m_defaultMeshModeType; diff --git a/ApplicationLibCode/Application/RiaPreferencesSumo.cpp b/ApplicationLibCode/Application/RiaPreferencesSumo.cpp new file mode 100644 index 0000000000..0ad7f66e76 --- /dev/null +++ b/ApplicationLibCode/Application/RiaPreferencesSumo.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RiaApplication.h" + +#include "RiaPreferences.h" +#include "RiaPreferencesSumo.h" + +CAF_PDM_SOURCE_INIT( RiaPreferencesSumo, "RiaPreferencesSumo" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesSumo::RiaPreferencesSumo() +{ + CAF_PDM_InitFieldNoDefault( &m_server, "server", "Server" ); + CAF_PDM_InitFieldNoDefault( &m_authority, "authority", "Authority" ); + CAF_PDM_InitFieldNoDefault( &m_scopes, "scopes", "Scopes" ); + CAF_PDM_InitFieldNoDefault( &m_clientId, "clientId", "Client Id" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesSumo* RiaPreferencesSumo::current() +{ + return RiaApplication::instance()->preferences()->sumoPreferences(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesSumo::server() const +{ + return m_server; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesSumo::authority() const +{ + return m_authority; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesSumo::scopes() const +{ + return m_scopes; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesSumo::clientId() const +{ + return m_clientId; +} diff --git a/ApplicationLibCode/Application/RiaPreferencesSumo.h b/ApplicationLibCode/Application/RiaPreferencesSumo.h new file mode 100644 index 0000000000..a66c2bef67 --- /dev/null +++ b/ApplicationLibCode/Application/RiaPreferencesSumo.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "cafPdmField.h" +#include "cafPdmObject.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RiaPreferencesSumo : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RiaPreferencesSumo(); + + static RiaPreferencesSumo* current(); + + QString server() const; + QString authority() const; + QString scopes() const; + QString clientId() const; + +private: + caf::PdmField m_server; + caf::PdmField m_authority; + caf::PdmField m_scopes; + caf::PdmField m_clientId; +}; diff --git a/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake b/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake new file mode 100644 index 0000000000..6fe5273a78 --- /dev/null +++ b/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake @@ -0,0 +1,17 @@ +set(SOURCE_GROUP_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h + ${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.h + ${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.h +) + +set(SOURCE_GROUP_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.cpp +) + +list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h) + +list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) + +list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp new file mode 100644 index 0000000000..c7872bc1b5 --- /dev/null +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp @@ -0,0 +1,80 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RiaConnectorTools.h" + +#include +#include +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaConnectorTools::tokenDataAsJson( QOAuth2AuthorizationCodeFlow* authCodeFlow ) +{ + QJsonObject obj; + obj.insert( "token", authCodeFlow->token() ); + obj.insert( "refreshToken", authCodeFlow->refreshToken() ); + + QJsonDocument doc( obj ); + return doc.toJson( QJsonDocument::Indented ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaConnectorTools::initializeTokenDataFromJson( QOAuth2AuthorizationCodeFlow* authCodeFlow, const QString& tokenDataJson ) +{ + QJsonDocument doc = QJsonDocument::fromJson( tokenDataJson.toUtf8() ); + QJsonObject obj = doc.object(); + + authCodeFlow->setToken( obj["token"].toString() ); + authCodeFlow->setRefreshToken( obj["refreshToken"].toString() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaConnectorTools::writeTokenData( const QString& filePath, const QString& tokenDataJson ) +{ + QFile file( filePath ); + if ( file.open( QIODevice::WriteOnly ) ) + { + QTextStream stream( &file ); + stream << tokenDataJson; + file.close(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaConnectorTools::readTokenData( const QString& filePath ) +{ + QFile file( filePath ); + if ( file.open( QIODevice::ReadOnly ) ) + { + QTextStream stream( &file ); + QString result = stream.readAll(); + file.close(); + return result; + } + return {}; +} diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.h b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.h new file mode 100644 index 0000000000..5acb2f4f8e --- /dev/null +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.h @@ -0,0 +1,31 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 + +class QOAuth2AuthorizationCodeFlow; + +namespace RiaConnectorTools +{ +QString tokenDataAsJson( QOAuth2AuthorizationCodeFlow* authCodeFlow ); +void initializeTokenDataFromJson( QOAuth2AuthorizationCodeFlow* authCodeFlow, const QString& tokenDataJson ); +void writeTokenData( const QString& filePath, const QString& tokenDataJson ); +QString readTokenData( const QString& filePath ); +} // namespace RiaConnectorTools diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp new file mode 100644 index 0000000000..9e7feda679 --- /dev/null +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -0,0 +1,1110 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RiaSumoConnector.h" + +#include "RiaConnectorTools.h" +#include "RiaFileDownloader.h" +#include "RiaLogging.h" +#include "RiaOsduDefines.h" + +#include "OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaSumoConnector::RiaSumoConnector( QObject* parent, const QString& server, const QString& authority, const QString& scopes, const QString& clientId ) + : QObject( parent ) + , m_server( server ) + , m_authority( authority ) + , m_scopes( scopes ) + , m_clientId( clientId ) +{ + m_authCodeFlow = new QOAuth2AuthorizationCodeFlow( this ); + m_networkAccessManager = new QNetworkAccessManager( this ); + m_authCodeFlow->setNetworkAccessManager( m_networkAccessManager ); + + RiaLogging::debug( "SSL BUILD VERSION: " + QSslSocket::sslLibraryBuildVersionString() ); + RiaLogging::debug( "SSL VERSION STRING: " + QSslSocket::sslLibraryVersionString() ); + + // NB: Make sure the port is not in use by another application + const unsigned int port = 53527; + + connect( m_authCodeFlow, + &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, + []( QUrl url ) + { + RiaLogging::info( "Authorize with url: " + url.toString() ); + QUrlQuery query( url ); + url.setQuery( query ); + QDesktopServices::openUrl( url ); + } ); + + QString authUrl = constructAuthUrl( m_authority ); + m_authCodeFlow->setAuthorizationUrl( QUrl( authUrl ) ); + + QString tokenUrl = constructTokenUrl( m_authority ); + m_authCodeFlow->setAccessTokenUrl( QUrl( tokenUrl ) ); + + // App key + m_authCodeFlow->setClientIdentifier( m_clientId ); + m_authCodeFlow->setScope( m_scopes ); + + auto replyHandler = new RiaOsduOAuthHttpServerReplyHandler( port, this ); + m_authCodeFlow->setReplyHandler( replyHandler ); + + connect( m_authCodeFlow, SIGNAL( granted() ), this, SLOT( accessGranted() ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::accessGranted() +{ + m_token = m_authCodeFlow->token(); + + QString tokenDataJson = RiaConnectorTools::tokenDataAsJson( m_authCodeFlow ); + RiaConnectorTools::writeTokenData( m_tokenDataFilePath, tokenDataJson ); + + emit tokenReady( m_token ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestFailed( const QAbstractOAuth::Error error ) +{ + RiaLogging::error( "Request failed: " ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::parquetDownloadComplete( const QString& blobId, const QByteArray& contents, const QString& url ) +{ + SumoRedirect obj; + obj.objectId = blobId; + obj.contents = contents; + obj.url = url; + + m_redirectInfo.push_back( obj ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestToken() +{ + RiaLogging::debug( "Requesting token." ); + m_authCodeFlow->grant(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaSumoConnector::~RiaSumoConnector() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaSumoConnector::token() const +{ + return m_token; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::importTokenFromFile() +{ + auto tokenDataJson = RiaConnectorTools::readTokenData( m_tokenDataFilePath ); + if ( !tokenDataJson.isEmpty() ) + { + RiaConnectorTools::initializeTokenDataFromJson( m_authCodeFlow, tokenDataJson ); + m_token = m_authCodeFlow->token(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::setTokenDataFilePath( const QString& filePath ) +{ + m_tokenDataFilePath = filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestCasesForField( const QString& fieldName ) +{ + m_cases.clear(); + + requestTokenBlocking(); + + QNetworkRequest m_networkRequest; + m_networkRequest.setUrl( QUrl( constructSearchUrl( m_server ) ) ); + + addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + + QString payloadTemplate = R"( +{ + "query": { + "bool": { + "filter": [ + {"term":{"class.keyword":"case"}}, + {"term":{"access.asset.name.keyword":"%1"}} + ] + } + }, + "sort": [ + {"tracklog.datetime":{"order":"desc"}} + ], + "track_total_hits":true, + "size":100, + "from":0 +} +)"; + + QString payload = payloadTemplate.arg( fieldName ); + auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); + + connect( reply, + &QNetworkReply::finished, + [this, reply]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + parseCases( reply ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestCasesForFieldBlocking( const QString& fieldName ) +{ + QEventLoop loop; + connect( this, SIGNAL( casesFinished() ), &loop, SLOT( quit() ) ); + QTimer timer; + + requestCasesForField( fieldName ); + + timer.setSingleShot( true ); + timer.start( RiaSumoDefines::requestTimeoutMillis() ); + loop.exec(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestAssets() +{ + requestTokenBlocking(); + + QNetworkRequest m_networkRequest; + m_networkRequest.setUrl( QUrl( m_server + "/api/v1/userpermissions" ) ); + + addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + + auto reply = m_networkAccessManager->get( m_networkRequest ); + + connect( reply, + &QNetworkReply::finished, + [this, reply]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + parseAssets( reply ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestAssetsBlocking() +{ + QEventLoop loop; + connect( this, SIGNAL( assetsFinished() ), &loop, SLOT( quit() ) ); + QTimer timer; + + requestAssets(); + + timer.setSingleShot( true ); + timer.start( RiaSumoDefines::requestTimeoutMillis() ); + loop.exec(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestEnsembleByCasesId( const SumoCaseId& caseId ) +{ + QString payloadTemplate = R"( + +{ + "query": { + "bool": { + "filter": [ + {"term":{"_sumo.parent_object.keyword":"%1"}} + ] + } + }, + "aggs": { + "aggs_columns": { + "terms": { "field": "fmu.iteration.name.keyword", "size": 5 } + } + }, + "track_total_hits":true, + "size":20, + "from":0, + "_source": false +} + +)"; + + QNetworkRequest m_networkRequest; + m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); + + addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + + auto payload = payloadTemplate.arg( caseId.get() ); + auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); + + connect( reply, + &QNetworkReply::finished, + [this, reply, caseId]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + parseEnsembleNames( reply, caseId ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestEnsembleByCasesIdBlocking( const SumoCaseId& caseId ) +{ + QEventLoop loop; + connect( this, SIGNAL( ensembleNamesFinished() ), &loop, SLOT( quit() ) ); + QTimer timer; + + requestEnsembleByCasesId( caseId ); + + timer.setSingleShot( true ); + timer.start( RiaSumoDefines::requestTimeoutMillis() ); + loop.exec(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestVectorNamesForEnsemble( const SumoCaseId& caseId, const QString& ensembleName ) +{ + QString payloadTemplate = R"( +{ + "track_total_hits": true, + "query": { "bool": { + "must": [ + {"term": {"class": "table"}}, + {"term": {"_sumo.parent_object.keyword": "%1"}}, + {"term": {"fmu.iteration.name.keyword": "%2"}}, + {"term": {"fmu.context.stage.keyword": "iteration"}}, + {"term": {"fmu.aggregation.operation.keyword": "collection"}}, + {"term": {"data.tagname.keyword": "summary"}}, + {"term": {"data.content.keyword": "timeseries"}} + ]} + }, + "aggs": { + "smry_tables": { + "terms": { + "field": "data.name.keyword" + }, + "aggs": { + "smry_columns": { + "terms": { + "field": "data.spec.columns.keyword", + "size": 65535 + } + } + } + } + }, + "_source": false, + "size": 0 +})"; + + QNetworkRequest m_networkRequest; + m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); + + addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + + auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName ); + auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); + + connect( reply, + &QNetworkReply::finished, + [this, reply, ensembleName, caseId]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + parseVectorNames( reply, caseId, ensembleName ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestVectorNamesForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName ) +{ + QEventLoop loop; + connect( this, SIGNAL( vectorNamesFinished() ), &loop, SLOT( quit() ) ); + QTimer timer; + + requestVectorNamesForEnsemble( caseId, ensembleName ); + + timer.setSingleShot( true ); + timer.start( RiaSumoDefines::requestTimeoutMillis() ); + loop.exec(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestRealizationIdsForEnsemble( const SumoCaseId& caseId, const QString& ensembleName ) +{ + QString payloadTemplate = R"( +{ + "track_total_hits": true, + "query": { + "bool": { + "must": [ + {"term": {"class": "table"}}, + {"term": {"_sumo.parent_object.keyword": "%1"}}, + {"term": {"fmu.iteration.name.keyword": "%2"}}, + {"term": {"fmu.context.stage.keyword": "iteration"}}, + {"term": {"fmu.aggregation.operation.keyword": "collection"}}, + {"term": {"data.tagname.keyword": "summary"}}, + {"term": {"data.content.keyword": "timeseries"}} + ]} + }, + "aggs": { + "realization-ids": { + "terms": { + "field": "fmu.aggregation.realization_ids", + "size":1000 + } + } + }, + "_source": false, + "size":0 +} +)"; + m_realizationIds.clear(); + + QNetworkRequest m_networkRequest; + m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); + + addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + + auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName ); + auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); + + connect( reply, + &QNetworkReply::finished, + [this, reply, ensembleName, caseId]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + parseRealizationNumbers( reply, caseId, ensembleName ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestRealizationIdsForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName ) +{ + QEventLoop loop; + connect( this, SIGNAL( realizationIdsFinished() ), &loop, SLOT( quit() ) ); + QTimer timer; + + requestRealizationIdsForEnsemble( caseId, ensembleName ); + + timer.setSingleShot( true ); + timer.start( RiaSumoDefines::requestTimeoutMillis() ); + loop.exec(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestBlobIdForEnsemble( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ) +{ + QString payloadTemplate = R"( +{ + "track_total_hits": true, + "query": { "bool": { + "must": [ + {"term": {"class": "table"}}, + {"term": {"_sumo.parent_object.keyword": "%1"}}, + {"term": {"fmu.iteration.name.keyword": "%2"}}, + {"term": {"fmu.context.stage.keyword": "iteration"}}, + {"term": {"fmu.aggregation.operation.keyword": "collection"}}, + {"term": {"data.tagname.keyword": "summary"}}, + {"term": {"data.spec.columns.keyword": "%3"}} + ]} + }, + "fields": [ + "data.name", + "_sumo.blob_name" + ], + "_source": true, + "size": 1 +} +)"; + + QNetworkRequest m_networkRequest; + m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); + + addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + + auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName ).arg( vectorName ); + auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); + + connect( reply, + &QNetworkReply::finished, + [this, reply, ensembleName, caseId, vectorName]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + parseBlobIds( reply, caseId, ensembleName, vectorName ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestBlobIdForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ) +{ + QEventLoop loop; + connect( this, SIGNAL( blobIdFinished() ), &loop, SLOT( quit() ) ); + QTimer timer; + + requestBlobIdForEnsemble( caseId, ensembleName, vectorName ); + + timer.setSingleShot( true ); + timer.start( RiaSumoDefines::requestTimeoutMillis() ); + loop.exec(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestBlobDownload( const QString& blobId ) +{ + QString url = constructDownloadUrl( m_server, blobId ); + + QNetworkRequest networkRequest; + networkRequest.setUrl( url ); + + // Other redirection policies are NoLessSafeRedirectPolicy, SameOriginRedirectPolicy, UserVerifiedRedirectPolicy. They were tested, but + // did not work. Use ManualRedirectPolicy instead, and inspect the reply for the redirection target. + networkRequest.setAttribute( QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::ManualRedirectPolicy ); + + addStandardHeader( networkRequest, m_token, RiaDefines::contentTypeJson() ); + + auto reply = m_networkAccessManager->get( networkRequest ); + + connect( reply, + &QNetworkReply::finished, + [this, reply, blobId, url]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + auto contents = reply->readAll(); + + QVariant redirectUrl = reply->attribute( QNetworkRequest::RedirectionTargetAttribute ); + if ( redirectUrl.isValid() ) + { + requestBlobByRedirectUri( blobId, redirectUrl.toString() ); + } + else + { + QString errorMessage = "Not able to parse and interpret valid redirect Url"; + RiaLogging::error( errorMessage ); + } + } + else + { + QString errorMessage = "Download failed: " + url + " failed." + reply->errorString(); + RiaLogging::error( errorMessage ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestBlobByRedirectUri( const QString& blobId, const QString& redirectUri ) +{ + QNetworkRequest networkRequest; + networkRequest.setUrl( redirectUri ); + + auto reply = m_networkAccessManager->get( networkRequest ); + + connect( reply, + &QNetworkReply::finished, + [this, reply, blobId, redirectUri]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + auto contents = reply->readAll(); + + QString msg = "Received data from : " + redirectUri; + RiaLogging::info( msg ); + + parquetDownloadComplete( blobId, contents, redirectUri ); + + emit parquetDownloadFinished( contents, redirectUri ); + } + else + { + QString errorMessage = "Download failed: " + redirectUri + " failed." + reply->errorString(); + RiaLogging::error( errorMessage ); + + emit parquetDownloadFinished( {}, redirectUri ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QByteArray RiaSumoConnector::requestParquetDataBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ) +{ + requestBlobIdForEnsembleBlocking( caseId, ensembleName, vectorName ); + + if ( m_blobUrl.empty() ) return {}; + + auto blobId = m_blobUrl.back(); + + QEventLoop loop; + connect( this, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ), &loop, SLOT( quit() ) ); + QTimer timer; + + requestBlobDownload( blobId ); + + timer.setSingleShot( true ); + timer.start( RiaSumoDefines::requestTimeoutMillis() ); + loop.exec(); + + for ( const auto& blobData : m_redirectInfo ) + { + if ( blobData.objectId == blobId ) + { + return blobData.contents; + } + } + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +// +//-------------------------------------------------------------------------------------------------- +QString RiaSumoConnector::constructSearchUrl( const QString& server ) +{ + return server + "/api/v1/search"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaSumoConnector::constructDownloadUrl( const QString& server, const QString& blobId ) +{ + return server + "/api/v1/objects('" + blobId + "')/blob"; + // https: // main-sumo-prod.radix.equinor.com/api/v1/objects('76d6d11f-2278-3fe2-f12f-77142ad163c6')/blob +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaSumoConnector::constructAuthUrl( const QString& authority ) +{ + return authority + "/oauth2/v2.0/authorize"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaSumoConnector::constructTokenUrl( const QString& authority ) +{ + return authority + "/oauth2/v2.0/token"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QNetworkReply* RiaSumoConnector::makeRequest( const std::map& parameters, const QString& server, const QString& token ) +{ + QNetworkRequest m_networkRequest; + m_networkRequest.setUrl( QUrl( constructSearchUrl( server ) ) ); + + addStandardHeader( m_networkRequest, token, RiaDefines::contentTypeJson() ); + + QJsonObject obj; + for ( auto [key, value] : parameters ) + { + obj.insert( key, value ); + } + + QJsonDocument doc( obj ); + QString strJson( doc.toJson( QJsonDocument::Compact ) ); + + auto reply = m_networkAccessManager->post( m_networkRequest, strJson.toUtf8() ); + return reply; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::parseAssets( QNetworkReply* reply ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + if ( reply->error() == QNetworkReply::NoError ) + { + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + + m_assets.clear(); + + for ( auto key : jsonObj.keys() ) + { + QString id; + QString kind; + QString fieldName = key; + m_assets.push_back( SumoAsset{ SumoAssetId( id ), kind, fieldName } ); + } + + for ( auto a : m_assets ) + { + RiaLogging::info( QString( "Asset: %1" ).arg( a.name ) ); + } + } + emit assetsFinished(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::parseEnsembleNames( QNetworkReply* reply, const SumoCaseId& caseId ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + if ( reply->error() == QNetworkReply::NoError ) + { + m_ensembleNames.clear(); + + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + auto keys_1 = jsonObj.keys(); + + auto aggregationsObject = jsonObj["aggregations"].toObject(); + + QJsonObject aggregationColumnsObject = aggregationsObject["aggs_columns"].toObject(); + auto keys_2 = aggregationColumnsObject.keys(); + + QJsonArray bucketsArray = aggregationColumnsObject["buckets"].toArray(); + foreach ( const QJsonValue& bucket, bucketsArray ) + { + QJsonObject bucketObj = bucket.toObject(); + auto keys_3 = bucketObj.keys(); + + auto ensembleName = bucketObj["key"].toString(); + m_ensembleNames.push_back( { caseId, ensembleName } ); + } + } + + emit ensembleNamesFinished(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::parseCases( QNetworkReply* reply ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + if ( reply->error() == QNetworkReply::NoError ) + { + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + QJsonObject rootHits = jsonObj["hits"].toObject(); + + QJsonArray hitsObjects = rootHits["hits"].toArray(); + + m_cases.clear(); + + foreach ( const QJsonValue& value, hitsObjects ) + { + QJsonObject resultObj = value.toObject(); + auto keys_1 = resultObj.keys(); + + QJsonObject sourceObj = resultObj["_source"].toObject(); + auto sourceKeys = sourceObj.keys(); + + QJsonObject fmuObj = sourceObj["fmu"].toObject(); + auto fmuObjKeys = fmuObj.keys(); + + QJsonObject fmuCase = fmuObj["case"].toObject(); + auto fmuCaseKeys = fmuCase.keys(); + + QString id = resultObj["_id"].toString(); + QString kind = ""; + QString fieldName = fmuCase["name"].toString(); + m_cases.push_back( SumoCase{ SumoCaseId( id ), kind, fieldName } ); + } + + emit casesFinished(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::parseVectorNames( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + m_vectorNames.clear(); + + if ( reply->error() == QNetworkReply::NoError ) + { + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + + QJsonArray tableHits = jsonObj["aggregations"].toObject()["smry_tables"].toObject()["buckets"].toArray(); + for ( const auto& tableHit : tableHits ) + { + QJsonArray columnHits = tableHit.toObject()["smry_columns"].toObject()["buckets"].toArray(); + for ( const auto& columnHit : columnHits ) + { + m_vectorNames.push_back( columnHit.toObject()["key"].toString() ); + } + } + } + + emit vectorNamesFinished(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::parseRealizationNumbers( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + if ( reply->error() == QNetworkReply::NoError ) + { + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + + QJsonArray hits = jsonObj["aggregations"].toObject()["realization-ids"].toObject()["buckets"].toArray(); + for ( const auto& hit : hits ) + { + QJsonObject resultObj = hit.toObject(); + auto keys_1 = resultObj.keys(); + + auto val = resultObj.value( "key" ); + auto intValue = val.toInt(); + + auto realizationId = QString::number( intValue ); + m_realizationIds.push_back( realizationId ); + } + } + + emit realizationIdsFinished(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::parseBlobIds( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + m_blobUrl.clear(); + + if ( reply->error() == QNetworkReply::NoError ) + { + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + + QJsonObject rootHits = jsonObj["hits"].toObject(); + QJsonArray hitsObjects = rootHits["hits"].toArray(); + + foreach ( const QJsonValue& value, hitsObjects ) + { + QJsonObject resultObj = value.toObject(); + auto keys_1 = resultObj.keys(); + + QJsonObject sourceObj = resultObj["_source"].toObject(); + auto sourceKeys = sourceObj.keys(); + + QJsonObject fmuObj = sourceObj["_sumo"].toObject(); + auto fmuObjKeys = fmuObj.keys(); + + auto blobName = fmuObj["blob_name"].toString(); + m_blobUrl.push_back( blobName ); + } + } + + emit blobIdFinished(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::saveFile( QNetworkReply* reply, const QString& fileId ) +{ + QByteArray result = reply->readAll(); + reply->deleteLater(); + + if ( reply->error() == QNetworkReply::NoError ) + { + QEventLoop loop; + + QJsonDocument doc = QJsonDocument::fromJson( result ); + QJsonObject jsonObj = doc.object(); + + QString signedUrl = jsonObj["SignedUrl"].toString(); + + RiaFileDownloader* downloader = new RiaFileDownloader; + QUrl url( signedUrl ); + QString filePath = "/tmp/" + generateRandomString( 30 ) + ".txt"; + + QString formattedJsonString = doc.toJson( QJsonDocument::Indented ); + + RiaLogging::info( QString( "File download: %1 => %2" ).arg( signedUrl ).arg( filePath ) ); + connect( this, SIGNAL( fileDownloadFinished( const QString&, const QString& ) ), &loop, SLOT( quit() ) ); + connect( downloader, + &RiaFileDownloader::done, + [this, fileId, filePath]() + { + RiaLogging::info( QString( "Download complete %1 => %2" ).arg( fileId ).arg( filePath ) ); + emit( fileDownloadFinished( fileId, filePath ) ); + } ); + RiaLogging::info( "Starting download" ); + downloader->downloadFile( url, filePath ); + + downloader->deleteLater(); + loop.exec(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& contentType ) +{ + networkRequest.setHeader( QNetworkRequest::ContentTypeHeader, contentType ); + networkRequest.setRawHeader( "Authorization", "Bearer " + token.toUtf8() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaSumoConnector::requestTokenBlocking() +{ + if ( !m_token.isEmpty() ) return m_token; + + QTimer timer; + timer.setSingleShot( true ); + QEventLoop loop; + connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) ); + connect( &timer, SIGNAL( timeout() ), &loop, SLOT( quit() ) ); + requestToken(); + timer.start( RiaSumoDefines::requestTimeoutMillis() ); + loop.exec(); + return m_token; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QNetworkReply* RiaSumoConnector::makeDownloadRequest( const QString& url, const QString& token, const QString& contentType ) +{ + QNetworkRequest m_networkRequest; + m_networkRequest.setUrl( QUrl( url ) ); + + addStandardHeader( m_networkRequest, token, contentType ); + + auto reply = m_networkAccessManager->get( m_networkRequest ); + return reply; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestParquetData( const QString& url, const QString& token ) +{ + RiaLogging::info( "Requesting download of parquet from: " + url ); + + auto reply = makeDownloadRequest( url, token, RiaDefines::contentTypeJson() ); + connect( reply, + &QNetworkReply::finished, + [this, reply, url]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + QByteArray contents = reply->readAll(); + RiaLogging::info( QString( "Download succeeded: %1 bytes." ).arg( contents.length() ) ); + emit parquetDownloadFinished( contents, "" ); + } + else + { + QString errorMessage = "Download failed: " + url + " failed." + reply->errorString(); + RiaLogging::error( errorMessage ); + emit parquetDownloadFinished( QByteArray(), errorMessage ); + } + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaSumoConnector::generateRandomString( int randomStringLength ) +{ + const QString possibleCharacters( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ); + QString randomString; + for ( int i = 0; i < randomStringLength; ++i ) + { + quint32 value = QRandomGenerator::global()->generate(); + int index = value % possibleCharacters.length(); + QChar nextChar = possibleCharacters.at( index ); + randomString.append( nextChar ); + } + return randomString; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaSumoConnector::server() const +{ + return m_server; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaSumoConnector::assets() const +{ + return m_assets; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaSumoConnector::cases() const +{ + return m_cases; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaSumoConnector::ensembleNamesForCase( const SumoCaseId& caseId ) const +{ + std::vector ensembleNames; + for ( const auto& ensemble : m_ensembleNames ) + { + if ( ensemble.caseId == caseId ) + { + ensembleNames.push_back( ensemble.name ); + } + } + return ensembleNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaSumoConnector::vectorNames() const +{ + return m_vectorNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaSumoConnector::realizationIds() const +{ + return m_realizationIds; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaSumoConnector::blobUrls() const +{ + return m_blobUrl; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaSumoConnector::blobContents() const +{ + return m_redirectInfo; +} diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h new file mode 100644 index 0000000000..3e8fb62a83 --- /dev/null +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h @@ -0,0 +1,182 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RiaSumoDefines.h" + +#include +#include +#include + +#include + +using SumoObjectId = QString; + +struct SumoAsset +{ + SumoAssetId assetId; + + QString kind; + QString name; +}; + +struct SumoCase +{ + SumoCaseId caseId; + + QString kind; + QString name; +}; + +struct SumoRedirect +{ + SumoObjectId objectId; + QString blobName; + QString url; + QString redirectBaseUri; + QString redirectAuth; + QByteArray contents; +}; + +struct SumoEnsemble +{ + SumoCaseId caseId; + QString name; +}; + +//================================================================================================== +/// +//================================================================================================== +class RiaSumoConnector : public QObject +{ + Q_OBJECT +public: + RiaSumoConnector( QObject* parent, const QString& server, const QString& authority, const QString& scopes, const QString& clientId ); + ~RiaSumoConnector() override; + + QString token() const; + + void importTokenFromFile(); + void setTokenDataFilePath( const QString& filePath ); + + void requestAssets(); + void requestAssetsBlocking(); + + void requestCasesForField( const QString& fieldName ); + void requestCasesForFieldBlocking( const QString& fieldName ); + + void requestEnsembleByCasesId( const SumoCaseId& caseId ); + void requestEnsembleByCasesIdBlocking( const SumoCaseId& caseId ); + + void requestVectorNamesForEnsemble( const SumoCaseId& caseId, const QString& ensembleName ); + void requestVectorNamesForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName ); + + void requestRealizationIdsForEnsemble( const SumoCaseId& caseId, const QString& ensembleName ); + void requestRealizationIdsForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName ); + + void requestBlobIdForEnsemble( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ); + void requestBlobIdForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ); + + void requestBlobDownload( const QString& blobId ); + void requestBlobByRedirectUri( const QString& blobId, const QString& redirectUri ); + + QByteArray requestParquetDataBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ); + + QString server() const; + + std::vector assets() const; + std::vector cases() const; + std::vector ensembleNamesForCase( const SumoCaseId& caseId ) const; + std::vector vectorNames() const; + std::vector realizationIds() const; + std::vector blobUrls() const; + std::vector blobContents() const; + +public slots: + void requestToken(); + + void parseAssets( QNetworkReply* reply ); + void parseEnsembleNames( QNetworkReply* reply, const SumoCaseId& caseId ); + void parseCases( QNetworkReply* reply ); + void parseVectorNames( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName ); + void parseRealizationNumbers( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName ); + void parseBlobIds( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ); + + void saveFile( QNetworkReply* reply, const QString& fileId ); + + void accessGranted(); + void requestFailed( const QAbstractOAuth::Error error ); + void parquetDownloadComplete( const QString& blobId, const QByteArray&, const QString& url ); + +signals: + void fileDownloadFinished( const QString& fileId, const QString& filePath ); + void casesFinished(); + void wellsFinished(); + void wellboresFinished( const QString& wellId ); + void wellboreTrajectoryFinished( const QString& wellboreId ); + void tokenReady( const QString& token ); + void parquetDownloadFinished( const QByteArray& contents, const QString& url ); + void ensembleNamesFinished(); + void vectorNamesFinished(); + void blobIdFinished(); + void assetsFinished(); + void realizationIdsFinished(); + +private: + void addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& contentType ); + + QString requestTokenBlocking(); + + QNetworkReply* makeRequest( const std::map& parameters, const QString& server, const QString& token ); + QNetworkReply* makeDownloadRequest( const QString& url, const QString& token, const QString& contentType ); + void requestParquetData( const QString& url, const QString& token ); + + static QString generateRandomString( int length = 20 ); + static QString constructSearchUrl( const QString& server ); + static QString constructDownloadUrl( const QString& server, const QString& blobId ); + static QString constructAuthUrl( const QString& authority ); + static QString constructTokenUrl( const QString& authority ); + +private: + QOAuth2AuthorizationCodeFlow* m_authCodeFlow; + QNetworkAccessManager* m_networkAccessManager; + + const QString m_server; + const QString m_authority; + const QString m_scopes; + const QString m_clientId; + + QString m_token; + + std::vector m_assets; + std::vector m_cases; + std::vector m_vectorNames; + std::vector m_realizationIds; + std::vector m_ensembleNames; + + std::vector m_blobUrl; + + QString m_redirect; + + std::vector m_redirectInfo; + + QByteArray m_parquetData; + + QString m_tokenDataFilePath; +}; diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp new file mode 100644 index 0000000000..c9502c7ab3 --- /dev/null +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RiaSumoDefines.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaSumoDefines::tokenPath() +{ + QString homePath = QDir::homePath(); + return homePath + "/.resinsight/sumo_token.json"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiaSumoDefines::requestTimeoutMillis() +{ + return 500; +} diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.h b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.h new file mode 100644 index 0000000000..2bb97f0ea4 --- /dev/null +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.h @@ -0,0 +1,32 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "nonstd/type.hpp" + +#include + +using SumoAssetId = nonstd::ordered; +using SumoCaseId = nonstd::ordered; + +namespace RiaSumoDefines +{ +QString tokenPath(); +int requestTimeoutMillis(); +}; // namespace RiaSumoDefines diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp b/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp index 5af3086149..9bc190d04d 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp @@ -393,3 +393,23 @@ void RiaSummaryTools::reloadSummaryCase( RimSummaryCase* summaryCase ) multiPlot->updatePlotTitles(); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSummaryTools::reloadSummaryEnsemble( RimSummaryCaseCollection* ensemble ) +{ + RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); + for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() ) + { + for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() ) + { + summaryPlot->loadDataAndUpdate(); + + // Consider to make the zoom optional + summaryPlot->zoomAll(); + } + + multiPlot->updatePlotTitles(); + } +} diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h index e232162407..1e1f19cb30 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h +++ b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h @@ -86,6 +86,7 @@ class RiaSummaryTools static void copyCurveAxisData( RimSummaryCurve& curve, const RimSummaryCurve& otherCurve ); static void reloadSummaryCase( RimSummaryCase* summaryCase ); + static void reloadSummaryEnsemble( RimSummaryCaseCollection* ensemble ); private: static void updateRequiredCalculatedCurves( RimSummaryCase* sourceSummaryCase ); diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index 2d476be4d7..dfdf6c6127 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -93,6 +93,7 @@ list( Application/CMakeLists_files.cmake Application/Tools/CMakeLists_files.cmake Application/Tools/WellPathTools/CMakeLists_files.cmake + Application/Tools/Cloud/CMakeLists_files.cmake ReservoirDataModel/CMakeLists_files.cmake ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake ReservoirDataModel/Completions/CMakeLists_files.cmake @@ -415,6 +416,7 @@ set(UNITY_EXCLUDE_FILES FileInterface/RifOsduWellPathReader.cpp FileInterface/RifOsduWellLogReader.cpp FileInterface/RifByteArrayArrowRandomAccessFile.cpp + FileInterface/RifArrowTools.cpp ) if(RESINSIGHT_ENABLE_UNITY_BUILD) diff --git a/ApplicationLibCode/Commands/ApplicationCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/ApplicationCommands/CMakeLists_files.cmake index 6d33bbcc4b..f75d1b73a8 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/ApplicationCommands/CMakeLists_files.cmake @@ -20,6 +20,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicOpenInTextEditorFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicShowMemoryReportFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicSumoDataFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -44,13 +45,16 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicOpenInTextEditorFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicShowMemoryReportFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicSumoDataFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) -set(COMMAND_QT_MOC_HEADERS ${COMMAND_QT_MOC_HEADERS}) +list(APPEND COMMAND_QT_MOC_HEADERS + ${CMAKE_CURRENT_LIST_DIR}/RicSumoDataFeature.h +) source_group( "CommandFeature\\Application" diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp index 6a8345f472..678f4e90ba 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp @@ -64,7 +64,6 @@ void RicEditPreferencesFeature::onActionTriggered( bool isChecked ) std::unique_ptr oldPreferences = clonePreferences( app->preferences() ); RiuPropertyViewTabWidget propertyDialog( nullptr, app->preferences(), "Preferences", tabNames ); - propertyDialog.setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); auto pushButton = propertyDialog.dialogButtonBox()->addButton( "Help", QDialogButtonBox::HelpRole ); connect( pushButton, &QPushButton::clicked, this, &RicEditPreferencesFeature::showHelp ); diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.cpp new file mode 100644 index 0000000000..e1c8e67203 --- /dev/null +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.cpp @@ -0,0 +1,288 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RicSumoDataFeature.h" + +#include "RiaApplication.h" +#include "RiaGuiApplication.h" +#include "RiaLogging.h" +#include "RiaPreferences.h" +#include "RiaPreferencesSystem.h" + +#include "RifArrowTools.h" + +#include "RiuMainWindow.h" + +#include +#include + +CAF_CMD_SOURCE_INIT( RicSumoDataFeature, "RicSumoDataFeature" ); + +SimpleDialog::SimpleDialog( QWidget* parent ) + : QDialog( parent ) +{ + setWindowTitle( "Simple Dialog" ); + + QVBoxLayout* layout = new QVBoxLayout( this ); + + label = new QLabel( "This is a simple dialog.", this ); + layout->addWidget( label ); + + authButton = new QPushButton( "Authenticate", this ); + connect( authButton, &QPushButton::clicked, this, &SimpleDialog::onAuthClicked ); + layout->addWidget( authButton ); + + assetsButton = new QPushButton( "Asset Names", this ); + connect( assetsButton, &QPushButton::clicked, this, &SimpleDialog::onAssetsClicked ); + layout->addWidget( assetsButton ); + + casesButton = new QPushButton( "Cases", this ); + connect( casesButton, &QPushButton::clicked, this, &SimpleDialog::onCasesClicked ); + layout->addWidget( casesButton ); + + vectorNamesButton = new QPushButton( "Vector Names", this ); + connect( vectorNamesButton, &QPushButton::clicked, this, &SimpleDialog::onVectorNamesClicked ); + layout->addWidget( vectorNamesButton ); + + blobIdButton = new QPushButton( "Blob Id", this ); + connect( blobIdButton, &QPushButton::clicked, this, &SimpleDialog::onFindBlobIdClicked ); + layout->addWidget( blobIdButton ); + + parquetDownloadButton = new QPushButton( "Parquet", this ); + connect( parquetDownloadButton, &QPushButton::clicked, this, &SimpleDialog::onParquetClicked ); + layout->addWidget( parquetDownloadButton ); + + showContentParquetButton = new QPushButton( "Show Content Parquet", this ); + connect( showContentParquetButton, &QPushButton::clicked, this, &SimpleDialog::onShowContentParquetClicked ); + layout->addWidget( showContentParquetButton ); + + realizationIdsButton = new QPushButton( "Realizations", this ); + connect( realizationIdsButton, &QPushButton::clicked, this, &SimpleDialog::onRealizationsClicked ); + layout->addWidget( realizationIdsButton ); + + okButton = new QPushButton( "OK", this ); + connect( okButton, &QPushButton::clicked, this, &SimpleDialog::onOkClicked ); + layout->addWidget( okButton ); + + cancelButton = new QPushButton( "Cancel", this ); + connect( cancelButton, &QPushButton::clicked, this, &SimpleDialog::onCancelClicked ); + layout->addWidget( cancelButton ); + + setLayout( layout ); + + m_sumoConnector = RiaApplication::instance()->makeSumoConnector(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +SimpleDialog::~SimpleDialog() +{ + if ( m_sumoConnector ) + { + m_sumoConnector->deleteLater(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void SimpleDialog::createConnection() +{ + m_sumoConnector = RiaApplication::instance()->makeSumoConnector(); + connect( m_sumoConnector, &RiaSumoConnector::tokenReady, this, &SimpleDialog::onTokenReady ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void SimpleDialog::onAuthClicked() +{ + createConnection(); + m_sumoConnector->requestToken(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void SimpleDialog::onAssetsClicked() +{ + if ( !isTokenValid() ) return; + + m_sumoConnector->requestAssets(); + m_sumoConnector->assets(); + + label->setText( "Requesting fields (see log for response" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void SimpleDialog::onCasesClicked() +{ + if ( !isTokenValid() ) return; + + QString fieldName = "Drogon"; + m_sumoConnector->requestCasesForField( fieldName ); + + label->setText( "Requesting cases (see log for response" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void SimpleDialog::onVectorNamesClicked() +{ + if ( !isTokenValid() ) return; + + SumoCaseId caseId( "5b783aab-ce10-4b78-b129-baf8d8ce4baa" ); + QString iteration = "iter-0"; + + m_sumoConnector->requestVectorNamesForEnsemble( caseId, iteration ); + + label->setText( "Requesting vector names (see log for response" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void SimpleDialog::onFindBlobIdClicked() +{ + if ( !isTokenValid() ) return; + + SumoCaseId caseId( "5b783aab-ce10-4b78-b129-baf8d8ce4baa" ); + QString iteration = "iter-0"; + QString vectorName = "FOPT"; + + m_sumoConnector->requestBlobIdForEnsemble( caseId, iteration, vectorName ); + + label->setText( "Requesting blob ID for vector name (see log for response" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void SimpleDialog::onParquetClicked() +{ + if ( !isTokenValid() ) return; + + if ( m_sumoConnector->blobUrls().empty() ) + { + onFindBlobIdClicked(); + } + + if ( !m_sumoConnector->blobUrls().empty() ) + { + m_sumoConnector->requestBlobDownload( m_sumoConnector->blobUrls().back() ); + + label->setText( "Requesting blob ID for vector name (see log for response" ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void SimpleDialog::onShowContentParquetClicked() +{ + if ( m_sumoConnector->blobContents().empty() ) return; + + auto blob = m_sumoConnector->blobContents().back(); + + auto content = blob.contents; + + // TODO: show content using parquet reader + auto tableText = RifArrowTools::readFirstRowsOfTable( content ); + RiaLogging::info( tableText ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void SimpleDialog::onRealizationsClicked() +{ + if ( !isTokenValid() ) return; + + SumoCaseId caseId( "485041ce-ad72-48a3-ac8c-484c0ed95cf8" ); + QString iteration = "iter-0"; + + m_sumoConnector->requestRealizationIdsForEnsembleBlocking( caseId, iteration ); + + auto ids = m_sumoConnector->realizationIds(); + for ( const auto& id : ids ) + { + RiaLogging::info( id ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool SimpleDialog::isTokenValid() +{ + if ( !m_sumoConnector ) + { + createConnection(); + } + + if ( m_sumoConnector->token().isEmpty() ) + { + m_sumoConnector->requestToken(); + } + + return !m_sumoConnector->token().isEmpty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void SimpleDialog::onTokenReady( const QString& token ) +{ + RiaLogging::info( "Token ready: " + token ); +} + +void SimpleDialog::onOkClicked() +{ + qDebug( "OK button clicked" ); + accept(); +} + +void SimpleDialog::onCancelClicked() +{ + qDebug( "Cancel button clicked" ); + reject(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSumoDataFeature::onActionTriggered( bool isChecked ) +{ + if ( !m_dialog ) + { + m_dialog = new SimpleDialog( RiaGuiApplication::instance()->mainWindow() ); + } + m_dialog->show(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSumoDataFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "SUMO" ); +} diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.h new file mode 100644 index 0000000000..7dffcd58e5 --- /dev/null +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.h @@ -0,0 +1,85 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "cafCmdFeature.h" + +#include "Cloud/RiaSumoConnector.h" + +#include +#include +#include +#include +#include + +class SimpleDialog : public QDialog +{ + Q_OBJECT + +public: + SimpleDialog( QWidget* parent = nullptr ); + ~SimpleDialog(); + + void createConnection(); + +private: + void onOkClicked(); + void onCancelClicked(); + void onTokenReady( const QString& token ); + void onAuthClicked(); + void onAssetsClicked(); + void onCasesClicked(); + void onVectorNamesClicked(); + void onFindBlobIdClicked(); + void onParquetClicked(); + void onShowContentParquetClicked(); + void onRealizationsClicked(); + + bool isTokenValid(); + +private: + QLabel* label; + QPushButton* okButton; + QPushButton* cancelButton; + QPushButton* authButton; + QPushButton* assetsButton; + QPushButton* casesButton; + QPushButton* vectorNamesButton; + QPushButton* blobIdButton; + QPushButton* parquetDownloadButton; + QPushButton* showContentParquetButton; + QPushButton* realizationIdsButton; + + QPointer m_sumoConnector; +}; + +//================================================================================================== +/// +//================================================================================================== +class RicSumoDataFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + SimpleDialog* m_dialog = nullptr; +}; diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp index 12ecc081e8..511f776eb9 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp @@ -684,6 +684,7 @@ void RiuMainWindow::createToolBars() { QToolBar* toolbar = addToolBar( tr( "Test" ) ); toolbar->setObjectName( toolbar->windowTitle() ); + toolbar->addAction( cmdFeatureMgr->action( "RicSumoDataFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicLaunchRegressionTestsFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicLaunchRegressionTestDialogFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicShowClassNamesFeature" ) ); diff --git a/ApplicationLibCode/UserInterface/RiuPropertyViewTabWidget.cpp b/ApplicationLibCode/UserInterface/RiuPropertyViewTabWidget.cpp index 122be125d4..16028dc8a1 100644 --- a/ApplicationLibCode/UserInterface/RiuPropertyViewTabWidget.cpp +++ b/ApplicationLibCode/UserInterface/RiuPropertyViewTabWidget.cpp @@ -114,7 +114,7 @@ QSize RiuPropertyViewTabWidget::sizeHint() const // qDebug() << "tab size hint" << w->sizeHint(); QSize pageSize = w->sizeHint(); - pageSize += QSize( 0, 100 ); + pageSize += QSize( 60, 100 ); maxSizeHint = maxSizeHint.expandedTo( pageSize ); } From e63005348cc537ef66bcace1505fc36695739dd2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 4 Jul 2024 08:35:45 +0200 Subject: [PATCH 169/332] Create a compact string representation of a list of integers --- .../Application/Tools/RiaStdStringTools.cpp | 48 +++++++++++++++++++ .../Application/Tools/RiaStdStringTools.h | 3 ++ 2 files changed, 51 insertions(+) diff --git a/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp b/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp index dd0178f1cd..154fa1c662 100644 --- a/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp @@ -419,3 +419,51 @@ std::set RiaStdStringTools::valuesFromRangeSelection( const std::string& s, return {}; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RiaStdStringTools::formatRangeSelection( const std::vector& values ) +{ + if ( values.empty() ) return ""; + + std::vector sortedNums = values; + std::sort( sortedNums.begin(), sortedNums.end() ); + + std::ostringstream result; + int start = sortedNums[0]; + int end = sortedNums[0]; + + for ( size_t i = 1; i < sortedNums.size(); ++i ) + { + if ( sortedNums[i] == end + 1 ) + { + end = sortedNums[i]; + } + else + { + if ( start == end ) + { + result << start; + } + else + { + result << start << "-" << end; + } + result << ", "; + start = sortedNums[i]; + end = sortedNums[i]; + } + } + + if ( start == end ) + { + result << start; + } + else + { + result << start << "-" << end; + } + + return result.str(); +} diff --git a/ApplicationLibCode/Application/Tools/RiaStdStringTools.h b/ApplicationLibCode/Application/Tools/RiaStdStringTools.h index 1cf32eb457..5ef8aecc0c 100644 --- a/ApplicationLibCode/Application/Tools/RiaStdStringTools.h +++ b/ApplicationLibCode/Application/Tools/RiaStdStringTools.h @@ -68,6 +68,9 @@ class RiaStdStringTools // The input "-3,5-8,10-", min:1, max:12 will produce {1, 2, 3, 5, 6, 7, 8, 10, 11, 12} static std::set valuesFromRangeSelection( const std::string& s, int minimumValue, int maximumValue ); + // Create a string from a set of values. {1, 2, 3, 5, 6, 7, 8, 10, 11, 12} will be converted to "1, 2, 3, 5-8, 10-12" + static std::string formatRangeSelection( const std::vector& values ); + private: template static void splitByDelimiter( const std::string& str, Container& cont, char delimiter = ' ' ); From c75ba450cef67b123cbe234823496c4794345847 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 3 Jul 2024 15:15:47 +0200 Subject: [PATCH 170/332] Tree Selection Editor: If no option items are present, use field value as options --- .../cafUserInterface/cafPdmUiTreeSelectionEditor.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp index 8c361eb6c2..b02fbb8413 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp @@ -181,6 +181,18 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi( const QString& uiConfigName QList options = uiField()->valueOptions(); + if ( options.empty() ) + { + QVariant fieldValue = uiField()->uiValue(); + QStringList texts = fieldValue.toStringList(); + + for ( const auto& text : texts ) + { + PdmOptionItemInfo item( text, text ); + options.push_back( item ); + } + } + bool itemCountHasChaged = false; if ( m_model->optionItemCount() != options.size() ) itemCountHasChaged = true; From ef8b0836bfea8040e7d428e3f5be4ffe78b15b2e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 3 Jul 2024 15:16:03 +0200 Subject: [PATCH 171/332] Improve handling of read only fields --- .../cafUserInterface/cafPdmUiTreeSelectionQModel.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp index 236a68c09f..b340ab4aac 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp @@ -92,7 +92,7 @@ int caf::PdmUiTreeSelectionQModel::optionItemValueRole() //-------------------------------------------------------------------------------------------------- void caf::PdmUiTreeSelectionQModel::setCheckedStateForItems( const QModelIndexList& sourceModelIndices, bool checked ) { - if ( !m_uiFieldHandle || !m_uiFieldHandle->uiField() ) return; + if ( !m_uiFieldHandle || !m_uiFieldHandle->uiField() || m_uiFieldHandle->uiField()->isUiReadOnly() ) return; std::set selectedIndices; { @@ -142,7 +142,7 @@ void caf::PdmUiTreeSelectionQModel::setCheckedStateForItems( const QModelIndexLi //-------------------------------------------------------------------------------------------------- void caf::PdmUiTreeSelectionQModel::invertCheckedStateForItems( const QModelIndexList& indices ) { - if ( !m_uiFieldHandle || !m_uiFieldHandle->uiField() ) return; + if ( !m_uiFieldHandle || !m_uiFieldHandle->uiField() || m_uiFieldHandle->uiField()->isUiReadOnly() ) return; std::set currentSelectedIndices; { @@ -178,6 +178,8 @@ void caf::PdmUiTreeSelectionQModel::invertCheckedStateForItems( const QModelInde //-------------------------------------------------------------------------------------------------- void caf::PdmUiTreeSelectionQModel::unselectAllItems() { + if ( m_uiFieldHandle->uiField()->isUiReadOnly() ) return; + PdmUiCommandSystemProxy::instance()->setUiValueToField( m_uiFieldHandle->uiField(), {} ); } @@ -464,7 +466,7 @@ QVariant caf::PdmUiTreeSelectionQModel::data( const QModelIndex& index, int role //-------------------------------------------------------------------------------------------------- bool caf::PdmUiTreeSelectionQModel::setData( const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole*/ ) { - if ( !m_uiFieldHandle || !m_uiFieldHandle->uiField() ) return false; + if ( !m_uiFieldHandle || !m_uiFieldHandle->uiField() || m_uiFieldHandle->uiField()->isUiReadOnly() ) return false; if ( role == Qt::CheckStateRole ) { From d751ce4ce020789443ca45bbdc894cb834396dc2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Jul 2024 08:58:58 +0200 Subject: [PATCH 172/332] Add flag to control display of check boxes --- .../cafUserInterface/cafPdmUiTreeSelectionEditor.cpp | 4 ++++ .../cafUserInterface/cafPdmUiTreeSelectionEditor.h | 4 ++++ .../cafUserInterface/cafPdmUiTreeSelectionQModel.cpp | 11 +++++++++++ .../cafUserInterface/cafPdmUiTreeSelectionQModel.h | 2 ++ 4 files changed, 21 insertions(+) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp index b02fbb8413..c2bc9df8f3 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp @@ -216,6 +216,8 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi( const QString& uiConfigName uiObject->editorAttribute( uiField()->fieldHandle(), uiConfigName, &m_attributes ); } + m_model->showCheckBoxes( m_attributes.showCheckBoxes ); + if ( PdmUiTreeSelectionQModel::isMultipleValueField( fieldValue ) ) { m_useSingleSelectionMode = m_attributes.singleSelectionMode; @@ -419,6 +421,8 @@ bool PdmUiTreeSelectionEditor::isMultiRowEditor() const //-------------------------------------------------------------------------------------------------- void PdmUiTreeSelectionEditor::customMenuRequested( const QPoint& pos ) { + if ( !m_attributes.showContextMenu ) return; + QMenu menu; QModelIndexList selectedIndexes = m_treeView->selectionModel()->selectedIndexes(); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h index 06abb8d84a..32edc020a2 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h @@ -64,6 +64,8 @@ class PdmUiTreeSelectionEditorAttribute : public PdmUiEditorAttribute bool showToggleAllCheckbox; bool singleSelectionMode; bool setCurrentIndexWhenItemIsChecked; + bool showCheckBoxes; + bool showContextMenu; int heightHint; /// currentIndexFieldHandle is used to communicate the value of current item in the tree view @@ -79,6 +81,8 @@ class PdmUiTreeSelectionEditorAttribute : public PdmUiEditorAttribute showToggleAllCheckbox = true; singleSelectionMode = false; setCurrentIndexWhenItemIsChecked = false; + showCheckBoxes = true; + showContextMenu = true; heightHint = -1; currentIndexFieldHandle = nullptr; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp index b340ab4aac..c5f005cf77 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.cpp @@ -56,6 +56,7 @@ caf::PdmUiTreeSelectionQModel::PdmUiTreeSelectionQModel( QObject* parent /*= 0*/ , m_uiValueCache( nullptr ) , m_tree( nullptr ) , m_singleSelectionMode( false ) + , m_showCheckBoxes( true ) , m_indexForLastUncheckedItem( QModelIndex() ) { } @@ -191,6 +192,14 @@ void caf::PdmUiTreeSelectionQModel::enableSingleSelectionMode( bool enable ) m_singleSelectionMode = enable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::PdmUiTreeSelectionQModel::showCheckBoxes( bool enable ) +{ + m_showCheckBoxes = enable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -403,6 +412,8 @@ QVariant caf::PdmUiTreeSelectionQModel::data( const QModelIndex& index, int role } else if ( role == Qt::CheckStateRole && !optionItemInfo->isHeading() ) { + if ( !m_showCheckBoxes ) return QVariant(); + if ( m_uiFieldHandle && m_uiFieldHandle->uiField() ) { // Avoid calling the seriously heavy uiValue method if we have a temporary valid cache. diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h index 3def9b3b76..db474e69af 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h @@ -66,6 +66,7 @@ class PdmUiTreeSelectionQModel : public QAbstractItemModel void unselectAllItems(); void enableSingleSelectionMode( bool enable ); + void showCheckBoxes( bool enable ); int optionItemCount() const; void setOptions( caf::PdmUiFieldEditorHandle* field, const QList& options ); @@ -111,6 +112,7 @@ class PdmUiTreeSelectionQModel : public QAbstractItemModel bool m_singleSelectionMode; QModelIndex m_indexForLastUncheckedItem; + bool m_showCheckBoxes; }; } // end namespace caf From 31d653bce75c2706748b671f56bcb4a11aeba350 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Jul 2024 09:06:16 +0200 Subject: [PATCH 173/332] Add Sumo summary ensemble and summary case Add feature to create ensemble from a sumo data source --- ApplicationLibCode/CMakeLists.txt | 2 + .../RicSumoDataFeature.cpp | 2 +- ApplicationLibCode/Commands/CMakeLists.txt | 1 + .../RicShowDataSourcesForRealization.cpp | 6 +- .../Commands/Sumo/CMakeLists_files.cmake | 10 + .../Sumo/RicCreateSumoEnsembleFeature.cpp | 62 +++ .../Sumo/RicCreateSumoEnsembleFeature.h | 33 ++ .../Cloud/CMakeLists_files.cmake | 11 + .../Cloud/RimCloudDataSourceCollection.cpp | 233 ++++++++++ .../Cloud/RimCloudDataSourceCollection.h | 65 +++ .../ProjectDataModel/RimOilField.cpp | 4 + .../ProjectDataModel/RimOilField.h | 2 + .../ProjectDataModel/RimProject.cpp | 6 + .../RimSummaryCalculationCollection.cpp | 2 +- .../RimDerivedEnsembleCaseCollection.cpp | 4 + .../Summary/RimSummaryCase.cpp | 4 +- .../ProjectDataModel/Summary/RimSummaryCase.h | 4 +- .../Summary/RimSummaryCaseCollection.cpp | 2 +- .../Summary/RimSummaryCaseCollection.h | 3 +- .../Summary/RimSummaryCaseMainCollection.cpp | 18 + .../Summary/RimSummaryCaseMainCollection.h | 1 + .../Summary/Sumo/CMakeLists_files.cmake | 14 + .../Summary/Sumo/RimSummaryCaseSumo.cpp | 179 ++++++++ .../Summary/Sumo/RimSummaryCaseSumo.h | 67 +++ .../Summary/Sumo/RimSummaryEnsembleSumo.cpp | 421 ++++++++++++++++++ .../Summary/Sumo/RimSummaryEnsembleSumo.h | 92 ++++ .../Summary/Sumo/RimSummarySumoDataSource.cpp | 207 +++++++++ .../Summary/Sumo/RimSummarySumoDataSource.h | 73 +++ 28 files changed, 1517 insertions(+), 11 deletions(-) create mode 100644 ApplicationLibCode/Commands/Sumo/CMakeLists_files.cmake create mode 100644 ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp create mode 100644 ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.h create mode 100644 ApplicationLibCode/ProjectDataModel/Cloud/CMakeLists_files.cmake create mode 100644 ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.h create mode 100644 ApplicationLibCode/ProjectDataModel/Summary/Sumo/CMakeLists_files.cmake create mode 100644 ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryCaseSumo.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryCaseSumo.h create mode 100644 ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h create mode 100644 ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.h diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index dfdf6c6127..da5036c463 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -103,11 +103,13 @@ list( ProjectDataModel/CMakeLists_files.cmake ProjectDataModel/AnalysisPlots/CMakeLists_files.cmake ProjectDataModel/CorrelationPlots/CMakeLists_files.cmake + ProjectDataModel/Cloud/CMakeLists_files.cmake ProjectDataModel/Faults/CMakeLists_files.cmake ProjectDataModel/GeoMech/CMakeLists_files.cmake ProjectDataModel/GridCrossPlots/CMakeLists_files.cmake ProjectDataModel/GridCrossPlots/CellFilters/CMakeLists_files.cmake ProjectDataModel/Summary/CMakeLists_files.cmake + ProjectDataModel/Summary/Sumo/CMakeLists_files.cmake ProjectDataModel/Flow/CMakeLists_files.cmake ProjectDataModel/Annotations/CMakeLists_files.cmake ProjectDataModel/Completions/CMakeLists_files.cmake diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.cpp index e1c8e67203..c877ba196f 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.cpp @@ -124,7 +124,7 @@ void SimpleDialog::onAssetsClicked() { if ( !isTokenValid() ) return; - m_sumoConnector->requestAssets(); + m_sumoConnector->requestAssetsBlocking(); m_sumoConnector->assets(); label->setText( "Requesting fields (see log for response" ); diff --git a/ApplicationLibCode/Commands/CMakeLists.txt b/ApplicationLibCode/Commands/CMakeLists.txt index f3cd9401e4..34d7e65b88 100644 --- a/ApplicationLibCode/Commands/CMakeLists.txt +++ b/ApplicationLibCode/Commands/CMakeLists.txt @@ -42,6 +42,7 @@ set(COMMAND_REFERENCED_CMAKE_FILES FractureCommands/CMakeLists_files.cmake PlotBuilderCommands/CMakeLists_files.cmake PolygonCommands/CMakeLists_files.cmake + Sumo/CMakeLists_files.cmake ) # Include source file lists from *.cmake files diff --git a/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp b/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp index c1f9b92e80..f444d933e1 100644 --- a/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp +++ b/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp @@ -46,7 +46,7 @@ bool RicShowDataSourcesForRealization::isCommandChecked() const if ( !selection.empty() ) { - return selection.front()->showRealizationDataSources(); + return selection.front()->showVectorItemsInProjectTree(); } return false; @@ -80,10 +80,10 @@ void RicShowDataSourcesForRealization::onActionTriggered( bool isChecked ) if ( selection.empty() ) return; - bool enableDataSources = !selection.front()->showRealizationDataSources(); + bool enableDataSources = !selection.front()->showVectorItemsInProjectTree(); for ( auto summaryCase : selection ) { - summaryCase->setShowRealizationDataSource( enableDataSources ); + summaryCase->setShowVectorItemsInProjectTree( enableDataSources ); } } diff --git a/ApplicationLibCode/Commands/Sumo/CMakeLists_files.cmake b/ApplicationLibCode/Commands/Sumo/CMakeLists_files.cmake new file mode 100644 index 0000000000..8424c2cd60 --- /dev/null +++ b/ApplicationLibCode/Commands/Sumo/CMakeLists_files.cmake @@ -0,0 +1,10 @@ +set(SOURCE_GROUP_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/RicCreateSumoEnsembleFeature.h +) + +set(SOURCE_GROUP_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/RicCreateSumoEnsembleFeature.cpp +) + +list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) +list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) diff --git a/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp b/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp new file mode 100644 index 0000000000..957cda5e7e --- /dev/null +++ b/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RicCreateSumoEnsembleFeature.h" + +#include "RiaSummaryTools.h" + +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" + +#include "RimSummaryCaseMainCollection.h" +#include "Sumo/RimSummaryEnsembleSumo.h" +#include "Sumo/RimSummarySumoDataSource.h" + +#include "cafSelectionManagerTools.h" + +#include + +CAF_CMD_SOURCE_INIT( RicCreateSumoEnsembleFeature, "RicCreateSumoEnsembleFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateSumoEnsembleFeature::onActionTriggered( bool isChecked ) +{ + auto dataSources = caf::selectedObjectsByType(); + for ( auto dataSource : dataSources ) + { + RimSummaryEnsembleSumo* ensemble = new RimSummaryEnsembleSumo(); + ensemble->setSumoDataSource( dataSource ); + ensemble->updateName(); + RiaSummaryTools::summaryCaseMainCollection()->addEnsemble( ensemble ); + ensemble->loadDataAndUpdate(); + + RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( {}, { ensemble } ); + } + + RiaSummaryTools::summaryCaseMainCollection()->updateAllRequiredEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateSumoEnsembleFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Create Sumo Ensemble" ); + actionToSetup->setIcon( QIcon( ":/SummaryEnsemble.svg" ) ); +} diff --git a/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.h b/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.h new file mode 100644 index 0000000000..e9b7674926 --- /dev/null +++ b/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicCreateSumoEnsembleFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Cloud/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Cloud/CMakeLists_files.cmake new file mode 100644 index 0000000000..382da6d6a8 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Cloud/CMakeLists_files.cmake @@ -0,0 +1,11 @@ +set(SOURCE_GROUP_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/RimCloudDataSourceCollection.h +) + +set(SOURCE_GROUP_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/RimCloudDataSourceCollection.cpp +) + +list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) + +list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp new file mode 100644 index 0000000000..e8adeaa172 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp @@ -0,0 +1,233 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimCloudDataSourceCollection.h" + +#include "RiaApplication.h" + +#include "RimOilField.h" +#include "RimProject.h" +#include "Sumo/RimSummarySumoDataSource.h" + +#include "RiuPlotMainWindowTools.h" + +#include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTreeSelectionEditor.h" + +CAF_PDM_SOURCE_INIT( RimCloudDataSourceCollection, "RimCloudDataSourceCollection" ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCloudDataSourceCollection::RimCloudDataSourceCollection() +{ + CAF_PDM_InitObject( "Cloud Data", ":/cloud-and-server.svg" ); + + CAF_PDM_InitFieldNoDefault( &m_sumoFieldName, "SumoFieldId", "Field Id" ); + CAF_PDM_InitFieldNoDefault( &m_sumoCaseId, "SumoCaseId", "Case Id" ); + m_sumoCaseId.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_sumoEnsembleNames, "SumoEnsembleNames", "Ensembles" ); + m_sumoEnsembleNames.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_addEnsembles, "AddEnsembles", "" ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_addEnsembles ); + + CAF_PDM_InitFieldNoDefault( &m_sumoDataSources, "SumoDataSources", "Sumo Data Sources" ); + + m_sumoConnector = RiaApplication::instance()->makeSumoConnector(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCloudDataSourceCollection* RimCloudDataSourceCollection::instance() +{ + return RimProject::current()->activeOilField()->cloudDataCollection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCloudDataSourceCollection::sumoDataSources() const +{ + return m_sumoDataSources.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCloudDataSourceCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + if ( changedField == &m_sumoFieldName ) + { + m_sumoCaseId = ""; + m_sumoEnsembleNames.v().clear(); + + m_sumoConnector->requestCasesForFieldBlocking( m_sumoFieldName ); + } + else if ( changedField == &m_sumoCaseId ) + { + m_sumoEnsembleNames.v().clear(); + } + if ( changedField == &m_addEnsembles ) + { + addEnsemble(); + + m_addEnsembles = false; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimCloudDataSourceCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + if ( fieldNeedingOptions == &m_sumoFieldName ) + { + if ( m_sumoConnector->assets().empty() ) + { + m_sumoConnector->requestAssetsBlocking(); + } + + for ( const auto& asset : m_sumoConnector->assets() ) + { + if ( m_sumoFieldName().isEmpty() ) + { + m_sumoFieldName = asset.name; + } + + options.push_back( { asset.name, asset.name } ); + } + } + else if ( fieldNeedingOptions == &m_sumoCaseId && !m_sumoFieldName().isEmpty() ) + { + if ( m_sumoConnector->cases().empty() ) + { + m_sumoConnector->requestCasesForFieldBlocking( m_sumoFieldName ); + } + + for ( const auto& sumoCase : m_sumoConnector->cases() ) + { + options.push_back( { sumoCase.name, sumoCase.caseId.get() } ); + } + } + else if ( fieldNeedingOptions == &m_sumoEnsembleNames && !m_sumoCaseId().isEmpty() ) + { + if ( m_sumoConnector->ensembleNamesForCase( SumoCaseId( m_sumoCaseId ) ).empty() ) + { + m_sumoConnector->requestEnsembleByCasesIdBlocking( SumoCaseId( m_sumoCaseId ) ); + } + + for ( const auto& name : m_sumoConnector->ensembleNamesForCase( SumoCaseId( m_sumoCaseId ) ) ) + { + options.push_back( { name, name } ); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCloudDataSourceCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_sumoFieldName ); + uiOrdering.add( &m_sumoCaseId ); + uiOrdering.add( &m_sumoEnsembleNames ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCloudDataSourceCollection::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_addEnsembles ) + { + if ( auto attrib = dynamic_cast( attribute ) ) + { + attrib->m_buttonText = "Add Ensemble(s)"; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCloudDataSourceCollection::addEnsemble() +{ + RimSummarySumoDataSource* objectToSelect = nullptr; + auto sumoCaseId = SumoCaseId( m_sumoCaseId ); + + for ( const auto& ensembleName : m_sumoEnsembleNames() ) + { + bool createNewDataSource = true; + for ( const auto dataSource : sumoDataSources() ) + { + if ( dataSource->caseId() == sumoCaseId && dataSource->ensembleName() == ensembleName ) + { + createNewDataSource = false; + break; + } + } + + if ( !createNewDataSource ) + { + continue; + } + + QString caseName; + for ( const auto& sumoCase : m_sumoConnector->cases() ) + { + if ( sumoCase.caseId == sumoCaseId ) + { + caseName = sumoCase.name; + break; + } + } + + m_sumoConnector->requestRealizationIdsForEnsembleBlocking( sumoCaseId, ensembleName ); + m_sumoConnector->requestVectorNamesForEnsembleBlocking( sumoCaseId, ensembleName ); + + auto realizationIds = m_sumoConnector->realizationIds(); + auto vectorNames = m_sumoConnector->vectorNames(); + + auto dataSource = new RimSummarySumoDataSource(); + dataSource->setCaseId( sumoCaseId ); + dataSource->setCaseName( caseName ); + dataSource->setEnsembleName( ensembleName ); + dataSource->setRealizationIds( realizationIds ); + dataSource->setVectorNames( vectorNames ); + dataSource->updateName(); + + objectToSelect = dataSource; + + m_sumoDataSources.push_back( dataSource ); + } + + uiCapability()->updateAllRequiredEditors(); + + if ( objectToSelect ) + { + RiuPlotMainWindowTools::setExpanded( objectToSelect ); + RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect ); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.h b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.h new file mode 100644 index 0000000000..20f699e26d --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.h @@ -0,0 +1,65 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include "Cloud/RiaSumoConnector.h" + +#include +#include + +class RimSummarySumoDataSource; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimCloudDataSourceCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimCloudDataSourceCollection(); + + static RimCloudDataSourceCollection* instance(); + + std::vector sumoDataSources() const; + +private: + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + + void addEnsemble(); + +private: + caf::PdmField m_sumoFieldName; + caf::PdmField m_sumoCaseId; + caf::PdmField> m_sumoEnsembleNames; + + caf::PdmField m_addEnsembles; + caf::PdmChildArrayField m_sumoDataSources; + + QPointer m_sumoConnector; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp index 58355cdd4c..97cb58c00d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp @@ -37,6 +37,7 @@ #include "RimSurfaceCollection.h" #include "RimWellPathCollection.h" +#include "Cloud/RimCloudDataSourceCollection.h" #include "Polygons/RimPolygonCollection.h" #include "VerticalFlowPerformance/RimVfpDataCollection.h" @@ -97,6 +98,9 @@ RimOilField::RimOilField() CAF_PDM_InitFieldNoDefault( &vfpDataCollection, "VfpDataCollection", "VFP Data" ); vfpDataCollection = new RimVfpDataCollection(); + CAF_PDM_InitFieldNoDefault( &cloudDataCollection, "CloudDataCollection", "Cloud Data" ); + cloudDataCollection = new RimCloudDataSourceCollection(); + m_fractureTemplateCollection_OBSOLETE = new RimFractureTemplateCollection; m_fractureTemplateCollection_OBSOLETE.xmlCapability()->setIOWritable( false ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimOilField.h b/ApplicationLibCode/ProjectDataModel/RimOilField.h index 2974ea42c7..42cac85898 100644 --- a/ApplicationLibCode/ProjectDataModel/RimOilField.h +++ b/ApplicationLibCode/ProjectDataModel/RimOilField.h @@ -45,6 +45,7 @@ class RimPolygonCollection; class RimEclipseViewCollection; class RimEclipseContourMapViewCollection; class RimVfpDataCollection; +class RimCloudDataSourceCollection; //================================================================================================== /// @@ -81,6 +82,7 @@ class RimOilField : public caf::PdmObject caf::PdmChildField polygonCollection; caf::PdmChildField eclipseContourMapCollection; caf::PdmChildField vfpDataCollection; + caf::PdmChildField cloudDataCollection; protected: void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index bac06037db..5377b8079f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -34,6 +34,7 @@ #include "RigEclipseCaseData.h" #include "RigGridBase.h" +#include "Cloud/RimCloudDataSourceCollection.h" #include "PlotTemplates/RimPlotTemplateFolderItem.h" #include "Polygons/RimPolygonCollection.h" #include "RimAdvancedSnapshotExportDefinition.h" @@ -1364,6 +1365,11 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q { if ( m_mainPlotCollection ) { + if ( activeOilField()->cloudDataCollection() ) + { + uiTreeOrdering.add( activeOilField()->cloudDataCollection() ); + } + if ( m_mainPlotCollection->summaryMultiPlotCollection() ) { uiTreeOrdering.add( m_mainPlotCollection->summaryMultiPlotCollection() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp index 9e97481b73..7a6f338660 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp @@ -62,7 +62,7 @@ void RimSummaryCalculationCollection::updateDataDependingOnCalculations() { reader->buildMetaData(); - if ( summaryCase->showRealizationDataSources() ) + if ( summaryCase->showVectorItemsInProjectTree() ) { summaryCase->onCalculationUpdated(); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp index 3d09020a86..f882e17a23 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp @@ -429,6 +429,10 @@ RimDerivedSummaryCase* RimDerivedEnsembleCaseCollection::firstCaseNotInUse() // If no active case was found, add a new case to the collection auto newCase = new RimDerivedSummaryCase(); + + // Show realization data source for the first case. If we create for all, the performance will be bad + newCase->setShowVectorItemsInProjectTree( m_cases.empty() ); + m_cases.push_back( newCase ); return newCase; } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp index c4a9deab55..006ecc9548 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -104,7 +104,7 @@ bool RimSummaryCase::isObservedData() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimSummaryCase::showRealizationDataSources() const +bool RimSummaryCase::showVectorItemsInProjectTree() const { return m_showSubNodesInTree(); } @@ -112,7 +112,7 @@ bool RimSummaryCase::showRealizationDataSources() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCase::setShowRealizationDataSource( bool enable ) +void RimSummaryCase::setShowVectorItemsInProjectTree( bool enable ) { m_showSubNodesInTree = enable; updateConnectedEditors(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h index 7c6f36a3c3..81352cc701 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -79,8 +79,8 @@ class RimSummaryCase : public caf::PdmObject bool isObservedData() const; - bool showRealizationDataSources() const; - void setShowRealizationDataSource( bool enable ); + bool showVectorItemsInProjectTree() const; + void setShowVectorItemsInProjectTree( bool enable ); void setCaseRealizationParameters( const std::shared_ptr& crlParameters ); std::shared_ptr caseRealizationParameters() const; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index e53fa8085f..0124a43da3 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -121,7 +121,7 @@ void RimSummaryCaseCollection::addCase( RimSummaryCase* summaryCase ) { summaryCase->nameChanged.connect( this, &RimSummaryCaseCollection::onCaseNameChanged ); - summaryCase->setShowRealizationDataSource( m_cases.empty() ); + summaryCase->setShowVectorItemsInProjectTree( m_cases.empty() ); m_cases.push_back( summaryCase ); m_cachedSortedEnsembleParameters.clear(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index 02ce930e10..d52a28c69f 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -115,7 +115,6 @@ class RimSummaryCaseCollection : public caf::PdmObject void onCaseNameChanged( const SignalEmitter* emitter ); - void buildMetaData(); void buildChildNodes(); void clearChildNodes(); @@ -124,6 +123,8 @@ class RimSummaryCaseCollection : public caf::PdmObject void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; + void buildMetaData(); + caf::PdmChildArrayField m_cases; private: diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index d38616948d..3d4588cd4f 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -258,6 +258,24 @@ void RimSummaryCaseMainCollection::removeCaseCollection( RimSummaryCaseCollectio dataSourceHasChanged.send(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseMainCollection::addEnsemble( RimSummaryCaseCollection* ensemble ) +{ + CVF_ASSERT( ensemble ); + + m_caseCollections.push_back( ensemble ); + + if ( ensemble->ensembleId() == -1 ) + { + RimProject* project = RimProject::current(); + project->assignIdToEnsemble( ensemble ); + } + + dataSourceHasChanged.send(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index 2d1e6fe22b..a02f3e666e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -66,6 +66,7 @@ class RimSummaryCaseMainCollection : public caf::PdmObject bool isEnsemble, std::function allocator = defaultAllocator ); void removeCaseCollection( RimSummaryCaseCollection* caseCollection ); + void addEnsemble( RimSummaryCaseCollection* ensemble ); void loadAllSummaryCaseData(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/CMakeLists_files.cmake new file mode 100644 index 0000000000..16d2577a8f --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/CMakeLists_files.cmake @@ -0,0 +1,14 @@ +set(SOURCE_GROUP_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryEnsembleSumo.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseSumo.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummarySumoDataSource.h +) + +set(SOURCE_GROUP_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryEnsembleSumo.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseSumo.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummarySumoDataSource.cpp +) + +list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) +list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryCaseSumo.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryCaseSumo.cpp new file mode 100644 index 0000000000..9676dbacb0 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryCaseSumo.cpp @@ -0,0 +1,179 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimSummaryCaseSumo.h" + +#include "RimSummaryEnsembleSumo.h" + +#include "cafPdmObjectScriptingCapability.h" + +CAF_PDM_SOURCE_INIT( RimSummaryCaseSumo, "RimSummaryCaseSumo" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseSumo::RimSummaryCaseSumo() + : m_realizationNumber( -1 ) +{ + CAF_PDM_InitScriptableObject( "Sumo Realization", ":/SummaryCase.svg" ); + + m_ensemble = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseSumo::createSummaryReaderInterface() +{ + // Nothing to do here +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifSummaryReaderInterface* RimSummaryCaseSumo::summaryReader() +{ + return this; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryCaseSumo::timeSteps( const RifEclipseSummaryAddress& resultAddress ) const +{ + return m_timeSteps; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair> RimSummaryCaseSumo::values( const RifEclipseSummaryAddress& resultAddress ) const +{ + auto it = m_values.find( resultAddress ); + if ( it == m_values.end() && m_ensemble ) + { + // We can be asked for a result that is not available in the cache. In this case we need to load the data from the ensemble. + + m_ensemble->loadSummaryData( resultAddress ); + it = m_values.find( resultAddress ); + } + + if ( it != m_values.end() ) + { + std::vector doubleValues; + doubleValues.reserve( it->second.size() ); + for ( auto value : it->second ) + { + doubleValues.push_back( value ); + } + return { true, doubleValues }; + } + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimSummaryCaseSumo::unitName( const RifEclipseSummaryAddress& resultAddress ) const +{ + if ( m_ensemble ) return m_ensemble->unitName( resultAddress ); + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaDefines::EclipseUnitSystem RimSummaryCaseSumo::unitSystem() const +{ + if ( m_ensemble ) return m_ensemble->unitSystem(); + + return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseSumo::setEnsemble( RimSummaryEnsembleSumo* ensemble ) +{ + m_ensemble = ensemble; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseSumo::setValues( const std::vector& timeSteps, + const RifEclipseSummaryAddress& resultAddress, + const std::vector& values ) +{ + m_timeSteps = timeSteps; + m_values[resultAddress] = values; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int32_t RimSummaryCaseSumo::realizationNumber() const +{ + return m_realizationNumber; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseSumo::setRealizationNumber( int32_t realizationNumber ) +{ + m_realizationNumber = realizationNumber; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryCaseSumo::realizationName() const +{ + return m_realizationName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseSumo::setRealizationName( const QString& realizationName ) +{ + m_realizationName = realizationName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryCaseSumo::caseName() const +{ + return realizationName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseSumo::buildMetaData() +{ + if ( m_ensemble ) + { + auto addresses = m_ensemble->allResultAddresses(); + m_allResultAddresses = addresses; + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryCaseSumo.h b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryCaseSumo.h new file mode 100644 index 0000000000..54ffb0f3fe --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryCaseSumo.h @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RifSummaryReaderInterface.h" + +#include "RimSummaryCase.h" + +#include "cafPdmPointer.h" + +class RimSummaryEnsembleSumo; + +//================================================================================================== +// +// +// +//================================================================================================== +class RimSummaryCaseSumo : public RimSummaryCase, public RifSummaryReaderInterface +{ + CAF_PDM_HEADER_INIT; + +public: + RimSummaryCaseSumo(); + + void setEnsemble( RimSummaryEnsembleSumo* ensemble ); + void setValues( const std::vector& timeSteps, const RifEclipseSummaryAddress& resultAddress, const std::vector& values ); + + int32_t realizationNumber() const; + void setRealizationNumber( int32_t realizationNumber ); + + QString realizationName() const; + void setRealizationName( const QString& realizationName ); + + void createSummaryReaderInterface() override; + RifSummaryReaderInterface* summaryReader() override; + + std::vector timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override; + std::pair> values( const RifEclipseSummaryAddress& resultAddress ) const override; + std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override; + RiaDefines::EclipseUnitSystem unitSystem() const override; + +protected: + QString caseName() const override; + void buildMetaData() override; + +private: + caf::PdmPointer m_ensemble; + QString m_realizationName; + int32_t m_realizationNumber; + std::vector m_timeSteps; + std::map> m_values; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp new file mode 100644 index 0000000000..7f5d8d30d1 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp @@ -0,0 +1,421 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimSummaryEnsembleSumo.h" + +#include "RiaApplication.h" +#include "RiaLogging.h" +#include "RiaSummaryDefines.h" +#include "RiaSummaryTools.h" +#include "RiaTimeTTools.h" + +#include "RifArrowTools.h" +#include "RifByteArrayArrowRandomAccessFile.h" +#include "RifEclipseSummaryAddress.h" + +#include "Cloud/RimCloudDataSourceCollection.h" +#include "RimSummaryCaseSumo.h" +#include "RimSummarySumoDataSource.h" + +CAF_PDM_SOURCE_INIT( RimSummaryEnsembleSumo, "RimSummaryEnsembleSumo" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryEnsembleSumo::RimSummaryEnsembleSumo() +{ + CAF_PDM_InitObject( "Sumo Ensemble", ":/SummaryCase.svg", "", "The Base Class for all Summary Cases" ); + + CAF_PDM_InitFieldNoDefault( &m_sumoDataSource, "SumoDataSource", "Sumo Data Source" ); + + // Disable IO for cases, as the reconstruction is done by loading data from Sumo + // Will also reduce the amount of data stored in the project file + m_cases.xmlCapability()->disableIO(); + + setAsEnsemble( true ); + + m_sumoConnector = RiaApplication::instance()->makeSumoConnector(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleSumo::setSumoDataSource( RimSummarySumoDataSource* sumoDataSource ) +{ + m_sumoDataSource = sumoDataSource; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleSumo::updateName() +{ + if ( m_sumoDataSource() ) + { + setName( m_sumoDataSource()->name() ); + } + else + { + setName( "No Sumo Data Source" ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimSummaryEnsembleSumo::unitName( const RifEclipseSummaryAddress& resultAddress ) +{ + // TODO: Not implemented yet. Need to get the unit name from the Sumo data source + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaDefines::EclipseUnitSystem RimSummaryEnsembleSumo::unitSystem() const +{ + // TODO: Not implemented yet. Need to get the unit name from the Sumo data source + return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RimSummaryEnsembleSumo::allResultAddresses() const +{ + return m_resultAddresses; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleSumo::loadSummaryData( const RifEclipseSummaryAddress& resultAddress ) +{ + if ( resultAddress.category() == SummaryCategory::SUMMARY_ENSEMBLE_STATISTICS ) return; + + if ( !m_sumoDataSource() ) return; + + auto resultText = QString::fromStdString( resultAddress.toEclipseTextAddress() ); + + auto sumoCaseId = m_sumoDataSource->caseId(); + auto sumoEnsembleName = m_sumoDataSource->ensembleName(); + + auto key = ParquetKey{ sumoCaseId, sumoEnsembleName, resultText }; + + if ( m_parquetTable.find( key ) == m_parquetTable.end() ) + { + auto contents = loadParquetData( key ); + + arrow::MemoryPool* pool = arrow::default_memory_pool(); + + std::shared_ptr input = std::make_shared( contents ); + + std::shared_ptr table; + std::unique_ptr arrow_reader; + if ( parquet::arrow::OpenFile( input, pool, &arrow_reader ).ok() ) + { + if ( arrow_reader->ReadTable( &table ).ok() ) + { + RiaLogging::info( "Parquet: Read table" ); + } + else + { + RiaLogging::warning( "Parquet: Error detected during parsing of table" ); + } + } + else + { + RiaLogging::warning( "Parquet: Not able to open data stream" ); + } + + m_parquetTable[key] = table; + + distributeDataToRealizations( resultAddress, table ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QByteArray RimSummaryEnsembleSumo::loadParquetData( const ParquetKey& parquetKey ) +{ + if ( !m_sumoConnector ) return {}; + + return m_sumoConnector->requestParquetDataBlocking( SumoCaseId( parquetKey.caseId ), parquetKey.ensembleId, parquetKey.vectorName ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleSumo::distributeDataToRealizations( const RifEclipseSummaryAddress& resultAddress, std::shared_ptr table ) +{ + if ( !table ) + { + RiaLogging::warning( "Failed to load table" ); + return; + } + + { + // print header information + QString txt = "Column Names: "; + + for ( std::string columnName : table->ColumnNames() ) + { + txt += QString::fromStdString( columnName ) + " "; + } + + RiaLogging::info( txt ); + } + + std::vector timeSteps; + std::vector realizations; + std::vector values; + + { + const std::string columnName = "DATE"; + std::shared_ptr column = table->GetColumnByName( columnName ); + if ( column && column->type()->id() == arrow::Type::TIMESTAMP ) + { + auto timeColumn = RifArrowTools::chunkedArrayToVector( column ); + timeSteps = std::vector( timeColumn.size() ); + + for ( size_t i = 0; i < timeColumn.size(); ++i ) + { + timeSteps[i] = RiaTimeTTools::fromDouble( timeColumn[i] ); + } + } + else + { + RiaLogging::warning( "Failed to find DATE column" ); + return; + } + } + + { + const std::string columnName = "REAL"; + std::shared_ptr column = table->GetColumnByName( columnName ); + if ( column && column->type()->id() == arrow::Type::INT16 ) + { + realizations = RifArrowTools::chunkedArrayToVector( column ); + } + else + { + RiaLogging::warning( "Failed to find realization column" ); + return; + } + } + + { + const std::string columnName = resultAddress.toEclipseTextAddress(); + std::shared_ptr column = table->GetColumnByName( columnName ); + if ( column && column->type()->id() == arrow::Type::FLOAT ) + { + values = RifArrowTools::chunkedArrayToVector( column ); + } + else + { + RiaLogging::warning( "Failed to find values column" ); + return; + } + } + + // find unique realizations + std::set uniqueRealizations; + for ( auto realizationNumber : realizations ) + { + uniqueRealizations.insert( realizationNumber ); + } + + // find start and end index for a given realization number + std::map> realizationIndex; + for ( size_t i = 0; i < realizations.size(); ++i ) + { + auto realizationNumber = realizations[i]; + uniqueRealizations.insert( realizationNumber ); + + if ( realizationIndex.find( realizationNumber ) == realizationIndex.end() ) + { + realizationIndex[realizationNumber] = { i, i }; + } + else + { + realizationIndex[realizationNumber].second = i; + } + } + + auto findSummaryCase = [this]( int16_t realizationNumber ) -> RimSummaryCaseSumo* + { + for ( auto sumCase : allSummaryCases() ) + { + auto sumCaseSumo = dynamic_cast( sumCase ); + if ( sumCaseSumo->realizationNumber() == realizationNumber ) return sumCaseSumo; + } + + return nullptr; + }; + + for ( auto realizationNumber : uniqueRealizations ) + { + auto summaryCase = findSummaryCase( realizationNumber ); + if ( !summaryCase ) continue; + + auto start = realizationIndex[realizationNumber].first; + auto end = realizationIndex[realizationNumber].second; + + std::vector realizationTimeSteps( timeSteps.begin() + start, timeSteps.begin() + end ); + std::vector realizationValues( values.begin() + start, values.begin() + end ); + + summaryCase->setValues( realizationTimeSteps, resultAddress, realizationValues ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleSumo::buildMetaData() +{ + for ( auto summaryCase : allSummaryCases() ) + { + summaryCase->summaryReader()->buildMetaData(); + } + + RimSummaryCaseCollection::buildMetaData(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleSumo::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_sumoDataSource ); + + auto group = uiOrdering.addNewGroup( "General" ); + RimSummaryCaseCollection::defineUiOrdering( uiConfigName, *group ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimSummaryEnsembleSumo::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + if ( fieldNeedingOptions == &m_sumoDataSource ) + { + for ( const auto& sumoDataSource : RimCloudDataSourceCollection::instance()->sumoDataSources() ) + { + options.push_back( { sumoDataSource->name(), sumoDataSource } ); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleSumo::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + if ( changedField == &m_sumoDataSource ) + { + clearCachedData(); + updateResultAddresses(); + updateName(); + buildMetaData(); + + updateConnectedEditors(); + + RiaSummaryTools::reloadSummaryEnsemble( this ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleSumo::updateResultAddresses() +{ + m_resultAddresses.clear(); + + if ( !m_sumoDataSource() ) return; + + auto vectorNames = m_sumoDataSource->vectorNames(); + for ( auto vectorName : vectorNames ) + { + auto adr = RifEclipseSummaryAddress::fromEclipseTextAddress( vectorName.toStdString() ); + m_resultAddresses.insert( adr ); + } + + auto caseName = m_sumoDataSource->caseId().get(); + auto ensName = m_sumoDataSource->ensembleName(); + + RiaLogging::info( QString( "Case: %1, ens: %2, vector count: %3" ).arg( caseName ).arg( ensName ).arg( m_resultAddresses.size() ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleSumo::clearCachedData() +{ + m_resultAddresses.clear(); + m_parquetTable.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleSumo::onLoadDataAndUpdate() +{ + if ( m_sumoDataSource() ) + { + auto realizationIds = m_sumoDataSource->realizationIds(); + if ( realizationIds.size() != m_cases.size() ) + { + m_cases.deleteChildren(); + + for ( auto realId : realizationIds ) + { + auto realization = new RimSummaryCaseSumo(); + realization->setEnsemble( this ); + realization->setRealizationName( QString( "real-%1" ).arg( realId ) ); + realization->setRealizationNumber( realId.toInt() ); + realization->updateAutoShortName(); + + realization->setShowVectorItemsInProjectTree( m_cases.empty() ); + + // Create realization parameters, required to make derived ensemble cases work + // See RimDerivedEnsembleCaseCollection::createDerivedEnsembleCases() + auto parameters = std::shared_ptr( new RigCaseRealizationParameters() ); + + int realizationNumber = realId.toInt(); + parameters->setRealizationNumber( realizationNumber ); + parameters->addParameter( RiaDefines::summaryRealizationNumber(), realizationNumber ); + + realization->setCaseRealizationParameters( parameters ); + + m_cases.push_back( realization ); + } + } + } + + updateName(); + updateResultAddresses(); + + buildMetaData(); + + // call the base class method after data has been loaded + RimSummaryCaseCollection::onLoadDataAndUpdate(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h new file mode 100644 index 0000000000..ee81686d0a --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h @@ -0,0 +1,92 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimSummaryCaseCollection.h" + +#include "Cloud/RiaSumoConnector.h" + +#include "cafPdmPtrField.h" + +#include + +class RimSummarySumoDataSource; + +//================================================================================================== +// +// +// +//================================================================================================== + +struct ParquetKey +{ + SumoCaseId caseId; + QString ensembleId; + QString vectorName; + + auto operator<=>( const ParquetKey& other ) const + { + return std::tie( caseId, ensembleId, vectorName ) <=> std::tie( other.caseId, other.ensembleId, other.vectorName ); + } +}; + +namespace arrow +{ +class Table; +} + +class RimSummaryEnsembleSumo : public RimSummaryCaseCollection +{ + CAF_PDM_HEADER_INIT; + +public: + RimSummaryEnsembleSumo(); + + void setSumoDataSource( RimSummarySumoDataSource* sumoDataSource ); + void updateName(); + + void loadSummaryData( const RifEclipseSummaryAddress& resultAddress ); + std::string unitName( const RifEclipseSummaryAddress& resultAddress ); + RiaDefines::EclipseUnitSystem unitSystem() const; + std::set allResultAddresses() const; + +protected: + void onLoadDataAndUpdate() override; + +private: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + + void updateResultAddresses(); + void clearCachedData(); + + QByteArray loadParquetData( const ParquetKey& parquetKey ); + + void distributeDataToRealizations( const RifEclipseSummaryAddress& resultAddress, std::shared_ptr table ); + void buildMetaData(); + +private: + caf::PdmPtrField m_sumoDataSource; + + QPointer m_sumoConnector; + + std::set m_resultAddresses; + std::map> m_parquetTable; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp new file mode 100644 index 0000000000..7a5e915f02 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp @@ -0,0 +1,207 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimSummarySumoDataSource.h" + +#include "RiaStdStringTools.h" + +#include "cafCmdFeatureMenuBuilder.h" +#include "cafPdmUiTreeSelectionEditor.h" + +CAF_PDM_SOURCE_INIT( RimSummarySumoDataSource, "RimSummarySumoDataSource" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummarySumoDataSource::RimSummarySumoDataSource() +{ + CAF_PDM_InitObject( "Sumo Data Source", ":/SummaryCase.svg" ); + + CAF_PDM_InitFieldNoDefault( &m_caseId, "CaseId", "Case Id" ); + CAF_PDM_InitFieldNoDefault( &m_caseName, "CaseName", "Case Name" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleName, "EnsembleName", "Ensemble Name" ); + CAF_PDM_InitFieldNoDefault( &m_customName, "CustomName", "Custom Name" ); + + CAF_PDM_InitFieldNoDefault( &m_realizationIds, "RealizationIds", "Realizations Ids" ); + m_realizationIds.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_realizationInfo, "NameProxy", "Realization Info" ); + m_realizationInfo.registerGetMethod( this, &RimSummarySumoDataSource::realizationInfoText ); + + CAF_PDM_InitFieldNoDefault( &m_vectorNames, "VectorNames", "Vector Names" ); + m_vectorNames.uiCapability()->setUiReadOnly( true ); + + setDeletable( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +SumoCaseId RimSummarySumoDataSource::caseId() const +{ + return SumoCaseId( m_caseId() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummarySumoDataSource::setCaseId( const SumoCaseId& caseId ) +{ + m_caseId = caseId.get(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummarySumoDataSource::caseName() const +{ + return m_caseName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummarySumoDataSource::setCaseName( const QString& caseName ) +{ + m_caseName = caseName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummarySumoDataSource::ensembleName() const +{ + return m_ensembleName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummarySumoDataSource::setEnsembleName( const QString& ensembleName ) +{ + m_ensembleName = ensembleName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummarySumoDataSource::realizationIds() const +{ + return m_realizationIds(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummarySumoDataSource::setRealizationIds( const std::vector& realizationIds ) +{ + m_realizationIds = realizationIds; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummarySumoDataSource::vectorNames() const +{ + return m_vectorNames(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummarySumoDataSource::setVectorNames( const std::vector& vectorNames ) +{ + m_vectorNames = vectorNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummarySumoDataSource::updateName() +{ + if ( !m_customName().isEmpty() ) + { + setName( m_customName() ); + return; + } + + auto name = QString( "%1 (%2)" ).arg( ensembleName(), caseName() ); + + setName( name ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummarySumoDataSource::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder.addCmdFeature( "RicCreateSumoEnsembleFeature" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummarySumoDataSource::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_vectorNames ) + { + if ( auto attr = dynamic_cast( attribute ) ) + { + attr->showCheckBoxes = false; + attr->showContextMenu = false; + attr->showToggleAllCheckbox = false; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummarySumoDataSource::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + auto group = uiOrdering.addNewGroup( "General" ); + group->add( nameField() ); + group->add( &m_caseId ); + group->add( &m_caseName ); + group->add( &m_ensembleName ); + group->add( &m_customName ); + + auto summaryInfo = uiOrdering.addNewGroup( "Info" ); + summaryInfo->add( &m_realizationInfo ); + summaryInfo->add( &m_vectorNames ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummarySumoDataSource::realizationInfoText() const +{ + std::vector intValues; + for ( const auto& realizationId : realizationIds() ) + { + bool ok = false; + int value = realizationId.toInt( &ok ); + if ( ok ) + { + intValues.push_back( value ); + } + } + + auto rangeString = RiaStdStringTools::formatRangeSelection( intValues ); + return QString::fromStdString( rangeString ); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.h b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.h new file mode 100644 index 0000000000..948c7cc5ac --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.h @@ -0,0 +1,73 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimNamedObject.h" + +#include "Cloud/RiaSumoConnector.h" + +#include "cafPdmProxyValueField.h" + +//================================================================================================== +// +// +// +//================================================================================================== + +class RimSummarySumoDataSource : public RimNamedObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimSummarySumoDataSource(); + + SumoCaseId caseId() const; + void setCaseId( const SumoCaseId& caseId ); + + QString caseName() const; + void setCaseName( const QString& caseName ); + + QString ensembleName() const; + void setEnsembleName( const QString& ensembleName ); + + std::vector realizationIds() const; + void setRealizationIds( const std::vector& realizationIds ); + + std::vector vectorNames() const; + void setVectorNames( const std::vector& vectorNames ); + + void updateName(); + +private: + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + + QString realizationInfoText() const; + +private: + caf::PdmField m_caseId; + caf::PdmField m_caseName; + caf::PdmField m_ensembleName; + caf::PdmField m_customName; + + caf::PdmProxyValueField m_realizationInfo; + caf::PdmField> m_realizationIds; + + caf::PdmField> m_vectorNames; +}; From 1c2b8f41189bd47ada26b056d8c74a442a623ca3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Jul 2024 15:55:24 +0200 Subject: [PATCH 174/332] Updated icons --- ApplicationExeCode/Resources/Cloud.svg | 13 +++++++++++++ ApplicationExeCode/Resources/CloudBlobs.svg | 16 ++++++++++++++++ ApplicationExeCode/Resources/ResInsight.qrc | 2 ++ .../Cloud/RimCloudDataSourceCollection.cpp | 2 +- .../Summary/Sumo/RimSummarySumoDataSource.cpp | 2 +- 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 ApplicationExeCode/Resources/Cloud.svg create mode 100644 ApplicationExeCode/Resources/CloudBlobs.svg diff --git a/ApplicationExeCode/Resources/Cloud.svg b/ApplicationExeCode/Resources/Cloud.svg new file mode 100644 index 0000000000..985b713fb4 --- /dev/null +++ b/ApplicationExeCode/Resources/Cloud.svg @@ -0,0 +1,13 @@ + + + + + IconLightCloud + + + + + + + + diff --git a/ApplicationExeCode/Resources/CloudBlobs.svg b/ApplicationExeCode/Resources/CloudBlobs.svg new file mode 100644 index 0000000000..ee50bb1d6c --- /dev/null +++ b/ApplicationExeCode/Resources/CloudBlobs.svg @@ -0,0 +1,16 @@ + + + + + IconLightCloudBlobs + + + + + + + + + + + diff --git a/ApplicationExeCode/Resources/ResInsight.qrc b/ApplicationExeCode/Resources/ResInsight.qrc index cb62facd2e..efe7e9278b 100644 --- a/ApplicationExeCode/Resources/ResInsight.qrc +++ b/ApplicationExeCode/Resources/ResInsight.qrc @@ -288,6 +288,8 @@ padlock.svg warning.svg cloud-and-server.svg + Cloud.svg + CloudBlobs.svg fs_CellFace.glsl diff --git a/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp index e8adeaa172..8569991aa0 100644 --- a/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp @@ -35,7 +35,7 @@ CAF_PDM_SOURCE_INIT( RimCloudDataSourceCollection, "RimCloudDataSourceCollection //-------------------------------------------------------------------------------------------------- RimCloudDataSourceCollection::RimCloudDataSourceCollection() { - CAF_PDM_InitObject( "Cloud Data", ":/cloud-and-server.svg" ); + CAF_PDM_InitObject( "Cloud Data", ":/Cloud.svg" ); CAF_PDM_InitFieldNoDefault( &m_sumoFieldName, "SumoFieldId", "Field Id" ); CAF_PDM_InitFieldNoDefault( &m_sumoCaseId, "SumoCaseId", "Case Id" ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp index 7a5e915f02..3bcd310542 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp @@ -30,7 +30,7 @@ CAF_PDM_SOURCE_INIT( RimSummarySumoDataSource, "RimSummarySumoDataSource" ); //-------------------------------------------------------------------------------------------------- RimSummarySumoDataSource::RimSummarySumoDataSource() { - CAF_PDM_InitObject( "Sumo Data Source", ":/SummaryCase.svg" ); + CAF_PDM_InitObject( "Sumo Data Source", ":/CloudBlobs.svg" ); CAF_PDM_InitFieldNoDefault( &m_caseId, "CaseId", "Case Id" ); CAF_PDM_InitFieldNoDefault( &m_caseName, "CaseName", "Case Name" ); From 09565744c707cfde4bf25e0a395f9a1f40ae5226 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 8 Jul 2024 21:40:20 +0200 Subject: [PATCH 175/332] Osdu: Allow user to filter well logs before import. --- .../OsduImportCommands/CMakeLists_files.cmake | 12 +- .../OsduImportCommands/RiaOsduConnector.cpp | 33 +- .../OsduImportCommands/RiaOsduConnector.h | 1 + .../RiuWellLogImportWizard.cpp | 290 ++++++++++++++++++ .../RiuWellLogImportWizard.h | 226 ++++++++++++++ .../Commands/RicImportWellLogOsduFeature.cpp | 37 ++- 6 files changed, 580 insertions(+), 19 deletions(-) create mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp create mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h diff --git a/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake index af4c5c046d..25f302fe4c 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake @@ -5,6 +5,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.h ${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h + ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogImportWizard.h ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h ) @@ -16,6 +17,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogImportWizard.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.cpp ) @@ -24,9 +26,13 @@ list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) -list(APPEND COMMAND_QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h - ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h +list( + APPEND + COMMAND_QT_MOC_HEADERS + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h + ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h + ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogImportWizard.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h ) source_group( diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index 54bfc48027..e8aa60997b 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -621,7 +621,24 @@ void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellb QString id = resultObj["id"].toString(); QString kind = resultObj["kind"].toString(); - m_wellLogs[wellboreId].push_back( OsduWellLog{ id, kind, wellboreId } ); + QJsonArray curvesArray = resultObj["data"].toObject()["Curves"].toArray(); + QStringList curveIds; + RiaLogging::debug( QString( "Curves for '%1':" ).arg( id ) ); + for ( const QJsonValue& curve : curvesArray ) + { + QString curveId = curve["CurveID"].toString(); + QString curveDescription = curve["CurveDescription"].toString(); + double curveBaseDepth = curve["BaseDepth"].toDouble( 0.0 ); + double curveTopDepth = curve["TopDepth"].toDouble( 0.0 ); + + curveIds << curveId; + RiaLogging::debug( + QString( "%1: '%2' (%3 - %4)" ).arg( curveId ).arg( curveDescription ).arg( curveTopDepth ).arg( curveBaseDepth ) ); + } + + QString name = curveIds.join( ", " ); + + m_wellLogs[wellboreId].push_back( OsduWellLog{ id, kind, wellboreId, name } ); } } @@ -691,6 +708,20 @@ std::vector RiaOsduConnector::wells() const return m_wells; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaOsduConnector::wellLogs( const QString& wellboreId ) const +{ + QMutexLocker lock( &m_mutex ); + + auto it = m_wellLogs.find( wellboreId ); + if ( it != m_wellLogs.end() ) + return it->second; + else + return {}; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h index 32a0f44c1d..8198e24b6f 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -42,6 +42,7 @@ struct OsduWellLog QString id; QString kind; QString wellboreId; + QString name; }; //================================================================================================== diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp new file mode 100644 index 0000000000..dd95c6ba72 --- /dev/null +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp @@ -0,0 +1,290 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RiuWellLogImportWizard.h" + +#include "RiaFeatureCommandContext.h" +#include "RiaOsduConnector.h" + +#include +#include +#include + +#include +#include + +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuWellLogImportWizard::RiuWellLogImportWizard( RiaOsduConnector* osduConnector, const QString& wellboreId, QWidget* parent /*= 0*/ ) + : QWizard( parent ) +{ + m_osduConnector = osduConnector; + m_wellboreId = wellboreId; + + addPage( new WellLogAuthenticationPage( m_osduConnector, this ) ); + addPage( new WellLogSelectionPage( m_osduConnector, this ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuWellLogImportWizard::~RiuWellLogImportWizard() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuWellLogImportWizard::downloadWellLogs( const QString& wellboreId ) +{ + m_osduConnector->requestWellLogsByWellboreId( wellboreId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuWellLogImportWizard::setSelectedWellLogs( const std::vector& wellboreIds ) +{ + m_selectedWellLogs = wellboreIds; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiuWellLogImportWizard::selectedWellLogs() const +{ + return m_selectedWellLogs; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuWellLogImportWizard::wellboreId() const +{ + return m_wellboreId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiuWellLogImportWizard::importedWellLogs() const +{ + return m_wellLogInfos; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuWellLogImportWizard::addWellLogInfo( RiuWellLogImportWizard::WellLogInfo wellLogInfo ) +{ + m_wellLogInfos.push_back( wellLogInfo ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +WellLogAuthenticationPage::WellLogAuthenticationPage( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) + : QWizardPage( parent ) + , m_osduConnector( osduConnector ) + , m_accessOk( false ) +{ + setTitle( "OSDU - Login" ); + + QVBoxLayout* layout = new QVBoxLayout; + + m_connectionLabel = new QLabel( "Checking OSDU connection. You might need to login." ); + layout->addWidget( m_connectionLabel ); + + QFormLayout* formLayout = new QFormLayout; + layout->addLayout( formLayout ); + + QLineEdit* serverLineEdit = new QLineEdit( osduConnector->server(), this ); + serverLineEdit->setReadOnly( true ); + QLineEdit* partitionLineEdit = new QLineEdit( osduConnector->dataPartition(), this ); + partitionLineEdit->setReadOnly( true ); + + formLayout->addRow( "Server:", serverLineEdit ); + formLayout->addRow( "Data Partition:", partitionLineEdit ); + + setLayout( layout ); + + connect( osduConnector, SIGNAL( tokenReady( const QString& ) ), this, SLOT( accessOk() ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void WellLogAuthenticationPage::initializePage() +{ + m_osduConnector->requestToken(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool WellLogAuthenticationPage::isComplete() const +{ + return m_accessOk; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void WellLogAuthenticationPage::accessOk() +{ + m_connectionLabel->setText( "Connection to OSDU: OK." ); + m_accessOk = true; + emit( completeChanged() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +WellLogSelectionPage::WellLogSelectionPage( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) +{ + QVBoxLayout* layout = new QVBoxLayout; + setLayout( layout ); + + QLabel* label = new QLabel( "Select well logs" ); + layout->addWidget( label ); + + QHBoxLayout* filterLayout = new QHBoxLayout; + filterLayout->addWidget( new QLabel( "Filter:", this ) ); + QLineEdit* filterLineEdit = new QLineEdit( this ); + filterLayout->addWidget( filterLineEdit ); + + layout->addLayout( filterLayout ); + + m_tableView = new QTableView( this ); + m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows ); + m_tableView->setSelectionMode( QAbstractItemView::MultiSelection ); + m_tableView->setSortingEnabled( true ); + int nameColumn = 2; + m_tableView->sortByColumn( nameColumn, Qt::AscendingOrder ); + + QHeaderView* header = m_tableView->horizontalHeader(); + header->setSectionResizeMode( QHeaderView::Interactive ); + header->setStretchLastSection( true ); + + m_osduWellLogsModel = new OsduWellLogTableModel; + layout->addWidget( m_tableView ); + layout->setStretchFactor( m_tableView, 10 ); + + m_proxyModel = new QSortFilterProxyModel( this ); + m_proxyModel->setSourceModel( m_osduWellLogsModel ); + m_proxyModel->setFilterKeyColumn( nameColumn ); + m_proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive ); + + m_tableView->setModel( m_proxyModel ); + m_tableView->setSortingEnabled( true ); + + QObject::connect( filterLineEdit, &QLineEdit::textChanged, m_proxyModel, &QSortFilterProxyModel::setFilterWildcard ); + + m_osduConnector = osduConnector; + connect( m_osduConnector, SIGNAL( wellLogsFinished( const QString& ) ), SLOT( wellLogsFinished( const QString& ) ) ); + + connect( m_tableView->selectionModel(), + SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), + SLOT( selectWellLogs( const QItemSelection&, const QItemSelection& ) ) ); + + connect( m_tableView->selectionModel(), + SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), + SIGNAL( completeChanged() ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void WellLogSelectionPage::initializePage() +{ + RiuWellLogImportWizard* wiz = dynamic_cast( wizard() ); + if ( !wiz ) return; + + QString wellboreId = wiz->wellboreId(); + wiz->downloadWellLogs( wellboreId ); + + setButtonText( QWizard::NextButton, "Next" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +WellLogSelectionPage::~WellLogSelectionPage() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void WellLogSelectionPage::wellLogsFinished( const QString& wellboreId ) +{ + std::vector wellLogs = m_osduConnector->wellLogs( wellboreId ); + m_osduWellLogsModel->setOsduWellLogs( wellLogs ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool WellLogSelectionPage::isComplete() const +{ + QItemSelectionModel* select = m_tableView->selectionModel(); + return !select->selectedRows().empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void WellLogSelectionPage::selectWellLogs( const QItemSelection& newSelection, const QItemSelection& oldSelection ) +{ + if ( !newSelection.indexes().empty() ) + { + RiuWellLogImportWizard* wiz = dynamic_cast( wizard() ); + + std::vector wellLogs = m_osduConnector->wellLogs( wiz->wellboreId() ); + + auto findWellLogById = []( const std::vector& wellLogs, const QString& wellLogId ) -> std::optional + { + auto it = std::find_if( wellLogs.begin(), wellLogs.end(), [wellLogId]( const OsduWellLog& w ) { return w.id == wellLogId; } ); + if ( it != wellLogs.end() ) + return std::optional( *it ); + else + return {}; + }; + + QModelIndexList selection = m_tableView->selectionModel()->selectedRows(); + for ( QModelIndex index : selection ) + { + int idColumn = 0; + + if ( index.column() == idColumn ) + { + QString wellLogId = m_proxyModel->data( index.siblingAtColumn( idColumn ) ).toString(); + std::optional wellLog = findWellLogById( wellLogs, wellLogId ); + if ( wellLog.has_value() ) + { + wiz->addWellLogInfo( { .name = wellLog->name, .wellLog = wellLogId } ); + } + } + } + } +} diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h new file mode 100644 index 0000000000..dae2b6f5d9 --- /dev/null +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h @@ -0,0 +1,226 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 +#include +#include +#include +#include +#include +#include + +#include "RiaOsduConnector.h" + +#include + +class QFile; +class QLabel; +class QTextEdit; +class QTableView; + +class RimWellPathImport; + +class OsduWellLogTableModel : public QAbstractTableModel +{ + Q_OBJECT +public: + explicit OsduWellLogTableModel( QObject* parent = nullptr ) + : QAbstractTableModel( parent ) + { + } + + int rowCount( const QModelIndex& parent = QModelIndex() ) const override + { + Q_UNUSED( parent ); + return static_cast( m_osduWellLogs.size() ); + } + + int columnCount( const QModelIndex& parent = QModelIndex() ) const override + { + Q_UNUSED( parent ); + // Assuming you have three fields: id, kind, and name + return 3; + } + + QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override + { + if ( !index.isValid() ) return QVariant(); + + if ( index.row() >= static_cast( m_osduWellLogs.size() ) || index.row() < 0 ) return QVariant(); + + if ( role == Qt::DisplayRole ) + { + const OsduWellLog& field = m_osduWellLogs.at( index.row() ); + switch ( index.column() ) + { + case 0: + return field.id; + case 1: + return field.kind; + case 2: + return field.name; + default: + return QVariant(); + } + } + + return QVariant(); + } + + QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override + { + if ( role != Qt::DisplayRole ) return QVariant(); + + if ( orientation == Qt::Horizontal ) + { + switch ( section ) + { + case 0: + return tr( "ID" ); + case 1: + return tr( "Kind" ); + case 2: + return tr( "Name" ); + default: + return QVariant(); + } + } + return QVariant(); + } + + void setOsduWellLogs( const std::vector& osduWellLogs ) + { + beginResetModel(); + m_osduWellLogs.clear(); + for ( auto v : osduWellLogs ) + m_osduWellLogs.push_back( v ); + + endResetModel(); + } + + void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override + { + std::sort( m_osduWellLogs.begin(), + m_osduWellLogs.end(), + [column, order]( const OsduWellLog& a, const OsduWellLog& b ) + { + switch ( column ) + { + case 0: + return ( order == Qt::AscendingOrder ) ? a.id < b.id : a.id > b.id; + case 1: + return ( order == Qt::AscendingOrder ) ? a.kind < b.kind : a.kind > b.kind; + case 2: + return ( order == Qt::AscendingOrder ) ? a.name < b.name : a.name > b.name; + default: + return false; + } + } ); + emit dataChanged( index( 0, 0 ), index( rowCount() - 1, columnCount() - 1 ) ); + emit layoutChanged(); + } + +private: + std::vector m_osduWellLogs; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class WellLogAuthenticationPage : public QWizardPage +{ + Q_OBJECT + +public: + WellLogAuthenticationPage( RiaOsduConnector* osduConnector, QWidget* parent = nullptr ); + + void initializePage() override; + bool isComplete() const override; + +private slots: + void accessOk(); + +private: + RiaOsduConnector* m_osduConnector; + QLabel* m_connectionLabel; + bool m_accessOk; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class WellLogSelectionPage : public QWizardPage +{ + Q_OBJECT + +public: + WellLogSelectionPage( RiaOsduConnector* m_osduConnector, QWidget* parent = nullptr ); + ~WellLogSelectionPage() override; + + void initializePage() override; + bool isComplete() const override; + +private slots: + void wellLogsFinished( const QString& wellboreId ); + void selectWellLogs( const QItemSelection& newSelection, const QItemSelection& oldSelection ); + +private: + RiaOsduConnector* m_osduConnector; + + QTableView* m_tableView; + OsduWellLogTableModel* m_osduWellLogsModel; + QSortFilterProxyModel* m_proxyModel; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RiuWellLogImportWizard : public QWizard +{ + Q_OBJECT + +public: + struct WellLogInfo + { + QString name; + QString wellLog; + }; + + RiuWellLogImportWizard( RiaOsduConnector* osduConnector, const QString& wellboreId, QWidget* parent = nullptr ); + ~RiuWellLogImportWizard() override; + + void setSelectedWellLogs( const std::vector& wellLogIds ); + std::vector selectedWellLogs() const; + + void addWellLogInfo( RiuWellLogImportWizard::WellLogInfo wellLogInfo ); + std::vector importedWellLogs() const; + + QString wellboreId() const; + +public slots: + void downloadWellLogs( const QString& wellboreId ); + +private: + RiaOsduConnector* m_osduConnector; + std::vector m_selectedWellLogs; + + QString m_wellboreId; + std::vector m_wellLogInfos; +}; diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp index 9f34260a49..b1df7f3785 100644 --- a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp @@ -30,6 +30,7 @@ #include "RiuMainWindow.h" #include "OsduImportCommands/RiaOsduConnector.h" +#include "OsduImportCommands/RiuWellLogImportWizard.h" #include "RiaLogging.h" #include "RiaPreferences.h" @@ -61,25 +62,31 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked ) if ( !oilField->wellPathCollection ) oilField->wellPathCollection = std::make_unique(); - auto osduConnector = app->makeOsduConnector(); - std::vector wellLogs = osduConnector->requestWellLogsByWellboreIdBlocking( wellPath->wellboreId() ); + auto osduConnector = app->makeOsduConnector(); - for ( OsduWellLog wellLog : wellLogs ) + RiuWellLogImportWizard wellLogImportWizard( osduConnector, wellPath->wellboreId(), RiuMainWindow::instance() ); + + if ( QDialog::Accepted == wellLogImportWizard.exec() ) { - auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector, wellLog.id ); - if ( wellLogData.notNull() ) - { - RimOsduWellLog* osduWellLog = new RimOsduWellLog; - osduWellLog->setName( wellLog.id ); - osduWellLog->setWellLogId( wellLog.id ); - oilField->wellPathCollection->addWellLog( osduWellLog, wellPath ); + std::vector wellLogs = wellLogImportWizard.importedWellLogs(); - osduWellLog->setWellLogData( wellLogData.p() ); - osduWellLog->updateConnectedEditors(); - } - else + for ( RiuWellLogImportWizard::WellLogInfo wellLog : wellLogs ) { - RiaLogging::error( "Importing OSDU well log failed: " + errorMessage ); + auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector, wellLog.wellLog ); + if ( wellLogData.notNull() ) + { + RimOsduWellLog* osduWellLog = new RimOsduWellLog; + osduWellLog->setName( wellLog.name ); + osduWellLog->setWellLogId( wellLog.wellLog ); + oilField->wellPathCollection->addWellLog( osduWellLog, wellPath ); + + osduWellLog->setWellLogData( wellLogData.p() ); + osduWellLog->updateConnectedEditors(); + } + else + { + RiaLogging::error( "Importing OSDU well log failed: " + errorMessage ); + } } } } From c780c948eafdad9b9f13d3964225f366323de369 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 8 Jul 2024 09:02:52 +0200 Subject: [PATCH 176/332] Fix unsigned comparisons --- ApplicationLibCode/UnitTests/RigVfpTables-Test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/UnitTests/RigVfpTables-Test.cpp b/ApplicationLibCode/UnitTests/RigVfpTables-Test.cpp index 778c32f3ef..c1d93807e4 100644 --- a/ApplicationLibCode/UnitTests/RigVfpTables-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigVfpTables-Test.cpp @@ -28,7 +28,7 @@ TEST( RigVfpTables, MatchingValues ) std::vector sourceValues = { 1.0, 2.0, 3.0, 4.0, 5.0 }; std::vector valuesForMatch = { 1.0, 2.0, 3.0, 4.0, 5.0 }; std::vector closestIndices = RigVfpTables::uniqueClosestIndices( sourceValues, valuesForMatch ); - for ( int i = 0; i < sourceValues.size(); i++ ) + for ( size_t i = 0; i < sourceValues.size(); i++ ) { EXPECT_EQ( i, closestIndices[i] ); } @@ -42,7 +42,7 @@ TEST( RigVfpTables, MoreDestinationValues ) std::vector sourceValues = { 1.0, 2.0, 3.0, 4.0, 5.0 }; std::vector valuesForMatch = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; std::vector closestIndices = RigVfpTables::uniqueClosestIndices( sourceValues, valuesForMatch ); - for ( int i = 0; i < sourceValues.size(); i++ ) + for ( size_t i = 0; i < sourceValues.size(); i++ ) { EXPECT_EQ( i, closestIndices[i] ); } From 80f7623151a0d5b1a5f802b60c7d5238156c1077 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 8 Jul 2024 22:10:00 +0200 Subject: [PATCH 177/332] Bump to dev.08 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 3e926095fe..946f6f6c59 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".07") +set(RESINSIGHT_DEV_VERSION ".08") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 56e139b9d69d1c8c1b6efdea0081df7e9e79e0fb Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Jul 2024 16:22:15 +0200 Subject: [PATCH 178/332] #11556 StimPlan Model: export deviation with less precision. Fixes #11556. --- .../RifStimPlanModelDeviationFrkExporter.cpp | 24 ++++++++++++++++++- .../RifStimPlanModelDeviationFrkExporter.h | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/FileInterface/RifStimPlanModelDeviationFrkExporter.cpp b/ApplicationLibCode/FileInterface/RifStimPlanModelDeviationFrkExporter.cpp index 7ed227a5c5..826b162cd4 100644 --- a/ApplicationLibCode/FileInterface/RifStimPlanModelDeviationFrkExporter.cpp +++ b/ApplicationLibCode/FileInterface/RifStimPlanModelDeviationFrkExporter.cpp @@ -58,6 +58,11 @@ bool RifStimPlanModelDeviationFrkExporter::writeToFile( RimStimPlanModel* stimPl convertFromMeterToFeet( mdValues ); convertFromMeterToFeet( tvdValues ); + // Round to less precision. StimPlan does not handle high precision. + int numSignificantDigits = 2; + roundToPrecision( mdValues, numSignificantDigits ); + roundToPrecision( tvdValues, numSignificantDigits ); + std::vector exportTvdValues; std::vector exportMdValues; fixupDepthValuesForExport( tvdValues, mdValues, exportTvdValues, exportMdValues ); @@ -83,7 +88,7 @@ void RifStimPlanModelDeviationFrkExporter::appendHeaderToStream( QTextStream& st //-------------------------------------------------------------------------------------------------- void RifStimPlanModelDeviationFrkExporter::appendToStream( QTextStream& stream, const QString& label, const std::vector& values ) { - stream.setRealNumberPrecision( 20 ); + stream.setRealNumberPrecision( 8 ); stream << "" << '\n' << "" << '\n' << label << '\n' @@ -122,6 +127,23 @@ void RifStimPlanModelDeviationFrkExporter::convertFromMeterToFeet( std::vector& data, int numSignificantDigits ) +{ + auto roundUp = []( double value, int decimalPlaces ) -> double + { + const double multiplier = std::pow( 10.0, decimalPlaces ); + return std::ceil( value * multiplier ) / multiplier; + }; + + for ( size_t i = 0; i < data.size(); i++ ) + { + data[i] = roundUp( data[i], numSignificantDigits ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifStimPlanModelDeviationFrkExporter.h b/ApplicationLibCode/FileInterface/RifStimPlanModelDeviationFrkExporter.h index b673b51d0a..05edbc04e5 100644 --- a/ApplicationLibCode/FileInterface/RifStimPlanModelDeviationFrkExporter.h +++ b/ApplicationLibCode/FileInterface/RifStimPlanModelDeviationFrkExporter.h @@ -42,4 +42,5 @@ class RifStimPlanModelDeviationFrkExporter static void appendToStream( QTextStream& stream, const QString& label, const std::vector& values ); static void appendFooterToStream( QTextStream& stream ); static void convertFromMeterToFeet( std::vector& data ); + static void roundToPrecision( std::vector& data, int numSignificantDigits ); }; From 122b724a836deb6849a83a0b4d13383d79d7510a Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Jul 2024 10:27:46 +0200 Subject: [PATCH 179/332] Osdu: Split blocking and non-blocking api, and fix race condition on parquet data. --- .../OsduImportCommands/RiaOsduConnector.cpp | 75 ++++++++++++++----- .../OsduImportCommands/RiaOsduConnector.h | 20 +++-- .../WellPath/RimWellPathCollection.cpp | 4 +- 3 files changed, 70 insertions(+), 29 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index e8aa60997b..efec2e0a02 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -21,6 +21,8 @@ #include +#include "cafAssert.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -87,6 +89,11 @@ RiaOsduConnector::RiaOsduConnector( QObject* parent, SIGNAL( authorizationCallbackReceived( const QVariantMap& ) ), this, SLOT( authorizationCallbackReceived( const QVariantMap& ) ) ); + + connect( this, + SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ), + this, + SLOT( parquetDownloadComplete( const QByteArray&, const QString&, const QString& ) ) ); } //-------------------------------------------------------------------------------------------------- @@ -155,6 +162,7 @@ void RiaOsduConnector::clearCachedData() m_wellboreTrajectories.clear(); m_wellLogs.clear(); m_parquetData.clear(); + m_parquetErrors.clear(); } //-------------------------------------------------------------------------------------------------- @@ -779,66 +787,92 @@ std::vector RiaOsduConnector::wellboreTrajectories( cons //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair RiaOsduConnector::requestWellboreTrajectoryParquetDataById( const QString& wellboreTrajectoryId ) +void RiaOsduConnector::requestWellboreTrajectoryParquetDataById( const QString& wellboreTrajectoryId ) +{ + QString url = constructWellboreTrajectoriesDownloadUrl( m_server, wellboreTrajectoryId ); + RiaLogging::debug( "Wellbore trajectory URL: " + url ); + requestParquetDataByUrl( url, wellboreTrajectoryId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestWellLogParquetDataById( const QString& wellLogId ) +{ + QString url = constructWellLogDownloadUrl( m_server, wellLogId ); + RiaLogging::debug( "Well log URL: " + url ); + requestParquetDataByUrl( url, wellLogId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::requestParquetDataByUrl( const QString& url, const QString& id ) +{ + QString token = m_token; + requestParquetData( url, m_dataPartitionId, token, id ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiaOsduConnector::requestWellboreTrajectoryParquetDataByIdBlocking( const QString& wellboreTrajectoryId ) { QString url = constructWellboreTrajectoriesDownloadUrl( m_server, wellboreTrajectoryId ); RiaLogging::debug( "Wellbore trajectory URL: " + url ); - return requestParquetDataByUrl( url ); + return requestParquetDataByUrlBlocking( url, wellboreTrajectoryId ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair RiaOsduConnector::requestWellLogParquetDataById( const QString& wellLogId ) +std::pair RiaOsduConnector::requestWellLogParquetDataByIdBlocking( const QString& wellLogId ) { QString url = constructWellLogDownloadUrl( m_server, wellLogId ); RiaLogging::debug( "Well log URL: " + url ); - return requestParquetDataByUrl( url ); + return requestParquetDataByUrlBlocking( url, wellLogId ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair RiaOsduConnector::requestParquetDataByUrl( const QString& url ) +std::pair RiaOsduConnector::requestParquetDataByUrlBlocking( const QString& url, const QString& id ) { QString token = requestTokenBlocking(); QEventLoop loop; - connect( this, - SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ), - this, - SLOT( parquetDownloadComplete( const QByteArray&, const QString& ) ) ); - connect( this, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ), &loop, SLOT( quit() ) ); - - requestParquetData( url, m_dataPartitionId, token ); + connect( this, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ), &loop, SLOT( quit() ) ); + requestParquetData( url, m_dataPartitionId, token, id ); loop.exec(); - return { m_parquetData, "" }; + QMutexLocker lock( &m_mutex ); + return { m_parquetData[id], m_parquetErrors[id] }; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token ) +void RiaOsduConnector::requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token, const QString& id ) { RiaLogging::info( "Requesting download of parquet from: " + url ); auto reply = makeDownloadRequest( url, dataPartitionId, token, RiaDefines::contentTypeParquet() ); + connect( reply, &QNetworkReply::finished, - [this, reply, url]() + [this, reply, url, id]() { if ( reply->error() == QNetworkReply::NoError ) { QByteArray contents = reply->readAll(); RiaLogging::info( QString( "Download succeeded: %1 bytes." ).arg( contents.length() ) ); - emit parquetDownloadFinished( contents, "" ); + emit parquetDownloadFinished( contents, "", id ); } else { QString errorMessage = "Request failed: " + url + " failed." + reply->errorString(); RiaLogging::error( errorMessage ); - emit parquetDownloadFinished( QByteArray(), errorMessage ); + emit parquetDownloadFinished( QByteArray(), errorMessage, id ); } } ); } @@ -846,9 +880,12 @@ void RiaOsduConnector::requestParquetData( const QString& url, const QString& da //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::parquetDownloadComplete( const QByteArray& contents, const QString& url ) +void RiaOsduConnector::parquetDownloadComplete( const QByteArray& contents, const QString& errorMessage, const QString& id ) { - m_parquetData = contents; + CAF_ASSERT( !id.isEmpty() ); + QMutexLocker lock( &m_mutex ); + m_parquetData[id] = contents; + m_parquetErrors[id] = errorMessage; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h index 8198e24b6f..ce63f6d5fc 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -67,8 +67,11 @@ class RiaOsduConnector : public QObject void requestWellLogsByWellboreId( const QString& wellboreId ); std::vector requestWellLogsByWellboreIdBlocking( const QString& wellboreId ); - std::pair requestWellLogParquetDataById( const QString& wellLogId ); - std::pair requestWellboreTrajectoryParquetDataById( const QString& wellboreTrajectoryId ); + void requestWellLogParquetDataById( const QString& wellLogId ); + void requestWellboreTrajectoryParquetDataById( const QString& wellboreTrajectoryId ); + + std::pair requestWellLogParquetDataByIdBlocking( const QString& wellLogId ); + std::pair requestWellboreTrajectoryParquetDataByIdBlocking( const QString& wellboreTrajectoryId ); QString wellIdForWellboreId( const QString& wellboreId ) const; @@ -92,10 +95,10 @@ public slots: void parseWellLogs( QNetworkReply* reply, const QString& wellboreId ); void accessGranted(); - void parquetDownloadComplete( const QByteArray&, const QString& url ); + void parquetDownloadComplete( const QByteArray&, const QString& url, const QString& id ); signals: - void parquetDownloadFinished( const QByteArray& contents, const QString& url ); + void parquetDownloadFinished( const QByteArray& contents, const QString& url, const QString& id ); void fieldsFinished(); void wellsFinished(); void wellboresFinished( const QString& wellId ); @@ -106,10 +109,9 @@ public slots: private slots: void errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri ); void authorizationCallbackReceived( const QVariantMap& data ); + void requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token, const QString& id ); private: - void requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token ); - void addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& dataPartitionId, const QString& contentType ); QNetworkReply* makeSearchRequest( const std::map& parameters, @@ -136,7 +138,8 @@ private slots: static QString constructWellLogDownloadUrl( const QString& server, const QString& wellLogId ); static QString constructWellboreTrajectoriesDownloadUrl( const QString& server, const QString& wellboreTrajectoryId ); - std::pair requestParquetDataByUrl( const QString& url ); + std::pair requestParquetDataByUrlBlocking( const QString& url, const QString& id ); + void requestParquetDataByUrl( const QString& url, const QString& id ); QString requestTokenBlocking(); @@ -156,5 +159,6 @@ private slots: std::map> m_wellbores; std::map> m_wellboreTrajectories; std::map> m_wellLogs; - QByteArray m_parquetData; + std::map m_parquetData; + std::map m_parquetErrors; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 9d52f24cda..5572980258 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -1056,7 +1056,7 @@ std::pair, QString> RimWellPathCollection::loadWellPathGeo const QString& wellboreTrajectoryId, double datumElevation ) { - auto [fileContents, errorMessage] = osduConnector->requestWellboreTrajectoryParquetDataById( wellboreTrajectoryId ); + auto [fileContents, errorMessage] = osduConnector->requestWellboreTrajectoryParquetDataByIdBlocking( wellboreTrajectoryId ); if ( !errorMessage.isEmpty() ) { return { nullptr, errorMessage }; @@ -1071,7 +1071,7 @@ std::pair, QString> RimWellPathCollection::loadWellPathGeo std::pair, QString> RimWellPathCollection::loadWellLogFromOsdu( RiaOsduConnector* osduConnector, const QString& wellLogId ) { - auto [fileContents, errorMessage] = osduConnector->requestWellLogParquetDataById( wellLogId ); + auto [fileContents, errorMessage] = osduConnector->requestWellLogParquetDataByIdBlocking( wellLogId ); if ( !errorMessage.isEmpty() ) { return { nullptr, errorMessage }; From 0d845938b66f85b96c0a51512d43dea5f8f7798a Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Jul 2024 13:15:49 +0200 Subject: [PATCH 180/332] Osdu Well Log: show more values in filter. --- .../OsduImportCommands/RiaOsduConnector.cpp | 47 +++++++++++++----- .../OsduImportCommands/RiaOsduConnector.h | 24 +++++++-- .../RiuWellLogImportWizard.cpp | 49 +++++++++++++++++-- .../RiuWellLogImportWizard.h | 44 ++++++++++++----- .../Commands/RicImportWellLogOsduFeature.cpp | 8 +-- .../WellLog/RimOsduWellLog.cpp | 8 +-- 6 files changed, 137 insertions(+), 43 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp index efec2e0a02..7428ff3d25 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp @@ -629,24 +629,49 @@ void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellb QString id = resultObj["id"].toString(); QString kind = resultObj["kind"].toString(); - QJsonArray curvesArray = resultObj["data"].toObject()["Curves"].toArray(); - QStringList curveIds; + QJsonObject dataObj = resultObj["data"].toObject(); + QString name = dataObj["Name"].toString(); + QString description = dataObj["Description"].toString(); + double samplingStart = dataObj["SamplingStart"].toDouble( std::numeric_limits::infinity() ); + double samplingStop = dataObj["SamplingStop"].toDouble( std::numeric_limits::infinity() ); + + QJsonArray curvesArray = dataObj["Curves"].toArray(); + QStringList curveMnemonics; RiaLogging::debug( QString( "Curves for '%1':" ).arg( id ) ); + + std::vector channels; for ( const QJsonValue& curve : curvesArray ) { - QString curveId = curve["CurveID"].toString(); + QString mnemonic = curve["Mnemonic"].toString(); QString curveDescription = curve["CurveDescription"].toString(); - double curveBaseDepth = curve["BaseDepth"].toDouble( 0.0 ); - double curveTopDepth = curve["TopDepth"].toDouble( 0.0 ); - - curveIds << curveId; + double curveBaseDepth = curve["BaseDepth"].toDouble( std::numeric_limits::infinity() ); + double curveTopDepth = curve["TopDepth"].toDouble( std::numeric_limits::infinity() ); + QString interpreterName = curve["InterpreterName"].toString(); + QString quality = curve["CurveQuality"].toString(); + QString unit = curve["CurveUnit"].toString(); + QString depthUnit = curve["DepthUnit"].toString(); + + curveMnemonics << mnemonic; RiaLogging::debug( - QString( "%1: '%2' (%3 - %4)" ).arg( curveId ).arg( curveDescription ).arg( curveTopDepth ).arg( curveBaseDepth ) ); + QString( "%1: '%2' (%3 - %4)" ).arg( mnemonic ).arg( curveDescription ).arg( curveTopDepth ).arg( curveBaseDepth ) ); + channels.push_back( OsduWellLogChannel{ .mnemonic = mnemonic, + .description = curveDescription, + .topDepth = curveTopDepth, + .baseDepth = curveBaseDepth, + .interpreterName = interpreterName, + .quality = quality, + .unit = unit, + .depthUnit = depthUnit } ); } - QString name = curveIds.join( ", " ); - - m_wellLogs[wellboreId].push_back( OsduWellLog{ id, kind, wellboreId, name } ); + m_wellLogs[wellboreId].push_back( OsduWellLog{ .id = id, + .kind = kind, + .name = name, + .description = description, + .samplingStart = samplingStart, + .samplingStop = samplingStop, + .wellboreId = wellboreId, + .channels = channels } ); } } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h index ce63f6d5fc..8f24803978 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h @@ -37,12 +37,28 @@ struct OsduWellboreTrajectory QString wellboreId; }; +struct OsduWellLogChannel +{ + QString mnemonic; + QString description; + double topDepth; + double baseDepth; + QString interpreterName; + QString quality; + QString unit; + QString depthUnit; +}; + struct OsduWellLog { - QString id; - QString kind; - QString wellboreId; - QString name; + QString id; + QString kind; + QString name; + QString description; + double samplingStart; + double samplingStop; + QString wellboreId; + std::vector channels; }; //================================================================================================== diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp index dd95c6ba72..36c982c220 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -43,6 +44,8 @@ RiuWellLogImportWizard::RiuWellLogImportWizard( RiaOsduConnector* osduConnector, addPage( new WellLogAuthenticationPage( m_osduConnector, this ) ); addPage( new WellLogSelectionPage( m_osduConnector, this ) ); + + setMinimumSize( 800, 800 ); } //-------------------------------------------------------------------------------------------------- @@ -87,17 +90,17 @@ QString RiuWellLogImportWizard::wellboreId() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiuWellLogImportWizard::importedWellLogs() const +std::vector RiuWellLogImportWizard::importedWellLogs() const { - return m_wellLogInfos; + return m_wellLogs; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellLogImportWizard::addWellLogInfo( RiuWellLogImportWizard::WellLogInfo wellLogInfo ) +void RiuWellLogImportWizard::addWellLog( OsduWellLog wellLog ) { - m_wellLogInfos.push_back( wellLogInfo ); + m_wellLogs.push_back( wellLog ); } //-------------------------------------------------------------------------------------------------- @@ -198,6 +201,10 @@ WellLogSelectionPage::WellLogSelectionPage( RiaOsduConnector* osduConnector, QWi m_tableView->setModel( m_proxyModel ); m_tableView->setSortingEnabled( true ); + m_detailText = new QTextEdit( this ); + m_detailText->setReadOnly( true ); + layout->addWidget( m_detailText ); + QObject::connect( filterLineEdit, &QLineEdit::textChanged, m_proxyModel, &QSortFilterProxyModel::setFilterWildcard ); m_osduConnector = osduConnector; @@ -271,6 +278,37 @@ void WellLogSelectionPage::selectWellLogs( const QItemSelection& newSelection, c return {}; }; + auto generateWellLogDetailsText = []( const OsduWellLog& wellLog ) -> QString + { + QString text = QString( "Name: %1\n" ).arg( wellLog.name ); + if ( !wellLog.description.isEmpty() ) + { + text.append( QString( "Description: %2\n" ).arg( wellLog.description ) ); + } + + for ( auto channel : wellLog.channels ) + { + QString channelText = QString( " %1: \"%2\". Depth: %3 - %4." ) + .arg( channel.mnemonic ) + .arg( channel.description ) + .arg( channel.topDepth ) + .arg( channel.baseDepth ); + if ( !channel.interpreterName.isEmpty() ) + { + channelText.append( QString( " Interpreter: %1." ).arg( channel.interpreterName ) ); + } + + if ( !channel.quality.isEmpty() ) + { + channelText.append( QString( " Quality: %1." ).arg( channel.quality ) ); + } + + text.append( channelText + "\n" ); + } + + return text; + }; + QModelIndexList selection = m_tableView->selectionModel()->selectedRows(); for ( QModelIndex index : selection ) { @@ -282,7 +320,8 @@ void WellLogSelectionPage::selectWellLogs( const QItemSelection& newSelection, c std::optional wellLog = findWellLogById( wellLogs, wellLogId ); if ( wellLog.has_value() ) { - wiz->addWellLogInfo( { .name = wellLog->name, .wellLog = wellLogId } ); + wiz->addWellLog( wellLog.value() ); + m_detailText->setText( generateWellLogDetailsText( wellLog.value() ) ); } } } diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h index dae2b6f5d9..9fece3328d 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h @@ -55,8 +55,7 @@ class OsduWellLogTableModel : public QAbstractTableModel int columnCount( const QModelIndex& parent = QModelIndex() ) const override { Q_UNUSED( parent ); - // Assuming you have three fields: id, kind, and name - return 3; + return 7; } QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override @@ -65,6 +64,16 @@ class OsduWellLogTableModel : public QAbstractTableModel if ( index.row() >= static_cast( m_osduWellLogs.size() ) || index.row() < 0 ) return QVariant(); + auto createChannelsText = []( const OsduWellLog& wellLog ) -> QString + { + QStringList channels; + for ( auto c : wellLog.channels ) + { + channels.push_back( c.mnemonic ); + } + return channels.join( ", " ); + }; + if ( role == Qt::DisplayRole ) { const OsduWellLog& field = m_osduWellLogs.at( index.row() ); @@ -76,6 +85,14 @@ class OsduWellLogTableModel : public QAbstractTableModel return field.kind; case 2: return field.name; + case 3: + return createChannelsText( field ); + case 4: + return field.description; + case 5: + return field.samplingStart; + case 6: + return field.samplingStop; default: return QVariant(); } @@ -98,6 +115,14 @@ class OsduWellLogTableModel : public QAbstractTableModel return tr( "Kind" ); case 2: return tr( "Name" ); + case 3: + return tr( "Channels" ); + case 4: + return tr( "Description" ); + case 5: + return tr( "Sampling Start" ); + case 6: + return tr( "Sampling Stop" ); default: return QVariant(); } @@ -187,6 +212,7 @@ private slots: QTableView* m_tableView; OsduWellLogTableModel* m_osduWellLogsModel; QSortFilterProxyModel* m_proxyModel; + QTextEdit* m_detailText; }; //-------------------------------------------------------------------------------------------------- @@ -197,20 +223,14 @@ class RiuWellLogImportWizard : public QWizard Q_OBJECT public: - struct WellLogInfo - { - QString name; - QString wellLog; - }; - RiuWellLogImportWizard( RiaOsduConnector* osduConnector, const QString& wellboreId, QWidget* parent = nullptr ); ~RiuWellLogImportWizard() override; void setSelectedWellLogs( const std::vector& wellLogIds ); std::vector selectedWellLogs() const; - void addWellLogInfo( RiuWellLogImportWizard::WellLogInfo wellLogInfo ); - std::vector importedWellLogs() const; + void addWellLog( OsduWellLog wellLogInfo ); + std::vector importedWellLogs() const; QString wellboreId() const; @@ -221,6 +241,6 @@ public slots: RiaOsduConnector* m_osduConnector; std::vector m_selectedWellLogs; - QString m_wellboreId; - std::vector m_wellLogInfos; + QString m_wellboreId; + std::vector m_wellLogs; }; diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp index b1df7f3785..bd40f59e73 100644 --- a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp @@ -68,16 +68,16 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked ) if ( QDialog::Accepted == wellLogImportWizard.exec() ) { - std::vector wellLogs = wellLogImportWizard.importedWellLogs(); + std::vector wellLogs = wellLogImportWizard.importedWellLogs(); - for ( RiuWellLogImportWizard::WellLogInfo wellLog : wellLogs ) + for ( OsduWellLog wellLog : wellLogs ) { - auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector, wellLog.wellLog ); + auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector, wellLog.id ); if ( wellLogData.notNull() ) { RimOsduWellLog* osduWellLog = new RimOsduWellLog; osduWellLog->setName( wellLog.name ); - osduWellLog->setWellLogId( wellLog.wellLog ); + osduWellLog->setWellLogId( wellLog.id ); oilField->wellPathCollection->addWellLog( osduWellLog, wellPath ); osduWellLog->setWellLogData( wellLogData.p() ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp index feb3b5f44d..1941fd5d13 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp @@ -18,20 +18,14 @@ #include "RimOsduWellLog.h" -#include "RiaDateStringParser.h" #include "RiaFieldHandleTools.h" -#include "RiaGuiApplication.h" -#include "RiaLogging.h" -#include "RiaQDateTimeTools.h" -#include "RimFileWellPath.h" #include "RimTools.h" #include "RimWellLogChannel.h" +#include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPlotTools.h" -#include "Riu3DMainWindowTools.h" - #include CAF_PDM_SOURCE_INIT( RimOsduWellLog, "OsduWellLog" ); From ed7a3e98da85e5ee4085ffe1335885f08a7a6fed Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Jul 2024 15:09:05 +0200 Subject: [PATCH 181/332] Osdu Well Log: cache channel meta data from Osdu. --- .../RiuWellLogImportWizard.cpp | 5 +- .../Commands/RicImportWellLogOsduFeature.cpp | 16 +++ .../WellLog/CMakeLists_files.cmake | 3 +- .../WellLog/RimOsduWellLog.cpp | 19 ++- .../ProjectDataModel/WellLog/RimOsduWellLog.h | 4 +- .../WellLog/RimOsduWellLogChannel.cpp | 108 ++++++++++++++++++ .../WellLog/RimOsduWellLogChannel.h | 50 ++++++++ 7 files changed, 192 insertions(+), 13 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.h diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp index 36c982c220..0de3c68422 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp @@ -187,7 +187,6 @@ WellLogSelectionPage::WellLogSelectionPage( RiaOsduConnector* osduConnector, QWi QHeaderView* header = m_tableView->horizontalHeader(); header->setSectionResizeMode( QHeaderView::Interactive ); - header->setStretchLastSection( true ); m_osduWellLogsModel = new OsduWellLogTableModel; layout->addWidget( m_tableView ); @@ -201,6 +200,10 @@ WellLogSelectionPage::WellLogSelectionPage( RiaOsduConnector* osduConnector, QWi m_tableView->setModel( m_proxyModel ); m_tableView->setSortingEnabled( true ); + // Hide the ID and kind columns + m_tableView->hideColumn( 0 ); + m_tableView->hideColumn( 1 ); + m_detailText = new QTextEdit( this ); m_detailText->setReadOnly( true ); layout->addWidget( m_detailText ); diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp index bd40f59e73..7d7e891d7e 100644 --- a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp @@ -23,6 +23,7 @@ #include "RimOilField.h" #include "RimOsduWellLog.h" +#include "RimOsduWellLogChannel.h" #include "RimOsduWellPath.h" #include "RimProject.h" #include "RimWellPathCollection.h" @@ -78,6 +79,21 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked ) RimOsduWellLog* osduWellLog = new RimOsduWellLog; osduWellLog->setName( wellLog.name ); osduWellLog->setWellLogId( wellLog.id ); + for ( OsduWellLogChannel c : wellLog.channels ) + { + RimOsduWellLogChannel* osduWellLogChannel = new RimOsduWellLogChannel; + osduWellLogChannel->setName( c.mnemonic ); + osduWellLogChannel->setDescription( c.description ); + osduWellLogChannel->setTopDepth( c.topDepth ); + osduWellLogChannel->setBaseDepth( c.baseDepth ); + osduWellLogChannel->setInterpreterName( c.interpreterName ); + osduWellLogChannel->setQuality( c.quality ); + osduWellLogChannel->setUnit( c.unit ); + osduWellLogChannel->setDepthUnit( c.depthUnit ); + + osduWellLog->addWellLogChannel( osduWellLogChannel ); + } + oilField->wellPathCollection->addWellLog( osduWellLog, wellPath ); osduWellLog->setWellLogData( wellLogData.p() ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake index e0fa17dc2d..26f3ed0801 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake @@ -23,7 +23,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellLog.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileUtil.h - ${CMAKE_CURRENT_LIST_DIR}/RimWellLogChannel.h + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogChannel.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogLasFileCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogRftCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogWbsCurve.h @@ -46,6 +46,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileUtil.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogChannel.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogChannel.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogLasFileCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogRftCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogWbsCurve.cpp diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp index 1941fd5d13..05f311c243 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp @@ -20,8 +20,8 @@ #include "RiaFieldHandleTools.h" +#include "RimOsduWellLogChannel.h" #include "RimTools.h" -#include "RimWellLogChannel.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPlotTools.h" @@ -146,15 +146,6 @@ RigOsduWellLogData* RimOsduWellLog::wellLogData() void RimOsduWellLog::setWellLogData( RigOsduWellLogData* wellLogData ) { m_wellLogData = wellLogData; - - m_wellLogChannels.deleteChildren(); - - for ( const QString& wellLogName : wellLogData->wellLogChannelNames() ) - { - RimWellLogChannel* wellLog = new RimWellLogChannel(); - wellLog->setName( wellLogName ); - m_wellLogChannels.push_back( wellLog ); - } } //-------------------------------------------------------------------------------------------------- @@ -172,3 +163,11 @@ QString RimOsduWellLog::wellLogId() const { return m_wellLogId; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLog::addWellLogChannel( RimOsduWellLogChannel* channel ) +{ + m_wellLogChannels.push_back( channel ); +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h index 1051acf40a..789927232e 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h @@ -29,7 +29,7 @@ #include -class RimWellLogChannel; +class RimOsduWellLogChannel; class RimWellPath; class QString; @@ -54,6 +54,8 @@ class RimOsduWellLog : public RimWellLog RigOsduWellLogData* wellLogData() override; void setWellLogData( RigOsduWellLogData* wellLogData ); + void addWellLogChannel( RimOsduWellLogChannel* channel ); + void setWellLogId( const QString& wellLogId ); QString wellLogId() const; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp new file mode 100644 index 0000000000..57547819b9 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp @@ -0,0 +1,108 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimOsduWellLogChannel.h" + +#include "RiaFieldHandleTools.h" + +CAF_PDM_SOURCE_INIT( RimOsduWellLogChannel, "OsduWellLogChannel" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimOsduWellLogChannel::RimOsduWellLogChannel() +{ + CAF_PDM_InitObject( "OSDU Well Log Channel" ); + + CAF_PDM_InitFieldNoDefault( &m_description, "Description", "Description" ); + m_description.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_topDepth, "TopDepth", "Top Depth" ); + m_topDepth.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_baseDepth, "BaseDepth", "Base Depth" ); + m_baseDepth.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_interpreterName, "InterpreterName", "Interpreter Name" ); + m_interpreterName.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_quality, "Quality", "Quality" ); + m_quality.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_unit, "Unit", "Unit" ); + m_unit.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_depthUnit, "DepthUnit", "Depth Unit" ); + m_depthUnit.uiCapability()->setUiReadOnly( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogChannel::setDescription( const QString& description ) +{ + m_description = description; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogChannel::setTopDepth( double topDepth ) +{ + m_topDepth = topDepth; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogChannel::setBaseDepth( double baseDepth ) +{ + m_baseDepth = baseDepth; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogChannel::setInterpreterName( const QString& interpreterName ) +{ + m_interpreterName = interpreterName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogChannel::setQuality( const QString& quality ) +{ + m_quality = quality; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogChannel::setUnit( const QString& unit ) +{ + m_unit = unit; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogChannel::setDepthUnit( const QString& depthUnit ) +{ + m_depthUnit = depthUnit; +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.h new file mode 100644 index 0000000000..2fe010f7a1 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.h @@ -0,0 +1,50 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimWellLogChannel.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RimOsduWellLogChannel : public RimWellLogChannel +{ + CAF_PDM_HEADER_INIT; + +public: + RimOsduWellLogChannel(); + + void setDescription( const QString& description ); + void setTopDepth( double topDepth ); + void setBaseDepth( double baseDepth ); + void setInterpreterName( const QString& interpreterName ); + void setQuality( const QString& quality ); + void setUnit( const QString& unit ); + void setDepthUnit( const QString& depthUnit ); + +private: + caf::PdmField m_description; + caf::PdmField m_topDepth; + caf::PdmField m_baseDepth; + caf::PdmField m_interpreterName; + caf::PdmField m_quality; + caf::PdmField m_unit; + caf::PdmField m_depthUnit; +}; From 44daecac9a26954a939ab3b2226e0ea00b2f4a71 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Jul 2024 18:20:12 +0200 Subject: [PATCH 182/332] Refactor: move RiaOsduConnector to Tools/Cloud. --- ApplicationLibCode/Application/RiaApplication.cpp | 2 +- .../Application/Tools/Cloud/CMakeLists_files.cmake | 9 ++++++++- .../Tools/Cloud}/RiaOsduConnector.cpp | 0 .../Tools/Cloud}/RiaOsduConnector.h | 0 .../Cloud}/RiaOsduOAuthHttpServerReplyHandler.cpp | 0 .../Cloud}/RiaOsduOAuthHttpServerReplyHandler.h | 0 .../Application/Tools/Cloud/RiaSumoConnector.cpp | 3 +-- .../OsduImportCommands/CMakeLists_files.cmake | 14 +++----------- .../RicWellPathsImportOsduFeature.cpp | 2 +- .../OsduImportCommands/RiuWellImportWizard.cpp | 1 - .../OsduImportCommands/RiuWellImportWizard.h | 2 +- .../OsduImportCommands/RiuWellLogImportWizard.cpp | 1 - .../OsduImportCommands/RiuWellLogImportWizard.h | 4 ++-- .../Commands/RicImportWellLogOsduFeature.cpp | 8 +++----- .../WellPath/RimWellPathCollection.cpp | 2 +- 15 files changed, 21 insertions(+), 27 deletions(-) rename ApplicationLibCode/{Commands/OsduImportCommands => Application/Tools/Cloud}/RiaOsduConnector.cpp (100%) rename ApplicationLibCode/{Commands/OsduImportCommands => Application/Tools/Cloud}/RiaOsduConnector.h (100%) rename ApplicationLibCode/{Commands/OsduImportCommands => Application/Tools/Cloud}/RiaOsduOAuthHttpServerReplyHandler.cpp (100%) rename ApplicationLibCode/{Commands/OsduImportCommands => Application/Tools/Cloud}/RiaOsduOAuthHttpServerReplyHandler.h (100%) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 70a26aaf0a..e44afb6d53 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -17,9 +17,9 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaApplication.h" +#include "Cloud/RiaOsduConnector.h" #include "Cloud/RiaSumoConnector.h" #include "Cloud/RiaSumoDefines.h" -#include "OsduImportCommands/RiaOsduConnector.h" #include "RiaArgumentParser.h" #include "RiaBaseDefs.h" diff --git a/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake b/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake index 6fe5273a78..a7f9e5b580 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake @@ -2,15 +2,22 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h ${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h ) set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.cpp ) -list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h) +list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h +) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp similarity index 100% rename from ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.cpp rename to ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h similarity index 100% rename from ApplicationLibCode/Commands/OsduImportCommands/RiaOsduConnector.h rename to ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduOAuthHttpServerReplyHandler.cpp similarity index 100% rename from ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.cpp rename to ApplicationLibCode/Application/Tools/Cloud/RiaOsduOAuthHttpServerReplyHandler.cpp diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.h b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduOAuthHttpServerReplyHandler.h similarity index 100% rename from ApplicationLibCode/Commands/OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.h rename to ApplicationLibCode/Application/Tools/Cloud/RiaOsduOAuthHttpServerReplyHandler.h diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index 9e7feda679..b59e13f3da 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -22,8 +22,7 @@ #include "RiaFileDownloader.h" #include "RiaLogging.h" #include "RiaOsduDefines.h" - -#include "OsduImportCommands/RiaOsduOAuthHttpServerReplyHandler.h" +#include "RiaOsduOAuthHttpServerReplyHandler.h" #include #include diff --git a/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake index 25f302fe4c..afc1fb1b39 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake @@ -6,8 +6,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogImportWizard.h - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -18,21 +16,15 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogImportWizard.cpp - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.cpp - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) -list( - APPEND - COMMAND_QT_MOC_HEADERS - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h - ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h - ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogImportWizard.h - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h +list(APPEND COMMAND_QT_MOC_HEADERS + ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h + ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogImportWizard.h ) source_group( diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index d0209b9b26..f76cdd8861 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -18,10 +18,10 @@ #include "RicWellPathsImportOsduFeature.h" +#include "Cloud/RiaOsduConnector.h" #include "RiaApplication.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" -#include "RiaOsduConnector.h" #include "RiaPreferences.h" #include "RiaPreferencesOsdu.h" diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index d34f5c245b..5cc7a20eb1 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -19,7 +19,6 @@ #include "RiuWellImportWizard.h" #include "RiaFeatureCommandContext.h" -#include "RiaOsduConnector.h" #include "RimWellPathImport.h" diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index 4e27c87723..e1471237e1 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -26,7 +26,7 @@ #include #include -#include "RiaOsduConnector.h" +#include "Cloud/RiaOsduConnector.h" #include diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp index 0de3c68422..714dce642e 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp @@ -19,7 +19,6 @@ #include "RiuWellLogImportWizard.h" #include "RiaFeatureCommandContext.h" -#include "RiaOsduConnector.h" #include #include diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h index 9fece3328d..bf689771d3 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h @@ -18,6 +18,8 @@ #pragma once +#include "Cloud/RiaOsduConnector.h" + #include #include #include @@ -26,8 +28,6 @@ #include #include -#include "RiaOsduConnector.h" - #include class QFile; diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp index 7d7e891d7e..647b56bd7d 100644 --- a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp @@ -18,8 +18,10 @@ #include "RicImportWellLogOsduFeature.h" +#include "Cloud/RiaOsduConnector.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" +#include "RiaPreferences.h" #include "RimOilField.h" #include "RimOsduWellLog.h" @@ -28,12 +30,8 @@ #include "RimProject.h" #include "RimWellPathCollection.h" -#include "RiuMainWindow.h" - -#include "OsduImportCommands/RiaOsduConnector.h" #include "OsduImportCommands/RiuWellLogImportWizard.h" -#include "RiaLogging.h" -#include "RiaPreferences.h" +#include "RiuMainWindow.h" #include "cafSelectionManager.h" diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 5572980258..6a6f4033be 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -20,7 +20,7 @@ #include "RimWellPathCollection.h" -#include "OsduImportCommands/RiaOsduConnector.h" +#include "Cloud/RiaOsduConnector.h" #include "RiaColorTables.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" From 36e014d54d30035f17999f9692b504674483dc22 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Jul 2024 16:28:13 +0200 Subject: [PATCH 183/332] Bump to dev.09 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 946f6f6c59..2b49e6f3d7 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".08") +set(RESINSIGHT_DEV_VERSION ".09") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 9316715063629199203f874d8248699c22ce757d Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Jul 2024 19:51:55 +0200 Subject: [PATCH 184/332] Osdu Well Log: Save well log channels and names to xml. --- .../ProjectDataModel/WellLog/RimOsduWellLog.cpp | 7 +++++++ .../ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp index 05f311c243..6ce834c889 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp @@ -44,6 +44,13 @@ RimOsduWellLog::RimOsduWellLog() CAF_PDM_InitFieldNoDefault( &m_wellLogId, "WellLogId", "Well Log Id" ); m_wellLogId.uiCapability()->setUiReadOnly( true ); + + // Need to save channels for Osdu well logs. + // This reverts settings from RimWellLog constructor. + m_wellLogChannels.xmlCapability()->setIOReadable( true ); + m_wellLogChannels.xmlCapability()->setIOWritable( true ); + + setDeletable( true ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp index 57547819b9..032d3745cb 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp @@ -49,6 +49,11 @@ RimOsduWellLogChannel::RimOsduWellLogChannel() CAF_PDM_InitFieldNoDefault( &m_depthUnit, "DepthUnit", "Depth Unit" ); m_depthUnit.uiCapability()->setUiReadOnly( true ); + + // Need to save the name for Osdu well log channels. + // This reverts settings from RimWellLogChannel constructor. + nameField()->xmlCapability()->setIOReadable( true ); + nameField()->xmlCapability()->setIOWritable( true ); } //-------------------------------------------------------------------------------------------------- From cc2d1de1882f627f9e99cbeceec20bfeb56d49f6 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 10 Jul 2024 19:53:08 +0200 Subject: [PATCH 185/332] Bump to dev.10. --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 2b49e6f3d7..369e3a9b10 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".09") +set(RESINSIGHT_DEV_VERSION ".10") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From eda26bcc251abc8dc1c85e491f7b4f05e723f338 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 12 Jul 2024 13:26:39 +0200 Subject: [PATCH 186/332] Cloud: Extract common oauth2 parts of Sumo and Osdu connector. --- .../Application/RiaApplication.cpp | 20 +- .../Tools/Cloud/CMakeLists_files.cmake | 12 +- .../Tools/Cloud/RiaCloudConnector.cpp | 239 ++++++++++++++++++ .../Tools/Cloud/RiaCloudConnector.h | 78 ++++++ .../Tools/Cloud/RiaOsduConnector.cpp | 147 +---------- .../Tools/Cloud/RiaOsduConnector.h | 26 +- .../Tools/Cloud/RiaSumoConnector.cpp | 197 +-------------- .../Tools/Cloud/RiaSumoConnector.h | 41 +-- .../Tools/Cloud/RiaSumoDefines.cpp | 2 +- 9 files changed, 364 insertions(+), 398 deletions(-) create mode 100644 ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp create mode 100644 ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index e44afb6d53..6f1596883c 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -1711,7 +1711,12 @@ RiaOsduConnector* RiaApplication::makeOsduConnector() const QString authority = osduPreferences->authority(); const QString scopes = osduPreferences->scopes(); const QString clientId = osduPreferences->clientId(); - m_osduConnector = new RiaOsduConnector( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId ); + const unsigned int port = 35327; + + m_osduConnector = new RiaOsduConnector( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId, port ); + m_osduConnector->setTokenDataFilePath( RiaSumoDefines::tokenPath() ); + m_osduConnector->importTokenFromFile(); + return m_osduConnector; } @@ -1722,13 +1727,14 @@ RiaSumoConnector* RiaApplication::makeSumoConnector() { if ( !m_sumoConnector ) { - auto sumoPrefs = preferences()->sumoPreferences(); - const QString server = sumoPrefs->server(); - const QString authority = sumoPrefs->authority(); - const QString scopes = sumoPrefs->scopes(); - const QString clientId = sumoPrefs->clientId(); + auto sumoPrefs = preferences()->sumoPreferences(); + const QString server = sumoPrefs->server(); + const QString authority = sumoPrefs->authority(); + const QString scopes = sumoPrefs->scopes(); + const QString clientId = sumoPrefs->clientId(); + const unsigned int port = 53527; - m_sumoConnector = new RiaSumoConnector( RiuMainWindow::instance(), server, authority, scopes, clientId ); + m_sumoConnector = new RiaSumoConnector( RiuMainWindow::instance(), server, authority, scopes, clientId, port ); m_sumoConnector->setTokenDataFilePath( RiaSumoDefines::tokenPath() ); m_sumoConnector->importTokenFromFile(); diff --git a/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake b/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake index a7f9e5b580..5a5a829a74 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake @@ -1,4 +1,5 @@ set(SOURCE_GROUP_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/RiaCloudConnector.h ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h ${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.h @@ -7,6 +8,7 @@ set(SOURCE_GROUP_HEADER_FILES ) set(SOURCE_GROUP_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/RiaCloudConnector.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.cpp @@ -14,9 +16,13 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.cpp ) -list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h +list( + APPEND + QT_MOC_HEADERS + ${CMAKE_CURRENT_LIST_DIR}/RiaCloudConnector.h + ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp new file mode 100644 index 0000000000..ddcf50d1bf --- /dev/null +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp @@ -0,0 +1,239 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RiaCloudConnector.h" + +#include "RiaConnectorTools.h" +#include "RiaLogging.h" +#include "RiaOsduDefines.h" +#include "RiaOsduOAuthHttpServerReplyHandler.h" +#include "RiaSumoDefines.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaCloudConnector::RiaCloudConnector( QObject* parent, + const QString& server, + const QString& authority, + const QString& scopes, + const QString& clientId, + unsigned int port ) + : QObject( parent ) + , m_server( server ) + , m_authority( authority ) + , m_scopes( scopes ) + , m_clientId( clientId ) +{ + m_authCodeFlow = new QOAuth2AuthorizationCodeFlow( this ); + m_networkAccessManager = new QNetworkAccessManager( this ); + m_authCodeFlow->setNetworkAccessManager( m_networkAccessManager ); + + RiaLogging::debug( "SSL BUILD VERSION: " + QSslSocket::sslLibraryBuildVersionString() ); + RiaLogging::debug( "SSL VERSION STRING: " + QSslSocket::sslLibraryVersionString() ); + + RiaLogging::debug( "Cloud config:" ); + RiaLogging::debug( " server: '" + server + "'" ); + RiaLogging::debug( " authority: '" + authority + "'" ); + RiaLogging::debug( " scopes: '" + scopes + "'" ); + RiaLogging::debug( " client id: '" + clientId + "'" ); + + connect( m_authCodeFlow, + &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, + []( QUrl url ) + { + RiaLogging::info( "Authorize with url: " + url.toString() ); + QUrlQuery query( url ); + url.setQuery( query ); + QDesktopServices::openUrl( url ); + } ); + + QString authUrl = constructAuthUrl( m_authority ); + m_authCodeFlow->setAuthorizationUrl( QUrl( authUrl ) ); + + QString tokenUrl = constructTokenUrl( m_authority ); + m_authCodeFlow->setAccessTokenUrl( QUrl( tokenUrl ) ); + + // App key + m_authCodeFlow->setClientIdentifier( m_clientId ); + m_authCodeFlow->setScope( m_scopes ); + + auto replyHandler = new RiaOsduOAuthHttpServerReplyHandler( port, this ); + m_authCodeFlow->setReplyHandler( replyHandler ); + RiaLogging::debug( "Server callback: " + replyHandler->callback() ); + + connect( m_authCodeFlow, SIGNAL( granted() ), this, SLOT( accessGranted() ) ); + connect( m_authCodeFlow, + SIGNAL( error( const QString&, const QString&, const QUrl& ) ), + this, + SLOT( errorReceived( const QString&, const QString&, const QUrl& ) ) ); + connect( m_authCodeFlow, + SIGNAL( authorizationCallbackReceived( const QVariantMap& ) ), + this, + SLOT( authorizationCallbackReceived( const QVariantMap& ) ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaCloudConnector::~RiaCloudConnector() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCloudConnector::accessGranted() +{ + m_token = m_authCodeFlow->token(); + + QString tokenDataJson = RiaConnectorTools::tokenDataAsJson( m_authCodeFlow ); + RiaConnectorTools::writeTokenData( m_tokenDataFilePath, tokenDataJson ); + + emit tokenReady( m_token ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCloudConnector::errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri ) +{ + RiaLogging::debug( "Cloud Error Received: " + error + ". Description: " + errorDescription ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCloudConnector::authorizationCallbackReceived( const QVariantMap& data ) +{ + RiaLogging::debug( "Authorization callback received:" ); + for ( const auto& [key, value] : data.toStdMap() ) + { + RiaLogging::debug( " Key: " + key + " Value: " + value.toString() ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCloudConnector::requestFailed( const QAbstractOAuth::Error error ) +{ + RiaLogging::error( "Request failed: " ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCloudConnector::requestToken() +{ + if ( m_token.isEmpty() ) + { + RiaLogging::debug( "Requesting token." ); + m_authCodeFlow->grant(); + } + else + { + RiaLogging::debug( "Has token: skipping token request." ); + emit accessGranted(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaCloudConnector::token() const +{ + return m_token; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCloudConnector::importTokenFromFile() +{ + auto tokenDataJson = RiaConnectorTools::readTokenData( m_tokenDataFilePath ); + if ( !tokenDataJson.isEmpty() ) + { + RiaConnectorTools::initializeTokenDataFromJson( m_authCodeFlow, tokenDataJson ); + m_token = m_authCodeFlow->token(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCloudConnector::setTokenDataFilePath( const QString& filePath ) +{ + m_tokenDataFilePath = filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaCloudConnector::constructAuthUrl( const QString& authority ) +{ + return authority + "/oauth2/v2.0/authorize"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaCloudConnector::constructTokenUrl( const QString& authority ) +{ + return authority + "/oauth2/v2.0/token"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaCloudConnector::requestTokenBlocking() +{ + if ( !m_token.isEmpty() ) return m_token; + + QTimer timer; + timer.setSingleShot( true ); + QEventLoop loop; + connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) ); + connect( &timer, SIGNAL( timeout() ), &loop, SLOT( quit() ) ); + requestToken(); + timer.start( RiaSumoDefines::requestTimeoutMillis() ); + loop.exec(); + return m_token; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaCloudConnector::server() const +{ + return m_server; +} diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h new file mode 100644 index 0000000000..9983b060f6 --- /dev/null +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h @@ -0,0 +1,78 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 +#include +#include + +// #include + +//================================================================================================== +/// +//================================================================================================== +class RiaCloudConnector : public QObject +{ + Q_OBJECT +public: + RiaCloudConnector( QObject* parent, + const QString& server, + const QString& authority, + const QString& scopes, + const QString& clientId, + unsigned int port ); + ~RiaCloudConnector() override; + + QString token() const; + + void importTokenFromFile(); + void setTokenDataFilePath( const QString& filePath ); + + QString server() const; + +public slots: + void requestToken(); + void accessGranted(); + void requestFailed( const QAbstractOAuth::Error error ); + +signals: + void tokenReady( const QString& token ); + +private slots: + void errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri ); + void authorizationCallbackReceived( const QVariantMap& data ); + +protected: + QString requestTokenBlocking(); + + static QString constructAuthUrl( const QString& authority ); + static QString constructTokenUrl( const QString& authority ); + + QOAuth2AuthorizationCodeFlow* m_authCodeFlow; + QNetworkAccessManager* m_networkAccessManager; + + const QString m_server; + const QString m_authority; + const QString m_scopes; + const QString m_clientId; + + QString m_token; + + QString m_tokenDataFilePath; +}; diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp index 7428ff3d25..b0b1098bbf 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp @@ -31,118 +31,17 @@ RiaOsduConnector::RiaOsduConnector( QObject* parent, const QString& dataPartitionId, const QString& authority, const QString& scopes, - const QString& clientId ) - : QObject( parent ) - , m_server( server ) + const QString& clientId, + unsigned int port ) + : RiaCloudConnector( parent, server, authority, scopes, clientId, port ) , m_dataPartitionId( dataPartitionId ) - , m_authority( authority ) - , m_scopes( scopes ) - , m_clientId( clientId ) { - m_networkAccessManager = new QNetworkAccessManager( this ); - - m_osdu = new QOAuth2AuthorizationCodeFlow( this ); - - RiaLogging::debug( "SSL BUILD VERSION: " + QSslSocket::sslLibraryBuildVersionString() ); - RiaLogging::debug( "SSL VERSION STRING: " + QSslSocket::sslLibraryVersionString() ); - - RiaLogging::debug( "OSDU config:" ); - RiaLogging::debug( " server: '" + server + "'" ); - RiaLogging::debug( " data partition id: '" + dataPartitionId + "'" ); - RiaLogging::debug( " authority: '" + authority + "'" ); - RiaLogging::debug( " scopes: '" + scopes + "'" ); - RiaLogging::debug( " client id: '" + clientId + "'" ); - - int port = 35327; - - connect( m_osdu, - &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, - []( QUrl url ) - { - RiaLogging::debug( "Authorize with url: " + url.toString() ); - QUrlQuery query( url ); - url.setQuery( query ); - QDesktopServices::openUrl( url ); - } ); - - QString authUrl = constructAuthUrl( m_authority ); - m_osdu->setAuthorizationUrl( QUrl( authUrl ) ); - - QString tokenUrl = constructTokenUrl( m_authority ); - m_osdu->setAccessTokenUrl( QUrl( tokenUrl ) ); - - // App key - m_osdu->setClientIdentifier( m_clientId ); - m_osdu->setScope( m_scopes ); - - auto replyHandler = new RiaOsduOAuthHttpServerReplyHandler( port, this ); - m_osdu->setReplyHandler( replyHandler ); - RiaLogging::debug( "Osdu server callback: " + replyHandler->callback() ); - - connect( m_osdu, SIGNAL( granted() ), this, SLOT( accessGranted() ) ); - connect( m_osdu, - SIGNAL( error( const QString&, const QString&, const QUrl& ) ), - this, - SLOT( errorReceived( const QString&, const QString&, const QUrl& ) ) ); - - connect( m_osdu, - SIGNAL( authorizationCallbackReceived( const QVariantMap& ) ), - this, - SLOT( authorizationCallbackReceived( const QVariantMap& ) ) ); - connect( this, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ), this, SLOT( parquetDownloadComplete( const QByteArray&, const QString&, const QString& ) ) ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::accessGranted() -{ - RiaLogging::debug( "Access granted." ); - m_token = m_osdu->token(); - emit tokenReady( m_token ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri ) -{ - RiaLogging::debug( "OSDU Error Received: " + error + ". Description: " + errorDescription ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::authorizationCallbackReceived( const QVariantMap& data ) -{ - RiaLogging::debug( "Authorization callback received:" ); - for ( const auto& [key, value] : data.toStdMap() ) - { - RiaLogging::debug( " Key: " + key + " Value: " + value.toString() ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaOsduConnector::requestToken() -{ - if ( m_token.isEmpty() ) - { - RiaLogging::debug( "Requesting token." ); - m_osdu->grant(); - } - else - { - RiaLogging::debug( "Has token: skipping token request." ); - emit accessGranted(); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -390,22 +289,6 @@ QString RiaOsduConnector::constructFileDownloadUrl( const QString& server, const return server + "/api/file/v2/files/" + fileId + "/downloadURL"; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaOsduConnector::constructAuthUrl( const QString& authority ) -{ - return authority + "/oauth2/v2.0/authorize"; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaOsduConnector::constructTokenUrl( const QString& authority ) -{ - return authority + "/oauth2/v2.0/token"; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -707,14 +590,6 @@ QNetworkReply* return reply; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaOsduConnector::server() const -{ - return m_server; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -912,19 +787,3 @@ void RiaOsduConnector::parquetDownloadComplete( const QByteArray& contents, cons m_parquetData[id] = contents; m_parquetErrors[id] = errorMessage; } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaOsduConnector::requestTokenBlocking() -{ - if ( m_token.isEmpty() ) - { - QEventLoop loop; - connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) ); - requestToken(); - loop.exec(); - } - - return m_token; -} diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h index 8f24803978..c8bac574b2 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h @@ -1,5 +1,7 @@ #pragma once +#include "RiaCloudConnector.h" + #include #include @@ -64,7 +66,7 @@ struct OsduWellLog //================================================================================================== /// //================================================================================================== -class RiaOsduConnector : public QObject +class RiaOsduConnector : public RiaCloudConnector { Q_OBJECT public: @@ -73,7 +75,8 @@ class RiaOsduConnector : public QObject const QString& dataParitionId, const QString& authority, const QString& scopes, - const QString& clientId ); + const QString& clientId, + unsigned int port ); ~RiaOsduConnector() override; void requestFieldsByName( const QString& fieldName ); @@ -93,7 +96,6 @@ class RiaOsduConnector : public QObject void clearCachedData(); - QString server() const; QString dataPartition() const; std::vector fields() const; @@ -103,14 +105,11 @@ class RiaOsduConnector : public QObject std::vector wellLogs( const QString& wellboreId ) const; public slots: - void requestToken(); void parseFields( QNetworkReply* reply ); void parseWells( QNetworkReply* reply ); void parseWellbores( QNetworkReply* reply, const QString& wellId ); void parseWellTrajectory( QNetworkReply* reply, const QString& wellboreId ); void parseWellLogs( QNetworkReply* reply, const QString& wellboreId ); - - void accessGranted(); void parquetDownloadComplete( const QByteArray&, const QString& url, const QString& id ); signals: @@ -120,11 +119,8 @@ public slots: void wellboresFinished( const QString& wellId ); void wellboreTrajectoryFinished( const QString& wellboreId, int numTrajectories, const QString& errorMessage ); void wellLogsFinished( const QString& wellboreId ); - void tokenReady( const QString& token ); private slots: - void errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri ); - void authorizationCallbackReceived( const QVariantMap& data ); void requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token, const QString& id ); private: @@ -149,27 +145,15 @@ private slots: static QString constructSearchUrl( const QString& server ); static QString constructFileDownloadUrl( const QString& server, const QString& fileId ); - static QString constructAuthUrl( const QString& authority ); - static QString constructTokenUrl( const QString& authority ); static QString constructWellLogDownloadUrl( const QString& server, const QString& wellLogId ); static QString constructWellboreTrajectoriesDownloadUrl( const QString& server, const QString& wellboreTrajectoryId ); std::pair requestParquetDataByUrlBlocking( const QString& url, const QString& id ); void requestParquetDataByUrl( const QString& url, const QString& id ); - QString requestTokenBlocking(); - - QOAuth2AuthorizationCodeFlow* m_osdu; - QNetworkAccessManager* m_networkAccessManager; - - const QString m_server; const QString m_dataPartitionId; - const QString m_authority; - const QString m_scopes; - const QString m_clientId; mutable QMutex m_mutex; - QString m_token; std::vector m_fields; std::vector m_wells; std::map> m_wellbores; diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index b59e13f3da..2e080eefff 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -45,60 +45,14 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaSumoConnector::RiaSumoConnector( QObject* parent, const QString& server, const QString& authority, const QString& scopes, const QString& clientId ) - : QObject( parent ) - , m_server( server ) - , m_authority( authority ) - , m_scopes( scopes ) - , m_clientId( clientId ) +RiaSumoConnector::RiaSumoConnector( QObject* parent, + const QString& server, + const QString& authority, + const QString& scopes, + const QString& clientId, + unsigned int port ) + : RiaCloudConnector( parent, server, authority, scopes, clientId, port ) { - m_authCodeFlow = new QOAuth2AuthorizationCodeFlow( this ); - m_networkAccessManager = new QNetworkAccessManager( this ); - m_authCodeFlow->setNetworkAccessManager( m_networkAccessManager ); - - RiaLogging::debug( "SSL BUILD VERSION: " + QSslSocket::sslLibraryBuildVersionString() ); - RiaLogging::debug( "SSL VERSION STRING: " + QSslSocket::sslLibraryVersionString() ); - - // NB: Make sure the port is not in use by another application - const unsigned int port = 53527; - - connect( m_authCodeFlow, - &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, - []( QUrl url ) - { - RiaLogging::info( "Authorize with url: " + url.toString() ); - QUrlQuery query( url ); - url.setQuery( query ); - QDesktopServices::openUrl( url ); - } ); - - QString authUrl = constructAuthUrl( m_authority ); - m_authCodeFlow->setAuthorizationUrl( QUrl( authUrl ) ); - - QString tokenUrl = constructTokenUrl( m_authority ); - m_authCodeFlow->setAccessTokenUrl( QUrl( tokenUrl ) ); - - // App key - m_authCodeFlow->setClientIdentifier( m_clientId ); - m_authCodeFlow->setScope( m_scopes ); - - auto replyHandler = new RiaOsduOAuthHttpServerReplyHandler( port, this ); - m_authCodeFlow->setReplyHandler( replyHandler ); - - connect( m_authCodeFlow, SIGNAL( granted() ), this, SLOT( accessGranted() ) ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaSumoConnector::accessGranted() -{ - m_token = m_authCodeFlow->token(); - - QString tokenDataJson = RiaConnectorTools::tokenDataAsJson( m_authCodeFlow ); - RiaConnectorTools::writeTokenData( m_tokenDataFilePath, tokenDataJson ); - - emit tokenReady( m_token ); } //-------------------------------------------------------------------------------------------------- @@ -122,15 +76,6 @@ void RiaSumoConnector::parquetDownloadComplete( const QString& blobId, const QBy m_redirectInfo.push_back( obj ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaSumoConnector::requestToken() -{ - RiaLogging::debug( "Requesting token." ); - m_authCodeFlow->grant(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -138,35 +83,6 @@ RiaSumoConnector::~RiaSumoConnector() { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaSumoConnector::token() const -{ - return m_token; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaSumoConnector::importTokenFromFile() -{ - auto tokenDataJson = RiaConnectorTools::readTokenData( m_tokenDataFilePath ); - if ( !tokenDataJson.isEmpty() ) - { - RiaConnectorTools::initializeTokenDataFromJson( m_authCodeFlow, tokenDataJson ); - m_token = m_authCodeFlow->token(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaSumoConnector::setTokenDataFilePath( const QString& filePath ) -{ - m_tokenDataFilePath = filePath; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -668,22 +584,6 @@ QString RiaSumoConnector::constructDownloadUrl( const QString& server, const QSt // https: // main-sumo-prod.radix.equinor.com/api/v1/objects('76d6d11f-2278-3fe2-f12f-77142ad163c6')/blob } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaSumoConnector::constructAuthUrl( const QString& authority ) -{ - return authority + "/oauth2/v2.0/authorize"; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaSumoConnector::constructTokenUrl( const QString& authority ) -{ - return authority + "/oauth2/v2.0/token"; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -911,46 +811,6 @@ void RiaSumoConnector::parseBlobIds( QNetworkReply* reply, const SumoCaseId& cas emit blobIdFinished(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaSumoConnector::saveFile( QNetworkReply* reply, const QString& fileId ) -{ - QByteArray result = reply->readAll(); - reply->deleteLater(); - - if ( reply->error() == QNetworkReply::NoError ) - { - QEventLoop loop; - - QJsonDocument doc = QJsonDocument::fromJson( result ); - QJsonObject jsonObj = doc.object(); - - QString signedUrl = jsonObj["SignedUrl"].toString(); - - RiaFileDownloader* downloader = new RiaFileDownloader; - QUrl url( signedUrl ); - QString filePath = "/tmp/" + generateRandomString( 30 ) + ".txt"; - - QString formattedJsonString = doc.toJson( QJsonDocument::Indented ); - - RiaLogging::info( QString( "File download: %1 => %2" ).arg( signedUrl ).arg( filePath ) ); - connect( this, SIGNAL( fileDownloadFinished( const QString&, const QString& ) ), &loop, SLOT( quit() ) ); - connect( downloader, - &RiaFileDownloader::done, - [this, fileId, filePath]() - { - RiaLogging::info( QString( "Download complete %1 => %2" ).arg( fileId ).arg( filePath ) ); - emit( fileDownloadFinished( fileId, filePath ) ); - } ); - RiaLogging::info( "Starting download" ); - downloader->downloadFile( url, filePath ); - - downloader->deleteLater(); - loop.exec(); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -960,24 +820,6 @@ void RiaSumoConnector::addStandardHeader( QNetworkRequest& networkRequest, const networkRequest.setRawHeader( "Authorization", "Bearer " + token.toUtf8() ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaSumoConnector::requestTokenBlocking() -{ - if ( !m_token.isEmpty() ) return m_token; - - QTimer timer; - timer.setSingleShot( true ); - QEventLoop loop; - connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) ); - connect( &timer, SIGNAL( timeout() ), &loop, SLOT( quit() ) ); - requestToken(); - timer.start( RiaSumoDefines::requestTimeoutMillis() ); - loop.exec(); - return m_token; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1019,31 +861,6 @@ void RiaSumoConnector::requestParquetData( const QString& url, const QString& to } ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaSumoConnector::generateRandomString( int randomStringLength ) -{ - const QString possibleCharacters( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ); - QString randomString; - for ( int i = 0; i < randomStringLength; ++i ) - { - quint32 value = QRandomGenerator::global()->generate(); - int index = value % possibleCharacters.length(); - QChar nextChar = possibleCharacters.at( index ); - randomString.append( nextChar ); - } - return randomString; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaSumoConnector::server() const -{ - return m_server; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h index 3e8fb62a83..9dc9449a40 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h @@ -18,6 +18,7 @@ #pragma once +#include "RiaCloudConnector.h" #include "RiaSumoDefines.h" #include @@ -63,18 +64,18 @@ struct SumoEnsemble //================================================================================================== /// //================================================================================================== -class RiaSumoConnector : public QObject +class RiaSumoConnector : public RiaCloudConnector { Q_OBJECT public: - RiaSumoConnector( QObject* parent, const QString& server, const QString& authority, const QString& scopes, const QString& clientId ); + RiaSumoConnector( QObject* parent, + const QString& server, + const QString& authority, + const QString& scopes, + const QString& clientId, + unsigned int port ); ~RiaSumoConnector() override; - QString token() const; - - void importTokenFromFile(); - void setTokenDataFilePath( const QString& filePath ); - void requestAssets(); void requestAssetsBlocking(); @@ -98,8 +99,6 @@ class RiaSumoConnector : public QObject QByteArray requestParquetDataBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ); - QString server() const; - std::vector assets() const; std::vector cases() const; std::vector ensembleNamesForCase( const SumoCaseId& caseId ) const; @@ -109,8 +108,6 @@ class RiaSumoConnector : public QObject std::vector blobContents() const; public slots: - void requestToken(); - void parseAssets( QNetworkReply* reply ); void parseEnsembleNames( QNetworkReply* reply, const SumoCaseId& caseId ); void parseCases( QNetworkReply* reply ); @@ -118,9 +115,6 @@ public slots: void parseRealizationNumbers( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName ); void parseBlobIds( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ); - void saveFile( QNetworkReply* reply, const QString& fileId ); - - void accessGranted(); void requestFailed( const QAbstractOAuth::Error error ); void parquetDownloadComplete( const QString& blobId, const QByteArray&, const QString& url ); @@ -130,7 +124,6 @@ public slots: void wellsFinished(); void wellboresFinished( const QString& wellId ); void wellboreTrajectoryFinished( const QString& wellboreId ); - void tokenReady( const QString& token ); void parquetDownloadFinished( const QByteArray& contents, const QString& url ); void ensembleNamesFinished(); void vectorNamesFinished(); @@ -141,29 +134,15 @@ public slots: private: void addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& contentType ); - QString requestTokenBlocking(); - QNetworkReply* makeRequest( const std::map& parameters, const QString& server, const QString& token ); QNetworkReply* makeDownloadRequest( const QString& url, const QString& token, const QString& contentType ); void requestParquetData( const QString& url, const QString& token ); - static QString generateRandomString( int length = 20 ); + // static QString generateRandomString( int length = 20 ); static QString constructSearchUrl( const QString& server ); static QString constructDownloadUrl( const QString& server, const QString& blobId ); - static QString constructAuthUrl( const QString& authority ); - static QString constructTokenUrl( const QString& authority ); private: - QOAuth2AuthorizationCodeFlow* m_authCodeFlow; - QNetworkAccessManager* m_networkAccessManager; - - const QString m_server; - const QString m_authority; - const QString m_scopes; - const QString m_clientId; - - QString m_token; - std::vector m_assets; std::vector m_cases; std::vector m_vectorNames; @@ -177,6 +156,4 @@ public slots: std::vector m_redirectInfo; QByteArray m_parquetData; - - QString m_tokenDataFilePath; }; diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp index c9502c7ab3..f4354485e6 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp @@ -34,5 +34,5 @@ QString RiaSumoDefines::tokenPath() //-------------------------------------------------------------------------------------------------- int RiaSumoDefines::requestTimeoutMillis() { - return 500; + return 120 * 1000; } From 734a84956e33eb02f070454f8fa1d17531e2aa04 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 12 Jul 2024 15:09:17 +0200 Subject: [PATCH 187/332] Osdu Well Log: use channel "CurveId" instead of "Mnemonic". --- .../Application/Tools/Cloud/RiaOsduConnector.cpp | 10 +++++----- .../Application/Tools/Cloud/RiaOsduConnector.h | 1 + .../OsduImportCommands/RiuWellLogImportWizard.h | 2 +- .../Commands/RicImportWellLogOsduFeature.cpp | 1 + .../WellLog/RimOsduWellLogChannel.cpp | 11 +++++++++++ .../ProjectDataModel/WellLog/RimOsduWellLogChannel.h | 2 ++ 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp index b0b1098bbf..6d1a71b1ee 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp @@ -518,14 +518,14 @@ void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellb double samplingStart = dataObj["SamplingStart"].toDouble( std::numeric_limits::infinity() ); double samplingStop = dataObj["SamplingStop"].toDouble( std::numeric_limits::infinity() ); - QJsonArray curvesArray = dataObj["Curves"].toArray(); - QStringList curveMnemonics; + QJsonArray curvesArray = dataObj["Curves"].toArray(); RiaLogging::debug( QString( "Curves for '%1':" ).arg( id ) ); std::vector channels; for ( const QJsonValue& curve : curvesArray ) { QString mnemonic = curve["Mnemonic"].toString(); + QString curveId = curve["CurveID"].toString(); QString curveDescription = curve["CurveDescription"].toString(); double curveBaseDepth = curve["BaseDepth"].toDouble( std::numeric_limits::infinity() ); double curveTopDepth = curve["TopDepth"].toDouble( std::numeric_limits::infinity() ); @@ -534,10 +534,10 @@ void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellb QString unit = curve["CurveUnit"].toString(); QString depthUnit = curve["DepthUnit"].toString(); - curveMnemonics << mnemonic; RiaLogging::debug( - QString( "%1: '%2' (%3 - %4)" ).arg( mnemonic ).arg( curveDescription ).arg( curveTopDepth ).arg( curveBaseDepth ) ); - channels.push_back( OsduWellLogChannel{ .mnemonic = mnemonic, + QString( "%1: '%2' (%3 - %4)" ).arg( curveId ).arg( curveDescription ).arg( curveTopDepth ).arg( curveBaseDepth ) ); + channels.push_back( OsduWellLogChannel{ .id = curveId, + .mnemonic = mnemonic, .description = curveDescription, .topDepth = curveTopDepth, .baseDepth = curveBaseDepth, diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h index c8bac574b2..3efb2ba586 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h @@ -41,6 +41,7 @@ struct OsduWellboreTrajectory struct OsduWellLogChannel { + QString id; QString mnemonic; QString description; double topDepth; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h index bf689771d3..3024b756a3 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.h @@ -69,7 +69,7 @@ class OsduWellLogTableModel : public QAbstractTableModel QStringList channels; for ( auto c : wellLog.channels ) { - channels.push_back( c.mnemonic ); + channels.push_back( c.id ); } return channels.join( ", " ); }; diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp index 647b56bd7d..6e9070bbb3 100644 --- a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp @@ -80,6 +80,7 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked ) for ( OsduWellLogChannel c : wellLog.channels ) { RimOsduWellLogChannel* osduWellLogChannel = new RimOsduWellLogChannel; + osduWellLogChannel->setId( c.id ); osduWellLogChannel->setName( c.mnemonic ); osduWellLogChannel->setDescription( c.description ); osduWellLogChannel->setTopDepth( c.topDepth ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp index 032d3745cb..d443de1000 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.cpp @@ -29,6 +29,9 @@ RimOsduWellLogChannel::RimOsduWellLogChannel() { CAF_PDM_InitObject( "OSDU Well Log Channel" ); + CAF_PDM_InitFieldNoDefault( &m_id, "Id", "Id" ); + m_id.uiCapability()->setUiReadOnly( true ); + CAF_PDM_InitFieldNoDefault( &m_description, "Description", "Description" ); m_description.uiCapability()->setUiReadOnly( true ); @@ -56,6 +59,14 @@ RimOsduWellLogChannel::RimOsduWellLogChannel() nameField()->xmlCapability()->setIOWritable( true ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogChannel::setId( const QString& id ) +{ + m_id = id; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.h index 2fe010f7a1..632b6f69ad 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogChannel.h @@ -31,6 +31,7 @@ class RimOsduWellLogChannel : public RimWellLogChannel public: RimOsduWellLogChannel(); + void setId( const QString& id ); void setDescription( const QString& description ); void setTopDepth( double topDepth ); void setBaseDepth( double baseDepth ); @@ -40,6 +41,7 @@ class RimOsduWellLogChannel : public RimWellLogChannel void setDepthUnit( const QString& depthUnit ); private: + caf::PdmField m_id; caf::PdmField m_description; caf::PdmField m_topDepth; caf::PdmField m_baseDepth; From 151f433124cab7160a78797c3823487bfe80fcee Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 12 Jul 2024 16:04:13 +0200 Subject: [PATCH 188/332] Cloud: create directory if missing when saving access token. --- .../Application/Tools/Cloud/RiaConnectorTools.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp index c7872bc1b5..064d2b37fb 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp @@ -18,7 +18,9 @@ #include "RiaConnectorTools.h" +#include #include +#include #include #include #include @@ -55,6 +57,15 @@ void RiaConnectorTools::initializeTokenDataFromJson( QOAuth2AuthorizationCodeFlo void RiaConnectorTools::writeTokenData( const QString& filePath, const QString& tokenDataJson ) { QFile file( filePath ); + + // Ensure the directory exists (create it if it doesn't) + QString dirPath = QFileInfo( file ).absolutePath(); + QDir dir( dirPath ); + if ( !dir.exists() ) + { + dir.mkpath( dirPath ); + } + if ( file.open( QIODevice::WriteOnly ) ) { QTextStream stream( &file ); From a8004870d464db36b9e073dc0b6a07d23b07a9b3 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 12 Jul 2024 16:04:52 +0200 Subject: [PATCH 189/332] Well Log Track: show "New LAS file curve" menu item for Osdu well logs. --- .../WellLogCommands/RicNewWellLogFileCurveFeature.cpp | 6 +++--- .../WellLogCommands/RicNewWellLogFileCurveFeature.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp index cb542a5811..4292adf5f3 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp @@ -47,7 +47,7 @@ CAF_CMD_SOURCE_INIT( RicNewWellLogFileCurveFeature, "RicNewWellLogFileCurveFeatu bool RicNewWellLogFileCurveFeature::isCommandEnabled() const { if ( RicWellLogPlotCurveFeatureImpl::parentWellRftPlot() ) return false; - return ( caf::SelectionManager::instance()->selectedItemAncestorOfType() != nullptr && wellLogFilesAvailable() ) || + return ( caf::SelectionManager::instance()->selectedItemAncestorOfType() != nullptr && wellLogsAvailable() ) || RicWellLogTools::selectedWellPathWithLog() != nullptr; } @@ -91,14 +91,14 @@ void RicNewWellLogFileCurveFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicNewWellLogFileCurveFeature::wellLogFilesAvailable() +bool RicNewWellLogFileCurveFeature::wellLogsAvailable() { auto wellPathCollection = RimTools::wellPathCollection(); if ( wellPathCollection ) { for ( auto wellPath : wellPathCollection->allWellPaths() ) { - if ( !wellPath->wellLogFiles().empty() ) + if ( !wellPath->wellLogs().empty() ) { return true; } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h index 6f777ac723..5c1d89a728 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h @@ -36,5 +36,5 @@ class RicNewWellLogFileCurveFeature : public caf::CmdFeature void setupActionLook( QAction* actionToSetup ) override; private: - static bool wellLogFilesAvailable(); + static bool wellLogsAvailable(); }; From 896e4979bf68d89d92d6ab2add5b2b4f64ad31ee Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 12 Jul 2024 18:51:22 +0200 Subject: [PATCH 190/332] Cloud: Handle refresh of access token. --- .../Tools/Cloud/RiaCloudConnector.cpp | 74 +++++++++++++++---- .../Tools/Cloud/RiaCloudConnector.h | 6 +- .../Tools/Cloud/RiaOsduConnector.cpp | 13 ++-- .../Tools/Cloud/RiaSumoConnector.cpp | 14 ++-- 4 files changed, 77 insertions(+), 30 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp index ddcf50d1bf..3939a81da8 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp @@ -25,6 +25,7 @@ #include "RiaSumoDefines.h" #include +#include #include #include #include @@ -100,6 +101,30 @@ RiaCloudConnector::RiaCloudConnector( QObject* parent, SIGNAL( authorizationCallbackReceived( const QVariantMap& ) ), this, SLOT( authorizationCallbackReceived( const QVariantMap& ) ) ); + + connect( m_authCodeFlow, + &QOAuth2AuthorizationCodeFlow::tokenChanged, + this, + [&]( const QString& token ) + { + RiaLogging::debug( "Access token changed." ); + exportTokenToFile(); + } ); + + connect( m_authCodeFlow, + &QOAuth2AuthorizationCodeFlow::refreshTokenChanged, + this, + [&]( const QString& refreshToken ) + { + RiaLogging::debug( "Refresh token changed." ); + exportTokenToFile(); + } ); + + connect( m_authCodeFlow, + &QOAuth2AuthorizationCodeFlow::expirationAtChanged, + this, + [&]( const QDateTime& expiration ) + { RiaLogging::debug( QString( "Access token expiration changed: %1" ).arg( expiration.toString() ) ); } ); } //-------------------------------------------------------------------------------------------------- @@ -114,12 +139,8 @@ RiaCloudConnector::~RiaCloudConnector() //-------------------------------------------------------------------------------------------------- void RiaCloudConnector::accessGranted() { - m_token = m_authCodeFlow->token(); - - QString tokenDataJson = RiaConnectorTools::tokenDataAsJson( m_authCodeFlow ); - RiaConnectorTools::writeTokenData( m_tokenDataFilePath, tokenDataJson ); - - emit tokenReady( m_token ); + QString currentToken = m_authCodeFlow->token(); + emit tokenReady( currentToken ); } //-------------------------------------------------------------------------------------------------- @@ -155,10 +176,19 @@ void RiaCloudConnector::requestFailed( const QAbstractOAuth::Error error ) //-------------------------------------------------------------------------------------------------- void RiaCloudConnector::requestToken() { - if ( m_token.isEmpty() ) + if ( token().isEmpty() ) { - RiaLogging::debug( "Requesting token." ); - m_authCodeFlow->grant(); + RiaLogging::debug( "No valid access token found." ); + if ( !m_authCodeFlow->refreshToken().isEmpty() ) + { + RiaLogging::info( "Refreshing access token with refresh token." ); + m_authCodeFlow->refreshAccessToken(); + } + else + { + RiaLogging::info( "Requesting token." ); + m_authCodeFlow->grant(); + } } else { @@ -172,7 +202,25 @@ void RiaCloudConnector::requestToken() //-------------------------------------------------------------------------------------------------- QString RiaCloudConnector::token() const { - return m_token; + QString currentToken = m_authCodeFlow->token(); + QDateTime expiration = m_authCodeFlow->expirationAt(); + if ( !currentToken.isEmpty() && expiration.isValid() && expiration > QDateTime::currentDateTime() ) + { + return currentToken; + } + else + { + return QString(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCloudConnector::exportTokenToFile() +{ + QString tokenDataJson = RiaConnectorTools::tokenDataAsJson( m_authCodeFlow ); + RiaConnectorTools::writeTokenData( m_tokenDataFilePath, tokenDataJson ); } //-------------------------------------------------------------------------------------------------- @@ -184,7 +232,6 @@ void RiaCloudConnector::importTokenFromFile() if ( !tokenDataJson.isEmpty() ) { RiaConnectorTools::initializeTokenDataFromJson( m_authCodeFlow, tokenDataJson ); - m_token = m_authCodeFlow->token(); } } @@ -217,7 +264,8 @@ QString RiaCloudConnector::constructTokenUrl( const QString& authority ) //-------------------------------------------------------------------------------------------------- QString RiaCloudConnector::requestTokenBlocking() { - if ( !m_token.isEmpty() ) return m_token; + QString currentToken = token(); + if ( !currentToken.isEmpty() ) return currentToken; QTimer timer; timer.setSingleShot( true ); @@ -227,7 +275,7 @@ QString RiaCloudConnector::requestTokenBlocking() requestToken(); timer.start( RiaSumoDefines::requestTimeoutMillis() ); loop.exec(); - return m_token; + return m_authCodeFlow->token(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h index 9983b060f6..9d5e7b6fa0 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h @@ -42,13 +42,14 @@ class RiaCloudConnector : public QObject QString token() const; void importTokenFromFile(); + void exportTokenToFile(); + void setTokenDataFilePath( const QString& filePath ); QString server() const; public slots: void requestToken(); - void accessGranted(); void requestFailed( const QAbstractOAuth::Error error ); signals: @@ -57,6 +58,7 @@ public slots: private slots: void errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri ); void authorizationCallbackReceived( const QVariantMap& data ); + void accessGranted(); protected: QString requestTokenBlocking(); @@ -72,7 +74,5 @@ private slots: const QString m_scopes; const QString m_clientId; - QString m_token; - QString m_tokenDataFilePath; }; diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp index 6d1a71b1ee..90d4470192 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp @@ -77,7 +77,7 @@ void RiaOsduConnector::requestFieldsByName( const QString& token, const QString& //-------------------------------------------------------------------------------------------------- void RiaOsduConnector::requestFieldsByName( const QString& fieldName ) { - requestFieldsByName( m_token, fieldName ); + requestFieldsByName( token(), fieldName ); } //-------------------------------------------------------------------------------------------------- @@ -113,7 +113,7 @@ void RiaOsduConnector::requestFieldsByName( const QString& server, const QString //-------------------------------------------------------------------------------------------------- void RiaOsduConnector::requestWellsByFieldId( const QString& fieldId ) { - requestWellsByFieldId( m_server, m_dataPartitionId, m_token, fieldId ); + requestWellsByFieldId( m_server, m_dataPartitionId, token(), fieldId ); } //-------------------------------------------------------------------------------------------------- @@ -149,7 +149,7 @@ void RiaOsduConnector::requestWellsByFieldId( const QString& server, const QStri //-------------------------------------------------------------------------------------------------- void RiaOsduConnector::requestWellboresByWellId( const QString& wellId ) { - requestWellboresByWellId( m_server, m_dataPartitionId, m_token, wellId ); + requestWellboresByWellId( m_server, m_dataPartitionId, token(), wellId ); } //-------------------------------------------------------------------------------------------------- @@ -200,7 +200,7 @@ std::vector RiaOsduConnector::requestWellLogsByWellboreIdBlocking( //-------------------------------------------------------------------------------------------------- void RiaOsduConnector::requestWellLogsByWellboreId( const QString& wellboreId ) { - requestWellLogsByWellboreId( m_server, m_dataPartitionId, m_token, wellboreId ); + requestWellLogsByWellboreId( m_server, m_dataPartitionId, token(), wellboreId ); } //-------------------------------------------------------------------------------------------------- @@ -239,7 +239,7 @@ void RiaOsduConnector::requestWellLogsByWellboreId( const QString& server, //-------------------------------------------------------------------------------------------------- void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& wellboreId ) { - requestWellboreTrajectoryByWellboreId( m_server, m_dataPartitionId, m_token, wellboreId ); + requestWellboreTrajectoryByWellboreId( m_server, m_dataPartitionId, token(), wellboreId ); } //-------------------------------------------------------------------------------------------------- @@ -709,8 +709,7 @@ void RiaOsduConnector::requestWellLogParquetDataById( const QString& wellLogId ) //-------------------------------------------------------------------------------------------------- void RiaOsduConnector::requestParquetDataByUrl( const QString& url, const QString& id ) { - QString token = m_token; - requestParquetData( url, m_dataPartitionId, token, id ); + requestParquetData( url, m_dataPartitionId, token(), id ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index 2e080eefff..1d2ea2a4ef 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -95,7 +95,7 @@ void RiaSumoConnector::requestCasesForField( const QString& fieldName ) QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( constructSearchUrl( m_server ) ) ); - addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() ); QString payloadTemplate = R"( { @@ -156,7 +156,7 @@ void RiaSumoConnector::requestAssets() QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( m_server + "/api/v1/userpermissions" ) ); - addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() ); auto reply = m_networkAccessManager->get( m_networkRequest ); @@ -218,7 +218,7 @@ void RiaSumoConnector::requestEnsembleByCasesId( const SumoCaseId& caseId ) QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); - addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() ); auto payload = payloadTemplate.arg( caseId.get() ); auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); @@ -291,7 +291,7 @@ void RiaSumoConnector::requestVectorNamesForEnsemble( const SumoCaseId& caseId, QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); - addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() ); auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName ); auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); @@ -360,7 +360,7 @@ void RiaSumoConnector::requestRealizationIdsForEnsemble( const SumoCaseId& caseI QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); - addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() ); auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName ); auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); @@ -423,7 +423,7 @@ void RiaSumoConnector::requestBlobIdForEnsemble( const SumoCaseId& caseId, const QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); - addStandardHeader( m_networkRequest, m_token, RiaDefines::contentTypeJson() ); + addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() ); auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName ).arg( vectorName ); auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); @@ -469,7 +469,7 @@ void RiaSumoConnector::requestBlobDownload( const QString& blobId ) // did not work. Use ManualRedirectPolicy instead, and inspect the reply for the redirection target. networkRequest.setAttribute( QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::ManualRedirectPolicy ); - addStandardHeader( networkRequest, m_token, RiaDefines::contentTypeJson() ); + addStandardHeader( networkRequest, token(), RiaDefines::contentTypeJson() ); auto reply = m_networkAccessManager->get( networkRequest ); From 8ddcbe7368ae722699f07ddbfbcbf05618b1d7ac Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 12 Jul 2024 15:21:26 +0200 Subject: [PATCH 191/332] Bump to dev.11. --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 369e3a9b10..92392f91df 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".10") +set(RESINSIGHT_DEV_VERSION ".11") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 3e2af38c907a99c1777e709bf2891afe23709777 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Sat, 13 Jul 2024 10:33:26 +0200 Subject: [PATCH 192/332] Cloud: Use separate files for Osdu and Sumo tokens. --- .../Application/CMakeLists_files.cmake | 2 ++ .../Application/RiaApplication.cpp | 4 +-- .../Application/RiaCloudDefines.cpp | 35 +++++++++++++++++++ .../Application/RiaCloudDefines.h | 27 ++++++++++++++ .../Application/RiaOsduDefines.cpp | 25 ++++++------- .../Application/RiaOsduDefines.h | 7 ++-- .../Tools/Cloud/RiaOsduConnector.cpp | 15 ++++---- .../Tools/Cloud/RiaSumoConnector.cpp | 19 +++++----- 8 files changed, 99 insertions(+), 35 deletions(-) create mode 100644 ApplicationLibCode/Application/RiaCloudDefines.cpp create mode 100644 ApplicationLibCode/Application/RiaCloudDefines.h diff --git a/ApplicationLibCode/Application/CMakeLists_files.cmake b/ApplicationLibCode/Application/CMakeLists_files.cmake index 8dc2c7f0aa..2206547e4b 100644 --- a/ApplicationLibCode/Application/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/CMakeLists_files.cmake @@ -37,6 +37,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.h + ${CMAKE_CURRENT_LIST_DIR}/RiaCloudDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.h ${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h @@ -81,6 +82,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaSeismicDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaCloudDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.cpp diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 6f1596883c..428cd6f5ca 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -20,6 +20,7 @@ #include "Cloud/RiaOsduConnector.h" #include "Cloud/RiaSumoConnector.h" #include "Cloud/RiaSumoDefines.h" +#include "RiaOsduDefines.h" #include "RiaArgumentParser.h" #include "RiaBaseDefs.h" @@ -1714,7 +1715,7 @@ RiaOsduConnector* RiaApplication::makeOsduConnector() const unsigned int port = 35327; m_osduConnector = new RiaOsduConnector( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId, port ); - m_osduConnector->setTokenDataFilePath( RiaSumoDefines::tokenPath() ); + m_osduConnector->setTokenDataFilePath( RiaOsduDefines::tokenPath() ); m_osduConnector->importTokenFromFile(); return m_osduConnector; @@ -1735,7 +1736,6 @@ RiaSumoConnector* RiaApplication::makeSumoConnector() const unsigned int port = 53527; m_sumoConnector = new RiaSumoConnector( RiuMainWindow::instance(), server, authority, scopes, clientId, port ); - m_sumoConnector->setTokenDataFilePath( RiaSumoDefines::tokenPath() ); m_sumoConnector->importTokenFromFile(); } diff --git a/ApplicationLibCode/Application/RiaCloudDefines.cpp b/ApplicationLibCode/Application/RiaCloudDefines.cpp new file mode 100644 index 0000000000..6c4516beb1 --- /dev/null +++ b/ApplicationLibCode/Application/RiaCloudDefines.cpp @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RiaCloudDefines.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaCloudDefines::contentTypeJson() +{ + return "application/json"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaCloudDefines::contentTypeParquet() +{ + return "application/x-parquet"; +} diff --git a/ApplicationLibCode/Application/RiaCloudDefines.h b/ApplicationLibCode/Application/RiaCloudDefines.h new file mode 100644 index 0000000000..e384d1df95 --- /dev/null +++ b/ApplicationLibCode/Application/RiaCloudDefines.h @@ -0,0 +1,27 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 + +namespace RiaCloudDefines +{ +QString contentTypeJson(); +QString contentTypeParquet(); +}; // namespace RiaCloudDefines diff --git a/ApplicationLibCode/Application/RiaOsduDefines.cpp b/ApplicationLibCode/Application/RiaOsduDefines.cpp index 2c14f207f9..867de76b87 100644 --- a/ApplicationLibCode/Application/RiaOsduDefines.cpp +++ b/ApplicationLibCode/Application/RiaOsduDefines.cpp @@ -18,10 +18,12 @@ #include "RiaOsduDefines.h" +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaDefines::osduFieldKind() +QString RiaOsduDefines::osduFieldKind() { return "osdu:wks:master-data--Field:1.0.0"; } @@ -29,7 +31,7 @@ QString RiaDefines::osduFieldKind() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaDefines::osduWellKind() +QString RiaOsduDefines::osduWellKind() { return "osdu:wks:master-data--Well:1.*.*"; } @@ -37,7 +39,7 @@ QString RiaDefines::osduWellKind() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaDefines::osduWellboreKind() +QString RiaOsduDefines::osduWellboreKind() { return "osdu:wks:master-data--Wellbore:1.*.*"; } @@ -45,7 +47,7 @@ QString RiaDefines::osduWellboreKind() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaDefines::osduWellboreTrajectoryKind() +QString RiaOsduDefines::osduWellboreTrajectoryKind() { return "osdu:wks:work-product-component--WellboreTrajectory:1.*.*"; } @@ -53,7 +55,7 @@ QString RiaDefines::osduWellboreTrajectoryKind() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaDefines::osduWellLogKind() +QString RiaOsduDefines::osduWellLogKind() { return "osdu:wks:work-product-component--WellLog:1.*.*"; } @@ -61,15 +63,8 @@ QString RiaDefines::osduWellLogKind() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaDefines::contentTypeJson() -{ - return "application/json"; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaDefines::contentTypeParquet() +QString RiaOsduDefines::tokenPath() { - return "application/x-parquet"; + QString homePath = QDir::homePath(); + return homePath + "/.resinsight/osdu_token.json"; } diff --git a/ApplicationLibCode/Application/RiaOsduDefines.h b/ApplicationLibCode/Application/RiaOsduDefines.h index 6168386e1a..0b72ccd183 100644 --- a/ApplicationLibCode/Application/RiaOsduDefines.h +++ b/ApplicationLibCode/Application/RiaOsduDefines.h @@ -20,7 +20,7 @@ #include -namespace RiaDefines +namespace RiaOsduDefines { QString osduFieldKind(); QString osduWellKind(); @@ -29,4 +29,7 @@ QString osduWellboreTrajectoryKind(); QString osduWellLogKind(); QString contentTypeJson(); QString contentTypeParquet(); -}; // namespace RiaDefines + +QString tokenPath(); + +}; // namespace RiaOsduDefines diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp index 90d4470192..82f1cad3e0 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp @@ -1,4 +1,5 @@ #include "RiaOsduConnector.h" +#include "RiaCloudDefines.h" #include "RiaFileDownloader.h" #include "RiaLogging.h" #include "RiaOsduDefines.h" @@ -86,7 +87,7 @@ void RiaOsduConnector::requestFieldsByName( const QString& fieldName ) void RiaOsduConnector::requestFieldsByName( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldName ) { std::map params; - params["kind"] = RiaDefines::osduFieldKind(); + params["kind"] = RiaOsduDefines::osduFieldKind(); params["limit"] = "10000"; params["query"] = "data.FieldName:" + fieldName; @@ -122,7 +123,7 @@ void RiaOsduConnector::requestWellsByFieldId( const QString& fieldId ) void RiaOsduConnector::requestWellsByFieldId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldId ) { std::map params; - params["kind"] = RiaDefines::osduWellKind(); + params["kind"] = RiaOsduDefines::osduWellKind(); params["limit"] = "10000"; params["query"] = QString( "nested(data.GeoContexts, (FieldID:\"%1\"))" ).arg( fieldId ); @@ -158,7 +159,7 @@ void RiaOsduConnector::requestWellboresByWellId( const QString& wellId ) void RiaOsduConnector::requestWellboresByWellId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellId ) { std::map params; - params["kind"] = RiaDefines::osduWellboreKind(); + params["kind"] = RiaOsduDefines::osduWellboreKind(); params["limit"] = "10000"; params["query"] = "data.WellID: \"" + wellId + "\""; @@ -212,7 +213,7 @@ void RiaOsduConnector::requestWellLogsByWellboreId( const QString& server, const QString& wellboreId ) { std::map params; - params["kind"] = RiaDefines::osduWellLogKind(); + params["kind"] = RiaOsduDefines::osduWellLogKind(); params["limit"] = "10000"; params["query"] = "data.WellboreID: \"" + wellboreId + "\""; @@ -251,7 +252,7 @@ void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& ser const QString& wellboreId ) { std::map params; - params["kind"] = RiaDefines::osduWellboreTrajectoryKind(); + params["kind"] = RiaOsduDefines::osduWellboreTrajectoryKind(); params["limit"] = "10000"; params["query"] = "data.WellboreID: \"" + wellboreId + "\""; @@ -316,7 +317,7 @@ QNetworkReply* RiaOsduConnector::makeSearchRequest( const std::mapget( m_networkRequest ); @@ -218,7 +219,7 @@ void RiaSumoConnector::requestEnsembleByCasesId( const SumoCaseId& caseId ) QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); - addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() ); + addStandardHeader( m_networkRequest, token(), RiaCloudDefines::contentTypeJson() ); auto payload = payloadTemplate.arg( caseId.get() ); auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); @@ -291,7 +292,7 @@ void RiaSumoConnector::requestVectorNamesForEnsemble( const SumoCaseId& caseId, QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); - addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() ); + addStandardHeader( m_networkRequest, token(), RiaCloudDefines::contentTypeJson() ); auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName ); auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); @@ -360,7 +361,7 @@ void RiaSumoConnector::requestRealizationIdsForEnsemble( const SumoCaseId& caseI QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); - addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() ); + addStandardHeader( m_networkRequest, token(), RiaCloudDefines::contentTypeJson() ); auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName ); auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); @@ -423,7 +424,7 @@ void RiaSumoConnector::requestBlobIdForEnsemble( const SumoCaseId& caseId, const QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); - addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() ); + addStandardHeader( m_networkRequest, token(), RiaCloudDefines::contentTypeJson() ); auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName ).arg( vectorName ); auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); @@ -469,7 +470,7 @@ void RiaSumoConnector::requestBlobDownload( const QString& blobId ) // did not work. Use ManualRedirectPolicy instead, and inspect the reply for the redirection target. networkRequest.setAttribute( QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::ManualRedirectPolicy ); - addStandardHeader( networkRequest, token(), RiaDefines::contentTypeJson() ); + addStandardHeader( networkRequest, token(), RiaCloudDefines::contentTypeJson() ); auto reply = m_networkAccessManager->get( networkRequest ); @@ -592,7 +593,7 @@ QNetworkReply* RiaSumoConnector::makeRequest( const std::map& QNetworkRequest m_networkRequest; m_networkRequest.setUrl( QUrl( constructSearchUrl( server ) ) ); - addStandardHeader( m_networkRequest, token, RiaDefines::contentTypeJson() ); + addStandardHeader( m_networkRequest, token, RiaCloudDefines::contentTypeJson() ); QJsonObject obj; for ( auto [key, value] : parameters ) @@ -841,7 +842,7 @@ void RiaSumoConnector::requestParquetData( const QString& url, const QString& to { RiaLogging::info( "Requesting download of parquet from: " + url ); - auto reply = makeDownloadRequest( url, token, RiaDefines::contentTypeJson() ); + auto reply = makeDownloadRequest( url, token, RiaCloudDefines::contentTypeJson() ); connect( reply, &QNetworkReply::finished, [this, reply, url]() From 2aa1bfe9404c45a61c989bb643a77d9bcf5de13c Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Sat, 13 Jul 2024 11:12:53 +0200 Subject: [PATCH 193/332] Cloud: save expiration timestamp for access token. Expired access tokens are ignored when reading from file. --- .../Application/Tools/Cloud/RiaCloudConnector.cpp | 5 ++++- .../Application/Tools/Cloud/RiaConnectorTools.cpp | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp index 3939a81da8..926bbbcdb6 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp @@ -124,7 +124,10 @@ RiaCloudConnector::RiaCloudConnector( QObject* parent, &QOAuth2AuthorizationCodeFlow::expirationAtChanged, this, [&]( const QDateTime& expiration ) - { RiaLogging::debug( QString( "Access token expiration changed: %1" ).arg( expiration.toString() ) ); } ); + { + RiaLogging::debug( QString( "Access token expiration changed: %1" ).arg( expiration.toString() ) ); + exportTokenToFile(); + } ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp index 064d2b37fb..f57b3f5c99 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp @@ -34,6 +34,10 @@ QString RiaConnectorTools::tokenDataAsJson( QOAuth2AuthorizationCodeFlow* authCo QJsonObject obj; obj.insert( "token", authCodeFlow->token() ); obj.insert( "refreshToken", authCodeFlow->refreshToken() ); + if ( authCodeFlow->expirationAt().isValid() ) + { + obj.insert( "expiration", authCodeFlow->expirationAt().toSecsSinceEpoch() ); + } QJsonDocument doc( obj ); return doc.toJson( QJsonDocument::Indented ); @@ -47,7 +51,16 @@ void RiaConnectorTools::initializeTokenDataFromJson( QOAuth2AuthorizationCodeFlo QJsonDocument doc = QJsonDocument::fromJson( tokenDataJson.toUtf8() ); QJsonObject obj = doc.object(); - authCodeFlow->setToken( obj["token"].toString() ); + if ( obj.contains( "expiration" ) && obj.contains( "token" ) ) + { + quint64 secondsSinceEpoch = obj["expiration"].toVariant().toULongLong(); + QDateTime expiration = QDateTime::fromSecsSinceEpoch( secondsSinceEpoch ); + if ( expiration.isValid() && expiration > QDateTime::currentDateTime() ) + { + authCodeFlow->setToken( obj["token"].toString() ); + } + } + authCodeFlow->setRefreshToken( obj["refreshToken"].toString() ); } From 773d9b08c95af7b6da8b080cc6737b1b9e9d7f62 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Sat, 13 Jul 2024 11:47:32 +0200 Subject: [PATCH 194/332] Janitor: remove unused code. --- .../Application/CMakeLists_files.cmake | 3 -- .../Application/RiaFileDownloader.cpp | 54 ------------------- .../Application/RiaFileDownloader.h | 16 ------ .../Tools/Cloud/RiaCloudConnector.cpp | 1 + .../Tools/Cloud/RiaCloudConnector.h | 8 +-- .../Tools/Cloud/RiaOsduConnector.cpp | 2 - .../Tools/Cloud/RiaSumoConnector.cpp | 1 - 7 files changed, 5 insertions(+), 80 deletions(-) delete mode 100644 ApplicationLibCode/Application/RiaFileDownloader.cpp delete mode 100644 ApplicationLibCode/Application/RiaFileDownloader.h diff --git a/ApplicationLibCode/Application/CMakeLists_files.cmake b/ApplicationLibCode/Application/CMakeLists_files.cmake index 2206547e4b..ea2ea6c50d 100644 --- a/ApplicationLibCode/Application/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/CMakeLists_files.cmake @@ -40,7 +40,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaCloudDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.h - ${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -85,7 +84,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaCloudDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.cpp - ${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) @@ -99,7 +97,6 @@ set(QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.h ${CMAKE_CURRENT_LIST_DIR}/RiaPlotWindowRedrawScheduler.h ${CMAKE_CURRENT_LIST_DIR}/RiaScheduler.h - ${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h ) source_group( diff --git a/ApplicationLibCode/Application/RiaFileDownloader.cpp b/ApplicationLibCode/Application/RiaFileDownloader.cpp deleted file mode 100644 index ed67eda849..0000000000 --- a/ApplicationLibCode/Application/RiaFileDownloader.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "RiaFileDownloader.h" - -#include -#include -#include -#include -#include -#include - -#include "RiaLogging.h" - -RiaFileDownloader::RiaFileDownloader( QObject* parent ) - : QObject( parent ) -{ -} - -void RiaFileDownloader::downloadFile( const QUrl& url, const QString& filePath ) -{ - QNetworkAccessManager* manager = new QNetworkAccessManager( this ); - QNetworkRequest request( url ); - - RiaLogging::debug( "Downloading from: " + url.toString() ); - - QNetworkReply* reply = manager->get( request ); - - connect( reply, - &QNetworkReply::finished, - [=, this]() - { - if ( reply->error() ) - { - RiaLogging::error( "Download failed:" + reply->errorString() ); - emit done(); - } - else - { - QFile file( filePath ); - if ( file.open( QIODevice::WriteOnly ) ) - { - file.write( reply->readAll() ); - file.close(); - RiaLogging::info( "Download succeeded. File saved to " + filePath ); - emit done(); - } - else - { - RiaLogging::info( "Failed to save file to " + filePath ); - emit done(); - } - } - reply->deleteLater(); - manager->deleteLater(); - } ); -} diff --git a/ApplicationLibCode/Application/RiaFileDownloader.h b/ApplicationLibCode/Application/RiaFileDownloader.h deleted file mode 100644 index a29cfe423b..0000000000 --- a/ApplicationLibCode/Application/RiaFileDownloader.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include -#include -#include - -class RiaFileDownloader : public QObject -{ - Q_OBJECT -public: - explicit RiaFileDownloader( QObject* parent = nullptr ); - - void downloadFile( const QUrl& url, const QString& filePath ); -signals: - void done(); -}; diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp index 926bbbcdb6..c9d9f5e04f 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp @@ -25,6 +25,7 @@ #include "RiaSumoDefines.h" #include +#include #include #include #include diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h index 9d5e7b6fa0..24acd33319 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h @@ -18,11 +18,11 @@ #pragma once -#include -#include -#include +#include +#include -// #include +class QNetworkAccessManager; +class QOAuth2AuthorizationCodeFlow; //================================================================================================== /// diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp index 82f1cad3e0..96f315a171 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp @@ -1,12 +1,10 @@ #include "RiaOsduConnector.h" #include "RiaCloudDefines.h" -#include "RiaFileDownloader.h" #include "RiaLogging.h" #include "RiaOsduDefines.h" #include "RiaOsduOAuthHttpServerReplyHandler.h" #include -#include #include #include #include diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index 56dd8e43bd..68df3eae84 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -20,7 +20,6 @@ #include "RiaCloudDefines.h" #include "RiaConnectorTools.h" -#include "RiaFileDownloader.h" #include "RiaLogging.h" #include "RiaOsduDefines.h" #include "RiaOsduOAuthHttpServerReplyHandler.h" From a9f34f7fa297369bdeb85454f7df2363bb6a399f Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Sat, 13 Jul 2024 11:49:06 +0200 Subject: [PATCH 195/332] Bump to dev.12. --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 92392f91df..ad8d28ec50 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".11") +set(RESINSIGHT_DEV_VERSION ".12") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From a77f50e3a85fba0842cd8c941cda961027850d89 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Jul 2024 11:33:38 +0200 Subject: [PATCH 196/332] SUMO connector adjustments Disable SUMO connector object when running regression tests to avoid request for credentials --- .../Application/RiaApplication.cpp | 34 ++++++------------- .../Application/RiaApplication.h | 2 -- .../Cloud/RimCloudDataSourceCollection.cpp | 6 ++++ ApplicationLibCode/UnitTests/main.cpp | 4 +++ 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 428cd6f5ca..df2cc4cbd9 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -22,25 +22,22 @@ #include "Cloud/RiaSumoDefines.h" #include "RiaOsduDefines.h" -#include "RiaArgumentParser.h" #include "RiaBaseDefs.h" #include "RiaFilePathTools.h" #include "RiaFontCache.h" -#include "RiaGuiApplication.h" #include "RiaImportEclipseCaseTools.h" #include "RiaLogging.h" #include "RiaPreferences.h" #include "RiaPreferencesSumo.h" #include "RiaPreferencesSystem.h" #include "RiaProjectModifier.h" +#include "RiaRegressionTestRunner.h" #include "RiaSocketServer.h" #include "RiaTextStringTools.h" #include "RiaVersionInfo.h" #include "RiaViewRedrawScheduler.h" #include "RiaWellNameComparer.h" -#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" -#include "HoloLensCommands/RicHoloLensSessionManager.h" #include "RicImportGeneralDataFeature.h" #include "RicfCommandFileExecutor.h" #include "RicfCommandObject.h" @@ -49,9 +46,6 @@ #include "Polygons/RimPolygonCollection.h" #include "Rim2dIntersectionViewCollection.h" -#include "RimAnnotationCollection.h" -#include "RimAnnotationInViewCollection.h" -#include "RimAnnotationTextAppearance.h" #include "RimCellFilterCollection.h" #include "RimCommandObject.h" #include "RimCommandRouter.h" @@ -63,7 +57,6 @@ #include "RimFormationNamesCollection.h" #include "RimFractureTemplateCollection.h" #include "RimGeoMechCase.h" -#include "RimGeoMechCellColors.h" #include "RimGeoMechModels.h" #include "RimGeoMechView.h" #include "RimGridCalculationCollection.h" @@ -74,7 +67,6 @@ #include "RimObservedFmuRftData.h" #include "RimObservedSummaryData.h" #include "RimOilField.h" -#include "RimPlotWindow.h" #include "RimProject.h" #include "RimScriptCollection.h" #include "RimSeismicData.h" @@ -90,8 +82,6 @@ #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSurfaceCollection.h" -#include "RimTextAnnotation.h" -#include "RimTextAnnotationInView.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" #include "RimWellLogLasFile.h" @@ -102,7 +92,6 @@ #include "VerticalFlowPerformance/RimVfpPlotCollection.h" #include "Riu3DMainWindowTools.h" -#include "RiuGuiTheme.h" #include "RiuMainWindow.h" #include "RiuViewer.h" #include "RiuViewerCommands.h" @@ -120,14 +109,8 @@ #include "cafUiProcess.h" #include "cafUtils.h" -#include "cvfProgramOptions.h" -#include "cvfqtUtils.h" - #include -#include -#include -#include #include #ifdef WIN32 @@ -1088,7 +1071,7 @@ QStringList RiaApplication::octaveArguments() const QStringList arguments; arguments.append( "--path" ); - arguments << QApplication::applicationDirPath(); + arguments << QCoreApplication::applicationDirPath(); if ( !m_preferences->octaveShowHeaderInfoWhenExecutingScripts() ) { @@ -1116,9 +1099,9 @@ QProcessEnvironment RiaApplication::octaveProcessEnvironment() const QString pathString = penv.value( "PATH", "" ); if ( pathString == "" ) - pathString = QApplication::applicationDirPath() + "\\octave_plugin_dependencies"; + pathString = QCoreApplication::applicationDirPath() + "\\octave_plugin_dependencies"; else - pathString = QApplication::applicationDirPath() + "\\octave_plugin_dependencies" + ";" + pathString; + pathString = QCoreApplication::applicationDirPath() + "\\octave_plugin_dependencies" + ";" + pathString; penv.insert( "PATH", pathString ); #else @@ -1126,9 +1109,9 @@ QProcessEnvironment RiaApplication::octaveProcessEnvironment() const QString ldPath = penv.value( "LD_LIBRARY_PATH", "" ); if ( ldPath == "" ) - ldPath = QApplication::applicationDirPath(); + ldPath = QCoreApplication::applicationDirPath(); else - ldPath = QApplication::applicationDirPath() + ":" + ldPath; + ldPath = QCoreApplication::applicationDirPath() + ":" + ldPath; penv.insert( "LD_LIBRARY_PATH", ldPath ); #endif @@ -1726,6 +1709,11 @@ RiaOsduConnector* RiaApplication::makeOsduConnector() //-------------------------------------------------------------------------------------------------- RiaSumoConnector* RiaApplication::makeSumoConnector() { + if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() ) + { + return nullptr; + } + if ( !m_sumoConnector ) { auto sumoPrefs = preferences()->sumoPreferences(); diff --git a/ApplicationLibCode/Application/RiaApplication.h b/ApplicationLibCode/Application/RiaApplication.h index c9e45cb537..ce0feaac55 100644 --- a/ApplicationLibCode/Application/RiaApplication.h +++ b/ApplicationLibCode/Application/RiaApplication.h @@ -184,8 +184,6 @@ class RiaApplication void executeCommandObjects(); void waitUntilCommandObjectsHasBeenProcessed(); - int launchUnitTests(); - const QString startDir() const; void setStartDir( const QString& startDir ); diff --git a/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp index 8569991aa0..0d1f5b309d 100644 --- a/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp @@ -73,6 +73,8 @@ std::vector RimCloudDataSourceCollection::sumoDataSou //-------------------------------------------------------------------------------------------------- void RimCloudDataSourceCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { + if ( !m_sumoConnector ) return; + if ( changedField == &m_sumoFieldName ) { m_sumoCaseId = ""; @@ -97,6 +99,8 @@ void RimCloudDataSourceCollection::fieldChangedByUi( const caf::PdmFieldHandle* //-------------------------------------------------------------------------------------------------- QList RimCloudDataSourceCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { + if ( !m_sumoConnector ) return {}; + QList options; if ( fieldNeedingOptions == &m_sumoFieldName ) { @@ -174,6 +178,8 @@ void RimCloudDataSourceCollection::defineEditorAttribute( const caf::PdmFieldHan //-------------------------------------------------------------------------------------------------- void RimCloudDataSourceCollection::addEnsemble() { + if ( !m_sumoConnector ) return; + RimSummarySumoDataSource* objectToSelect = nullptr; auto sumoCaseId = SumoCaseId( m_sumoCaseId ); diff --git a/ApplicationLibCode/UnitTests/main.cpp b/ApplicationLibCode/UnitTests/main.cpp index b6b01932b5..ac87d86c3a 100644 --- a/ApplicationLibCode/UnitTests/main.cpp +++ b/ApplicationLibCode/UnitTests/main.cpp @@ -19,6 +19,7 @@ #include "gtest/gtest.h" #include "RiaConsoleApplication.h" +#include "RiaRegressionTestRunner.h" #include @@ -27,6 +28,9 @@ //-------------------------------------------------------------------------------------------------- int main( int argc, char** argv ) { + // Create feature manager before the application object is created + RiaRegressionTestRunner::createSingleton(); + RiaApplication* app = new RiaConsoleApplication( argc, argv ); app->initialize(); From d8bd7bc81aa018ead905fd34d4c0966499519ec9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 23 Jul 2024 11:49:07 +0200 Subject: [PATCH 197/332] Cloud connector cleanup * Rename to RiaOAuthHttpServerReplyHandler * Add comment header * SUMO: Use function pointer to simplify network request --- .../Application/RiaCloudDefines.cpp | 8 ++ .../Application/RiaCloudDefines.h | 1 + .../Application/RiaOsduDefines.h | 2 - .../Tools/Cloud/CMakeLists_files.cmake | 6 +- .../Tools/Cloud/RiaCloudConnector.cpp | 20 +-- ...cpp => RiaOAuthHttpServerReplyHandler.cpp} | 6 +- ...ler.h => RiaOAuthHttpServerReplyHandler.h} | 4 +- .../Tools/Cloud/RiaOsduConnector.cpp | 67 +++++----- .../Tools/Cloud/RiaOsduConnector.h | 18 +++ .../Tools/Cloud/RiaSumoConnector.cpp | 125 ++++++++---------- .../Tools/Cloud/RiaSumoConnector.h | 5 +- .../Tools/Cloud/RiaSumoDefines.cpp | 2 +- 12 files changed, 141 insertions(+), 123 deletions(-) rename ApplicationLibCode/Application/Tools/Cloud/{RiaOsduOAuthHttpServerReplyHandler.cpp => RiaOAuthHttpServerReplyHandler.cpp} (77%) rename ApplicationLibCode/Application/Tools/Cloud/{RiaOsduOAuthHttpServerReplyHandler.h => RiaOAuthHttpServerReplyHandler.h} (88%) diff --git a/ApplicationLibCode/Application/RiaCloudDefines.cpp b/ApplicationLibCode/Application/RiaCloudDefines.cpp index 6c4516beb1..653599119c 100644 --- a/ApplicationLibCode/Application/RiaCloudDefines.cpp +++ b/ApplicationLibCode/Application/RiaCloudDefines.cpp @@ -33,3 +33,11 @@ QString RiaCloudDefines::contentTypeParquet() { return "application/x-parquet"; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiaCloudDefines::requestTokenTimeoutMillis() +{ + return 120 * 1000; +} diff --git a/ApplicationLibCode/Application/RiaCloudDefines.h b/ApplicationLibCode/Application/RiaCloudDefines.h index e384d1df95..9799aeb925 100644 --- a/ApplicationLibCode/Application/RiaCloudDefines.h +++ b/ApplicationLibCode/Application/RiaCloudDefines.h @@ -24,4 +24,5 @@ namespace RiaCloudDefines { QString contentTypeJson(); QString contentTypeParquet(); +int requestTokenTimeoutMillis(); }; // namespace RiaCloudDefines diff --git a/ApplicationLibCode/Application/RiaOsduDefines.h b/ApplicationLibCode/Application/RiaOsduDefines.h index 0b72ccd183..3db5f2f0ef 100644 --- a/ApplicationLibCode/Application/RiaOsduDefines.h +++ b/ApplicationLibCode/Application/RiaOsduDefines.h @@ -27,8 +27,6 @@ QString osduWellKind(); QString osduWellboreKind(); QString osduWellboreTrajectoryKind(); QString osduWellLogKind(); -QString contentTypeJson(); -QString contentTypeParquet(); QString tokenPath(); diff --git a/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake b/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake index 5a5a829a74..ccb2a99a36 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/Tools/Cloud/CMakeLists_files.cmake @@ -4,7 +4,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOAuthHttpServerReplyHandler.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -13,7 +13,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.cpp - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaOAuthHttpServerReplyHandler.cpp ) list( @@ -22,7 +22,7 @@ list( ${CMAKE_CURRENT_LIST_DIR}/RiaCloudConnector.h ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h - ${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h + ${CMAKE_CURRENT_LIST_DIR}/RiaOAuthHttpServerReplyHandler.h ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp index c9d9f5e04f..bf9c00ee37 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp @@ -18,28 +18,19 @@ #include "RiaCloudConnector.h" +#include "RiaCloudDefines.h" #include "RiaConnectorTools.h" #include "RiaLogging.h" -#include "RiaOsduDefines.h" -#include "RiaOsduOAuthHttpServerReplyHandler.h" -#include "RiaSumoDefines.h" +#include "RiaOAuthHttpServerReplyHandler.h" -#include -#include #include #include #include #include #include -#include #include -#include -#include -#include #include -#include #include -#include //-------------------------------------------------------------------------------------------------- /// @@ -89,15 +80,17 @@ RiaCloudConnector::RiaCloudConnector( QObject* parent, m_authCodeFlow->setClientIdentifier( m_clientId ); m_authCodeFlow->setScope( m_scopes ); - auto replyHandler = new RiaOsduOAuthHttpServerReplyHandler( port, this ); + auto replyHandler = new RiaOAuthHttpServerReplyHandler( port, this ); m_authCodeFlow->setReplyHandler( replyHandler ); RiaLogging::debug( "Server callback: " + replyHandler->callback() ); connect( m_authCodeFlow, SIGNAL( granted() ), this, SLOT( accessGranted() ) ); + connect( m_authCodeFlow, SIGNAL( error( const QString&, const QString&, const QUrl& ) ), this, SLOT( errorReceived( const QString&, const QString&, const QUrl& ) ) ); + connect( m_authCodeFlow, SIGNAL( authorizationCallbackReceived( const QVariantMap& ) ), this, @@ -277,8 +270,9 @@ QString RiaCloudConnector::requestTokenBlocking() connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) ); connect( &timer, SIGNAL( timeout() ), &loop, SLOT( quit() ) ); requestToken(); - timer.start( RiaSumoDefines::requestTimeoutMillis() ); + timer.start( RiaCloudDefines::requestTokenTimeoutMillis() ); loop.exec(); + return m_authCodeFlow->token(); } diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduOAuthHttpServerReplyHandler.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.cpp similarity index 77% rename from ApplicationLibCode/Application/Tools/Cloud/RiaOsduOAuthHttpServerReplyHandler.cpp rename to ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.cpp index 849ea56a78..8e35a6d9a6 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduOAuthHttpServerReplyHandler.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.cpp @@ -1,4 +1,4 @@ -#include "RiaOsduOAuthHttpServerReplyHandler.h" +#include "RiaOAuthHttpServerReplyHandler.h" #include #include @@ -8,7 +8,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaOsduOAuthHttpServerReplyHandler::RiaOsduOAuthHttpServerReplyHandler( quint16 port, QObject* parent ) +RiaOAuthHttpServerReplyHandler::RiaOAuthHttpServerReplyHandler( quint16 port, QObject* parent ) : QOAuthHttpServerReplyHandler( port, parent ) , m_port( port ) { @@ -17,7 +17,7 @@ RiaOsduOAuthHttpServerReplyHandler::RiaOsduOAuthHttpServerReplyHandler( quint16 //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaOsduOAuthHttpServerReplyHandler::callback() const +QString RiaOAuthHttpServerReplyHandler::callback() const { const QUrl url( QString::fromLatin1( "http://localhost:%1/" ).arg( m_port ) ); return url.toString( QUrl::EncodeDelimiters ); diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduOAuthHttpServerReplyHandler.h b/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h similarity index 88% rename from ApplicationLibCode/Application/Tools/Cloud/RiaOsduOAuthHttpServerReplyHandler.h rename to ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h index 4aaedd6e90..420ab30da6 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduOAuthHttpServerReplyHandler.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h @@ -25,11 +25,11 @@ //================================================================================================== /// //================================================================================================== -class RiaOsduOAuthHttpServerReplyHandler : public QOAuthHttpServerReplyHandler +class RiaOAuthHttpServerReplyHandler : public QOAuthHttpServerReplyHandler { Q_OBJECT public: - RiaOsduOAuthHttpServerReplyHandler( quint16 port, QObject* parent ); + RiaOAuthHttpServerReplyHandler( quint16 port, QObject* parent ); QString callback() const override; diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp index 96f315a171..d2f3fd0329 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp @@ -1,22 +1,30 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RiaOsduConnector.h" #include "RiaCloudDefines.h" #include "RiaLogging.h" #include "RiaOsduDefines.h" -#include "RiaOsduOAuthHttpServerReplyHandler.h" -#include #include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include #include @@ -312,10 +320,10 @@ QNetworkReply* RiaOsduConnector::makeSearchRequest( const std::mappost( m_networkRequest, strJson.toUtf8() ); + auto reply = m_networkAccessManager->post( networkRequest, strJson.toUtf8() ); return reply; } @@ -623,10 +631,9 @@ std::vector RiaOsduConnector::wellLogs( const QString& wellboreId ) QMutexLocker lock( &m_mutex ); auto it = m_wellLogs.find( wellboreId ); - if ( it != m_wellLogs.end() ) - return it->second; - else - return {}; + if ( it != m_wellLogs.end() ) return it->second; + + return {}; } //-------------------------------------------------------------------------------------------------- @@ -637,10 +644,9 @@ std::vector RiaOsduConnector::wellbores( const QString& wellId ) c QMutexLocker lock( &m_mutex ); auto it = m_wellbores.find( wellId ); - if ( it != m_wellbores.end() ) - return it->second; - else - return {}; + if ( it != m_wellbores.end() ) return it->second; + + return {}; } //-------------------------------------------------------------------------------------------------- @@ -651,10 +657,9 @@ QString RiaOsduConnector::wellIdForWellboreId( const QString& wellboreId ) const auto findWellIdForWellboreId = []( const std::vector& wellbores, const QString& wellboreId ) { auto it = std::find_if( wellbores.begin(), wellbores.end(), [wellboreId]( const OsduWellbore& w ) { return w.id == wellboreId; } ); - if ( it != wellbores.end() ) - return it->wellId; - else - return QString(); + if ( it != wellbores.end() ) return it->wellId; + + return QString(); }; QMutexLocker lock( &m_mutex ); @@ -677,10 +682,9 @@ std::vector RiaOsduConnector::wellboreTrajectories( cons QMutexLocker lock( &m_mutex ); auto it = m_wellboreTrajectories.find( wellboreId ); - if ( it != m_wellboreTrajectories.end() ) - return it->second; - else - return {}; + if ( it != m_wellboreTrajectories.end() ) return it->second; + + return {}; } //-------------------------------------------------------------------------------------------------- @@ -700,6 +704,7 @@ void RiaOsduConnector::requestWellLogParquetDataById( const QString& wellLogId ) { QString url = constructWellLogDownloadUrl( m_server, wellLogId ); RiaLogging::debug( "Well log URL: " + url ); + requestParquetDataByUrl( url, wellLogId ); } @@ -718,6 +723,7 @@ std::pair RiaOsduConnector::requestWellboreTrajectoryParque { QString url = constructWellboreTrajectoriesDownloadUrl( m_server, wellboreTrajectoryId ); RiaLogging::debug( "Wellbore trajectory URL: " + url ); + return requestParquetDataByUrlBlocking( url, wellboreTrajectoryId ); } @@ -728,6 +734,7 @@ std::pair RiaOsduConnector::requestWellLogParquetDataByIdBl { QString url = constructWellLogDownloadUrl( m_server, wellLogId ); RiaLogging::debug( "Well log URL: " + url ); + return requestParquetDataByUrlBlocking( url, wellLogId ); } diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h index 3efb2ba586..bbb4e2af85 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h @@ -1,3 +1,21 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RiaCloudConnector.h" diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index 68df3eae84..4875f1dbf3 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -19,28 +19,17 @@ #include "RiaSumoConnector.h" #include "RiaCloudDefines.h" -#include "RiaConnectorTools.h" #include "RiaLogging.h" +#include "RiaOAuthHttpServerReplyHandler.h" #include "RiaOsduDefines.h" -#include "RiaOsduOAuthHttpServerReplyHandler.h" -#include -#include #include #include #include #include #include #include -#include -#include -#include -#include -#include #include -#include -#include -#include //-------------------------------------------------------------------------------------------------- /// @@ -135,15 +124,10 @@ void RiaSumoConnector::requestCasesForField( const QString& fieldName ) //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestCasesForFieldBlocking( const QString& fieldName ) { - QEventLoop loop; - connect( this, SIGNAL( casesFinished() ), &loop, SLOT( quit() ) ); - QTimer timer; - - requestCasesForField( fieldName ); + auto requestCallable = [this, fieldName] { requestCasesForField( fieldName ); }; + auto signalCallable = [this]() { casesFinished(); }; - timer.setSingleShot( true ); - timer.start( RiaSumoDefines::requestTimeoutMillis() ); - loop.exec(); + wrapAndCallNetworkRequest( requestCallable, signalCallable ); } //-------------------------------------------------------------------------------------------------- @@ -176,15 +160,9 @@ void RiaSumoConnector::requestAssets() //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestAssetsBlocking() { - QEventLoop loop; - connect( this, SIGNAL( assetsFinished() ), &loop, SLOT( quit() ) ); - QTimer timer; - - requestAssets(); - - timer.setSingleShot( true ); - timer.start( RiaSumoDefines::requestTimeoutMillis() ); - loop.exec(); + auto requestCallable = [this] { requestAssets(); }; + auto signalCallable = [this]() { assetsFinished(); }; + wrapAndCallNetworkRequest( requestCallable, signalCallable ); } //-------------------------------------------------------------------------------------------------- @@ -192,6 +170,8 @@ void RiaSumoConnector::requestAssetsBlocking() //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestEnsembleByCasesId( const SumoCaseId& caseId ) { + requestTokenBlocking(); + QString payloadTemplate = R"( { @@ -239,15 +219,9 @@ void RiaSumoConnector::requestEnsembleByCasesId( const SumoCaseId& caseId ) //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestEnsembleByCasesIdBlocking( const SumoCaseId& caseId ) { - QEventLoop loop; - connect( this, SIGNAL( ensembleNamesFinished() ), &loop, SLOT( quit() ) ); - QTimer timer; - - requestEnsembleByCasesId( caseId ); - - timer.setSingleShot( true ); - timer.start( RiaSumoDefines::requestTimeoutMillis() ); - loop.exec(); + auto requestCallable = [this, caseId] { requestEnsembleByCasesId( caseId ); }; + auto signalCallable = [this]() { ensembleNamesFinished(); }; + wrapAndCallNetworkRequest( requestCallable, signalCallable ); } //-------------------------------------------------------------------------------------------------- @@ -255,6 +229,8 @@ void RiaSumoConnector::requestEnsembleByCasesIdBlocking( const SumoCaseId& caseI //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestVectorNamesForEnsemble( const SumoCaseId& caseId, const QString& ensembleName ) { + requestTokenBlocking(); + QString payloadTemplate = R"( { "track_total_hits": true, @@ -312,15 +288,10 @@ void RiaSumoConnector::requestVectorNamesForEnsemble( const SumoCaseId& caseId, //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestVectorNamesForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName ) { - QEventLoop loop; - connect( this, SIGNAL( vectorNamesFinished() ), &loop, SLOT( quit() ) ); - QTimer timer; - - requestVectorNamesForEnsemble( caseId, ensembleName ); + auto requestCallable = [this, caseId, ensembleName] { requestVectorNamesForEnsemble( caseId, ensembleName ); }; + auto signalCallable = [this]() { vectorNamesFinished(); }; - timer.setSingleShot( true ); - timer.start( RiaSumoDefines::requestTimeoutMillis() ); - loop.exec(); + wrapAndCallNetworkRequest( requestCallable, signalCallable ); } //-------------------------------------------------------------------------------------------------- @@ -381,15 +352,10 @@ void RiaSumoConnector::requestRealizationIdsForEnsemble( const SumoCaseId& caseI //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestRealizationIdsForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName ) { - QEventLoop loop; - connect( this, SIGNAL( realizationIdsFinished() ), &loop, SLOT( quit() ) ); - QTimer timer; - - requestRealizationIdsForEnsemble( caseId, ensembleName ); + auto requestCallable = [this, caseId, ensembleName] { requestRealizationIdsForEnsemble( caseId, ensembleName ); }; + auto signalCallable = [this]() { realizationIdsFinished(); }; - timer.setSingleShot( true ); - timer.start( RiaSumoDefines::requestTimeoutMillis() ); - loop.exec(); + wrapAndCallNetworkRequest( requestCallable, signalCallable ); } //-------------------------------------------------------------------------------------------------- @@ -397,6 +363,8 @@ void RiaSumoConnector::requestRealizationIdsForEnsembleBlocking( const SumoCaseI //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestBlobIdForEnsemble( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ) { + requestTokenBlocking(); + QString payloadTemplate = R"( { "track_total_hits": true, @@ -444,15 +412,9 @@ void RiaSumoConnector::requestBlobIdForEnsemble( const SumoCaseId& caseId, const //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestBlobIdForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ) { - QEventLoop loop; - connect( this, SIGNAL( blobIdFinished() ), &loop, SLOT( quit() ) ); - QTimer timer; - - requestBlobIdForEnsemble( caseId, ensembleName, vectorName ); - - timer.setSingleShot( true ); - timer.start( RiaSumoDefines::requestTimeoutMillis() ); - loop.exec(); + auto requestCallable = [this, caseId, ensembleName, vectorName] { requestBlobIdForEnsemble( caseId, ensembleName, vectorName ); }; + auto signalCallable = [this]() { blobIdFinished(); }; + wrapAndCallNetworkRequest( requestCallable, signalCallable ); } //-------------------------------------------------------------------------------------------------- @@ -460,6 +422,8 @@ void RiaSumoConnector::requestBlobIdForEnsembleBlocking( const SumoCaseId& caseI //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestBlobDownload( const QString& blobId ) { + requestTokenBlocking(); + QString url = constructDownloadUrl( m_server, blobId ); QNetworkRequest networkRequest; @@ -505,6 +469,8 @@ void RiaSumoConnector::requestBlobDownload( const QString& blobId ) //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestBlobByRedirectUri( const QString& blobId, const QString& redirectUri ) { + requestTokenBlocking(); + QNetworkRequest networkRequest; networkRequest.setUrl( redirectUri ); @@ -546,15 +512,16 @@ QByteArray RiaSumoConnector::requestParquetDataBlocking( const SumoCaseId& caseI auto blobId = m_blobUrl.back(); - QEventLoop loop; - connect( this, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ), &loop, SLOT( quit() ) ); - QTimer timer; + QEventLoop eventLoop; + QTimer timer; + timer.setSingleShot( true ); + QObject::connect( &timer, SIGNAL( timeout() ), &eventLoop, SLOT( quit() ) ); + QObject::connect( &timer, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ), &eventLoop, SLOT( quit() ) ); requestBlobDownload( blobId ); - timer.setSingleShot( true ); timer.start( RiaSumoDefines::requestTimeoutMillis() ); - loop.exec(); + eventLoop.exec(); for ( const auto& blobData : m_redirectInfo ) { @@ -584,6 +551,28 @@ QString RiaSumoConnector::constructDownloadUrl( const QString& server, const QSt // https: // main-sumo-prod.radix.equinor.com/api/v1/objects('76d6d11f-2278-3fe2-f12f-77142ad163c6')/blob } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::wrapAndCallNetworkRequest( std::function requestCallable, std::function signalCallable ) +{ + QEventLoop eventLoop; + + QTimer timer; + timer.setSingleShot( true ); + + QObject::connect( &timer, &QTimer::timeout, &eventLoop, &QEventLoop::quit ); + + // Not able to use the modern connect syntax here, as the signal is communicated as a std::function + QObject::connect( this, SIGNAL( signalCallable ), &eventLoop, SLOT( quit() ) ); + + // Call the function that will execute the request + requestCallable(); + + timer.start( RiaSumoDefines::requestTimeoutMillis() ); + eventLoop.exec(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h index 9dc9449a40..c067e0bf06 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h @@ -27,6 +27,8 @@ #include +class QEventLoop; + using SumoObjectId = QString; struct SumoAsset @@ -138,10 +140,11 @@ public slots: QNetworkReply* makeDownloadRequest( const QString& url, const QString& token, const QString& contentType ); void requestParquetData( const QString& url, const QString& token ); - // static QString generateRandomString( int length = 20 ); static QString constructSearchUrl( const QString& server ); static QString constructDownloadUrl( const QString& server, const QString& blobId ); + void wrapAndCallNetworkRequest( std::function requestCallable, std::function signalCallable ); + private: std::vector m_assets; std::vector m_cases; diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp index f4354485e6..7ad21eacc7 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp @@ -34,5 +34,5 @@ QString RiaSumoDefines::tokenPath() //-------------------------------------------------------------------------------------------------- int RiaSumoDefines::requestTimeoutMillis() { - return 120 * 1000; + return 1 * 1000; } From 337584025c0a550d714f2f60bfa71553f63306b1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 24 Jul 2024 10:23:05 +0200 Subject: [PATCH 198/332] Add convenience function to set number format to fixed with two decimals --- .../RimGridCrossPlotRegressionCurve.cpp | 7 +------ .../ProjectDataModel/RimDepthTrackPlot.cpp | 7 +------ .../StimPlanModel/RimStimPlanModel.cpp | 7 +------ .../StimPlanModel/RimStimPlanModelTemplate.cpp | 7 +------ .../cafUserInterface/cafPdmUiDoubleValueEditor.h | 15 +++++++++++++++ 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotRegressionCurve.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotRegressionCurve.cpp index a1197a59a9..54b9cd7dc7 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotRegressionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotRegressionCurve.cpp @@ -392,12 +392,7 @@ void RimGridCrossPlotRegressionCurve::defineEditorAttribute( const caf::PdmField } else if ( field == &m_minExtrapolationRangeX || field == &m_maxExtrapolationRangeX ) { - auto doubleAttr = dynamic_cast( attribute ); - if ( doubleAttr ) - { - doubleAttr->m_decimals = 2; - doubleAttr->m_numberFormat = caf::PdmUiDoubleValueEditorAttribute::NumberFormat::FIXED; - } + caf::PdmUiDoubleValueEditorAttribute::testAndSetFixedWithTwoDecimals( attribute ); } else if ( field == &m_expressionText ) diff --git a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp index 9a0f59a664..9fb0c84135 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp @@ -1228,12 +1228,7 @@ void RimDepthTrackPlot::defineEditorAttribute( const caf::PdmFieldHandle* field, { if ( field == &m_minVisibleDepth || field == &m_maxVisibleDepth ) { - auto doubleAttr = dynamic_cast( attribute ); - if ( doubleAttr ) - { - doubleAttr->m_decimals = 2; - doubleAttr->m_numberFormat = caf::PdmUiDoubleValueEditorAttribute::NumberFormat::FIXED; - } + caf::PdmUiDoubleValueEditorAttribute::testAndSetFixedWithTwoDecimals( attribute ); } } diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp index 84554e9cd3..7fc1ba1220 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp @@ -896,12 +896,7 @@ void RimStimPlanModel::defineEditorAttribute( const caf::PdmFieldHandle* field, { if ( field == &m_formationDip || field == &m_barrierDip || field == &m_distanceToBarrier ) { - auto doubleAttr = dynamic_cast( attribute ); - if ( doubleAttr ) - { - doubleAttr->m_decimals = 2; - doubleAttr->m_numberFormat = caf::PdmUiDoubleValueEditorAttribute::NumberFormat::FIXED; - } + caf::PdmUiDoubleValueEditorAttribute::testAndSetFixedWithTwoDecimals( attribute ); } if ( field == &m_MD ) diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.cpp index dead357728..5863d3d8ce 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.cpp @@ -307,12 +307,7 @@ void RimStimPlanModelTemplate::defineEditorAttribute( const caf::PdmFieldHandle* { if ( field == &m_stressDepth || field == &m_verticalStress ) { - auto doubleAttr = dynamic_cast( attribute ); - if ( doubleAttr ) - { - doubleAttr->m_decimals = 2; - doubleAttr->m_numberFormat = caf::PdmUiDoubleValueEditorAttribute::NumberFormat::FIXED; - } + caf::PdmUiDoubleValueEditorAttribute::testAndSetFixedWithTwoDecimals( attribute ); } if ( field == &m_faciesInitialPressureConfigs ) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.h index b03dc1d450..6c208a2397 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.h @@ -66,6 +66,21 @@ class PdmUiDoubleValueEditorAttribute : public PdmUiEditorAttribute m_numberFormat = NumberFormat::AUTOMATIC; } + void setFixedWithTwoDecimals() + { + m_decimals = 2; + m_numberFormat = NumberFormat::FIXED; + } + + // Convenience function to set the number format to fixed with two decimals + static void testAndSetFixedWithTwoDecimals( caf::PdmUiEditorAttribute* attr ) + { + if ( auto doubleAttr = dynamic_cast( attr ) ) + { + doubleAttr->setFixedWithTwoDecimals(); + } + } + public: int m_decimals; NumberFormat m_numberFormat; From 736bfd9a96218cbe35397e28fdd3e25447a3737d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 24 Jul 2024 10:25:42 +0200 Subject: [PATCH 199/332] Add Depth Surface Add Depth surface and initialize the location of the surface based on the first available grid model. Add feature to create Depth surface. --- .../SurfaceCommands/CMakeLists_files.cmake | 2 + .../RicNewDepthSurfaceFeature.cpp | 77 ++++++ .../RicNewDepthSurfaceFeature.h | 33 +++ .../RimContextCommandBuilder.cpp | 10 - .../Surfaces/CMakeLists_files.cmake | 2 + .../Surfaces/RimDepthSurface.cpp | 239 ++++++++++++++++++ .../Surfaces/RimDepthSurface.h | 59 +++++ .../ProjectDataModel/Surfaces/RimSurface.h | 7 +- .../Surfaces/RimSurfaceCollection.cpp | 15 ++ .../Surfaces/RimSurfaceCollection.h | 1 + 10 files changed, 432 insertions(+), 13 deletions(-) create mode 100644 ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp create mode 100644 ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.h create mode 100644 ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h diff --git a/ApplicationLibCode/Commands/SurfaceCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/SurfaceCommands/CMakeLists_files.cmake index 63e20f2e9b..72da9fcc1f 100644 --- a/ApplicationLibCode/Commands/SurfaceCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/SurfaceCommands/CMakeLists_files.cmake @@ -6,6 +6,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicExportKLayerToPtlFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicExportSurfaceToTsurfFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewSurfaceCollectionFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewDepthSurfaceFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -16,6 +17,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicExportKLayerToPtlFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportSurfaceToTsurfFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewSurfaceCollectionFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewDepthSurfaceFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp b/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp new file mode 100644 index 0000000000..fe51440dc5 --- /dev/null +++ b/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp @@ -0,0 +1,77 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RicNewDepthSurfaceFeature.h" + +#include "RimCase.h" +#include "RimDepthSurface.h" +#include "RimProject.h" +#include "RimSurface.h" +#include "RimSurfaceCollection.h" + +#include "Riu3DMainWindowTools.h" + +#include "cafSelectionManagerTools.h" + +#include "cvfBoundingBox.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewDepthSurfaceFeature, "RicNewDepthSurfaceFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewDepthSurfaceFeature::onActionTriggered( bool isChecked ) +{ + auto colls = caf::selectedObjectsByTypeStrict(); + if ( colls.empty() ) return; + + auto surface = new RimDepthSurface; + + auto allCases = RimProject::current()->allGridCases(); + if ( !allCases.empty() ) + { + auto sourceCase = allCases.front(); + auto bb = sourceCase->activeCellsBoundingBox(); + surface->setPlaneExtent( bb.min().x(), bb.min().y(), bb.max().x(), bb.max().y() ); + surface->setDepth( -bb.center().z() ); + + bb.expand( 0.1 * bb.extent().z() ); + + auto lowerDepthLimit = -bb.max().z(); + auto upperDepthLimit = -bb.min().z(); + surface->setDepthSliderLimits( lowerDepthLimit, upperDepthLimit ); + } + surface->loadDataIfRequired(); + + auto surfColl = colls.front(); + surfColl->addSurfacesAtIndex( -1, { surface } ); + surfColl->updateConnectedEditors(); + + Riu3DMainWindowTools::selectAsCurrentItem( surface ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewDepthSurfaceFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setIcon( QIcon( ":/ReservoirSurfaces16x16.png" ) ); + actionToSetup->setText( "Create Depth Surface" ); +} diff --git a/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.h b/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.h new file mode 100644 index 0000000000..58a6424c90 --- /dev/null +++ b/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicNewDepthSurfaceFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 2953a58d55..6c2e62cd0b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -146,7 +146,6 @@ #include "RimSummaryTableCollection.h" #include "RimSummaryTimeAxisProperties.h" #include "RimSurface.h" -#include "RimSurfaceCollection.h" #include "RimValveTemplate.h" #include "RimValveTemplateCollection.h" #include "RimViewController.h" @@ -1023,15 +1022,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicNewElasticPropertyScalingFeature"; } - else if ( dynamic_cast( firstUiItem ) ) - { - menuBuilder << "RicImportSurfacesFeature"; - menuBuilder << "RicNewGridSurfaceFeature"; - menuBuilder << "RicImportEnsembleSurfaceFeature"; - menuBuilder << "RicCreateEnsembleSurfaceFeature"; - menuBuilder.addSeparator(); - menuBuilder << "RicNewSurfaceCollectionFeature"; - } else if ( dynamic_cast( firstUiItem ) ) { if ( dynamic_cast( firstUiItem ) ) diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Surfaces/CMakeLists_files.cmake index 40d2d3b7fa..bc2b29ee77 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/CMakeLists_files.cmake @@ -8,6 +8,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSurfaceResultDefinition.h ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleSurface.h ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleStatisticsSurface.h + ${CMAKE_CURRENT_LIST_DIR}/RimDepthSurface.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -20,6 +21,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSurfaceResultDefinition.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleSurface.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleStatisticsSurface.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimDepthSurface.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp new file mode 100644 index 0000000000..18f6678fed --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp @@ -0,0 +1,239 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimDepthSurface.h" + +#include "RigSurface.h" + +#include "RimSurfaceCollection.h" + +#include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiDoubleSliderEditor.h" +#include "cafPdmUiDoubleValueEditor.h" + +#include "cvfVector3.h" + +CAF_PDM_SOURCE_INIT( RimDepthSurface, "RimDepthSurface" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimDepthSurface::RimDepthSurface() +{ + CAF_PDM_InitScriptableObject( "DepthSurface", ":/ReservoirSurface16x16.png" ); + + CAF_PDM_InitField( &m_minX, "MinX", 0.0, "Min X" ); + CAF_PDM_InitField( &m_maxX, "MaxX", 0.0, "Max X" ); + CAF_PDM_InitField( &m_minY, "MinY", 0.0, "Min Y" ); + CAF_PDM_InitField( &m_maxY, "MaxY", 0.0, "Min Y" ); + CAF_PDM_InitField( &m_depth, "Depth", 0.0, "Depth" ); + + CAF_PDM_InitField( &m_depthLowerLimit, "DepthLowerLimit", 0.0, "Lower Limit" ); + m_depthLowerLimit.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); + CAF_PDM_InitField( &m_depthUpperLimit, "DepthUpperLimit", 100000.0, "Upper Limit" ); + m_depthUpperLimit.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); + + m_minX.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); + m_maxX.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); + m_minY.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); + m_maxY.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); + m_depth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimDepthSurface::~RimDepthSurface() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimDepthSurface::onLoadData() +{ + return updateSurfaceData(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSurface* RimDepthSurface::createCopy() +{ + return copyObject(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDepthSurface::setPlaneExtent( double minX, double minY, double maxX, double maxY ) +{ + m_minX = minX; + m_minY = minY; + m_maxX = maxX; + m_maxY = maxY; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDepthSurface::setDepth( double depth ) +{ + m_depth = depth; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDepthSurface::setDepthSliderLimits( double lower, double upper ) +{ + m_depthLowerLimit = lower; + m_depthUpperLimit = upper; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDepthSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + RimSurface::fieldChangedByUi( changedField, oldValue, newValue ); + + clearCachedNativeData(); + updateSurfaceData(); + + auto surfColl = firstAncestorOrThisOfTypeAsserted(); + surfColl->updateViews( { this } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDepthSurface::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + caf::PdmUiDoubleValueEditorAttribute::testAndSetFixedWithTwoDecimals( attribute ); + + if ( field == &m_depth ) + { + if ( auto attr = dynamic_cast( attribute ) ) + { + attr->m_minimum = m_depthLowerLimit; + attr->m_maximum = m_depthUpperLimit; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDepthSurface::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_depth ); + + { + auto group = uiOrdering.addNewGroup( "Depth Limits" ); + group->setCollapsedByDefault(); + group->add( &m_depthLowerLimit ); + group->add( &m_depthUpperLimit ); + } + + { + auto group = uiOrdering.addNewGroup( "Extent" ); + group->add( &m_minX ); + group->add( &m_maxX ); + group->add( &m_minY ); + group->add( &m_maxY ); + } + + { + // Fields from RimSurface + + auto group = uiOrdering.addNewGroup( "Appearance" ); + group->add( &m_userDescription ); + group->add( &m_color ); + } + + uiOrdering.skipRemainingFields(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDepthSurface::clearCachedNativeData() +{ + m_vertices.clear(); + m_triangleIndices.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// Returns false for fatal failure +//-------------------------------------------------------------------------------------------------- +bool RimDepthSurface::updateSurfaceData() +{ + auto displayZ = -m_depth; + + cvf::Vec3d a( m_minX, m_minY, displayZ ); + cvf::Vec3d b( m_maxX, m_minY, displayZ ); + cvf::Vec3d c( m_maxX, m_maxY, displayZ ); + cvf::Vec3d d( m_minX, m_maxY, displayZ ); + + m_vertices.push_back( a ); + m_vertices.push_back( b ); + m_vertices.push_back( c ); + m_vertices.push_back( d ); + + m_triangleIndices.push_back( 0 ); + m_triangleIndices.push_back( 1 ); + m_triangleIndices.push_back( 2 ); + + m_triangleIndices.push_back( 0 ); + m_triangleIndices.push_back( 2 ); + m_triangleIndices.push_back( 3 ); + + if ( !m_triangleIndices.empty() ) + { + std::vector tringleIndices{ m_triangleIndices }; + std::vector vertices{ m_vertices }; + + cvf::Vec3d offset; + offset.z() += depthOffset(); + + RimSurface::applyDepthOffset( offset, &vertices ); + auto surfaceData = new RigSurface; + surfaceData->setTriangleData( tringleIndices, vertices ); + + setSurfaceData( surfaceData ); + } + else + { + setSurfaceData( nullptr ); + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// Return the name to show in the project tree +//-------------------------------------------------------------------------------------------------- +QString RimDepthSurface::fullName() const +{ + QString retval = RimSurface::fullName(); + if ( !retval.isEmpty() ) retval += " - "; + retval += "Depth: "; + retval += QString::number( m_depth ); + return retval; +} diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h new file mode 100644 index 0000000000..ac30150dd5 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimSurface.h" + +class RimDepthSurface : public RimSurface +{ + CAF_PDM_HEADER_INIT; + +public: + RimDepthSurface(); + ~RimDepthSurface() override; + + bool onLoadData() override; + RimSurface* createCopy() override; + + void setPlaneExtent( double minX, double minY, double maxX, double maxY ); + void setDepth( double depth ); + void setDepthSliderLimits( double lower, double upper ); + +private: + bool updateSurfaceData() override; + void clearCachedNativeData() override; + QString fullName() const override; + + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + +private: + caf::PdmField m_minX; + caf::PdmField m_maxX; + caf::PdmField m_minY; + caf::PdmField m_maxY; + + caf::PdmField m_depth; + caf::PdmField m_depthLowerLimit; + caf::PdmField m_depthUpperLimit; + + std::vector m_triangleIndices; + std::vector m_vertices; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.h index 9f963db466..64e433769f 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.h @@ -80,11 +80,12 @@ class RimSurface : public caf::PdmObject virtual void clearCachedNativeData() = 0; protected: + caf::PdmField m_userDescription; + caf::PdmField m_color; + cvf::ref m_surfaceData; private: - caf::PdmField m_userDescription; - caf::PdmField m_color; - caf::PdmField m_depthOffset; caf::PdmProxyValueField m_nameProxy; + caf::PdmField m_depthOffset; }; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp index c26cc39498..0e668da9b1 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp @@ -37,6 +37,7 @@ #include "cafPdmFieldReorderCapability.h" +#include "cafCmdFeatureMenuBuilder.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" @@ -274,6 +275,20 @@ std::vector RimSurfaceCollection::subCollections() const return m_subCollections.childrenByType(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSurfaceCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder << "RicImportSurfacesFeature"; + menuBuilder << "RicNewGridSurfaceFeature"; + menuBuilder << "RicNewDepthSurfaceFeature"; + menuBuilder << "RicImportEnsembleSurfaceFeature"; + menuBuilder << "RicCreateEnsembleSurfaceFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicNewSurfaceCollectionFeature"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.h index b452145664..d8c554f390 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.h @@ -71,6 +71,7 @@ class RimSurfaceCollection : public caf::PdmObject protected: caf::PdmFieldHandle* userDescriptionField() override; + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; private: void orderChanged( const caf::SignalEmitter* emitter ); From 3164b392253fab2b9e9b7e140e695cd40093d543 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 20 Jun 2024 08:34:05 +0200 Subject: [PATCH 200/332] Allow hiding of category name in color legend item --- .../RicInsertColorLegendItemFeature.cpp | 11 ++++----- .../ProjectDataModel/RimColorLegendItem.cpp | 9 +++++++ .../ProjectDataModel/RimColorLegendItem.h | 2 ++ .../RimCustomVfpPlot.cpp | 24 +++++++++++++++++++ .../RimCustomVfpPlot.h | 2 ++ 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/ApplicationLibCode/Commands/ColorLegendCommands/RicInsertColorLegendItemFeature.cpp b/ApplicationLibCode/Commands/ColorLegendCommands/RicInsertColorLegendItemFeature.cpp index 6951af9a67..3da469712f 100644 --- a/ApplicationLibCode/Commands/ColorLegendCommands/RicInsertColorLegendItemFeature.cpp +++ b/ApplicationLibCode/Commands/ColorLegendCommands/RicInsertColorLegendItemFeature.cpp @@ -38,15 +38,12 @@ CAF_CMD_SOURCE_INIT( RicInsertColorLegendItemFeature, "RicInsertColorLegendItemF bool RicInsertColorLegendItemFeature::isCommandEnabled() const { RimColorLegend* legend = selectedColorLegend(); + if ( !legend ) return false; - if ( legend ) - { - RimColorLegendCollection* colorLegendCollection = legend->firstAncestorOrThisOfType(); - - if ( colorLegendCollection && !colorLegendCollection->isStandardColorLegend( legend ) ) return true; - } + RimColorLegendCollection* colorLegendCollection = legend->firstAncestorOrThisOfType(); + if ( !colorLegendCollection ) return true; - return false; + return !colorLegendCollection->isStandardColorLegend( legend ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.cpp b/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.cpp index 902ea74c26..692d4e46ec 100644 --- a/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.cpp @@ -58,6 +58,15 @@ RimColorLegendItem::~RimColorLegendItem() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimColorLegendItem::setCategoryFieldsHidden( bool hidden ) +{ + m_categoryName.uiCapability()->setUiHidden( hidden ); + m_categoryValue.uiCapability()->setUiHidden( hidden ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.h b/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.h index d6318881ef..f7d899f7ef 100644 --- a/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.h +++ b/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.h @@ -41,6 +41,8 @@ class RimColorLegendItem : public caf::PdmObject RimColorLegendItem(); ~RimColorLegendItem() override; + void setCategoryFieldsHidden( bool hidden ); + void setValues( const QString& categoryName, int categoryValue, const cvf::Color3f& color ); void setCategoryValue( int categoryValue ); void setReadOnly( bool doReadOnly ); diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp index 7a862a57df..a2920a4e90 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp @@ -250,6 +250,8 @@ void RimCustomVfpPlot::createDefaultColors() } m_legendConfig->setColorLegend( m_colorLegend ); + + setColorItemCategoryHidden(); } //-------------------------------------------------------------------------------------------------- @@ -712,6 +714,14 @@ void RimCustomVfpPlot::onLoadDataAndUpdate() m_plotWidget->scheduleReplot(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::initAfterRead() +{ + setColorItemCategoryHidden(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1127,6 +1137,20 @@ void RimCustomVfpPlot::legendColorsChanged( const caf::SignalEmitter* emitter ) onLoadDataAndUpdate(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCustomVfpPlot::setColorItemCategoryHidden() +{ + if ( m_colorLegend ) + { + for ( auto item : m_colorLegend->colorLegendItems() ) + { + item->setCategoryFieldsHidden( true ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h index 521b5449f4..71c5e4de5f 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.h @@ -96,6 +96,7 @@ class RimCustomVfpPlot : public RimPlot void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) override; void deleteViewWidget() override; void onLoadDataAndUpdate() override; + void initAfterRead() override; caf::PdmFieldHandle* userDescriptionField() override; @@ -180,6 +181,7 @@ class RimCustomVfpPlot : public RimPlot caf::ColorTable curveColors() const; void legendColorsChanged( const caf::SignalEmitter* emitter ); + void setColorItemCategoryHidden(); private: caf::PdmField m_plotTitle; From 2680611a7afa8dba522c1ef627edcf73d1258efd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 20 Jun 2024 09:55:27 +0200 Subject: [PATCH 201/332] Use latest buildcache version --- .github/workflows/ResInsightWithCache.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 91416c8a0f..4dfa3126dd 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -9,7 +9,6 @@ on: - cron: '0 1 * * *' env: BUILD_TYPE: Release - BUILDCACHE_VERSION: 0.27.6 BUILDCACHE_DIR: ${{ github.workspace }}/buildcache_dir BUILDCACHE_ACCURACY: SLOPPY VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" @@ -109,8 +108,7 @@ jobs: set(buildcache_suffix "linux.tar.gz") endif() - set(buildcache_version $ENV{BUILDCACHE_VERSION}) - set(buildcache_url "https://github.com/mbitsnbites/buildcache/releases/download/v${buildcache_version}/buildcache-${buildcache_suffix}") + set(buildcache_url "https://gitlab.com/bits-n-bites/buildcache/-/releases/permalink/latest/downloads/buildcache-${buildcache_suffix}") file(DOWNLOAD "${buildcache_url}" ./buildcache.zip) execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./buildcache.zip) From 34e30b38d3c754474815a69a62ac7a07a4c1c03d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 23 Jul 2024 14:10:18 +0200 Subject: [PATCH 202/332] #11372 Make sure regression curves can be resampled Make sure a regression curve based on observed data can be resampled. Split display of curves, one section for resampled curves and one section for observed curves without resampling. --- .../RicShowPlotDataFeature.cpp | 10 ++----- .../Summary/RimSummaryCurvesData.cpp | 3 ++ .../Summary/RimSummaryPlot.cpp | 29 +++++++++---------- .../ProjectDataModel/Summary/RimSummaryPlot.h | 2 -- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp index 7aee55ec6d..8f7df9de98 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp @@ -87,15 +87,9 @@ class RiuTabbedSummaryPlotTextProvider : public RiuTabbedTextProvider CVF_ASSERT( m_summaryPlot.notNull() && "Need to check that provider is valid" ); RiaDefines::DateTimePeriod timePeriod = indexToPeriod( tabIndex ); + RiaPreferencesSummary* prefs = RiaPreferencesSummary::current(); - if ( m_summaryPlot->containsResamplableCurves() ) - { - RiaPreferencesSummary* prefs = RiaPreferencesSummary::current(); - - return m_summaryPlot->asciiDataForSummaryPlotExport( timePeriod, prefs->showSummaryTimeAsLongString() ); - } - - return m_summaryPlot->asciiDataForSummaryPlotExport( RiaDefines::DateTimePeriod::NONE, true ); + return m_summaryPlot->asciiDataForSummaryPlotExport( timePeriod, prefs->showSummaryTimeAsLongString() ); } int tabCount() const override { return (int)tabs().size(); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp index 24d7841dae..753fde3009 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp @@ -234,6 +234,9 @@ void RimSummaryCurvesData::populateSummaryCurvesData( std::vectorsummaryCaseY() ? curve->summaryCaseY()->isObservedData() : false; + // Make sure a regression curve can be resampled https://github.com/OPM/ResInsight/issues/11372 + if ( curve->isRegressionCurve() ) isObservedCurve = false; + if ( !curve->isChecked() ) continue; if ( isObservedCurve && ( curveType != SummaryCurveType::CURVE_TYPE_OBSERVED ) ) continue; if ( !isObservedCurve && ( curveType != SummaryCurveType::CURVE_TYPE_GRID ) ) continue; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 0e76314dd0..c355fac7c4 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -333,12 +333,18 @@ QString RimSummaryPlot::asciiDataForSummaryPlotExport( RiaDefines::DateTimePerio std::vector crossPlotCurves; std::vector curves; + std::vector observedCurves; + for ( auto c : allCurves ) { if ( c->axisTypeX() == RiaDefines::HorizontalAxisType::SUMMARY_VECTOR ) { crossPlotCurves.push_back( c ); } + else if ( c->summaryCaseY() && c->summaryCaseY()->isObservedData() && !c->isRegressionCurve() ) + { + observedCurves.push_back( c ); + } else { curves.push_back( c ); @@ -348,7 +354,14 @@ QString RimSummaryPlot::asciiDataForSummaryPlotExport( RiaDefines::DateTimePerio auto gridCurves = m_gridTimeHistoryCurves.childrenByType(); auto asciiCurves = m_asciiDataCurves.childrenByType(); - QString text = RimSummaryCurvesData::createTextForExport( curves, asciiCurves, gridCurves, resamplingPeriod, showTimeAsLongString ); + QString text; + text += RimSummaryCurvesData::createTextForExport( curves, asciiCurves, gridCurves, resamplingPeriod, showTimeAsLongString ); + + if ( !observedCurves.empty() ) + { + text += "\n\n------------ Observed Curves --------------"; + text += RimSummaryCurvesData::createTextForExport( observedCurves, {}, {}, RiaDefines::DateTimePeriod::NONE, showTimeAsLongString ); + } text += RimSummaryCurvesData::createTextForCrossPlotCurves( crossPlotCurves ); @@ -722,20 +735,6 @@ void RimSummaryPlot::updatePlotInfoLabel() showPlotInfoLabel( anyCurveSetFiltered ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimSummaryPlot::containsResamplableCurves() const -{ - std::vector summaryCurves = summaryAndEnsembleCurves(); - size_t resamplableSummaryCurveCount = - std::count_if( summaryCurves.begin(), - summaryCurves.end(), - []( RimSummaryCurve* curve ) { return curve->summaryCaseY() ? !curve->summaryCaseY()->isObservedData() : false; } ); - - return !m_gridTimeHistoryCurves.empty() || resamplableSummaryCurveCount > 0; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h index 5c340e22e0..913ec48b9c 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -168,8 +168,6 @@ class RimSummaryPlot : public RimPlot, public RimSummaryDataSourceStepping void showPlotInfoLabel( bool show ); void updatePlotInfoLabel(); - bool containsResamplableCurves() const; - size_t singleColorCurveCount() const; void applyDefaultCurveAppearances(); void applyDefaultCurveAppearances( std::vector curvesToUpdate ); From 33ffa10ec97e5065b2db6f2d8eb0990fb35bd6bc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Jul 2024 13:58:31 +0200 Subject: [PATCH 203/332] Janitor: Remove obsolete deleteChildren Remove obsolete deleteChildren() in destructors. deleteChildren() is called in the destructor of PdmChildArrayField --- .../ExportCommands/RicExportToLasFileResampleUi.cpp | 8 -------- .../ExportCommands/RicExportToLasFileResampleUi.h | 1 - .../Commands/OsduImportCommands/RimOilFieldEntry.cpp | 8 -------- .../Commands/OsduImportCommands/RimOilFieldEntry.h | 1 - .../Commands/OsduImportCommands/RimOilRegionEntry.cpp | 8 -------- .../Commands/OsduImportCommands/RimOilRegionEntry.h | 1 - .../Commands/OsduImportCommands/RimWellPathImport.cpp | 8 -------- .../Commands/OsduImportCommands/RimWellPathImport.h | 1 - .../CellFilters/RimEclipsePropertyFilterCollection.cpp | 8 -------- .../CellFilters/RimEclipsePropertyFilterCollection.h | 1 - .../CellFilters/RimGeoMechPropertyFilterCollection.cpp | 8 -------- .../CellFilters/RimGeoMechPropertyFilterCollection.h | 1 - .../Completions/Rim3dWellLogCurveCollection.cpp | 8 -------- .../Completions/Rim3dWellLogCurveCollection.h | 1 - .../Completions/RimFractureTemplateCollection.cpp | 8 -------- .../Completions/RimFractureTemplateCollection.h | 1 - .../Completions/RimPerforationCollection.cpp | 8 -------- .../Completions/RimPerforationCollection.h | 1 - .../Completions/RimSimWellFractureCollection.cpp | 8 -------- .../Completions/RimSimWellFractureCollection.h | 1 - .../Faults/RimFaultInViewCollection.cpp | 8 -------- .../ProjectDataModel/Faults/RimFaultInViewCollection.h | 1 - .../ProjectDataModel/Flow/RimFlowPlotCollection.cpp | 2 -- .../Intersections/RimIntersectionCollection.cpp | 9 --------- .../Intersections/RimIntersectionCollection.h | 1 - .../ProjectDataModel/RimCaseCollection.cpp | 8 -------- .../ProjectDataModel/RimCaseCollection.h | 3 --- .../RimEclipseInputPropertyCollection.cpp | 8 -------- .../RimEclipseInputPropertyCollection.h | 1 - .../ProjectDataModel/RimEclipseResultCase.cpp | 2 -- .../RimEclipseStatisticsCaseCollection.cpp | 8 -------- .../RimEclipseStatisticsCaseCollection.h | 1 - .../ProjectDataModel/RimFormationNamesCollection.cpp | 8 -------- .../ProjectDataModel/RimFormationNamesCollection.h | 1 - .../ProjectDataModel/RimObservedDataCollection.cpp | 10 ---------- .../ProjectDataModel/RimObservedDataCollection.h | 1 - .../ProjectDataModel/RimPltPlotCollection.cpp | 8 -------- .../ProjectDataModel/RimPltPlotCollection.h | 1 - .../RimReservoirCellResultsStorage.cpp | 8 -------- .../ProjectDataModel/RimReservoirCellResultsStorage.h | 1 - .../ProjectDataModel/RimRftPlotCollection.cpp | 8 -------- .../ProjectDataModel/RimRftPlotCollection.h | 1 - .../ProjectDataModel/RimScriptCollection.cpp | 9 --------- .../ProjectDataModel/RimScriptCollection.h | 1 - .../ProjectDataModel/RimSimWellInViewCollection.cpp | 8 -------- .../ProjectDataModel/RimSimWellInViewCollection.h | 1 - .../RimElasticPropertyScalingCollection.cpp | 8 -------- .../RimElasticPropertyScalingCollection.h | 1 - .../StimPlanModel/RimStimPlanModelPlotCollection.cpp | 8 -------- .../StimPlanModel/RimStimPlanModelPlotCollection.h | 1 - .../RimStimPlanModelTemplateCollection.cpp | 8 -------- .../StimPlanModel/RimStimPlanModelTemplateCollection.h | 1 - .../Summary/RimEnsembleCurveSetCollection.cpp | 8 -------- .../Summary/RimEnsembleCurveSetCollection.h | 1 - .../Summary/RimSummaryCurveCollection.cpp | 8 -------- .../Summary/RimSummaryCurveCollection.h | 1 - .../WellLog/RimEnsembleWellLogsCollection.cpp | 8 -------- .../WellLog/RimEnsembleWellLogsCollection.h | 1 - .../ProjectDataModel/WellLog/RimOsduWellLog.cpp | 8 -------- .../ProjectDataModel/WellLog/RimOsduWellLog.h | 1 - .../ProjectDataModel/WellLog/RimWellLogCsvFile.cpp | 8 -------- .../ProjectDataModel/WellLog/RimWellLogCsvFile.h | 1 - .../ProjectDataModel/WellLog/RimWellLogLasFile.cpp | 8 -------- .../ProjectDataModel/WellLog/RimWellLogLasFile.h | 1 - .../cafPdmScriptingBasicTest.cpp | 4 ---- .../cafPdmCore/cafPdmCore_UnitTests/Parent.cpp | 1 - .../cafPdmChildArrayFieldHandleTest.cpp | 6 ------ .../cafPdmCore_UnitTests/cafPdmReferenceHelperTest.cpp | 6 +----- .../cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp | 8 +------- .../cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp | 4 ---- .../cafPdmUiTreeViewModelTest.cpp | 2 -- 71 files changed, 2 insertions(+), 318 deletions(-) diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp index c2dfb84fa1..9c5d9c5c87 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp @@ -78,14 +78,6 @@ RicExportToLasFileResampleUi::RicExportToLasFileResampleUi() updateFieldVisibility(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RicExportToLasFileResampleUi::~RicExportToLasFileResampleUi() -{ - m_tvdrkbOffsets.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.h b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.h index 054ac0c58b..70c253a204 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.h @@ -53,7 +53,6 @@ class RicExportToLasFileResampleUi : public caf::PdmObject public: RicExportToLasFileResampleUi(); - ~RicExportToLasFileResampleUi() override; caf::PdmField exportFolder; caf::PdmField filePrefix; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.cpp index 53c310dd79..e3410cb72d 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.cpp @@ -47,14 +47,6 @@ RimOilFieldEntry::RimOilFieldEntry() wells.uiCapability()->setUiTreeChildrenHidden( true ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimOilFieldEntry::~RimOilFieldEntry() -{ - wells.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.h b/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.h index 08278a52dd..b0c71c6706 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.h @@ -30,7 +30,6 @@ class RimOilFieldEntry : public caf::PdmObject public: RimOilFieldEntry(); - ~RimOilFieldEntry() override; caf::PdmField name; caf::PdmField edmId; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.cpp index 7a3b7b355b..bc8875233b 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.cpp @@ -35,14 +35,6 @@ RimOilRegionEntry::RimOilRegionEntry() CAF_PDM_InitField( &selected, "Selected", false, "Selected" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimOilRegionEntry::~RimOilRegionEntry() -{ - fields.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.h b/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.h index 9a564086d5..897286bb56 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.h @@ -30,7 +30,6 @@ class RimOilRegionEntry : public caf::PdmObject public: RimOilRegionEntry(); - ~RimOilRegionEntry() override; caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* objectToggleField() override; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp index b384171f4f..f78dc3edc9 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp @@ -103,11 +103,3 @@ void RimWellPathImport::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel updateFieldVisibility(); } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPathImport::~RimWellPathImport() -{ - regions_OBSOLETE.deleteChildren(); -} diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h index bb4ad472a9..abaf3f0a09 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h @@ -39,7 +39,6 @@ class RimWellPathImport : public caf::PdmObject public: RimWellPathImport(); - ~RimWellPathImport() override; caf::PdmField> utmFilterMode; caf::PdmField north; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp index 231d522db8..3774fedfa0 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp @@ -43,14 +43,6 @@ RimEclipsePropertyFilterCollection::RimEclipsePropertyFilterCollection() CAF_PDM_InitFieldNoDefault( &m_propertyFilters, "PropertyFilters", "Property Filters" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimEclipsePropertyFilterCollection::~RimEclipsePropertyFilterCollection() -{ - m_propertyFilters.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.h index 00035095b8..594c070c13 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.h @@ -37,7 +37,6 @@ class RimEclipsePropertyFilterCollection : public RimPropertyFilterCollection public: RimEclipsePropertyFilterCollection(); - ~RimEclipsePropertyFilterCollection() override; RimEclipseView* reservoirView(); void setIsDuplicatedFromLinkedView(); diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp index 432025ca8f..7b24077c07 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp @@ -39,14 +39,6 @@ RimGeoMechPropertyFilterCollection::RimGeoMechPropertyFilterCollection() CAF_PDM_InitFieldNoDefault( &propertyFilters, "PropertyFilters", "Property Filters" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimGeoMechPropertyFilterCollection::~RimGeoMechPropertyFilterCollection() -{ - propertyFilters.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.h index 4bedbff51c..5b9bf413fb 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.h @@ -38,7 +38,6 @@ class RimGeoMechPropertyFilterCollection : public RimPropertyFilterCollection public: RimGeoMechPropertyFilterCollection(); - ~RimGeoMechPropertyFilterCollection() override; RimGeoMechView* reservoirView(); diff --git a/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index 920664f8c8..c7564e1c5d 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -44,14 +44,6 @@ Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() CAF_PDM_InitFieldNoDefault( &m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -Rim3dWellLogCurveCollection::~Rim3dWellLogCurveCollection() -{ - m_3dWellLogCurves.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index d53153b484..16190587aa 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -37,7 +37,6 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject public: Rim3dWellLogCurveCollection(); - ~Rim3dWellLogCurveCollection() override; bool has3dWellLogCurves() const; void add3dWellLogCurve( Rim3dWellLogCurve* curve ); diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 9a1b4c8605..be51962b32 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -54,14 +54,6 @@ RimFractureTemplateCollection::RimFractureTemplateCollection() m_nextValidFractureTemplateId.uiCapability()->setUiHidden( true ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimFractureTemplateCollection::~RimFractureTemplateCollection() -{ - m_fractureDefinitions.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index b8681eb64a..2729aee506 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -37,7 +37,6 @@ class RimFractureTemplateCollection : public caf::PdmObject public: RimFractureTemplateCollection(); - ~RimFractureTemplateCollection() override; RimFractureTemplate* fractureTemplate( int id ) const; std::vector fractureTemplates() const; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.cpp index eb72cc800f..2a2c0483b4 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.cpp @@ -55,14 +55,6 @@ RimPerforationCollection::RimPerforationCollection() m_nonDarcyParameters.uiCapability()->setUiTreeChildrenHidden( true ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPerforationCollection::~RimPerforationCollection() -{ - m_perforations.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.h b/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.h index b8db71201a..bc9e6c4074 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.h @@ -40,7 +40,6 @@ class RimPerforationCollection : public RimCheckableNamedObject public: RimPerforationCollection(); - ~RimPerforationCollection() override; bool hasPerforations() const; const RimNonDarcyPerforationParameters* nonDarcyParameters() const; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp index 627f50bfc8..f3664e4a2a 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp @@ -35,14 +35,6 @@ RimSimWellFractureCollection::RimSimWellFractureCollection() setDeletable( true ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSimWellFractureCollection::~RimSimWellFractureCollection() -{ - simwellFractures.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h b/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h index 28d646e768..d262139bca 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h @@ -34,7 +34,6 @@ class RimSimWellFractureCollection : public caf::PdmObject public: RimSimWellFractureCollection(); - ~RimSimWellFractureCollection() override; caf::PdmChildArrayField simwellFractures; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp index d203a33482..f8143e5c5e 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp @@ -102,14 +102,6 @@ RimFaultInViewCollection::RimFaultInViewCollection() m_showFaultsOutsideFilters_obsolete.uiCapability()->setUiHidden( true ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimFaultInViewCollection::~RimFaultInViewCollection() -{ - m_faults.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h index 374d37fc32..0365c9fa5c 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h @@ -52,7 +52,6 @@ class RimFaultInViewCollection : public caf::PdmObject public: RimFaultInViewCollection(); - ~RimFaultInViewCollection() override; bool isActive() const; void setActive( bool bActive ); diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp index 6c11e5468d..a673ecae8d 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp @@ -57,8 +57,6 @@ RimFlowPlotCollection::RimFlowPlotCollection() RimFlowPlotCollection::~RimFlowPlotCollection() { delete m_defaultWellAllocPlot(); - - m_storedWellAllocPlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp index 8781b96c4f..fad6e63760 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp @@ -79,15 +79,6 @@ RimIntersectionCollection::RimIntersectionCollection() CAF_PDM_InitField( &m_applyCellFilters, "ApplyCellFilters", true, "Use Cell Filters for Intersections" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimIntersectionCollection::~RimIntersectionCollection() -{ - m_intersections.deleteChildren(); - m_intersectionBoxes.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h index 7e6eb07ee8..697f749543 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h @@ -53,7 +53,6 @@ class RimIntersectionCollection : public caf::PdmObject public: RimIntersectionCollection(); - ~RimIntersectionCollection() override; void appendIntersectionAndUpdate( RimExtrudedCurveIntersection* intersection, bool allowActiveViewChange = true ); void appendIntersectionNoUpdate( RimExtrudedCurveIntersection* intersection ); diff --git a/ApplicationLibCode/ProjectDataModel/RimCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimCaseCollection.cpp index 73d94d2748..4a90f23926 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCaseCollection.cpp @@ -35,14 +35,6 @@ RimCaseCollection::RimCaseCollection() CAF_PDM_InitFieldNoDefault( &reservoirs, "Reservoirs", "Reservoirs ChildArrayField" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimCaseCollection::~RimCaseCollection() -{ - reservoirs.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimCaseCollection.h b/ApplicationLibCode/ProjectDataModel/RimCaseCollection.h index a85fe393b4..56d7052a83 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimCaseCollection.h @@ -36,11 +36,8 @@ class RimCaseCollection : public caf::PdmObject public: RimCaseCollection(); - ~RimCaseCollection() override; caf::PdmChildArrayField reservoirs; RimIdenticalGridCaseGroup* parentCaseGroup(); RimEclipseCase* findByDescription( const QString& caseDescription ) const; - -private: }; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp index b261ec1166..0d4aa4aeaf 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp @@ -36,14 +36,6 @@ RimEclipseInputPropertyCollection::RimEclipseInputPropertyCollection() CAF_PDM_InitFieldNoDefault( &inputProperties, "InputProperties", "" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimEclipseInputPropertyCollection::~RimEclipseInputPropertyCollection() -{ - inputProperties.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// Returns the InputProperties pointing to the same file as \a fileName //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.h b/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.h index 7e6e2e8516..f5eae1cd8a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.h @@ -39,7 +39,6 @@ class RimEclipseInputPropertyCollection : public caf::PdmObject public: RimEclipseInputPropertyCollection(); - ~RimEclipseInputPropertyCollection() override; std::vector findInputProperties( QString fileName ); RimEclipseInputProperty* findInputProperty( QString resultName ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp index 2ad964e321..28604204a3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -510,8 +510,6 @@ RimEclipseResultCase::~RimEclipseResultCase() { if ( v ) v->setComparisonView( nullptr ); } - - m_flowDiagSolutions.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.cpp index 55b5f12057..087507928c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.cpp @@ -36,14 +36,6 @@ RimEclipseStatisticsCaseCollection::RimEclipseStatisticsCaseCollection() CAF_PDM_InitFieldNoDefault( &cases, "Reservoirs", "" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimEclipseStatisticsCaseCollection::~RimEclipseStatisticsCaseCollection() -{ - cases.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.h b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.h index fcf5eef8b1..e8bb28c12b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.h @@ -40,7 +40,6 @@ class RimEclipseStatisticsCaseCollection : public caf::PdmObject public: RimEclipseStatisticsCaseCollection(); - ~RimEclipseStatisticsCaseCollection() override; caf::PdmChildArrayField cases; diff --git a/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.cpp index 3925ea453c..f9b7f14a4f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.cpp @@ -36,14 +36,6 @@ RimFormationNamesCollection::RimFormationNamesCollection() setDeletable( true ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimFormationNamesCollection::~RimFormationNamesCollection() -{ - m_formationNamesList.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.h b/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.h index 21f5aa6888..1a3f165da7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.h @@ -31,7 +31,6 @@ class RimFormationNamesCollection : public caf::PdmObject public: RimFormationNamesCollection(); - ~RimFormationNamesCollection() override; const caf::PdmChildArrayField& formationNamesList() const { return m_formationNamesList; } diff --git a/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp index 73dabb85e8..b3649ae8d0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp @@ -58,16 +58,6 @@ RimObservedDataCollection::RimObservedDataCollection() CAF_PDM_InitFieldNoDefault( &m_observedPressureDepthArray, "PressureDepthDataArray", "" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimObservedDataCollection::~RimObservedDataCollection() -{ - m_observedDataArray.deleteChildren(); - m_observedFmuRftArray.deleteChildren(); - m_observedPressureDepthArray.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.h b/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.h index 3b2bee93b7..c6b573c782 100644 --- a/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.h @@ -34,7 +34,6 @@ class RimObservedDataCollection : public caf::PdmObject public: RimObservedDataCollection(); - ~RimObservedDataCollection() override; void removeObservedSummaryData( RimObservedSummaryData* observedSummaryData ); void removeObservedFmuRftData( RimObservedFmuRftData* observedFmuRftData ); diff --git a/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.cpp index 3b7a0deb49..2d29e8a557 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.cpp @@ -44,14 +44,6 @@ RimPltPlotCollection::RimPltPlotCollection() CAF_PDM_InitFieldNoDefault( &m_pltPlots, "PltPlots", "" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPltPlotCollection::~RimPltPlotCollection() -{ - m_pltPlots.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.h b/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.h index 60a59e477d..320a219778 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.h @@ -50,7 +50,6 @@ class RimPltPlotCollection : public caf::PdmObject, public RimPlotCollection public: RimPltPlotCollection(); - ~RimPltPlotCollection() override; RigEclipseWellLogExtractor* findOrCreateSimWellExtractor( const QString& simWellName, const QString& caseUserDescription, diff --git a/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp b/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp index bfa24e1397..1a8402f9fc 100644 --- a/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp @@ -58,14 +58,6 @@ RimReservoirCellResultsStorage::RimReservoirCellResultsStorage() CAF_PDM_InitFieldNoDefault( &m_resultCacheMetaData, "ResultCacheEntries", "UiDummyname" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimReservoirCellResultsStorage::~RimReservoirCellResultsStorage() -{ - m_resultCacheMetaData.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// This override populates the metainfo regarding the cell results data in the RigCaseCellResultsData /// object. This metainfo will then be written to the project file when saving, and thus read on project file open. diff --git a/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.h b/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.h index 51caa35521..8643a08212 100644 --- a/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.h +++ b/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.h @@ -41,7 +41,6 @@ class RimReservoirCellResultsStorage : public caf::PdmObject public: RimReservoirCellResultsStorage(); - ~RimReservoirCellResultsStorage() override; void setCellResults( RigCaseCellResultsData* cellResults ); diff --git a/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp index d827dabcbc..12bf81457a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp @@ -44,14 +44,6 @@ RimRftPlotCollection::RimRftPlotCollection() CAF_PDM_InitFieldNoDefault( &m_rftPlots, "RftPlots", "" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimRftPlotCollection::~RimRftPlotCollection() -{ - m_rftPlots.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.h b/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.h index 7c015ff047..90be5310f3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.h @@ -50,7 +50,6 @@ class RimRftPlotCollection : public caf::PdmObject, public RimPlotCollection public: RimRftPlotCollection(); - ~RimRftPlotCollection() override; RigEclipseWellLogExtractor* findOrCreateSimWellExtractor( const QString& simWellName, const QString& caseUserDescription, diff --git a/ApplicationLibCode/ProjectDataModel/RimScriptCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimScriptCollection.cpp index b2ba21531b..dd21f5bbe7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimScriptCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimScriptCollection.cpp @@ -45,15 +45,6 @@ RimScriptCollection::RimScriptCollection() CAF_PDM_InitFieldNoDefault( &subDirectories, "SubDirectories", "" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimScriptCollection::~RimScriptCollection() -{ - calcScripts.deleteChildren(); - subDirectories.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimScriptCollection.h b/ApplicationLibCode/ProjectDataModel/RimScriptCollection.h index 432fa82dba..817a34375d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimScriptCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimScriptCollection.h @@ -41,7 +41,6 @@ class RimScriptCollection : public caf::PdmObject public: RimScriptCollection(); - ~RimScriptCollection() override; public: caf::PdmField directory; diff --git a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp index 00519da768..cf14080a43 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -233,14 +233,6 @@ RimSimWellInViewCollection::RimSimWellInViewCollection() m_reservoirView = nullptr; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSimWellInViewCollection::~RimSimWellInViewCollection() -{ - wells.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.h b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.h index b767e0ad69..2fa2a50b56 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.h @@ -44,7 +44,6 @@ class RimSimWellInViewCollection : public caf::PdmObject public: RimSimWellInViewCollection(); - ~RimSimWellInViewCollection() override; void setReservoirView( RimEclipseView* ownerReservoirView ); diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.cpp index 9b504765ec..016bda07b7 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.cpp @@ -37,14 +37,6 @@ RimElasticPropertyScalingCollection::RimElasticPropertyScalingCollection() CAF_PDM_InitScriptableFieldNoDefault( &m_elasticPropertyScalings, "ElasticPropertyScalings", "Elastic Property Scalings" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimElasticPropertyScalingCollection::~RimElasticPropertyScalingCollection() -{ - m_elasticPropertyScalings.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.h index ba6077bf85..87cbb1bcb8 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.h @@ -36,7 +36,6 @@ class RimElasticPropertyScalingCollection : public caf::PdmObject public: RimElasticPropertyScalingCollection(); - ~RimElasticPropertyScalingCollection() override; caf::Signal<> changed; diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.cpp index da70a84418..4be57666bc 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.cpp @@ -35,14 +35,6 @@ RimStimPlanModelPlotCollection::RimStimPlanModelPlotCollection() CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModelPlots, "StimPlanModelPlots", "" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimStimPlanModelPlotCollection::~RimStimPlanModelPlotCollection() -{ - m_stimPlanModelPlots.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.h index 9f273e4e8e..b9d4008efc 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.h @@ -36,7 +36,6 @@ class RimStimPlanModelPlotCollection : public caf::PdmObject, public RimPlotColl public: RimStimPlanModelPlotCollection(); - ~RimStimPlanModelPlotCollection() override; void addStimPlanModelPlot( RimStimPlanModelPlot* newPlot ); diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp index b024a6e570..a4d60b63f3 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp @@ -44,14 +44,6 @@ RimStimPlanModelTemplateCollection::RimStimPlanModelTemplateCollection() m_nextValidId.uiCapability()->setUiHidden( true ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimStimPlanModelTemplateCollection::~RimStimPlanModelTemplateCollection() -{ - m_stimPlanModelTemplates.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.h index 7d3e1328a9..b48e11b300 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.h @@ -34,7 +34,6 @@ class RimStimPlanModelTemplateCollection : public caf::PdmObject public: RimStimPlanModelTemplateCollection(); - ~RimStimPlanModelTemplateCollection() override; RimStimPlanModelTemplate* stimPlanModelTemplate( int id ) const; std::vector stimPlanModelTemplates() const; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index cd592cbe5d..61fef7f43c 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -54,14 +54,6 @@ RimEnsembleCurveSetCollection::RimEnsembleCurveSetCollection() m_ySourceStepping.xmlCapability()->disableIO(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimEnsembleCurveSetCollection::~RimEnsembleCurveSetCollection() -{ - m_curveSets.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h index 0b7b24ff29..6efd10c1cc 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h @@ -38,7 +38,6 @@ class RimEnsembleCurveSetCollection : public caf::PdmObject public: RimEnsembleCurveSetCollection(); - ~RimEnsembleCurveSetCollection() override; bool isCurveSetsVisible() const; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index 8ea9fda02b..e9af288277 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -65,14 +65,6 @@ RimSummaryCurveCollection::RimSummaryCurveCollection() m_ySourceStepping.xmlCapability()->disableIO(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCurveCollection::~RimSummaryCurveCollection() -{ - m_curves.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h index 376188283e..64711ef739 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h @@ -45,7 +45,6 @@ class RimSummaryCurveCollection : public caf::PdmObject public: RimSummaryCurveCollection(); - ~RimSummaryCurveCollection() override; bool isCurvesVisible(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.cpp index c44197ff15..220443b29e 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.cpp @@ -34,14 +34,6 @@ RimEnsembleWellLogsCollection::RimEnsembleWellLogsCollection() CAF_PDM_InitFieldNoDefault( &m_ensembleWellLogs, "EnsembleWellLogsCollection", "" ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimEnsembleWellLogsCollection::~RimEnsembleWellLogsCollection() -{ - m_ensembleWellLogs.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.h index b53bca398d..7777273178 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.h @@ -31,7 +31,6 @@ class RimEnsembleWellLogsCollection : public caf::PdmObject public: RimEnsembleWellLogsCollection(); - ~RimEnsembleWellLogsCollection() override; std::vector ensembleWellLogs() const; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp index 6ce834c889..919a37483b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp @@ -53,14 +53,6 @@ RimOsduWellLog::RimOsduWellLog() setDeletable( true ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimOsduWellLog::~RimOsduWellLog() -{ - m_wellLogChannels.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h index 789927232e..22494e074e 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.h @@ -44,7 +44,6 @@ class RimOsduWellLog : public RimWellLog public: RimOsduWellLog(); - ~RimOsduWellLog() override; void setName( const QString& name ); QString name() const override; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp index 384bedd19c..b103ef8426 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp @@ -51,14 +51,6 @@ RimWellLogCsvFile::RimWellLogCsvFile() m_wellLogDataFile = nullptr; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellLogCsvFile::~RimWellLogCsvFile() -{ - m_wellLogChannels.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.h index f93a66ce0b..aa38802b1e 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.h @@ -41,7 +41,6 @@ class RimWellLogCsvFile : public RimWellLogFile public: RimWellLogCsvFile(); - ~RimWellLogCsvFile() override; QString name() const override { return m_name; } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp index 28655c2b37..409f3732a1 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp @@ -82,14 +82,6 @@ RimWellLogLasFile::RimWellLogLasFile() m_lasFileHasValidDate = false; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellLogLasFile::~RimWellLogLasFile() -{ - m_wellLogChannels.deleteChildren(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h index 1c679033e5..e72a7a31a9 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.h @@ -44,7 +44,6 @@ class RimWellLogLasFile : public RimWellLogFile public: RimWellLogLasFile(); - ~RimWellLogLasFile() override; static RimWellLogLasFile* readWellLogFile( const QString& logFilePath, QString* errorMessage ); diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmScriptingBasicTest.cpp b/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmScriptingBasicTest.cpp index 6395bed5a1..62f6c7e102 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmScriptingBasicTest.cpp +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmScriptingBasicTest.cpp @@ -201,8 +201,6 @@ class InheritedDemoObj : public DemoPdmObject "Whatsthis SimpleObjectsField" ); } - ~InheritedDemoObj() { m_simpleObjectsField.deleteChildren(); } - caf::PdmField> m_texts; caf::PdmField> m_numbers; @@ -222,8 +220,6 @@ class MyPdmDocument : public caf::PdmDocument CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "", "", "", "" ) } - ~MyPdmDocument() { objects.deleteChildren(); } - caf::PdmChildArrayField objects; }; CAF_PDM_SOURCE_INIT( MyPdmDocument, "MyPdmDocument" ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/Parent.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/Parent.cpp index 74b5371a54..140c1aee39 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/Parent.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/Parent.cpp @@ -10,7 +10,6 @@ Parent::Parent() Parent::~Parent() { delete m_simpleObjectF(); - m_simpleObjectsField.deleteChildren(); } void Parent::doSome() diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmChildArrayFieldHandleTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmChildArrayFieldHandleTest.cpp index f44a40f599..01e1214e63 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmChildArrayFieldHandleTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmChildArrayFieldHandleTest.cpp @@ -66,12 +66,6 @@ class ContainerObj : public caf::PdmObjectHandle this->addField( &derivedOtherObjs, "derivedOtherObjs" ); } - ~ContainerObj() - { - derivedObjs.deleteChildren(); - derivedOtherObjs.deleteChildren(); - } - caf::PdmChildArrayField derivedObjs; caf::PdmChildArrayField derivedOtherObjs; }; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmReferenceHelperTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmReferenceHelperTest.cpp index ee1e11af6a..c5c23a5233 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmReferenceHelperTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmReferenceHelperTest.cpp @@ -53,11 +53,7 @@ class ReferenceSimpleObj : public caf::PdmObjectHandle this->addField( &m_simpleObjPtrField, "m_simpleObjPtrField" ); } - ~ReferenceSimpleObj() - { - delete m_pointersField(); - m_simpleObjPtrField.deleteChildren(); - } + ~ReferenceSimpleObj() { delete m_pointersField(); } // Fields caf::PdmChildField m_pointersField; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp index fc37b8922b..a2281783d3 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp @@ -189,8 +189,6 @@ class InheritedDemoObj : public DemoPdmObject CAF_PDM_XML_InitField( &m_childArrayField, "DemoPdmObjectects" ); } - ~InheritedDemoObj() { m_childArrayField.deleteChildren(); } - caf::PdmDataValueField m_texts; caf::PdmChildArrayField m_childArrayField; }; @@ -254,11 +252,7 @@ class ReferenceDemoPdmObject : public caf::PdmObjectHandle, public caf::PdmXmlOb CAF_PDM_XML_InitField( &m_simpleObjPtrField2, "SimpleObjPtrField2" ); } - ~ReferenceDemoPdmObject() - { - delete m_pointersField(); - m_simpleObjPtrField2.deleteChildren(); - } + ~ReferenceDemoPdmObject() { delete m_pointersField(); } // Fields caf::PdmChildField m_pointersField; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp index ea19bdfc4d..d304e06c5f 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp @@ -193,8 +193,6 @@ class InheritedDemoObj : public DemoPdmObject "Whatsthis SimpleObjectsField" ); } - ~InheritedDemoObj() { m_simpleObjectsField.deleteChildren(); } - caf::PdmField> m_texts; caf::PdmField> m_testEnumField; caf::PdmChildArrayField m_simpleObjectsField; @@ -212,8 +210,6 @@ class MyPdmDocument : public caf::PdmDocument CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "", "", "", "" ) } - ~MyPdmDocument() { objects.deleteChildren(); } - caf::PdmChildArrayField objects; }; CAF_PDM_SOURCE_INIT( MyPdmDocument, "MyPdmDocument" ); diff --git a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/cafPdmUiTreeViewModelTest.cpp b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/cafPdmUiTreeViewModelTest.cpp index 1f60b7e568..2e1afa06f9 100644 --- a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/cafPdmUiTreeViewModelTest.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/cafPdmUiTreeViewModelTest.cpp @@ -37,8 +37,6 @@ class DemoPdmObject : public caf::PdmObject m_simpleObjPtrField.uiCapability()->setUiTreeHidden( false ); } - ~DemoPdmObject() { m_simpleObjPtrField.deleteChildren(); } - caf::PdmChildArrayField m_simpleObjPtrField; }; From 6fb74654a198a81305355f135f032155f3653a4a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Jul 2024 20:11:49 +0200 Subject: [PATCH 204/332] Improve interface for string operations Trim incoming string before converting to number Remove use of std::strtod and std::stoi Use std::string_view instead of std::string when possible --- .../Application/Tools/RiaStdStringTools.cpp | 47 +++++------- .../Application/Tools/RiaStdStringTools.h | 19 +++-- .../RifEclipseUserDataParserTools.cpp | 3 +- .../FileInterface/RifKeywordVectorParser.cpp | 4 +- .../FileInterface/RifOpmCommonSummary.cpp | 2 +- .../FileInterface/RifOpmHdf5Summary.cpp | 2 +- .../GeoMechFileInterface/RifInpReader.cpp | 2 +- .../Polygons/RimPolygonAppearance.cpp | 3 +- .../UnitTests/RiaStdStringTools-Test.cpp | 72 +++++++++++++++++++ 9 files changed, 108 insertions(+), 46 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp b/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp index 154fa1c662..35277b0230 100644 --- a/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp @@ -32,7 +32,7 @@ const std::string WHITESPACE = " \n\r\t\f\v"; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::string RiaStdStringTools::leftTrimString( const std::string& s ) +std::string_view RiaStdStringTools::leftTrimString( std::string_view s ) { size_t start = s.find_first_not_of( WHITESPACE ); return ( start == std::string::npos ) ? "" : s.substr( start ); @@ -41,7 +41,7 @@ std::string RiaStdStringTools::leftTrimString( const std::string& s ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::string RiaStdStringTools::rightTrimString( const std::string& s ) +std::string_view RiaStdStringTools::rightTrimString( std::string_view s ) { size_t end = s.find_last_not_of( WHITESPACE ); return ( end == std::string::npos ) ? "" : s.substr( 0, end + 1 ); @@ -50,7 +50,7 @@ std::string RiaStdStringTools::rightTrimString( const std::string& s ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::string RiaStdStringTools::trimString( const std::string& s ) +std::string_view RiaStdStringTools::trimString( std::string_view s ) { return rightTrimString( leftTrimString( s ) ); } @@ -87,42 +87,24 @@ bool RiaStdStringTools::isNumber( const std::string& s, char decimalPoint ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int16_t RiaStdStringTools::toInt16( const std::string& s ) +int16_t RiaStdStringTools::toInt16( std::string_view s ) { return (int16_t)toInt( s ); } //-------------------------------------------------------------------------------------------------- -/// +/// Convert a string to an integer. If the string is not a valid integer, the function returns -1. +/// For best performance, use toInt( const std::string_view& s, int& value ); //-------------------------------------------------------------------------------------------------- -int RiaStdStringTools::toInt( const std::string& s ) +int RiaStdStringTools::toInt( std::string_view s ) { int intValue = -1; - try - { - intValue = std::stoi( s ); - } - catch ( ... ) - { - } + toInt( s, intValue ); return intValue; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RiaStdStringTools::toDouble( const std::string& s ) -{ - double doubleValue = -1.0; - - char* end; - doubleValue = std::strtod( s.data(), &end ); - - return doubleValue; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -164,8 +146,11 @@ std::string RiaStdStringTools::formatThousandGrouping( long value ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiaStdStringTools::toDouble( const std::string_view& s, double& value ) +bool RiaStdStringTools::toDouble( std::string_view s, double& value ) { + s.remove_prefix( std::min( s.find_first_not_of( " " ), s.size() ) ); + + // NB! Note that we use fast_float:: here, and not std:: auto resultObject = fast_float::from_chars( s.data(), s.data() + s.size(), value ); return ( resultObject.ec == std::errc() ); @@ -174,8 +159,10 @@ bool RiaStdStringTools::toDouble( const std::string_view& s, double& value ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiaStdStringTools::toInt( const std::string_view& s, int& value ) +bool RiaStdStringTools::toInt( std::string_view s, int& value ) { + s.remove_prefix( std::min( s.find_first_not_of( " " ), s.size() ) ); + auto resultObject = std::from_chars( s.data(), s.data() + s.size(), value ); return ( resultObject.ec == std::errc() ); @@ -184,9 +171,9 @@ bool RiaStdStringTools::toInt( const std::string_view& s, int& value ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::string RiaStdStringTools::toUpper( const std::string& s ) +std::string RiaStdStringTools::toUpper( std::string_view s ) { - auto strCopy( s ); + std::string strCopy( s ); std::transform( strCopy.begin(), strCopy.end(), strCopy.begin(), []( unsigned char c ) { return std::toupper( c ); } ); return strCopy; diff --git a/ApplicationLibCode/Application/Tools/RiaStdStringTools.h b/ApplicationLibCode/Application/Tools/RiaStdStringTools.h index 5ef8aecc0c..b070aaf9ee 100644 --- a/ApplicationLibCode/Application/Tools/RiaStdStringTools.h +++ b/ApplicationLibCode/Application/Tools/RiaStdStringTools.h @@ -31,26 +31,25 @@ class RiaStdStringTools { public: - static std::string trimString( const std::string& s ); - static std::string rightTrimString( const std::string& s ); - static std::string leftTrimString( const std::string& s ); - static std::string removeWhitespace( const std::string& line ); + static std::string_view trimString( std::string_view s ); + static std::string_view rightTrimString( std::string_view s ); + static std::string_view leftTrimString( std::string_view s ); + static std::string removeWhitespace( const std::string& line ); static bool isNumber( const std::string& s, char decimalPoint ); - static int16_t toInt16( const std::string& s ); - static int toInt( const std::string& s ); - static double toDouble( const std::string& s ); + static int16_t toInt16( std::string_view s ); + static int toInt( std::string_view s ); static bool containsAlphabetic( const std::string& s ); static bool startsWithAlphabetic( const std::string& s ); static std::string formatThousandGrouping( long value ); // Conversion using fastest known approach - static bool toDouble( const std::string_view& s, double& value ); - static bool toInt( const std::string_view& s, int& value ); + static bool toDouble( std::string_view s, double& value ); + static bool toInt( std::string_view s, int& value ); - static std::string toUpper( const std::string& s ); + static std::string toUpper( std::string_view s ); static bool endsWith( const std::string& mainStr, const std::string& toMatch ); diff --git a/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.cpp index 691b3fbf59..8da9eb70d0 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.cpp @@ -228,7 +228,8 @@ bool RifEclipseUserDataParserTools::hasOnlyValidDoubleValues( const std::vector< } else { - double doubleVal = RiaStdStringTools::toDouble( word ); + double doubleVal = 0.0; + RiaStdStringTools::toDouble( word, doubleVal ); doubleValues->push_back( doubleVal ); } } diff --git a/ApplicationLibCode/FileInterface/RifKeywordVectorParser.cpp b/ApplicationLibCode/FileInterface/RifKeywordVectorParser.cpp index d9981721c2..53e690a0cb 100644 --- a/ApplicationLibCode/FileInterface/RifKeywordVectorParser.cpp +++ b/ApplicationLibCode/FileInterface/RifKeywordVectorParser.cpp @@ -89,9 +89,11 @@ void RifKeywordVectorParser::parseData( const QString& data ) keywordBasedVector.header = RifEclipseUserDataParserTools::headerReader( streamData, line ); if ( keywordBasedVector.header.empty() ) break; + double value = 0.0; while ( RifEclipseUserDataParserTools::isANumber( line ) ) { - keywordBasedVector.values.push_back( RiaStdStringTools::toDouble( line ) ); + RiaStdStringTools::toDouble( line, value ); + keywordBasedVector.values.push_back( value ); std::getline( streamData, line ); } diff --git a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp index 448653b8d8..93d9b9cf20 100644 --- a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp +++ b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp @@ -217,7 +217,7 @@ std::string RifOpmCommonEclipseSummary::unitName( const RifEclipseSummaryAddress } } - return RiaStdStringTools::trimString( nameString ); + return std::string( RiaStdStringTools::trimString( nameString ) ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.cpp b/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.cpp index 46afa8d0ad..dda481841e 100644 --- a/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.cpp +++ b/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.cpp @@ -125,7 +125,7 @@ std::string RifOpmHdf5Summary::unitName( const RifEclipseSummaryAddress& resultA auto keyword = it->second; auto stringFromFileReader = m_eSmry->get_unit( keyword ); - return RiaStdStringTools::trimString( stringFromFileReader ); + return std::string( RiaStdStringTools::trimString( stringFromFileReader ) ); } } diff --git a/ApplicationLibCode/GeoMech/GeoMechFileInterface/RifInpReader.cpp b/ApplicationLibCode/GeoMech/GeoMechFileInterface/RifInpReader.cpp index 27aee18007..0efb00005b 100644 --- a/ApplicationLibCode/GeoMech/GeoMechFileInterface/RifInpReader.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechFileInterface/RifInpReader.cpp @@ -452,7 +452,7 @@ std::vector RifInpReader::readElementSet( std::istream& stream ) auto parts = RiaStdStringTools::splitString( line, ',' ); for ( auto part : parts ) { - std::string trimmedPart = RiaStdStringTools::trimString( part ); + auto trimmedPart = RiaStdStringTools::trimString( part ); if ( !trimmedPart.empty() ) { diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp index ea8446151c..7dbba7429b 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp @@ -61,7 +61,8 @@ class RadiusValidator : public QValidator { if ( input.isEmpty() ) return State::Intermediate; - double val = RiaStdStringTools::toDouble( input.toStdString() ); + double val = 0.0; + RiaStdStringTools::toDouble( input.toStdString(), val ); if ( val > 0.001 && val <= 2.0 ) return State::Acceptable; else diff --git a/ApplicationLibCode/UnitTests/RiaStdStringTools-Test.cpp b/ApplicationLibCode/UnitTests/RiaStdStringTools-Test.cpp index c419e2476b..ff5c8d976d 100644 --- a/ApplicationLibCode/UnitTests/RiaStdStringTools-Test.cpp +++ b/ApplicationLibCode/UnitTests/RiaStdStringTools-Test.cpp @@ -257,3 +257,75 @@ TEST( RiaStdStringToolsTest, TestInvalidRangeStrings ) ASSERT_EQ( expectedValues, actualValues ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RiaStdStringToolsTest, TestToDouble ) +{ + { + std::string text = " 0.123"; + + double resultValue = 0.0; + auto isOk = RiaStdStringTools::toDouble( text, resultValue ); + EXPECT_TRUE( isOk ); + + EXPECT_DOUBLE_EQ( resultValue, 0.123 ); + } + + { + std::string text = " 0.123 2"; + + double resultValue = 0.0; + auto isOk = RiaStdStringTools::toDouble( text, resultValue ); + EXPECT_TRUE( isOk ); + + EXPECT_DOUBLE_EQ( resultValue, 0.123 ); + } + + { + std::string text = "0.123 2"; + + double resultValue = 0.0; + auto isOk = RiaStdStringTools::toDouble( text, resultValue ); + EXPECT_TRUE( isOk ); + + EXPECT_DOUBLE_EQ( resultValue, 0.123 ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RiaStdStringToolsTest, TestToInt ) +{ + { + std::string text = " 12"; + + int resultValue = -1; + auto isOk = RiaStdStringTools::toInt( text, resultValue ); + EXPECT_TRUE( isOk ); + + EXPECT_EQ( resultValue, 12 ); + } + + { + std::string text = " 12 "; + + int resultValue = -1; + auto isOk = RiaStdStringTools::toInt( text, resultValue ); + EXPECT_TRUE( isOk ); + + EXPECT_EQ( resultValue, 12 ); + } + + { + std::string text = "12"; + + int resultValue = -1; + auto isOk = RiaStdStringTools::toInt( text, resultValue ); + EXPECT_TRUE( isOk ); + + EXPECT_EQ( resultValue, 12 ); + } +} From 4aadf6e801dd1881c869c48ded00f2362ccf937a Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 29 Jul 2024 09:45:44 +0200 Subject: [PATCH 205/332] Correct or remove ssihub references. --- .../Commands/OsduImportCommands/CMakeLists_files.cmake | 2 +- .../ProjectDataModel/WellPath/RimWellPath.cpp | 8 ++++---- ApplicationLibCode/UserInterface/RiuMainWindow.h | 5 ----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake index afc1fb1b39..dc30cc6baa 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake @@ -28,7 +28,7 @@ list(APPEND COMMAND_QT_MOC_HEADERS ) source_group( - "CommandFeature\\SsiHub" + "CommandFeature\\Osdu" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp index 339d974dee..98bad74ac8 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp @@ -736,18 +736,18 @@ void RimWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& ui simWellGroup->add( &m_branchIndex ); } - caf::PdmUiGroup* ssihubGroup = uiOrdering.addNewGroup( "Well Info" ); + caf::PdmUiGroup* wellInfoGroup = uiOrdering.addNewGroup( "Well Info" ); if ( m_wellPathGeometry.notNull() && m_wellPathGeometry->rkbDiff() > 0.0 ) { - ssihubGroup->add( &m_airGap ); + wellInfoGroup->add( &m_airGap ); } if ( m_wellPathGeometry.notNull() && m_wellPathGeometry->hasDatumElevation() ) { - ssihubGroup->add( &m_datumElevation ); + wellInfoGroup->add( &m_datumElevation ); } - ssihubGroup->add( &m_unitSystem ); + wellInfoGroup->add( &m_unitSystem ); caf::PdmUiGroup* formationFileInfoGroup = uiOrdering.addNewGroup( "Well Picks" ); formationFileInfoGroup->add( &m_wellPathFormationFilePath ); diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.h b/ApplicationLibCode/UserInterface/RiuMainWindow.h index e16cbebfe8..c2e48906a7 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.h +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.h @@ -69,11 +69,6 @@ class PdmUiPropertyView; class PdmUiItem; } // namespace caf -namespace ssihub -{ -class Interface; -} - namespace ads { class CDockWidget; From 1d7b40fbddd0ecb1d1a59b0c88b95ce3a4a11587 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 29 Jul 2024 11:30:28 +0200 Subject: [PATCH 206/332] Remove SSIHUB-related classes. --- .../OsduImportCommands/CMakeLists_files.cmake | 8 -- .../RicWellPathsImportOsduFeature.cpp | 18 +-- .../OsduImportCommands/RimOilFieldEntry.cpp | 119 ------------------ .../OsduImportCommands/RimOilFieldEntry.h | 50 -------- .../OsduImportCommands/RimOilRegionEntry.cpp | 75 ----------- .../OsduImportCommands/RimOilRegionEntry.h | 44 ------- .../OsduImportCommands/RimWellPathImport.cpp | 105 ---------------- .../OsduImportCommands/RimWellPathImport.h | 56 --------- .../OsduImportCommands/RimWellsEntry.cpp | 117 ----------------- .../OsduImportCommands/RimWellsEntry.h | 61 --------- .../RiuWellImportWizard.cpp | 36 ++---- .../OsduImportCommands/RiuWellImportWizard.h | 35 ++---- .../ProjectDataModel/RimProject.cpp | 46 ------- .../ProjectDataModel/RimProject.h | 4 - 14 files changed, 17 insertions(+), 757 deletions(-) delete mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.cpp delete mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.h delete mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.cpp delete mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.h delete mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp delete mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h delete mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.cpp delete mode 100644 ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.h diff --git a/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake index dc30cc6baa..185ab41659 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/OsduImportCommands/CMakeLists_files.cmake @@ -1,19 +1,11 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportOsduFeature.h - ${CMAKE_CURRENT_LIST_DIR}/RimOilFieldEntry.h - ${CMAKE_CURRENT_LIST_DIR}/RimOilRegionEntry.h - ${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.h - ${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogImportWizard.h ) set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportOsduFeature.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimOilFieldEntry.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimOilRegionEntry.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogImportWizard.cpp ) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index f76cdd8861..f0b7356989 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -33,7 +33,6 @@ #include "RimProject.h" #include "RimTools.h" #include "RimWellPathCollection.h" -#include "RimWellPathImport.h" #include "RiuMainWindow.h" #include "RiuWellImportWizard.h" @@ -55,17 +54,6 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) RiaApplication* app = RiaApplication::instance(); if ( !app->project() ) return; - // Update the UTM bounding box from the reservoir - app->project()->computeUtmAreaOfInterest(); - - QString wellPathsFolderPath = QStandardPaths::writableLocation( QStandardPaths::CacheLocation ) + QString( "/wellpaths/" ); - QDir::root().mkpath( wellPathsFolderPath ); - - if ( !app->project()->wellPathImport() ) return; - - // Keep a copy of the import settings, and restore if cancel is pressed in the import wizard - QString copyOfOriginalObject = app->project()->wellPathImport()->writeObjectToXmlString(); - if ( !app->preferences() ) return; RimProject* project = RimProject::current(); @@ -78,7 +66,7 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) RiaOsduConnector* osduConnector = app->makeOsduConnector(); - RiuWellImportWizard wellImportwizard( wellPathsFolderPath, osduConnector, app->project()->wellPathImport(), RiuMainWindow::instance() ); + RiuWellImportWizard wellImportwizard( osduConnector, RiuMainWindow::instance() ); if ( QDialog::Accepted == wellImportwizard.exec() ) { @@ -115,10 +103,6 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) project->updateConnectedEditors(); app->project()->scheduleCreateDisplayModelAndRedrawAllViews(); } - else - { - app->project()->wellPathImport()->readObjectFromXmlString( copyOfOriginalObject, caf::PdmDefaultObjectFactory::instance() ); - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.cpp deleted file mode 100644 index e3410cb72d..0000000000 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.cpp +++ /dev/null @@ -1,119 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011- Statoil ASA -// Copyright (C) 2013- Ceetron Solutions AS -// Copyright (C) 2011-2012 Ceetron AS -// -// 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 "RimOilFieldEntry.h" -#include "RimWellPathImport.h" - -#include "RifJsonEncodeDecode.h" - -#include -#include -#include -#include - -CAF_PDM_SOURCE_INIT( RimOilFieldEntry, "RimOilFieldEntry" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimOilFieldEntry::RimOilFieldEntry() -{ - CAF_PDM_InitObject( "OilFieldEntry" ); - - CAF_PDM_InitFieldNoDefault( &name, "OilFieldName", "Oil Field Name" ); - CAF_PDM_InitFieldNoDefault( &edmId, "EdmId", "Edm ID" ); - CAF_PDM_InitField( &selected, "Selected", false, "Selected" ); - - CAF_PDM_InitFieldNoDefault( &wellsFilePath, "wellsFilePath", "Wells File Path" ); - - CAF_PDM_InitFieldNoDefault( &wells, "Wells", "" ); - wells.uiCapability()->setUiTreeChildrenHidden( true ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimOilFieldEntry::userDescriptionField() -{ - return &name; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimOilFieldEntry::objectToggleField() -{ - return &selected; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimOilFieldEntry::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) -{ - if ( changedField == &selected ) - { - updateEnabledState(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimOilFieldEntry::initAfterRead() -{ - updateEnabledState(); - - updateUiIconFromToggleField(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimOilFieldEntry::updateEnabledState() -{ - bool wellsReadOnly = !selected; - if ( isUiReadOnly() ) - { - wellsReadOnly = true; - } - - for ( size_t i = 0; i < wells.size(); i++ ) - { - wells[i]->setUiReadOnly( wellsReadOnly ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPathEntry* RimOilFieldEntry::find( const QString& entryName, RimWellPathEntry::WellTypeEnum wellPathType ) -{ - for ( size_t i = 0; i < wells.size(); i++ ) - { - RimWellPathEntry* wellPathEntry = wells[i]; - if ( wellPathEntry->name == entryName && wellPathEntry->wellPathType == wellPathType ) - { - return wellPathEntry; - } - } - - return nullptr; -} diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.h b/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.h deleted file mode 100644 index b0c71c6706..0000000000 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimOilFieldEntry.h +++ /dev/null @@ -1,50 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS -// -// 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 "cafPdmChildArrayField.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" - -#include "RimWellsEntry.h" - -class RimOilFieldEntry : public caf::PdmObject -{ - CAF_PDM_HEADER_INIT; - -public: - RimOilFieldEntry(); - - caf::PdmField name; - caf::PdmField edmId; - caf::PdmField selected; - caf::PdmField wellsFilePath; // Location of the response file from request "/wells" - - caf::PdmChildArrayField wells; - - RimWellPathEntry* find( const QString& name, RimWellPathEntry::WellTypeEnum wellPathType ); - - caf::PdmFieldHandle* userDescriptionField() override; - caf::PdmFieldHandle* objectToggleField() override; - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - void initAfterRead() override; - - // private: - void updateEnabledState(); -}; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.cpp deleted file mode 100644 index bc8875233b..0000000000 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.cpp +++ /dev/null @@ -1,75 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS -// -// 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 "RimOilRegionEntry.h" -#include "RimOilFieldEntry.h" - -CAF_PDM_SOURCE_INIT( RimOilRegionEntry, "RimOilRegionEntry" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimOilRegionEntry::RimOilRegionEntry() -{ - CAF_PDM_InitObject( "OilRegionEntry" ); - - CAF_PDM_InitFieldNoDefault( &name, "OilRegionEntry", "OilRegionEntry" ); - - CAF_PDM_InitFieldNoDefault( &fields, "Fields", "" ); - - CAF_PDM_InitField( &selected, "Selected", false, "Selected" ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimOilRegionEntry::userDescriptionField() -{ - return &name; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimOilRegionEntry::objectToggleField() -{ - return &selected; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimOilRegionEntry::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) -{ - if ( &selected == changedField ) - { - updateState(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimOilRegionEntry::updateState() -{ - for ( size_t i = 0; i < fields.size(); i++ ) - { - fields[i]->setUiReadOnly( !selected ); - fields[i]->updateEnabledState(); - } -} diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.h b/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.h deleted file mode 100644 index 897286bb56..0000000000 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimOilRegionEntry.h +++ /dev/null @@ -1,44 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS -// -// 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 "cafPdmChildArrayField.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" - -class RimOilFieldEntry; - -class RimOilRegionEntry : public caf::PdmObject -{ - CAF_PDM_HEADER_INIT; - -public: - RimOilRegionEntry(); - - caf::PdmFieldHandle* userDescriptionField() override; - caf::PdmFieldHandle* objectToggleField() override; - - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - - void updateState(); - - caf::PdmField name; - caf::PdmField selected; - caf::PdmChildArrayField fields; -}; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp deleted file mode 100644 index f78dc3edc9..0000000000 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp +++ /dev/null @@ -1,105 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2024 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 "RimWellPathImport.h" - -#include "RimFileWellPath.h" -#include "RimOilFieldEntry.h" -#include "RimOilRegionEntry.h" -#include "RimTools.h" -#include "RimWellPath.h" -#include "RimWellPathCollection.h" - -#include "cafPdmUiCheckBoxEditor.h" -#include "cafPdmUiTreeAttributes.h" -#include "cafPdmUiTreeViewEditor.h" - -#include - -namespace caf -{ -template <> -void caf::AppEnum::setUp() -{ - addItem( RimWellPathImport::UTM_FILTER_OFF, "UTM_FILTER_OFF", "Off" ); - addItem( RimWellPathImport::UTM_FILTER_PROJECT, "UTM_FILTER_PROJECT", "Project" ); - addItem( RimWellPathImport::UTM_FILTER_CUSTOM, "UTM_FILTER_CUSTOM", "Custom" ); - setDefault( RimWellPathImport::UTM_FILTER_PROJECT ); -} - -} // End namespace caf - -CAF_PDM_SOURCE_INIT( RimWellPathImport, "RimWellPathImport" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPathImport::RimWellPathImport() -{ - CAF_PDM_InitObject( "RimWellPathImport" ); - - caf::AppEnum defaultUtmMode = UTM_FILTER_OFF; - CAF_PDM_InitField( &utmFilterMode, "UtmMode", defaultUtmMode, "Utm Filter" ); - - CAF_PDM_InitField( &north, "UtmNorth", 0.0, "North" ); - CAF_PDM_InitField( &south, "UtmSouth", 0.0, "South" ); - CAF_PDM_InitField( &east, "UtmEast", 0.0, "East" ); - CAF_PDM_InitField( &west, "UtmWest", 0.0, "West" ); - - CAF_PDM_InitFieldNoDefault( ®ions_OBSOLETE, "Regions", "" ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathImport::initAfterRead() -{ - updateFieldVisibility(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathImport::updateFieldVisibility() -{ - if ( utmFilterMode == UTM_FILTER_CUSTOM ) - { - north.uiCapability()->setUiReadOnly( false ); - south.uiCapability()->setUiReadOnly( false ); - east.uiCapability()->setUiReadOnly( false ); - west.uiCapability()->setUiReadOnly( false ); - } - else - { - north.uiCapability()->setUiReadOnly( true ); - south.uiCapability()->setUiReadOnly( true ); - east.uiCapability()->setUiReadOnly( true ); - west.uiCapability()->setUiReadOnly( true ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathImport::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) -{ - if ( changedField == &utmFilterMode ) - { - updateFieldVisibility(); - } -} diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h b/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h deleted file mode 100644 index abaf3f0a09..0000000000 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.h +++ /dev/null @@ -1,56 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS -// -// 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 "cafAppEnum.h" -#include "cafPdmChildArrayField.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" - -class RimOilRegionEntry; - -class RimWellPathImport : public caf::PdmObject -{ - CAF_PDM_HEADER_INIT; - -public: - enum UtmFilterEnum - { - UTM_FILTER_OFF, - UTM_FILTER_PROJECT, - UTM_FILTER_CUSTOM - }; - -public: - RimWellPathImport(); - - caf::PdmField> utmFilterMode; - caf::PdmField north; - caf::PdmField south; - caf::PdmField east; - caf::PdmField west; - -protected: - void initAfterRead() override; - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - - void updateFieldVisibility(); - - caf::PdmChildArrayField regions_OBSOLETE; -}; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.cpp deleted file mode 100644 index 4da94f883d..0000000000 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.cpp +++ /dev/null @@ -1,117 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS -// -// 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 "RimWellsEntry.h" -#include "cafAppEnum.h" - -namespace caf -{ -template <> -void caf::AppEnum::setUp() -{ - addItem( RimWellPathEntry::WELL_ALL, "WELL_ALL", "All" ); - addItem( RimWellPathEntry::WELL_SURVEY, "WELL_SURVEY", "Survey" ); - addItem( RimWellPathEntry::WELL_PLAN, "WELL_PLAN", "Plan" ); - setDefault( RimWellPathEntry::WELL_ALL ); -} - -} // End namespace caf - -CAF_PDM_SOURCE_INIT( RimWellPathEntry, "RimWellPathEntry" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPathEntry::RimWellPathEntry() -{ - CAF_PDM_InitObject( "WellPathEntry" ); - - CAF_PDM_InitFieldNoDefault( &name, "Name", "Name" ); - CAF_PDM_InitField( &selected, "Selected", false, "Selected" ); - - caf::AppEnum wellType = WELL_ALL; - CAF_PDM_InitField( &wellPathType, "WellPathType", wellType, "Well path type" ); - - CAF_PDM_InitFieldNoDefault( &surveyType, "surveyType", "surveyType" ); - CAF_PDM_InitFieldNoDefault( &requestUrl, "requestUrl", "requestUrl" ); - - CAF_PDM_InitFieldNoDefault( &wellPathFilePath, "wellPathFilePath", "wellPathFilePath" ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimWellPathEntry::userDescriptionField() -{ - return &name; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimWellPathEntry::objectToggleField() -{ - return &selected; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPathEntry* RimWellPathEntry::createWellPathEntry( const QString& name, - const QString& surveyType, - const QString& requestUrl, - const QString& absolutePath, - WellTypeEnum wellType ) -{ - RimWellPathEntry* entry = new RimWellPathEntry(); - entry->name = name; - entry->surveyType = surveyType; - entry->requestUrl = requestUrl; - entry->wellPathType = wellType; - - QString responseFilePath = undefinedWellPathLocation(); - - int strIndex = requestUrl.indexOf( "edm/" ); - if ( strIndex >= 0 ) - { - QString lastPart = requestUrl.right( requestUrl.size() - strIndex ); - lastPart = lastPart.replace( '/', '_' ); - - responseFilePath = absolutePath + "/" + lastPart + ".json"; - } - - entry->wellPathFilePath = responseFilePath; - - return entry; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimWellPathEntry::undefinedWellPathLocation() -{ - return "UNDEFIED_WELLPATH_FILE"; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimWellPathEntry::isWellPathValid() -{ - return ( wellPathFilePath().compare( undefinedWellPathLocation() ) != 0 ); -} diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.h b/ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.h deleted file mode 100644 index 85fb7a2cdd..0000000000 --- a/ApplicationLibCode/Commands/OsduImportCommands/RimWellsEntry.h +++ /dev/null @@ -1,61 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS -// -// 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 "cafAppEnum.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" - -class RimWellPathEntry : public caf::PdmObject -{ - CAF_PDM_HEADER_INIT; - -public: - enum WellTypeEnum - { - WELL_SURVEY, - WELL_PLAN, - WELL_ALL - }; - -public: - RimWellPathEntry(); - - static RimWellPathEntry* createWellPathEntry( const QString& name, - const QString& surveyType, - const QString& requestUrl, - const QString& absolutePath, - WellTypeEnum wellType ); - - caf::PdmFieldHandle* userDescriptionField() override; - caf::PdmFieldHandle* objectToggleField() override; - - caf::PdmField name; - caf::PdmField selected; - - caf::PdmField> wellPathType; - caf::PdmField surveyType; - caf::PdmField requestUrl; - - bool isWellPathValid(); - caf::PdmField wellPathFilePath; // Location of the well path response - -private: - static QString undefinedWellPathLocation(); -}; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index 5cc7a20eb1..9a1e2c79c8 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -20,15 +20,7 @@ #include "RiaFeatureCommandContext.h" -#include "RimWellPathImport.h" - #include "cafCmdFeatureMenuBuilder.h" -#include "cafPdmUiListView.h" -#include "cafPdmUiPropertyView.h" -#include "cafPdmUiTreeAttributes.h" -#include "cafPdmUiTreeView.h" -#include "cafPdmUiTreeViewEditor.h" -#include "cafUtils.h" #include #include @@ -44,23 +36,17 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuWellImportWizard::RiuWellImportWizard( const QString& downloadFolder, - RiaOsduConnector* osduConnector, - RimWellPathImport* wellPathImportObject, - QWidget* parent /*= 0*/ ) +RiuWellImportWizard::RiuWellImportWizard( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) : QWizard( parent ) { - m_wellPathImportObject = wellPathImportObject; - - m_osduConnector = osduConnector; - m_destinationFolder = downloadFolder; + m_osduConnector = osduConnector; m_firstTimeRequestingAuthentication = true; addPage( new AuthenticationPage( m_osduConnector, this ) ); - addPage( new FieldSelectionPage( m_wellPathImportObject, m_osduConnector, this ) ); - addPage( new WellSelectionPage( m_wellPathImportObject, m_osduConnector, this ) ); - addPage( new WellSummaryPage( m_wellPathImportObject, m_osduConnector, this ) ); + addPage( new FieldSelectionPage( m_osduConnector, this ) ); + addPage( new WellSelectionPage( m_osduConnector, this ) ); + addPage( new WellSummaryPage( m_osduConnector, this ) ); } //-------------------------------------------------------------------------------------------------- @@ -75,7 +61,6 @@ RiuWellImportWizard::~RiuWellImportWizard() //-------------------------------------------------------------------------------------------------- void RiuWellImportWizard::downloadFields( const QString& fieldName ) { - // TODO: filter by user input m_osduConnector->requestFieldsByName( fieldName ); } @@ -234,7 +219,7 @@ void AuthenticationPage::accessOk() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) +FieldSelectionPage::FieldSelectionPage( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) { setTitle( "Field Selection" ); @@ -349,7 +334,7 @@ FieldSelectionPage::~FieldSelectionPage() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -WellSelectionPage::WellSelectionPage( RimWellPathImport* wellPathImport, RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) +WellSelectionPage::WellSelectionPage( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) { QVBoxLayout* layout = new QVBoxLayout; setLayout( layout ); @@ -389,8 +374,6 @@ WellSelectionPage::WellSelectionPage( RimWellPathImport* wellPathImport, RiaOsdu QObject::connect( filterLineEdit, &QLineEdit::textChanged, m_proxyModel, &QSortFilterProxyModel::setFilterWildcard ); - m_wellPathImportObject = wellPathImport; - m_osduConnector = osduConnector; connect( m_osduConnector, SIGNAL( wellsFinished() ), SLOT( wellsFinished() ) ); connect( m_osduConnector, SIGNAL( wellboresFinished( const QString& ) ), SLOT( wellboresFinished( const QString& ) ) ); @@ -483,11 +466,8 @@ void WellSelectionPage::selectWellbore( const QItemSelection& newSelection, cons //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -WellSummaryPage::WellSummaryPage( RimWellPathImport* wellPathImport, RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) +WellSummaryPage::WellSummaryPage( RiaOsduConnector* osduConnector, QWidget* parent /*= 0*/ ) { - m_wellPathImportObject = wellPathImport; - m_wellPathImportObject->setUiHidden( true ); - m_osduConnector = osduConnector; QVBoxLayout* layout = new QVBoxLayout; diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index e1471237e1..7b2583167c 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -35,15 +35,6 @@ class QLabel; class QTextEdit; class QTableView; -class RimWellPathImport; - -namespace caf -{ -class PdmUiTreeView; -class PdmUiListView; -class PdmUiPropertyView; -} // namespace caf - class OsduFieldTableModel : public QAbstractTableModel { Q_OBJECT @@ -285,7 +276,7 @@ class FieldSelectionPage : public QWizardPage Q_OBJECT public: - FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOsduConnector* m_osduConnector, QWidget* parent = nullptr ); + FieldSelectionPage( RiaOsduConnector* m_osduConnector, QWidget* parent = nullptr ); ~FieldSelectionPage() override; bool isComplete() const override; @@ -313,7 +304,7 @@ class WellSelectionPage : public QWizardPage Q_OBJECT public: - WellSelectionPage( RimWellPathImport* wellPathImport, RiaOsduConnector* m_osduConnector, QWidget* parent = nullptr ); + WellSelectionPage( RiaOsduConnector* m_osduConnector, QWidget* parent = nullptr ); ~WellSelectionPage() override; void initializePage() override; @@ -325,7 +316,6 @@ private slots: void selectWellbore( const QItemSelection& newSelection, const QItemSelection& oldSelection ); private: - RimWellPathImport* m_wellPathImportObject; RiaOsduConnector* m_osduConnector; QTableView* m_tableView; OsduWellboreTableModel* m_osduWellboresModel; @@ -340,7 +330,7 @@ class WellSummaryPage : public QWizardPage Q_OBJECT public: - WellSummaryPage( RimWellPathImport* wellPathImport, RiaOsduConnector* osduConnector, QWidget* parent = nullptr ); + WellSummaryPage( RiaOsduConnector* osduConnector, QWidget* parent = nullptr ); void initializePage() override; bool isComplete() const override; @@ -349,11 +339,10 @@ private slots: void wellboreTrajectoryFinished( const QString& wellboreId, int numTrajectories, const QString& errorMessage ); private: - RimWellPathImport* m_wellPathImportObject; - RiaOsduConnector* m_osduConnector; - QTextEdit* m_textEdit; - std::set m_pendingWellboreIds; - mutable QMutex m_mutex; + RiaOsduConnector* m_osduConnector; + QTextEdit* m_textEdit; + std::set m_pendingWellboreIds; + mutable QMutex m_mutex; }; //-------------------------------------------------------------------------------------------------- @@ -373,10 +362,7 @@ class RiuWellImportWizard : public QWizard double datumElevation; }; - RiuWellImportWizard( const QString& downloadFolder, - RiaOsduConnector* osduConnector, - RimWellPathImport* wellPathImportObject, - QWidget* parent = nullptr ); + RiuWellImportWizard( RiaOsduConnector* osduConnector, QWidget* parent = nullptr ); ~RiuWellImportWizard() override; // Methods used from the wizard pages @@ -402,11 +388,6 @@ public slots: QString m_selectedFieldId; std::vector m_selectedWellboreIds; - QString m_destinationFolder; - - RimWellPathImport* m_wellPathImportObject; - caf::PdmUiTreeView* m_pdmTreeView; - bool m_firstTimeRequestingAuthentication; std::vector m_wellInfos; diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 5377b8079f..2d0762ecb6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -113,8 +113,6 @@ #include "RimGridStatisticsPlotCollection.h" #endif -#include "OsduImportCommands/RimWellPathImport.h" - #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" @@ -161,10 +159,6 @@ RimProject::RimProject() CAF_PDM_InitFieldNoDefault( &scriptCollection, "ScriptCollection", "Octave Scripts", ":/octave.png" ); scriptCollection.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &wellPathImport, "WellPathImport", "WellPathImport" ); - wellPathImport = new RimWellPathImport(); - wellPathImport.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_mainPlotCollection, "MainPlotCollection", "Plots" ); CAF_PDM_InitFieldNoDefault( &viewLinkerCollection, "LinkedViews", "Linked Views", ":/LinkView.svg" ); @@ -914,46 +908,6 @@ const RimOilField* RimProject::activeOilField() const return oilFields[0]; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimProject::computeUtmAreaOfInterest() -{ - cvf::BoundingBox projectBB; - for ( RimCase* rimCase : allGridCases() ) - { - RimEclipseCase* eclipseCase = dynamic_cast( rimCase ); - if ( eclipseCase && eclipseCase->eclipseCaseData() ) - { - for ( size_t gridIdx = 0; gridIdx < eclipseCase->eclipseCaseData()->gridCount(); gridIdx++ ) - { - RigGridBase* rigGrid = eclipseCase->eclipseCaseData()->grid( gridIdx ); - projectBB.add( rigGrid->boundingBox() ); - } - } - else - { - // Todo : calculate BBox of GeoMechCase - } - } - - if ( projectBB.isValid() ) - { - double north, south, east, west; - - north = projectBB.max().y(); - south = projectBB.min().y(); - - west = projectBB.min().x(); - east = projectBB.max().x(); - - wellPathImport->north = north; - wellPathImport->south = south; - wellPathImport->east = east; - wellPathImport->west = west; - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.h b/ApplicationLibCode/ProjectDataModel/RimProject.h index 6c4641c481..a2f77816f0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.h +++ b/ApplicationLibCode/ProjectDataModel/RimProject.h @@ -66,7 +66,6 @@ class RimViewLinker; class RimViewLinkerCollection; class RimViewWindow; class RimWellPath; -class RimWellPathImport; class RimFractureTemplateCollection; class RimFractureTemplate; class RimValveTemplateCollection; @@ -99,7 +98,6 @@ class RimProject : public caf::PdmDocument caf::PdmChildArrayField oilFields; caf::PdmChildField colorLegendCollection; caf::PdmChildField scriptCollection; - caf::PdmChildField wellPathImport; caf::PdmChildField viewLinkerCollection; caf::PdmChildField calculationCollection; caf::PdmChildField gridCalculationCollection; @@ -146,8 +144,6 @@ class RimProject : public caf::PdmDocument void scheduleCreateDisplayModelAndRedrawAllViews(); - void computeUtmAreaOfInterest(); - [[nodiscard]] std::vector allOilFields() const; RimOilField* activeOilField(); const RimOilField* activeOilField() const; From e9c46c5cecc22dc13de0bdc75b6dbebf6b0d7afd Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 29 Jul 2024 15:38:17 +0200 Subject: [PATCH 207/332] Rename RimSummaryCaseCollection to RimSummaryEnsemble. --- .../Application/RiaApplication.cpp | 2 +- .../Application/RiaCurveSetDefinition.cpp | 6 +- .../Application/RiaCurveSetDefinition.h | 10 +- ApplicationLibCode/Application/RiaFontCache.h | 2 +- .../Application/RiaGuiApplication.cpp | 2 +- .../Application/RiaRftPltCurveDefinition.cpp | 4 +- .../Application/RiaSummaryCurveDefinition.cpp | 10 +- .../Application/RiaSummaryCurveDefinition.h | 26 ++--- .../Tools/RiaEnsembleNameTools.cpp | 2 +- .../Tools/RiaImportEclipseCaseTools.cpp | 6 +- .../Tools/RiaSummaryStringTools.cpp | 14 +-- .../Application/Tools/RiaSummaryStringTools.h | 9 +- .../Application/Tools/RiaSummaryTools.cpp | 6 +- .../Application/Tools/RiaSummaryTools.h | 8 +- .../RicNewAnalysisPlotFeature.cpp | 8 +- .../RicNewCorrelationMatrixPlotFeature.cpp | 4 +- .../RicNewCorrelationPlotFeature.cpp | 16 +-- .../RicNewCorrelationPlotFeature.h | 20 ++-- .../RicNewCorrelationReportPlotFeature.cpp | 6 +- .../RicNewParameterResultCrossPlotFeature.cpp | 8 +- .../RicCutReferencesToClipboardFeature.cpp | 2 +- ...endSummaryCurvesForSummaryCasesFeature.cpp | 4 +- ...RicAppendSummaryPlotsForObjectsFeature.cpp | 16 +-- .../RicAppendSummaryPlotsForObjectsFeature.h | 12 +- ...pendSummaryPlotsForSummaryCasesFeature.cpp | 6 +- ...AppendSummaryPlotsForSummaryCasesFeature.h | 6 +- .../RicNewEmptySummaryMultiPlotFeature.cpp | 6 +- .../RicNewSummaryMultiPlotFeature.cpp | 14 +-- .../RicNewSummaryMultiPlotFeature.h | 6 +- ...wSummaryMultiPlotFromDataVectorFeature.cpp | 14 +-- ...RicNewSummaryPlotFromDataVectorFeature.cpp | 12 +- .../RicSummaryPlotBuilder.cpp | 39 +++---- .../RicSummaryPlotBuilder.h | 38 +++--- .../RicCreateNewPlotFromTemplateFeature.cpp | 4 +- .../RicCreateNewPlotFromTemplateFeature.h | 6 +- .../RicSaveMultiPlotTemplateFeature.cpp | 4 +- .../RicSelectCaseOrEnsembleUi.cpp | 14 +-- .../RicSelectCaseOrEnsembleUi.h | 10 +- .../RicSummaryPlotTemplateTools.cpp | 60 +++++----- .../RicSummaryPlotTemplateTools.h | 32 +++--- ...RicCloseSummaryCaseInCollectionFeature.cpp | 10 +- .../RicConvertGroupToEnsembleFeature.cpp | 6 +- .../RicCreateSummaryCaseCollectionFeature.cpp | 6 +- .../RicCreateSummaryCaseCollectionFeature.h | 4 +- .../RicDeleteSummaryCaseCollectionFeature.cpp | 18 +-- .../RicDeleteSummaryCaseCollectionFeature.h | 6 +- .../Commands/RicImportEnsembleFeature.cpp | 12 +- .../RicImportRevealSummaryCaseFeature.cpp | 2 +- .../RicImportStimPlanSummaryCaseFeature.cpp | 2 +- .../Commands/RicImportSummaryCasesFeature.cpp | 6 +- .../Commands/RicReloadSummaryCaseFeature.cpp | 4 +- .../RicCreateCrossPlotFeature.cpp | 4 +- .../RicNewDefaultSummaryPlotFeature.cpp | 18 +-- .../RicNewDerivedEnsembleFeature.cpp | 6 +- .../RicNewSummaryEnsembleCurveSetFeature.cpp | 11 +- .../RicNewSummaryEnsembleCurveSetFeature.h | 6 +- .../RicOpenSummaryPlotEditorFeature.cpp | 16 +-- .../RicPasteSummaryCaseFeature.cpp | 8 +- .../RicSummaryPlotEditorUi.cpp | 20 ++-- .../RicSummaryPlotFeatureImpl.cpp | 10 +- .../RicSummaryPlotFeatureImpl.h | 8 +- .../RicCreateRftPlotsFeature.cpp | 4 +- .../FileInterface/RifDataSourceForRftPlt.cpp | 8 +- .../FileInterface/RifDataSourceForRftPlt.h | 30 ++--- .../RifReaderEnsembleStatisticsRft.cpp | 5 +- .../RifReaderEnsembleStatisticsRft.h | 8 +- .../AnalysisPlots/RimAnalysisPlot.cpp | 8 +- .../RimAnalysisPlotCollection.cpp | 19 ++- .../AnalysisPlots/RimAnalysisPlotCollection.h | 14 +-- .../RimAnalysisPlotDataEntry.cpp | 4 +- .../AnalysisPlots/RimAnalysisPlotDataEntry.h | 18 +-- .../AnalysisPlots/RimPlotDataFilterItem.cpp | 2 +- .../RimAbstractCorrelationPlot.cpp | 16 +-- .../RimAbstractCorrelationPlot.h | 6 +- .../RimCorrelationMatrixPlot.cpp | 2 +- .../CorrelationPlots/RimCorrelationPlot.cpp | 2 +- .../RimCorrelationPlotCollection.cpp | 24 ++-- .../RimCorrelationPlotCollection.h | 20 ++-- .../RimCorrelationReportPlot.cpp | 2 +- .../RimCorrelationReportPlot.h | 2 +- .../RimParameterResultCrossPlot.cpp | 4 +- .../Flow/RimDataSourceForRftPlt.cpp | 2 +- .../Flow/RimDataSourceForRftPlt.h | 14 +-- .../Flow/RimWellPlotTools.cpp | 30 ++--- .../ProjectDataModel/Flow/RimWellPlotTools.h | 16 +-- .../Flow/RimWellRftEnsembleCurveSet.cpp | 14 +-- .../Flow/RimWellRftEnsembleCurveSet.h | 18 +-- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 44 +++---- .../ProjectDataModel/Flow/RimWellRftPlot.h | 10 +- .../RimContextCommandBuilder.cpp | 6 +- .../RimCustomObjectiveFunction.cpp | 4 +- .../RimCustomObjectiveFunctionWeight.cpp | 2 +- .../ProjectDataModel/RimProject.cpp | 12 +- .../ProjectDataModel/RimProject.h | 10 +- .../RimSummaryCalculationCollection.cpp | 4 +- .../RimSummaryCalculationVariable.cpp | 2 +- .../Summary/CMakeLists_files.cmake | 4 +- .../RimDerivedEnsembleCaseCollection.cpp | 18 +-- .../RimDerivedEnsembleCaseCollection.h | 22 ++-- .../Summary/RimDerivedSummaryCase.cpp | 2 +- .../RimEnsembleCrossPlotStatisticsCase.cpp | 2 +- .../Summary/RimEnsembleCurveFilter.cpp | 12 +- .../Summary/RimEnsembleCurveSet.cpp | 77 ++++++------- .../Summary/RimEnsembleCurveSet.h | 10 +- .../RimEnsembleCurveSetColorManager.cpp | 2 +- .../Summary/RimEnsembleStatisticsCase.cpp | 2 +- .../Summary/RimObjectiveFunction.cpp | 2 +- .../Summary/RimObjectiveFunction.h | 2 +- .../Summary/RimSummaryAddressSelector.cpp | 12 +- .../Summary/RimSummaryAddressSelector.h | 8 +- .../Summary/RimSummaryCase.cpp | 6 +- .../ProjectDataModel/Summary/RimSummaryCase.h | 4 +- .../Summary/RimSummaryCaseMainCollection.cpp | 30 ++--- .../Summary/RimSummaryCaseMainCollection.h | 30 ++--- .../Summary/RimSummaryCurve.cpp | 4 +- .../Summary/RimSummaryCurveAutoName.cpp | 10 +- .../Summary/RimSummaryCurvesData.cpp | 2 +- ...eCollection.cpp => RimSummaryEnsemble.cpp} | 108 +++++++++--------- ...yCaseCollection.h => RimSummaryEnsemble.h} | 8 +- .../Summary/RimSummaryMultiPlot.cpp | 24 ++-- .../Summary/RimSummaryNameHelper.h | 2 +- .../Summary/RimSummaryPlot.cpp | 26 ++--- .../ProjectDataModel/Summary/RimSummaryPlot.h | 4 +- .../Summary/RimSummaryPlotAxisFormatter.cpp | 2 +- .../Summary/RimSummaryPlotManager.cpp | 20 ++-- .../Summary/RimSummaryPlotManager.h | 5 +- .../Summary/RimSummaryPlotNameHelper.cpp | 8 +- .../Summary/RimSummaryPlotNameHelper.h | 12 +- .../Summary/RimSummaryPlotSourceStepping.cpp | 30 ++--- .../Summary/RimSummaryPlotSourceStepping.h | 18 +-- .../RimSummaryRegressionAnalysisCurve.cpp | 4 +- .../Summary/Sumo/RimSummaryEnsembleSumo.cpp | 6 +- .../Summary/Sumo/RimSummaryEnsembleSumo.h | 4 +- .../Surfaces/RimEnsembleSurface.cpp | 6 +- .../WellLog/RimEnsembleWellLogCurveSet.cpp | 6 +- .../WellLog/RimWellLogRftCurve.cpp | 6 +- .../WellLog/RimWellLogRftCurve.h | 26 ++--- .../RimcSummaryPlotCollection.cpp | 2 +- .../RimcSummaryPlotCollection.h | 8 +- .../RimSummaryCaseCollection-Test.cpp | 8 +- .../UserInterface/RiuDragDrop.cpp | 18 +-- .../UserInterface/RiuDragDrop.h | 6 +- .../UserInterface/RiuSummaryPlot.cpp | 10 +- .../RiuSummaryVectorSelectionDialog.cpp | 7 +- .../RiuSummaryVectorSelectionDialog.h | 6 +- .../RiuSummaryVectorSelectionUi.cpp | 20 ++-- .../RiuSummaryVectorSelectionUi.h | 2 +- 147 files changed, 853 insertions(+), 863 deletions(-) rename ApplicationLibCode/ProjectDataModel/Summary/{RimSummaryCaseCollection.cpp => RimSummaryEnsemble.cpp} (87%) rename ApplicationLibCode/ProjectDataModel/Summary/{RimSummaryCaseCollection.h => RimSummaryEnsemble.h} (96%) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index df2cc4cbd9..f373e31a06 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -79,8 +79,8 @@ #include "RimStimPlanModelCollection.h" #include "RimSummaryCalculationCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSurfaceCollection.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" diff --git a/ApplicationLibCode/Application/RiaCurveSetDefinition.cpp b/ApplicationLibCode/Application/RiaCurveSetDefinition.cpp index 741e07d86a..18899bd243 100644 --- a/ApplicationLibCode/Application/RiaCurveSetDefinition.cpp +++ b/ApplicationLibCode/Application/RiaCurveSetDefinition.cpp @@ -19,7 +19,7 @@ #include "RiaCurveSetDefinition.h" #include "RifSummaryReaderInterface.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" //-------------------------------------------------------------------------------------------------- /// @@ -32,7 +32,7 @@ RiaCurveSetDefinition::RiaCurveSetDefinition() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaCurveSetDefinition::RiaCurveSetDefinition( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& summaryAddress ) +RiaCurveSetDefinition::RiaCurveSetDefinition( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& summaryAddress ) : m_ensemble( ensemble ) , m_summaryAddress( summaryAddress ) { @@ -41,7 +41,7 @@ RiaCurveSetDefinition::RiaCurveSetDefinition( RimSummaryCaseCollection* ensemble //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RiaCurveSetDefinition::ensemble() const +RimSummaryEnsemble* RiaCurveSetDefinition::ensemble() const { return m_ensemble; } diff --git a/ApplicationLibCode/Application/RiaCurveSetDefinition.h b/ApplicationLibCode/Application/RiaCurveSetDefinition.h index edc7f2bb9d..9deec24177 100644 --- a/ApplicationLibCode/Application/RiaCurveSetDefinition.h +++ b/ApplicationLibCode/Application/RiaCurveSetDefinition.h @@ -25,7 +25,7 @@ #include #include -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -34,14 +34,14 @@ class RiaCurveSetDefinition { public: RiaCurveSetDefinition(); - explicit RiaCurveSetDefinition( RimSummaryCaseCollection* emsemble, const RifEclipseSummaryAddress& summaryAddress ); + explicit RiaCurveSetDefinition( RimSummaryEnsemble* emsemble, const RifEclipseSummaryAddress& summaryAddress ); - RimSummaryCaseCollection* ensemble() const; + RimSummaryEnsemble* ensemble() const; const RifEclipseSummaryAddress& summaryAddress() const; bool operator<( const RiaCurveSetDefinition& other ) const; private: - RimSummaryCaseCollection* m_ensemble; - RifEclipseSummaryAddress m_summaryAddress; + RimSummaryEnsemble* m_ensemble; + RifEclipseSummaryAddress m_summaryAddress; }; diff --git a/ApplicationLibCode/Application/RiaFontCache.h b/ApplicationLibCode/Application/RiaFontCache.h index 1fda0497d5..e06d3f0778 100644 --- a/ApplicationLibCode/Application/RiaFontCache.h +++ b/ApplicationLibCode/Application/RiaFontCache.h @@ -31,7 +31,7 @@ template class AppEnum; } -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// diff --git a/ApplicationLibCode/Application/RiaGuiApplication.cpp b/ApplicationLibCode/Application/RiaGuiApplication.cpp index 8fee5f12cd..b08fa79e4a 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.cpp +++ b/ApplicationLibCode/Application/RiaGuiApplication.cpp @@ -77,8 +77,8 @@ #include "RimSimWellInViewCollection.h" #include "RimStimPlanColors.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "RimTextAnnotation.h" #include "RimTextAnnotationInView.h" diff --git a/ApplicationLibCode/Application/RiaRftPltCurveDefinition.cpp b/ApplicationLibCode/Application/RiaRftPltCurveDefinition.cpp index ef60ecd6d2..6bbc49fb3c 100644 --- a/ApplicationLibCode/Application/RiaRftPltCurveDefinition.cpp +++ b/ApplicationLibCode/Application/RiaRftPltCurveDefinition.cpp @@ -57,8 +57,8 @@ const QDateTime& RiaRftPltCurveDefinition::timeStep() const //-------------------------------------------------------------------------------------------------- auto RiaRftPltCurveDefinition::operator<=>( const RiaRftPltCurveDefinition& other ) const -> std::strong_ordering { - RimSummaryCaseCollection* thisEnsemble = m_curveAddress.ensemble(); - RimSummaryCaseCollection* otherEnsemble = other.m_curveAddress.ensemble(); + RimSummaryEnsemble* thisEnsemble = m_curveAddress.ensemble(); + RimSummaryEnsemble* otherEnsemble = other.m_curveAddress.ensemble(); if ( ( thisEnsemble && !otherEnsemble ) || ( !thisEnsemble && otherEnsemble ) ) { diff --git a/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp b/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp index 3c9a11f9dc..274c2973d7 100644 --- a/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp +++ b/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp @@ -23,7 +23,7 @@ #include "RifSummaryReaderInterface.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "cafAssert.h" @@ -57,7 +57,7 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCase* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& summaryAddressY ) +RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& summaryAddressY ) : m_summaryCaseY( nullptr ) , m_summaryAddressY( summaryAddressY ) , m_summaryCaseX( nullptr ) @@ -70,7 +70,7 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress ) +RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryEnsemble* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress ) : m_summaryCaseY( nullptr ) , m_summaryAddressY( summaryCurveAddress.summaryAddressY() ) , m_summaryCaseX( nullptr ) @@ -91,7 +91,7 @@ RimSummaryCase* RiaSummaryCurveDefinition::summaryCaseY() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RiaSummaryCurveDefinition::ensemble() const +RimSummaryEnsemble* RiaSummaryCurveDefinition::ensemble() const { return m_ensemble; } @@ -99,7 +99,7 @@ RimSummaryCaseCollection* RiaSummaryCurveDefinition::ensemble() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryCurveDefinition::setEnsemble( RimSummaryCaseCollection* ensemble ) +void RiaSummaryCurveDefinition::setEnsemble( RimSummaryEnsemble* ensemble ) { m_ensemble = ensemble; } diff --git a/ApplicationLibCode/Application/RiaSummaryCurveDefinition.h b/ApplicationLibCode/Application/RiaSummaryCurveDefinition.h index 74ecb14365..af76d1714e 100644 --- a/ApplicationLibCode/Application/RiaSummaryCurveDefinition.h +++ b/ApplicationLibCode/Application/RiaSummaryCurveDefinition.h @@ -29,7 +29,7 @@ #include class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RiaSummaryCurveAddress; //================================================================================================== @@ -40,12 +40,12 @@ class RiaSummaryCurveDefinition public: RiaSummaryCurveDefinition(); explicit RiaSummaryCurveDefinition( RimSummaryCase* summaryCaseY, const RifEclipseSummaryAddress& summaryAddressY, bool isEnsembleCurve ); - explicit RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& summaryAddressY ); - explicit RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress ); + explicit RiaSummaryCurveDefinition( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& summaryAddressY ); + explicit RiaSummaryCurveDefinition( RimSummaryEnsemble* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress ); // X and Y Axis - RimSummaryCaseCollection* ensemble() const; - void setEnsemble( RimSummaryCaseCollection* ensemble ); + RimSummaryEnsemble* ensemble() const; + void setEnsemble( RimSummaryEnsemble* ensemble ); // Y Axis RimSummaryCase* summaryCaseY() const; @@ -74,12 +74,12 @@ class RiaSummaryCurveDefinition static QString curveDefinitionText( const QString& caseName, const RifEclipseSummaryAddress& summaryAddress ); private: - RimSummaryCase* m_summaryCaseY; - RifEclipseSummaryAddress m_summaryAddressY; - RimSummaryCase* m_summaryCaseX; - RifEclipseSummaryAddress m_summaryAddressX; - RimSummaryCaseCollection* m_ensemble; - bool m_isEnsembleCurve; + RimSummaryCase* m_summaryCaseY; + RifEclipseSummaryAddress m_summaryAddressY; + RimSummaryCase* m_summaryCaseX; + RifEclipseSummaryAddress m_summaryAddressX; + RimSummaryEnsemble* m_ensemble; + bool m_isEnsembleCurve; }; class RiaSummaryCurveDefinitionAnalyser @@ -88,8 +88,8 @@ class RiaSummaryCurveDefinitionAnalyser RiaSummaryCurveDefinitionAnalyser() = default; void setCurveDefinitions( const std::vector& curveDefs ); - std::set m_singleSummaryCases; // All summary cases used - std::set m_ensembles; // All the ensembles referenced by the summary cases + std::set m_singleSummaryCases; // All summary cases used + std::set m_ensembles; // All the ensembles referenced by the summary cases std::set m_summaryAdresses; std::set m_vectorNames; diff --git a/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.cpp b/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.cpp index 4d26685c23..5d17195a1c 100644 --- a/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.cpp @@ -25,7 +25,7 @@ #include "RimCaseDisplayNameTools.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "cafAppEnum.h" diff --git a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp index 1f53a5db39..a3183d0f17 100644 --- a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -49,10 +49,10 @@ #include "RimProject.h" #include "RimRoffCase.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "RimWellLogRftCurve.h" @@ -121,11 +121,11 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& fil for ( RimSummaryCase* newSumCase : candidateCases ) { - RimSummaryCaseCollection* existingCollection = nullptr; + RimSummaryEnsemble* existingCollection = nullptr; auto existingSummaryCase = sumCaseColl->findTopLevelSummaryCaseFromFileName( newSumCase->summaryHeaderFilename() ); if ( existingSummaryCase ) { - existingCollection = existingSummaryCase->firstAncestorOrThisOfType(); + existingCollection = existingSummaryCase->firstAncestorOrThisOfType(); // Replace file summary case pointers in Rft Curves auto rftCurves = existingSummaryCase->objectsWithReferringPtrFieldsOfType(); diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.cpp b/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.cpp index 2e4edb12aa..f4aebecbbf 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.cpp @@ -29,8 +29,8 @@ #include "RimMainPlotCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h" @@ -142,7 +142,7 @@ void RiaSummaryStringTools::splitUsingDataSourceNames( const QStringList& filter //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair, std::vector> RiaSummaryStringTools::allDataSourcesInProject() +std::pair, std::vector> RiaSummaryStringTools::allDataSourcesInProject() { auto sumCaseMainColl = RiaSummaryTools::summaryCaseMainCollection(); if ( !sumCaseMainColl ) return { {}, {} }; @@ -156,11 +156,11 @@ std::pair, std::vector> //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair, std::vector> +std::pair, std::vector> RiaSummaryStringTools::dataSourcesMatchingFilters( const QStringList& dataSourceFilters ) { - std::vector matchingSummaryCases; - std::vector matchingEnsembles; + std::vector matchingSummaryCases; + std::vector matchingEnsembles; auto [allSummaryCases, allEnsembles] = allDataSourcesInProject(); @@ -223,8 +223,8 @@ QStringList RiaSummaryStringTools::splitIntoWords( const QString& text ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RiaSummaryStringTools::dataSourceNames( const std::vector& summaryCases, - const std::vector& ensembles ) +QStringList RiaSummaryStringTools::dataSourceNames( const std::vector& summaryCases, + const std::vector& ensembles ) { QStringList names; for ( const auto& summaryCase : summaryCases ) diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h b/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h index 1c9150026c..e284cd55ad 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h +++ b/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h @@ -25,7 +25,7 @@ class RimSummaryCase; class RifEclipseSummaryAddress; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class QString; @@ -42,14 +42,13 @@ class RiaSummaryStringTools static std::pair splitIntoAddressAndDataSourceFilters( const QString& filter ); - static std::pair, std::vector> allDataSourcesInProject(); - static std::pair, std::vector> + static std::pair, std::vector> allDataSourcesInProject(); + static std::pair, std::vector> dataSourcesMatchingFilters( const QStringList& dataSourceFilters ); static QStringList splitIntoWords( const QString& text ); - static QStringList dataSourceNames( const std::vector& summaryCases, - const std::vector& ensembles ); + static QStringList dataSourceNames( const std::vector& summaryCases, const std::vector& ensembles ); static std::set computeFilteredAddresses( const QStringList& textFilters, const std::set& sourceAddresses, diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp b/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp index 9bc190d04d..699fae29b7 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp @@ -32,9 +32,9 @@ #include "RimSummaryCalculationCollection.h" #include "RimSummaryCalculationVariable.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -268,7 +268,7 @@ RimSummaryCase* RiaSummaryTools::summaryCaseById( int caseId ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RiaSummaryTools::ensembleById( int ensembleId ) +RimSummaryEnsemble* RiaSummaryTools::ensembleById( int ensembleId ) { auto ensembles = RimProject::current()->summaryGroups(); @@ -397,7 +397,7 @@ void RiaSummaryTools::reloadSummaryCase( RimSummaryCase* summaryCase ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryTools::reloadSummaryEnsemble( RimSummaryCaseCollection* ensemble ) +void RiaSummaryTools::reloadSummaryEnsemble( RimSummaryEnsemble* ensemble ) { RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() ) diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h index 1e1f19cb30..e210015408 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h +++ b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h @@ -32,7 +32,7 @@ class RimSummaryMultiPlot; class RimSummaryMultiPlotCollection; class RimSummaryCaseMainCollection; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimSummaryTable; class RimSummaryTableCollection; class RimObservedDataCollection; @@ -76,8 +76,8 @@ class RiaSummaryTools const std::vector& values, RiaDefines::DateTimePeriod period ); - static RimSummaryCase* summaryCaseById( int caseId ); - static RimSummaryCaseCollection* ensembleById( int ensembleId ); + static RimSummaryCase* summaryCaseById( int caseId ); + static RimSummaryEnsemble* ensembleById( int ensembleId ); static QList optionsForAllSummaryCases(); static QList optionsForSummaryCases( const std::vector& cases ); @@ -86,7 +86,7 @@ class RiaSummaryTools static void copyCurveAxisData( RimSummaryCurve& curve, const RimSummaryCurve& otherCurve ); static void reloadSummaryCase( RimSummaryCase* summaryCase ); - static void reloadSummaryEnsemble( RimSummaryCaseCollection* ensemble ); + static void reloadSummaryEnsemble( RimSummaryEnsemble* ensemble ); private: static void updateRequiredCalculatedCurves( RimSummaryCase* sourceSummaryCase ); diff --git a/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.cpp b/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.cpp index 9a1f1fb3ff..9032163661 100644 --- a/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.cpp +++ b/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.cpp @@ -62,10 +62,10 @@ void RicNewAnalysisPlotFeature::onActionTriggered( bool isChecked ) CAF_ASSERT( !correlationPlotCollections.empty() ); analysisPlotColl = correlationPlotCollections.front(); - EnsemblePlotParams params = userData.value(); - RimSummaryCaseCollection* ensemble = params.ensemble; - QString quantityName = params.mainQuantityName; - std::time_t timeStep = params.timeStep; + EnsemblePlotParams params = userData.value(); + RimSummaryEnsemble* ensemble = params.ensemble; + QString quantityName = params.mainQuantityName; + std::time_t timeStep = params.timeStep; newPlot = analysisPlotColl->createAnalysisPlot( ensemble, quantityName, timeStep ); } diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.cpp b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.cpp index d3e80c8650..0e0065e189 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.cpp +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.cpp @@ -67,8 +67,8 @@ void RicNewCorrelationMatrixPlotFeature::onActionTriggered( bool isChecked ) std::vector includedQuantityNames = std::vector( params.includedQuantityNames.begin(), params.includedQuantityNames.end() ); - RimSummaryCaseCollection* ensemble = params.ensemble; - std::time_t timeStep = params.timeStep; + RimSummaryEnsemble* ensemble = params.ensemble; + std::time_t timeStep = params.timeStep; newPlot = correlationPlotColl->createCorrelationMatrixPlot( ensemble, includedQuantityNames, timeStep ); } diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.cpp b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.cpp index ddf7f48e2f..7323b909da 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.cpp +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.cpp @@ -60,10 +60,10 @@ void RicNewCorrelationPlotFeature::onActionTriggered( bool isChecked ) CAF_ASSERT( !correlationPlotCollections.empty() ); correlationPlotColl = correlationPlotCollections.front(); - EnsemblePlotParams params = userData.value(); - RimSummaryCaseCollection* ensemble = params.ensemble; - QString quantityName = params.mainQuantityName; - std::time_t timeStep = params.timeStep; + EnsemblePlotParams params = userData.value(); + RimSummaryEnsemble* ensemble = params.ensemble; + QString quantityName = params.mainQuantityName; + std::time_t timeStep = params.timeStep; newPlot = correlationPlotColl->createCorrelationPlot( ensemble, quantityName, timeStep ); } @@ -104,10 +104,10 @@ EnsemblePlotParams::EnsemblePlotParams() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -EnsemblePlotParams::EnsemblePlotParams( RimSummaryCaseCollection* ensemble, - const QStringList& includedQuantityNames, - const QString& mainQuantityName, - const std::time_t& timeStep ) +EnsemblePlotParams::EnsemblePlotParams( RimSummaryEnsemble* ensemble, + const QStringList& includedQuantityNames, + const QString& mainQuantityName, + const std::time_t& timeStep ) : ensemble( ensemble ) , includedQuantityNames( includedQuantityNames ) , mainQuantityName( mainQuantityName ) diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.h b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.h index 45412207e0..756ba0d145 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.h +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.h @@ -22,24 +22,24 @@ #include -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class EnsemblePlotParams { public: - RimSummaryCaseCollection* ensemble; - QStringList includedQuantityNames; - QString mainQuantityName; - QString ensembleParameter; - std::time_t timeStep; + RimSummaryEnsemble* ensemble; + QStringList includedQuantityNames; + QString mainQuantityName; + QString ensembleParameter; + std::time_t timeStep; EnsemblePlotParams(); EnsemblePlotParams( const EnsemblePlotParams& rhs ) = default; - EnsemblePlotParams( RimSummaryCaseCollection* ensemble, - const QStringList& includedQuantityNames, - const QString& mainQuantityName, - const std::time_t& timeStep ); + EnsemblePlotParams( RimSummaryEnsemble* ensemble, + const QStringList& includedQuantityNames, + const QString& mainQuantityName, + const std::time_t& timeStep ); ~EnsemblePlotParams() = default; }; diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.cpp b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.cpp index 19e810e676..b3fdc0650e 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.cpp +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.cpp @@ -61,9 +61,9 @@ void RicNewCorrelationReportPlotFeature::onActionTriggered( bool isChecked ) CAF_ASSERT( !correlationPlotCollections.empty() ); correlationPlotColl = correlationPlotCollections.front(); - EnsemblePlotParams params = userData.value(); - RimSummaryCaseCollection* ensemble = params.ensemble; - std::vector includedQuantityNames = + EnsemblePlotParams params = userData.value(); + RimSummaryEnsemble* ensemble = params.ensemble; + std::vector includedQuantityNames = std::vector( params.includedQuantityNames.begin(), params.includedQuantityNames.end() ); QString mainQuantityName = params.mainQuantityName; diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.cpp b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.cpp index 9f4b0cc049..d9654baf7a 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.cpp +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.cpp @@ -52,10 +52,10 @@ void RicNewParameterResultCrossPlotFeature::onActionTriggered( bool isChecked ) { RimCorrelationPlotCollection* correlationPlotColl = caf::firstAncestorOfTypeFromSelectedObject(); - RimSummaryCaseCollection* ensemble = nullptr; - QString quantityName; - QString ensembleParameter; - std::time_t timeStep = 0; + RimSummaryEnsemble* ensemble = nullptr; + QString quantityName; + QString ensembleParameter; + std::time_t timeStep = 0; RimParameterResultCrossPlot* newPlot = nullptr; if ( !correlationPlotColl ) diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCutReferencesToClipboardFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCutReferencesToClipboardFeature.cpp index d71d9d0eca..7f17e059c7 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCutReferencesToClipboardFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCutReferencesToClipboardFeature.cpp @@ -20,8 +20,8 @@ #include "RimMimeData.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "cafPdmObject.h" #include "cafPdmUiItem.h" diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.cpp index d21cab00ad..93209a6ab2 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.cpp @@ -24,7 +24,7 @@ #include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" @@ -88,7 +88,7 @@ std::vector RicAppendSummaryCurvesForSummaryCasesFeature: generalObjects.insert( generalObjects.begin(), objects.begin(), objects.end() ); } { - std::vector objects; + std::vector objects; caf::SelectionManager::instance()->objectsByType( &objects ); generalObjects.insert( generalObjects.begin(), objects.begin(), objects.end() ); diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp index 434cef964d..6baa1de7bd 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp @@ -30,8 +30,8 @@ #include "RimSummaryAddressCollection.h" #include "RimSummaryAddressModifier.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -94,7 +94,7 @@ void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* { for ( auto c : duplicatedPlot->curveSets() ) { - c->setSummaryCaseCollection( ensemble ); + c->setSummaryEnsemble( ensemble ); } } } @@ -120,9 +120,9 @@ void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* summaryMultiPlot, - const std::vector& cases, - const std::vector& ensembles ) +void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* summaryMultiPlot, + const std::vector& cases, + const std::vector& ensembles ) { auto addressCollectionsToBeDeleted = RicAppendSummaryPlotsForObjectsFeature::createAddressCollections( cases, ensembles ); RicAppendSummaryPlotsForObjectsFeature::appendPlots( summaryMultiPlot, addressCollectionsToBeDeleted ); @@ -137,8 +137,8 @@ void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* /// //-------------------------------------------------------------------------------------------------- std::vector - RicAppendSummaryPlotsForObjectsFeature::createAddressCollections( const std::vector& cases, - const std::vector& ensembles ) + RicAppendSummaryPlotsForObjectsFeature::createAddressCollections( const std::vector& cases, + const std::vector& ensembles ) { std::vector addresses; @@ -351,7 +351,7 @@ std::vector auto curveSets = sourcePlot->curveSets(); for ( auto c : curveSets ) { - if ( c->summaryCaseCollection()->ensembleId() == ensembleIdToMatch ) isMatching = true; + if ( c->summaryEnsemble()->ensembleId() == ensembleIdToMatch ) isMatching = true; } } else diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.h index 594b238a42..b68af6807b 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.h +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.h @@ -30,7 +30,7 @@ class RimSummaryMultiPlot; class RifEclipseSummaryAddress; class RimSummaryPlot; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -50,9 +50,9 @@ class RicAppendSummaryPlotsForObjectsFeature : public caf::CmdFeature static void appendPlots( RimSummaryMultiPlot* summaryMultiPlot, const std::vector& selection ); - static void appendPlots( RimSummaryMultiPlot* summaryMultiPlot, - const std::vector& cases, - const std::vector& ensembles ); + static void appendPlots( RimSummaryMultiPlot* summaryMultiPlot, + const std::vector& cases, + const std::vector& ensembles ); protected: bool isCommandEnabled() const override; @@ -60,6 +60,6 @@ class RicAppendSummaryPlotsForObjectsFeature : public caf::CmdFeature void setupActionLook( QAction* actionToSetup ) override; private: - static std::vector createAddressCollections( const std::vector& cases, - const std::vector& ensembles ); + static std::vector createAddressCollections( const std::vector& cases, + const std::vector& ensembles ); }; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.cpp index 0aece309f3..179a49eb41 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.cpp @@ -24,7 +24,7 @@ #include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "cafSelectionManager.h" @@ -86,9 +86,9 @@ std::vector RicAppendSummaryPlotsForSummaryCasesFeature::select //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicAppendSummaryPlotsForSummaryCasesFeature::selectedEnsembles() +std::vector RicAppendSummaryPlotsForSummaryCasesFeature::selectedEnsembles() { - std::vector objects; + std::vector objects; caf::SelectionManager::instance()->objectsByType( &objects ); return objects; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.h index 06b1efd555..f6247ad1aa 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.h +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.h @@ -24,7 +24,7 @@ class RimSummaryCase; class RimSummaryMultiPlot; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -39,6 +39,6 @@ class RicAppendSummaryPlotsForSummaryCasesFeature : public caf::CmdFeature void setupActionLook( QAction* actionToSetup ) override; private: - static std::vector selectedCases(); - static std::vector selectedEnsembles(); + static std::vector selectedCases(); + static std::vector selectedEnsembles(); }; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewEmptySummaryMultiPlotFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewEmptySummaryMultiPlotFeature.cpp index 0d510a8b02..55fcac0837 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewEmptySummaryMultiPlotFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewEmptySummaryMultiPlotFeature.cpp @@ -22,7 +22,7 @@ #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -41,8 +41,8 @@ CAF_CMD_SOURCE_INIT( RicNewEmptySummaryMultiPlotFeature, "RicNewEmptySummaryMult //-------------------------------------------------------------------------------------------------- void RicNewEmptySummaryMultiPlotFeature::onActionTriggered( bool isChecked ) { - std::vector selectedIndividualSummaryCases; - std::vector selectedEnsembles; + std::vector selectedIndividualSummaryCases; + std::vector selectedEnsembles; bool skipCreationOfPlotBasedOnPreferences = false; RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( selectedIndividualSummaryCases, diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.cpp index feee5f339b..50f11bed74 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.cpp @@ -22,7 +22,7 @@ #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -46,8 +46,8 @@ bool RicNewSummaryMultiPlotFeature::isCommandEnabled() const if ( selectedCollection( selectedUiItems ) ) return true; - std::vector selectedIndividualSummaryCases; - std::vector selectedEnsembles; + std::vector selectedIndividualSummaryCases; + std::vector selectedEnsembles; return selectedCases( &selectedIndividualSummaryCases, &selectedEnsembles ); } @@ -59,8 +59,8 @@ void RicNewSummaryMultiPlotFeature::onActionTriggered( bool isChecked ) std::vector selectedUiItems; caf::SelectionManager::instance()->selectedItems( selectedUiItems ); - std::vector selectedIndividualSummaryCases; - std::vector selectedEnsembles; + std::vector selectedIndividualSummaryCases; + std::vector selectedEnsembles; RimSummaryMultiPlotCollection* coll = selectedCollection( selectedUiItems ); if ( coll ) @@ -110,8 +110,8 @@ RimSummaryMultiPlotCollection* RicNewSummaryMultiPlotFeature::selectedCollection //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicNewSummaryMultiPlotFeature::selectedCases( std::vector* selectedIndividualSummaryCases, - std::vector* selectedEnsembles ) +bool RicNewSummaryMultiPlotFeature::selectedCases( std::vector* selectedIndividualSummaryCases, + std::vector* selectedEnsembles ) { CAF_ASSERT( selectedIndividualSummaryCases && selectedEnsembles ); diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.h index 3e4254daaf..eaa029493e 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.h +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.h @@ -26,7 +26,7 @@ class RimSummaryMultiPlotCollection; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -43,6 +43,6 @@ class RicNewSummaryMultiPlotFeature : public caf::CmdFeature private: static RimSummaryMultiPlotCollection* selectedCollection( std::vector& items ); - static bool selectedCases( std::vector* selectedIndividualSummaryCases, - std::vector* selectedEnsembles ); + static bool selectedCases( std::vector* selectedIndividualSummaryCases, + std::vector* selectedEnsembles ); }; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp index 91006dedb6..fbc977952b 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp @@ -23,7 +23,7 @@ #include "RimSummaryAddress.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "RicSummaryPlotBuilder.h" @@ -70,12 +70,12 @@ bool RicNewSummaryMultiPlotFromDataVectorFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicNewSummaryMultiPlotFromDataVectorFeature::onActionTriggered( bool isChecked ) { - std::vector selectedAddressItems = caf::selectedObjectsByType(); - std::set caseIds; - std::set ensembleIds; - std::vector selectedCases; - std::set eclipseAddresses; - std::vector selectedEnsembles; + std::vector selectedAddressItems = caf::selectedObjectsByType(); + std::set caseIds; + std::set ensembleIds; + std::vector selectedCases; + std::set eclipseAddresses; + std::vector selectedEnsembles; bool isEnsemble = false; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.cpp index 94d044bd12..3ef03ffa15 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.cpp @@ -67,12 +67,12 @@ bool RicNewSummaryPlotFromDataVectorFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicNewSummaryPlotFromDataVectorFeature::onActionTriggered( bool isChecked ) { - std::vector selectedAddressItems = caf::selectedObjectsByType(); - std::set caseIds; - std::set ensembleIds; - std::vector selectedCases; - std::set eclipseAddresses; - std::vector selectedEnsembles; + std::vector selectedAddressItems = caf::selectedObjectsByType(); + std::set caseIds; + std::set ensembleIds; + std::vector selectedCases; + std::set eclipseAddresses; + std::vector selectedEnsembles; bool isEnsemble = false; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp index b4a8fb6141..a9987e40c4 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp @@ -38,9 +38,9 @@ #include "RimPlot.h" #include "RimSaturationPressurePlot.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveAppearanceCalculator.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -59,8 +59,7 @@ RicSummaryPlotBuilder::RicSummaryPlotBuilder() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryPlotBuilder::setDataSources( const std::vector& summaryCases, - const std::vector& ensembles ) +void RicSummaryPlotBuilder::setDataSources( const std::vector& summaryCases, const std::vector& ensembles ) { m_summaryCases = summaryCases; m_ensembles = ensembles; @@ -224,7 +223,7 @@ std::vector RicSummaryPlotBuilder::createPlots() const //-------------------------------------------------------------------------------------------------- std::set RicSummaryPlotBuilder::addressesForSource( caf::PdmObject* summarySource ) { - auto ensemble = dynamic_cast( summarySource ); + auto ensemble = dynamic_cast( summarySource ); if ( ensemble ) { return ensemble->ensembleSummaryAddresses(); @@ -246,11 +245,11 @@ std::set RicSummaryPlotBuilder::addressesForSource( ca //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEnsembleCurveSet* RicSummaryPlotBuilder::createCurveSet( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& addr ) +RimEnsembleCurveSet* RicSummaryPlotBuilder::createCurveSet( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& addr ) { auto curveSet = new RimEnsembleCurveSet(); - curveSet->setSummaryCaseCollection( ensemble ); + curveSet->setSummaryEnsemble( ensemble ); curveSet->setSummaryAddressYAndStatisticsFlag( addr ); return curveSet; @@ -400,8 +399,8 @@ void RicSummaryPlotBuilder::appendPlotsToMultiPlot( RimMultiPlot* multiPlot, con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryMultiPlot* RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( const std::vector& cases, - const std::vector& ensembles, +RimSummaryMultiPlot* RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( const std::vector& cases, + const std::vector& ensembles, bool skipCreationOfPlotBasedOnPreferences ) { RiaPreferencesSummary* prefs = RiaPreferencesSummary::current(); @@ -604,9 +603,9 @@ RimSummaryPlot* RicSummaryPlotBuilder::createPlot( const std::vector& addresses, - const std::vector& summaryCases, - const std::vector& ensembles ) +RimSummaryPlot* RicSummaryPlotBuilder::createPlot( const std::set& addresses, + const std::vector& summaryCases, + const std::vector& ensembles ) { auto* plot = new RimSummaryPlot(); plot->enableAutoPlotTitle( true ); @@ -621,9 +620,9 @@ RimSummaryPlot* RicSummaryPlotBuilder::createPlot( const std::set& addresses, - const std::vector& summaryCases, - const std::vector& ensembles ) +RimSummaryPlot* RicSummaryPlotBuilder::createCrossPlot( const std::vector& addresses, + const std::vector& summaryCases, + const std::vector& ensembles ) { auto* summaryPlot = new RimSummaryPlot(); summaryPlot->enableAutoPlotTitle( true ); @@ -656,10 +655,10 @@ RimSummaryPlot* RicSummaryPlotBuilder::createCrossPlot( const std::vector& addresses, - const std::vector& summaryCases, - const std::vector& ensembles ) +void RicSummaryPlotBuilder::appendCurvesToPlot( RimSummaryPlot* summaryPlot, + const std::set& addresses, + const std::vector& summaryCases, + const std::vector& ensembles ) { for ( const auto& addr : addresses ) { @@ -683,11 +682,11 @@ void RicSummaryPlotBuilder::appendCurvesToPlot( RimSummaryPlot* //-------------------------------------------------------------------------------------------------- RimEnsembleCurveSet* RicSummaryPlotBuilder::addNewEnsembleCurve( RimSummaryPlot* summaryPlot, const RiaSummaryCurveAddress& curveAddress, - RimSummaryCaseCollection* ensemble ) + RimSummaryEnsemble* ensemble ) { auto* curveSet = new RimEnsembleCurveSet(); - curveSet->setSummaryCaseCollection( ensemble ); + curveSet->setSummaryEnsemble( ensemble ); curveSet->setCurveAddress( curveAddress ); cvf::Color3f curveColor = diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.h index bc57c3ba29..df2e105b5d 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.h +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.h @@ -22,7 +22,7 @@ class RimPlot; class RimMultiPlot; class RifEclipseSummaryAddress; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimSummaryPlot; class RimEnsembleCurveSet; class RimSummaryCurve; @@ -54,7 +54,7 @@ class RicSummaryPlotBuilder public: RicSummaryPlotBuilder(); - void setDataSources( const std::vector& summaryCases, const std::vector& ensembles ); + void setDataSources( const std::vector& summaryCases, const std::vector& ensembles ); void setAddresses( const std::set& addresses ); @@ -66,7 +66,7 @@ class RicSummaryPlotBuilder // Static helper functions static std::set addressesForSource( caf::PdmObject* summarySource ); - static RimEnsembleCurveSet* createCurveSet( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& addr ); + static RimEnsembleCurveSet* createCurveSet( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& addr ); static RimSummaryCurve* createCurve( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& addr ); static std::vector duplicatePlots( const std::vector& plots ); @@ -75,8 +75,8 @@ class RicSummaryPlotBuilder static RimMultiPlot* createAndAppendMultiPlot( const std::vector& plots ); static void appendPlotsToMultiPlot( RimMultiPlot* multiPlot, const std::vector& plots ); - static RimSummaryMultiPlot* createAndAppendDefaultSummaryMultiPlot( const std::vector& cases, - const std::vector& ensembles, + static RimSummaryMultiPlot* createAndAppendDefaultSummaryMultiPlot( const std::vector& cases, + const std::vector& ensembles, bool skipCreationOfPlotBasedOnPreferences = true ); static RimSummaryMultiPlot* createAndAppendSingleSummaryMultiPlotNoAutoSettings( RimSummaryPlot* plot ); @@ -87,29 +87,29 @@ class RicSummaryPlotBuilder static RimSummaryPlot* createPlot( const std::vector& summaryCurves ); - static RimSummaryPlot* createPlot( const std::set& addresses, - const std::vector& summaryCases, - const std::vector& ensembles ); + static RimSummaryPlot* createPlot( const std::set& addresses, + const std::vector& summaryCases, + const std::vector& ensembles ); - static RimSummaryPlot* createCrossPlot( const std::vector& addresses, - const std::vector& summaryCases, - const std::vector& ensembles ); + static RimSummaryPlot* createCrossPlot( const std::vector& addresses, + const std::vector& summaryCases, + const std::vector& ensembles ); - static void appendCurvesToPlot( RimSummaryPlot* summaryPlot, - const std::set& addresses, - const std::vector& summaryCases, - const std::vector& ensembles ); + static void appendCurvesToPlot( RimSummaryPlot* summaryPlot, + const std::set& addresses, + const std::vector& summaryCases, + const std::vector& ensembles ); static RimEnsembleCurveSet* - addNewEnsembleCurve( RimSummaryPlot* summaryPlot, const RiaSummaryCurveAddress& curveAddress, RimSummaryCaseCollection* ensemble ); + addNewEnsembleCurve( RimSummaryPlot* summaryPlot, const RiaSummaryCurveAddress& curveAddress, RimSummaryEnsemble* ensemble ); static RimSummaryCurve* addNewSummaryCurve( RimSummaryPlot* summaryPlot, const RiaSummaryCurveAddress& curveAddress, RimSummaryCase* summaryCase ); private: - std::set m_addresses; - std::vector m_summaryCases; - std::vector m_ensembles; + std::set m_addresses; + std::vector m_summaryCases; + std::vector m_ensembles; bool m_individualPlotPerDataSource; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.cpp index 70ab010cfc..fd20ca1d31 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.cpp @@ -27,7 +27,7 @@ #include "RicSummaryPlotTemplateTools.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RiuPlotMainWindow.h" @@ -126,7 +126,7 @@ RimSummaryCase* RicCreateNewPlotFromTemplateFeature::selectSummaryCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RicCreateNewPlotFromTemplateFeature::selectEnsemble() +RimSummaryEnsemble* RicCreateNewPlotFromTemplateFeature::selectEnsemble() { RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow(); RicSelectCaseOrEnsembleUi ui; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.h index f2ae7f7ffb..276632d3b7 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.h +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.h @@ -21,7 +21,7 @@ #include "cafCmdFeature.h" class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -36,6 +36,6 @@ class RicCreateNewPlotFromTemplateFeature : public caf::CmdFeature void setupActionLook( QAction* actionToSetup ) override; private: - RimSummaryCase* selectSummaryCase(); - RimSummaryCaseCollection* selectEnsemble(); + RimSummaryCase* selectSummaryCase(); + RimSummaryEnsemble* selectEnsemble(); }; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeature.cpp index 293c791b20..ea8e05bd59 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeature.cpp @@ -33,8 +33,8 @@ #include "RimProject.h" #include "RimSummaryAddress.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" @@ -214,7 +214,7 @@ QString RicSaveMultiPlotTemplateFeature::createTextFromObject( RimSummaryMultiPl auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword ); if ( fieldHandle ) { - auto reference = caf::PdmReferenceHelper::referenceFromFieldToObject( fieldHandle, curveSet->summaryCaseCollection() ); + auto reference = caf::PdmReferenceHelper::referenceFromFieldToObject( fieldHandle, curveSet->summaryEnsemble() ); ensembleReferenceStrings.insert( reference ); } diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.cpp index 87f728b00e..d36ebdc3b3 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.cpp @@ -22,7 +22,7 @@ #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" CAF_PDM_SOURCE_INIT( RicSelectCaseOrEnsembleUi, "RicSelectCaseOrEnsembleUi" ); @@ -52,9 +52,9 @@ void RicSelectCaseOrEnsembleUi::setEnsembleSelectionMode( bool ensembleMode ) if ( ensembleMode ) { - std::vector groups = proj->summaryGroups(); + std::vector groups = proj->summaryGroups(); - for ( RimSummaryCaseCollection* group : groups ) + for ( RimSummaryEnsemble* group : groups ) { if ( group->isEnsemble() ) { @@ -83,10 +83,10 @@ QList RicSelectCaseOrEnsembleUi::calculateValueOptions( } else if ( fieldNeedingOptions == &m_selectedEnsemble ) { - RimProject* proj = RimProject::current(); - std::vector groups = proj->summaryGroups(); + RimProject* proj = RimProject::current(); + std::vector groups = proj->summaryGroups(); - for ( RimSummaryCaseCollection* group : groups ) + for ( RimSummaryEnsemble* group : groups ) { if ( group->isEnsemble() ) options.push_back( caf::PdmOptionItemInfo( group->name(), group ) ); } @@ -120,7 +120,7 @@ RimSummaryCase* RicSelectCaseOrEnsembleUi::selectedSummaryCase() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RicSelectCaseOrEnsembleUi::selectedEnsemble() const +RimSummaryEnsemble* RicSelectCaseOrEnsembleUi::selectedEnsemble() const { if ( !m_useEnsembleMode ) return nullptr; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.h index bbb77062e6..dc5e66d31d 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.h +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.h @@ -26,7 +26,7 @@ #include class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -40,8 +40,8 @@ class RicSelectCaseOrEnsembleUi : public caf::PdmObject void setEnsembleSelectionMode( bool selectEnsemble ); - RimSummaryCase* selectedSummaryCase() const; - RimSummaryCaseCollection* selectedEnsemble() const; + RimSummaryCase* selectedSummaryCase() const; + RimSummaryEnsemble* selectedEnsemble() const; protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; @@ -49,8 +49,8 @@ class RicSelectCaseOrEnsembleUi : public caf::PdmObject QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: - caf::PdmPtrField m_selectedSummaryCase; - caf::PdmPtrField m_selectedEnsemble; + caf::PdmPtrField m_selectedSummaryCase; + caf::PdmPtrField m_selectedEnsemble; bool m_useEnsembleMode; }; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp index bd02e4765c..ceba810a69 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp @@ -36,8 +36,8 @@ #include "RimMainPlotCollection.h" #include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -77,16 +77,16 @@ RimSummaryMultiPlot* RicSummaryPlotTemplateTools::createMultiPlotFromTemplateFil //-------------------------------------------------------------------------------------------------- RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileName ) { - auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases(); - auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections(); + auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases(); + auto sumEnsembles = RicSummaryPlotTemplateTools::selectedSummaryEnsembles(); auto summaryAddressCollections = RicSummaryPlotTemplateTools::selectedSummaryAddressCollections(); - std::vector wellNames; - std::vector groupNames; - std::vector regions; - std::set caseSet; - std::set caseCollectionSet; + std::vector wellNames; + std::vector groupNames; + std::vector regions; + std::set caseSet; + std::set caseCollectionSet; if ( summaryAddressCollections.empty() ) { @@ -98,9 +98,9 @@ RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileNam analyzer.appendAddresses( firstCase->summaryReader()->allResultAddresses() ); } - else if ( !sumCaseCollections.empty() ) + else if ( !sumEnsembles.empty() ) { - auto caseCollection = sumCaseCollections.front(); + auto caseCollection = sumEnsembles.front(); auto firstCase = caseCollection->firstSummaryCase(); if ( firstCase != nullptr ) @@ -145,7 +145,7 @@ RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileNam for ( auto sumCaseCollection : caseCollectionSet ) { - sumCaseCollections.push_back( sumCaseCollection ); + sumEnsembles.push_back( sumCaseCollection ); } auto collections = RimMainPlotCollection::current()->summaryMultiPlotCollection(); @@ -156,7 +156,7 @@ RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileNam collections->addSummaryMultiPlot( newSummaryPlot ); newSummaryPlot->resolveReferencesRecursively(); - RicSummaryPlotTemplateTools::setValuesForPlaceholders( newSummaryPlot, sumCases, sumCaseCollections, wellNames, groupNames, regions ); + RicSummaryPlotTemplateTools::setValuesForPlaceholders( newSummaryPlot, sumCases, sumEnsembles, wellNames, groupNames, regions ); newSummaryPlot->initAfterReadRecursively(); newSummaryPlot->loadDataAndUpdate(); @@ -168,9 +168,9 @@ RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileNam //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileName, - const std::vector& sumCases, - const std::vector& ensembles ) +RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileName, + const std::vector& sumCases, + const std::vector& ensembles ) { std::vector wellNames; std::vector groupNames; @@ -218,12 +218,12 @@ RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryMultiPlot* summaryMultiPlot, - const std::vector& selectedSummaryCases, - const std::vector& selectedEnsembles, - const std::vector& wellNames, - const std::vector& groupNames, - const std::vector& regions ) +void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryMultiPlot* summaryMultiPlot, + const std::vector& selectedSummaryCases, + const std::vector& selectedEnsembles, + const std::vector& wellNames, + const std::vector& groupNames, + const std::vector& regions ) { auto plots = summaryMultiPlot->plots(); @@ -237,12 +237,12 @@ void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryMultiPlot* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryPlot* summaryPlot, - const std::vector& selectedSummaryCases, - const std::vector& selectedEnsembles, - const std::vector& wellNames, - const std::vector& groupNames, - const std::vector& regions ) +void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryPlot* summaryPlot, + const std::vector& selectedSummaryCases, + const std::vector& selectedEnsembles, + const std::vector& wellNames, + const std::vector& groupNames, + const std::vector& regions ) { { // Replace single summary curves data sources @@ -315,7 +315,7 @@ void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryPlot* if ( conversionOk && indexValue >= 0 && indexValue < static_cast( selectedEnsembles.size() ) ) { auto ensembleCase = selectedEnsembles[static_cast( indexValue )]; - curveSet->setSummaryCaseCollection( ensembleCase ); + curveSet->setSummaryEnsemble( ensembleCase ); } } @@ -496,9 +496,9 @@ std::vector RicSummaryPlotTemplateTools::selectedSummaryCases() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicSummaryPlotTemplateTools::selectedSummaryCaseCollections() +std::vector RicSummaryPlotTemplateTools::selectedSummaryEnsembles() { - std::vector objects; + std::vector objects; caf::SelectionManager::instance()->objectsByType( &objects ); return objects; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h index 1476d3859d..10ce7701a3 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h @@ -30,7 +30,7 @@ class PdmObject; class RimSummaryPlot; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RifEclipseSummaryAddress; class RimSummaryMultiPlot; class RimSummaryAddressCollection; @@ -45,7 +45,7 @@ class RicSummaryPlotTemplateTools static RimSummaryMultiPlot* create( const QString& fileName ); static RimSummaryMultiPlot* - create( const QString& fileName, const std::vector& cases, const std::vector& ensembles ); + create( const QString& fileName, const std::vector& cases, const std::vector& ensembles ); static QString selectPlotTemplatePath(); static std::vector selectDefaultPlotTemplates( std::vector currentSelection ); @@ -64,7 +64,7 @@ class RicSummaryPlotTemplateTools static RimSummaryMultiPlot* createMultiPlotFromTemplateFile( const QString& fileName ); static std::vector selectedSummaryCases(); - static std::vector selectedSummaryCaseCollections(); + static std::vector selectedSummaryEnsembles(); static std::vector selectedSummaryAddressCollections(); static QString htmlTextFromPlotAndSelection( const RimSummaryPlot* templatePlot, @@ -74,19 +74,19 @@ class RicSummaryPlotTemplateTools static QString htmlTextFromCount( const QString& itemText, size_t requiredItemCount, size_t selectionCount ); - static void setValuesForPlaceholders( RimSummaryMultiPlot* summaryMultiPlot, - const std::vector& selectedSummaryCases, - const std::vector& selectedEnsembles, - const std::vector& wellNames, - const std::vector& groupNames, - const std::vector& regions ); - - static void setValuesForPlaceholders( RimSummaryPlot* summaryPlot, - const std::vector& selectedSummaryCases, - const std::vector& selectedEnsembles, - const std::vector& wellNames, - const std::vector& groupNames, - const std::vector& regions ); + static void setValuesForPlaceholders( RimSummaryMultiPlot* summaryMultiPlot, + const std::vector& selectedSummaryCases, + const std::vector& selectedEnsembles, + const std::vector& wellNames, + const std::vector& groupNames, + const std::vector& regions ); + + static void setValuesForPlaceholders( RimSummaryPlot* summaryPlot, + const std::vector& selectedSummaryCases, + const std::vector& selectedEnsembles, + const std::vector& wellNames, + const std::vector& groupNames, + const std::vector& regions ); static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress, const std::set& allAddresses ); diff --git a/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp b/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp index ab8c002115..2d7f8031d9 100644 --- a/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp +++ b/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp @@ -26,8 +26,8 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "RiuPlotMainWindow.h" @@ -58,12 +58,12 @@ bool RicCloseSummaryCaseInCollectionFeature::isCommandEnabled() const std::vector summaryCaseMainCollections; caf::SelectionManager::instance()->objectsByType( &summaryCaseMainCollections ); - std::vector summaryCaseCollections; + std::vector summaryCaseCollections; caf::SelectionManager::instance()->objectsByType( &summaryCaseCollections ); summaryCaseCollections.erase( std::remove_if( summaryCaseCollections.begin(), summaryCaseCollections.end(), - []( RimSummaryCaseCollection* coll ) + []( RimSummaryEnsemble* coll ) { return dynamic_cast( coll ) != nullptr; } ), summaryCaseCollections.end() ); @@ -84,10 +84,10 @@ void RicCloseSummaryCaseInCollectionFeature::onActionTriggered( bool isChecked ) RicCloseSummaryCaseFeature::deleteSummaryCases( allSummaryCases ); } - std::vector summaryCaseCollections; + std::vector summaryCaseCollections; caf::SelectionManager::instance()->objectsByType( &summaryCaseCollections ); - for ( RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections ) + for ( RimSummaryEnsemble* summaryCaseCollection : summaryCaseCollections ) { std::vector collectionSummaryCases = summaryCaseCollection->allSummaryCases(); RicCloseSummaryCaseFeature::deleteSummaryCases( collectionSummaryCases ); diff --git a/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.cpp b/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.cpp index bb4bfef956..3196571cfc 100644 --- a/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.cpp +++ b/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.cpp @@ -29,8 +29,8 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" @@ -47,7 +47,7 @@ CAF_CMD_SOURCE_INIT( RicConvertGroupToEnsembleFeature, "RicConvertGroupToEnsembl //-------------------------------------------------------------------------------------------------- bool RicConvertGroupToEnsembleFeature::isCommandEnabled() const { - const auto& selGroups = caf::selectedObjectsByTypeStrict(); + const auto& selGroups = caf::selectedObjectsByTypeStrict(); if ( selGroups.empty() ) return false; for ( const auto& group : selGroups ) @@ -62,7 +62,7 @@ bool RicConvertGroupToEnsembleFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicConvertGroupToEnsembleFeature::onActionTriggered( bool isChecked ) { - const auto& selGroups = caf::selectedObjectsByTypeStrict(); + const auto& selGroups = caf::selectedObjectsByTypeStrict(); for ( const auto& group : selGroups ) { diff --git a/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp b/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp index 0486ffee06..99f442abec 100644 --- a/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp @@ -21,8 +21,8 @@ #include "RiaSummaryTools.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RiuPlotMainWindowTools.h" @@ -36,13 +36,13 @@ CAF_CMD_SOURCE_INIT( RicCreateSummaryCaseCollectionFeature, "RicCreateSummaryCas //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* +RimSummaryEnsemble* RicCreateSummaryCaseCollectionFeature::groupSummaryCases( std::vector cases, const QString& groupName, bool isEnsemble ) { RimSummaryCaseMainCollection* summaryCaseMainCollection = RiaSummaryTools::summaryCaseMainCollection(); if ( !cases.empty() ) { - auto newGroup = summaryCaseMainCollection->addCaseCollection( cases, groupName, isEnsemble ); + auto newGroup = summaryCaseMainCollection->addEnsemble( cases, groupName, isEnsemble ); summaryCaseMainCollection->updateConnectedEditors(); RiuPlotMainWindowTools::showPlotMainWindow(); diff --git a/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.h b/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.h index a9f1cfb1a4..2793ebcba3 100644 --- a/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.h +++ b/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.h @@ -23,7 +23,7 @@ #include class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -32,7 +32,7 @@ class RicCreateSummaryCaseCollectionFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; - static RimSummaryCaseCollection* groupSummaryCases( std::vector cases, const QString& groupName, bool isEnsemble = false ); + static RimSummaryEnsemble* groupSummaryCases( std::vector cases, const QString& groupName, bool isEnsemble = false ); private: bool isCommandEnabled() const override; diff --git a/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp b/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp index ac41678550..fd2c009441 100644 --- a/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp @@ -24,8 +24,8 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -43,7 +43,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteSummaryCaseCollectionFeature, "RicDeleteSummaryCas //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicDeleteSummaryCaseCollectionFeature::deleteSummaryCaseCollection( RimSummaryCaseCollection* caseCollection ) +void RicDeleteSummaryCaseCollectionFeature::deleteSummaryCaseCollection( RimSummaryEnsemble* caseCollection ) { RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); @@ -65,12 +65,12 @@ void RicDeleteSummaryCaseCollectionFeature::deleteSummaryCaseCollection( RimSumm //-------------------------------------------------------------------------------------------------- bool RicDeleteSummaryCaseCollectionFeature::isCommandEnabled() const { - std::vector selection; + std::vector selection; caf::SelectionManager::instance()->objectsByType( &selection ); selection.erase( std::remove_if( selection.begin(), selection.end(), - []( RimSummaryCaseCollection* coll ) + []( RimSummaryEnsemble* coll ) { return dynamic_cast( coll ) != nullptr; } ), selection.end() ); return ( !selection.empty() ); @@ -81,7 +81,7 @@ bool RicDeleteSummaryCaseCollectionFeature::isCommandEnabled() const //-------------------------------------------------------------------------------------------------- void RicDeleteSummaryCaseCollectionFeature::onActionTriggered( bool isChecked ) { - std::vector selection; + std::vector selection; caf::SelectionManager::instance()->objectsByType( &selection ); if ( selection.empty() ) return; @@ -103,14 +103,14 @@ void RicDeleteSummaryCaseCollectionFeature::onActionTriggered( bool isChecked ) if ( ret == QMessageBox::Yes ) { - for ( RimSummaryCaseCollection* summaryCaseCollection : selection ) + for ( RimSummaryEnsemble* summaryCaseCollection : selection ) { RicDeleteSummaryCaseCollectionFeature::deleteSummaryCaseCollection( summaryCaseCollection ); } } else if ( ret == QMessageBox::No ) { - for ( RimSummaryCaseCollection* summaryCaseCollection : selection ) + for ( RimSummaryEnsemble* summaryCaseCollection : selection ) { RicDeleteSummaryCaseCollectionFeature::moveAllCasesToMainSummaryCollection( summaryCaseCollection ); } @@ -118,7 +118,7 @@ void RicDeleteSummaryCaseCollectionFeature::onActionTriggered( bool isChecked ) RimSummaryCaseMainCollection* summaryCaseMainCollection = selection[0]->firstAncestorOrThisOfTypeAsserted(); - for ( RimSummaryCaseCollection* caseCollection : selection ) + for ( RimSummaryEnsemble* caseCollection : selection ) { summaryCaseMainCollection->removeCaseCollection( caseCollection ); delete caseCollection; @@ -140,7 +140,7 @@ void RicDeleteSummaryCaseCollectionFeature::setupActionLook( QAction* actionToSe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicDeleteSummaryCaseCollectionFeature::moveAllCasesToMainSummaryCollection( RimSummaryCaseCollection* summaryCaseCollection ) +void RicDeleteSummaryCaseCollectionFeature::moveAllCasesToMainSummaryCollection( RimSummaryEnsemble* summaryCaseCollection ) { std::vector summaryCases = summaryCaseCollection->allSummaryCases(); if ( summaryCases.empty() ) return; diff --git a/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.h b/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.h index d805e37108..a44fb23474 100644 --- a/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.h +++ b/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.h @@ -22,7 +22,7 @@ #include -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -36,6 +36,6 @@ class RicDeleteSummaryCaseCollectionFeature : public caf::CmdFeature void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; - static void deleteSummaryCaseCollection( RimSummaryCaseCollection* caseCollection ); - static void moveAllCasesToMainSummaryCollection( RimSummaryCaseCollection* summaryCaseCollection ); + static void deleteSummaryCaseCollection( RimSummaryEnsemble* caseCollection ); + static void moveAllCasesToMainSummaryCollection( RimSummaryEnsemble* summaryCaseCollection ); }; diff --git a/ApplicationLibCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationLibCode/Commands/RicImportEnsembleFeature.cpp index 511277681c..9abdf5c8f8 100644 --- a/ApplicationLibCode/Commands/RicImportEnsembleFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportEnsembleFeature.cpp @@ -36,8 +36,8 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "RiuMainWindow.h" @@ -119,7 +119,7 @@ void RicImportEnsembleFeature::importSingleEnsemble( const QStringList& if ( !isOk || cases.empty() ) return; - RimSummaryCaseCollection* ensemble = RicCreateSummaryCaseCollectionFeature::groupSummaryCases( cases, ensembleName, true ); + RimSummaryEnsemble* ensemble = RicCreateSummaryCaseCollectionFeature::groupSummaryCases( cases, ensembleName, true ); if ( ensemble ) { @@ -152,11 +152,11 @@ void RicImportEnsembleFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- QString RicImportEnsembleFeature::askForEnsembleName( const QString& suggestion ) { - RimProject* project = RimProject::current(); - std::vector groups = project->summaryGroups(); - int ensemblesStartingWithRoot = std::count_if( groups.begin(), + RimProject* project = RimProject::current(); + std::vector groups = project->summaryGroups(); + int ensemblesStartingWithRoot = std::count_if( groups.begin(), groups.end(), - [suggestion]( RimSummaryCaseCollection* group ) + [suggestion]( RimSummaryEnsemble* group ) { return group->isEnsemble() && group->name().startsWith( suggestion ); } ); QInputDialog dialog; diff --git a/ApplicationLibCode/Commands/RicImportRevealSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicImportRevealSummaryCaseFeature.cpp index e8f44e6e52..80a358dcbd 100644 --- a/ApplicationLibCode/Commands/RicImportRevealSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportRevealSummaryCaseFeature.cpp @@ -23,8 +23,8 @@ #include "RimCsvSummaryCase.h" #include "RimOilField.h" #include "RimProject.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RiuFileDialogTools.h" diff --git a/ApplicationLibCode/Commands/RicImportStimPlanSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicImportStimPlanSummaryCaseFeature.cpp index 90b82957c0..4bc0ffdb39 100644 --- a/ApplicationLibCode/Commands/RicImportStimPlanSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportStimPlanSummaryCaseFeature.cpp @@ -23,8 +23,8 @@ #include "RimCsvSummaryCase.h" #include "RimOilField.h" #include "RimProject.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RiuFileDialogTools.h" diff --git a/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp index 8f43fe16b6..a383ab297c 100644 --- a/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp @@ -34,8 +34,8 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" @@ -240,11 +240,11 @@ void RicImportSummaryCasesFeature::addSummaryCases( const std::vector& cases ) { - std::vector selectedColl = caf::selectedObjectsByTypeStrict(); + std::vector selectedColl = caf::selectedObjectsByTypeStrict(); if ( selectedColl.size() == 1 ) { - RimSummaryCaseCollection* coll = selectedColl.front(); + RimSummaryEnsemble* coll = selectedColl.front(); RimSummaryCaseMainCollection* mainColl = coll->firstAncestorOrThisOfType(); if ( mainColl ) diff --git a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp index a8b33df69c..8ec73873a4 100644 --- a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp @@ -24,8 +24,8 @@ #include "RimObservedDataCollection.h" #include "RimObservedSummaryData.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "cafPdmObject.h" #include "cafSelectionManager.h" @@ -84,7 +84,7 @@ std::vector RicReloadSummaryCaseFeature::selectedSummaryCases() caf::SelectionManager::instance()->objectsByType( &caseSelection ); { - std::vector collectionSelection; + std::vector collectionSelection; caf::SelectionManager::instance()->objectsByType( &collectionSelection ); for ( auto collection : collectionSelection ) diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicCreateCrossPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicCreateCrossPlotFeature.cpp index 570b45633a..23390366d4 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicCreateCrossPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicCreateCrossPlotFeature.cpp @@ -28,7 +28,7 @@ #include "RimSummaryAddress.h" #include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "cafSelectionManagerTools.h" @@ -110,7 +110,7 @@ void RicCreateCrossPlotFeature::onSubMenuActionTriggered( bool isChecked ) RiaSummaryCurveAddress curveAddress( adrX, adrY ); auto selectedCases = caf::firstAncestorOfTypeFromSelectedObject(); - auto selectedEnsembles = caf::firstAncestorOfTypeFromSelectedObject(); + auto selectedEnsembles = caf::firstAncestorOfTypeFromSelectedObject(); auto newPlot = RicSummaryPlotBuilder::createCrossPlot( { curveAddress }, { selectedCases }, { selectedEnsembles } ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp index 93fcee8d9f..b45f88f08e 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp @@ -35,8 +35,8 @@ #include "RimProject.h" #include "RimRegularLegendConfig.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" @@ -50,8 +50,8 @@ CAF_CMD_SOURCE_INIT( RicNewDefaultSummaryPlotFeature, "RicNewDefaultSummaryPlotFeature" ); -void extractPlotObjectsFromSelection( std::vector* selectedIndividualSummaryCases, - std::vector* selectedEnsembles ) +void extractPlotObjectsFromSelection( std::vector* selectedIndividualSummaryCases, + std::vector* selectedEnsembles ) { CAF_ASSERT( selectedIndividualSummaryCases && selectedEnsembles ); @@ -101,8 +101,8 @@ bool RicNewDefaultSummaryPlotFeature::isCommandEnabled() const return true; } - std::vector selectedIndividualSummaryCases; - std::vector selectedEnsembles; + std::vector selectedIndividualSummaryCases; + std::vector selectedEnsembles; extractPlotObjectsFromSelection( &selectedIndividualSummaryCases, &selectedEnsembles ); @@ -135,8 +135,8 @@ void RicNewDefaultSummaryPlotFeature::onActionTriggered( bool isChecked ) return; } - std::vector selectedIndividualSummaryCases; - std::vector selectedEnsembles; + std::vector selectedIndividualSummaryCases; + std::vector selectedEnsembles; extractPlotObjectsFromSelection( &selectedIndividualSummaryCases, &selectedEnsembles ); if ( !selectedIndividualSummaryCases.empty() ) @@ -155,8 +155,8 @@ void RicNewDefaultSummaryPlotFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicNewDefaultSummaryPlotFeature::setupActionLook( QAction* actionToSetup ) { - std::vector selectedIndividualSummaryCases; - std::vector selectedEnsembles; + std::vector selectedIndividualSummaryCases; + std::vector selectedEnsembles; extractPlotObjectsFromSelection( &selectedIndividualSummaryCases, &selectedEnsembles ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedEnsembleFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedEnsembleFeature.cpp index eae546aa50..b446aedbbe 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedEnsembleFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedEnsembleFeature.cpp @@ -63,7 +63,7 @@ bool RicNewDerivedEnsembleFeature::showWarningDialogWithQuestion() bool RicNewDerivedEnsembleFeature::isCommandEnabled() const { std::vector mainColls = caf::selectedObjectsByTypeStrict(); - std::vector ensembles = caf::selectedObjectsByTypeStrict(); + std::vector ensembles = caf::selectedObjectsByTypeStrict(); return mainColls.size() == 1 || ensembles.size() == 1 || ensembles.size() == 2; } @@ -78,11 +78,11 @@ void RicNewDerivedEnsembleFeature::onActionTriggered( bool isChecked ) auto project = RimProject::current(); auto mainColl = project->firstSummaryCaseMainCollection(); - auto newColl = mainColl->addCaseCollection( {}, "", true, []() { return new RimDerivedEnsembleCaseCollection(); } ); + auto newColl = mainColl->addEnsemble( {}, "", true, []() { return new RimDerivedEnsembleCaseCollection(); } ); auto newEnsemble = dynamic_cast( newColl ); { - std::vector ensembles = caf::selectedObjectsByType(); + std::vector ensembles = caf::selectedObjectsByType(); if ( !ensembles.empty() ) newEnsemble->setEnsemble1( ensembles[0] ); if ( ensembles.size() == 2 ) diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index 3de987c369..6cb2809bdb 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -32,10 +32,10 @@ #include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimProject.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveAppearanceCalculator.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -56,8 +56,7 @@ CAF_CMD_SOURCE_INIT( RicNewSummaryEnsembleCurveSetFeature, "RicNewSummaryEnsembl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( RimSummaryPlot* plot, - RimSummaryCaseCollection* ensemble ) +std::vector RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( RimSummaryPlot* plot, RimSummaryEnsemble* ensemble ) { CVF_ASSERT( plot && ensemble ); @@ -88,7 +87,7 @@ std::vector RicNewSummaryEnsembleCurveSetFeature::addDefau curveSet->legendConfig()->setColorLegend( RimRegularLegendConfig::mapToColorLegend( RimEnsembleCurveSetColorManager::cycledEnsembleColorRange( static_cast( colorIndex ) ) ) ); - curveSet->setSummaryCaseCollection( ensemble ); + curveSet->setSummaryEnsemble( ensemble ); curveSet->setSummaryAddressYAndStatisticsFlag( addr ); auto filter = curveSet->filterCollection()->addFilter(); filter->setActive( false ); @@ -105,7 +104,7 @@ std::vector RicNewSummaryEnsembleCurveSetFeature::addDefau //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryPlot* RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetsAndUpdate( std::vector ensembles ) +RimSummaryPlot* RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetsAndUpdate( std::vector ensembles ) { RiaGuiApplication* app = RiaGuiApplication::instance(); @@ -118,7 +117,7 @@ RimSummaryPlot* RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetsAndU RimSummaryMultiPlot* multiPlot = RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( plot ); RimEnsembleCurveSet* firstCurveSetCreated = nullptr; - for ( RimSummaryCaseCollection* ensemble : ensembles ) + for ( RimSummaryEnsemble* ensemble : ensembles ) { std::vector curveSets = RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( plot, ensemble ); if ( !firstCurveSetCreated && !curveSets.empty() ) firstCurveSetCreated = curveSets.front(); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h index e2a15100f3..3fc2a692ce 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h @@ -24,7 +24,7 @@ class RimSummaryPlot; class RimEnsembleCurveSet; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -34,8 +34,8 @@ class RicNewSummaryEnsembleCurveSetFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static RimSummaryPlot* createPlotForCurveSetsAndUpdate( std::vector ensembles ); - static std::vector addDefaultCurveSets( RimSummaryPlot* plot, RimSummaryCaseCollection* ensemble ); + static RimSummaryPlot* createPlotForCurveSetsAndUpdate( std::vector ensembles ); + static std::vector addDefaultCurveSets( RimSummaryPlot* plot, RimSummaryEnsemble* ensemble ); protected: bool isCommandEnabled() const override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicOpenSummaryPlotEditorFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicOpenSummaryPlotEditorFeature.cpp index 33766273d8..74c96d4d34 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicOpenSummaryPlotEditorFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicOpenSummaryPlotEditorFeature.cpp @@ -33,8 +33,8 @@ #include "RimProject.h" #include "RimRegularLegendConfig.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -59,7 +59,7 @@ bool RicOpenSummaryPlotEditorFeature::isCommandEnabled() const std::vector selectedCases = caf::selectedObjectsByType(); if ( !selectedCases.empty() ) return true; - std::vector selectedGroups = caf::selectedObjectsByType(); + std::vector selectedGroups = caf::selectedObjectsByType(); if ( !selectedGroups.empty() ) return true; std::vector selectedPlotCollections = caf::selectedObjectsByType(); @@ -81,7 +81,7 @@ bool RicOpenSummaryPlotEditorFeature::isCommandEnabled() const if ( multiPlot ) return true; auto summaryCase = dynamic_cast( selObj ); - auto summaryCaseColl = dynamic_cast( selObj ); + auto summaryCaseColl = dynamic_cast( selObj ); auto obsColl = dynamic_cast( selObj ); return summaryCase || summaryCaseColl || obsColl; @@ -95,16 +95,16 @@ void RicOpenSummaryPlotEditorFeature::onActionTriggered( bool isChecked ) RimProject* project = RimProject::current(); CVF_ASSERT( project ); - std::vector selectedCases = caf::selectedObjectsByType(); - std::vector selectedGroups = caf::selectedObjectsByType(); + std::vector selectedCases = caf::selectedObjectsByType(); + std::vector selectedGroups = caf::selectedObjectsByType(); std::vector sourcesToSelect( selectedCases.begin(), selectedCases.end() ); if ( sourcesToSelect.empty() && selectedGroups.empty() ) { - const auto allSingleCases = project->firstSummaryCaseMainCollection()->topLevelSummaryCases(); - const auto allGroups = project->summaryGroups(); - std::vector allEnsembles; + const auto allSingleCases = project->firstSummaryCaseMainCollection()->topLevelSummaryCases(); + const auto allGroups = project->summaryGroups(); + std::vector allEnsembles; for ( const auto group : allGroups ) if ( group->isEnsemble() ) allEnsembles.push_back( group ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCaseFeature.cpp index 6bcc1445a9..82f93c0b0a 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCaseFeature.cpp @@ -21,8 +21,8 @@ #include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "cafPdmDefaultObjectFactory.h" @@ -44,7 +44,7 @@ bool RicPasteSummaryCaseFeature::isCommandEnabled() const caf::PdmObjectHandle* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); if ( !destinationObject ) return false; - RimSummaryCaseCollection* summaryCaseCollection = destinationObject->firstAncestorOrThisOfType(); + RimSummaryEnsemble* summaryCaseCollection = destinationObject->firstAncestorOrThisOfType(); RimSummaryCaseMainCollection* summaryCaseMainCollection = destinationObject->firstAncestorOrThisOfType(); if ( !( summaryCaseCollection || summaryCaseMainCollection ) ) @@ -79,7 +79,7 @@ void RicPasteSummaryCaseFeature::onActionTriggered( bool isChecked ) std::vector> sourceObjects = RicPasteSummaryCaseFeature::summaryCases(); - RimSummaryCaseCollection* summaryCaseCollection = destinationObject->firstAncestorOrThisOfType(); + RimSummaryEnsemble* summaryCaseCollection = destinationObject->firstAncestorOrThisOfType(); if ( summaryCaseCollection ) { @@ -138,7 +138,7 @@ std::vector> RicPasteSummaryCaseFeature::summary //-------------------------------------------------------------------------------------------------- void RicPasteSummaryCaseFeature::removeFromSourceCollection( RimSummaryCase* summaryCase ) { - RimSummaryCaseCollection* sourceSummaryCaseCollection = summaryCase->firstAncestorOrThisOfType(); + RimSummaryEnsemble* sourceSummaryCaseCollection = summaryCase->firstAncestorOrThisOfType(); if ( sourceSummaryCaseCollection ) { sourceSummaryCaseCollection->removeCase( summaryCase ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp index 4fd1b0a712..64b434d21a 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp @@ -36,11 +36,11 @@ #include "RimProject.h" #include "RimSummaryCalculationCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveAutoName.h" #include "RimSummaryCurveCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" @@ -400,7 +400,7 @@ void RicSummaryPlotEditorUi::syncPreviewCurvesFromUiSelection() for ( const auto& curveSet : currentCurveSetsInPreviewPlot ) { - RimSummaryCaseCollection* ensemble = curveSet->summaryCaseCollection(); + RimSummaryEnsemble* ensemble = curveSet->summaryEnsemble(); currentCurveSetDefs.insert( RiaCurveSetDefinition( ensemble, curveSet->summaryAddressY() ) ); } @@ -416,8 +416,8 @@ void RicSummaryPlotEditorUi::syncPreviewCurvesFromUiSelection() for ( const auto& curveSet : currentCurveSetsInPreviewPlot ) { - RimSummaryCaseCollection* ensemble = curveSet->summaryCaseCollection(); - RiaCurveSetDefinition curveSetDef = RiaCurveSetDefinition( ensemble, curveSet->summaryAddressY() ); + RimSummaryEnsemble* ensemble = curveSet->summaryEnsemble(); + RiaCurveSetDefinition curveSetDef = RiaCurveSetDefinition( ensemble, curveSet->summaryAddressY() ); if ( deleteCurveSetDefs.count( curveSetDef ) > 0 ) curveSetsToDelete.insert( curveSet ); } } @@ -478,7 +478,7 @@ void RicSummaryPlotEditorUi::updatePreviewCurvesFromCurveDefinitions( const std: RimEnsembleCurveSet* curveSet = nullptr; for ( const auto& cs : m_previewPlot->ensembleCurveSetCollection()->curveSets() ) { - if ( cs->summaryCaseCollection() == curveDef.ensemble() && cs->summaryAddressY() == curveDef.summaryAddressY() ) + if ( cs->summaryEnsemble() == curveDef.ensemble() && cs->summaryAddressY() == curveDef.summaryAddressY() ) { curveSet = cs; break; @@ -488,7 +488,7 @@ void RicSummaryPlotEditorUi::updatePreviewCurvesFromCurveDefinitions( const std: { curveSet = new RimEnsembleCurveSet(); curveSet->disableStatisticCurves(); - curveSet->setSummaryCaseCollection( curveDef.ensemble() ); + curveSet->setSummaryEnsemble( curveDef.ensemble() ); // Do not call setSummaryAddressAndStatisticsFlag() here, as the call to m_statistics->updateAllRequiredEditors(); causes a // crash in updateUiOrdering. The statistics curves will be created when the curve set is added to the plot. @@ -632,7 +632,7 @@ void RicSummaryPlotEditorUi::populateCurveCreator( const RimSummaryPlot& sourceS newCurveSet->disableStatisticCurves(); previewCurveSetColl->addCurveSet( newCurveSet ); - RimSummaryCaseCollection* ensemble = curveSet->summaryCaseCollection(); + RimSummaryEnsemble* ensemble = curveSet->summaryEnsemble(); curveDefs.emplace_back( ensemble, curveSet->summaryAddressY() ); } @@ -921,15 +921,15 @@ void RicSummaryPlotEditorUi::setInitialCurveVisibility( const RimSummaryPlot* ta } } - std::set> sourceCurveSetDefs; + std::set> sourceCurveSetDefs; for ( const auto& curveSet : targetPlot->ensembleCurveSetCollection()->curveSets() ) { - sourceCurveSetDefs.insert( std::make_pair( curveSet->summaryCaseCollection(), curveSet->summaryAddressY() ) ); + sourceCurveSetDefs.insert( std::make_pair( curveSet->summaryEnsemble(), curveSet->summaryAddressY() ) ); } for ( const auto& curveSet : m_previewPlot->ensembleCurveSetCollection()->curveSets() ) { - auto curveDef = std::make_pair( curveSet->summaryCaseCollection(), curveSet->summaryAddressY() ); + auto curveDef = std::make_pair( curveSet->summaryEnsemble(), curveSet->summaryAddressY() ); if ( sourceCurveSetDefs.count( curveDef ) == 0 ) { curveSet->showCurves( false ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp index 00d3b50c08..1dc62e353a 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp @@ -312,7 +312,7 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin if ( !summaryAddressFilters.empty() ) { - RimSummaryCaseCollection* ensemble = nullptr; + RimSummaryEnsemble* ensemble = nullptr; if ( isEnsembleMode ) { @@ -510,7 +510,7 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin } RimSummaryPlot* RicSummaryPlotFeatureImpl::createSummaryPlotForEnsemble( const std::vector& summaryCasesToUse, - RimSummaryCaseCollection* ensemble, + RimSummaryEnsemble* ensemble, QStringList summaryAddressFilters, bool addHistoryCurves, EnsembleColoringType ensembleColoringStyle, @@ -545,14 +545,14 @@ RimSummaryPlot* RicSummaryPlotFeatureImpl::createSummaryPlotForEnsemble( const s //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEnsembleCurveSet* RicSummaryPlotFeatureImpl::createCurveSet( RimSummaryCaseCollection* ensemble, +RimEnsembleCurveSet* RicSummaryPlotFeatureImpl::createCurveSet( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& addr, EnsembleColoringType ensembleColoringStyle, QString ensembleColoringParameter ) { auto curveSet = new RimEnsembleCurveSet(); - curveSet->setSummaryCaseCollection( ensemble ); + curveSet->setSummaryEnsemble( ensemble ); curveSet->setSummaryAddressYAndStatisticsFlag( addr ); if ( ensembleColoringStyle == EnsembleColoringType::PARAMETER || ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER ) @@ -594,7 +594,7 @@ RimSummaryPlot* RicSummaryPlotFeatureImpl::createSummaryPlotForCases( const std: //-------------------------------------------------------------------------------------------------- std::vector RicSummaryPlotFeatureImpl::createMultipleSummaryPlotsFromAddresses( const std::vector& summaryCasesToUse, - RimSummaryCaseCollection* ensemble, + RimSummaryEnsemble* ensemble, QStringList summaryAddressFilters, bool addHistoryCurves, EnsembleColoringType ensembleColoringStyle /*= EnsembleColoringType::NONE*/, diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h index e083e3a887..4207cc33a1 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h @@ -33,7 +33,7 @@ class PdmObject; class RimSummaryCurve; class RimSummaryPlot; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimEnsembleCurveSet; class RicSummaryPlotFeatureImpl @@ -52,7 +52,7 @@ class RicSummaryPlotFeatureImpl static void createSummaryPlotsFromArgumentLine( const QStringList& arguments ); static RimSummaryPlot* createSummaryPlotForEnsemble( const std::vector& summaryCasesToUse, - RimSummaryCaseCollection* ensemble, + RimSummaryEnsemble* ensemble, QStringList summaryAddressFilters, bool addHistoryCurves = false, EnsembleColoringType ensembleColoringStyle = EnsembleColoringType::NONE, @@ -64,7 +64,7 @@ class RicSummaryPlotFeatureImpl static std::vector createMultipleSummaryPlotsFromAddresses( const std::vector& summaryCasesToUse, - RimSummaryCaseCollection* ensemble, + RimSummaryEnsemble* ensemble, QStringList summaryAddressFilters, bool addHistoryCurves = false, EnsembleColoringType ensembleColoringStyle = EnsembleColoringType::NONE, @@ -78,7 +78,7 @@ class RicSummaryPlotFeatureImpl static QString summaryPlotCommandLineHelpText(); private: - static RimEnsembleCurveSet* createCurveSet( RimSummaryCaseCollection* ensemble, + static RimEnsembleCurveSet* createCurveSet( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& addr, EnsembleColoringType ensembleColoringStyle, QString ensembleColoringParameter ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp index 41e729f3d8..1cda07c759 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicCreateRftPlotsFeature.cpp @@ -27,7 +27,7 @@ #include "RimMainPlotCollection.h" #include "RimRftPlotCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryEnsembleTools.h" #include "RimWellLogPlotNameConfig.h" #include "RimWellLogTrack.h" @@ -56,7 +56,7 @@ void RicCreateRftPlotsFeature::onActionTriggered( bool isChecked ) std::set wellsWithRftData; auto dataSource = sourcePlot->dataSource(); - if ( auto summaryCollection = std::get_if( &dataSource ) ) + if ( auto summaryCollection = std::get_if( &dataSource ) ) { wellsWithRftData = RimSummaryEnsembleTools::wellsWithRftData( ( *summaryCollection )->allSummaryCases() ); } diff --git a/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp b/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp index 6b26aa729b..4f0a06280e 100644 --- a/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp +++ b/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp @@ -25,7 +25,7 @@ #include "RimObservedFmuRftData.h" #include "RimPressureDepthData.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimWellLogLasFile.h" #include "cafAppEnum.h" @@ -83,7 +83,7 @@ RifDataSourceForRftPlt::RifDataSourceForRftPlt( RimWellLogLasFile* wellLogFile ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifDataSourceForRftPlt::RifDataSourceForRftPlt( RimSummaryCaseCollection* ensemble ) +RifDataSourceForRftPlt::RifDataSourceForRftPlt( RimSummaryEnsemble* ensemble ) { m_sourceType = SourceType::ENSEMBLE_RFT; m_ensemble = ensemble; @@ -92,7 +92,7 @@ RifDataSourceForRftPlt::RifDataSourceForRftPlt( RimSummaryCaseCollection* ensemb //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifDataSourceForRftPlt::RifDataSourceForRftPlt( RimSummaryCase* summaryCase, RimSummaryCaseCollection* ensemble, RimEclipseCase* eclipseCase ) +RifDataSourceForRftPlt::RifDataSourceForRftPlt( RimSummaryCase* summaryCase, RimSummaryEnsemble* ensemble, RimEclipseCase* eclipseCase ) { m_sourceType = SourceType::SUMMARY_RFT; m_summaryCase = summaryCase; @@ -232,7 +232,7 @@ auto RifDataSourceForRftPlt::operator<=>( const RifDataSourceForRftPlt& addr2 ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RifDataSourceForRftPlt::ensemble() const +RimSummaryEnsemble* RifDataSourceForRftPlt::ensemble() const { return m_ensemble; } diff --git a/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.h b/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.h index 218452f33a..232d5de901 100644 --- a/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.h +++ b/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.h @@ -32,7 +32,7 @@ class RimWellLogLasFile; class RimEclipseCase; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimObservedFmuRftData; class RimPressureDepthData; @@ -57,20 +57,20 @@ class RifDataSourceForRftPlt RifDataSourceForRftPlt(); RifDataSourceForRftPlt( SourceType sourceType, RimEclipseCase* eclCase ); - RifDataSourceForRftPlt( RimSummaryCaseCollection* ensemble ); - RifDataSourceForRftPlt( RimSummaryCase* summaryCase, RimSummaryCaseCollection* ensemble, RimEclipseCase* eclipseCase ); + RifDataSourceForRftPlt( RimSummaryEnsemble* ensemble ); + RifDataSourceForRftPlt( RimSummaryCase* summaryCase, RimSummaryEnsemble* ensemble, RimEclipseCase* eclipseCase ); RifDataSourceForRftPlt( RimWellLogLasFile* wellLogFile ); RifDataSourceForRftPlt( RimObservedFmuRftData* observedFmuRftData ); RifDataSourceForRftPlt( RimPressureDepthData* pressureDepthData ); SourceType sourceType() const; - RimEclipseCase* eclCase() const; - RimSummaryCase* summaryCase() const; - RimSummaryCaseCollection* ensemble() const; - RimWellLogLasFile* wellLogFile() const; - RimObservedFmuRftData* observedFmuRftData() const; - RimPressureDepthData* pressureDepthData() const; + RimEclipseCase* eclCase() const; + RimSummaryCase* summaryCase() const; + RimSummaryEnsemble* ensemble() const; + RimWellLogLasFile* wellLogFile() const; + RimObservedFmuRftData* observedFmuRftData() const; + RimPressureDepthData* pressureDepthData() const; static QString sourceTypeUiText( SourceType sourceType ); @@ -85,12 +85,12 @@ class RifDataSourceForRftPlt private: SourceType m_sourceType; - caf::PdmPointer m_eclCase; - caf::PdmPointer m_summaryCase; - caf::PdmPointer m_ensemble; - caf::PdmPointer m_wellLogFile; - caf::PdmPointer m_observedFmuRftData; - caf::PdmPointer m_pressureDepthData; + caf::PdmPointer m_eclCase; + caf::PdmPointer m_summaryCase; + caf::PdmPointer m_ensemble; + caf::PdmPointer m_wellLogFile; + caf::PdmPointer m_observedFmuRftData; + caf::PdmPointer m_pressureDepthData; }; QTextStream& operator<<( QTextStream& str, const RifDataSourceForRftPlt& addr ); diff --git a/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.cpp b/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.cpp index 84dae8d890..b8fe39ecc1 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.cpp @@ -25,7 +25,7 @@ #include "RigWellPath.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimTools.h" #include "cafAssert.h" @@ -33,8 +33,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifReaderEnsembleStatisticsRft::RifReaderEnsembleStatisticsRft( const RimSummaryCaseCollection* summaryCaseCollection, - RimEclipseCase* eclipseCase ) +RifReaderEnsembleStatisticsRft::RifReaderEnsembleStatisticsRft( const RimSummaryEnsemble* summaryCaseCollection, RimEclipseCase* eclipseCase ) : m_summaryCaseCollection( summaryCaseCollection ) , m_eclipseCase( eclipseCase ) { diff --git a/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.h b/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.h index e343d0b618..91ab39ba98 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.h +++ b/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.h @@ -25,14 +25,14 @@ #include "cvfObject.h" -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimEclipseCase; class RigWellPath; class RifReaderEnsembleStatisticsRft : public RifReaderRftInterface { public: - RifReaderEnsembleStatisticsRft( const RimSummaryCaseCollection* summaryCaseCollection, RimEclipseCase* eclipseCase ); + RifReaderEnsembleStatisticsRft( const RimSummaryEnsemble* summaryCaseCollection, RimEclipseCase* eclipseCase ); std::set eclipseRftAddresses() override; void values( const RifEclipseRftAddress& rftAddress, std::vector* values ) override; @@ -58,8 +58,8 @@ class RifReaderEnsembleStatisticsRft : public RifReaderRftInterface void clearCache( const QString& wellName, const QDateTime& timeStep ); private: - const RimSummaryCaseCollection* m_summaryCaseCollection; - RimEclipseCase* m_eclipseCase; + const RimSummaryEnsemble* m_summaryCaseCollection; + RimEclipseCase* m_eclipseCase; std::map> m_cachedValues; }; diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp index d69bc2fa9b..cdc24d2212 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp @@ -34,7 +34,7 @@ #include "RimPlotDataFilterCollection.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlotAxisFormatter.h" #include "RiuContextMenuLauncher.h" @@ -259,7 +259,7 @@ std::set RimAnalysisPlot::ensembleParameters() const RiaSummaryCurveDefinitionAnalyser* analyserOfSelectedCurveDefs = updateAndGetCurveAnalyzer(); - std::set ensembles; + std::set ensembles; for ( RimSummaryCase* sumCase : analyserOfSelectedCurveDefs->m_singleSummaryCases ) { @@ -269,7 +269,7 @@ std::set RimAnalysisPlot::ensembleParameters() const } } - for ( RimSummaryCaseCollection* ensemble : ensembles ) + for ( RimSummaryEnsemble* ensemble : ensembles ) { std::vector parameters = ensemble->variationSortedEnsembleParameters(); ensembleParms.insert( parameters.begin(), parameters.end() ); @@ -671,7 +671,7 @@ QList RimAnalysisPlot::calculateValueOptions( const caf: for ( auto sumCase : allSummaryCases ) { QString displayName = sumCase->displayCaseName(); - auto caseColl = dynamic_cast( sumCase->parentField()->ownerObject() ); + auto caseColl = dynamic_cast( sumCase->parentField()->ownerObject() ); if ( caseColl ) { displayName = caseColl->name() + "/" + displayName; diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp index 7ca063932c..5a9cf7c8fa 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp @@ -24,7 +24,7 @@ #include "RimPlotDataFilterCollection.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" CAF_PDM_SOURCE_INIT( RimAnalysisPlotCollection, "AnalysisPlotCollection" ); @@ -83,8 +83,7 @@ RimAnalysisPlot* RimAnalysisPlotCollection::createAnalysisPlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimAnalysisPlot* - RimAnalysisPlotCollection::createAnalysisPlot( RimSummaryCaseCollection* ensemble, const QString& quantityName, std::time_t timeStep ) +RimAnalysisPlot* RimAnalysisPlotCollection::createAnalysisPlot( RimSummaryEnsemble* ensemble, const QString& quantityName, std::time_t timeStep ) { RimAnalysisPlot* plot = new RimAnalysisPlot(); plot->setAsPlotMdiWindow(); @@ -181,9 +180,9 @@ void RimAnalysisPlotCollection::applyAllSummaryCasesAndFieldAddressesToPlot( Rim //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimAnalysisPlotCollection::applySummaryCaseCollectionAndFieldAddressToPlot( RimAnalysisPlot* plot, - RimSummaryCaseCollection* summaryCaseCollection, - const std::string& quantityName ) +void RimAnalysisPlotCollection::applySummaryCaseCollectionAndFieldAddressToPlot( RimAnalysisPlot* plot, + RimSummaryEnsemble* summaryCaseCollection, + const std::string& quantityName ) { if ( summaryCaseCollection ) { @@ -219,9 +218,9 @@ void RimAnalysisPlotCollection::applySummaryCaseCollectionAndFieldAddressToPlot( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RimAnalysisPlotCollection::firstEnsemble() const +RimSummaryEnsemble* RimAnalysisPlotCollection::firstEnsemble() const { - std::vector allSummaryCaseCollections = RimProject::current()->descendantsOfType(); + std::vector allSummaryCaseCollections = RimProject::current()->descendantsOfType(); for ( auto summaryCaseCollection : allSummaryCaseCollections ) { if ( summaryCaseCollection->isEnsemble() ) return summaryCaseCollection; @@ -232,9 +231,9 @@ RimSummaryCaseCollection* RimAnalysisPlotCollection::firstEnsemble() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RimAnalysisPlotCollection::firstSummaryCaseCollection() const +RimSummaryEnsemble* RimAnalysisPlotCollection::firstSummaryCaseCollection() const { - std::vector allSummaryCaseCollections = RimProject::current()->descendantsOfType(); + std::vector allSummaryCaseCollections = RimProject::current()->descendantsOfType(); if ( !allSummaryCaseCollections.empty() ) return allSummaryCaseCollections.front(); diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.h b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.h index 7467a7a441..80c32c9f4a 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.h @@ -26,7 +26,7 @@ #include -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -41,7 +41,7 @@ class RimAnalysisPlotCollection : public caf::PdmObject, public RimTypedPlotColl ~RimAnalysisPlotCollection() override; RimAnalysisPlot* createAnalysisPlot(); - RimAnalysisPlot* createAnalysisPlot( RimSummaryCaseCollection* ensemble, const QString& quantityName, std::time_t timeStep ); + RimAnalysisPlot* createAnalysisPlot( RimSummaryEnsemble* ensemble, const QString& quantityName, std::time_t timeStep ); void updateSummaryNameHasChanged(); @@ -54,12 +54,12 @@ class RimAnalysisPlotCollection : public caf::PdmObject, public RimTypedPlotColl void applyFirstEnsembleFieldAddressesToPlot( RimAnalysisPlot* plot, const std::string& quantityName = "" ); void applyFirstSummaryCaseCollectionAndFieldAddressesToPlot( RimAnalysisPlot* plot, const std::string& quantityName = "" ); void applyAllSummaryCasesAndFieldAddressesToPlot( RimAnalysisPlot* plot, const std::string& quantityName = "" ); - void applySummaryCaseCollectionAndFieldAddressToPlot( RimAnalysisPlot* plot, - RimSummaryCaseCollection* summaryCaseCollection, - const std::string& quantityName ); + void applySummaryCaseCollectionAndFieldAddressToPlot( RimAnalysisPlot* plot, + RimSummaryEnsemble* summaryCaseCollection, + const std::string& quantityName ); - RimSummaryCaseCollection* firstEnsemble() const; - RimSummaryCaseCollection* firstSummaryCaseCollection() const; + RimSummaryEnsemble* firstEnsemble() const; + RimSummaryEnsemble* firstSummaryCaseCollection() const; private: caf::PdmChildArrayField m_analysisPlots; diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp index 0270c25904..c2e50c5e7c 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp @@ -21,7 +21,7 @@ #include "RiaSummaryCurveDefinition.h" #include "RifEclipseSummaryAddress.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryAddress.h" #include "RimSummaryCase.h" @@ -98,7 +98,7 @@ RimSummaryCase* RimAnalysisPlotDataEntry::summaryCase() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RimAnalysisPlotDataEntry::ensemble() const +RimSummaryEnsemble* RimAnalysisPlotDataEntry::ensemble() const { return m_ensemble; } diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.h b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.h index cc73e7aa7e..4c82cb331b 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.h +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.h @@ -25,7 +25,7 @@ class RimSummaryCase; class RimSummaryAddress; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RiaSummaryCurveDefinition; class RifEclipseSummaryAddress; @@ -40,14 +40,14 @@ class RimAnalysisPlotDataEntry : public caf::PdmObject void setFromCurveDefinition( const RiaSummaryCurveDefinition& curveDef ); RiaSummaryCurveDefinition curveDefinition() const; - RimSummaryCase* summaryCase() const; - RimSummaryCaseCollection* ensemble() const; - RifEclipseSummaryAddress summaryAddress() const; - bool isEnsembleCurve() const; + RimSummaryCase* summaryCase() const; + RimSummaryEnsemble* ensemble() const; + RifEclipseSummaryAddress summaryAddress() const; + bool isEnsembleCurve() const; private: - caf::PdmPtrField m_summaryCase; - caf::PdmPtrField m_ensemble; - caf::PdmChildField m_summaryAddress; - caf::PdmField m_isEnsembleCurve; + caf::PdmPtrField m_summaryCase; + caf::PdmPtrField m_ensemble; + caf::PdmChildField m_summaryAddress; + caf::PdmField m_isEnsembleCurve; }; diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp index 8ac9c6b181..599a6ee699 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp @@ -25,7 +25,7 @@ #include "RimAnalysisPlot.h" #include "RimSummaryAddress.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "cafPdmUiActionPushButtonEditor.h" #include "cafPdmUiDoubleSliderEditor.h" diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp index f657e90da0..0f33aa3fb1 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp @@ -31,7 +31,7 @@ #include "RimProject.h" #include "RimSummaryAddress.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryEnsembleTools.h" #include "RiuContextMenuLauncher.h" @@ -304,7 +304,7 @@ QList RimAbstractCorrelationPlot::calculateValueOptions( } else if ( fieldNeedingOptions == &m_curveSetForFiltering ) { - RimSummaryCaseCollection* ensemble = nullptr; + RimSummaryEnsemble* ensemble = nullptr; for ( auto e : m_dataSources ) { @@ -340,7 +340,7 @@ std::set RimAbstractCorrelationPlot::allAvailableTimeSteps() std::set timeStepUnion; RiaSummaryCurveDefinitionAnalyser* analyserOfSelectedCurveDefs = getOrCreateSelectedCurveDefAnalyser(); - for ( RimSummaryCaseCollection* ensemble : analyserOfSelectedCurveDefs->m_ensembles ) + for ( RimSummaryEnsemble* ensemble : analyserOfSelectedCurveDefs->m_ensembles ) { const std::set& timeSteps = ensemble->ensembleTimeSteps(); timeStepUnion.insert( timeSteps.begin(), timeSteps.end() ); @@ -390,7 +390,7 @@ std::set RimAbstractCorrelationPlot::addresses() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimAbstractCorrelationPlot::ensembles() const +std::set RimAbstractCorrelationPlot::ensembles() const { RiaSummaryCurveDefinitionAnalyser* analyserOfSelectedCurveDefs = getOrCreateSelectedCurveDefAnalyser(); return analyserOfSelectedCurveDefs->m_ensembles; @@ -399,7 +399,7 @@ std::set RimAbstractCorrelationPlot::ensembles() cons //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimAbstractCorrelationPlot::filterEnsembleCases( RimSummaryCaseCollection* ensemble ) const +std::set RimAbstractCorrelationPlot::filterEnsembleCases( RimSummaryEnsemble* ensemble ) const { std::set setOfCases; @@ -407,7 +407,7 @@ std::set RimAbstractCorrelationPlot::filterEnsembleCases( RimSu { std::vector summaryCasesVector; - if ( m_useCaseFilter() && m_curveSetForFiltering() && m_curveSetForFiltering->summaryCaseCollection() == ensemble ) + if ( m_useCaseFilter() && m_curveSetForFiltering() && m_curveSetForFiltering->summaryEnsemble() == ensemble ) { summaryCasesVector = m_curveSetForFiltering->filterEnsembleCases( ensemble->allSummaryCases() ); } @@ -464,7 +464,7 @@ std::set RimAbstractCorrelationPlot::ensembleParameters() RiaSummaryCurveDefinitionAnalyser* analyserOfSelectedCurveDefs = getOrCreateSelectedCurveDefAnalyser(); - for ( RimSummaryCaseCollection* ensemble : analyserOfSelectedCurveDefs->m_ensembles ) + for ( RimSummaryEnsemble* ensemble : analyserOfSelectedCurveDefs->m_ensembles ) { std::vector parameters = RimSummaryEnsembleTools::alphabeticEnsembleParameters( ensemble->allSummaryCases() ); ensembleParms.insert( parameters.begin(), parameters.end() ); @@ -481,7 +481,7 @@ std::set RimAbstractCorrelationPlot::variationSortedEnsemb RiaSummaryCurveDefinitionAnalyser* analyserOfSelectedCurveDefs = getOrCreateSelectedCurveDefAnalyser(); - for ( RimSummaryCaseCollection* ensemble : analyserOfSelectedCurveDefs->m_ensembles ) + for ( RimSummaryEnsemble* ensemble : analyserOfSelectedCurveDefs->m_ensembles ) { std::vector parameters = ensemble->variationSortedEnsembleParameters(); ensembleParms.insert( parameters.begin(), parameters.end() ); diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.h b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.h index fcc27671aa..095dd7e896 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.h +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.h @@ -32,7 +32,7 @@ class RiaSummaryCurveDefinitionAnalyser; class RimAnalysisPlotDataEntry; class RimSummaryAddress; class RimEnsembleCurveSet; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimSummaryCase; class RigEnsembleParameter; class RifEclipseSummaryAddress; @@ -52,10 +52,10 @@ class RimAbstractCorrelationPlot : public RimPlot std::vector curveDefinitions() const; void setCurveDefinitions( const std::vector& curveDefinitions ); void setTimeStep( std::time_t timeStep ); - std::set ensembles() const; + std::set ensembles() const; // Get summary cases filtered by attached ensemble parameter filter - std::set filterEnsembleCases( RimSummaryCaseCollection* ensemble ) const; + std::set filterEnsembleCases( RimSummaryEnsemble* ensemble ) const; bool isCaseFilterEnabled() const; void enableCaseFilter( bool enable ); RimEnsembleCurveSet* caseFilterDataSource() const; diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp index f972ba8795..b117efff40 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp @@ -37,7 +37,7 @@ #include "RimRegularLegendConfig.h" #include "RimSummaryAddress.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlotAxisFormatter.h" #include "RiuPlotMainWindowTools.h" diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp index f9f972e40e..fd1665020e 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp @@ -36,7 +36,7 @@ #include "RimPlotDataFilterCollection.h" #include "RimSummaryAddress.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlotAxisFormatter.h" #include "cafFontTools.h" diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp index 9f31a77c5a..f48fe20ad4 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp @@ -25,7 +25,7 @@ #include "RimCorrelationReportPlot.h" #include "RimParameterResultCrossPlot.h" #include "RimProject.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryEnsembleTools.h" CAF_PDM_SOURCE_INIT( RimCorrelationPlotCollection, "CorrelationPlotCollection" ); @@ -68,7 +68,7 @@ RimCorrelationPlot* RimCorrelationPlotCollection::createCorrelationPlot( bool de /// //-------------------------------------------------------------------------------------------------- RimCorrelationPlot* - RimCorrelationPlotCollection::createCorrelationPlot( RimSummaryCaseCollection* ensemble, const QString& quantityName, std::time_t timeStep ) + RimCorrelationPlotCollection::createCorrelationPlot( RimSummaryEnsemble* ensemble, const QString& quantityName, std::time_t timeStep ) { RimCorrelationPlot* plot = new RimCorrelationPlot(); plot->setAsPlotMdiWindow(); @@ -99,7 +99,7 @@ RimCorrelationMatrixPlot* RimCorrelationPlotCollection::createCorrelationMatrixP //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCorrelationMatrixPlot* RimCorrelationPlotCollection::createCorrelationMatrixPlot( RimSummaryCaseCollection* ensemble, +RimCorrelationMatrixPlot* RimCorrelationPlotCollection::createCorrelationMatrixPlot( RimSummaryEnsemble* ensemble, const std::vector& quantityNames, std::time_t timeStep ) { @@ -129,10 +129,10 @@ RimParameterResultCrossPlot* RimCorrelationPlotCollection::createParameterResult //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimParameterResultCrossPlot* RimCorrelationPlotCollection::createParameterResultCrossPlot( RimSummaryCaseCollection* ensemble, - const QString& paramName, - const QString& quantityName, - std::time_t timeStep ) +RimParameterResultCrossPlot* RimCorrelationPlotCollection::createParameterResultCrossPlot( RimSummaryEnsemble* ensemble, + const QString& paramName, + const QString& quantityName, + std::time_t timeStep ) { RimParameterResultCrossPlot* plot = new RimParameterResultCrossPlot; plot->setAsPlotMdiWindow(); @@ -160,7 +160,7 @@ RimCorrelationReportPlot* RimCorrelationPlotCollection::createCorrelationReportP //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCorrelationReportPlot* RimCorrelationPlotCollection::createCorrelationReportPlot( RimSummaryCaseCollection* ensemble, +RimCorrelationReportPlot* RimCorrelationPlotCollection::createCorrelationReportPlot( RimSummaryEnsemble* ensemble, const std::vector& matrixQuantityNames, const QString& tornadoAndCrossPlotQuantityName, std::time_t timeStep ) @@ -230,7 +230,7 @@ void RimCorrelationPlotCollection::deleteAllPlots() void RimCorrelationPlotCollection::applyFirstEnsembleFieldAddressesToPlot( RimAbstractCorrelationPlot* plot, const std::vector& quantityNames /*= {} */ ) { - std::vector ensembles = RimProject::current()->descendantsIncludingThisOfType(); + std::vector ensembles = RimProject::current()->descendantsIncludingThisOfType(); if ( !ensembles.empty() ) { std::set allAddresses = ensembles.front()->ensembleSummaryAddresses(); @@ -258,7 +258,7 @@ void RimCorrelationPlotCollection::applyFirstEnsembleFieldAddressesToPlot( RimAb /// //-------------------------------------------------------------------------------------------------- void RimCorrelationPlotCollection::applyEnsembleFieldAndTimeStepToPlot( RimAbstractCorrelationPlot* plot, - RimSummaryCaseCollection* ensemble, + RimSummaryEnsemble* ensemble, const std::vector& quantityNames, std::time_t timeStep ) { @@ -296,7 +296,7 @@ void RimCorrelationPlotCollection::applyFirstEnsembleFieldAddressesToReport( Rim const std::vector& matrixQuantityNames, const QString& tornadoAndCrossPlotQuantityName ) { - std::vector ensembles = RimProject::current()->descendantsIncludingThisOfType(); + std::vector ensembles = RimProject::current()->descendantsIncludingThisOfType(); if ( !ensembles.empty() ) { std::set allAddresses = ensembles.front()->ensembleSummaryAddresses(); @@ -336,7 +336,7 @@ void RimCorrelationPlotCollection::applyFirstEnsembleFieldAddressesToReport( Rim /// //-------------------------------------------------------------------------------------------------- void RimCorrelationPlotCollection::applyEnsembleFieldAndTimeStepToReport( RimCorrelationReportPlot* plot, - RimSummaryCaseCollection* ensemble, + RimSummaryEnsemble* ensemble, const std::vector& matrixQuantityNames, const QString& tornadoAndCrossPlotQuantityName, std::time_t timeStep ) diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.h b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.h index ae1c851a2a..0e9c11b4d7 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.h @@ -31,7 +31,7 @@ class RimCorrelationPlot; class RimCorrelationMatrixPlot; class RimCorrelationReportPlot; class RimParameterResultCrossPlot; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -46,20 +46,20 @@ class RimCorrelationPlotCollection : public caf::PdmObject, public RimTypedPlotC ~RimCorrelationPlotCollection() override; RimCorrelationPlot* createCorrelationPlot( bool defaultToFirstEnsembleFopt = true ); - RimCorrelationPlot* createCorrelationPlot( RimSummaryCaseCollection* ensemble, const QString& quantityName, std::time_t timeStep ); + RimCorrelationPlot* createCorrelationPlot( RimSummaryEnsemble* ensemble, const QString& quantityName, std::time_t timeStep ); RimCorrelationMatrixPlot* createCorrelationMatrixPlot( bool defaultToFirstEnsembleField = true ); RimCorrelationMatrixPlot* - createCorrelationMatrixPlot( RimSummaryCaseCollection* ensemble, const std::vector& quantityNames, std::time_t timeStep ); + createCorrelationMatrixPlot( RimSummaryEnsemble* ensemble, const std::vector& quantityNames, std::time_t timeStep ); RimParameterResultCrossPlot* createParameterResultCrossPlot( bool defaultToFirstEnsembleFopt = true ); - RimParameterResultCrossPlot* createParameterResultCrossPlot( RimSummaryCaseCollection* ensemble, - const QString& paramName, - const QString& quantityName, - std::time_t timeStep ); + RimParameterResultCrossPlot* createParameterResultCrossPlot( RimSummaryEnsemble* ensemble, + const QString& paramName, + const QString& quantityName, + std::time_t timeStep ); RimCorrelationReportPlot* createCorrelationReportPlot( bool defaultToFirstEnsembleField = true ); - RimCorrelationReportPlot* createCorrelationReportPlot( RimSummaryCaseCollection* ensemble, + RimCorrelationReportPlot* createCorrelationReportPlot( RimSummaryEnsemble* ensemble, const std::vector& matrixQuantityNames, const QString& tornadoAndCrossPlotQuantityName, std::time_t timeStep ); @@ -78,14 +78,14 @@ class RimCorrelationPlotCollection : public caf::PdmObject, public RimTypedPlotC private: void applyFirstEnsembleFieldAddressesToPlot( RimAbstractCorrelationPlot* plot, const std::vector& quantityNames = {} ); void applyEnsembleFieldAndTimeStepToPlot( RimAbstractCorrelationPlot* plot, - RimSummaryCaseCollection* ensemble, + RimSummaryEnsemble* ensemble, const std::vector& quantityNames, std::time_t timeStep ); void applyFirstEnsembleFieldAddressesToReport( RimCorrelationReportPlot* plot, const std::vector& matrixQuantityNames, const QString& tornadoAndCrossPlotQuantityName ); void applyEnsembleFieldAndTimeStepToReport( RimCorrelationReportPlot* plot, - RimSummaryCaseCollection* ensemble, + RimSummaryEnsemble* ensemble, const std::vector& matrixQuantityNames, const QString& tornadoAndCrossPlotQuantityName, std::time_t timeStep ); diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp index e75eb7d66d..a8a616510d 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp @@ -26,7 +26,7 @@ #include "RimCorrelationPlotCollection.h" #include "RimParameterResultCrossPlot.h" #include "RimRegularLegendConfig.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RiuMultiPlotPage.h" #include "RiuPlotWidget.h" diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.h b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.h index 757a47b170..36c63ef34d 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.h +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.h @@ -30,7 +30,7 @@ class RimAnalysisPlotDataEntry; class RimCorrelationMatrixPlot; class RimParameterResultCrossPlot; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimCorrelationPlot; class RiaSummaryCurveDefinition; diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp index 7d3c8661cd..386dd01f17 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp @@ -36,7 +36,7 @@ #include "RimProject.h" #include "RimSummaryAddress.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlotAxisFormatter.h" #include "RiuPlotCurve.h" @@ -203,7 +203,7 @@ void RimParameterResultCrossPlot::updateAxes() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList caseNamesOfValidEnsembleCases( const RimSummaryCaseCollection* ensemble ) +QStringList caseNamesOfValidEnsembleCases( const RimSummaryEnsemble* ensemble ) { QStringList caseNames; for ( auto summaryCase : ensemble->allSummaryCases() ) diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.cpp index 510fea492f..15b6fadec6 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.cpp @@ -21,7 +21,7 @@ #include "RimObservedFmuRftData.h" #include "RimPressureDepthData.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimWellLogLasFile.h" #include "cafAppEnum.h" diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.h b/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.h index 58b5c1f0e3..d4633118c5 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.h @@ -34,7 +34,7 @@ #include class RimObservedFmuRftData; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimWellLogLasFile; class RimEclipseCase; @@ -59,10 +59,10 @@ class RimDataSourceForRftPlt : public caf::PdmObject private: caf::PdmField> m_sourceType; - caf::PdmPtrField m_eclCase; - caf::PdmPtrField m_summaryCase; - caf::PdmPtrField m_ensemble; - caf::PdmPtrField m_wellLogFile; - caf::PdmPtrField m_observedFmuRftData; - caf::PdmPtrField m_pressureDepthData; + caf::PdmPtrField m_eclCase; + caf::PdmPtrField m_summaryCase; + caf::PdmPtrField m_ensemble; + caf::PdmPtrField m_wellLogFile; + caf::PdmPtrField m_observedFmuRftData; + caf::PdmPtrField m_pressureDepthData; }; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 1943183b6a..515c0d74b5 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -33,7 +33,7 @@ #include "RimPressureDepthData.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryEnsembleTools.h" #include "RimWellLogChannel.h" #include "RimWellLogExtractionCurve.h" @@ -449,15 +449,15 @@ std::set rftTimeStepsForWell( const std::vector& sum //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector rftEnsemblesForWell( const QString& simWellName ) +std::vector rftEnsemblesForWell( const QString& simWellName ) { const RimProject* project = RimProject::current(); - std::vector allSummaryCaseCollections = project->summaryGroups(); + std::vector allSummaryCaseCollections = project->summaryGroups(); - std::vector rftEnsembles; + std::vector rftEnsembles; - for ( RimSummaryCaseCollection* summaryCaseColl : allSummaryCaseCollections ) + for ( RimSummaryEnsemble* summaryCaseColl : allSummaryCaseCollections ) { if ( summaryCaseColl && summaryCaseColl->isEnsemble() && !rftTimeStepsForWell( summaryCaseColl->allSummaryCases(), simWellName ).empty() ) @@ -471,15 +471,15 @@ std::vector rftEnsemblesForWell( const QString& simWe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector rftEnsembles() +std::vector rftEnsembles() { const RimProject* project = RimProject::current(); - std::vector allSummaryCaseCollections = project->summaryGroups(); + std::vector allSummaryCaseCollections = project->summaryGroups(); - std::vector rftEnsembles; + std::vector rftEnsembles; - for ( RimSummaryCaseCollection* summaryCaseColl : allSummaryCaseCollections ) + for ( RimSummaryEnsemble* summaryCaseColl : allSummaryCaseCollections ) { if ( summaryCaseColl && summaryCaseColl->isEnsemble() && !RimSummaryEnsembleTools::wellsWithRftData( summaryCaseColl->allSummaryCases() ).empty() ) @@ -663,11 +663,11 @@ RiaRftPltCurveDefinition curveDefFromCurve( const RimWellLogCurve* curve ) if ( rftCurve != nullptr ) { - RimEclipseResultCase* rftCase = dynamic_cast( rftCurve->eclipseCase() ); - RimSummaryCase* rftSummaryCase = rftCurve->summaryCase(); - RimSummaryCaseCollection* rftEnsemble = rftCurve->ensemble(); - RimObservedFmuRftData* rftFmuData = rftCurve->observedFmuRftData(); - RimPressureDepthData* pressureDepthData = rftCurve->pressureDepthData(); + RimEclipseResultCase* rftCase = dynamic_cast( rftCurve->eclipseCase() ); + RimSummaryCase* rftSummaryCase = rftCurve->summaryCase(); + RimSummaryEnsemble* rftEnsemble = rftCurve->ensemble(); + RimObservedFmuRftData* rftFmuData = rftCurve->observedFmuRftData(); + RimPressureDepthData* pressureDepthData = rftCurve->pressureDepthData(); const RifEclipseRftAddress rftAddress = rftCurve->rftAddress(); const QString& wellName = rftAddress.wellName(); @@ -678,7 +678,7 @@ RiaRftPltCurveDefinition curveDefFromCurve( const RimWellLogCurve* curve ) // Presens of rftSummaryCase must be tested before rftCase because a rftSummaryCase can have a rftCase // The rftCase is used to extract TVD/MD from the grid model - RimSummaryCaseCollection* parentEnsemble = rftSummaryCase->firstAncestorOrThisOfType(); + RimSummaryEnsemble* parentEnsemble = rftSummaryCase->firstAncestorOrThisOfType(); return RiaRftPltCurveDefinition( RifDataSourceForRftPlt( rftSummaryCase, parentEnsemble, rftCase ), wellName, timeStep ); } else if ( rftCase != nullptr ) diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h index f6f4f8d9f7..f87e7262e2 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.h @@ -31,7 +31,7 @@ class RimEclipseCase; class RimEclipseResultCase; class RimObservedFmuRftData; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimWellLogCurve; class RimWellLogChannel; class RimWellLogPlot; @@ -80,13 +80,13 @@ RiaRftPltCurveDefinition curveDefFromCurve( const R bool hasFlowData( const RimWellLog* wellLog ); bool hasAssociatedWellPath( const QString& wellName ); -std::vector gridCasesForWell( const QString& simWellName ); -std::vector rftCasesForWell( const QString& simWellName ); -std::vector rftEnsemblesForWell( const QString& simWellName ); -std::vector rftEnsembles(); -std::vector observedFmuRftDataForWell( const QString& simWellName ); -std::vector observedFmuRftData(); -QString simWellName( const QString& wellPathNameOrSimWellName ); +std::vector gridCasesForWell( const QString& simWellName ); +std::vector rftCasesForWell( const QString& simWellName ); +std::vector rftEnsemblesForWell( const QString& simWellName ); +std::vector rftEnsembles(); +std::vector observedFmuRftDataForWell( const QString& simWellName ); +std::vector observedFmuRftData(); +QString simWellName( const QString& wellPathNameOrSimWellName ); std::map> calculateRelevantTimeStepsFromCases( const QString& wellPathNameOrSimWellName, diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp index 1c368d3566..9aecd5ebaa 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp @@ -24,7 +24,7 @@ #include "RimEnsembleCurveSetColorManager.h" #include "RimRegularLegendConfig.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimTools.h" #include "RimWellRftPlot.h" @@ -77,7 +77,7 @@ RimWellRftEnsembleCurveSet::~RimWellRftEnsembleCurveSet() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RimWellRftEnsembleCurveSet::ensemble() const +RimSummaryEnsemble* RimWellRftEnsembleCurveSet::ensemble() const { return m_ensemble; } @@ -85,7 +85,7 @@ RimSummaryCaseCollection* RimWellRftEnsembleCurveSet::ensemble() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellRftEnsembleCurveSet::setEnsemble( RimSummaryCaseCollection* ensemble ) +void RimWellRftEnsembleCurveSet::setEnsemble( RimSummaryEnsemble* ensemble ) { m_ensemble = ensemble; @@ -148,8 +148,8 @@ void RimWellRftEnsembleCurveSet::setEnsembleParameter( const QString& parameterN //-------------------------------------------------------------------------------------------------- std::vector RimWellRftEnsembleCurveSet::parametersWithVariation() const { - std::set paramSet; - RimSummaryCaseCollection* group = m_ensemble; + std::set paramSet; + RimSummaryEnsemble* group = m_ensemble; if ( group ) { auto parameters = group->variationSortedEnsembleParameters( true ); @@ -192,8 +192,8 @@ RigEnsembleParameter::Type RimWellRftEnsembleCurveSet::currentEnsembleParameterT { if ( m_ensembleColorMode() == ColorMode::BY_ENSEMBLE_PARAM ) { - RimSummaryCaseCollection* group = m_ensemble(); - QString parameterName = m_ensembleParameter(); + RimSummaryEnsemble* group = m_ensemble(); + QString parameterName = m_ensembleParameter(); if ( group && !parameterName.isEmpty() ) { diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.h index ceabd9ac59..e35fb8e936 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.h @@ -31,7 +31,7 @@ #include class RiuCvfOverlayItemWidget; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimEclipseCase; class RifReaderEnsembleStatisticsRft; class RifReaderRftInterface; @@ -48,13 +48,13 @@ class RimWellRftEnsembleCurveSet : public caf::PdmObject RimWellRftEnsembleCurveSet(); ~RimWellRftEnsembleCurveSet() override; - RimSummaryCaseCollection* ensemble() const; - void setEnsemble( RimSummaryCaseCollection* ensemble ); - ColorMode colorMode() const; - void setColorMode( ColorMode mode ); - void initializeLegend(); - cvf::Color3f caseColor( const RimSummaryCase* summaryCase ) const; - QString currentEnsembleParameter() const; + RimSummaryEnsemble* ensemble() const; + void setEnsemble( RimSummaryEnsemble* ensemble ); + ColorMode colorMode() const; + void setColorMode( ColorMode mode ); + void initializeLegend(); + cvf::Color3f caseColor( const RimSummaryCase* summaryCase ) const; + QString currentEnsembleParameter() const; void setEnsembleParameter( const QString& parameterName ); RimRegularLegendConfig* legendConfig(); @@ -81,7 +81,7 @@ class RimWellRftEnsembleCurveSet : public caf::PdmObject private: caf::PdmPtrField m_eclipseCase; - caf::PdmPtrField m_ensemble; + caf::PdmPtrField m_ensemble; caf::PdmProxyValueField m_ensembleName; caf::PdmField m_ensembleColorMode; caf::PdmField m_ensembleParameter; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index d2b78676d3..44bcb8bb6e 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -38,7 +38,7 @@ #include "RimRegularLegendConfig.h" #include "RimReloadCaseTools.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryEnsembleTools.h" #include "RimTools.h" #include "RimWellLogChannel.h" @@ -233,7 +233,7 @@ QString RimWellRftPlot::associatedSimWellName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellRftPlot::applyInitialSelections( std::variant dataSource ) +void RimWellRftPlot::applyInitialSelections( std::variant dataSource ) { std::map wellSources = findWellSources(); if ( m_wellPathNameOrSimWellName() == "None" && !wellSources.empty() ) @@ -241,10 +241,10 @@ void RimWellRftPlot::applyInitialSelections( std::variantfirst; } - RimSummaryCaseCollection* ensemble = nullptr; - RimSummaryCase* summaryCase = nullptr; + RimSummaryEnsemble* ensemble = nullptr; + RimSummaryCase* summaryCase = nullptr; - if ( auto summaryCollection = std::get_if( &dataSource ) ) + if ( auto summaryCollection = std::get_if( &dataSource ) ) { ensemble = *summaryCollection; } @@ -270,7 +270,7 @@ void RimWellRftPlot::applyInitialSelections( std::variant ensemblesWithSummaryCurves; + std::set ensemblesWithSummaryCurves; // Add new curves for ( const RiaRftPltCurveDefinition& curveDefToAdd : allCurveDefs ) @@ -595,8 +595,8 @@ void RimWellRftPlot::updateCurvesInPlot( const std::set rftAddresses = curveSet->statisticsEclipseRftReader()->eclipseRftAddresses( m_wellPathNameOrSimWellName, curveDefToAdd.timeStep() ); @@ -867,14 +867,14 @@ QList RimWellRftPlot::calculateValueOptionsForSources() } } - const std::vector rftEnsembles = RimWellPlotTools::rftEnsemblesForWell( m_wellPathNameOrSimWellName ); + const std::vector rftEnsembles = RimWellPlotTools::rftEnsemblesForWell( m_wellPathNameOrSimWellName ); if ( !rftEnsembles.empty() ) { options.push_back( caf::PdmOptionItemInfo::createHeader( RifDataSourceForRftPlt::sourceTypeUiText( RifDataSourceForRftPlt::SourceType::ENSEMBLE_RFT ), true ) ); - for ( RimSummaryCaseCollection* rftEnsemble : rftEnsembles ) + for ( RimSummaryEnsemble* rftEnsemble : rftEnsembles ) { auto addr = RifDataSourceForRftPlt( rftEnsemble ); auto item = caf::PdmOptionItemInfo( rftEnsemble->name(), QVariant::fromValue( addr ) ); @@ -894,7 +894,7 @@ QList RimWellRftPlot::calculateValueOptionsForSources() if ( summaryCase->rftReader() && summaryCase->rftReader()->wellNames().contains( m_wellPathNameOrSimWellName ) ) { auto eclipeGridModel = RimReloadCaseTools::gridModelFromSummaryCase( summaryCase ); - auto parentEnsemble = summaryCase->firstAncestorOrThisOfType(); + auto parentEnsemble = summaryCase->firstAncestorOrThisOfType(); auto addr = RifDataSourceForRftPlt( summaryCase, parentEnsemble, eclipeGridModel ); auto item = caf::PdmOptionItemInfo( summaryCase->displayCaseName(), QVariant::fromValue( addr ) ); @@ -1036,7 +1036,7 @@ void RimWellRftPlot::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin for ( RimWellRftEnsembleCurveSet* curveSet : m_ensembleCurveSets() ) { bool isSelected = false; - for ( RimSummaryCaseCollection* selectedCurveSet : selectedEnsembles() ) + for ( RimSummaryEnsemble* selectedCurveSet : selectedEnsembles() ) { if ( curveSet->ensemble() == selectedCurveSet ) { @@ -1149,10 +1149,10 @@ std::map RimWellRftPlot::findWellSources() } } - const std::vector rftEnsembles = RimWellPlotTools::rftEnsembles(); + const std::vector rftEnsembles = RimWellPlotTools::rftEnsembles(); // Ensemble RFT wells { - for ( RimSummaryCaseCollection* summaryCaseColl : rftEnsembles ) + for ( RimSummaryEnsemble* summaryCaseColl : rftEnsembles ) { std::set wellsWithRftData = RimSummaryEnsembleTools::wellsWithRftData( summaryCaseColl->allSummaryCases() ); for ( const QString& wellName : wellsWithRftData ) @@ -1412,7 +1412,7 @@ void RimWellRftPlot::defineCurveColorsAndSymbols( const std::setensemble() == ensemble; } ); + [&curveSet]( const RimSummaryEnsemble* ensemble ) { return curveSet->ensemble() == ensemble; } ); if ( ensemble_it != ensembles.end() ) { curveSet->initializeLegend(); @@ -1475,9 +1475,9 @@ void RimWellRftPlot::defineCurveColorsAndSymbols( const std::set RimWellRftPlot::selectedEnsembles() const +std::vector RimWellRftPlot::selectedEnsembles() const { - std::vector ensembleSets; + std::vector ensembleSets; for ( const RifDataSourceForRftPlt& dataSource : m_selectedSources() ) { if ( dataSource.ensemble() != nullptr ) @@ -1493,7 +1493,7 @@ std::vector RimWellRftPlot::selectedEnsembles() const //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::createEnsembleCurveSets() { - const std::vector rftEnsembles = RimWellPlotTools::rftEnsemblesForWell( m_wellPathNameOrSimWellName ); + const std::vector rftEnsembles = RimWellPlotTools::rftEnsemblesForWell( m_wellPathNameOrSimWellName ); // First delete any curve sets not belonging to the given rftEnsembles std::vector curveSetsToDelete; @@ -1512,7 +1512,7 @@ void RimWellRftPlot::createEnsembleCurveSets() } // Then add curve set for any ensembles we haven't already added - for ( RimSummaryCaseCollection* ensemble : rftEnsembles ) + for ( RimSummaryEnsemble* ensemble : rftEnsembles ) { auto it = std::find_if( m_ensembleCurveSets.begin(), m_ensembleCurveSets.end(), @@ -1529,7 +1529,7 @@ void RimWellRftPlot::createEnsembleCurveSets() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellRftEnsembleCurveSet* RimWellRftPlot::findEnsembleCurveSet( RimSummaryCaseCollection* ensemble ) const +RimWellRftEnsembleCurveSet* RimWellRftPlot::findEnsembleCurveSet( RimSummaryEnsemble* ensemble ) const { for ( RimWellRftEnsembleCurveSet* curveSet : m_ensembleCurveSets() ) { @@ -1544,7 +1544,7 @@ RimWellRftEnsembleCurveSet* RimWellRftPlot::findEnsembleCurveSet( RimSummaryCase //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::variant RimWellRftPlot::dataSource() const +std::variant RimWellRftPlot::dataSource() const { // Return the first selected ensemble, if any // If no ensemble is selected, return the first selected summary case, if any diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h index 6fc08f2293..56f0de8845 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h @@ -84,8 +84,8 @@ class RimWellRftPlot : public RimWellLogPlot int branchIndex() const; - std::variant dataSource() const; - void applyInitialSelections( std::variant dataSource ); + std::variant dataSource() const; + void applyInitialSelections( std::variant dataSource ); static const char* plotNameFormatString(); @@ -94,7 +94,7 @@ class RimWellRftPlot : public RimWellLogPlot bool showErrorBarsForObservedData() const; void onLegendDefinitionChanged(); - RimWellRftEnsembleCurveSet* findEnsembleCurveSet( RimSummaryCaseCollection* ensemble ) const; + RimWellRftEnsembleCurveSet* findEnsembleCurveSet( RimSummaryEnsemble* ensemble ) const; protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; @@ -140,8 +140,8 @@ class RimWellRftPlot : public RimWellLogPlot cvf::Color3f findCurveColor( RimWellLogCurve* curve ); void defineCurveColorsAndSymbols( const std::set& allCurveDefs ); - std::vector selectedEnsembles() const; - void createEnsembleCurveSets(); + std::vector selectedEnsembles() const; + void createEnsembleCurveSets(); private: friend class RimWellRftEnsembleCurveSet; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 6c2e62cd0b..3816add774 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -135,10 +135,10 @@ #include "RimSummaryAddress.h" #include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -798,7 +798,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; menuBuilder << "RicShowSummaryCurveCalculatorFeature"; } - else if ( dynamic_cast( firstUiItem ) ) + else if ( dynamic_cast( firstUiItem ) ) { menuBuilder.subMenuStart( "Import" ); menuBuilder << "RicImportSummaryCaseFeature"; @@ -1204,7 +1204,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicDeleteWellPathFeature"; menuBuilder << "RicLinkWellPathFeature"; - if ( dynamic_cast( firstUiItem ) || dynamic_cast( firstUiItem ) ) + if ( dynamic_cast( firstUiItem ) || dynamic_cast( firstUiItem ) ) { menuBuilder << "RicAppendSummaryCurvesForSummaryCasesFeature"; menuBuilder << "RicAppendSummaryPlotsForSummaryCasesFeature"; diff --git a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunction.cpp b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunction.cpp index 2b34e1c9fb..ed507053e8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunction.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunction.cpp @@ -20,7 +20,7 @@ #include "RimCustomObjectiveFunctionWeight.h" #include "RimEnsembleCurveSet.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include #include @@ -90,7 +90,7 @@ std::vector RimCustomObjectiveFunction::functionValueForAllCases() const { if ( m_weights.empty() ) return {}; - RimSummaryCaseCollection* caseCollection = parentCurveSet()->summaryCaseCollection(); + RimSummaryEnsemble* caseCollection = parentCurveSet()->summaryEnsemble(); if ( !caseCollection || caseCollection->allSummaryCases().empty() ) return {}; std::vector values; diff --git a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp index 977d8c2903..94fbc1884e 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp @@ -146,7 +146,7 @@ void RimCustomObjectiveFunctionWeight::fieldChangedByUi( const caf::PdmFieldHand { RiuSummaryVectorSelectionDialog dlg( nullptr ); RimObjectiveFunctionTools::configureDialogForObjectiveFunctions( &dlg ); - RimSummaryCaseCollection* candidateEnsemble = parentCurveSet()->summaryCaseCollection(); + RimSummaryEnsemble* candidateEnsemble = parentCurveSet()->summaryEnsemble(); std::vector candidateAddresses; for ( auto address : m_objectiveValuesSummaryAddresses().childrenByType() ) diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 2d0762ecb6..30d25a2dd8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -84,8 +84,8 @@ #include "RimStimPlanModelPlotCollection.h" #include "RimSummaryCalculation.h" #include "RimSummaryCalculationCollection.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryTableCollection.h" #include "RimSurfaceCollection.h" @@ -538,11 +538,11 @@ void RimProject::assignCaseIdToSummaryCase( RimSummaryCase* summaryCase ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::assignIdToEnsemble( RimSummaryCaseCollection* summaryCaseCollection ) +void RimProject::assignIdToEnsemble( RimSummaryEnsemble* summaryCaseCollection ) { if ( summaryCaseCollection ) { - for ( RimSummaryCaseCollection* s : RimProject::summaryGroups() ) + for ( RimSummaryEnsemble* s : RimProject::summaryGroups() ) { m_nextValidEnsembleId = std::max( m_nextValidEnsembleId, s->ensembleId() + 1 ); } @@ -715,9 +715,9 @@ std::vector RimProject::allSummaryCases() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimProject::summaryGroups() const +std::vector RimProject::summaryGroups() const { - std::vector groups; + std::vector groups; for ( RimOilField* oilField : oilFields ) { @@ -725,7 +725,7 @@ std::vector RimProject::summaryGroups() const RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); if ( sumCaseMainColl ) { - std::vector g = sumCaseMainColl->summaryCaseCollections(); + std::vector g = sumCaseMainColl->summaryCaseCollections(); groups.insert( groups.end(), g.begin(), g.end() ); } } diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.h b/ApplicationLibCode/ProjectDataModel/RimProject.h index a2f77816f0..77998ebb52 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.h +++ b/ApplicationLibCode/ProjectDataModel/RimProject.h @@ -57,7 +57,7 @@ class RimOilField; class RimColorLegendCollection; class RimScriptCollection; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimSummaryCaseMainCollection; class Rim3dView; class RimGridView; @@ -129,13 +129,13 @@ class RimProject : public caf::PdmDocument void assignViewIdToView( Rim3dView* view ); void assignPlotIdToPlotWindow( RimPlotWindow* plotWindow ); void assignCaseIdToSummaryCase( RimSummaryCase* summaryCase ); - void assignIdToEnsemble( RimSummaryCaseCollection* summaryCaseCollection ); + void assignIdToEnsemble( RimSummaryEnsemble* summaryCaseCollection ); [[nodiscard]] std::vector allGridCases() const; - std::vector allSummaryCases() const; - std::vector summaryGroups() const; - RimSummaryCaseMainCollection* firstSummaryCaseMainCollection() const; + std::vector allSummaryCases() const; + std::vector summaryGroups() const; + RimSummaryCaseMainCollection* firstSummaryCaseMainCollection() const; [[nodiscard]] std::vector allViews() const; [[nodiscard]] std::vector allVisibleViews() const; diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp index 7a6f338660..f8b9092129 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp @@ -25,8 +25,8 @@ #include "RimObservedSummaryData.h" #include "RimSummaryCalculation.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" CAF_PDM_SOURCE_INIT( RimSummaryCalculationCollection, "RimSummaryCalculationCollection" ); //-------------------------------------------------------------------------------------------------- @@ -83,7 +83,7 @@ void RimSummaryCalculationCollection::updateDataDependingOnCalculations() } auto summaryCaseCollections = summaryCaseCollection->summaryCaseCollections(); - for ( RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections ) + for ( RimSummaryEnsemble* summaryCaseCollection : summaryCaseCollections ) { summaryCaseCollection->onCalculationUpdated(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp index 3c90249bef..e0bb8bc853 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp @@ -28,8 +28,8 @@ #include "RimSummaryAddress.h" #include "RimSummaryCalculation.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "RiuDragDrop.h" #include "RiuSummaryVectorSelectionDialog.h" diff --git a/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake index fbcf8fb25c..9fc85d5fe1 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake @@ -4,7 +4,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCase.h ${CMAKE_CURRENT_LIST_DIR}/RimGridSummaryCase.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseMainCollection.h - ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryEnsemble.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurvesData.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAppearanceCalculator.h @@ -63,7 +63,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimGridSummaryCase.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCase.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseMainCollection.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryEnsemble.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurvesData.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAppearanceCalculator.cpp diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp index f882e17a23..ab7c613a4d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp @@ -23,8 +23,8 @@ #include "RimDerivedEnsembleCaseCollection.h" #include "RimDerivedSummaryCase.h" #include "RimProject.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RifSummaryReaderInterface.h" @@ -96,7 +96,7 @@ RimDerivedEnsembleCaseCollection::~RimDerivedEnsembleCaseCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimDerivedEnsembleCaseCollection::setEnsemble1( RimSummaryCaseCollection* ensemble ) +void RimDerivedEnsembleCaseCollection::setEnsemble1( RimSummaryEnsemble* ensemble ) { m_ensemble1 = ensemble; updateAutoName(); @@ -105,7 +105,7 @@ void RimDerivedEnsembleCaseCollection::setEnsemble1( RimSummaryCaseCollection* e //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimDerivedEnsembleCaseCollection::setEnsemble2( RimSummaryCaseCollection* ensemble ) +void RimDerivedEnsembleCaseCollection::setEnsemble2( RimSummaryEnsemble* ensemble ) { m_ensemble2 = ensemble; updateAutoName(); @@ -253,7 +253,7 @@ QList RimDerivedEnsembleCaseCollection::calculateValueOp if ( fieldNeedingOptions == &m_fixedTimeStepIndex ) { - RimSummaryCaseCollection* sourceEnsemble = nullptr; + RimSummaryEnsemble* sourceEnsemble = nullptr; if ( m_useFixedTimeStep() == FixedTimeStepMode::FIXED_TIME_STEP_CASE_1 ) { sourceEnsemble = m_ensemble1; @@ -282,7 +282,7 @@ QList RimDerivedEnsembleCaseCollection::calculateValueOp //-------------------------------------------------------------------------------------------------- void RimDerivedEnsembleCaseCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - RimSummaryCaseCollection::defineUiOrdering( uiConfigName, uiOrdering ); + RimSummaryEnsemble::defineUiOrdering( uiConfigName, uiOrdering ); uiOrdering.add( &m_caseCount ); uiOrdering.add( &m_ensemble1 ); @@ -443,7 +443,7 @@ RimDerivedSummaryCase* RimDerivedEnsembleCaseCollection::firstCaseNotInUse() std::vector RimDerivedEnsembleCaseCollection::allDerivedCases( bool activeOnly ) const { std::vector activeCases; - for ( auto sumCase : RimSummaryCaseCollection::allSummaryCases() ) + for ( auto sumCase : RimSummaryEnsemble::allSummaryCases() ) { auto derivedCase = dynamic_cast( sumCase ); if ( derivedCase && ( !activeOnly || derivedCase->isInUse() ) ) @@ -461,7 +461,7 @@ void RimDerivedEnsembleCaseCollection::updateAutoName() { QString timeStepString; { - RimSummaryCaseCollection* sourceEnsemble = nullptr; + RimSummaryEnsemble* sourceEnsemble = nullptr; if ( m_useFixedTimeStep() == FixedTimeStepMode::FIXED_TIME_STEP_CASE_1 ) { sourceEnsemble = m_ensemble1; @@ -598,9 +598,9 @@ std::vector RimDerivedEnsembleCaseCollection: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimDerivedEnsembleCaseCollection::allEnsembles() const +std::vector RimDerivedEnsembleCaseCollection::allEnsembles() const { - std::vector ensembles; + std::vector ensembles; auto project = RimProject::current(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.h index 879967df92..a6e10ef142 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.h @@ -19,7 +19,7 @@ #pragma once #include "RimDerivedSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "cafPdmChildArrayField.h" #include "cafPdmField.h" @@ -34,7 +34,7 @@ class RimSummaryCase; //================================================================================================== /// //================================================================================================== -class RimDerivedEnsembleCaseCollection : public RimSummaryCaseCollection +class RimDerivedEnsembleCaseCollection : public RimSummaryEnsemble { CAF_PDM_HEADER_INIT; @@ -50,13 +50,13 @@ class RimDerivedEnsembleCaseCollection : public RimSummaryCaseCollection RimDerivedEnsembleCaseCollection(); ~RimDerivedEnsembleCaseCollection() override; - RimSummaryCaseCollection* ensemble1() const { return m_ensemble1; } - RimSummaryCaseCollection* ensemble2() const { return m_ensemble2; } - DerivedSummaryOperator op() const { return m_operator(); } - bool isValid() const { return m_ensemble1 != nullptr && m_ensemble2 != nullptr; } + RimSummaryEnsemble* ensemble1() const { return m_ensemble1; } + RimSummaryEnsemble* ensemble2() const { return m_ensemble2; } + DerivedSummaryOperator op() const { return m_operator(); } + bool isValid() const { return m_ensemble1 != nullptr && m_ensemble2 != nullptr; } - void setEnsemble1( RimSummaryCaseCollection* ensemble ); - void setEnsemble2( RimSummaryCaseCollection* ensemble ); + void setEnsemble1( RimSummaryEnsemble* ensemble ); + void setEnsemble2( RimSummaryEnsemble* ensemble ); std::vector allSummaryCases() const override; std::set ensembleSummaryAddresses() const override; @@ -85,11 +85,11 @@ class RimDerivedEnsembleCaseCollection : public RimSummaryCaseCollection std::vector findReferringEnsembles() const; private: - std::vector allEnsembles() const; + std::vector allEnsembles() const; private: - caf::PdmPtrField m_ensemble1; - caf::PdmPtrField m_ensemble2; + caf::PdmPtrField m_ensemble1; + caf::PdmPtrField m_ensemble2; caf::PdmField> m_operator; caf::PdmField m_swapEnsemblesButton; caf::PdmField m_caseCount; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp index da5a5cf243..63cfb84b44 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp @@ -25,7 +25,7 @@ #include "RifDerivedEnsembleReader.h" #include "RimProject.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "cafPdmUiTreeSelectionEditor.h" diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCrossPlotStatisticsCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCrossPlotStatisticsCase.cpp index 88cfe1f713..6ffb4259f2 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCrossPlotStatisticsCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCrossPlotStatisticsCase.cpp @@ -28,7 +28,7 @@ #include "RimEnsembleCurveSet.h" #include "RimEnsembleStatisticsCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include #include diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp index 5ab3e25ade..9766c399de 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp @@ -29,7 +29,7 @@ #include "RimObjectiveFunctionTools.h" #include "RimSummaryAddress.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RiuSummaryVectorSelectionDialog.h" @@ -271,7 +271,7 @@ QList RimEnsembleCurveFilter::calculateValueOptions( con else if ( fieldNeedingOptions == &m_categories ) { auto curveSet = parentCurveSet(); - auto ensemble = curveSet ? curveSet->summaryCaseCollection() : nullptr; + auto ensemble = curveSet ? curveSet->summaryEnsemble() : nullptr; auto eParam = ensemble ? ensemble->ensembleParameter( m_ensembleParameterName ) : RigEnsembleParameter(); if ( eParam.isText() ) @@ -378,7 +378,7 @@ void RimEnsembleCurveFilter::fieldChangedByUi( const caf::PdmFieldHandle* change { RiuSummaryVectorSelectionDialog dlg( nullptr ); RimObjectiveFunctionTools::configureDialogForObjectiveFunctions( &dlg ); - RimSummaryCaseCollection* candidateEnsemble = parentCurveSet()->summaryCaseCollection(); + RimSummaryEnsemble* candidateEnsemble = parentCurveSet()->summaryEnsemble(); std::vector candidateAddresses; for ( auto address : m_objectiveValuesSummaryAddresses().childrenByType() ) @@ -516,7 +516,7 @@ void RimEnsembleCurveFilter::defineEditorAttribute( const caf::PdmFieldHandle* f std::vector RimEnsembleCurveFilter::applyFilter( const std::vector& allSumCases ) { auto curveSet = parentCurveSet(); - auto ensemble = curveSet ? curveSet->summaryCaseCollection() : nullptr; + auto ensemble = curveSet ? curveSet->summaryEnsemble() : nullptr; if ( !ensemble || !isActive() ) return allSumCases; bool useIntegerSelection = false; @@ -712,7 +712,7 @@ void RimEnsembleCurveFilter::updateMaxMinAndDefaultValues( bool forceDefault ) addresses.push_back( address->address() ); } { - auto summaryCases = parentCurveSet()->summaryCaseCollection()->allSummaryCases(); + auto summaryCases = parentCurveSet()->summaryEnsemble()->allSummaryCases(); auto [minObjValue, maxObjValue] = objectiveFunction->minMaxValues( summaryCases, addresses, parentCurveSet()->objectiveFunctionTimeConfig() ); @@ -751,6 +751,6 @@ void RimEnsembleCurveFilter::updateMaxMinAndDefaultValues( bool forceDefault ) RigEnsembleParameter RimEnsembleCurveFilter::selectedEnsembleParameter() const { auto curveSet = parentCurveSet(); - auto ensemble = curveSet ? curveSet->summaryCaseCollection() : nullptr; + auto ensemble = curveSet ? curveSet->summaryEnsemble() : nullptr; return ensemble ? ensemble->ensembleParameter( m_ensembleParameterName ) : RigEnsembleParameter(); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index c2ec618fb7..0b24911b66 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -49,9 +49,9 @@ #include "RimSummaryAddressSelector.h" #include "RimSummaryCalculationCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveAutoName.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" #include "RimTimeStepFilter.h" @@ -126,9 +126,9 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() m_showCurves.uiCapability()->setUiHidden( true ); // Y Values - CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryCaseCollection, "SummaryGroup", "Ensemble" ); - m_yValuesSummaryCaseCollection.uiCapability()->setUiTreeChildrenHidden( true ); - m_yValuesSummaryCaseCollection.uiCapability()->setAutoAddingOptionFromValue( false ); + CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryEnsemble, "SummaryGroup", "Ensemble" ); + m_yValuesSummaryEnsemble.uiCapability()->setUiTreeChildrenHidden( true ); + m_yValuesSummaryEnsemble.uiCapability()->setAutoAddingOptionFromValue( false ); CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryAddressUiField, "SelectedVariableDisplayVar", "Vector" ); m_yValuesSummaryAddressUiField.xmlCapability()->disableIO(); @@ -643,18 +643,18 @@ void RimEnsembleCurveSet::onLegendDefinitionChanged() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSet::setSummaryCaseCollection( RimSummaryCaseCollection* sumCaseCollection ) +void RimEnsembleCurveSet::setSummaryEnsemble( RimSummaryEnsemble* sumCaseCollection ) { - m_yValuesSummaryCaseCollection = sumCaseCollection; + m_yValuesSummaryEnsemble = sumCaseCollection; m_xAddressSelector->setEnsemble( sumCaseCollection ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RimEnsembleCurveSet::summaryCaseCollection() const +RimSummaryEnsemble* RimEnsembleCurveSet::summaryEnsemble() const { - return m_yValuesSummaryCaseCollection(); + return m_yValuesSummaryEnsemble(); } //-------------------------------------------------------------------------------------------------- @@ -696,8 +696,8 @@ RigEnsembleParameter::Type RimEnsembleCurveSet::currentEnsembleParameterType() c { if ( m_colorMode() == ColorMode::BY_ENSEMBLE_PARAM ) { - RimSummaryCaseCollection* group = m_yValuesSummaryCaseCollection(); - QString parameterName = m_ensembleParameter(); + RimSummaryEnsemble* group = m_yValuesSummaryEnsemble(); + QString parameterName = m_ensembleParameter(); if ( group && !parameterName.isEmpty() ) { @@ -713,8 +713,8 @@ RigEnsembleParameter::Type RimEnsembleCurveSet::currentEnsembleParameterType() c //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSet::updateAllCurves() { - RimSummaryCaseCollection* group = m_yValuesSummaryCaseCollection(); - RimSummaryAddress* addr = m_yValuesSummaryAddress(); + RimSummaryEnsemble* group = m_yValuesSummaryEnsemble(); + RimSummaryAddress* addr = m_yValuesSummaryAddress(); if ( group && addr->address().category() != RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_INVALID ) { @@ -797,7 +797,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi updateTextInPlot = true; } - else if ( changedField == &m_yValuesSummaryCaseCollection ) + else if ( changedField == &m_yValuesSummaryEnsemble ) { updateAllCurves(); @@ -814,7 +814,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi { if ( !m_xAddressSelector->ensemble() ) { - m_xAddressSelector->setEnsemble( summaryCaseCollection() ); + m_xAddressSelector->setEnsemble( summaryEnsemble() ); } if ( !m_xAddressSelector->summaryAddress().isValid() ) @@ -968,7 +968,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi else if ( changedField == &m_yPushButtonSelectSummaryAddress ) { RiuSummaryVectorSelectionDialog dlg( nullptr ); - RimSummaryCaseCollection* candidateEnsemble = m_yValuesSummaryCaseCollection(); + RimSummaryEnsemble* candidateEnsemble = m_yValuesSummaryEnsemble(); RifEclipseSummaryAddress candicateAddress = m_yValuesSummaryAddress->address(); dlg.hideSummaryCases(); @@ -979,7 +979,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi auto curveSelection = dlg.curveSelection(); if ( !curveSelection.empty() ) { - m_yValuesSummaryCaseCollection = curveSelection[0].ensemble(); + m_yValuesSummaryEnsemble = curveSelection[0].ensemble(); m_yValuesSummaryAddress->setAddress( curveSelection[0].summaryAddressY() ); loadDataAndUpdate( true ); @@ -999,7 +999,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi { RiuSummaryVectorSelectionDialog dlg( nullptr ); RimObjectiveFunctionTools::configureDialogForObjectiveFunctions( &dlg ); - RimSummaryCaseCollection* candidateEnsemble = m_yValuesSummaryCaseCollection(); + RimSummaryEnsemble* candidateEnsemble = m_yValuesSummaryEnsemble(); std::vector candidateAddresses; for ( auto address : m_objectiveValuesSummaryAddresses().childrenByType() ) @@ -1119,7 +1119,7 @@ void RimEnsembleCurveSet::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde { caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Summary Vector" ); - curveDataGroup->add( &m_yValuesSummaryCaseCollection ); + curveDataGroup->add( &m_yValuesSummaryEnsemble ); curveDataGroup->add( &m_yValuesSummaryAddressUiField ); curveDataGroup->add( &m_yPushButtonSelectSummaryAddress, { .newRow = false, .totalColumnSpan = 1, .leftLabelColumnSpan = 0 } ); @@ -1295,7 +1295,7 @@ void RimEnsembleCurveSet::onObjectiveFunctionChanged( const caf::SignalEmitter* void RimEnsembleCurveSet::appendColorGroup( caf::PdmUiOrdering& uiOrdering ) { caf::PdmUiGroup* colorsGroup = uiOrdering.addNewGroup( "Appearance" ); - m_colorMode.uiCapability()->setUiReadOnly( !m_yValuesSummaryCaseCollection() ); + m_colorMode.uiCapability()->setUiReadOnly( !m_yValuesSummaryEnsemble() ); colorsGroup->add( &m_colorMode ); if ( m_colorMode() == RimEnsembleCurveSetColorManager::ColorMode::SINGLE_COLOR ) @@ -1309,7 +1309,7 @@ void RimEnsembleCurveSet::appendColorGroup( caf::PdmUiOrdering& uiOrdering ) } else if ( m_colorMode == ColorMode::BY_ENSEMBLE_PARAM ) { - m_ensembleParameter.uiCapability()->setUiReadOnly( !m_yValuesSummaryCaseCollection() ); + m_ensembleParameter.uiCapability()->setUiReadOnly( !m_yValuesSummaryEnsemble() ); colorsGroup->add( &m_ensembleParameterSorting ); colorsGroup->add( &m_ensembleParameter ); } @@ -1461,12 +1461,12 @@ QList RimEnsembleCurveSet::calculateValueOptions( const { QList options; - if ( fieldNeedingOptions == &m_yValuesSummaryCaseCollection ) + if ( fieldNeedingOptions == &m_yValuesSummaryEnsemble ) { - RimProject* proj = RimProject::current(); - std::vector groups = proj->summaryGroups(); + RimProject* proj = RimProject::current(); + std::vector groups = proj->summaryGroups(); - for ( RimSummaryCaseCollection* group : groups ) + for ( RimSummaryEnsemble* group : groups ) { if ( group->isEnsemble() ) options.push_back( caf::PdmOptionItemInfo( group->name(), group ) ); } @@ -1484,7 +1484,7 @@ QList RimEnsembleCurveSet::calculateValueOptions( const options.push_back( caf::PdmOptionItemInfo( singleColorOption.uiText(), ColorMode::SINGLE_COLOR ) ); options.push_back( caf::PdmOptionItemInfo( singleColorWithAlphaOption.uiText(), ColorMode::SINGLE_COLOR_WITH_ALPHA ) ); - RimSummaryCaseCollection* group = m_yValuesSummaryCaseCollection(); + RimSummaryEnsemble* group = m_yValuesSummaryEnsemble(); if ( group && group->hasEnsembleParameters() ) { options.push_back( caf::PdmOptionItemInfo( byEnsParamOption.uiText(), ColorMode::BY_ENSEMBLE_PARAM ) ); @@ -1504,7 +1504,7 @@ QList RimEnsembleCurveSet::calculateValueOptions( const } else if ( fieldNeedingOptions == &m_yValuesSummaryAddressUiField ) { - appendOptionItemsForSummaryAddresses( &options, m_yValuesSummaryCaseCollection() ); + appendOptionItemsForSummaryAddresses( &options, m_yValuesSummaryEnsemble() ); } else if ( fieldNeedingOptions == &m_selectedTimeSteps ) { @@ -1591,7 +1591,7 @@ std::set RimEnsembleCurveSet::allAvailableTimeSteps() const { std::set timeStepUnion; - for ( RimSummaryCase* sumCase : summaryCaseCollection()->allSummaryCases() ) + for ( RimSummaryCase* sumCase : summaryEnsemble()->allSummaryCases() ) { if ( sumCase->summaryReader() ) { @@ -1659,8 +1659,7 @@ std::vector RimEnsembleCurveSet::curveDefinitions() c //-------------------------------------------------------------------------------------------------- /// Optimization candidate //-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSet::appendOptionItemsForSummaryAddresses( QList* options, - RimSummaryCaseCollection* summaryCaseGroup ) +void RimEnsembleCurveSet::appendOptionItemsForSummaryAddresses( QList* options, RimSummaryEnsemble* summaryCaseGroup ) { if ( !summaryCaseGroup ) return; @@ -1837,7 +1836,7 @@ std::vector RimEnsembleCurveSet::generateColorsForCases( const std if ( m_colorMode == ColorMode::BY_ENSEMBLE_PARAM ) { - RimSummaryCaseCollection* group = m_yValuesSummaryCaseCollection(); + RimSummaryEnsemble* group = m_yValuesSummaryEnsemble(); QString parameterName = m_ensembleParameter(); @@ -1860,7 +1859,7 @@ std::vector RimEnsembleCurveSet::generateColorsForCases( const std } else if ( m_colorMode == ColorMode::BY_OBJECTIVE_FUNCTION ) { - RimSummaryCaseCollection* group = m_yValuesSummaryCaseCollection(); + RimSummaryEnsemble* group = m_yValuesSummaryEnsemble(); if ( group && !group->allSummaryCases().empty() ) { @@ -1889,7 +1888,7 @@ std::vector RimEnsembleCurveSet::generateColorsForCases( const std } else if ( m_colorMode == ColorMode::BY_CUSTOM_OBJECTIVE_FUNCTION ) { - RimSummaryCaseCollection* group = m_yValuesSummaryCaseCollection(); + RimSummaryEnsemble* group = m_yValuesSummaryEnsemble(); if ( group && !group->allSummaryCases().empty() && m_customObjectiveFunction() && m_customObjectiveFunction->isValid() ) { @@ -1943,7 +1942,7 @@ void RimEnsembleCurveSet::updateCurveColors() auto plot = firstAncestorOrThisOfType(); if ( plot && plot->plotWidget() ) { - if ( m_yValuesSummaryCaseCollection() && isCurvesVisible() && + if ( m_yValuesSummaryEnsemble() && isCurvesVisible() && !RimEnsembleCurveSetColorManager::hasSameColorForAllRealizationCurves( m_colorMode() ) && m_legendConfig->showLegend() ) { if ( !m_legendOverlayFrame ) @@ -2120,8 +2119,8 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vectoraddress().category() == RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_INVALID ) return; @@ -2283,7 +2282,7 @@ void RimEnsembleCurveSet::updateStatisticsCurves() RimEnsembleCurveSet* RimEnsembleCurveSet::clone() const { auto copy = copyObject(); - copy->setSummaryCaseCollection( m_yValuesSummaryCaseCollection() ); + copy->setSummaryEnsemble( m_yValuesSummaryEnsemble() ); // Update summary case references for ( size_t i = 0; i < m_curves.size(); i++ ) @@ -2320,7 +2319,7 @@ void RimEnsembleCurveSet::updateAllTextInPlot() //-------------------------------------------------------------------------------------------------- std::vector RimEnsembleCurveSet::variationSortedEnsembleParameters() const { - RimSummaryCaseCollection* ensemble = m_yValuesSummaryCaseCollection; + RimSummaryEnsemble* ensemble = m_yValuesSummaryEnsemble; if ( ensemble ) { return ensemble->variationSortedEnsembleParameters(); @@ -2336,7 +2335,7 @@ std::vector RimEnsembleCurveSet::variationSortedEnsemblePa //-------------------------------------------------------------------------------------------------- std::vector> RimEnsembleCurveSet::ensembleParameters( ParameterSorting sortingMode ) const { - RimSummaryCaseCollection* ensemble = m_yValuesSummaryCaseCollection; + RimSummaryEnsemble* ensemble = m_yValuesSummaryEnsemble; if ( ensemble ) { if ( sortingMode == ParameterSorting::ABSOLUTE_VALUE ) @@ -2474,7 +2473,7 @@ void RimEnsembleCurveSet::updateEnsembleLegendItem() //-------------------------------------------------------------------------------------------------- int RimEnsembleCurveSet::ensembleId() const { - if ( m_yValuesSummaryCaseCollection() != nullptr ) return m_yValuesSummaryCaseCollection()->ensembleId(); + if ( m_yValuesSummaryEnsemble() != nullptr ) return m_yValuesSummaryEnsemble()->ensembleId(); return -1; } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 5e7041cee6..fc6639a258 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -51,7 +51,7 @@ #include class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimSummaryCurve; class RimSummaryAddress; class RimSummaryPlotSourceStepping; @@ -139,8 +139,8 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt void onLegendDefinitionChanged(); - void setSummaryCaseCollection( RimSummaryCaseCollection* sumCaseCollection ); - RimSummaryCaseCollection* summaryCaseCollection() const; + void setSummaryEnsemble( RimSummaryEnsemble* sumEnsemble ); + RimSummaryEnsemble* summaryEnsemble() const; RimEnsembleCurveFilterCollection* filterCollection() const; @@ -180,7 +180,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt void appendColorGroup( caf::PdmUiOrdering& uiOrdering ); - static void appendOptionItemsForSummaryAddresses( QList* options, RimSummaryCaseCollection* summaryCaseGroup ); + static void appendOptionItemsForSummaryAddresses( QList* options, RimSummaryEnsemble* summaryCaseGroup ); const RimEnsembleCurveFilterCollection* curveFilters() const; @@ -252,7 +252,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt caf::PdmPointer m_currentSummaryCurve; - caf::PdmPtrField m_yValuesSummaryCaseCollection; + caf::PdmPtrField m_yValuesSummaryEnsemble; caf::PdmChildField m_yValuesSummaryAddress; caf::PdmField m_yValuesSummaryAddressUiField; caf::PdmField m_yPushButtonSelectSummaryAddress; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp index 45f109f8ae..08eea67be9 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp @@ -26,7 +26,7 @@ #include "RimObjectiveFunction.h" #include "RimRegularLegendConfig.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "cvfScalarMapper.h" diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp index 3a821cb465..82e3be9ebb 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp @@ -24,7 +24,7 @@ #include "RigStatisticsMath.h" #include "RimEnsembleCurveSet.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include #include diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.cpp index 33be813418..8cf1f1197b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.cpp @@ -19,7 +19,7 @@ #include "RimObjectiveFunction.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RifReaderEclipseSummary.h" diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.h b/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.h index 71ced1b1c9..9f7d4fde60 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.h @@ -28,7 +28,7 @@ #include class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RifEclipseSummaryAddress; class ObjectiveFunctionTimeConfig diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp index 5bc5789dd9..29a0f6c7db 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp @@ -28,7 +28,7 @@ #include "RimProject.h" #include "RimSummaryAddress.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "RiuSummaryVectorSelectionDialog.h" @@ -85,7 +85,7 @@ void RimSummaryAddressSelector::setSummaryCase( RimSummaryCase* summaryCase ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryAddressSelector::setEnsemble( RimSummaryCaseCollection* ensemble ) +void RimSummaryAddressSelector::setEnsemble( RimSummaryEnsemble* ensemble ) { m_summaryCaseCollection = ensemble; } @@ -149,7 +149,7 @@ RimSummaryCase* RimSummaryAddressSelector::summaryCase() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RimSummaryAddressSelector::ensemble() const +RimSummaryEnsemble* RimSummaryAddressSelector::ensemble() const { return m_summaryCaseCollection(); } @@ -245,10 +245,10 @@ auto createOptionsForEnsemble = []() -> QList { QList options; - RimProject* proj = RimProject::current(); - std::vector groups = proj->summaryGroups(); + RimProject* proj = RimProject::current(); + std::vector groups = proj->summaryGroups(); - for ( RimSummaryCaseCollection* group : groups ) + for ( RimSummaryEnsemble* group : groups ) { if ( group->isEnsemble() ) options.push_back( caf::PdmOptionItemInfo( group->name(), group ) ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h index 1e383db564..32cc8ca767 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h @@ -31,7 +31,7 @@ #include "cafPdmPtrField.h" class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimSummaryAddress; class RimPlotAxisPropertiesInterface; @@ -46,7 +46,7 @@ class RimSummaryAddressSelector : public caf::PdmObject RimSummaryAddressSelector(); void setSummaryCase( RimSummaryCase* summaryCase ); - void setEnsemble( RimSummaryCaseCollection* ensemble ); + void setEnsemble( RimSummaryEnsemble* ensemble ); void setAddress( const RifEclipseSummaryAddress& address ); void setResamplingPeriod( RiaDefines::DateTimePeriodEnum resampling ); void setPlotAxisProperties( RimPlotAxisPropertiesInterface* plotAxisProperties ); @@ -56,7 +56,7 @@ class RimSummaryAddressSelector : public caf::PdmObject void setShowResampling( bool enable ); RimSummaryCase* summaryCase() const; - RimSummaryCaseCollection* ensemble() const; + RimSummaryEnsemble* ensemble() const; RifEclipseSummaryAddress summaryAddress() const; RiaDefines::DateTimePeriodEnum resamplingPeriod() const; RimPlotAxisPropertiesInterface* plotAxisProperties() const; @@ -71,7 +71,7 @@ class RimSummaryAddressSelector : public caf::PdmObject private: caf::PdmPtrField m_summaryCase; - caf::PdmPtrField m_summaryCaseCollection; + caf::PdmPtrField m_summaryCaseCollection; caf::PdmChildField m_summaryAddress; caf::PdmField m_summaryAddressUiField; caf::PdmField m_pushButtonSelectSummaryAddress; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp index 006ecc9548..a933d94079 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -25,7 +25,7 @@ #include "RimProject.h" #include "RimSummaryAddressCollection.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmUiCheckBoxEditor.h" @@ -145,9 +145,9 @@ bool RimSummaryCase::hasCaseRealizationParameters() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RimSummaryCase::ensemble() const +RimSummaryEnsemble* RimSummaryCase::ensemble() const { - RimSummaryCaseCollection* e = firstAncestorOrThisOfType(); + RimSummaryEnsemble* e = firstAncestorOrThisOfType(); return e && e->isEnsemble() ? e : nullptr; } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h index 81352cc701..a01a47b24c 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -31,7 +31,7 @@ class RifReaderRftInterface; class RifSummaryReaderInterface; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimSummaryAddressCollection; //================================================================================================== @@ -85,7 +85,7 @@ class RimSummaryCase : public caf::PdmObject void setCaseRealizationParameters( const std::shared_ptr& crlParameters ); std::shared_ptr caseRealizationParameters() const; bool hasCaseRealizationParameters() const; - RimSummaryCaseCollection* ensemble() const; + RimSummaryEnsemble* ensemble() const; void copyFrom( const RimSummaryCase& rhs ); bool operator<( const RimSummaryCase& rhs ) const; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 3d4588cd4f..c727384790 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -40,8 +40,8 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -170,7 +170,7 @@ void RimSummaryCaseMainCollection::removeCase( RimSummaryCase* summaryCase, bool m_cases.removeChild( summaryCase ); - for ( RimSummaryCaseCollection* summaryCaseCollection : m_caseCollections ) + for ( RimSummaryEnsemble* summaryCaseCollection : m_caseCollections ) { summaryCaseCollection->removeCase( summaryCase, notifyChange ); } @@ -194,7 +194,7 @@ void RimSummaryCaseMainCollection::removeCases( std::vector& ca removeCase( sumCase, false ); } - for ( RimSummaryCaseCollection* summaryCaseCollection : m_caseCollections ) + for ( RimSummaryEnsemble* summaryCaseCollection : m_caseCollections ) { summaryCaseCollection->updateReferringCurveSets(); } @@ -205,12 +205,12 @@ void RimSummaryCaseMainCollection::removeCases( std::vector& ca //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RimSummaryCaseMainCollection::addCaseCollection( std::vector summaryCases, - const QString& collectionName, - bool isEnsemble, - std::function allocator ) +RimSummaryEnsemble* RimSummaryCaseMainCollection::addEnsemble( const std::vector& summaryCases, + const QString& collectionName, + bool isEnsemble, + std::function allocator ) { - RimSummaryCaseCollection* summaryCaseCollection = allocator(); + RimSummaryEnsemble* summaryCaseCollection = allocator(); if ( !collectionName.isEmpty() ) summaryCaseCollection->setName( collectionName ); if ( summaryCaseCollection->ensembleId() == -1 ) @@ -221,7 +221,7 @@ RimSummaryCaseCollection* RimSummaryCaseMainCollection::addCaseCollection( std:: for ( RimSummaryCase* summaryCase : summaryCases ) { - auto currentSummaryCaseCollection = summaryCase->firstAncestorOrThisOfType(); + auto currentSummaryCaseCollection = summaryCase->firstAncestorOrThisOfType(); if ( currentSummaryCaseCollection ) { currentSummaryCaseCollection->removeCase( summaryCase ); @@ -251,7 +251,7 @@ RimSummaryCaseCollection* RimSummaryCaseMainCollection::addCaseCollection( std:: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseMainCollection::removeCaseCollection( RimSummaryCaseCollection* caseCollection ) +void RimSummaryCaseMainCollection::removeCaseCollection( RimSummaryEnsemble* caseCollection ) { m_caseCollections.removeChild( caseCollection ); @@ -261,7 +261,7 @@ void RimSummaryCaseMainCollection::removeCaseCollection( RimSummaryCaseCollectio //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseMainCollection::addEnsemble( RimSummaryCaseCollection* ensemble ) +void RimSummaryCaseMainCollection::addEnsemble( RimSummaryEnsemble* ensemble ) { CVF_ASSERT( ensemble ); @@ -327,9 +327,9 @@ std::vector RimSummaryCaseMainCollection::topLevelSummaryCases( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCaseMainCollection::summaryCaseCollections() const +std::vector RimSummaryCaseMainCollection::summaryCaseCollections() const { - std::vector summaryCaseCollections; + std::vector summaryCaseCollections; for ( const auto& caseColl : m_caseCollections ) { summaryCaseCollections.push_back( caseColl ); @@ -511,9 +511,9 @@ void RimSummaryCaseMainCollection::loadFileSummaryCaseData( std::vector allSummaryCases() const; - std::vector topLevelSummaryCases() const; - std::vector summaryCaseCollections() const; + std::vector allSummaryCases() const; + std::vector topLevelSummaryCases() const; + std::vector summaryCaseCollections() const; std::vector createSummaryCasesFromFileInfos( const std::vector& summaryHeaderFileInfos, bool showProgress = false ); @@ -61,12 +61,12 @@ class RimSummaryCaseMainCollection : public caf::PdmObject void removeCase( RimSummaryCase* summaryCase, bool notifyChange = true ); void removeCases( std::vector& cases ); - RimSummaryCaseCollection* addCaseCollection( std::vector summaryCases, - const QString& coolectionName, - bool isEnsemble, - std::function allocator = defaultAllocator ); - void removeCaseCollection( RimSummaryCaseCollection* caseCollection ); - void addEnsemble( RimSummaryCaseCollection* ensemble ); + RimSummaryEnsemble* addEnsemble( const std::vector& summaryCases, + const QString& coolectionName, + bool isEnsemble, + std::function allocator = defaultAllocator ); + void removeCaseCollection( RimSummaryEnsemble* caseCollection ); + void addEnsemble( RimSummaryEnsemble* ensemble ); void loadAllSummaryCaseData(); @@ -78,13 +78,13 @@ class RimSummaryCaseMainCollection : public caf::PdmObject private: void initAfterRead() override; - static void loadSummaryCaseData( std::vector summaryCases ); - static void loadFileSummaryCaseData( std::vector fileSummaryCases ); - static RimSummaryCaseCollection* defaultAllocator(); + static void loadSummaryCaseData( std::vector summaryCases ); + static void loadFileSummaryCaseData( std::vector fileSummaryCases ); + static RimSummaryEnsemble* defaultAllocator(); void onCaseNameChanged( const SignalEmitter* emitter ); private: - caf::PdmChildArrayField m_cases; - caf::PdmChildArrayField m_caseCollections; + caf::PdmChildArrayField m_cases; + caf::PdmChildArrayField m_caseCollections; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 7a63fbeefb..2012c41db1 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -39,9 +39,9 @@ #include "RimSummaryAddress.h" #include "RimSummaryCalculationCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurveAutoName.h" #include "RimSummaryCurveCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" #include "RimSummaryTimeAxisProperties.h" @@ -1021,7 +1021,7 @@ QString RimSummaryCurve::curveExportDescription( const RifEclipseSummaryAddress& RimEnsembleCurveSetCollection* coll = firstAncestorOrThisOfType(); auto curveSet = coll ? coll->findCurveSetFromPlotCurve( m_plotCurve ) : nullptr; - auto group = curveSet ? curveSet->summaryCaseCollection() : nullptr; + auto group = curveSet ? curveSet->summaryEnsemble() : nullptr; auto addressUiText = addr.uiText(); if ( !m_yValuesSummaryCase() ) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index 4bb8fff39f..c04fdcd076 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -25,8 +25,8 @@ #include "RimSummaryCalculation.h" #include "RimSummaryCalculationCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryNameHelper.h" #include "SummaryPlotCommands/RicSummaryPlotEditorUi.h" @@ -121,9 +121,9 @@ QString RimSummaryCurveAutoName::curveNameY( const RifEclipseSummaryAddress& sum { auto ensembleCurveSet = firstAncestorOrThisOfType(); - if ( ensembleCurveSet && ensembleCurveSet->summaryCaseCollection() ) + if ( ensembleCurveSet && ensembleCurveSet->summaryEnsemble() ) { - caseNameY = ensembleCurveSet->summaryCaseCollection()->name().toStdString(); + caseNameY = ensembleCurveSet->summaryEnsemble()->name().toStdString(); } } @@ -155,9 +155,9 @@ QString RimSummaryCurveAutoName::curveNameX( const RifEclipseSummaryAddress& sum { auto ensembleCurveSet = firstAncestorOrThisOfType(); - if ( ensembleCurveSet && ensembleCurveSet->summaryCaseCollection() ) + if ( ensembleCurveSet && ensembleCurveSet->summaryEnsemble() ) { - caseNameX = ensembleCurveSet->summaryCaseCollection()->name().toStdString(); + caseNameX = ensembleCurveSet->summaryEnsemble()->name().toStdString(); } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp index 753fde3009..b831a2ba0b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp @@ -26,8 +26,8 @@ #include "RimAsciiDataCurve.h" #include "RimGridTimeHistoryCurve.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "cvfAssert.h" diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.cpp similarity index 87% rename from ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp rename to ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.cpp index 0124a43da3..047ad81e70 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RiaEnsembleNameTools.h" #include "RiaFieldHandleTools.h" @@ -41,12 +41,12 @@ #include -CAF_PDM_SOURCE_INIT( RimSummaryCaseCollection, "SummaryCaseSubCollection" ); +CAF_PDM_SOURCE_INIT( RimSummaryEnsemble, "SummaryCaseSubCollection" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection::RimSummaryCaseCollection() +RimSummaryEnsemble::RimSummaryEnsemble() : caseNameChanged( this ) , caseRemoved( this ) { @@ -58,7 +58,7 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() CAF_PDM_InitScriptableField( &m_autoName, "CreateAutoName", true, "Auto Name" ); CAF_PDM_InitScriptableFieldNoDefault( &m_nameAndItemCount, "NameCount", "Name" ); - m_nameAndItemCount.registerGetMethod( this, &RimSummaryCaseCollection::nameAndItemCount ); + m_nameAndItemCount.registerGetMethod( this, &RimSummaryEnsemble::nameAndItemCount ); RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_nameAndItemCount ); CAF_PDM_InitScriptableField( &m_isEnsemble, "IsEnsemble", false, "Is Ensemble" ); @@ -81,7 +81,7 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection::~RimSummaryCaseCollection() +RimSummaryEnsemble::~RimSummaryEnsemble() { m_cases.deleteChildrenAsync(); updateReferringCurveSets(); @@ -90,7 +90,7 @@ RimSummaryCaseCollection::~RimSummaryCaseCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::removeCase( RimSummaryCase* summaryCase, bool notifyChange ) +void RimSummaryEnsemble::removeCase( RimSummaryCase* summaryCase, bool notifyChange ) { size_t caseCountBeforeRemove = m_cases.size(); @@ -117,9 +117,9 @@ void RimSummaryCaseCollection::removeCase( RimSummaryCase* summaryCase, bool not //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::addCase( RimSummaryCase* summaryCase ) +void RimSummaryEnsemble::addCase( RimSummaryCase* summaryCase ) { - summaryCase->nameChanged.connect( this, &RimSummaryCaseCollection::onCaseNameChanged ); + summaryCase->nameChanged.connect( this, &RimSummaryEnsemble::onCaseNameChanged ); summaryCase->setShowVectorItemsInProjectTree( m_cases.empty() ); @@ -151,7 +151,7 @@ void RimSummaryCaseCollection::addCase( RimSummaryCase* summaryCase ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCaseCollection::allSummaryCases() const +std::vector RimSummaryEnsemble::allSummaryCases() const { return m_cases.childrenByType(); } @@ -159,7 +159,7 @@ std::vector RimSummaryCaseCollection::allSummaryCases() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCase* RimSummaryCaseCollection::firstSummaryCase() const +RimSummaryCase* RimSummaryEnsemble::firstSummaryCase() const { if ( !m_cases.empty() ) return m_cases[0]; @@ -169,7 +169,7 @@ RimSummaryCase* RimSummaryCaseCollection::firstSummaryCase() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::setName( const QString& name ) +void RimSummaryEnsemble::setName( const QString& name ) { m_name = name; } @@ -177,7 +177,7 @@ void RimSummaryCaseCollection::setName( const QString& name ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryCaseCollection::name() const +QString RimSummaryEnsemble::name() const { return m_name; } @@ -185,7 +185,7 @@ QString RimSummaryCaseCollection::name() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::ensureNameIsUpdated() +void RimSummaryEnsemble::ensureNameIsUpdated() { if ( m_autoName ) { @@ -208,7 +208,7 @@ void RimSummaryCaseCollection::ensureNameIsUpdated() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimSummaryCaseCollection::isEnsemble() const +bool RimSummaryEnsemble::isEnsemble() const { return m_isEnsemble(); } @@ -216,7 +216,7 @@ bool RimSummaryCaseCollection::isEnsemble() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::setAsEnsemble( bool isEnsemble ) +void RimSummaryEnsemble::setAsEnsemble( bool isEnsemble ) { if ( isEnsemble != m_isEnsemble ) { @@ -236,7 +236,7 @@ void RimSummaryCaseCollection::setAsEnsemble( bool isEnsemble ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimSummaryCaseCollection::ensembleSummaryAddresses() const +std::set RimSummaryEnsemble::ensembleSummaryAddresses() const { std::set addresses; size_t maxAddrCount = 0; @@ -270,7 +270,7 @@ std::set RimSummaryCaseCollection::ensembleSummaryAddr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimSummaryCaseCollection::ensembleTimeSteps() const +std::set RimSummaryEnsemble::ensembleTimeSteps() const { std::set allTimeSteps; size_t maxAddrCount = 0; @@ -313,7 +313,7 @@ std::set RimSummaryCaseCollection::ensembleTimeSteps() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCaseCollection::variationSortedEnsembleParameters( bool excludeNoVariation ) const +std::vector RimSummaryEnsemble::variationSortedEnsembleParameters( bool excludeNoVariation ) const { if ( m_cachedSortedEnsembleParameters.empty() ) { @@ -341,7 +341,7 @@ std::vector RimSummaryCaseCollection::variationSortedEnsem /// //-------------------------------------------------------------------------------------------------- std::vector> - RimSummaryCaseCollection::correlationSortedEnsembleParameters( const RifEclipseSummaryAddress& address ) const + RimSummaryEnsemble::correlationSortedEnsembleParameters( const RifEclipseSummaryAddress& address ) const { auto parameters = parameterCorrelationsAllTimeSteps( address ); std::sort( parameters.begin(), @@ -355,7 +355,7 @@ std::vector> /// //-------------------------------------------------------------------------------------------------- std::vector> - RimSummaryCaseCollection::correlationSortedEnsembleParameters( const RifEclipseSummaryAddress& address, time_t selectedTimeStep ) const + RimSummaryEnsemble::correlationSortedEnsembleParameters( const RifEclipseSummaryAddress& address, time_t selectedTimeStep ) const { auto parameters = parameterCorrelations( address, selectedTimeStep ); std::sort( parameters.begin(), @@ -378,10 +378,10 @@ time_t timeDiff( time_t lhs, time_t rhs ) /// //-------------------------------------------------------------------------------------------------- std::vector> - RimSummaryCaseCollection::parameterCorrelations( const RifEclipseSummaryAddress& address, - time_t timeStep, - const std::vector& selectedParameters, - const std::set& selectedCases ) const + RimSummaryEnsemble::parameterCorrelations( const RifEclipseSummaryAddress& address, + time_t timeStep, + const std::vector& selectedParameters, + const std::set& selectedCases ) const { auto parameters = variationSortedEnsembleParameters( true ); @@ -454,8 +454,8 @@ std::vector> /// Returns a vector of the parameters and the average absolute values of correlations per time step //-------------------------------------------------------------------------------------------------- std::vector> - RimSummaryCaseCollection::parameterCorrelationsAllTimeSteps( const RifEclipseSummaryAddress& address, - const std::vector& selectedParameters ) const + RimSummaryEnsemble::parameterCorrelationsAllTimeSteps( const RifEclipseSummaryAddress& address, + const std::vector& selectedParameters ) const { const size_t maxTimeStepCount = 10; std::set timeSteps = ensembleTimeSteps(); @@ -491,7 +491,7 @@ std::vector> //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigEnsembleParameter RimSummaryCaseCollection::ensembleParameter( const QString& paramName ) const +RigEnsembleParameter RimSummaryEnsemble::ensembleParameter( const QString& paramName ) const { if ( !isEnsemble() || paramName.isEmpty() ) return {}; @@ -506,7 +506,7 @@ RigEnsembleParameter RimSummaryCaseCollection::ensembleParameter( const QString& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::calculateEnsembleParametersIntersectionHash() +void RimSummaryEnsemble::calculateEnsembleParametersIntersectionHash() { m_commonAddressCount = RimSummaryEnsembleTools::calculateEnsembleParametersIntersectionHash( allSummaryCases() ); } @@ -514,7 +514,7 @@ void RimSummaryCaseCollection::calculateEnsembleParametersIntersectionHash() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::loadDataAndUpdate() +void RimSummaryEnsemble::loadDataAndUpdate() { onLoadDataAndUpdate(); } @@ -522,7 +522,7 @@ void RimSummaryCaseCollection::loadDataAndUpdate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimSummaryCaseCollection::validateEnsembleCases( const std::vector cases ) +bool RimSummaryEnsemble::validateEnsembleCases( const std::vector cases ) { // Validate ensemble parameters QString errors; @@ -576,7 +576,7 @@ bool RimSummaryCaseCollection::validateEnsembleCases( const std::vector referringObjects = objectsWithReferringPtrFieldsOfType(); @@ -636,7 +636,7 @@ void RimSummaryCaseCollection::updateReferringCurveSets() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaSummaryAddressAnalyzer* RimSummaryCaseCollection::addressAnalyzer() +RiaSummaryAddressAnalyzer* RimSummaryEnsemble::addressAnalyzer() { if ( !m_analyzer ) { @@ -651,7 +651,7 @@ RiaSummaryAddressAnalyzer* RimSummaryCaseCollection::addressAnalyzer() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::computeMinMax( const RifEclipseSummaryAddress& address ) +void RimSummaryEnsemble::computeMinMax( const RifEclipseSummaryAddress& address ) { if ( m_minMaxValues.count( address ) > 0 ) return; @@ -680,7 +680,7 @@ void RimSummaryCaseCollection::computeMinMax( const RifEclipseSummaryAddress& ad //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::setMinMax( const RifEclipseSummaryAddress& address, double min, double max ) +void RimSummaryEnsemble::setMinMax( const RifEclipseSummaryAddress& address, double min, double max ) { m_minMaxValues[address] = std::pair( min, max ); } @@ -688,7 +688,7 @@ void RimSummaryCaseCollection::setMinMax( const RifEclipseSummaryAddress& addres //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair RimSummaryCaseCollection::minMax( const RifEclipseSummaryAddress& address ) +std::pair RimSummaryEnsemble::minMax( const RifEclipseSummaryAddress& address ) { computeMinMax( address ); @@ -698,7 +698,7 @@ std::pair RimSummaryCaseCollection::minMax( const RifEclipseSumm //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryCaseCollection::nameAndItemCount() const +QString RimSummaryEnsemble::nameAndItemCount() const { size_t itemCount = m_cases.size(); const size_t itemCountThreshold = 20; @@ -713,7 +713,7 @@ QString RimSummaryCaseCollection::nameAndItemCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::updateIcon() +void RimSummaryEnsemble::updateIcon() { if ( m_isEnsemble ) setUiIconFromResourceString( ":/SummaryEnsemble.svg" ); @@ -724,7 +724,7 @@ void RimSummaryCaseCollection::updateIcon() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::initAfterRead() +void RimSummaryEnsemble::initAfterRead() { if ( m_ensembleId() == -1 ) { @@ -736,7 +736,7 @@ void RimSummaryCaseCollection::initAfterRead() for ( const auto& summaryCase : m_cases ) { - summaryCase->nameChanged.connect( this, &RimSummaryCaseCollection::onCaseNameChanged ); + summaryCase->nameChanged.connect( this, &RimSummaryEnsemble::onCaseNameChanged ); } if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2022.06.2" ) ) m_autoName = false; @@ -745,7 +745,7 @@ void RimSummaryCaseCollection::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +void RimSummaryEnsemble::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { if ( changedField == &m_isEnsemble ) { @@ -765,7 +765,7 @@ void RimSummaryCaseCollection::fieldChangedByUi( const caf::PdmFieldHandle* chan //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::onCaseNameChanged( const SignalEmitter* emitter ) +void RimSummaryEnsemble::onCaseNameChanged( const SignalEmitter* emitter ) { caseNameChanged.send(); } @@ -773,7 +773,7 @@ void RimSummaryCaseCollection::onCaseNameChanged( const SignalEmitter* emitter ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +void RimSummaryEnsemble::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_autoName ); uiOrdering.add( &m_name ); @@ -787,7 +787,7 @@ void RimSummaryCaseCollection::defineUiOrdering( QString uiConfigName, caf::PdmU //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) +void RimSummaryEnsemble::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) { if ( m_isEnsemble() ) { @@ -811,7 +811,7 @@ void RimSummaryCaseCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiT //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::setEnsembleId( int ensembleId ) +void RimSummaryEnsemble::setEnsembleId( int ensembleId ) { m_ensembleId = ensembleId; } @@ -819,7 +819,7 @@ void RimSummaryCaseCollection::setEnsembleId( int ensembleId ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RimSummaryCaseCollection::ensembleId() const +int RimSummaryEnsemble::ensembleId() const { return m_ensembleId(); } @@ -827,7 +827,7 @@ int RimSummaryCaseCollection::ensembleId() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimSummaryCaseCollection::hasEnsembleParameters() const +bool RimSummaryEnsemble::hasEnsembleParameters() const { for ( RimSummaryCase* rimCase : allSummaryCases() ) { @@ -843,7 +843,7 @@ bool RimSummaryCaseCollection::hasEnsembleParameters() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::buildChildNodes() +void RimSummaryEnsemble::buildChildNodes() { if ( m_dataVectorFolders->isEmpty() ) { @@ -854,7 +854,7 @@ void RimSummaryCaseCollection::buildChildNodes() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::buildMetaData() +void RimSummaryEnsemble::buildMetaData() { clearChildNodes(); buildChildNodes(); @@ -864,7 +864,7 @@ void RimSummaryCaseCollection::buildMetaData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::onCalculationUpdated() +void RimSummaryEnsemble::onCalculationUpdated() { m_dataVectorFolders->deleteCalculatedAddresses(); m_dataVectorFolders->updateFolderStructure( ensembleSummaryAddresses(), -1, m_ensembleId ); @@ -877,7 +877,7 @@ void RimSummaryCaseCollection::onCalculationUpdated() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::clearChildNodes() +void RimSummaryEnsemble::clearChildNodes() { m_dataVectorFolders->deleteChildren(); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.h similarity index 96% rename from ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h rename to ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.h index d52a28c69f..d2dbb334ea 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.h @@ -43,7 +43,7 @@ class RiaSummaryAddressAnalyzer; //================================================================================================== /// //================================================================================================== -class RimSummaryCaseCollection : public caf::PdmObject +class RimSummaryEnsemble : public caf::PdmObject { CAF_PDM_HEADER_INIT; @@ -52,8 +52,8 @@ class RimSummaryCaseCollection : public caf::PdmObject caf::Signal caseRemoved; public: - RimSummaryCaseCollection(); - ~RimSummaryCaseCollection() override; + RimSummaryEnsemble(); + ~RimSummaryEnsemble() override; void removeCase( RimSummaryCase* summaryCase, bool notifyChange = true ); void addCase( RimSummaryCase* summaryCase ); @@ -91,7 +91,7 @@ class RimSummaryCaseCollection : public caf::PdmObject void loadDataAndUpdate(); static bool validateEnsembleCases( const std::vector cases ); - bool operator<( const RimSummaryCaseCollection& rhs ) const; + bool operator<( const RimSummaryEnsemble& rhs ) const; RiaDefines::EclipseUnitSystem unitSystem() const; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp index 219f4d8821..8006475053 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp @@ -44,8 +44,8 @@ #include "RimSummaryAddressCollection.h" #include "RimSummaryAddressModifier.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotControls.h" @@ -231,7 +231,7 @@ void RimSummaryMultiPlot::handleDroppedObjects( const std::vector addresses; std::vector addressCollections; std::vector cases; - std::vector ensembles; + std::vector ensembles; for ( auto o : objects ) { @@ -253,7 +253,7 @@ void RimSummaryMultiPlot::handleDroppedObjects( const std::vector( o ); if ( summaryCase ) cases.push_back( summaryCase ); - auto ensemble = dynamic_cast( o ); + auto ensemble = dynamic_cast( o ); if ( ensemble ) ensembles.push_back( ensemble ); } @@ -357,9 +357,9 @@ void RimSummaryMultiPlot::populateNameHelper( RimSummaryPlotNameHelper* nameHelp { nameHelper->clear(); - std::vector addresses; - std::vector sumCases; - std::vector ensembleCases; + std::vector addresses; + std::vector sumCases; + std::vector ensembleCases; for ( RimSummaryCurve* curve : allCurves() ) { @@ -370,7 +370,7 @@ void RimSummaryMultiPlot::populateNameHelper( RimSummaryPlotNameHelper* nameHelp for ( auto curveSet : curveSets() ) { addresses.push_back( curveSet->curveAddress() ); - ensembleCases.push_back( curveSet->summaryCaseCollection() ); + ensembleCases.push_back( curveSet->summaryEnsemble() ); } nameHelper->appendAddresses( addresses ); @@ -1104,7 +1104,7 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange() for ( auto curveSet : plot->curveSets() ) { - if ( !curveSet->summaryCaseCollection() ) continue; + if ( !curveSet->summaryEnsemble() ) continue; if ( curveSet->axisY() == axis->plotAxis() ) { @@ -1122,7 +1122,7 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange() for ( const auto& adr : addresses ) { - auto [min, max] = curveSet->summaryCaseCollection()->minMax( adr ); + auto [min, max] = curveSet->summaryEnsemble()->minMax( adr ); minimum = std::min( min, minimum ); maximum = std::max( max, maximum ); @@ -1534,10 +1534,10 @@ void RimSummaryMultiPlot::appendSubPlotByStepping( int direction ) } else if ( m_sourceStepping()->stepDimension() == RimSummaryDataSourceStepping::SourceSteppingDimension::ENSEMBLE ) { - RimSummaryCaseCollection* newEnsemble = m_sourceStepping()->stepEnsemble( direction ); + RimSummaryEnsemble* newEnsemble = m_sourceStepping()->stepEnsemble( direction ); for ( auto curveSet : newPlot->curveSets() ) { - curveSet->setSummaryCaseCollection( newEnsemble ); + curveSet->setSummaryEnsemble( newEnsemble ); } } else @@ -1594,7 +1594,7 @@ void RimSummaryMultiPlot::appendCurveByStepping( int direction ) for ( auto curveSet : plot->curveSets() ) { auto address = curveSet->summaryAddressY(); - auto sumEns = curveSet->summaryCaseCollection(); + auto sumEns = curveSet->summaryEnsemble(); int sumEnsId = sumEns->ensembleId(); if ( m_sourceStepping()->stepDimension() == RimSummaryDataSourceStepping::SourceSteppingDimension::ENSEMBLE ) { diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.h index 641f3c0fcd..9ad9456b43 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.h @@ -25,7 +25,7 @@ class QString; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RifEclipseSummaryAddress; //================================================================================================== diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index c355fac7c4..f84b9f1791 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -55,10 +55,10 @@ #include "RimSummaryAddressCollection.h" #include "RimSummaryCalculationCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryCurvesData.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlotAxisFormatter.h" #include "RimSummaryPlotControls.h" #include "RimSummaryPlotNameHelper.h" @@ -911,13 +911,13 @@ void RimSummaryPlot::updateNumericalAxis( RiaDefines::PlotAxis plotAxis ) { if ( curveSet->axisY() == riuPlotAxis ) { - RiaSummaryCurveDefinition def( curveSet->summaryCaseCollection(), curveSet->summaryAddressY() ); + RiaSummaryCurveDefinition def( curveSet->summaryEnsemble(), curveSet->summaryAddressY() ); curveDefs.push_back( def ); } if ( curveSet->axisX() == riuPlotAxis ) { RiaSummaryCurveDefinition def; - def.setEnsemble( curveSet->summaryCaseCollection() ); + def.setEnsemble( curveSet->summaryEnsemble() ); def.setSummaryAddressX( curveSet->curveAddress().summaryAddressX() ); curveDefs.push_back( def ); @@ -2308,17 +2308,17 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleSummaryCaseDrop( RimSummaryCase* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryPlot::CurveInfo RimSummaryPlot::handleEnsembleDrop( RimSummaryCaseCollection* ensemble ) +RimSummaryPlot::CurveInfo RimSummaryPlot::handleEnsembleDrop( RimSummaryEnsemble* ensemble ) { int newCurves = 0; std::vector curveSetsToUpdate; - std::map> dataVectorMap; + std::map> dataVectorMap; for ( auto& curve : curveSets() ) { const auto addr = curve->curveAddress(); - dataVectorMap[addr].insert( curve->summaryCaseCollection() ); + dataVectorMap[addr].insert( curve->summaryEnsemble() ); } for ( const auto& [addr, ensembles] : dataVectorMap ) @@ -2474,12 +2474,12 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleSummaryAddressDrop( RimSummaryAd if ( summaryAddr->isEnsemble() ) { - std::map> dataVectorMap; + std::map> dataVectorMap; for ( auto& curve : curveSets() ) { const auto addr = curve->summaryAddressY(); - dataVectorMap[addr].insert( curve->summaryCaseCollection() ); + dataVectorMap[addr].insert( curve->summaryEnsemble() ); } auto ensemble = RiaSummaryTools::ensembleById( summaryAddr->ensembleId() ); @@ -2557,7 +2557,7 @@ void RimSummaryPlot::handleDroppedObjects( const std::vector( obj ) ) + else if ( auto ensemble = dynamic_cast( obj ) ) { curveInfo.appendCurveInfo( handleEnsembleDrop( ensemble ) ); } @@ -2833,9 +2833,9 @@ void RimSummaryPlot::updateNameHelperWithCurveData( RimSummaryPlotNameHelper* na if ( !nameHelper ) return; nameHelper->clear(); - std::vector addresses; - std::vector sumCases; - std::vector ensembleCases; + std::vector addresses; + std::vector sumCases; + std::vector ensembleCases; if ( m_summaryCurveCollection && m_summaryCurveCollection->isCurvesVisible() ) { @@ -2854,7 +2854,7 @@ void RimSummaryPlot::updateNameHelperWithCurveData( RimSummaryPlotNameHelper* na for ( auto curveSet : m_ensembleCurveSetCollection->curveSets() ) { addresses.push_back( curveSet->curveAddress() ); - ensembleCases.push_back( curveSet->summaryCaseCollection() ); + ensembleCases.push_back( curveSet->summaryEnsemble() ); } nameHelper->clear(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h index 913ec48b9c..c5b9b845ba 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -45,7 +45,7 @@ class RimGridTimeHistoryCurve; class RimSummaryAddress; class RimSummaryAddressCollection; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimSummaryCurve; class RimSummaryCurveCollection; class RimEnsembleCurveSet; @@ -311,7 +311,7 @@ private slots: struct CurveInfo; CurveInfo handleSummaryCaseDrop( RimSummaryCase* summaryCase ); - CurveInfo handleEnsembleDrop( RimSummaryCaseCollection* ensemble ); + CurveInfo handleEnsembleDrop( RimSummaryEnsemble* ensemble ); CurveInfo handleAddressCollectionDrop( RimSummaryAddressCollection* addrColl ); CurveInfo handleSummaryAddressDrop( RimSummaryAddress* summaryAddr ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp index 3ad7f60911..50fa6dea60 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp @@ -27,8 +27,8 @@ #include "RimAsciiDataCurve.h" #include "RimPlotAxisProperties.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "Tools/RimPlotAxisTools.h" #include "RiuQtChartsPlotWidget.h" diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp index c71a20221e..acf616aff4 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp @@ -33,9 +33,9 @@ #include "RimMultiPlotCollection.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -387,8 +387,8 @@ void RimSummaryPlotManager::createNewPlot() { if ( m_filterText().trimmed().isEmpty() ) return; - std::vector summaryCases; - std::vector ensembles; + std::vector summaryCases; + std::vector ensembles; findFilteredSummaryCasesAndEnsembles( summaryCases, ensembles ); std::set filteredAddressesFromSource; @@ -484,8 +484,8 @@ void RimSummaryPlotManager::updateUiFromSelection() //-------------------------------------------------------------------------------------------------- std::set RimSummaryPlotManager::filteredAddresses() { - std::vector summaryCases; - std::vector ensembles; + std::vector summaryCases; + std::vector ensembles; findFilteredSummaryCasesAndEnsembles( summaryCases, ensembles ); std::set nativeAddresses; @@ -512,8 +512,8 @@ void RimSummaryPlotManager::appendCurvesToPlot( RimSummaryPlot* destinationPlot { CAF_ASSERT( destinationPlot ); - std::vector summaryCases; - std::vector ensembles; + std::vector summaryCases; + std::vector ensembles; findFilteredSummaryCasesAndEnsembles( summaryCases, ensembles ); std::set filteredAddressesFromSource = filteredAddresses(); @@ -599,8 +599,8 @@ QStringList RimSummaryPlotManager::extractDataSourceFilters() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlotManager::findFilteredSummaryCasesAndEnsembles( std::vector& summaryCases, - std::vector& ensembles ) const +void RimSummaryPlotManager::findFilteredSummaryCasesAndEnsembles( std::vector& summaryCases, + std::vector& ensembles ) const { auto filteredDataSources = findDataSourceCandidates(); for ( const auto& [dataSourceName, dataSource] : filteredDataSources ) @@ -616,7 +616,7 @@ void RimSummaryPlotManager::findFilteredSummaryCasesAndEnsembles( std::vector( dataSource ); + auto ensemble = dynamic_cast( dataSource ); if ( ensemble ) { ensembles.push_back( ensemble ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.h index d4b6b9a6c4..c01e7aabef 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.h @@ -26,7 +26,7 @@ class RifEclipseSummaryAddress; class RimSummaryPlot; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimEnsembleCurveSet; class RimSummaryCurve; class RimMultiPlot; @@ -77,8 +77,7 @@ class RimSummaryPlotManager : public QObject, public caf::PdmObject, public caf: QStringList extractDataSourceFilters() const; - void findFilteredSummaryCasesAndEnsembles( std::vector& summaryCases, - std::vector& ensembles ) const; + void findFilteredSummaryCasesAndEnsembles( std::vector& summaryCases, std::vector& ensembles ) const; static void setFocusToEditorWidget( caf::PdmUiFieldHandle* uiFieldHandle ); static QString curveFilterRecentlyUsedRegistryKey(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp index fdbfe67cd4..12583cb217 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -23,7 +23,7 @@ #include "RimObjectiveFunctionTools.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" //-------------------------------------------------------------------------------------------------- /// @@ -75,7 +75,7 @@ void RimSummaryPlotNameHelper::setSummaryCases( const std::vector& ensembleCases ) +void RimSummaryPlotNameHelper::setEnsembleCases( const std::vector& ensembleCases ) { m_ensembleCases.clear(); @@ -395,9 +395,9 @@ std::set RimSummaryPlotNameHelper::setOfSummaryCases() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimSummaryPlotNameHelper::setOfEnsembleCases() const +std::set RimSummaryPlotNameHelper::setOfEnsembleCases() const { - std::set ensembleCases; + std::set ensembleCases; for ( const auto& ensemble : m_ensembleCases ) { diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h index 3de76c7175..f5936f6990 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h @@ -30,7 +30,7 @@ class RimSummaryCurve; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RiaSummaryAddressAnalyzer; class RifEclipseSummaryAddress; class RiaSummaryCurveAddress; @@ -47,7 +47,7 @@ class RimSummaryPlotNameHelper : public RimSummaryNameHelper void appendAddresses( const std::vector& addresses ); void setSummaryCases( const std::vector& summaryCases ); - void setEnsembleCases( const std::vector& ensembleCases ); + void setEnsembleCases( const std::vector& ensembleCases ); QString plotTitle() const override; @@ -79,14 +79,14 @@ class RimSummaryPlotNameHelper : public RimSummaryNameHelper void clearTitleSubStrings(); void extractPlotTitleSubStrings(); - std::set setOfSummaryCases() const; - std::set setOfEnsembleCases() const; + std::set setOfSummaryCases() const; + std::set setOfEnsembleCases() const; private: std::unique_ptr m_analyzer; - std::vector> m_summaryCases; - std::vector> m_ensembleCases; + std::vector> m_summaryCases; + std::vector> m_ensembleCases; std::string m_titleQuantity; std::string m_titleWellName; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index f8222e1975..c7d7f5ee9d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -30,11 +30,11 @@ #include "RimProject.h" #include "RimSummaryAddressModifier.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryDataSourceStepping.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotControls.h" @@ -208,9 +208,9 @@ QList RimSummaryPlotSourceStepping::calculateValueOption if ( !dataSourceSteppingObject()->curveSets().empty() ) { auto first = dataSourceSteppingObject()->curveSets().front(); - if ( first->summaryCaseCollection() ) + if ( first->summaryEnsemble() ) { - analyzer = first->summaryCaseCollection()->addressAnalyzer(); + analyzer = first->summaryEnsemble()->addressAnalyzer(); } } @@ -419,13 +419,13 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* if ( m_ensemble() && dataSourceSteppingObject() ) { caf::PdmPointer variantHandle = oldValue.value>(); - RimSummaryCaseCollection* previousCollection = dynamic_cast( variantHandle.p() ); + RimSummaryEnsemble* previousCollection = dynamic_cast( variantHandle.p() ); for ( auto curveSet : dataSourceSteppingObject()->curveSets() ) { - if ( curveSet->summaryCaseCollection() == previousCollection ) + if ( curveSet->summaryEnsemble() == previousCollection ) { - curveSet->setSummaryCaseCollection( m_ensemble ); + curveSet->setSummaryEnsemble( m_ensemble ); } } @@ -607,9 +607,9 @@ std::set RimSummaryPlotSourceStepping::adressesForSour { for ( auto curveSet : dataSourceSteppingObject()->curveSets() ) { - if ( curveSet && curveSet->summaryCaseCollection() ) + if ( curveSet && curveSet->summaryEnsemble() ) { - auto addresses = curveSet->summaryCaseCollection()->ensembleSummaryAddresses(); + auto addresses = curveSet->summaryEnsemble()->ensembleSummaryAddresses(); addressSet.insert( addresses.begin(), addresses.end() ); } } @@ -875,17 +875,17 @@ std::vector RimSummaryPlotSourceStepping::activeFieldsForD //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimSummaryPlotSourceStepping::ensembleCollection() const +std::set RimSummaryPlotSourceStepping::ensembleCollection() const { - std::set summaryCaseCollections; + std::set summaryCaseCollections; if ( dataSourceSteppingObject() ) { for ( auto curveSet : dataSourceSteppingObject()->curveSets() ) { - if ( curveSet && curveSet->summaryCaseCollection() ) + if ( curveSet && curveSet->summaryEnsemble() ) { - summaryCaseCollections.insert( curveSet->summaryCaseCollection() ); + summaryCaseCollections.insert( curveSet->summaryEnsemble() ); } } } @@ -914,7 +914,7 @@ std::vector RimSummaryPlotSourceStepping::summaryCasesForSource { if ( sumCase->isObservedData() ) continue; - auto sumCaseColl = sumCase->firstAncestorOrThisOfType(); + auto sumCaseColl = sumCase->firstAncestorOrThisOfType(); if ( sumCaseColl && sumCaseColl->isEnsemble() ) { if ( m_includeEnsembleCasesForCaseStepping() ) @@ -1352,9 +1352,9 @@ RimSummaryCase* RimSummaryPlotSourceStepping::stepCase( int direction ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RimSummaryPlotSourceStepping::stepEnsemble( int direction ) +RimSummaryEnsemble* RimSummaryPlotSourceStepping::stepEnsemble( int direction ) { - std::vector ensembles; + std::vector ensembles; RimProject* proj = RimProject::current(); for ( auto ensemble : proj->summaryGroups() ) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h index 09cf0091d8..0e85aff560 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h @@ -33,7 +33,7 @@ class RimSummaryCase; class RimSummaryCurve; class RifSummaryReaderInterface; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RifEclipseSummaryAddress; class RiaSummaryAddressAnalyzer; class RimSummaryPlot; @@ -56,9 +56,9 @@ class RimSummaryPlotSourceStepping : public caf::PdmObject std::vector fieldsToShowInToolbar(); - RifEclipseSummaryAddress stepAddress( RifEclipseSummaryAddress addr, int direction ); - RimSummaryCase* stepCase( int direction ); - RimSummaryCaseCollection* stepEnsemble( int direction ); + RifEclipseSummaryAddress stepAddress( RifEclipseSummaryAddress addr, int direction ); + RimSummaryCase* stepCase( int direction ); + RimSummaryEnsemble* stepEnsemble( int direction ); void syncWithStepper( RimSummaryPlotSourceStepping* other ); void setStep( QString stepIdentifier ); @@ -84,9 +84,9 @@ class RimSummaryPlotSourceStepping : public caf::PdmObject std::set adressesForSourceStepping() const; - std::set addressesForCurvesInPlot() const; - std::set summaryCasesCurveCollection() const; - std::set ensembleCollection() const; + std::set addressesForCurvesInPlot() const; + std::set summaryCasesCurveCollection() const; + std::set ensembleCollection() const; std::vector activeFieldsForDataSourceStepping(); std::vector toolbarFieldsForDataSourceStepping(); @@ -109,8 +109,8 @@ class RimSummaryPlotSourceStepping : public caf::PdmObject caf::PdmField> m_stepDimension; - caf::PdmPtrField m_summaryCase; - caf::PdmPtrField m_ensemble; + caf::PdmPtrField m_summaryCase; + caf::PdmPtrField m_ensemble; caf::PdmField m_wellName; caf::PdmField m_groupName; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp index 7a5b8955de..a6e4464174 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp @@ -27,7 +27,7 @@ #include "RimEnsembleCurveSet.h" #include "RimEnsembleCurveSetCollection.h" #include "RimEnsembleStatistics.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "RimTimeAxisAnnotation.h" @@ -308,7 +308,7 @@ void RimSummaryRegressionAnalysisCurve::extractSourceCurveData() { // Fallback to use time steps from summary case // The time steps are used for reference, not used when computing the regression curve - auto summaryCase = m_ensembleCurveSet->summaryCaseCollection()->allSummaryCases().back(); + auto summaryCase = m_ensembleCurveSet->summaryEnsemble()->allSummaryCases().back(); auto allTimeSteps = summaryCase->summaryReader()->timeSteps( {} ); yTimeSteps = allTimeSteps; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp index 7f5d8d30d1..a770069b9d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp @@ -294,7 +294,7 @@ void RimSummaryEnsembleSumo::buildMetaData() summaryCase->summaryReader()->buildMetaData(); } - RimSummaryCaseCollection::buildMetaData(); + RimSummaryEnsemble::buildMetaData(); } //-------------------------------------------------------------------------------------------------- @@ -305,7 +305,7 @@ void RimSummaryEnsembleSumo::defineUiOrdering( QString uiConfigName, caf::PdmUiO uiOrdering.add( &m_sumoDataSource ); auto group = uiOrdering.addNewGroup( "General" ); - RimSummaryCaseCollection::defineUiOrdering( uiConfigName, *group ); + RimSummaryEnsemble::defineUiOrdering( uiConfigName, *group ); } //-------------------------------------------------------------------------------------------------- @@ -417,5 +417,5 @@ void RimSummaryEnsembleSumo::onLoadDataAndUpdate() buildMetaData(); // call the base class method after data has been loaded - RimSummaryCaseCollection::onLoadDataAndUpdate(); + RimSummaryEnsemble::onLoadDataAndUpdate(); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h index ee81686d0a..6c0adbf435 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h @@ -18,7 +18,7 @@ #pragma once -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "Cloud/RiaSumoConnector.h" @@ -51,7 +51,7 @@ namespace arrow class Table; } -class RimSummaryEnsembleSumo : public RimSummaryCaseCollection +class RimSummaryEnsembleSumo : public RimSummaryEnsemble { CAF_PDM_HEADER_INIT; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.cpp index 4adcfc187a..429a291e6f 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.cpp @@ -30,7 +30,7 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSurface.h" #include "RimSurfaceCollection.h" @@ -171,10 +171,10 @@ std::vector RimEnsembleSurface::filterByEnsembleCurveSet( const if ( m_ensembleCurveSet != nullptr ) { // Get the summary cases from the related ensemble summary curve set. - RimSummaryCaseCollection* summaryCaseCollection = m_ensembleCurveSet->summaryCaseCollection(); + RimSummaryEnsemble* summaryEnsemble = m_ensembleCurveSet->summaryEnsemble(); // - std::vector sumCases = m_ensembleCurveSet->filterEnsembleCases( summaryCaseCollection->allSummaryCases() ); + std::vector sumCases = m_ensembleCurveSet->filterEnsembleCases( summaryEnsemble->allSummaryCases() ); for ( auto sumCase : sumCases ) { for ( auto fileSurface : fileSurfaces ) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp index ece94e43ab..3edfe71131 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp @@ -37,7 +37,7 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimWellLogChannel.h" #include "RimWellLogCurve.h" #include "RimWellLogLasFile.h" @@ -641,7 +641,7 @@ void RimEnsembleWellLogCurveSet::updateFilterLegend() //-------------------------------------------------------------------------------------------------- RimSummaryCase* RimEnsembleWellLogCurveSet::findMatchingSummaryCase( RimWellLogLasFileCurve* wellLogCurve ) const { - RimSummaryCaseCollection* summaryCaseCollection = m_ensembleCurveSet->summaryCaseCollection(); + RimSummaryEnsemble* summaryCaseCollection = m_ensembleCurveSet->summaryEnsemble(); std::vector sumCases = summaryCaseCollection->allSummaryCases(); for ( auto sumCase : sumCases ) { @@ -994,7 +994,7 @@ std::vector RimEnsembleWellLogCurveSet::filterEnsembleCases( if ( m_ensembleCurveSet != nullptr && m_statistics->basedOnFilteredCases() ) { // Get the summary cases from the related ensemble summary curve set. - RimSummaryCaseCollection* summaryCaseCollection = m_ensembleCurveSet->summaryCaseCollection(); + RimSummaryEnsemble* summaryCaseCollection = m_ensembleCurveSet->summaryEnsemble(); // std::vector sumCases = m_ensembleCurveSet->filterEnsembleCases( summaryCaseCollection->allSummaryCases() ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp index 3ed71e357f..148472ac2c 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp @@ -50,7 +50,7 @@ #include "RimProject.h" #include "RimRftTools.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimTools.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" @@ -296,7 +296,7 @@ RimSummaryCase* RimWellLogRftCurve::summaryCase() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogRftCurve::setEnsemble( RimSummaryCaseCollection* ensemble ) +void RimWellLogRftCurve::setEnsemble( RimSummaryEnsemble* ensemble ) { m_ensemble = ensemble; } @@ -304,7 +304,7 @@ void RimWellLogRftCurve::setEnsemble( RimSummaryCaseCollection* ensemble ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCaseCollection* RimWellLogRftCurve::ensemble() const +RimSummaryEnsemble* RimWellLogRftCurve::ensemble() const { return m_ensemble; } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h index 2bb460fc26..9e6fd21bbf 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h @@ -36,7 +36,7 @@ class RigEclipseWellLogExtractor; class RimEclipseCase; class RimObservedFmuRftData; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimWellPath; class RimPressureDepthData; @@ -77,8 +77,8 @@ class RimWellLogRftCurve : public RimWellLogCurve void setSummaryCase( RimSummaryCase* summaryCase ); RimSummaryCase* summaryCase() const; - void setEnsemble( RimSummaryCaseCollection* ensemble ); - RimSummaryCaseCollection* ensemble() const; + void setEnsemble( RimSummaryEnsemble* ensemble ); + RimSummaryEnsemble* ensemble() const; void setObservedFmuRftData( RimObservedFmuRftData* observedFmuRftData ); RimObservedFmuRftData* observedFmuRftData() const; @@ -134,16 +134,16 @@ class RimWellLogRftCurve : public RimWellLogCurve static bool isSegmentResult( const QString& resultName ); private: - caf::PdmPtrField m_eclipseCase; - caf::PdmPtrField m_summaryCase; - caf::PdmPtrField m_ensemble; - caf::PdmPtrField m_observedFmuRftData; - caf::PdmPtrField m_pressureDepthData; - caf::PdmField m_timeStep; - caf::PdmField m_wellName; - caf::PdmField m_branchIndex; - caf::PdmField m_branchDetection; - caf::PdmField m_curveColorByPhase; + caf::PdmPtrField m_eclipseCase; + caf::PdmPtrField m_summaryCase; + caf::PdmPtrField m_ensemble; + caf::PdmPtrField m_observedFmuRftData; + caf::PdmPtrField m_pressureDepthData; + caf::PdmField m_timeStep; + caf::PdmField m_wellName; + caf::PdmField m_branchIndex; + caf::PdmField m_branchDetection; + caf::PdmField m_curveColorByPhase; caf::PdmField m_scaleFactor; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp index 0af19a5092..8a750efd3e 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp @@ -25,7 +25,7 @@ #include "RiaTextStringTools.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.h index ab651749bd..6c50e7b5e7 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.h @@ -30,7 +30,7 @@ class RimSummaryCase; class RimSummaryPlotCollection; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; //================================================================================================== /// @@ -47,7 +47,7 @@ class RimcSummaryPlotCollection_newSummaryPlot : public caf::PdmObjectMethod std::unique_ptr defaultResult() const override; private: - caf::PdmField m_addressString; - caf::PdmPtrArrayField m_summaryCases; - caf::PdmPtrField m_ensemble; + caf::PdmField m_addressString; + caf::PdmPtrArrayField m_summaryCases; + caf::PdmPtrField m_ensemble; }; diff --git a/ApplicationLibCode/UnitTests/RimSummaryCaseCollection-Test.cpp b/ApplicationLibCode/UnitTests/RimSummaryCaseCollection-Test.cpp index 84943ba3d9..e72a30896c 100644 --- a/ApplicationLibCode/UnitTests/RimSummaryCaseCollection-Test.cpp +++ b/ApplicationLibCode/UnitTests/RimSummaryCaseCollection-Test.cpp @@ -5,18 +5,18 @@ #include -class RimSummaryCaseCollection_TESTER +class RimSummaryEnsemble_TESTER { public: static void test1(); }; -TEST( RimSummaryCaseCollection, RigEnsembleParameter ) +TEST( RimSummaryEnsemble, RigEnsembleParameter ) { - RimSummaryCaseCollection_TESTER::test1(); + RimSummaryEnsemble_TESTER::test1(); } -void RimSummaryCaseCollection_TESTER::test1() +void RimSummaryEnsemble_TESTER::test1() { std::random_device rd; std::mt19937 gen( rd() ); diff --git a/ApplicationLibCode/UserInterface/RiuDragDrop.cpp b/ApplicationLibCode/UserInterface/RiuDragDrop.cpp index 81aea9b534..f769dac2b5 100644 --- a/ApplicationLibCode/UserInterface/RiuDragDrop.cpp +++ b/ApplicationLibCode/UserInterface/RiuDragDrop.cpp @@ -36,8 +36,8 @@ #include "RimSummaryAddress.h" #include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RimSurface.h" #include "RimSurfaceCollection.h" #include "RimWellAllocationPlot.h" @@ -248,7 +248,7 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const if ( dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || - dynamic_cast( uiItem ) || dynamic_cast( uiItem ) ) + dynamic_cast( uiItem ) || dynamic_cast( uiItem ) ) { itemflags |= Qt::ItemIsDragEnabled; } @@ -316,7 +316,7 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const } } } - else if ( dynamic_cast( uiItem ) ) + else if ( dynamic_cast( uiItem ) ) { if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) { @@ -411,7 +411,7 @@ bool RiuDragDrop::dropMimeData( const QMimeData* data, Qt::DropAction action, in return handleMultiPlotDrop( action, draggedObjects, multiPlot, row ); } - auto summaryCaseCollection = dropTarget->firstAncestorOrThisOfType(); + auto summaryCaseCollection = dropTarget->firstAncestorOrThisOfType(); if ( summaryCaseCollection ) { return handleSummaryCaseCollectionDrop( action, draggedObjects, summaryCaseCollection ); @@ -570,9 +570,9 @@ bool RiuDragDrop::handleWellLogPlotDrop( Qt::DropAction action, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiuDragDrop::handleSummaryCaseCollectionDrop( Qt::DropAction action, - caf::PdmObjectGroup& draggedObjects, - RimSummaryCaseCollection* summaryCaseDropTarget ) +bool RiuDragDrop::handleSummaryCaseCollectionDrop( Qt::DropAction action, + caf::PdmObjectGroup& draggedObjects, + RimSummaryEnsemble* summaryCaseDropTarget ) { std::vector summaryCases = RiuTypedPdmObjects::typedObjectsFromGroup( draggedObjects ); @@ -580,7 +580,7 @@ bool RiuDragDrop::handleSummaryCaseCollectionDrop( Qt::DropAction act for ( RimSummaryCase* summaryCase : summaryCases ) { - auto summaryCaseCollection = summaryCase->firstAncestorOrThisOfType(); + auto summaryCaseCollection = summaryCase->firstAncestorOrThisOfType(); if ( summaryCaseCollection ) { @@ -615,7 +615,7 @@ bool RiuDragDrop::handleSummaryCaseMainCollectionDrop( Qt::DropAction for ( RimSummaryCase* summaryCase : summaryCases ) { - auto summaryCaseCollection = summaryCase->firstAncestorOrThisOfType(); + auto summaryCaseCollection = summaryCase->firstAncestorOrThisOfType(); if ( summaryCaseCollection ) { diff --git a/ApplicationLibCode/UserInterface/RiuDragDrop.h b/ApplicationLibCode/UserInterface/RiuDragDrop.h index f6b5531e5b..fbeedd02dc 100644 --- a/ApplicationLibCode/UserInterface/RiuDragDrop.h +++ b/ApplicationLibCode/UserInterface/RiuDragDrop.h @@ -32,7 +32,7 @@ class PdmUiTreeView; class RimMultiPlot; class RimIdenticalGridCaseGroup; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimSummaryCaseMainCollection; class RimSummaryCurve; class RimSummaryPlot; @@ -79,9 +79,7 @@ class RiuDragDrop : public caf::PdmUiDragDropInterface bool handleWellLogPlotDrop( Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogPlot* wellLogPlot, int insertAtPosition ); bool handleMultiPlotDrop( Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimMultiPlot* multiPlot, int insertAtPosition ); - bool handleSummaryCaseCollectionDrop( Qt::DropAction action, - caf::PdmObjectGroup& objectGroup, - RimSummaryCaseCollection* summaryCaseCollection ); + bool handleSummaryCaseCollectionDrop( Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimSummaryEnsemble* summaryCaseCollection ); bool handleSummaryCaseMainCollectionDrop( Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimSummaryCaseMainCollection* summaryCaseMainCollection ); diff --git a/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp b/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp index 9cd95d1fda..7806fab2ec 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp @@ -23,8 +23,8 @@ #include "RimEnsembleCurveSet.h" #include "RimPlot.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryEnsemble.h" #include "RimSummaryPlot.h" #include "RiuPlotCurve.h" @@ -85,9 +85,9 @@ void RiuSummaryPlot::showContextMenu( QPoint pos ) { std::time_t timeStep = summaryCurve->timeStepsY()[closestCurvePoint]; - RimSummaryCaseCollection* ensemble = nullptr; - QString clickedQuantityName; - QStringList allQuantityNamesInPlot; + RimSummaryEnsemble* ensemble = nullptr; + QString clickedQuantityName; + QStringList allQuantityNamesInPlot; auto clickedEnsembleCurveSet = summaryCurve->firstAncestorOrThisOfType(); @@ -95,7 +95,7 @@ void RiuSummaryPlot::showContextMenu( QPoint pos ) if ( clickedEnsembleCurveSet ) { - ensemble = clickedEnsembleCurveSet->summaryCaseCollection(); + ensemble = clickedEnsembleCurveSet->summaryEnsemble(); if ( ensemble && ensemble->isEnsemble() ) { clickedQuantityName = QString::fromStdString( clickedEnsembleCurveSet->summaryAddressY().uiText() ); diff --git a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.cpp b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.cpp index e7ce07ff71..c18d65dd5c 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.cpp @@ -20,7 +20,7 @@ #include "RiaSummaryCurveDefinition.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryEnsemble.h" #include "RiuSummaryVectorSelectionUi.h" #include "RiuSummaryVectorSelectionWidgetCreator.h" @@ -94,7 +94,7 @@ void RiuSummaryVectorSelectionDialog::setCaseAndAddress( RimSummaryCase* summary //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuSummaryVectorSelectionDialog::setEnsembleAndAddress( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& address ) +void RiuSummaryVectorSelectionDialog::setEnsembleAndAddress( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& address ) { if ( ensemble ) { @@ -113,8 +113,7 @@ void RiuSummaryVectorSelectionDialog::setEnsembleAndAddress( RimSummaryCaseColle //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuSummaryVectorSelectionDialog::setEnsembleAndAddresses( RimSummaryCaseCollection* ensemble, - std::vector addresses ) +void RiuSummaryVectorSelectionDialog::setEnsembleAndAddresses( RimSummaryEnsemble* ensemble, std::vector addresses ) { if ( ensemble ) { diff --git a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.h b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.h index e0b6ed2393..f34aa4a6d8 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.h +++ b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.h @@ -25,7 +25,7 @@ class RiaSummaryCurveDefinition; class RifEclipseSummaryAddress; class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RiuSummaryVectorSelectionUi; class RiuSummaryVectorSelectionWidgetCreator; @@ -42,8 +42,8 @@ class RiuSummaryVectorSelectionDialog : public QDialog ~RiuSummaryVectorSelectionDialog() override; void setCaseAndAddress( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& address ); - void setEnsembleAndAddress( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& address ); - void setEnsembleAndAddresses( RimSummaryCaseCollection* ensemble, std::vector addresses ); + void setEnsembleAndAddress( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& address ); + void setEnsembleAndAddresses( RimSummaryEnsemble* ensemble, std::vector addresses ); void setCurveSelection( const std::vector& selection ); std::vector curveSelection() const; diff --git a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp index 046059581d..95361d00cc 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp @@ -35,8 +35,8 @@ #include "RimSummaryCalculation.h" #include "RimSummaryCalculationCollection.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryEnsemble.h" #include "RiuSummaryCurveDefinitionKeywords.h" #include "RiuSummaryQuantityNameInfoProvider.h" @@ -372,7 +372,7 @@ std::vector RiuSummaryVectorSelectionUi::allCurveSetDefin for ( SummarySource* currSource : selectedSummarySources() ) { - RimSummaryCaseCollection* ensemble = dynamic_cast( currSource ); + RimSummaryEnsemble* ensemble = dynamic_cast( currSource ); if ( !ensemble ) continue; std::set addressesFromSource; @@ -406,8 +406,8 @@ std::vector RiuSummaryVectorSelectionUi::selection() std::set selectedAddressesFromUi = buildAddressListFromSelections(); for ( SummarySource* currSource : selectedSummarySources() ) { - RimSummaryCaseCollection* ensemble = dynamic_cast( currSource ); - RimSummaryCase* sourceCase = dynamic_cast( currSource ); + RimSummaryEnsemble* ensemble = dynamic_cast( currSource ); + RimSummaryCase* sourceCase = dynamic_cast( currSource ); if ( ensemble ) { @@ -528,8 +528,8 @@ void RiuSummaryVectorSelectionUi::setDefaultSelection( const std::vector curveDefs; for ( SummarySource* s : selectTheseSources ) { - RimSummaryCase* sumCase = dynamic_cast( s ); - RimSummaryCaseCollection* ensemble = dynamic_cast( s ); + RimSummaryCase* sumCase = dynamic_cast( s ); + RimSummaryEnsemble* ensemble = dynamic_cast( s ); if ( ensemble ) { curveDefs.push_back( RiaSummaryCurveDefinition( ensemble, defaultAddress ) ); @@ -983,8 +983,8 @@ std::set std::vector sources; for ( const auto& source : m_selectedSources.value() ) { - RimSummaryCase* sumCase = dynamic_cast( source.p() ); - RimSummaryCaseCollection* ensemble = dynamic_cast( source.p() ); + RimSummaryCase* sumCase = dynamic_cast( source.p() ); + RimSummaryEnsemble* ensemble = dynamic_cast( source.p() ); if ( sumCase ) { @@ -1040,8 +1040,8 @@ std::set { std::set allAddresses; - RimSummaryCase* currCase = dynamic_cast( currSource ); - RimSummaryCaseCollection* currEnsemble = dynamic_cast( currSource ); + RimSummaryCase* currCase = dynamic_cast( currSource ); + RimSummaryEnsemble* currEnsemble = dynamic_cast( currSource ); if ( currCase ) { diff --git a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.h b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.h index 744228101e..4736ad6e73 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.h +++ b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.h @@ -32,7 +32,7 @@ #define OBSERVED_DATA_AVALUE_POSTFIX "_OBSDATA" class RimSummaryCase; -class RimSummaryCaseCollection; +class RimSummaryEnsemble; class RimSummaryCurveAutoName; class RimSummaryPlot; class RiaSummaryCurveDefinition; From 21c38e925d6fe2ebf1d7785e63ce2093cdb6e150 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:10:43 +0200 Subject: [PATCH 208/332] Update to latest advanced docking to get the latest bug fixes. (#11584) * Update to latest advanced docking to get the latest bug fixes. --- ThirdParty/qtadvanceddocking | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdParty/qtadvanceddocking b/ThirdParty/qtadvanceddocking index fc54cc5e5a..b2156037a8 160000 --- a/ThirdParty/qtadvanceddocking +++ b/ThirdParty/qtadvanceddocking @@ -1 +1 @@ -Subproject commit fc54cc5e5af0bdf49670e10bd6366015eb3ab3f2 +Subproject commit b2156037a83a99c208b07bb65893630079fd1365 From 451862801340174a74569163197d23758dcbd778 Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Tue, 6 Aug 2024 17:06:58 +0200 Subject: [PATCH 209/332] Support skipping invalid IWEL records without shutting down ResInsight --- ThirdParty/Ert/lib/ecl/well_state.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ThirdParty/Ert/lib/ecl/well_state.cpp b/ThirdParty/Ert/lib/ecl/well_state.cpp index 64671264c6..cf98022f5c 100644 --- a/ThirdParty/Ert/lib/ecl/well_state.cpp +++ b/ThirdParty/Ert/lib/ecl/well_state.cpp @@ -217,7 +217,11 @@ well_state_type* well_state_alloc(const char* well_name, int global_well_nr, boo /* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */ if ((type == ECL_WELL_ZERO) && open) - util_abort("%s: Invalid type value for open wells.\n", __func__); + { + delete well_state; + //util_abort("%s: Invalid type value for open wells.\n", __func__); + return nullptr; + } return well_state; } @@ -600,12 +604,14 @@ well_state_type* well_state_alloc_from_file2(ecl_file_view_type* file_view, std: well_state = well_state_alloc(name, global_well_nr, open, type, report_nr, global_header->sim_time); free(name); + if (well_state != nullptr) + { + well_state_add_connections2(well_state, grid_names, file_view, global_well_nr); + if (ecl_file_view_has_kw(file_view, ISEG_KW)) + well_state_add_MSW2(well_state, file_view, global_well_nr, load_segment_information); - well_state_add_connections2(well_state, grid_names, file_view, global_well_nr); - if (ecl_file_view_has_kw(file_view, ISEG_KW)) - well_state_add_MSW2(well_state, file_view, global_well_nr, load_segment_information); - - well_state_add_rates(well_state, file_view, global_well_nr); + well_state_add_rates(well_state, file_view, global_well_nr); + } } ecl_rsthead_free(global_header); return well_state; From 4a2339661c3b8b5a52140ab25fc4432814c472a9 Mon Sep 17 00:00:00 2001 From: Samiha Hoque <86004629+samihahoque@users.noreply.github.com> Date: Mon, 12 Aug 2024 06:00:17 -0600 Subject: [PATCH 210/332] fix: GrpcInterface/Python/dev-requirements.txt to reduce vulnerabilities The following vulnerabilities are fixed by pinning transitive dependencies: - https://snyk.io/vuln/SNYK-PYTHON-SETUPTOOLS-7448482 Co-authored-by: snyk-bot --- GrpcInterface/Python/dev-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/GrpcInterface/Python/dev-requirements.txt b/GrpcInterface/Python/dev-requirements.txt index 26207d9c11..1dc6aea7a2 100644 --- a/GrpcInterface/Python/dev-requirements.txt +++ b/GrpcInterface/Python/dev-requirements.txt @@ -4,3 +4,4 @@ protobuf wheel typing-extensions pytest +setuptools>=70.0.0 # not directly required, pinned by Snyk to avoid a vulnerability From aac694b66a6616449eff9cdd43a220d7401986a5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 13 Aug 2024 09:53:39 +0200 Subject: [PATCH 211/332] Add configuration file for Dependabot used to create PR when selected submodules are updated --- .github/dependabot.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..d8188795c1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: gitsubmodule + directory: "/" + allow: + - dependency-name: "ThirdParty/fast_float" + - dependency-name: "ThirdParty/qtadvanceddocking" + - dependency-name: "ThirdParty/regression-analysis" + - dependency-name: "ThirdParty/roff-cpp" + - dependency-name: "ThirdParty/spdlog" + - dependency-name: "ThirdParty/tomlplusplus" + schedule: + interval: "weekly" From 123baa5d4e48cb575f06515e0ebfc704089a8347 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 13 Aug 2024 13:59:47 +0200 Subject: [PATCH 212/332] Create update-submodules.yml Update specified submodules to latest available version by creating a PR for each submodule. --- .github/workflows/update-submodules.yml | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/update-submodules.yml diff --git a/.github/workflows/update-submodules.yml b/.github/workflows/update-submodules.yml new file mode 100644 index 0000000000..e601b1893c --- /dev/null +++ b/.github/workflows/update-submodules.yml @@ -0,0 +1,62 @@ +name: Update Submodules + +on: + schedule: + - cron: '0 0 * * 0' # Runs every Sunday at midnight + workflow_dispatch: # Allows manual triggering of the workflow + +jobs: + update-submodules: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install GitHub CLI + run: sudo apt-get install -y gh + + - name: Configure Git + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Update submodules to latest release + run: | + cd ThirdParty + submodules=("fast_float" "qtadvanceddocking" "regression-analysis" "roff-cpp" "spdlog" "tomlplusplus" ) + for submodule in "${submodules[@]}"; do + BRANCH_NAME=ci-update-$submodule + if git show-ref --verify --quiet refs/heads/$BRANCH_NAME; then + echo "Branch $BRANCH_NAME exists." + git checkout $BRANCH_NAME + else + echo "Branch $BRANCH_NAME does not exist. Creating branch." + git checkout -b $BRANCH_NAME + fi + + cd $submodule + git fetch --tags + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $latest_tag + cd .. + git add $submodule + git commit -m "Update $submodule to $latest_tag" || echo "No changes to commit" + git push origin $BRANCH_NAME + git checkout dev + + git reset --hard origin/dev --recurse-submodule + done + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Pull Requests for each submodule + run: | + submodules=("fast_float" "qtadvanceddocking" "regression-analysis" "roff-cpp" "spdlog" "tomlplusplus" ) + for submodule in "${submodules[@]}"; do + gh pr create --title "Update $submodule to latest release" --body "This PR updates the $submodule submodule to its latest release." --head ci-update-$submodule --base dev + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0ee28b73dd547a1a8779b26b1922be36b49cc758 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 13 Aug 2024 15:32:19 +0200 Subject: [PATCH 213/332] Update update-submodules.yml --- .github/workflows/update-submodules.yml | 31 +++++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/update-submodules.yml b/.github/workflows/update-submodules.yml index e601b1893c..2404e8a375 100644 --- a/.github/workflows/update-submodules.yml +++ b/.github/workflows/update-submodules.yml @@ -26,27 +26,38 @@ jobs: - name: Update submodules to latest release run: | cd ThirdParty - submodules=("fast_float" "qtadvanceddocking" "regression-analysis" "roff-cpp" "spdlog" "tomlplusplus" ) + + submodules=("fast_float" "spdlog" "tomlplusplus" ) for submodule in "${submodules[@]}"; do BRANCH_NAME=ci-update-$submodule - if git show-ref --verify --quiet refs/heads/$BRANCH_NAME; then + if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then echo "Branch $BRANCH_NAME exists." - git checkout $BRANCH_NAME + git checkout -b "$BRANCH_NAME" "origin/$BRANCH_NAME" else echo "Branch $BRANCH_NAME does not exist. Creating branch." - git checkout -b $BRANCH_NAME + git checkout -b "$BRANCH_NAME" fi cd $submodule git fetch --tags latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) - git checkout $latest_tag + + if [ -n "$latest_tag" ]; then + git checkout $latest_tag + else + echo "Empty tag detected in $submodule. Nothing to do." + fi + cd .. - git add $submodule - git commit -m "Update $submodule to $latest_tag" || echo "No changes to commit" - git push origin $BRANCH_NAME + if git diff --quiet; then + echo "No changes detected in $submodule" + else + git add $submodule + git commit -m "Update $submodule to $latest_tag" || echo "No changes to commit" + git push origin "$BRANCH_NAME" + fi + git checkout dev - git reset --hard origin/dev --recurse-submodule done env: @@ -54,7 +65,7 @@ jobs: - name: Create Pull Requests for each submodule run: | - submodules=("fast_float" "qtadvanceddocking" "regression-analysis" "roff-cpp" "spdlog" "tomlplusplus" ) + submodules=("fast_float" "spdlog" "tomlplusplus" ) for submodule in "${submodules[@]}"; do gh pr create --title "Update $submodule to latest release" --body "This PR updates the $submodule submodule to its latest release." --head ci-update-$submodule --base dev done From c0334cce623cc6b4aa62500d2c906f47216993df Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 13 Aug 2024 15:51:34 +0200 Subject: [PATCH 214/332] Update update-submodules.yml --- .github/workflows/update-submodules.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/update-submodules.yml b/.github/workflows/update-submodules.yml index 2404e8a375..c03e1878ba 100644 --- a/.github/workflows/update-submodules.yml +++ b/.github/workflows/update-submodules.yml @@ -26,6 +26,8 @@ jobs: - name: Update submodules to latest release run: | cd ThirdParty + + git fetch --all submodules=("fast_float" "spdlog" "tomlplusplus" ) for submodule in "${submodules[@]}"; do From 17ba68f45bf5728b4143810e84505e0b6a91c143 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 13 Aug 2024 16:02:23 +0200 Subject: [PATCH 215/332] Use Dependabot to update the version of GitHub actions used in our own GitHub Actions --- .github/dependabot.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d8188795c1..58c498d4c3 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,14 +5,8 @@ version: 2 updates: - - package-ecosystem: gitsubmodule + - package-ecosystem: "github-actions" directory: "/" - allow: - - dependency-name: "ThirdParty/fast_float" - - dependency-name: "ThirdParty/qtadvanceddocking" - - dependency-name: "ThirdParty/regression-analysis" - - dependency-name: "ThirdParty/roff-cpp" - - dependency-name: "ThirdParty/spdlog" - - dependency-name: "ThirdParty/tomlplusplus" schedule: + # Check for updates to GitHub Actions every week interval: "weekly" From 98aacf2a54c51789ad6805da892322b9facaee95 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:03:27 +0000 Subject: [PATCH 216/332] Bump actions/github-script from 6 to 7 Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/github-script dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/close-label.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/close-label.yml b/.github/workflows/close-label.yml index e2ea258443..a6ca624514 100644 --- a/.github/workflows/close-label.yml +++ b/.github/workflows/close-label.yml @@ -9,7 +9,7 @@ jobs: permissions: issues: write steps: - - uses: actions/github-script@v6 + - uses: actions/github-script@v7 with: script: | github.rest.issues.addLabels({ From f1fa944c5872c9320d9b2b505b349f939d04eb99 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:03:23 +0000 Subject: [PATCH 217/332] Bump jurplel/install-qt-action from 3 to 4 Bumps [jurplel/install-qt-action](https://github.com/jurplel/install-qt-action) from 3 to 4. - [Release notes](https://github.com/jurplel/install-qt-action/releases) - [Commits](https://github.com/jurplel/install-qt-action/compare/v3...v4) --- updated-dependencies: - dependency-name: jurplel/install-qt-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/AppFwkUnitTest.yml | 2 +- .github/workflows/ResInsightWithCache.yml | 2 +- .github/workflows/clang-tidy.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/AppFwkUnitTest.yml b/.github/workflows/AppFwkUnitTest.yml index 34419982e0..18bfd30b83 100644 --- a/.github/workflows/AppFwkUnitTest.yml +++ b/.github/workflows/AppFwkUnitTest.yml @@ -34,7 +34,7 @@ jobs: sudo apt-get install --option="APT::Acquire::Retries=3" libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev - name: Install Qt - uses: jurplel/install-qt-action@v3 + uses: jurplel/install-qt-action@v4 with: version: ${{ matrix.qtver }} dir: "${{ github.workspace }}/Qt/" diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 4dfa3126dd..a962432c41 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -170,7 +170,7 @@ jobs: sudo ./llvm.sh 16 all - name: Install Qt - uses: jurplel/install-qt-action@v3 + uses: jurplel/install-qt-action@v4 with: version: 5.12.12 dir: "${{ github.workspace }}/Qt/" diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index f417dc72ba..55ec260867 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -43,7 +43,7 @@ jobs: sudo apt-get install clang-tidy-15 clang-format-15 - name: Install Qt - uses: jurplel/install-qt-action@v3 + uses: jurplel/install-qt-action@v4 with: version: 5.12.12 dir: "${{ github.workspace }}/Qt/" From d38db625d62183412e40c4b7d198f17382b6ff1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:03:19 +0000 Subject: [PATCH 218/332] Bump actions/checkout from 2 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/centos7.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/centos7.yml b/.github/workflows/centos7.yml index 2e4de20260..048bb85ee3 100644 --- a/.github/workflows/centos7.yml +++ b/.github/workflows/centos7.yml @@ -44,7 +44,7 @@ jobs: make -j 4 make install - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: true - name: Set up Python From 694d2eda66d5b42718aa93362918afadad81da68 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 28 Jun 2024 12:33:19 +0200 Subject: [PATCH 219/332] Add background data loader framework and well path loaders. --- .../Application/RiaApplication.cpp | 29 ++++ .../Application/RiaApplication.h | 2 + .../WellPath/CMakeLists_files.cmake | 9 ++ .../WellPath/RimFileWellPathDataLoader.cpp | 63 ++++++++ .../WellPath/RimFileWellPathDataLoader.h | 45 ++++++ .../WellPath/RimModeledWellPathDataLoader.cpp | 54 +++++++ .../WellPath/RimModeledWellPathDataLoader.h | 36 +++++ .../WellPath/RimOsduWellPathDataLoader.cpp | 109 ++++++++++++++ .../WellPath/RimOsduWellPathDataLoader.h | 51 +++++++ .../WellPath/RimWellPathCollection.cpp | 79 ++++------ CMakeLists.txt | 2 + Fwk/AppFwk/CMakeLists.txt | 1 + Fwk/AppFwk/cafDataLoader/CMakeLists.txt | 48 +++++++ .../cafDataLoader/cafDataLoadController.cpp | 136 ++++++++++++++++++ .../cafDataLoader/cafDataLoadController.h | 86 +++++++++++ Fwk/AppFwk/cafDataLoader/cafDataLoadTask.cpp | 67 +++++++++ Fwk/AppFwk/cafDataLoader/cafDataLoadTask.h | 75 ++++++++++ Fwk/AppFwk/cafDataLoader/cafDataLoader.cpp | 47 ++++++ Fwk/AppFwk/cafDataLoader/cafDataLoader.h | 65 +++++++++ Fwk/CMakeLists.txt | 1 + 20 files changed, 954 insertions(+), 51 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.h create mode 100644 ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPathDataLoader.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPathDataLoader.h create mode 100644 ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h create mode 100644 Fwk/AppFwk/cafDataLoader/CMakeLists.txt create mode 100644 Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp create mode 100644 Fwk/AppFwk/cafDataLoader/cafDataLoadController.h create mode 100644 Fwk/AppFwk/cafDataLoader/cafDataLoadTask.cpp create mode 100644 Fwk/AppFwk/cafDataLoader/cafDataLoadTask.h create mode 100644 Fwk/AppFwk/cafDataLoader/cafDataLoader.cpp create mode 100644 Fwk/AppFwk/cafDataLoader/cafDataLoader.h diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index f373e31a06..c615eac49c 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -54,6 +54,8 @@ #include "RimEclipseView.h" #include "RimEnsembleWellLogsCollection.h" #include "RimFaultReactivationModelCollection.h" +#include "RimFileWellPath.h" +#include "RimFileWellPathDataLoader.h" #include "RimFormationNamesCollection.h" #include "RimFractureTemplateCollection.h" #include "RimGeoMechCase.h" @@ -63,10 +65,15 @@ #include "RimGridSummaryCase.h" #include "RimIdenticalGridCaseGroup.h" #include "RimMainPlotCollection.h" +#include "RimModeledWellPath.h" +#include "RimModeledWellPathDataLoader.h" #include "RimObservedDataCollection.h" #include "RimObservedFmuRftData.h" #include "RimObservedSummaryData.h" #include "RimOilField.h" +#include "RimOsduWellPath.h" +#include "RimOsduWellPathDataLoader.h" +#include "RimPlotWindow.h" #include "RimProject.h" #include "RimScriptCollection.h" #include "RimSeismicData.h" @@ -96,6 +103,7 @@ #include "RiuViewer.h" #include "RiuViewerCommands.h" +#include "cafDataLoadController.h" #include "cafPdmCodeGenerator.h" #include "cafPdmDataValueField.h" #include "cafPdmDefaultObjectFactory.h" @@ -1525,6 +1533,8 @@ void RiaApplication::initialize() m_project->setPlotTemplateFolders( m_preferences->plotTemplateFolders() ); caf::SelectionManager::instance()->setPdmRootObject( project() ); + + initializeDataLoadController(); } //-------------------------------------------------------------------------------------------------- @@ -1730,3 +1740,22 @@ RiaSumoConnector* RiaApplication::makeSumoConnector() return m_sumoConnector; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaApplication::initializeDataLoadController() +{ + caf::DataLoadController* dataLoadController = caf::DataLoadController::instance(); + + const QString wellPathGeometryKeyword = "WELL_PATH_GEOMETRY"; + dataLoadController->registerDataLoader( RimFileWellPath::classKeywordStatic(), + wellPathGeometryKeyword, + std::make_shared() ); + dataLoadController->registerDataLoader( RimOsduWellPath::classKeywordStatic(), + wellPathGeometryKeyword, + std::make_shared() ); + dataLoadController->registerDataLoader( RimModeledWellPath::classKeywordStatic(), + wellPathGeometryKeyword, + std::make_shared() ); +} diff --git a/ApplicationLibCode/Application/RiaApplication.h b/ApplicationLibCode/Application/RiaApplication.h index ce0feaac55..5d9d046c2e 100644 --- a/ApplicationLibCode/Application/RiaApplication.h +++ b/ApplicationLibCode/Application/RiaApplication.h @@ -227,6 +227,8 @@ class RiaApplication bool generateCode( const QString& outputPath, gsl::not_null errMsg ); protected: + void initializeDataLoadController(); + cvf::ref m_defaultSceneFont; cvf::ref m_defaultAnnotationFont; cvf::ref m_defaultWellLabelFont; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake index ab55fcaf61..14418631df 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake @@ -16,6 +16,9 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellIAModelData.h ${CMAKE_CURRENT_LIST_DIR}/RimWellIADataAccess.h ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellPath.h + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellPathDataLoader.h + ${CMAKE_CURRENT_LIST_DIR}/RimFileWellPathDataLoader.h + ${CMAKE_CURRENT_LIST_DIR}/RimModeledWellPathDataLoader.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -36,12 +39,18 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellIAModelData.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellIADataAccess.cpp ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellPath.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellPathDataLoader.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimFileWellPathDataLoader.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimModeledWellPathDataLoader.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) +list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellPathDataLoader.h) + + source_group( "ProjectDataModel\\WellPath" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.cpp new file mode 100644 index 0000000000..d751ff4eb5 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.cpp @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimFileWellPathDataLoader.h" + +#include "RiaLogging.h" +#include "RimFileWellPath.h" + +#include "RigWellPath.h" + +#include "cafProgressInfo.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFileWellPathDataLoader::RimFileWellPathDataLoader() + : caf::DataLoader() +{ + m_wellPathImporter = std::make_unique(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFileWellPathDataLoader::loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) +{ + auto* fWPath = dynamic_cast( &pdmObject ); + if ( fWPath && !fWPath->filePath().isEmpty() ) + { + QString errorMessage; + if ( !fWPath->readWellPathFile( &errorMessage, m_wellPathImporter.get(), false ) ) + { + RiaLogging::warning( errorMessage ); + } + } + taskDone.send( dataType, taskId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFileWellPathDataLoader::isRunnable() const +{ + return true; +} diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.h new file mode 100644 index 0000000000..5f9b2a2b08 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimFileWellPath.h" + +#include "cafDataLoader.h" +#include "cafProgressInfo.h" + +#include + +#include + +#include "RifWellPathImporter.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RimFileWellPathDataLoader : public caf::DataLoader +{ +public: + RimFileWellPathDataLoader(); + void loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) override; + bool isRunnable() const override; + +private: + std::unique_ptr m_wellPathImporter; +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPathDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPathDataLoader.cpp new file mode 100644 index 0000000000..1520f2a8a0 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPathDataLoader.cpp @@ -0,0 +1,54 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimModeledWellPathDataLoader.h" + +#include "RimModeledWellPath.h" + +#include "RigWellPath.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimModeledWellPathDataLoader::RimModeledWellPathDataLoader() + : caf::DataLoader() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimModeledWellPathDataLoader::loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) +{ + auto* mWPath = dynamic_cast( &pdmObject ); + + if ( mWPath ) + { + mWPath->createWellPathGeometry(); + } + + taskDone.send( dataType, taskId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimModeledWellPathDataLoader::isRunnable() const +{ + return true; +} diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPathDataLoader.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPathDataLoader.h new file mode 100644 index 0000000000..c17fd1deab --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPathDataLoader.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "cafDataLoader.h" +#include "cafProgressInfo.h" + +#include + +//================================================================================================== +/// +/// +//================================================================================================== +class RimModeledWellPathDataLoader : public caf::DataLoader +{ +public: + RimModeledWellPathDataLoader(); + void loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) override; + bool isRunnable() const override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp new file mode 100644 index 0000000000..72f1ea04bf --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp @@ -0,0 +1,109 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimOsduWellPathDataLoader.h" + +#include "Cloud/RiaOsduConnector.h" +#include "RiaApplication.h" +#include "RiaLogging.h" + +#include "RimOsduWellPath.h" + +#include "RifOsduWellPathReader.h" + +#include "RigWellPath.h" + +#include "cafProgressInfo.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimOsduWellPathDataLoader::RimOsduWellPathDataLoader() + : caf::DataLoader() +{ + RiaApplication* app = RiaApplication::instance(); + RiaOsduConnector* osduConnector = app->makeOsduConnector(); + + connect( osduConnector, + SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ), + this, + SLOT( parquetDownloadComplete( const QByteArray&, const QString&, const QString& ) ), + Qt::QueuedConnection ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellPathDataLoader::loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) +{ + RiaApplication* app = RiaApplication::instance(); + RiaOsduConnector* osduConnector = app->makeOsduConnector(); + + // TODO: this is weird? + m_dataType = dataType; + + auto oWPath = dynamic_cast( &pdmObject ); + if ( oWPath ) + { + QString trajectoryId = oWPath->wellboreTrajectoryId(); + osduConnector->requestWellboreTrajectoryParquetDataById( trajectoryId ); + m_wellPaths[trajectoryId] = oWPath; + m_taskIds[trajectoryId] = taskId; + } + QApplication::processEvents(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimOsduWellPathDataLoader::isRunnable() const +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellPathDataLoader::parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id ) +{ + RiaLogging::info( QString( "Parquet download complete. Id: %1 Size: %2" ).arg( id ).arg( contents.size() ) ); + + QMutexLocker lock( &m_mutex ); + int taskId = m_taskIds[id]; + + if ( !contents.isEmpty() ) + { + m_parquetData[id] = contents; + + auto oWPath = m_wellPaths[id]; + auto [wellPathGeometry, errorMessage] = RifOsduWellPathReader::readWellPathData( contents, oWPath->datumElevationFromOsdu() ); + if ( wellPathGeometry.notNull() ) + { + oWPath->setWellPathGeometry( wellPathGeometry.p() ); + } + else + { + RiaLogging::warning( errorMessage ); + } + } + + taskDone.send( m_dataType, taskId ); +} diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h new file mode 100644 index 0000000000..7387e40986 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimOsduWellPath.h" + +#include "cafDataLoader.h" +#include "cafProgressInfo.h" + +#include +#include +#include + +//================================================================================================== +/// +/// +//================================================================================================== +class RimOsduWellPathDataLoader : public QObject, public caf::DataLoader +{ + Q_OBJECT +public: + RimOsduWellPathDataLoader(); + void loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) override; + bool isRunnable() const override; + +private slots: + void parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id ); + +private: + std::map m_parquetData; + std::map m_wellPaths; + std::map m_taskIds; + QString m_dataType; + QMutex m_mutex; +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 6a6f4033be..b66067adc4 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -22,6 +22,7 @@ #include "Cloud/RiaOsduConnector.h" #include "RiaColorTables.h" +#include "RiaDateStringParser.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" #include "RiaPreferences.h" @@ -62,6 +63,8 @@ #include "Riu3DMainWindowTools.h" +#include "cafDataLoadController.h" +#include "cafDataLoader.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" #include "cafPdmUiEditorHandle.h" @@ -154,73 +157,47 @@ void RimWellPathCollection::loadDataAndUpdate() RiaApplication* app = RiaApplication::instance(); + caf::DataLoadController* dataLoadController = caf::DataLoadController::instance(); + + const QString wellPathGeometryKeyword = "WELL_PATH_GEOMETRY"; + for ( RimWellPath* wellPath : allWellPaths() ) { - progress.setProgressDescription( QString( "Reading file %1" ).arg( wellPath->name() ) ); + progress.setProgressDescription( QString( "Reading well %1" ).arg( wellPath->name() ) ); + dataLoadController->loadData( *wellPath, wellPathGeometryKeyword, progress ); + } - auto* fWPath = dynamic_cast( wellPath ); - auto* mWPath = dynamic_cast( wellPath ); - auto* oWPath = dynamic_cast( wellPath ); - if ( fWPath ) + dataLoadController->blockUntilDone( wellPathGeometryKeyword ); + + for ( RimWellPath* wellPath : allWellPaths() ) + { + for ( RimWellLog* wellLog : wellPath->wellLogs() ) { - if ( !fWPath->filePath().isEmpty() ) + if ( RimWellLogFile* wellLogFile = dynamic_cast( wellLog ) ) { QString errorMessage; - if ( !fWPath->readWellPathFile( &errorMessage, m_wellPathImporter.get(), false ) ) + if ( !wellLogFile->readFile( &errorMessage ) ) { RiaLogging::warning( errorMessage ); } } - } - else if ( mWPath ) - { - mWPath->createWellPathGeometry(); - } - else if ( oWPath ) - { - RiaOsduConnector* osduConnector = app->makeOsduConnector(); - auto [wellPathGeometry, errorMessage] = - loadWellPathGeometryFromOsdu( osduConnector, oWPath->wellboreTrajectoryId(), oWPath->datumElevationFromOsdu() ); - if ( wellPathGeometry.notNull() ) + else if ( RimOsduWellLog* osduWellLog = dynamic_cast( wellLog ) ) { - oWPath->setWellPathGeometry( wellPathGeometry.p() ); - } - else - { - RiaLogging::warning( errorMessage ); - } - } - - if ( wellPath ) - { - for ( RimWellLog* wellLog : wellPath->wellLogs() ) - { - if ( RimWellLogFile* wellLogFile = dynamic_cast( wellLog ) ) - { - QString errorMessage; - if ( !wellLogFile->readFile( &errorMessage ) ) - { - RiaLogging::warning( errorMessage ); - } - } - else if ( RimOsduWellLog* osduWellLog = dynamic_cast( wellLog ) ) + RiaOsduConnector* osduConnector = app->makeOsduConnector(); + auto [wellLogData, errorMessage] = loadWellLogFromOsdu( osduConnector, osduWellLog->wellLogId() ); + if ( wellLogData.notNull() ) { - RiaOsduConnector* osduConnector = app->makeOsduConnector(); - auto [wellLogData, errorMessage] = loadWellLogFromOsdu( osduConnector, osduWellLog->wellLogId() ); - if ( wellLogData.notNull() ) - { - osduWellLog->setWellLogData( wellLogData.p() ); - } + osduWellLog->setWellLogData( wellLogData.p() ); } } + } - RimStimPlanModelCollection* stimPlanModelCollection = wellPath->stimPlanModelCollection(); - if ( stimPlanModelCollection ) + RimStimPlanModelCollection* stimPlanModelCollection = wellPath->stimPlanModelCollection(); + if ( stimPlanModelCollection ) + { + for ( RimStimPlanModel* stimPlanModel : stimPlanModelCollection->allStimPlanModels() ) { - for ( RimStimPlanModel* stimPlanModel : stimPlanModelCollection->allStimPlanModels() ) - { - stimPlanModel->loadDataAndUpdate(); - } + stimPlanModel->loadDataAndUpdate(); } } progress.incrementProgress(); diff --git a/CMakeLists.txt b/CMakeLists.txt index 4600813045..f970c62e39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -805,6 +805,7 @@ add_subdirectory(Fwk/AppFwk/cafProjectDataModel/cafPdmCore) add_subdirectory(Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore) add_subdirectory(Fwk/AppFwk/cafProjectDataModel/cafPdmXml) add_subdirectory(Fwk/AppFwk/cafProjectDataModel) +add_subdirectory(Fwk/AppFwk/cafDataLoader) add_subdirectory(Fwk/AppFwk/cafCommand) add_subdirectory(Fwk/AppFwk/cafUserInterface) @@ -864,6 +865,7 @@ list( cafCommand cafPdmCvf cafTensor + cafDataLoader CommonCode cafVizExtensions cafPdmScripting diff --git a/Fwk/AppFwk/CMakeLists.txt b/Fwk/AppFwk/CMakeLists.txt index b7f3c7f0e0..1cedc7fb32 100644 --- a/Fwk/AppFwk/CMakeLists.txt +++ b/Fwk/AppFwk/CMakeLists.txt @@ -45,6 +45,7 @@ add_subdirectory(cafCommand) add_subdirectory(cafCommandFeatures) add_subdirectory(cafUserInterface) add_subdirectory(cafPdmScripting) +add_subdirectory(cafDataLoader) # executables add_subdirectory(cafTests/cafTestApplication) diff --git a/Fwk/AppFwk/cafDataLoader/CMakeLists.txt b/Fwk/AppFwk/cafDataLoader/CMakeLists.txt new file mode 100644 index 0000000000..a805077cbd --- /dev/null +++ b/Fwk/AppFwk/cafDataLoader/CMakeLists.txt @@ -0,0 +1,48 @@ +project(cafDataLoader) + +# Unity Build +if(CAF_ENABLE_UNITY_BUILD) + message("Cmake Unity build is enabled on : ${PROJECT_NAME}") + set(CMAKE_UNITY_BUILD true) +endif() + +# Qt +if(CEE_USE_QT6) + find_package( + Qt6 + COMPONENTS + REQUIRED Core Gui Widgets + ) + set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets) + qt_standard_project_setup() +else() + find_package( + Qt5 + COMPONENTS + REQUIRED Core Gui Widgets + ) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets) +endif() + +set(PROJECT_FILES + cafDataLoader.h + cafDataLoader.cpp + cafDataLoadTask.h + cafDataLoadTask.cpp + cafDataLoadController.h + cafDataLoadController.cpp +) + +add_library(${PROJECT_NAME} ${PROJECT_FILES}) + +target_link_libraries(${PROJECT_NAME} cafProjectDataModel ${QT_LIBRARIES}) + +target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +if(MSVC) + set_target_properties( + ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W4 /wd4100 /wd4127 /wd4996" + ) +endif() + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp new file mode 100644 index 0000000000..5440eeeea3 --- /dev/null +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp @@ -0,0 +1,136 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#include "cafDataLoadController.h" + +#include "cafDataLoadTask.h" +#include "cafDataLoader.h" +#include "cafPdmObject.h" + +#include +#include +#include + +using namespace caf; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +DataLoadController::DataLoadController() + : m_taskId( 0 ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +DataLoadController* DataLoadController::instance() +{ + static DataLoadController* singleton = new DataLoadController; + return singleton; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void DataLoadController::registerDataLoader( const QString& objectType, + const QString& dataType, + std::shared_ptr dataLoader ) +{ + std::pair key = { objectType, dataType }; + m_dataLoaders[key] = dataLoader; + + dataLoader->taskDone.connect( this, &DataLoadController::onTaskFinished ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void DataLoadController::loadData( caf::PdmObject& object, const QString& dataType, ProgressInfo& progressInfo ) +{ + std::pair key = { object.classKeyword(), dataType }; + auto it = m_dataLoaders.find( key ); + if ( it != m_dataLoaders.end() ) + { + std::shared_ptr dataLoader = it->second; + + QMutexLocker locker( &m_mutex ); + m_pendingTasksByType[dataType]++; + locker.unlock(); + + if ( dataLoader->isRunnable() ) + { + DataLoadTask* task = new DataLoadTask( *this, *dataLoader.get(), object, dataType, m_taskId++, progressInfo ); + task->setAutoDelete( true ); + QThreadPool::globalInstance()->start( task ); + } + else + { + dataLoader->loadData( object, dataType, m_taskId++, progressInfo ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void DataLoadController::blockUntilDone( const QString& dataType ) +{ + int numPending = 0; + { + QMutexLocker locker( &m_mutex ); + numPending = m_pendingTasksByType[dataType]; + } + while ( numPending > 0 ) + { + { + QMutexLocker locker( &m_mutex ); + numPending = m_pendingTasksByType[dataType]; + } + + QApplication::processEvents(); + QThread::msleep( 100 ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void DataLoadController::onTaskFinished( const caf::SignalEmitter* emitter, QString dataType, int taskId ) +{ + QMutexLocker locker( &m_mutex ); + m_pendingTasksByType[dataType]--; +} diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.h b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.h new file mode 100644 index 0000000000..ea40f7b44e --- /dev/null +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.h @@ -0,0 +1,86 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#pragma once + +#include "cafDataLoader.h" + +#include +#include + +#include +#include +#include +#include +#include + +namespace caf +{ + +class ProgressInfo; +class PdmObject; + +//================================================================================================== +/// +//================================================================================================== +class DataLoadController : public caf::SignalObserver +{ +public: + static DataLoadController* instance(); + + DataLoadController( const DataLoadController& ) = delete; + DataLoadController& operator=( const DataLoadController& ) = delete; + + void registerDataLoader( const QString& objectType, const QString& dataType, std::shared_ptr dataLoader ); + + void loadData( caf::PdmObject& object, const QString& dateType, ProgressInfo& progressInfo ); + + void blockUntilDone( const QString& dataType ); + + void onTaskFinished( const caf::SignalEmitter* emitter, QString dataType, int taskId ); + +private: + DataLoadController(); + + std::map, std::shared_ptr> m_dataLoaders; + std::map m_pendingTasksByType; + int m_taskId; + + QMutex m_mutex; + QWaitCondition m_waitCondition; +}; + +} // end namespace caf diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoadTask.cpp b/Fwk/AppFwk/cafDataLoader/cafDataLoadTask.cpp new file mode 100644 index 0000000000..8162b45ad9 --- /dev/null +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoadTask.cpp @@ -0,0 +1,67 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#include "cafDataLoadTask.h" + +#include "cafDataLoader.h" +#include "cafPdmObject.h" + +using namespace caf; + +DataLoadTask::DataLoadTask( DataLoadController& controller, + DataLoader& loader, + caf::PdmObject& object, + const QString& dataType, + int taskId, + ProgressInfo& progressInfo ) + : QRunnable() + , m_dataLoadController( controller ) + , m_loader( loader ) + , m_object( object ) + , m_dataType( dataType ) + , m_taskId( taskId ) + , m_progressInfo( progressInfo ) +{ +} + +DataLoadTask::~DataLoadTask() +{ +} + +void DataLoadTask::run() +{ + m_loader.loadData( m_object, m_dataType, m_taskId, m_progressInfo ); +} diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoadTask.h b/Fwk/AppFwk/cafDataLoader/cafDataLoadTask.h new file mode 100644 index 0000000000..0e13816dbd --- /dev/null +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoadTask.h @@ -0,0 +1,75 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#pragma once + +#include "cafDataLoadController.h" +#include "cafDataLoader.h" + +#include +#include + +namespace caf +{ + +class ProgressInfo; +class PdmObject; +class DataLoadController; + +class DataLoadTask : public QRunnable +{ +public: + DataLoadTask( DataLoadController& controller, + DataLoader& loader, + caf::PdmObject& object, + const QString& dataType, + int taskId, + ProgressInfo& progressInfo ); + + ~DataLoadTask() override; + + void run() override; + +private: + DataLoadController& m_dataLoadController; + DataLoader& m_loader; + caf::PdmObject& m_object; + QString m_dataType; + int m_taskId; + ProgressInfo& m_progressInfo; +}; + +} // end namespace caf diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoader.cpp b/Fwk/AppFwk/cafDataLoader/cafDataLoader.cpp new file mode 100644 index 0000000000..0f05a0d850 --- /dev/null +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoader.cpp @@ -0,0 +1,47 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#include "cafDataLoader.h" + +using namespace caf; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +DataLoader::DataLoader() + : taskDone( this ) +{ +} diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoader.h b/Fwk/AppFwk/cafDataLoader/cafDataLoader.h new file mode 100644 index 0000000000..737d426f01 --- /dev/null +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoader.h @@ -0,0 +1,65 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#pragma once + +#include + +#include + +#include "cafSignal.h" + +namespace caf +{ +class ProgressInfo; +class PdmObject; + +//================================================================================================== +/// +//================================================================================================== +class DataLoader : public SignalEmitter +{ +public: + DataLoader(); + + virtual void loadData( PdmObject& pdmObject, const QString& dataType, int taskId, ProgressInfo& progressInfo ) = 0; + + virtual bool isRunnable() const = 0; + + caf::Signal taskDone; +}; + +} // end namespace caf diff --git a/Fwk/CMakeLists.txt b/Fwk/CMakeLists.txt index 14cf32a91e..bb17d9c9ea 100644 --- a/Fwk/CMakeLists.txt +++ b/Fwk/CMakeLists.txt @@ -58,6 +58,7 @@ add_subdirectory(AppFwk/cafCommand) add_subdirectory(AppFwk/cafCommandFeatures) add_subdirectory(AppFwk/cafUserInterface) add_subdirectory(AppFwk/cafPdmScripting) +add_subdirectory(AppFwk/cafDataLoader) # Unit Tests add_subdirectory(AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests) From 2651ca91b6e455f36dd8b955a6c54ca5e7b3eea0 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 5 Jul 2024 15:57:26 +0200 Subject: [PATCH 220/332] Add well log loaders. --- .../Application/RiaApplication.cpp | 8 ++ .../WellLog/CMakeLists_files.cmake | 6 + .../WellLog/RimOsduWellLogDataLoader.cpp | 111 ++++++++++++++++++ .../WellLog/RimOsduWellLogDataLoader.h | 50 ++++++++ .../WellLog/RimWellLogFileDataLoader.cpp | 62 ++++++++++ .../WellLog/RimWellLogFileDataLoader.h | 40 +++++++ .../WellPath/CMakeLists_files.cmake | 5 +- .../WellPath/RimOsduWellPathDataLoader.cpp | 31 ++--- .../WellPath/RimOsduWellPathDataLoader.h | 1 - .../WellPath/RimWellPathCollection.cpp | 36 ++---- Fwk/AppFwk/cafDataLoader/CMakeLists.txt | 8 +- 11 files changed, 311 insertions(+), 47 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.h create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.h diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index c615eac49c..7656062f30 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -71,6 +71,8 @@ #include "RimObservedFmuRftData.h" #include "RimObservedSummaryData.h" #include "RimOilField.h" +#include "RimOsduWellLog.h" +#include "RimOsduWellLogDataLoader.h" #include "RimOsduWellPath.h" #include "RimOsduWellPathDataLoader.h" #include "RimPlotWindow.h" @@ -91,6 +93,8 @@ #include "RimSurfaceCollection.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" +#include "RimWellLogFile.h" +#include "RimWellLogFileDataLoader.h" #include "RimWellLogLasFile.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" @@ -1758,4 +1762,8 @@ void RiaApplication::initializeDataLoadController() dataLoadController->registerDataLoader( RimModeledWellPath::classKeywordStatic(), wellPathGeometryKeyword, std::make_shared() ); + + const QString wellLogKeyword = "WELL_LOG"; + dataLoadController->registerDataLoader( RimWellLogFile::classKeywordStatic(), wellLogKeyword, std::make_shared() ); + dataLoadController->registerDataLoader( RimOsduWellLog::classKeywordStatic(), wellLogKeyword, std::make_shared() ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake index 26f3ed0801..6022f3d169 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake @@ -31,6 +31,8 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimRftTopologyCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveInfoTextProvider.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCalculatedCurve.h + ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileDataLoader.h + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -68,12 +70,16 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimRftTopologyCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveInfoTextProvider.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCalculatedCurve.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileDataLoader.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) +list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.h) + source_group( "ProjectDataModel\\WellLog" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp new file mode 100644 index 0000000000..707d830e3d --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp @@ -0,0 +1,111 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimOsduWellLogDataLoader.h" + +#include "Cloud/RiaOsduConnector.h" +#include "RiaApplication.h" +#include "RiaLogging.h" + +#include "RimOsduWellLog.h" + +#include "RifOsduWellLogReader.h" + +#include "RigWellLogData.h" + +#include "cafProgressInfo.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimOsduWellLogDataLoader::RimOsduWellLogDataLoader() + : caf::DataLoader() +{ + RiaApplication* app = RiaApplication::instance(); + RiaOsduConnector* osduConnector = app->makeOsduConnector(); + + connect( osduConnector, + SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ), + this, + SLOT( parquetDownloadComplete( const QByteArray&, const QString&, const QString& ) ), + Qt::QueuedConnection ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogDataLoader::loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) +{ + RiaApplication* app = RiaApplication::instance(); + RiaOsduConnector* osduConnector = app->makeOsduConnector(); + + // TODO: this is weird? + m_dataType = dataType; + + if ( RimOsduWellLog* osduWellLog = dynamic_cast( &pdmObject ) ) + { + QString wellLogId = osduWellLog->wellLogId(); + osduConnector->requestWellLogParquetDataById( wellLogId ); + m_wellLogs[wellLogId] = osduWellLog; + m_taskIds[wellLogId] = taskId; + } + QApplication::processEvents(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimOsduWellLogDataLoader::isRunnable() const +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogDataLoader::parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id ) +{ + QMutexLocker lock( &m_mutex ); + + if ( m_wellLogs.find( id ) != m_wellLogs.end() ) + { + int taskId = m_taskIds[id]; + + RiaLogging::info( QString( "Parquet download complete. Id: %1 Size: %2" ).arg( id ).arg( contents.size() ) ); + + if ( !contents.isEmpty() ) + { + auto osduWellLog = m_wellLogs[id]; + auto [wellLogData, errorMessage] = RifOsduWellLogReader::readWellLogData( contents ); + + if ( wellLogData.notNull() ) + { + osduWellLog->setWellLogData( wellLogData.p() ); + } + else + { + RiaLogging::warning( errorMessage ); + } + } + + taskDone.send( m_dataType, taskId ); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.h new file mode 100644 index 0000000000..77123c05be --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.h @@ -0,0 +1,50 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "cafDataLoader.h" +#include "cafProgressInfo.h" + +#include +#include +#include + +class RimOsduWellLog; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimOsduWellLogDataLoader : public QObject, public caf::DataLoader +{ + Q_OBJECT +public: + RimOsduWellLogDataLoader(); + void loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) override; + bool isRunnable() const override; + +private slots: + void parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id ); + +private: + std::map m_wellLogs; + std::map m_taskIds; + QString m_dataType; + QMutex m_mutex; +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.cpp new file mode 100644 index 0000000000..dc9b482dd1 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.cpp @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimWellLogFileDataLoader.h" + +#include "RiaLogging.h" +#include "RimWellLogFile.h" + +#include "RigWellPath.h" + +#include "cafProgressInfo.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogFileDataLoader::RimWellLogFileDataLoader() + : caf::DataLoader() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogFileDataLoader::loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) +{ + if ( RimWellLogFile* wellLogFile = dynamic_cast( &pdmObject ) ) + { + QString errorMessage; + if ( !wellLogFile->readFile( &errorMessage ) ) + { + RiaLogging::warning( errorMessage ); + } + } + + taskDone.send( dataType, taskId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogFileDataLoader::isRunnable() const +{ + return true; +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.h new file mode 100644 index 0000000000..8186d50948 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimFileWellPath.h" + +#include "cafDataLoader.h" +#include "cafProgressInfo.h" + +#include + +#include + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLogFileDataLoader : public caf::DataLoader +{ +public: + RimWellLogFileDataLoader(); + void loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) override; + bool isRunnable() const override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake index 14418631df..f84f4f9c8b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake @@ -48,8 +48,9 @@ list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) -list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellPathDataLoader.h) - +list(APPEND QT_MOC_HEADERS + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellPathDataLoader.h +) source_group( "ProjectDataModel\\WellPath" diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp index 72f1ea04bf..b823e7b51c 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp @@ -84,26 +84,27 @@ bool RimOsduWellPathDataLoader::isRunnable() const //-------------------------------------------------------------------------------------------------- void RimOsduWellPathDataLoader::parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id ) { - RiaLogging::info( QString( "Parquet download complete. Id: %1 Size: %2" ).arg( id ).arg( contents.size() ) ); - QMutexLocker lock( &m_mutex ); - int taskId = m_taskIds[id]; - if ( !contents.isEmpty() ) + if ( m_wellPaths.find( id ) != m_wellPaths.end() ) { - m_parquetData[id] = contents; + RiaLogging::info( QString( "Parquet download complete. Id: %1 Size: %2" ).arg( id ).arg( contents.size() ) ); + int taskId = m_taskIds[id]; - auto oWPath = m_wellPaths[id]; - auto [wellPathGeometry, errorMessage] = RifOsduWellPathReader::readWellPathData( contents, oWPath->datumElevationFromOsdu() ); - if ( wellPathGeometry.notNull() ) - { - oWPath->setWellPathGeometry( wellPathGeometry.p() ); - } - else + if ( !contents.isEmpty() ) { - RiaLogging::warning( errorMessage ); + auto oWPath = m_wellPaths[id]; + auto [wellPathGeometry, errorMessage] = RifOsduWellPathReader::readWellPathData( contents, oWPath->datumElevationFromOsdu() ); + if ( wellPathGeometry.notNull() ) + { + oWPath->setWellPathGeometry( wellPathGeometry.p() ); + } + else + { + RiaLogging::warning( errorMessage ); + } } - } - taskDone.send( m_dataType, taskId ); + taskDone.send( m_dataType, taskId ); + } } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h index 7387e40986..230cb7c6cf 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h @@ -43,7 +43,6 @@ private slots: void parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id ); private: - std::map m_parquetData; std::map m_wellPaths; std::map m_taskIds; QString m_dataType; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index b66067adc4..608081d187 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -151,47 +151,37 @@ void RimWellPathCollection::fieldChangedByUi( const caf::PdmFieldHandle* changed //-------------------------------------------------------------------------------------------------- void RimWellPathCollection::loadDataAndUpdate() { - caf::ProgressInfo progress( m_wellPaths.size(), "Reading well paths from file" ); + caf::ProgressInfo progress( 3, "Reading well paths from file" ); readWellPathFormationFiles(); - RiaApplication* app = RiaApplication::instance(); - caf::DataLoadController* dataLoadController = caf::DataLoadController::instance(); const QString wellPathGeometryKeyword = "WELL_PATH_GEOMETRY"; + const QString wellLogKeyword = "WELL_LOG"; + progress.setProgressDescription( QString( "Reading well path geometry." ) ); for ( RimWellPath* wellPath : allWellPaths() ) { - progress.setProgressDescription( QString( "Reading well %1" ).arg( wellPath->name() ) ); dataLoadController->loadData( *wellPath, wellPathGeometryKeyword, progress ); } - dataLoadController->blockUntilDone( wellPathGeometryKeyword ); + progress.incrementProgress(); + progress.setProgressDescription( QString( "Reading well logs." ) ); for ( RimWellPath* wellPath : allWellPaths() ) { for ( RimWellLog* wellLog : wellPath->wellLogs() ) { - if ( RimWellLogFile* wellLogFile = dynamic_cast( wellLog ) ) - { - QString errorMessage; - if ( !wellLogFile->readFile( &errorMessage ) ) - { - RiaLogging::warning( errorMessage ); - } - } - else if ( RimOsduWellLog* osduWellLog = dynamic_cast( wellLog ) ) - { - RiaOsduConnector* osduConnector = app->makeOsduConnector(); - auto [wellLogData, errorMessage] = loadWellLogFromOsdu( osduConnector, osduWellLog->wellLogId() ); - if ( wellLogData.notNull() ) - { - osduWellLog->setWellLogData( wellLogData.p() ); - } - } + dataLoadController->loadData( *wellLog, wellLogKeyword, progress ); } + } + dataLoadController->blockUntilDone( wellLogKeyword ); + progress.incrementProgress(); + progress.setProgressDescription( QString( "Reading additional data." ) ); + for ( RimWellPath* wellPath : allWellPaths() ) + { RimStimPlanModelCollection* stimPlanModelCollection = wellPath->stimPlanModelCollection(); if ( stimPlanModelCollection ) { @@ -200,8 +190,8 @@ void RimWellPathCollection::loadDataAndUpdate() stimPlanModel->loadDataAndUpdate(); } } - progress.incrementProgress(); } + progress.incrementProgress(); rebuildWellPathNodes(); diff --git a/Fwk/AppFwk/cafDataLoader/CMakeLists.txt b/Fwk/AppFwk/cafDataLoader/CMakeLists.txt index a805077cbd..a4296954fe 100644 --- a/Fwk/AppFwk/cafDataLoader/CMakeLists.txt +++ b/Fwk/AppFwk/cafDataLoader/CMakeLists.txt @@ -25,12 +25,8 @@ else() endif() set(PROJECT_FILES - cafDataLoader.h - cafDataLoader.cpp - cafDataLoadTask.h - cafDataLoadTask.cpp - cafDataLoadController.h - cafDataLoadController.cpp + cafDataLoader.h cafDataLoader.cpp cafDataLoadTask.h cafDataLoadTask.cpp + cafDataLoadController.h cafDataLoadController.cpp ) add_library(${PROJECT_NAME} ${PROJECT_FILES}) From 76a1d43b0ed9751a850224a15091fc34520e01f7 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Sat, 13 Jul 2024 12:48:06 +0200 Subject: [PATCH 221/332] Osdu: make sure token is valid before background loading. --- .../Tools/Cloud/RiaCloudConnector.h | 4 ++-- .../WellPath/RimWellPathCollection.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h index 24acd33319..f3b9982639 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h @@ -48,6 +48,8 @@ class RiaCloudConnector : public QObject QString server() const; + QString requestTokenBlocking(); + public slots: void requestToken(); void requestFailed( const QAbstractOAuth::Error error ); @@ -61,8 +63,6 @@ private slots: void accessGranted(); protected: - QString requestTokenBlocking(); - static QString constructAuthUrl( const QString& authority ); static QString constructTokenUrl( const QString& authority ); diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 608081d187..3b25cfc7e6 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -155,6 +155,25 @@ void RimWellPathCollection::loadDataAndUpdate() readWellPathFormationFiles(); + auto hasOsduData = []( const std::vector& wellPaths ) -> bool + { + for ( RimWellPath* wellPath : wellPaths ) + { + if ( dynamic_cast( wellPath ) ) + { + return true; + } + } + + return false; + }; + + if ( hasOsduData( allWellPaths() ) ) + { + auto osduConnector = RiaApplication::instance()->makeOsduConnector(); + osduConnector->requestTokenBlocking(); + } + caf::DataLoadController* dataLoadController = caf::DataLoadController::instance(); const QString wellPathGeometryKeyword = "WELL_PATH_GEOMETRY"; From 6e3e0ad538c74d3e61778cb967974d83a7406d74 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 14 Aug 2024 11:02:39 +0200 Subject: [PATCH 222/332] Use unique_ptr for data loaders. --- .../Application/RiaApplication.cpp | 10 +++++----- .../cafDataLoader/cafDataLoadController.cpp | 16 +++++++--------- Fwk/AppFwk/cafDataLoader/cafDataLoadController.h | 4 ++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 7656062f30..688997098a 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -1755,15 +1755,15 @@ void RiaApplication::initializeDataLoadController() const QString wellPathGeometryKeyword = "WELL_PATH_GEOMETRY"; dataLoadController->registerDataLoader( RimFileWellPath::classKeywordStatic(), wellPathGeometryKeyword, - std::make_shared() ); + std::make_unique() ); dataLoadController->registerDataLoader( RimOsduWellPath::classKeywordStatic(), wellPathGeometryKeyword, - std::make_shared() ); + std::make_unique() ); dataLoadController->registerDataLoader( RimModeledWellPath::classKeywordStatic(), wellPathGeometryKeyword, - std::make_shared() ); + std::make_unique() ); const QString wellLogKeyword = "WELL_LOG"; - dataLoadController->registerDataLoader( RimWellLogFile::classKeywordStatic(), wellLogKeyword, std::make_shared() ); - dataLoadController->registerDataLoader( RimOsduWellLog::classKeywordStatic(), wellLogKeyword, std::make_shared() ); + dataLoadController->registerDataLoader( RimWellLogFile::classKeywordStatic(), wellLogKeyword, std::make_unique() ); + dataLoadController->registerDataLoader( RimOsduWellLog::classKeywordStatic(), wellLogKeyword, std::make_unique() ); } diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp index 5440eeeea3..04313323ae 100644 --- a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp @@ -68,12 +68,12 @@ DataLoadController* DataLoadController::instance() //-------------------------------------------------------------------------------------------------- void DataLoadController::registerDataLoader( const QString& objectType, const QString& dataType, - std::shared_ptr dataLoader ) + std::unique_ptr dataLoader ) { - std::pair key = { objectType, dataType }; - m_dataLoaders[key] = dataLoader; - dataLoader->taskDone.connect( this, &DataLoadController::onTaskFinished ); + + std::pair key = { objectType, dataType }; + m_dataLoaders[key] = std::move( dataLoader ); } //-------------------------------------------------------------------------------------------------- @@ -85,21 +85,19 @@ void DataLoadController::loadData( caf::PdmObject& object, const QString& dataTy auto it = m_dataLoaders.find( key ); if ( it != m_dataLoaders.end() ) { - std::shared_ptr dataLoader = it->second; - QMutexLocker locker( &m_mutex ); m_pendingTasksByType[dataType]++; locker.unlock(); - if ( dataLoader->isRunnable() ) + if ( it->second->isRunnable() ) { - DataLoadTask* task = new DataLoadTask( *this, *dataLoader.get(), object, dataType, m_taskId++, progressInfo ); + DataLoadTask* task = new DataLoadTask( *this, *it->second.get(), object, dataType, m_taskId++, progressInfo ); task->setAutoDelete( true ); QThreadPool::globalInstance()->start( task ); } else { - dataLoader->loadData( object, dataType, m_taskId++, progressInfo ); + it->second->loadData( object, dataType, m_taskId++, progressInfo ); } } } diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.h b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.h index ea40f7b44e..2ac62c7662 100644 --- a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.h +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.h @@ -64,7 +64,7 @@ class DataLoadController : public caf::SignalObserver DataLoadController( const DataLoadController& ) = delete; DataLoadController& operator=( const DataLoadController& ) = delete; - void registerDataLoader( const QString& objectType, const QString& dataType, std::shared_ptr dataLoader ); + void registerDataLoader( const QString& objectType, const QString& dataType, std::unique_ptr dataLoader ); void loadData( caf::PdmObject& object, const QString& dateType, ProgressInfo& progressInfo ); @@ -75,7 +75,7 @@ class DataLoadController : public caf::SignalObserver private: DataLoadController(); - std::map, std::shared_ptr> m_dataLoaders; + std::map, std::unique_ptr> m_dataLoaders; std::map m_pendingTasksByType; int m_taskId; From 3fbe38343deec9c46db1e4fba8d0f627741e0e9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:03:12 +0000 Subject: [PATCH 223/332] Bump celinekurpershoek/link-checker from 1.0.1 to 1.0.2 Bumps [celinekurpershoek/link-checker](https://github.com/celinekurpershoek/link-checker) from 1.0.1 to 1.0.2. - [Release notes](https://github.com/celinekurpershoek/link-checker/releases) - [Commits](https://github.com/celinekurpershoek/link-checker/compare/v1.0.1...v1.0.2) --- updated-dependencies: - dependency-name: celinekurpershoek/link-checker dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/check-broken-links.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-broken-links.yml b/.github/workflows/check-broken-links.yml index a31dc35100..49a8e8b8db 100644 --- a/.github/workflows/check-broken-links.yml +++ b/.github/workflows/check-broken-links.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Check for broken links id: link-report - uses: celinekurpershoek/link-checker@v1.0.1 + uses: celinekurpershoek/link-checker@v1.0.2 with: # Required: url: 'https://resinsight.org/' From 3fdb30d1e9da4b4c02e35776bf5d7932943b8c1f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Aug 2024 12:51:16 +0200 Subject: [PATCH 224/332] Improve workflow for clang-tidy Use github action cache for vcpkg --- .github/workflows/clang-tidy.yml | 40 +++++++++++++------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 55ec260867..3e159633e9 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -12,23 +12,13 @@ on: # Once every night - cron: "0 1 * * *" +env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + jobs: - ResInsight-x64-buildcache: - runs-on: ${{ matrix.config.os }} + ResInsight-clang-tidy: + runs-on: ubuntu-22.04 continue-on-error: true - strategy: - fail-fast: false - matrix: - config: - - { - name: "Ubuntu 22.04", - os: ubuntu-22.04, - cc: "gcc", - cxx: "g++", - vcpkg-response-file: vcpkg_x64-linux.txt, - vcpkg-triplet: x64-linux, - cmake-toolchain: "ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake", - } steps: - name: Checkout uses: actions/checkout@v4 @@ -36,7 +26,6 @@ jobs: submodules: true - name: Install Linux dependencies - if: ${{contains( matrix.config.os, 'ubuntu') }} run: | sudo apt-get update --option="APT::Acquire::Retries=3" sudo apt-get install --option="APT::Acquire::Retries=3" libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev libhdf5-dev @@ -49,20 +38,23 @@ jobs: dir: "${{ github.workspace }}/Qt/" cache: true modules: "qtnetworkauth" - - - name: Run vcpkg - uses: lukka/run-vcpkg@v7 - id: runvcpkg + + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 with: - vcpkgArguments: "@${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}" - vcpkgDirectory: - "${{ github.workspace }}/ThirdParty/vcpkg" + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + - name: vcpkg bootstrap + run: ThirdParty/vcpkg/bootstrap-vcpkg.sh + - name: Create compile commands and run clang-tidy # https://clang.llvm.org/extra/doxygen/run-clang-tidy_8py_source.html run: | mkdir build cd build - cmake -DCMAKE_TOOLCHAIN_FILE=${{ matrix.config.cmake-toolchain }} -DRESINSIGHT_USE_OPENMP=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. + cmake -DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux-release -DRESINSIGHT_USE_OPENMP=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. mv compile_commands.json compile_commands_original.json python ../scripts/fix_json_database.py compile_commands_original.json >> compile_commands.json - name: Run clang-tidy and apply fixes, clang-format after fixes From f0e19b0fb56afc261447d473aca8ecc65de6a13a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Aug 2024 13:31:12 +0200 Subject: [PATCH 225/332] Use vcpkg for fast-float and spdlog --- .gitmodules | 6 ------ ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp | 2 +- .../FileInterface/RifEclipseTextFileReader.cpp | 2 +- CMakeLists.txt | 7 ++++--- ThirdParty/fast_float | 1 - ThirdParty/spdlog | 1 - vcpkg.json | 4 +++- 7 files changed, 9 insertions(+), 14 deletions(-) delete mode 160000 ThirdParty/fast_float delete mode 160000 ThirdParty/spdlog diff --git a/.gitmodules b/.gitmodules index 03c750c207..90447290d1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,6 @@ [submodule "ThirdParty/vcpkg"] path = ThirdParty/vcpkg url = https://github.com/microsoft/vcpkg -[submodule "ThirdParty/fast_float"] - path = ThirdParty/fast_float - url = https://github.com/fastfloat/fast_float [submodule "ThirdParty/custom-opm-common/opm-common"] path = ThirdParty/custom-opm-common/opm-common url = https://github.com/CeetronSolutions/opm-common @@ -25,6 +22,3 @@ [submodule "ThirdParty/qtadvanceddocking"] path = ThirdParty/qtadvanceddocking url = https://github.com/CeetronSolutions/qtadvanceddocking.git -[submodule "ThirdParty/spdlog"] - path = ThirdParty/spdlog - url = https://github.com/gabime/spdlog.git diff --git a/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp b/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp index 35277b0230..0ae2ac76b5 100644 --- a/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp @@ -19,7 +19,7 @@ #include "RiaStdStringTools.h" #include "RiaLogging.h" -#include "fast_float/include/fast_float/fast_float.h" +#include "fast_float/fast_float.h" #include diff --git a/ApplicationLibCode/FileInterface/RifEclipseTextFileReader.cpp b/ApplicationLibCode/FileInterface/RifEclipseTextFileReader.cpp index 1c5f4d9ad9..fb31d6cb15 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseTextFileReader.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseTextFileReader.cpp @@ -20,7 +20,7 @@ #include "RifEclipseKeywordContent.h" // Utility class for fast conversion from string to float -#include "fast_float/include/fast_float/fast_float.h" +#include "fast_float/fast_float.h" // Utility class memory mapping of files #include "mio/mio.hpp" diff --git a/CMakeLists.txt b/CMakeLists.txt index f970c62e39..13f8c4bd00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -633,11 +633,12 @@ set_property( add_subdirectory(ThirdParty/tomlplusplus) # ############################################################################## -# spdlog +# spdlog and fast_float # ############################################################################## -add_subdirectory(ThirdParty/spdlog) -list(APPEND THIRD_PARTY_LIBRARIES spdlog) +find_package(FastFloat CONFIG REQUIRED) +find_package(spdlog CONFIG REQUIRED) +list(APPEND THIRD_PARTY_LIBRARIES FastFloat::fast_float spdlog::spdlog) # ############################################################################## # Arrow diff --git a/ThirdParty/fast_float b/ThirdParty/fast_float deleted file mode 160000 index 052975dd5f..0000000000 --- a/ThirdParty/fast_float +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 052975dd5f8166d0f9e4a215fa75a349d5985b91 diff --git a/ThirdParty/spdlog b/ThirdParty/spdlog deleted file mode 160000 index 8979f7fb2a..0000000000 --- a/ThirdParty/spdlog +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8979f7fb2a119754e5fe7fe6d8155f67d934316a diff --git a/vcpkg.json b/vcpkg.json index 13c9ad3d43..c4f349ea5f 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -5,6 +5,8 @@ "boost-spirit", "eigen3", "grpc", - "type-lite" + "type-lite", + "fast-float", + "spdlog" ] } From b717615bfde26ee6ef6a77c03c2f7aa4cf035d75 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Aug 2024 15:05:01 +0200 Subject: [PATCH 226/332] Use create-pull-request for update of submodules --- .github/workflows/update-submodules.yml | 81 ++++++++----------------- 1 file changed, 25 insertions(+), 56 deletions(-) diff --git a/.github/workflows/update-submodules.yml b/.github/workflows/update-submodules.yml index c03e1878ba..e8157b1f9a 100644 --- a/.github/workflows/update-submodules.yml +++ b/.github/workflows/update-submodules.yml @@ -8,6 +8,11 @@ on: jobs: update-submodules: runs-on: ubuntu-latest + strategy: + matrix: + submodule: + - tomlplusplus + - vcpkg steps: - name: Checkout repository @@ -15,61 +20,25 @@ jobs: with: submodules: recursive - - name: Install GitHub CLI - run: sudo apt-get install -y gh - - - name: Configure Git - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - - name: Update submodules to latest release + id: git-change-job run: | - cd ThirdParty - - git fetch --all - - submodules=("fast_float" "spdlog" "tomlplusplus" ) - for submodule in "${submodules[@]}"; do - BRANCH_NAME=ci-update-$submodule - if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then - echo "Branch $BRANCH_NAME exists." - git checkout -b "$BRANCH_NAME" "origin/$BRANCH_NAME" - else - echo "Branch $BRANCH_NAME does not exist. Creating branch." - git checkout -b "$BRANCH_NAME" - fi - - cd $submodule - git fetch --tags - latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) - - if [ -n "$latest_tag" ]; then - git checkout $latest_tag - else - echo "Empty tag detected in $submodule. Nothing to do." - fi - - cd .. - if git diff --quiet; then - echo "No changes detected in $submodule" - else - git add $submodule - git commit -m "Update $submodule to $latest_tag" || echo "No changes to commit" - git push origin "$BRANCH_NAME" - fi - - git checkout dev - git reset --hard origin/dev --recurse-submodule - done - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create Pull Requests for each submodule - run: | - submodules=("fast_float" "spdlog" "tomlplusplus" ) - for submodule in "${submodules[@]}"; do - gh pr create --title "Update $submodule to latest release" --body "This PR updates the $submodule submodule to its latest release." --head ci-update-$submodule --base dev - done - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + cd ThirdParty/${{ matrix.submodule }} + git fetch --tags + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + + if [ -n "$latest_tag" ]; then + git checkout $latest_tag + echo "LATEST_TAG=$latest_tag" >> "$GITHUB_OUTPUT" + else + echo "Empty tag detected in ${{ matrix.submodule }}. Nothing to do." + fi + + - name: Create PR + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Update ${{ matrix.submodule }} to ${{ steps.git-change-job.outputs.LATEST_TAG }}" + title: "Update ${{ matrix.submodule }} to ${{ steps.git-change-job.outputs.LATEST_TAG }}" + branch: ci-update-${{ matrix.submodule }} + branch-suffix: random From 478ac1868f6bf9a0ecae1d9caeabfdd23cc8a62c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Aug 2024 15:14:00 +0200 Subject: [PATCH 227/332] Add comment on how to activate tests on GitHub The generated PR does not have any tests. Close and reopen the PR to activate tests. --- .github/workflows/update-submodules.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update-submodules.yml b/.github/workflows/update-submodules.yml index e8157b1f9a..9ec2bbd695 100644 --- a/.github/workflows/update-submodules.yml +++ b/.github/workflows/update-submodules.yml @@ -35,6 +35,7 @@ jobs: fi - name: Create PR + # The generated PR does not have any tests. Close and reopen the PR to activate tests. uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} From 3a54045c28a7c2883693fb0c9c08ef2539a51275 Mon Sep 17 00:00:00 2001 From: magnesj <1793152+magnesj@users.noreply.github.com> Date: Thu, 15 Aug 2024 02:47:44 +0000 Subject: [PATCH 228/332] Fixes by clang-tidy --- .../Commands/ApplicationCommands/RicSumoDataFeature.h | 2 +- ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.h index 7dffcd58e5..3b75d55f79 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicSumoDataFeature.h @@ -34,7 +34,7 @@ class SimpleDialog : public QDialog public: SimpleDialog( QWidget* parent = nullptr ); - ~SimpleDialog(); + ~SimpleDialog() override; void createConnection(); diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp index ed5c23dc1c..27f3aaabc0 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp @@ -317,7 +317,7 @@ void RifReaderOpmCommon::transferStaticNNCData( Opm::EclIO::EGrid& opmMainGrid, connections.insert( connections.end(), conn.begin(), conn.end() ); } - if ( connections.size() > 0 ) + if ( !connections.empty() ) { // Transform to our own data structures RigConnectionContainer nncConnections; @@ -805,7 +805,7 @@ void RifReaderOpmCommon::buildMetaData( RigEclipseCaseData* eclipseCaseData, caf eclipseCaseData, m_restartFile->numberOfReportSteps() ); - if ( filteredTimeStepInfos.size() > 0 ) firstTimeStepInfo = filteredTimeStepInfos.front(); + if ( !filteredTimeStepInfos.empty() ) firstTimeStepInfo = filteredTimeStepInfos.front(); } if ( m_initFile != nullptr ) From e7b3f3cd173f21176ee7e37c8e737696b5fb6bf9 Mon Sep 17 00:00:00 2001 From: magnesj <1793152+magnesj@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:09:49 +0000 Subject: [PATCH 229/332] Update tomlplusplus to v3.4.0 --- ThirdParty/tomlplusplus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdParty/tomlplusplus b/ThirdParty/tomlplusplus index d8fa9a1fdd..30172438ce 160000 --- a/ThirdParty/tomlplusplus +++ b/ThirdParty/tomlplusplus @@ -1 +1 @@ -Subproject commit d8fa9a1fddc90254cac2366dde23f0b613bc1280 +Subproject commit 30172438cee64926dc41fdd9c11fb3ba5b2ba9de From bf471b6c73db63bf36dac84abbfd1bc20aa435ae Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Aug 2024 10:38:30 +0200 Subject: [PATCH 230/332] #11595 Always return the pick event handler Always return the pick event handler to make it possible to deactivate handler. Move the activation logic to pickingEnabled. --- .../CellFilters/RimPolygonFilter.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index 7145f05834..22cfe2556c 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -834,6 +834,8 @@ void RimPolygonFilter::configurePolygonEditor() m_polygonEditor->setPolygon( polygon ); + if ( polygon && polygon->isReadOnly() ) m_polygonEditor->enablePicking( false ); + // Must connect the signals after polygon is assigned to the polygon editor // When assigning an object to a ptr field, all signals are disconnected connectObjectSignals( polygon ); @@ -891,6 +893,12 @@ std::vector RimPolygonFilter::activeTargets() const //-------------------------------------------------------------------------------------------------- bool RimPolygonFilter::pickingEnabled() const { + auto filterColl = firstAncestorOfType(); + if ( filterColl && !filterColl->isActive() ) return false; + + if ( !isActive() ) return false; + if ( !isPolygonDefinedLocally() && m_cellFilterPolygon && m_cellFilterPolygon()->isReadOnly() ) return false; + return m_polygonEditor->pickingEnabled(); } @@ -899,12 +907,6 @@ bool RimPolygonFilter::pickingEnabled() const //-------------------------------------------------------------------------------------------------- caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const { - auto filterColl = firstAncestorOfType(); - if ( filterColl && !filterColl->isActive() ) return nullptr; - - if ( !isActive() ) return nullptr; - if ( !isPolygonDefinedLocally() && m_cellFilterPolygon && m_cellFilterPolygon()->isReadOnly() ) return nullptr; - return m_pickTargetsEventHandler.get(); } From f5619733196c4dc960b612557245f6a5fbae7cdb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Aug 2024 12:15:12 +0200 Subject: [PATCH 231/332] #11618 Add menu to create filter from existing polygons --- .../RicNewPolygonFilterFeature.cpp | 24 ++++++++--- .../CellFilters/RimCellFilterCollection.cpp | 40 +++++++++++++++++++ .../CellFilters/RimCellFilterCollection.h | 2 + .../ProjectDataModel/Polygons/RimPolygon.cpp | 3 +- .../RimContextCommandBuilder.cpp | 25 ------------ 5 files changed, 62 insertions(+), 32 deletions(-) diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp index 80a329c593..607f4999ad 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp @@ -42,6 +42,13 @@ CAF_CMD_SOURCE_INIT( RicNewPolygonFilterFeature, "RicNewPolygonFilterFeature" ); //-------------------------------------------------------------------------------------------------- void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked ) { + RimPolygon* polygonDataSource = nullptr; + QVariant userData = this->userData(); + if ( !userData.isNull() && userData.canConvert() ) + { + polygonDataSource = static_cast( userData.value() ); + } + auto cellFilterCollection = caf::SelectionManager::instance()->selectedItemOfType(); if ( !cellFilterCollection ) @@ -55,19 +62,24 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked ) if ( !cellFilterCollection ) return; - auto polygon = caf::SelectionManager::instance()->selectedItemOfType(); - if ( !polygon ) + if ( !polygonDataSource ) { - if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType() ) + auto selectedPolygon = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !selectedPolygon ) { - polygon = polygonInView->polygon(); + if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType() ) + { + selectedPolygon = polygonInView->polygon(); + } } + + polygonDataSource = selectedPolygon; } auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted()->ownerCase(); if ( sourceCase ) { - if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) ) + if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygonDataSource ) ) { Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); } @@ -80,5 +92,5 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked ) void RicNewPolygonFilterFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setIcon( QIcon( ":/CellFilter_Polygon.png" ) ); - actionToSetup->setText( "New Polygon Filter" ); + actionToSetup->setText( "New User Defined Polygon Filter" ); } diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp index a2074e16a4..172358f1dd 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp @@ -23,6 +23,7 @@ #include "RimCellFilter.h" #include "RimCellIndexFilter.h" #include "RimCellRangeFilter.h" +#include "RimOilField.h" #include "RimPolygonFilter.h" #include "RimProject.h" #include "RimUserDefinedFilter.h" @@ -30,6 +31,10 @@ #include "RimViewController.h" #include "RimViewLinker.h" +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" + +#include "cafCmdFeatureMenuBuilder.h" #include "cafPdmFieldReorderCapability.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" @@ -126,6 +131,41 @@ void RimCellFilterCollection::setCase( RimCase* theCase ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCellFilterCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder << "RicPasteCellFiltersFeature"; + menuBuilder << "Separator"; + + menuBuilder.subMenuStart( "New Polygon Filter", QIcon( ":/CellFilter_Polygon.png" ) ); + { + auto project = RimProject::current(); + auto polygonCollection = project->activeOilField()->polygonCollection(); + for ( auto p : polygonCollection->allPolygons() ) + { + if ( !p ) continue; + + menuBuilder.addCmdFeatureWithUserData( "RicNewPolygonFilterFeature", p->name(), QVariant::fromValue( static_cast( p ) ) ); + } + } + menuBuilder.subMenuEnd(); + + menuBuilder << "RicNewPolygonFilterFeature"; + menuBuilder << "Separator"; + menuBuilder.subMenuStart( "Slice Filters" ); + menuBuilder << "RicNewRangeFilterSliceIFeature"; + menuBuilder << "RicNewRangeFilterSliceJFeature"; + menuBuilder << "RicNewRangeFilterSliceKFeature"; + menuBuilder.subMenuEnd(); + menuBuilder << "RicNewCellRangeFilterFeature"; + menuBuilder << "RicNewCellIndexFilterFeature"; + menuBuilder << "Separator"; + menuBuilder << "RicNewUserDefinedFilterFeature"; + menuBuilder << "RicNewUserDefinedIndexFilterFeature"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h index 45e23fc90b..143c5ad0cb 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h @@ -93,6 +93,8 @@ class RimCellFilterCollection : public caf::PdmObject void setCase( RimCase* theCase ); + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; + protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp index 3865b86be9..9291037d70 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp @@ -250,8 +250,9 @@ void RimPolygon::onColorTagClicked( const SignalEmitter* emitter, size_t index ) void RimPolygon::appendPolygonMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) { menuBuilder << "RicNewPolygonIntersectionFeature"; - menuBuilder << "RicNewPolygonFilterFeature"; + menuBuilder.addCmdFeature( "RicNewPolygonFilterFeature", "New Polygon Filter" ); menuBuilder << "Separator"; + menuBuilder << "RicDuplicatePolygonFeature"; menuBuilder << "RicSimplifyPolygonFeature"; menuBuilder << "Separator"; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 3816add774..c706f9f0e3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -37,8 +37,6 @@ #include "RimCalcScript.h" #include "RimCaseCollection.h" #include "RimCellEdgeColors.h" -#include "RimCellFilterCollection.h" -#include "RimCellRangeFilter.h" #include "RimColorLegend.h" #include "RimColorLegendCollection.h" #include "RimColorLegendItem.h" @@ -51,14 +49,12 @@ #include "RimEclipseCaseCollection.h" #include "RimEclipseCaseEnsemble.h" #include "RimEclipseCellColors.h" -#include "RimEclipseContourMapView.h" #include "RimEclipseContourMapViewCollection.h" #include "RimEclipseFaultColors.h" #include "RimEclipseInputProperty.h" #include "RimEclipsePropertyFilter.h" #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseResultAddress.h" -#include "RimEclipseResultCase.h" #include "RimEclipseStatisticsCase.h" #include "RimEclipseView.h" #include "RimEclipseViewCollection.h" @@ -70,7 +66,6 @@ #include "RimEnsembleFractureStatisticsCollection.h" #include "RimExtrudedCurveIntersection.h" #include "RimFaultInView.h" -#include "RimFaultInViewCollection.h" #include "RimFaultReactivationModel.h" #include "RimFishbones.h" #include "RimFishbonesCollection.h" @@ -79,11 +74,9 @@ #include "RimFlowPlotCollection.h" #include "RimFormationNames.h" #include "RimFormationNamesCollection.h" -#include "RimFractureTemplate.h" #include "RimFractureTemplateCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" -#include "RimGeoMechContourMapView.h" #include "RimGeoMechContourMapViewCollection.h" #include "RimGeoMechModels.h" #include "RimGeoMechPropertyFilter.h" @@ -100,7 +93,6 @@ #include "RimIntersectionResultsDefinitionCollection.h" #include "RimModeledWellPath.h" #include "RimMultiPlot.h" -#include "RimMultiPlotCollection.h" #include "RimObservedSummaryData.h" #include "RimOsduWellPath.h" #include "RimParameterResultCrossPlot.h" @@ -128,7 +120,6 @@ #include "RimStimPlanFractureTemplate.h" #include "RimStimPlanModel.h" #include "RimStimPlanModelCollection.h" -#include "RimStimPlanModelPlot.h" #include "RimStimPlanModelTemplate.h" #include "RimStimPlanModelTemplateCollection.h" #include "RimStreamlineInViewCollection.h" @@ -1034,22 +1025,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicCopySurfaceFeature"; menuBuilder << "RicReloadSurfaceFeature"; } - else if ( dynamic_cast( firstUiItem ) ) - { - menuBuilder << "RicPasteCellFiltersFeature"; - menuBuilder << "Separator"; - menuBuilder << "RicNewPolygonFilterFeature"; - menuBuilder << "RicNewCellRangeFilterFeature"; - menuBuilder.subMenuStart( "Slice Filters" ); - menuBuilder << "RicNewRangeFilterSliceIFeature"; - menuBuilder << "RicNewRangeFilterSliceJFeature"; - menuBuilder << "RicNewRangeFilterSliceKFeature"; - menuBuilder.subMenuEnd(); - menuBuilder << "RicNewCellIndexFilterFeature"; - menuBuilder << "Separator"; - menuBuilder << "RicNewUserDefinedFilterFeature"; - menuBuilder << "RicNewUserDefinedIndexFilterFeature"; - } else if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicNewInlineSeismicSectionFeature"; From 8d9290825314eaed0fe335d93aa3c5d7a61e482f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Aug 2024 14:33:41 +0200 Subject: [PATCH 232/332] Bump to dev.13 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index ad8d28ec50..1be499030a 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".12") +set(RESINSIGHT_DEV_VERSION ".13") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From bf2a852b4d53a54486c74512a87b3c32772862df Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 14 Aug 2024 16:54:41 +0200 Subject: [PATCH 233/332] Add cancellation of well path collection loading. --- .../Tools/Cloud/RiaOsduConnector.cpp | 19 ++++++++ .../Tools/Cloud/RiaOsduConnector.h | 4 ++ .../WellPath/RimOsduWellPathDataLoader.cpp | 14 ++++++ .../WellPath/RimOsduWellPathDataLoader.h | 1 + .../WellPath/RimWellPathCollection.cpp | 33 +++++++++---- Fwk/AppFwk/cafDataLoader/CMakeLists.txt | 4 +- .../cafDataLoader/cafDataLoadController.cpp | 13 +++++ .../cafDataLoader/cafDataLoadController.h | 1 + Fwk/AppFwk/cafDataLoader/cafDataLoader.cpp | 7 +++ Fwk/AppFwk/cafDataLoader/cafDataLoader.h | 2 + .../cafUserInterface/cafProgressInfo.cpp | 48 ++++++++++++++++--- Fwk/AppFwk/cafUserInterface/cafProgressInfo.h | 16 ++++++- 12 files changed, 143 insertions(+), 19 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp index d2f3fd0329..5915450de0 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.cpp @@ -762,6 +762,9 @@ void RiaOsduConnector::requestParquetData( const QString& url, const QString& da RiaLogging::info( "Requesting download of parquet from: " + url ); auto reply = makeDownloadRequest( url, dataPartitionId, token, RiaCloudDefines::contentTypeParquet() ); + m_repliesMutex.lock(); + m_replies[id] = reply; + m_repliesMutex.unlock(); connect( reply, &QNetworkReply::finished, @@ -792,3 +795,19 @@ void RiaOsduConnector::parquetDownloadComplete( const QByteArray& contents, cons m_parquetData[id] = contents; m_parquetErrors[id] = errorMessage; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaOsduConnector::cancelRequestForId( const QString& id ) +{ + QMutexLocker lock( &m_repliesMutex ); + auto it = m_replies.find( id ); + if ( it != m_replies.end() ) + { + if ( !it->second.isNull() ) + { + it->second->abort(); + } + } +} diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h index bbb4e2af85..6095768093 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h @@ -113,6 +113,8 @@ class RiaOsduConnector : public RiaCloudConnector QString wellIdForWellboreId( const QString& wellboreId ) const; + void cancelRequestForId( const QString& id ); + void clearCachedData(); QString dataPartition() const; @@ -173,6 +175,7 @@ private slots: const QString m_dataPartitionId; mutable QMutex m_mutex; + mutable QMutex m_repliesMutex; std::vector m_fields; std::vector m_wells; std::map> m_wellbores; @@ -180,4 +183,5 @@ private slots: std::map> m_wellLogs; std::map m_parquetData; std::map m_parquetErrors; + std::map> m_replies; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp index b823e7b51c..ac8c957607 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp @@ -79,6 +79,20 @@ bool RimOsduWellPathDataLoader::isRunnable() const return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellPathDataLoader::cancel() +{ + RiaApplication* app = RiaApplication::instance(); + RiaOsduConnector* osduConnector = app->makeOsduConnector(); + + for ( auto& [trajectoryId, taskId] : m_taskIds ) + { + osduConnector->cancelRequestForId( trajectoryId ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h index 230cb7c6cf..58ded9b6fd 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h @@ -38,6 +38,7 @@ class RimOsduWellPathDataLoader : public QObject, public caf::DataLoader RimOsduWellPathDataLoader(); void loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) override; bool isRunnable() const override; + void cancel() override; private slots: void parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id ); diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 3b25cfc7e6..406f780326 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -151,10 +151,6 @@ void RimWellPathCollection::fieldChangedByUi( const caf::PdmFieldHandle* changed //-------------------------------------------------------------------------------------------------- void RimWellPathCollection::loadDataAndUpdate() { - caf::ProgressInfo progress( 3, "Reading well paths from file" ); - - readWellPathFormationFiles(); - auto hasOsduData = []( const std::vector& wellPaths ) -> bool { for ( RimWellPath* wellPath : wellPaths ) @@ -168,6 +164,22 @@ void RimWellPathCollection::loadDataAndUpdate() return false; }; + auto countWellLogs = []( const std::vector& wellPaths ) -> bool + { + size_t count = 0; + for ( RimWellPath* wellPath : wellPaths ) + { + count += wellPath->wellLogs().size(); + } + return count; + }; + + caf::ProgressInfo progress( allWellPaths().size() + countWellLogs( allWellPaths() ) + 2, "Reading well paths from file", false, true ); + + readWellPathFormationFiles(); + + progress.incrementProgress(); + if ( hasOsduData( allWellPaths() ) ) { auto osduConnector = RiaApplication::instance()->makeOsduConnector(); @@ -185,7 +197,11 @@ void RimWellPathCollection::loadDataAndUpdate() dataLoadController->loadData( *wellPath, wellPathGeometryKeyword, progress ); } dataLoadController->blockUntilDone( wellPathGeometryKeyword ); - progress.incrementProgress(); + + if ( progress.isCancelled() ) + { + return; + } progress.setProgressDescription( QString( "Reading well logs." ) ); for ( RimWellPath* wellPath : allWellPaths() ) @@ -196,7 +212,6 @@ void RimWellPathCollection::loadDataAndUpdate() } } dataLoadController->blockUntilDone( wellLogKeyword ); - progress.incrementProgress(); progress.setProgressDescription( QString( "Reading additional data." ) ); for ( RimWellPath* wellPath : allWellPaths() ) @@ -692,15 +707,15 @@ void RimWellPathCollection::readWellPathFormationFiles() { caf::ProgressInfo progress( m_wellPaths.size(), "Reading well picks from file" ); - for ( size_t wpIdx = 0; wpIdx < m_wellPaths.size(); wpIdx++ ) + for ( const auto& wellPath : m_wellPaths ) { QString errorMessage; - if ( !m_wellPaths[wpIdx]->readWellPathFormationsFile( &errorMessage, m_wellPathFormationsImporter.get() ) ) + if ( !wellPath->readWellPathFormationsFile( &errorMessage, m_wellPathFormationsImporter.get() ) ) { RiaLogging::errorInMessageBox( Riu3DMainWindowTools::mainWindowWidget(), "File open error", errorMessage ); } - progress.setProgressDescription( QString( "Reading formation file %1" ).arg( wpIdx ) ); + progress.setProgressDescription( QString( "Reading formation file for %1" ).arg( wellPath->name() ) ); progress.incrementProgress(); } } diff --git a/Fwk/AppFwk/cafDataLoader/CMakeLists.txt b/Fwk/AppFwk/cafDataLoader/CMakeLists.txt index a4296954fe..28a736c7e8 100644 --- a/Fwk/AppFwk/cafDataLoader/CMakeLists.txt +++ b/Fwk/AppFwk/cafDataLoader/CMakeLists.txt @@ -31,7 +31,9 @@ set(PROJECT_FILES add_library(${PROJECT_NAME} ${PROJECT_FILES}) -target_link_libraries(${PROJECT_NAME} cafProjectDataModel ${QT_LIBRARIES}) +target_link_libraries( + ${PROJECT_NAME} cafProjectDataModel cafUserInterface ${QT_LIBRARIES} +) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp index 04313323ae..1d5d3b200d 100644 --- a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp @@ -39,6 +39,7 @@ #include "cafDataLoadTask.h" #include "cafDataLoader.h" #include "cafPdmObject.h" +#include "cafProgressInfo.h" #include #include @@ -87,6 +88,7 @@ void DataLoadController::loadData( caf::PdmObject& object, const QString& dataTy { QMutexLocker locker( &m_mutex ); m_pendingTasksByType[dataType]++; + m_progressInfos[dataType] = &progressInfo; locker.unlock(); if ( it->second->isRunnable() ) @@ -117,6 +119,16 @@ void DataLoadController::blockUntilDone( const QString& dataType ) { QMutexLocker locker( &m_mutex ); numPending = m_pendingTasksByType[dataType]; + if ( m_progressInfos[dataType]->isCancelled() ) + { + for ( auto& [key, loader] : m_dataLoaders ) + { + if ( key.second == dataType ) + { + loader->cancel(); + } + } + } } QApplication::processEvents(); @@ -131,4 +143,5 @@ void DataLoadController::onTaskFinished( const caf::SignalEmitter* emitter, QStr { QMutexLocker locker( &m_mutex ); m_pendingTasksByType[dataType]--; + m_progressInfos[dataType]->incrementProgress(); } diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.h b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.h index 2ac62c7662..4fb5b79dfa 100644 --- a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.h +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.h @@ -77,6 +77,7 @@ class DataLoadController : public caf::SignalObserver std::map, std::unique_ptr> m_dataLoaders; std::map m_pendingTasksByType; + std::map m_progressInfos; int m_taskId; QMutex m_mutex; diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoader.cpp b/Fwk/AppFwk/cafDataLoader/cafDataLoader.cpp index 0f05a0d850..46a32fc08b 100644 --- a/Fwk/AppFwk/cafDataLoader/cafDataLoader.cpp +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoader.cpp @@ -45,3 +45,10 @@ DataLoader::DataLoader() : taskDone( this ) { } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void DataLoader::cancel() +{ +} diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoader.h b/Fwk/AppFwk/cafDataLoader/cafDataLoader.h index 737d426f01..9467e914ee 100644 --- a/Fwk/AppFwk/cafDataLoader/cafDataLoader.h +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoader.h @@ -59,6 +59,8 @@ class DataLoader : public SignalEmitter virtual bool isRunnable() const = 0; + virtual void cancel(); + caf::Signal taskDone; }; diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index 7980caa197..59c4706441 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -71,6 +72,7 @@ ProgressTask::ProgressTask( ProgressInfo& parentTask ) : m_parentTask( parentTask ) { } + ProgressTask::~ProgressTask() { m_parentTask.incrementProgress(); @@ -125,9 +127,11 @@ ProgressTask::~ProgressTask() /// If you do not need a title for a particular level, simply pass "" and it will be ignored. /// \sa setProgressDescription //-------------------------------------------------------------------------------------------------- -ProgressInfo::ProgressInfo( size_t maxProgressValue, const QString& title, bool delayShowingProgress ) +ProgressInfo::ProgressInfo( size_t maxProgressValue, const QString& title, bool delayShowingProgress, bool allowCancel ) { - ProgressInfoStatic::start( maxProgressValue, title, delayShowingProgress ); + m_isCancelled.store( false ); + + ProgressInfoStatic::start( *this, maxProgressValue, title, delayShowingProgress, allowCancel ); if ( dynamic_cast( QCoreApplication::instance() ) ) { @@ -195,6 +199,16 @@ void ProgressInfo::setNextProgressIncrement( size_t nextStepSize ) ProgressInfoStatic::setNextProgressIncrement( nextStepSize ); } +void ProgressInfo::cancel() +{ + m_isCancelled.store( true ); +} + +bool ProgressInfo::isCancelled() const +{ + return m_isCancelled; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -462,13 +476,18 @@ ProgressInfoBlocker::~ProgressInfoBlocker() /// //================================================================================================== -bool ProgressInfoStatic::s_disabled = false; -bool ProgressInfoStatic::s_running = false; +bool ProgressInfoStatic::s_disabled = false; +bool ProgressInfoStatic::s_running = false; +bool ProgressInfoStatic::s_isButtonConnected = false; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void ProgressInfoStatic::start( size_t maxProgressValue, const QString& title, bool delayShowingProgress ) +void ProgressInfoStatic::start( ProgressInfo& progressInfo, + size_t maxProgressValue, + const QString& title, + bool delayShowingProgress, + bool allowCancel ) { if ( !isUpdatePossible() ) return; @@ -485,7 +504,20 @@ void ProgressInfoStatic::start( size_t maxProgressValue, const QString& title, b { dialog->setMinimum( 0 ); dialog->setWindowTitle( title ); - dialog->setCancelButton( nullptr ); + if ( allowCancel ) + { + dialog->setCancelButtonText( "Cancel" ); + if ( !s_isButtonConnected ) + { + QObject::connect( dialog, &QProgressDialog::canceled, [&progressInfo]() { progressInfo.cancel(); } ); + s_isButtonConnected = true; + } + } + else + { + dialog->setCancelButton( nullptr ); + } + if ( delayShowingProgress ) { dialog->setMinimumDuration( 2000 ); @@ -548,7 +580,7 @@ void ProgressInfoStatic::setProgress( size_t progressValue ) if ( progressValue > maxProgressStack_v.back() ) { reportError( "setProgress() is called with a progressValue > max, progressValue == " + - std::to_string( progressValue ) ); + std::to_string( progressValue ) + " max == " + std::to_string( maxProgressStack_v.back() ) ); progressValue = maxProgressStack_v.back(); } @@ -662,6 +694,8 @@ void ProgressInfoStatic::finished() { if ( dialog ) { + QObject::disconnect( dialog, &QProgressDialog::canceled, nullptr, nullptr ); + dialog->reset(); dialog->close(); s_running = false; diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h index 321716f450..48a50170a0 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h @@ -38,6 +38,8 @@ #include +#include + class QString; namespace caf @@ -57,15 +59,20 @@ class ProgressTask class ProgressInfo { public: - ProgressInfo( size_t maxProgressValue, const QString& title, bool delayShowingProgress = true ); + ProgressInfo( size_t maxProgressValue, const QString& title, bool delayShowingProgress = true, bool allowCancel = false ); ~ProgressInfo(); void setProgressDescription( const QString& description ); void setProgress( size_t progressValue ); void incrementProgress(); void setNextProgressIncrement( size_t nextStepSize ); + void cancel(); + bool isCancelled() const; ProgressTask task( const QString& description, int stepSize = 1 ); + +private: + std::atomic m_isCancelled; }; class ProgressInfoBlocker @@ -78,7 +85,11 @@ class ProgressInfoBlocker class ProgressInfoStatic { public: - static void start( size_t maxProgressValue, const QString& title, bool delayShowingProgress ); + static void start( ProgressInfo& progressInfo, + size_t maxProgressValue, + const QString& title, + bool delayShowingProgress, + bool allowCance ); static void setProgressDescription( const QString& description ); static void setProgress( size_t progressValue ); @@ -95,6 +106,7 @@ class ProgressInfoStatic friend class ProgressInfoBlocker; static bool s_running; static bool s_disabled; + static bool s_isButtonConnected; }; } // namespace caf From 0216d9b57b229e99cb2e87a03a35dc2ffaa649ce Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 14 Aug 2024 16:55:18 +0200 Subject: [PATCH 234/332] Remove QApplication::processEvents uses. --- Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index 59c4706441..d05a49b0be 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -541,7 +541,7 @@ void ProgressInfoStatic::start( ProgressInfo& progressInfo, dialog->setValue( static_cast( currentTotalProgress() ) ); dialog->setLabelText( currentComposedLabel() ); } - QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); // if (progressDialog()) progressDialog()->repaint(); } @@ -559,7 +559,7 @@ void ProgressInfoStatic::setProgressDescription( const QString& description ) { dialog->setLabelText( currentComposedLabel() ); } - QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); // if (progressDialog()) progressDialog()->repaint(); } @@ -605,7 +605,7 @@ void ProgressInfoStatic::setProgress( size_t progressValue ) dialog->setValue( totalProgress ); } - QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); // if (progressDialog()) progressDialog()->repaint(); } @@ -687,7 +687,7 @@ void ProgressInfoStatic::finished() dialog->setLabelText( currentComposedLabel() ); } - QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); // If we are finishing the last level, clean up if ( maxProgressStack_v.empty() ) From 9bea7392528ff0558626b2c493e370c498971aff Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 16 Aug 2024 13:28:44 +0200 Subject: [PATCH 235/332] Parallelize initial import of OSDU well path. --- .../RicWellPathsImportOsduFeature.cpp | 51 ++++++++++--------- .../WellPath/RimOsduWellPathDataLoader.cpp | 6 +-- .../cafDataLoader/cafDataLoadController.cpp | 2 +- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index f0b7356989..f2530f7fe9 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -20,6 +20,7 @@ #include "Cloud/RiaOsduConnector.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" #include "RiaPreferences.h" @@ -37,6 +38,7 @@ #include "RiuMainWindow.h" #include "RiuWellImportWizard.h" +#include "cafDataLoadController.h" #include "cafProgressInfo.h" #include "cvfObject.h" @@ -72,34 +74,35 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) { std::vector importedWells = wellImportwizard.importedWells(); - caf::ProgressInfo progress( importedWells.size(), "Importing wells from OSDU" ); + caf::ProgressInfo progress( importedWells.size(), "Importing wells from OSDU", false, true ); + int colorIndex = 0; + std::vector newWells; for ( auto w : importedWells ) { - auto task = progress.task( QString( "Importing well: %1" ).arg( w.name ) ); - - auto [wellPathGeometry, errorMessage] = - RimWellPathCollection::loadWellPathGeometryFromOsdu( osduConnector, w.wellboreTrajectoryId, w.datumElevation ); - if ( wellPathGeometry.notNull() ) - { - auto wellPath = new RimOsduWellPath; - wellPath->setName( w.name ); - wellPath->setWellId( w.wellId ); - wellPath->setWellboreId( w.wellboreId ); - wellPath->setWellboreTrajectoryId( w.wellboreTrajectoryId ); - wellPath->setDatumElevationFromOsdu( w.datumElevation ); - - oilField->wellPathCollection->addWellPath( wellPath ); - - wellPath->setWellPathGeometry( wellPathGeometry.p() ); - } - else - { - RiaLogging::error( "Importing OSDU well failed: " + errorMessage ); - } - - oilField->wellPathCollection->updateConnectedEditors(); + auto wellPath = new RimOsduWellPath; + wellPath->setName( w.name ); + wellPath->setWellId( w.wellId ); + wellPath->setWellboreId( w.wellboreId ); + wellPath->setWellboreTrajectoryId( w.wellboreTrajectoryId ); + wellPath->setDatumElevationFromOsdu( w.datumElevation ); + wellPath->setWellPathColor( RiaColorTables::wellPathsPaletteColors().cycledColor3f( colorIndex++ ) ); + + newWells.push_back( wellPath ); + oilField->wellPathCollection->addWellPath( wellPath ); } + const QString wellPathGeometryKeyword = "WELL_PATH_GEOMETRY"; + + caf::DataLoadController* dataLoadController = caf::DataLoadController::instance(); + progress.setProgressDescription( QString( "Reading well path geometry." ) ); + for ( RimWellPath* wellPath : newWells ) + { + dataLoadController->loadData( *wellPath, wellPathGeometryKeyword, progress ); + } + dataLoadController->blockUntilDone( wellPathGeometryKeyword ); + + oilField->wellPathCollection->updateConnectedEditors(); + project->updateConnectedEditors(); app->project()->scheduleCreateDisplayModelAndRedrawAllViews(); } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp index ac8c957607..d97efd6fe8 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp @@ -63,10 +63,10 @@ void RimOsduWellPathDataLoader::loadData( caf::PdmObject& pdmObject, const QStri auto oWPath = dynamic_cast( &pdmObject ); if ( oWPath ) { - QString trajectoryId = oWPath->wellboreTrajectoryId(); - osduConnector->requestWellboreTrajectoryParquetDataById( trajectoryId ); + QString trajectoryId = oWPath->wellboreTrajectoryId(); m_wellPaths[trajectoryId] = oWPath; m_taskIds[trajectoryId] = taskId; + osduConnector->requestWellboreTrajectoryParquetDataById( trajectoryId ); } QApplication::processEvents(); } @@ -100,7 +100,7 @@ void RimOsduWellPathDataLoader::parquetDownloadComplete( const QByteArray& conte { QMutexLocker lock( &m_mutex ); - if ( m_wellPaths.find( id ) != m_wellPaths.end() ) + if ( m_wellPaths.find( id ) != m_wellPaths.end() && m_taskIds.find( id ) != m_taskIds.end() ) { RiaLogging::info( QString( "Parquet download complete. Id: %1 Size: %2" ).arg( id ).arg( contents.size() ) ); int taskId = m_taskIds[id]; diff --git a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp index 1d5d3b200d..e2b598fe82 100644 --- a/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp +++ b/Fwk/AppFwk/cafDataLoader/cafDataLoadController.cpp @@ -143,5 +143,5 @@ void DataLoadController::onTaskFinished( const caf::SignalEmitter* emitter, QStr { QMutexLocker locker( &m_mutex ); m_pendingTasksByType[dataType]--; - m_progressInfos[dataType]->incrementProgress(); + if ( m_progressInfos.find( dataType ) != m_progressInfos.end() ) m_progressInfos[dataType]->incrementProgress(); } From b324fdb26b333c24d8dce9db9fec3cb1fb5d53a0 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 16 Aug 2024 13:45:53 +0200 Subject: [PATCH 236/332] Close project if cancelling well path loading. --- ApplicationLibCode/Application/RiaApplication.cpp | 10 +++++++++- .../WellPath/RimWellPathCollection.cpp | 6 ++++-- .../ProjectDataModel/WellPath/RimWellPathCollection.h | 2 +- Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 688997098a..96663c3ff9 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -548,7 +548,15 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct } // Initialize well paths - oilField->wellPathCollection->loadDataAndUpdate(); + if ( !oilField->wellPathCollection->loadDataAndUpdate() ) + { + // Opening well path was cancelled or failed: close project. + closeProject(); + m_project = std::make_unique(); + onProjectOpened(); + return true; + } + oilField->ensembleWellLogsCollection->loadDataAndUpdate(); oilField->vfpDataCollection->loadDataAndUpdate(); diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 406f780326..f9b34e1ccd 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -149,7 +149,7 @@ void RimWellPathCollection::fieldChangedByUi( const caf::PdmFieldHandle* changed //-------------------------------------------------------------------------------------------------- /// Read files containing well path data, or create geometry based on the targets //-------------------------------------------------------------------------------------------------- -void RimWellPathCollection::loadDataAndUpdate() +bool RimWellPathCollection::loadDataAndUpdate() { auto hasOsduData = []( const std::vector& wellPaths ) -> bool { @@ -200,7 +200,7 @@ void RimWellPathCollection::loadDataAndUpdate() if ( progress.isCancelled() ) { - return; + return false; } progress.setProgressDescription( QString( "Reading well logs." ) ); @@ -230,6 +230,8 @@ void RimWellPathCollection::loadDataAndUpdate() rebuildWellPathNodes(); sortWellsByName(); + + return true; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h index 966725626d..a2de76456e 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.h @@ -97,7 +97,7 @@ class RimWellPathCollection : public caf::PdmObject caf::PdmField wellPathClip; caf::PdmField wellPathClipZDistance; - void loadDataAndUpdate(); + bool loadDataAndUpdate(); std::vector addWellPaths( QStringList filePaths, QStringList* errorMessages ); std::vector allWellPaths() const; void removeWellPath( gsl::not_null wellPath ); diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index d05a49b0be..6b44139b28 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -695,6 +695,7 @@ void ProgressInfoStatic::finished() if ( dialog ) { QObject::disconnect( dialog, &QProgressDialog::canceled, nullptr, nullptr ); + s_isButtonConnected = false; dialog->reset(); dialog->close(); From 3f2c669bc42bf586e95c2fa5c3c176a85da7b375 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 16 Aug 2024 13:50:25 +0200 Subject: [PATCH 237/332] Respect RESINSIGHT_ENABLED_HDF5 flag on linux. --- CMakeLists.txt | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13f8c4bd00..4431f8d4f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -422,22 +422,24 @@ if(MSVC) ) endif() else() - find_package(HDF5 COMPONENTS CXX) - if(HDF5_FOUND) - list(APPEND EXTERNAL_LINK_LIBRARIES ${HDF5_LIBRARIES}) - - set(RESINSIGHT_FOUND_HDF5 1) - message(STATUS "Using HDF5 libraries : ${HDF5_LIBRARIES}") - - option(RESINSIGHT_HDF5_BUNDLE_LIBRARIES "Bundle HDF5 libraries" OFF) - mark_as_advanced(FORCE RESINSIGHT_HDF5_BUNDLE_LIBRARIES) - if(RESINSIGHT_HDF5_BUNDLE_LIBRARIES) - message(STATUS "Bundling of HDF5 libraries is enabled") - endif() # RESINSIGHT_HDF5_BUNDLE_LIBRARIES - - else() - message(WARNING "Use of HDF5 is enabled, but no HDF5 is found.") - endif() # HDF5_FOUND + if(RESINSIGHT_ENABLE_HDF5) + find_package(HDF5 COMPONENTS CXX) + if(HDF5_FOUND) + list(APPEND EXTERNAL_LINK_LIBRARIES ${HDF5_LIBRARIES}) + + set(RESINSIGHT_FOUND_HDF5 1) + message(STATUS "Using HDF5 libraries : ${HDF5_LIBRARIES}") + + option(RESINSIGHT_HDF5_BUNDLE_LIBRARIES "Bundle HDF5 libraries" OFF) + mark_as_advanced(FORCE RESINSIGHT_HDF5_BUNDLE_LIBRARIES) + if(RESINSIGHT_HDF5_BUNDLE_LIBRARIES) + message(STATUS "Bundling of HDF5 libraries is enabled") + endif() # RESINSIGHT_HDF5_BUNDLE_LIBRARIES + + else() + message(WARNING "Use of HDF5 is enabled, but no HDF5 is found.") + endif() # HDF5_FOUND + endif() endif() # MSVC # ############################################################################## From 141484f8a7a9a5e2deda37ffb7d57278e357bbe0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Aug 2024 16:48:04 +0200 Subject: [PATCH 238/332] Improve error handling when trying to access OSDU data Show more details when support for SSL is missing. Move connection of signal/slot away from constructor. This makes it possible to use ResInsight even if SSL is not available. --- .../Application/RiaApplication.cpp | 12 ++++++++++++ .../RicWellPathsImportOsduFeature.cpp | 5 +++++ .../Commands/RicImportWellLogOsduFeature.cpp | 5 +++++ .../WellLog/RimOsduWellLogDataLoader.cpp | 19 +++++++++++-------- .../WellPath/RimOsduWellPathDataLoader.cpp | 19 +++++++++++-------- .../WellPath/RimWellPathCollection.cpp | 6 ++++-- 6 files changed, 48 insertions(+), 18 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 96663c3ff9..a724d1012c 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -1711,6 +1711,18 @@ RiaOsduConnector* RiaApplication::makeOsduConnector() { if ( m_osduConnector ) return m_osduConnector; + if ( !QSslSocket::supportsSsl() ) + { + QString errMsg = "SSL support is not available. "; +#ifdef Q_OS_WIN + errMsg += + "Make sure that the SSL libraries are available (on Windows platform, they are called 'libcrypto*.dll' and 'libssl*.dll')."; +#endif + RiaLogging::errorInMessageBox( nullptr, "OSDU Service Connection", errMsg ); + + return nullptr; + } + RiaPreferencesOsdu* osduPreferences = preferences()->osduPreferences(); const QString server = osduPreferences->server(); const QString dataPartitionId = osduPreferences->dataPartitionId(); diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index f2530f7fe9..03ae6290dd 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -67,6 +67,11 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) if ( !oilField ) return; RiaOsduConnector* osduConnector = app->makeOsduConnector(); + if ( !osduConnector ) + { + RiaLogging::error( "Failed to create OSDU connector" ); + return; + } RiuWellImportWizard wellImportwizard( osduConnector, RiuMainWindow::instance() ); diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp index 6e9070bbb3..a0b2c0f111 100644 --- a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp @@ -62,6 +62,11 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked ) if ( !oilField->wellPathCollection ) oilField->wellPathCollection = std::make_unique(); auto osduConnector = app->makeOsduConnector(); + if ( !osduConnector ) + { + RiaLogging::error( "Failed to create OSDU connector" ); + return; + } RiuWellLogImportWizard wellLogImportWizard( osduConnector, wellPath->wellboreId(), RiuMainWindow::instance() ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp index 707d830e3d..8bc7352ac3 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp @@ -39,14 +39,6 @@ RimOsduWellLogDataLoader::RimOsduWellLogDataLoader() : caf::DataLoader() { - RiaApplication* app = RiaApplication::instance(); - RiaOsduConnector* osduConnector = app->makeOsduConnector(); - - connect( osduConnector, - SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ), - this, - SLOT( parquetDownloadComplete( const QByteArray&, const QString&, const QString& ) ), - Qt::QueuedConnection ); } //-------------------------------------------------------------------------------------------------- @@ -56,12 +48,23 @@ void RimOsduWellLogDataLoader::loadData( caf::PdmObject& pdmObject, const QStrin { RiaApplication* app = RiaApplication::instance(); RiaOsduConnector* osduConnector = app->makeOsduConnector(); + if ( !osduConnector ) + { + RiaLogging::error( "Failed to create OSDU connector" ); + return; + } // TODO: this is weird? m_dataType = dataType; if ( RimOsduWellLog* osduWellLog = dynamic_cast( &pdmObject ) ) { + connect( osduConnector, + SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ), + this, + SLOT( parquetDownloadComplete( const QByteArray&, const QString&, const QString& ) ), + Qt::ConnectionType( Qt::QueuedConnection | Qt::UniqueConnection ) ); + QString wellLogId = osduWellLog->wellLogId(); osduConnector->requestWellLogParquetDataById( wellLogId ); m_wellLogs[wellLogId] = osduWellLog; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp index d97efd6fe8..bacaae7dbb 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp @@ -39,14 +39,6 @@ RimOsduWellPathDataLoader::RimOsduWellPathDataLoader() : caf::DataLoader() { - RiaApplication* app = RiaApplication::instance(); - RiaOsduConnector* osduConnector = app->makeOsduConnector(); - - connect( osduConnector, - SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ), - this, - SLOT( parquetDownloadComplete( const QByteArray&, const QString&, const QString& ) ), - Qt::QueuedConnection ); } //-------------------------------------------------------------------------------------------------- @@ -56,6 +48,11 @@ void RimOsduWellPathDataLoader::loadData( caf::PdmObject& pdmObject, const QStri { RiaApplication* app = RiaApplication::instance(); RiaOsduConnector* osduConnector = app->makeOsduConnector(); + if ( !osduConnector ) + { + RiaLogging::error( "Failed to create OSDU connector" ); + return; + } // TODO: this is weird? m_dataType = dataType; @@ -63,6 +60,12 @@ void RimOsduWellPathDataLoader::loadData( caf::PdmObject& pdmObject, const QStri auto oWPath = dynamic_cast( &pdmObject ); if ( oWPath ) { + connect( osduConnector, + SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ), + this, + SLOT( parquetDownloadComplete( const QByteArray&, const QString&, const QString& ) ), + Qt::ConnectionType( Qt::QueuedConnection | Qt::UniqueConnection ) ); + QString trajectoryId = oWPath->wellboreTrajectoryId(); m_wellPaths[trajectoryId] = oWPath; m_taskIds[trajectoryId] = taskId; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index f9b34e1ccd..219266f89a 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -182,8 +182,10 @@ bool RimWellPathCollection::loadDataAndUpdate() if ( hasOsduData( allWellPaths() ) ) { - auto osduConnector = RiaApplication::instance()->makeOsduConnector(); - osduConnector->requestTokenBlocking(); + if ( auto osduConnector = RiaApplication::instance()->makeOsduConnector() ) + { + osduConnector->requestTokenBlocking(); + } } caf::DataLoadController* dataLoadController = caf::DataLoadController::instance(); From 7c9db3d48b806dbdef3c7ada5e98791873c8ed7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 10:54:50 +0000 Subject: [PATCH 239/332] Bump actions/upload-artifact from 2 to 4 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v2...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/centos7.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/centos7.yml b/.github/workflows/centos7.yml index 048bb85ee3..17def04c69 100644 --- a/.github/workflows/centos7.yml +++ b/.github/workflows/centos7.yml @@ -90,7 +90,7 @@ jobs: ls - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ResInsight path: ./cmakebuild/packages From 392a7943936b26f578b7f56fb848a268aa7ce8a2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Jul 2024 10:02:44 +0200 Subject: [PATCH 240/332] #11562 RFT plots with nonproducing segments Identify when we have a tubing segments that do not have a device segment connected. Mark the downstream device segment as non-continuous. When MD for device curve is created, add an extra MD for noncontinuous segments. Use inf as data value for this MD. This will ensure that no curve is displayed in this section of the device curve. --- .../FileInterface/RifReaderOpmRft.cpp | 50 ++++++++++++++++++- .../FileInterface/RifRftSegment.cpp | 43 ++++++++++++++++ .../FileInterface/RifRftSegment.h | 2 +- 3 files changed, 93 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp index f3ba7d0b53..d7800f8181 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp @@ -88,11 +88,25 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto { auto data = segment.topology(); + std::vector nonContinuousSegmentIndices; + if ( rftAddress.segmentBranchType() == RiaDefines::RftBranchType::RFT_DEVICE ) + { + nonContinuousSegmentIndices = segment.nonContinuousDeviceSegmentIndices( rftAddress.segmentBranchIndex() ); + } + auto indices = segment.segmentIndicesForBranchIndex( rftAddress.segmentBranchIndex(), rftAddress.segmentBranchType() ); for ( const auto& i : indices ) { CAF_ASSERT( i < data.size() ); + values->push_back( data[i].segNo() ); + + if ( std::find( nonContinuousSegmentIndices.begin(), nonContinuousSegmentIndices.end(), i ) != + nonContinuousSegmentIndices.end() ) + { + // Use the same segment number for the dummy segment as the previous segment + values->push_back( values->back() ); + } } return; } @@ -123,6 +137,12 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto auto key = std::make_pair( wellName, RftDate{ y, m, d } ); auto segment = m_rftWellDateSegments[key]; + std::vector nonContinuousDeviceSegmentIndices; + if ( rftAddress.segmentBranchType() == RiaDefines::RftBranchType::RFT_DEVICE ) + { + nonContinuousDeviceSegmentIndices = segment.nonContinuousDeviceSegmentIndices( rftAddress.segmentBranchIndex() ); + } + if ( m_connectionResultItemCount.count( wellName ) && data.size() == m_connectionResultItemCount[wellName] ) { // Connection results with size equal to length of result CONSEGNO. CONSEGNO defines the segment @@ -138,6 +158,16 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto size_t resultDataIndex = 0; for ( int segmentNumber : segmentNumbers ) { + auto segmentIndex = segment.segmentIndexFromSegmentNumber( segmentNumber ); + + if ( std::find( nonContinuousDeviceSegmentIndices.begin(), nonContinuousDeviceSegmentIndices.end(), segmentIndex ) != + nonContinuousDeviceSegmentIndices.end() ) + { + // Insert an extra infinity value for segments that are not continuous. The number of values in the values + // vector must be equal to the number of x-values (measured depths) + values->push_back( std::numeric_limits::infinity() ); + } + if ( std::find( connnectionSegmentNumbers.begin(), connnectionSegmentNumbers.end(), segmentNumber ) != connnectionSegmentNumbers.end() ) { @@ -157,7 +187,25 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto for ( const auto& i : indices ) { CAF_ASSERT( i < data.size() ); - values->push_back( data[i] ); + auto dataValue = data[i]; + + if ( std::find( nonContinuousDeviceSegmentIndices.begin(), nonContinuousDeviceSegmentIndices.end(), i ) != + nonContinuousDeviceSegmentIndices.end() ) + { + if ( rftAddress.segmentResultName() == RiaDefines::segmentEndDepthResultName() ) + { + // Insert a depth value for segments that are not continuous. When infinity is assigned to this measured + // depth, no curve is drawn for this segment + values->push_back( dataValue - 0.1 ); + } + else + { + // Use infinity to make sure no curve is drawn for this segment + values->push_back( std::numeric_limits::infinity() ); + } + } + + values->push_back( dataValue ); } } diff --git a/ApplicationLibCode/FileInterface/RifRftSegment.cpp b/ApplicationLibCode/FileInterface/RifRftSegment.cpp index 0fe3c62c26..80b73a26f7 100644 --- a/ApplicationLibCode/FileInterface/RifRftSegment.cpp +++ b/ApplicationLibCode/FileInterface/RifRftSegment.cpp @@ -383,3 +383,46 @@ int RifRftSegment::segmentIndexFromSegmentNumber( int segmentNumber ) const return -1; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifRftSegment::nonContinuousDeviceSegmentIndices( int branchIndex ) const +{ + auto deviceSegmentNumbers = segmentNumbersForBranchIndex( branchIndex, RiaDefines::RftBranchType::RFT_DEVICE ); + if ( deviceSegmentNumbers.size() < 2 ) return {}; + + // Find all device segments that are connected to a tubing segment with a upstream tubing segment that is not connected to a device + // segment. + // + // Device numbers : 50 51 52 53 + // | | | | + // Tubing numbers : 1 - 2 - 3 - 4 - 5 - 6 + // + // Device 53 is connected to tubing 5. There are tubing segments between device 52 and 51. We mark device 52 as non-continuous + // device segment. + + std::vector deviceSegmentIndices; + size_t i = deviceSegmentNumbers.size() - 1; + while ( i > 1 ) + { + auto currentDeviceSegment = segmentData( deviceSegmentNumbers[i] ); + if ( !currentDeviceSegment ) continue; + + auto upstreamDeviceSegment = segmentData( deviceSegmentNumbers[i - 1] ); + if ( !upstreamDeviceSegment ) continue; + + auto tubingSegData = segmentData( currentDeviceSegment->segNext() ); + if ( !tubingSegData ) continue; + + auto upstreamTubingSegmentNumber = tubingSegData->segNext(); + if ( upstreamDeviceSegment->segNext() != upstreamTubingSegmentNumber ) + { + deviceSegmentIndices.push_back( segmentIndexFromSegmentNumber( deviceSegmentNumbers[i] ) ); + } + + i--; + } + + return deviceSegmentIndices; +} diff --git a/ApplicationLibCode/FileInterface/RifRftSegment.h b/ApplicationLibCode/FileInterface/RifRftSegment.h index 87c9a7d36f..956f9c3626 100644 --- a/ApplicationLibCode/FileInterface/RifRftSegment.h +++ b/ApplicationLibCode/FileInterface/RifRftSegment.h @@ -74,12 +74,12 @@ class RifRftSegment std::vector segmentIndicesForBranchNumber( int branchNumber ) const; std::vector segmentIndicesForBranchIndex( int branchIndex, RiaDefines::RftBranchType branchType ) const; std::vector packerSegmentIndicesOnAnnulus( int branchIndex ) const; + std::vector nonContinuousDeviceSegmentIndices( int branchIndex ) const; std::vector segmentNumbersForBranchIndex( int oneBasedBranchIndex, RiaDefines::RftBranchType branchType ) const; std::set uniqueOneBasedBranchIndices( RiaDefines::RftBranchType branchType ) const; -private: int segmentIndexFromSegmentNumber( int segmentNumber ) const; private: From b730a077f19acf189b98e939d610db86067347c5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Aug 2024 17:24:31 +0200 Subject: [PATCH 241/332] #11626 Python: By default, use port number assigned by GRPC Using ResInsight in a server environment when many multiple versions of ResInsight is launched, can cause the port assignment to fail. Change the default value for launch_port from -1 to 0, as this will improve the logic used to assign a port to a new ResInsight session. Using 0 will ask GRPC to find an available port to be used. --- GrpcInterface/Python/rips/instance.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/GrpcInterface/Python/rips/instance.py b/GrpcInterface/Python/rips/instance.py index 1bfd20779e..d5c78a4fc7 100644 --- a/GrpcInterface/Python/rips/instance.py +++ b/GrpcInterface/Python/rips/instance.py @@ -97,7 +97,7 @@ def __kill_process(pid: int) -> None: def launch( resinsight_executable: str = "", console: bool = False, - launch_port: int = -1, + launch_port: int = 0, command_line_parameters: List[str] = [], ) -> Optional[Instance]: """Launch a new Instance of ResInsight. This requires the environment variable @@ -109,9 +109,10 @@ def launch( will take precedence over what is provided in the RESINSIGHT_EXECUTABLE environment variable. console (bool): If True, launch as console application, without GUI. - launch_port(int): If -1 will use the default port 50051 or RESINSIGHT_GRPC_PORT - if anything else, ResInsight will try to launch with this port. - If 0 a random port will be used. + launch_port(int): If 0, GRPC will find an available port. + If -1, use the default port 50051 or RESINSIGHT_GRPC_PORT + If anything else, ResInsight will try to launch with the specified portnumber. + command_line_parameters(list): Additional parameters as string entries in the list. Returns: Instance: an instance object if it worked. None if not. From 7651952c8994f5bce94dd72fd16c97af21fb68dd Mon Sep 17 00:00:00 2001 From: Jon Jenssen Date: Wed, 21 Aug 2024 14:59:25 +0200 Subject: [PATCH 242/332] Fix regression test crash --- .../ModelVisualization/RivContourMapProjectionPartMgr.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ApplicationLibCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp index 0265417b5a..62f31799fb 100644 --- a/ApplicationLibCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp @@ -26,6 +26,7 @@ #include "cvfPrimitiveSetIndexedUInt.h" #include "cvfRay.h" #include "cvfScalarMapper.h" +#include "cvfViewport.h" #include "cvfqtUtils.h" #include @@ -398,7 +399,11 @@ std::vector> labelBBoxes->clear(); labelBBoxes->resize( m_contourLinePolygons.size() ); + if ( !camera->viewport() || camera->viewport()->width() == 0 ) return labelDrawables; + const cvf::ScalarMapper* mapper = m_contourMapProjection->legendConfig()->scalarMapper(); + if ( mapper == nullptr ) return labelDrawables; + if ( dynamic_cast( mapper ) != nullptr ) return labelDrawables; std::vector tickValues; From 1a3a005c1c436255cc06409ffa0146effe9c2e8d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Aug 2024 07:18:06 +0200 Subject: [PATCH 243/332] Add optional import of SUMO/OSDU settings from JSON (#11630) Add optionally import of SUMO/OSDU settings from JSON. Check for sumo_config.json and osdu_config.json. If present, import settings to preferences and set fields read only. --- .../Application/RiaApplication.cpp | 31 ++++++++++++++ .../Application/RiaPreferencesOsdu.cpp | 42 +++++++++++++++++++ .../Application/RiaPreferencesOsdu.h | 3 ++ .../Application/RiaPreferencesSumo.cpp | 37 ++++++++++++++++ .../Application/RiaPreferencesSumo.h | 3 ++ .../Tools/Cloud/RiaCloudConnector.cpp | 2 +- .../Tools/Cloud/RiaConnectorTools.cpp | 21 +++++++++- .../Tools/Cloud/RiaConnectorTools.h | 5 ++- 8 files changed, 141 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index a724d1012c..d450865031 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaApplication.h" +#include "Cloud/RiaConnectorTools.h" #include "Cloud/RiaOsduConnector.h" #include "Cloud/RiaSumoConnector.h" #include "Cloud/RiaSumoDefines.h" @@ -1529,6 +1530,34 @@ cvf::Font* RiaApplication::defaultWellLabelFont() return m_defaultWellLabelFont.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +auto readConfigFiles = []( RiaPreferences* preferences ) +{ + if ( preferences == nullptr ) return; + + { + QString osduConfigPath = QDir::homePath() + "/.resinsight/osdu_config.json"; + auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( osduConfigPath ); + if ( !keyValuePairs.empty() ) + { + preferences->osduPreferences()->setData( keyValuePairs ); + preferences->osduPreferences()->setFieldsReadOnly(); + } + } + + { + QString sumoConfigPath = QDir::homePath() + "/.resinsight/sumo_config.json"; + auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( sumoConfigPath ); + if ( !keyValuePairs.empty() ) + { + preferences->sumoPreferences()->setData( keyValuePairs ); + preferences->sumoPreferences()->setFieldsReadOnly(); + } + } +}; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1547,6 +1576,8 @@ void RiaApplication::initialize() caf::SelectionManager::instance()->setPdmRootObject( project() ); initializeDataLoadController(); + + readConfigFiles( m_preferences.get() ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferencesOsdu.cpp b/ApplicationLibCode/Application/RiaPreferencesOsdu.cpp index 941390f345..372b74fcbd 100644 --- a/ApplicationLibCode/Application/RiaPreferencesOsdu.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesOsdu.cpp @@ -43,6 +43,48 @@ RiaPreferencesOsdu* RiaPreferencesOsdu::current() return RiaApplication::instance()->preferences()->osduPreferences(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesOsdu::setData( const std::map& keyValuePairs ) +{ + for ( const auto& [key, value] : keyValuePairs ) + { + if ( key == "server" ) + { + m_server = value; + } + else if ( key == "dataPartitionId" ) + { + m_dataPartitionId = value; + } + else if ( key == "authority" ) + { + m_authority = value; + } + else if ( key == "scopes" ) + { + m_scopes = value; + } + else if ( key == "clientId" ) + { + m_clientId = value; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesOsdu::setFieldsReadOnly() +{ + m_server.uiCapability()->setUiReadOnly( true ); + m_dataPartitionId.uiCapability()->setUiReadOnly( true ); + m_authority.uiCapability()->setUiReadOnly( true ); + m_scopes.uiCapability()->setUiReadOnly( true ); + m_clientId.uiCapability()->setUiReadOnly( true ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferencesOsdu.h b/ApplicationLibCode/Application/RiaPreferencesOsdu.h index 6a0643b082..019d7849dc 100644 --- a/ApplicationLibCode/Application/RiaPreferencesOsdu.h +++ b/ApplicationLibCode/Application/RiaPreferencesOsdu.h @@ -33,6 +33,9 @@ class RiaPreferencesOsdu : public caf::PdmObject static RiaPreferencesOsdu* current(); + void setData( const std::map& keyValuePairs ); + void setFieldsReadOnly(); + QString server() const; QString dataPartitionId() const; QString authority() const; diff --git a/ApplicationLibCode/Application/RiaPreferencesSumo.cpp b/ApplicationLibCode/Application/RiaPreferencesSumo.cpp index 0ad7f66e76..71c339c0a7 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSumo.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesSumo.cpp @@ -42,6 +42,43 @@ RiaPreferencesSumo* RiaPreferencesSumo::current() return RiaApplication::instance()->preferences()->sumoPreferences(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesSumo::setData( const std::map& keyValuePairs ) +{ + for ( const auto& [key, value] : keyValuePairs ) + { + if ( key == "server" ) + { + m_server = value; + } + else if ( key == "authority" ) + { + m_authority = value; + } + else if ( key == "scopes" ) + { + m_scopes = value; + } + else if ( key == "clientId" ) + { + m_clientId = value; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesSumo::setFieldsReadOnly() +{ + m_server.uiCapability()->setUiReadOnly( true ); + m_authority.uiCapability()->setUiReadOnly( true ); + m_scopes.uiCapability()->setUiReadOnly( true ); + m_clientId.uiCapability()->setUiReadOnly( true ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferencesSumo.h b/ApplicationLibCode/Application/RiaPreferencesSumo.h index a66c2bef67..f63755c3b3 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSumo.h +++ b/ApplicationLibCode/Application/RiaPreferencesSumo.h @@ -33,6 +33,9 @@ class RiaPreferencesSumo : public caf::PdmObject static RiaPreferencesSumo* current(); + void setData( const std::map& keyValuePairs ); + void setFieldsReadOnly(); + QString server() const; QString authority() const; QString scopes() const; diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp index bf9c00ee37..6b95cba214 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp @@ -225,7 +225,7 @@ void RiaCloudConnector::exportTokenToFile() //-------------------------------------------------------------------------------------------------- void RiaCloudConnector::importTokenFromFile() { - auto tokenDataJson = RiaConnectorTools::readTokenData( m_tokenDataFilePath ); + auto tokenDataJson = RiaConnectorTools::readStringFromFile( m_tokenDataFilePath ); if ( !tokenDataJson.isEmpty() ) { RiaConnectorTools::initializeTokenDataFromJson( m_authCodeFlow, tokenDataJson ); diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp index f57b3f5c99..61bb5fafa2 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp @@ -90,7 +90,7 @@ void RiaConnectorTools::writeTokenData( const QString& filePath, const QString& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaConnectorTools::readTokenData( const QString& filePath ) +QString RiaConnectorTools::readStringFromFile( const QString& filePath ) { QFile file( filePath ); if ( file.open( QIODevice::ReadOnly ) ) @@ -102,3 +102,22 @@ QString RiaConnectorTools::readTokenData( const QString& filePath ) } return {}; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map RiaConnectorTools::readKeyValuePairs( const QString& filePath ) +{ + auto content = readStringFromFile( filePath ); + + QJsonDocument doc = QJsonDocument::fromJson( content.toUtf8() ); + QJsonObject obj = doc.object(); + + std::map keyValuePairs; + for ( auto it = obj.begin(); it != obj.end(); ++it ) + { + keyValuePairs[it.key()] = it.value().toString(); + } + + return keyValuePairs; +} diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.h b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.h index 5acb2f4f8e..274ff2a13c 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.h @@ -19,6 +19,7 @@ #pragma once #include +#include class QOAuth2AuthorizationCodeFlow; @@ -27,5 +28,7 @@ namespace RiaConnectorTools QString tokenDataAsJson( QOAuth2AuthorizationCodeFlow* authCodeFlow ); void initializeTokenDataFromJson( QOAuth2AuthorizationCodeFlow* authCodeFlow, const QString& tokenDataJson ); void writeTokenData( const QString& filePath, const QString& tokenDataJson ); -QString readTokenData( const QString& filePath ); +QString readStringFromFile( const QString& filePath ); + +std::map readKeyValuePairs( const QString& filePath ); } // namespace RiaConnectorTools From f777dfa4ba80d478c11cf91af1fd457132afa63b Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 21 Aug 2024 08:37:33 +0200 Subject: [PATCH 244/332] Sumo: Increase request timeout. --- ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp index 7ad21eacc7..e8876409d3 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoDefines.cpp @@ -34,5 +34,5 @@ QString RiaSumoDefines::tokenPath() //-------------------------------------------------------------------------------------------------- int RiaSumoDefines::requestTimeoutMillis() { - return 1 * 1000; + return 10 * 1000; } From 12069ca80ae15fe7942dd384a1540c1b08747027 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 21 Aug 2024 08:40:15 +0200 Subject: [PATCH 245/332] Sumo: Fix incorrect signal connection. The signal was not connect using the std::function signalCallable. Therefore the signal would never trigger the QEventLoop::quit() slot, and UI would be stuck waiting for the time out. --- .../Tools/Cloud/RiaSumoConnector.cpp | 49 ++++++++++--------- .../Tools/Cloud/RiaSumoConnector.h | 2 +- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index 4875f1dbf3..c82aa36daa 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -124,10 +125,9 @@ void RiaSumoConnector::requestCasesForField( const QString& fieldName ) //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestCasesForFieldBlocking( const QString& fieldName ) { - auto requestCallable = [this, fieldName] { requestCasesForField( fieldName ); }; - auto signalCallable = [this]() { casesFinished(); }; - - wrapAndCallNetworkRequest( requestCallable, signalCallable ); + auto requestCallable = [this, fieldName] { requestCasesForField( fieldName ); }; + QMetaMethod signalMethod = QMetaMethod::fromSignal( &RiaSumoConnector::casesFinished ); + wrapAndCallNetworkRequest( requestCallable, signalMethod ); } //-------------------------------------------------------------------------------------------------- @@ -160,9 +160,9 @@ void RiaSumoConnector::requestAssets() //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestAssetsBlocking() { - auto requestCallable = [this] { requestAssets(); }; - auto signalCallable = [this]() { assetsFinished(); }; - wrapAndCallNetworkRequest( requestCallable, signalCallable ); + auto requestCallable = [this] { requestAssets(); }; + QMetaMethod signalMethod = QMetaMethod::fromSignal( &RiaSumoConnector::assetsFinished ); + wrapAndCallNetworkRequest( requestCallable, signalMethod ); } //-------------------------------------------------------------------------------------------------- @@ -219,9 +219,9 @@ void RiaSumoConnector::requestEnsembleByCasesId( const SumoCaseId& caseId ) //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestEnsembleByCasesIdBlocking( const SumoCaseId& caseId ) { - auto requestCallable = [this, caseId] { requestEnsembleByCasesId( caseId ); }; - auto signalCallable = [this]() { ensembleNamesFinished(); }; - wrapAndCallNetworkRequest( requestCallable, signalCallable ); + auto requestCallable = [this, caseId] { requestEnsembleByCasesId( caseId ); }; + QMetaMethod signalMethod = QMetaMethod::fromSignal( &RiaSumoConnector::ensembleNamesFinished ); + wrapAndCallNetworkRequest( requestCallable, signalMethod ); } //-------------------------------------------------------------------------------------------------- @@ -288,10 +288,9 @@ void RiaSumoConnector::requestVectorNamesForEnsemble( const SumoCaseId& caseId, //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestVectorNamesForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName ) { - auto requestCallable = [this, caseId, ensembleName] { requestVectorNamesForEnsemble( caseId, ensembleName ); }; - auto signalCallable = [this]() { vectorNamesFinished(); }; - - wrapAndCallNetworkRequest( requestCallable, signalCallable ); + auto requestCallable = [this, caseId, ensembleName] { requestVectorNamesForEnsemble( caseId, ensembleName ); }; + QMetaMethod signalMethod = QMetaMethod::fromSignal( &RiaSumoConnector::vectorNamesFinished ); + wrapAndCallNetworkRequest( requestCallable, signalMethod ); } //-------------------------------------------------------------------------------------------------- @@ -352,10 +351,9 @@ void RiaSumoConnector::requestRealizationIdsForEnsemble( const SumoCaseId& caseI //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestRealizationIdsForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName ) { - auto requestCallable = [this, caseId, ensembleName] { requestRealizationIdsForEnsemble( caseId, ensembleName ); }; - auto signalCallable = [this]() { realizationIdsFinished(); }; - - wrapAndCallNetworkRequest( requestCallable, signalCallable ); + auto requestCallable = [this, caseId, ensembleName] { requestRealizationIdsForEnsemble( caseId, ensembleName ); }; + QMetaMethod signalMethod = QMetaMethod::fromSignal( &RiaSumoConnector::realizationIdsFinished ); + wrapAndCallNetworkRequest( requestCallable, signalMethod ); } //-------------------------------------------------------------------------------------------------- @@ -412,9 +410,9 @@ void RiaSumoConnector::requestBlobIdForEnsemble( const SumoCaseId& caseId, const //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestBlobIdForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ) { - auto requestCallable = [this, caseId, ensembleName, vectorName] { requestBlobIdForEnsemble( caseId, ensembleName, vectorName ); }; - auto signalCallable = [this]() { blobIdFinished(); }; - wrapAndCallNetworkRequest( requestCallable, signalCallable ); + auto requestCallable = [this, caseId, ensembleName, vectorName] { requestBlobIdForEnsemble( caseId, ensembleName, vectorName ); }; + QMetaMethod signalMethod = QMetaMethod::fromSignal( &RiaSumoConnector::blobIdFinished ); + wrapAndCallNetworkRequest( requestCallable, signalMethod ); } //-------------------------------------------------------------------------------------------------- @@ -554,17 +552,20 @@ QString RiaSumoConnector::constructDownloadUrl( const QString& server, const QSt //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSumoConnector::wrapAndCallNetworkRequest( std::function requestCallable, std::function signalCallable ) +void RiaSumoConnector::wrapAndCallNetworkRequest( std::function requestCallable, const QMetaMethod& signalMethod ) { QEventLoop eventLoop; QTimer timer; timer.setSingleShot( true ); + QObject::connect( &timer, &QTimer::timeout, [] { RiaLogging::error( "Sumo request timed out." ); } ); QObject::connect( &timer, &QTimer::timeout, &eventLoop, &QEventLoop::quit ); - // Not able to use the modern connect syntax here, as the signal is communicated as a std::function - QObject::connect( this, SIGNAL( signalCallable ), &eventLoop, SLOT( quit() ) ); + // Not able to use the modern connect syntax here, as the signal is communicated as a QMetaMethod + int methodIndex = eventLoop.metaObject()->indexOfMethod( "quit()" ); + QMetaMethod quitMethod = eventLoop.metaObject()->method( methodIndex ); + QObject::connect( this, signalMethod, &eventLoop, quitMethod ); // Call the function that will execute the request requestCallable(); diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h index c067e0bf06..beae5fc9c6 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h @@ -143,7 +143,7 @@ public slots: static QString constructSearchUrl( const QString& server ); static QString constructDownloadUrl( const QString& server, const QString& blobId ); - void wrapAndCallNetworkRequest( std::function requestCallable, std::function signalCallable ); + void wrapAndCallNetworkRequest( std::function requestCallable, const QMetaMethod& signalMethod ); private: std::vector m_assets; From 123f6fdcfac1d405a1c0cb178a845418ce8e6416 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 21 Aug 2024 08:43:33 +0200 Subject: [PATCH 246/332] Sumo: Fix incorrect signal-slot connection. --- ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index c82aa36daa..902003b17f 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -514,7 +514,7 @@ QByteArray RiaSumoConnector::requestParquetDataBlocking( const SumoCaseId& caseI QTimer timer; timer.setSingleShot( true ); QObject::connect( &timer, SIGNAL( timeout() ), &eventLoop, SLOT( quit() ) ); - QObject::connect( &timer, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ), &eventLoop, SLOT( quit() ) ); + QObject::connect( this, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ), &eventLoop, SLOT( quit() ) ); requestBlobDownload( blobId ); From ef9a397188a16efb46e5b6ad597feb1685f84caf Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 21 Aug 2024 16:39:48 +0200 Subject: [PATCH 247/332] Sumo: improve logging and remove some unused code. --- .../Application/Tools/Cloud/RiaSumoConnector.cpp | 6 ++++-- .../Application/Tools/Cloud/RiaSumoConnector.h | 4 ---- .../Summary/Sumo/RimSummaryEnsembleSumo.cpp | 13 ++++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index 902003b17f..efd27a220d 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -467,6 +467,8 @@ void RiaSumoConnector::requestBlobDownload( const QString& blobId ) //-------------------------------------------------------------------------------------------------- void RiaSumoConnector::requestBlobByRedirectUri( const QString& blobId, const QString& redirectUri ) { + RiaLogging::debug( QString( "Requesting blob. Id: %1 Redirect URL: %2" ).arg( blobId ).arg( redirectUri ) ); + requestTokenBlocking(); QNetworkRequest networkRequest; @@ -700,9 +702,9 @@ void RiaSumoConnector::parseCases( QNetworkReply* reply ) QString fieldName = fmuCase["name"].toString(); m_cases.push_back( SumoCase{ SumoCaseId( id ), kind, fieldName } ); } - - emit casesFinished(); } + + emit casesFinished(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h index beae5fc9c6..76f4603d7e 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h @@ -154,9 +154,5 @@ public slots: std::vector m_blobUrl; - QString m_redirect; - std::vector m_redirectInfo; - - QByteArray m_parquetData; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp index a770069b9d..5282d1fa40 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp @@ -120,6 +120,7 @@ void RimSummaryEnsembleSumo::loadSummaryData( const RifEclipseSummaryAddress& re if ( m_parquetTable.find( key ) == m_parquetTable.end() ) { auto contents = loadParquetData( key ); + RiaLogging::debug( QString( "Load Summary Data. Contents size: %1" ).arg( contents.size() ) ); arrow::MemoryPool* pool = arrow::default_memory_pool(); @@ -127,20 +128,22 @@ void RimSummaryEnsembleSumo::loadSummaryData( const RifEclipseSummaryAddress& re std::shared_ptr table; std::unique_ptr arrow_reader; - if ( parquet::arrow::OpenFile( input, pool, &arrow_reader ).ok() ) + if ( auto openResult = parquet::arrow::OpenFile( input, pool, &arrow_reader ); openResult.ok() ) { - if ( arrow_reader->ReadTable( &table ).ok() ) + if ( auto readResult = arrow_reader->ReadTable( &table ); readResult.ok() ) { - RiaLogging::info( "Parquet: Read table" ); + RiaLogging::info( QString( "Parquet: Read table successfully for %1" ).arg( QString::fromStdString( resultAddress.uiText() ) ) ); } else { - RiaLogging::warning( "Parquet: Error detected during parsing of table" ); + RiaLogging::warning( QString( "Parquet: Error detected during parsing of table. Message: %1" ) + .arg( QString::fromStdString( readResult.ToString() ) ) ); } } else { - RiaLogging::warning( "Parquet: Not able to open data stream" ); + RiaLogging::warning( + QString( "Parquet: Not able to open data stream. Message: %1" ).arg( QString::fromStdString( openResult.ToString() ) ) ); } m_parquetTable[key] = table; From f6fa93bb666c443dc92deab886294b8920df09b5 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 21 Aug 2024 16:40:07 +0200 Subject: [PATCH 248/332] Sumo: Fix concurrency issue when stepping too fast. --- .../Application/Tools/Cloud/RiaSumoConnector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index efd27a220d..22f267837d 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -521,7 +521,7 @@ QByteArray RiaSumoConnector::requestParquetDataBlocking( const SumoCaseId& caseI requestBlobDownload( blobId ); timer.start( RiaSumoDefines::requestTimeoutMillis() ); - eventLoop.exec(); + eventLoop.exec( QEventLoop::ProcessEventsFlag::ExcludeUserInputEvents ); for ( const auto& blobData : m_redirectInfo ) { @@ -573,7 +573,7 @@ void RiaSumoConnector::wrapAndCallNetworkRequest( std::function requestC requestCallable(); timer.start( RiaSumoDefines::requestTimeoutMillis() ); - eventLoop.exec(); + eventLoop.exec( QEventLoop::ProcessEventsFlag::ExcludeUserInputEvents ); } //-------------------------------------------------------------------------------------------------- From 83443ae2ffacb7801f469f234acc9136e5ec654d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Aug 2024 11:49:06 +0200 Subject: [PATCH 249/332] Guard use of empty OpenGL context --- .../ModelVisualization/RivWellSpheresPartMgr.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/ModelVisualization/RivWellSpheresPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivWellSpheresPartMgr.cpp index 58c43d47ed..9e04c755fb 100644 --- a/ApplicationLibCode/ModelVisualization/RivWellSpheresPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivWellSpheresPartMgr.cpp @@ -178,11 +178,14 @@ cvf::ref RivWellSpheresPartMgr::createPart( std::vectorviewer() ) { - cvf::ref oglContext = m_rimReservoirView->viewer()->cvfOpenGLContext(); - cvf::OpenGLResourceManager* resourceManager = oglContext->resourceManager(); - cvf::ref vectorProgram = resourceManager->getLinkedVectorDrawerShaderProgram( oglContext.p() ); + cvf::ref oglContext = m_rimReservoirView->viewer()->cvfOpenGLContext(); + if ( oglContext.notNull() ) + { + cvf::OpenGLResourceManager* resourceManager = oglContext->resourceManager(); + cvf::ref vectorProgram = resourceManager->getLinkedVectorDrawerShaderProgram( oglContext.p() ); - eff->setShaderProgram( vectorProgram.p() ); + eff->setShaderProgram( vectorProgram.p() ); + } } } From 1b509c0384a1e9afce87a2b70a4901632ab6ac8a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Aug 2024 13:22:15 +0200 Subject: [PATCH 250/332] Use mutex when import well paths A shared data structure (RifWellPathImporter) is used when importing well paths. Add mutex to ensure single use of shared data structure. --- .../ProjectDataModel/WellPath/RimFileWellPathDataLoader.cpp | 3 ++- .../ProjectDataModel/WellPath/RimFileWellPathDataLoader.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.cpp index d751ff4eb5..2f3e14b61b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.cpp @@ -45,7 +45,8 @@ void RimFileWellPathDataLoader::loadData( caf::PdmObject& pdmObject, const QStri auto* fWPath = dynamic_cast( &pdmObject ); if ( fWPath && !fWPath->filePath().isEmpty() ) { - QString errorMessage; + QMutexLocker lock( &m_mutex ); + QString errorMessage; if ( !fWPath->readWellPathFile( &errorMessage, m_wellPathImporter.get(), false ) ) { RiaLogging::warning( errorMessage ); diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.h index 5f9b2a2b08..54cbe8ccba 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPathDataLoader.h @@ -23,6 +23,7 @@ #include "cafDataLoader.h" #include "cafProgressInfo.h" +#include #include #include @@ -42,4 +43,5 @@ class RimFileWellPathDataLoader : public caf::DataLoader private: std::unique_ptr m_wellPathImporter; + QMutex m_mutex; }; From c322ba62bb446b7aa52cbfcd57ec5967e7e2d451 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 23 Aug 2024 11:46:33 +0200 Subject: [PATCH 251/332] #11636 Fix missing well path creation when importing LAS file without a well path file Fixes #11636. --- ApplicationLibCode/Application/RiaApplication.cpp | 3 +++ .../ProjectDataModel/WellLog/RimWellLogLasFile.cpp | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index d450865031..3c6759a6da 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -1815,6 +1815,9 @@ void RiaApplication::initializeDataLoadController() std::make_unique() ); const QString wellLogKeyword = "WELL_LOG"; + dataLoadController->registerDataLoader( RimWellLogLasFile::classKeywordStatic(), + wellLogKeyword, + std::make_unique() ); dataLoadController->registerDataLoader( RimWellLogFile::classKeywordStatic(), wellLogKeyword, std::make_unique() ); dataLoadController->registerDataLoader( RimOsduWellLog::classKeywordStatic(), wellLogKeyword, std::make_unique() ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp index 409f3732a1..26d24bbd2e 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp @@ -152,10 +152,19 @@ bool RimWellLogLasFile::readFile( QString* errorMessage ) m_wellLogChannels.push_back( wellLog ); } - auto wellPath = firstAncestorOrThisOfType(); + auto fileWellPath = firstAncestorOrThisOfType(); + if ( fileWellPath ) + { + if ( fileWellPath->filePath().isEmpty() ) // Has dummy wellpath + { + fileWellPath->setName( m_wellName ); + } + } + + auto wellPath = firstAncestorOrThisOfType(); if ( wellPath ) { - if ( wellPath->filePath().isEmpty() ) // Has dummy wellpath + if ( wellPath->name().isEmpty() ) { wellPath->setName( m_wellName ); } From bc9db44fe032891cad2d7a59c57bb9daebd234fa Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Aug 2024 16:58:43 +0200 Subject: [PATCH 252/332] Use 1 as default size for fault mesh lines --- .../ProjectDataModel/Faults/RimFaultInViewCollection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp index f8143e5c5e..874dc79872 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp @@ -70,7 +70,7 @@ RimFaultInViewCollection::RimFaultInViewCollection() caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showOppositeFaultFaces ); CAF_PDM_InitField( &m_applyCellFilters, "ApplyCellFilters", true, "Use Cell Filters for Faults" ); - CAF_PDM_InitField( &m_meshLineThickness, "MeshLineThickness", 2, "Mesh Line Thickness [1..10]" ); + CAF_PDM_InitField( &m_meshLineThickness, "MeshLineThickness", 1, "Mesh Line Thickness [1..10]" ); CAF_PDM_InitField( &m_onlyShowWithNeighbor, "OnlyShowWithDefNeighbor", false, "Show Only Faces with Juxtaposition" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_onlyShowWithNeighbor ); From ff505f587eae97797706cc4d30c207f8ef30ddeb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Aug 2024 17:00:58 +0200 Subject: [PATCH 253/332] Bump version to dev.14 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 1be499030a..fd6bfbf635 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".13") +set(RESINSIGHT_DEV_VERSION ".14") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 41256e0b756f5f08b4d47f962b6af3a4f4487962 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 27 Aug 2024 07:38:53 +0200 Subject: [PATCH 254/332] Include build server OS as text in about dialog --- ApplicationLibCode/Adm/RiaVersionInfo.h.cmake | 4 +++- .../ApplicationCommands/RicHelpFeatures.cpp | 2 ++ CMakeLists.txt | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake b/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake index 8e2910f76a..c710fe6ae7 100644 --- a/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake +++ b/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake @@ -35,4 +35,6 @@ #define RESINSIGHT_PYTHON_VERSION "@Python3_VERSION@" -#define RESINSIGHT_GIT_HASH "@RESINSIGHT_GIT_HASH@" \ No newline at end of file +#define RESINSIGHT_GIT_HASH "@RESINSIGHT_GIT_HASH@" + +#define RESINSIGHT_BUILD_SYSTEM_ID "@RESINSIGHT_BUILD_SYSTEM_ID@" \ No newline at end of file diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.cpp index b927d259c2..eecc502e6b 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.cpp @@ -148,6 +148,8 @@ void RicHelpAboutFeature::onActionTriggered( bool isChecked ) dlg.addVersionEntry( " ", QString( " " ) + vendor + " : " + render ); } + dlg.addVersionEntry( " ", QString( " Build Server : " ) + RESINSIGHT_BUILD_SYSTEM_ID ); + QString compiledUsingPythonVersion = RESINSIGHT_PYTHON_VERSION; if ( !compiledUsingPythonVersion.isEmpty() ) { diff --git a/CMakeLists.txt b/CMakeLists.txt index 4431f8d4f6..a7e68405de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,6 +169,22 @@ endif() # ############################################################################## # Version number # ############################################################################## +if(UNIX AND NOT APPLE) + if(EXISTS "/etc/os-release") + # Read the contents of /etc/os-release + file(READ "/etc/os-release" OS_RELEASE_CONTENT) + + # Extract ID + string(REGEX MATCH "PRETTY_NAME=\"?([^\n\"]+)\"?" _ ${OS_RELEASE_CONTENT}) + set(RESINSIGHT_BUILD_SYSTEM_ID ${CMAKE_MATCH_1}) + + # Display the extracted values + message(STATUS "Operating System ID: ${RESINSIGHT_BUILD_SYSTEM_ID}") + else() + message(WARNING "/etc/os-release not found. Cannot determine OS details.") + endif() +endif() + include(ResInsightVersion.cmake) # ############################################################################## From 44076f4911cda14bb40d340c3512fe012ada13db Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 26 Aug 2024 08:37:26 +0200 Subject: [PATCH 255/332] Sumo: load parameter sensitivities (i.e. "parameters.txt") for ensembles. --- .../Tools/Cloud/RiaSumoConnector.cpp | 93 +++++++++ .../Tools/Cloud/RiaSumoConnector.h | 4 + .../Summary/RimSummaryCaseMainCollection.cpp | 12 +- .../Summary/Sumo/RimSummaryEnsembleSumo.cpp | 195 +++++++++++++++--- .../Summary/Sumo/RimSummaryEnsembleSumo.h | 4 + 5 files changed, 270 insertions(+), 38 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index 22f267837d..96de04bc7b 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -356,6 +356,99 @@ void RiaSumoConnector::requestRealizationIdsForEnsembleBlocking( const SumoCaseI wrapAndCallNetworkRequest( requestCallable, signalMethod ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QByteArray RiaSumoConnector::requestParametersParquetDataBlocking( const SumoCaseId& caseId, const QString& ensembleName ) +{ + requestParametersBlobIdForEnsembleBlocking( caseId, ensembleName ); + + if ( m_blobUrl.empty() ) return {}; + + auto blobId = m_blobUrl.back(); + + QEventLoop eventLoop; + QTimer timer; + timer.setSingleShot( true ); + QObject::connect( &timer, SIGNAL( timeout() ), &eventLoop, SLOT( quit() ) ); + QObject::connect( this, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ), &eventLoop, SLOT( quit() ) ); + + requestBlobDownload( blobId ); + + timer.start( RiaSumoDefines::requestTimeoutMillis() ); + eventLoop.exec( QEventLoop::ProcessEventsFlag::ExcludeUserInputEvents ); + + for ( const auto& blobData : m_redirectInfo ) + { + if ( blobData.objectId == blobId ) + { + return blobData.contents; + } + } + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestParametersBlobIdForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName ) +{ + auto requestCallable = [this, caseId, ensembleName] { requestParametersBlobIdForEnsemble( caseId, ensembleName ); }; + QMetaMethod signalMethod = QMetaMethod::fromSignal( &RiaSumoConnector::blobIdFinished ); + wrapAndCallNetworkRequest( requestCallable, signalMethod ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSumoConnector::requestParametersBlobIdForEnsemble( const SumoCaseId& caseId, const QString& ensembleName ) +{ + requestTokenBlocking(); + + QString payloadTemplate = R"( +{ + "track_total_hits": true, + "query": { "bool": { + "must": [ + {"term": {"class": "table"}}, + {"term": {"_sumo.parent_object.keyword": "%1"}}, + {"term": {"data.tagname.keyword": "all"}}, + {"term": {"fmu.iteration.name.keyword": "%2"}}, + {"term": {"fmu.aggregation.operation.keyword": "collection"}} + ]} + }, + "fields": [ + "data.name", + "_sumo.blob_name" + ], + "size": 1 +} +)"; + + QNetworkRequest m_networkRequest; + m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) ); + + addStandardHeader( m_networkRequest, token(), RiaCloudDefines::contentTypeJson() ); + + auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName ); + auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() ); + + connect( reply, + &QNetworkReply::finished, + [this, reply, ensembleName, caseId, payload]() + { + if ( reply->error() == QNetworkReply::NoError ) + { + parseBlobIds( reply, caseId, ensembleName, "" ); + } + else + { + RiaLogging::error( QString( "Request parameters failed: : '%s'" ).arg( reply->errorString() ) ); + } + } ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h index 76f4603d7e..6887f322fd 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h @@ -93,6 +93,10 @@ class RiaSumoConnector : public RiaCloudConnector void requestRealizationIdsForEnsemble( const SumoCaseId& caseId, const QString& ensembleName ); void requestRealizationIdsForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName ); + void requestParametersBlobIdForEnsemble( const SumoCaseId& caseId, const QString& ensembleName ); + void requestParametersBlobIdForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName ); + QByteArray requestParametersParquetDataBlocking( const SumoCaseId& caseId, const QString& ensembleName ); + void requestBlobIdForEnsemble( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ); void requestBlobIdForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index c727384790..6de76eac6e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -27,6 +27,7 @@ #include "RifEclipseSummaryTools.h" #include "RifOpmCommonSummary.h" #include "RifSummaryCaseRestartSelector.h" +#include "Sumo/RimSummaryCaseSumo.h" #ifdef USE_HDF5 #include "RifHdf5SummaryExporter.h" @@ -80,11 +81,14 @@ void addCaseRealizationParametersIfFound( RimSummaryCase& sumCase, const QString parameters = std::shared_ptr( new RigCaseRealizationParameters() ); } - int realizationNumber = RifCaseRealizationParametersFileLocator::realizationNumber( modelFolderOrFile ); - parameters->setRealizationNumber( realizationNumber ); - parameters->addParameter( RiaDefines::summaryRealizationNumber(), realizationNumber ); + if ( dynamic_cast( &sumCase ) == nullptr ) + { + int realizationNumber = RifCaseRealizationParametersFileLocator::realizationNumber( modelFolderOrFile ); + parameters->setRealizationNumber( realizationNumber ); + parameters->addParameter( RiaDefines::summaryRealizationNumber(), realizationNumber ); - sumCase.setCaseRealizationParameters( parameters ); + sumCase.setCaseRealizationParameters( parameters ); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp index 5282d1fa40..59ffa409b2 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp @@ -119,36 +119,25 @@ void RimSummaryEnsembleSumo::loadSummaryData( const RifEclipseSummaryAddress& re if ( m_parquetTable.find( key ) == m_parquetTable.end() ) { - auto contents = loadParquetData( key ); - RiaLogging::debug( QString( "Load Summary Data. Contents size: %1" ).arg( contents.size() ) ); - - arrow::MemoryPool* pool = arrow::default_memory_pool(); + { + auto contents = loadParquetData( key ); + RiaLogging::debug( QString( "Load Summary Data. Contents size: %1" ).arg( contents.size() ) ); - std::shared_ptr input = std::make_shared( contents ); + std::shared_ptr table = readParquetTable( contents, QString::fromStdString( resultAddress.uiText() ) ); + m_parquetTable[key] = table; - std::shared_ptr table; - std::unique_ptr arrow_reader; - if ( auto openResult = parquet::arrow::OpenFile( input, pool, &arrow_reader ); openResult.ok() ) - { - if ( auto readResult = arrow_reader->ReadTable( &table ); readResult.ok() ) - { - RiaLogging::info( QString( "Parquet: Read table successfully for %1" ).arg( QString::fromStdString( resultAddress.uiText() ) ) ); - } - else - { - RiaLogging::warning( QString( "Parquet: Error detected during parsing of table. Message: %1" ) - .arg( QString::fromStdString( readResult.ToString() ) ) ); - } + distributeDataToRealizations( resultAddress, table ); } - else + { - RiaLogging::warning( - QString( "Parquet: Not able to open data stream. Message: %1" ).arg( QString::fromStdString( openResult.ToString() ) ) ); - } + auto contents = m_sumoConnector->requestParametersParquetDataBlocking( sumoCaseId, sumoEnsembleName ); + RiaLogging::debug( QString( "Load ensemble parameter sensitivities. Contents size: %1" ).arg( contents.size() ) ); - m_parquetTable[key] = table; + std::shared_ptr table = + readParquetTable( contents, QString::fromStdString( resultAddress.uiText() + " parameter sensitivities" ) ); - distributeDataToRealizations( resultAddress, table ); + distributeParametersDataToRealizations( table ); + } } } @@ -162,6 +151,38 @@ QByteArray RimSummaryEnsembleSumo::loadParquetData( const ParquetKey& parquetKey return m_sumoConnector->requestParquetDataBlocking( SumoCaseId( parquetKey.caseId ), parquetKey.ensembleId, parquetKey.vectorName ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::shared_ptr RimSummaryEnsembleSumo::readParquetTable( const QByteArray& contents, const QString& messageTag ) +{ + arrow::MemoryPool* pool = arrow::default_memory_pool(); + + std::shared_ptr input = std::make_shared( contents ); + + std::shared_ptr table; + std::unique_ptr arrow_reader; + if ( auto openResult = parquet::arrow::OpenFile( input, pool, &arrow_reader ); openResult.ok() ) + { + if ( auto readResult = arrow_reader->ReadTable( &table ); readResult.ok() ) + { + RiaLogging::info( QString( "Parquet: Read table successfully for %1" ).arg( messageTag ) ); + } + else + { + RiaLogging::warning( + QString( "Parquet: Error detected during parsing of table. Message: %1" ).arg( QString::fromStdString( readResult.ToString() ) ) ); + } + } + else + { + RiaLogging::warning( + QString( "Parquet: Not able to open data stream. Message: %1" ).arg( QString::fromStdString( openResult.ToString() ) ) ); + } + + return table; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -287,6 +308,122 @@ void RimSummaryEnsembleSumo::distributeDataToRealizations( const RifEclipseSumma } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsembleSumo::distributeParametersDataToRealizations( std::shared_ptr table ) +{ + if ( !table ) + { + RiaLogging::warning( "Failed to load table" ); + return; + } + + { + // print header information + QString txt = "Column Names: "; + for ( std::string columnName : table->ColumnNames() ) + { + txt += QString::fromStdString( columnName ) + " (" + + QString::fromStdString( table->GetColumnByName( columnName )->type()->ToString() + ") " ); + } + + RiaLogging::debug( txt ); + } + + std::vector realizations; + + { + const std::string columnName = "REAL"; + std::shared_ptr column = table->GetColumnByName( columnName ); + if ( column && column->type()->id() == arrow::Type::INT64 ) + { + realizations = RifArrowTools::chunkedArrayToVector( column ); + } + else + { + RiaLogging::warning( "Failed to find realization column for parameter sensitivities." ); + return; + } + } + + std::map> doubleValuesForRealizations; + std::map> intValuesForRealizations; + for ( std::string columnName : table->ColumnNames() ) + { + if ( columnName != "REAL" ) + { + std::shared_ptr column = table->GetColumnByName( columnName ); + + if ( column ) + { + if ( column->type()->id() == arrow::Type::DOUBLE ) + { + std::vector values = RifArrowTools::chunkedArrayToVector( column ); + doubleValuesForRealizations[columnName] = values; + } + else if ( column->type()->id() == arrow::Type::INT64 ) + { + std::vector values = RifArrowTools::chunkedArrayToVector( column ); + intValuesForRealizations[columnName] = values; + } + } + else + { + RiaLogging::warning( QString( "Failed to find values column for %1" ).arg( QString::fromStdString( columnName ) ) ); + return; + } + } + } + + // find unique realizations + std::set uniqueRealizations; + for ( auto realizationNumber : realizations ) + { + uniqueRealizations.insert( realizationNumber ); + } + + auto findSummaryCase = [this]( int16_t realizationNumber ) -> RimSummaryCaseSumo* + { + for ( auto sumCase : allSummaryCases() ) + { + auto sumCaseSumo = dynamic_cast( sumCase ); + if ( sumCaseSumo->realizationNumber() == realizationNumber ) return sumCaseSumo; + } + + return nullptr; + }; + + for ( auto realizationNumber : uniqueRealizations ) + { + if ( auto summaryCase = findSummaryCase( realizationNumber ) ) + { + auto parameters = std::make_shared(); + parameters->setRealizationNumber( realizationNumber ); + parameters->addParameter( RiaDefines::summaryRealizationNumber(), realizationNumber ); + + for ( std::string columnName : table->ColumnNames() ) + { + if ( columnName != "REAL" ) + { + if ( auto it = doubleValuesForRealizations.find( columnName ); it != doubleValuesForRealizations.end() ) + { + double value = it->second[realizationNumber]; + parameters->addParameter( QString::fromStdString( columnName ), value ); + } + else if ( auto it = intValuesForRealizations.find( columnName ); it != intValuesForRealizations.end() ) + { + double value = it->second[realizationNumber]; + parameters->addParameter( QString::fromStdString( columnName ), value ); + } + } + } + + summaryCase->setCaseRealizationParameters( parameters ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -399,16 +536,6 @@ void RimSummaryEnsembleSumo::onLoadDataAndUpdate() realization->setShowVectorItemsInProjectTree( m_cases.empty() ); - // Create realization parameters, required to make derived ensemble cases work - // See RimDerivedEnsembleCaseCollection::createDerivedEnsembleCases() - auto parameters = std::shared_ptr( new RigCaseRealizationParameters() ); - - int realizationNumber = realId.toInt(); - parameters->setRealizationNumber( realizationNumber ); - parameters->addParameter( RiaDefines::summaryRealizationNumber(), realizationNumber ); - - realization->setCaseRealizationParameters( parameters ); - m_cases.push_back( realization ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h index 6c0adbf435..f7dfbfe072 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h @@ -82,6 +82,10 @@ class RimSummaryEnsembleSumo : public RimSummaryEnsemble void distributeDataToRealizations( const RifEclipseSummaryAddress& resultAddress, std::shared_ptr table ); void buildMetaData(); + void distributeParametersDataToRealizations( std::shared_ptr table ); + + static std::shared_ptr readParquetTable( const QByteArray& contents, const QString& messageTag ); + private: caf::PdmPtrField m_sumoDataSource; From 48e32668ec1816683dde837ef43573796fc15f99 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 26 Aug 2024 18:54:56 +0200 Subject: [PATCH 256/332] Sumo ensemble parameters: handle string properties. --- .../FileInterface/RifArrowTools.cpp | 22 +++++++++++++++++++ .../FileInterface/RifArrowTools.h | 5 +++++ .../Summary/Sumo/RimSummaryEnsembleSumo.cpp | 17 ++++++++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifArrowTools.cpp b/ApplicationLibCode/FileInterface/RifArrowTools.cpp index c127ce7872..b9661c8297 100644 --- a/ApplicationLibCode/FileInterface/RifArrowTools.cpp +++ b/ApplicationLibCode/FileInterface/RifArrowTools.cpp @@ -101,3 +101,25 @@ QString RifArrowTools::readFirstRowsOfTable( const QByteArray& contents ) return tableText; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifArrowTools::chunkedArrayToStringVector( const std::shared_ptr& chunkedArray ) +{ + std::vector result; + + for ( int i = 0; i < chunkedArray->num_chunks(); ++i ) + { + auto chunk = std::static_pointer_cast( chunkedArray->chunk( i ) ); + for ( int j = 0; j < chunk->length(); ++j ) + { + if ( !chunk->IsNull( j ) ) + { + result.push_back( chunk->Value( j ).data() ); + } + } + } + + return result; +} diff --git a/ApplicationLibCode/FileInterface/RifArrowTools.h b/ApplicationLibCode/FileInterface/RifArrowTools.h index 6778d26cbc..afc554d3c1 100644 --- a/ApplicationLibCode/FileInterface/RifArrowTools.h +++ b/ApplicationLibCode/FileInterface/RifArrowTools.h @@ -19,7 +19,9 @@ #pragma once #undef signals +#include #include + #define signals Q_SIGNALS #include @@ -67,5 +69,8 @@ std::vector chunkedArrayToVector( const std::shared_ptr chunkedArrayToStringVector( const std::shared_ptr& chunkedArray ); + QString readFirstRowsOfTable( const QByteArray& contents ); + }; // namespace RifArrowTools diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp index 59ffa409b2..1f4811dc24 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp @@ -32,6 +32,8 @@ #include "RimSummaryCaseSumo.h" #include "RimSummarySumoDataSource.h" +#include + CAF_PDM_SOURCE_INIT( RimSummaryEnsembleSumo, "RimSummaryEnsembleSumo" ); //-------------------------------------------------------------------------------------------------- @@ -347,8 +349,9 @@ void RimSummaryEnsembleSumo::distributeParametersDataToRealizations( std::shared } } - std::map> doubleValuesForRealizations; - std::map> intValuesForRealizations; + std::map> doubleValuesForRealizations; + std::map> intValuesForRealizations; + std::map> stringValuesForRealizations; for ( std::string columnName : table->ColumnNames() ) { if ( columnName != "REAL" ) @@ -367,6 +370,11 @@ void RimSummaryEnsembleSumo::distributeParametersDataToRealizations( std::shared std::vector values = RifArrowTools::chunkedArrayToVector( column ); intValuesForRealizations[columnName] = values; } + else if ( column->type()->id() == arrow::Type::STRING ) + { + std::vector values = RifArrowTools::chunkedArrayToStringVector( column ); + stringValuesForRealizations[columnName] = values; + } } else { @@ -416,6 +424,11 @@ void RimSummaryEnsembleSumo::distributeParametersDataToRealizations( std::shared double value = it->second[realizationNumber]; parameters->addParameter( QString::fromStdString( columnName ), value ); } + else if ( auto it = stringValuesForRealizations.find( columnName ); it != stringValuesForRealizations.end() ) + { + QString value = QString::fromStdString( it->second[realizationNumber] ); + parameters->addParameter( QString::fromStdString( columnName ), value ); + } } } From 0518e594cee79a6faa69f3047759c3032051b99c Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 26 Aug 2024 19:21:24 +0200 Subject: [PATCH 257/332] Improve caching. --- .../Tools/Cloud/RiaSumoConnector.cpp | 10 ++++-- .../Tools/Cloud/RiaSumoConnector.h | 2 +- .../Summary/Sumo/RimSummaryEnsembleSumo.cpp | 31 +++++++++---------- .../Summary/Sumo/RimSummaryEnsembleSumo.h | 4 ++- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index 96de04bc7b..278d5ba6af 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -440,7 +440,7 @@ void RiaSumoConnector::requestParametersBlobIdForEnsemble( const SumoCaseId& cas { if ( reply->error() == QNetworkReply::NoError ) { - parseBlobIds( reply, caseId, ensembleName, "" ); + parseBlobIds( reply, caseId, ensembleName, "", true ); } else { @@ -493,7 +493,7 @@ void RiaSumoConnector::requestBlobIdForEnsemble( const SumoCaseId& caseId, const { if ( reply->error() == QNetworkReply::NoError ) { - parseBlobIds( reply, caseId, ensembleName, vectorName ); + parseBlobIds( reply, caseId, ensembleName, vectorName, false ); } } ); } @@ -862,7 +862,11 @@ void RiaSumoConnector::parseRealizationNumbers( QNetworkReply* reply, const Sumo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSumoConnector::parseBlobIds( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ) +void RiaSumoConnector::parseBlobIds( QNetworkReply* reply, + const SumoCaseId& caseId, + const QString& ensembleName, + const QString& vectorName, + bool isParameters ) { QByteArray result = reply->readAll(); reply->deleteLater(); diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h index 6887f322fd..e7e3cf7353 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h @@ -119,7 +119,7 @@ public slots: void parseCases( QNetworkReply* reply ); void parseVectorNames( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName ); void parseRealizationNumbers( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName ); - void parseBlobIds( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName ); + void parseBlobIds( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName, bool isParameters ); void requestFailed( const QAbstractOAuth::Error error ); void parquetDownloadComplete( const QString& blobId, const QByteArray&, const QString& url ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp index 1f4811dc24..d3a7b6e605 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp @@ -117,29 +117,28 @@ void RimSummaryEnsembleSumo::loadSummaryData( const RifEclipseSummaryAddress& re auto sumoCaseId = m_sumoDataSource->caseId(); auto sumoEnsembleName = m_sumoDataSource->ensembleName(); - auto key = ParquetKey{ sumoCaseId, sumoEnsembleName, resultText }; - + auto key = ParquetKey{ sumoCaseId, sumoEnsembleName, resultText, false }; if ( m_parquetTable.find( key ) == m_parquetTable.end() ) { - { - auto contents = loadParquetData( key ); - RiaLogging::debug( QString( "Load Summary Data. Contents size: %1" ).arg( contents.size() ) ); + auto contents = loadParquetData( key ); + RiaLogging::debug( QString( "Load Summary Data. Contents size: %1" ).arg( contents.size() ) ); - std::shared_ptr table = readParquetTable( contents, QString::fromStdString( resultAddress.uiText() ) ); - m_parquetTable[key] = table; + std::shared_ptr table = readParquetTable( contents, QString::fromStdString( resultAddress.uiText() ) ); + m_parquetTable[key] = table; - distributeDataToRealizations( resultAddress, table ); - } + distributeDataToRealizations( resultAddress, table ); + } - { - auto contents = m_sumoConnector->requestParametersParquetDataBlocking( sumoCaseId, sumoEnsembleName ); - RiaLogging::debug( QString( "Load ensemble parameter sensitivities. Contents size: %1" ).arg( contents.size() ) ); + auto parametersKey = ParquetKey{ sumoCaseId, sumoEnsembleName, "", true }; + if ( m_parquetTable.find( parametersKey ) == m_parquetTable.end() ) + { + auto contents = m_sumoConnector->requestParametersParquetDataBlocking( sumoCaseId, sumoEnsembleName ); + RiaLogging::debug( QString( "Load ensemble parameter sensitivities. Contents size: %1" ).arg( contents.size() ) ); - std::shared_ptr table = - readParquetTable( contents, QString::fromStdString( resultAddress.uiText() + " parameter sensitivities" ) ); + std::shared_ptr table = readParquetTable( contents, QString( "%1 parameter sensitivities" ).arg( sumoEnsembleName ) ); + m_parquetTable[parametersKey] = table; - distributeParametersDataToRealizations( table ); - } + distributeParametersDataToRealizations( table ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h index f7dfbfe072..1cd828cda4 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.h @@ -39,10 +39,12 @@ struct ParquetKey SumoCaseId caseId; QString ensembleId; QString vectorName; + bool isSensitivityParameters; auto operator<=>( const ParquetKey& other ) const { - return std::tie( caseId, ensembleId, vectorName ) <=> std::tie( other.caseId, other.ensembleId, other.vectorName ); + return std::tie( caseId, ensembleId, vectorName, isSensitivityParameters ) <=> + std::tie( other.caseId, other.ensembleId, other.vectorName, other.isSensitivityParameters ); } }; From a89fe80de3437d0e34522eb87ddd6af576e409fd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Aug 2024 18:55:59 +0200 Subject: [PATCH 258/332] Use sliders to manipulate surface plane extent --- .../RicNewDepthSurfaceFeature.cpp | 4 +- .../Surfaces/RimDepthSurface.cpp | 42 +++++++++++++++++-- .../Surfaces/RimDepthSurface.h | 4 ++ 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp b/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp index fe51440dc5..47ac3f718b 100644 --- a/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp +++ b/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp @@ -54,9 +54,7 @@ void RicNewDepthSurfaceFeature::onActionTriggered( bool isChecked ) bb.expand( 0.1 * bb.extent().z() ); - auto lowerDepthLimit = -bb.max().z(); - auto upperDepthLimit = -bb.min().z(); - surface->setDepthSliderLimits( lowerDepthLimit, upperDepthLimit ); + surface->setAreaOfInterest( bb.min(), bb.max() ); } surface->loadDataIfRequired(); diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp index 18f6678fed..cfb0778c0c 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp @@ -48,11 +48,14 @@ RimDepthSurface::RimDepthSurface() CAF_PDM_InitField( &m_depthUpperLimit, "DepthUpperLimit", 100000.0, "Upper Limit" ); m_depthUpperLimit.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - m_minX.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - m_maxX.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - m_minY.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - m_maxY.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); + m_minX.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + m_maxX.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + m_minY.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + m_maxY.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); m_depth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_areaOfInterestMin, "AreaOfInterestMin", "Area Of Interest Min" ); + CAF_PDM_InitFieldNoDefault( &m_areaOfInterestMax, "AreaOfInterestMax", "Area Of Interest Max" ); } //-------------------------------------------------------------------------------------------------- @@ -106,6 +109,19 @@ void RimDepthSurface::setDepthSliderLimits( double lower, double upper ) m_depthUpperLimit = upper; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDepthSurface::setAreaOfInterest( cvf::Vec3d min, cvf::Vec3d max ) +{ + m_areaOfInterestMin = min; + m_areaOfInterestMax = max; + + auto lowerDepthLimit = -max.z(); + auto upperDepthLimit = -min.z(); + setDepthSliderLimits( lowerDepthLimit, upperDepthLimit ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -135,6 +151,24 @@ void RimDepthSurface::defineEditorAttribute( const caf::PdmFieldHandle* field, Q attr->m_maximum = m_depthUpperLimit; } } + + if ( field == &m_minX || field == &m_maxX ) + { + if ( auto attr = dynamic_cast( attribute ) ) + { + attr->m_minimum = m_areaOfInterestMin().x(); + attr->m_maximum = m_areaOfInterestMax().x(); + } + } + + if ( field == &m_minY || field == &m_maxY ) + { + if ( auto attr = dynamic_cast( attribute ) ) + { + attr->m_minimum = m_areaOfInterestMin().y(); + attr->m_maximum = m_areaOfInterestMax().y(); + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h index ac30150dd5..7b100ceead 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h @@ -34,6 +34,7 @@ class RimDepthSurface : public RimSurface void setPlaneExtent( double minX, double minY, double maxX, double maxY ); void setDepth( double depth ); void setDepthSliderLimits( double lower, double upper ); + void setAreaOfInterest( cvf::Vec3d min, cvf::Vec3d max ); private: bool updateSurfaceData() override; @@ -54,6 +55,9 @@ class RimDepthSurface : public RimSurface caf::PdmField m_depthLowerLimit; caf::PdmField m_depthUpperLimit; + caf::PdmField m_areaOfInterestMin; + caf::PdmField m_areaOfInterestMax; + std::vector m_triangleIndices; std::vector m_vertices; }; From 0fd27a3a8d8f60273cbffc829860fb33589e1918 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 26 Aug 2024 13:51:26 +0200 Subject: [PATCH 259/332] Add [BETA] as postfix to user interface Add postfix to SUMO and OSDU cloud import features. --- ApplicationLibCode/Application/RiaDefines.cpp | 8 ++++++++ ApplicationLibCode/Application/RiaDefines.h | 2 ++ .../OsduImportCommands/RicWellPathsImportOsduFeature.cpp | 5 +++-- .../Commands/RicImportWellLogOsduFeature.cpp | 3 ++- .../Commands/Sumo/RicCreateSumoEnsembleFeature.cpp | 3 ++- .../ProjectDataModel/RimContextCommandBuilder.cpp | 7 ++++++- 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ApplicationLibCode/Application/RiaDefines.cpp b/ApplicationLibCode/Application/RiaDefines.cpp index 82640c21d0..ec48f9dcdc 100644 --- a/ApplicationLibCode/Application/RiaDefines.cpp +++ b/ApplicationLibCode/Application/RiaDefines.cpp @@ -374,3 +374,11 @@ std::vector RiaDefines::viewScaleOptions() { return { 0.005, 0.01, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 50.0 }; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::betaFeaturePostfix() +{ + return " [BETA]"; +} diff --git a/ApplicationLibCode/Application/RiaDefines.h b/ApplicationLibCode/Application/RiaDefines.h index 95ae5705ea..1bcd51c4f3 100644 --- a/ApplicationLibCode/Application/RiaDefines.h +++ b/ApplicationLibCode/Application/RiaDefines.h @@ -252,6 +252,8 @@ enum class ItemIn3dView ALL = 0b00000011 }; +QString betaFeaturePostfix(); + }; // namespace RiaDefines // Activate bit mask operators at global scope diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index 03ae6290dd..58854cd9da 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -21,6 +21,7 @@ #include "Cloud/RiaOsduConnector.h" #include "RiaApplication.h" #include "RiaColorTables.h" +#include "RiaDefines.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" #include "RiaPreferences.h" @@ -82,7 +83,7 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) caf::ProgressInfo progress( importedWells.size(), "Importing wells from OSDU", false, true ); int colorIndex = 0; std::vector newWells; - for ( auto w : importedWells ) + for ( const auto& w : importedWells ) { auto wellPath = new RimOsduWellPath; wellPath->setName( w.name ); @@ -118,6 +119,6 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicWellPathsImportOsduFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "Import Well Paths from &OSDU" ); + actionToSetup->setText( "Import Well Paths from &OSDU" + RiaDefines::betaFeaturePostfix() ); actionToSetup->setIcon( QIcon( ":/WellCollection.png" ) ); } diff --git a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp index a0b2c0f111..183329b25d 100644 --- a/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportWellLogOsduFeature.cpp @@ -19,6 +19,7 @@ #include "RicImportWellLogOsduFeature.h" #include "Cloud/RiaOsduConnector.h" +#include "RiaDefines.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" #include "RiaPreferences.h" @@ -118,5 +119,5 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked ) void RicImportWellLogOsduFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setIcon( QIcon( ":/LasFile16x16.png" ) ); - actionToSetup->setText( "Import Well Log From OSDU" ); + actionToSetup->setText( "Import Well Log From OSDU" + RiaDefines::betaFeaturePostfix() ); } diff --git a/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp b/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp index 957cda5e7e..26a4e8d235 100644 --- a/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp +++ b/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp @@ -18,6 +18,7 @@ #include "RicCreateSumoEnsembleFeature.h" +#include "RiaDefines.h" #include "RiaSummaryTools.h" #include "PlotBuilderCommands/RicSummaryPlotBuilder.h" @@ -57,6 +58,6 @@ void RicCreateSumoEnsembleFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicCreateSumoEnsembleFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "Create Sumo Ensemble" ); + actionToSetup->setText( "Create Sumo Ensemble" + RiaDefines::betaFeaturePostfix() ); actionToSetup->setIcon( QIcon( ":/SummaryEnsemble.svg" ) ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index c706f9f0e3..5323aaf512 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -1475,7 +1475,12 @@ int RimContextCommandBuilder::appendImportMenu( caf::CmdFeatureMenuBuilder& menu candidates << "RicImportWellLogCsvFileFeature"; candidates << "RicReloadWellPathFormationNamesFeature"; - if ( addOsduImportMenuItem ) candidates << "RicImportWellLogOsduFeature"; + // Import of well logs from OSDU is disabled by default. The quality of well log data from OSDU is not sufficient for effective + // use. The environment variable RESINSIGHT_DEVEL must be set to enable this feature. + if ( addOsduImportMenuItem && RiaApplication::enableDevelopmentFeatures() ) + { + candidates << "RicImportWellLogOsduFeature"; + } return appendSubMenuWithCommands( menuBuilder, candidates, "Import", QIcon(), addSeparatorBeforeMenu ); } From 64a559756f66118d549aa057d93f28dd03f3bd5e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 27 Aug 2024 09:48:21 +0200 Subject: [PATCH 260/332] Improve visual appearance for depth surface - disable intersection geometry with cell property colors - allow opacity - set default color to blue, as most user use this plane for oil-water contact --- .../RicNewDepthSurfaceFeature.cpp | 4 ++ .../Surfaces/RivSurfacePartMgr.cpp | 27 ++++++++++-- .../Surfaces/RimDepthSurface.cpp | 14 +++++++ .../Surfaces/RimDepthSurface.h | 4 ++ .../ProjectDataModel/Surfaces/RimSurface.cpp | 41 +++++++++++++++++++ .../ProjectDataModel/Surfaces/RimSurface.h | 10 ++++- .../WellPath/RimWellPathTarget.h | 1 - 7 files changed, 96 insertions(+), 5 deletions(-) diff --git a/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp b/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp index 47ac3f718b..77d0f0e66a 100644 --- a/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp +++ b/ApplicationLibCode/Commands/SurfaceCommands/RicNewDepthSurfaceFeature.cpp @@ -44,6 +44,10 @@ void RicNewDepthSurfaceFeature::onActionTriggered( bool isChecked ) auto surface = new RimDepthSurface; + // As this surface is usually a oil-water contact, we set the color to blue + surface->setColor( cvf::Color3f::BLUE ); + surface->setOpacity( true, 0.6f ); + auto allCases = RimProject::current()->allGridCases(); if ( !allCases.empty() ) { diff --git a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp index 42d72709e2..c614c7ef90 100644 --- a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp @@ -43,6 +43,7 @@ #include "cvfModelBasicList.h" #include "cvfPart.h" #include "cvfPrimitiveSetIndexedUInt.h" +#include "cvfRenderStateBlending.h" #include @@ -121,7 +122,8 @@ void RivSurfacePartMgr::updateCellResultColor( int timeStepIndex ) //-------------------------------------------------------------------------------------------------- void RivSurfacePartMgr::appendIntersectionGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ) { - if ( !m_surfaceInView->surfaceResultDefinition()->isChecked() ) + if ( m_surfaceInView->surface() && m_surfaceInView->surface()->showIntersectionCellResults() && + !m_surfaceInView->surfaceResultDefinition()->isChecked() ) { if ( m_intersectionFaces.isNull() ) { @@ -162,6 +164,9 @@ void RivSurfacePartMgr::appendIntersectionGeometryPartsToModel( cvf::ModelBasicL //-------------------------------------------------------------------------------------------------- void RivSurfacePartMgr::updateNativeSurfaceColors() { + const auto [opacityEnabled, surfaceOpacityValue] = m_surfaceInView->surface()->opacity(); + const auto opacityValueToUse = opacityEnabled ? surfaceOpacityValue : 1.0f; + if ( m_surfaceInView->surfaceResultDefinition()->isChecked() ) { if ( m_usedSurfaceData.isNull() ) generateNativePartGeometry(); @@ -199,19 +204,35 @@ void RivSurfacePartMgr::updateNativeSurfaceColors() } else { - caf::SurfaceEffectGenerator surfaceGenBehind( cvf::Color4f( m_surfaceInView->surface()->color() ), caf::PO_POS_LARGE ); + const auto color = cvf::Color4f( m_surfaceInView->surface()->color(), opacityValueToUse ); + caf::SurfaceEffectGenerator surfaceGenBehind( color, caf::PO_POS_LARGE ); cvf::ref effBehind = surfaceGenBehind.generateCachedEffect(); if ( m_nativeTrianglesPart.notNull() ) { + if ( opacityEnabled ) + { + m_nativeTrianglesPart->setPriority( RivPartPriority::PartType::Transparent ); + cvf::ref blending = new cvf::RenderStateBlending; + blending->configureTransparencyBlending(); + effBehind->setRenderState( blending.p() ); + } + m_nativeTrianglesPart->setEffect( effBehind.p() ); } } if ( m_intersectionFaces.notNull() ) { - caf::SurfaceEffectGenerator surfaceGen( cvf::Color4f( m_surfaceInView->surface()->color() ), caf::PO_1 ); + caf::SurfaceEffectGenerator surfaceGen( cvf::Color4f( m_surfaceInView->surface()->color(), opacityValueToUse ), caf::PO_1 ); cvf::ref eff = surfaceGen.generateCachedEffect(); + if ( opacityEnabled ) + { + m_intersectionFaces->setPriority( RivPartPriority::PartType::Transparent ); + cvf::ref blending = new cvf::RenderStateBlending; + blending->configureTransparencyBlending(); + eff->setRenderState( blending.p() ); + } m_intersectionFaces->setEffect( eff.p() ); } diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp index cfb0778c0c..95d33567d5 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.cpp @@ -81,6 +81,15 @@ RimSurface* RimDepthSurface::createCopy() return copyObject(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimDepthSurface::showIntersectionCellResults() +{ + // Avoid use of cell intersection results color for depth surfaces + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -141,6 +150,8 @@ void RimDepthSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedField, //-------------------------------------------------------------------------------------------------- void RimDepthSurface::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { + RimSurface::defineEditorAttribute( field, uiConfigName, attribute ); + caf::PdmUiDoubleValueEditorAttribute::testAndSetFixedWithTwoDecimals( attribute ); if ( field == &m_depth ) @@ -199,6 +210,9 @@ void RimDepthSurface::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering auto group = uiOrdering.addNewGroup( "Appearance" ); group->add( &m_userDescription ); group->add( &m_color ); + + group->add( &m_enableOpacity ); + group->add( &m_opacity ); } uiOrdering.skipRemainingFields(); diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h index 7b100ceead..e3ac532115 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimDepthSurface.h @@ -20,6 +20,8 @@ #include "RimSurface.h" +#include "cafPdmCoreVec3d.h" + class RimDepthSurface : public RimSurface { CAF_PDM_HEADER_INIT; @@ -31,6 +33,8 @@ class RimDepthSurface : public RimSurface bool onLoadData() override; RimSurface* createCopy() override; + bool showIntersectionCellResults() override; + void setPlaneExtent( double minX, double minY, double maxX, double maxY ); void setDepth( double depth ); void setDepthSliderLimits( double lower, double upper ); diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.cpp index 4b4046ce90..d6bc2bcabd 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.cpp @@ -56,7 +56,11 @@ RimSurface::RimSurface() CAF_PDM_InitScriptableObject( "Surface", ":/ReservoirSurface16x16.png" ); CAF_PDM_InitScriptableFieldNoDefault( &m_userDescription, "SurfaceUserDecription", "Name" ); + CAF_PDM_InitField( &m_color, "SurfaceColor", cvf::Color3f( 0.5f, 0.3f, 0.2f ), "Color" ); + CAF_PDM_InitField( &m_enableOpacity, "EnableOpacity", false, "Enable Opacity" ); + CAF_PDM_InitField( &m_opacity, "Opacity", 0.6, "Opacity Value [0..1]" ); + m_opacity.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); CAF_PDM_InitScriptableField( &m_depthOffset, "DepthOffset", 0.0, "Depth Offset" ); m_depthOffset.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); @@ -94,6 +98,31 @@ cvf::Color3f RimSurface::color() const return m_color(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimSurface::opacity() const +{ + return std::make_pair( m_enableOpacity(), m_opacity() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSurface::setOpacity( bool useOpacity, float opacity ) +{ + m_enableOpacity.setValue( useOpacity ); + m_opacity.setValue( opacity ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSurface::showIntersectionCellResults() +{ + return true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -162,6 +191,9 @@ double RimSurface::depthOffset() const return m_depthOffset; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- void RimSurface::setDepthOffset( double depthoffset ) { m_depthOffset.setValue( depthoffset ); @@ -273,4 +305,13 @@ void RimSurface::defineEditorAttribute( const caf::PdmFieldHandle* field, QStrin doubleSliderAttrib->m_maximum = minimumExtent; } } + + if ( field == &m_opacity ) + { + if ( auto attr = dynamic_cast( attribute ) ) + { + attr->m_minimum = 0.0; + attr->m_maximum = 1.0; + } + } } diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.h index 64e433769f..1177f402cf 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.h @@ -51,6 +51,11 @@ class RimSurface : public caf::PdmObject void setColor( const cvf::Color3f& color ); cvf::Color3f color() const; + std::pair opacity() const; + void setOpacity( bool useOpacity, float opacity ); + + virtual bool showIntersectionCellResults(); + RigSurface* surfaceData(); QString userDescription(); void setUserDescription( const QString& description ); @@ -80,8 +85,11 @@ class RimSurface : public caf::PdmObject virtual void clearCachedNativeData() = 0; protected: - caf::PdmField m_userDescription; + caf::PdmField m_userDescription; + caf::PdmField m_color; + caf::PdmField m_enableOpacity; + caf::PdmField m_opacity; cvf::ref m_surfaceData; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.h index cfe4523eff..23079ed4b1 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.h @@ -26,7 +26,6 @@ #include "cafPdmField.h" #include "cafPdmProxyValueField.h" #include "cafPdmPtrField.h" -#include "cvfVector3.h" class RimWellPathGeometryDef; From 27c46a65fde131b36fd6bc95113a6bcf6fb9e4b2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 28 Aug 2024 15:23:07 +0200 Subject: [PATCH 261/332] Improve user control on resampling operations Allow user to specify Accumulated or Rate for a summary curve. Default setting is Auto, and summary address is used to derive Accumulated/Rate. User can set curve type explicitly. --- .../Application/RiaSummaryDefines.cpp | 9 ++ .../Application/RiaSummaryDefines.h | 6 ++ .../Application/Tools/RiaSummaryTools.cpp | 27 ++++-- .../Application/Tools/RiaSummaryTools.h | 17 +++- .../RifEclipseSummaryAddressDefines.cpp | 9 ++ .../RifEclipseSummaryAddressDefines.h | 6 ++ .../Summary/RimSummaryCurve.cpp | 58 +++++++++--- .../Summary/RimSummaryCurve.h | 8 ++ .../Summary/RimSummaryCurvesData.cpp | 37 ++++---- .../Summary/RimSummaryCurvesData.h | 8 +- .../Summary/RimSummaryDeclineCurve.cpp | 89 ++++++++----------- .../Summary/RimSummaryDeclineCurve.h | 21 +++-- 12 files changed, 190 insertions(+), 105 deletions(-) diff --git a/ApplicationLibCode/Application/RiaSummaryDefines.cpp b/ApplicationLibCode/Application/RiaSummaryDefines.cpp index 26fff23313..3ef5bac537 100644 --- a/ApplicationLibCode/Application/RiaSummaryDefines.cpp +++ b/ApplicationLibCode/Application/RiaSummaryDefines.cpp @@ -28,6 +28,15 @@ void caf::AppEnum::setUp() addItem( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR, "SUMMARY_VECTOR", "Summary Vector" ); setDefault( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR ); } + +template <> +void caf::AppEnum::setUp() +{ + addItem( RiaDefines::SummaryCurveTypeMode::AUTO, "AUTO", "Auto" ); + addItem( RiaDefines::SummaryCurveTypeMode::CUSTOM, "CUSTOM", "Custom" ); + setDefault( RiaDefines::SummaryCurveTypeMode::AUTO ); +} + } // namespace caf //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaSummaryDefines.h b/ApplicationLibCode/Application/RiaSummaryDefines.h index cdc26b3854..eeff79fe40 100644 --- a/ApplicationLibCode/Application/RiaSummaryDefines.h +++ b/ApplicationLibCode/Application/RiaSummaryDefines.h @@ -35,6 +35,12 @@ enum class HorizontalAxisType SUMMARY_VECTOR }; +enum class SummaryCurveTypeMode +{ + AUTO, + CUSTOM +}; + QString summaryField(); QString summaryAquifer(); QString summaryNetwork(); diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp b/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp index 699fae29b7..d6081ba623 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp @@ -175,7 +175,7 @@ RimSummaryTableCollection* RiaSummaryTools::parentSummaryTableCollection( caf::P //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiaSummaryTools::hasAccumulatedData( const RifEclipseSummaryAddress& address ) +RifEclipseSummaryAddressDefines::CurveType RiaSummaryTools::identifyCurveType( const RifEclipseSummaryAddress& address ) { if ( address.isCalculated() ) { @@ -187,15 +187,16 @@ bool RiaSummaryTools::hasAccumulatedData( const RifEclipseSummaryAddress& addres { if ( !variableAddress.hasAccumulatedData() ) { - return false; + return RifEclipseSummaryAddressDefines::CurveType::RATE; } } // All the variables are accumulated - return true; + return RifEclipseSummaryAddressDefines::CurveType::ACCUMULATED; } - return address.hasAccumulatedData(); + return address.hasAccumulatedData() ? RifEclipseSummaryAddressDefines::CurveType::ACCUMULATED + : RifEclipseSummaryAddressDefines::CurveType::RATE; } //-------------------------------------------------------------------------------------------------- @@ -231,11 +232,27 @@ std::pair, std::vector> RiaSummaryTools::resampledVa const std::vector& timeSteps, const std::vector& values, RiaDefines::DateTimePeriod period ) +{ + // NB! The curve type can be overridden by the user, so there might be a discrepancy between the curve type and the curve type derived + // from the address + // See RimSummaryCurve::curveType() + + return resampledValuesForPeriod( RiaSummaryTools::identifyCurveType( address ), timeSteps, values, period ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair, std::vector> + RiaSummaryTools::resampledValuesForPeriod( RifEclipseSummaryAddressDefines::CurveType accumulatedOrRate, + const std::vector& timeSteps, + const std::vector& values, + RiaDefines::DateTimePeriod period ) { RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( values, timeSteps ); - if ( RiaSummaryTools::hasAccumulatedData( address ) ) + if ( accumulatedOrRate == CurveType::ACCUMULATED ) { resampler.resampleAndComputePeriodEndValues( period ); } diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h index e210015408..b97b8a52c0 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h +++ b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h @@ -19,6 +19,9 @@ #pragma once #include "RiaDateTimeDefines.h" + +#include "RifEclipseSummaryAddressDefines.h" + #include "RimObservedDataCollection.h" #include @@ -66,16 +69,22 @@ class RiaSummaryTools static RimSummaryTable* parentSummaryTable( caf::PdmObject* object ); static RimSummaryTableCollection* parentSummaryTableCollection( caf::PdmObject* object ); - static bool hasAccumulatedData( const RifEclipseSummaryAddress& address ); - static void getSummaryCasesAndAddressesForCalculation( int id, - std::vector& cases, - std::vector& addresses ); + static RifEclipseSummaryAddressDefines::CurveType identifyCurveType( const RifEclipseSummaryAddress& address ); + static void getSummaryCasesAndAddressesForCalculation( int id, + std::vector& cases, + std::vector& addresses ); static std::pair, std::vector> resampledValuesForPeriod( const RifEclipseSummaryAddress& address, const std::vector& timeSteps, const std::vector& values, RiaDefines::DateTimePeriod period ); + static std::pair, std::vector> + resampledValuesForPeriod( RifEclipseSummaryAddressDefines::CurveType accumulatedOrRate, + const std::vector& timeSteps, + const std::vector& values, + RiaDefines::DateTimePeriod period ); + static RimSummaryCase* summaryCaseById( int caseId ); static RimSummaryEnsemble* ensembleById( int ensembleId ); diff --git a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddressDefines.cpp b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddressDefines.cpp index df4a459575..339c47a1a0 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddressDefines.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddressDefines.cpp @@ -32,6 +32,15 @@ void caf::AppEnum::setUp() addItem( RifEclipseSummaryAddressDefines::StatisticsType::MEAN, "MEAN", "Mean" ); setDefault( RifEclipseSummaryAddressDefines::StatisticsType::NONE ); } + +template <> +void caf::AppEnum::setUp() +{ + addItem( RifEclipseSummaryAddressDefines::CurveType::RATE, "RATE", "Rate" ); + addItem( RifEclipseSummaryAddressDefines::CurveType::ACCUMULATED, "ACCUMULATED", "Accumulated" ); + setDefault( RifEclipseSummaryAddressDefines::CurveType::ACCUMULATED ); +} + } // namespace caf //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddressDefines.h b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddressDefines.h index 7eff78ef04..c79ddcb240 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddressDefines.h +++ b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddressDefines.h @@ -73,6 +73,12 @@ enum class StatisticsType MEAN }; +enum class CurveType +{ + ACCUMULATED, + RATE +}; + std::string statisticsNameP10(); std::string statisticsNameP50(); std::string statisticsNameP90(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 2012c41db1..a67bb77046 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -87,6 +87,9 @@ RimSummaryCurve::RimSummaryCurve() CAF_PDM_InitFieldNoDefault( &m_yValuesResampling, "Resampling", "Resampling" ); + CAF_PDM_InitFieldNoDefault( &m_yCurveTypeMode, "CurveTypeMode", "Curve Type" ); + CAF_PDM_InitFieldNoDefault( &m_yCurveType, "CurveType", "" ); + // X Values CAF_PDM_InitField( &m_xAxisType, @@ -419,6 +422,14 @@ void RimSummaryCurve::setOverrideCurveDataY( const std::vector& dateTime setSamplesFromTimeTAndYValues( dateTimes, yValues, true ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEclipseSummaryAddressDefines::CurveType RimSummaryCurve::curveType() const +{ + return m_yCurveType(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -899,9 +910,15 @@ void RimSummaryCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering curveDataGroup->add( &m_yValuesSummaryCase, { .newRow = true, .totalColumnSpan = 3, .leftLabelColumnSpan = 1 } ); curveDataGroup->add( &m_yValuesSummaryAddressUiField, { .newRow = true, .totalColumnSpan = 2, .leftLabelColumnSpan = 1 } ); curveDataGroup->add( &m_yPushButtonSelectSummaryAddress, { .newRow = false, .totalColumnSpan = 1, .leftLabelColumnSpan = 0 } ); - curveDataGroup->add( &m_yValuesResampling, { .newRow = true, .totalColumnSpan = 3, .leftLabelColumnSpan = 1 } ); curveDataGroup->add( &m_yPlotAxisProperties, { .newRow = true, .totalColumnSpan = 3, .leftLabelColumnSpan = 1 } ); - curveDataGroup->add( &m_showErrorBars ); + + caf::PdmUiGroup* detailGroup = curveDataGroup->addNewGroup( "Advanced Properties" ); + detailGroup->setCollapsedByDefault(); + detailGroup->add( &m_yValuesResampling ); + detailGroup->add( &m_showErrorBars ); + detailGroup->add( &m_yCurveTypeMode ); + detailGroup->add( &m_yCurveType ); + m_yCurveType.uiCapability()->setUiReadOnly( m_yCurveTypeMode() == RiaDefines::SummaryCurveTypeMode::AUTO ); } if ( m_showXAxisGroup ) @@ -1251,6 +1268,10 @@ void RimSummaryCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, m_xPushButtonSelectSummaryAddress = false; } + else if ( changedField == &m_yCurveTypeMode ) + { + calculateCurveTypeFromAddress(); + } if ( crossPlotTestForMatchingTimeSteps ) { @@ -1369,17 +1390,30 @@ std::vector RimSummaryCurve::timeStepsX() const //-------------------------------------------------------------------------------------------------- void RimSummaryCurve::calculateCurveInterpolationFromAddress() { - if ( m_yValuesSummaryAddress() ) + if ( !m_yValuesSummaryAddress() ) return; + + calculateCurveTypeFromAddress(); + + if ( curveType() == RifEclipseSummaryAddressDefines::CurveType::ACCUMULATED ) { - auto address = m_yValuesSummaryAddress()->address(); - if ( RiaSummaryTools::hasAccumulatedData( address ) ) - { - m_curveAppearance->setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationEnum::INTERPOLATION_POINT_TO_POINT ); - } - else - { - m_curveAppearance->setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationEnum::INTERPOLATION_STEP_LEFT ); - } + m_curveAppearance->setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationEnum::INTERPOLATION_POINT_TO_POINT ); + } + else + { + m_curveAppearance->setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationEnum::INTERPOLATION_STEP_LEFT ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurve::calculateCurveTypeFromAddress() +{ + if ( !m_yValuesSummaryAddress() ) return; + + if ( m_yCurveTypeMode() == RiaDefines::SummaryCurveTypeMode::AUTO ) + { + m_yCurveType = RiaSummaryTools::identifyCurveType( m_yValuesSummaryAddress()->address() ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h index 9e9dc33acd..4dd28e7b32 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h @@ -29,7 +29,9 @@ #include "RiaSummaryCurveAddress.h" #include "RiaSummaryDefines.h" +#include "RifEclipseSummaryAddressDefines.h" #include "RifEclipseSummaryAddressQMetaType.h" + #include "RimStackablePlotCurve.h" #include "cafAppEnum.h" @@ -76,6 +78,8 @@ class RimSummaryCurve : public RimStackablePlotCurve double yValueAtTimeT( time_t time ) const; void setOverrideCurveDataY( const std::vector& xValues, const std::vector& yValues ); + RifEclipseSummaryAddressDefines::CurveType curveType() const; + // X Axis functions void setAxisTypeX( RiaDefines::HorizontalAxisType axisType ); RiaDefines::HorizontalAxisType axisTypeX() const; @@ -140,6 +144,7 @@ class RimSummaryCurve : public RimStackablePlotCurve RifSummaryReaderInterface* valuesSummaryReaderY() const; void calculateCurveInterpolationFromAddress(); + void calculateCurveTypeFromAddress(); static void appendOptionItemsForSummaryAddresses( QList* options, RimSummaryCase* summaryCase ); @@ -152,6 +157,9 @@ class RimSummaryCurve : public RimStackablePlotCurve caf::PdmPtrField m_yPlotAxisProperties; caf::PdmField m_yValuesResampling; + caf::PdmField> m_yCurveTypeMode; + caf::PdmField> m_yCurveType; + // X values caf::PdmField> m_xAxisType; caf::PdmPtrField m_xValuesSummaryCase; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp index b831a2ba0b..75a465542e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp @@ -49,7 +49,7 @@ void RimSummaryCurvesData::populateTimeHistoryCurvesData( std::vectorisChecked() ) continue; QString curveCaseName = curve->caseName(); - CurveData curveData = { curve->curveExportDescription( {} ), RifEclipseSummaryAddress(), curve->yValues() }; + CurveData curveData = { curve->curveExportDescription( {} ), RifEclipseSummaryAddressDefines::CurveType::ACCUMULATED, curve->yValues() }; curvesData->addCurveData( curveCaseName, "", curve->timeStepValues(), curveData ); } @@ -68,7 +68,7 @@ void RimSummaryCurvesData::populateAsciiDataCurvesData( std::vectorisChecked() ) continue; - CurveData curveData = { curve->curveExportDescription( {} ), RifEclipseSummaryAddress(), curve->yValues() }; + CurveData curveData = { curve->curveExportDescription( {} ), RifEclipseSummaryAddressDefines::CurveType::ACCUMULATED, curve->yValues() }; curvesData->addCurveDataNoSearch( "", "", curve->timeSteps(), { curveData } ); } @@ -145,30 +145,25 @@ QString RimSummaryCurvesData::createTextForExport( const std::vector exportData( 2 ); - // Summary grid data for export - RimSummaryCurvesData::prepareCaseCurvesForExport( resamplingPeriod, ResampleAlgorithm::DATA_DECIDES, summaryCurvesGridData, &exportData[0] ); - - // Time history data for export - RimSummaryCurvesData::prepareCaseCurvesForExport( resamplingPeriod, ResampleAlgorithm::PERIOD_END, timeHistoryCurvesData, &exportData[1] ); + RimSummaryCurvesData::prepareCaseCurvesForExport( resamplingPeriod, ResampleAlgorithm::DATA_DECIDES, summaryCurvesData, &exportData[0] ); + RimSummaryCurvesData::prepareCaseCurvesForExport( resamplingPeriod, ResampleAlgorithm::PERIOD_END, gridCurvesData, &exportData[1] ); - // Export resampled summary and time history data RimSummaryCurvesData::appendToExportData( out, exportData, showTimeAsLongString ); - // Pasted observed data { + // Handle observed data pasted into plot from clipboard + RimSummaryCurvesData asciiCurvesData; RimSummaryCurvesData::populateAsciiDataCurvesData( asciiCurves, &asciiCurvesData ); @@ -239,7 +234,7 @@ void RimSummaryCurvesData::populateSummaryCurvesData( std::vectorisChecked() ) continue; if ( isObservedCurve && ( curveType != SummaryCurveType::CURVE_TYPE_OBSERVED ) ) continue; - if ( !isObservedCurve && ( curveType != SummaryCurveType::CURVE_TYPE_GRID ) ) continue; + if ( !isObservedCurve && ( curveType != SummaryCurveType::CURVE_TYPE_SUMMARY ) ) continue; if ( !curve->summaryCaseY() ) continue; QString curveCaseName = curve->summaryCaseY()->displayCaseName(); @@ -249,7 +244,7 @@ void RimSummaryCurvesData::populateSummaryCurvesData( std::vectorcurveDefinition().ensemble()->name(); } - CurveData curveData = { curve->curveExportDescription( {} ), curve->summaryAddressY(), curve->valuesY() }; + CurveData curveData = { curve->curveExportDescription( {} ), curve->curveType(), curve->valuesY() }; CurveData errorCurveData; // Error data @@ -258,9 +253,9 @@ void RimSummaryCurvesData::populateSummaryCurvesData( std::vectorcurveExportDescription( curve->errorSummaryAddressY() ); - errorCurveData.address = curve->errorSummaryAddressY(); - errorCurveData.values = errorValues; + errorCurveData.name = curve->curveExportDescription( curve->errorSummaryAddressY() ); + errorCurveData.curveType = curve->curveType(); + errorCurveData.values = errorValues; } auto curveDataList = std::vector( { curveData } ); @@ -307,7 +302,7 @@ void RimSummaryCurvesData::prepareCaseCurvesForExport( RiaDefines::DateTimePerio for ( auto& curveDataItem : caseCurveData ) { const auto [resampledTime, resampledValues] = - RiaSummaryTools::resampledValuesForPeriod( curveDataItem.address, caseTimeSteps, curveDataItem.values, period ); + RiaSummaryTools::resampledValuesForPeriod( curveDataItem.curveType, caseTimeSteps, curveDataItem.values, period ); auto cd = curveDataItem; cd.values = resampledValues; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.h index 4aa19cc99c..b7396d4cba 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.h @@ -29,14 +29,14 @@ class RimAsciiDataCurve; struct CurveData { - QString name; - RifEclipseSummaryAddress address; - std::vector values; + QString name; + RifEclipseSummaryAddressDefines::CurveType curveType; + std::vector values; }; enum class SummaryCurveType { - CURVE_TYPE_GRID = 0x1, + CURVE_TYPE_SUMMARY = 0x1, CURVE_TYPE_OBSERVED = 0x2 }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDeclineCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDeclineCurve.cpp index 4576cac93d..a2f3281494 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDeclineCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDeclineCurve.cpp @@ -86,11 +86,7 @@ std::vector RimSummaryDeclineCurve::valuesY() const { auto [minTimeStep, maxTimeStep] = selectedTimeStepRange(); - return createDeclineCurveValues( RimSummaryCurve::valuesY(), - RimSummaryCurve::timeStepsY(), - minTimeStep, - maxTimeStep, - RiaSummaryTools::hasAccumulatedData( summaryAddressY() ) ); + return createDeclineCurveValues( RimSummaryCurve::valuesY(), RimSummaryCurve::timeStepsY(), minTimeStep, maxTimeStep, curveType() ); } //-------------------------------------------------------------------------------------------------- @@ -100,11 +96,7 @@ std::vector RimSummaryDeclineCurve::valuesX() const { auto [minTimeStep, maxTimeStep] = selectedTimeStepRange(); - return createDeclineCurveValues( RimSummaryCurve::valuesX(), - RimSummaryCurve::timeStepsX(), - minTimeStep, - maxTimeStep, - RiaSummaryTools::hasAccumulatedData( summaryAddressX() ) ); + return createDeclineCurveValues( RimSummaryCurve::valuesX(), RimSummaryCurve::timeStepsX(), minTimeStep, maxTimeStep, curveType() ); } //-------------------------------------------------------------------------------------------------- @@ -134,11 +126,11 @@ std::vector RimSummaryDeclineCurve::timeStepsX() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryDeclineCurve::createDeclineCurveValues( const std::vector& values, - const std::vector& timeSteps, - time_t minTimeStep, - time_t maxTimeStep, - bool isAccumulatedResult ) const +std::vector RimSummaryDeclineCurve::createDeclineCurveValues( const std::vector& values, + const std::vector& timeSteps, + time_t minTimeStep, + time_t maxTimeStep, + RifEclipseSummaryAddressDefines::CurveType curveType ) const { if ( values.empty() || timeSteps.empty() ) return values; @@ -147,8 +139,7 @@ std::vector RimSummaryDeclineCurve::createDeclineCurveValues( const std: if ( timeStepsInRange.empty() || valuesInRange.empty() ) return values; - auto [initialProductionRate, initialDeclineRate] = - computeInitialProductionAndDeclineRate( valuesInRange, timeStepsInRange, isAccumulatedResult ); + auto [initialProductionRate, initialDeclineRate] = computeInitialProductionAndDeclineRate( valuesInRange, timeStepsInRange, curveType ); if ( std::isinf( initialProductionRate ) || std::isnan( initialProductionRate ) || std::isinf( initialDeclineRate ) || std::isnan( initialDeclineRate ) ) { @@ -162,8 +153,8 @@ std::vector RimSummaryDeclineCurve::createDeclineCurveValues( const std: for ( const QDateTime& futureTime : futureTimeSteps ) { double timeSinceStart = futureTime.toSecsSinceEpoch() - initialTime.toSecsSinceEpoch(); - double predictedValue = computePredictedValue( initialProductionRate, initialDeclineRate, timeSinceStart, isAccumulatedResult ); - if ( isAccumulatedResult ) predictedValue += valuesInRange.back(); + double predictedValue = computePredictedValue( initialProductionRate, initialDeclineRate, timeSinceStart, curveType ); + if ( curveType == RifEclipseSummaryAddressDefines::CurveType::ACCUMULATED ) predictedValue += valuesInRange.back(); outValues.push_back( predictedValue ); } @@ -175,13 +166,13 @@ std::vector RimSummaryDeclineCurve::createDeclineCurveValues( const std: //-------------------------------------------------------------------------------------------------- std::pair RimSummaryDeclineCurve::computeInitialProductionAndDeclineRate( const std::vector& values, const std::vector& timeSteps, - bool isAccumulatedResult ) + RifEclipseSummaryAddressDefines::CurveType curveType ) { CAF_ASSERT( values.size() == timeSteps.size() ); auto computeProductionRate = []( double t0, double v0, double t1, double v1 ) { return ( v1 - v0 ) / ( t1 - t0 ); }; - if ( !isAccumulatedResult ) + if ( curveType == RifEclipseSummaryAddressDefines::CurveType::RATE ) { // Use the first (time step, value) pair as t0 const size_t idx0 = 0; @@ -197,42 +188,40 @@ std::pair RimSummaryDeclineCurve::computeInitialProductionAndDec RigDeclineCurveCalculator::computeDeclineRate( t0.toSecsSinceEpoch(), v0, initialTime.toSecsSinceEpoch(), initialProductionRate ); return { initialProductionRate, initialDeclineRate }; } - else - { - // Select a point (t0) 1/4 into the user-specified range - const double historyStep = 0.25; - const size_t idx0 = static_cast( timeSteps.size() * historyStep ); - const QDateTime t0 = RiaQDateTimeTools::fromTime_t( timeSteps[idx0] ); - const double v0 = values[idx0]; - - // For accumulated result: compute the initial production rate from the two points. - const QDateTime initialTime = RiaQDateTimeTools::fromTime_t( timeSteps.back() ); - double initialProductionRate = computeProductionRate( t0.toSecsSinceEpoch(), v0, initialTime.toSecsSinceEpoch(), values.back() ); - - // Compute the at production rate at time t0 by using a point even further back in the existing curve (tx). - size_t idxX = 0; - QDateTime tx = RiaQDateTimeTools::fromTime_t( timeSteps[idxX] ); - double vx = values[idxX]; - double productionRate0 = computeProductionRate( tx.toSecsSinceEpoch(), vx, t0.toSecsSinceEpoch(), v0 ); - // Compute the decline rate using the rates at the two points - double initialDeclineRate = RigDeclineCurveCalculator::computeDeclineRate( t0.toSecsSinceEpoch(), - productionRate0, - initialTime.toSecsSinceEpoch(), - initialProductionRate ); - return { initialProductionRate, initialDeclineRate }; - } + // Select a point (t0) 1/4 into the user-specified range + const double historyStep = 0.25; + const size_t idx0 = static_cast( timeSteps.size() * historyStep ); + const QDateTime t0 = RiaQDateTimeTools::fromTime_t( timeSteps[idx0] ); + const double v0 = values[idx0]; + + // For accumulated result: compute the initial production rate from the two points. + const QDateTime initialTime = RiaQDateTimeTools::fromTime_t( timeSteps.back() ); + double initialProductionRate = computeProductionRate( t0.toSecsSinceEpoch(), v0, initialTime.toSecsSinceEpoch(), values.back() ); + + // Compute the at production rate at time t0 by using a point even further back in the existing curve (tx). + size_t idxX = 0; + QDateTime tx = RiaQDateTimeTools::fromTime_t( timeSteps[idxX] ); + double vx = values[idxX]; + double productionRate0 = computeProductionRate( tx.toSecsSinceEpoch(), vx, t0.toSecsSinceEpoch(), v0 ); + + // Compute the decline rate using the rates at the two points + double initialDeclineRate = RigDeclineCurveCalculator::computeDeclineRate( t0.toSecsSinceEpoch(), + productionRate0, + initialTime.toSecsSinceEpoch(), + initialProductionRate ); + return { initialProductionRate, initialDeclineRate }; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimSummaryDeclineCurve::computePredictedValue( double initialProductionRate, - double initialDeclineRate, - double timeSinceStart, - bool isAccumulatedResult ) const +double RimSummaryDeclineCurve::computePredictedValue( double initialProductionRate, + double initialDeclineRate, + double timeSinceStart, + RifEclipseSummaryAddressDefines::CurveType curveType ) const { - if ( isAccumulatedResult ) + if ( curveType == RifEclipseSummaryAddressDefines::CurveType::ACCUMULATED ) { if ( m_declineCurveType == RimSummaryDeclineCurve::DeclineCurveType::EXPONENTIAL ) { diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDeclineCurve.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDeclineCurve.h index 35e2b6aa38..7e59e4d639 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDeclineCurve.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDeclineCurve.h @@ -72,11 +72,11 @@ class RimSummaryDeclineCurve : public RimSummaryCurve void appendFutureTimeSteps( std::vector& timeSteps ) const; - std::vector createDeclineCurveValues( const std::vector& values, - const std::vector& timeSteps, - time_t minTimeStep, - time_t maxTimeStep, - bool isAccumulatedResult ) const; + std::vector createDeclineCurveValues( const std::vector& values, + const std::vector& timeSteps, + time_t minTimeStep, + time_t maxTimeStep, + RifEclipseSummaryAddressDefines::CurveType curveType ) const; static std::pair, std::vector> getInRangeValues( const std::vector& timeSteps, const std::vector& values, time_t minTimeStep, time_t maxTimeStep ); @@ -85,11 +85,14 @@ class RimSummaryDeclineCurve : public RimSummaryCurve std::set createFutureTimeSteps( const std::vector& timeSteps ) const; static void appendTimeSteps( std::vector& timeSteps, const std::set& moreTimeSteps ); - static std::pair computeInitialProductionAndDeclineRate( const std::vector& values, - const std::vector& timeSteps, - bool isAccumulatedResult ); + static std::pair computeInitialProductionAndDeclineRate( const std::vector& values, + const std::vector& timeSteps, + RifEclipseSummaryAddressDefines::CurveType curveType ); - double computePredictedValue( double initialProductionRate, double initialDeclineRate, double timeSinceStart, bool isAccumulatedResult ) const; + double computePredictedValue( double initialProductionRate, + double initialDeclineRate, + double timeSinceStart, + RifEclipseSummaryAddressDefines::CurveType curveType ) const; std::pair fullTimeStepRange() const; std::pair selectedTimeStepRange() const; From 057206951142afd5fa94f30ee143af13519ea914 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Wed, 28 Aug 2024 18:22:57 +0200 Subject: [PATCH 262/332] Support for loading only active cell geometry (#11624) * Only load active cells for main grid, skip LGRs for now * Handle wells with inactive cells * Validate mapaxes transform before using it. * Add log message * Additional guarding when trying to find the geometrical location of a simulation cell * Add extra safeguarding for init/restart file access in opm common. Only support unified restart files. --- .../Application/RiaPreferencesGrid.cpp | 6 +- .../FileInterface/CMakeLists_files.cmake | 2 + .../FileInterface/RifReaderEclipseWell.cpp | 24 +- .../FileInterface/RifReaderInterface.cpp | 8 + .../FileInterface/RifReaderInterface.h | 1 + .../FileInterface/RifReaderOpmCommon.cpp | 39 ++- .../FileInterface/RifReaderOpmCommon.h | 53 ++-- .../RifReaderOpmCommonActive.cpp | 235 ++++++++++++++++++ .../FileInterface/RifReaderOpmCommonActive.h | 38 +++ .../FileInterface/RifReaderSettings.h | 1 + .../ProjectDataModel/RimEclipseCase.cpp | 6 + .../ProjectDataModel/RimEclipseResultCase.cpp | 12 +- .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../ReservoirDataModel/RigActiveCellGrid.cpp | 164 ++++++++++++ .../ReservoirDataModel/RigActiveCellGrid.h | 51 ++++ .../ReservoirDataModel/RigEclipseCaseData.cpp | 28 ++- .../ReservoirDataModel/RigEclipseCaseData.h | 2 +- .../ReservoirDataModel/RigGridBase.cpp | 23 +- .../ReservoirDataModel/RigGridBase.h | 22 +- .../ReservoirDataModel/RigMainGrid.h | 18 +- .../RigSimulationWellCenterLineCalculator.cpp | 5 +- .../ReservoirDataModel/RigWellResultFrame.cpp | 2 +- Fwk/AppFwk/CommonCode/cvfStructGrid.h | 4 +- ThirdParty/custom-opm-common/opm-common | 2 +- 24 files changed, 670 insertions(+), 78 deletions(-) create mode 100644 ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp create mode 100644 ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.h create mode 100644 ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp create mode 100644 ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h diff --git a/ApplicationLibCode/Application/RiaPreferencesGrid.cpp b/ApplicationLibCode/Application/RiaPreferencesGrid.cpp index 151401e58c..f75aa1c1bd 100644 --- a/ApplicationLibCode/Application/RiaPreferencesGrid.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesGrid.cpp @@ -157,7 +157,8 @@ RifReaderSettings RiaPreferencesGrid::gridOnlyReaderSettings() false, // useResultIndexFile true, // skipWellData false, // import summary data - "" // include prefix + "", // include prefix, + false // only active cells }; return rs; } @@ -174,7 +175,8 @@ RifReaderSettings RiaPreferencesGrid::readerSettings() m_useResultIndexFile, m_skipWellData, true, // import summary data - m_includeFileAbsolutePathPrefix }; + m_includeFileAbsolutePathPrefix, + m_onlyLoadActiveCells }; return rs; } diff --git a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake index 89777e2723..259176ad1c 100644 --- a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake @@ -86,6 +86,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RifRevealCsvSectionSummaryReader.h ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanCsvSummaryReader.h ${CMAKE_CURRENT_LIST_DIR}/RifReaderOpmCommon.h + ${CMAKE_CURRENT_LIST_DIR}/RifReaderOpmCommonActive.h ${CMAKE_CURRENT_LIST_DIR}/RifEclipseReportKeywords.h ${CMAKE_CURRENT_LIST_DIR}/RifInpExportTools.h ${CMAKE_CURRENT_LIST_DIR}/RifFaultReactivationModelExporter.h @@ -188,6 +189,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RifRevealCsvSectionSummaryReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanCsvSummaryReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifReaderOpmCommon.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifReaderOpmCommonActive.cpp ${CMAKE_CURRENT_LIST_DIR}/RifInpExportTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RifFaultReactivationModelExporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifThermalToStimPlanFractureXmlOutput.cpp diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp index aee64e1e36..c6fa2e7212 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp @@ -132,6 +132,11 @@ size_t RifReaderEclipseWell::localGridCellIndexFromErtConnection( const RigGridB return cvf::UNDEFINED_SIZE_T; } + if ( ( cellI < 0 ) || ( cellJ < 0 ) ) + { + return cvf::UNDEFINED_SIZE_T; + } + return grid->cellIndexFromIJK( cellI, cellJ, cellK ); } @@ -158,6 +163,17 @@ RigWellResultPoint RifReaderEclipseWell::createWellResultPoint( const RigEclipse RigWellResultPoint resultPoint; + if ( ( grid->cellCount() == 0 ) || ( gridCellIndex > grid->cellCount() - 1 ) ) + { + return resultPoint; + } + + const RigCell& c = grid->cell( gridCellIndex ); + if ( c.isInvalid() ) + { + return resultPoint; + } + if ( gridCellIndex != cvf::UNDEFINED_SIZE_T ) { int branchId = -1, segmentId = -1, outletBranchId = -1, outletSegmentId = -1; @@ -857,11 +873,17 @@ void RifReaderEclipseWell::readWellCells( RifEclipseRestartDataAccess* restartDa { prevResPoint = wellResFrame.wellHead(); } - else + else if ( rpIdx > 0 ) { prevResPoint = wellResultBranch.branchResultPoints()[rpIdx - 1]; } + if ( !prevResPoint.isCell() ) + { + // When importing only active cells, this situation can occur if the well head is a inactive cell. + continue; + } + cvf::Vec3d lastConnectionPos = grids[prevResPoint.gridIndex()]->cell( prevResPoint.cellIndex() ).center(); SegmentPositionContribution diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp index 05ddf0983a..fc6d643bd7 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp @@ -80,6 +80,14 @@ const QString RifReaderInterface::faultIncludeFileAbsolutePathPrefix() const return m_readerSettings.includeFileAbsolutePathPrefix; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderInterface::onlyLoadActiveCells() const +{ + return m_readerSettings.onlyLoadActiveCells; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.h b/ApplicationLibCode/FileInterface/RifReaderInterface.h index 0da770f2c4..cd391a3766 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.h +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.h @@ -57,6 +57,7 @@ class RifReaderInterface : public cvf::Object bool includeInactiveCellsInFaultGeometry() const; bool loadWellDataEnabled() const; const QString faultIncludeFileAbsolutePathPrefix() const; + bool onlyLoadActiveCells() const; void setReaderSettings( RifReaderSettings readerSettings ); diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp index 27f3aaabc0..0d48feb263 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp @@ -29,6 +29,7 @@ #include "RifOpmRadialGridTools.h" #include "RifReaderEclipseWell.h" +#include "RigActiveCellGrid.h" #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" @@ -87,18 +88,16 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli return false; } + if ( isFaultImportEnabled() ) { auto task = progress.task( "Reading faults", 25 ); - if ( isFaultImportEnabled() ) - { - cvf::Collection faults; + cvf::Collection faults; - importFaults( fileSet, &faults ); + importFaults( fileSet, &faults ); - RigMainGrid* mainGrid = eclipseCaseData->mainGrid(); - mainGrid->setFaults( faults ); - } + RigMainGrid* mainGrid = eclipseCaseData->mainGrid(); + mainGrid->setFaults( faults ); } m_eclipseCaseData = eclipseCaseData; @@ -108,9 +107,10 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli buildMetaData( eclipseCaseData, progress ); } - auto task = progress.task( "Handling NCC Result data", 25 ); if ( isNNCsEnabled() ) { + auto task = progress.task( "Handling NCC Result data", 25 ); + caf::ProgressInfo nncProgress( 10, "" ); RigMainGrid* mainGrid = eclipseCaseData->mainGrid(); @@ -278,9 +278,11 @@ bool RifReaderOpmCommon::importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* mapAxes[i] = opmMapAxes[i]; } + double norm_denominator = mapAxes[2] * mapAxes[5] - mapAxes[4] * mapAxes[3]; + // Set the map axes transformation matrix on the main grid mainGrid->setMapAxes( mapAxes ); - mainGrid->setUseMapAxes( true ); + mainGrid->setUseMapAxes( norm_denominator != 0.0 ); auto transform = mainGrid->mapAxisTransform(); @@ -414,6 +416,7 @@ void RifReaderOpmCommon::transferGeometry( Opm::EclIO::EGrid& opmMainGrid, RigCell defaultCell; defaultCell.setHostGrid( localGrid ); + mainGrid->globalCellArray().resize( cellStartIndex + cellCount, defaultCell ); mainGrid->nodes().resize( nodeStartIndex + cellCount * 8, cvf::Vec3d( 0, 0, 0 ) ); @@ -724,12 +727,26 @@ void RifReaderOpmCommon::setupInitAndRestartAccess() { if ( ( m_initFile == nullptr ) && !m_initFileName.empty() ) { - m_initFile = std::make_unique( m_initFileName ); + try + { + m_initFile = std::make_unique( m_initFileName ); + } + catch ( ... ) + { + m_initFile = nullptr; + } } if ( ( m_restartFile == nullptr ) && !m_restartFileName.empty() ) { - m_restartFile = std::make_unique( m_restartFileName ); + try + { + m_restartFile = std::make_unique( m_restartFileName ); + } + catch ( ... ) + { + m_restartFile = nullptr; + } } } diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h index 2400a3c15e..c33554d95d 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h @@ -32,6 +32,7 @@ class EGrid; } // namespace Opm::EclIO class RigMainGrid; +class RigActiveCellGrid; class RigGridBase; class RigEclipseCaseData; class RigEclipseTimeStepInfo; @@ -58,35 +59,37 @@ class RifReaderOpmCommon : public RifReaderInterface std::vector timeStepsOnFile( QString gridFileName ); -private: - void buildMetaData( RigEclipseCaseData* caseData, caf::ProgressInfo& progress ); - bool importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* caseData ); - void transferGeometry( Opm::EclIO::EGrid& opmMainGrid, - Opm::EclIO::EGrid& opmGrid, - RigMainGrid* riMainGrid, - RigGridBase* riGrid, - RigEclipseCaseData* caseData ); +protected: + virtual bool importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* caseData ); void transferActiveCells( Opm::EclIO::EGrid& opmGrid, size_t cellStartIndex, RigEclipseCaseData* eclipseCaseData, size_t matrixActiveStartIndex, size_t fractureActiveStartIndex ); - void transferStaticNNCData( Opm::EclIO::EGrid& opmMainGrid, std::vector& lgrGrids, RigMainGrid* mainGrid ); - void transferDynamicNNCData( RigMainGrid* mainGrid ); - void locateInitAndRestartFiles( QString gridFileName ); - void setupInitAndRestartAccess(); + bool verifyActiveCellInfo( int activeSizeMat, int activeSizeFrac ); + void updateActiveCellInfo( RigEclipseCaseData* eclipseCaseData, + Opm::EclIO::EGrid& opmGrid, + std::vector& lgrGrids, + RigMainGrid* mainGrid ); + +private: + void buildMetaData( RigEclipseCaseData* caseData, caf::ProgressInfo& progress ); std::vector createFilteredTimeStepInfos(); + std::vector> readActiveCellInfoFromPorv( RigEclipseCaseData* eclipseCaseData, bool isDualPorosity ); - bool verifyActiveCellInfo( int activeSizeMat, int activeSizeFrac ); - std::vector> readActiveCellInfoFromPorv( RigEclipseCaseData* eclipseCaseData, bool isDualPorosity ); - void updateActiveCellInfo( RigEclipseCaseData* eclipseCaseData, - Opm::EclIO::EGrid& opmGrid, - std::vector& lgrGrids, - RigMainGrid* mainGrid ); + void transferGeometry( Opm::EclIO::EGrid& opmMainGrid, + Opm::EclIO::EGrid& opmGrid, + RigMainGrid* riMainGrid, + RigGridBase* riGrid, + RigEclipseCaseData* caseData ); + void transferDynamicNNCData( RigMainGrid* mainGrid ); + + void locateInitAndRestartFiles( QString gridFileName ); + void setupInitAndRestartAccess(); struct TimeDataFile { @@ -99,22 +102,22 @@ class RifReaderOpmCommon : public RifReaderInterface std::vector readTimeSteps(); -private: +protected: enum class ActiveType { ACTIVE_MATRIX_VALUE = 1, ACTIVE_FRACTURE_VALUE = 2 }; - std::string m_gridFileName; - std::string m_initFileName; - std::string m_restartFileName; - int m_gridUnit; + std::string m_gridFileName; + int m_gridUnit; + std::vector m_gridNames; RigEclipseCaseData* m_eclipseCaseData; +private: + std::string m_initFileName; + std::string m_restartFileName; std::unique_ptr m_restartFile; std::unique_ptr m_initFile; - - std::vector m_gridNames; }; diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp new file mode 100644 index 0000000000..53ea8662ae --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp @@ -0,0 +1,235 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RifReaderOpmCommonActive.h" + +#include "RiaLogging.h" +#include "RiaStdStringTools.h" + +#include "RifOpmRadialGridTools.h" + +#include "RigActiveCellGrid.h" +#include "RigActiveCellInfo.h" +#include "RigEclipseCaseData.h" + +#include "cafProgressInfo.h" + +#include "opm/io/eclipse/EGrid.hpp" + +#include + +using namespace Opm; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderOpmCommonActive::RifReaderOpmCommonActive() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderOpmCommonActive::~RifReaderOpmCommonActive() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclipseCaseData* eclipseCaseData ) +{ + RigActiveCellGrid* activeGrid = new RigActiveCellGrid(); + eclipseCaseData->setMainGrid( activeGrid ); + + caf::ProgressInfo progInfo( 5, "Importing Eclipse Grid" ); + + Opm::EclIO::EGrid opmGrid( m_gridFileName ); + + const auto& dims = opmGrid.dimension(); + activeGrid->setGridPointDimensions( cvf::Vec3st( dims[0] + 1, dims[1] + 1, dims[2] + 1 ) ); + activeGrid->setGridName( "Main grid" ); + activeGrid->setDualPorosity( opmGrid.porosity_mode() > 0 ); + + // assign grid unit, if found (1 = Metric, 2 = Field, 3 = Lab) + auto gridUnitStr = RiaStdStringTools::toUpper( opmGrid.grid_unit() ); + if ( gridUnitStr.starts_with( 'M' ) ) + m_gridUnit = 1; + else if ( gridUnitStr.starts_with( 'F' ) ) + m_gridUnit = 2; + else if ( gridUnitStr.starts_with( 'C' ) ) + m_gridUnit = 3; + + auto globalMatrixActiveSize = opmGrid.activeCells(); + auto globalFractureActiveSize = opmGrid.activeFracCells(); + + m_gridNames.clear(); + m_gridNames.push_back( "global" ); + + std::vector lgrGrids; // lgrs not supported here for now + + // active cell information + { + auto task = progInfo.task( "Getting Active Cell Information", 1 ); + + // in case init file and grid file disagrees with number of active cells, read extra porv information from init file to correct this + if ( !verifyActiveCellInfo( globalMatrixActiveSize, globalFractureActiveSize ) ) + { + updateActiveCellInfo( eclipseCaseData, opmGrid, lgrGrids, activeGrid ); + } + + activeGrid->transferActiveInformation( eclipseCaseData, + opmGrid.totalActiveCells(), + opmGrid.activeCells(), + opmGrid.activeFracCells(), + opmGrid.active_indexes(), + opmGrid.active_frac_indexes() ); + } + + // grid geometry + { + RiaLogging::info( QString( "Loading %0 active of %1 total cells." ) + .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalActiveCells() ) ) ) + .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalNumberOfCells() ) ) ) ); + + auto task = progInfo.task( "Loading Active Cell Main Grid Geometry", 1 ); + transferActiveGeometry( opmGrid, activeGrid, eclipseCaseData ); + } + + activeGrid->initAllSubGridsParentGridPointer(); + + if ( isNNCsEnabled() ) + { + auto task = progInfo.task( "Loading NNC data", 1 ); + transferStaticNNCData( opmGrid, lgrGrids, activeGrid ); + } + + auto opmMapAxes = opmGrid.get_mapaxes(); + if ( opmMapAxes.size() == 6 ) + { + std::array mapAxes; + for ( size_t i = 0; i < opmMapAxes.size(); ++i ) + { + mapAxes[i] = opmMapAxes[i]; + } + + double norm_denominator = mapAxes[2] * mapAxes[5] - mapAxes[4] * mapAxes[3]; + + // Set the map axes transformation matrix on the main grid + activeGrid->setMapAxes( mapAxes ); + activeGrid->setUseMapAxes( norm_denominator != 0.0 ); + + auto transform = activeGrid->mapAxisTransform(); + + // Invert the transformation matrix to convert from file coordinates to domain coordinates + transform.invert(); + +#pragma omp parallel for + for ( long i = 0; i < static_cast( activeGrid->nodes().size() ); i++ ) + { + auto& n = activeGrid->nodes()[i]; + n.transformPoint( transform ); + } + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMainGrid, + RigActiveCellGrid* activeGrid, + RigEclipseCaseData* eclipseCaseData ) +{ + int cellCount = opmMainGrid.totalActiveCells(); + + RigCell defaultCell; + defaultCell.setHostGrid( activeGrid ); + for ( size_t i = 0; i < 8; i++ ) + defaultCell.cornerIndices()[i] = 0; + + activeGrid->globalCellArray().resize( cellCount + 1, defaultCell ); + activeGrid->globalCellArray()[cellCount].setInvalid( true ); + + activeGrid->nodes().resize( ( cellCount + 1 ) * 8, cvf::Vec3d( 0, 0, 0 ) ); + + auto& riNodes = activeGrid->nodes(); + + opmMainGrid.loadData(); + opmMainGrid.load_grid_data(); + + const bool isRadialGrid = opmMainGrid.is_radial(); + const auto& activeMatIndexes = opmMainGrid.active_indexes(); + const auto& activeFracIndexes = opmMainGrid.active_frac_indexes(); + + // Compute the center of the LGR radial grid cells for each K layer + auto radialGridCenterTopLayerOpm = isRadialGrid + ? RifOpmRadialGridTools::computeXyCenterForTopOfCells( opmMainGrid, opmMainGrid, activeGrid ) + : std::map>(); + + // use same mapping as resdata + const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 }; + +#pragma omp parallel for + for ( int opmCellIndex = 0; opmCellIndex < static_cast( opmMainGrid.totalNumberOfCells() ); opmCellIndex++ ) + { + if ( ( activeMatIndexes[opmCellIndex] < 0 ) && ( activeFracIndexes[opmCellIndex] < 0 ) ) continue; + + auto opmIJK = opmMainGrid.ijk_from_global_index( opmCellIndex ); + + double xCenterCoordOpm = 0.0; + double yCenterCoordOpm = 0.0; + + if ( isRadialGrid && radialGridCenterTopLayerOpm.contains( opmIJK[2] ) ) + { + const auto& [xCenter, yCenter] = radialGridCenterTopLayerOpm[opmIJK[2]]; + xCenterCoordOpm = xCenter; + yCenterCoordOpm = yCenter; + } + + auto riReservoirIndex = activeGrid->cellIndexFromIJK( opmIJK[0], opmIJK[1], opmIJK[2] ); + RigCell& cell = activeGrid->globalCellArray()[riReservoirIndex]; + cell.setGridLocalCellIndex( riReservoirIndex ); + cell.setParentCellIndex( cvf::UNDEFINED_SIZE_T ); + + // corner coordinates + std::array opmX{}; + std::array opmY{}; + std::array opmZ{}; + opmMainGrid.getCellCorners( opmCellIndex, opmX, opmY, opmZ ); + + // Each cell has 8 nodes, use reservoir cell index and multiply to find first node index for cell + auto riNodeStartIndex = riReservoirIndex * 8; + + for ( size_t opmNodeIndex = 0; opmNodeIndex < 8; opmNodeIndex++ ) + { + auto riCornerIndex = cellMappingECLRi[opmNodeIndex]; + size_t riNodeIndex = riNodeStartIndex + riCornerIndex; + + auto& riNode = riNodes[riNodeIndex]; + riNode.x() = opmX[opmNodeIndex] + xCenterCoordOpm; + riNode.y() = opmY[opmNodeIndex] + yCenterCoordOpm; + riNode.z() = -opmZ[opmNodeIndex]; + + cell.cornerIndices()[riCornerIndex] = riNodeIndex; + } + + cell.setInvalid( cell.isLongPyramidCell() ); + } +} diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.h b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.h new file mode 100644 index 0000000000..99a2d3224c --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RifReaderOpmCommon.h" + +class RigActiveCellGrid; + +//================================================================================================== +// +// +//================================================================================================== +class RifReaderOpmCommonActive : public RifReaderOpmCommon +{ +public: + RifReaderOpmCommonActive(); + ~RifReaderOpmCommonActive() override; + +protected: + bool importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* caseData ) override; + void transferActiveGeometry( Opm::EclIO::EGrid& opmMainGrid, RigActiveCellGrid* riMainGrid, RigEclipseCaseData* caseData ); +}; diff --git a/ApplicationLibCode/FileInterface/RifReaderSettings.h b/ApplicationLibCode/FileInterface/RifReaderSettings.h index 8041974822..689de687cd 100644 --- a/ApplicationLibCode/FileInterface/RifReaderSettings.h +++ b/ApplicationLibCode/FileInterface/RifReaderSettings.h @@ -35,4 +35,5 @@ struct RifReaderSettings bool skipWellData; bool importSummaryData; QString includeFileAbsolutePathPrefix; + bool onlyLoadActiveCells; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index 845e4f8e19..17a4a85dc6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -771,6 +771,12 @@ void RimEclipseCase::computeActiveCellsBoundingBox() bool useOptimizedVersion = true; + const auto gridPref = RiaPreferencesGrid::current(); + if ( ( gridPref != nullptr ) && ( gridPref->gridModelReader() == RiaDefines::GridModelReader::OPM_COMMON ) ) + { + useOptimizedVersion = !gridPref->onlyLoadActiveCells(); + } + if ( auto proj = RimProject::current() ) { if ( proj->isProjectFileVersionEqualOrOlderThan( "2023.12.0" ) ) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp index 28604204a3..07fba987c2 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -36,6 +36,7 @@ #include "RifReaderEclipseRft.h" #include "RifReaderMockModel.h" #include "RifReaderOpmCommon.h" +#include "RifReaderOpmCommonActive.h" #include "RifReaderOpmRft.h" #include "RigCaseCellResultsData.h" @@ -188,7 +189,16 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter } else { - auto readerOpmCommon = new RifReaderOpmCommon(); + RifReaderOpmCommon* readerOpmCommon = nullptr; + + if ( RiaPreferencesGrid::current()->onlyLoadActiveCells() ) + { + readerOpmCommon = new RifReaderOpmCommonActive(); + } + else + { + readerOpmCommon = new RifReaderOpmCommon(); + } std::vector timeSteps = readerOpmCommon->timeStepsOnFile( gridFileName() ); m_timeStepFilter->setTimeStepsFromFile( timeSteps ); diff --git a/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake index f42b255323..c6f90aafa8 100644 --- a/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ReservoirDataModel/CMakeLists_files.cmake @@ -22,6 +22,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RigEclipseWellLogExtractor.h ${CMAKE_CURRENT_LIST_DIR}/RigLocalGrid.h ${CMAKE_CURRENT_LIST_DIR}/RigMainGrid.h + ${CMAKE_CURRENT_LIST_DIR}/RigActiveCellGrid.h ${CMAKE_CURRENT_LIST_DIR}/RigReservoirBuilderMock.h ${CMAKE_CURRENT_LIST_DIR}/RigCaseCellResultsData.h ${CMAKE_CURRENT_LIST_DIR}/RigSimWellData.h @@ -124,6 +125,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RigEclipseWellLogExtractor.cpp ${CMAKE_CURRENT_LIST_DIR}/RigLocalGrid.cpp ${CMAKE_CURRENT_LIST_DIR}/RigMainGrid.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigActiveCellGrid.cpp ${CMAKE_CURRENT_LIST_DIR}/RigReservoirBuilderMock.cpp ${CMAKE_CURRENT_LIST_DIR}/RigCaseCellResultsData.cpp ${CMAKE_CURRENT_LIST_DIR}/RigSimWellData.cpp diff --git a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp new file mode 100644 index 0000000000..f1c7e36617 --- /dev/null +++ b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp @@ -0,0 +1,164 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RigActiveCellGrid.h" + +#include "RigActiveCellInfo.h" +#include "RigEclipseCaseData.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigActiveCellGrid::RigActiveCellGrid() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigActiveCellGrid::~RigActiveCellGrid() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellGrid::transferActiveInformation( RigEclipseCaseData* eclipseCaseData, + size_t totalActiveCells, + size_t matrixActiveCells, + size_t fractureActiveCells, + const std::vector& activeMatrixIndexes, + const std::vector& activeFracIndexes ) +{ + const auto totalCells = activeMatrixIndexes.size(); + + m_globalToActiveMap.resize( totalCells ); + size_t activeCells = 0; + size_t anInactiveCellIdx = 0; + + for ( size_t i = 0; i < totalCells; i++ ) + { + if ( ( activeMatrixIndexes[i] < 0 ) && ( activeFracIndexes[i] < 0 ) ) + { + m_globalToActiveMap[i] = totalActiveCells; + anInactiveCellIdx = i; + continue; + } + m_activeToGlobalMap.push_back( i ); + m_globalToActiveMap[i] = activeCells++; + } + m_activeToGlobalMap.push_back( anInactiveCellIdx ); + + RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); + + activeCellInfo->setReservoirCellCount( totalActiveCells + 1 ); + fractureActiveCellInfo->setReservoirCellCount( totalActiveCells + 1 ); + + activeCellInfo->setGridCount( 1 ); + fractureActiveCellInfo->setGridCount( 1 ); + + activeCellInfo->setGridActiveCellCounts( 0, matrixActiveCells ); + fractureActiveCellInfo->setGridActiveCellCounts( 0, fractureActiveCells ); + +#pragma omp parallel for + for ( int opmCellIndex = 0; opmCellIndex < (int)totalCells; opmCellIndex++ ) + { + auto activeCellIndex = m_globalToActiveMap[opmCellIndex]; + + // active cell index + int matrixActiveIndex = activeMatrixIndexes[opmCellIndex]; + if ( matrixActiveIndex != -1 ) + { + activeCellInfo->setCellResultIndex( activeCellIndex, matrixActiveIndex ); + } + + int fractureActiveIndex = activeFracIndexes[opmCellIndex]; + if ( fractureActiveIndex != -1 ) + { + fractureActiveCellInfo->setCellResultIndex( activeCellIndex, fractureActiveIndex ); + } + } + + activeCellInfo->computeDerivedData(); + fractureActiveCellInfo->computeDerivedData(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigActiveCellGrid::cellIndexFromIJK( size_t i, size_t j, size_t k ) const +{ + auto index = RigGridBase::cellIndexFromIJK( i, j, k ); + return m_globalToActiveMap[index]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigActiveCellGrid::cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const +{ + auto index = RigGridBase::cellIndexFromIJKUnguarded( i, j, k ); + return m_globalToActiveMap[index]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigActiveCellGrid::ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const +{ + if ( cellIndex >= m_activeToGlobalMap.size() ) + { + return false; + } + auto index = m_activeToGlobalMap[cellIndex]; + return RigGridBase::ijkFromCellIndex( index, i, j, k ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellGrid::ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const +{ + auto index = m_activeToGlobalMap[cellIndex]; + RigGridBase::ijkFromCellIndexUnguarded( index, i, j, k ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCell& RigActiveCellGrid::cell( size_t gridLocalCellIndex ) +{ + return m_cells[gridLocalCellIndex]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigCell& RigActiveCellGrid::cell( size_t gridLocalCellIndex ) const +{ + return m_cells[gridLocalCellIndex]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigActiveCellGrid::cellCount() const +{ + return m_cells.size(); +} diff --git a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h new file mode 100644 index 0000000000..da0e124a2c --- /dev/null +++ b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RigMainGrid.h" + +#include + +class RigActiveCellGrid : public RigMainGrid +{ +public: + RigActiveCellGrid(); + ~RigActiveCellGrid() override; + + void transferActiveInformation( RigEclipseCaseData* eclipseCaseData, + size_t totalActiveCells, + size_t matrixActiveCells, + size_t fractureActiveCells, + const std::vector& activeMatrixIndexes, + const std::vector& activeFracIndexes ); + + size_t cellIndexFromIJK( size_t i, size_t j, size_t k ) const override; + size_t cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const override; + bool ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override; + void ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override; + + RigCell& cell( size_t gridLocalCellIndex ) override; + const RigCell& cell( size_t gridLocalCellIndex ) const override; + size_t cellCount() const override; + +private: + std::vector m_globalToActiveMap; + std::vector m_activeToGlobalMap; + RigCell m_invalidCell; +}; diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.cpp b/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.cpp index d10442cbd6..839d18da54 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.cpp @@ -333,12 +333,12 @@ const cvf::UIntArray* RigEclipseCaseData::gridCellToResultWellIndex( size_t grid //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigCell& RigEclipseCaseData::cellFromWellResultCell( const RigWellResultPoint& wellResultCell ) const +const RigCell& RigEclipseCaseData::cellFromWellResultCell( const RigWellResultPoint& wellResultPoint ) const { - CVF_ASSERT( wellResultCell.isCell() ); + CVF_ASSERT( wellResultPoint.isCell() ); - size_t gridIndex = wellResultCell.gridIndex(); - size_t gridCellIndex = wellResultCell.cellIndex(); + size_t gridIndex = wellResultPoint.gridIndex(); + size_t gridCellIndex = wellResultPoint.cellIndex(); std::vector grids; allGrids( &grids ); @@ -429,12 +429,13 @@ void RigEclipseCaseData::computeActiveCellIJKBBox() CellRangeBB matrixModelActiveBB; CellRangeBB fractureModelActiveBB; - size_t idx; - for ( idx = 0; idx < m_mainGrid->cellCount(); idx++ ) + for ( size_t idx = 0; idx < m_mainGrid->cellCount(); idx++ ) { size_t i, j, k; m_mainGrid->ijkFromCellIndex( idx, &i, &j, &k ); + if ( !m_mainGrid->isCellValid( i, j, k ) ) continue; + if ( m_activeCellInfo->isActive( idx ) ) { matrixModelActiveBB.add( i, j, k ); @@ -724,13 +725,16 @@ void RigEclipseCaseData::computeActiveCellsGeometryBoundingBoxOptimized() { for ( size_t j = minBB.y(); j <= maxBB.y(); j++ ) { - size_t cellIndex = m_mainGrid->cellIndexFromIJK( i, j, k ); - - std::array hexCorners; - m_mainGrid->cellCornerVertices( cellIndex, hexCorners.data() ); - for ( const auto& corner : hexCorners ) + if ( m_mainGrid->isCellValid( i, j, k ) ) { - bb.add( corner ); + size_t cellIndex = m_mainGrid->cellIndexFromIJK( i, j, k ); + + std::array hexCorners; + m_mainGrid->cellCornerVertices( cellIndex, hexCorners.data() ); + for ( const auto& corner : hexCorners ) + { + bb.add( corner ); + } } } } diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.h b/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.h index 63416b16cb..b37a9d527b 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.h +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.h @@ -98,7 +98,7 @@ class RigEclipseCaseData : public cvf::Object const cvf::UByteArray* wellCellsInGrid( size_t gridIndex ); const cvf::UIntArray* gridCellToResultWellIndex( size_t gridIndex ); - const RigCell& cellFromWellResultCell( const RigWellResultPoint& wellResultCell ) const; + const RigCell& cellFromWellResultCell( const RigWellResultPoint& wellResultPoint ) const; bool findSharedSourceFace( cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultPoint& sourceWellCellResult, const RigWellResultPoint& otherWellCellResult ) const; diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp index ac27d61adb..19d88793b8 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp @@ -208,7 +208,7 @@ void RigGridBase::cellMinMaxCordinates( size_t cellIndex, cvf::Vec3d* minCoordin //-------------------------------------------------------------------------------------------------- bool RigGridBase::ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const { - CVF_TIGHT_ASSERT( cellIndex < cellCount() ); + CVF_TIGHT_ASSERT( cellIndex < RigGridBase::cellCount() ); size_t index = cellIndex; @@ -413,6 +413,27 @@ double RigGridBase::characteristicIJCellSize() const return characteristicCellSize; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigGridBase::characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const +{ + CVF_ASSERT( iSize && jSize && kSize ); + + if ( !hasValidCharacteristicCellSizes() ) + { + std::vector reservoirCellIndices; + reservoirCellIndices.resize( cellCount() ); + std::iota( reservoirCellIndices.begin(), reservoirCellIndices.end(), 0 ); + + computeCharacteristicCellSize( reservoirCellIndices ); + } + + *iSize = m_characteristicCellSizeI; + *jSize = m_characteristicCellSizeJ; + *kSize = m_characteristicCellSizeK; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h index 72af3574a0..3502e2b72a 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h @@ -49,9 +49,11 @@ class RigGridBase : public cvf::StructGridInterface size_t cellCountJ() const override; size_t cellCountK() const override; - size_t cellCount() const; - RigCell& cell( size_t gridLocalCellIndex ); - const RigCell& cell( size_t gridLocalCellIndex ) const; + virtual size_t cellCount() const; + virtual RigCell& cell( size_t gridLocalCellIndex ); + virtual const RigCell& cell( size_t gridLocalCellIndex ) const; + + void characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const override; size_t reservoirCellIndex( size_t gridLocalCellIndex ) const; void setIndexToStartOfCells( size_t indexToStartOfCells ) { m_indexToStartOfCells = indexToStartOfCells; } @@ -91,20 +93,20 @@ class RigGridBase : public cvf::StructGridInterface cvf::Vec3d maxCoordinate() const override; cvf::Vec3d displayModelOffset() const override; - size_t cellIndexFromIJK( size_t i, size_t j, size_t k ) const override; - size_t cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const; - bool ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override; - void ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const; + size_t cellIndexFromIJK( size_t i, size_t j, size_t k ) const override; + virtual size_t cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const; + bool ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override; + virtual void ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const; std::optional ijkFromCellIndex( size_t cellIndex ) const; std::optional ijkFromCellIndexOneBased( size_t cellIndex ) const; - bool cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k ) const override; + bool cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k ) const override; // unused + void cellMinMaxCordinates( size_t cellIndex, cvf::Vec3d* minCoordinate, cvf::Vec3d* maxCoordinate ) const override; // unused + void cellCornerVertices( size_t cellIndex, cvf::Vec3d vertices[8] ) const override; cvf::Vec3d cellCentroid( size_t cellIndex ) const override; - void cellMinMaxCordinates( size_t cellIndex, cvf::Vec3d* minCoordinate, cvf::Vec3d* maxCoordinate ) const override; - size_t gridPointIndexFromIJK( size_t i, size_t j, size_t k ) const override; cvf::Vec3d gridPointCoordinate( size_t i, size_t j, size_t k ) const override; diff --git a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h index d0a851dad4..821f7fde94 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h @@ -43,20 +43,20 @@ class RigMainGrid : public RigGridBase RigMainGrid(); ~RigMainGrid() override; -public: std::vector& nodes(); const std::vector& nodes() const; std::vector& globalCellArray(); const std::vector& globalCellArray() const; - RigGridBase* gridAndGridLocalIdxFromGlobalCellIdx( size_t globalCellIdx, size_t* gridLocalCellIdx ); - const RigGridBase* gridAndGridLocalIdxFromGlobalCellIdx( size_t globalCellIdx, size_t* gridLocalCellIdx ) const; + virtual RigGridBase* gridAndGridLocalIdxFromGlobalCellIdx( size_t globalCellIdx, size_t* gridLocalCellIdx ); + virtual const RigGridBase* gridAndGridLocalIdxFromGlobalCellIdx( size_t globalCellIdx, size_t* gridLocalCellIdx ) const; + + virtual const RigCell& cellByGridAndGridLocalCellIdx( size_t gridIdx, size_t gridLocalCellIdx ) const; + virtual size_t reservoirCellIndexByGridAndGridLocalCellIndex( size_t gridIdx, size_t gridLocalCellIdx ) const; + virtual size_t findReservoirCellIndexFromPoint( const cvf::Vec3d& point ) const; - const RigCell& cellByGridAndGridLocalCellIdx( size_t gridIdx, size_t gridLocalCellIdx ) const; - size_t reservoirCellIndexByGridAndGridLocalCellIndex( size_t gridIdx, size_t gridLocalCellIdx ) const; - size_t findReservoirCellIndexFromPoint( const cvf::Vec3d& point ) const; - void addLocalGrid( RigLocalGrid* localGrid ); + void addLocalGrid( RigLocalGrid* localGrid ); size_t gridCountOnFile() const; size_t gridCount() const; @@ -114,7 +114,7 @@ class RigMainGrid : public RigGridBase bool isDualPorosity() const; void setDualPorosity( bool enable ); -private: +protected: void initAllSubCellsMainGridCellIndex(); void buildCellSearchTree(); void buildCellSearchTreeOptimized( size_t cellsPerBoundingBox ); @@ -123,7 +123,7 @@ class RigMainGrid : public RigGridBase static std::array defaultMapAxes(); -private: +protected: std::vector m_nodes; ///< Global vertex table std::vector m_cells; ///< Global array of all cells in the reservoir (including the ones in LGR's) cvf::Collection m_localGrids; ///< List of all the LGR's in this reservoir diff --git a/ApplicationLibCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp index 014a96d9ef..7d1e39aeb4 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp @@ -243,7 +243,10 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineForTimeSt // Well head // Match this position with well head position in RivWellHeadPartMgr::buildWellHeadParts() - const RigCell& whCell = eclipseCaseData->cellFromWellResultCell( wellFrame.wellHeadOrStartCell() ); + auto wellPoint = wellFrame.wellHeadOrStartCell(); + if ( !wellPoint.isCell() ) return; + + const RigCell& whCell = eclipseCaseData->cellFromWellResultCell( wellPoint ); cvf::Vec3d whStartPos = whCell.faceCenter( cvf::StructGridInterface::NEG_K ); RigWellResultPoint wellHead = wellFrame.wellHeadOrStartCell(); diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellResultFrame.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellResultFrame.cpp index 417b1dc07d..1d5584ac22 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellResultFrame.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellResultFrame.cpp @@ -101,7 +101,7 @@ RigWellResultPoint RigWellResultFrame::wellHeadOrStartCell() const } } - return m_wellHead; // Nothing else to do + return RigWellResultPoint(); // Nothing else matters } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/CommonCode/cvfStructGrid.h b/Fwk/AppFwk/CommonCode/cvfStructGrid.h index 7275be352a..94adf0d436 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGrid.h +++ b/Fwk/AppFwk/CommonCode/cvfStructGrid.h @@ -85,7 +85,7 @@ class StructGridInterface : public Object virtual cvf::Vec3d minCoordinate() const = 0; virtual cvf::Vec3d maxCoordinate() const = 0; - void characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const; + virtual void characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const; bool hasValidCharacteristicCellSizes() const; void computeCharacteristicCellSize( const std::vector& globalCellIndices ) const; @@ -123,7 +123,7 @@ class StructGridInterface : public Object cvf::StructGridInterface::FaceType face2 ); static std::vector validFaceTypes(); -private: +protected: mutable double m_characteristicCellSizeI; mutable double m_characteristicCellSizeJ; mutable double m_characteristicCellSizeK; diff --git a/ThirdParty/custom-opm-common/opm-common b/ThirdParty/custom-opm-common/opm-common index ea6dba538b..c351cfbbdd 160000 --- a/ThirdParty/custom-opm-common/opm-common +++ b/ThirdParty/custom-opm-common/opm-common @@ -1 +1 @@ -Subproject commit ea6dba538bfb0498eb1ec6ad51a853b99e446a5b +Subproject commit c351cfbbdd7eefdf7fc76cbe846637e14eb3671e From 8886905fd2eeb13aa8e516c727478f3a6bfd46a3 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 28 Aug 2024 14:05:57 +0200 Subject: [PATCH 263/332] #11422 Grid Ensemble: Fix copy and paste of a view. Fixes #11422. --- .../RicPasteEclipseViewsFeature.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp index 660141b4b0..a91eab7c1d 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp @@ -26,6 +26,7 @@ #include "RimEclipseContourMapView.h" #include "RimEclipseContourMapViewCollection.h" #include "RimEclipseView.h" +#include "RimEclipseViewCollection.h" #include "RimSimWellInViewCollection.h" #include "Riu3DMainWindowTools.h" @@ -99,9 +100,13 @@ void RicPasteEclipseViewsFeature::onActionTriggered( bool isChecked ) eclipseCase->contourMapCollection()->addView( contourMapView ); } + else if ( auto viewCollection = dynamic_cast( destinationObject ) ) + { + viewCollection->addView( rimReservoirView ); + } else { - eclipseCase->reservoirViews().push_back( rimReservoirView ); + eclipseCase->viewCollection()->addView( rimReservoirView ); } rimReservoirView->setEclipseCase( eclipseCase ); From c3d8f13eebfca77265a6c72a3dd05c85d8c612fd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 29 Aug 2024 08:34:40 +0200 Subject: [PATCH 264/332] Bump to dev.15 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index fd6bfbf635..4e94d1f087 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".14") +set(RESINSIGHT_DEV_VERSION ".15") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 681b4fbffee11e18b10d17ebb87832d145c6ad52 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 29 Aug 2024 09:37:07 +0200 Subject: [PATCH 265/332] #11650 Cloud data configuration file search order Check multiple locations for configuration files. The first valid configuration file is used. Currently, using Qt5 the ResInsight binary file is stored at the root of the installation folder. When moving to Qt6, we will probably use sub folders /bin /lib and others. Support both one and two search levels to support Qt6. --- .../Application/RiaApplication.cpp | 49 ++++++++++++++----- .../Application/RiaPreferences.cpp | 2 + 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 3c6759a6da..f3c2e9166a 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -1533,27 +1533,52 @@ cvf::Font* RiaApplication::defaultWellLabelFont() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -auto readConfigFiles = []( RiaPreferences* preferences ) +auto readCloudConfigFiles = []( RiaPreferences* preferences ) { if ( preferences == nullptr ) return; + // Check multiple locations for configuration files. The first valid configuration file is used. Currently, using Qt5 the ResInsight + // binary file is stored at the root of the installation folder. When moving to Qt6, we will probably use sub folders /bin /lib and + // others. Support both one and two search levels to support Qt6. + // + // home_folder/.resinsight/*_config.json + // location_of_resinsight_executable/../share/cloud_services/*_config.json + // location_of_resinsight_executable/../../share/cloud_services/*_config.json + // + { - QString osduConfigPath = QDir::homePath() + "/.resinsight/osdu_config.json"; - auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( osduConfigPath ); - if ( !keyValuePairs.empty() ) + QStringList osduFilePathCandidates; + osduFilePathCandidates << QDir::homePath() + "/.resinsight/osdu_config.json"; + osduFilePathCandidates << QCoreApplication::applicationDirPath() + "/../share/cloud_services/osdu_config.json"; + osduFilePathCandidates << QCoreApplication::applicationDirPath() + "/../../share/cloud_services/osdu_config.json"; + + for ( const auto& osduFileCandidate : osduFilePathCandidates ) { - preferences->osduPreferences()->setData( keyValuePairs ); - preferences->osduPreferences()->setFieldsReadOnly(); + auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( osduFileCandidate ); + if ( !keyValuePairs.empty() ) + { + preferences->osduPreferences()->setData( keyValuePairs ); + preferences->osduPreferences()->setFieldsReadOnly(); + break; + } } } { - QString sumoConfigPath = QDir::homePath() + "/.resinsight/sumo_config.json"; - auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( sumoConfigPath ); - if ( !keyValuePairs.empty() ) + QStringList sumoFilePathCandidates; + sumoFilePathCandidates << QDir::homePath() + "/.resinsight/sumo_config.json"; + sumoFilePathCandidates << QCoreApplication::applicationDirPath() + "/../share/cloud_services/sumo_config.json"; + sumoFilePathCandidates << QCoreApplication::applicationDirPath() + "/../../share/cloud_services/sumo_config.json"; + + for ( const auto& sumoFileCandidate : sumoFilePathCandidates ) { - preferences->sumoPreferences()->setData( keyValuePairs ); - preferences->sumoPreferences()->setFieldsReadOnly(); + auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( sumoFileCandidate ); + if ( !keyValuePairs.empty() ) + { + preferences->sumoPreferences()->setData( keyValuePairs ); + preferences->sumoPreferences()->setFieldsReadOnly(); + break; + } } } }; @@ -1577,7 +1602,7 @@ void RiaApplication::initialize() initializeDataLoadController(); - readConfigFiles( m_preferences.get() ); + readCloudConfigFiles( m_preferences.get() ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index 131551e6f1..ff64446bc2 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -475,9 +475,11 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& otherGroup->add( &m_summaryCalculationExpressionFolder ); caf::PdmUiGroup* osduGroup = uiOrdering.addNewGroup( "OSDU" ); + osduGroup->setCollapsedByDefault(); m_osduPreferences()->uiOrdering( uiConfigName, *osduGroup ); caf::PdmUiGroup* sumoGroup = uiOrdering.addNewGroup( "SUMO" ); + sumoGroup->setCollapsedByDefault(); m_sumoPreferences()->uiOrdering( uiConfigName, *sumoGroup ); } else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() ) From 24fcec79ab1e65bd40a93ccd4a1a6c3837e827aa Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 30 Aug 2024 10:03:03 +0200 Subject: [PATCH 266/332] Look for fault definition in Pflotran input files Look for fault definition in Pflotran input files If no *.DATA file is found, look for *.IN file and search for fault definitions. --- .../RifEclipseInputFileTools.cpp | 101 ++++++ .../FileInterface/RifEclipseInputFileTools.h | 2 + .../FileInterface/RifReaderInterface.cpp | 24 +- .../RifEclipseInputFileTools-Test.cpp | 18 ++ .../pflotran/include/Faults_test_KH.grdecl | 287 ++++++++++++++++++ .../pflotran/include/ccs_3df_kh.grdecl | 27 ++ .../pflotran/model/P_FLT_TEST_NO-KH.in | 24 ++ 7 files changed, 480 insertions(+), 3 deletions(-) create mode 100644 ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/Faults_test_KH.grdecl create mode 100644 ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/ccs_3df_kh.grdecl create mode 100644 ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/model/P_FLT_TEST_NO-KH.in diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp index ee4c7f9c19..28bc9d940a 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp @@ -1054,6 +1054,107 @@ QString RifEclipseInputFileTools::faultFaceText( cvf::StructGridInterface::FaceT return ""; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseInputFileTools::parsePflotranInputFile( const QString& fileName, cvf::Collection* faults ) +{ + QStringList gridSectionFilenames; + + RiaLogging::info( "Looking for 'Pflotran' fault definitions in " + fileName ); + + { + // Find all referenced grdecl files in a pflotran input file, in the GRID section, example + /* + GRID + TYPE grdecl ../include/ccs_3df_kh.grdecl + TYPE grdecl ../include/ccs_3df_other.grdecl + END + */ + + QFile file( fileName ); + if ( !file.open( QFile::ReadOnly ) ) return; + + bool continueParsing = true; + bool foundGridKeyword = false; + bool foundEndKeyword = false; + do + { + QString line; + line = file.readLine().trimmed(); + + if ( line.startsWith( "GRID" ) ) foundGridKeyword = true; + + if ( foundGridKeyword ) + { + if ( line.startsWith( "TYPE" ) ) + { + auto words = RiaTextStringTools::splitSkipEmptyParts( line, " " ); + if ( words.size() == 3 && words[1].startsWith( "grdecl", Qt::CaseInsensitive ) ) + { + QFileInfo fi( fileName ); + QDir currentFileFolder = fi.absoluteDir(); + + QString absoluteFilePath = currentFileFolder.absoluteFilePath( words.back() ); + gridSectionFilenames.push_back( absoluteFilePath ); + } + } + + if ( line.startsWith( "END" ) ) foundEndKeyword = true; + } + + if ( foundEndKeyword || file.atEnd() ) + { + continueParsing = false; + } + + } while ( continueParsing ); + } + + // Find all grdecl files defined by the external_file keyword + // For all these files, search for the FAULTS keyword and create fault objects + /* + external_file ccs_3df_kh.grdecl + external_file ccs_3df_other.grdecl + */ + + for ( const auto& gridSectionFilename : gridSectionFilenames ) + { + QFile file( gridSectionFilename ); + if ( !file.open( QFile::ReadOnly ) ) continue; + + do + { + QString line; + line = file.readLine().trimmed(); + + if ( line.startsWith( "external_file", Qt::CaseInsensitive ) ) + { + auto words = RiaTextStringTools::splitSkipEmptyParts( line, " " ); + if ( words.size() == 2 ) + { + QFileInfo fi( gridSectionFilename ); + QDir currentFileFolder = fi.absoluteDir(); + + QString absoluteFilePath = currentFileFolder.absoluteFilePath( words.back() ); + QFile grdeclFilename( absoluteFilePath ); + if ( !grdeclFilename.open( QFile::ReadOnly ) ) continue; + + auto currentFaultCount = faults->size(); + + readFaults( grdeclFilename, 0, faults, nullptr ); + + if ( currentFaultCount != faults->size() ) + { + RiaLogging::info( "Imported faults from " + absoluteFilePath ); + } + } + } + + } while ( !file.atEnd() ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.h b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.h index 70db3f726e..ce23b7041d 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.h +++ b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.h @@ -126,6 +126,8 @@ class RifEclipseInputFileTools : public cvf::Object static bool hasGridData( const QString& fileName ); + static void parsePflotranInputFile( const QString& fileName, cvf::Collection* faults ); + private: static void readFaults( QFile& data, qint64 filePos, cvf::Collection* faults, bool* isEditKeywordDetected ); diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp index fc6d643bd7..48da9d6007 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp @@ -19,6 +19,7 @@ #include "RifReaderInterface.h" +#include "RiaLogging.h" #include "RiaPreferencesGrid.h" #include "RifEclipseInputFileTools.h" @@ -159,12 +160,16 @@ void RifReaderInterface::importFaults( const QStringList& fileSet, cvf::Collecti } else { - foreach ( QString fname, fileSet ) + bool isDataFileFound = false; + + for ( const auto& filename : fileSet ) { - if ( fname.endsWith( ".DATA" ) ) + if ( filename.endsWith( ".DATA" ) ) { + isDataFileFound = true; + std::vector filenamesWithFaults; - RifEclipseInputFileTools::readFaultsInGridSection( fname, faults, &filenamesWithFaults, faultIncludeFileAbsolutePathPrefix() ); + RifEclipseInputFileTools::readFaultsInGridSection( filename, faults, &filenamesWithFaults, faultIncludeFileAbsolutePathPrefix() ); std::sort( filenamesWithFaults.begin(), filenamesWithFaults.end() ); std::vector::iterator last = std::unique( filenamesWithFaults.begin(), filenamesWithFaults.end() ); @@ -173,5 +178,18 @@ void RifReaderInterface::importFaults( const QStringList& fileSet, cvf::Collecti setFilenamesWithFaults( filenamesWithFaults ); } } + + if ( !isDataFileFound ) + { + RiaLogging::info( "No *.DATA file is found" ); + + for ( const auto& filename : fileSet ) + { + if ( filename.endsWith( ".IN", Qt::CaseInsensitive ) ) + { + RifEclipseInputFileTools::parsePflotranInputFile( filename, faults ); + } + } + } } } diff --git a/ApplicationLibCode/UnitTests/RifEclipseInputFileTools-Test.cpp b/ApplicationLibCode/UnitTests/RifEclipseInputFileTools-Test.cpp index 0204f6a495..4fc7da0395 100644 --- a/ApplicationLibCode/UnitTests/RifEclipseInputFileTools-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifEclipseInputFileTools-Test.cpp @@ -251,6 +251,24 @@ TEST( RifEclipseInputFileToolsTest, FaultData ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RifEclipseInputFileToolsTest, FaultDataPflotran ) +{ + static const QString testDataRootFolder = QString( "%1/RifEclipseInputFileTools/pflotran" ).arg( TEST_DATA_DIR ); + + { + QString fileName = testDataRootFolder + "/model/P_FLT_TEST_NO-KH.in"; + + cvf::Collection faults; + + RifEclipseInputFileTools::parsePflotranInputFile( fileName, &faults ); + + EXPECT_EQ( (size_t)4, faults.size() ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/Faults_test_KH.grdecl b/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/Faults_test_KH.grdecl new file mode 100644 index 0000000000..0b5f25153b --- /dev/null +++ b/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/Faults_test_KH.grdecl @@ -0,0 +1,287 @@ +NOECHO + + +SPECGRID + 30 30 12 F / + + +FAULTS +-- NAME IX1 IX2 IY1 IY2 IZ1 IZ2 FACE + +'F_TEST1' 8 8 1 1 1 12 J / +'F_TEST1' 8 8 1 1 1 12 I- / +'F_TEST1' 9 9 2 2 1 12 J / +'F_TEST1' 9 9 2 2 1 12 I- / +'F_TEST1' 10 10 3 3 1 12 J / +'F_TEST1' 10 10 3 3 1 12 I- / + +'F_TEST2' 2 2 1 1 1 12 J / +'F_TEST2' 2 2 1 1 1 12 I- / +'F_TEST2' 3 3 2 2 1 12 J / +'F_TEST2' 3 3 2 2 1 12 I- / +'F_TEST2' 4 4 3 3 1 12 J / +'F_TEST2' 4 4 3 3 1 12 I- / + +'F_ORIG1' 1 1 21 21 1 5 I / +'F_ORIG1' 1 1 21 21 8 8 I / +'F_ORIG1' 1 1 21 21 11 12 I / +'F_ORIG1' 1 1 21 21 1 6 J / +'F_ORIG1' 1 1 21 21 8 9 J / +'F_ORIG1' 1 1 21 21 11 12 J / +'F_ORIG1' 2 2 20 20 1 2 I / +'F_ORIG1' 2 2 20 20 5 5 I / +'F_ORIG1' 2 2 20 20 7 12 I / +'F_ORIG1' 2 2 20 20 1 3 J / +'F_ORIG1' 2 2 20 20 5 5 J / +'F_ORIG1' 2 2 20 20 8 8 J / +'F_ORIG1' 2 2 20 20 11 12 J / +'F_ORIG1' 3 3 19 19 1 2 I / +'F_ORIG1' 3 3 19 19 5 7 I / +'F_ORIG1' 3 3 19 19 10 12 I / +'F_ORIG1' 3 3 19 19 1 2 J / +'F_ORIG1' 3 3 19 19 5 8 J / +'F_ORIG1' 3 3 19 19 10 12 J / +'F_ORIG1' 4 4 18 18 1 2 I / +'F_ORIG1' 4 4 18 18 5 5 I / +'F_ORIG1' 4 4 18 18 7 10 I / +'F_ORIG1' 4 4 18 18 12 12 I / +'F_ORIG1' 4 4 18 18 1 2 J / +'F_ORIG1' 4 4 18 18 4 5 J / +'F_ORIG1' 4 4 18 18 7 7 J / +'F_ORIG1' 4 4 18 18 9 10 J / +'F_ORIG1' 4 4 18 18 12 12 J / +'F_ORIG1' 5 5 17 17 2 2 I / +'F_ORIG1' 5 5 17 17 4 4 I / +'F_ORIG1' 5 5 17 17 6 10 I / +'F_ORIG1' 5 5 17 17 12 12 I / +'F_ORIG1' 5 5 17 17 1 2 J / +'F_ORIG1' 5 5 17 17 5 10 J / +'F_ORIG1' 5 5 17 17 12 12 J / +'F_ORIG1' 6 6 16 16 1 10 I / +'F_ORIG1' 6 6 16 16 2 2 J / +'F_ORIG1' 6 6 16 16 4 4 J / +'F_ORIG1' 6 6 16 16 6 10 J / +'F_ORIG1' 7 7 15 15 3 3 I / +'F_ORIG1' 7 7 15 15 6 11 I / +'F_ORIG1' 7 7 15 15 3 4 J / +'F_ORIG1' 7 7 15 15 6 12 J / +'F_ORIG1' 8 8 14 14 1 1 I / +'F_ORIG1' 8 8 14 14 3 9 I / +'F_ORIG1' 8 8 14 14 11 12 I / +'F_ORIG1' 8 8 14 14 1 1 J / +'F_ORIG1' 8 8 14 14 3 3 J / +'F_ORIG1' 8 8 14 14 6 11 J / +'F_ORIG1' 9 9 13 13 1 1 I / +'F_ORIG1' 9 9 13 13 3 12 I / +'F_ORIG1' 9 9 13 13 1 1 J / +'F_ORIG1' 9 9 13 13 3 9 J / +'F_ORIG1' 9 9 13 13 11 12 J / +'F_ORIG1' 10 10 12 12 1 1 I / +'F_ORIG1' 10 10 12 12 4 6 I / +'F_ORIG1' 10 10 12 12 8 8 I / +'F_ORIG1' 10 10 12 12 10 11 I / +'F_ORIG1' 10 10 12 12 1 1 J / +'F_ORIG1' 10 10 12 12 4 8 J / +'F_ORIG1' 10 10 12 12 10 11 J / +'F_ORIG1' 11 11 11 11 2 6 I / +'F_ORIG1' 11 11 11 11 8 8 I / +'F_ORIG1' 11 11 11 11 3 6 J / +'F_ORIG1' 11 11 11 11 8 8 J / +'F_ORIG1' 11 11 11 11 11 11 J / +'F_ORIG1' 12 12 10 10 1 1 I / +'F_ORIG1' 12 12 10 10 3 6 I / +'F_ORIG1' 12 12 10 10 8 11 I / +'F_ORIG1' 12 12 10 10 1 6 J / +'F_ORIG1' 12 12 10 10 8 10 J / +'F_ORIG1' 13 13 9 9 3 3 I / +'F_ORIG1' 13 13 9 9 5 10 I / +'F_ORIG1' 13 13 9 9 12 12 I / +'F_ORIG1' 13 13 9 9 1 1 J / +'F_ORIG1' 13 13 9 9 3 3 J / +'F_ORIG1' 13 13 9 9 5 12 J / +'F_ORIG1' 14 14 8 8 3 3 I / +'F_ORIG1' 14 14 8 8 7 7 I / +'F_ORIG1' 14 14 8 8 9 12 I / +'F_ORIG1' 14 14 8 8 3 3 J / +'F_ORIG1' 14 14 8 8 7 10 J / +'F_ORIG1' 14 14 8 8 12 12 J / +'F_ORIG1' 15 15 7 7 3 4 I / +'F_ORIG1' 15 15 7 7 6 12 I / +'F_ORIG1' 15 15 7 7 2 4 J / +'F_ORIG1' 15 15 7 7 6 7 J / +'F_ORIG1' 15 15 7 7 9 12 J / +'F_ORIG1' 16 16 6 6 1 4 I / +'F_ORIG1' 16 16 6 6 6 7 I / +'F_ORIG1' 16 16 6 6 9 12 I / +'F_ORIG1' 16 16 6 6 1 1 J / +'F_ORIG1' 16 16 6 6 3 4 J / +'F_ORIG1' 16 16 6 6 6 12 J / +'F_ORIG1' 17 17 5 5 1 2 J / +'F_ORIG1' 17 17 5 5 4 4 J / +'F_ORIG1' 17 17 5 5 6 7 J / +'F_ORIG1' 17 17 5 5 9 9 J / +'F_ORIG1' 17 17 5 5 11 12 J / +'F_ORIG1' 18 18 4 4 1 2 I / +'F_ORIG1' 18 18 4 4 4 7 I / +'F_ORIG1' 18 18 4 4 11 11 I / +'F_ORIG1' 18 18 4 4 1 2 J / +'F_ORIG1' 18 18 4 4 4 5 J / +'F_ORIG1' 18 18 4 4 7 8 J / +'F_ORIG1' 18 18 4 4 10 11 J / +'F_ORIG1' 19 19 3 3 3 5 I / +'F_ORIG1' 19 19 3 3 7 9 I / +'F_ORIG1' 19 19 3 3 11 12 I / +'F_ORIG1' 19 19 3 3 2 2 J / +'F_ORIG1' 19 19 3 3 4 7 J / +'F_ORIG1' 19 19 3 3 11 11 J / +'F_ORIG1' 20 20 2 2 2 3 I / +'F_ORIG1' 20 20 2 2 5 10 I / +'F_ORIG1' 20 20 2 2 12 12 I / +'F_ORIG1' 20 20 2 2 3 3 J / +'F_ORIG1' 20 20 2 2 5 5 J / +'F_ORIG1' 20 20 2 2 7 12 J / +'F_ORIG1' 21 21 1 1 1 5 I / +'F_ORIG1' 21 21 1 1 8 11 I / +'F_ORIG1' 21 21 1 1 1 5 J / +'F_ORIG1' 21 21 1 1 7 10 J / +'F_ORIG1' 21 21 1 1 12 12 J / + +'F_ORIG2' 15 15 1 1 1 3 I / +'F_ORIG2' 15 15 1 1 5 6 I / +'F_ORIG2' 15 15 1 1 8 9 I / +'F_ORIG2' 15 15 1 1 11 11 I / +'F_ORIG2' 16 16 1 1 1 3 J / +'F_ORIG2' 16 16 1 1 5 8 J / +'F_ORIG2' 16 16 1 1 10 11 J / +'F_ORIG2' 16 16 2 2 1 3 I / +'F_ORIG2' 16 16 2 2 5 5 I / +'F_ORIG2' 16 16 2 2 7 8 I / +'F_ORIG2' 16 16 2 2 10 12 I / +'F_ORIG2' 16 16 3 3 1 3 I / +'F_ORIG2' 16 16 3 3 6 7 I / +'F_ORIG2' 16 16 3 3 10 10 I / +'F_ORIG2' 16 16 3 3 12 12 I / +'F_ORIG2' 17 17 3 3 2 2 J / +'F_ORIG2' 17 17 3 3 4 4 J / +'F_ORIG2' 17 17 3 3 7 8 J / +'F_ORIG2' 17 17 3 3 10 10 J / +'F_ORIG2' 17 17 3 3 12 12 J / +'F_ORIG2' 17 17 4 4 2 2 I / +'F_ORIG2' 17 17 4 4 4 5 I / +'F_ORIG2' 17 17 4 4 7 8 I / +'F_ORIG2' 17 17 4 4 10 10 I / +'F_ORIG2' 17 17 4 4 12 12 I / +'F_ORIG2' 17 17 5 5 1 2 I / +'F_ORIG2' 17 17 5 5 4 5 I / +'F_ORIG2' 17 17 5 5 7 7 I / +'F_ORIG2' 17 17 5 5 11 11 I / +'F_ORIG2' 18 18 5 5 1 2 J / +'F_ORIG2' 18 18 5 5 5 5 J / +'F_ORIG2' 18 18 5 5 7 8 J / +'F_ORIG2' 18 18 5 5 10 10 J / +'F_ORIG2' 18 18 6 6 1 3 I / +'F_ORIG2' 18 18 6 6 7 10 I / +'F_ORIG2' 18 18 7 7 1 2 I / +'F_ORIG2' 18 18 7 7 4 5 I / +'F_ORIG2' 18 18 7 7 9 12 I / +'F_ORIG2' 19 19 7 7 1 2 J / +'F_ORIG2' 19 19 7 7 4 6 J / +'F_ORIG2' 19 19 7 7 10 12 J / +'F_ORIG2' 19 19 8 8 1 5 I / +'F_ORIG2' 19 19 8 8 8 8 I / +'F_ORIG2' 19 19 8 8 10 11 I / +'F_ORIG2' 19 19 9 9 2 2 I / +'F_ORIG2' 19 19 9 9 4 12 I / +'F_ORIG2' 20 20 9 9 1 2 J / +'F_ORIG2' 20 20 9 9 4 12 J / +'F_ORIG2' 20 20 10 10 1 4 I / +'F_ORIG2' 20 20 10 10 6 9 I / +'F_ORIG2' 20 20 10 10 11 12 I / +'F_ORIG2' 20 20 11 11 1 6 I / +'F_ORIG2' 20 20 11 11 8 8 I / +'F_ORIG2' 20 20 11 11 10 11 I / +'F_ORIG2' 21 21 11 11 1 3 J / +'F_ORIG2' 21 21 11 11 5 6 J / +'F_ORIG2' 21 21 11 11 11 11 J / +'F_ORIG2' 21 21 12 12 1 1 I / +'F_ORIG2' 21 21 12 12 3 3 I / +'F_ORIG2' 21 21 12 12 6 6 I / +'F_ORIG2' 21 21 12 12 11 12 I / +'F_ORIG2' 21 21 13 13 3 3 I / +'F_ORIG2' 21 21 13 13 6 12 I / +'F_ORIG2' 22 22 13 13 3 3 J / +'F_ORIG2' 22 22 13 13 7 7 J / +'F_ORIG2' 22 22 13 13 10 12 J / +'F_ORIG2' 22 22 14 14 2 2 I / +'F_ORIG2' 22 22 14 14 4 4 I / +'F_ORIG2' 22 22 14 14 7 7 I / +'F_ORIG2' 22 22 14 14 10 12 I / +'F_ORIG2' 22 22 15 15 1 3 I / +'F_ORIG2' 22 22 15 15 6 7 I / +'F_ORIG2' 22 22 15 15 9 11 I / +'F_ORIG2' 23 23 15 15 2 3 J / +'F_ORIG2' 23 23 15 15 6 7 J / +'F_ORIG2' 23 23 15 15 9 11 J / +'F_ORIG2' 23 23 16 16 2 7 I / +'F_ORIG2' 23 23 16 16 10 12 I / +'F_ORIG2' 23 23 17 17 1 7 I / +'F_ORIG2' 23 23 17 17 10 12 I / +'F_ORIG2' 24 24 17 17 1 7 J / +'F_ORIG2' 24 24 17 17 10 12 J / +'F_ORIG2' 24 24 18 18 1 2 I / +'F_ORIG2' 24 24 18 18 6 8 I / +'F_ORIG2' 24 24 18 18 10 10 I / +'F_ORIG2' 24 24 18 18 12 12 I / +'F_ORIG2' 24 24 19 19 1 2 I / +'F_ORIG2' 24 24 19 19 5 6 I / +'F_ORIG2' 24 24 19 19 8 8 I / +'F_ORIG2' 24 24 19 19 10 12 I / +'F_ORIG2' 25 25 19 19 1 1 J / +'F_ORIG2' 25 25 19 19 4 6 J / +'F_ORIG2' 25 25 19 19 8 8 J / +'F_ORIG2' 25 25 19 19 10 11 J / +'F_ORIG2' 25 25 20 20 1 1 I / +'F_ORIG2' 25 25 20 20 4 4 I / +'F_ORIG2' 25 25 20 20 6 8 I / +'F_ORIG2' 25 25 20 20 10 11 I / +'F_ORIG2' 25 25 21 21 1 1 I / +'F_ORIG2' 25 25 21 21 6 11 I / +'F_ORIG2' 26 26 21 21 1 1 J / +'F_ORIG2' 26 26 21 21 4 4 J / +'F_ORIG2' 26 26 21 21 6 11 J / +'F_ORIG2' 26 26 22 22 1 1 I / +'F_ORIG2' 26 26 22 22 3 4 I / +'F_ORIG2' 26 26 22 22 6 10 I / +'F_ORIG2' 26 26 23 23 1 8 I / +'F_ORIG2' 26 26 23 23 10 10 I / +'F_ORIG2' 26 26 23 23 12 12 I / +'F_ORIG2' 27 27 23 23 1 10 J / +'F_ORIG2' 27 27 23 23 12 12 J / +'F_ORIG2' 27 27 24 24 1 2 I / +'F_ORIG2' 27 27 24 24 5 9 I / +'F_ORIG2' 27 27 24 24 12 12 I / +'F_ORIG2' 27 27 25 25 3 3 I / +'F_ORIG2' 27 27 25 25 6 6 I / +'F_ORIG2' 27 27 25 25 10 10 I / +'F_ORIG2' 27 27 25 25 12 12 I / +'F_ORIG2' 28 28 25 25 3 3 J / +'F_ORIG2' 28 28 25 25 6 7 J / +'F_ORIG2' 28 28 25 25 9 12 J / +'F_ORIG2' 28 28 26 26 2 2 I / +'F_ORIG2' 28 28 26 26 4 4 I / +'F_ORIG2' 28 28 26 26 6 11 I / +'F_ORIG2' 28 28 27 27 1 1 I / +'F_ORIG2' 28 28 27 27 4 6 I / +'F_ORIG2' 28 28 27 27 9 12 I / +'F_ORIG2' 29 29 27 27 2 2 J / +'F_ORIG2' 29 29 27 27 4 6 J / +'F_ORIG2' 29 29 27 27 9 12 J / +'F_ORIG2' 29 29 28 28 2 5 I / +'F_ORIG2' 29 29 28 28 8 11 I / +'F_ORIG2' 29 29 29 29 1 3 I / +'F_ORIG2' 29 29 29 29 5 5 I / +'F_ORIG2' 29 29 29 29 7 9 I / +'F_ORIG2' 30 30 29 29 2 3 J / +'F_ORIG2' 30 30 29 29 7 10 J / +/ +ECHO diff --git a/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/ccs_3df_kh.grdecl b/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/ccs_3df_kh.grdecl new file mode 100644 index 0000000000..b4ad7e7bc5 --- /dev/null +++ b/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/ccs_3df_kh.grdecl @@ -0,0 +1,27 @@ +DIMENS +30 30 12 / + +external_file ccs_3df_geom_kh.grdecl + +external_file ccs_3df_prop.grdecl + +external_file Faults_test_KH.grdecl + +external_file multflt_test_KH.grdecl + +EQUALS + ACTNUM 0 7 7 15 15 1 1 + ACTNUM 0 30 30 29 29 12 12 +/ + + +EQUALS +FIPNUM 1 1 30 1 30 1 2 / overburden +FIPNUM 2 1 30 1 30 1 6 / +FIPNUM 3 1 30 1 30 1 4 / +/ + +EQUALS +SATNUM 1 / +IMBNUM 2 / +/ diff --git a/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/model/P_FLT_TEST_NO-KH.in b/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/model/P_FLT_TEST_NO-KH.in new file mode 100644 index 0000000000..399110ddfe --- /dev/null +++ b/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/model/P_FLT_TEST_NO-KH.in @@ -0,0 +1,24 @@ + +SIMULATION + SIMULATION_TYPE SUBSURFACE + PROCESS_MODELS + SUBSURFACE_FLOW Flow + MODE GAS_WATER + OPTIONS + RESERVOIR_DEFAULTS + ISOTHERMAL + HYSTERESIS + STRAND + / + / ! end of subsurface_flow + / +END !! end simulation block + +SUBSURFACE + +#=========================== discretization =================================== + +GRID + TYPE grdecl ../include/ccs_3df_kh.grdecl +END + From cf23a6ae5f8b001e54ef23466689dfbba5aa627e Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 28 Aug 2024 15:29:31 +0200 Subject: [PATCH 267/332] Improve name of Summary Curve Calculator. --- .../RicShowSummaryCurveCalculatorFeature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp index 478cfb2bda..4ab75ad42f 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp @@ -80,6 +80,6 @@ void RicShowSummaryCurveCalculatorFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicShowSummaryCurveCalculatorFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "Curve Calculator" ); + actionToSetup->setText( "Summary Curve Calculator" ); actionToSetup->setIcon( QIcon( ":/Calculator.svg" ) ); } From cf7a38375d2b9714610c8aa7486eadfe5157f75b Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 28 Aug 2024 15:41:51 +0200 Subject: [PATCH 268/332] #11649 Reverse order of terms in polynomial expression. --- ApplicationLibCode/Application/Tools/RiaRegressionTextTools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/Application/Tools/RiaRegressionTextTools.cpp b/ApplicationLibCode/Application/Tools/RiaRegressionTextTools.cpp index b0756300a9..89c507e4e7 100644 --- a/ApplicationLibCode/Application/Tools/RiaRegressionTextTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaRegressionTextTools.cpp @@ -49,7 +49,7 @@ QString RiaRegressionTextTools::generateRegressionText( const regression::Polyno bool isFirst = true; std::vector coeffs = reg.coeffisients(); QStringList parts; - for ( size_t i = 0; i < coeffs.size(); i++ ) + for ( int i = static_cast( coeffs.size() ) - 1; i >= 0; i-- ) { double coeff = coeffs[i]; // Skip zero coeffs From cbb7e101e29d93e19a2e248cc78285744f139749 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 30 Aug 2024 08:59:12 +0200 Subject: [PATCH 269/332] #11649 Hide X axis in Result Plot before data has been set. --- ApplicationLibCode/UserInterface/RiuResultQwtPlot.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ApplicationLibCode/UserInterface/RiuResultQwtPlot.cpp b/ApplicationLibCode/UserInterface/RiuResultQwtPlot.cpp index ced34d866f..aafd930867 100644 --- a/ApplicationLibCode/UserInterface/RiuResultQwtPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuResultQwtPlot.cpp @@ -35,6 +35,7 @@ #include "cvfColor3.h" +#include "qwt_axis_id.h" #include "qwt_date_scale_draw.h" #include "qwt_date_scale_engine.h" #include "qwt_legend.h" @@ -54,6 +55,7 @@ RiuResultQwtPlot::RiuResultQwtPlot( QWidget* parent ) { setAutoFillBackground( true ); setDefaults(); + setAxisVisible( QwtAxis::XBottom, false ); } //-------------------------------------------------------------------------------------------------- @@ -91,6 +93,8 @@ void RiuResultQwtPlot::addCurve( const RimCase* rimCase, setAxisScale( QwtAxis::XTop, QwtDate::toDouble( dateTimes.front() ), QwtDate::toDouble( dateTimes.back() ) ); applyFontSizes( false ); + setAxisVisible( QwtAxis::XBottom, true ); + replot(); int caseId = rimCase->caseId(); From 9deeb41f4c84de3b699f0050e264515d143b7621 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 2 Sep 2024 08:06:56 +0200 Subject: [PATCH 270/332] Drop vcpkg from update-submodule automation --- .github/workflows/update-submodules.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/update-submodules.yml b/.github/workflows/update-submodules.yml index 9ec2bbd695..096a5661e0 100644 --- a/.github/workflows/update-submodules.yml +++ b/.github/workflows/update-submodules.yml @@ -12,7 +12,6 @@ jobs: matrix: submodule: - tomlplusplus - - vcpkg steps: - name: Checkout repository From 33188f3d6e8e88993fc4e0f586276f866f7b8516 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 2 Sep 2024 12:40:00 +0200 Subject: [PATCH 271/332] Improve robustness when importing incomplete project file Avoid assert, and return empty curve definition if both summary case and ensemble is undefined. --- .../AnalysisPlots/RimAnalysisPlotDataEntry.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp index c2e50c5e7c..bd05815aa3 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp @@ -80,11 +80,12 @@ RiaSummaryCurveDefinition RimAnalysisPlotDataEntry::curveDefinition() const { return RiaSummaryCurveDefinition( m_summaryCase(), m_summaryAddress->address(), m_isEnsembleCurve ); } - else + else if ( m_ensemble() ) { - CAF_ASSERT( m_ensemble() ); return RiaSummaryCurveDefinition( m_ensemble(), m_summaryAddress->address() ); } + + return {}; } //-------------------------------------------------------------------------------------------------- From 1736c01dfabf4bbcd41e2ff0c78f84e1944f0310 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 2 Sep 2024 10:25:49 +0200 Subject: [PATCH 272/332] Janitor: fix warning on clang 14. --- ApplicationLibCode/FileInterface/RifRftSegment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/FileInterface/RifRftSegment.cpp b/ApplicationLibCode/FileInterface/RifRftSegment.cpp index 80b73a26f7..384d388291 100644 --- a/ApplicationLibCode/FileInterface/RifRftSegment.cpp +++ b/ApplicationLibCode/FileInterface/RifRftSegment.cpp @@ -361,7 +361,7 @@ std::set RifRftSegment::uniqueOneBasedBranchIndices( RiaDefines::RftBranchT { std::set indices; - for ( const auto [branchId, branchIndex] : m_oneBasedBranchIndexMap ) + for ( const auto& [branchId, branchIndex] : m_oneBasedBranchIndexMap ) { indices.insert( branchIndex ); } From d8eb34c00d288dddeb1b75c3c2c0f15e1581d577 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 2 Sep 2024 11:57:07 +0200 Subject: [PATCH 273/332] Janitor: fix memory leaks. --- ApplicationLibCode/Application/RiaApplication.cpp | 11 +++++++++++ .../Application/RiaGuiApplication.cpp | 3 +++ ApplicationLibCode/ProjectDataModel/Rim3dView.cpp | 2 +- ApplicationLibCode/UserInterface/RiuWellLogPlot.cpp | 13 +++++++++++-- ApplicationLibCode/UserInterface/RiuWellLogPlot.h | 1 + .../cafUserInterface/cafPdmUiTreeEditorHandle.h | 6 +++++- .../cafUserInterface/cafPdmUiTreeViewEditor.h | 6 +++++- 7 files changed, 37 insertions(+), 5 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index f3c2e9166a..976d519475 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -174,6 +174,7 @@ RiaApplication::RiaApplication() m_commandRouter = std::make_unique(); m_osduConnector = nullptr; + m_sumoConnector = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -184,6 +185,16 @@ RiaApplication::~RiaApplication() RiaFontCache::clear(); caf::SelectionManager::instance()->setPdmRootObject( nullptr ); + + m_project.reset(); + + delete m_osduConnector.data(); + m_osduConnector.clear(); + m_osduConnector = nullptr; + + delete m_sumoConnector.data(); + m_sumoConnector.clear(); + m_sumoConnector = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaGuiApplication.cpp b/ApplicationLibCode/Application/RiaGuiApplication.cpp index b08fa79e4a..fa54439c78 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.cpp +++ b/ApplicationLibCode/Application/RiaGuiApplication.cpp @@ -190,7 +190,10 @@ RiaGuiApplication::RiaGuiApplication( int& argc, char** argv ) //-------------------------------------------------------------------------------------------------- RiaGuiApplication::~RiaGuiApplication() { + delete m_mainWindow.data(); m_mainWindow.clear(); + + m_mainPlotWindow.reset(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp index b48917ba63..9aa90a641f 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp @@ -180,7 +180,7 @@ Rim3dView::Rim3dView() // Every timer tick, send a signal for updating animations. // Any animation is supposed to connect to this signal // in order to having only one central animation driver. - m_animationTimer = std::make_unique( new QTimer() ); + m_animationTimer = std::make_unique(); m_animationTimer->setInterval( m_animationIntervalMillisec ); QObject::connect( m_animationTimer.get(), &QTimer::timeout, [this]() { updateAnimations.send(); } ); } diff --git a/ApplicationLibCode/UserInterface/RiuWellLogPlot.cpp b/ApplicationLibCode/UserInterface/RiuWellLogPlot.cpp index dd6f3bff3b..7b9c83f24a 100644 --- a/ApplicationLibCode/UserInterface/RiuWellLogPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuWellLogPlot.cpp @@ -18,7 +18,7 @@ RiuWellLogPlot::RiuWellLogPlot( RimDepthTrackPlot* plotDefinition, QWidget* parent ) : RiuMultiPlotPage( plotDefinition, parent ) { - m_verticalTrackScrollBar = new QScrollBar( nullptr ); + m_verticalTrackScrollBar = new QScrollBar( this ); m_verticalTrackScrollBar->setOrientation( Qt::Vertical ); m_verticalTrackScrollBar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); @@ -27,7 +27,7 @@ RiuWellLogPlot::RiuWellLogPlot( RimDepthTrackPlot* plotDefinition, QWidget* pare connect( m_verticalTrackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) ); - m_horizontalTrackScrollBar = new QScrollBar( nullptr ); + m_horizontalTrackScrollBar = new QScrollBar( this ); m_horizontalTrackScrollBar->setOrientation( Qt::Horizontal ); m_horizontalTrackScrollBar->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); @@ -37,6 +37,15 @@ RiuWellLogPlot::RiuWellLogPlot( RimDepthTrackPlot* plotDefinition, QWidget* pare connect( m_horizontalTrackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuWellLogPlot::~RiuWellLogPlot() +{ + delete m_horizontalTrackScrollBarLayout.data(); + delete m_verticalTrackScrollBarLayout.data(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuWellLogPlot.h b/ApplicationLibCode/UserInterface/RiuWellLogPlot.h index e0f2a16c8a..1bb6462665 100644 --- a/ApplicationLibCode/UserInterface/RiuWellLogPlot.h +++ b/ApplicationLibCode/UserInterface/RiuWellLogPlot.h @@ -28,6 +28,7 @@ class RiuWellLogPlot : public RiuMultiPlotPage Q_OBJECT public: RiuWellLogPlot( RimDepthTrackPlot* plotDefinition, QWidget* parent ); + ~RiuWellLogPlot() override; RimViewWindow* ownerViewWindow() const override; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeEditorHandle.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeEditorHandle.h index ff189e739a..91bd089398 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeEditorHandle.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeEditorHandle.h @@ -54,7 +54,11 @@ class PdmUiTreeEditorHandle : public PdmUiEditorHandle { public: PdmUiTreeEditorHandle() {} - ~PdmUiTreeEditorHandle() override {} + ~PdmUiTreeEditorHandle() override + { + delete m_widget.data(); + m_widget.clear(); + } QWidget* getOrCreateWidget( QWidget* parent ); QWidget* widget() { return m_widget; } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h index 800da2cf66..7e87a34a12 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h @@ -87,8 +87,10 @@ class PdmUiTreeViewWidget : public QTreeView explicit PdmUiTreeViewWidget( QWidget* parent = nullptr ) : QTreeView( parent ) { - setStyle( new PdmUiTreeViewStyle ); + m_style = std::make_shared(); + setStyle( m_style.get() ); }; + ~PdmUiTreeViewWidget() override{}; bool isTreeItemEditWidgetActive() const { return state() == QAbstractItemView::EditingState; } @@ -96,6 +98,8 @@ class PdmUiTreeViewWidget : public QTreeView protected: void dragMoveEvent( QDragMoveEvent* event ) override; void dragLeaveEvent( QDragLeaveEvent* event ) override; + + std::shared_ptr m_style; }; //-------------------------------------------------------------------------------------------------- From f201c72a78d8307d4222d1df32155a910f34ee6e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 2 Sep 2024 14:09:19 +0200 Subject: [PATCH 274/332] Bump to dev.16 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 4e94d1f087..ff487e8883 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".15") +set(RESINSIGHT_DEV_VERSION ".16") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 4a2e730ee0c2205a0487d921906941aa6d82d0d0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 2 Sep 2024 12:58:16 +0200 Subject: [PATCH 275/332] Add modernize-make-unique and modernize-make-shared --- ApplicationLibCode/.clang-tidy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/.clang-tidy b/ApplicationLibCode/.clang-tidy index 3ea3b05fe3..5fd28b04e4 100644 --- a/ApplicationLibCode/.clang-tidy +++ b/ApplicationLibCode/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '-*,modernize-use-override,modernize-deprecated-headers,modernize-use-using,bugprone-bool-pointer-implicit-conversion,bugprone-parent-virtual-call,bugprone-redundant-branch-condition,bugprone-suspicious-semicolon,bugprone-suspicious-string-compare,modernize-redundant-void-arg,readability-static-accessed-through-instance,readability-simplify-boolean-expr,readability-container-size-empty' +Checks: '-*,modernize-use-override,modernize-deprecated-headers,modernize-use-using,modernize-make-unique,modernize-make-shared,bugprone-bool-pointer-implicit-conversion,bugprone-parent-virtual-call,bugprone-redundant-branch-condition,bugprone-suspicious-semicolon,bugprone-suspicious-string-compare,modernize-redundant-void-arg,readability-static-accessed-through-instance,readability-simplify-boolean-expr,readability-container-size-empty' WarningsAsErrors: '' HeaderFilterRegex: 'ApplicationLibCode/*.*$' FormatStyle: 'file' From fc2106edb09dc82d15013188fdd70ab49dc07651 Mon Sep 17 00:00:00 2001 From: magnesj <1793152+magnesj@users.noreply.github.com> Date: Mon, 2 Sep 2024 11:35:00 +0000 Subject: [PATCH 276/332] Fixes by clang-tidy --- .../Application/Tools/RiaFilePathTools.cpp | 4 +-- .../RicExportSelectedWellPathsFeature.cpp | 2 +- .../Commands/RicGridCalculatorDialog.cpp | 4 ++- .../RicSummaryCurveCalculatorDialog.cpp | 5 ++-- .../RicSummaryPlotEditorWidgetCreator.cpp | 3 +- .../RifCaseRealizationParametersReader.cpp | 3 +- .../FileInterface/RifColumnBasedUserData.cpp | 3 +- .../FileInterface/RifCsvUserData.cpp | 3 +- .../RifKeywordVectorUserData.cpp | 3 +- .../RifRevealCsvSectionSummaryReader.cpp | 3 +- .../RifStimPlanCsvSummaryReader.cpp | 3 +- .../Completions/RimFishbones.cpp | 3 +- .../Flow/RimWellAllocationPlot.cpp | 16 +++++----- .../ProjectDataModel/Flow/RimWellPltPlot.cpp | 5 ++-- .../Rim3dOverlayInfoConfig.cpp | 5 ++-- .../RimGridTimeHistoryCurve.cpp | 30 +++++++++---------- .../ProjectDataModel/RimProject.cpp | 3 +- .../RimUserDefinedCalculation.cpp | 3 +- .../StimPlanModel/RimStimPlanModel.cpp | 3 +- .../Summary/RimDerivedSummaryCase.cpp | 3 +- .../Summary/RimEnsembleCurveSet.cpp | 7 +++-- .../Summary/RimSummaryCaseMainCollection.cpp | 5 ++-- .../Surfaces/RimFileSurface.cpp | 3 +- .../WellLog/RimEnsembleWellLogCurveSet.cpp | 3 +- .../WellLog/RimWellLogTrack.cpp | 6 ++-- .../RigEclipseCrossPlotDataExtractor.cpp | 3 +- .../RigFlowDiagSolverInterface.cpp | 22 +++++++------- .../UserInterface/RiuGridCrossQwtPlot.cpp | 3 +- .../RiuSelectionChangedHandler.cpp | 29 +++++++++--------- .../UserInterface/RiuSummaryQwtPlot.cpp | 3 +- .../RiuSummaryVectorSelectionDialog.cpp | 3 +- ...RiuSummaryVectorSelectionWidgetCreator.cpp | 3 +- .../UserInterface/RiuViewer.cpp | 3 +- 33 files changed, 115 insertions(+), 85 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/RiaFilePathTools.cpp b/ApplicationLibCode/Application/Tools/RiaFilePathTools.cpp index 9cb625acd1..aa3d25796b 100644 --- a/ApplicationLibCode/Application/Tools/RiaFilePathTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaFilePathTools.cpp @@ -259,7 +259,7 @@ void addToPathTree( PathNode* node, QStringList pathComponents, const QString& f } } - node->children.push_back( std::unique_ptr( new PathNode( pathComponent, node ) ) ); + node->children.push_back( std::make_unique( pathComponent, node ) ); addToPathTree( node->children.back().get(), pathComponents, fileName ); } else @@ -335,7 +335,7 @@ std::map RiaFilePathTools::keyPathComponentsForEachFilePat allComponents[fileName] = pathComponentsForFile; } - auto topNode = std::unique_ptr( new PathNode( "", nullptr ) ); + auto topNode = std::make_unique( "", nullptr ); for ( auto keyComponentsPair : allComponents ) { diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp index 9c692e92fc..452eb0d040 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp @@ -168,7 +168,7 @@ QFilePtr RicExportSelectedWellPathsFeature::openFileForExport( const QString& fo //-------------------------------------------------------------------------------------------------- QTextStreamPtr RicExportSelectedWellPathsFeature::createOutputFileStream( QFile& file ) { - auto stream = QTextStreamPtr( new QTextStream( &file ) ); + auto stream = std::make_shared( &file ); stream->setRealNumberNotation( QTextStream::FixedNotation ); stream->setRealNumberPrecision( 2 ); return stream; diff --git a/ApplicationLibCode/Commands/RicGridCalculatorDialog.cpp b/ApplicationLibCode/Commands/RicGridCalculatorDialog.cpp index 3a5e53a941..0ec9ab3c48 100644 --- a/ApplicationLibCode/Commands/RicGridCalculatorDialog.cpp +++ b/ApplicationLibCode/Commands/RicGridCalculatorDialog.cpp @@ -18,6 +18,8 @@ #include "RicGridCalculatorDialog.h" +#include + #include "RicCalculatorWidgetCreator.h" #include "RicGridCalculatorUi.h" @@ -75,7 +77,7 @@ QWidget* RicGridCalculatorDialog::getCalculatorWidget() { if ( !m_calcEditor ) { - m_calcEditor = std::unique_ptr( new RicCalculatorWidgetCreator( std::make_unique() ) ); + m_calcEditor = std::make_unique( std::make_unique() ); } return m_calcEditor->getOrCreateWidget( this ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.cpp index a3cf6e491f..ad99dafa5c 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.cpp @@ -18,6 +18,8 @@ #include "RicSummaryCurveCalculatorDialog.h" +#include + #include "RicCalculatorWidgetCreator.h" #include "RicSummaryCurveCalculatorUi.h" @@ -75,8 +77,7 @@ QWidget* RicSummaryCurveCalculatorDialog::getCalculatorWidget() { if ( !m_summaryCalcEditor ) { - m_summaryCalcEditor = - std::unique_ptr( new RicCalculatorWidgetCreator( std::make_unique() ) ); + m_summaryCalcEditor = std::make_unique( std::make_unique() ); } return m_summaryCalcEditor->getOrCreateWidget( this ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorWidgetCreator.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorWidgetCreator.cpp index ecb14439c4..602c66c27b 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorWidgetCreator.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorWidgetCreator.cpp @@ -38,6 +38,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -46,7 +47,7 @@ RicSummaryPlotEditorWidgetCreator::RicSummaryPlotEditorWidgetCreator( QWidget* p { m_parentWidget = parent; - m_summaryCurveCreator.reset( new RicSummaryPlotEditorUi() ); + m_summaryCurveCreator = std::make_unique(); setPdmObject( m_summaryCurveCreator.get() ); } diff --git a/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.cpp b/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.cpp index afaf99d583..979b6301b0 100644 --- a/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.cpp +++ b/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.cpp @@ -27,13 +27,14 @@ #include #include +#include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RifCaseRealizationReader::RifCaseRealizationReader( const QString& fileName ) { - m_parameters = std::shared_ptr( new RigCaseRealizationParameters() ); + m_parameters = std::make_shared(); m_fileName = fileName; } diff --git a/ApplicationLibCode/FileInterface/RifColumnBasedUserData.cpp b/ApplicationLibCode/FileInterface/RifColumnBasedUserData.cpp index dbf3bca8ca..e3eabc5405 100644 --- a/ApplicationLibCode/FileInterface/RifColumnBasedUserData.cpp +++ b/ApplicationLibCode/FileInterface/RifColumnBasedUserData.cpp @@ -31,6 +31,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -56,7 +57,7 @@ bool RifColumnBasedUserData::parse( const QString& data, QString* errorText ) m_mapFromAddressToTimeStepIndex.clear(); m_mapFromAddressToResultIndex.clear(); - m_parser = std::unique_ptr( new RifColumnBasedUserDataParser( data, errorText ) ); + m_parser = std::make_unique( data, errorText ); if ( !m_parser ) { RiaLogging::error( QString( "Failed to parse file" ) ); diff --git a/ApplicationLibCode/FileInterface/RifCsvUserData.cpp b/ApplicationLibCode/FileInterface/RifCsvUserData.cpp index 3559a23682..d60fe4bb77 100644 --- a/ApplicationLibCode/FileInterface/RifCsvUserData.cpp +++ b/ApplicationLibCode/FileInterface/RifCsvUserData.cpp @@ -31,6 +31,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -54,7 +55,7 @@ bool RifCsvUserData::parse( const QString& fileName, const RifAsciiDataParseOpti m_allResultAddresses.clear(); m_mapFromAddressToResultIndex.clear(); - m_parser = std::unique_ptr( new RifCsvUserDataFileParser( fileName, errorText ) ); + m_parser = std::make_unique( fileName, errorText ); if ( !m_parser->parse( parseOptions ) ) { RiaLogging::error( QString( "Failed to parse file" ) ); diff --git a/ApplicationLibCode/FileInterface/RifKeywordVectorUserData.cpp b/ApplicationLibCode/FileInterface/RifKeywordVectorUserData.cpp index e1b7d9de93..ef5df2e43a 100644 --- a/ApplicationLibCode/FileInterface/RifKeywordVectorUserData.cpp +++ b/ApplicationLibCode/FileInterface/RifKeywordVectorUserData.cpp @@ -31,6 +31,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -54,7 +55,7 @@ bool RifKeywordVectorUserData::parse( const QString& data, const QString& custom m_allResultAddresses.clear(); m_timeSteps.clear(); - m_parser = std::unique_ptr( new RifKeywordVectorParser( data ) ); + m_parser = std::make_unique( data ); if ( !m_parser ) { RiaLogging::error( QString( "Failed to parse file" ) ); diff --git a/ApplicationLibCode/FileInterface/RifRevealCsvSectionSummaryReader.cpp b/ApplicationLibCode/FileInterface/RifRevealCsvSectionSummaryReader.cpp index aead5bff80..810ecfb2a8 100644 --- a/ApplicationLibCode/FileInterface/RifRevealCsvSectionSummaryReader.cpp +++ b/ApplicationLibCode/FileInterface/RifRevealCsvSectionSummaryReader.cpp @@ -34,6 +34,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -68,7 +69,7 @@ bool RifRevealCsvSectionSummaryReader::parse( const QString& parseOptions.timeSeriesColumnName = "Date"; parseOptions.defaultCategory = defaultCategory; - m_parser = std::unique_ptr( new RifCsvUserDataPastedTextParser( text, errorText ) ); + m_parser = std::make_unique( text, errorText ); std::map> unitMapping = { { "Sm3", { "SM3", 1.0 } }, { "Sm3/day", { "SM3/DAY", 1.0 } }, { "Sm3/day/bar", { "SM3/DAY/BAR", 1.0 } }, diff --git a/ApplicationLibCode/FileInterface/RifStimPlanCsvSummaryReader.cpp b/ApplicationLibCode/FileInterface/RifStimPlanCsvSummaryReader.cpp index c16989036f..474829495b 100644 --- a/ApplicationLibCode/FileInterface/RifStimPlanCsvSummaryReader.cpp +++ b/ApplicationLibCode/FileInterface/RifStimPlanCsvSummaryReader.cpp @@ -33,6 +33,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -76,7 +77,7 @@ std::pair RifStimPlanCsvSummaryReader::parse( const QString& file parseOptions.timeSeriesColumnName = "Time"; parseOptions.startDateTime = startDateTime; - m_parser = std::unique_ptr( new RifCsvUserDataPastedTextParser( fileContents, errorText ) ); + m_parser = std::make_unique( fileContents, errorText ); if ( !m_parser->parse( parseOptions ) ) { diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbones.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbones.cpp index 2007363447..5e7bd42c9b 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbones.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbones.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include CAF_PDM_SOURCE_INIT( RimFishbones, "FishbonesMultipleSubs" ); @@ -126,7 +127,7 @@ RimFishbones::RimFishbones() m_pipeProperties = new RimFishbonesPipeProperties; - m_rigFishbonesGeometry = std::unique_ptr( new RigFisbonesGeometry( this ) ); + m_rigFishbonesGeometry = std::make_unique( this ); setDeletable( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index b81e7766e6..a35e8c677e 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -18,6 +18,8 @@ #include "RimWellAllocationPlot.h" +#include + #include "RiaNumericalTools.h" #include "RiaPlotDefines.h" #include "RiaPreferences.h" @@ -332,18 +334,18 @@ void RimWellAllocationPlot::updateFromWell() RigEclCellIndexCalculator cellIdxCalc( m_case->eclipseCaseData()->mainGrid(), m_case->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ), nullptr ); - wfCalculator.reset( new RigAccWellFlowCalculator( pipeBranchesCLCoords, - pipeBranchesCellIds, - tracerFractionCellValues, - cellIdxCalc, - smallContributionThreshold, - isProducer ) ); + wfCalculator = std::make_unique( pipeBranchesCLCoords, + pipeBranchesCellIds, + tracerFractionCellValues, + cellIdxCalc, + smallContributionThreshold, + isProducer ); } else { if ( !pipeBranchesCLCoords.empty() ) { - wfCalculator.reset( new RigAccWellFlowCalculator( pipeBranchesCLCoords, pipeBranchesCellIds, smallContributionThreshold ) ); + wfCalculator = std::make_unique( pipeBranchesCLCoords, pipeBranchesCellIds, smallContributionThreshold ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index 81aba6b70e..089c1fdf8d 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -67,6 +67,7 @@ #include #include +#include #include CAF_PDM_SOURCE_INIT( RimWellPltPlot, "WellPltPlot" ); @@ -507,11 +508,11 @@ void RimWellPltPlot::syncCurvesFromUiSelection() if ( sourceDef.sourceType() == RifDataSourceForRftPlt::SourceType::RFT_SIM_WELL_DATA ) { - resultPointCalc.reset( new RigRftResultPointCalculator( m_wellPathName, rimEclipseResultCase, timeStep ) ); + resultPointCalc = std::make_unique( m_wellPathName, rimEclipseResultCase, timeStep ); } else if ( sourceDef.sourceType() == RifDataSourceForRftPlt::SourceType::GRID_MODEL_CELL_DATA ) { - resultPointCalc.reset( new RigSimWellResultPointCalculator( m_wellPathName, rimEclipseResultCase, timeStep ) ); + resultPointCalc = std::make_unique( m_wellPathName, rimEclipseResultCase, timeStep ); } RiaDefines::EclipseUnitSystem unitSet = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN; diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 86f6ef7e2e..7a3c08ed59 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -66,6 +66,7 @@ #include "caf.h" #include +#include CAF_PDM_SOURCE_INIT( Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig" ); //-------------------------------------------------------------------------------------------------- @@ -98,7 +99,7 @@ Rim3dOverlayInfoConfig::Rim3dOverlayInfoConfig() RimHistogramCalculator::StatisticsCellRangeType::VISIBLE_CELLS; CAF_PDM_InitField( &m_statisticsCellRange, "StatisticsCellRange", defaultCellRange, "Statistics Cell Range" ); - m_histogramCalculator.reset( new RimHistogramCalculator ); + m_histogramCalculator = std::make_unique(); } //-------------------------------------------------------------------------------------------------- @@ -240,7 +241,7 @@ RicGridStatisticsDialog* Rim3dOverlayInfoConfig::getOrCreateGridStatisticsDialog { if ( !m_gridStatisticsDialog ) { - m_gridStatisticsDialog.reset( new RicGridStatisticsDialog( nullptr ) ); + m_gridStatisticsDialog = std::make_unique( nullptr ); } CVF_ASSERT( m_gridStatisticsDialog ); return m_gridStatisticsDialog.get(); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp index 030f63e3ec..34d25a2358 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp @@ -18,6 +18,8 @@ #include "RimGridTimeHistoryCurve.h" +#include + #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" #include "RigFemResultAddress.h" @@ -714,24 +716,22 @@ std::unique_ptr RimGridTimeHistoryCurve::femTim intersectionTriangle[1] = cvf::Vec3f( geoMechTopItem->m_intersectionTriangle_1() ); intersectionTriangle[2] = cvf::Vec3f( geoMechTopItem->m_intersectionTriangle_2() ); - timeHistResultAccessor = std::unique_ptr( - new RiuFemTimeHistoryResultAccessor( geoMechTopItem->geoMechCase()->geoMechData(), - m_geoMechResultDefinition()->resultAddress(), - geoMechTopItem->m_gridIndex, - static_cast( geoMechTopItem->m_cellIndex ), - geoMechTopItem->m_elementFace, - geoMechTopItem->m_localIntersectionPoint, - intersectionTriangle ) ); + timeHistResultAccessor = std::make_unique( geoMechTopItem->geoMechCase()->geoMechData(), + m_geoMechResultDefinition()->resultAddress(), + geoMechTopItem->m_gridIndex, + static_cast( geoMechTopItem->m_cellIndex ), + geoMechTopItem->m_elementFace, + geoMechTopItem->m_localIntersectionPoint, + intersectionTriangle ); } else { - timeHistResultAccessor = std::unique_ptr( - new RiuFemTimeHistoryResultAccessor( geoMechTopItem->geoMechCase()->geoMechData(), - m_geoMechResultDefinition()->resultAddress(), - geoMechTopItem->m_gridIndex, - static_cast( geoMechTopItem->m_cellIndex ), - geoMechTopItem->m_elementFace, - geoMechTopItem->m_localIntersectionPoint ) ); + timeHistResultAccessor = std::make_unique( geoMechTopItem->geoMechCase()->geoMechData(), + m_geoMechResultDefinition()->resultAddress(), + geoMechTopItem->m_gridIndex, + static_cast( geoMechTopItem->m_cellIndex ), + geoMechTopItem->m_elementFace, + geoMechTopItem->m_localIntersectionPoint ); } } diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 30d25a2dd8..1e9a193247 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -129,6 +129,7 @@ #include #include +#include CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" ); //-------------------------------------------------------------------------------------------------- @@ -1545,7 +1546,7 @@ QString RimProject::updatedFilePathFromPathId( QString filePath, RiaVariableMapp if ( pathListMapper == nullptr ) { - internalMapper.reset( new RiaVariableMapper( m_globalPathList ) ); + internalMapper = std::make_unique( m_globalPathList ); pathListMapper = internalMapper.get(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.cpp index cdfdb98b86..9a581ed373 100644 --- a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.cpp @@ -35,6 +35,7 @@ #include "cafPdmUiTextEditor.h" #include +#include CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimUserDefinedCalculation, "RimUserDefinedCalculation" ); @@ -77,7 +78,7 @@ RimUserDefinedCalculation::RimUserDefinedCalculation() CAF_PDM_InitField( &m_id, "Id", -1, "Id" ); m_id.uiCapability()->setUiHidden( true ); - m_exprContextMenuMgr = std::unique_ptr( new RiuExpressionContextMenuManager() ); + m_exprContextMenuMgr = std::make_unique(); m_isDirty = false; } diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp index 7fc1ba1220..8e4c7b2303 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp @@ -78,6 +78,7 @@ #include #include +#include CAF_PDM_SOURCE_INIT( RimStimPlanModel, "StimPlanModel" ); @@ -240,7 +241,7 @@ RimStimPlanModel::RimStimPlanModel() CAF_PDM_InitScriptableFieldNoDefault( &m_perforationInterval, "PerforationInterval", "Perforation Interval" ); - m_calculator = std::shared_ptr( new RimStimPlanModelCalculator ); + m_calculator = std::make_shared(); m_calculator->setStimPlanModel( this ); setDeletable( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp index 63cfb84b44..84c28cea23 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp @@ -33,6 +33,7 @@ #include #include +#include namespace caf { @@ -297,7 +298,7 @@ void RimDerivedSummaryCase::createSummaryReaderInterface() summaryCase1Reader2 = m_summaryCase2->summaryReader(); } - m_reader.reset( new RifDerivedEnsembleReader( this, summaryCase1Reader1, summaryCase1Reader2 ) ); + m_reader = std::make_unique( this, summaryCase1Reader1, summaryCase1Reader2 ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 0b24911b66..43b11fb23e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -79,6 +79,7 @@ #include "cafTitledOverlayFrame.h" #include +#include #include //-------------------------------------------------------------------------------------------------- @@ -254,8 +255,8 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() m_summaryAddressNameTools = new RimSummaryCurveAutoName; - m_ensembleStatCaseY.reset( new RimEnsembleStatisticsCase() ); - m_ensembleStatCaseXY.reset( new RimEnsembleCrossPlotStatisticsCase() ); + m_ensembleStatCaseY = std::make_unique(); + m_ensembleStatCaseXY = std::make_unique(); m_disableStatisticCurves = false; m_isCurveSetFiltered = false; @@ -1636,7 +1637,7 @@ RiaSummaryCurveDefinitionAnalyser* RimEnsembleCurveSet::getOrCreateSelectedCurve { if ( !m_analyserOfSelectedCurveDefs ) { - m_analyserOfSelectedCurveDefs = std::unique_ptr( new RiaSummaryCurveDefinitionAnalyser ); + m_analyserOfSelectedCurveDefs = std::make_unique(); } m_analyserOfSelectedCurveDefs->setCurveDefinitions( curveDefinitions() ); return m_analyserOfSelectedCurveDefs.get(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 6de76eac6e..edeecd0f0b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -50,6 +50,7 @@ #include #include +#include CAF_PDM_SOURCE_INIT( RimSummaryCaseMainCollection, "SummaryCaseCollection" ); @@ -78,7 +79,7 @@ void addCaseRealizationParametersIfFound( RimSummaryCase& sumCase, const QString } else { - parameters = std::shared_ptr( new RigCaseRealizationParameters() ); + parameters = std::make_shared(); } if ( dynamic_cast( &sumCase ) == nullptr ) @@ -548,7 +549,7 @@ std::vector if ( showProgress ) { - progress.reset( new caf::ProgressInfo( summaryHeaderFileInfos.size(), "Creating summary cases" ) ); + progress = std::make_unique( summaryHeaderFileInfos.size(), "Creating summary cases" ); } for ( const RifSummaryCaseFileResultInfo& fileInfo : summaryHeaderFileInfos ) diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp index 81e6c9a30a..6cdce72d8e 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp @@ -30,6 +30,7 @@ #include "cafPdmObjectScriptingCapability.h" #include +#include CAF_PDM_SOURCE_INIT( RimFileSurface, "Surface", "FileSurface" ); @@ -170,7 +171,7 @@ bool RimFileSurface::loadDataFromFile() } else if ( filePath.endsWith( "ts", Qt::CaseInsensitive ) ) { - m_gocadData.reset( new RigGocadData ); + m_gocadData = std::make_unique(); RifSurfaceImporter::readGocadFile( filePath, m_gocadData.get() ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp index 3edfe71131..dcde97ec4e 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp @@ -68,6 +68,7 @@ #include "qwt_symbol.h" #include +#include #include //-------------------------------------------------------------------------------------------------- @@ -143,7 +144,7 @@ RimEnsembleWellLogCurveSet::RimEnsembleWellLogCurveSet() m_qwtPlotCurveForLegendText = new QwtPlotCurve; m_qwtPlotCurveForLegendText->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true ); - m_ensembleWellLogStatistics.reset( new RimEnsembleWellLogStatistics ); + m_ensembleWellLogStatistics = std::make_unique(); m_disableStatisticCurves = false; m_isCurveSetFiltered = false; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp index 6b60209760..2dc922f73d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp @@ -102,6 +102,7 @@ #include #include +#include #include #define RI_LOGPLOTTRACK_MINX_DEFAULT -10.0 @@ -2842,7 +2843,7 @@ void RimWellLogTrack::updateRegionAnnotationsOnPlot() if ( m_annotationTool == nullptr ) { - m_annotationTool = std::unique_ptr( new RiuPlotAnnotationTool() ); + m_annotationTool = std::make_unique(); } if ( m_regionAnnotationType == RiaDefines::RegionAnnotationType::FORMATION_ANNOTATIONS ) @@ -3280,8 +3281,7 @@ void RimWellLogTrack::updateWellPathAttributesOnPlot() if ( wellPathAttributeSource()->wellPathGeometry() && ( m_showWellPathAttributes || m_showWellPathCompletions ) ) { - m_wellPathAttributePlotObjects.push_back( - std::unique_ptr( new RiuWellPathComponentPlotItem( wellPathAttributeSource() ) ) ); + m_wellPathAttributePlotObjects.push_back( std::make_unique( wellPathAttributeSource() ) ); } if ( m_showWellPathAttributes ) diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseCrossPlotDataExtractor.cpp b/ApplicationLibCode/ReservoirDataModel/RigEclipseCrossPlotDataExtractor.cpp index 4dd84b6125..67a1fb691c 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseCrossPlotDataExtractor.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseCrossPlotDataExtractor.cpp @@ -110,7 +110,8 @@ RigEclipseCrossPlotResult RigEclipseCrossPlotDataExtractor::extract( RigEclipseC if ( catValuesForAllSteps ) { int catIndex = timeStep >= (int)catValuesForAllSteps->size() ? 0 : timeStep; - catAccessor.reset( new RigActiveCellsResultAccessor( mainGrid, &( catValuesForAllSteps->at( catIndex ) ), activeCellInfo ) ); + catAccessor = + std::make_unique( mainGrid, &( catValuesForAllSteps->at( catIndex ) ), activeCellInfo ); } for ( size_t globalCellIdx = 0; globalCellIdx < activeCellInfo->reservoirCellCount(); ++globalCellIdx ) diff --git a/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp b/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp index a246f0f78e..3e21bfa9db 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp @@ -18,6 +18,8 @@ #include "RigFlowDiagSolverInterface.h" +#include + #include "RiaLogging.h" #include "RifEclipseOutputFileTools.h" @@ -122,12 +124,12 @@ class RigOpmFlowDiagStaticData : public cvf::Object try { - m_eclGraph.reset( new Opm::ECLGraph( Opm::ECLGraph::load( mainGrid, initData ) ) ); + m_eclGraph = std::make_unique( Opm::ECLGraph::load( mainGrid, initData ) ); m_hasUnifiedRestartFile = false; m_poreVolume = m_eclGraph->poreVolume(); - m_eclSaturationFunc.reset( new Opm::ECLSaturationFunc( *m_eclGraph, initData ) ); + m_eclSaturationFunc = std::make_unique( *m_eclGraph, initData ); } catch ( ... ) { @@ -137,7 +139,7 @@ class RigOpmFlowDiagStaticData : public cvf::Object try { - m_eclPvtCurveCollection.reset( new Opm::ECLPVT::ECLPvtCurveCollection( *m_eclGraph, initData ) ); + m_eclPvtCurveCollection = std::make_unique( *m_eclGraph, initData ); } catch ( ... ) { @@ -256,7 +258,7 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate( size_t // Create the Toolbox. - m_opmFlowDiagStaticData->m_fldToolbox.reset( new Opm::FlowDiagnostics::Toolbox{ connGraph } ); + m_opmFlowDiagStaticData->m_fldToolbox = std::make_unique( connGraph ); // Look for unified restart file QStringList m_filesWithSameBaseName; @@ -267,8 +269,8 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate( size_t QString firstRestartFileName = RifEclipseOutputFileTools::firstFileNameOfType( m_filesWithSameBaseName, ECL_UNIFIED_RESTART_FILE ); if ( !firstRestartFileName.isEmpty() ) { - m_opmFlowDiagStaticData->m_unifiedRestartData.reset( - new Opm::ECLRestartData( Opm::ECLRestartData( firstRestartFileName.toStdString() ) ) ); + m_opmFlowDiagStaticData->m_unifiedRestartData = + std::make_unique( Opm::ECLRestartData( firstRestartFileName.toStdString() ) ); m_opmFlowDiagStaticData->m_hasUnifiedRestartFile = true; } else @@ -400,8 +402,8 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate( size_t injectorCellSets.push_back( CellSet( CellSetID( tracerName ), tIt.second ) ); } - injectorSolution.reset( - new Toolbox::Forward( m_opmFlowDiagStaticData->m_fldToolbox->computeInjectionDiagnostics( injectorCellSets ) ) ); + injectorSolution = + std::make_unique( m_opmFlowDiagStaticData->m_fldToolbox->computeInjectionDiagnostics( injectorCellSets ) ); for ( const CellSetID& tracerId : injectorSolution->fd.startPoints() ) { @@ -434,8 +436,8 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate( size_t prodjCellSets.push_back( CellSet( CellSetID( tracerName ), tIt.second ) ); } - producerSolution.reset( - new Toolbox::Reverse( m_opmFlowDiagStaticData->m_fldToolbox->computeProductionDiagnostics( prodjCellSets ) ) ); + producerSolution = + std::make_unique( m_opmFlowDiagStaticData->m_fldToolbox->computeProductionDiagnostics( prodjCellSets ) ); for ( const CellSetID& tracerId : producerSolution->fd.startPoints() ) { diff --git a/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp b/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp index e3d993e8b4..6006f91a72 100644 --- a/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp @@ -58,6 +58,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -83,7 +84,7 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimGridCrossPlot* plot, QWidget* paren SIGNAL( plotItemSelected( std::shared_ptr, bool, int ) ), SLOT( onPlotItemSelected( std::shared_ptr, bool, int ) ) ); - m_annotationTool = std::unique_ptr( new RiuPlotAnnotationTool() ); + m_annotationTool = std::make_unique(); m_selectedPointMarker = new QwtPlotMarker; // QwtPlotMarker takes ownership of the symbol, it is deleted in destructor of QwtPlotMarker diff --git a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp index e71596e7f7..baa220bac9 100644 --- a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -58,6 +58,7 @@ #include #include +#include //================================================================================================== // @@ -206,24 +207,22 @@ void RiuSelectionChangedHandler::addResultCurveFromSelectionItem( const RiuGeoMe if ( geomSelectionItem->m_hasIntersectionTriangle ) { - timeHistResultAccessor = std::unique_ptr( - new RiuFemTimeHistoryResultAccessor( geomResDef->geoMechCase()->geoMechData(), - geomResDef->resultAddress(), - geomSelectionItem->m_gridIndex, - static_cast( geomSelectionItem->m_cellIndex ), - geomSelectionItem->m_elementFace, - intersectionPointInDomain, - geomSelectionItem->m_intersectionTriangle ) ); + timeHistResultAccessor = std::make_unique( geomResDef->geoMechCase()->geoMechData(), + geomResDef->resultAddress(), + geomSelectionItem->m_gridIndex, + static_cast( geomSelectionItem->m_cellIndex ), + geomSelectionItem->m_elementFace, + intersectionPointInDomain, + geomSelectionItem->m_intersectionTriangle ); } else { - timeHistResultAccessor = std::unique_ptr( - new RiuFemTimeHistoryResultAccessor( geomResDef->geoMechCase()->geoMechData(), - geomResDef->resultAddress(), - geomSelectionItem->m_gridIndex, - static_cast( geomSelectionItem->m_cellIndex ), - geomSelectionItem->m_elementFace, - intersectionPointInDomain ) ); + timeHistResultAccessor = std::make_unique( geomResDef->geoMechCase()->geoMechData(), + geomResDef->resultAddress(), + geomSelectionItem->m_gridIndex, + static_cast( geomSelectionItem->m_cellIndex ), + geomSelectionItem->m_elementFace, + intersectionPointInDomain ); } QString curveName; diff --git a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp index f821b33fac..cf6cec3da7 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -67,6 +67,7 @@ #include #include +#include static RimEnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider; @@ -105,7 +106,7 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= // Do not set internal legends visible, as this will cause a performance hit. m_plotWidget->clearLegend(); - m_annotationTool = std::unique_ptr( new RiuPlotAnnotationTool() ); + m_annotationTool = std::make_unique(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.cpp b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.cpp index c18d65dd5c..48bf71bb0d 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionDialog.cpp @@ -30,6 +30,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -37,7 +38,7 @@ RiuSummaryVectorSelectionDialog::RiuSummaryVectorSelectionDialog( QWidget* parent ) : QDialog( parent, RiuTools::defaultDialogFlags() ) { - m_addrSelWidget = std::unique_ptr( new RiuSummaryVectorSelectionWidgetCreator() ); + m_addrSelWidget = std::make_unique(); QWidget* addrWidget = m_addrSelWidget->getOrCreateWidget( this ); QVBoxLayout* mainLayout = new QVBoxLayout( this ); diff --git a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionWidgetCreator.cpp b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionWidgetCreator.cpp index d366550c8f..beafa7a200 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionWidgetCreator.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionWidgetCreator.cpp @@ -29,13 +29,14 @@ #include #include #include +#include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RiuSummaryVectorSelectionWidgetCreator::RiuSummaryVectorSelectionWidgetCreator() { - m_summaryAddressSelection = std::unique_ptr( new RiuSummaryVectorSelectionUi() ); + m_summaryAddressSelection = std::make_unique(); setPdmObject( m_summaryAddressSelection.get() ); } diff --git a/ApplicationLibCode/UserInterface/RiuViewer.cpp b/ApplicationLibCode/UserInterface/RiuViewer.cpp index dbbe9b31e2..ff55dfc44e 100644 --- a/ApplicationLibCode/UserInterface/RiuViewer.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewer.cpp @@ -66,6 +66,7 @@ #include #include +#include using cvf::ManipulatorTrackball; @@ -1321,7 +1322,7 @@ void RiuViewer::showScaleLegend( bool show ) //-------------------------------------------------------------------------------------------------- void RiuViewer::setHoverCursor( const QCursor& cursor ) { - s_hoverCursor.reset( new QCursor( cursor ) ); + s_hoverCursor = std::make_unique( cursor ); } //-------------------------------------------------------------------------------------------------- From a00bfea40baa3e265a1b226da67d3f1cbc91baab Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 3 Sep 2024 15:06:55 +0200 Subject: [PATCH 277/332] #11663 Make sure non-Darcy data is computed The computation of non-Darcy properties is expensive, so we cache the results. Make sure that the calling function calls this function before using the properties. --- .../RicExportFractureCompletionsImpl.cpp | 2 ++ .../RicWellPathExportMswCompletionsImpl.cpp | 2 ++ .../ProjectDataModel/Completions/RimFracture.cpp | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index b707801c30..09338e0413 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -117,6 +117,8 @@ std::vector { if ( fracture->isChecked() && static_cast( fracture->branchIndex() ) == branchIndex ) { + fracture->ensureValidNonDarcyProperties(); + fractures.push_back( fracture ); } } diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 909c78c5f5..1374c10f8c 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -789,6 +789,8 @@ bool RicWellPathExportMswCompletionsImpl::generateFracturesMswExportInfo( RimEcl // Check if fractures are to be assigned to current main bore segment for ( RimWellPathFracture* fracture : fractures ) { + fracture->ensureValidNonDarcyProperties(); + double fractureStartMD = fracture->fractureMD(); if ( fracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH ) { diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp index bbc536d936..199741a6fe 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp @@ -316,6 +316,10 @@ const NonDarcyData& RimFracture::nonDarcyProperties() const //-------------------------------------------------------------------------------------------------- void RimFracture::ensureValidNonDarcyProperties() { + // The computation of non-Darcy properties is expensive, so we cache the results. + // Make sure that the calling function calls this function before using the properties. + // https://github.com/OPM/ResInsight/issues/11663 + if ( m_cachedFractureProperties.isDirty() ) { NonDarcyData props; From 93f856cc5384ad70bdea5b4967e1be56e04a0bba Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 4 Sep 2024 18:51:53 +0200 Subject: [PATCH 278/332] Python: increase launch timeout. --- GrpcInterface/Python/rips/instance.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/GrpcInterface/Python/rips/instance.py b/GrpcInterface/Python/rips/instance.py index d5c78a4fc7..dd255fbd4a 100644 --- a/GrpcInterface/Python/rips/instance.py +++ b/GrpcInterface/Python/rips/instance.py @@ -66,20 +66,25 @@ def __is_valid_port(port: int) -> bool: return True @staticmethod - def __read_port_number_from_file(file_path: str) -> int: + def __read_port_number_from_file(file_path: str, max_attempts: int) -> int: retry_count = 0 - while not os.path.exists(file_path) and retry_count < 60: + while not os.path.exists(file_path) and retry_count < max_attempts: time.sleep(1) retry_count = retry_count + 1 - print("Portnumber file retry count : ", retry_count) - if os.path.isfile(file_path): with open(file_path) as f: value = f.readline() return int(value) - else: - return -1 + + if retry_count == max_attempts: + print( + "Waiting for port number file timed out after {} seconds. File: {}".format( + max_attempts, file_path + ) + ) + + return -1 @staticmethod def __kill_process(pid: int) -> None: @@ -98,6 +103,7 @@ def launch( resinsight_executable: str = "", console: bool = False, launch_port: int = 0, + init_timeout: int = 300, command_line_parameters: List[str] = [], ) -> Optional[Instance]: """Launch a new Instance of ResInsight. This requires the environment variable @@ -112,7 +118,7 @@ def launch( launch_port(int): If 0, GRPC will find an available port. If -1, use the default port 50051 or RESINSIGHT_GRPC_PORT If anything else, ResInsight will try to launch with the specified portnumber. - + init_timeout: Number of seconds to wait for initialization before timing out. command_line_parameters(list): Additional parameters as string entries in the list. Returns: Instance: an instance object if it worked. None if not. @@ -168,7 +174,9 @@ def launch( pid = os.spawnv(os.P_NOWAIT, resinsight_executable, parameters) if pid: - port = Instance.__read_port_number_from_file(port_number_file) + port = Instance.__read_port_number_from_file( + port_number_file, init_timeout + ) if port == -1: print("Unable to read port number. Launch failed.") # Need to kill the process using PID since there is no GRPC connection to use. From 03c0e972962ed52c577871706141fc8864cdfce2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 4 Sep 2024 08:22:18 +0200 Subject: [PATCH 279/332] Prefix Sql includes --- .../Application/Tools/RiaProjectBackupTools.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp b/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp index 49844b8b57..d43b3328dc 100644 --- a/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaProjectBackupTools.cpp @@ -20,10 +20,10 @@ #include "RiaLogging.h" #include -#include -#include -#include #include +#include +#include +#include namespace RiaProjectBackupTools { From a443655b426672f87d902688a526bbab3c15827e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 6 Sep 2024 10:46:08 +0200 Subject: [PATCH 280/332] Prefix NetworkAuth includes --- .../Application/Tools/Cloud/RiaCloudConnector.cpp | 2 +- .../Application/Tools/Cloud/RiaCloudConnector.h | 2 +- .../Application/Tools/Cloud/RiaConnectorTools.cpp | 2 +- .../Tools/Cloud/RiaOAuthHttpServerReplyHandler.cpp | 4 ++-- .../Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h | 2 +- ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h | 2 +- ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp index 6b95cba214..97863ec1e0 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h index f3b9982639..0a162f7f6a 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.h @@ -18,8 +18,8 @@ #pragma once -#include #include +#include class QNetworkAccessManager; class QOAuth2AuthorizationCodeFlow; diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp index 61bb5fafa2..eb1e650e57 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaConnectorTools.cpp @@ -23,8 +23,8 @@ #include #include #include -#include #include +#include //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.cpp index 8e35a6d9a6..d289466fd3 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.cpp @@ -1,9 +1,9 @@ #include "RiaOAuthHttpServerReplyHandler.h" -#include -#include #include #include +#include +#include //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h b/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h index 420ab30da6..b6240b7624 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h @@ -18,7 +18,7 @@ #pragma once -#include +#include #include #include diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h index 6095768093..8224845506 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOsduConnector.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h index e7e3cf7353..db9ce25b84 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include From 7ba4329bb488ba94d6eee7c28dde9bcb0b32ee12 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 6 Sep 2024 11:02:31 +0200 Subject: [PATCH 281/332] Add qt-version to matrix configuration --- .github/workflows/ResInsightWithCache.yml | 5 ++++- .../Application/Tools/Cloud/RiaCloudConnector.cpp | 2 +- .../Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index a962432c41..81de5064ad 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -37,6 +37,7 @@ jobs: publish-to-pypi: false, vcpkg-bootstrap: bootstrap-vcpkg.bat, vcpkg-triplet: x64-windows-release, + qt-version: 5.12.12, } - { name: "Ubuntu 22.04 gcc", @@ -50,6 +51,7 @@ jobs: publish-to-pypi: true, vcpkg-bootstrap: bootstrap-vcpkg.sh, vcpkg-triplet: x64-linux-release, + qt-version: 5.12.12, } - { name: "Ubuntu 22.04 clang-16", @@ -63,6 +65,7 @@ jobs: publish-to-pypi: false, vcpkg-bootstrap: bootstrap-vcpkg.sh, vcpkg-triplet: x64-linux-release, + qt-version: 5.12.12, } steps: - name: Checkout @@ -172,7 +175,7 @@ jobs: - name: Install Qt uses: jurplel/install-qt-action@v4 with: - version: 5.12.12 + version: ${{ matrix.config.qt-version }} dir: "${{ github.workspace }}/Qt/" cache: true modules: "qtnetworkauth" diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp index 97863ec1e0..33829c73a2 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp @@ -28,9 +28,9 @@ #include #include #include -#include #include #include +#include //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h b/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h index b6240b7624..e3063c4241 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaOAuthHttpServerReplyHandler.h @@ -18,9 +18,9 @@ #pragma once -#include #include #include +#include //================================================================================================== /// From e9509f026a50d7981ed7bc7e05881a8f733ab51c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 6 Sep 2024 16:39:43 +0200 Subject: [PATCH 282/332] Improve robustness when parsing PFLOTRAN files The include statements can optionally have a / at the end of the line. Make sure the parsing handles this correctly. --- .../FileInterface/RifEclipseInputFileTools.cpp | 10 ++++++---- .../pflotran/include/ccs_3df_kh.grdecl | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp index 28bc9d940a..82815dcd8a 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp @@ -1065,6 +1065,7 @@ void RifEclipseInputFileTools::parsePflotranInputFile( const QString& fileName, { // Find all referenced grdecl files in a pflotran input file, in the GRID section, example + // The line can optionally contain a '/' at the end, which is ignored /* GRID TYPE grdecl ../include/ccs_3df_kh.grdecl @@ -1090,12 +1091,12 @@ void RifEclipseInputFileTools::parsePflotranInputFile( const QString& fileName, if ( line.startsWith( "TYPE" ) ) { auto words = RiaTextStringTools::splitSkipEmptyParts( line, " " ); - if ( words.size() == 3 && words[1].startsWith( "grdecl", Qt::CaseInsensitive ) ) + if ( words.size() > 2 && words[1].startsWith( "grdecl", Qt::CaseInsensitive ) ) { QFileInfo fi( fileName ); QDir currentFileFolder = fi.absoluteDir(); - QString absoluteFilePath = currentFileFolder.absoluteFilePath( words.back() ); + QString absoluteFilePath = currentFileFolder.absoluteFilePath( words[2] ); gridSectionFilenames.push_back( absoluteFilePath ); } } @@ -1113,6 +1114,7 @@ void RifEclipseInputFileTools::parsePflotranInputFile( const QString& fileName, // Find all grdecl files defined by the external_file keyword // For all these files, search for the FAULTS keyword and create fault objects + // The line can optionally contain a '/' at the end, which is ignored /* external_file ccs_3df_kh.grdecl external_file ccs_3df_other.grdecl @@ -1131,12 +1133,12 @@ void RifEclipseInputFileTools::parsePflotranInputFile( const QString& fileName, if ( line.startsWith( "external_file", Qt::CaseInsensitive ) ) { auto words = RiaTextStringTools::splitSkipEmptyParts( line, " " ); - if ( words.size() == 2 ) + if ( words.size() > 1 ) { QFileInfo fi( gridSectionFilename ); QDir currentFileFolder = fi.absoluteDir(); - QString absoluteFilePath = currentFileFolder.absoluteFilePath( words.back() ); + QString absoluteFilePath = currentFileFolder.absoluteFilePath( words[1] ); QFile grdeclFilename( absoluteFilePath ); if ( !grdeclFilename.open( QFile::ReadOnly ) ) continue; diff --git a/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/ccs_3df_kh.grdecl b/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/ccs_3df_kh.grdecl index b4ad7e7bc5..b88eb52644 100644 --- a/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/ccs_3df_kh.grdecl +++ b/ApplicationLibCode/UnitTests/TestData/RifEclipseInputFileTools/pflotran/include/ccs_3df_kh.grdecl @@ -5,7 +5,7 @@ external_file ccs_3df_geom_kh.grdecl external_file ccs_3df_prop.grdecl -external_file Faults_test_KH.grdecl +external_file Faults_test_KH.grdecl / external_file multflt_test_KH.grdecl From 19269ecf72f63ceaa7426a5ccb43f556bee6f543 Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Mon, 9 Sep 2024 13:17:20 +0200 Subject: [PATCH 283/332] Add "experimental" to setting label --- ApplicationLibCode/Application/RiaPreferencesGrid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/Application/RiaPreferencesGrid.cpp b/ApplicationLibCode/Application/RiaPreferencesGrid.cpp index f75aa1c1bd..ffd0df384e 100644 --- a/ApplicationLibCode/Application/RiaPreferencesGrid.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesGrid.cpp @@ -89,7 +89,7 @@ RiaPreferencesGrid::RiaPreferencesGrid() CAF_PDM_InitField( &m_loadAndShowSoil, "loadAndShowSoil", true, "Load and Show SOIL" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_loadAndShowSoil ); - CAF_PDM_InitField( &m_onlyLoadActiveCells, "onlyLoadActiveCells", false, "Only Load Active Cell Geometry" ); + CAF_PDM_InitField( &m_onlyLoadActiveCells, "onlyLoadActiveCells", false, "Only Load Active Cell Geometry (Experimental)" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_onlyLoadActiveCells ); } From 9b5c5ae0d3049540713e78b38973ac650993c2c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:01:54 +0000 Subject: [PATCH 284/332] Bump peter-evans/create-pull-request from 6 to 7 Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 6 to 7. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v6...v7) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/clang-format.yml | 2 +- .github/workflows/clang-tidy.yml | 2 +- .github/workflows/cmake-format.yml | 2 +- .github/workflows/python-linting.yml | 2 +- .github/workflows/spell-check.yml | 2 +- .github/workflows/update-submodules.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 25010ffe32..c0ec9cf233 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -36,7 +36,7 @@ jobs: cd Fwk/AppFwk find -name '*.h' -o -name '*.cpp' -o -name '*.inl' | grep -v gtest | xargs clang-format-15 -i git diff - - uses: peter-evans/create-pull-request@v6 + - uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Fixes by clang-format" diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 3e159633e9..cda1562bdb 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -68,7 +68,7 @@ jobs: find -name '*.h' -o -name '*.cpp' -o -name '*.inl' | xargs clang-format-15 -i cd ../GrpcInterface find -name '*.h' -o -name '*.cpp' -o -name '*.inl' | xargs clang-format-15 -i - - uses: peter-evans/create-pull-request@v6 + - uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Fixes by clang-tidy" diff --git a/.github/workflows/cmake-format.yml b/.github/workflows/cmake-format.yml index eb6b5ec436..32202bb333 100644 --- a/.github/workflows/cmake-format.yml +++ b/.github/workflows/cmake-format.yml @@ -32,7 +32,7 @@ jobs: cd .. git diff - - uses: peter-evans/create-pull-request@v6 + - uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Fixes by cmake-format" diff --git a/.github/workflows/python-linting.yml b/.github/workflows/python-linting.yml index 6e312f79ca..7666ffe855 100644 --- a/.github/workflows/python-linting.yml +++ b/.github/workflows/python-linting.yml @@ -15,7 +15,7 @@ jobs: pip install black cd GrpcInterface black . - - uses: peter-evans/create-pull-request@v6 + - uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Python code linting changes detected by black" diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index 7c4799a0db..047fcb961e 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -11,7 +11,7 @@ jobs: - uses: sobolevn/misspell-fixer-action@master with: options: "-rsvnuR ApplicationLibCode/" - - uses: peter-evans/create-pull-request@v6 + - uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Fixes by misspell-fixer" diff --git a/.github/workflows/update-submodules.yml b/.github/workflows/update-submodules.yml index 096a5661e0..b966c3c328 100644 --- a/.github/workflows/update-submodules.yml +++ b/.github/workflows/update-submodules.yml @@ -35,7 +35,7 @@ jobs: - name: Create PR # The generated PR does not have any tests. Close and reopen the PR to activate tests. - uses: peter-evans/create-pull-request@v6 + uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Update ${{ matrix.submodule }} to ${{ steps.git-change-job.outputs.LATEST_TAG }}" From eb762fd1228a6541e4ccb6f0b7246500816e78c4 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 9 Sep 2024 10:16:49 +0200 Subject: [PATCH 285/332] Progress: optionally call QApplication::processEvents on progress updates. Fixes the missing updates of UI when running long tasks in main thread. --- .../WellPath/RimWellPathCollection.cpp | 2 +- .../cafUserInterface/cafProgressInfo.cpp | 33 +++++++++++-------- Fwk/AppFwk/cafUserInterface/cafProgressInfo.h | 10 ++++-- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 219266f89a..20e47b76ea 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -174,7 +174,7 @@ bool RimWellPathCollection::loadDataAndUpdate() return count; }; - caf::ProgressInfo progress( allWellPaths().size() + countWellLogs( allWellPaths() ) + 2, "Reading well paths from file", false, true ); + caf::ProgressInfo progress( allWellPaths().size() + countWellLogs( allWellPaths() ) + 2, "Reading well paths from file", false, true, false ); readWellPathFormationFiles(); diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index 6b44139b28..d8bf3793b2 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -127,11 +127,15 @@ ProgressTask::~ProgressTask() /// If you do not need a title for a particular level, simply pass "" and it will be ignored. /// \sa setProgressDescription //-------------------------------------------------------------------------------------------------- -ProgressInfo::ProgressInfo( size_t maxProgressValue, const QString& title, bool delayShowingProgress, bool allowCancel ) +ProgressInfo::ProgressInfo( size_t maxProgressValue, + const QString& title, + bool delayShowingProgress, + bool allowCancel, + bool shouldProcessEvents ) { m_isCancelled.store( false ); - ProgressInfoStatic::start( *this, maxProgressValue, title, delayShowingProgress, allowCancel ); + ProgressInfoStatic::start( *this, maxProgressValue, title, delayShowingProgress, allowCancel, shouldProcessEvents ); if ( dynamic_cast( QCoreApplication::instance() ) ) { @@ -476,9 +480,10 @@ ProgressInfoBlocker::~ProgressInfoBlocker() /// //================================================================================================== -bool ProgressInfoStatic::s_disabled = false; -bool ProgressInfoStatic::s_running = false; -bool ProgressInfoStatic::s_isButtonConnected = false; +bool ProgressInfoStatic::s_disabled = false; +bool ProgressInfoStatic::s_running = false; +bool ProgressInfoStatic::s_isButtonConnected = false; +bool ProgressInfoStatic::s_shouldProcessEvents = true; //-------------------------------------------------------------------------------------------------- /// @@ -487,8 +492,11 @@ void ProgressInfoStatic::start( ProgressInfo& progressInfo, size_t maxProgressValue, const QString& title, bool delayShowingProgress, - bool allowCancel ) + bool allowCancel, + bool shouldProcessEvents ) { + s_shouldProcessEvents = shouldProcessEvents; + if ( !isUpdatePossible() ) return; std::vector& progressStack_v = progressStack(); @@ -541,8 +549,8 @@ void ProgressInfoStatic::start( ProgressInfo& progressInfo, dialog->setValue( static_cast( currentTotalProgress() ) ); dialog->setLabelText( currentComposedLabel() ); } - // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); - // if (progressDialog()) progressDialog()->repaint(); + + if ( s_shouldProcessEvents ) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); } //-------------------------------------------------------------------------------------------------- @@ -559,8 +567,8 @@ void ProgressInfoStatic::setProgressDescription( const QString& description ) { dialog->setLabelText( currentComposedLabel() ); } - // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); - // if (progressDialog()) progressDialog()->repaint(); + + if ( s_shouldProcessEvents ) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); } //-------------------------------------------------------------------------------------------------- @@ -605,8 +613,7 @@ void ProgressInfoStatic::setProgress( size_t progressValue ) dialog->setValue( totalProgress ); } - // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); - // if (progressDialog()) progressDialog()->repaint(); + if ( s_shouldProcessEvents ) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); } //-------------------------------------------------------------------------------------------------- @@ -687,8 +694,6 @@ void ProgressInfoStatic::finished() dialog->setLabelText( currentComposedLabel() ); } - // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); - // If we are finishing the last level, clean up if ( maxProgressStack_v.empty() ) { diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h index 48a50170a0..a0c791fd25 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h @@ -59,7 +59,11 @@ class ProgressTask class ProgressInfo { public: - ProgressInfo( size_t maxProgressValue, const QString& title, bool delayShowingProgress = true, bool allowCancel = false ); + ProgressInfo( size_t maxProgressValue, + const QString& title, + bool delayShowingProgress = true, + bool allowCancel = false, + bool shouldProcessEvents = true ); ~ProgressInfo(); void setProgressDescription( const QString& description ); @@ -89,7 +93,8 @@ class ProgressInfoStatic size_t maxProgressValue, const QString& title, bool delayShowingProgress, - bool allowCance ); + bool allowCancel, + bool shouldProcessEvents ); static void setProgressDescription( const QString& description ); static void setProgress( size_t progressValue ); @@ -107,6 +112,7 @@ class ProgressInfoStatic static bool s_running; static bool s_disabled; static bool s_isButtonConnected; + static bool s_shouldProcessEvents; }; } // namespace caf From 58c73debe0eb6d11e199ecb9feaf5c17b0ad53e4 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 2 Sep 2024 14:08:19 +0200 Subject: [PATCH 286/332] Add project tree for cloud data. --- .../ProjectDataModel/RimProject.cpp | 15 ++-- .../UserInterface/RiuDockWidgetTools.cpp | 69 ++++++++++++------- .../UserInterface/RiuDockWidgetTools.h | 2 + .../UserInterface/RiuMainWindowBase.h | 13 ++-- .../UserInterface/RiuPlotMainWindow.cpp | 66 +++++++++++------- .../UserInterface/RiuPlotMainWindow.h | 3 +- 6 files changed, 107 insertions(+), 61 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 1e9a193247..e0e0561523 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -1320,11 +1320,6 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q { if ( m_mainPlotCollection ) { - if ( activeOilField()->cloudDataCollection() ) - { - uiTreeOrdering.add( activeOilField()->cloudDataCollection() ); - } - if ( m_mainPlotCollection->summaryMultiPlotCollection() ) { uiTreeOrdering.add( m_mainPlotCollection->summaryMultiPlotCollection() ); @@ -1433,6 +1428,16 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q { uiTreeOrdering.add( m_plotTemplateTopFolder ); } + else if ( uiConfigName == "PlotWindow.Cloud" ) + { + if ( m_mainPlotCollection ) + { + if ( activeOilField()->cloudDataCollection() ) + { + uiTreeOrdering.add( activeOilField()->cloudDataCollection() ); + } + } + } else if ( uiConfigName == "MainWindow.DataSources" ) { RimOilField* oilField = activeOilField(); diff --git a/ApplicationLibCode/UserInterface/RiuDockWidgetTools.cpp b/ApplicationLibCode/UserInterface/RiuDockWidgetTools.cpp index 8a34d5bdee..af8c8d3314 100644 --- a/ApplicationLibCode/UserInterface/RiuDockWidgetTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuDockWidgetTools.cpp @@ -203,6 +203,14 @@ QString RiuDockWidgetTools::plotMainWindowScriptsTreeName() return "dockScriptsTree_plotMainWindow"; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::plotMainWindowCloudTreeName() +{ + return "dockCloudTree_plotMainWindow"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -211,6 +219,14 @@ QString RiuDockWidgetTools::plotMainWindowPropertyEditorName() return "dockPropertyEditor_plotMainWindow"; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::plotMainWindowPropertyEditorRightName() +{ + return "dockPropertyEditorRight_plotMainWindow"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -325,6 +341,8 @@ QIcon RiuDockWidgetTools::dockIcon( const QString dockWidgetName ) return QIcon( ":/scripts.svg" ); else if ( dockWidgetName == plotMainWindowPropertyEditorName() ) return QIcon( ":/property-editor.svg" ); + else if ( dockWidgetName == plotMainWindowPropertyEditorRightName() ) + return QIcon( ":/property-editor.svg" ); else if ( dockWidgetName == plotMainWindowMessagesName() ) return QIcon( ":/messages.svg" ); else if ( dockWidgetName == plotMainWindowUndoStackName() ) @@ -363,6 +381,8 @@ QIcon RiuDockWidgetTools::dockIcon( const QString dockWidgetName ) return QIcon( ":/window-management.svg" ); else if ( dockWidgetName == mainWindowSeismicHistogramName() ) return QIcon( ":/graph.svg" ); + else if ( dockWidgetName == plotMainWindowCloudTreeName() ) + return QIcon( ":/Cloud.svg" ); return QIcon( ":/view.svg" ); } @@ -487,30 +507,31 @@ QByteArray RiuDockWidgetTools::defaultPlotDockState() // start paste static const char stateData[] = - { '\x00', '\x00', '\x04', '\xbd', '\x78', '\xda', '\x9d', '\x54', '\x51', '\x6f', '\x82', '\x30', '\x10', '\x7e', '\xdf', '\xaf', - '\x68', '\xfa', '\xee', '\x50', '\xc1', '\x89', '\x09', '\x62', '\x8c', '\xce', '\x37', '\x37', '\x17', '\x70', '\x3e', '\x9a', - '\x8e', '\x5e', '\x48', '\x33', '\x68', '\x49', '\x5b', '\xdd', '\x5c', '\xf6', '\xe3', '\x57', '\x60', '\x61', '\x9b', '\x01', - '\xc4', '\x3d', '\xd1', '\xbb', '\xfb', '\xbe', '\xde', '\x77', '\xf9', '\xae', '\x78', '\xb3', '\xf7', '\x34', '\x41', '\x47', - '\x90', '\x8a', '\x09', '\x3e', '\xc5', '\x83', '\xdb', '\x3e', '\x46', '\xc0', '\x23', '\x41', '\x19', '\x8f', '\xa7', '\x78', - '\x1b', '\xae', '\x7a', '\x2e', '\x9e', '\xf9', '\xde', '\x93', '\x9e', '\xd3', '\x23', '\xe1', '\x11', '\xd0', '\xa5', '\x88', - '\x5e', '\x4d', '\x2d', '\x38', '\x29', '\x0d', '\x29', '\x7a', '\xae', '\x88', '\x18', '\x6d', '\x15', '\xc8', '\x2a', '\xb6', - '\x31', '\x5a', '\x08', '\xae', '\x09', '\xe3', '\x26', '\x53', '\x94', '\x17', '\xc0', '\xb5', '\x24', '\xc9', '\x8e', '\xd1', - '\x18', '\xf4', '\x14', '\x53', '\x73', '\xcf', '\x26', '\x11', '\x7a', '\xc7', '\x38', '\x15', '\x6f', '\xfb', '\xd4', '\x20', - '\x7f', '\x42', '\xec', '\x7b', '\x15', '\x1b', '\xad', '\x12', '\x41', '\x74', '\x21', '\xa7', '\x6f', '\xf2', '\x41', '\x96', - '\x30', '\xad', '\x4d', '\xfa', '\x51', '\x32', '\x73', '\xa3', '\xa9', '\xe4', '\xed', '\x3e', '\xf3', '\x76', '\x07', '\xae', - '\xf3', '\xc6', '\x4d', '\x98', '\x5e', '\x85', '\x19', '\x1a', '\xcc', '\x5c', '\x02', '\x41', '\x21', '\x79', '\x51', '\xa5', - '\xd6', '\x83', '\x94', '\xc0', '\x7f', '\xc9', '\x52', '\xa1', '\x04', '\xd8', '\x67', '\xe6', '\xb4', '\x36', '\x2a', '\x2a', - '\x55', '\xa5', '\x7a', '\xf4', '\x40', '\x52', '\xb8', '\x80', '\x45', '\x8b', '\x44', '\x28', '\xa0', '\xb9', '\x68', '\xab', - '\x86', '\x17', '\x42', '\x9a', '\x25', '\x44', '\xc3', '\x7f', '\xb8', '\x41', '\x24', '\x59', '\xd6', '\xa5', '\xab', '\x95', - '\x0f', '\xf9', '\x67', '\xd4', '\xc1', '\xf9', '\xa8', '\x52', '\x64', '\x20', '\xf5', '\xe9', '\x9e', '\x32', '\x2d', '\x64', - '\x97', '\x79', '\x5b', '\x09', '\xb5', '\xed', '\x03', '\xf6', '\x01', '\xca', '\x1f', '\x4f', '\x5c', '\xe4', '\x8c', '\x27', - '\xc8', '\xb3', '\xca', '\xd8', '\x7c', '\xbf', '\x5d', '\x6a', '\x17', '\xd8', '\xb8', '\x22', '\x66', '\x2f', '\x48', '\x5c', - '\x30', '\x1a', '\x6c', '\x69', '\xa0', '\xd5', '\x4a', '\xbc', '\x6e', '\x61', '\x86', '\x67', '\x22', '\x97', '\x44', '\x93', - '\x40', '\x1c', '\x64', '\x04', '\x1d', '\xb7', '\xa6', '\x9d', '\x70', '\xc9', '\xfe', '\x43', '\x9a', '\x12', '\x79', '\xda', - '\x14', '\x24', '\x4e', '\x62', '\x90', '\x57', '\xdb', '\xbe', '\x06', '\xa5', '\x0c', '\x51', '\x75', '\x90', '\xda', '\x04', - '\x6d', '\xb1', '\xda', '\x9d', '\xd8', '\xc8', '\x76', '\x9d', '\x5a', '\xab', '\xcb', '\x8c', '\x3d', '\x72', '\xd0', '\x60', - '\x3c', '\xba', '\x43', '\x8e', '\xed', '\xd6', '\xc2', '\xac', '\xea', '\xf9', '\x9b', '\x73', '\xc3', '\xcf', '\xc7', '\xbf', - '\xf9', '\x02', '\x51', '\x97', '\xa4', '\x18' }; + { '\x00', '\x00', '\x05', '\x83', '\x78', '\xda', '\xa5', '\x54', '\x5d', '\x6f', '\x82', '\x30', '\x14', '\x7d', '\xdf', '\xaf', + '\x68', '\xfa', '\xee', '\x00', '\x75', '\x8e', '\x25', '\xa8', '\x31', '\x3a', '\xdf', '\xdc', '\x17', '\x38', '\x1f', '\x4d', + '\x47', '\x6f', '\x58', '\x33', '\x68', '\x49', '\x5b', '\xdc', '\x5c', '\xf6', '\xe3', '\x57', '\x60', '\x61', '\x1f', '\x01', + '\x44', '\xf7', '\x40', '\x68', '\xef', '\x3d', '\xa7', '\xe7', '\xdc', '\xf4', '\xa4', '\xde', '\xf4', '\x2d', '\x89', '\xd1', + '\x0e', '\xa4', '\x62', '\x82', '\x8f', '\xb1', '\x73', '\x6e', '\x63', '\x04', '\x3c', '\x14', '\x94', '\xf1', '\x68', '\x8c', + '\xd7', '\xc1', '\xb2', '\xe7', '\xe2', '\xe9', '\xc4', '\xbb', '\xd7', '\x33', '\xba', '\x23', '\x3c', '\x04', '\xba', '\x10', + '\xe1', '\x8b', '\xe9', '\xf9', '\x7b', '\xa5', '\x21', '\x41', '\x8f', '\x15', '\x11', '\xa3', '\xb5', '\x02', '\x59', '\xed', + '\x07', '\x18', '\xcd', '\x05', '\xd7', '\x84', '\x71', '\x53', '\x29', '\xda', '\x73', '\xe0', '\x5a', '\x92', '\x78', '\xc3', + '\x68', '\x04', '\x7a', '\x8c', '\xa9', '\x39', '\xe7', '\x2e', '\x16', '\x7a', '\xc3', '\x38', '\x15', '\xaf', '\xdb', '\xc4', + '\x20', '\xbf', '\xb7', '\x78', '\xe2', '\x55', '\x6c', '\xb4', '\x8c', '\x05', '\xd1', '\x85', '\x1d', '\xdb', '\xd4', '\xfd', + '\x34', '\x66', '\x5a', '\x9b', '\xf2', '\xad', '\x64', '\xe6', '\x44', '\xd3', '\xc9', '\xe5', '\x3e', '\x72', '\xb9', '\x8c', + '\xeb', '\x5c', '\xb8', '\x09', '\xd3', '\xab', '\x30', '\x7d', '\x83', '\x99', '\x49', '\x20', '\x28', '\x20', '\x4f', '\xaa', + '\xf4', '\x9a', '\x49', '\x09', '\xfc', '\x87', '\x2d', '\x15', '\x48', '\x80', '\x6d', '\x6a', '\x56', '\x2b', '\xe3', '\xa2', + '\x72', '\x55', '\xba', '\x47', '\x37', '\x24', '\x81', '\x03', '\x58', '\x34', '\x8f', '\x85', '\x02', '\x9a', '\x9b', '\xb6', + '\x6a', '\x78', '\x01', '\x24', '\x69', '\x4c', '\x34', '\x9c', '\xc2', '\xf5', '\x43', '\xc9', '\xd2', '\x2e', '\xaa', '\x56', + '\x3e', '\xe4', '\xaf', '\x51', '\x9d', '\xbf', '\xa3', '\x4a', '\x91', '\x82', '\xd4', '\xfb', '\x6b', '\xca', '\xb4', '\x90', + '\x5d', '\xe6', '\x6d', '\x25', '\xd4', '\xca', '\xfb', '\xec', '\x1d', '\xd4', '\xc4', '\xb1', '\xed', '\x0b', '\x34', '\x18', + '\x5d', '\x22', '\xcf', '\x2a', '\x0b', '\xe6', '\xff', '\x75', '\x4d', '\xed', '\x0e', '\x1b', '\x33', '\x62', '\x82', '\x41', + '\xa2', '\x82', '\xd1', '\x70', '\x2f', '\x0d', '\xb4', '\x5a', '\x8f', '\x07', '\x12', '\x33', '\x68', '\x4f', '\xcc', '\x82', + '\x68', '\xe2', '\x8b', '\x4c', '\x86', '\xd0', '\x31', '\x36', '\xed', '\x84', '\x03', '\xf7', '\x6f', '\xba', '\x19', '\x3d', + '\x25', '\x37', '\x59', '\x92', '\x10', '\xb9', '\xbf', '\x2b', '\x48', '\x9c', '\x44', '\x20', '\xff', '\x99', '\x97', '\x07', + '\x16', '\x3d', '\xeb', '\xa3', '\x43', '\x53', '\xcb', '\x3a', '\xd6', '\xc8', '\x0a', '\x94', '\x32', '\x13', '\xa8', '\x0e', + '\xea', '\x4d', '\xd0', '\x96', '\xb0', '\xba', '\xb6', '\x8d', '\xfa', '\x6e', '\xfe', '\xb9', '\xb5', '\x79', '\x2d', '\x2b', + '\x43', '\xdb', '\x41', '\xce', '\x68', '\x74', '\x85', '\x86', '\x6e', '\xbf', '\x16', '\x66', '\x55', '\x8f', '\x98', '\x59', + '\x37', '\x3c', '\xa1', '\x93', '\xb3', '\x4f', '\x33', '\x96', '\xe9', '\xd8' }; // end paste diff --git a/ApplicationLibCode/UserInterface/RiuDockWidgetTools.h b/ApplicationLibCode/UserInterface/RiuDockWidgetTools.h index 1c22356009..40e8d95e89 100644 --- a/ApplicationLibCode/UserInterface/RiuDockWidgetTools.h +++ b/ApplicationLibCode/UserInterface/RiuDockWidgetTools.h @@ -67,8 +67,10 @@ class RiuDockWidgetTools static QString plotMainWindowPlotsTreeName(); static QString plotMainWindowTemplateTreeName(); static QString plotMainWindowScriptsTreeName(); + static QString plotMainWindowCloudTreeName(); static QString plotMainWindowPropertyEditorName(); + static QString plotMainWindowPropertyEditorRightName(); static QString plotMainWindowMessagesName(); static QString plotMainWindowUndoStackName(); static QString plotMainWindowPlotManagerName(); diff --git a/ApplicationLibCode/UserInterface/RiuMainWindowBase.h b/ApplicationLibCode/UserInterface/RiuMainWindowBase.h index 55d9fdbe46..752aa3e605 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindowBase.h +++ b/ApplicationLibCode/UserInterface/RiuMainWindowBase.h @@ -45,6 +45,7 @@ namespace caf class PdmObject; class PdmUiTreeView; class PdmUiItem; +class PdmUiPropertyView; } // namespace caf class QAction; @@ -145,16 +146,16 @@ protected slots: QByteArray m_lastDockState; + std::vector m_projectTreeViews; + std::vector> m_propertyViews; + private: QString registryFolderName(); -private: - std::vector m_projectTreeViews; std::vector> m_dragDropInterfaces; - - bool m_showFirstVisibleWindowMaximized; - bool m_blockSubWindowActivation; - bool m_blockSubWindowProjectTreeSelection; + bool m_showFirstVisibleWindowMaximized; + bool m_blockSubWindowActivation; + bool m_blockSubWindowProjectTreeSelection; ads::CDockManager* m_dockManager; }; diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp index db0f58a2f6..a32cc45799 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp @@ -246,9 +246,9 @@ void RiuPlotMainWindow::cleanupGuiBeforeProjectClose() { setPdmRoot( nullptr ); - if ( m_pdmUiPropertyView ) + for ( auto pdmUiPropertyView : m_propertyViews ) { - m_pdmUiPropertyView->showProperties( nullptr ); + pdmUiPropertyView->showProperties( nullptr ); } cleanUpTemporaryWidgets(); @@ -466,18 +466,24 @@ void RiuPlotMainWindow::refreshToolbars() //-------------------------------------------------------------------------------------------------- void RiuPlotMainWindow::createDockPanels() { - const int nTreeViews = 4; - const std::vector treeViewTitles = { "Plots", "Data Sources", "Templates", "Scripts" }; - const std::vector treeViewConfigs = { "PlotWindow.Plots", "PlotWindow.DataSources", "PlotWindow.Templates", "PlotWindow.Scripts" }; + const std::vector treeViewTitles = { "Plots", "Data Sources", "Templates", "Scripts", "Cloud" }; + const std::vector treeViewConfigs = { "PlotWindow.Plots", + "PlotWindow.DataSources", + "PlotWindow.Templates", + "PlotWindow.Scripts", + "PlotWindow.Cloud" }; const std::vector treeViewDockNames = { RiuDockWidgetTools::plotMainWindowPlotsTreeName(), RiuDockWidgetTools::plotMainWindowDataSourceTreeName(), RiuDockWidgetTools::plotMainWindowTemplateTreeName(), - RiuDockWidgetTools::plotMainWindowScriptsTreeName() }; + RiuDockWidgetTools::plotMainWindowScriptsTreeName(), + RiuDockWidgetTools::plotMainWindowCloudTreeName() }; + const int nTreeViews = static_cast( treeViewConfigs.size() ); const std::vector defaultDockWidgetArea{ ads::DockWidgetArea::LeftDockWidgetArea, ads::DockWidgetArea::RightDockWidgetArea, ads::DockWidgetArea::LeftDockWidgetArea, - ads::DockWidgetArea::LeftDockWidgetArea }; + ads::DockWidgetArea::LeftDockWidgetArea, + ads::DockWidgetArea::RightDockWidgetArea }; createTreeViews( nTreeViews ); @@ -514,7 +520,6 @@ void RiuPlotMainWindow::createDockPanels() if ( defaultDockWidgetArea[i] == ads::DockWidgetArea::RightDockWidgetArea ) rightWidgets.push_back( dockWidget ); connect( dockWidget, SIGNAL( visibilityChanged( bool ) ), projectTree, SLOT( treeVisibilityChanged( bool ) ) ); - connect( projectTree, SIGNAL( selectionChanged() ), this, SLOT( selectedObjectsChanged() ) ); projectTree->treeView()->setContextMenuPolicy( Qt::CustomContextMenu ); connect( projectTree->treeView(), SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( customMenuRequested( const QPoint& ) ) ); @@ -554,16 +559,6 @@ void RiuPlotMainWindow::createDockPanels() ads::CDockAreaWidget* bottomArea = addTabbedWidgets( bottomWidgets, ads::DockWidgetArea::BottomDockWidgetArea, dockManager()->centralWidget()->dockAreaWidget() ); - // the property editor - { - auto dockWidget = - RiuDockWidgetTools::createDockWidget( "Property Editor", RiuDockWidgetTools::plotMainWindowPropertyEditorName(), dockManager() ); - - m_pdmUiPropertyView = std::make_unique( dockWidget ); - dockWidget->setWidget( m_pdmUiPropertyView.get() ); - dockManager()->addDockWidget( ads::DockWidgetArea::BottomDockWidgetArea, dockWidget, leftArea ); - } - // the log message view { auto dockWidget = RiuDockWidgetTools::createDockWidget( "Messages", RiuDockWidgetTools::plotMainWindowMessagesName(), dockManager() ); @@ -573,6 +568,33 @@ void RiuPlotMainWindow::createDockPanels() dockManager()->addDockWidget( ads::DockWidgetArea::BottomDockWidgetArea, dockWidget, rightArea ); } + auto createPropertyView = [this]( const QString& displayName, const QString& internalName, ads::CDockAreaWidget* dockArea ) + { + auto dockWidget = RiuDockWidgetTools::createDockWidget( displayName, internalName, dockManager() ); + auto pdmUiPropertyView = std::make_shared( dockWidget ); + dockWidget->setWidget( pdmUiPropertyView.get() ); + dockManager()->addDockWidget( ads::DockWidgetArea::BottomDockWidgetArea, dockWidget, dockArea ); + return pdmUiPropertyView; + }; + + auto leftPropertyView = createPropertyView( "Property Editor", RiuDockWidgetTools::plotMainWindowPropertyEditorName(), leftArea ); + auto rightPropertyView = + createPropertyView( "Property Editor (Right)", RiuDockWidgetTools::plotMainWindowPropertyEditorRightName(), rightArea ); + + // Connect project trees with property views + for ( int i = 0; i < nTreeViews; i++ ) + { + caf::PdmUiTreeView* projectTree = projectTreeView( i ); + + auto pdmUiPropertyView = defaultDockWidgetArea[i] == ads::DockWidgetArea::LeftDockWidgetArea ? leftPropertyView : rightPropertyView; + + connect( projectTree, + &caf::PdmUiTreeView::selectionChanged, + [this, projectTree, pdmUiPropertyView]() { selectedObjectsChanged( projectTree, pdmUiPropertyView.get() ); } ); + + m_propertyViews.push_back( pdmUiPropertyView ); + } + if ( leftArea ) leftArea->setCurrentIndex( 0 ); if ( rightArea ) rightArea->setCurrentIndex( 0 ); if ( bottomArea ) bottomArea->setCurrentIndex( 0 ); @@ -897,11 +919,8 @@ void RiuPlotMainWindow::slotBuildWindowActions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPlotMainWindow::selectedObjectsChanged() +void RiuPlotMainWindow::selectedObjectsChanged( caf::PdmUiTreeView* projectTree, caf::PdmUiPropertyView* propertyView ) { - caf::PdmUiTreeView* projectTree = dynamic_cast( sender() ); - if ( !projectTree ) return; - std::vector uiItems; projectTree->selectedUiItems( uiItems ); @@ -911,12 +930,11 @@ void RiuPlotMainWindow::selectedObjectsChanged() firstSelectedObject = dynamic_cast( uiItems.front() ); } - m_pdmUiPropertyView->showProperties( firstSelectedObject ); + propertyView->showProperties( firstSelectedObject ); if ( uiItems.size() == 1 && m_allowActiveViewChangeFromSelection ) { // Find the reservoir view or the Plot that the selected item is within - if ( !firstSelectedObject ) { caf::PdmFieldHandle* selectedField = dynamic_cast( uiItems.front() ); diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h index 0d33a5a6e3..139b25ad23 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h @@ -125,7 +125,7 @@ private slots: void slotSubWindowActivated( QMdiSubWindow* subWindow ); - void selectedObjectsChanged(); + void selectedObjectsChanged( caf::PdmUiTreeView* projectTree, caf::PdmUiPropertyView* propertyView ); void customMenuRequested( const QPoint& pos ); private: @@ -136,7 +136,6 @@ private slots: std::unique_ptr m_multiPlotToolBarEditor; std::unique_ptr m_multiPlotLayoutToolBarEditor; - std::unique_ptr m_pdmUiPropertyView; std::unique_ptr m_summaryPlotManagerView; std::unique_ptr m_summaryCurveCreatorDialog; From ff3b932257e504ebce2e6a95f8fc7f0143872216 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 6 Sep 2024 13:02:19 +0200 Subject: [PATCH 287/332] Cloud: fix crash in PdmUiEditorHandle due to recursive event loop. --- .../Application/Tools/Cloud/RiaCloudConnector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp index 33829c73a2..1453f70296 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaCloudConnector.cpp @@ -271,7 +271,7 @@ QString RiaCloudConnector::requestTokenBlocking() connect( &timer, SIGNAL( timeout() ), &loop, SLOT( quit() ) ); requestToken(); timer.start( RiaCloudDefines::requestTokenTimeoutMillis() ); - loop.exec(); + loop.exec( QEventLoop::ProcessEventsFlag::ExcludeUserInputEvents ); return m_authCodeFlow->token(); } From 64a48d083266284ed0421f00a5d25addf6e29e27 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 9 Sep 2024 11:20:22 +0200 Subject: [PATCH 288/332] #11673 Osdu import: Improve selection in table. --- .../Commands/OsduImportCommands/RiuWellImportWizard.cpp | 2 +- .../Commands/OsduImportCommands/RiuWellLogImportWizard.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index 9a1e2c79c8..10e97818ba 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -351,7 +351,7 @@ WellSelectionPage::WellSelectionPage( RiaOsduConnector* osduConnector, QWidget* m_tableView = new QTableView( this ); m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows ); - m_tableView->setSelectionMode( QAbstractItemView::MultiSelection ); + m_tableView->setSelectionMode( QAbstractItemView::ExtendedSelection ); m_tableView->setSortingEnabled( true ); int nameColumn = 2; m_tableView->sortByColumn( nameColumn, Qt::AscendingOrder ); diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp index 714dce642e..53d24a2c17 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellLogImportWizard.cpp @@ -179,7 +179,7 @@ WellLogSelectionPage::WellLogSelectionPage( RiaOsduConnector* osduConnector, QWi m_tableView = new QTableView( this ); m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows ); - m_tableView->setSelectionMode( QAbstractItemView::MultiSelection ); + m_tableView->setSelectionMode( QAbstractItemView::ExtendedSelection ); m_tableView->setSortingEnabled( true ); int nameColumn = 2; m_tableView->sortByColumn( nameColumn, Qt::AscendingOrder ); From b31e131d2078c5012a2b091acb32063290bf8df0 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 9 Sep 2024 13:09:57 +0200 Subject: [PATCH 289/332] Osdu import: Refactor column indexing. --- .../RiuWellImportWizard.cpp | 9 ++- .../OsduImportCommands/RiuWellImportWizard.h | 72 +++++++++++-------- 2 files changed, 46 insertions(+), 35 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index 10e97818ba..ea4cfc8fb0 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -248,7 +248,7 @@ FieldSelectionPage::FieldSelectionPage( RiaOsduConnector* osduConnector, QWidget m_osduFieldsModel = new OsduFieldTableModel; m_tableView->setModel( m_osduFieldsModel ); m_tableView->setSortingEnabled( true ); - int nameColumn = 2; + int nameColumn = OsduFieldTableModel::Column::Name; m_tableView->sortByColumn( nameColumn, Qt::AscendingOrder ); layout->addWidget( m_tableView ); @@ -308,7 +308,7 @@ void FieldSelectionPage::selectField( const QItemSelection& newSelection, const if ( !newSelection.indexes().empty() ) { QModelIndex index = newSelection.indexes()[0]; - int column = 0; + int column = OsduFieldTableModel::Column::Id; QString fieldId = m_osduFieldsModel->data( index.siblingAtColumn( column ) ).toString(); RiuWellImportWizard* wiz = dynamic_cast( wizard() ); wiz->setSelectedFieldId( fieldId ); @@ -353,7 +353,7 @@ WellSelectionPage::WellSelectionPage( RiaOsduConnector* osduConnector, QWidget* m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows ); m_tableView->setSelectionMode( QAbstractItemView::ExtendedSelection ); m_tableView->setSortingEnabled( true ); - int nameColumn = 2; + int nameColumn = OsduWellboreTableModel::Column::Name; m_tableView->sortByColumn( nameColumn, Qt::AscendingOrder ); QHeaderView* header = m_tableView->horizontalHeader(); @@ -449,8 +449,7 @@ void WellSelectionPage::selectWellbore( const QItemSelection& newSelection, cons QModelIndexList selection = m_tableView->selectionModel()->selectedRows(); for ( QModelIndex index : selection ) { - int idColumn = 0; - + int idColumn = OsduWellboreTableModel::Column::Id; if ( index.column() == idColumn ) { QString wellboreId = m_proxyModel->data( index.siblingAtColumn( idColumn ) ).toString(); diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index 7b2583167c..83914c95f2 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -34,7 +34,6 @@ class QFile; class QLabel; class QTextEdit; class QTableView; - class OsduFieldTableModel : public QAbstractTableModel { Q_OBJECT @@ -45,6 +44,14 @@ class OsduFieldTableModel : public QAbstractTableModel { } + enum Column + { + Id, + Kind, + Name, + ColumnCount + }; + int rowCount( const QModelIndex& parent = QModelIndex() ) const override { Q_UNUSED( parent ); @@ -54,8 +61,7 @@ class OsduFieldTableModel : public QAbstractTableModel int columnCount( const QModelIndex& parent = QModelIndex() ) const override { Q_UNUSED( parent ); - // Assuming you have three fields: id, kind, and name - return 3; + return ColumnCount; } QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override @@ -67,13 +73,13 @@ class OsduFieldTableModel : public QAbstractTableModel if ( role == Qt::DisplayRole ) { const OsduField& field = m_osduFields.at( index.row() ); - switch ( index.column() ) + switch ( static_cast( index.column() ) ) { - case 0: + case Id: return field.id; - case 1: + case Kind: return field.kind; - case 2: + case Name: return field.name; default: return QVariant(); @@ -89,13 +95,13 @@ class OsduFieldTableModel : public QAbstractTableModel if ( orientation == Qt::Horizontal ) { - switch ( section ) + switch ( static_cast( section ) ) { - case 0: + case Id: return tr( "ID" ); - case 1: + case Kind: return tr( "Kind" ); - case 2: + case Name: return tr( "Name" ); default: return QVariant(); @@ -117,13 +123,13 @@ class OsduFieldTableModel : public QAbstractTableModel m_osduFields.end(), [column, order]( const OsduField& a, const OsduField& b ) { - switch ( column ) + switch ( static_cast( column ) ) { - case 0: + case Id: return ( order == Qt::AscendingOrder ) ? a.id < b.id : a.id > b.id; - case 1: + case Kind: return ( order == Qt::AscendingOrder ) ? a.kind < b.kind : a.kind > b.kind; - case 2: + case Name: return ( order == Qt::AscendingOrder ) ? a.name < b.name : a.name > b.name; default: return false; @@ -147,6 +153,14 @@ class OsduWellboreTableModel : public QAbstractTableModel { } + enum Column + { + Id, + Kind, + Name, + ColumnCount + }; + int rowCount( const QModelIndex& parent = QModelIndex() ) const override { Q_UNUSED( parent ); @@ -156,8 +170,7 @@ class OsduWellboreTableModel : public QAbstractTableModel int columnCount( const QModelIndex& parent = QModelIndex() ) const override { Q_UNUSED( parent ); - // Assuming you have three fields: id, kind, and name - return 3; + return ColumnCount; } QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override @@ -169,13 +182,13 @@ class OsduWellboreTableModel : public QAbstractTableModel if ( role == Qt::DisplayRole ) { const OsduWellbore& field = m_osduWellbores.at( index.row() ); - switch ( index.column() ) + switch ( static_cast( index.column() ) ) { - case 0: + case Id: return field.id; - case 1: + case Kind: return field.kind; - case 2: + case Name: return field.name; default: return QVariant(); @@ -191,13 +204,13 @@ class OsduWellboreTableModel : public QAbstractTableModel if ( orientation == Qt::Horizontal ) { - switch ( section ) + switch ( static_cast( section ) ) { - case 0: + case Id: return tr( "ID" ); - case 1: + case Kind: return tr( "Kind" ); - case 2: + case Name: return tr( "Name" ); default: return QVariant(); @@ -216,7 +229,6 @@ class OsduWellboreTableModel : public QAbstractTableModel for ( auto v : values ) m_osduWellbores.push_back( v ); } - endResetModel(); } @@ -226,13 +238,13 @@ class OsduWellboreTableModel : public QAbstractTableModel m_osduWellbores.end(), [column, order]( const OsduWellbore& a, const OsduWellbore& b ) { - switch ( column ) + switch ( static_cast( column ) ) { - case 0: + case Id: return ( order == Qt::AscendingOrder ) ? a.id < b.id : a.id > b.id; - case 1: + case Kind: return ( order == Qt::AscendingOrder ) ? a.kind < b.kind : a.kind > b.kind; - case 2: + case Name: return ( order == Qt::AscendingOrder ) ? a.name < b.name : a.name > b.name; default: return false; From 6c098cccc1152889e508f116d320cdfa16ba06bf Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 9 Sep 2024 14:11:15 +0200 Subject: [PATCH 290/332] #11673 Osdu Well Path Import: fix order and size of columns. --- .../RiuWellImportWizard.cpp | 29 ++++++++++--------- .../OsduImportCommands/RiuWellImportWizard.h | 8 ++--- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index ea4cfc8fb0..c67d7ea910 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -239,18 +239,21 @@ FieldSelectionPage::FieldSelectionPage( RiaOsduConnector* osduConnector, QWidget QLabel* label = new QLabel( "Select fields" ); layout->addWidget( label ); + int nameColumn = OsduFieldTableModel::Column::Name; + m_tableView = new QTableView( this ); m_tableView->setSelectionBehavior( QAbstractItemView::SelectRows ); - QHeaderView* header = m_tableView->horizontalHeader(); - header->setSectionResizeMode( QHeaderView::Interactive ); - header->setStretchLastSection( true ); m_osduFieldsModel = new OsduFieldTableModel; m_tableView->setModel( m_osduFieldsModel ); m_tableView->setSortingEnabled( true ); - int nameColumn = OsduFieldTableModel::Column::Name; m_tableView->sortByColumn( nameColumn, Qt::AscendingOrder ); + QHeaderView* header = m_tableView->horizontalHeader(); + header->setSectionResizeMode( QHeaderView::Interactive ); + header->setSectionResizeMode( nameColumn, QHeaderView::ResizeToContents ); + header->setStretchLastSection( true ); + layout->addWidget( m_tableView ); layout->setStretchFactor( m_tableView, 10 ); @@ -356,10 +359,6 @@ WellSelectionPage::WellSelectionPage( RiaOsduConnector* osduConnector, QWidget* int nameColumn = OsduWellboreTableModel::Column::Name; m_tableView->sortByColumn( nameColumn, Qt::AscendingOrder ); - QHeaderView* header = m_tableView->horizontalHeader(); - header->setSectionResizeMode( QHeaderView::Interactive ); - header->setStretchLastSection( true ); - m_osduWellboresModel = new OsduWellboreTableModel; layout->addWidget( m_tableView ); layout->setStretchFactor( m_tableView, 10 ); @@ -372,6 +371,11 @@ WellSelectionPage::WellSelectionPage( RiaOsduConnector* osduConnector, QWidget* m_tableView->setModel( m_proxyModel ); m_tableView->setSortingEnabled( true ); + QHeaderView* header = m_tableView->horizontalHeader(); + header->setSectionResizeMode( QHeaderView::Interactive ); + header->setSectionResizeMode( nameColumn, QHeaderView::ResizeToContents ); + header->setStretchLastSection( true ); + QObject::connect( filterLineEdit, &QLineEdit::textChanged, m_proxyModel, &QSortFilterProxyModel::setFilterWildcard ); m_osduConnector = osduConnector; @@ -449,12 +453,9 @@ void WellSelectionPage::selectWellbore( const QItemSelection& newSelection, cons QModelIndexList selection = m_tableView->selectionModel()->selectedRows(); for ( QModelIndex index : selection ) { - int idColumn = OsduWellboreTableModel::Column::Id; - if ( index.column() == idColumn ) - { - QString wellboreId = m_proxyModel->data( index.siblingAtColumn( idColumn ) ).toString(); - wellboreIds.push_back( wellboreId ); - } + int idColumn = OsduWellboreTableModel::Column::Id; + QString wellboreId = m_proxyModel->data( index.siblingAtColumn( idColumn ) ).toString(); + wellboreIds.push_back( wellboreId ); } RiuWellImportWizard* wiz = dynamic_cast( wizard() ); diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index 83914c95f2..435258ec98 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -46,9 +46,9 @@ class OsduFieldTableModel : public QAbstractTableModel enum Column { - Id, - Kind, Name, + Kind, + Id, ColumnCount }; @@ -155,9 +155,9 @@ class OsduWellboreTableModel : public QAbstractTableModel enum Column { - Id, - Kind, Name, + Kind, + Id, ColumnCount }; From 1235c3f92e50a270c45fb7db92f90f8425df3e3f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 10 Sep 2024 07:28:28 +0200 Subject: [PATCH 291/332] Bump to dev.17 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index ff487e8883..74171d4079 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".16") +set(RESINSIGHT_DEV_VERSION ".17") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From cfc97bb61522b636872776c2e33e7fb3c4bc684a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 10 Sep 2024 08:18:37 +0200 Subject: [PATCH 292/332] Revert "Progress: optionally call QApplication::processEvents on progress updates." This reverts commit eb762fd1228a6541e4ccb6f0b7246500816e78c4. --- .../WellPath/RimWellPathCollection.cpp | 2 +- .../cafUserInterface/cafProgressInfo.cpp | 33 ++++++++----------- Fwk/AppFwk/cafUserInterface/cafProgressInfo.h | 10 ++---- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 20e47b76ea..219266f89a 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -174,7 +174,7 @@ bool RimWellPathCollection::loadDataAndUpdate() return count; }; - caf::ProgressInfo progress( allWellPaths().size() + countWellLogs( allWellPaths() ) + 2, "Reading well paths from file", false, true, false ); + caf::ProgressInfo progress( allWellPaths().size() + countWellLogs( allWellPaths() ) + 2, "Reading well paths from file", false, true ); readWellPathFormationFiles(); diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index d8bf3793b2..6b44139b28 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -127,15 +127,11 @@ ProgressTask::~ProgressTask() /// If you do not need a title for a particular level, simply pass "" and it will be ignored. /// \sa setProgressDescription //-------------------------------------------------------------------------------------------------- -ProgressInfo::ProgressInfo( size_t maxProgressValue, - const QString& title, - bool delayShowingProgress, - bool allowCancel, - bool shouldProcessEvents ) +ProgressInfo::ProgressInfo( size_t maxProgressValue, const QString& title, bool delayShowingProgress, bool allowCancel ) { m_isCancelled.store( false ); - ProgressInfoStatic::start( *this, maxProgressValue, title, delayShowingProgress, allowCancel, shouldProcessEvents ); + ProgressInfoStatic::start( *this, maxProgressValue, title, delayShowingProgress, allowCancel ); if ( dynamic_cast( QCoreApplication::instance() ) ) { @@ -480,10 +476,9 @@ ProgressInfoBlocker::~ProgressInfoBlocker() /// //================================================================================================== -bool ProgressInfoStatic::s_disabled = false; -bool ProgressInfoStatic::s_running = false; -bool ProgressInfoStatic::s_isButtonConnected = false; -bool ProgressInfoStatic::s_shouldProcessEvents = true; +bool ProgressInfoStatic::s_disabled = false; +bool ProgressInfoStatic::s_running = false; +bool ProgressInfoStatic::s_isButtonConnected = false; //-------------------------------------------------------------------------------------------------- /// @@ -492,11 +487,8 @@ void ProgressInfoStatic::start( ProgressInfo& progressInfo, size_t maxProgressValue, const QString& title, bool delayShowingProgress, - bool allowCancel, - bool shouldProcessEvents ) + bool allowCancel ) { - s_shouldProcessEvents = shouldProcessEvents; - if ( !isUpdatePossible() ) return; std::vector& progressStack_v = progressStack(); @@ -549,8 +541,8 @@ void ProgressInfoStatic::start( ProgressInfo& progressInfo, dialog->setValue( static_cast( currentTotalProgress() ) ); dialog->setLabelText( currentComposedLabel() ); } - - if ( s_shouldProcessEvents ) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + // if (progressDialog()) progressDialog()->repaint(); } //-------------------------------------------------------------------------------------------------- @@ -567,8 +559,8 @@ void ProgressInfoStatic::setProgressDescription( const QString& description ) { dialog->setLabelText( currentComposedLabel() ); } - - if ( s_shouldProcessEvents ) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + // if (progressDialog()) progressDialog()->repaint(); } //-------------------------------------------------------------------------------------------------- @@ -613,7 +605,8 @@ void ProgressInfoStatic::setProgress( size_t progressValue ) dialog->setValue( totalProgress ); } - if ( s_shouldProcessEvents ) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + // if (progressDialog()) progressDialog()->repaint(); } //-------------------------------------------------------------------------------------------------- @@ -694,6 +687,8 @@ void ProgressInfoStatic::finished() dialog->setLabelText( currentComposedLabel() ); } + // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + // If we are finishing the last level, clean up if ( maxProgressStack_v.empty() ) { diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h index a0c791fd25..48a50170a0 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h @@ -59,11 +59,7 @@ class ProgressTask class ProgressInfo { public: - ProgressInfo( size_t maxProgressValue, - const QString& title, - bool delayShowingProgress = true, - bool allowCancel = false, - bool shouldProcessEvents = true ); + ProgressInfo( size_t maxProgressValue, const QString& title, bool delayShowingProgress = true, bool allowCancel = false ); ~ProgressInfo(); void setProgressDescription( const QString& description ); @@ -93,8 +89,7 @@ class ProgressInfoStatic size_t maxProgressValue, const QString& title, bool delayShowingProgress, - bool allowCancel, - bool shouldProcessEvents ); + bool allowCance ); static void setProgressDescription( const QString& description ); static void setProgress( size_t progressValue ); @@ -112,7 +107,6 @@ class ProgressInfoStatic static bool s_running; static bool s_disabled; static bool s_isButtonConnected; - static bool s_shouldProcessEvents; }; } // namespace caf From 2e61023a855c14efd1fabf88ee3c6c5ae1dc7540 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 10 Sep 2024 08:19:32 +0200 Subject: [PATCH 293/332] Bump to dev.18 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 74171d4079..20c969a3ac 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".17") +set(RESINSIGHT_DEV_VERSION ".18") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 8ea818f03e14e2ac1a60694d332e26342b856869 Mon Sep 17 00:00:00 2001 From: Jon Jenssen Date: Tue, 10 Sep 2024 14:48:01 +0200 Subject: [PATCH 294/332] Don't skip loading data if one or more timesteps are missing. --- .../ReservoirDataModel/RigCaseCellResultsData.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 0c4f2fe446..cb2f55eec1 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -1441,8 +1441,6 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu // Add one more result to result container size_t timeStepCount = infoForEachResultIndex()[scalarResultIndex].timeStepInfos().size(); - bool resultLoadingSuccess = true; - size_t tempGridCellCount = m_ownerMainGrid->totalTemporaryGridCellCount(); if ( type == RiaDefines::ResultCatType::DYNAMIC_NATIVE && timeStepCount > 0 ) @@ -1455,7 +1453,7 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu std::vector& values = m_cellScalarResults[scalarResultIndex][i]; if ( !m_readerInterface->dynamicResult( resultName, m_porosityModel, i, &values ) ) { - resultLoadingSuccess = false; + values.clear(); } else if ( tempGridCellCount > 0 ) { @@ -1475,7 +1473,7 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu std::vector& values = m_cellScalarResults[scalarResultIndex][0]; if ( !m_readerInterface->staticResult( resultName, m_porosityModel, &values ) ) { - resultLoadingSuccess = false; + values.clear(); } else if ( tempGridCellCount > 0 ) { @@ -1487,12 +1485,6 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu } } } - - if ( !resultLoadingSuccess ) - { - // Remove last scalar result because loading of result failed - m_cellScalarResults[scalarResultIndex].clear(); - } } if ( resultName == RiaResultNames::riCellVolumeResultName() ) From a3a740b722898befa9293cbbcaaf24e848ae5a4d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 11 Sep 2024 09:32:11 +0200 Subject: [PATCH 295/332] PFLOTRAN: Make parsing of faults more robust Remove logging text causing noise, write out message only when PFLOTRAN file is found. --- .../FileInterface/RifEclipseInputFileTools.cpp | 14 ++++---------- .../FileInterface/RifReaderInterface.cpp | 2 -- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp index 82815dcd8a..932c171ac2 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp @@ -1061,7 +1061,7 @@ void RifEclipseInputFileTools::parsePflotranInputFile( const QString& fileName, { QStringList gridSectionFilenames; - RiaLogging::info( "Looking for 'Pflotran' fault definitions in " + fileName ); + RiaLogging::info( "Looking for faults in 'PFLOTRAN' file: " + fileName ); { // Find all referenced grdecl files in a pflotran input file, in the GRID section, example @@ -1137,15 +1137,9 @@ void RifEclipseInputFileTools::parsePflotranInputFile( const QString& fileName, { QFileInfo fi( gridSectionFilename ); QDir currentFileFolder = fi.absoluteDir(); - - QString absoluteFilePath = currentFileFolder.absoluteFilePath( words[1] ); - QFile grdeclFilename( absoluteFilePath ); - if ( !grdeclFilename.open( QFile::ReadOnly ) ) continue; - - auto currentFaultCount = faults->size(); - - readFaults( grdeclFilename, 0, faults, nullptr ); - + auto currentFaultCount = faults->size(); + QString absoluteFilePath = currentFileFolder.absoluteFilePath( words[1] ); + parseAndReadFaults( absoluteFilePath, faults ); if ( currentFaultCount != faults->size() ) { RiaLogging::info( "Imported faults from " + absoluteFilePath ); diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp index 48da9d6007..305972c1ae 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp @@ -181,8 +181,6 @@ void RifReaderInterface::importFaults( const QStringList& fileSet, cvf::Collecti if ( !isDataFileFound ) { - RiaLogging::info( "No *.DATA file is found" ); - for ( const auto& filename : fileSet ) { if ( filename.endsWith( ".IN", Qt::CaseInsensitive ) ) From 9e41db33f5e10c6502db2e63f7c0eb186992e4b5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 11 Sep 2024 11:01:25 +0200 Subject: [PATCH 296/332] Progress: optionally call QApplication::processEvents on progress updates Add ProgressInfoEventProcessingBlocker Co-authored-by: Kristian Bendiksen kristian.bendiksen@gmail.com --- .../RicWellPathsImportOsduFeature.cpp | 7 ++-- .../WellPath/RimWellPathCollection.cpp | 1 + .../cafUserInterface/cafProgressInfo.cpp | 36 +++++++++++++------ Fwk/AppFwk/cafUserInterface/cafProgressInfo.h | 13 ++++++- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp index 58854cd9da..5c29c921d1 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RicWellPathsImportOsduFeature.cpp @@ -80,9 +80,10 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked ) { std::vector importedWells = wellImportwizard.importedWells(); - caf::ProgressInfo progress( importedWells.size(), "Importing wells from OSDU", false, true ); - int colorIndex = 0; - std::vector newWells; + caf::ProgressInfoEventProcessingBlocker blocker; + caf::ProgressInfo progress( importedWells.size(), "Importing wells from OSDU", false, true ); + int colorIndex = 0; + std::vector newWells; for ( const auto& w : importedWells ) { auto wellPath = new RimOsduWellPath; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index 219266f89a..c6c69e8db8 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -174,6 +174,7 @@ bool RimWellPathCollection::loadDataAndUpdate() return count; }; + caf::ProgressInfoEventProcessingBlocker blocker; caf::ProgressInfo progress( allWellPaths().size() + countWellLogs( allWellPaths() ) + 2, "Reading well paths from file", false, true ); readWellPathFormationFiles(); diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index 6b44139b28..1d1f3399b8 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -476,9 +476,10 @@ ProgressInfoBlocker::~ProgressInfoBlocker() /// //================================================================================================== -bool ProgressInfoStatic::s_disabled = false; -bool ProgressInfoStatic::s_running = false; -bool ProgressInfoStatic::s_isButtonConnected = false; +bool ProgressInfoStatic::s_disabled = false; +bool ProgressInfoStatic::s_running = false; +bool ProgressInfoStatic::s_isButtonConnected = false; +bool ProgressInfoStatic::s_shouldProcessEvents = true; //-------------------------------------------------------------------------------------------------- /// @@ -541,8 +542,8 @@ void ProgressInfoStatic::start( ProgressInfo& progressInfo, dialog->setValue( static_cast( currentTotalProgress() ) ); dialog->setLabelText( currentComposedLabel() ); } - // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); - // if (progressDialog()) progressDialog()->repaint(); + + if ( s_shouldProcessEvents ) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); } //-------------------------------------------------------------------------------------------------- @@ -559,8 +560,8 @@ void ProgressInfoStatic::setProgressDescription( const QString& description ) { dialog->setLabelText( currentComposedLabel() ); } - // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); - // if (progressDialog()) progressDialog()->repaint(); + + if ( s_shouldProcessEvents ) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); } //-------------------------------------------------------------------------------------------------- @@ -605,8 +606,7 @@ void ProgressInfoStatic::setProgress( size_t progressValue ) dialog->setValue( totalProgress ); } - // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); - // if (progressDialog()) progressDialog()->repaint(); + if ( s_shouldProcessEvents ) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); } //-------------------------------------------------------------------------------------------------- @@ -687,8 +687,6 @@ void ProgressInfoStatic::finished() dialog->setLabelText( currentComposedLabel() ); } - // QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); - // If we are finishing the last level, clean up if ( maxProgressStack_v.empty() ) { @@ -730,4 +728,20 @@ bool ProgressInfoStatic::isUpdatePossible() return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +ProgressInfoEventProcessingBlocker::ProgressInfoEventProcessingBlocker() +{ + ProgressInfoStatic::s_shouldProcessEvents = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +ProgressInfoEventProcessingBlocker::~ProgressInfoEventProcessingBlocker() +{ + ProgressInfoStatic::s_shouldProcessEvents = true; +} + } // namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h index 48a50170a0..3016ec02bb 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.h @@ -75,6 +75,15 @@ class ProgressInfo std::atomic m_isCancelled; }; +// This class is used to block the processing of events while a progress info dialog is shown. This is required when the +// progress info dialog is shown from a non-GUI thread. +class ProgressInfoEventProcessingBlocker +{ +public: + ProgressInfoEventProcessingBlocker(); + ~ProgressInfoEventProcessingBlocker(); +}; + class ProgressInfoBlocker { public: @@ -89,7 +98,7 @@ class ProgressInfoStatic size_t maxProgressValue, const QString& title, bool delayShowingProgress, - bool allowCance ); + bool allowCancel ); static void setProgressDescription( const QString& description ); static void setProgress( size_t progressValue ); @@ -104,9 +113,11 @@ class ProgressInfoStatic private: friend class ProgressInfoBlocker; + friend class ProgressInfoEventProcessingBlocker; static bool s_running; static bool s_disabled; static bool s_isButtonConnected; + static bool s_shouldProcessEvents; }; } // namespace caf From eb0b02ae46611c0bc99e36adf266312d96281ef5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 11 Sep 2024 15:56:35 +0200 Subject: [PATCH 297/332] #9935 Avoid storing dock layout if window never has been visible Do not save the state if the window never has been visible. This will write out a state that is not valid. --- .../UserInterface/RiuMainWindowBase.cpp | 15 +++++++++++++++ .../UserInterface/RiuMainWindowBase.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp b/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp index adfcd08106..8267eb9e80 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp @@ -63,6 +63,7 @@ RiuMainWindowBase::RiuMainWindowBase() , m_showFirstVisibleWindowMaximized( true ) , m_blockSubWindowActivation( false ) , m_blockSubWindowProjectTreeSelection( false ) + , m_hasBeenVisible( false ) , m_windowMenu( nullptr ) , m_mdiArea( nullptr ) { @@ -214,6 +215,10 @@ QString mainWindowDockWidgetSettingsKey( const QString& settingsFolderName ) //-------------------------------------------------------------------------------------------------- void RiuMainWindowBase::saveWinGeoAndDockToolBarLayout() { + // Do not save the state if the window never has been visible. This will write out a state that is not valid. + // https://github.com/OPM/ResInsight/issues/9935 + if ( !m_hasBeenVisible ) return; + // Company and appname set through QCoreApplication QSettings settings; @@ -787,3 +792,13 @@ void RiuMainWindowBase::addDefaultEntriesToWindowsMenu() m_windowMenu->addAction( cascadeWindowsAction ); m_windowMenu->addAction( closeAllSubWindowsAction ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::showEvent( QShowEvent* event ) +{ + m_hasBeenVisible = true; + + QMainWindow::showEvent( event ); +} diff --git a/ApplicationLibCode/UserInterface/RiuMainWindowBase.h b/ApplicationLibCode/UserInterface/RiuMainWindowBase.h index 752aa3e605..6b94a3bb7a 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindowBase.h +++ b/ApplicationLibCode/UserInterface/RiuMainWindowBase.h @@ -117,6 +117,8 @@ class RiuMainWindowBase : public QMainWindow virtual QStringList windowsMenuFeatureNames() = 0; + void showEvent( QShowEvent* event ) override; + protected slots: void slotDockWidgetToggleViewActionTriggered(); void slotRefreshHelpActions(); @@ -156,6 +158,7 @@ protected slots: bool m_showFirstVisibleWindowMaximized; bool m_blockSubWindowActivation; bool m_blockSubWindowProjectTreeSelection; + bool m_hasBeenVisible; ads::CDockManager* m_dockManager; }; From 92907b04ef8ea602eb4a14f33aa2291a54b0b2d2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 12 Sep 2024 09:27:49 +0200 Subject: [PATCH 298/332] Bump to dev.19 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 20c969a3ac..4d5ee19826 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".18") +set(RESINSIGHT_DEV_VERSION ".19") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From fd2989972dffb92eb435491a67874af53fe2a173 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Fri, 13 Sep 2024 07:34:14 +0200 Subject: [PATCH 299/332] Add option to skip/invalidate long, thin cells. (#11691) * Add option to choose if the user wants to skip/invalidate long, thin cells. --- .../Application/RiaPreferencesGrid.cpp | 18 +++++++++++++-- .../Application/RiaPreferencesGrid.h | 2 ++ .../RifEclipseInputFileTools.cpp | 2 +- .../FileInterface/RifReaderEclipseOutput.cpp | 23 ++++++++++++++----- .../FileInterface/RifReaderEclipseOutput.h | 5 ++-- .../FileInterface/RifReaderInterface.cpp | 8 +++++++ .../FileInterface/RifReaderInterface.h | 1 + .../FileInterface/RifReaderOpmCommon.cpp | 8 +++++-- .../RifReaderOpmCommonActive.cpp | 7 +++++- .../FileInterface/RifReaderSettings.h | 1 + 10 files changed, 61 insertions(+), 14 deletions(-) diff --git a/ApplicationLibCode/Application/RiaPreferencesGrid.cpp b/ApplicationLibCode/Application/RiaPreferencesGrid.cpp index ffd0df384e..8325153351 100644 --- a/ApplicationLibCode/Application/RiaPreferencesGrid.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesGrid.cpp @@ -91,6 +91,9 @@ RiaPreferencesGrid::RiaPreferencesGrid() CAF_PDM_InitField( &m_onlyLoadActiveCells, "onlyLoadActiveCells", false, "Only Load Active Cell Geometry (Experimental)" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_onlyLoadActiveCells ); + + CAF_PDM_InitField( &m_invalidateLongThinCells, "invalidateLongThinCells", false, "Skip Long, Thin Cells" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_invalidateLongThinCells ); } //-------------------------------------------------------------------------------------------------- @@ -109,6 +112,7 @@ void RiaPreferencesGrid::appendItems( caf::PdmUiOrdering& uiOrdering ) auto newCBGroup = uiOrdering.addNewGroup( "Behavior When Loading Data" ); newCBGroup->add( &m_autoComputeDepthRelatedProperties ); newCBGroup->add( &m_loadAndShowSoil ); + newCBGroup->add( &m_invalidateLongThinCells ); auto faultGrp = uiOrdering.addNewGroup( "Fault Import" ); @@ -158,7 +162,8 @@ RifReaderSettings RiaPreferencesGrid::gridOnlyReaderSettings() true, // skipWellData false, // import summary data "", // include prefix, - false // only active cells + false, // only active cells + true // ignore long thin cells }; return rs; } @@ -176,7 +181,8 @@ RifReaderSettings RiaPreferencesGrid::readerSettings() m_skipWellData, true, // import summary data m_includeFileAbsolutePathPrefix, - m_onlyLoadActiveCells }; + m_onlyLoadActiveCells, + m_invalidateLongThinCells }; return rs; } @@ -260,6 +266,14 @@ bool RiaPreferencesGrid::onlyLoadActiveCells() const return m_onlyLoadActiveCells; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesGrid::invalidateLongThinCells() const +{ + return m_invalidateLongThinCells; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferencesGrid.h b/ApplicationLibCode/Application/RiaPreferencesGrid.h index 9c2d4ec63a..c748e6ce54 100644 --- a/ApplicationLibCode/Application/RiaPreferencesGrid.h +++ b/ApplicationLibCode/Application/RiaPreferencesGrid.h @@ -55,6 +55,7 @@ class RiaPreferencesGrid : public caf::PdmObject bool loadAndShowSoil() const; bool autoComputeDepthRelatedProperties() const; bool onlyLoadActiveCells() const; + bool invalidateLongThinCells() const; RiaDefines::GridModelReader gridModelReader() const; void setGridModelReaderOverride( const std::string& readerName ); @@ -75,4 +76,5 @@ class RiaPreferencesGrid : public caf::PdmObject caf::PdmField m_autoComputeDepthRelatedProperties; caf::PdmField m_loadAndShowSoil; caf::PdmField m_onlyLoadActiveCells; + caf::PdmField m_invalidateLongThinCells; }; diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp index 932c171ac2..c13e4e6060 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp @@ -161,7 +161,7 @@ bool RifEclipseInputFileTools::openGridFile( const QString& fileName, RigEclipse ecl_grid_type* inputGrid = ecl_grid_alloc_GRDECL_kw( nx, ny, nz, zCornKw, coordKw, actNumKw, mapAxesKw ); - RifReaderEclipseOutput::transferGeometry( inputGrid, eclipseCase ); + RifReaderEclipseOutput::transferGeometry( inputGrid, eclipseCase, false ); if ( readFaultData ) { diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp index 17c842596d..5f69945f3a 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp @@ -155,7 +155,8 @@ bool RifReaderEclipseOutput::transferGridCellData( RigMainGrid* mainGrid RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t matrixActiveStartIndex, - size_t fractureActiveStartIndex ) + size_t fractureActiveStartIndex, + bool invalidateLongPyramidCells ) { CVF_ASSERT( activeCellInfo && fractureActiveCellInfo ); @@ -225,7 +226,10 @@ bool RifReaderEclipseOutput::transferGridCellData( RigMainGrid* mainGrid // Forslag // if (!invalid && (cell.isInCoarseCell() || (!cell.isActiveInMatrixModel() && // !cell.isActiveInFractureModel()) ) ) - cell.setInvalid( cell.isLongPyramidCell() ); + if ( invalidateLongPyramidCells ) + { + cell.setInvalid( cell.isLongPyramidCell() ); + } } return true; @@ -234,7 +238,7 @@ bool RifReaderEclipseOutput::transferGridCellData( RigMainGrid* mainGrid //-------------------------------------------------------------------------------------------------- /// Read geometry from file given by name into given reservoir object //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::transferGeometry( const ecl_grid_type* mainEclGrid, RigEclipseCaseData* eclipseCase ) +bool RifReaderEclipseOutput::transferGeometry( const ecl_grid_type* mainEclGrid, RigEclipseCaseData* eclipseCase, bool invalidateLongThinCells ) { CVF_ASSERT( eclipseCase ); @@ -306,7 +310,7 @@ bool RifReaderEclipseOutput::transferGeometry( const ecl_grid_type* mainEclGrid, { auto task = progInfo.task( "Loading Main Grid Data", 3 ); - transferGridCellData( mainGrid, activeCellInfo, fractureActiveCellInfo, mainGrid, mainEclGrid, 0, 0 ); + transferGridCellData( mainGrid, activeCellInfo, fractureActiveCellInfo, mainGrid, mainEclGrid, 0, 0, invalidateLongThinCells ); } size_t globalMatrixActiveSize = ecl_grid_get_nactive( mainEclGrid ); @@ -327,7 +331,14 @@ bool RifReaderEclipseOutput::transferGeometry( const ecl_grid_type* mainEclGrid, ecl_grid_type* localEclGrid = ecl_grid_iget_lgr( mainEclGrid, lgrIdx ); RigLocalGrid* localGrid = static_cast( mainGrid->gridByIndex( lgrIdx + 1 ) ); - transferGridCellData( mainGrid, activeCellInfo, fractureActiveCellInfo, localGrid, localEclGrid, globalMatrixActiveSize, globalFractureActiveSize ); + transferGridCellData( mainGrid, + activeCellInfo, + fractureActiveCellInfo, + localGrid, + localEclGrid, + globalMatrixActiveSize, + globalFractureActiveSize, + invalidateLongThinCells ); int matrixActiveCellCount = ecl_grid_get_nactive( localEclGrid ); globalMatrixActiveSize += matrixActiveCellCount; @@ -395,7 +406,7 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* { auto task = progress.task( "Transferring grid geometry", 10 ); - if ( !transferGeometry( mainEclGrid, eclipseCaseData ) ) return false; + if ( !transferGeometry( mainEclGrid, eclipseCaseData, invalidateLongThinCells() ) ) return false; RifOpmRadialGridTools::importCoordinatesForRadialGrid( fileName.toStdString(), eclipseCaseData->mainGrid() ); } diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h index 2b57a74231..b7aee2dfb7 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h @@ -72,7 +72,7 @@ class RifReaderEclipseOutput : public RifReaderInterface std::vector allTimeSteps() const; - static bool transferGeometry( const ecl_grid_type* mainEclGrid, RigEclipseCaseData* eclipseCase ); + static bool transferGeometry( const ecl_grid_type* mainEclGrid, RigEclipseCaseData* eclipseCase, bool invalidateLongThinCells ); static void transferCoarseningInfo( const ecl_grid_type* eclGrid, RigGridBase* grid ); static void importEquilData( const QString& deckFileName, const QString& includeStatementAbsolutePathPrefix, RigEclipseCaseData* eclipseCase ); @@ -111,7 +111,8 @@ class RifReaderEclipseOutput : public RifReaderInterface RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t matrixActiveStartIndex, - size_t fractureActiveStartIndex ); + size_t fractureActiveStartIndex, + bool invalidateLongPyramidCells ); private: QString m_fileName; // Name of file used to start accessing Eclipse output files diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp index 305972c1ae..a52a73a613 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp @@ -89,6 +89,14 @@ bool RifReaderInterface::onlyLoadActiveCells() const return m_readerSettings.onlyLoadActiveCells; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderInterface::invalidateLongThinCells() const +{ + return m_readerSettings.invalidateLongThinCells; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.h b/ApplicationLibCode/FileInterface/RifReaderInterface.h index cd391a3766..4706f64357 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.h +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.h @@ -58,6 +58,7 @@ class RifReaderInterface : public cvf::Object bool loadWellDataEnabled() const; const QString faultIncludeFileAbsolutePathPrefix() const; bool onlyLoadActiveCells() const; + bool invalidateLongThinCells() const; void setReaderSettings( RifReaderSettings readerSettings ); diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp index 0d48feb263..dd9ba7c4c9 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp @@ -414,6 +414,8 @@ void RifReaderOpmCommon::transferGeometry( Opm::EclIO::EGrid& opmMainGrid, size_t cellStartIndex = mainGrid->globalCellArray().size(); size_t nodeStartIndex = mainGrid->nodes().size(); + const bool invalidateLongPyramidCells = invalidateLongThinCells(); + RigCell defaultCell; defaultCell.setHostGrid( localGrid ); @@ -504,8 +506,10 @@ void RifReaderOpmCommon::transferGeometry( Opm::EclIO::EGrid& opmMainGrid, yCenterCoordOpm ); } } - - cell.setInvalid( cell.isLongPyramidCell() ); + if ( invalidateLongPyramidCells ) + { + cell.setInvalid( cell.isLongPyramidCell() ); + } } // subgrid pointers diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp index 53ea8662ae..6807d44fc7 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp @@ -183,6 +183,8 @@ void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMa ? RifOpmRadialGridTools::computeXyCenterForTopOfCells( opmMainGrid, opmMainGrid, activeGrid ) : std::map>(); + const bool invalidateLongPyramidCells = invalidateLongThinCells(); + // use same mapping as resdata const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 }; @@ -230,6 +232,9 @@ void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMa cell.cornerIndices()[riCornerIndex] = riNodeIndex; } - cell.setInvalid( cell.isLongPyramidCell() ); + if ( invalidateLongPyramidCells ) + { + cell.setInvalid( cell.isLongPyramidCell() ); + } } } diff --git a/ApplicationLibCode/FileInterface/RifReaderSettings.h b/ApplicationLibCode/FileInterface/RifReaderSettings.h index 689de687cd..da664225b6 100644 --- a/ApplicationLibCode/FileInterface/RifReaderSettings.h +++ b/ApplicationLibCode/FileInterface/RifReaderSettings.h @@ -36,4 +36,5 @@ struct RifReaderSettings bool importSummaryData; QString includeFileAbsolutePathPrefix; bool onlyLoadActiveCells; + bool invalidateLongThinCells; }; From 83eef053698a4202367505fb98678d0a1d4cf874 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 13 Sep 2024 08:40:08 +0200 Subject: [PATCH 300/332] Bump to dev.20 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 4d5ee19826..88a07763bb 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".19") +set(RESINSIGHT_DEV_VERSION ".20") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 6b4e7fbdc9a20a3a21b989f382ad995ea6fcee91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Berland?= Date: Fri, 13 Sep 2024 12:55:26 +0200 Subject: [PATCH 301/332] Solve Python SyntaxWarning when running tests Using is in this way has been triggering a SyntaxWarning since Python 3.8 --- GrpcInterface/Python/rips/tests/test_cases.py | 10 +++++----- .../Python/rips/tests/test_object_lifetime.py | 8 ++++---- GrpcInterface/Python/rips/tests/test_project.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/GrpcInterface/Python/rips/tests/test_cases.py b/GrpcInterface/Python/rips/tests/test_cases.py index 8da2b405c9..904f9401e6 100644 --- a/GrpcInterface/Python/rips/tests/test_cases.py +++ b/GrpcInterface/Python/rips/tests/test_cases.py @@ -17,7 +17,7 @@ def test_Launch(rips_instance, initialize_test): def test_EmptyProject(rips_instance, initialize_test): cases = rips_instance.project.cases() - assert len(cases) is 0 + assert len(cases) == 0 def test_OneCase(rips_instance, initialize_test): @@ -27,7 +27,7 @@ def test_OneCase(rips_instance, initialize_test): assert case.name == "TEST10K_FLT_LGR_NNC" assert case.id == 0 cases = rips_instance.project.cases() - assert len(cases) is 1 + assert len(cases) == 1 def test_BoundingBox(rips_instance, initialize_test): @@ -136,7 +136,7 @@ def test_PdmObject(rips_instance, initialize_test): case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID" case = rips_instance.project.load_case(path=case_path) assert case.id == 0 - assert case.address() is not 0 + assert case.address() != 0 assert case.__class__.__name__ == "EclipseCase" @@ -163,7 +163,7 @@ def test_replaceCase(rips_instance, initialize_test): assert case.name == "TEST10K_FLT_LGR_NNC" assert case.id == 0 cases = rips_instance.project.cases() - assert len(cases) is 1 + assert len(cases) == 1 case.replace(new_grid_file=case_path) # Check that the case object has been changed @@ -171,7 +171,7 @@ def test_replaceCase(rips_instance, initialize_test): assert case.id == 0 cases = rips_instance.project.cases() - assert len(cases) is 1 + assert len(cases) == 1 # Check that retrieving the case object again will yield the changed object case = project.case(case_id=0) assert case.name == "BRUGGE_0000" diff --git a/GrpcInterface/Python/rips/tests/test_object_lifetime.py b/GrpcInterface/Python/rips/tests/test_object_lifetime.py index 1175a002b8..8a157d9306 100644 --- a/GrpcInterface/Python/rips/tests/test_object_lifetime.py +++ b/GrpcInterface/Python/rips/tests/test_object_lifetime.py @@ -7,14 +7,14 @@ def test_well_path(rips_instance, initialize_test): well_path_coll = rips_instance.project.descendants(rips.WellPathCollection)[0] - assert len(well_path_coll.well_paths()) is 0 + assert len(well_path_coll.well_paths()) == 0 well_path = well_path_coll.add_new_object(rips.ModeledWellPath) well_path2 = well_path_coll.add_new_object(rips.ModeledWellPath) - assert len(well_path_coll.well_paths()) is 2 + assert len(well_path_coll.well_paths()) == 2 well_path.delete() - assert len(well_path_coll.well_paths()) is 1 + assert len(well_path_coll.well_paths()) == 1 try: # Delete again should throw exception @@ -24,4 +24,4 @@ def test_well_path(rips_instance, initialize_test): assert True well_path2.delete() - assert len(well_path_coll.well_paths()) is 0 + assert len(well_path_coll.well_paths()) == 0 diff --git a/GrpcInterface/Python/rips/tests/test_project.py b/GrpcInterface/Python/rips/tests/test_project.py index 000e3e509a..76e5e1f4b1 100644 --- a/GrpcInterface/Python/rips/tests/test_project.py +++ b/GrpcInterface/Python/rips/tests/test_project.py @@ -19,7 +19,7 @@ def test_loadProject(rips_instance, initialize_test): assert case.name == "TEST10K_FLT_LGR_NNC" assert case.id == 0 cases = rips_instance.project.cases() - assert len(cases) is 1 + assert len(cases) == 1 def test_well_log_plots(rips_instance, initialize_test): From 281706e2eb32c99e4e57e5856028a7050a18357a Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 13 Sep 2024 14:08:15 +0200 Subject: [PATCH 302/332] Fix missing grid ensemble cases in RimProject::allGridCases. --- .../ProjectDataModel/RimProject.cpp | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index e0e0561523..6144efaefe 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -52,6 +52,7 @@ #include "RimDialogData.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" +#include "RimEclipseCaseEnsemble.h" #include "RimEclipseContourMapViewCollection.h" #include "RimEclipseViewCollection.h" #include "RimEnsembleWellLogsCollection.h" @@ -570,6 +571,7 @@ std::vector RimProject::allGridCases() const { cases.push_back( eclipseCase ); } + for ( RimIdenticalGridCaseGroup* cg : analysisModels->caseGroups ) { // Load the Main case of each IdenticalGridCaseGroup @@ -590,14 +592,22 @@ std::vector RimProject::allGridCases() const } } } - } - RimGeoMechModels* geomModels = oilField->geoMechModels(); - if ( geomModels ) - { - for ( auto acase : geomModels->cases() ) + for ( RimEclipseCaseEnsemble* ensemble : analysisModels->caseEnsembles() ) { - cases.push_back( acase ); + for ( RimEclipseCase* acase : ensemble->cases() ) + { + cases.push_back( acase ); + } + } + + RimGeoMechModels* geomModels = oilField->geoMechModels(); + if ( geomModels ) + { + for ( auto acase : geomModels->cases() ) + { + cases.push_back( acase ); + } } } } From f4da2d748f1b51a0d792011ac01a90df52c05050 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 13 Sep 2024 10:55:53 +0200 Subject: [PATCH 303/332] #11693 Store camera position for each associated case A top level view can change the connected grid case. Add option to store the camera position for each grid case. Add option Store View Settings for Case , default off. --- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/Rim3dView.h | 4 +- .../ProjectDataModel/RimCameraPosition.cpp | 87 +++++++++++++++++++ .../ProjectDataModel/RimCameraPosition.h | 54 ++++++++++++ .../ProjectDataModel/RimEclipseView.cpp | 73 +++++++++++++++- .../ProjectDataModel/RimEclipseView.h | 7 +- 6 files changed, 221 insertions(+), 6 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/RimCameraPosition.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/RimCameraPosition.h diff --git a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake index abefbff49e..67bccb2642 100644 --- a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake @@ -133,6 +133,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimEmCase.h ${CMAKE_CURRENT_LIST_DIR}/RimEclipseViewCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseEnsemble.h + ${CMAKE_CURRENT_LIST_DIR}/RimCameraPosition.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -266,6 +267,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimPolylinePickerInterface.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEclipseViewCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseEnsemble.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimCameraPosition.cpp ) if(RESINSIGHT_USE_QT_CHARTS) diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.h b/ApplicationLibCode/ProjectDataModel/Rim3dView.h index 7272e8ea8a..dca057a54b 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.h @@ -266,6 +266,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public QWidget* createViewWidget( QWidget* mainWindowParent ) override; void setCameraPosition( const cvf::Mat4d& cameraPosition ) override; + void setCameraPointOfInterest( const cvf::Vec3d& cameraPointOfInterest ) override; protected: // Timestep Field. Children clamps this differently @@ -295,9 +296,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public // Implementation of RimNameConfigHolderInterface void performAutoNameUpdate() final; - // Implementation of RiuViewerToViewInterface - void setCameraPointOfInterest( const cvf::Vec3d& cameraPointOfInterest ) override; - void endAnimation() override; caf::PdmObjectHandle* implementingPdmObject() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimCameraPosition.cpp b/ApplicationLibCode/ProjectDataModel/RimCameraPosition.cpp new file mode 100644 index 0000000000..81ac3199b4 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimCameraPosition.cpp @@ -0,0 +1,87 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimCameraPosition.h" + +#include "RimEclipseCase.h" + +CAF_PDM_SOURCE_INIT( RimCameraPosition, "RimCameraPosition" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCameraPosition::RimCameraPosition() +{ + CAF_PDM_InitObject( "Camera Position for Case" ); + + CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case" ); + + CAF_PDM_InitField( &m_cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "" ); + m_cameraPosition.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitField( &m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "" ); + m_cameraPointOfInterest.uiCapability()->setUiHidden( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase* RimCameraPosition::eclipseCase() const +{ + return m_eclipseCase(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCameraPosition::setEclipseCase( RimEclipseCase* eclipseCase ) +{ + m_eclipseCase = eclipseCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Mat4d RimCameraPosition::cameraPosition() const +{ + return m_cameraPosition(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCameraPosition::setCameraPosition( const cvf::Mat4d& cameraPosition ) +{ + m_cameraPosition = cameraPosition; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RimCameraPosition::cameraPointOfInterest() const +{ + return m_cameraPointOfInterest(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCameraPosition::setCameraPointOfInterest( const cvf::Vec3d& cameraPointOfInterest ) +{ + m_cameraPointOfInterest = cameraPointOfInterest; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimCameraPosition.h b/ApplicationLibCode/ProjectDataModel/RimCameraPosition.h new file mode 100644 index 0000000000..6a6d652121 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimCameraPosition.h @@ -0,0 +1,54 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "cafPdmObject.h" + +#include "cafPdmField.h" +#include "cafPdmFieldCvfMat4d.h" +#include "cafPdmFieldCvfVec3d.h" +#include "cafPdmPtrField.h" + +class RimEclipseCase; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimCameraPosition : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimCameraPosition(); + + RimEclipseCase* eclipseCase() const; + void setEclipseCase( RimEclipseCase* eclipseCase ); + + cvf::Mat4d cameraPosition() const; + void setCameraPosition( const cvf::Mat4d& cameraPosition ); + + cvf::Vec3d cameraPointOfInterest() const; + void setCameraPointOfInterest( const cvf::Vec3d& cameraPointOfInterest ); + +private: + caf::PdmPtrField m_eclipseCase; + caf::PdmField m_cameraPosition; + caf::PdmField m_cameraPointOfInterest; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 9618024d72..33c7e0ebcb 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -47,6 +47,7 @@ #include "Rim3dOverlayInfoConfig.h" #include "RimAnnotationCollection.h" #include "RimAnnotationInViewCollection.h" +#include "RimCameraPosition.h" #include "RimCellEdgeColors.h" #include "RimCellFilterCollection.h" #include "RimEclipseCase.h" @@ -147,6 +148,7 @@ RimEclipseView::RimEclipseView() CAF_PDM_InitFieldNoDefault( &m_customEclipseCase_OBSOLETE, "CustomEclipseCase", "Custom Case" ); CAF_PDM_InitScriptableFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case" ); + CAF_PDM_InitField( &m_storeViewSettingsPerCase, "StoreViewSettingsPerCase", false, "Store View Settings for Case" ); CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault( &m_cellResult, "GridCellResult", "CellResult", "Cell Result", ":/CellResult.png" ); m_cellResult = new RimEclipseCellColors(); @@ -218,6 +220,8 @@ RimEclipseView::RimEclipseView() m_cellResult()->setAdditionalUiTreeObjects( { m_additionalResultsForResultInfo() } ); + CAF_PDM_InitFieldNoDefault( &m_cameraPositions, "CameraPositions", "Camera Positions for Cases" ); + setDeletable( true ); updateAnimations.connect( this, &RimEclipseView::onAnimationsUpdate ); @@ -394,6 +398,55 @@ void RimEclipseView::propagateEclipseCaseToChildObjects() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseView::storeCurrentAndApplyNewCameraPosition( RimEclipseCase* currentCase, RimEclipseCase* newCase ) +{ + auto settingsForCases = m_cameraPositions.childrenByType(); + + // Propagate viewer UI settings to RimEclipseView before accessing camera positions + setupBeforeSave(); + + auto findSettingsForCase = [&]( RimEclipseCase* eclipseCase ) -> RimCameraPosition* + { + for ( auto settingsForCase : settingsForCases ) + { + if ( settingsForCase->eclipseCase() == eclipseCase ) + { + return settingsForCase; + } + } + return nullptr; + }; + + if ( currentCase ) + { + RimCameraPosition* settingsForCurrentCase = findSettingsForCase( currentCase ); + if ( !settingsForCurrentCase ) + { + settingsForCurrentCase = new RimCameraPosition; + settingsForCurrentCase->setEclipseCase( currentCase ); + m_cameraPositions.push_back( settingsForCurrentCase ); + } + + settingsForCurrentCase->setCameraPosition( cameraPosition() ); + settingsForCurrentCase->setCameraPointOfInterest( cameraPointOfInterest() ); + } + + if ( newCase ) + { + if ( RimCameraPosition* settingsForNewCase = findSettingsForCase( newCase ) ) + { + viewer()->mainCamera()->setViewMatrix( settingsForNewCase->cameraPosition() ); + viewer()->setPointOfInterest( settingsForNewCase->cameraPointOfInterest() ); + return; + } + } + + zoomAll(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -410,7 +463,15 @@ void RimEclipseView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, updateGridBoxData(); updateAnnotationItems(); - zoomAll(); + if ( m_storeViewSettingsPerCase() ) + { + auto currentEclipseCase = dynamic_cast( oldValue.value>().rawPtr() ); + storeCurrentAndApplyNewCameraPosition( currentEclipseCase, m_eclipseCase ); + } + else + { + zoomAll(); + } return; } @@ -1564,6 +1625,8 @@ void RimEclipseView::updateLegendRangesTextAndVisibility( RimRegularLegendConfig //-------------------------------------------------------------------------------------------------- void RimEclipseView::setEclipseCase( RimEclipseCase* reservoir ) { + // TODO: How should we manage the view settings? See storeCurrentAndApplyNewCameraPosition() + m_eclipseCase = reservoir; propagateEclipseCaseToChildObjects(); @@ -1900,7 +1963,13 @@ const std::vector& RimEclipseView::visibleGridParts() const void RimEclipseView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { // Only show case option when not under a case in the project tree. - if ( !firstAncestorOrThisOfType() ) uiOrdering.add( &m_eclipseCase ); + if ( !firstAncestorOrThisOfType() ) + { + caf::PdmUiGroup* dataSourceGroup = uiOrdering.addNewGroup( "Data Source" ); + + dataSourceGroup->add( &m_eclipseCase ); + dataSourceGroup->add( &m_storeViewSettingsPerCase ); + } Rim3dView::defineUiOrdering( uiConfigName, uiOrdering ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h index a5730e9a4b..a3fd53385b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h @@ -69,6 +69,7 @@ class RimStreamlineInViewCollection; class RimMultipleEclipseResults; class RigEclipseResultAddress; class RimFaultReactivationModelCollection; +class RimCameraPosition; namespace cvf { @@ -220,10 +221,13 @@ class RimEclipseView : public RimGridView void setVisibleGridPartsWatertight(); void propagateEclipseCaseToChildObjects(); + void storeCurrentAndApplyNewCameraPosition( RimEclipseCase* previousCase, RimEclipseCase* newCase ); protected: - cvf::ref m_faultReactVizModel; + cvf::ref m_faultReactVizModel; + caf::PdmPtrField m_eclipseCase; + caf::PdmField m_storeViewSettingsPerCase; private: caf::PdmField m_showInvalidCells; @@ -255,4 +259,5 @@ class RimEclipseView : public RimGridView std::vector m_visibleGridParts; caf::PdmChildField m_additionalResultsForResultInfo; + caf::PdmChildArrayField m_cameraPositions; }; From fcec67e95e26ef8f6483dbd7b8d5695f9580c96e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 12 Sep 2024 12:57:56 +0200 Subject: [PATCH 304/332] Use gray background for read only line edit --- Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index 15ab06d5b8..c8259369c0 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -153,6 +153,10 @@ void PdmUiLineEditor::configureAndUpdateUi( const QString& uiConfigName ) QString highlightColor = UiAppearanceSettings::instance()->autoValueEditorColor(); m_lineEdit->setStyleSheet( QString( "QLineEdit {background-color: %1;}" ).arg( highlightColor ) ); } + else if ( uiField()->isUiReadOnly() ) + { + m_lineEdit->setStyleSheet( "QLineEdit:read-only{background: palette(window);}" ); + } else { m_lineEdit->setStyleSheet( "" ); From 50185418c2bd59615fa91f71dfe70619d144bffb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 12 Sep 2024 12:58:35 +0200 Subject: [PATCH 305/332] Rename to Data Source Property Editor --- ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp index a32cc45799..c86f8cf2d7 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp @@ -579,7 +579,7 @@ void RiuPlotMainWindow::createDockPanels() auto leftPropertyView = createPropertyView( "Property Editor", RiuDockWidgetTools::plotMainWindowPropertyEditorName(), leftArea ); auto rightPropertyView = - createPropertyView( "Property Editor (Right)", RiuDockWidgetTools::plotMainWindowPropertyEditorRightName(), rightArea ); + createPropertyView( "Data Source Property Editor", RiuDockWidgetTools::plotMainWindowPropertyEditorRightName(), rightArea ); // Connect project trees with property views for ( int i = 0; i < nTreeViews; i++ ) From a4159cd11ed335e1f0d23c9ee1360ae3ad82f9a4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 12 Sep 2024 12:59:13 +0200 Subject: [PATCH 306/332] Set fields read-only and make sure custom name is propagated --- .../Summary/Sumo/RimSummarySumoDataSource.cpp | 21 +++++++++++++++++++ .../Summary/Sumo/RimSummarySumoDataSource.h | 1 + 2 files changed, 22 insertions(+) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp index 3bcd310542..b2e2dc768a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.cpp @@ -175,17 +175,38 @@ void RimSummarySumoDataSource::defineEditorAttribute( const caf::PdmFieldHandle* void RimSummarySumoDataSource::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { auto group = uiOrdering.addNewGroup( "General" ); + group->add( nameField() ); + nameField()->uiCapability()->setUiReadOnly( true ); + group->add( &m_caseId ); + m_caseId.uiCapability()->setUiReadOnly( true ); + group->add( &m_caseName ); + m_caseName.uiCapability()->setUiReadOnly( true ); + group->add( &m_ensembleName ); + m_ensembleName.uiCapability()->setUiReadOnly( true ); + group->add( &m_customName ); auto summaryInfo = uiOrdering.addNewGroup( "Info" ); + summaryInfo->setCollapsedByDefault(); summaryInfo->add( &m_realizationInfo ); summaryInfo->add( &m_vectorNames ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummarySumoDataSource::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + if ( changedField == &m_customName ) + { + updateName(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.h b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.h index 948c7cc5ac..992b460a2e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummarySumoDataSource.h @@ -57,6 +57,7 @@ class RimSummarySumoDataSource : public RimNamedObject void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; QString realizationInfoText() const; From d8b8c86b8f8cba94c18de77465a00d60be7c4c7c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 12 Sep 2024 13:40:50 +0200 Subject: [PATCH 307/332] SUMO: Improve user interface - set fields read only - make sure custom case name is used in other UI items - use two buttons to create data source and ensemble for selected cloud ensembles --- .../Sumo/RicCreateSumoEnsembleFeature.cpp | 20 ++---- .../Cloud/RimCloudDataSourceCollection.cpp | 72 +++++++++++++++++-- .../Cloud/RimCloudDataSourceCollection.h | 6 +- 3 files changed, 74 insertions(+), 24 deletions(-) diff --git a/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp b/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp index 26a4e8d235..97d31d2921 100644 --- a/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp +++ b/ApplicationLibCode/Commands/Sumo/RicCreateSumoEnsembleFeature.cpp @@ -19,12 +19,10 @@ #include "RicCreateSumoEnsembleFeature.h" #include "RiaDefines.h" -#include "RiaSummaryTools.h" #include "PlotBuilderCommands/RicSummaryPlotBuilder.h" -#include "RimSummaryCaseMainCollection.h" -#include "Sumo/RimSummaryEnsembleSumo.h" +#include "Cloud/RimCloudDataSourceCollection.h" #include "Sumo/RimSummarySumoDataSource.h" #include "cafSelectionManagerTools.h" @@ -39,18 +37,8 @@ CAF_CMD_SOURCE_INIT( RicCreateSumoEnsembleFeature, "RicCreateSumoEnsembleFeature void RicCreateSumoEnsembleFeature::onActionTriggered( bool isChecked ) { auto dataSources = caf::selectedObjectsByType(); - for ( auto dataSource : dataSources ) - { - RimSummaryEnsembleSumo* ensemble = new RimSummaryEnsembleSumo(); - ensemble->setSumoDataSource( dataSource ); - ensemble->updateName(); - RiaSummaryTools::summaryCaseMainCollection()->addEnsemble( ensemble ); - ensemble->loadDataAndUpdate(); - - RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( {}, { ensemble } ); - } - - RiaSummaryTools::summaryCaseMainCollection()->updateAllRequiredEditors(); + + RimCloudDataSourceCollection::createEnsemblesFromSelectedDataSources( dataSources ); } //-------------------------------------------------------------------------------------------------- @@ -58,6 +46,6 @@ void RicCreateSumoEnsembleFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicCreateSumoEnsembleFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "Create Sumo Ensemble" + RiaDefines::betaFeaturePostfix() ); + actionToSetup->setText( "Create Ensemble Plot" + RiaDefines::betaFeaturePostfix() ); actionToSetup->setIcon( QIcon( ":/SummaryEnsemble.svg" ) ); } diff --git a/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp index 0d1f5b309d..5f1c7874c0 100644 --- a/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.cpp @@ -19,9 +19,14 @@ #include "RimCloudDataSourceCollection.h" #include "RiaApplication.h" +#include "RiaSummaryTools.h" + +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" #include "RimOilField.h" #include "RimProject.h" +#include "RimSummaryCaseMainCollection.h" +#include "Sumo/RimSummaryEnsembleSumo.h" #include "Sumo/RimSummarySumoDataSource.h" #include "RiuPlotMainWindowTools.h" @@ -44,7 +49,10 @@ RimCloudDataSourceCollection::RimCloudDataSourceCollection() CAF_PDM_InitFieldNoDefault( &m_sumoEnsembleNames, "SumoEnsembleNames", "Ensembles" ); m_sumoEnsembleNames.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_addEnsembles, "AddEnsembles", "" ); + CAF_PDM_InitFieldNoDefault( &m_addDataSources, "AddDataSources", "", "", "Add Data Sources without Ensembles" ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_addDataSources ); + + CAF_PDM_InitFieldNoDefault( &m_addEnsembles, "AddEnsembles", "", "", "Add Data Sources and Create Summary Ensemble Plots" ); caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_addEnsembles ); CAF_PDM_InitFieldNoDefault( &m_sumoDataSources, "SumoDataSources", "Sumo Data Sources" ); @@ -68,6 +76,25 @@ std::vector RimCloudDataSourceCollection::sumoDataSou return m_sumoDataSources.childrenByType(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCloudDataSourceCollection::createEnsemblesFromSelectedDataSources( const std::vector& dataSources ) +{ + for ( auto dataSource : dataSources ) + { + RimSummaryEnsembleSumo* ensemble = new RimSummaryEnsembleSumo(); + ensemble->setSumoDataSource( dataSource ); + ensemble->updateName(); + RiaSummaryTools::summaryCaseMainCollection()->addEnsemble( ensemble ); + ensemble->loadDataAndUpdate(); + + RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( {}, { ensemble } ); + } + + RiaSummaryTools::summaryCaseMainCollection()->updateAllRequiredEditors(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -88,10 +115,16 @@ void RimCloudDataSourceCollection::fieldChangedByUi( const caf::PdmFieldHandle* } if ( changedField == &m_addEnsembles ) { - addEnsemble(); + addEnsembles(); m_addEnsembles = false; } + if ( changedField == &m_addDataSources ) + { + addDataSources(); + + m_addDataSources = false; + } } //-------------------------------------------------------------------------------------------------- @@ -152,9 +185,13 @@ QList RimCloudDataSourceCollection::calculateValueOption //-------------------------------------------------------------------------------------------------- void RimCloudDataSourceCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - uiOrdering.add( &m_sumoFieldName ); - uiOrdering.add( &m_sumoCaseId ); - uiOrdering.add( &m_sumoEnsembleNames ); + caf::PdmUiOrdering::LayoutOptions layout = { .newRow = true, .totalColumnSpan = 3, .leftLabelColumnSpan = 1 }; + uiOrdering.add( &m_sumoFieldName, layout ); + uiOrdering.add( &m_sumoCaseId, layout ); + uiOrdering.add( &m_sumoEnsembleNames, layout ); + + uiOrdering.add( &m_addDataSources, { .totalColumnSpan = 2, .leftLabelColumnSpan = 1 } ); + uiOrdering.add( &m_addEnsembles, { .newRow = false, .totalColumnSpan = 1, .leftLabelColumnSpan = 0 } ); } //-------------------------------------------------------------------------------------------------- @@ -164,6 +201,13 @@ void RimCloudDataSourceCollection::defineEditorAttribute( const caf::PdmFieldHan QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { + if ( field == &m_addDataSources ) + { + if ( auto attrib = dynamic_cast( attribute ) ) + { + attrib->m_buttonText = "Add Data Sources(s)"; + } + } if ( field == &m_addEnsembles ) { if ( auto attrib = dynamic_cast( attribute ) ) @@ -176,9 +220,11 @@ void RimCloudDataSourceCollection::defineEditorAttribute( const caf::PdmFieldHan //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCloudDataSourceCollection::addEnsemble() +std::vector RimCloudDataSourceCollection::addDataSources() { - if ( !m_sumoConnector ) return; + if ( !m_sumoConnector ) return {}; + + std::vector dataSources; RimSummarySumoDataSource* objectToSelect = nullptr; auto sumoCaseId = SumoCaseId( m_sumoCaseId ); @@ -227,6 +273,7 @@ void RimCloudDataSourceCollection::addEnsemble() objectToSelect = dataSource; m_sumoDataSources.push_back( dataSource ); + dataSources.push_back( dataSource ); } uiCapability()->updateAllRequiredEditors(); @@ -236,4 +283,15 @@ void RimCloudDataSourceCollection::addEnsemble() RiuPlotMainWindowTools::setExpanded( objectToSelect ); RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect ); } + + return dataSources; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCloudDataSourceCollection::addEnsembles() +{ + auto dataSources = addDataSources(); + createEnsemblesFromSelectedDataSources( dataSources ); } diff --git a/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.h b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.h index 20f699e26d..6458431b1e 100644 --- a/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Cloud/RimCloudDataSourceCollection.h @@ -44,6 +44,8 @@ class RimCloudDataSourceCollection : public caf::PdmObject std::vector sumoDataSources() const; + static void createEnsemblesFromSelectedDataSources( const std::vector& dataSources ); + private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; @@ -51,13 +53,15 @@ class RimCloudDataSourceCollection : public caf::PdmObject void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - void addEnsemble(); + std::vector addDataSources(); + void addEnsembles(); private: caf::PdmField m_sumoFieldName; caf::PdmField m_sumoCaseId; caf::PdmField> m_sumoEnsembleNames; + caf::PdmField m_addDataSources; caf::PdmField m_addEnsembles; caf::PdmChildArrayField m_sumoDataSources; From 74cfc14143712b83b01757cbabf88b010e1111e6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 14 Sep 2024 17:05:53 +0200 Subject: [PATCH 308/332] #11696 Make sure PC axis is visible when required Use QwtPlotCurve directly to make it possible to see the Y Axis --- .../RiuRelativePermeabilityPlotPanel.cpp | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp index 0b8e5b6c2d..f6a5924f8a 100644 --- a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp +++ b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp @@ -27,14 +27,12 @@ #include "RiuDockedQwtPlot.h" #include "RiuGuiTheme.h" #include "RiuPlotCurveSymbol.h" -#include "RiuQwtPlotCurve.h" #include "RiuQwtPlotTools.h" #include "RiuQwtSymbol.h" #include "RiuRelativePermeabilityPlotUpdater.h" #include "RiuTextDialog.h" #include "cvfAssert.h" -#include "cvfTrace.h" #include "qwt_legend.h" #include "qwt_plot.h" @@ -89,6 +87,14 @@ RiuRelativePermeabilityPlotPanel::RiuRelativePermeabilityPlotPanel( QWidget* par , m_swat( HUGE_VAL ) , m_sgas( HUGE_VAL ) , m_plotUpdater( new RiuRelativePermeabilityPlotUpdater( this ) ) + , m_qwtPlot( nullptr ) + , m_selectedCurvesButtonGroup( nullptr ) + , m_groupBox( nullptr ) + , m_logarithmicScaleKrAxisCheckBox( nullptr ) + , m_showUnscaledCheckBox( nullptr ) + , m_fixedXAxisCheckBox( nullptr ) + , m_fixedLeftYAxisCheckBox( nullptr ) + { m_qwtPlot = new RelPermQwtPlot( this ); m_qwtPlot->setProperty( "qss-class", "RelPermPlot" ); @@ -161,7 +167,6 @@ RiuRelativePermeabilityPlotPanel::RiuRelativePermeabilityPlotPanel( QWidget* par RiuRelativePermeabilityPlotPanel::~RiuRelativePermeabilityPlotPanel() { } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -352,11 +357,10 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS plotOnWhichYAxis = RIGHT_YAXIS; } - RiuQwtPlotCurve* qwtCurve = new RiuQwtPlotCurve( nullptr, curve.name.c_str() ); + QwtPlotCurve* qwtCurve = new QwtPlotCurve( curve.name.c_str() ); CVF_ASSERT( curve.saturationVals.size() == curve.yVals.size() ); - const bool includePositiveValuesOnly = ( logScaleLeftAxis && plotOnWhichYAxis == LEFT_YAXIS ); - qwtCurve->setSamplesFromXValuesAndYValues( curve.saturationVals, curve.yVals, includePositiveValuesOnly ); + qwtCurve->setSamples( curve.saturationVals.data(), curve.yVals.data(), static_cast( curve.saturationVals.size() ) ); qwtCurve->setTitle( curve.name.c_str() ); @@ -390,7 +394,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS const QPen curvePen( QBrush(), 1, penStyle ); qwtCurve->setPen( curvePen ); - RiuQwtSymbol* curveSymbol = new RiuQwtSymbol( RiuPlotCurveSymbol::SYMBOL_ELLIPSE ); + auto* curveSymbol = new RiuQwtSymbol( RiuPlotCurveSymbol::SYMBOL_ELLIPSE ); curveSymbol->setSize( 6, 6 ); curveSymbol->setBrush( Qt::NoBrush ); qwtCurve->setSymbol( curveSymbol ); @@ -403,7 +407,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS if ( plotOnWhichYAxis == RIGHT_YAXIS ) { - qwtCurve->setYAxis( RiuPlotAxis::defaultRight() ); + qwtCurve->setYAxis( { QwtAxis::YRight, 0 } ); shouldEnableRightYAxis = true; } @@ -432,9 +436,15 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS } if ( shouldEnableRightYAxis ) + { plot->setAxesCount( QwtAxis::YRight, 1 ); + plot->setAxisVisible( QwtAxis::YRight, true ); + } else + { plot->setAxesCount( QwtAxis::YRight, 0 ); + plot->setAxisVisible( QwtAxis::YRight, false ); + } addTransparentCurve( plot, points, axes, logScaleLeftAxis ); From 1f80503f01de7b79e9f74f960590a67568d8b284 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 14 Sep 2024 17:07:06 +0200 Subject: [PATCH 309/332] #9405 Update window title when required --- .../ProjectDataModel/RimEclipseContourMapView.cpp | 11 +++++++++++ .../ProjectDataModel/RimEclipseContourMapView.h | 2 ++ .../ProjectDataModel/RimEclipseView.cpp | 11 +++++++++++ ApplicationLibCode/ProjectDataModel/RimEclipseView.h | 1 + 4 files changed, 25 insertions(+) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp index b7d9ea0050..f830879552 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp @@ -504,6 +504,17 @@ void RimEclipseContourMapView::fieldChangedByUi( const caf::PdmFieldHandle* chan } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseContourMapView::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) +{ + if ( changedChildField == &m_contourMapProjection ) + { + updateMdiWindowTitle(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.h b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.h index bd8528317e..29b15be988 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.h @@ -62,7 +62,9 @@ class RimEclipseContourMapView : public RimEclipseView void updateViewWidgetAfterCreation() override; void updateViewFollowingCellFilterUpdates() override; void onLoadDataAndUpdate() override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; bool isTimeStepDependentDataVisible() const override; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 33c7e0ebcb..f85ffd017f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -513,6 +513,17 @@ void RimEclipseView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseView::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) +{ + if ( changedChildField == &m_cellResult ) + { + updateMdiWindowTitle(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h index a3fd53385b..9c65dd3738 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h @@ -150,6 +150,7 @@ class RimEclipseView : public RimGridView // Overridden PDM methods: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; void updateIconStateForFilterCollections(); void defineAxisLabels( cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel ) override; From 9d66e6195e1ed84d10976d2c31f87bb31ad8d085 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 16 Sep 2024 09:49:22 +0200 Subject: [PATCH 310/332] Release adjustments * Use appendMenuItems instead of ContextCommandBuilder * Specify RimEclipseCaseCollection menu features once * Add function to enable up/down arrows for combo box * Guard crash when closing project * Improve UI for grid case ensemble - Create a view for the first case in the ensemble - Show case name in view title - Enable up/down buttons to Eclipse case * Make sure 3D views in grid ensemble are created on project load --- .../Application/RiaApplication.cpp | 16 +++++++ ...reateGridCaseEnsemblesFromFilesFeature.cpp | 42 ++++++++++++++----- ...cCreateGridCaseEnsemblesFromFilesFeature.h | 7 +++- .../Commands/RicNewViewFeature.cpp | 4 +- .../Commands/RicNewViewFeature.h | 2 +- .../Flow/RimWellConnectivityTable.cpp | 9 +--- .../ProjectDataModel/Rim3dView.h | 14 +++---- .../RimContextCommandBuilder.cpp | 19 +-------- .../RimEclipseCaseCollection.cpp | 27 ++++++++++++ .../RimEclipseCaseCollection.h | 5 +++ .../RimEclipseCaseEnsemble.cpp | 11 +++++ .../ProjectDataModel/RimEclipseCaseEnsemble.h | 1 + .../ProjectDataModel/RimEclipseView.cpp | 13 ++++++ .../ProjectDataModel/RimEclipseView.h | 1 + .../Summary/RimSummaryPlotSourceStepping.cpp | 8 ++-- .../RimCustomVfpPlot.cpp | 8 +--- .../RimWellLogCurveCommonDataSource.cpp | 6 +-- .../UserInterface/RiuMenuBarBuildTools.cpp | 15 ++++--- ApplicationLibCode/UserInterface/RiuTools.cpp | 19 ++++++++- ApplicationLibCode/UserInterface/RiuTools.h | 6 +++ .../cafCommand/cafCmdFeatureMenuBuilder.cpp | 23 ++++++++++ .../cafCommand/cafCmdFeatureMenuBuilder.h | 3 ++ 22 files changed, 189 insertions(+), 70 deletions(-) diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 976d519475..205e8209c1 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -52,7 +52,9 @@ #include "RimCommandRouter.h" #include "RimCompletionTemplateCollection.h" #include "RimEclipseCaseCollection.h" +#include "RimEclipseCaseEnsemble.h" #include "RimEclipseView.h" +#include "RimEclipseViewCollection.h" #include "RimEnsembleWellLogsCollection.h" #include "RimFaultReactivationModelCollection.h" #include "RimFileWellPath.h" @@ -713,6 +715,20 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct } } + // Load all grid ensemble views + { + auto gridCaseEnsembles = m_project->activeOilField()->analysisModels()->caseEnsembles.childrenByType(); + + for ( auto gridCaseEnsemble : gridCaseEnsembles ) + { + auto views = gridCaseEnsemble->viewCollection()->views(); + for ( auto view : views ) + { + view->loadDataAndUpdate(); + } + } + } + if ( m_project->viewLinkerCollection() && m_project->viewLinkerCollection()->viewLinker() ) { m_project->viewLinkerCollection()->viewLinker()->updateOverrides(); diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.cpp index daef75bc99..2810064dcd 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.cpp @@ -22,13 +22,16 @@ #include "RiaImportEclipseCaseTools.h" #include "RicCreateGridCaseGroupFromFilesFeature.h" +#include "RicNewViewFeature.h" #include "RicRecursiveFileSearchDialog.h" +#include "Rim3dView.h" #include "RimEclipseCaseCollection.h" #include "RimEclipseCaseEnsemble.h" #include "RimEclipseResultCase.h" #include "RimOilField.h" #include "RimProject.h" +#include "RimViewNameConfig.h" #include "cafProgressInfo.h" #include "cafSelectionManager.h" @@ -46,18 +49,35 @@ void RicCreateGridCaseEnsemblesFromFilesFeature::onActionTriggered( bool isCheck QString pathCacheName = "INPUT_FILES"; auto [fileNames, groupByEnsemble] = runRecursiveFileSearchDialog( "Import Grid Ensembles", pathCacheName ); + std::vector gridEnsembles; + if ( groupByEnsemble == RiaEnsembleNameTools::EnsembleGroupingMode::NONE ) { - importSingleGridCaseEnsemble( fileNames ); + gridEnsembles.push_back( importSingleGridCaseEnsemble( fileNames ) ); } else { std::vector groupedByEnsemble = RiaEnsembleNameTools::groupFilesByEnsemble( fileNames, groupByEnsemble ); for ( const QStringList& groupedFileNames : groupedByEnsemble ) { - importSingleGridCaseEnsemble( groupedFileNames ); + gridEnsembles.push_back( importSingleGridCaseEnsemble( groupedFileNames ) ); } } + + if ( gridEnsembles.empty() ) return; + + auto firstEnsemble = gridEnsembles.front(); + if ( firstEnsemble->cases().empty() ) return; + + auto firstCase = firstEnsemble->cases().front(); + if ( !firstCase ) return; + + auto view = RicNewViewFeature::addReservoirView( firstCase, nullptr, firstEnsemble->viewCollection() ); + if ( view ) + { + // Show the case name in the view title, as this is useful information for a grid case ensemble + view->nameConfig()->setAddCaseName( true ); + } } //-------------------------------------------------------------------------------------------------- @@ -66,14 +86,20 @@ void RicCreateGridCaseEnsemblesFromFilesFeature::onActionTriggered( bool isCheck void RicCreateGridCaseEnsemblesFromFilesFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setIcon( QIcon( ":/CreateGridCaseGroup16x16.png" ) ); - actionToSetup->setText( "&Create Grid Case Ensembles" ); + actionToSetup->setText( "&Create Grid Case Ensemble" ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicCreateGridCaseEnsemblesFromFilesFeature::importSingleGridCaseEnsemble( const QStringList& fileNames ) +RimEclipseCaseEnsemble* RicCreateGridCaseEnsemblesFromFilesFeature::importSingleGridCaseEnsemble( const QStringList& fileNames ) { + RimProject* project = RimProject::current(); + CVF_ASSERT( project ); + + RimOilField* oilfield = project->activeOilField(); + if ( !oilfield ) return nullptr; + auto eclipseCaseEnsemble = new RimEclipseCaseEnsemble; QString ensembleNameSuggestion = RiaEnsembleNameTools::findSuitableEnsembleName( fileNames, RiaEnsembleNameTools::EnsembleGroupingMode::FMU_FOLDER_STRUCTURE ); @@ -81,12 +107,6 @@ void RicCreateGridCaseEnsemblesFromFilesFeature::importSingleGridCaseEnsemble( c caf::ProgressInfo progInfo( fileNames.size() + 1, "Creating Grid Ensembles" ); - RimProject* project = RimProject::current(); - CVF_ASSERT( project ); - - RimOilField* oilfield = project->activeOilField(); - if ( !oilfield ) return; - for ( auto caseFileName : fileNames ) { auto task = progInfo.task( "Loading files", 1 ); @@ -102,6 +122,8 @@ void RicCreateGridCaseEnsemblesFromFilesFeature::importSingleGridCaseEnsemble( c oilfield->analysisModels()->caseEnsembles.push_back( eclipseCaseEnsemble ); oilfield->analysisModels()->updateConnectedEditors(); + + return eclipseCaseEnsemble; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.h index a32681e548..653f348c17 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseEnsemblesFromFilesFeature.h @@ -24,6 +24,8 @@ #include +class RimEclipseCaseEnsemble; + //================================================================================================== /// //================================================================================================== @@ -32,7 +34,8 @@ class RicCreateGridCaseEnsemblesFromFilesFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; RicCreateGridCaseEnsemblesFromFilesFeature() - : m_pathFilter( "*" ) + : caf::CmdFeature() + , m_pathFilter( "*" ) , m_fileNameFilter( "*" ) { } @@ -41,7 +44,7 @@ class RicCreateGridCaseEnsemblesFromFilesFeature : public caf::CmdFeature void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; - void importSingleGridCaseEnsemble( const QStringList& fileNames ); + RimEclipseCaseEnsemble* importSingleGridCaseEnsemble( const QStringList& fileNames ); std::pair runRecursiveFileSearchDialog( const QString& dialogTitle, const QString& pathCacheName ); diff --git a/ApplicationLibCode/Commands/RicNewViewFeature.cpp b/ApplicationLibCode/Commands/RicNewViewFeature.cpp index e5ec6a4b9b..2c4baae064 100644 --- a/ApplicationLibCode/Commands/RicNewViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewViewFeature.cpp @@ -42,7 +42,7 @@ CAF_CMD_SOURCE_INIT( RicNewViewFeature, "RicNewViewFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewViewFeature::addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, RimEclipseViewCollection* viewColl ) +Rim3dView* RicNewViewFeature::addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, RimEclipseViewCollection* viewColl ) { Rim3dView* newView = createReservoirView( eclipseCase, geomCase, viewColl ); @@ -53,6 +53,8 @@ void RicNewViewFeature::addReservoirView( RimEclipseCase* eclipseCase, RimGeoMec // Select the new view to make sure RiaApplication::setActiveReservoirView() is called Riu3DMainWindowTools::selectAsCurrentItem( newView ); } + + return newView; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicNewViewFeature.h b/ApplicationLibCode/Commands/RicNewViewFeature.h index acc145bbdb..b3beba0322 100644 --- a/ApplicationLibCode/Commands/RicNewViewFeature.h +++ b/ApplicationLibCode/Commands/RicNewViewFeature.h @@ -37,7 +37,7 @@ class RicNewViewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static void addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, RimEclipseViewCollection* viewColl ); + static Rim3dView* addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase, RimEclipseViewCollection* viewColl ); protected: bool isCommandEnabled() const override; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp index ff0208564f..ca6b6f4bdd 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp @@ -44,6 +44,7 @@ #include "RimWellPlotTools.h" #include "RiuMatrixPlotWidget.h" +#include "RiuTools.h" #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiPushButtonEditor.h" @@ -530,13 +531,7 @@ void RimWellConnectivityTable::defineEditorAttribute( const caf::PdmFieldHandle* } if ( field == &m_selectedTimeStep || field == &m_selectedFromTimeStep || field == &m_selectedToTimeStep ) { - auto* attrib = dynamic_cast( attribute ); - if ( attrib ) - { - attrib->nextIcon = QIcon( ":/ComboBoxDown.svg" ); - attrib->previousIcon = QIcon( ":/ComboBoxUp.svg" ); - attrib->showPreviousAndNextButtons = true; - } + RiuTools::enableUpDownArrowsForComboBox( attribute ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.h b/ApplicationLibCode/ProjectDataModel/Rim3dView.h index dca057a54b..0a60790f77 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.h @@ -114,9 +114,10 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public virtual RimCase* ownerCase() const = 0; RiuViewer* viewer() const; - void setName( const QString& name ); - QString name() const; - QString autoName() const; + void setName( const QString& name ); + QString name() const; + QString autoName() const; + RimViewNameConfig* nameConfig() const; virtual RiaDefines::View3dContent viewContent() const = 0; @@ -200,10 +201,9 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public protected: static void removeModelByName( cvf::Scene* scene, const cvf::String& modelName ); - virtual void setDefaultView(); - cvf::Mat4d cameraPosition() const; - cvf::Vec3d cameraPointOfInterest() const; - RimViewNameConfig* nameConfig() const; + virtual void setDefaultView(); + cvf::Mat4d cameraPosition() const; + cvf::Vec3d cameraPointOfInterest() const; void disableGridBoxField(); void disablePerspectiveProjectionField(); diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 5323aaf512..927648c78b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -46,8 +46,6 @@ #include "RimCustomObjectiveFunction.h" #include "RimCustomObjectiveFunctionCollection.h" #include "RimEclipseCase.h" -#include "RimEclipseCaseCollection.h" -#include "RimEclipseCaseEnsemble.h" #include "RimEclipseCellColors.h" #include "RimEclipseContourMapViewCollection.h" #include "RimEclipseFaultColors.h" @@ -211,18 +209,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() if ( uiItems.size() == 1 ) { - if ( dynamic_cast( firstUiItem ) ) - { - menuBuilder.subMenuStart( "Import" ); - menuBuilder << "RicImportEclipseCaseFeature"; - menuBuilder << "RicImportEclipseCasesFeature"; - menuBuilder << "RicImportInputEclipseCaseFeature"; - menuBuilder << "RicCreateGridCaseGroupFromFilesFeature"; - menuBuilder << "RicCreateGridCaseEnsemblesFromFilesFeature"; - menuBuilder.subMenuEnd(); - menuBuilder << "RicEclipseCaseNewGroupFeature"; - } - else if ( dynamic_cast( firstUiItem ) ) + if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicPasteGeoMechViewsFeature"; menuBuilder << "Separator"; @@ -264,10 +251,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; menuBuilder << "RicNewStatisticsCaseFeature"; } - else if ( dynamic_cast( firstUiItem ) ) - { - menuBuilder << "RicNewViewForGridEnsembleFeature"; - } else if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicImportGeoMechCaseFeature"; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp index 99405784ab..1f474e82c7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp @@ -33,6 +33,8 @@ #include "RimIdenticalGridCaseGroup.h" #include "RimProject.h" +#include "cafCmdFeatureMenuBuilder.h" + CAF_PDM_SOURCE_INIT( RimEclipseCaseCollection, "ResInsightAnalysisModels" ); //-------------------------------------------------------------------------------------------------- /// @@ -110,6 +112,17 @@ void RimEclipseCaseCollection::removeCaseFromAllGroups( RimEclipseCase* reservoi cases().removeChild( reservoir ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCaseCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder.subMenuStart( "Import" ); + menuBuilder << importMenuFeatureNames(); + menuBuilder.subMenuEnd(); + menuBuilder << "RicEclipseCaseNewGroupFeature"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -174,3 +187,17 @@ void RimEclipseCaseCollection::recomputeStatisticsForAllCaseGroups() } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimEclipseCaseCollection::importMenuFeatureNames() +{ + return { "RicImportEclipseCaseFeature", + "RicImportEclipseCasesFeature", + "RicImportEclipseCaseTimeStepFilterFeature", + "RicImportInputEclipseCaseFeature", + "Separator", + "RicCreateGridCaseGroupFromFilesFeature", + "RicCreateGridCaseEnsemblesFromFilesFeature" }; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.h index e204d454d3..2773f09b37 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.h @@ -59,6 +59,11 @@ class RimEclipseCaseCollection : public caf::PdmObject void recomputeStatisticsForAllCaseGroups(); + static QStringList importMenuFeatureNames(); + +private: + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; + private: RigMainGrid* registerCaseInGridCollection( RimEclipseCase* rimEclipseCase ); cvf::ref m_gridCollection; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp index 65fb04e8d5..f00e47e3d8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp @@ -23,6 +23,7 @@ #include "RimEclipseView.h" #include "RimEclipseViewCollection.h" +#include "cafCmdFeatureMenuBuilder.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" @@ -104,6 +105,8 @@ bool RimEclipseCaseEnsemble::contains( RimEclipseCase* reservoir ) const //-------------------------------------------------------------------------------------------------- std::vector RimEclipseCaseEnsemble::cases() const { + if ( !m_caseCollection ) return {}; + return m_caseCollection->reservoirs.childrenByType(); } @@ -160,6 +163,14 @@ void RimEclipseCaseEnsemble::fieldChangedByUi( const caf::PdmFieldHandle* change } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCaseEnsemble::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder << "RicNewViewForGridEnsembleFeature"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h index 4104428af1..2e723505e8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h @@ -57,6 +57,7 @@ class RimEclipseCaseEnsemble : public RimNamedObject protected: QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; private: caf::PdmField m_groupId; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index f85ffd017f..b6a3e4f829 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -101,6 +101,7 @@ #include "Riu3dSelectionManager.h" #include "RiuMainWindow.h" +#include "RiuTools.h" #include "RiuViewer.h" #include "RivReservoirSimWellsPartMgr.h" @@ -118,6 +119,7 @@ #include "cafOverlayScalarMapperLegend.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiTreeOrdering.h" #include "cvfDrawable.h" @@ -2084,6 +2086,17 @@ QList RimEclipseView::calculateValueOptions( const caf:: return RimGridView::calculateValueOptions( fieldNeedingOptions ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseView::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_eclipseCase ) + { + RiuTools::enableUpDownArrowsForComboBox( attribute ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h index 9c65dd3738..4068b8a4bc 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h @@ -187,6 +187,7 @@ class RimEclipseView : public RimGridView virtual std::set allVisibleFaultGeometryTypes() const; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; private: QString createAutoName() const override; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index c7d7f5ee9d..0a6bbcee57 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -40,6 +40,7 @@ #include "RimSummaryPlotControls.h" #include "RiuPlotMainWindow.h" +#include "RiuTools.h" #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiItem.h" @@ -955,15 +956,12 @@ void RimSummaryPlotSourceStepping::defineEditorAttribute( const caf::PdmFieldHan } else { + RiuTools::enableUpDownArrowsForComboBox( attribute ); + QString nextText = RimSummaryPlotControls::nextStepKeyText(); QString prevText = RimSummaryPlotControls::prevStepKeyText(); myAttr->nextButtonText = "Next (" + nextText + ")"; myAttr->prevButtonText = "Previous (" + prevText + ")"; - - myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" ); - myAttr->previousIcon = QIcon( ":/ComboBoxUp.svg" ); - - myAttr->showPreviousAndNextButtons = true; } } diff --git a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp index a2920a4e90..81135fe3b6 100644 --- a/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/VerticalFlowPerformance/RimCustomVfpPlot.cpp @@ -49,6 +49,7 @@ #include "RiuQwtPlotWheelZoomer.h" #include "RiuQwtPlotWidget.h" #include "RiuQwtPlotZoomer.h" +#include "RiuTools.h" #include "cafColorTable.h" #include "cafPdmUiComboBoxEditor.h" @@ -1366,12 +1367,7 @@ void RimCustomVfpPlot::defineEditorAttribute( const caf::PdmFieldHandle* field, if ( field == &m_mainDataSource ) { - if ( auto* myAttr = dynamic_cast( attribute ) ) - { - myAttr->showPreviousAndNextButtons = true; - myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" ); - myAttr->previousIcon = QIcon( ":/ComboBoxUp.svg" ); - } + RiuTools::enableUpDownArrowsForComboBox( attribute ); } } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp index 84d557d059..720d35c8bc 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp @@ -45,6 +45,8 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" +#include "RiuTools.h" + #include "cafPdmUiCheckBoxEditor.h" #include "cafPdmUiCheckBoxTristateEditor.h" #include "cafPdmUiComboBoxEditor.h" @@ -1083,9 +1085,7 @@ void RimWellLogCurveCommonDataSource::defineEditorAttribute( const caf::PdmField if ( field == &m_case || field == &m_summaryCase || field == &m_simWellName || field == &m_wellPath || field == &m_timeStep || field == &m_rftTimeStep || field == &m_rftSegmentBranchIndex || field == &m_rftWellName ) { - myAttr->showPreviousAndNextButtons = true; - myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" ); - myAttr->previousIcon = QIcon( ":/ComboBoxUp.svg" ); + RiuTools::enableUpDownArrowsForComboBox( attribute ); } QString modifierText; diff --git a/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp b/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp index a658e219c9..ad406ff217 100644 --- a/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp @@ -18,13 +18,16 @@ #include "RiuMenuBarBuildTools.h" -#include "cafCmdFeatureManager.h" - -#include "cvfAssert.h" +#include "RimEclipseCaseCollection.h" #include "RiuToolTipMenu.h" #include "RiuTools.h" +#include "cafCmdFeatureManager.h" +#include "cafCmdFeatureMenuBuilder.h" + +#include "cvfAssert.h" + #include #include #include @@ -113,11 +116,7 @@ void RiuMenuBarBuildTools::addImportMenuWithActions( QObject* parent, QMenu* men QMenu* importMenu = menu->addMenu( "&Import" ); QMenu* importEclipseMenu = importMenu->addMenu( QIcon( ":/Case48x48.png" ), "Eclipse Cases" ); - importEclipseMenu->addAction( cmdFeatureMgr->action( "RicImportEclipseCaseFeature" ) ); - importEclipseMenu->addAction( cmdFeatureMgr->action( "RicImportEclipseCasesFeature" ) ); - importEclipseMenu->addAction( cmdFeatureMgr->action( "RicImportEclipseCaseTimeStepFilterFeature" ) ); - importEclipseMenu->addAction( cmdFeatureMgr->action( "RicImportInputEclipseCaseFeature" ) ); - importEclipseMenu->addAction( cmdFeatureMgr->action( "RicCreateGridCaseGroupFromFilesFeature" ) ); + caf::CmdFeatureMenuBuilder::appendToMenu( importEclipseMenu, RimEclipseCaseCollection::importMenuFeatureNames() ); QMenu* importRoffMenu = importMenu->addMenu( QIcon( ":/Case48x48.png" ), "Roff Grid Models" ); importRoffMenu->addAction( cmdFeatureMgr->action( "RicImportRoffCaseFeature" ) ); diff --git a/ApplicationLibCode/UserInterface/RiuTools.cpp b/ApplicationLibCode/UserInterface/RiuTools.cpp index a1359664df..5298f35fd0 100644 --- a/ApplicationLibCode/UserInterface/RiuTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuTools.cpp @@ -18,8 +18,10 @@ #include "RiuTools.h" -#include "QMenu" -#include "QObject" +#include "cafPdmUiComboBoxEditor.h" + +#include +#include //-------------------------------------------------------------------------------------------------- /// @@ -48,3 +50,16 @@ void RiuTools::enableAllActionsOnShow( QObject* object, QMenu* menu ) } ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuTools::enableUpDownArrowsForComboBox( caf::PdmUiEditorAttribute* attribute ) +{ + if ( auto attrib = dynamic_cast( attribute ) ) + { + attrib->nextIcon = QIcon( ":/ComboBoxDown.svg" ); + attrib->previousIcon = QIcon( ":/ComboBoxUp.svg" ); + attrib->showPreviousAndNextButtons = true; + } +} diff --git a/ApplicationLibCode/UserInterface/RiuTools.h b/ApplicationLibCode/UserInterface/RiuTools.h index 3f3e416a71..b4b6909322 100644 --- a/ApplicationLibCode/UserInterface/RiuTools.h +++ b/ApplicationLibCode/UserInterface/RiuTools.h @@ -23,8 +23,14 @@ class QMenu; class QObject; +namespace caf +{ +class PdmUiEditorAttribute; +} + namespace RiuTools { Qt::WindowFlags defaultDialogFlags(); void enableAllActionsOnShow( QObject* object, QMenu* menu ); +void enableUpDownArrowsForComboBox( caf::PdmUiEditorAttribute* attribute ); } // end namespace RiuTools diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp index 5b5702c0ee..66191bfd71 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp @@ -77,6 +77,19 @@ CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::operator<<( const QString& command return *this; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::operator<<( const QStringList& commandIds ) +{ + for ( const QString& commandId : commandIds ) + { + *this << commandId; + } + + return *this; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -228,6 +241,16 @@ void CmdFeatureMenuBuilder::appendToMenu( QMenu* menu ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void CmdFeatureMenuBuilder::appendToMenu( QMenu* menu, const QStringList& commandIds ) +{ + CmdFeatureMenuBuilder builder; + builder << commandIds; + builder.appendToMenu( menu ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.h b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.h index be06556204..d7b7c300de 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.h +++ b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.h @@ -58,6 +58,7 @@ class CmdFeatureMenuBuilder virtual ~CmdFeatureMenuBuilder(); CmdFeatureMenuBuilder& operator<<( const QString& commandIdOrSeparator ); + CmdFeatureMenuBuilder& operator<<( const QStringList& commandIdOrSeparators ); CmdFeatureMenuBuilder& addCmdFeature( const QString commandId, const QString& customUiText = "" ); CmdFeatureMenuBuilder& addCmdFeatureWithUserData( const QString commandId, const QString& customUiText, const QVariant& userData ); @@ -69,6 +70,8 @@ class CmdFeatureMenuBuilder void appendToMenu( QMenu* menu ); + static void appendToMenu( QMenu* menu, const QStringList& commandIds ); + bool isCmdFeatureAdded( const QString& commandId ); size_t itemCount() const; From 89bd3a8c90027f8927cf1149e669fd8ac57cb061 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 16 Sep 2024 09:26:25 +0200 Subject: [PATCH 311/332] #11357 Reorganize menu in 3D view Simplify menu text for range filter Reorganize to improve readability Simplify cell filter menu in Project Tree --- .../RicNewCellRangeFilterFeature.cpp | 2 +- .../RicNewPolygonFilterFeature.cpp | 2 +- .../RicNewRangeFilterSliceFeature.cpp | 30 +++++-- .../RicNewRangeFilterSliceIFeature.cpp | 2 +- .../RicNewRangeFilterSliceJFeature.cpp | 2 +- .../RicNewRangeFilterSliceKFeature.cpp | 2 +- .../RicNewUserDefinedFilterFeature.cpp | 2 +- .../RicNewUserDefinedIndexFilterFeature.cpp | 2 +- .../CellFilters/RimCellFilterCollection.cpp | 6 +- .../ProjectDataModel/Polygons/RimPolygon.cpp | 2 +- .../UserInterface/RiuViewerCommands.cpp | 83 +++++++++---------- 11 files changed, 72 insertions(+), 63 deletions(-) diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellRangeFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellRangeFilterFeature.cpp index 9a46c17870..ee8c5daa85 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellRangeFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellRangeFilterFeature.cpp @@ -26,6 +26,6 @@ CAF_CMD_SOURCE_INIT( RicNewCellRangeFilterFeature, "RicNewCellRangeFilterFeature /// //-------------------------------------------------------------------------------------------------- RicNewCellRangeFilterFeature::RicNewCellRangeFilterFeature() - : RicNewRangeFilterSliceFeature( "New Range Filter", -1 ) + : RicNewRangeFilterSliceFeature( "IJK Filter", -1 ) { } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp index 607f4999ad..274bda4898 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp @@ -92,5 +92,5 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked ) void RicNewPolygonFilterFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setIcon( QIcon( ":/CellFilter_Polygon.png" ) ); - actionToSetup->setText( "New User Defined Polygon Filter" ); + actionToSetup->setText( "User Defined Polygon Filter" ); } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp index a0d6b7772f..43ab5a2ac9 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp @@ -18,10 +18,13 @@ #include "RicNewRangeFilterSliceFeature.h" +#include "RiaApplication.h" + #include "Rim3dView.h" #include "RimCase.h" #include "RimCellFilterCollection.h" #include "RimCellRangeFilter.h" +#include "RimGridView.h" #include "Riu3DMainWindowTools.h" @@ -41,18 +44,31 @@ RicNewRangeFilterSliceFeature::RicNewRangeFilterSliceFeature( QString cmdText, i //-------------------------------------------------------------------------------------------------- void RicNewRangeFilterSliceFeature::onActionTriggered( bool isChecked ) { - // Find the selected Cell Filter Collection + RimCellFilterCollection* filterCollection = nullptr; + RimCase* sourceCase = nullptr; + std::vector colls = caf::selectedObjectsByTypeStrict(); - if ( colls.empty() ) return; - RimCellFilterCollection* filtColl = colls[0]; + if ( !colls.empty() ) + { + filterCollection = colls.front(); + sourceCase = filterCollection->firstAncestorOrThisOfTypeAsserted()->ownerCase(); + } - // and the case to use - RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted()->ownerCase(); + if ( !filterCollection ) + { + // Find filter collection for active view + + RimGridView* viewOrComparisonView = RiaApplication::instance()->activeMainOrComparisonGridView(); + if ( !viewOrComparisonView ) return; + + filterCollection = viewOrComparisonView->cellFilterCollection(); + sourceCase = viewOrComparisonView->ownerCase(); + } - if ( sourceCase ) + if ( sourceCase && filterCollection ) { int gridIndex = 0; - RimCellFilter* lastCreatedOrUpdated = filtColl->addNewCellRangeFilter( sourceCase, gridIndex, m_sliceDirection ); + RimCellFilter* lastCreatedOrUpdated = filterCollection->addNewCellRangeFilter( sourceCase, gridIndex, m_sliceDirection ); if ( lastCreatedOrUpdated ) { Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceIFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceIFeature.cpp index a8bfa92087..fd70809202 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceIFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceIFeature.cpp @@ -26,6 +26,6 @@ CAF_CMD_SOURCE_INIT( RicNewRangeFilterSliceIFeature, "RicNewRangeFilterSliceIFea /// //-------------------------------------------------------------------------------------------------- RicNewRangeFilterSliceIFeature::RicNewRangeFilterSliceIFeature() - : RicNewRangeFilterSliceFeature( "New Range Filter - I slice", 0 ) + : RicNewRangeFilterSliceFeature( "I Slice", 0 ) { } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceJFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceJFeature.cpp index 220b5e06d0..7111df34af 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceJFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceJFeature.cpp @@ -26,6 +26,6 @@ CAF_CMD_SOURCE_INIT( RicNewRangeFilterSliceJFeature, "RicNewRangeFilterSliceJFea /// //-------------------------------------------------------------------------------------------------- RicNewRangeFilterSliceJFeature::RicNewRangeFilterSliceJFeature() - : RicNewRangeFilterSliceFeature( "New Range Filter - J slice", 1 ) + : RicNewRangeFilterSliceFeature( "J Slice", 1 ) { } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceKFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceKFeature.cpp index 2aa731ed2a..b52f51049b 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceKFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceKFeature.cpp @@ -26,6 +26,6 @@ CAF_CMD_SOURCE_INIT( RicNewRangeFilterSliceKFeature, "RicNewRangeFilterSliceKFea /// //-------------------------------------------------------------------------------------------------- RicNewRangeFilterSliceKFeature::RicNewRangeFilterSliceKFeature() - : RicNewRangeFilterSliceFeature( "New Range Filter - K slice", 2 ) + : RicNewRangeFilterSliceFeature( "K Slice", 2 ) { } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp index 414d96d9d0..0dfdfb3c2c 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp @@ -61,5 +61,5 @@ void RicNewUserDefinedFilterFeature::onActionTriggered( bool isChecked ) void RicNewUserDefinedFilterFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setIcon( QIcon( ":/CellFilter_UserDefined.png" ) ); - actionToSetup->setText( "New User Defined IJK Filter" ); + actionToSetup->setText( "User Defined IJK Filter" ); } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp index 3e41191ae9..147f6743bd 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp @@ -61,5 +61,5 @@ void RicNewUserDefinedIndexFilterFeature::onActionTriggered( bool isChecked ) void RicNewUserDefinedIndexFilterFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setIcon( QIcon( ":/CellFilter_UserDefined.png" ) ); - actionToSetup->setText( "New User Defined Index Filter" ); + actionToSetup->setText( "User Defined Index Filter" ); } diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp index 172358f1dd..ba1333b91e 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp @@ -139,7 +139,7 @@ void RimCellFilterCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuB menuBuilder << "RicPasteCellFiltersFeature"; menuBuilder << "Separator"; - menuBuilder.subMenuStart( "New Polygon Filter", QIcon( ":/CellFilter_Polygon.png" ) ); + menuBuilder.subMenuStart( "Polygon Filter", QIcon( ":/CellFilter_Polygon.png" ) ); { auto project = RimProject::current(); auto polygonCollection = project->activeOilField()->polygonCollection(); @@ -154,12 +154,12 @@ void RimCellFilterCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuB menuBuilder << "RicNewPolygonFilterFeature"; menuBuilder << "Separator"; - menuBuilder.subMenuStart( "Slice Filters" ); + menuBuilder.subMenuStart( "Range Filter" ); menuBuilder << "RicNewRangeFilterSliceIFeature"; menuBuilder << "RicNewRangeFilterSliceJFeature"; menuBuilder << "RicNewRangeFilterSliceKFeature"; - menuBuilder.subMenuEnd(); menuBuilder << "RicNewCellRangeFilterFeature"; + menuBuilder.subMenuEnd(); menuBuilder << "RicNewCellIndexFilterFeature"; menuBuilder << "Separator"; menuBuilder << "RicNewUserDefinedFilterFeature"; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp index 9291037d70..5263751c51 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp @@ -250,7 +250,7 @@ void RimPolygon::onColorTagClicked( const SignalEmitter* emitter, size_t index ) void RimPolygon::appendPolygonMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) { menuBuilder << "RicNewPolygonIntersectionFeature"; - menuBuilder.addCmdFeature( "RicNewPolygonFilterFeature", "New Polygon Filter" ); + menuBuilder.addCmdFeature( "RicNewPolygonFilterFeature", "Create Polygon Filter" ); menuBuilder << "Separator"; menuBuilder << "RicDuplicatePolygonFeature"; diff --git a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp index d83182c029..aead16b7a8 100644 --- a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp @@ -162,6 +162,9 @@ void RiuViewerCommands::setOwnerView( Rim3dView* owner ) m_reservoirView = owner; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- void RiuViewerCommands::addCompareToViewMenu( caf::CmdFeatureMenuBuilder* menuBuilder ) { auto* mainGridView = m_reservoirView.p(); @@ -266,18 +269,11 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event ) if ( firstHitPart && firstPartTriangleIndex != cvf::UNDEFINED_UINT ) { - const RivSourceInfo* rivSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); - - const RivFemPickSourceInfo* femSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); - - const RivReservoirSurfaceIntersectionSourceInfo* surfIntersectSourceInfo = - dynamic_cast( firstHitPart->sourceInfo() ); - - const RivExtrudedCurveIntersectionSourceInfo* crossSectionSourceInfo = - dynamic_cast( firstHitPart->sourceInfo() ); - - const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo = - dynamic_cast( firstHitPart->sourceInfo() ); + const auto* rivSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + const auto* femSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + const auto* surfIntersectSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + const auto* crossSectionSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + const auto* intersectionBoxSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); if ( rivSourceInfo || femSourceInfo || crossSectionSourceInfo || intersectionBoxSourceInfo || surfIntersectSourceInfo ) { @@ -308,12 +304,6 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event ) RiuSelectionItem* selItem = new RiuGeneralSelectionItem( surfIntersectSourceInfo->intersection() ); Riu3dSelectionManager::instance()->setSelectedItem( selItem, Riu3dSelectionManager::RUI_TEMPORARY ); - - if ( gridView ) - { - // menuBuilder << "RicHideSurfaceFeature"; // Not yet created... - // menuBuilder.addSeparator(); - } } else if ( crossSectionSourceInfo ) { @@ -383,21 +373,23 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event ) kSliceList.push_back( std::max( static_cast( k + 1 ), 1 ) ); kSliceList.push_back( static_cast( m_currentGridIdx ) ); - menuBuilder.subMenuStart( "Range Filter Slice", QIcon( ":/CellFilter_Range.png" ) ); + menuBuilder.subMenuStart( "Range Filter", QIcon( ":/CellFilter_Range.png" ) ); - menuBuilder.addCmdFeatureWithUserData( "RicNewRangeFilterSlice3dviewFeature", "I-slice Range Filter", iSliceList ); - menuBuilder.addCmdFeatureWithUserData( "RicNewRangeFilterSlice3dviewFeature", "J-slice Range Filter", jSliceList ); - menuBuilder.addCmdFeatureWithUserData( "RicNewRangeFilterSlice3dviewFeature", "K-slice Range Filter", kSliceList ); + menuBuilder.addCmdFeatureWithUserData( "RicNewRangeFilterSlice3dviewFeature", "I Slice", iSliceList ); + menuBuilder.addCmdFeatureWithUserData( "RicNewRangeFilterSlice3dviewFeature", "J Slice", jSliceList ); + menuBuilder.addCmdFeatureWithUserData( "RicNewRangeFilterSlice3dviewFeature", "K Slice", kSliceList ); + menuBuilder.addCmdFeature( "RicNewCellRangeFilterFeature", "IJK Filter" ); menuBuilder.subMenuEnd(); } - menuBuilder << "RicNewPolygonFilter3dviewFeature"; - menuBuilder.addCmdFeature( "RicCreatePolygonFeature", "Polygon" ); - + // Property filter commands menuBuilder << "RicEclipsePropertyFilterNewInViewFeature"; menuBuilder << "RicGeoMechPropertyFilterNewInViewFeature"; + // Polygon commands + menuBuilder << "RicNewPolygonFilter3dviewFeature"; + menuBuilder.addSeparator(); menuBuilder.subMenuStart( "Intersections", QIcon( ":/IntersectionXPlane16x16.png" ) ); @@ -446,14 +438,15 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event ) menuBuilder << "RicToggleMeasurementModeFeature"; menuBuilder << "RicTogglePolyMeasurementModeFeature"; + menuBuilder.addCmdFeature( "RicCreatePolygonFeature", "Polygon" ); } } // Well log curve creation commands if ( firstHitPart && firstHitPart->sourceInfo() ) { - RimWellPath* wellPath = nullptr; - const RivWellPathSourceInfo* wellPathSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + RimWellPath* wellPath = nullptr; + const auto* wellPathSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); if ( wellPathSourceInfo ) { wellPath = wellPathSourceInfo->wellPath(); @@ -540,7 +533,7 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event ) menuBuilder << "RicDuplicateWellPathFeature"; } - const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + const auto* eclipseWellSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); if ( eclipseWellSourceInfo ) { RimSimWellInView* well = eclipseWellSourceInfo->well(); @@ -597,11 +590,6 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event ) menuBuilder << "RicSelectColorResult"; } } - else - { - menuBuilder.addSeparator(); - menuBuilder << "RicCreateTextAnnotationIn3dViewFeature"; - } if ( gridView ) { @@ -613,19 +601,27 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event ) menuBuilder << "RicCreateGridCrossPlotFeature"; } menuBuilder.addSeparator(); + menuBuilder.subMenuStart( "Export" ); menuBuilder << "RicExportEclipseInputGridFeature"; menuBuilder << "RicSaveEclipseInputActiveVisibleCellsFeature"; menuBuilder << "RicSaveEclipseResultAsInputPropertyFeature"; + menuBuilder << "RicExportContourMapToTextFeature"; + menuBuilder.subMenuEnd(); + menuBuilder.addSeparator(); #ifdef USE_QTCHARTS menuBuilder << "RicCreateGridStatisticsPlotFeature"; #endif menuBuilder << "RicShowGridStatisticsFeature"; - menuBuilder << "RicSelectColorResult"; menuBuilder << "RicCopyGridStatisticsToClipboardFeature"; + menuBuilder << "RicSelectColorResult"; } - menuBuilder << "RicExportContourMapToTextFeature"; + if ( firstHitPart ) + { + menuBuilder.addSeparator(); + menuBuilder << "RicCreateTextAnnotationIn3dViewFeature"; + } menuBuilder.appendToMenu( &menu ); @@ -719,12 +715,10 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard if ( firstHitPart && firstHitPart->sourceInfo() ) { - // clang-format off - const RivObjectSourceInfo* rivObjectSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); - const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); - const RivWellConnectionSourceInfo* wellConnectionSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); - const RivSeismicSectionSourceInfo* seismicSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); - // clang-format on + const auto* rivObjectSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + const auto* eclipseWellSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + const auto* wellConnectionSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + const auto* seismicSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); if ( rivObjectSourceInfo ) { @@ -813,21 +807,20 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard RiuMainWindow::instance()->setResultInfo( resultInfoText ); } } - else if ( const RivReservoirSurfaceIntersectionSourceInfo* surfIntersectSourceInfo = + else if ( const auto* surfIntersectSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ) ) { RiuMainWindow::instance()->selectAsCurrentItem( surfIntersectSourceInfo->intersection() ); } - else if ( const RivExtrudedCurveIntersectionSourceInfo* crossSectionSourceInfo = + else if ( const auto* crossSectionSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ) ) { bool allowActiveViewChange = dynamic_cast( m_viewer->ownerViewWindow() ) == nullptr; RiuMainWindow::instance()->selectAsCurrentItem( crossSectionSourceInfo->intersection(), allowActiveViewChange ); } - else if ( const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo = - dynamic_cast( firstHitPart->sourceInfo() ) ) + else if ( const auto* intersectionBoxSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ) ) { RiuMainWindow::instance()->selectAsCurrentItem( intersectionBoxSourceInfo->intersectionBox() ); } From f95b085419ac8afeac111356bbfb2c345b6dfcb5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 16 Sep 2024 10:20:50 +0200 Subject: [PATCH 312/332] Bump to dev.21 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 88a07763bb..7f96962d28 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".20") +set(RESINSIGHT_DEV_VERSION ".21") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From e006fe52c9f4810a98d04a6c875dcdae3b717fd0 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Thu, 19 Sep 2024 08:41:57 +0200 Subject: [PATCH 313/332] 2d intersection view filter support (#11711) Enable filters in 2d intersection view. Controlled by "Use Cell Filters for Intersections" setting in Intersection Collection properties --- .../RivExtrudedCurveIntersectionPartMgr.cpp | 70 +++++---- .../RivExtrudedCurveIntersectionPartMgr.h | 2 +- .../Rim2dIntersectionView.cpp | 146 +++++++++++++++++- .../ProjectDataModel/Rim2dIntersectionView.h | 9 ++ .../Rim2dIntersectionViewCollection.cpp | 8 +- 5 files changed, 194 insertions(+), 41 deletions(-) diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp index d0d5c321cd..fc53751118 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp @@ -842,52 +842,58 @@ void RivExtrudedCurveIntersectionPartMgr::appendMeshLinePartsToModel( cvf::Model //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivExtrudedCurveIntersectionPartMgr::appendPolylinePartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform ) +void RivExtrudedCurveIntersectionPartMgr::appendPolylinePartsToModel( Rim3dView& view, + cvf::ModelBasicList* model, + cvf::Transform* scaleTransform, + bool annotationOnly ) { auto* curr2dView = dynamic_cast( &view ); - if ( m_rimIntersection->inputPolyLineFromViewerEnabled() || ( curr2dView && curr2dView->showDefiningPoints() ) ) + if ( !annotationOnly ) { - if ( m_highlightLineAlongPolyline.notNull() ) + if ( m_rimIntersection->inputPolyLineFromViewerEnabled() || ( curr2dView && curr2dView->showDefiningPoints() ) ) { - m_highlightLineAlongPolyline->setTransform( scaleTransform ); - model->addPart( m_highlightLineAlongPolyline.p() ); - } + if ( m_highlightLineAlongPolyline.notNull() ) + { + m_highlightLineAlongPolyline->setTransform( scaleTransform ); + model->addPart( m_highlightLineAlongPolyline.p() ); + } - if ( m_highlightPointsForPolyline.notNull() ) - { - m_highlightPointsForPolyline->setTransform( scaleTransform ); - model->addPart( m_highlightPointsForPolyline.p() ); + if ( m_highlightPointsForPolyline.notNull() ) + { + m_highlightPointsForPolyline->setTransform( scaleTransform ); + model->addPart( m_highlightPointsForPolyline.p() ); + } } - } - if ( m_rimIntersection->inputExtrusionPointsFromViewerEnabled() ) - { - if ( m_highlightLineAlongExtrusionDir.notNull() ) + if ( m_rimIntersection->inputExtrusionPointsFromViewerEnabled() ) { - m_highlightLineAlongExtrusionDir->setTransform( scaleTransform ); - model->addPart( m_highlightLineAlongExtrusionDir.p() ); - } + if ( m_highlightLineAlongExtrusionDir.notNull() ) + { + m_highlightLineAlongExtrusionDir->setTransform( scaleTransform ); + model->addPart( m_highlightLineAlongExtrusionDir.p() ); + } - if ( m_highlightPointsForExtrusionDir.notNull() ) - { - m_highlightPointsForExtrusionDir->setTransform( scaleTransform ); - model->addPart( m_highlightPointsForExtrusionDir.p() ); + if ( m_highlightPointsForExtrusionDir.notNull() ) + { + m_highlightPointsForExtrusionDir->setTransform( scaleTransform ); + model->addPart( m_highlightPointsForExtrusionDir.p() ); + } } - } - if ( m_rimIntersection->inputTwoAzimuthPointsFromViewerEnabled() || ( curr2dView && curr2dView->showDefiningPoints() ) ) - { - if ( m_highlightLineAlongPolyline.notNull() ) + if ( m_rimIntersection->inputTwoAzimuthPointsFromViewerEnabled() || ( curr2dView && curr2dView->showDefiningPoints() ) ) { - m_highlightLineAlongPolyline->setTransform( scaleTransform ); - model->addPart( m_highlightLineAlongPolyline.p() ); - } + if ( m_highlightLineAlongPolyline.notNull() ) + { + m_highlightLineAlongPolyline->setTransform( scaleTransform ); + model->addPart( m_highlightLineAlongPolyline.p() ); + } - if ( m_highlightPointsForPolyline.notNull() ) - { - m_highlightPointsForPolyline->setTransform( scaleTransform ); - model->addPart( m_highlightPointsForPolyline.p() ); + if ( m_highlightPointsForPolyline.notNull() ) + { + m_highlightPointsForPolyline->setTransform( scaleTransform ); + model->addPart( m_highlightPointsForPolyline.p() ); + } } } diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h index ae30e02ce3..8cf97e267d 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h @@ -75,7 +75,7 @@ class RivExtrudedCurveIntersectionPartMgr : public cvf::Object void appendIntersectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); - void appendPolylinePartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); + void appendPolylinePartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform, bool annotationOnly = false ); cvf::Mat4d unflattenTransformMatrix( const cvf::Vec3d& intersectionPointFlat ) const; diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp index b89a90414b..156d756fc1 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -20,13 +20,16 @@ #include "Rim3dOverlayInfoConfig.h" #include "RimCase.h" +#include "RimCellFilterCollection.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" +#include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseView.h" #include "RimExtrudedCurveIntersection.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" #include "RimGridView.h" +#include "RimIntersectionCollection.h" #include "RimIntersectionResultDefinition.h" #include "RimRegularLegendConfig.h" #include "RimSimWellInView.h" @@ -516,16 +519,19 @@ void Rim2dIntersectionView::onCreateDisplayModel() nativeOrOverrideViewer()->addFrame( new cvf::Scene(), isUsingOverrideViewer() ); } - m_flatIntersectionPartMgr = new RivExtrudedCurveIntersectionPartMgr( m_intersection(), true ); + bool propertiesFiltersActive = false; + bool cellFiltersActive = false; - m_intersectionVizModel->removeAllParts(); + RimGridView* grView = m_intersection->firstAncestorOrThisOfType(); + if ( grView && grView->intersectionCollection()->shouldApplyCellFiltersToIntersections() ) + { + propertiesFiltersActive = grView->propertyFilterCollection()->hasActiveFilters(); + cellFiltersActive = grView->cellFilterCollection()->hasActiveFilters(); + } - m_flatIntersectionPartMgr->generatePartGeometry( nullptr, scaleTransform() ); - m_flatIntersectionPartMgr->appendIntersectionFacesToModel( m_intersectionVizModel.p(), scaleTransform() ); - m_flatIntersectionPartMgr->appendMeshLinePartsToModel( m_intersectionVizModel.p(), scaleTransform() ); - m_flatIntersectionPartMgr->appendPolylinePartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() ); + m_flatIntersectionPartMgr = new RivExtrudedCurveIntersectionPartMgr( m_intersection, true ); - m_flatIntersectionPartMgr->applySingleColorEffect(); + appendIntersectionToModel( cellFiltersActive, propertiesFiltersActive ); m_flatSimWellPipePartMgr = nullptr; m_flatWellHeadPartMgr = nullptr; @@ -574,6 +580,17 @@ void Rim2dIntersectionView::onUpdateDisplayModelForCurrentTimeStep() update3dInfo(); onUpdateLegends(); + RimGridView* grView = m_intersection->firstAncestorOrThisOfType(); + if ( grView ) + { + if ( grView->intersectionCollection()->shouldApplyCellFiltersToIntersections() && + grView->propertyFilterCollection()->hasActiveFilters() ) + { + m_flatIntersectionPartMgr = new RivExtrudedCurveIntersectionPartMgr( m_intersection, true ); + appendIntersectionForCurrentTimeStep(); + } + } + if ( m_flatSimWellPipePartMgr.notNull() ) { cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() ); @@ -831,3 +848,118 @@ void Rim2dIntersectionView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTree { uiTreeOrdering.skipRemainingChildren( true ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::appendIntersectionToModel( bool cellFiltersActive, bool propertyFiltersActive ) +{ + m_intersectionVizModel->removeAllParts(); + + RimEclipseView* eclView = m_intersection->firstAncestorOrThisOfType(); + RimGeoMechView* geoView = m_intersection->firstAncestorOrThisOfType(); + + if ( cellFiltersActive || propertyFiltersActive ) + { + if ( eclView ) + { + if ( !propertyFiltersActive ) + { + cvf::UByteArray visibleCells; + eclView->calculateCellVisibility( &visibleCells, { RANGE_FILTERED_WELL_CELLS, RANGE_FILTERED }, m_currentTimeStep ); + appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), &visibleCells ); + } + } + else if ( geoView ) + { + if ( !propertyFiltersActive ) + { + cvf::UByteArray visibleCells; + geoView->calculateCurrentTotalCellVisibility( &visibleCells, m_currentTimeStep ); + appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), &visibleCells ); + } + } + + // NB! Geometry objects are recreated in appendDynamicPartsToModel(), always call + // appendPartsToModel() after appendDynamicPartsToModel() + appendPartsToModel( m_intersectionVizModel.p(), scaleTransform() ); + } + else + { + appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), nullptr ); + + // NB! Geometry objects are recreated in appendDynamicPartsToModel(), always call + // appendPartsToModel() after appendDynamicPartsToModel() + appendPartsToModel( m_intersectionVizModel.p(), scaleTransform() ); + } + m_intersectionVizModel->updateBoundingBoxesRecursive(); + nativeOrOverrideViewer()->addStaticModelOnce( m_intersectionVizModel.p(), isUsingOverrideViewer() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::appendIntersectionForCurrentTimeStep() +{ + if ( nativeOrOverrideViewer() ) + { + cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() ); + if ( frameScene ) + { + cvf::String name = "IntersectionDynamicModel"; + Rim3dView::removeModelByName( frameScene, name ); + + cvf::ref frameParts = new cvf::ModelBasicList; + frameParts->setName( name ); + + RimEclipseView* eclView = m_intersection->firstAncestorOrThisOfType(); + RimGeoMechView* geoView = m_intersection->firstAncestorOrThisOfType(); + if ( eclView ) + { + cvf::UByteArray visibility; + eclView->calculateCellVisibility( &visibility, { PROPERTY_FILTERED, PROPERTY_FILTERED_WELL_CELLS }, m_currentTimeStep ); + appendDynamicPartsToModel( frameParts.p(), scaleTransform(), &visibility ); + } + else if ( geoView ) + { + cvf::UByteArray visibility; + geoView->calculateCurrentTotalCellVisibility( &visibility, m_currentTimeStep ); + appendDynamicPartsToModel( frameParts.p(), scaleTransform(), &visibility ); + } + else + { + appendDynamicPartsToModel( frameParts.p(), scaleTransform(), nullptr ); + } + frameParts->updateBoundingBoxesRecursive(); + + frameScene->addModel( frameParts.p() ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::appendPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ) +{ + m_flatIntersectionPartMgr->appendPolylinePartsToModel( *this, model, scaleTransform, true /*annotationOnly*/ ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::appendDynamicPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform, cvf::UByteArray* visibleCells ) +{ + m_flatIntersectionPartMgr->generatePartGeometry( visibleCells, scaleTransform ); + m_flatIntersectionPartMgr->appendIntersectionFacesToModel( model, scaleTransform ); + m_flatIntersectionPartMgr->appendMeshLinePartsToModel( model, scaleTransform ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::onCellVisibilityChanged( const SignalEmitter* emitter ) +{ + onCreateDisplayModel(); + scheduleCreateDisplayModelAndRedraw(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h index a9a83af986..1482dac5fc 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h @@ -21,6 +21,7 @@ #include "Rim3dView.h" #include "cafPdmProxyValueField.h" #include "cafPdmPtrField.h" +#include "cvfArray.h" class RimExtrudedCurveIntersection; class RimRegularLegendConfig; @@ -73,6 +74,8 @@ class Rim2dIntersectionView : public Rim3dView std::vector legendConfigs() const override; + void onCellVisibilityChanged( const SignalEmitter* emitter ); + protected: void onUpdateLegends() override; @@ -96,11 +99,17 @@ class Rim2dIntersectionView : public Rim3dView size_t onTimeStepCountRequested() override; + void appendIntersectionForCurrentTimeStep(); + void appendIntersectionToModel( bool cellFiltersActive, bool propertyFiltersActive ); + private: QString createAutoName() const override; QString getName() const; void setName( const QString& name ); + void appendPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); + void appendDynamicPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform, cvf::UByteArray* visibleCells ); + caf::PdmChildField m_legendConfig; caf::PdmChildField m_ternaryLegendConfig; diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp index 7502d72fb7..972d2ea4d5 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp @@ -21,6 +21,7 @@ #include "Rim2dIntersectionView.h" #include "RimCase.h" #include "RimExtrudedCurveIntersection.h" +#include "RimGridView.h" CAF_PDM_SOURCE_INIT( Rim2dIntersectionViewCollection, "Intersection2dViewCollection" ); @@ -88,23 +89,28 @@ void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpda for ( RimExtrudedCurveIntersection* intersection : allOrderedIntersectionsInCase ) { + auto view = intersection->firstAncestorOrThisOfType(); + auto it = intersectionToViewMap.find( intersection ); if ( it == intersectionToViewMap.end() ) { Rim2dIntersectionView* newView = new Rim2dIntersectionView(); - auto view = intersection->firstAncestorOrThisOfType(); if ( view ) { newView->setCurrentTimeStep( view->currentTimeStep() ); + view->cellVisibilityChanged.connect( newView, &Rim2dIntersectionView::onCellVisibilityChanged ); } newView->setIntersection( intersection ); + m_intersectionViews.push_back( newView ); } else { + view->cellVisibilityChanged.disconnect( it->second ); m_intersectionViews.push_back( it->second ); + view->cellVisibilityChanged.connect( it->second, &Rim2dIntersectionView::onCellVisibilityChanged ); } } From 48070f6539418b8d0cc46dff53df356653233274 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 17 Sep 2024 11:28:50 +0200 Subject: [PATCH 314/332] #11706 Use connection depths when plotting connection data The plotting of curve values for connections to a segment fails in some cases. The current implementation finds the segment a connection is attached to, and use the depth (both MD and TVD) information from this segment. This method is not working in all cases. Use the reported location of connections attached to segments based on CONLENST and CONLENEN. When measured depth is requested, use these values. There might be gaps in the reported segment sequence. Use CONDEPTH when TVD depth is requested. Use CONBRNO to find the branch number, and then use lookup table branchIdsAndOneBasedBranchIndices to find the branch index. Use the branch index to filter the results for requested branch. The number of values in CON* result values is different to result values for SEG* results. --- .../Application/RiaRftDefines.cpp | 80 +++++++ .../Application/RiaRftDefines.h | 11 + .../FileInterface/RifReaderOpmRft.cpp | 205 +++++++++++++----- .../FileInterface/RifReaderOpmRft.h | 7 + .../ProjectDataModel/WellLog/RimRftTools.cpp | 88 +++++--- .../ProjectDataModel/WellLog/RimRftTools.h | 14 +- .../WellLog/RimRftTopologyCurve.cpp | 5 +- .../RimWellLogCurveCommonDataSource.cpp | 7 +- .../WellLog/RimWellLogRftCurve.cpp | 47 ++-- .../WellLog/RimWellLogRftCurve.h | 2 - 10 files changed, 355 insertions(+), 111 deletions(-) diff --git a/ApplicationLibCode/Application/RiaRftDefines.cpp b/ApplicationLibCode/Application/RiaRftDefines.cpp index 1d39a5023a..e1c6792d80 100644 --- a/ApplicationLibCode/Application/RiaRftDefines.cpp +++ b/ApplicationLibCode/Application/RiaRftDefines.cpp @@ -19,6 +19,14 @@ #include "RiaRftDefines.h" #include "cafAppEnum.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaDefines::isSegmentResult( const QString& resultName ) +{ + return resultName.startsWith( "SEG" ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -51,6 +59,78 @@ QString RiaDefines::segmentNumberResultName() return "SEGMENTNUMBER"; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaDefines::isSegmentConnectionResult( const QString& resultName ) +{ + return resultName.startsWith( "CON" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::segmentConnectionTvdDepthResultName() +{ + return "CONDEPTH"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RiaDefines::segmentConnectionEndDepthResultName() +{ + return "CONLENEN"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RiaDefines::segmentConnectionStartDepthResultName() +{ + return "CONLENST"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RiaDefines::segmentConnectionBranchNoResultName() +{ + return "CONBRNO"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::segmentConnectionMeasuredDepthResultName() +{ + return "SegmentConnectionMeasuredDepth"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RiaDefines::segmentConnectionIPos() +{ + return "CONIPOS"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RiaDefines::segmentConnectionJPos() +{ + return "CONJPOS"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RiaDefines::segmentConnectionKPos() +{ + return "CONKPOS"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaRftDefines.h b/ApplicationLibCode/Application/RiaRftDefines.h index de143df071..ef0e0944c6 100644 --- a/ApplicationLibCode/Application/RiaRftDefines.h +++ b/ApplicationLibCode/Application/RiaRftDefines.h @@ -22,11 +22,22 @@ namespace RiaDefines { +bool isSegmentResult( const QString& resultName ); QString segmentStartDepthResultName(); QString segmentEndDepthResultName(); QString segmentTvdDepthResultName(); QString segmentNumberResultName(); +bool isSegmentConnectionResult( const QString& resultName ); +QString segmentConnectionTvdDepthResultName(); +std::string segmentConnectionEndDepthResultName(); +std::string segmentConnectionStartDepthResultName(); +std::string segmentConnectionBranchNoResultName(); +QString segmentConnectionMeasuredDepthResultName(); +std::string segmentConnectionIPos(); +std::string segmentConnectionJPos(); +std::string segmentConnectionKPos(); + QString allBranches(); QString segmentBranchNumberResultName(); diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp index d7800f8181..49bd7042ef 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp @@ -119,6 +119,16 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto } return; } + else if ( rftAddress.segmentResultName() == RiaDefines::segmentConnectionMeasuredDepthResultName() ) + { + auto segmentConnectionValues = segmentConnectionStartEndMeasuredDepth( rftAddress ); + for ( const auto& [startMD, endMD, isValidSegment] : segmentConnectionValues ) + { + values->push_back( endMD ); + } + + return; + } } if ( resultName.empty() ) @@ -137,52 +147,19 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto auto key = std::make_pair( wellName, RftDate{ y, m, d } ); auto segment = m_rftWellDateSegments[key]; - std::vector nonContinuousDeviceSegmentIndices; - if ( rftAddress.segmentBranchType() == RiaDefines::RftBranchType::RFT_DEVICE ) - { - nonContinuousDeviceSegmentIndices = segment.nonContinuousDeviceSegmentIndices( rftAddress.segmentBranchIndex() ); - } - if ( m_connectionResultItemCount.count( wellName ) && data.size() == m_connectionResultItemCount[wellName] ) { - // Connection results with size equal to length of result CONSEGNO. CONSEGNO defines the segment - // numbers the connection is connected to. - - const std::string consegResultName = "CONSEGNO"; - auto connnectionSegmentNumbers = m_opm_rft->getRft( consegResultName, wellName, y, m, d ); - if ( connnectionSegmentNumbers.empty() ) return; - - auto segmentNumbers = - segment.segmentNumbersForBranchIndex( rftAddress.segmentBranchIndex(), rftAddress.segmentBranchType() ); - - size_t resultDataIndex = 0; - for ( int segmentNumber : segmentNumbers ) - { - auto segmentIndex = segment.segmentIndexFromSegmentNumber( segmentNumber ); - - if ( std::find( nonContinuousDeviceSegmentIndices.begin(), nonContinuousDeviceSegmentIndices.end(), segmentIndex ) != - nonContinuousDeviceSegmentIndices.end() ) - { - // Insert an extra infinity value for segments that are not continuous. The number of values in the values - // vector must be equal to the number of x-values (measured depths) - values->push_back( std::numeric_limits::infinity() ); - } - - if ( std::find( connnectionSegmentNumbers.begin(), connnectionSegmentNumbers.end(), segmentNumber ) != - connnectionSegmentNumbers.end() ) - { - values->push_back( data[resultDataIndex++] ); - } - else - { - // The number of values must be equal to the number of segments, use infinity for segments - // with no data - values->push_back( std::numeric_limits::infinity() ); - } - } + auto connectionValues = segmentConnectionValues( rftAddress, segment, data ); + values->insert( values->end(), connectionValues.begin(), connectionValues.end() ); } else { + std::vector nonContinuousDeviceSegmentIndices; + if ( rftAddress.segmentBranchType() == RiaDefines::RftBranchType::RFT_DEVICE ) + { + nonContinuousDeviceSegmentIndices = segment.nonContinuousDeviceSegmentIndices( rftAddress.segmentBranchIndex() ); + } + auto indices = segment.segmentIndicesForBranchIndex( rftAddress.segmentBranchIndex(), rftAddress.segmentBranchType() ); for ( const auto& i : indices ) { @@ -212,7 +189,7 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto if ( resultName == "CONFAC" || resultName == "CONKH" ) { // Replace undefined values with zero to improve readability of plots - std::replace( values->begin(), values->end(), std::numeric_limits::infinity(), 0.0 ); + std::replace( data.begin(), data.end(), std::numeric_limits::infinity(), 0.0 ); } } else @@ -335,14 +312,9 @@ std::vector RifReaderOpmRft::cellIndices( const QString& wellName, try { - auto resultNameI = "CONIPOS"; - auto dataI = m_opm_rft->getRft( resultNameI, stdWellName, y, m, d ); - - auto resultNameJ = "CONJPOS"; - auto dataJ = m_opm_rft->getRft( resultNameJ, stdWellName, y, m, d ); - - auto resultNameK = "CONKPOS"; - auto dataK = m_opm_rft->getRft( resultNameK, stdWellName, y, m, d ); + auto dataI = m_opm_rft->getRft( RiaDefines::segmentConnectionIPos(), stdWellName, y, m, d ); + auto dataJ = m_opm_rft->getRft( RiaDefines::segmentConnectionJPos(), stdWellName, y, m, d ); + auto dataK = m_opm_rft->getRft( RiaDefines::segmentConnectionKPos(), stdWellName, y, m, d ); if ( !dataI.empty() && ( dataI.size() == dataJ.size() ) && ( dataI.size() == dataK.size() ) ) { @@ -454,6 +426,134 @@ void RifReaderOpmRft::openFiles( const QString& fileName, const QString& dataDec m_detectedErrorWhenOpeningRftFile = true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + RifReaderOpmRft::segmentConnectionStartEndMeasuredDepth( const RifEclipseRftAddress& rftAddress ) +{ + try + { + std::vector startEndValues; + + if ( !isOpen() ) return startEndValues; + + const int y = rftAddress.timeStep().date().year(); + const int m = rftAddress.timeStep().date().month(); + const int d = rftAddress.timeStep().date().day(); + + const std::string wellName = rftAddress.wellName().toStdString(); + + const std::string conbrnoResultName = RiaDefines::segmentConnectionBranchNoResultName(); + const std::string conlenstResultName = RiaDefines::segmentConnectionStartDepthResultName(); + const std::string conlenenResultName = RiaDefines::segmentConnectionEndDepthResultName(); + + const auto connnectionBranchNumbers = m_opm_rft->getRft( conbrnoResultName, wellName, y, m, d ); + const auto startMD = m_opm_rft->getRft( conlenstResultName, wellName, y, m, d ); + const auto endMD = m_opm_rft->getRft( conlenenResultName, wellName, y, m, d ); + + const size_t size = connnectionBranchNumbers.size(); + if ( size == startMD.size() && size == endMD.size() ) + { + auto segment = segmentForWell( rftAddress.wellName(), rftAddress.timeStep() ); + + auto branchIdIndex = segment.branchIdsAndOneBasedBranchIndices( rftAddress.segmentBranchType() ); + + // Convert the branch number to the branch index + // Filter data based on branch index + + bool isFirstSegment = true; + + for ( size_t i = 0; i < connnectionBranchNumbers.size(); i++ ) + { + if ( branchIdIndex.count( connnectionBranchNumbers[i] ) ) + { + auto branchIndex = branchIdIndex[connnectionBranchNumbers[i]]; + if ( branchIndex == rftAddress.segmentBranchIndex() ) + { + if ( !isFirstSegment && std::fabs( startMD[i] - endMD[i - 1] ) > 0.1 ) + { + // Insert a segment representing the connection between the segments. Assign infinity as value to this segment + // to allow discontinuous plotting. + startEndValues.emplace_back( endMD[i - 1], startMD[i], false ); + } + startEndValues.emplace_back( startMD[i], endMD[i], true ); + isFirstSegment = false; + } + } + } + } + + return startEndValues; + } + catch ( ... ) + { + } + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifReaderOpmRft::segmentConnectionValues( const RifEclipseRftAddress& rftAddress, + const RifRftSegment& rftSegment, + const std::vector& nativeValues ) +{ + std::vector branchValues; + + const int y = rftAddress.timeStep().date().year(); + const int m = rftAddress.timeStep().date().month(); + const int d = rftAddress.timeStep().date().day(); + + const auto connnectionBranchNumbers = + m_opm_rft->getRft( RiaDefines::segmentConnectionBranchNoResultName(), rftAddress.wellName().toStdString(), y, m, d ); + + if ( nativeValues.size() == connnectionBranchNumbers.size() ) + { + auto branchIdIndex = rftSegment.branchIdsAndOneBasedBranchIndices( rftAddress.segmentBranchType() ); + + // Convert the branch number to the branch index + // Filter data based on branch index + for ( size_t i = 0; i < connnectionBranchNumbers.size(); i++ ) + { + if ( branchIdIndex.count( connnectionBranchNumbers[i] ) ) + { + auto branchIndex = branchIdIndex[connnectionBranchNumbers[i]]; + if ( branchIndex == rftAddress.segmentBranchIndex() ) + { + branchValues.push_back( nativeValues[i] ); + } + } + } + } + + std::vector allResultValues; + + auto segmentConnectionValues = segmentConnectionStartEndMeasuredDepth( rftAddress ); + size_t segmentConnectionIndex = 0; + for ( auto branchValue : branchValues ) + { + if ( segmentConnectionIndex < segmentConnectionValues.size() ) + { + auto [startMD, endMD, isValidSegment] = segmentConnectionValues[segmentConnectionIndex]; + + if ( !isValidSegment ) + { + // Use infinity to make sure no curve is drawn for this segment + allResultValues.push_back( std::numeric_limits::infinity() ); + + segmentConnectionIndex++; + } + allResultValues.push_back( branchValue ); + } + + segmentConnectionIndex++; + } + + return allResultValues; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -572,11 +672,12 @@ void RifReaderOpmRft::buildSegmentData() for ( const auto& [name, arrayType, size] : results ) { - if ( ( name.find( "SEG" ) == 0 ) && m_segmentResultItemCount.count( wellName ) == 0 ) + if ( ( RiaDefines::isSegmentResult( QString::fromStdString( name ) ) ) && m_segmentResultItemCount.count( wellName ) == 0 ) { m_segmentResultItemCount[wellName] = size; } - if ( name.find( "CON" ) == 0 && m_connectionResultItemCount.count( wellName ) == 0 ) + if ( RiaDefines::isSegmentConnectionResult( QString::fromStdString( name ) ) && + m_connectionResultItemCount.count( wellName ) == 0 ) { m_connectionResultItemCount[wellName] = size; } diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmRft.h b/ApplicationLibCode/FileInterface/RifReaderOpmRft.h index acb8c2da7f..97b40172df 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmRft.h +++ b/ApplicationLibCode/FileInterface/RifReaderOpmRft.h @@ -90,6 +90,13 @@ class RifReaderOpmRft : public RifReaderRftInterface, public cvf::Object bool openFiles(); + using SegmentConnectionStartEnd = std::tuple; + std::vector segmentConnectionStartEndMeasuredDepth( const RifEclipseRftAddress& rftAddress ); + + std::vector segmentConnectionValues( const RifEclipseRftAddress& rftAddress, + const RifRftSegment& rftSegment, + const std::vector& nativeValues ); + private: std::unique_ptr m_opm_rft; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp index b6ac8e17f7..82f5af372d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp @@ -136,57 +136,54 @@ QList //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimRftTools::segmentBranchIndexOptions( RifReaderRftInterface* readerRft, +QList RimRftTools::segmentBranchIndexOptions( RifReaderOpmRft* readerRft, const QString& wellName, const QDateTime& timeStep, RiaDefines::RftBranchType branchType ) { - auto opmReader = dynamic_cast( readerRft ); - if ( opmReader ) - { - QList options; - options.push_front( caf::PdmOptionItemInfo( RiaDefines::allBranches(), -1 ) ); + if ( !readerRft ) return {}; + + QList options; + options.push_front( caf::PdmOptionItemInfo( RiaDefines::allBranches(), -1 ) ); + + auto branchIdIndex = readerRft->branchIdsAndOneBasedIndices( wellName, timeStep, branchType ); - auto branchIdIndex = opmReader->branchIdsAndOneBasedIndices( wellName, timeStep, branchType ); + std::set indices; + for ( auto b : branchIdIndex ) + { + indices.insert( b.second ); + } - std::set indices; + for ( auto i : indices ) + { + std::vector branchIds; for ( auto b : branchIdIndex ) { - indices.insert( b.second ); + if ( b.second == i ) branchIds.push_back( b.first ); } - for ( auto i : indices ) - { - std::vector branchIds; - for ( auto b : branchIdIndex ) - { - if ( b.second == i ) branchIds.push_back( b.first ); - } + auto minMax = std::minmax_element( branchIds.begin(), branchIds.end() ); - auto minMax = std::minmax_element( branchIds.begin(), branchIds.end() ); - - auto txt = QString( "%1 (Branch Id %2-%3)" ).arg( i ).arg( *minMax.first ).arg( *minMax.second ); - options.push_back( caf::PdmOptionItemInfo( txt, i ) ); - } - - return options; + auto txt = QString( "%1 (Branch Id %2-%3)" ).arg( i ).arg( *minMax.first ).arg( *minMax.second ); + options.push_back( caf::PdmOptionItemInfo( txt, i ) ); } - return {}; + return options; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimRftTools::segmentStartMdValues( RifReaderRftInterface* readerRft, +std::vector RimRftTools::segmentStartMdValues( RifReaderOpmRft* readerRft, const QString& wellName, const QDateTime& dateTime, int segmentBranchIndex, RiaDefines::RftBranchType segmentBranchType ) { - std::vector values; + if ( !readerRft ) return {}; - auto resultNameSeglenst = RifEclipseRftAddress::createBranchSegmentAddress( wellName, + std::vector values; + auto resultNameSeglenst = RifEclipseRftAddress::createBranchSegmentAddress( wellName, dateTime, RiaDefines::segmentStartDepthResultName(), segmentBranchIndex, @@ -206,20 +203,43 @@ std::vector RimRftTools::segmentStartMdValues( RifReaderRftInterface* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimRftTools::segmentEndMdValues( RifReaderRftInterface* readerRft, +std::vector RimRftTools::segmentEndMdValues( RifReaderOpmRft* readerRft, const QString& wellName, const QDateTime& dateTime, int segmentBranchIndex, RiaDefines::RftBranchType segmentBranchType ) { + if ( !readerRft ) return {}; + std::vector values; + auto resultAddress = RifEclipseRftAddress::createBranchSegmentAddress( wellName, + dateTime, + RiaDefines::segmentEndDepthResultName(), + segmentBranchIndex, + segmentBranchType ); + readerRft->values( resultAddress, &values ); - auto resultNameSeglenst = RifEclipseRftAddress::createBranchSegmentAddress( wellName, - dateTime, - RiaDefines::segmentEndDepthResultName(), - segmentBranchIndex, - segmentBranchType ); - readerRft->values( resultNameSeglenst, &values ); + return values; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimRftTools::segmentConnectionMdValues( RifReaderOpmRft* readerRft, + const QString& wellName, + const QDateTime& dateTime, + int segmentBranchIndex, + RiaDefines::RftBranchType segmentBranchType ) +{ + if ( !readerRft ) return {}; + + std::vector values; + auto resultAddress = RifEclipseRftAddress::createBranchSegmentAddress( wellName, + dateTime, + RiaDefines::segmentConnectionMeasuredDepthResultName(), + segmentBranchIndex, + segmentBranchType ); + readerRft->values( resultAddress, &values ); return values; } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h index acc7f79437..6cee6e235b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h @@ -28,6 +28,7 @@ namespace caf class PdmOptionItemInfo; } class RifReaderRftInterface; +class RifReaderOpmRft; class RimRftTools { @@ -41,20 +42,27 @@ class RimRftTools static QList segmentResultNameOptions( RifReaderRftInterface* readerRft, const QString& wellName, const QDateTime& timeStep ); - static QList segmentBranchIndexOptions( RifReaderRftInterface* readerRft, + + static QList segmentBranchIndexOptions( RifReaderOpmRft* readerRft, const QString& wellName, const QDateTime& timeStep, RiaDefines::RftBranchType branchType ); - static std::vector segmentStartMdValues( RifReaderRftInterface* readerRft, + static std::vector segmentStartMdValues( RifReaderOpmRft* readerRft, const QString& wellName, const QDateTime& dateTime, int segmentBranchIndex, RiaDefines::RftBranchType segmentBranchType ); - static std::vector segmentEndMdValues( RifReaderRftInterface* readerRft, + static std::vector segmentEndMdValues( RifReaderOpmRft* readerRft, const QString& wellName, const QDateTime& dateTime, int segmentBranchIndex, RiaDefines::RftBranchType segmentBranchType ); + + static std::vector segmentConnectionMdValues( RifReaderOpmRft* readerRft, + const QString& wellName, + const QDateTime& dateTime, + int segmentBranchIndex, + RiaDefines::RftBranchType segmentBranchType ); }; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.cpp index e0e638839b..4a039eaf0c 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.cpp @@ -267,7 +267,10 @@ QList RimRftTopologyCurve::calculateValueOptions( const } else if ( fieldNeedingOptions == &m_segmentBranchIndex ) { - options = RimRftTools::segmentBranchIndexOptions( reader, m_wellName(), m_timeStep(), RiaDefines::RftBranchType::RFT_UNKNOWN ); + options = RimRftTools::segmentBranchIndexOptions( dynamic_cast( reader ), + m_wellName(), + m_timeStep(), + RiaDefines::RftBranchType::RFT_UNKNOWN ); } return options; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp index 720d35c8bc..2e1459b887 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp @@ -21,6 +21,8 @@ #include "RiaSimWellBranchTools.h" #include "RiaSummaryTools.h" +#include "RifReaderOpmRft.h" + #include "RimCase.h" #include "RimDataSourceSteppingTools.h" #include "RimEclipseCase.h" @@ -1005,7 +1007,10 @@ QList RimWellLogCurveCommonDataSource::calculateValueOpt } else if ( fieldNeedingOptions == &m_rftSegmentBranchIndex ) { - options = RimRftTools::segmentBranchIndexOptions( rftReader(), m_rftWellName(), m_rftTimeStep(), m_rftSegmentBranchType() ); + options = RimRftTools::segmentBranchIndexOptions( dynamic_cast( rftReader() ), + m_rftWellName(), + m_rftTimeStep(), + m_rftSegmentBranchType() ); } return options; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp index 148472ac2c..1f0144a0fd 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp @@ -33,6 +33,7 @@ #include "RifEclipseRftAddress.h" #include "RifReaderEclipseRft.h" +#include "RifReaderOpmRft.h" #include "RigEclipseCaseData.h" #include "RigEclipseWellLogExtractor.h" @@ -572,7 +573,7 @@ std::map RimWellLogRftCurve::createCurveNameKeyValueMap() cons variableValueMap[RiaDefines::namingVariableWellBranch()] = branchText; - if ( isSegmentResult( m_segmentResultName() ) ) + if ( RiaDefines::isSegmentResult( m_segmentResultName() ) ) { variableValueMap[RiaDefines::namingVariableResultType()] = m_segmentBranchType().uiText(); } @@ -911,7 +912,8 @@ QList RimWellLogRftCurve::calculateValueOptions( const c } else if ( fieldNeedingOptions == &m_segmentBranchIndex ) { - options = RimRftTools::segmentBranchIndexOptions( reader, m_wellName(), m_timeStep(), m_segmentBranchType() ); + options = + RimRftTools::segmentBranchIndexOptions( dynamic_cast( reader ), m_wellName(), m_timeStep(), m_segmentBranchType() ); } else if ( fieldNeedingOptions == &m_scaleFactor ) { @@ -1128,11 +1130,23 @@ std::vector RimWellLogRftCurve::tvDepthValues() if ( m_rftDataType() == RftDataType::RFT_SEGMENT_DATA ) { - depthAddress = RifEclipseRftAddress::createBranchSegmentAddress( m_wellName(), - m_timeStep, - RiaDefines::segmentTvdDepthResultName(), - segmentBranchIndex(), - m_segmentBranchType() ); + if ( RiaDefines::isSegmentConnectionResult( m_segmentResultName ) ) + + { + depthAddress = RifEclipseRftAddress::createBranchSegmentAddress( m_wellName(), + m_timeStep, + RiaDefines::segmentConnectionTvdDepthResultName(), + segmentBranchIndex(), + m_segmentBranchType() ); + } + else + { + depthAddress = RifEclipseRftAddress::createBranchSegmentAddress( m_wellName(), + m_timeStep, + RiaDefines::segmentTvdDepthResultName(), + segmentBranchIndex(), + m_segmentBranchType() ); + } } reader->values( depthAddress, &values ); @@ -1147,14 +1161,19 @@ std::vector RimWellLogRftCurve::measuredDepthValues( QString& prefixText { if ( m_rftDataType() == RftDataType::RFT_SEGMENT_DATA ) { - RifReaderRftInterface* reader = rftReader(); - if ( reader ) + if ( auto opmRftReader = dynamic_cast( rftReader() ) ) { prefixText = "SEGMENT/"; + if ( RiaDefines::isSegmentConnectionResult( m_segmentResultName() ) ) + { + return RimRftTools::segmentConnectionMdValues( opmRftReader, m_wellName(), m_timeStep, segmentBranchIndex(), m_segmentBranchType() ); + } + // Always use segment end MD values for segment data, as the curve is plotted as step left - return RimRftTools::segmentEndMdValues( reader, m_wellName(), m_timeStep, segmentBranchIndex(), m_segmentBranchType() ); + return RimRftTools::segmentEndMdValues( opmRftReader, m_wellName(), m_timeStep, segmentBranchIndex(), m_segmentBranchType() ); } + return {}; } @@ -1238,11 +1257,3 @@ int RimWellLogRftCurve::segmentBranchIndex() const { return m_segmentBranchIndex(); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimWellLogRftCurve::isSegmentResult( const QString& resultName ) -{ - return resultName.startsWith( "SEG" ); -} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h index 9e6fd21bbf..3110ecadf9 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h @@ -131,8 +131,6 @@ class RimWellLogRftCurve : public RimWellLogCurve int segmentBranchIndex() const; - static bool isSegmentResult( const QString& resultName ); - private: caf::PdmPtrField m_eclipseCase; caf::PdmPtrField m_summaryCase; From 2c98438528d5098bc412fcd300488345be15f927 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Sep 2024 09:49:56 +0200 Subject: [PATCH 315/332] #11708 Summary: Improve robustness for statistics calculations There can be incomplete realizations in an ensemble. Make sure that the calculation is robust for all variants of incomplete curves. Use RiaTimeHistoryCurveMerger to ensure one definition of time steps and extraction of curve values to be used to compute ensemble statistics. Remove unused function. --- .../RimEnsembleCrossPlotStatisticsCase.cpp | 2 +- .../Summary/RimEnsembleStatisticsCase.cpp | 121 ++++++------------ .../Summary/RimEnsembleStatisticsCase.h | 11 +- 3 files changed, 44 insertions(+), 90 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCrossPlotStatisticsCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCrossPlotStatisticsCase.cpp index 6ffb4259f2..fdeb533540 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCrossPlotStatisticsCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCrossPlotStatisticsCase.cpp @@ -130,7 +130,7 @@ void RimEnsembleCrossPlotStatisticsCase::calculate( const std::vector sampleData; - auto [minTimeStep, maxTimeStep] = RimEnsembleStatisticsCase::findMinMaxTimeStep( sumCases, inputAddressX ); + auto [minTimeStep, maxTimeStep] = RimEnsembleStatisticsCase::findMinMaxTime( sumCases, inputAddressX ); RiaDefines::DateTimePeriod period = RimEnsembleStatisticsCase::findBestResamplingPeriod( minTimeStep, maxTimeStep ); for ( const auto& sumCase : sumCases ) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp index 82e3be9ebb..ee8416675a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp @@ -18,17 +18,13 @@ #include "RimEnsembleStatisticsCase.h" +#include "RiaCurveMerger.h" #include "RiaSummaryTools.h" #include "RiaTimeHistoryCurveResampler.h" #include "RigStatisticsMath.h" -#include "RimEnsembleCurveSet.h" -#include "RimSummaryEnsemble.h" - #include -#include -#include //-------------------------------------------------------------------------------------------------- /// @@ -129,55 +125,62 @@ RifSummaryReaderInterface* RimEnsembleStatisticsCase::summaryReader() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleStatisticsCase::calculate( const std::vector& sumCases, +void RimEnsembleStatisticsCase::calculate( const std::vector& summaryCases, const RifEclipseSummaryAddress& inputAddress, bool includeIncompleteCurves ) { clearData(); + if ( !inputAddress.isValid() ) return; - if ( sumCases.empty() ) return; + if ( summaryCases.empty() ) return; // Use first summary case to get unit system and other meta data - m_firstSummaryCase = sumCases.front(); + m_firstSummaryCase = summaryCases.front(); - auto [minTimeStep, maxTimeStep] = findMinMaxTimeStep( sumCases, inputAddress ); - RiaDefines::DateTimePeriod period = findBestResamplingPeriod( minTimeStep, maxTimeStep ); + const auto [minTime, maxTime] = findMinMaxTime( summaryCases, inputAddress ); + RiaDefines::DateTimePeriod period = findBestResamplingPeriod( minTime, maxTime ); - std::vector allTimeSteps; - std::vector> caseAndTimeStepValues; - caseAndTimeStepValues.reserve( sumCases.size() ); - for ( const auto& sumCase : sumCases ) + // The last time step for the individual realizations in an ensemble is usually identical. Add a small threshold to improve robustness. + const auto timeThreshold = maxTime - ( maxTime - minTime ) * 0.01; + + RiaTimeHistoryCurveMerger curveMerger; + + for ( const auto& sumCase : summaryCases ) { const auto& reader = sumCase->summaryReader(); if ( reader ) { const std::vector& timeSteps = reader->timeSteps( inputAddress ); - auto [isOk, values] = reader->values( inputAddress ); + const auto [isOk, values] = reader->values( inputAddress ); - if ( values.empty() ) continue; + if ( values.empty() || timeSteps.empty() ) continue; - if ( !includeIncompleteCurves && timeSteps.size() != values.size() ) continue; + if ( !includeIncompleteCurves && ( timeSteps.back() < timeThreshold ) ) continue; - auto [resampledTimeSteps, resampledValues] = RiaSummaryTools::resampledValuesForPeriod( inputAddress, timeSteps, values, period ); - - if ( allTimeSteps.empty() ) allTimeSteps = resampledTimeSteps; - caseAndTimeStepValues.push_back( resampledValues ); + const auto [resampledTimeSteps, resampledValues] = + RiaSummaryTools::resampledValuesForPeriod( inputAddress, timeSteps, values, period ); + curveMerger.addCurveData( resampledTimeSteps, resampledValues ); } } - m_timeSteps = allTimeSteps; + curveMerger.computeInterpolatedValues(); + + std::vector> curveValues; + for ( size_t i = 0; i < curveMerger.curveCount(); i++ ) + { + curveValues.push_back( curveMerger.interpolatedYValuesForAllXValues( i ) ); + } + + m_timeSteps = curveMerger.allXValues(); - for ( size_t timeStepIndex = 0; timeStepIndex < allTimeSteps.size(); timeStepIndex++ ) + for ( size_t timeStepIndex = 0; timeStepIndex < m_timeSteps.size(); timeStepIndex++ ) { std::vector valuesAtTimeStep; - valuesAtTimeStep.reserve( sumCases.size() ); + valuesAtTimeStep.reserve( curveMerger.curveCount() ); - for ( const std::vector& caseValues : caseAndTimeStepValues ) + for ( size_t curveIdx = 0; curveIdx < curveMerger.curveCount(); curveIdx++ ) { - if ( timeStepIndex < caseValues.size() ) - { - valuesAtTimeStep.push_back( caseValues[timeStepIndex] ); - } + valuesAtTimeStep.push_back( curveValues[curveIdx][timeStepIndex] ); } double p10, p50, p90, mean; @@ -218,57 +221,11 @@ void RimEnsembleStatisticsCase::clearData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimEnsembleStatisticsCase::validSummaryCases( const std::vector& allSumCases, - const RifEclipseSummaryAddress& inputAddress, - bool includeIncompleteCurves ) -{ - std::vector validCases; - std::vector> times; - - time_t maxTimeStep = 0; - - for ( auto& sumCase : allSumCases ) - { - const auto& reader = sumCase->summaryReader(); - if ( reader ) - { - const std::vector& timeSteps = reader->timeSteps( inputAddress ); - if ( !timeSteps.empty() ) - { - time_t lastTimeStep = timeSteps.back(); - - maxTimeStep = std::max( lastTimeStep, maxTimeStep ); - times.push_back( std::make_pair( sumCase, lastTimeStep ) ); - } - } - } - - for ( const auto& [sumCase, lastTimeStep] : times ) - { - // Previous versions tested on identical first time step, this test is now removed. For large simulations with - // numerical issues the first time step can be slightly different - // - // https://github.com/OPM/ResInsight/issues/7774 - // - if ( !includeIncompleteCurves && lastTimeStep != maxTimeStep ) - { - continue; - } - - validCases.push_back( sumCase ); - } - - return validCases; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::pair RimEnsembleStatisticsCase::findMinMaxTimeStep( const std::vector& sumCases, - const RifEclipseSummaryAddress& inputAddress ) +std::pair RimEnsembleStatisticsCase::findMinMaxTime( const std::vector& sumCases, + const RifEclipseSummaryAddress& inputAddress ) { - time_t minTimeStep = std::numeric_limits::max(); - time_t maxTimeStep = 0; + time_t minTime = std::numeric_limits::max(); + time_t maxTime = 0; for ( const auto& sumCase : sumCases ) { @@ -278,13 +235,13 @@ std::pair RimEnsembleStatisticsCase::findMinMaxTimeStep( const s const std::vector& timeSteps = reader->timeSteps( inputAddress ); if ( !timeSteps.empty() ) { - minTimeStep = std::min( timeSteps.front(), minTimeStep ); - maxTimeStep = std::max( timeSteps.back(), maxTimeStep ); + minTime = std::min( timeSteps.front(), minTime ); + maxTime = std::max( timeSteps.back(), maxTime ); } } } - return std::make_pair( minTimeStep, maxTimeStep ); + return std::make_pair( minTime, maxTime ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.h index 7322f30e67..9b3fcc518f 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.h @@ -43,18 +43,15 @@ class RimEnsembleStatisticsCase : public RimSummaryCase, public RifSummaryReader RifSummaryReaderInterface* summaryReader() override; RiaDefines::EclipseUnitSystem unitSystem() const override; - void calculate( const std::vector& sumCases, const RifEclipseSummaryAddress& inputAddress, bool includeIncompleteCurves ); + void calculate( const std::vector& summaryCases, const RifEclipseSummaryAddress& inputAddress, bool includeIncompleteCurves ); std::vector timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override; std::pair> values( const RifEclipseSummaryAddress& resultAddress ) const override; std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override; - static std::vector validSummaryCases( const std::vector& allSumCases, - const RifEclipseSummaryAddress& inputAddress, - bool includeIncompleteCurves ); - static std::pair findMinMaxTimeStep( const std::vector& sumCases, - const RifEclipseSummaryAddress& inputAddress ); - static RiaDefines::DateTimePeriod findBestResamplingPeriod( time_t minTimeStep, time_t maxTimeStep ); + static std::pair findMinMaxTime( const std::vector& sumCases, + const RifEclipseSummaryAddress& inputAddress ); + static RiaDefines::DateTimePeriod findBestResamplingPeriod( time_t minTimeStep, time_t maxTimeStep ); private: void clearData(); From 80b112f4ce6fc33e419216c021df0041395dbbdd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Sep 2024 11:39:43 +0200 Subject: [PATCH 316/332] #11713 Polygon filter: Use a ray from point in polygon both up and down Make sure that a polygon defined below the grid can be used to filter grid cells --- .../CellFilters/RimPolygonFilter.cpp | 62 +++++++++++-------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index 22cfe2556c..2a8461c411 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -1022,42 +1022,54 @@ int RimPolygonFilter::findEclipseKLayer( const std::vector& points, } } - auto findKLayerBelowPoint = []( const cvf::Vec3d& point, RigMainGrid* mainGrid ) + auto findClosestKLayer = []( const cvf::Vec3d& point, RigMainGrid* mainGrid ) { - // Create a bounding box (ie a ray) from the point down to minimum of grid - cvf::Vec3d lowestPoint( point.x(), point.y(), mainGrid->boundingBox().min().z() ); - - cvf::BoundingBox rayBBox; - rayBBox.add( point ); - rayBBox.add( lowestPoint ); - - // Find the cells intersecting the ray - std::vector allCellIndices = mainGrid->findIntersectingCells( rayBBox ); - - // Get the minimum K layer index - int minK = std::numeric_limits::max(); - bool anyHits = false; - for ( size_t cIdx : allCellIndices ) + auto findKLayerForBoundingBox = []( const cvf::BoundingBox& bb, RigMainGrid* mainGrid ) { - if ( cIdx != cvf::UNDEFINED_SIZE_T ) + // Find the cells intersecting the ray + std::vector allCellIndices = mainGrid->findIntersectingCells( bb ); + + // Get the minimum K layer index + int minK = std::numeric_limits::max(); + bool anyHits = false; + for ( size_t cIdx : allCellIndices ) { - size_t ni, nj, nk; - mainGrid->ijkFromCellIndexUnguarded( cIdx, &ni, &nj, &nk ); - if ( mainGrid->isCellValid( ni, nj, nk ) ) + if ( cIdx != cvf::UNDEFINED_SIZE_T ) { - anyHits = true; - minK = std::min( minK, static_cast( nk ) ); + size_t ni, nj, nk; + mainGrid->ijkFromCellIndexUnguarded( cIdx, &ni, &nj, &nk ); + if ( mainGrid->isCellValid( ni, nj, nk ) ) + { + anyHits = true; + minK = std::min( minK, static_cast( nk ) ); + } } } - } - return anyHits ? minK : -1; + return anyHits ? minK : -1; + }; + + // Create a bounding box from the point down to minimum of grid + cvf::Vec3d lowestPoint( point.x(), point.y(), mainGrid->boundingBox().min().z() ); + + cvf::BoundingBox bb; + bb.add( point ); + bb.add( lowestPoint ); + + auto kForBB = findKLayerForBoundingBox( bb, mainGrid ); + if ( kForBB != -1 ) return kForBB; + + // Add the highest point to the bounding box + cvf::Vec3d highestPoint( point.x(), point.y(), mainGrid->boundingBox().max().z() ); + bb.add( highestPoint ); + + return findKLayerForBoundingBox( bb, mainGrid ); }; - // shoot a ray down from each point to try to find a valid hit there + // shoot a ray up and down from each point to try to find a valid hit there for ( size_t p = 0; p < points.size(); p++ ) { - int k = findKLayerBelowPoint( points[p], data->mainGrid() ); + int k = findClosestKLayer( points[p], data->mainGrid() ); if ( k != -1 ) return k; } From 864d20bf0dc80a911a59ddd7360f5674f9aecdd2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Sep 2024 12:05:58 +0200 Subject: [PATCH 317/332] #11715 Replace assert with a warning message --- ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp index bf7fbbb581..133f30dc6e 100644 --- a/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -19,6 +19,7 @@ #include "RiuMohrsCirclePlot.h" #include "RiaColorTables.h" +#include "RiaLogging.h" #include "RigFemPart.h" #include "RigFemPartCollection.h" @@ -37,8 +38,6 @@ #include "Riu3dSelectionManager.h" #include "RiuQwtPlotTools.h" -#include "cvfAssert.h" - #include #include #include @@ -405,8 +404,6 @@ bool RiuMohrsCirclePlot::addOrUpdateCurves( const RimGeoMechResultDefinition* ge size_t i, j, k; bool validIndex = femPart->getOrCreateStructGrid()->ijkFromCellIndex( elmIndex, &i, &j, &k ); - - CVF_ASSERT( validIndex ); if ( validIndex ) { int elmId = femPart->elmId( elmIndex ); @@ -423,6 +420,9 @@ bool RiuMohrsCirclePlot::addOrUpdateCurves( const RimGeoMechResultDefinition* ge return true; } + auto txt = QString( "Not able to create Mohr plot for element index:%1, element ID:%2" ).arg( elmIndex ).arg( elmId ); + RiaLogging::warning( txt ); + return false; } From c65e15fad1c38829f07e43fee05900bc8a97496f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Sep 2024 13:15:51 +0200 Subject: [PATCH 318/332] #11693 Add enum to control zoom operation when case is changed --- .../ProjectDataModel/RimEclipseView.cpp | 29 +++++++++++++++---- .../ProjectDataModel/RimEclipseView.h | 12 ++++++-- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index b6a3e4f829..96fc88b4bd 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -129,8 +129,24 @@ #include "cvfViewport.h" #include "cvfqtUtils.h" +#include + #include +namespace caf +{ +template <> +void caf::AppEnum::setUp() +{ + addItem( RimEclipseView::RimCaseChangeBehaviour::KEEP_CURRENT_SETTINGS, "KEEP_CURRENT_SETTINGS", "Keep Current View Settings" ); + addItem( RimEclipseView::RimCaseChangeBehaviour::STORE_VIEW_SETTINGS_FOR_CASE, + "STORE_VIEW_SETTINGS_FOR_CASE", + "Store View Settings for Case" ); + addItem( RimEclipseView::RimCaseChangeBehaviour::ZOOM_TO_FIT, "ZOOM_TO_FIT", "Zoom to Fit" ); + setDefault( RimEclipseView::RimCaseChangeBehaviour::KEEP_CURRENT_SETTINGS ); +} +} // namespace caf + CAF_PDM_XML_SOURCE_INIT( RimEclipseView, "ReservoirView" ); //-------------------------------------------------------------------------------------------------- /// @@ -150,7 +166,7 @@ RimEclipseView::RimEclipseView() CAF_PDM_InitFieldNoDefault( &m_customEclipseCase_OBSOLETE, "CustomEclipseCase", "Custom Case" ); CAF_PDM_InitScriptableFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case" ); - CAF_PDM_InitField( &m_storeViewSettingsPerCase, "StoreViewSettingsPerCase", false, "Store View Settings for Case" ); + CAF_PDM_InitFieldNoDefault( &m_caseChangeBehaviour, "CaseChangeBehaviour", "Zoom Operation When Changing Case" ); CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault( &m_cellResult, "GridCellResult", "CellResult", "Cell Result", ":/CellResult.png" ); m_cellResult = new RimEclipseCellColors(); @@ -465,13 +481,16 @@ void RimEclipseView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, updateGridBoxData(); updateAnnotationItems(); - if ( m_storeViewSettingsPerCase() ) + if ( m_caseChangeBehaviour() == RimEclipseView::RimCaseChangeBehaviour::STORE_VIEW_SETTINGS_FOR_CASE ) { auto currentEclipseCase = dynamic_cast( oldValue.value>().rawPtr() ); storeCurrentAndApplyNewCameraPosition( currentEclipseCase, m_eclipseCase ); } - else + else if ( m_caseChangeBehaviour() == RimEclipseView::RimCaseChangeBehaviour::ZOOM_TO_FIT ) { + // Required to update the view after the case change. zoomAll() is not working without this. + QApplication::processEvents(); + zoomAll(); } @@ -1981,7 +2000,7 @@ void RimEclipseView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& caf::PdmUiGroup* dataSourceGroup = uiOrdering.addNewGroup( "Data Source" ); dataSourceGroup->add( &m_eclipseCase ); - dataSourceGroup->add( &m_storeViewSettingsPerCase ); + dataSourceGroup->add( &m_caseChangeBehaviour ); } Rim3dView::defineUiOrdering( uiConfigName, uiOrdering ); @@ -2073,8 +2092,6 @@ QList RimEclipseView::calculateValueOptions( const caf:: { QList options; - options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) ); - for ( auto eclCase : RimEclipseCaseTools::allEclipseGridCases() ) { options.push_back( caf::PdmOptionItemInfo( eclCase->caseUserDescription(), eclCase, false, eclCase->uiIconProvider() ) ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h index 4068b8a4bc..71d30ffa7d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h @@ -87,6 +87,14 @@ class RimEclipseView : public RimGridView { CAF_PDM_HEADER_INIT; +public: + enum class RimCaseChangeBehaviour + { + ZOOM_TO_FIT, + KEEP_CURRENT_SETTINGS, + STORE_VIEW_SETTINGS_FOR_CASE + }; + public: RimEclipseView(); ~RimEclipseView() override; @@ -228,8 +236,8 @@ class RimEclipseView : public RimGridView protected: cvf::ref m_faultReactVizModel; - caf::PdmPtrField m_eclipseCase; - caf::PdmField m_storeViewSettingsPerCase; + caf::PdmPtrField m_eclipseCase; + caf::PdmField> m_caseChangeBehaviour; private: caf::PdmField m_showInvalidCells; From b5c0201702628e9edb232d89dd1767404fcb1a54 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Sep 2024 13:55:40 +0200 Subject: [PATCH 319/332] Bump to 2024.09-RC_01 --- ResInsightVersion.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 7f96962d28..dedac6e2bf 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,11 +1,11 @@ set(RESINSIGHT_MAJOR_VERSION 2024) -set(RESINSIGHT_MINOR_VERSION 03) -set(RESINSIGHT_PATCH_VERSION 4) +set(RESINSIGHT_MINOR_VERSION 09) +set(RESINSIGHT_PATCH_VERSION 0) # Opional text with no restrictions -set(RESINSIGHT_VERSION_TEXT "-dev") -#set(RESINSIGHT_VERSION_TEXT "-RC_02") +#set(RESINSIGHT_VERSION_TEXT "-dev") +set(RESINSIGHT_VERSION_TEXT "-RC_01") # Optional text # Must be unique and increasing within one combination of major/minor/patch version From 5792a3a53f7f1f981d37e727b4d640a436b349d6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Sep 2024 14:03:57 +0200 Subject: [PATCH 320/332] Fix version number --- ResInsightVersion.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index dedac6e2bf..fa77a841d0 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -5,13 +5,13 @@ set(RESINSIGHT_PATCH_VERSION 0) # Opional text with no restrictions #set(RESINSIGHT_VERSION_TEXT "-dev") -set(RESINSIGHT_VERSION_TEXT "-RC_01") +set(RESINSIGHT_VERSION_TEXT "-RC") # Optional text # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".21") +set(RESINSIGHT_DEV_VERSION ".01") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 9b150ca38a05c9fa96f7d65a3315745544a2c0b1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 23 Sep 2024 11:51:32 +0200 Subject: [PATCH 321/332] Make sure statistics cases are displayed in an Eclipse view --- ...mportGridCalculationExpressionsFeature.cpp | 2 +- .../Commands/RicNewViewFeature.cpp | 2 +- .../ProjectDataModel/RimEclipseCaseTools.cpp | 27 ++++++++++++++++++- .../ProjectDataModel/RimEclipseCaseTools.h | 5 +++- .../ProjectDataModel/RimGridCalculation.cpp | 4 +-- .../ProjectDataModel/RimResultSelectionUi.cpp | 2 +- 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/ApplicationLibCode/Commands/RicImportGridCalculationExpressionsFeature.cpp b/ApplicationLibCode/Commands/RicImportGridCalculationExpressionsFeature.cpp index f761dcdb33..49d36aa129 100644 --- a/ApplicationLibCode/Commands/RicImportGridCalculationExpressionsFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportGridCalculationExpressionsFeature.cpp @@ -71,7 +71,7 @@ void RicImportGridCalculationExpressionsFeature::onActionTriggered( bool isCheck auto calcColl = proj->gridCalculationCollection(); RimEclipseCase* firstCase = nullptr; - auto eclCases = RimEclipseCaseTools::allEclipseGridCases(); + auto eclCases = RimEclipseCaseTools::nativeEclipseGridCases(); if ( !eclCases.empty() ) firstCase = eclCases.front(); for ( auto calc : calculations ) diff --git a/ApplicationLibCode/Commands/RicNewViewFeature.cpp b/ApplicationLibCode/Commands/RicNewViewFeature.cpp index 2c4baae064..866dbbf0ca 100644 --- a/ApplicationLibCode/Commands/RicNewViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewViewFeature.cpp @@ -101,7 +101,7 @@ void RicNewViewFeature::onActionTriggered( bool isChecked ) { // Use cases from grid ensemble if applicable auto gridEnsemble = viewCollection->firstAncestorOfType(); - auto eclipseCases = gridEnsemble ? gridEnsemble->cases() : RimEclipseCaseTools::allEclipseGridCases(); + auto eclipseCases = gridEnsemble ? gridEnsemble->cases() : RimEclipseCaseTools::nativeEclipseGridCases(); if ( !eclipseCases.empty() ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.cpp index be0abdfa9f..4232396a0a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.cpp @@ -22,6 +22,8 @@ #include "RimEclipseStatisticsCase.h" #include "RimProject.h" +#include "GeoMech/RimGeoMechCase.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -58,7 +60,7 @@ std::vector RimEclipseCaseTools::eclipseResultCases() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimEclipseCaseTools::allEclipseGridCases() +std::vector RimEclipseCaseTools::nativeEclipseGridCases() { // Find all Eclipse cases, including all single grid cases and source cases in a grid case group. Statistics cases are excluded. @@ -81,3 +83,26 @@ std::vector RimEclipseCaseTools::allEclipseGridCases() return {}; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseCaseTools::allEclipseGridCases() +{ + RimProject* proj = RimProject::current(); + if ( proj ) + { + std::vector eclipseCases; + for ( auto c : proj->allGridCases() ) + { + if ( auto ec = dynamic_cast( c ) ) + { + eclipseCases.push_back( ec ); + } + } + + return eclipseCases; + } + + return {}; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.h index 0c197957ba..12c3a17911 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.h @@ -35,6 +35,9 @@ class RimEclipseCaseTools // Result cases based on RimEclipseCaseTools::elipseCases() static std::vector eclipseResultCases(); - // All Eclipse cases including grid case group source cases, excluding statistics cases + // All native Eclipse cases including grid case group source cases, excluding statistics cases + static std::vector nativeEclipseGridCases(); + + // All Eclipse cases including statistics cases static std::vector allEclipseGridCases(); }; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp index ac64cf6395..6211ad6b9f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp @@ -266,7 +266,7 @@ std::vector RimGridCalculation::outputEclipseCases() const { // Find all Eclipse cases suitable for grid calculations. This includes all single grid cases and source cases in a grid case group. // Exclude the statistics cases, as it is not possible to use them in a grid calculations. - return RimEclipseCaseTools::allEclipseGridCases(); + return RimEclipseCaseTools::nativeEclipseGridCases(); } if ( m_additionalCasesType() == RimGridCalculation::AdditionalCasesType::GRID_CASE_GROUP ) @@ -402,7 +402,7 @@ QList RimGridCalculation::calculateValueOptions( const c firstInputCase = inputCases()[0]; } - for ( auto eclipseCase : RimEclipseCaseTools::allEclipseGridCases() ) + for ( auto eclipseCase : RimEclipseCaseTools::nativeEclipseGridCases() ) { if ( !eclipseCase ) continue; if ( firstInputCase && !firstInputCase->isGridSizeEqualTo( eclipseCase ) ) continue; diff --git a/ApplicationLibCode/ProjectDataModel/RimResultSelectionUi.cpp b/ApplicationLibCode/ProjectDataModel/RimResultSelectionUi.cpp index 76edca567e..71e9f5c5a2 100644 --- a/ApplicationLibCode/ProjectDataModel/RimResultSelectionUi.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimResultSelectionUi.cpp @@ -110,7 +110,7 @@ QList RimResultSelectionUi::calculateValueOptions( const if ( fieldNeedingOptions == &m_eclipseCase ) { - for ( auto* c : RimEclipseCaseTools::allEclipseGridCases() ) + for ( auto* c : RimEclipseCaseTools::nativeEclipseGridCases() ) { options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, false, c->uiIconProvider() ) ); } From 7486f20e9868ddbee2d95462e35fc7f91b5c8ed4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 23 Sep 2024 11:58:50 +0200 Subject: [PATCH 322/332] Exclude some statistics results from category classification Avoid FIPOIL_MEAN and similar as a category result. --- ApplicationLibCode/Application/RiaResultNames.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/Application/RiaResultNames.cpp b/ApplicationLibCode/Application/RiaResultNames.cpp index 88636a20a4..52e393dcf9 100644 --- a/ApplicationLibCode/Application/RiaResultNames.cpp +++ b/ApplicationLibCode/Application/RiaResultNames.cpp @@ -102,9 +102,10 @@ bool RiaResultNames::isFlowResultWithBothPosAndNegValues( const QString& resultN //-------------------------------------------------------------------------------------------------- bool RiaResultNames::isCategoryResult( const QString& resultName ) { - static std::set excludedResultNames = { "FIPOIL", "FIPGAS", "FIPWAT" }; - - if ( excludedResultNames.find( resultName.toUpper() ) != excludedResultNames.end() ) return false; + // Check for special FIP* results. This will also match statistics results FIPOIL_MEAN, FIPOIL_P90, ... + if ( resultName.startsWith( "FIPOIL", Qt::CaseInsensitive ) ) return false; + if ( resultName.startsWith( "FIPGAS", Qt::CaseInsensitive ) ) return false; + if ( resultName.startsWith( "FIPWAT", Qt::CaseInsensitive ) ) return false; if ( resultName.endsWith( "NUM", Qt::CaseInsensitive ) ) return true; if ( resultName.startsWith( "FIP", Qt::CaseInsensitive ) ) return true; From 3cb55cacb2854befaba9ab3a86d8468c43e61645 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 23 Sep 2024 13:30:42 +0200 Subject: [PATCH 323/332] Keep grid visibility unchanged when adding filter --- .../EclipseCommands/RicEclipsePropertyFilterNewExec.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp index 6ac5883660..6eef9b76ec 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp @@ -56,11 +56,6 @@ QString RicEclipsePropertyFilterNewExec::name() void RicEclipsePropertyFilterNewExec::redo() { RicEclipsePropertyFilterFeatureImpl::addPropertyFilter( m_propertyFilterCollection ); - - RimGridView* view = m_propertyFilterCollection->firstAncestorOrThisOfTypeAsserted(); - - // Enable display of grid cells, to be able to show generated property filter - view->showGridCells( true ); } //-------------------------------------------------------------------------------------------------- From a0997821c67aa343113efdddd40e209a28e0c456 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 23 Sep 2024 14:03:35 +0200 Subject: [PATCH 324/332] Make sure intersection calculations are done before legend update The legend categories can be filtered to only visible categories. This requires the geometry generators to do intersection calculations, as the legend is created based on intersected cells. --- ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 96fc88b4bd..84736cd07c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -1632,6 +1632,12 @@ void RimEclipseView::updateLegendRangesTextAndVisibility( RimRegularLegendConfig RimEclipseResultDefinition* eclResultDef, int timeStepIndex ) { + // Call appendIntersectionsForCurrentTimeStep() is required to get the intersected cells. If the legend to update should list visible + // categories, the intersection geometry defines the intersected cells. These cells are then used to extract all category values, and + // find unique values. appendIntersectionsForCurrentTimeStep() is now called twice, and this could potentially be a performance issue + // for very large models. + appendIntersectionsForCurrentTimeStep(); + eclResultDef->updateRangesForExplicitLegends( legendConfig, ternaryLegendConfig, timeStepIndex ); if ( eclResultDef->hasResult() && legendConfig->showLegend() ) From d44cd19951f02e536fa3abc14fb17585acfbeb5a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 23 Sep 2024 14:43:14 +0200 Subject: [PATCH 325/332] Bump to 2024.09-RC_02 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index fa77a841d0..988b9cb303 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-RC") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".01") +set(RESINSIGHT_DEV_VERSION ".02") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From de573a83cc5becc96f1e1d528db4a5b74a98889a Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Tue, 24 Sep 2024 14:04:11 +0200 Subject: [PATCH 326/332] Support another special case for coordinates --- ThirdParty/custom-opm-common/opm-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdParty/custom-opm-common/opm-common b/ThirdParty/custom-opm-common/opm-common index c351cfbbdd..ebec02d410 160000 --- a/ThirdParty/custom-opm-common/opm-common +++ b/ThirdParty/custom-opm-common/opm-common @@ -1 +1 @@ -Subproject commit c351cfbbdd7eefdf7fc76cbe846637e14eb3671e +Subproject commit ebec02d410e4f227a5d128ce9fe081f209fcb56b From 12ae4dbaaaa6624b84f9dfe95345771bf21dc399 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 24 Sep 2024 08:43:22 +0200 Subject: [PATCH 327/332] Improve detection of special *FIP* property names Make sure RFIP* and SFIP* are not treated as category results --- .../Application/RiaResultNames.cpp | 10 ++-- ApplicationLibCode/UnitTests/CMakeLists.txt | 1 + .../UnitTests/RiaResultName-Test.cpp | 56 +++++++++++++++++++ 3 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 ApplicationLibCode/UnitTests/RiaResultName-Test.cpp diff --git a/ApplicationLibCode/Application/RiaResultNames.cpp b/ApplicationLibCode/Application/RiaResultNames.cpp index 52e393dcf9..ac928bf83d 100644 --- a/ApplicationLibCode/Application/RiaResultNames.cpp +++ b/ApplicationLibCode/Application/RiaResultNames.cpp @@ -102,10 +102,12 @@ bool RiaResultNames::isFlowResultWithBothPosAndNegValues( const QString& resultN //-------------------------------------------------------------------------------------------------- bool RiaResultNames::isCategoryResult( const QString& resultName ) { - // Check for special FIP* results. This will also match statistics results FIPOIL_MEAN, FIPOIL_P90, ... - if ( resultName.startsWith( "FIPOIL", Qt::CaseInsensitive ) ) return false; - if ( resultName.startsWith( "FIPGAS", Qt::CaseInsensitive ) ) return false; - if ( resultName.startsWith( "FIPWAT", Qt::CaseInsensitive ) ) return false; + // Identify and mark some FIP-results as non-category result. + // This includes statistics results FIPOIL_MEAN, FIPOIL_P90, SFIP* and RFIP*. + + if ( resultName.contains( "FIPOIL", Qt::CaseInsensitive ) ) return false; + if ( resultName.contains( "FIPGAS", Qt::CaseInsensitive ) ) return false; + if ( resultName.contains( "FIPWAT", Qt::CaseInsensitive ) ) return false; if ( resultName.endsWith( "NUM", Qt::CaseInsensitive ) ) return true; if ( resultName.startsWith( "FIP", Qt::CaseInsensitive ) ) return true; diff --git a/ApplicationLibCode/UnitTests/CMakeLists.txt b/ApplicationLibCode/UnitTests/CMakeLists.txt index 8a276f4732..f78d38797a 100644 --- a/ApplicationLibCode/UnitTests/CMakeLists.txt +++ b/ApplicationLibCode/UnitTests/CMakeLists.txt @@ -105,6 +105,7 @@ set(SOURCE_UNITTEST_FILES ${CMAKE_CURRENT_LIST_DIR}/RifParquetReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifOsduWellPathReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RigVfpTables-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaResultName-Test.cpp ) if(RESINSIGHT_ENABLE_GRPC) diff --git a/ApplicationLibCode/UnitTests/RiaResultName-Test.cpp b/ApplicationLibCode/UnitTests/RiaResultName-Test.cpp new file mode 100644 index 0000000000..aa931d6597 --- /dev/null +++ b/ApplicationLibCode/UnitTests/RiaResultName-Test.cpp @@ -0,0 +1,56 @@ +#include "gtest/gtest.h" + +#include "RiaResultNames.h" + +TEST( RiaResultNames, TestIsCategoryResult ) +{ + // Test for non-category result names + { + QString resultVariable = "FIPOIL"; + bool result = RiaResultNames::isCategoryResult( resultVariable ); + EXPECT_FALSE( result ); + } + + { + QString resultVariable = "FIPWAT"; + bool result = RiaResultNames::isCategoryResult( resultVariable ); + EXPECT_FALSE( result ); + } + + { + QString resultVariable = "FIPGAS"; + bool result = RiaResultNames::isCategoryResult( resultVariable ); + EXPECT_FALSE( result ); + } + + { + QString resultVariable = "SFIPGAS"; + bool result = RiaResultNames::isCategoryResult( resultVariable ); + EXPECT_FALSE( result ); + } + + { + QString resultVariable = "RFIPGAS"; + bool result = RiaResultNames::isCategoryResult( resultVariable ); + EXPECT_FALSE( result ); + } + + { + QString resultVariable = "RFIPGAS_P90"; + bool result = RiaResultNames::isCategoryResult( resultVariable ); + EXPECT_FALSE( result ); + } + + // Test for category result names + { + QString resultVariable = "MYNUM"; + bool result = RiaResultNames::isCategoryResult( resultVariable ); + EXPECT_TRUE( result ); + } + + { + QString resultVariable = "FIPMYPROP"; + bool result = RiaResultNames::isCategoryResult( resultVariable ); + EXPECT_TRUE( result ); + } +} From e1864bf93bb46cf21ac1c09aaf77591ae140bfda Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 24 Sep 2024 08:51:41 +0200 Subject: [PATCH 328/332] Disable experimental settings for only load active cells --- ApplicationLibCode/Application/RiaPreferencesGrid.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/Application/RiaPreferencesGrid.cpp b/ApplicationLibCode/Application/RiaPreferencesGrid.cpp index 8325153351..9bf0e8b270 100644 --- a/ApplicationLibCode/Application/RiaPreferencesGrid.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesGrid.cpp @@ -137,8 +137,9 @@ void RiaPreferencesGrid::appendItems( caf::PdmUiOrdering& uiOrdering ) auto resdataGrp = uiOrdering.addNewGroup( "ResData Reader Settings" ); resdataGrp->add( &m_useResultIndexFile ); - auto opmcGrp = uiOrdering.addNewGroup( "OPM Common Reader Settings" ); - opmcGrp->add( &m_onlyLoadActiveCells ); + // TODO: Disabled for the 2024.09 release, enable after release + // auto opmcGrp = uiOrdering.addNewGroup( "OPM Common Reader Settings" ); + // opmcGrp->add( &m_onlyLoadActiveCells ); const bool setFaultImportSettingsReadOnly = !importFaults(); @@ -181,7 +182,7 @@ RifReaderSettings RiaPreferencesGrid::readerSettings() m_skipWellData, true, // import summary data m_includeFileAbsolutePathPrefix, - m_onlyLoadActiveCells, + onlyLoadActiveCells(), m_invalidateLongThinCells }; return rs; } @@ -263,7 +264,8 @@ bool RiaPreferencesGrid::autoComputeDepthRelatedProperties() const //-------------------------------------------------------------------------------------------------- bool RiaPreferencesGrid::onlyLoadActiveCells() const { - return m_onlyLoadActiveCells; + return false; + // return m_onlyLoadActiveCells; } //-------------------------------------------------------------------------------------------------- From 19354ac7b2998e4d1e405bc442c419e8cdacf298 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 24 Sep 2024 13:30:25 +0200 Subject: [PATCH 329/332] Revert "Make sure intersection calculations are done before legend update" This reverts commit a0997821c67aa343113efdddd40e209a28e0c456. --- ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 84736cd07c..96fc88b4bd 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -1632,12 +1632,6 @@ void RimEclipseView::updateLegendRangesTextAndVisibility( RimRegularLegendConfig RimEclipseResultDefinition* eclResultDef, int timeStepIndex ) { - // Call appendIntersectionsForCurrentTimeStep() is required to get the intersected cells. If the legend to update should list visible - // categories, the intersection geometry defines the intersected cells. These cells are then used to extract all category values, and - // find unique values. appendIntersectionsForCurrentTimeStep() is now called twice, and this could potentially be a performance issue - // for very large models. - appendIntersectionsForCurrentTimeStep(); - eclResultDef->updateRangesForExplicitLegends( legendConfig, ternaryLegendConfig, timeStepIndex ); if ( eclResultDef->hasResult() && legendConfig->showLegend() ) From a870fceb42427cb37fd672b7dae837d1008f08ea Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 24 Sep 2024 13:30:02 +0200 Subject: [PATCH 330/332] Intersection: Make sure property filtered geometry is visible When an intersection geometry is filtered by property filters, make sure that the static geometry is hidden. --- .../ProjectDataModel/RimGridView.cpp | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp index 0de0fb62b9..7c2081beda 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp @@ -571,9 +571,21 @@ void RimGridView::appendIntersectionsToModel( bool cellFiltersActive, bool prope { m_intersectionCollection->clearGeometry(); + bool addStaticModel = true; + if ( m_intersectionCollection->shouldApplyCellFiltersToIntersections() && ( cellFiltersActive || propertyFiltersActive ) ) { - if ( !propertyFiltersActive ) + if ( propertyFiltersActive ) + { + cvf::UByteArray visibleCells; + calculateCellVisibility( &visibleCells, { PROPERTY_FILTERED, PROPERTY_FILTERED_WELL_CELLS } ); + m_intersectionCollection->appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), currentTimeStep(), &visibleCells ); + + // If property filters are active, we do not want to add the static model as the static parts can cover the dynamic parts in + // some cases + addStaticModel = false; + } + else { cvf::UByteArray visibleCells; calculateCellVisibility( &visibleCells, { RANGE_FILTERED_WELL_CELLS, RANGE_FILTERED } ); @@ -592,7 +604,16 @@ void RimGridView::appendIntersectionsToModel( bool cellFiltersActive, bool prope // appendPartsToModel() after appendDynamicPartsToModel() m_intersectionCollection->appendPartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() ); } + + if ( addStaticModel ) + { + nativeOrOverrideViewer()->addStaticModelOnce( m_intersectionVizModel.p(), isUsingOverrideViewer() ); + } + else + { + nativeOrOverrideViewer()->removeStaticModel( m_intersectionVizModel.p() ); + } + m_intersectionVizModel->updateBoundingBoxesRecursive(); - nativeOrOverrideViewer()->addStaticModelOnce( m_intersectionVizModel.p(), isUsingOverrideViewer() ); } } From d2a160f7930c01561e750b62b0b8877373cdb221 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 24 Sep 2024 14:10:37 +0200 Subject: [PATCH 331/332] Make RFT pressure data more robust Replace tab with space, and fix an out of bounds bug. --- .../RifPressureDepthTextFileReader.cpp | 11 +++++-- .../RifPressureDepthTextFileReader-Test.cpp | 15 +++++++++ .../example_file_tabs.txt | 32 +++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 ApplicationLibCode/UnitTests/TestData/RifPressureDepthTextFileReader/example_file_tabs.txt diff --git a/ApplicationLibCode/FileInterface/RifPressureDepthTextFileReader.cpp b/ApplicationLibCode/FileInterface/RifPressureDepthTextFileReader.cpp index f1d068205f..ca557a454b 100644 --- a/ApplicationLibCode/FileInterface/RifPressureDepthTextFileReader.cpp +++ b/ApplicationLibCode/FileInterface/RifPressureDepthTextFileReader.cpp @@ -58,12 +58,19 @@ std::pair, QString> RifPressureDepthTextFileRe while ( !in.atEnd() ) { QString line = in.readLine(); + + // Replace tab with space to be able to split the string using space as separator + line.replace( "\t", " " ); + if ( isHeaderLine( line ) ) { bool skipEmptyParts = true; - QStringList headerValues = RifFileParseTools::splitLineAndTrim( line, separator, skipEmptyParts ); RigPressureDepthData data; - data.setWellName( headerValues[1].replace( "'", "" ) ); + QStringList headerValues = RifFileParseTools::splitLineAndTrim( line, separator, skipEmptyParts ); + if ( headerValues.size() > 1 ) + { + data.setWellName( headerValues[1].replace( "'", "" ) ); + } items.push_back( data ); } else if ( isDateLine( line ) ) diff --git a/ApplicationLibCode/UnitTests/RifPressureDepthTextFileReader-Test.cpp b/ApplicationLibCode/UnitTests/RifPressureDepthTextFileReader-Test.cpp index f06b2acd84..54aaa8befe 100644 --- a/ApplicationLibCode/UnitTests/RifPressureDepthTextFileReader-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifPressureDepthTextFileReader-Test.cpp @@ -92,3 +92,18 @@ PSIA FEET EXPECT_NEAR( 12008.0, values0[0].first, delta ); EXPECT_NEAR( 22640.66, values0[0].second, delta ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RifPressureDepthTextFileReaderTest, LoadFileWithTabs ) +{ + QString fileName = CASE_REAL_TEST_DATA_DIRECTORY_04 + "example_file_tabs.txt"; + + auto [items, errorMessage] = RifPressureDepthTextFileReader::readFile( fileName ); + + EXPECT_TRUE( errorMessage.isEmpty() ); + ASSERT_EQ( 3u, items.size() ); + + EXPECT_EQ( "G-14", items[0].wellName().toStdString() ); +} diff --git a/ApplicationLibCode/UnitTests/TestData/RifPressureDepthTextFileReader/example_file_tabs.txt b/ApplicationLibCode/UnitTests/TestData/RifPressureDepthTextFileReader/example_file_tabs.txt new file mode 100644 index 0000000000..4c2274bc01 --- /dev/null +++ b/ApplicationLibCode/UnitTests/TestData/RifPressureDepthTextFileReader/example_file_tabs.txt @@ -0,0 +1,32 @@ +--TVDMSL +RFT +-- +WELLNAME 'G-14' +DATE 28-DEC-1995 +PRESSURE DEPTH +BARSA METRES +418.88 2726.91 +419.02 2729.36 +419.11 2733.29 +419.17 2735.26 +-- +WELLNAME 'G-14' +DATE 28-DEC-1996 +PRESSURE DEPTH +BARSA METRES +418.88 2726.91 +419.02 2729.36 +419.11 2733.29 +419.17 2735.26 +-- +WELLNAME 'F-56' +DATE 15-jan-12 +PRESSURE DEPTH +BARSA METRES +414.40 2911.029 +415.92 2929.496 +417.23 2935.801 +415.76 2934.981 +414.75 2919.446 +413.53 2903.147 +413.32 2896.555 From f54be2783fd6c2c32e90a8df0a83de42ac0be1a3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 24 Sep 2024 14:50:11 +0200 Subject: [PATCH 332/332] Bump to 2024.09-RC_03 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 988b9cb303..8af94c1081 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-RC") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".02") +set(RESINSIGHT_DEV_VERSION ".03") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f")