From bbc279d5875c39e3e534b470b69057e43e4dff7d Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Mon, 8 Apr 2024 23:07:23 +0200 Subject: [PATCH 01/32] 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 02/32] 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 03/32] 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 04/32] 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 05/32] 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 06/32] #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 07/32] 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 08/32] 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 09/32] 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 10/32] #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 11/32] 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 12/32] 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 13/32] 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 14/32] 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 15/32] 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 16/32] 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 17/32] 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 18/32] 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 19/32] 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 20/32] 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 21/32] 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 22/32] 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 23/32] 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 24/32] 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 25/32] 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 26/32] 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 27/32] 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 28/32] 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 29/32] 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 30/32] #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 31/32] 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 32/32] 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() );